1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 07:36:48 +02:00

Add requestId tracking to InfoSystem in preparation for timeouts

This commit is contained in:
Jeff Mitchell
2011-07-06 12:16:44 -04:00
parent ce7040d1fd
commit 5d0c734187
14 changed files with 245 additions and 193 deletions

View File

@@ -66,37 +66,37 @@ EchoNestPlugin::namChangedSlot( QNetworkAccessManager *nam )
} }
void void
EchoNestPlugin::getInfo(const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData) EchoNestPlugin::getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
switch (type) switch ( type )
{ {
case Tomahawk::InfoSystem::InfoArtistBiography: case Tomahawk::InfoSystem::InfoArtistBiography:
return getArtistBiography(caller, input, customData); return getArtistBiography( requestId, caller, input, customData );
case Tomahawk::InfoSystem::InfoArtistFamiliarity: case Tomahawk::InfoSystem::InfoArtistFamiliarity:
return getArtistFamiliarity(caller, input, customData); return getArtistFamiliarity( requestId, caller, input, customData );
case Tomahawk::InfoSystem::InfoArtistHotttness: case Tomahawk::InfoSystem::InfoArtistHotttness:
return getArtistHotttnesss(caller, input, customData); return getArtistHotttnesss( requestId, caller, input, customData );
case Tomahawk::InfoSystem::InfoArtistTerms: case Tomahawk::InfoSystem::InfoArtistTerms:
return getArtistTerms(caller, input, customData); return getArtistTerms( requestId, caller, input, customData );
case Tomahawk::InfoSystem::InfoTrackEnergy: case Tomahawk::InfoSystem::InfoTrackEnergy:
return getSongProfile(caller, input, customData, "energy"); return getSongProfile( requestId, caller, input, customData, "energy" );
case Tomahawk::InfoSystem::InfoMiscTopTerms: case Tomahawk::InfoSystem::InfoMiscTopTerms:
return getMiscTopTerms(caller, input, customData); return getMiscTopTerms( requestId, caller, input, customData );
default: default:
{ {
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
return; return;
} }
} }
} }
void void
EchoNestPlugin::getSongProfile(const QString &caller, const QVariant &input, const QVariantMap &customData, const QString &item) EchoNestPlugin::getSongProfile( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData, const QString &item )
{ {
//WARNING: Totally not implemented yet //WARNING: Totally not implemented yet
Q_UNUSED( item ); Q_UNUSED( item );
if( !isValidTrackData( caller, input, customData ) ) if( !isValidTrackData( requestId, caller, input, customData ) )
return; return;
// Track track( input.toString() ); // Track track( input.toString() );
@@ -108,9 +108,9 @@ EchoNestPlugin::getSongProfile(const QString &caller, const QVariant &input, con
} }
void void
EchoNestPlugin::getArtistBiography(const QString &caller, const QVariant &input, const QVariantMap &customData) EchoNestPlugin::getArtistBiography( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
{ {
if( !isValidArtistData( caller, input, customData ) ) if( !isValidArtistData( requestId, caller, input, customData ) )
return; return;
Echonest::Artist artist( input.toString() ); Echonest::Artist artist( input.toString() );
@@ -119,62 +119,67 @@ EchoNestPlugin::getArtistBiography(const QString &caller, const QVariant &input,
reply->setProperty( "input", input ); reply->setProperty( "input", input );
reply->setProperty( "customData", customData ); reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot())); reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( getArtistBiographySlot() ) );
} }
void void
EchoNestPlugin::getArtistFamiliarity(const QString &caller, const QVariant &input, const QVariantMap &customData) EchoNestPlugin::getArtistFamiliarity( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
{ {
if( !isValidArtistData( caller, input, customData ) ) if( !isValidArtistData( requestId, caller, input, customData ) )
return; return;
qDebug() << "Fetching artist familiarity!" << input; qDebug() << "Fetching artist familiarity!" << input;
Echonest::Artist artist( input.toString() ); Echonest::Artist artist( input.toString() );
QNetworkReply* reply = artist.fetchFamiliarity(); QNetworkReply* reply = artist.fetchFamiliarity();
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist)); reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
reply->setProperty( "input", input ); reply->setProperty( "input", input );
reply->setProperty( "customData", customData ); reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
connect(reply, SIGNAL(finished()), SLOT(getArtistFamiliaritySlot())); reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( getArtistFamiliaritySlot() ) );
} }
void void
EchoNestPlugin::getArtistHotttnesss(const QString &caller, const QVariant &input, const QVariantMap &customData) EchoNestPlugin::getArtistHotttnesss( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
{ {
if( !isValidArtistData( caller, input, customData ) ) if( !isValidArtistData( requestId, caller, input, customData ) )
return; return;
Echonest::Artist artist( input.toString() ); Echonest::Artist artist( input.toString() );
QNetworkReply* reply = artist.fetchHotttnesss(); QNetworkReply* reply = artist.fetchHotttnesss();
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist)); reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
reply->setProperty( "input", input ); reply->setProperty( "input", input );
reply->setProperty( "customData", customData ); reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
connect(reply, SIGNAL(finished()), SLOT(getArtistHotttnesssSlot())); reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( getArtistHotttnesssSlot() ) );
} }
void void
EchoNestPlugin::getArtistTerms(const QString &caller, const QVariant &input, const QVariantMap &customData) EchoNestPlugin::getArtistTerms( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
{ {
if( !isValidArtistData( caller, input, customData ) ) if( !isValidArtistData( requestId, caller, input, customData ) )
return; return;
Echonest::Artist artist( input.toString() ); Echonest::Artist artist( input.toString() );
QNetworkReply* reply = artist.fetchTerms( Echonest::Artist::Weight ); QNetworkReply* reply = artist.fetchTerms( Echonest::Artist::Weight );
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist)); reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
reply->setProperty( "input", input ); reply->setProperty( "input", input );
reply->setProperty( "customData", customData ); reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
connect(reply, SIGNAL( finished() ), SLOT( getArtistTermsSlot() ) ); reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( getArtistTermsSlot() ) );
} }
void void
EchoNestPlugin::getMiscTopTerms(const QString &caller, const QVariant &input, const QVariantMap& customData) EchoNestPlugin::getMiscTopTerms( uint requestId, const QString &caller, const QVariant &input, const QVariantMap& customData )
{ {
Q_UNUSED( input ); Q_UNUSED( input );
QNetworkReply* reply = Echonest::Artist::topTerms( 20 ); QNetworkReply* reply = Echonest::Artist::topTerms( 20 );
reply->setProperty( "customData", customData ); reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( getMiscTopSlot() ) ); connect( reply, SIGNAL( finished() ), SLOT( getMiscTopSlot() ) );
} }
@@ -196,7 +201,8 @@ EchoNestPlugin::getArtistBiographySlot()
biographyMap[biography.site()]["attribution"] = biography.license().url.toString(); biographyMap[biography.site()]["attribution"] = biography.license().url.toString();
} }
emit info( reply->property( "caller" ).toString(), emit info( reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoArtistBiography, Tomahawk::InfoSystem::InfoArtistBiography,
reply->property( "input" ), reply->property( "input" ),
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( biographyMap ), QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( biographyMap ),
@@ -210,7 +216,8 @@ EchoNestPlugin::getArtistFamiliaritySlot()
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() ); QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
Echonest::Artist artist = artistFromReply( reply ); Echonest::Artist artist = artistFromReply( reply );
qreal familiarity = artist.familiarity(); qreal familiarity = artist.familiarity();
emit info( reply->property( "caller" ).toString(), emit info( reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoArtistFamiliarity, Tomahawk::InfoSystem::InfoArtistFamiliarity,
reply->property( "input" ), reply->property( "input" ),
familiarity, familiarity,
@@ -224,7 +231,8 @@ EchoNestPlugin::getArtistHotttnesssSlot()
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() ); QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
Echonest::Artist artist = artistFromReply( reply ); Echonest::Artist artist = artistFromReply( reply );
qreal hotttnesss = artist.hotttnesss(); qreal hotttnesss = artist.hotttnesss();
emit info( reply->property( "caller" ).toString(), emit info( reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoArtistHotttness, Tomahawk::InfoSystem::InfoArtistHotttness,
reply->property( "input" ), reply->property( "input" ),
hotttnesss, hotttnesss,
@@ -245,7 +253,8 @@ EchoNestPlugin::getArtistTermsSlot()
termMap[ "frequency" ] = QString::number(term.frequency()); termMap[ "frequency" ] = QString::number(term.frequency());
termsMap[ term.name() ] = termMap; termsMap[ term.name() ] = termMap;
} }
emit info( reply->property( "caller" ).toString(), emit info( reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoArtistTerms, Tomahawk::InfoSystem::InfoArtistTerms,
reply->property( "input" ), reply->property( "input" ),
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ), QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ),
@@ -265,7 +274,8 @@ EchoNestPlugin::getMiscTopSlot()
termMap[ "frequency" ] = QString::number( term.frequency() ); termMap[ "frequency" ] = QString::number( term.frequency() );
termsMap[ term.name().toLower() ] = termMap; termsMap[ term.name().toLower() ] = termMap;
} }
emit info( reply->property( "caller" ).toString(), emit info( reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoMiscTopTerms, Tomahawk::InfoSystem::InfoMiscTopTerms,
QVariant(), QVariant(),
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ), QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ),
@@ -274,50 +284,53 @@ EchoNestPlugin::getMiscTopSlot()
} }
bool bool
EchoNestPlugin::isValidArtistData(const QString &caller, const QVariant &input, const QVariantMap &customData) EchoNestPlugin::isValidArtistData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
{ {
if (input.isNull() || !input.isValid() || !input.canConvert<QString>()) if ( input.isNull() || !input.isValid() || !input.canConvert< QString >() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
return false; return false;
} }
QString artistName = input.toString(); QString artistName = input.toString();
if (artistName.isEmpty() ) if ( artistName.isEmpty() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
return false; return false;
} }
return true; return true;
} }
bool bool
EchoNestPlugin::isValidTrackData(const QString &caller, const QVariant &input, const QVariantMap &customData) EchoNestPlugin::isValidTrackData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
{ {
if (input.isNull() || !input.isValid() || !input.canConvert<QString>()) if ( input.isNull() || !input.isValid() || !input.canConvert< QString >() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
return false; return false;
} }
QString trackName = input.toString(); QString trackName = input.toString();
if (trackName.isEmpty() ) if ( trackName.isEmpty() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
return false; return false;
} }
if (!customData.contains("artistName") || if ( !customData.contains( "artistName" ) || customData[ "artistName" ].toString().isEmpty() )
customData["artistName"].toString().isEmpty()) {
emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
return false; return false;
}
return true; return true;
} }
Artist Artist
EchoNestPlugin::artistFromReply(QNetworkReply* reply) EchoNestPlugin::artistFromReply( QNetworkReply* reply )
{ {
Echonest::Artist artist = reply->property("artist").value<Echonest::Artist>(); Echonest::Artist artist = reply->property("artist").value<Echonest::Artist>();
try { try {
artist.parseProfile(reply); artist.parseProfile( reply );
} catch( const Echonest::ParseError& e ) { } catch( const Echonest::ParseError& e ) {
qWarning() << "Caught parser error from echonest!" << e.what(); qWarning() << "Caught parser error from echonest!" << e.what();
} }
return artist; return artist;
} }
//

View File

@@ -44,7 +44,7 @@ public:
virtual ~EchoNestPlugin(); virtual ~EchoNestPlugin();
protected slots: protected slots:
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ); virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData );
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data ) virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data )
{ {
@@ -53,8 +53,9 @@ protected slots:
Q_UNUSED( data ); Q_UNUSED( data );
} }
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
Q_UNUSED( requestId );
Q_UNUSED( criteria ); Q_UNUSED( criteria );
Q_UNUSED( caller ); Q_UNUSED( caller );
Q_UNUSED( type ); Q_UNUSED( type );
@@ -66,15 +67,15 @@ public slots:
void namChangedSlot( QNetworkAccessManager *nam ); void namChangedSlot( QNetworkAccessManager *nam );
private: private:
void getSongProfile( const QString &caller, const QVariant &input, const QVariantMap &customData, const QString &item = QString() ); void getSongProfile( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData, const QString &item = QString() );
void getArtistBiography ( const QString &caller, const QVariant &input, const QVariantMap &customData ); void getArtistBiography ( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData );
void getArtistFamiliarity( const QString &caller, const QVariant &input, const QVariantMap &customData ); void getArtistFamiliarity( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData );
void getArtistHotttnesss( const QString &caller, const QVariant &input, const QVariantMap &customData ); void getArtistHotttnesss( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData );
void getArtistTerms( const QString &caller, const QVariant &input, const QVariantMap &customData ); void getArtistTerms( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData );
void getMiscTopTerms( const QString &caller, const QVariant &input, const QVariantMap &customData ); void getMiscTopTerms( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData );
bool isValidArtistData( const QString &caller, const QVariant &input, const QVariantMap& customData ); bool isValidArtistData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap& customData );
bool isValidTrackData( const QString &caller, const QVariant &input, const QVariantMap& customData ); bool isValidTrackData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap& customData );
Echonest::Artist artistFromReply( QNetworkReply* ); Echonest::Artist artistFromReply( QNetworkReply* );
private slots: private slots:

View File

@@ -120,38 +120,38 @@ LastFmPlugin::namChangedSlot( QNetworkAccessManager *nam )
void void
LastFmPlugin::dataError( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData ) LastFmPlugin::dataError( uint requestId, const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData )
{ {
emit info( caller, type, input, QVariant(), customData ); emit info( requestId, caller, type, input, QVariant(), customData );
return; return;
} }
void void
LastFmPlugin::getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) LastFmPlugin::getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
switch ( type ) switch ( type )
{ {
case InfoArtistImages: case InfoArtistImages:
fetchArtistImages( caller, type, input, customData ); fetchArtistImages( requestId, caller, type, input, customData );
break; break;
case InfoAlbumCoverArt: case InfoAlbumCoverArt:
fetchCoverArt( caller, type, input, customData ); fetchCoverArt( requestId, caller, type, input, customData );
break; break;
case InfoArtistSimilars: case InfoArtistSimilars:
fetchSimilarArtists( caller, type, input, customData ); fetchSimilarArtists( requestId, caller, type, input, customData );
break; break;
case InfoArtistSongs: case InfoArtistSongs:
fetchTopTracks( caller, type, input, customData ); fetchTopTracks( requestId, caller, type, input, customData );
break; break;
default: default:
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
} }
} }
@@ -263,64 +263,64 @@ LastFmPlugin::sendLoveSong( const InfoType type, QVariant input )
void void
LastFmPlugin::fetchSimilarArtists( const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData ) LastFmPlugin::fetchSimilarArtists( uint requestId, const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() ) if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{ {
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
return; return;
} }
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >(); InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
if ( !hash.contains( "artist" ) ) if ( !hash.contains( "artist" ) )
{ {
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
return; return;
} }
Tomahawk::InfoSystem::InfoCriteriaHash criteria; Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = hash["artist"]; criteria["artist"] = hash["artist"];
emit getCachedInfo( criteria, 2419200000, caller, type, input, customData ); emit getCachedInfo( requestId, criteria, 2419200000, caller, type, input, customData );
} }
void void
LastFmPlugin::fetchTopTracks( const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData ) LastFmPlugin::fetchTopTracks( uint requestId, const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() ) if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{ {
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
return; return;
} }
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >(); InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
if ( !hash.contains( "artist" ) ) if ( !hash.contains( "artist" ) )
{ {
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
return; return;
} }
Tomahawk::InfoSystem::InfoCriteriaHash criteria; Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = hash["artist"]; criteria["artist"] = hash["artist"];
emit getCachedInfo( criteria, 2419200000, caller, type, input, customData ); emit getCachedInfo( requestId, criteria, 2419200000, caller, type, input, customData );
} }
void void
LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData ) LastFmPlugin::fetchCoverArt( uint requestId, const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() ) if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{ {
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
return; return;
} }
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >(); InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
if ( !hash.contains( "artist" ) || !hash.contains( "album" ) ) if ( !hash.contains( "artist" ) || !hash.contains( "album" ) )
{ {
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
return; return;
} }
@@ -328,42 +328,42 @@ LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const Q
criteria["artist"] = hash["artist"]; criteria["artist"] = hash["artist"];
criteria["album"] = hash["album"]; criteria["album"] = hash["album"];
emit getCachedInfo( criteria, 2419200000, caller, type, input, customData ); emit getCachedInfo( requestId, criteria, 2419200000, caller, type, input, customData );
} }
void void
LastFmPlugin::fetchArtistImages( const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData ) LastFmPlugin::fetchArtistImages( uint requestId, const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() ) if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{ {
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
return; return;
} }
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >(); InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
if ( !hash.contains( "artist" ) ) if ( !hash.contains( "artist" ) )
{ {
dataError( caller, type, input, customData ); dataError( requestId, caller, type, input, customData );
return; return;
} }
Tomahawk::InfoSystem::InfoCriteriaHash criteria; Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = hash["artist"]; criteria["artist"] = hash["artist"];
emit getCachedInfo( criteria, 2419200000, caller, type, input, customData ); emit getCachedInfo( requestId, criteria, 2419200000, caller, type, input, customData );
} }
void void
LastFmPlugin::notInCacheSlot( const QHash<QString, QString> criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) LastFmPlugin::notInCacheSlot( uint requestId, const QHash<QString, QString> criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if ( !lastfm::nam() ) if ( !lastfm::nam() )
{ {
qDebug() << "Have a null QNAM, uh oh"; qDebug() << "Have a null QNAM, uh oh";
emit info( caller, type, input, QVariant(), customData ); emit info( requestId, caller, type, input, QVariant(), customData );
return; return;
} }
@@ -376,7 +376,8 @@ LastFmPlugin::notInCacheSlot( const QHash<QString, QString> criteria, const QStr
reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) ); reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) );
reply->setProperty( "origData", input ); reply->setProperty( "origData", input );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
reply->setProperty( "type", (uint)(type) ); reply->setProperty( "type", (uint)( type ) );
reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( similarArtistsReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( similarArtistsReturned() ) );
return; return;
@@ -389,7 +390,8 @@ LastFmPlugin::notInCacheSlot( const QHash<QString, QString> criteria, const QStr
reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) ); reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) );
reply->setProperty( "origData", input ); reply->setProperty( "origData", input );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
reply->setProperty( "type", (uint)(type) ); reply->setProperty( "type", (uint)( type ) );
reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( topTracksReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( topTracksReturned() ) );
return; return;
@@ -406,7 +408,8 @@ LastFmPlugin::notInCacheSlot( const QHash<QString, QString> criteria, const QStr
reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) ); reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) );
reply->setProperty( "origData", input ); reply->setProperty( "origData", input );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
reply->setProperty( "type", (uint)(type) ); reply->setProperty( "type", (uint)( type ) );
reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( coverArtReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
return; return;
@@ -422,7 +425,8 @@ LastFmPlugin::notInCacheSlot( const QHash<QString, QString> criteria, const QStr
reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) ); reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) );
reply->setProperty( "origData", input ); reply->setProperty( "origData", input );
reply->setProperty( "caller", caller ); reply->setProperty( "caller", caller );
reply->setProperty( "type", (uint)(type) ); reply->setProperty( "type", (uint)( type ) );
reply->setProperty( "requestId", requestId );
connect( reply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) );
return; return;
@@ -431,7 +435,7 @@ LastFmPlugin::notInCacheSlot( const QHash<QString, QString> criteria, const QStr
default: default:
{ {
qDebug() << "Couldn't figure out what to do with this type of request after cache miss"; qDebug() << "Couldn't figure out what to do with this type of request after cache miss";
emit info( caller, type, input, QVariant(), customData ); emit info( requestId, caller, type, input, QVariant(), customData );
return; return;
} }
} }
@@ -461,6 +465,7 @@ LastFmPlugin::similarArtistsReturned()
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >(); QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
emit info( emit info(
reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(), reply->property( "caller" ).toString(),
type, type,
reply->property( "origData" ), reply->property( "origData" ),
@@ -493,6 +498,7 @@ LastFmPlugin::topTracksReturned()
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >(); QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
emit info( emit info(
reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(), reply->property( "caller" ).toString(),
type, type,
reply->property( "origData" ), reply->property( "origData" ),
@@ -521,7 +527,7 @@ LastFmPlugin::coverArtReturned()
qDebug() << "Uh oh, null byte array"; qDebug() << "Uh oh, null byte array";
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >(); QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData ); emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData );
return; return;
} }
foreach ( const QUrl& url, m_badUrls ) foreach ( const QUrl& url, m_badUrls )
@@ -537,6 +543,7 @@ LastFmPlugin::coverArtReturned()
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >(); QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
emit info( emit info(
reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(), reply->property( "caller" ).toString(),
type, type,
reply->property( "origData" ), reply->property( "origData" ),
@@ -557,7 +564,7 @@ LastFmPlugin::coverArtReturned()
qDebug() << "Uh oh, nam is null"; qDebug() << "Uh oh, nam is null";
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >(); QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData ); emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData );
return; return;
} }
// Follow HTTP redirect // Follow HTTP redirect
@@ -567,6 +574,7 @@ LastFmPlugin::coverArtReturned()
newReply->setProperty( "customData", reply->property( "customData" ) ); newReply->setProperty( "customData", reply->property( "customData" ) );
newReply->setProperty( "caller", reply->property( "caller" ) ); newReply->setProperty( "caller", reply->property( "caller" ) );
newReply->setProperty( "type", reply->property( "type" ) ); newReply->setProperty( "type", reply->property( "type" ) );
newReply->setProperty( "requestId", reply->property( "requestId" ) );
connect( newReply, SIGNAL( finished() ), SLOT( coverArtReturned() ) ); connect( newReply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
} }
@@ -588,7 +596,7 @@ LastFmPlugin::artistImagesReturned()
qDebug() << "Uh oh, null byte array"; qDebug() << "Uh oh, null byte array";
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >(); QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData ); emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData );
return; return;
} }
foreach ( const QUrl& url, m_badUrls ) foreach ( const QUrl& url, m_badUrls )
@@ -602,7 +610,7 @@ LastFmPlugin::artistImagesReturned()
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >(); QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "caller" ).toString(), type, reply->property( "origData" ), returnedData, customData ); emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), returnedData, customData );
InfoCriteriaHash origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCriteriaHash >(); InfoCriteriaHash origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash criteria; Tomahawk::InfoSystem::InfoCriteriaHash criteria;
@@ -616,7 +624,7 @@ LastFmPlugin::artistImagesReturned()
qDebug() << "Uh oh, nam is null"; qDebug() << "Uh oh, nam is null";
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()); InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >(); QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData ); emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData );
return; return;
} }
// Follow HTTP redirect // Follow HTTP redirect
@@ -626,6 +634,7 @@ LastFmPlugin::artistImagesReturned()
newReply->setProperty( "customData", reply->property( "customData" ) ); newReply->setProperty( "customData", reply->property( "customData" ) );
newReply->setProperty( "caller", reply->property( "caller" ) ); newReply->setProperty( "caller", reply->property( "caller" ) );
newReply->setProperty( "type", reply->property( "type" ) ); newReply->setProperty( "type", reply->property( "type" ) );
newReply->setProperty( "requestId", reply->property( "requestId" ) );
connect( newReply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) ); connect( newReply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) );
} }

View File

@@ -55,23 +55,23 @@ public slots:
void namChangedSlot( QNetworkAccessManager *nam ); void namChangedSlot( QNetworkAccessManager *nam );
protected slots: protected slots:
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ); virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData );
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ); virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData );
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data ); virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data );
private: private:
void fetchCoverArt( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData ); void fetchCoverArt( uint requestId, const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData );
void fetchArtistImages( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData ); void fetchArtistImages( uint requestId, const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData );
void fetchSimilarArtists( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData ); void fetchSimilarArtists( uint requestId, const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData );
void fetchTopTracks( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData ); void fetchTopTracks( uint requestId, const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData );
void createScrobbler(); void createScrobbler();
void nowPlaying( const QVariant &input ); void nowPlaying( const QVariant &input );
void scrobble(); void scrobble();
void sendLoveSong( const InfoType type, QVariant input ); void sendLoveSong( const InfoType type, QVariant input );
void dataError( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData ); void dataError( uint requestId, const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData );
lastfm::MutableTrack m_track; lastfm::MutableTrack m_track;
lastfm::Audioscrobbler* m_scrobbler; lastfm::Audioscrobbler* m_scrobbler;

View File

@@ -51,53 +51,54 @@ MusixMatchPlugin::namChangedSlot( QNetworkAccessManager *nam )
} }
void void
MusixMatchPlugin::getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) MusixMatchPlugin::getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if( !isValidTrackData(caller, input, customData) || !input.canConvert<QVariantMap>() || m_nam.isNull() || type != Tomahawk::InfoSystem::InfoTrackLyrics ) if( !isValidTrackData( requestId, caller, input, customData ) || !input.canConvert< QVariantMap >() || m_nam.isNull() || type != Tomahawk::InfoSystem::InfoTrackLyrics )
return; return;
QVariantMap hash = input.value<QVariantMap>(); QVariantMap hash = input.value< QVariantMap >();
QString artist = hash["artistName"].toString(); QString artist = hash["artistName"].toString();
QString track = hash["trackName"].toString(); QString track = hash["trackName"].toString();
if( artist.isEmpty() || track.isEmpty() ) if( artist.isEmpty() || track.isEmpty() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData );
return; return;
} }
qDebug() << "artist is " << artist << ", track is " << track; qDebug() << "artist is " << artist << ", track is " << track;
QString requestString("http://api.musixmatch.com/ws/1.1/track.search?format=xml&page_size=1&f_has_lyrics=1"); QString requestString( "http://api.musixmatch.com/ws/1.1/track.search?format=xml&page_size=1&f_has_lyrics=1" );
QUrl url(requestString); QUrl url( requestString );
url.addQueryItem("apikey", m_apiKey); url.addQueryItem( "apikey", m_apiKey );
url.addQueryItem("q_artist", artist); url.addQueryItem( "q_artist", artist );
url.addQueryItem("q_track", track); url.addQueryItem( "q_track", track );
QNetworkReply* reply = m_nam.data()->get(QNetworkRequest(url)); QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) );
reply->setProperty("customData", QVariant::fromValue<QVariantMap>(customData)); reply->setProperty( "customData", QVariant::fromValue< QVariantMap >( customData ) );
reply->setProperty("origData", input); reply->setProperty( "origData", input );
reply->setProperty("caller", caller); reply->setProperty( "caller", caller );
reply->setProperty( "requestId", requestId );
connect(reply, SIGNAL(finished()), SLOT(trackSearchSlot())); connect( reply, SIGNAL( finished() ), SLOT( trackSearchSlot() ) );
} }
bool bool
MusixMatchPlugin::isValidTrackData( const QString &caller, const QVariant &input, const QVariantMap &customData ) MusixMatchPlugin::isValidTrackData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if (input.isNull() || !input.isValid() || !input.canConvert<QVariantMap>()) if ( input.isNull() || !input.isValid() || !input.canConvert< QVariantMap >() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData );
qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert"; qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert";
return false; return false;
} }
QVariantMap hash = input.value<QVariantMap>(); QVariantMap hash = input.value< QVariantMap >();
if (hash["trackName"].toString().isEmpty() ) if ( hash["trackName"].toString().isEmpty() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData );
qDebug() << "MusixMatchPlugin::isValidTrackData: Track name is empty"; qDebug() << "MusixMatchPlugin::isValidTrackData: Track name is empty";
return false; return false;
} }
if (hash["artistName"].toString().isEmpty() ) if ( hash["artistName"].toString().isEmpty() )
{ {
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData); emit info( requestId, caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData );
qDebug() << "MusixMatchPlugin::isValidTrackData: No artist name found"; qDebug() << "MusixMatchPlugin::isValidTrackData: No artist name found";
return false; return false;
} }
@@ -109,9 +110,9 @@ MusixMatchPlugin::trackSearchSlot()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() ); QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
if ( !oldReply || m_nam.isNull() ) if ( !oldReply )
{ {
emit info(QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), QVariantMap()); emit info( 0, QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), QVariantMap() );
return; return;
} }
QDomDocument doc; QDomDocument doc;
@@ -120,40 +121,41 @@ MusixMatchPlugin::trackSearchSlot()
QDomNodeList domNodeList = doc.elementsByTagName("track_id"); QDomNodeList domNodeList = doc.elementsByTagName("track_id");
if (domNodeList.isEmpty()) if (domNodeList.isEmpty())
{ {
emit info(oldReply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, oldReply->property("origData"), QVariant(), oldReply->property("customData").value<QVariantMap>()); emit info( oldReply->property( "requestId" ).toUInt(), oldReply->property( "caller" ).toString(), Tomahawk::InfoSystem::InfoTrackLyrics, oldReply->property( "origData" ), QVariant(), oldReply->property( "customData" ).value< QVariantMap >() );
return; return;
} }
QString track_id = domNodeList.at(0).toElement().text(); QString track_id = domNodeList.at(0).toElement().text();
QString requestString("http://api.musixmatch.com/ws/1.1/track.lyrics.get?track_id=%1&format=xml&apikey=%2"); QString requestString( "http://api.musixmatch.com/ws/1.1/track.lyrics.get?track_id=%1&format=xml&apikey=%2" );
QUrl url(requestString); QUrl url( requestString );
url.addQueryItem("apikey", m_apiKey); url.addQueryItem( "apikey", m_apiKey );
url.addQueryItem("track_id", track_id); url.addQueryItem( "track_id", track_id );
QNetworkReply* newReply = m_nam.data()->get(QNetworkRequest(url)); QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) );
newReply->setProperty("origData", oldReply->property("origData")); newReply->setProperty( "origData", oldReply->property( "origData" ) );
newReply->setProperty("customData", oldReply->property("customData")); newReply->setProperty( "customData", oldReply->property( "customData" ) );
newReply->setProperty("caller", oldReply->property("caller")); newReply->setProperty( "caller", oldReply->property( "caller" ) );
connect(newReply, SIGNAL(finished()), SLOT(trackLyricsSlot())); newReply->setProperty( "requestId", oldReply->property( "requestId" ) );
connect( newReply, SIGNAL( finished() ), SLOT( trackLyricsSlot() ) );
} }
void void
MusixMatchPlugin::trackLyricsSlot() MusixMatchPlugin::trackLyricsSlot()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() ); QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
if (!reply) if ( !reply )
{ {
emit info(QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), QVariantMap()); emit info( 0, QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), QVariantMap() );
return; return;
} }
QDomDocument doc; QDomDocument doc;
doc.setContent(reply->readAll()); doc.setContent( reply->readAll() );
QDomNodeList domNodeList = doc.elementsByTagName("lyrics_body"); QDomNodeList domNodeList = doc.elementsByTagName( "lyrics_body" );
if (domNodeList.isEmpty()) if ( domNodeList.isEmpty() )
{ {
emit info(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property("origData"), QVariant(), reply->property("customData").value<QVariantMap>()); emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property( "origData" ), QVariant(), reply->property( "customData" ).value< QVariantMap >() );
return; return;
} }
QString lyrics = domNodeList.at(0).toElement().text(); QString lyrics = domNodeList.at(0).toElement().text();
qDebug() << "Emitting lyrics: " << lyrics; qDebug() << "Emitting lyrics: " << lyrics;
emit info(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property("origData"), QVariant(lyrics), reply->property("customData").value<QVariantMap>()); emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property( "origData" ), QVariant( lyrics ), reply->property( "customData" ).value<QVariantMap>() );
} }

View File

@@ -45,7 +45,7 @@ public slots:
void namChangedSlot( QNetworkAccessManager *nam ); void namChangedSlot( QNetworkAccessManager *nam );
protected slots: protected slots:
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ); virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData );
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data ) virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data )
{ {
@@ -54,8 +54,9 @@ protected slots:
Q_UNUSED( data ); Q_UNUSED( data );
} }
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
Q_UNUSED( requestId );
Q_UNUSED( criteria ); Q_UNUSED( criteria );
Q_UNUSED( caller ); Q_UNUSED( caller );
Q_UNUSED( type ); Q_UNUSED( type );
@@ -64,7 +65,7 @@ protected slots:
} }
private: private:
bool isValidTrackData( const QString &caller, const QVariant &input, const QVariantMap &customData ); bool isValidTrackData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData );
QString m_apiKey; QString m_apiKey;

View File

@@ -39,12 +39,29 @@ public:
virtual ~AdiumPlugin(); virtual ~AdiumPlugin();
protected slots: protected slots:
void getInfo( const QString caller, const InfoType type, const QVariant data, QVariantMap customData ); virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{
Q_UNUSED( requestId );
Q_UNUSED( caller );
Q_UNUSED( type );
Q_UNUSED( input );
Q_UNUSED( customData );
}
void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input ); void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input );
public slots: public slots:
void namChangedSlot( QNetworkAccessManager* /*nam*/ ) {} // unused void namChangedSlot( QNetworkAccessManager* /*nam*/ ) {} // unused
void notInCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash /*criteria*/, const QString /*caller*/, const Tomahawk::InfoSystem::InfoType /*type*/, const QVariant /*input*/, const QVariantMap /*customData*/ ) {} // unused
virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{
Q_UNUSED( requestId );
Q_UNUSED( criteria );
Q_UNUSED( caller );
Q_UNUSED( type );
Q_UNUSED( input );
Q_UNUSED( customData );
}
private slots: private slots:
void clearStatus(); void clearStatus();

View File

@@ -38,8 +38,9 @@ public:
virtual void namChangedSlot( QNetworkAccessManager* ) {} virtual void namChangedSlot( QNetworkAccessManager* ) {}
protected slots: protected slots:
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
Q_UNUSED( requestId );
Q_UNUSED( caller ); Q_UNUSED( caller );
Q_UNUSED( type ); Q_UNUSED( type );
Q_UNUSED( input ); Q_UNUSED( input );
@@ -48,8 +49,9 @@ protected slots:
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant pushData ); virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant pushData );
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
Q_UNUSED( requestId );
Q_UNUSED( criteria ); Q_UNUSED( criteria );
Q_UNUSED( caller ); Q_UNUSED( caller );
Q_UNUSED( type ); Q_UNUSED( type );

View File

@@ -52,6 +52,9 @@ InfoSystem::instance()
InfoSystem::InfoSystem(QObject *parent) InfoSystem::InfoSystem(QObject *parent)
: QObject(parent) : QObject(parent)
, m_infoSystemCacheThreadController( 0 )
, m_infoSystemWorkerThreadController( 0 )
, m_nextRequest( 0 )
{ {
s_instance = this; s_instance = this;
@@ -71,11 +74,11 @@ InfoSystem::InfoSystem(QObject *parent)
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( newNam() ) ); connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( newNam() ) );
connect( m_cache.data(), SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), connect( m_cache.data(), SIGNAL( info( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
this, SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), Qt::UniqueConnection ); this, SLOT( infoSlot( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), Qt::UniqueConnection );
connect( m_worker.data(), SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), connect( m_worker.data(), SIGNAL( info( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
this, SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), Qt::UniqueConnection ); this, SLOT( infoSlot( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), Qt::UniqueConnection );
} }
InfoSystem::~InfoSystem() InfoSystem::~InfoSystem()
@@ -120,9 +123,11 @@ InfoSystem::getInfo( const QString &caller, const InfoType type, const QVariant&
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
uint requestnum = ++m_nextRequest;
qDebug() << "assigning request with requestId " << requestnum;
m_dataTracker[caller][type] = m_dataTracker[caller][type] + 1; m_dataTracker[caller][type] = m_dataTracker[caller][type] + 1;
qDebug() << "current count in dataTracker for type" << type << "is" << m_dataTracker[caller][type]; qDebug() << "current count in dataTracker for type" << type << "is" << m_dataTracker[caller][type];
QMetaObject::invokeMethod( m_worker.data(), "getInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ), Q_ARG( QVariantMap, customData ) ); QMetaObject::invokeMethod( m_worker.data(), "getInfo", Qt::QueuedConnection, Q_ARG( uint, requestnum ), Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ), Q_ARG( QVariantMap, customData ) );
} }
@@ -147,34 +152,34 @@ void
InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input ) InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input )
{ {
Q_FOREACH( InfoType type, input.keys() ) Q_FOREACH( InfoType type, input.keys() )
pushInfo( caller, type, input[type] ); pushInfo( caller, type, input[ type ] );
} }
void void
InfoSystem::infoSlot( QString target, InfoType type, QVariant input, QVariant output, QVariantMap customData ) InfoSystem::infoSlot( uint requestId, QString target, InfoType type, QVariant input, QVariant output, QVariantMap customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO << " with requestId " << requestId;
qDebug() << "current count in dataTracker is " << m_dataTracker[target][type]; qDebug() << "current count in dataTracker for target " << target << " is " << m_dataTracker[ target ][ type ];
if (m_dataTracker[target][type] == 0) if ( m_dataTracker[ target ][ type ] == 0 )
{ {
qDebug() << "Caller was not waiting for that type of data!"; qDebug() << "Caller was not waiting for that type of data!";
return; return;
} }
emit info(target, type, input, output, customData); emit info( target, type, input, output, customData );
m_dataTracker[target][type] = m_dataTracker[target][type] - 1; m_dataTracker[ target ][ type ] = m_dataTracker[ target ][ type ] - 1;
qDebug() << "current count in dataTracker is " << m_dataTracker[target][type]; qDebug() << "current count in dataTracker for target " << target << " is " << m_dataTracker[ target ][ type ];
Q_FOREACH(InfoType testtype, m_dataTracker[target].keys()) Q_FOREACH( InfoType testtype, m_dataTracker[ target ].keys() )
{ {
if (m_dataTracker[target][testtype] != 0) if ( m_dataTracker[ target ][ testtype ] != 0)
{ {
qDebug() << "found outstanding request of type" << testtype; qDebug() << "found outstanding request of type" << testtype;
return; return;
} }
} }
qDebug() << "emitting finished with target" << target; qDebug() << "emitting finished with target" << target;
emit finished(target); emit finished( target );
} }
} //namespace InfoSystem } //namespace InfoSystem

View File

@@ -124,15 +124,15 @@ public:
QSet< InfoType > supportedPushTypes() const { return m_supportedPushTypes; } QSet< InfoType > supportedPushTypes() const { return m_supportedPushTypes; }
signals: signals:
void getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariantMap customData ); void getCachedInfo( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariantMap customData );
void info( uint requestId, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
void updateCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64, Tomahawk::InfoSystem::InfoType type, QVariant output ); void updateCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64, Tomahawk::InfoSystem::InfoType type, QVariant output );
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
void finished( QString, Tomahawk::InfoSystem::InfoType );
protected slots: protected slots:
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data, const QVariantMap customData ) = 0; virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data, const QVariantMap customData ) = 0;
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data ) = 0; virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data ) = 0;
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) = 0; virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) = 0;
virtual void namChangedSlot( QNetworkAccessManager *nam ) = 0; virtual void namChangedSlot( QNetworkAccessManager *nam ) = 0;
@@ -167,7 +167,7 @@ signals:
void finished( QString target ); void finished( QString target );
public slots: public slots:
void infoSlot( const QString target, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariant output, const QVariantMap customData ); void infoSlot( uint requestId, const QString target, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariant output, const QVariantMap customData );
void newNam() const; void newNam() const;
@@ -179,6 +179,8 @@ private:
QThread* m_infoSystemCacheThreadController; QThread* m_infoSystemCacheThreadController;
QThread* m_infoSystemWorkerThreadController; QThread* m_infoSystemWorkerThreadController;
uint m_nextRequest;
static InfoSystem* s_instance; static InfoSystem* s_instance;
}; };

View File

@@ -84,7 +84,7 @@ InfoSystemCache::pruneTimerFired()
void void
InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 newMaxAge, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ) InfoSystemCache::getCachedInfoSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 newMaxAge, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
const QString criteriaHashVal = criteriaMd5( criteria ); const QString criteriaHashVal = criteriaMd5( criteria );
@@ -94,7 +94,7 @@ InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash
if ( !fileLocationHash.isEmpty() ) if ( !fileLocationHash.isEmpty() )
{ {
//We already know of some values, so no need to re-read the directory again as it's already happened //We already know of some values, so no need to re-read the directory again as it's already happened
emit notInCache( criteria, caller, type, input, customData ); emit notInCache( requestId, criteria, caller, type, input, customData );
return; return;
} }
@@ -103,7 +103,7 @@ InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash
if ( !dir.exists() ) if ( !dir.exists() )
{ {
//Dir doesn't exist so clearly not in cache //Dir doesn't exist so clearly not in cache
emit notInCache( criteria, caller, type, input, customData ); emit notInCache( requestId, criteria, caller, type, input, customData );
return; return;
} }
@@ -119,7 +119,7 @@ InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash
if ( !fileLocationHash.contains( criteriaHashVal ) ) if ( !fileLocationHash.contains( criteriaHashVal ) )
{ {
//Still didn't fine it? It's really not in the cache then //Still didn't fine it? It's really not in the cache then
emit notInCache( criteria, caller, type, input, customData ); emit notInCache( requestId, criteria, caller, type, input, customData );
return; return;
} }
} }
@@ -138,7 +138,7 @@ InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash
m_fileLocationCache[type] = fileLocationHash; m_fileLocationCache[type] = fileLocationHash;
m_dataCache.remove( criteriaHashVal ); m_dataCache.remove( criteriaHashVal );
emit notInCache( criteria, caller, type, input, customData ); emit notInCache( requestId, criteria, caller, type, input, customData );
return; return;
} }
else if ( newMaxAge > 0 ) else if ( newMaxAge > 0 )
@@ -148,7 +148,7 @@ InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash
if ( !QFile::rename( file.canonicalFilePath(), newFilePath ) ) if ( !QFile::rename( file.canonicalFilePath(), newFilePath ) )
{ {
qDebug() << "Failed to move old cache file to new location!"; qDebug() << "Failed to move old cache file to new location!";
emit notInCache( criteria, caller, type, input, customData ); emit notInCache( requestId, criteria, caller, type, input, customData );
return; return;
} }
@@ -162,11 +162,11 @@ InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash
QVariant output = cachedSettings.value( "data" ); QVariant output = cachedSettings.value( "data" );
m_dataCache.insert( criteriaHashVal, new QVariant( output ) ); m_dataCache.insert( criteriaHashVal, new QVariant( output ) );
emit info( caller, type, input, output, customData ); emit info( requestId, caller, type, input, output, customData );
} }
else else
{ {
emit info( caller, type, input, QVariant( *(m_dataCache[criteriaHashVal]) ), customData ); emit info( requestId, caller, type, input, QVariant( *(m_dataCache[criteriaHashVal]) ), customData );
} }
} }

View File

@@ -43,11 +43,11 @@ public:
virtual ~InfoSystemCache(); virtual ~InfoSystemCache();
signals: signals:
void notInCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariantMap customData ); void notInCache( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariantMap customData );
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData ); void info( uint requestId, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
public slots: public slots:
void getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 newMaxAge, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ); void getCachedInfoSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 newMaxAge, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData );
void updateCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 maxAge, const Tomahawk::InfoSystem::InfoType type, const QVariant output ); void updateCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 maxAge, const Tomahawk::InfoSystem::InfoType type, const QVariant output );
private slots: private slots:

View File

@@ -87,23 +87,23 @@ InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cac
{ {
connect( connect(
plugin.data(), plugin.data(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), SIGNAL( info( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
InfoSystem::instance(), InfoSystem::instance(),
SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), SLOT( infoSlot( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
Qt::UniqueConnection Qt::UniqueConnection
); );
connect( connect(
plugin.data(), plugin.data(),
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) ), SIGNAL( getCachedInfo( uint, Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) ),
cache.data(), cache.data(),
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) ) SLOT( getCachedInfoSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) )
); );
connect( connect(
cache.data(), cache.data(),
SIGNAL( notInCache( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) ), SIGNAL( notInCache( uint, Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) ),
plugin.data(), plugin.data(),
SLOT( notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) ) SLOT( notInCacheSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) )
); );
connect( connect(
plugin.data(), plugin.data(),
@@ -147,24 +147,24 @@ InfoSystemWorker::determineOrderedMatches( const InfoType type ) const
void void
InfoSystemWorker::getInfo( QString caller, InfoType type, QVariant input, QVariantMap customData ) InfoSystemWorker::getInfo( uint requestId, QString caller, InfoType type, QVariant input, QVariantMap customData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
QLinkedList< InfoPluginPtr > providers = determineOrderedMatches(type); QLinkedList< InfoPluginPtr > providers = determineOrderedMatches(type);
if ( providers.isEmpty() ) if ( providers.isEmpty() )
{ {
emit info( caller, type, QVariant(), QVariant(), customData ); emit info( requestId, caller, type, QVariant(), QVariant(), customData );
return; return;
} }
InfoPluginPtr ptr = providers.first(); InfoPluginPtr ptr = providers.first();
if ( !ptr ) if ( !ptr )
{ {
emit info( caller, type, QVariant(), QVariant(), customData ); emit info( requestId, caller, type, QVariant(), QVariant(), customData );
return; return;
} }
QMetaObject::invokeMethod( ptr.data(), "getInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ), Q_ARG( QVariantMap, customData ) ); QMetaObject::invokeMethod( ptr.data(), "getInfo", Qt::QueuedConnection, Q_ARG( uint, requestId ), Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ), Q_ARG( QVariantMap, customData ) );
} }

View File

@@ -48,12 +48,12 @@ public:
QNetworkAccessManager* nam() const; QNetworkAccessManager* nam() const;
signals: signals:
void info( QString target, Tomahawk::InfoSystem::InfoType, QVariant input, QVariant output, QVariantMap customData ); void info( uint requestId, QString target, Tomahawk::InfoSystem::InfoType, QVariant input, QVariant output, QVariantMap customData );
void namChanged( QNetworkAccessManager* ); void namChanged( QNetworkAccessManager* );
public slots: public slots:
void init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > cache ); void init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > cache );
void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData ); void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData );
void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input ); void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input );
void newNam(); void newNam();