mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Merge branch 'master' of github.com:tomahawk-player/tomahawk
This commit is contained in:
commit
e9fa2259a7
File diff suppressed because it is too large
Load Diff
@ -64,28 +64,28 @@ RoviPlugin::namChangedSlot( QNetworkAccessManager* nam )
|
||||
|
||||
|
||||
void
|
||||
RoviPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
RoviPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
if ( !hash.contains( "artist" ) || !hash.contains( "album" ) )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria["album"] = hash["album"];
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
|
||||
emit getCachedInfo( criteria, 2419200000, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
RoviPlugin::notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
RoviPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
switch ( requestData.type )
|
||||
{
|
||||
@ -96,7 +96,6 @@ RoviPlugin::notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash
|
||||
|
||||
QNetworkReply* reply = makeRequest( baseUrl );
|
||||
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
connect( reply, SIGNAL( finished() ), this, SLOT( albumLookupFinished() ) );
|
||||
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( albumLookupError( QNetworkReply::NetworkError ) ) );
|
||||
@ -120,9 +119,8 @@ RoviPlugin::albumLookupError( QNetworkReply::NetworkError error )
|
||||
Q_ASSERT( reply );
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
int requestId = reply->property( "requestId" ).toUInt();
|
||||
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
|
||||
}
|
||||
|
||||
@ -136,7 +134,6 @@ RoviPlugin::albumLookupFinished()
|
||||
return;
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
int requestId = reply->property( "requestId" ).toUInt();
|
||||
|
||||
QJson::Parser p;
|
||||
bool ok;
|
||||
@ -145,7 +142,7 @@ RoviPlugin::albumLookupFinished()
|
||||
if ( !ok || result.isEmpty() || !result.contains( "tracks" ) )
|
||||
{
|
||||
tLog() << "Error parsing JSON from Rovi!" << p.errorString() << result;
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
}
|
||||
|
||||
QVariantList tracks = result[ "tracks" ].toList();
|
||||
@ -160,7 +157,7 @@ RoviPlugin::albumLookupFinished()
|
||||
QVariantMap returnedData;
|
||||
returnedData["tracks"] = trackNameList;
|
||||
|
||||
emit info( requestId, requestData, returnedData );
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria["artist"] = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>()["artist"];
|
||||
|
@ -40,12 +40,12 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void namChangedSlot( QNetworkAccessManager* nam );
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant )
|
||||
{}
|
||||
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
private slots:
|
||||
void albumLookupFinished();
|
||||
|
@ -93,15 +93,15 @@ ChartsPlugin::namChangedSlot( QNetworkAccessManager *nam )
|
||||
|
||||
|
||||
void
|
||||
ChartsPlugin::dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
ChartsPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChartsPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
ChartsPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << requestData.caller;
|
||||
qDebug() << Q_FUNC_INFO << requestData.customData;
|
||||
@ -116,7 +116,7 @@ ChartsPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData req
|
||||
/// We need something to check if the request is actually ment to go to this plugin
|
||||
if ( !hash.contains( "chart_source" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -131,19 +131,19 @@ ChartsPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData req
|
||||
|
||||
if( !foundSource )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
fetchChart( requestId, requestData );
|
||||
fetchChart( requestData );
|
||||
break;
|
||||
|
||||
case InfoChartCapabilities:
|
||||
fetchChartCapabilities( requestId, requestData );
|
||||
fetchChartCapabilities( requestData );
|
||||
break;
|
||||
default:
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,12 +158,12 @@ ChartsPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoTy
|
||||
|
||||
|
||||
void
|
||||
ChartsPlugin::fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
ChartsPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ ChartsPlugin::fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData
|
||||
/// Each request needs to contain both a id and source
|
||||
if ( !hash.contains( "chart_id" ) && !hash.contains( "chart_source" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
|
||||
}
|
||||
@ -181,29 +181,29 @@ ChartsPlugin::fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData
|
||||
criteria["chart_id"] = hash["chart_id"];
|
||||
criteria["chart_source"] = hash["chart_source"];
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 0, requestData );
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
ChartsPlugin::fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
ChartsPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
emit getCachedInfo( requestId, criteria, 0, requestData );
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
ChartsPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !m_nam.data() )
|
||||
{
|
||||
tLog() << "Have a null QNAM, uh oh";
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -217,7 +217,6 @@ ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
|
||||
|
||||
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
|
||||
@ -230,22 +229,18 @@ ChartsPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
if ( m_chartsFetchJobs > 0 )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "InfoChartCapabilities still fetching!";
|
||||
m_cachedRequests.append( QPair< uint, InfoRequestData >( requestId, requestData ) );
|
||||
m_cachedRequests.append( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
emit info(
|
||||
requestId,
|
||||
requestData,
|
||||
m_allChartsMap
|
||||
);
|
||||
emit info( requestData, m_allChartsMap );
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Couldn't figure out what to do with this type of request after cache miss";
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -408,10 +403,9 @@ ChartsPlugin::chartTypes()
|
||||
m_chartsFetchJobs--;
|
||||
if ( !m_cachedRequests.isEmpty() && m_chartsFetchJobs == 0 )
|
||||
{
|
||||
QPair< uint, InfoRequestData > request;
|
||||
foreach ( request, m_cachedRequests )
|
||||
foreach ( InfoRequestData request, m_cachedRequests )
|
||||
{
|
||||
emit info( request.first, request.second, m_allChartsMap );
|
||||
emit info( request, m_allChartsMap );
|
||||
}
|
||||
m_cachedRequests.clear();
|
||||
}
|
||||
@ -526,11 +520,7 @@ ChartsPlugin::chartReturned()
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
|
||||
emit info(
|
||||
reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
returnedData
|
||||
);
|
||||
emit info( requestData, returnedData );
|
||||
// TODO update cache
|
||||
}
|
||||
else
|
||||
|
@ -56,15 +56,15 @@ public slots:
|
||||
void namChangedSlot( QNetworkAccessManager *nam );
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data );
|
||||
|
||||
private:
|
||||
void fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void dataError( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
QVariantList m_chartResources;
|
||||
QList<InfoStringHash> m_charts;
|
||||
@ -73,7 +73,7 @@ private:
|
||||
QVariantMap m_allChartsMap;
|
||||
|
||||
uint m_chartsFetchJobs;
|
||||
QList< QPair< uint, InfoRequestData > > m_cachedRequests;
|
||||
QList< InfoRequestData > m_cachedRequests;
|
||||
|
||||
QHash< QString, QString > m_cachedCountries;
|
||||
|
||||
|
@ -68,37 +68,37 @@ EchoNestPlugin::namChangedSlot( QNetworkAccessManager *nam )
|
||||
}
|
||||
|
||||
void
|
||||
EchoNestPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
EchoNestPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
switch ( requestData.type )
|
||||
{
|
||||
case Tomahawk::InfoSystem::InfoArtistBiography:
|
||||
return getArtistBiography( requestId, requestData );
|
||||
return getArtistBiography( requestData );
|
||||
case Tomahawk::InfoSystem::InfoArtistFamiliarity:
|
||||
return getArtistFamiliarity( requestId, requestData );
|
||||
return getArtistFamiliarity( requestData );
|
||||
case Tomahawk::InfoSystem::InfoArtistHotttness:
|
||||
return getArtistHotttnesss( requestId, requestData );
|
||||
return getArtistHotttnesss( requestData );
|
||||
case Tomahawk::InfoSystem::InfoArtistTerms:
|
||||
return getArtistTerms( requestId, requestData );
|
||||
return getArtistTerms( requestData );
|
||||
case Tomahawk::InfoSystem::InfoTrackEnergy:
|
||||
return getSongProfile( requestId, requestData, "energy" );
|
||||
return getSongProfile( requestData, "energy" );
|
||||
case Tomahawk::InfoSystem::InfoMiscTopTerms:
|
||||
return getMiscTopTerms( requestId, requestData );
|
||||
return getMiscTopTerms( requestData );
|
||||
default:
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EchoNestPlugin::getSongProfile( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item )
|
||||
EchoNestPlugin::getSongProfile( const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item )
|
||||
{
|
||||
//WARNING: Totally not implemented yet
|
||||
Q_UNUSED( item );
|
||||
|
||||
if( !isValidTrackData( requestId, requestData ) )
|
||||
if( !isValidTrackData( requestData ) )
|
||||
return;
|
||||
|
||||
// Track track( input.toString() );
|
||||
@ -110,67 +110,62 @@ EchoNestPlugin::getSongProfile( uint requestId, const Tomahawk::InfoSystem::Info
|
||||
}
|
||||
|
||||
void
|
||||
EchoNestPlugin::getArtistBiography( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
EchoNestPlugin::getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
{
|
||||
if( !isValidArtistData( requestId, requestData ) )
|
||||
if( !isValidArtistData( requestData ) )
|
||||
return;
|
||||
|
||||
Echonest::Artist artist( requestData.input.toString() );
|
||||
QNetworkReply *reply = artist.fetchBiographies();
|
||||
reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
connect( reply, SIGNAL( finished() ), SLOT( getArtistBiographySlot() ) );
|
||||
}
|
||||
|
||||
void
|
||||
EchoNestPlugin::getArtistFamiliarity( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
EchoNestPlugin::getArtistFamiliarity( const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
{
|
||||
if( !isValidArtistData( requestId, requestData ) )
|
||||
if( !isValidArtistData( requestData ) )
|
||||
return;
|
||||
|
||||
qDebug() << "Fetching artist familiarity!" << requestData.input;
|
||||
Echonest::Artist artist( requestData.input.toString() );
|
||||
QNetworkReply* reply = artist.fetchFamiliarity();
|
||||
reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
connect( reply, SIGNAL( finished() ), SLOT( getArtistFamiliaritySlot() ) );
|
||||
}
|
||||
|
||||
void
|
||||
EchoNestPlugin::getArtistHotttnesss( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
EchoNestPlugin::getArtistHotttnesss( const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
{
|
||||
if( !isValidArtistData( requestId, requestData ) )
|
||||
if( !isValidArtistData( requestData ) )
|
||||
return;
|
||||
|
||||
Echonest::Artist artist( requestData.input.toString() );
|
||||
QNetworkReply* reply = artist.fetchHotttnesss();
|
||||
reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
connect( reply, SIGNAL( finished() ), SLOT( getArtistHotttnesssSlot() ) );
|
||||
}
|
||||
|
||||
void
|
||||
EchoNestPlugin::getArtistTerms( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
EchoNestPlugin::getArtistTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
{
|
||||
if( !isValidArtistData( requestId, requestData ) )
|
||||
if( !isValidArtistData( requestData ) )
|
||||
return;
|
||||
|
||||
Echonest::Artist artist( requestData.input.toString() );
|
||||
QNetworkReply* reply = artist.fetchTerms( Echonest::Artist::Weight );
|
||||
reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
connect( reply, SIGNAL( finished() ), SLOT( getArtistTermsSlot() ) );
|
||||
}
|
||||
|
||||
void
|
||||
EchoNestPlugin::getMiscTopTerms( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
EchoNestPlugin::getMiscTopTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
{
|
||||
QNetworkReply* reply = Echonest::Artist::topTerms( 20 );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
connect( reply, SIGNAL( finished() ), SLOT( getMiscTopSlot() ) );
|
||||
}
|
||||
@ -195,9 +190,7 @@ EchoNestPlugin::getArtistBiographySlot()
|
||||
biographyMap[ biography.site() ] = siteData;
|
||||
}
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
emit info( reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
biographyMap );
|
||||
emit info( requestData, biographyMap );
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
@ -208,9 +201,7 @@ EchoNestPlugin::getArtistFamiliaritySlot()
|
||||
Echonest::Artist artist = artistFromReply( reply );
|
||||
qreal familiarity = artist.familiarity();
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
emit info( reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
familiarity );
|
||||
emit info( requestData, familiarity );
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
@ -221,9 +212,7 @@ EchoNestPlugin::getArtistHotttnesssSlot()
|
||||
Echonest::Artist artist = artistFromReply( reply );
|
||||
qreal hotttnesss = artist.hotttnesss();
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
emit info( reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
hotttnesss );
|
||||
emit info( requestData, hotttnesss );
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
@ -241,9 +230,7 @@ EchoNestPlugin::getArtistTermsSlot()
|
||||
termsMap[ term.name() ] = termHash;
|
||||
}
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
emit info( reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
termsMap );
|
||||
emit info( requestData, termsMap );
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
@ -260,46 +247,44 @@ EchoNestPlugin::getMiscTopSlot()
|
||||
termsMap[ term.name() ] = termHash;
|
||||
}
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
emit info( reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
termsMap );
|
||||
emit info( requestData, termsMap );
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
bool
|
||||
EchoNestPlugin::isValidArtistData( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
EchoNestPlugin::isValidArtistData( const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
{
|
||||
if ( requestData.input.isNull() || !requestData.input.isValid() || !requestData.input.canConvert< QString >() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return false;
|
||||
}
|
||||
QString artistName = requestData.input.toString();
|
||||
if ( artistName.isEmpty() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
EchoNestPlugin::isValidTrackData( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
EchoNestPlugin::isValidTrackData( const Tomahawk::InfoSystem::InfoRequestData &requestData )
|
||||
{
|
||||
if ( requestData.input.isNull() || !requestData.input.isValid() || !requestData.input.canConvert< QString >() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return false;
|
||||
}
|
||||
QString trackName = requestData.input.toString();
|
||||
if ( trackName.isEmpty() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return false;
|
||||
}
|
||||
if ( !requestData.customData.contains( "artistName" ) || requestData.customData[ "artistName" ].toString().isEmpty() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
virtual ~EchoNestPlugin();
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data )
|
||||
{
|
||||
@ -55,9 +55,8 @@ protected slots:
|
||||
Q_UNUSED( data );
|
||||
}
|
||||
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( criteria );
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
@ -66,15 +65,15 @@ public slots:
|
||||
void namChangedSlot( QNetworkAccessManager *nam );
|
||||
|
||||
private:
|
||||
void getSongProfile( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item = QString() );
|
||||
void getArtistBiography( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getArtistFamiliarity( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getArtistHotttnesss( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getArtistTerms( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getMiscTopTerms( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getSongProfile( const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item = QString() );
|
||||
void getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getArtistFamiliarity( const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getArtistHotttnesss( const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getArtistTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
void getMiscTopTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
|
||||
bool isValidArtistData( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
bool isValidTrackData( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
bool isValidArtistData( const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
bool isValidTrackData( const Tomahawk::InfoSystem::InfoRequestData &requestData );
|
||||
Echonest::Artist artistFromReply( QNetworkReply* );
|
||||
|
||||
private slots:
|
||||
|
@ -123,43 +123,43 @@ LastFmPlugin::namChangedSlot( QNetworkAccessManager *nam )
|
||||
|
||||
|
||||
void
|
||||
LastFmPlugin::dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LastFmPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
switch ( requestData.type )
|
||||
{
|
||||
case InfoArtistImages:
|
||||
fetchArtistImages( requestId, requestData );
|
||||
fetchArtistImages( requestData );
|
||||
break;
|
||||
|
||||
case InfoAlbumCoverArt:
|
||||
fetchCoverArt( requestId, requestData );
|
||||
fetchCoverArt( requestData );
|
||||
break;
|
||||
|
||||
case InfoArtistSimilars:
|
||||
fetchSimilarArtists( requestId, requestData );
|
||||
fetchSimilarArtists( requestData );
|
||||
break;
|
||||
|
||||
case InfoArtistSongs:
|
||||
fetchTopTracks( requestId, requestData );
|
||||
fetchTopTracks( requestData );
|
||||
break;
|
||||
|
||||
case InfoChart:
|
||||
fetchChart( requestId, requestData );
|
||||
fetchChart( requestData );
|
||||
break;
|
||||
|
||||
case InfoChartCapabilities:
|
||||
fetchChartCapabilities( requestId, requestData );
|
||||
fetchChartCapabilities( requestData );
|
||||
break;
|
||||
default:
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,95 +267,95 @@ LastFmPlugin::sendLoveSong( const InfoType type, QVariant input )
|
||||
|
||||
|
||||
void
|
||||
LastFmPlugin::fetchSimilarArtists( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::fetchSimilarArtists( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
if ( !hash.contains( "artist" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria["artist"] = hash["artist"];
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
|
||||
emit getCachedInfo( criteria, 2419200000, requestData );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LastFmPlugin::fetchTopTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::fetchTopTracks( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
if ( !hash.contains( "artist" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria["artist"] = hash["artist"];
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
|
||||
emit getCachedInfo( criteria, 2419200000, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
LastFmPlugin::fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
if ( !hash.contains( "chart_id" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
} else {
|
||||
criteria["chart_id"] = hash["chart_id"];
|
||||
}
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 0, requestData );
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
LastFmPlugin::fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 0, requestData );
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
LastFmPlugin::fetchCoverArt( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::fetchCoverArt( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
if ( !hash.contains( "artist" ) || !hash.contains( "album" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -363,39 +363,39 @@ LastFmPlugin::fetchCoverArt( uint requestId, Tomahawk::InfoSystem::InfoRequestDa
|
||||
criteria["artist"] = hash["artist"];
|
||||
criteria["album"] = hash["album"];
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
|
||||
emit getCachedInfo( criteria, 2419200000, requestData );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LastFmPlugin::fetchArtistImages( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::fetchArtistImages( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
if ( !hash.contains( "artist" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria["artist"] = hash["artist"];
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
|
||||
emit getCachedInfo( criteria, 2419200000, requestData );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
LastFmPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !lastfm::nam() )
|
||||
{
|
||||
tLog() << "Have a null QNAM, uh oh";
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -407,14 +407,14 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
/// We need something to check if the request is actually ment to go to this plugin
|
||||
if ( !hash.contains( "chart_source" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( "last.fm" != hash["chart_source"] )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -425,7 +425,6 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
args["method"] = criteria["chart_id"];
|
||||
args["limit"] = "100";
|
||||
QNetworkReply* reply = lastfm::ws::get(args);
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
|
||||
@ -466,11 +465,7 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
result.insert( "Last.fm", QVariant::fromValue<QVariantMap>( charts ) );
|
||||
|
||||
tDebug() << "LASTFM RETURNING CHART LIST!";
|
||||
emit info(
|
||||
requestId,
|
||||
requestData,
|
||||
result
|
||||
);
|
||||
emit info( requestData, result );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -478,7 +473,6 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
{
|
||||
lastfm::Artist a( criteria["artist"] );
|
||||
QNetworkReply* reply = a.getSimilar();
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( similarArtistsReturned() ) );
|
||||
@ -489,7 +483,6 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
{
|
||||
lastfm::Artist a( criteria["artist"] );
|
||||
QNetworkReply* reply = a.getTopTracks();
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( topTracksReturned() ) );
|
||||
@ -504,7 +497,6 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
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 = lastfm::nam()->get( req );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
|
||||
@ -518,7 +510,6 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=artist.imageredirect&artist=%1&autocorrect=1&size=large&api_key=7a90f6672a04b809ee309af169f34b8b";
|
||||
QNetworkRequest req( imgurl.arg( artistName ) );
|
||||
QNetworkReply* reply = lastfm::nam()->get( req );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) );
|
||||
@ -528,7 +519,7 @@ LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
default:
|
||||
{
|
||||
tLog() << "Couldn't figure out what to do with this type of request after cache miss";
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -553,11 +544,7 @@ LastFmPlugin::similarArtistsReturned()
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
emit info(
|
||||
reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
returnedData
|
||||
);
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
@ -609,11 +596,7 @@ LastFmPlugin::chartReturned()
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
emit info(
|
||||
reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
returnedData
|
||||
);
|
||||
emit info( requestData, returnedData );
|
||||
// TODO update cache
|
||||
}
|
||||
|
||||
@ -629,11 +612,7 @@ LastFmPlugin::topTracksReturned()
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
emit info(
|
||||
reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
returnedData
|
||||
);
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
@ -653,7 +632,7 @@ LastFmPlugin::coverArtReturned()
|
||||
if ( ba.isNull() || !ba.length() )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Uh oh, null byte array";
|
||||
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
foreach ( const QUrl& url, m_badUrls )
|
||||
@ -668,11 +647,7 @@ LastFmPlugin::coverArtReturned()
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
emit info(
|
||||
reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
returnedData
|
||||
);
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
@ -685,13 +660,12 @@ LastFmPlugin::coverArtReturned()
|
||||
if ( !lastfm::nam() )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Uh oh, nam is null";
|
||||
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
// Follow HTTP redirect
|
||||
QNetworkRequest req( redir );
|
||||
QNetworkReply* newReply = lastfm::nam()->get( req );
|
||||
newReply->setProperty( "requestId", reply->property( "requestId" ) );
|
||||
newReply->setProperty( "requestData", reply->property( "requestData" ) );
|
||||
connect( newReply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
|
||||
}
|
||||
@ -711,7 +685,7 @@ LastFmPlugin::artistImagesReturned()
|
||||
if ( ba.isNull() || !ba.length() )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Uh oh, null byte array";
|
||||
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
foreach ( const QUrl& url, m_badUrls )
|
||||
@ -725,7 +699,7 @@ LastFmPlugin::artistImagesReturned()
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
emit info( reply->property( "requestId" ).toUInt(), requestData, returnedData );
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
@ -737,13 +711,12 @@ LastFmPlugin::artistImagesReturned()
|
||||
if ( !lastfm::nam() )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Uh oh, nam is null";
|
||||
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
// Follow HTTP redirect
|
||||
QNetworkRequest req( redir );
|
||||
QNetworkReply* newReply = lastfm::nam()->get( req );
|
||||
newReply->setProperty( "requestId", reply->property( "requestId" ) );
|
||||
newReply->setProperty( "requestData", reply->property( "requestData" ) );
|
||||
connect( newReply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) );
|
||||
}
|
||||
|
@ -56,25 +56,25 @@ public slots:
|
||||
void namChangedSlot( QNetworkAccessManager *nam );
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data );
|
||||
|
||||
private:
|
||||
void fetchCoverArt( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchArtistImages( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchSimilarArtists( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchTopTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchCoverArt( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchArtistImages( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchSimilarArtists( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchTopTracks( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
void createScrobbler();
|
||||
void nowPlaying( const QVariant &input );
|
||||
void scrobble();
|
||||
void sendLoveSong( const InfoType type, QVariant input );
|
||||
|
||||
void dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void dataError( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
QList<lastfm::Track> parseTrackList( QNetworkReply * reply );
|
||||
|
||||
|
@ -52,17 +52,17 @@ MusicBrainzPlugin::namChangedSlot( QNetworkAccessManager *nam )
|
||||
|
||||
|
||||
void
|
||||
MusicBrainzPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
MusicBrainzPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
if ( !hash.contains( "artist" ) )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -74,7 +74,6 @@ MusicBrainzPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestDat
|
||||
QUrl url( requestString );
|
||||
url.addQueryItem( "query", hash["artist"] );
|
||||
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( artistSearchSlot() ) );
|
||||
@ -87,7 +86,6 @@ MusicBrainzPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestDat
|
||||
QUrl url( requestString );
|
||||
url.addQueryItem( "query", hash["artist"] );
|
||||
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( albumSearchSlot() ) );
|
||||
@ -104,24 +102,24 @@ MusicBrainzPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestDat
|
||||
|
||||
|
||||
bool
|
||||
MusicBrainzPlugin::isValidTrackData( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
MusicBrainzPlugin::isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( requestData.input.isNull() || !requestData.input.isValid() || !requestData.input.canConvert< QVariantMap >() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
qDebug() << Q_FUNC_INFO << "Data null, invalid, or can't convert";
|
||||
return false;
|
||||
}
|
||||
QVariantMap hash = requestData.input.value< QVariantMap >();
|
||||
if ( hash[ "trackName" ].toString().isEmpty() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
qDebug() << Q_FUNC_INFO << "Track name is empty";
|
||||
return false;
|
||||
}
|
||||
if ( hash[ "artistName" ].toString().isEmpty() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
qDebug() << Q_FUNC_INFO << "No artist name found";
|
||||
return false;
|
||||
}
|
||||
@ -141,7 +139,7 @@ MusicBrainzPlugin::artistSearchSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName( "artist" );
|
||||
if ( domNodeList.isEmpty() )
|
||||
{
|
||||
emit info( oldReply->property( "requestId" ).toUInt(), oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -151,7 +149,6 @@ MusicBrainzPlugin::artistSearchSlot()
|
||||
url.addQueryItem( "artist", artist_id );
|
||||
|
||||
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
newReply->setProperty( "requestId", oldReply->property( "requestId" ) );
|
||||
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
|
||||
connect( newReply, SIGNAL( finished() ), SLOT( albumFoundSlot() ) );
|
||||
}
|
||||
@ -169,7 +166,7 @@ MusicBrainzPlugin::albumSearchSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName( "artist" );
|
||||
if ( domNodeList.isEmpty() )
|
||||
{
|
||||
emit info( oldReply->property( "requestId" ).toUInt(), oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -179,7 +176,6 @@ MusicBrainzPlugin::albumSearchSlot()
|
||||
url.addQueryItem( "artist", artist_id );
|
||||
|
||||
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
newReply->setProperty( "requestId", oldReply->property( "requestId" ) );
|
||||
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
|
||||
connect( newReply, SIGNAL( finished() ), SLOT( tracksSearchSlot() ) );
|
||||
}
|
||||
@ -197,7 +193,7 @@ MusicBrainzPlugin::tracksSearchSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName( "release" );
|
||||
if ( domNodeList.isEmpty() )
|
||||
{
|
||||
emit info( oldReply->property( "requestId" ).toUInt(), oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -214,7 +210,7 @@ MusicBrainzPlugin::tracksSearchSlot()
|
||||
|
||||
if ( element.isNull() )
|
||||
{
|
||||
emit info( oldReply->property( "requestId" ).toUInt(), oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -223,7 +219,6 @@ MusicBrainzPlugin::tracksSearchSlot()
|
||||
QUrl url( requestString );
|
||||
|
||||
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
newReply->setProperty( "requestId", oldReply->property( "requestId" ) );
|
||||
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
|
||||
connect( newReply, SIGNAL( finished() ), SLOT( tracksFoundSlot() ) );
|
||||
}
|
||||
@ -241,7 +236,7 @@ MusicBrainzPlugin::albumFoundSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName( "title" );
|
||||
if ( domNodeList.isEmpty() )
|
||||
{
|
||||
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -256,7 +251,7 @@ MusicBrainzPlugin::albumFoundSlot()
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
QVariantMap returnedData;
|
||||
returnedData["albums"] = albums;
|
||||
emit info( reply->property( "requestId" ).toUInt(), requestData, returnedData );
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
@ -277,7 +272,7 @@ MusicBrainzPlugin::tracksFoundSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName( "recording" );
|
||||
if ( domNodeList.isEmpty() )
|
||||
{
|
||||
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -297,7 +292,7 @@ MusicBrainzPlugin::tracksFoundSlot()
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
QVariantMap returnedData;
|
||||
returnedData["tracks"] = tracks;
|
||||
emit info( reply->property( "requestId" ).toUInt(), requestData, returnedData );
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
|
@ -42,7 +42,7 @@ public slots:
|
||||
void namChangedSlot( QNetworkAccessManager *nam );
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data )
|
||||
{
|
||||
@ -51,9 +51,8 @@ protected slots:
|
||||
Q_UNUSED( data );
|
||||
}
|
||||
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( criteria );
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
@ -67,7 +66,7 @@ private slots:
|
||||
void tracksFoundSlot();
|
||||
|
||||
private:
|
||||
bool isValidTrackData( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
bool isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
QWeakPointer< QNetworkAccessManager > m_nam;
|
||||
};
|
||||
|
@ -53,17 +53,17 @@ MusixMatchPlugin::namChangedSlot( QNetworkAccessManager *nam )
|
||||
}
|
||||
|
||||
void
|
||||
MusixMatchPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
MusixMatchPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if( !isValidTrackData( requestId, requestData ) || !requestData.input.canConvert< QVariantMap >() || m_nam.isNull() || requestData.type != Tomahawk::InfoSystem::InfoTrackLyrics )
|
||||
if( !isValidTrackData( requestData ) || !requestData.input.canConvert< QVariantMap >() || m_nam.isNull() || requestData.type != Tomahawk::InfoSystem::InfoTrackLyrics )
|
||||
return;
|
||||
QVariantMap hash = requestData.input.value< QVariantMap >();
|
||||
QString artist = hash["artistName"].toString();
|
||||
QString track = hash["trackName"].toString();
|
||||
if( artist.isEmpty() || track.isEmpty() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
qDebug() << "artist is " << artist << ", track is " << track;
|
||||
@ -73,32 +73,31 @@ MusixMatchPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData
|
||||
url.addQueryItem( "q_artist", artist );
|
||||
url.addQueryItem( "q_track", track );
|
||||
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( trackSearchSlot() ) );
|
||||
}
|
||||
|
||||
bool
|
||||
MusixMatchPlugin::isValidTrackData( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
MusixMatchPlugin::isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( requestData.input.isNull() || !requestData.input.isValid() || !requestData.input.canConvert< QVariantMap >() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert";
|
||||
return false;
|
||||
}
|
||||
QVariantMap hash = requestData.input.value< QVariantMap >();
|
||||
if ( hash[ "trackName" ].toString().isEmpty() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
qDebug() << "MusixMatchPlugin::isValidTrackData: Track name is empty";
|
||||
return false;
|
||||
}
|
||||
if ( hash[ "artistName" ].toString().isEmpty() )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
qDebug() << "MusixMatchPlugin::isValidTrackData: No artist name found";
|
||||
return false;
|
||||
}
|
||||
@ -119,7 +118,7 @@ MusixMatchPlugin::trackSearchSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName("track_id");
|
||||
if ( domNodeList.isEmpty() )
|
||||
{
|
||||
emit info( oldReply->property( "requestId" ).toUInt(), oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
QString track_id = domNodeList.at(0).toElement().text();
|
||||
@ -128,7 +127,6 @@ MusixMatchPlugin::trackSearchSlot()
|
||||
url.addQueryItem( "apikey", m_apiKey );
|
||||
url.addQueryItem( "track_id", track_id );
|
||||
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
newReply->setProperty( "requestId", oldReply->property( "requestId" ) );
|
||||
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
|
||||
connect( newReply, SIGNAL( finished() ), SLOT( trackLyricsSlot() ) );
|
||||
}
|
||||
@ -146,10 +144,10 @@ MusixMatchPlugin::trackLyricsSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName( "lyrics_body" );
|
||||
if ( domNodeList.isEmpty() )
|
||||
{
|
||||
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
|
||||
return;
|
||||
}
|
||||
QString lyrics = domNodeList.at(0).toElement().text();
|
||||
qDebug() << "Emitting lyrics: " << lyrics;
|
||||
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant( lyrics ) );
|
||||
emit info( reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant( lyrics ) );
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public slots:
|
||||
void namChangedSlot( QNetworkAccessManager *nam );
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data )
|
||||
{
|
||||
@ -54,15 +54,14 @@ protected slots:
|
||||
Q_UNUSED( data );
|
||||
}
|
||||
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( criteria );
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
|
||||
private:
|
||||
bool isValidTrackData( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
bool isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
QString m_apiKey;
|
||||
|
||||
|
@ -77,15 +77,15 @@ SpotifyPlugin::namChangedSlot( QNetworkAccessManager *nam )
|
||||
|
||||
|
||||
void
|
||||
SpotifyPlugin::dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
SpotifyPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SpotifyPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
SpotifyPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << requestData.caller;
|
||||
qDebug() << Q_FUNC_INFO << requestData.customData;
|
||||
@ -98,18 +98,18 @@ SpotifyPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData re
|
||||
case InfoChart:
|
||||
if ( !hash.contains( "chart_source" ) || hash["chart_source"] != "spotify" )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
break;
|
||||
}
|
||||
qDebug() << Q_FUNC_INFO << "InfoCHart req for" << hash["chart_source"];
|
||||
fetchChart( requestId, requestData );
|
||||
fetchChart( requestData );
|
||||
break;
|
||||
|
||||
case InfoChartCapabilities:
|
||||
fetchChartCapabilities( requestId, requestData );
|
||||
fetchChartCapabilities( requestData );
|
||||
break;
|
||||
default:
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,45 +123,45 @@ SpotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoT
|
||||
}
|
||||
|
||||
void
|
||||
SpotifyPlugin::fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
SpotifyPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
if ( !hash.contains( "chart_id" ) )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
} else {
|
||||
criteria["chart_id"] = hash["chart_id"];
|
||||
}
|
||||
|
||||
emit getCachedInfo( requestId, criteria, 0, requestData );
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
void
|
||||
SpotifyPlugin::fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
SpotifyPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
dataError( requestId, requestData );
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
emit getCachedInfo( requestId, criteria, 0, requestData );
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
SpotifyPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
SpotifyPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
if ( !m_nam.data() )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Have a null QNAM, uh oh";
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -176,7 +176,6 @@ SpotifyPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
|
||||
|
||||
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) );
|
||||
reply->setProperty( "requestId", requestId );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
|
||||
return;
|
||||
@ -186,18 +185,14 @@ SpotifyPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria,
|
||||
case InfoChartCapabilities:
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "EMITTING CHART" << m_allChartsMap;
|
||||
emit info(
|
||||
requestId,
|
||||
requestData,
|
||||
m_allChartsMap
|
||||
);
|
||||
emit info( requestData, m_allChartsMap );
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Couldn't figure out what to do with this type of request after cache miss";
|
||||
emit info( requestId, requestData, QVariant() );
|
||||
emit info( requestData, QVariant() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -381,11 +376,7 @@ SpotifyPlugin::chartReturned()
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
|
||||
emit info(
|
||||
reply->property( "requestId" ).toUInt(),
|
||||
requestData,
|
||||
returnedData
|
||||
);
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -56,14 +56,14 @@ public slots:
|
||||
void namChangedSlot( QNetworkAccessManager *nam );
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data );
|
||||
|
||||
private:
|
||||
void fetchChart( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChartCapabilities( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void dataError( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
|
||||
ChartType m_chartType;
|
||||
|
@ -41,9 +41,8 @@ public:
|
||||
virtual ~AdiumPlugin();
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
|
||||
@ -52,9 +51,8 @@ protected slots:
|
||||
public slots:
|
||||
void namChangedSlot( QNetworkAccessManager* nam );
|
||||
|
||||
virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( criteria );
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
|
@ -38,17 +38,15 @@ public:
|
||||
virtual void namChangedSlot( QNetworkAccessManager* ) {}
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant pushData );
|
||||
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( criteria );
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
|
@ -432,9 +432,8 @@ MprisPlugin::Stop()
|
||||
// InfoPlugin Methods
|
||||
|
||||
void
|
||||
MprisPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
MprisPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( requestData );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
|
@ -119,9 +119,8 @@ public:
|
||||
public slots:
|
||||
void namChangedSlot( QNetworkAccessManager* /*nam*/ ) {} // unused
|
||||
|
||||
virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
Q_UNUSED( requestId );
|
||||
Q_UNUSED( criteria );
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
@ -143,7 +142,7 @@ public slots:
|
||||
|
||||
|
||||
protected slots:
|
||||
void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
||||
|
||||
private slots:
|
||||
|
@ -74,8 +74,8 @@ InfoSystem::InfoSystem( QObject *parent )
|
||||
|
||||
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( newNam() ) );
|
||||
|
||||
connect( m_cache.data(), SIGNAL( info( uint, Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
m_worker.data(), SLOT( infoSlot( uint, Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
connect( m_cache.data(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
m_worker.data(), SLOT( infoSlot( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( m_worker.data(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
this, SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include "dllmacro.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
class QNetworkAccessManager;
|
||||
|
||||
@ -43,28 +44,29 @@ class InfoSystemCache;
|
||||
class InfoSystemWorker;
|
||||
|
||||
enum InfoType { // as items are saved in cache, mark them here to not change them
|
||||
InfoTrackID = 0,
|
||||
InfoTrackArtist = 1,
|
||||
InfoTrackAlbum = 2,
|
||||
InfoTrackGenre = 3,
|
||||
InfoTrackComposer = 4,
|
||||
InfoTrackDate = 5,
|
||||
InfoTrackNumber = 6,
|
||||
InfoTrackDiscNumber = 7,
|
||||
InfoTrackBitRate = 8,
|
||||
InfoTrackLength = 9,
|
||||
InfoTrackSampleRate = 10,
|
||||
InfoTrackFileSize = 11,
|
||||
InfoTrackBPM = 12,
|
||||
InfoTrackReplayGain = 13,
|
||||
InfoTrackReplayPeakGain = 14,
|
||||
InfoTrackLyrics = 15,
|
||||
InfoTrackLocation = 16,
|
||||
InfoTrackProfile = 17,
|
||||
InfoTrackEnergy = 18,
|
||||
InfoTrackDanceability = 19,
|
||||
InfoTrackTempo = 20,
|
||||
InfoTrackLoudness = 21,
|
||||
InfoNoInfo = 0, //WARNING: *ALWAYS* keep this first!
|
||||
InfoTrackID = 1,
|
||||
InfoTrackArtist = 2,
|
||||
InfoTrackAlbum = 3,
|
||||
InfoTrackGenre = 4,
|
||||
InfoTrackComposer = 5,
|
||||
InfoTrackDate = 6,
|
||||
InfoTrackNumber = 7,
|
||||
InfoTrackDiscNumber = 8,
|
||||
InfoTrackBitRate = 9,
|
||||
InfoTrackLength = 10,
|
||||
InfoTrackSampleRate = 11,
|
||||
InfoTrackFileSize = 12,
|
||||
InfoTrackBPM = 13,
|
||||
InfoTrackReplayGain = 14,
|
||||
InfoTrackReplayPeakGain = 15,
|
||||
InfoTrackLyrics = 16,
|
||||
InfoTrackLocation = 17,
|
||||
InfoTrackProfile = 18,
|
||||
InfoTrackEnergy = 19,
|
||||
InfoTrackDanceability = 20,
|
||||
InfoTrackTempo = 21,
|
||||
InfoTrackLoudness = 22,
|
||||
|
||||
InfoArtistID = 25,
|
||||
InfoArtistName = 26,
|
||||
@ -120,14 +122,34 @@ enum InfoType { // as items are saved in cache, mark them here to not change the
|
||||
|
||||
InfoNotifyUser = 100,
|
||||
|
||||
InfoNoInfo = 101 //WARNING: *ALWAYS* keep this last!
|
||||
InfoLastInfo = 101 //WARNING: *ALWAYS* keep this last!
|
||||
};
|
||||
|
||||
struct InfoRequestData {
|
||||
quint64 requestId;
|
||||
quint64 internalId; //do not assign to this; it may get overwritten by the InfoSystem
|
||||
QString caller;
|
||||
Tomahawk::InfoSystem::InfoType type;
|
||||
QVariant input;
|
||||
QVariantMap customData;
|
||||
|
||||
InfoRequestData()
|
||||
: requestId( TomahawkUtils::infosystemRequestId() )
|
||||
, internalId( TomahawkUtils::infosystemRequestId() )
|
||||
, caller( QString() )
|
||||
, type( Tomahawk::InfoSystem::InfoNoInfo )
|
||||
, input( QVariant() )
|
||||
, customData( QVariantMap() )
|
||||
{}
|
||||
|
||||
InfoRequestData( const quint64 rId, const QString &callr, const Tomahawk::InfoSystem::InfoType typ, const QVariant &inputvar, const QVariantMap &custom )
|
||||
: requestId( rId )
|
||||
, internalId( TomahawkUtils::infosystemRequestId() )
|
||||
, caller( callr )
|
||||
, type( typ )
|
||||
, input( inputvar )
|
||||
, customData( custom )
|
||||
{}
|
||||
};
|
||||
|
||||
typedef QMap< InfoType, QVariant > InfoTypeMap;
|
||||
@ -147,15 +169,15 @@ public:
|
||||
QSet< InfoType > supportedPushTypes() const { return m_supportedPushTypes; }
|
||||
|
||||
signals:
|
||||
void getCachedInfo( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void info( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void getCachedInfo( Tomahawk::InfoSystem::InfoStringHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
|
||||
void updateCache( Tomahawk::InfoSystem::InfoStringHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data ) = 0;
|
||||
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
|
||||
|
||||
virtual void namChangedSlot( QNetworkAccessManager *nam ) = 0;
|
||||
|
||||
|
@ -75,7 +75,7 @@ InfoSystemCache::doUpgrade( uint oldVersion, uint newVersion )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Wiping cache";
|
||||
|
||||
for ( int i = 0; i <= InfoNoInfo; i++ )
|
||||
for ( int i = InfoNoInfo; i <= InfoLastInfo; i++ )
|
||||
{
|
||||
InfoType type = (InfoType)(i);
|
||||
const QString cacheDirName = m_cacheBaseDir + QString::number( (int)type );
|
||||
@ -96,7 +96,7 @@ InfoSystemCache::pruneTimerFired()
|
||||
qDebug() << Q_FUNC_INFO << "Pruning infosystemcache";
|
||||
qlonglong currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
for ( int i = 0; i <= InfoNoInfo; i++ )
|
||||
for ( int i = InfoNoInfo; i <= InfoLastInfo; i++ )
|
||||
{
|
||||
InfoType type = (InfoType)(i);
|
||||
QHash< QString, QString > fileLocationHash = m_fileLocationCache[type];
|
||||
@ -121,7 +121,7 @@ InfoSystemCache::pruneTimerFired()
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoStringHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
QObject* sendingObj = sender();
|
||||
const QString criteriaHashVal = criteriaMd5( criteria );
|
||||
@ -133,7 +133,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoSt
|
||||
{
|
||||
//We already know of some values, so no need to re-read the directory again as it's already happened
|
||||
qDebug() << Q_FUNC_INFO << "notInCache -- filelocationhash empty";
|
||||
notInCache( sendingObj, requestId, criteria, requestData );
|
||||
notInCache( sendingObj, criteria, requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoSt
|
||||
{
|
||||
//Dir doesn't exist so clearly not in cache
|
||||
qDebug() << Q_FUNC_INFO << "notInCache -- dir doesn't exist";
|
||||
notInCache( sendingObj, requestId, criteria, requestData );
|
||||
notInCache( sendingObj, criteria, requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoSt
|
||||
{
|
||||
//Still didn't find it? It's really not in the cache then
|
||||
qDebug() << Q_FUNC_INFO << "notInCache -- filelocationhash doesn't contain criteria val";
|
||||
notInCache( sendingObj, requestId, criteria, requestData );
|
||||
notInCache( sendingObj, criteria, requestData );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -180,7 +180,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoSt
|
||||
m_dataCache.remove( criteriaHashValWithType );
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "notInCache -- file was stale";
|
||||
notInCache( sendingObj, requestId, criteria, requestData );
|
||||
notInCache( sendingObj, criteria, requestData );
|
||||
return;
|
||||
}
|
||||
else if ( newMaxAge > 0 )
|
||||
@ -190,7 +190,7 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoSt
|
||||
if ( !QFile::rename( file.canonicalFilePath(), newFilePath ) )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "notInCache -- failed to move old cache file to new location";
|
||||
notInCache( sendingObj, requestId, criteria, requestData );
|
||||
notInCache( sendingObj, criteria, requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -204,25 +204,26 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoSt
|
||||
QVariant output = cachedSettings.value( "data" );
|
||||
m_dataCache.insert( criteriaHashValWithType, new QVariant( output ) );
|
||||
|
||||
emit info( requestId, requestData, output );
|
||||
emit info( requestData, output );
|
||||
}
|
||||
else
|
||||
{
|
||||
emit info( requestId, requestData, QVariant( *( m_dataCache[ criteriaHashValWithType ] ) ) );
|
||||
emit info( requestData, QVariant( *( m_dataCache[ criteriaHashValWithType ] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCache::notInCache( QObject *receiver, uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
InfoSystemCache::notInCache( QObject *receiver, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
QMetaObject::invokeMethod( receiver, "notInCacheSlot", Q_ARG( uint, requestId ), Q_ARG( Tomahawk::InfoSystem::InfoStringHash, criteria ), Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
|
||||
QMetaObject::invokeMethod( receiver, "notInCacheSlot", Q_ARG( Tomahawk::InfoSystem::InfoStringHash, criteria ), Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
const QString criteriaHashVal = criteriaMd5( criteria );
|
||||
const QString criteriaHashValWithType = criteriaMd5( criteria, type );
|
||||
const QString cacheDir = m_cacheBaseDir + QString::number( (int)type );
|
||||
@ -283,7 +284,7 @@ InfoSystemCache::criteriaMd5( const Tomahawk::InfoSystem::InfoStringHash &criter
|
||||
md5.addData( key.toUtf8() );
|
||||
md5.addData( criteria[key].toUtf8() );
|
||||
}
|
||||
if ( type != Tomahawk::InfoSystem::InfoNoInfo )
|
||||
if ( type != Tomahawk::InfoSystem::InfoNoInfo && type != Tomahawk::InfoSystem::InfoLastInfo )
|
||||
md5.addData( QString::number( (int)type ).toUtf8() );
|
||||
return md5.result().toHex();
|
||||
}
|
||||
|
@ -43,17 +43,17 @@ public:
|
||||
virtual ~InfoSystemCache();
|
||||
|
||||
signals:
|
||||
void info( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
|
||||
public slots:
|
||||
void getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void getCachedInfoSlot( Tomahawk::InfoSystem::InfoStringHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void updateCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||
|
||||
private slots:
|
||||
void pruneTimerFired();
|
||||
|
||||
private:
|
||||
void notInCache( QObject *receiver, uint requestId, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void notInCache( QObject *receiver, Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void doUpgrade( uint oldVersion, uint newVersion );
|
||||
const QString criteriaMd5( const Tomahawk::InfoSystem::InfoStringHash &criteria, Tomahawk::InfoSystem::InfoType type = Tomahawk::InfoSystem::InfoNoInfo ) const;
|
||||
|
||||
|
@ -51,7 +51,6 @@ namespace InfoSystem
|
||||
|
||||
InfoSystemWorker::InfoSystemWorker()
|
||||
: QObject()
|
||||
, m_nextRequest( 0 )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@ -119,17 +118,17 @@ InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cac
|
||||
{
|
||||
connect(
|
||||
plugin.data(),
|
||||
SIGNAL( info( uint, Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
this,
|
||||
SLOT( infoSlot( uint, Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SLOT( infoSlot( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
Qt::UniqueConnection
|
||||
);
|
||||
|
||||
connect(
|
||||
plugin.data(),
|
||||
SIGNAL( getCachedInfo( uint, Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) ),
|
||||
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) ),
|
||||
cache.data(),
|
||||
SLOT( getCachedInfoSlot( uint, Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) )
|
||||
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) )
|
||||
);
|
||||
connect(
|
||||
plugin.data(),
|
||||
@ -174,7 +173,7 @@ InfoSystemWorker::determineOrderedMatches( const InfoType type ) const
|
||||
void
|
||||
InfoSystemWorker::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData, uint timeoutMillis, bool allSources )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
//qDebug() << Q_FUNC_INFO << "type is " << requestData.type << " and allSources = " << (allSources ? "true" : "false" );
|
||||
|
||||
QList< InfoPluginPtr > providers = determineOrderedMatches( requestData.type );
|
||||
if ( providers.isEmpty() )
|
||||
@ -194,7 +193,13 @@ InfoSystemWorker::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData, ui
|
||||
continue;
|
||||
|
||||
foundOne = true;
|
||||
uint requestId = ++m_nextRequest;
|
||||
|
||||
if ( allSources )
|
||||
requestData.internalId = TomahawkUtils::infosystemRequestId();
|
||||
else
|
||||
requestData.internalId = requestData.requestId;
|
||||
|
||||
quint64 requestId = requestData.internalId;
|
||||
m_requestSatisfiedMap[ requestId ] = false;
|
||||
if ( timeoutMillis != 0 )
|
||||
{
|
||||
@ -212,7 +217,7 @@ InfoSystemWorker::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData, ui
|
||||
data->customData = requestData.customData;
|
||||
m_savedRequestMap[ requestId ] = data;
|
||||
|
||||
QMetaObject::invokeMethod( ptr.data(), "getInfo", Qt::QueuedConnection, Q_ARG( uint, requestId ), Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
|
||||
QMetaObject::invokeMethod( ptr.data(), "getInfo", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
|
||||
}
|
||||
|
||||
if ( !foundOne )
|
||||
@ -237,10 +242,12 @@ InfoSystemWorker::pushInfo( QString caller, InfoType type, QVariant input )
|
||||
|
||||
|
||||
void
|
||||
InfoSystemWorker::infoSlot( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
InfoSystemWorker::infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << "with requestId" << requestId;
|
||||
|
||||
quint64 requestId = requestData.internalId;
|
||||
|
||||
if ( m_dataTracker[ requestData.caller ][ requestData.type ] == 0 )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << "Caller was not waiting for that type of data!";
|
||||
@ -285,7 +292,7 @@ InfoSystemWorker::checkTimeoutsTimerFired()
|
||||
qint64 currTime = QDateTime::currentMSecsSinceEpoch();
|
||||
Q_FOREACH( qint64 time, m_timeRequestMapper.keys() )
|
||||
{
|
||||
Q_FOREACH( uint requestId, m_timeRequestMapper.values( time ) )
|
||||
Q_FOREACH( quint64 requestId, m_timeRequestMapper.values( time ) )
|
||||
{
|
||||
if ( time < currTime )
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ public slots:
|
||||
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData, uint timeoutMillis, bool allSources );
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
||||
|
||||
void infoSlot( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
|
||||
void newNam();
|
||||
|
||||
@ -73,7 +73,7 @@ private:
|
||||
QList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
|
||||
|
||||
QHash< QString, QHash< InfoType, int > > m_dataTracker;
|
||||
QMultiMap< qint64, uint > m_timeRequestMapper;
|
||||
QMultiMap< qint64, quint64 > m_timeRequestMapper;
|
||||
QHash< uint, bool > m_requestSatisfiedMap;
|
||||
QHash< uint, InfoRequestData* > m_savedRequestMap;
|
||||
|
||||
@ -85,8 +85,6 @@ private:
|
||||
|
||||
QWeakPointer< QNetworkAccessManager> m_nam;
|
||||
|
||||
uint m_nextRequest;
|
||||
|
||||
QTimer m_checkTimeoutsTimer;
|
||||
};
|
||||
|
||||
|
@ -51,8 +51,8 @@ DropJobNotifier::DropJobNotifier( QPixmap servicePixmap, QString service, DropJo
|
||||
|
||||
DropJobNotifier::DropJobNotifier( QPixmap pixmap, DropJob::DropType type )
|
||||
: JobStatusItem()
|
||||
, m_pixmap( pixmap )
|
||||
, m_job( 0 )
|
||||
, m_pixmap( pixmap )
|
||||
{
|
||||
init( type );
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QtGui/QColor>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QPixmap>
|
||||
@ -64,6 +65,8 @@ namespace TomahawkUtils
|
||||
|
||||
|
||||
static int s_headerHeight = 0;
|
||||
static quint64 s_infosystemRequestId = 0;
|
||||
static QMutex s_infosystemRequestIdMutex;
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
QString
|
||||
@ -690,4 +693,13 @@ removeDirectory( const QString& dir )
|
||||
}
|
||||
|
||||
|
||||
quint64 infosystemRequestId()
|
||||
{
|
||||
QMutexLocker locker( &s_infosystemRequestIdMutex );
|
||||
quint64 result = s_infosystemRequestId;
|
||||
s_infosystemRequestId++;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // ns
|
||||
|
@ -106,6 +106,8 @@ namespace TomahawkUtils
|
||||
DLLEXPORT void setHeaderHeight( int height );
|
||||
|
||||
DLLEXPORT bool removeDirectory( const QString& dir );
|
||||
|
||||
DLLEXPORT quint64 infosystemRequestId();
|
||||
}
|
||||
|
||||
#endif // TOMAHAWKUTILS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user