diff --git a/src/libtomahawk/Pipeline.cpp b/src/libtomahawk/Pipeline.cpp index 17c6a6cf3..944a00176 100644 --- a/src/libtomahawk/Pipeline.cpp +++ b/src/libtomahawk/Pipeline.cpp @@ -173,14 +173,14 @@ Pipeline::addExternalResolverFactory( ResolverFactoryFunc resolverFactory ) Tomahawk::ExternalResolver* -Pipeline::addScriptResolver( const QString& path, const QStringList& additionalScriptPaths ) +Pipeline::addScriptResolver( const QString& accountId, const QString& path, const QStringList& additionalScriptPaths ) { Q_D( Pipeline ); ExternalResolver* res = 0; foreach ( ResolverFactoryFunc factory, d->resolverFactories ) { - res = factory( path, additionalScriptPaths ); + res = factory( accountId, path, additionalScriptPaths ); if ( !res ) continue; diff --git a/src/libtomahawk/Pipeline.h b/src/libtomahawk/Pipeline.h index 541d774b7..f1f0c7e13 100644 --- a/src/libtomahawk/Pipeline.h +++ b/src/libtomahawk/Pipeline.h @@ -37,7 +37,7 @@ namespace Tomahawk class PipelinePrivate; class Resolver; class ExternalResolver; -typedef boost::function ResolverFactoryFunc; +typedef boost::function ResolverFactoryFunc; class DLLEXPORT Pipeline : public QObject { @@ -59,7 +59,7 @@ public: void reportArtists( QID qid, const QList< artist_ptr >& artists ); void addExternalResolverFactory( ResolverFactoryFunc resolverFactory ); - Tomahawk::ExternalResolver* addScriptResolver( const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() ); + Tomahawk::ExternalResolver* addScriptResolver( const QString& accountId, const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() ); void stopScriptResolver( const QString& scriptPath ); void removeScriptResolver( const QString& scriptPath ); QList< QPointer< ExternalResolver > > scriptResolvers() const; diff --git a/src/libtomahawk/accounts/ResolverAccount.cpp b/src/libtomahawk/accounts/ResolverAccount.cpp index b7a614158..03ef1fe23 100644 --- a/src/libtomahawk/accounts/ResolverAccount.cpp +++ b/src/libtomahawk/accounts/ResolverAccount.cpp @@ -349,7 +349,7 @@ ResolverAccount::hookupResolver() if ( configuration().contains( "scripts" ) ) additionalPaths = configuration().value( "scripts" ).toStringList(); - Tomahawk::ExternalResolver* er = Pipeline::instance()->addScriptResolver( mainScriptPath, additionalPaths ); + Tomahawk::ExternalResolver* er = Pipeline::instance()->addScriptResolver( accountId(), mainScriptPath, additionalPaths ); m_resolver = QPointer< ExternalResolverGui >( qobject_cast< ExternalResolverGui* >( er ) ); connect( m_resolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) ); diff --git a/src/libtomahawk/accounts/lastfm/LastFmAccount.cpp b/src/libtomahawk/accounts/lastfm/LastFmAccount.cpp index 5deff8d58..3963b6fe1 100644 --- a/src/libtomahawk/accounts/lastfm/LastFmAccount.cpp +++ b/src/libtomahawk/accounts/lastfm/LastFmAccount.cpp @@ -286,7 +286,11 @@ LastFmAccount::hookupResolver() const AtticaManager::Resolver data = AtticaManager::instance()->resolverData( res.id() ); - m_resolver = QPointer< ExternalResolverGui >( qobject_cast< ExternalResolverGui* >( Pipeline::instance()->addScriptResolver( data.scriptPath ) ) ); + m_resolver = QPointer< ExternalResolverGui >( + qobject_cast< ExternalResolverGui* >( + Pipeline::instance()->addScriptResolver( accountId(), data.scriptPath ) + ) + ); m_resolver.data()->setIcon( icon() ); connect( m_resolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) ); } diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp index babf61f93..e93efdb2b 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp +++ b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp @@ -227,7 +227,7 @@ SpotifyAccount::hookupResolver() // Since the resolver in 0.4.x used an incompatible version of kdsingleappguard, we can't auto-kill old resolvers on the // 0.4.x->0.5.x upgrade. So we do it manually for a while killExistingResolvers(); - m_spotifyResolver = QPointer< ScriptResolver >( qobject_cast< ScriptResolver* >( Pipeline::instance()->addScriptResolver( path ) ) ); + m_spotifyResolver = QPointer< ScriptResolver >( qobject_cast< ScriptResolver* >( Pipeline::instance()->addScriptResolver( accountId(), path ) ) ); m_spotifyResolver.data()->setIcon( TomahawkUtils::defaultPixmap( TomahawkUtils::SpotifyIcon ) ); connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) ); diff --git a/src/libtomahawk/resolvers/JSResolver.cpp b/src/libtomahawk/resolvers/JSResolver.cpp index 4b44b65f7..28c2861ed 100644 --- a/src/libtomahawk/resolvers/JSResolver.cpp +++ b/src/libtomahawk/resolvers/JSResolver.cpp @@ -55,9 +55,9 @@ #include -JSResolver::JSResolver( const QString& scriptPath, const QStringList& additionalScriptPaths ) +JSResolver::JSResolver( const QString& accountId, const QString& scriptPath, const QStringList& additionalScriptPaths ) : Tomahawk::ExternalResolverGui( scriptPath ) - , d_ptr( new JSResolverPrivate( this, scriptPath, additionalScriptPaths ) ) + , d_ptr( new JSResolverPrivate( this, accountId, scriptPath, additionalScriptPaths ) ) { Q_D( JSResolver ); tLog() << Q_FUNC_INFO << "Loading JS resolver:" << scriptPath; @@ -91,14 +91,14 @@ JSResolver::~JSResolver() } -Tomahawk::ExternalResolver* JSResolver::factory( const QString& scriptPath, const QStringList& additionalScriptPaths ) +Tomahawk::ExternalResolver* JSResolver::factory( const QString& accountId, const QString& scriptPath, const QStringList& additionalScriptPaths ) { ExternalResolver* res = 0; const QFileInfo fi( scriptPath ); if ( fi.suffix() == "js" || fi.suffix() == "script" ) { - res = new JSResolver( scriptPath, additionalScriptPaths ); + res = new JSResolver( accountId, scriptPath, additionalScriptPaths ); tLog() << Q_FUNC_INFO << scriptPath << "Loaded."; } diff --git a/src/libtomahawk/resolvers/JSResolver.h b/src/libtomahawk/resolvers/JSResolver.h index 74de68b5d..4e4bc01ed 100644 --- a/src/libtomahawk/resolvers/JSResolver.h +++ b/src/libtomahawk/resolvers/JSResolver.h @@ -38,9 +38,9 @@ Q_OBJECT friend class ::JSResolverHelper; public: - explicit JSResolver( const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() ); + explicit JSResolver( const QString& accountId, const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() ); virtual ~JSResolver(); - static ExternalResolver* factory( const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() ); + static ExternalResolver* factory( const QString& accountId, const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() ); virtual Capabilities capabilities() const; diff --git a/src/libtomahawk/resolvers/JSResolver_p.h b/src/libtomahawk/resolvers/JSResolver_p.h index 8eb37fcec..6c0d85af9 100644 --- a/src/libtomahawk/resolvers/JSResolver_p.h +++ b/src/libtomahawk/resolvers/JSResolver_p.h @@ -30,8 +30,9 @@ class JSResolverPrivate { friend class ::JSResolverHelper; public: - JSResolverPrivate( JSResolver* q, const QString& scriptPath, const QStringList& additionalScriptPaths ) + JSResolverPrivate( JSResolver* q, const QString& pAccountId, const QString& scriptPath, const QStringList& additionalScriptPaths ) : q_ptr ( q ) + , accountId( pAccountId ) , ready( false ) , stopped( true ) , error( Tomahawk::ExternalResolver::NoError ) @@ -45,6 +46,7 @@ public: private: ScriptEngine* engine; + QString accountId; QString name; QPixmap icon; unsigned int weight, timeout; diff --git a/src/libtomahawk/resolvers/ScriptResolver.cpp b/src/libtomahawk/resolvers/ScriptResolver.cpp index 2cddf5d3e..add42eccf 100644 --- a/src/libtomahawk/resolvers/ScriptResolver.cpp +++ b/src/libtomahawk/resolvers/ScriptResolver.cpp @@ -101,8 +101,9 @@ ScriptResolver::~ScriptResolver() Tomahawk::ExternalResolver* -ScriptResolver::factory( const QString& exe, const QStringList& unused ) +ScriptResolver::factory( const QString& accountId, const QString& exe, const QStringList& unused ) { + Q_UNUSED( accountId ) Q_UNUSED( unused ) ExternalResolver* res = 0; diff --git a/src/libtomahawk/resolvers/ScriptResolver.h b/src/libtomahawk/resolvers/ScriptResolver.h index 88bac9566..99f2c9103 100644 --- a/src/libtomahawk/resolvers/ScriptResolver.h +++ b/src/libtomahawk/resolvers/ScriptResolver.h @@ -39,7 +39,7 @@ Q_OBJECT public: explicit ScriptResolver( const QString& exe ); virtual ~ScriptResolver(); - static ExternalResolver* factory( const QString& exe, const QStringList& ); + static ExternalResolver* factory( const QString& accountId, const QString& exe, const QStringList& ); virtual QString name() const { return m_name; } virtual QPixmap icon() const { return m_icon; } diff --git a/src/tomahawk/TomahawkApp.cpp b/src/tomahawk/TomahawkApp.cpp index 7fa07aad7..a427116cc 100644 --- a/src/tomahawk/TomahawkApp.cpp +++ b/src/tomahawk/TomahawkApp.cpp @@ -234,8 +234,8 @@ TomahawkApp::init() m_scanManager = QPointer( new ScanManager( this ) ); #ifndef ENABLE_HEADLESS - Pipeline::instance()->addExternalResolverFactory( boost::bind( &JSResolver::factory, _1, _2 ) ); - Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1, _2 ) ); + Pipeline::instance()->addExternalResolverFactory( boost::bind( &JSResolver::factory, _1, _2, _3 ) ); + Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1, _2, _3 ) ); new ActionCollection( this ); connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );