diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp index 9491275d0..dd5a910b4 100644 --- a/src/libtomahawk/audio/audioengine.cpp +++ b/src/libtomahawk/audio/audioengine.cpp @@ -147,7 +147,7 @@ AudioEngine::stop() setCurrentTrack( Tomahawk::result_ptr() ); emit stopped(); - Tomahawk::InfoSystem::InfoMap map; + Tomahawk::InfoSystem::InfoTypeMap map; map[ Tomahawk::InfoSystem::InfoNowStopped ] = QVariant(); if ( m_waitingOnNewTrack ) @@ -319,7 +319,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result ) DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack, DatabaseCommand_LogPlayback::Started ); Database::instance()->enqueue( QSharedPointer(cmd) ); - Tomahawk::InfoSystem::InfoMap map; + Tomahawk::InfoSystem::InfoTypeMap map; Tomahawk::InfoSystem::InfoCriteriaHash trackInfo; trackInfo["title"] = m_currentTrack->track(); diff --git a/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp index bca856a2b..7034b565e 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.cpp @@ -63,7 +63,6 @@ EchoNestPlugin::namChangedSlot( QNetworkAccessManager *nam ) newProxyFactory->setNoProxyHosts( oldProxyFactory->noProxyHosts() ); newProxyFactory->setProxy( oldProxyFactory->proxy() ); currNam->setProxyFactory( newProxyFactory ); - m_nam = QWeakPointer< QNetworkAccessManager >( currNam ); } void @@ -116,10 +115,10 @@ EchoNestPlugin::getArtistBiography(const QString &caller, const QVariant &input, Echonest::Artist artist( input.toString() ); QNetworkReply *reply = artist.fetchBiographies(); - reply->setProperty("artist", QVariant::fromValue(artist)); + reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) ); reply->setProperty( "input", input ); - m_replyMap[reply] = customData; - m_callerMap[reply] = caller; + reply->setProperty( "customData", customData ); + reply->setProperty( "caller", caller ); connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot())); } @@ -134,8 +133,8 @@ EchoNestPlugin::getArtistFamiliarity(const QString &caller, const QVariant &inpu QNetworkReply* reply = artist.fetchFamiliarity(); reply->setProperty( "artist", QVariant::fromValue(artist)); reply->setProperty( "input", input ); - m_replyMap[reply] = customData; - m_callerMap[reply] = caller; + reply->setProperty( "customData", customData ); + reply->setProperty( "caller", caller ); connect(reply, SIGNAL(finished()), SLOT(getArtistFamiliaritySlot())); } @@ -149,8 +148,8 @@ EchoNestPlugin::getArtistHotttnesss(const QString &caller, const QVariant &input QNetworkReply* reply = artist.fetchHotttnesss(); reply->setProperty( "artist", QVariant::fromValue(artist)); reply->setProperty( "input", input ); - m_replyMap[reply] = customData; - m_callerMap[reply] = caller; + reply->setProperty( "customData", customData ); + reply->setProperty( "caller", caller ); connect(reply, SIGNAL(finished()), SLOT(getArtistHotttnesssSlot())); } @@ -164,9 +163,9 @@ EchoNestPlugin::getArtistTerms(const QString &caller, const QVariant &input, con QNetworkReply* reply = artist.fetchTerms( Echonest::Artist::Weight ); reply->setProperty( "artist", QVariant::fromValue(artist)); reply->setProperty( "input", input ); - m_replyMap[reply] = customData; - m_callerMap[reply] = caller; - connect(reply, SIGNAL(finished()), SLOT(getArtistTermsSlot())); + reply->setProperty( "customData", customData ); + reply->setProperty( "caller", caller ); + connect(reply, SIGNAL( finished() ), SLOT( getArtistTermsSlot() ) ); } void @@ -174,9 +173,9 @@ EchoNestPlugin::getMiscTopTerms(const QString &caller, const QVariant &input, co { Q_UNUSED( input ); QNetworkReply* reply = Echonest::Artist::topTerms( 20 ); - m_replyMap[reply] = customData; - m_callerMap[reply] = caller; - connect( reply,SIGNAL(finished()), SLOT( getMiscTopSlot())); + reply->setProperty( "customData", customData ); + reply->setProperty( "caller", caller ); + connect( reply, SIGNAL( finished() ), SLOT( getMiscTopSlot() ) ); } @@ -197,9 +196,11 @@ EchoNestPlugin::getArtistBiographySlot() biographyMap[biography.site()]["attribution"] = biography.license().url.toString(); } - emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistBiography, reply->property( "input" ), QVariant::fromValue(biographyMap), m_replyMap[reply] ); - m_replyMap.remove(reply); - m_callerMap.remove(reply); + emit info( reply->property( "caller" ).toString(), + Tomahawk::InfoSystem::InfoArtistBiography, + reply->property( "input" ), + QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( biographyMap ), + reply->property( "customData" ).value< Tomahawk::InfoSystem::InfoCustomData >() ); reply->deleteLater(); } @@ -209,9 +210,11 @@ EchoNestPlugin::getArtistFamiliaritySlot() QNetworkReply* reply = qobject_cast( sender() ); Echonest::Artist artist = artistFromReply( reply ); qreal familiarity = artist.familiarity(); - emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistFamiliarity, reply->property( "input" ), familiarity, m_replyMap[reply] ); - m_replyMap.remove(reply); - m_callerMap.remove(reply); + emit info( reply->property( "caller" ).toString(), + Tomahawk::InfoSystem::InfoArtistFamiliarity, + reply->property( "input" ), + familiarity, + reply->property( "customData" ).value< Tomahawk::InfoSystem::InfoCustomData >() ); reply->deleteLater(); } @@ -221,9 +224,11 @@ EchoNestPlugin::getArtistHotttnesssSlot() QNetworkReply* reply = qobject_cast( sender() ); Echonest::Artist artist = artistFromReply( reply ); qreal hotttnesss = artist.hotttnesss(); - emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistHotttness, reply->property( "input" ), hotttnesss, m_replyMap[reply] ); - m_replyMap.remove(reply); - m_callerMap.remove(reply); + emit info( reply->property( "caller" ).toString(), + Tomahawk::InfoSystem::InfoArtistHotttness, + reply->property( "input" ), + hotttnesss, + reply->property( "customData" ).value< Tomahawk::InfoSystem::InfoCustomData >() ); reply->deleteLater(); } @@ -240,9 +245,11 @@ EchoNestPlugin::getArtistTermsSlot() termMap[ "frequency" ] = QString::number(term.frequency()); termsMap[ term.name() ] = termMap; } - emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistTerms, reply->property( "input" ), QVariant::fromValue(termsMap), m_replyMap[reply] ); - m_replyMap.remove(reply); - m_callerMap.remove(reply); + emit info( reply->property( "caller" ).toString(), + Tomahawk::InfoSystem::InfoArtistTerms, + reply->property( "input" ), + QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ), + reply->property( "customData" ).value< Tomahawk::InfoSystem::InfoCustomData >() ); reply->deleteLater(); } @@ -258,9 +265,11 @@ EchoNestPlugin::getMiscTopSlot() termMap[ "frequency" ] = QString::number( term.frequency() ); termsMap[ term.name().toLower() ] = termMap; } - emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoMiscTopTerms, QVariant(), QVariant::fromValue(termsMap), m_replyMap[reply] ); - m_replyMap.remove(reply); - m_callerMap.remove(reply); + emit info( reply->property( "caller" ).toString(), + Tomahawk::InfoSystem::InfoMiscTopTerms, + QVariant(), + QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ), + reply->property( "customData" ).value< Tomahawk::InfoSystem::InfoCustomData >() ); reply->deleteLater(); } diff --git a/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.h b/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.h index bd21cbca2..e27a306f7 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.h +++ b/src/libtomahawk/infosystem/infoplugins/generic/echonestplugin.h @@ -83,11 +83,6 @@ private slots: void getArtistHotttnesssSlot(); void getArtistTermsSlot(); void getMiscTopSlot(); - -private: - QHash< QNetworkReply*, InfoCustomData > m_replyMap; - QHash< QNetworkReply*, QString > m_callerMap; - QWeakPointer< QNetworkAccessManager > m_nam; }; } diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp index 387becd3b..d26efe385 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp @@ -115,9 +115,6 @@ LastFmPlugin::namChangedSlot( QNetworkAccessManager *nam ) currNam->setProxyFactory( newProxyFactory ); //FIXME: on Mac/Win as liblastfm's network access manager also sets its overriding application proxy //may have to do a QNetworkProxy::setApplicationProxy and clobber our own factory to override it - - m_nam = QWeakPointer< QNetworkAccessManager >( currNam ); - settingsChanged(); // to get the scrobbler set up } @@ -309,7 +306,7 @@ LastFmPlugin::notInCacheSlot( const QHash criteria, const QStr { qDebug() << Q_FUNC_INFO; - if ( m_nam.isNull() ) + if ( !lastfm::nam() ) { qDebug() << "Have a null QNAM, uh oh"; emit info( caller, type, input, QVariant(), customData ); @@ -325,7 +322,7 @@ LastFmPlugin::notInCacheSlot( const QHash criteria, const QStr QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=album.imageredirect&artist=%1&album=%2&autocorrect=1&size=large&api_key=7a90f6672a04b809ee309af169f34b8b"; QNetworkRequest req( imgurl.arg( artistName ).arg( albumName ) ); - QNetworkReply* reply = m_nam.data()->get( req ); + QNetworkReply* reply = lastfm::nam()->get( req ); reply->setProperty( "customData", QVariant::fromValue( customData ) ); reply->setProperty( "origData", input ); reply->setProperty( "caller", caller ); @@ -341,7 +338,7 @@ LastFmPlugin::notInCacheSlot( const QHash criteria, const QStr QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=artist.imageredirect&artist=%1&autocorrect=1&size=medium&api_key=7a90f6672a04b809ee309af169f34b8b"; QNetworkRequest req( imgurl.arg( artistName ) ); - QNetworkReply* reply = m_nam.data()->get( req ); + QNetworkReply* reply = lastfm::nam()->get( req ); reply->setProperty( "customData", QVariant::fromValue( customData ) ); reply->setProperty( "origData", input ); reply->setProperty( "caller", caller ); @@ -406,7 +403,7 @@ LastFmPlugin::coverArtReturned() } else { - if ( m_nam.isNull() ) + if ( !lastfm::nam() ) { qDebug() << "Uh oh, nam is null"; InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); @@ -416,7 +413,7 @@ LastFmPlugin::coverArtReturned() } // Follow HTTP redirect QNetworkRequest req( redir ); - QNetworkReply* newReply = m_nam.data()->get( req ); + QNetworkReply* newReply = lastfm::nam()->get( req ); newReply->setProperty( "origData", reply->property( "origData" ) ); newReply->setProperty( "customData", reply->property( "customData" ) ); newReply->setProperty( "caller", reply->property( "caller" ) ); @@ -465,7 +462,7 @@ LastFmPlugin::artistImagesReturned() } else { - if ( m_nam.isNull() ) + if ( !lastfm::nam() ) { qDebug() << "Uh oh, nam is null"; InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); @@ -475,7 +472,7 @@ LastFmPlugin::artistImagesReturned() } // Follow HTTP redirect QNetworkRequest req( redir ); - QNetworkReply* newReply = m_nam.data()->get( req ); + QNetworkReply* newReply = lastfm::nam()->get( req ); newReply->setProperty( "origData", reply->property( "origData" ) ); newReply->setProperty( "customData", reply->property( "customData" ) ); newReply->setProperty( "caller", reply->property( "caller" ) ); diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h index 597082638..e2b470770 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h +++ b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h @@ -74,8 +74,6 @@ private: QString m_pw; QList< QUrl > m_badUrls; - - QWeakPointer< QNetworkAccessManager > m_nam; }; } diff --git a/src/libtomahawk/infosystem/infosystem.cpp b/src/libtomahawk/infosystem/infosystem.cpp index 611533ade..4fe9af12f 100644 --- a/src/libtomahawk/infosystem/infosystem.cpp +++ b/src/libtomahawk/infosystem/infosystem.cpp @@ -127,7 +127,7 @@ InfoSystem::getInfo( const QString &caller, const InfoType type, const QVariant& void -InfoSystem::getInfo( const QString &caller, const InfoMap &input, InfoCustomData customData ) +InfoSystem::getInfo( const QString &caller, const InfoTypeMap &input, InfoCustomData customData ) { Q_FOREACH( InfoType type, input.keys() ) getInfo( caller, type, input[type], customData ); @@ -144,7 +144,7 @@ InfoSystem::pushInfo( const QString &caller, const InfoType type, const QVariant void -InfoSystem::pushInfo( const QString &caller, const InfoMap &input ) +InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input ) { Q_FOREACH( InfoType type, input.keys() ) pushInfo( caller, type, input[type] ); diff --git a/src/libtomahawk/infosystem/infosystem.h b/src/libtomahawk/infosystem/infosystem.h index 0dea90be1..2a3c873d8 100644 --- a/src/libtomahawk/infosystem/infosystem.h +++ b/src/libtomahawk/infosystem/infosystem.h @@ -107,7 +107,7 @@ enum InfoType { // as items are saved in cache, mark them here to not change the InfoNotifyUser = 55 }; -typedef QMap< InfoType, QVariant > InfoMap; +typedef QMap< InfoType, QVariant > InfoTypeMap; typedef QMap< QString, QMap< QString, QString > > InfoGenericMap; typedef QHash< QString, QVariant > InfoCustomData; typedef QHash< QString, QString > InfoCriteriaHash; @@ -159,9 +159,9 @@ public: ~InfoSystem(); void getInfo( const QString &caller, const InfoType type, const QVariant &input, InfoCustomData customData ); - void getInfo( const QString &caller, const InfoMap &input, InfoCustomData customData ); + void getInfo( const QString &caller, const InfoTypeMap &input, InfoCustomData customData ); void pushInfo( const QString &caller, const InfoType type, const QVariant &input ); - void pushInfo( const QString &caller, const InfoMap &input ); + void pushInfo( const QString &caller, const InfoTypeMap &input ); signals: void info( QString caller, Tomahawk::InfoSystem::InfoType, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData ); diff --git a/src/xmppbot/xmppbot.cpp b/src/xmppbot/xmppbot.cpp index 404d64fd2..01ebe5509 100644 --- a/src/xmppbot/xmppbot.cpp +++ b/src/xmppbot/xmppbot.cpp @@ -201,7 +201,7 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session) return; } - InfoMap infoMap; + InfoTypeMap infoMap; Q_FOREACH(QString token, tokens) { if (token == "biography") diff --git a/src/xmppbot/xmppbot.h b/src/xmppbot/xmppbot.h index e22a564ae..20b504118 100644 --- a/src/xmppbot/xmppbot.h +++ b/src/xmppbot/xmppbot.h @@ -87,7 +87,7 @@ private slots: private: QWeakPointer m_client; Tomahawk::result_ptr m_currTrack; - Tomahawk::InfoSystem::InfoMap m_currInfoMap; + Tomahawk::InfoSystem::InfoTypeMap m_currInfoMap; QString m_currReturnMessage; QString m_currReturnJid; };