mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-18 23:09:42 +01:00
Pass accountId to the resolver
This commit is contained in:
parent
c0b6785bde
commit
607a82c248
@ -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;
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace Tomahawk
|
||||
class PipelinePrivate;
|
||||
class Resolver;
|
||||
class ExternalResolver;
|
||||
typedef boost::function<Tomahawk::ExternalResolver*( QString, QStringList )> ResolverFactoryFunc;
|
||||
typedef boost::function<Tomahawk::ExternalResolver*( QString, QString, QStringList )> 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;
|
||||
|
@ -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() ) );
|
||||
|
||||
|
@ -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() ) );
|
||||
}
|
||||
|
@ -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() ) );
|
||||
|
@ -55,9 +55,9 @@
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
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.";
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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; }
|
||||
|
@ -234,8 +234,8 @@ TomahawkApp::init()
|
||||
m_scanManager = QPointer<ScanManager>( 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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user