mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 22:56:42 +02:00
More work towards cleaning up and making safer the info plugins. Twitter should be pretty good, but need to make lastfm and xmpp use the same paradigm
This commit is contained in:
@@ -74,9 +74,9 @@ LastFmAccount::LastFmAccount( const QString& accountId )
|
|||||||
|
|
||||||
if ( infoPlugin() && Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() )
|
if ( infoPlugin() && Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() )
|
||||||
{
|
{
|
||||||
infoPlugin()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() );
|
infoPlugin().data()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() );
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() );
|
Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() );
|
||||||
QMetaObject::invokeMethod( infoPlugin(), "init", Qt::QueuedConnection );
|
QMetaObject::invokeMethod( infoPlugin().data(), "init", Qt::QueuedConnection );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,12 +164,12 @@ LastFmAccount::icon() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoPlugin*
|
InfoPluginPtr
|
||||||
LastFmAccount::infoPlugin()
|
LastFmAccount::infoPlugin()
|
||||||
{
|
{
|
||||||
if ( m_infoPlugin )
|
if ( m_infoPlugin )
|
||||||
return m_infoPlugin.data();
|
return InfoPluginPtr( m_infoPlugin.data() );
|
||||||
return 0;
|
return InfoPluginPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@@ -72,7 +72,7 @@ public:
|
|||||||
virtual void authenticate();
|
virtual void authenticate();
|
||||||
|
|
||||||
virtual SipPlugin* sipPlugin() { return 0; }
|
virtual SipPlugin* sipPlugin() { return 0; }
|
||||||
virtual Tomahawk::InfoSystem::InfoPlugin* infoPlugin();
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
||||||
|
|
||||||
virtual bool isAuthenticated() const;
|
virtual bool isAuthenticated() const;
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ public:
|
|||||||
virtual QPixmap icon() const;
|
virtual QPixmap icon() const;
|
||||||
|
|
||||||
virtual QWidget* aclWidget() { return 0; }
|
virtual QWidget* aclWidget() { return 0; }
|
||||||
virtual InfoSystem::InfoPlugin* infoPlugin() { return 0; }
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
||||||
virtual SipPlugin* sipPlugin() { return 0; }
|
virtual SipPlugin* sipPlugin() { return 0; }
|
||||||
|
|
||||||
void addPlaylist( const QString &qid, const QString& title, QList< Tomahawk::query_ptr > tracks );
|
void addPlaylist( const QString &qid, const QString& title, QList< Tomahawk::query_ptr > tracks );
|
||||||
|
@@ -48,6 +48,7 @@ TwitterAccountFactory::createAccount( const QString& accountId )
|
|||||||
TwitterAccount::TwitterAccount( const QString &accountId )
|
TwitterAccount::TwitterAccount( const QString &accountId )
|
||||||
: Account( accountId )
|
: Account( accountId )
|
||||||
, m_isAuthenticated( false )
|
, m_isAuthenticated( false )
|
||||||
|
, m_isAuthenticating( false )
|
||||||
{
|
{
|
||||||
setAccountServiceName( "Twitter" );
|
setAccountServiceName( "Twitter" );
|
||||||
setTypes( AccountTypes( StatusPushType | SipType ) );
|
setTypes( AccountTypes( StatusPushType | SipType ) );
|
||||||
@@ -100,22 +101,48 @@ TwitterAccount::sipPlugin()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPlugin*
|
Tomahawk::InfoSystem::InfoPluginPtr
|
||||||
TwitterAccount::infoPlugin()
|
TwitterAccount::infoPlugin()
|
||||||
{
|
{
|
||||||
if ( m_twitterInfoPlugin.isNull() )
|
if ( m_twitterInfoPlugin.isNull() )
|
||||||
{
|
{
|
||||||
m_twitterInfoPlugin = QWeakPointer< Tomahawk::InfoSystem::TwitterInfoPlugin >( new Tomahawk::InfoSystem::TwitterInfoPlugin( this ) );
|
m_twitterInfoPlugin = QWeakPointer< Tomahawk::InfoSystem::TwitterInfoPlugin >( new Tomahawk::InfoSystem::TwitterInfoPlugin( this ) );
|
||||||
|
|
||||||
return m_twitterInfoPlugin.data();
|
return Tomahawk::InfoSystem::InfoPluginPtr( m_twitterInfoPlugin.data() );
|
||||||
}
|
}
|
||||||
return m_twitterInfoPlugin.data();
|
return Tomahawk::InfoSystem::InfoPluginPtr( m_twitterInfoPlugin.data() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TwitterAccount::authenticate()
|
TwitterAccount::authenticate()
|
||||||
{
|
{
|
||||||
|
// Since we need to have a chance for deletion (via the infosystem) to work on the info plugin, we put this on the event loop
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
|
QTimer::singleShot( 0, this, SLOT( authenticateSlot() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TwitterAccount::authenticateSlot()
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO;
|
||||||
|
if ( m_twitterInfoPlugin.isNull() )
|
||||||
|
{
|
||||||
|
if ( infoPlugin() && Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() )
|
||||||
|
{
|
||||||
|
infoPlugin().data()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() );
|
||||||
|
Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() );
|
||||||
|
QMetaObject::invokeMethod( infoPlugin().data(), "init", Qt::QueuedConnection );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_isAuthenticating )
|
||||||
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Already authenticating";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tDebug() << Q_FUNC_INFO << "credentials: " << credentials().keys();
|
tDebug() << Q_FUNC_INFO << "credentials: " << credentials().keys();
|
||||||
|
|
||||||
if ( credentials()[ "oauthtoken" ].toString().isEmpty() || credentials()[ "oauthtokensecret" ].toString().isEmpty() )
|
if ( credentials()[ "oauthtoken" ].toString().isEmpty() || credentials()[ "oauthtokensecret" ].toString().isEmpty() )
|
||||||
@@ -126,6 +153,7 @@ TwitterAccount::authenticate()
|
|||||||
|
|
||||||
if ( refreshTwitterAuth() )
|
if ( refreshTwitterAuth() )
|
||||||
{
|
{
|
||||||
|
m_isAuthenticating = true;
|
||||||
tDebug() << Q_FUNC_INFO << "Verifying credentials";
|
tDebug() << Q_FUNC_INFO << "Verifying credentials";
|
||||||
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
|
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
|
||||||
connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( connectAuthVerifyReply( const QTweetUser & ) ) );
|
connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( connectAuthVerifyReply( const QTweetUser & ) ) );
|
||||||
@@ -143,9 +171,10 @@ TwitterAccount::deauthenticate()
|
|||||||
sipPlugin()->disconnectPlugin();
|
sipPlugin()->disconnectPlugin();
|
||||||
|
|
||||||
if ( m_twitterInfoPlugin )
|
if ( m_twitterInfoPlugin )
|
||||||
m_twitterInfoPlugin.data()->deleteLater();
|
Tomahawk::InfoSystem::InfoSystem::instance()->removeInfoPlugin( m_twitterInfoPlugin.data() );
|
||||||
|
|
||||||
m_isAuthenticated = false;
|
m_isAuthenticated = false;
|
||||||
|
m_isAuthenticating = false;
|
||||||
|
|
||||||
emit nowDeauthenticated();
|
emit nowDeauthenticated();
|
||||||
}
|
}
|
||||||
@@ -176,6 +205,7 @@ TwitterAccount::refreshTwitterAuth()
|
|||||||
void
|
void
|
||||||
TwitterAccount::connectAuthVerifyReply( const QTweetUser &user )
|
TwitterAccount::connectAuthVerifyReply( const QTweetUser &user )
|
||||||
{
|
{
|
||||||
|
m_isAuthenticating = false;
|
||||||
if ( user.id() == 0 )
|
if ( user.id() == 0 )
|
||||||
{
|
{
|
||||||
qDebug() << "TwitterAccount could not authenticate to Twitter";
|
qDebug() << "TwitterAccount could not authenticate to Twitter";
|
||||||
@@ -191,13 +221,6 @@ TwitterAccount::connectAuthVerifyReply( const QTweetUser &user )
|
|||||||
|
|
||||||
sipPlugin()->connectPlugin();
|
sipPlugin()->connectPlugin();
|
||||||
|
|
||||||
if ( infoPlugin() && Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() )
|
|
||||||
{
|
|
||||||
infoPlugin()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() );
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() );
|
|
||||||
QMetaObject::invokeMethod( infoPlugin(), "init", Qt::QueuedConnection );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_isAuthenticated = true;
|
m_isAuthenticated = true;
|
||||||
emit nowAuthenticated( m_twitterAuth, user );
|
emit nowAuthenticated( m_twitterAuth, user );
|
||||||
}
|
}
|
||||||
|
@@ -70,7 +70,7 @@ public:
|
|||||||
|
|
||||||
ConnectionState connectionState() const;
|
ConnectionState connectionState() const;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPlugin* infoPlugin();
|
Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
||||||
SipPlugin* sipPlugin();
|
SipPlugin* sipPlugin();
|
||||||
|
|
||||||
QWidget* configurationWidget() { return m_configWidget.data(); }
|
QWidget* configurationWidget() { return m_configWidget.data(); }
|
||||||
@@ -84,12 +84,14 @@ signals:
|
|||||||
void nowDeauthenticated();
|
void nowDeauthenticated();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void authenticateSlot();
|
||||||
void configDialogAuthedSignalSlot( bool authed );
|
void configDialogAuthedSignalSlot( bool authed );
|
||||||
void connectAuthVerifyReply( const QTweetUser &user );
|
void connectAuthVerifyReply( const QTweetUser &user );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
bool m_isAuthenticated;
|
bool m_isAuthenticated;
|
||||||
|
bool m_isAuthenticating;
|
||||||
QWeakPointer< TomahawkOAuthTwitter > m_twitterAuth;
|
QWeakPointer< TomahawkOAuthTwitter > m_twitterAuth;
|
||||||
QWeakPointer< TwitterConfigWidget > m_configWidget;
|
QWeakPointer< TwitterConfigWidget > m_configWidget;
|
||||||
QWeakPointer< TwitterSipPlugin > m_twitterSipPlugin;
|
QWeakPointer< TwitterSipPlugin > m_twitterSipPlugin;
|
||||||
|
@@ -116,6 +116,7 @@ TwitterInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
|||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
if ( !isValid() )
|
if ( !isValid() )
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "Plugin not valid, deleting and returning";
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -141,6 +142,7 @@ TwitterInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
|||||||
QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( m_twitterAuth.data(), this );
|
QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( m_twitterAuth.data(), this );
|
||||||
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postLovedStatusUpdateReply(const QTweetStatus &) ) );
|
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postLovedStatusUpdateReply(const QTweetStatus &) ) );
|
||||||
connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postLovedStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
|
connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postLovedStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
|
||||||
|
tDebug() << Q_FUNC_INFO << "Posting message: " << msg;
|
||||||
statUpdate->post( msg );
|
statUpdate->post( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -86,7 +86,6 @@ JreenMessageHandler(QtMsgType type, const char *msg)
|
|||||||
|
|
||||||
XmppSipPlugin::XmppSipPlugin( Account *account )
|
XmppSipPlugin::XmppSipPlugin( Account *account )
|
||||||
: SipPlugin( account )
|
: SipPlugin( account )
|
||||||
, m_infoPlugin( 0 )
|
|
||||||
, m_state( Account::Disconnected )
|
, m_state( Account::Disconnected )
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
, m_menu( 0 )
|
, m_menu( 0 )
|
||||||
@@ -174,10 +173,10 @@ XmppSipPlugin::~XmppSipPlugin()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystem::InfoPlugin*
|
InfoSystem::InfoPluginPtr
|
||||||
XmppSipPlugin::infoPlugin()
|
XmppSipPlugin::infoPlugin()
|
||||||
{
|
{
|
||||||
return m_infoPlugin;
|
return InfoSystem::InfoPluginPtr( m_infoPlugin.data() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -273,8 +272,8 @@ XmppSipPlugin::onConnect()
|
|||||||
// load XmppInfoPlugin
|
// load XmppInfoPlugin
|
||||||
if( !m_infoPlugin )
|
if( !m_infoPlugin )
|
||||||
{
|
{
|
||||||
m_infoPlugin = new Tomahawk::InfoSystem::XmppInfoPlugin( this );
|
m_infoPlugin = QWeakPointer< Tomahawk::InfoSystem::XmppInfoPlugin >( new Tomahawk::InfoSystem::XmppInfoPlugin( this ) );
|
||||||
InfoSystem::InfoSystem::instance()->addInfoPlugin( m_infoPlugin );
|
InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P
|
//FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P
|
||||||
|
@@ -67,7 +67,7 @@ public:
|
|||||||
//FIXME: Make this more correct
|
//FIXME: Make this more correct
|
||||||
virtual bool isValid() const { return true; }
|
virtual bool isValid() const { return true; }
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPlugin* infoPlugin();
|
Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
virtual QMenu* menu();
|
virtual QMenu* menu();
|
||||||
@@ -131,7 +131,7 @@ private:
|
|||||||
int m_currentPort;
|
int m_currentPort;
|
||||||
QString m_currentResource;
|
QString m_currentResource;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPlugin* m_infoPlugin;
|
QWeakPointer< Tomahawk::InfoSystem::XmppInfoPlugin> m_infoPlugin;
|
||||||
Tomahawk::Accounts::Account::ConnectionState m_state;
|
Tomahawk::Accounts::Account::ConnectionState m_state;
|
||||||
|
|
||||||
// sort out
|
// sort out
|
||||||
|
@@ -91,13 +91,13 @@ XmppAccount::saveConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystem::InfoPlugin*
|
InfoSystem::InfoPluginPtr
|
||||||
XmppAccount::infoPlugin()
|
XmppAccount::infoPlugin()
|
||||||
{
|
{
|
||||||
if( !m_xmppSipPlugin.isNull() )
|
if( !m_xmppSipPlugin.isNull() )
|
||||||
return m_xmppSipPlugin.data()->infoPlugin();
|
return m_xmppSipPlugin.data()->infoPlugin();
|
||||||
|
|
||||||
return 0;
|
return InfoSystem::InfoPluginPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ public:
|
|||||||
void deauthenticate();
|
void deauthenticate();
|
||||||
bool isAuthenticated() const;
|
bool isAuthenticated() const;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPlugin* infoPlugin();
|
Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
|
||||||
|
|
||||||
SipPlugin* sipPlugin();
|
SipPlugin* sipPlugin();
|
||||||
|
|
||||||
|
@@ -64,7 +64,7 @@ public:
|
|||||||
bool isAuthenticated() const;
|
bool isAuthenticated() const;
|
||||||
ConnectionState connectionState() const;
|
ConnectionState connectionState() const;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPlugin* infoPlugin() { return 0; }
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
||||||
SipPlugin* sipPlugin();
|
SipPlugin* sipPlugin();
|
||||||
|
|
||||||
QWidget* configurationWidget() { return 0; }
|
QWidget* configurationWidget() { return 0; }
|
||||||
|
@@ -31,16 +31,13 @@
|
|||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
|
|
||||||
|
#include "libtomahawk/infosystem/infosystem.h"
|
||||||
|
|
||||||
class SipPlugin;
|
class SipPlugin;
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace InfoSystem
|
|
||||||
{
|
|
||||||
class InfoPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Accounts
|
namespace Accounts
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -100,7 +97,7 @@ public:
|
|||||||
|
|
||||||
virtual QString errorMessage() const { QMutexLocker locker( &m_mutex ); return m_cachedError; }
|
virtual QString errorMessage() const { QMutexLocker locker( &m_mutex ); return m_cachedError; }
|
||||||
|
|
||||||
virtual Tomahawk::InfoSystem::InfoPlugin* infoPlugin() = 0;
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() = 0;
|
||||||
virtual SipPlugin* sipPlugin() = 0;
|
virtual SipPlugin* sipPlugin() = 0;
|
||||||
|
|
||||||
AccountTypes types() const;
|
AccountTypes types() const;
|
||||||
|
@@ -51,14 +51,7 @@ AccountManager::AccountManager( QObject *parent )
|
|||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|
||||||
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ) );
|
QTimer::singleShot( 0, this, SLOT( init() ) );
|
||||||
|
|
||||||
loadPluginFactories( findPluginFactories() );
|
|
||||||
|
|
||||||
// We include the resolver factory manually, not in a plugin
|
|
||||||
ResolverAccountFactory* f = new ResolverAccountFactory();
|
|
||||||
m_accountFactories[ f->factoryId() ] = f;
|
|
||||||
registerAccountFactoryForFilesystem( f );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -72,6 +65,29 @@ AccountManager::~AccountManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::init()
|
||||||
|
{
|
||||||
|
if ( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().isNull() )
|
||||||
|
{
|
||||||
|
//We need the info system worker to be alive so that we can move info plugins into its thread
|
||||||
|
QTimer::singleShot( 0, this, SLOT( init() ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ) );
|
||||||
|
|
||||||
|
loadPluginFactories( findPluginFactories() );
|
||||||
|
|
||||||
|
// We include the resolver factory manually, not in a plugin
|
||||||
|
ResolverAccountFactory* f = new ResolverAccountFactory();
|
||||||
|
m_accountFactories[ f->factoryId() ] = f;
|
||||||
|
registerAccountFactoryForFilesystem( f );
|
||||||
|
|
||||||
|
emit ready();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
AccountManager::findPluginFactories()
|
AccountManager::findPluginFactories()
|
||||||
{
|
{
|
||||||
@@ -180,6 +196,7 @@ AccountManager::loadPluginFactory( const QString& path )
|
|||||||
void
|
void
|
||||||
AccountManager::enableAccount( Account* account )
|
AccountManager::enableAccount( Account* account )
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
if ( account->enabled() )
|
if ( account->enabled() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -195,6 +212,7 @@ AccountManager::enableAccount( Account* account )
|
|||||||
void
|
void
|
||||||
AccountManager::disableAccount( Account* account )
|
AccountManager::disableAccount( Account* account )
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
if ( !account->enabled() )
|
if ( !account->enabled() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -209,6 +227,7 @@ AccountManager::disableAccount( Account* account )
|
|||||||
void
|
void
|
||||||
AccountManager::connectAll()
|
AccountManager::connectAll()
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
foreach( Account* acc, m_accounts )
|
foreach( Account* acc, m_accounts )
|
||||||
{
|
{
|
||||||
acc->authenticate();
|
acc->authenticate();
|
||||||
@@ -222,6 +241,7 @@ AccountManager::connectAll()
|
|||||||
void
|
void
|
||||||
AccountManager::disconnectAll()
|
AccountManager::disconnectAll()
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
foreach( Account* acc, m_enabledAccounts )
|
foreach( Account* acc, m_enabledAccounts )
|
||||||
acc->deauthenticate();
|
acc->deauthenticate();
|
||||||
|
|
||||||
@@ -234,6 +254,7 @@ AccountManager::disconnectAll()
|
|||||||
void
|
void
|
||||||
AccountManager::toggleAccountsConnected()
|
AccountManager::toggleAccountsConnected()
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
if ( m_connected )
|
if ( m_connected )
|
||||||
disconnectAll();
|
disconnectAll();
|
||||||
else
|
else
|
||||||
@@ -367,6 +388,7 @@ AccountManager::hookupAccount( Account* account ) const
|
|||||||
void
|
void
|
||||||
AccountManager::hookupAndEnable( Account* account, bool startup )
|
AccountManager::hookupAndEnable( Account* account, bool startup )
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
SipPlugin* p = account->sipPlugin();
|
SipPlugin* p = account->sipPlugin();
|
||||||
if ( p )
|
if ( p )
|
||||||
SipHandler::instance()->hookUpPlugin( p );
|
SipHandler::instance()->hookUpPlugin( p );
|
||||||
|
@@ -84,6 +84,8 @@ public slots:
|
|||||||
void toggleAccountsConnected();
|
void toggleAccountsConnected();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void ready();
|
||||||
|
|
||||||
void added( Tomahawk::Accounts::Account* );
|
void added( Tomahawk::Accounts::Account* );
|
||||||
void removed( Tomahawk::Accounts::Account* );
|
void removed( Tomahawk::Accounts::Account* );
|
||||||
|
|
||||||
@@ -94,6 +96,7 @@ signals:
|
|||||||
void stateChanged( Account* p, Accounts::Account::ConnectionState state );
|
void stateChanged( Account* p, Accounts::Account::ConnectionState state );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void init();
|
||||||
void onStateChanged( Tomahawk::Accounts::Account::ConnectionState state );
|
void onStateChanged( Tomahawk::Accounts::Account::ConnectionState state );
|
||||||
void onError( int code, const QString& msg );
|
void onError( int code, const QString& msg );
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@ public:
|
|||||||
// Not relevant
|
// Not relevant
|
||||||
virtual QPixmap icon() const { return QPixmap(); }
|
virtual QPixmap icon() const { return QPixmap(); }
|
||||||
virtual SipPlugin* sipPlugin() { return 0; }
|
virtual SipPlugin* sipPlugin() { return 0; }
|
||||||
virtual Tomahawk::InfoSystem::InfoPlugin* infoPlugin() { return 0; }
|
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
||||||
virtual QWidget* aclWidget() { return 0; }
|
virtual QWidget* aclWidget() { return 0; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@@ -328,6 +328,7 @@ AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ty
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_detail::Closure* closure = NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type );
|
_detail::Closure* closure = NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type );
|
||||||
|
Q_UNUSED( closure );
|
||||||
m_currentTrack->album()->cover( QSize( 0, 0 ) );
|
m_currentTrack->album()->cover( QSize( 0, 0 ) );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -210,22 +210,56 @@ InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input, const Pus
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoSystem::addInfoPlugin( InfoPlugin* plugin )
|
InfoSystem::addInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin )
|
||||||
{
|
{
|
||||||
// Init is not complete (waiting for worker thread to start and create worker object) so keep trying till then
|
// Init is not complete (waiting for worker thread to start and create worker object) so keep trying till then
|
||||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod( this, "addInfoPlugin", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoPlugin*, plugin ) );
|
QMetaObject::invokeMethod( this, "addInfoPlugin", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoPluginPtr, plugin ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( plugin->thread() != m_infoSystemWorkerThreadController->worker()->thread() )
|
if ( plugin.isNull() )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "Given plugin is null!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( plugin.data()->thread() != m_infoSystemWorkerThreadController->worker()->thread() )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "The object must be moved to the worker thread first, see InfoSystem::workerThread()";
|
tDebug() << Q_FUNC_INFO << "The object must be moved to the worker thread first, see InfoSystem::workerThread()";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "addInfoPlugin", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoPlugin*, plugin ) );
|
tDebug() << Q_FUNC_INFO << plugin.data();
|
||||||
|
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "addInfoPlugin", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoPluginPtr, plugin ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InfoSystem::removeInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin )
|
||||||
|
{
|
||||||
|
// Init is not complete (waiting for worker th read to start and create worker object) so keep trying till then
|
||||||
|
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod( this, "removeInfoPlugin", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoPluginPtr, plugin ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( plugin.isNull() )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "Given plugin is null!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( plugin.data()->thread() != m_infoSystemWorkerThreadController->worker()->thread() )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "The object must be moved to the worker thread first, see InfoSystem::workerThread()";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tDebug() << Q_FUNC_INFO << plugin.data();
|
||||||
|
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "removeInfoPlugin", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoPluginPtr, plugin ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -286,7 +286,8 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// InfoSystem takes ownership of InfoPlugins
|
// InfoSystem takes ownership of InfoPlugins
|
||||||
void addInfoPlugin( Tomahawk::InfoSystem::InfoPlugin* plugin );
|
void addInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin );
|
||||||
|
void removeInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
@@ -309,7 +310,6 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline uint qHash( Tomahawk::InfoSystem::InfoStringHash hash )
|
inline uint qHash( Tomahawk::InfoSystem::InfoStringHash hash )
|
||||||
{
|
{
|
||||||
QCryptographicHash md5( QCryptographicHash::Md5 );
|
QCryptographicHash md5( QCryptographicHash::Md5 );
|
||||||
@@ -331,6 +331,7 @@ inline uint qHash( Tomahawk::InfoSystem::InfoStringHash hash )
|
|||||||
return returnval;
|
return returnval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoRequestData );
|
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoRequestData );
|
||||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoPushData );
|
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoPushData );
|
||||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoStringHash );
|
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoStringHash );
|
||||||
@@ -339,6 +340,7 @@ Q_DECLARE_METATYPE( Tomahawk::InfoSystem::PushInfoFlags );
|
|||||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoType );
|
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoType );
|
||||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoSystemCache* );
|
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoSystemCache* );
|
||||||
Q_DECLARE_METATYPE( QList< Tomahawk::InfoSystem::InfoStringHash > );
|
Q_DECLARE_METATYPE( QList< Tomahawk::InfoSystem::InfoStringHash > );
|
||||||
|
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoPluginPtr );
|
||||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoPlugin* );
|
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoPlugin* );
|
||||||
|
|
||||||
#endif // TOMAHAWK_INFOSYSTEM_H
|
#endif // TOMAHAWK_INFOSYSTEM_H
|
||||||
|
@@ -82,44 +82,51 @@ InfoSystemWorker::init( Tomahawk::InfoSystem::InfoSystemCache* cache )
|
|||||||
m_shortLinksWaiting = 0;
|
m_shortLinksWaiting = 0;
|
||||||
m_cache = cache;
|
m_cache = cache;
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
addInfoPlugin( new EchoNestPlugin() );
|
addInfoPlugin( InfoPluginPtr( new EchoNestPlugin() ) );
|
||||||
addInfoPlugin( new MusixMatchPlugin() );
|
addInfoPlugin( InfoPluginPtr( new MusixMatchPlugin() ) );
|
||||||
addInfoPlugin( new MusicBrainzPlugin() );
|
addInfoPlugin( InfoPluginPtr( new MusicBrainzPlugin() ) );
|
||||||
addInfoPlugin( new ChartsPlugin() );
|
addInfoPlugin( InfoPluginPtr( new ChartsPlugin() ) );
|
||||||
addInfoPlugin( new RoviPlugin() );
|
addInfoPlugin( InfoPluginPtr( new RoviPlugin() ) );
|
||||||
addInfoPlugin( new SpotifyPlugin() );
|
addInfoPlugin( InfoPluginPtr( new SpotifyPlugin() ) );
|
||||||
addInfoPlugin( new hypemPlugin() );
|
addInfoPlugin( InfoPluginPtr( new hypemPlugin() ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
addInfoPlugin( new AdiumPlugin() );
|
addInfoPlugin( InfoPluginPtr( new AdiumPlugin() ) );
|
||||||
#endif
|
#endif
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
addInfoPlugin( new FdoNotifyPlugin() );
|
addInfoPlugin( InfoPluginPtr( new FdoNotifyPlugin() ) );
|
||||||
addInfoPlugin( new MprisPlugin() );
|
addInfoPlugin( InfoPluginPtr( new MprisPlugin() ) );
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoSystemWorker::addInfoPlugin( InfoPlugin* plugin )
|
InfoSystemWorker::addInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << plugin;
|
tDebug() << Q_FUNC_INFO << plugin;
|
||||||
foreach ( InfoPluginPtr ptr, m_plugins )
|
foreach ( InfoPluginPtr ptr, m_plugins )
|
||||||
{
|
{
|
||||||
if ( ptr.data() == plugin )
|
if ( ptr == plugin )
|
||||||
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "This plugin is already added to the infosystem.";
|
tDebug() << Q_FUNC_INFO << "This plugin is already added to the infosystem.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
InfoPluginPtr weakptr( plugin );
|
if ( plugin.isNull() )
|
||||||
m_plugins.append( weakptr );
|
{
|
||||||
registerInfoTypes( weakptr, weakptr.data()->supportedGetTypes(), weakptr.data()->supportedPushTypes() );
|
tDebug() << Q_FUNC_INFO << "passed-in plugin is null";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_plugins.append( plugin );
|
||||||
|
registerInfoTypes( plugin, plugin.data()->supportedGetTypes(), plugin.data()->supportedPushTypes() );
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
plugin,
|
plugin.data(),
|
||||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
this,
|
this,
|
||||||
SLOT( infoSlot( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
SLOT( infoSlot( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
@@ -127,14 +134,14 @@ InfoSystemWorker::addInfoPlugin( InfoPlugin* plugin )
|
|||||||
);
|
);
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
plugin,
|
plugin.data(),
|
||||||
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) ),
|
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) ),
|
||||||
m_cache,
|
m_cache,
|
||||||
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) ),
|
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) ),
|
||||||
Qt::QueuedConnection
|
Qt::QueuedConnection
|
||||||
);
|
);
|
||||||
connect(
|
connect(
|
||||||
plugin,
|
plugin.data(),
|
||||||
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
||||||
m_cache,
|
m_cache,
|
||||||
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
||||||
@@ -143,6 +150,32 @@ InfoSystemWorker::addInfoPlugin( InfoPlugin* plugin )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InfoSystemWorker::removeInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << plugin;
|
||||||
|
|
||||||
|
if ( plugin.isNull() )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "passed-in plugin is null";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( InfoPluginPtr ptr, m_plugins )
|
||||||
|
{
|
||||||
|
if ( ptr == plugin )
|
||||||
|
break;
|
||||||
|
|
||||||
|
tDebug() << Q_FUNC_INFO << "This plugin does not exist in the infosystem.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_plugins.removeOne( plugin );
|
||||||
|
deregisterInfoTypes( plugin, plugin.data()->supportedGetTypes(), plugin.data()->supportedPushTypes() );
|
||||||
|
delete plugin.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoSystemWorker::registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType >& getTypes, const QSet< InfoType >& pushTypes )
|
InfoSystemWorker::registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType >& getTypes, const QSet< InfoType >& pushTypes )
|
||||||
{
|
{
|
||||||
@@ -153,6 +186,16 @@ InfoSystemWorker::registerInfoTypes( const InfoPluginPtr &plugin, const QSet< In
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InfoSystemWorker::deregisterInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType >& getTypes, const QSet< InfoType >& pushTypes )
|
||||||
|
{
|
||||||
|
Q_FOREACH( InfoType type, getTypes )
|
||||||
|
m_infoGetMap[type].removeOne( plugin );
|
||||||
|
Q_FOREACH( InfoType type, pushTypes )
|
||||||
|
m_infoPushMap[type].removeOne( plugin );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList< InfoPluginPtr >
|
QList< InfoPluginPtr >
|
||||||
InfoSystemWorker::determineOrderedMatches( const InfoType type ) const
|
InfoSystemWorker::determineOrderedMatches( const InfoType type ) const
|
||||||
{
|
{
|
||||||
@@ -242,6 +285,8 @@ InfoSystemWorker::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tDebug() << Q_FUNC_INFO << "number of matching plugins: " << m_infoPushMap[ pushData.type ].size();
|
||||||
|
|
||||||
Q_FOREACH( InfoPluginPtr ptr, m_infoPushMap[ pushData.type ] )
|
Q_FOREACH( InfoPluginPtr ptr, m_infoPushMap[ pushData.type ] )
|
||||||
{
|
{
|
||||||
if( ptr )
|
if( ptr )
|
||||||
|
@@ -49,8 +49,6 @@ public:
|
|||||||
InfoSystemWorker();
|
InfoSystemWorker();
|
||||||
~InfoSystemWorker();
|
~InfoSystemWorker();
|
||||||
|
|
||||||
void registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &getTypes, const QSet< InfoType > &pushTypes );
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
void finished( QString target );
|
void finished( QString target );
|
||||||
@@ -64,7 +62,8 @@ public slots:
|
|||||||
|
|
||||||
void infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
|
|
||||||
void addInfoPlugin( Tomahawk::InfoSystem::InfoPlugin* plugin );
|
void addInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin );
|
||||||
|
void removeInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin );
|
||||||
|
|
||||||
void getShortUrl( Tomahawk::InfoSystem::InfoPushData data );
|
void getShortUrl( Tomahawk::InfoSystem::InfoPushData data );
|
||||||
void shortLinkReady( QUrl longUrl, QUrl shortUrl, QVariant callbackObj );
|
void shortLinkReady( QUrl longUrl, QUrl shortUrl, QVariant callbackObj );
|
||||||
@@ -73,6 +72,8 @@ private slots:
|
|||||||
void checkTimeoutsTimerFired();
|
void checkTimeoutsTimerFired();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &getTypes, const QSet< InfoType > &pushTypes );
|
||||||
|
void deregisterInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &getTypes, const QSet< InfoType > &pushTypes );
|
||||||
|
|
||||||
void checkFinished( const Tomahawk::InfoSystem::InfoRequestData &target );
|
void checkFinished( const Tomahawk::InfoSystem::InfoRequestData &target );
|
||||||
QList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
|
QList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
|
||||||
|
@@ -174,7 +174,6 @@ MusicScanner::scan()
|
|||||||
SLOT( commitBatch( QVariantList, QVariantList ) ), Qt::DirectConnection );
|
SLOT( commitBatch( QVariantList, QVariantList ) ), Qt::DirectConnection );
|
||||||
|
|
||||||
m_dirListerThreadController = new QThread( this );
|
m_dirListerThreadController = new QThread( this );
|
||||||
m_dirListerThreadController->setPriority( QThread::IdlePriority );
|
|
||||||
|
|
||||||
m_dirLister = QWeakPointer< DirLister >( new DirLister( m_dirs ) );
|
m_dirLister = QWeakPointer< DirLister >( new DirLister( m_dirs ) );
|
||||||
m_dirLister.data()->moveToThread( m_dirListerThreadController );
|
m_dirLister.data()->moveToThread( m_dirListerThreadController );
|
||||||
@@ -186,7 +185,7 @@ MusicScanner::scan()
|
|||||||
connect( m_dirLister.data(), SIGNAL( finished() ),
|
connect( m_dirLister.data(), SIGNAL( finished() ),
|
||||||
SLOT( listerFinished() ), Qt::QueuedConnection );
|
SLOT( listerFinished() ), Qt::QueuedConnection );
|
||||||
|
|
||||||
m_dirListerThreadController->start();
|
m_dirListerThreadController->start( QThread::IdlePriority );
|
||||||
QMetaObject::invokeMethod( m_dirLister.data(), "go" );
|
QMetaObject::invokeMethod( m_dirLister.data(), "go" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -196,7 +196,6 @@ ScanManager::runDirScan()
|
|||||||
{
|
{
|
||||||
m_scanTimer->stop();
|
m_scanTimer->stop();
|
||||||
m_musicScannerThreadController = new QThread( this );
|
m_musicScannerThreadController = new QThread( this );
|
||||||
m_musicScannerThreadController->setPriority( QThread::IdlePriority );
|
|
||||||
m_scanner = QWeakPointer< MusicScanner >( new MusicScanner( paths ) );
|
m_scanner = QWeakPointer< MusicScanner >( new MusicScanner( paths ) );
|
||||||
m_scanner.data()->moveToThread( m_musicScannerThreadController );
|
m_scanner.data()->moveToThread( m_musicScannerThreadController );
|
||||||
connect( m_scanner.data(), SIGNAL( finished() ), SLOT( scannerFinished() ) );
|
connect( m_scanner.data(), SIGNAL( finished() ), SLOT( scannerFinished() ) );
|
||||||
|
@@ -35,6 +35,8 @@
|
|||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "infosystem/infosystem.h"
|
#include "infosystem/infosystem.h"
|
||||||
#include "accounts/AccountManager.h"
|
#include "accounts/AccountManager.h"
|
||||||
|
#include "accounts/spotify/SpotifyAccount.h"
|
||||||
|
#include "accounts/lastfm/LastFmAccount.h"
|
||||||
#include "database/database.h"
|
#include "database/database.h"
|
||||||
#include "database/databasecollection.h"
|
#include "database/databasecollection.h"
|
||||||
#include "database/databasecommand_collectionstats.h"
|
#include "database/databasecommand_collectionstats.h"
|
||||||
@@ -60,8 +62,6 @@
|
|||||||
#include "utils/jspfloader.h"
|
#include "utils/jspfloader.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "utils/tomahawkutilsgui.h"
|
#include "utils/tomahawkutilsgui.h"
|
||||||
#include "accounts/lastfm/LastFmAccount.h"
|
|
||||||
#include "accounts/spotify/SpotifyAccount.h"
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
@@ -227,15 +227,7 @@ TomahawkApp::init()
|
|||||||
|
|
||||||
tDebug() << "Init AccountManager.";
|
tDebug() << "Init AccountManager.";
|
||||||
m_accountManager = QWeakPointer< Tomahawk::Accounts::AccountManager >( new Tomahawk::Accounts::AccountManager( this ) );
|
m_accountManager = QWeakPointer< Tomahawk::Accounts::AccountManager >( new Tomahawk::Accounts::AccountManager( this ) );
|
||||||
|
connect( m_accountManager.data(), SIGNAL( ready() ), SLOT( accountManagerReady() ) );
|
||||||
Tomahawk::Accounts::LastFmAccountFactory* lastfmFactory = new Tomahawk::Accounts::LastFmAccountFactory();
|
|
||||||
m_accountManager.data()->addAccountFactory( lastfmFactory );
|
|
||||||
|
|
||||||
Tomahawk::Accounts::SpotifyAccountFactory* spotifyFactory = new Tomahawk::Accounts::SpotifyAccountFactory;
|
|
||||||
m_accountManager.data()->addAccountFactory( spotifyFactory );
|
|
||||||
m_accountManager.data()->registerAccountFactoryForFilesystem( spotifyFactory );
|
|
||||||
|
|
||||||
Tomahawk::Accounts::AccountManager::instance()->loadFromConfig();
|
|
||||||
|
|
||||||
Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() );
|
Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() );
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
@@ -447,6 +439,7 @@ TomahawkApp::registerMetaTypes()
|
|||||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
|
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
|
||||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoPushData >( "Tomahawk::InfoSystem::InfoPushData" );
|
qRegisterMetaType< Tomahawk::InfoSystem::InfoPushData >( "Tomahawk::InfoSystem::InfoPushData" );
|
||||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
|
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
|
||||||
|
qRegisterMetaType< Tomahawk::InfoSystem::InfoPluginPtr >( "Tomahawk::InfoSystem::InfoPluginPtr" );
|
||||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoPlugin* >( "Tomahawk::InfoSystem::InfoPlugin*" );
|
qRegisterMetaType< Tomahawk::InfoSystem::InfoPlugin* >( "Tomahawk::InfoSystem::InfoPlugin*" );
|
||||||
qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
||||||
|
|
||||||
@@ -598,6 +591,20 @@ TomahawkApp::spotifyApiCheckFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkApp::accountManagerReady()
|
||||||
|
{
|
||||||
|
Tomahawk::Accounts::LastFmAccountFactory* lastfmFactory = new Tomahawk::Accounts::LastFmAccountFactory();
|
||||||
|
m_accountManager.data()->addAccountFactory( lastfmFactory );
|
||||||
|
|
||||||
|
Tomahawk::Accounts::SpotifyAccountFactory* spotifyFactory = new Tomahawk::Accounts::SpotifyAccountFactory;
|
||||||
|
m_accountManager.data()->addAccountFactory( spotifyFactory );
|
||||||
|
m_accountManager.data()->registerAccountFactoryForFilesystem( spotifyFactory );
|
||||||
|
|
||||||
|
Tomahawk::Accounts::AccountManager::instance()->loadFromConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkApp::activate()
|
TomahawkApp::activate()
|
||||||
{
|
{
|
||||||
|
@@ -111,6 +111,7 @@ private slots:
|
|||||||
void initHTTP();
|
void initHTTP();
|
||||||
|
|
||||||
void spotifyApiCheckFinished();
|
void spotifyApiCheckFinished();
|
||||||
|
void accountManagerReady();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void registerMetaTypes();
|
void registerMetaTypes();
|
||||||
|
Reference in New Issue
Block a user