1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-21 00:12:06 +02:00

* Moved AtticaManager and all its deps into libtomahawk.

This commit is contained in:
Christian Muehlhaeuser 2011-09-12 02:52:52 +02:00
parent 2b947254d5
commit e7d78ea52e
43 changed files with 195 additions and 136 deletions

View File

@ -112,14 +112,14 @@ macro_optional_find_package(QuaZip)
macro_log_feature(QuaZip_FOUND "QuaZip" "Provides support for extracting downloaded resolvers autmatically. Will build internal copy instead." "http://quazip.sourceforge.net/" FALSE "" "")
IF( NOT QuaZip_FOUND )
add_subdirectory( ${THIRDPARTY_DIR}/quazip )
SET( QuaZip_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} )
add_subdirectory( ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip )
SET( QuaZip_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/libtomahawk/thirdparty )
SET( QuaZip_LIBRARY quazip )
SET( QuaZip_LIBRARIES ${QuaZip_LIBRARY} )
SET( QuaZip_FOUND true )
SET( QuaZip_FOUND true )
# copy headers to build/quazip so we can use proper includes inside the code
FILE( COPY ${CMAKE_SOURCE_DIR}/thirdparty/quazip/quazip/ DESTINATION ${CMAKE_BINARY_DIR}/quazip )
FILE( COPY ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip/quazip/ DESTINATION ${CMAKE_BINARY_DIR}/libtomahawk/thirdparty/quazip )
ENDIF()
# required

View File

@ -1,6 +1,7 @@
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
tomahawklib
breakpad_client
)
FILE( GLOB _icons "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )

View File

@ -37,9 +37,6 @@ ENDIF()
SET( tomahawkSources ${tomahawkSources}
web/api_v1.cpp
resolvers/scriptresolver.cpp
resolvers/qtscriptresolver.cpp
musicscanner.cpp
shortcuthandler.cpp
scanmanager.cpp
@ -85,9 +82,6 @@ SET( tomahawkHeaders ${tomahawkHeaders}
web/api_v1.h
resolvers/scriptresolver.h
resolvers/qtscriptresolver.h
musicscanner.h
scanmanager.h
shortcuthandler.h
@ -99,6 +93,12 @@ IF(LIBLASTFM_FOUND)
)
ENDIF(LIBLASTFM_FOUND)
IF(LIBATTICA_FOUND)
SET( tomahawkSources ${tomahawkSources} GetNewStuffDialog.cpp GetNewStuffDelegate.cpp GetNewStuffModel.cpp )
SET( tomahawkHeaders ${tomahawkHeaders} GetNewStuffDialog.h GetNewStuffDelegate.h GetNewStuffModel.h )
INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} )
ENDIF(LIBATTICA_FOUND)
SET( tomahawkHeadersGui ${tomahawkHeadersGui}
sourcetree/sourcesmodel.h
@ -126,8 +126,6 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
resolversmodel.h
delegateconfigwrapper.h
tomahawkwindow.h
AtticaManager.h
)
SET( tomahawkUI ${tomahawkUI}
@ -159,13 +157,13 @@ INCLUDE_DIRECTORIES(
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
${THIRDPARTY_DIR}/qtweetlib/qtweetlib/src
${THIRDPARTY_DIR}/qtweetlib/tomahawk-custom
${THIRDPARTY_DIR}/breakpad
${TAGLIB_INCLUDES}
${PHONON_INCLUDES}
${QJSON_INCLUDE_DIR}
${LIBECHONEST_INCLUDE_DIR}
${LIBECHONEST_INCLUDE_DIR}/..
${QuaZip_INCLUDE_DIR}
)
SET( OS_SPECIFIC_LINK_LIBRARIES "" )
@ -199,12 +197,6 @@ IF(QCA2_FOUND)
INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} )
ENDIF(QCA2_FOUND)
IF(LIBATTICA_FOUND)
SET( tomahawkSources ${tomahawkSources} AtticaManager.cpp GetNewStuffDialog.cpp GetNewStuffDelegate.cpp GetNewStuffModel.cpp )
SET( tomahawkHeaders ${tomahawkHeaders} GetNewStuffDialog.h GetNewStuffDelegate.h GetNewStuffModel.h )
INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} )
ENDIF(LIBATTICA_FOUND)
kde4_add_app_icon( tomahawkSources "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )
qt4_add_resources( RC_SRCS "../resources.qrc" )
qt4_wrap_cpp( tomahawkMoc ${tomahawkHeaders} )
@ -244,16 +236,10 @@ ENDIF(LIBLASTFM_FOUND)
IF(GLOOX_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${GLOOX_LIBRARIES} )
ENDIF(GLOOX_FOUND)
IF(QCA2_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} )
ENDIF(QCA2_FOUND)
IF(LIBATTICA_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${LIBATTICA_LIBRARIES} )
ENDIF(LIBATTICA_FOUND)
TARGET_LINK_LIBRARIES( tomahawk
${LINK_LIBRARIES}
${TOMAHAWK_LIBRARIES}
@ -265,7 +251,6 @@ TARGET_LINK_LIBRARIES( tomahawk
${QXTWEB_LIBRARIES}
${QJSON_LIBRARIES}
${TAGLIB_LIBRARIES}
${QuaZip_LIBRARIES}
)
IF( APPLE )

View File

@ -18,23 +18,26 @@
#include "AtticaManager.h"
#include "utils/logger.h"
#include "tomahawksettings.h"
#include "utils/tomahawkutils.h"
#include "tomahawksettings.h"
#include "pipeline.h"
#include <attica/downloaditem.h>
#include <quazip/quazip.h>
#include <quazip/quazipfile.h>
#include <QNetworkReply>
#include <QtCore/qtemporaryfile.h>
#include <QTemporaryFile>
#include <QDir>
#include "tomahawkapp.h"
#include <QTimer>
#include "utils/logger.h"
using namespace Attica;
AtticaManager* AtticaManager::s_instance = 0;
AtticaManager::AtticaManager( QObject* parent )
{
connect( &m_manager, SIGNAL( providerAdded( Attica::Provider ) ), this, SLOT( providerAdded( Attica::Provider ) ) );
@ -44,11 +47,13 @@ AtticaManager::AtticaManager( QObject* parent )
QTimer::singleShot( 0, this, SLOT( loadPixmapsFromCache() ) );
}
AtticaManager::~AtticaManager()
{
savePixmapsToCache();
}
void
AtticaManager::loadPixmapsFromCache()
{
@ -65,6 +70,7 @@ AtticaManager::loadPixmapsFromCache()
}
}
void
AtticaManager::savePixmapsToCache()
{
@ -86,6 +92,7 @@ AtticaManager::savePixmapsToCache()
}
}
QPixmap
AtticaManager::iconForResolver( const Content& resolver )
{
@ -99,6 +106,7 @@ AtticaManager::resolvers() const
return m_resolvers;
}
AtticaManager::ResolverState
AtticaManager::resolverState ( const Content& resolver ) const
{
@ -110,12 +118,14 @@ AtticaManager::resolverState ( const Content& resolver ) const
return m_resolverStates[ resolver.id() ];
}
bool
AtticaManager::resolversLoaded() const
{
return !m_resolvers.isEmpty();
}
QString
AtticaManager::pathFromId( const QString& resolverId ) const
{
@ -142,6 +152,7 @@ AtticaManager::providerAdded( const Provider& provider )
}
}
void
AtticaManager::resolversList( BaseJob* j )
{
@ -163,6 +174,7 @@ AtticaManager::resolversList( BaseJob* j )
}
}
void
AtticaManager::resolverIconFetched()
{
@ -199,6 +211,7 @@ AtticaManager::installResolver( const Content& resolver )
job->start();
}
void
AtticaManager::resolverDownloadFinished ( BaseJob* j )
{
@ -217,10 +230,9 @@ AtticaManager::resolverDownloadFinished ( BaseJob* j )
{
tLog() << "Failed to do resolver download job!" << job->metadata().error();
}
}
void
AtticaManager::payloadFetched()
{
@ -242,10 +254,10 @@ AtticaManager::payloadFetched()
QString resolverId = reply->property( "resolverId" ).toString();
QString resolverPath = extractPayload( f.fileName(), resolverId );
if( !resolverPath.isEmpty() )
if ( !resolverPath.isEmpty() )
{
// Do the install / add to tomahawk
TomahawkApp::instance()->addScriptResolver( resolverPath, true );
Tomahawk::Pipeline::instance()->addScriptResolver( resolverPath, true );
m_resolverStates[ resolverId ] = Installed;
TomahawkSettings::instance()->setAtticaResolverState( resolverId, Installed );
emit resolverInstalled( resolverId );
@ -258,6 +270,7 @@ AtticaManager::payloadFetched()
}
}
QString
AtticaManager::extractPayload( const QString& filename, const QString& resolverId ) const
{
@ -327,6 +340,7 @@ AtticaManager::extractPayload( const QString& filename, const QString& resolverI
return QString( QFile( resolverDir.absolutePath() + "/contents/code/main.js" ).fileName() );
}
void
AtticaManager::uninstallResolver( const QString& pathToResolver )
{
@ -357,13 +371,14 @@ AtticaManager::uninstallResolver( const Content& resolver )
emit resolverUninstalled( resolver.id() );
emit resolverStateChanged( resolver.id() );
TomahawkApp::instance()->removeScriptResolver( pathFromId( resolver.id() ) );
Tomahawk::Pipeline::instance()->removeScriptResolver( pathFromId( resolver.id() ) );
m_resolverStates[ resolver.id() ] = Uninstalled;
TomahawkSettings::instance()->setAtticaResolverState( resolver.id(), Uninstalled );
doResolverRemove( resolver.id() );
}
void
AtticaManager::doResolverRemove( const QString& id ) const
{

View File

@ -24,6 +24,8 @@
#include <QObject>
#include <QHash>
#include "dllmacro.h"
#ifdef LIBATTICA_FOUND
#include <attica/provider.h>
#include <attica/providermanager.h>
@ -31,7 +33,7 @@
#include <QPixmap>
#endif
class AtticaManager : public QObject
class DLLEXPORT AtticaManager : public QObject
{
Q_OBJECT
public:
@ -46,7 +48,8 @@ public:
typedef QHash< QString, AtticaManager::ResolverState > StateHash;
static AtticaManager* instance() {
static AtticaManager* instance()
{
if ( !s_instance )
s_instance = new AtticaManager();

View File

@ -159,6 +159,9 @@ set( libSources
playlist/dynamic/database/DatabaseControl.cpp
playlist/dynamic/database/DatabaseGenerator.cpp
resolvers/scriptresolver.cpp
resolvers/qtscriptresolver.cpp
network/bufferiodevice.cpp
network/msgprocessor.cpp
network/streamconnection.cpp
@ -232,6 +235,7 @@ set( libHeaders
globalactionmanager.h
contextmenu.h
dropjob.h
AtticaManager.h
artist.h
album.h
@ -372,6 +376,9 @@ set( libHeaders
playlist/dynamic/database/DatabaseControl.h
playlist/dynamic/database/DatabaseGenerator.h
resolvers/scriptresolver.h
resolvers/qtscriptresolver.h
utils/widgetdragfilter.h
utils/xspfloader.h
utils/xspfgenerator.h
@ -456,9 +463,19 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.
${LIBPORTFWD_INCLUDE_DIR}
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
${QuaZip_INCLUDE_DIR}
)
IF(QCA2_FOUND)
INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} )
ENDIF(QCA2_FOUND)
IF(LIBATTICA_FOUND)
SET( libSources ${libSources} AtticaManager.cpp )
SET( libHeaders ${libHeaders} AtticaManager.h )
INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} )
ENDIF(LIBATTICA_FOUND)
IF( UNIX AND NOT APPLE )
SET( libSources ${libSources}
infosystem/infoplugins/unix/mprispluginrootadaptor.cpp
@ -533,9 +550,17 @@ qt4_wrap_cpp( libMoc ${libHeaders} )
SET( libSources ${libSources} ${libUI_H} ${libHeaders_NoMOC} )
add_library( tomahawklib SHARED ${libSources} ${libMoc} )
ADD_LIBRARY( tomahawklib SHARED ${libSources} ${libMoc} )
target_link_libraries( tomahawklib
IF(QCA2_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} )
ENDIF(QCA2_FOUND)
IF(LIBATTICA_FOUND)
SET( LINK_LIBRARIES ${LINK_LIBRARIES} ${LIBATTICA_LIBRARIES} ${QuaZip_LIBRARIES} )
ENDIF(LIBATTICA_FOUND)
TARGET_LINK_LIBRARIES( tomahawklib
# Thirdparty shipped with tomahawk
${LIBPORTFWD_LIBRARIES}

View File

@ -22,6 +22,8 @@
#include "functimeout.h"
#include "database/database.h"
#include "resolvers/scriptresolver.h"
#include "resolvers/qtscriptresolver.h"
#include "utils/logger.h"
@ -59,6 +61,10 @@ Pipeline::Pipeline( QObject* parent )
Pipeline::~Pipeline()
{
m_running = false;
// stop script resolvers
qDeleteAll( m_scriptResolvers );
m_scriptResolvers.clear();
}
@ -108,6 +114,67 @@ Pipeline::addResolver( Resolver* r )
}
Tomahawk::ExternalResolver*
Pipeline::addScriptResolver( const QString& path, bool start )
{
ExternalResolver* res = 0;
const QFileInfo fi( path );
if ( fi.suffix() == "js" || fi.suffix() == "script" )
res = new QtScriptResolver( path );
else
res = new ScriptResolver( path );
m_scriptResolvers << res;
if ( start )
res->start();
return res;
}
void
Pipeline::stopScriptResolver( const QString& path )
{
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == path )
res->stop();
}
}
void
Pipeline::removeScriptResolver( const QString& scriptPath )
{
ExternalResolver* r = 0;
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == scriptPath )
r = res;
}
m_scriptResolvers.removeAll( r );
if ( r )
{
r->stop();
connect( r, SIGNAL( stopped() ), r, SLOT( deleteLater() ) );
}
}
ExternalResolver*
Pipeline::resolverForPath( const QString& scriptPath )
{
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == scriptPath )
return res;
}
return 0;
}
void
Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized, bool temporaryQuery )
{

View File

@ -52,6 +52,12 @@ public:
void reportResults( QID qid, const QList< result_ptr >& results );
Tomahawk::ExternalResolver* addScriptResolver( const QString& scriptPath, bool start = true );
void stopScriptResolver( const QString& scriptPath );
void removeScriptResolver( const QString& scriptPath );
QList< Tomahawk::ExternalResolver* > scriptResolvers() const { return m_scriptResolvers; }
Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath );
void addResolver( Resolver* r );
void removeResolver( Resolver* r );
@ -96,6 +102,7 @@ private:
int decQIDState( const Tomahawk::query_ptr& query );
QList< Resolver* > m_resolvers;
QList< Tomahawk::ExternalResolver* > m_scriptResolvers;
QMap< QID, bool > m_qidsTimeout;
QMap< QID, unsigned int > m_qidsState;

View File

@ -36,9 +36,11 @@
#include <QtCrypto>
#endif
#include "dllmacro.h"
class QtScriptResolver;
class QtScriptResolverHelper : public QObject
class DLLEXPORT QtScriptResolverHelper : public QObject
{
Q_OBJECT
@ -46,10 +48,10 @@ public:
QtScriptResolverHelper( const QString& scriptPath, QtScriptResolver* parent );
void setResolverConfig( const QVariantMap& config );
// Return a HMAC (md5) signature of the input text with the desired key
Q_INVOKABLE QString hmac( const QByteArray& key, const QByteArray& input );
Q_INVOKABLE QString md5( const QByteArray& input );
public slots:
QByteArray readRaw( const QString& fileName );
QString readBase64( const QString& fileName );
@ -72,7 +74,7 @@ private:
#endif
};
class ScriptEngine : public QWebPage
class DLLEXPORT ScriptEngine : public QWebPage
{
Q_OBJECT
@ -110,7 +112,7 @@ private:
};
class QtScriptResolver : public Tomahawk::ExternalResolver
class DLLEXPORT QtScriptResolver : public Tomahawk::ExternalResolver
{
Q_OBJECT

View File

@ -30,8 +30,11 @@
#include "result.h"
#include "source.h"
#include "dllmacro.h"
class QWidget;
class ScriptResolver : public Tomahawk::ExternalResolver
class DLLEXPORT ScriptResolver : public Tomahawk::ExternalResolver
{
Q_OBJECT

View File

@ -6,6 +6,8 @@ find_package(Qt4 REQUIRED)
set(QT_USE_QTGUI false)
include(${QT_USE_FILE})
ADD_DEFINITIONS(-fPIC)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
set(LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name" FORCE)

View File

@ -24,7 +24,6 @@
CheckDirModel::CheckDirModel( QWidget* parent )
: QDirModel( parent )
{
setLazyChildCount( false );
}

View File

@ -28,10 +28,32 @@
static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long );
#endif
#ifdef Q_OS_LINUX
#include "client/linux/handler/exception_handler.h"
static bool
dumpCallback( const char* dump_path, const char* minidump_id, void* /* context */, bool succeeded )
{
printf( "Tomahawk crashed - Dump path: %s/%s.dmp\n", dump_path, minidump_id );
return succeeded;
}
void
crash()
{
volatile int* a = (int*)(NULL);
*a = 1;
}
#endif
int
main( int argc, char *argv[] )
{
#ifdef Q_OS_LINUX
google_breakpad::ExceptionHandler eh( "/tmp", NULL, dumpCallback, NULL, true );
#endif
#ifdef Q_WS_MAC
// Do Mac specific startup to get media keys working.
// This must go before QApplication initialisation.

View File

@ -23,6 +23,7 @@
#include "tomahawksettings.h"
#include "tomahawkapp.h"
#include "resolver.h"
#include "pipeline.h"
#include "config.h"
#include "utils/logger.h"
@ -46,7 +47,7 @@ ResolversModel::data( const QModelIndex& index, int role ) const
if( !index.isValid() || !hasIndex( index.row(), index.column(), QModelIndex() ) )
return QVariant();
Tomahawk::ExternalResolver* res = TomahawkApp::instance()->scriptResolvers().at( index.row() );
Tomahawk::ExternalResolver* res = Tomahawk::Pipeline::instance()->scriptResolvers().at( index.row() );
switch( role )
{
case Qt::DisplayRole:
@ -73,7 +74,7 @@ ResolversModel::setData( const QModelIndex& index, const QVariant& value, int ro
if ( !hasIndex( index.row(), index.column(), QModelIndex() ) )
return false;
Tomahawk::ExternalResolver* r = TomahawkApp::instance()->scriptResolvers().at( index.row() );
Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->scriptResolvers().at( index.row() );
if ( r && r->error() == Tomahawk::ExternalResolver::FileNotFound ) // give it a shot to see if the user manually fixed paths
{
r->reload();
@ -109,7 +110,7 @@ int
ResolversModel::rowCount( const QModelIndex& parent ) const
{
Q_UNUSED( parent );
return APP->scriptResolvers().count();
return Tomahawk::Pipeline::instance()->scriptResolvers().count();
}
int
@ -131,7 +132,7 @@ ResolversModel::addResolver( const QString& resolver, bool enable )
{
const int count = rowCount( QModelIndex() );
beginInsertRows( QModelIndex(), count, count );
Tomahawk::ExternalResolver* res = APP->addScriptResolver( resolver, enable );
Tomahawk::ExternalResolver* res = Tomahawk::Pipeline::instance()->addScriptResolver( resolver, enable );
connect( res, SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
endInsertRows();
}
@ -140,10 +141,10 @@ void
ResolversModel::atticaResolverInstalled( const QString& resolverId )
{
#ifdef LIBATTICA_FOUND
Tomahawk::ExternalResolver* r = APP->resolverForPath( AtticaManager::instance()->pathFromId( resolverId ) );
Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->resolverForPath( AtticaManager::instance()->pathFromId( resolverId ) );
if ( !r )
return;
const int idx = APP->scriptResolvers().indexOf( r );
const int idx = Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( r );
if ( idx >= 0 )
{
beginInsertRows( QModelIndex(), idx, idx );
@ -156,12 +157,12 @@ ResolversModel::atticaResolverInstalled( const QString& resolverId )
void
ResolversModel::removeResolver( const QString& resolver )
{
const int idx = APP->scriptResolvers().indexOf( APP->resolverForPath( resolver ) );
const int idx = Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( Tomahawk::Pipeline::instance()->resolverForPath( resolver ) );
if ( idx < 0 )
return;
beginRemoveRows( QModelIndex(), idx, idx );
APP->removeScriptResolver( resolver );
Tomahawk::Pipeline::instance()->removeScriptResolver( resolver );
endRemoveRows();
}
@ -171,10 +172,10 @@ ResolversModel::resolverChanged()
Tomahawk::ExternalResolver* res = qobject_cast< Tomahawk::ExternalResolver* >( sender() );
Q_ASSERT( res );
if ( APP->scriptResolvers().contains( res ) )
if ( Tomahawk::Pipeline::instance()->scriptResolvers().contains( res ) )
{
qDebug() << "Got resolverChanged signal, does it have a config UI yet?" << res->configUI();
const QModelIndex idx = index( APP->scriptResolvers().indexOf( res ), 0, QModelIndex() );
const QModelIndex idx = index( Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( res ), 0, QModelIndex() );
emit dataChanged( idx, idx );
}
}
@ -199,13 +200,13 @@ ResolversModel::addInstalledResolvers()
if ( fileName.contains( "_tomahawkresolver" ) ) {
const QString path = pluginDir.absoluteFilePath( fileName );
bool found = false;
foreach ( Tomahawk::ExternalResolver* res, APP->scriptResolvers() )
foreach ( Tomahawk::ExternalResolver* res, Tomahawk::Pipeline::instance()->scriptResolvers() )
{
if ( res->filePath() == path )
found = true;
}
if ( !found ) {
APP->addScriptResolver( path, false );
Tomahawk::Pipeline::instance()->addScriptResolver( path, false );
}
}
}
@ -216,7 +217,7 @@ void
ResolversModel::saveScriptResolvers()
{
QStringList enabled, all;
foreach ( Tomahawk::ExternalResolver* res, APP->scriptResolvers() )
foreach ( Tomahawk::ExternalResolver* res, Tomahawk::Pipeline::instance()->scriptResolvers() )
{
all << res->filePath();
if ( res->running() )

View File

@ -41,6 +41,7 @@
#include "sip/SipHandler.h"
#include "database/database.h"
#include "scanmanager.h"
#include "pipeline.h"
#include "resolverconfigdelegate.h"
#include "resolversmodel.h"
#include "delegateconfigwrapper.h"
@ -319,7 +320,7 @@ SettingsDialog::createIcons()
ui->listWidget->setMaximumWidth( maxlen + 8 );
#endif
connect( ui->listWidget, SIGNAL( currentItemChanged( QListWidgetItem* ,QListWidgetItem* ) ), this, SLOT( changePage( QListWidgetItem*, QListWidgetItem* ) ) );
connect( ui->listWidget, SIGNAL( currentItemChanged( QListWidgetItem*, QListWidgetItem* ) ), SLOT( changePage( QListWidgetItem*, QListWidgetItem* ) ) );
}
@ -588,7 +589,7 @@ SettingsDialog::getMoreResolversFinished( int ret )
void
SettingsDialog::openResolverConfig( const QString& resolver )
{
Tomahawk::ExternalResolver* r = TomahawkApp::instance()->resolverForPath( resolver );
Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->resolverForPath( resolver );
if( r && r->configUI() )
{
#ifndef Q_WS_MAC

View File

@ -44,8 +44,6 @@
#include "playlist/dynamic/echonest/EchonestGenerator.h"
#include "playlist/dynamic/database/DatabaseGenerator.h"
#include "web/api_v1.h"
#include "resolvers/scriptresolver.h"
#include "resolvers/qtscriptresolver.h"
#include "sourcelist.h"
#include "shortcuthandler.h"
#include "scanmanager.h"
@ -268,10 +266,6 @@ TomahawkApp::~TomahawkApp()
{
tLog() << "Shutting down Tomahawk...";
// stop script resolvers
qDeleteAll( m_scriptResolvers );
m_scriptResolvers.clear();
if ( !m_servent.isNull() )
delete m_servent.data();
if ( !m_scanManager.isNull() )
@ -447,76 +441,16 @@ TomahawkApp::initPipeline()
{
// setup resolvers for local content, and (cached) remote collection content
Pipeline::instance()->addResolver( new DatabaseResolver( 100 ) );
// load script resolvers
QStringList enabled = TomahawkSettings::instance()->enabledScriptResolvers();
foreach ( QString resolver, TomahawkSettings::instance()->allScriptResolvers() )
{
const bool enable = enabled.contains( resolver );
addScriptResolver( resolver, enable );
Pipeline::instance()->addScriptResolver( resolver, enable );
}
}
Tomahawk::ExternalResolver*
TomahawkApp::addScriptResolver( const QString& path, bool start )
{
const QFileInfo fi( path );
ExternalResolver* res = 0;
if ( fi.suffix() == "js" || fi.suffix() == "script" )
res = new QtScriptResolver( path );
else
res = new ScriptResolver( path );
m_scriptResolvers << res;
if ( start )
res->start();
return res;
}
void
TomahawkApp::stopScriptResolver( const QString& path )
{
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == path )
res->stop();
}
}
void
TomahawkApp::removeScriptResolver( const QString& scriptPath )
{
ExternalResolver* r = 0;
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == scriptPath )
r = res;
}
m_scriptResolvers.removeAll( r );
if ( r )
{
r->stop();
connect( r, SIGNAL( stopped() ), r, SLOT( deleteLater() ) );
}
}
Tomahawk::ExternalResolver*
TomahawkApp::resolverForPath( const QString& scriptPath )
{
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == scriptPath )
return res;
}
return 0;
}
void
TomahawkApp::initLocalCollection()
{

View File

@ -90,13 +90,6 @@ public:
TomahawkWindow* mainWindow() const { return m_mainwindow; }
#endif
Tomahawk::ExternalResolver* addScriptResolver( const QString& scriptPath, bool start = true );
void stopScriptResolver( const QString& scriptPath );
void removeScriptResolver( const QString& scriptPath );
QList< Tomahawk::ExternalResolver* > scriptResolvers() const { return m_scriptResolvers; }
Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath );
// PlatformInterface
virtual bool loadUrl( const QString& url );
@ -123,7 +116,6 @@ private:
void loadPlugins();
QList<Tomahawk::collection_ptr> m_collections;
QList<Tomahawk::ExternalResolver*> m_scriptResolvers;
QWeakPointer<Database> m_database;
QWeakPointer<ScanManager> m_scanManager;