From 3f3a2798c7421e9fc386c738740bec3127fbdbfb Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 1 May 2011 01:04:48 -0400 Subject: [PATCH] have the worker let any interested plugins know when the nam changes, and have the echonestplugin make use of that to set the appropriate nam for the thread --- src/libtomahawk/infosystem/infoplugins/echonestplugin.cpp | 8 ++++++++ src/libtomahawk/infosystem/infoplugins/echonestplugin.h | 3 +++ src/libtomahawk/infosystem/infosystemworker.cpp | 2 ++ src/libtomahawk/infosystem/infosystemworker.h | 1 + 4 files changed, 14 insertions(+) diff --git a/src/libtomahawk/infosystem/infoplugins/echonestplugin.cpp b/src/libtomahawk/infosystem/infoplugins/echonestplugin.cpp index d2d8f5879..26bb30217 100644 --- a/src/libtomahawk/infosystem/infoplugins/echonestplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/echonestplugin.cpp @@ -33,6 +33,8 @@ EchoNestPlugin::EchoNestPlugin(InfoSystemWorker *parent) QSet< InfoType > supportedTypes; supportedTypes << Tomahawk::InfoSystem::InfoArtistBiography << Tomahawk::InfoSystem::InfoArtistFamiliarity << Tomahawk::InfoSystem::InfoArtistHotttness << Tomahawk::InfoSystem::InfoArtistTerms << Tomahawk::InfoSystem::InfoMiscTopTerms; parent->registerInfoTypes( this, supportedTypes, QSet< InfoType>() ); + + connect( parent, SIGNAL( namChanged() ), SLOT( namChangedSlot() ) ); } EchoNestPlugin::~EchoNestPlugin() @@ -40,6 +42,12 @@ EchoNestPlugin::~EchoNestPlugin() qDebug() << Q_FUNC_INFO; } +void +EchoNestPlugin::namChangedSlot() +{ + Echonest::Config::instance()->setNetworkAccessManager( m_infoSystemWorker->nam() ); +} + void EchoNestPlugin::getInfo(const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData) { diff --git a/src/libtomahawk/infosystem/infoplugins/echonestplugin.h b/src/libtomahawk/infosystem/infoplugins/echonestplugin.h index 7537861e8..d8492e4a0 100644 --- a/src/libtomahawk/infosystem/infoplugins/echonestplugin.h +++ b/src/libtomahawk/infosystem/infoplugins/echonestplugin.h @@ -62,6 +62,9 @@ protected slots: Q_UNUSED( customData ); } +public slots: + void namChangedSlot(); + private: void getSongProfile( const QString &caller, const QVariant &input, const InfoCustomData &customData, const QString &item = QString() ); void getArtistBiography ( const QString &caller, const QVariant &input, const InfoCustomData &customData ); diff --git a/src/libtomahawk/infosystem/infosystemworker.cpp b/src/libtomahawk/infosystem/infosystemworker.cpp index f154169d5..332e95820 100644 --- a/src/libtomahawk/infosystem/infosystemworker.cpp +++ b/src/libtomahawk/infosystem/infosystemworker.cpp @@ -177,6 +177,8 @@ InfoSystemWorker::newNam() newNam->setNetworkAccessible( oldNam->networkAccessible() ); newNam->setProxy( oldNam->proxy() ); m_nam = newNam; + + emit namChanged(); } diff --git a/src/libtomahawk/infosystem/infosystemworker.h b/src/libtomahawk/infosystem/infosystemworker.h index 071a53dac..e42f89a36 100644 --- a/src/libtomahawk/infosystem/infosystemworker.h +++ b/src/libtomahawk/infosystem/infosystemworker.h @@ -49,6 +49,7 @@ public: signals: void info( QString target, Tomahawk::InfoSystem::InfoType, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData ); + void namChanged(); public slots: void init();