mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Pass accountId to the resolver
This commit is contained in:
@@ -173,14 +173,14 @@ Pipeline::addExternalResolverFactory( ResolverFactoryFunc resolverFactory )
|
|||||||
|
|
||||||
|
|
||||||
Tomahawk::ExternalResolver*
|
Tomahawk::ExternalResolver*
|
||||||
Pipeline::addScriptResolver( const QString& path, const QStringList& additionalScriptPaths )
|
Pipeline::addScriptResolver( const QString& accountId, const QString& path, const QStringList& additionalScriptPaths )
|
||||||
{
|
{
|
||||||
Q_D( Pipeline );
|
Q_D( Pipeline );
|
||||||
ExternalResolver* res = 0;
|
ExternalResolver* res = 0;
|
||||||
|
|
||||||
foreach ( ResolverFactoryFunc factory, d->resolverFactories )
|
foreach ( ResolverFactoryFunc factory, d->resolverFactories )
|
||||||
{
|
{
|
||||||
res = factory( path, additionalScriptPaths );
|
res = factory( accountId, path, additionalScriptPaths );
|
||||||
if ( !res )
|
if ( !res )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ namespace Tomahawk
|
|||||||
class PipelinePrivate;
|
class PipelinePrivate;
|
||||||
class Resolver;
|
class Resolver;
|
||||||
class ExternalResolver;
|
class ExternalResolver;
|
||||||
typedef boost::function<Tomahawk::ExternalResolver*( QString, QStringList )> ResolverFactoryFunc;
|
typedef boost::function<Tomahawk::ExternalResolver*( QString, QString, QStringList )> ResolverFactoryFunc;
|
||||||
|
|
||||||
class DLLEXPORT Pipeline : public QObject
|
class DLLEXPORT Pipeline : public QObject
|
||||||
{
|
{
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
void reportArtists( QID qid, const QList< artist_ptr >& artists );
|
void reportArtists( QID qid, const QList< artist_ptr >& artists );
|
||||||
|
|
||||||
void addExternalResolverFactory( ResolverFactoryFunc resolverFactory );
|
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 stopScriptResolver( const QString& scriptPath );
|
||||||
void removeScriptResolver( const QString& scriptPath );
|
void removeScriptResolver( const QString& scriptPath );
|
||||||
QList< QPointer< ExternalResolver > > scriptResolvers() const;
|
QList< QPointer< ExternalResolver > > scriptResolvers() const;
|
||||||
|
@@ -349,7 +349,7 @@ ResolverAccount::hookupResolver()
|
|||||||
if ( configuration().contains( "scripts" ) )
|
if ( configuration().contains( "scripts" ) )
|
||||||
additionalPaths = configuration().value( "scripts" ).toStringList();
|
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 ) );
|
m_resolver = QPointer< ExternalResolverGui >( qobject_cast< ExternalResolverGui* >( er ) );
|
||||||
connect( m_resolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
|
connect( m_resolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
|
||||||
|
|
||||||
|
@@ -286,7 +286,11 @@ LastFmAccount::hookupResolver()
|
|||||||
|
|
||||||
const AtticaManager::Resolver data = AtticaManager::instance()->resolverData( res.id() );
|
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() );
|
m_resolver.data()->setIcon( icon() );
|
||||||
connect( m_resolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
|
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
|
// 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
|
// 0.4.x->0.5.x upgrade. So we do it manually for a while
|
||||||
killExistingResolvers();
|
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 ) );
|
m_spotifyResolver.data()->setIcon( TomahawkUtils::defaultPixmap( TomahawkUtils::SpotifyIcon ) );
|
||||||
|
|
||||||
connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
|
connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
|
||||||
|
@@ -55,9 +55,9 @@
|
|||||||
|
|
||||||
#include <boost/bind.hpp>
|
#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 )
|
: Tomahawk::ExternalResolverGui( scriptPath )
|
||||||
, d_ptr( new JSResolverPrivate( this, scriptPath, additionalScriptPaths ) )
|
, d_ptr( new JSResolverPrivate( this, accountId, scriptPath, additionalScriptPaths ) )
|
||||||
{
|
{
|
||||||
Q_D( JSResolver );
|
Q_D( JSResolver );
|
||||||
tLog() << Q_FUNC_INFO << "Loading JS resolver:" << scriptPath;
|
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;
|
ExternalResolver* res = 0;
|
||||||
|
|
||||||
const QFileInfo fi( scriptPath );
|
const QFileInfo fi( scriptPath );
|
||||||
if ( fi.suffix() == "js" || fi.suffix() == "script" )
|
if ( fi.suffix() == "js" || fi.suffix() == "script" )
|
||||||
{
|
{
|
||||||
res = new JSResolver( scriptPath, additionalScriptPaths );
|
res = new JSResolver( accountId, scriptPath, additionalScriptPaths );
|
||||||
tLog() << Q_FUNC_INFO << scriptPath << "Loaded.";
|
tLog() << Q_FUNC_INFO << scriptPath << "Loaded.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,9 +38,9 @@ Q_OBJECT
|
|||||||
friend class ::JSResolverHelper;
|
friend class ::JSResolverHelper;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit JSResolver( const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() );
|
explicit JSResolver( const QString& accountId, const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() );
|
||||||
virtual ~JSResolver();
|
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;
|
virtual Capabilities capabilities() const;
|
||||||
|
|
||||||
|
@@ -30,8 +30,9 @@ class JSResolverPrivate
|
|||||||
{
|
{
|
||||||
friend class ::JSResolverHelper;
|
friend class ::JSResolverHelper;
|
||||||
public:
|
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 )
|
: q_ptr ( q )
|
||||||
|
, accountId( pAccountId )
|
||||||
, ready( false )
|
, ready( false )
|
||||||
, stopped( true )
|
, stopped( true )
|
||||||
, error( Tomahawk::ExternalResolver::NoError )
|
, error( Tomahawk::ExternalResolver::NoError )
|
||||||
@@ -45,6 +46,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
ScriptEngine* engine;
|
ScriptEngine* engine;
|
||||||
|
|
||||||
|
QString accountId;
|
||||||
QString name;
|
QString name;
|
||||||
QPixmap icon;
|
QPixmap icon;
|
||||||
unsigned int weight, timeout;
|
unsigned int weight, timeout;
|
||||||
|
@@ -101,8 +101,9 @@ ScriptResolver::~ScriptResolver()
|
|||||||
|
|
||||||
|
|
||||||
Tomahawk::ExternalResolver*
|
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 )
|
Q_UNUSED( unused )
|
||||||
|
|
||||||
ExternalResolver* res = 0;
|
ExternalResolver* res = 0;
|
||||||
|
@@ -39,7 +39,7 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
explicit ScriptResolver( const QString& exe );
|
explicit ScriptResolver( const QString& exe );
|
||||||
virtual ~ScriptResolver();
|
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 QString name() const { return m_name; }
|
||||||
virtual QPixmap icon() const { return m_icon; }
|
virtual QPixmap icon() const { return m_icon; }
|
||||||
|
@@ -234,8 +234,8 @@ TomahawkApp::init()
|
|||||||
m_scanManager = QPointer<ScanManager>( new ScanManager( this ) );
|
m_scanManager = QPointer<ScanManager>( new ScanManager( this ) );
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
Pipeline::instance()->addExternalResolverFactory( boost::bind( &JSResolver::factory, _1, _2 ) );
|
Pipeline::instance()->addExternalResolverFactory( boost::bind( &JSResolver::factory, _1, _2, _3 ) );
|
||||||
Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1, _2 ) );
|
Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1, _2, _3 ) );
|
||||||
|
|
||||||
new ActionCollection( this );
|
new ActionCollection( this );
|
||||||
connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );
|
connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );
|
||||||
|
Reference in New Issue
Block a user