1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 01:09:42 +01:00

Huge overhaul of InfoSystem, using InfoRequestData structs to pass things around, making it far more clean (and easier to extend in the future)

This commit is contained in:
Jeff Mitchell 2011-07-07 09:33:43 -04:00
parent d7950472bc
commit e0b5597149
32 changed files with 377 additions and 434 deletions

View File

@ -167,8 +167,8 @@ AudioControls::AudioControls( QWidget* parent )
.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ) );
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
@ -218,20 +218,21 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
trackInfo["artist"] = result->artist()->name();
trackInfo["album"] = result->album()->name();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_acInfoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ), QVariantMap() );
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_acInfoIdentifier;
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
void
AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData )
AudioControls::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
Q_UNUSED( input );
Q_UNUSED( customData );
qDebug() << Q_FUNC_INFO << caller << type << s_acInfoIdentifier << Tomahawk::InfoSystem::InfoAlbumCoverArt;
if ( caller != s_acInfoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
qDebug() << Q_FUNC_INFO << requestData.caller << requestData.type << s_acInfoIdentifier << Tomahawk::InfoSystem::InfoAlbumCoverArt;
if ( requestData.caller != s_acInfoIdentifier || requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{
qDebug() << "Info of wrong type or not with our identifier";
return;

View File

@ -67,7 +67,7 @@ private slots:
void onTrackClicked();
void onLoveButtonClicked( bool );
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
private:

View File

@ -256,8 +256,8 @@ AudioEngine::sendNowPlayingNotification()
if ( ! m_infoSystemConnected )
{
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ) );
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
@ -267,24 +267,26 @@ AudioEngine::sendNowPlayingNotification()
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
trackInfo["artist"] = m_currentTrack->album()->artist()->name();
trackInfo["album"] = m_currentTrack->album()->name();
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_aeInfoIdentifier;
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ), QVariantMap() );
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
void
AudioEngine::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData )
AudioEngine::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
qDebug() << Q_FUNC_INFO;
Q_UNUSED( input );
Q_UNUSED( customData );
if ( caller != s_aeInfoIdentifier ||
( type != Tomahawk::InfoSystem::InfoAlbumCoverArt ) )
if ( requestData.caller != s_aeInfoIdentifier ||
requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{
qDebug() << Q_FUNC_INFO << " not desgined for us, caller is " << caller;
qDebug() << Q_FUNC_INFO << " not destined for us or wrong type, caller is " << requestData.caller << " and type is " << requestData.type;
return;
}

View File

@ -87,7 +87,7 @@ public slots:
void playlistNextTrackReady();
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString caller );
signals:

View File

@ -66,37 +66,37 @@ EchoNestPlugin::namChangedSlot( QNetworkAccessManager *nam )
}
void
EchoNestPlugin::getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
EchoNestPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
switch ( type )
switch ( requestData.type )
{
case Tomahawk::InfoSystem::InfoArtistBiography:
return getArtistBiography( requestId, caller, input, customData );
return getArtistBiography( requestId, requestData );
case Tomahawk::InfoSystem::InfoArtistFamiliarity:
return getArtistFamiliarity( requestId, caller, input, customData );
return getArtistFamiliarity( requestId, requestData );
case Tomahawk::InfoSystem::InfoArtistHotttness:
return getArtistHotttnesss( requestId, caller, input, customData );
return getArtistHotttnesss( requestId, requestData );
case Tomahawk::InfoSystem::InfoArtistTerms:
return getArtistTerms( requestId, caller, input, customData );
return getArtistTerms( requestId, requestData );
case Tomahawk::InfoSystem::InfoTrackEnergy:
return getSongProfile( requestId, caller, input, customData, "energy" );
return getSongProfile( requestId, requestData, "energy" );
case Tomahawk::InfoSystem::InfoMiscTopTerms:
return getMiscTopTerms( requestId, caller, input, customData );
return getMiscTopTerms( requestId, requestData );
default:
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return;
}
}
}
void
EchoNestPlugin::getSongProfile( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData, const QString &item )
EchoNestPlugin::getSongProfile( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item )
{
//WARNING: Totally not implemented yet
Q_UNUSED( item );
if( !isValidTrackData( requestId, caller, input, customData ) )
if( !isValidTrackData( requestId, requestData ) )
return;
// Track track( input.toString() );
@ -108,78 +108,68 @@ EchoNestPlugin::getSongProfile( uint requestId, const QString &caller, const QVa
}
void
EchoNestPlugin::getArtistBiography( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
EchoNestPlugin::getArtistBiography( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
{
if( !isValidArtistData( requestId, caller, input, customData ) )
if( !isValidArtistData( requestId, requestData ) )
return;
Echonest::Artist artist( input.toString() );
Echonest::Artist artist( requestData.input.toString() );
QNetworkReply *reply = artist.fetchBiographies();
reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
reply->setProperty( "input", input );
reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller );
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 QString &caller, const QVariant &input, const QVariantMap &customData )
EchoNestPlugin::getArtistFamiliarity( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
{
if( !isValidArtistData( requestId, caller, input, customData ) )
if( !isValidArtistData( requestId, requestData ) )
return;
qDebug() << "Fetching artist familiarity!" << input;
Echonest::Artist artist( input.toString() );
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( "input", input );
reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller );
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 QString &caller, const QVariant &input, const QVariantMap &customData )
EchoNestPlugin::getArtistHotttnesss( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
{
if( !isValidArtistData( requestId, caller, input, customData ) )
if( !isValidArtistData( requestId, requestData ) )
return;
Echonest::Artist artist( input.toString() );
Echonest::Artist artist( requestData.input.toString() );
QNetworkReply* reply = artist.fetchHotttnesss();
reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
reply->setProperty( "input", input );
reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller );
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 QString &caller, const QVariant &input, const QVariantMap &customData )
EchoNestPlugin::getArtistTerms( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
{
if( !isValidArtistData( requestId, caller, input, customData ) )
if( !isValidArtistData( requestId, requestData ) )
return;
Echonest::Artist artist( input.toString() );
Echonest::Artist artist( requestData.input.toString() );
QNetworkReply* reply = artist.fetchTerms( Echonest::Artist::Weight );
reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
reply->setProperty( "input", input );
reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller );
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 QString &caller, const QVariant &input, const QVariantMap& customData )
EchoNestPlugin::getMiscTopTerms( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
{
Q_UNUSED( input );
QNetworkReply* reply = Echonest::Artist::topTerms( 20 );
reply->setProperty( "customData", customData );
reply->setProperty( "caller", caller );
reply->setProperty( "requestId", requestId );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( getMiscTopSlot() ) );
}
@ -201,12 +191,10 @@ EchoNestPlugin::getArtistBiographySlot()
biographyMap[biography.site()]["attribution"] = biography.license().url.toString();
}
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info( reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoArtistBiography,
reply->property( "input" ),
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( biographyMap ),
reply->property( "customData" ).value< QVariantMap >() );
requestData,
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( biographyMap ) );
reply->deleteLater();
}
@ -216,12 +204,10 @@ EchoNestPlugin::getArtistFamiliaritySlot()
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
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(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoArtistFamiliarity,
reply->property( "input" ),
familiarity,
reply->property( "customData" ).value< QVariantMap >() );
requestData,
familiarity );
reply->deleteLater();
}
@ -231,12 +217,10 @@ EchoNestPlugin::getArtistHotttnesssSlot()
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
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(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoArtistHotttness,
reply->property( "input" ),
hotttnesss,
reply->property( "customData" ).value< QVariantMap >() );
requestData,
hotttnesss );
reply->deleteLater();
}
@ -253,12 +237,10 @@ EchoNestPlugin::getArtistTermsSlot()
termMap[ "frequency" ] = QString::number(term.frequency());
termsMap[ term.name() ] = termMap;
}
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info( reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoArtistTerms,
reply->property( "input" ),
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ),
reply->property( "customData" ).value< QVariantMap >() );
requestData,
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ) );
reply->deleteLater();
}
@ -274,49 +256,47 @@ EchoNestPlugin::getMiscTopSlot()
termMap[ "frequency" ] = QString::number( term.frequency() );
termsMap[ term.name().toLower() ] = termMap;
}
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info( reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
Tomahawk::InfoSystem::InfoMiscTopTerms,
QVariant(),
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ),
reply->property( "customData" ).value< QVariantMap >() );
requestData,
QVariant::fromValue< Tomahawk::InfoSystem::InfoGenericMap >( termsMap ) );
reply->deleteLater();
}
bool
EchoNestPlugin::isValidArtistData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
EchoNestPlugin::isValidArtistData( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
{
if ( input.isNull() || !input.isValid() || !input.canConvert< QString >() )
if ( requestData.input.isNull() || !requestData.input.isValid() || !requestData.input.canConvert< QString >() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return false;
}
QString artistName = input.toString();
QString artistName = requestData.input.toString();
if ( artistName.isEmpty() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return false;
}
return true;
}
bool
EchoNestPlugin::isValidTrackData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
EchoNestPlugin::isValidTrackData( uint requestId, const Tomahawk::InfoSystem::InfoRequestData &requestData )
{
if ( input.isNull() || !input.isValid() || !input.canConvert< QString >() )
if ( requestData.input.isNull() || !requestData.input.isValid() || !requestData.input.canConvert< QString >() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return false;
}
QString trackName = input.toString();
QString trackName = requestData.input.toString();
if ( trackName.isEmpty() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return false;
}
if ( !customData.contains( "artistName" ) || customData[ "artistName" ].toString().isEmpty() )
if ( !requestData.customData.contains( "artistName" ) || requestData.customData[ "artistName" ].toString().isEmpty() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return false;
}
return true;

View File

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

View File

@ -120,38 +120,38 @@ LastFmPlugin::namChangedSlot( QNetworkAccessManager *nam )
void
LastFmPlugin::dataError( uint requestId, const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const QVariantMap &customData )
LastFmPlugin::dataError( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
emit info( requestId, caller, type, input, QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return;
}
void
LastFmPlugin::getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
LastFmPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO;
switch ( type )
switch ( requestData.type )
{
case InfoArtistImages:
fetchArtistImages( requestId, caller, type, input, customData );
fetchArtistImages( requestId, requestData );
break;
case InfoAlbumCoverArt:
fetchCoverArt( requestId, caller, type, input, customData );
fetchCoverArt( requestId, requestData );
break;
case InfoArtistSimilars:
fetchSimilarArtists( requestId, caller, type, input, customData );
fetchSimilarArtists( requestId, requestData );
break;
case InfoArtistSongs:
fetchTopTracks( requestId, caller, type, input, customData );
fetchTopTracks( requestId, requestData );
break;
default:
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
}
}
@ -263,64 +263,64 @@ LastFmPlugin::sendLoveSong( const InfoType type, QVariant input )
void
LastFmPlugin::fetchSimilarArtists( uint requestId, const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData )
LastFmPlugin::fetchSimilarArtists( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO;
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
return;
}
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
InfoCriteriaHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
if ( !hash.contains( "artist" ) )
{
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
return;
}
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = hash["artist"];
emit getCachedInfo( requestId, criteria, 2419200000, caller, type, input, customData );
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
}
void
LastFmPlugin::fetchTopTracks( uint requestId, const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData )
LastFmPlugin::fetchTopTracks( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO;
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
return;
}
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
InfoCriteriaHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
if ( !hash.contains( "artist" ) )
{
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
return;
}
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = hash["artist"];
emit getCachedInfo( requestId, criteria, 2419200000, caller, type, input, customData );
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
}
void
LastFmPlugin::fetchCoverArt( uint requestId, const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData )
LastFmPlugin::fetchCoverArt( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO;
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
return;
}
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
InfoCriteriaHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
if ( !hash.contains( "artist" ) || !hash.contains( "album" ) )
{
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
return;
}
@ -328,56 +328,53 @@ LastFmPlugin::fetchCoverArt( uint requestId, const QString &caller, const InfoTy
criteria["artist"] = hash["artist"];
criteria["album"] = hash["album"];
emit getCachedInfo( requestId, criteria, 2419200000, caller, type, input, customData );
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
}
void
LastFmPlugin::fetchArtistImages( uint requestId, const QString &caller, const InfoType type, const QVariant &input, const QVariantMap &customData )
LastFmPlugin::fetchArtistImages( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO;
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
{
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
return;
}
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
InfoCriteriaHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
if ( !hash.contains( "artist" ) )
{
dataError( requestId, caller, type, input, customData );
dataError( requestId, requestData );
return;
}
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = hash["artist"];
emit getCachedInfo( requestId, criteria, 2419200000, caller, type, input, customData );
emit getCachedInfo( requestId, criteria, 2419200000, requestData );
}
void
LastFmPlugin::notInCacheSlot( uint requestId, const QHash<QString, QString> criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
LastFmPlugin::notInCacheSlot( uint requestId, QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO << " for requestId " << requestId;
if ( !lastfm::nam() )
{
qDebug() << "Have a null QNAM, uh oh";
emit info( requestId, caller, type, input, QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return;
}
switch ( type )
switch ( requestData.type )
{
case InfoArtistSimilars:
{
lastfm::Artist a( criteria["artist"] );
QNetworkReply* reply = a.getSimilar();
reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) );
reply->setProperty( "origData", input );
reply->setProperty( "caller", caller );
reply->setProperty( "type", (uint)( type ) );
reply->setProperty( "requestId", requestId );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( similarArtistsReturned() ) );
return;
@ -387,11 +384,8 @@ LastFmPlugin::notInCacheSlot( uint requestId, const QHash<QString, QString> crit
{
lastfm::Artist a( criteria["artist"] );
QNetworkReply* reply = a.getTopTracks();
reply->setProperty( "customData", QVariant::fromValue<QVariantMap>( customData ) );
reply->setProperty( "origData", input );
reply->setProperty( "caller", caller );
reply->setProperty( "type", (uint)( type ) );
reply->setProperty( "requestId", requestId );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( topTracksReturned() ) );
return;
@ -405,11 +399,8 @@ LastFmPlugin::notInCacheSlot( uint requestId, const QHash<QString, QString> crit
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( "customData", QVariant::fromValue<QVariantMap>( customData ) );
reply->setProperty( "origData", input );
reply->setProperty( "caller", caller );
reply->setProperty( "type", (uint)( type ) );
reply->setProperty( "requestId", requestId );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
return;
@ -422,11 +413,8 @@ LastFmPlugin::notInCacheSlot( uint requestId, const QHash<QString, QString> crit
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( "customData", QVariant::fromValue<QVariantMap>( customData ) );
reply->setProperty( "origData", input );
reply->setProperty( "caller", caller );
reply->setProperty( "type", (uint)( type ) );
reply->setProperty( "requestId", requestId );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) );
return;
@ -435,7 +423,7 @@ LastFmPlugin::notInCacheSlot( uint requestId, const QHash<QString, QString> crit
default:
{
qDebug() << "Couldn't figure out what to do with this type of request after cache miss";
emit info( requestId, caller, type, input, QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return;
}
}
@ -462,21 +450,18 @@ LastFmPlugin::similarArtistsReturned()
returnedData["artists"] = al;
returnedData["score"] = sl;
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info(
reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
type,
reply->property( "origData" ),
returnedData,
customData
requestData,
returnedData
);
InfoCriteriaHash origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash>();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = origData["artist"];
emit updateCache( criteria, 2419200000, type, returnedData );
emit updateCache( criteria, 2419200000, requestData.type, returnedData );
}
@ -495,21 +480,18 @@ LastFmPlugin::topTracksReturned()
QVariantMap returnedData;
returnedData["tracks"] = topTracks;
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info(
reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
type,
reply->property( "origData" ),
returnedData,
customData
requestData,
returnedData
);
InfoCriteriaHash origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash>();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = origData["artist"];
emit updateCache( criteria, 2419200000, type, returnedData );
emit updateCache( criteria, 2419200000, requestData.type, returnedData );
}
@ -525,9 +507,7 @@ LastFmPlugin::coverArtReturned()
if ( ba.isNull() || !ba.length() )
{
qDebug() << "Uh oh, null byte array";
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData );
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
foreach ( const QUrl& url, m_badUrls )
@ -540,41 +520,33 @@ LastFmPlugin::coverArtReturned()
returnedData["imgbytes"] = ba;
returnedData["url"] = reply->url().toString();
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info(
reply->property( "requestId" ).toUInt(),
reply->property( "caller" ).toString(),
type,
reply->property( "origData" ),
returnedData,
customData
requestData,
returnedData
);
InfoCriteriaHash origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash>();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = origData["artist"];
criteria["album"] = origData["album"];
emit updateCache( criteria, 2419200000, type, returnedData );
emit updateCache( criteria, 2419200000, requestData.type, returnedData );
}
else
{
if ( !lastfm::nam() )
{
qDebug() << "Uh oh, nam is null";
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData );
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
// Follow HTTP redirect
QNetworkRequest req( redir );
QNetworkReply* newReply = lastfm::nam()->get( req );
newReply->setProperty( "origData", reply->property( "origData" ) );
newReply->setProperty( "customData", reply->property( "customData" ) );
newReply->setProperty( "caller", reply->property( "caller" ) );
newReply->setProperty( "type", reply->property( "type" ) );
newReply->setProperty( "requestId", reply->property( "requestId" ) );
newReply->setProperty( "requestData", reply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
}
@ -594,9 +566,7 @@ LastFmPlugin::artistImagesReturned()
if ( ba.isNull() || !ba.length() )
{
qDebug() << "Uh oh, null byte array";
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData );
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
foreach ( const QUrl& url, m_badUrls )
@ -608,33 +578,28 @@ LastFmPlugin::artistImagesReturned()
returnedData["imgbytes"] = ba;
returnedData["url"] = reply->url().toString();
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), returnedData, customData );
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
emit info( reply->property( "requestId" ).toUInt(), requestData, returnedData );
InfoCriteriaHash origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash>();
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = origData["artist"];
emit updateCache( criteria, 2419200000, type, returnedData );
emit updateCache( criteria, 2419200000, requestData.type, returnedData );
}
else
{
if ( !lastfm::nam() )
{
qDebug() << "Uh oh, nam is null";
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
QVariantMap customData = reply->property( "customData" ).value< QVariantMap >();
emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), type, reply->property( "origData" ), QVariant(), customData );
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
// Follow HTTP redirect
QNetworkRequest req( redir );
QNetworkReply* newReply = lastfm::nam()->get( req );
newReply->setProperty( "origData", reply->property( "origData" ) );
newReply->setProperty( "customData", reply->property( "customData" ) );
newReply->setProperty( "caller", reply->property( "caller" ) );
newReply->setProperty( "type", reply->property( "type" ) );
newReply->setProperty( "requestId", reply->property( "requestId" ) );
newReply->setProperty( "requestData", reply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( artistImagesReturned() ) );
}

View File

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

View File

@ -51,17 +51,17 @@ MusixMatchPlugin::namChangedSlot( QNetworkAccessManager *nam )
}
void
MusixMatchPlugin::getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
MusixMatchPlugin::getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO;
if( !isValidTrackData( requestId, caller, input, customData ) || !input.canConvert< QVariantMap >() || m_nam.isNull() || type != Tomahawk::InfoSystem::InfoTrackLyrics )
if( !isValidTrackData( requestId, requestData ) || !requestData.input.canConvert< QVariantMap >() || m_nam.isNull() || requestData.type != Tomahawk::InfoSystem::InfoTrackLyrics )
return;
QVariantMap hash = input.value< QVariantMap >();
QVariantMap hash = requestData.input.value< QVariantMap >();
QString artist = hash["artistName"].toString();
QString track = hash["trackName"].toString();
if( artist.isEmpty() || track.isEmpty() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData );
emit info( requestId, requestData, QVariant() );
return;
}
qDebug() << "artist is " << artist << ", track is " << track;
@ -71,34 +71,32 @@ MusixMatchPlugin::getInfo( uint requestId, const QString caller, const Tomahawk:
url.addQueryItem( "q_artist", artist );
url.addQueryItem( "q_track", track );
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) );
reply->setProperty( "customData", QVariant::fromValue< QVariantMap >( customData ) );
reply->setProperty( "origData", input );
reply->setProperty( "caller", caller );
reply->setProperty( "requestId", requestId );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( trackSearchSlot() ) );
}
bool
MusixMatchPlugin::isValidTrackData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData )
MusixMatchPlugin::isValidTrackData( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO;
if ( input.isNull() || !input.isValid() || !input.canConvert< QVariantMap >() )
if ( requestData.input.isNull() || !requestData.input.isValid() || !requestData.input.canConvert< QVariantMap >() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData );
emit info( requestId, requestData, QVariant() );
qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert";
return false;
}
QVariantMap hash = input.value< QVariantMap >();
if ( hash["trackName"].toString().isEmpty() )
QVariantMap hash = requestData.input.value< QVariantMap >();
if ( hash[ "trackName" ].toString().isEmpty() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData );
emit info( requestId, requestData, QVariant() );
qDebug() << "MusixMatchPlugin::isValidTrackData: Track name is empty";
return false;
}
if ( hash["artistName"].toString().isEmpty() )
if ( hash[ "artistName" ].toString().isEmpty() )
{
emit info( requestId, caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData );
emit info( requestId, requestData, QVariant() );
qDebug() << "MusixMatchPlugin::isValidTrackData: No artist name found";
return false;
}
@ -111,17 +109,15 @@ MusixMatchPlugin::trackSearchSlot()
qDebug() << Q_FUNC_INFO;
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
if ( !oldReply )
{
emit info( 0, QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), QVariantMap() );
return;
}
return; //timeout will handle it
QDomDocument doc;
doc.setContent(oldReply->readAll());
qDebug() << doc.toString();
QDomNodeList domNodeList = doc.elementsByTagName("track_id");
if (domNodeList.isEmpty())
if ( domNodeList.isEmpty() )
{
emit info( oldReply->property( "requestId" ).toUInt(), oldReply->property( "caller" ).toString(), Tomahawk::InfoSystem::InfoTrackLyrics, oldReply->property( "origData" ), QVariant(), oldReply->property( "customData" ).value< QVariantMap >() );
emit info( oldReply->property( "requestId" ).toUInt(), oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
QString track_id = domNodeList.at(0).toElement().text();
@ -130,10 +126,8 @@ MusixMatchPlugin::trackSearchSlot()
url.addQueryItem( "apikey", m_apiKey );
url.addQueryItem( "track_id", track_id );
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) );
newReply->setProperty( "origData", oldReply->property( "origData" ) );
newReply->setProperty( "customData", oldReply->property( "customData" ) );
newReply->setProperty( "caller", oldReply->property( "caller" ) );
newReply->setProperty( "requestId", oldReply->property( "requestId" ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( trackLyricsSlot() ) );
}
@ -143,19 +137,17 @@ MusixMatchPlugin::trackLyricsSlot()
qDebug() << Q_FUNC_INFO;
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
if ( !reply )
{
emit info( 0, QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), QVariantMap() );
return;
}
return; //timeout will handle it
QDomDocument doc;
doc.setContent( reply->readAll() );
QDomNodeList domNodeList = doc.elementsByTagName( "lyrics_body" );
if ( domNodeList.isEmpty() )
{
emit info( reply->property( "requestId" ).toUInt(), reply->property( "caller" ).toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property( "origData" ), QVariant(), reply->property( "customData" ).value< QVariantMap >() );
emit info( reply->property( "requestId" ).toUInt(), 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( "caller" ).toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property( "origData" ), QVariant( lyrics ), reply->property( "customData" ).value<QVariantMap>() );
emit info( reply->property( "requestId" ).toUInt(), reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant( lyrics ) );
}

View File

@ -45,27 +45,24 @@ public slots:
void namChangedSlot( QNetworkAccessManager *nam );
protected slots:
virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData );
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data )
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data )
{
Q_UNUSED( caller );
Q_UNUSED( type );
Q_UNUSED( data );
}
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 notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{
Q_UNUSED( requestId );
Q_UNUSED( criteria );
Q_UNUSED( caller );
Q_UNUSED( type );
Q_UNUSED( input );
Q_UNUSED( customData );
Q_UNUSED( requestData );
}
private:
bool isValidTrackData( uint requestId, const QString &caller, const QVariant &input, const QVariantMap &customData );
bool isValidTrackData( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData );
QString m_apiKey;

View File

@ -101,7 +101,7 @@ AdiumPlugin::settingsChanged()
void
AdiumPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
AdiumPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input )
{
qDebug() << Q_FUNC_INFO;

View File

@ -39,28 +39,22 @@ public:
virtual ~AdiumPlugin();
protected slots:
virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
Q_UNUSED( requestId );
Q_UNUSED( caller );
Q_UNUSED( type );
Q_UNUSED( input );
Q_UNUSED( customData );
Q_UNUSED( requestData );
}
void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input );
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
public slots:
void namChangedSlot( QNetworkAccessManager* /*nam*/ ) {} // 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 )
virtual void notInCacheSlot( uint requestId, const Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{
Q_UNUSED( requestId );
Q_UNUSED( criteria );
Q_UNUSED( caller );
Q_UNUSED( type );
Q_UNUSED( input );
Q_UNUSED( customData );
Q_UNUSED( requestData );
}
private slots:

View File

@ -59,7 +59,7 @@ FdoNotifyPlugin::~FdoNotifyPlugin()
}
void
FdoNotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant pushData )
FdoNotifyPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant pushData )
{
Q_UNUSED( caller );
qDebug() << Q_FUNC_INFO;

View File

@ -38,25 +38,19 @@ public:
virtual void namChangedSlot( QNetworkAccessManager* ) {}
protected slots:
virtual void getInfo( uint requestId, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariantMap customData )
virtual void getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData )
{
Q_UNUSED( requestId );
Q_UNUSED( caller );
Q_UNUSED( type );
Q_UNUSED( input );
Q_UNUSED( customData );
Q_UNUSED( requestData );
}
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant pushData );
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant pushData );
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 notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{
Q_UNUSED( requestId );
Q_UNUSED( criteria );
Q_UNUSED( caller );
Q_UNUSED( type );
Q_UNUSED( input );
Q_UNUSED( customData );
Q_UNUSED( requestData );
}
};

View File

@ -50,8 +50,8 @@ InfoSystem::instance()
}
InfoSystem::InfoSystem(QObject *parent)
: QObject(parent)
InfoSystem::InfoSystem( QObject *parent )
: QObject( parent )
, m_infoSystemCacheThreadController( 0 )
, m_infoSystemWorkerThreadController( 0 )
{
@ -73,12 +73,12 @@ InfoSystem::InfoSystem(QObject *parent)
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( newNam() ) );
connect( m_cache.data(), SIGNAL( info( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
m_worker.data(), SLOT( infoSlot( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), Qt::UniqueConnection );
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_worker.data(), SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
this, SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ), Qt::UniqueConnection );
connect( m_worker.data(), SIGNAL( finished( QString ) ), this, SIGNAL( finished( QString) ), Qt::UniqueConnection );
connect( m_worker.data(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
this, SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
connect( m_worker.data(), SIGNAL( finished( QString ) ), this, SIGNAL( finished( QString ) ), Qt::UniqueConnection );
}
InfoSystem::~InfoSystem()
@ -119,18 +119,25 @@ InfoSystem::newNam() const
void
InfoSystem::getInfo( const QString &caller, const InfoType type, const QVariant& input, QVariantMap customData, uint timeoutMillis )
InfoSystem::getInfo( const InfoRequestData &requestData, uint timeoutMillis )
{
qDebug() << Q_FUNC_INFO;
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 ), Q_ARG( uint, timeoutMillis ) );
QMetaObject::invokeMethod( m_worker.data(), "getInfo", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ), Q_ARG( uint, timeoutMillis ) );
}
void
InfoSystem::getInfo( const QString &caller, const InfoTypeMap &inputMap, QVariantMap customData, const InfoTimeoutMap &timeoutMap )
InfoSystem::getInfo( const QString &caller, const InfoTypeMap &inputMap, const QVariantMap &customData, const InfoTimeoutMap &timeoutMap )
{
InfoRequestData requestData;
requestData.caller = caller;
requestData.customData = customData;
Q_FOREACH( InfoType type, inputMap.keys() )
QMetaObject::invokeMethod( m_worker.data(), "getInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, inputMap[ type ] ), Q_ARG( QVariantMap, customData ), Q_ARG( uint, ( timeoutMap.contains( type ) ? timeoutMap[ type ] : 3000 ) ) );
{
requestData.type = type;
requestData.input = inputMap[ type ];
QMetaObject::invokeMethod( m_worker.data(), "getInfo", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ), Q_ARG( uint, ( timeoutMap.contains( type ) ? timeoutMap[ type ] : 3000 ) ) );
}
}

View File

@ -132,15 +132,15 @@ public:
QSet< InfoType > supportedPushTypes() const { return m_supportedPushTypes; }
signals:
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 getCachedInfo( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData );
void info( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void updateCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64, Tomahawk::InfoSystem::InfoType type, QVariant output );
void updateCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
protected slots:
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 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 getInfo( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data ) = 0;
virtual void notInCacheSlot( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
virtual void namChangedSlot( QNetworkAccessManager *nam ) = 0;
@ -165,13 +165,13 @@ public:
InfoSystem( QObject *parent );
~InfoSystem();
void getInfo( const QString &caller, const InfoType type, const QVariant &input, QVariantMap customData, uint timeoutMillis = 3000 );
void getInfo( const QString &caller, const InfoTypeMap &inputMap, QVariantMap customData, const InfoTimeoutMap &timeoutMap = InfoTimeoutMap() );
void getInfo( const InfoRequestData &requestData, uint timeoutMillis = 3000 );
void getInfo( const QString &caller, const InfoTypeMap &inputMap, const QVariantMap &customData, const InfoTimeoutMap &timeoutMap = InfoTimeoutMap() );
void pushInfo( const QString &caller, const InfoType type, const QVariant &input );
void pushInfo( const QString &caller, const InfoTypeMap &input );
signals:
void info( QString target, Tomahawk::InfoSystem::InfoType, QVariant input, QVariant output, QVariantMap customData );
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void finished( QString target );
public slots:
@ -208,6 +208,7 @@ inline uint qHash( Tomahawk::InfoSystem::InfoCriteriaHash hash )
return returnval;
}
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoRequestData );
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap );
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCriteriaHash );
Q_DECLARE_METATYPE( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > );

View File

@ -84,26 +84,26 @@ InfoSystemCache::pruneTimerFired()
void
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 )
InfoSystemCache::getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData )
{
qDebug() << Q_FUNC_INFO;
const QString criteriaHashVal = criteriaMd5( criteria );
QHash< QString, QString > fileLocationHash = m_fileLocationCache[type];
QHash< QString, QString > fileLocationHash = m_fileLocationCache[ requestData.type ];
if ( !fileLocationHash.contains( criteriaHashVal ) )
{
if ( !fileLocationHash.isEmpty() )
{
//We already know of some values, so no need to re-read the directory again as it's already happened
emit notInCache( requestId, criteria, caller, type, input, customData );
emit notInCache( requestId, criteria, requestData );
return;
}
const QString cacheDir = m_cacheBaseDir + QString::number( (int)type );
const QString cacheDir = m_cacheBaseDir + QString::number( (int)requestData.type );
QDir dir( cacheDir );
if ( !dir.exists() )
{
//Dir doesn't exist so clearly not in cache
emit notInCache( requestId, criteria, caller, type, input, customData );
emit notInCache( requestId, criteria, requestData );
return;
}
@ -111,20 +111,20 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, const Tomahawk::InfoSystem::
foreach ( QFileInfo file, fileList )
{
QString baseName = file.baseName();
fileLocationHash[baseName] = file.canonicalFilePath();
fileLocationHash[ baseName ] = file.canonicalFilePath();
}
//Store what we've loaded up
m_fileLocationCache[type] = fileLocationHash;
m_fileLocationCache[ requestData.type ] = fileLocationHash;
if ( !fileLocationHash.contains( criteriaHashVal ) )
{
//Still didn't fine it? It's really not in the cache then
emit notInCache( requestId, criteria, caller, type, input, customData );
emit notInCache( requestId, criteria, requestData );
return;
}
}
QFileInfo file( fileLocationHash[criteriaHashVal] );
QFileInfo file( fileLocationHash[ criteriaHashVal ] );
qlonglong currMaxAge = file.suffix().toLongLong();
if ( currMaxAge < QDateTime::currentMSecsSinceEpoch() )
@ -135,10 +135,10 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, const Tomahawk::InfoSystem::
qDebug() << "Removed stale cache file " << file.canonicalFilePath();
fileLocationHash.remove( criteriaHashVal );
m_fileLocationCache[type] = fileLocationHash;
m_fileLocationCache[ requestData.type ] = fileLocationHash;
m_dataCache.remove( criteriaHashVal );
emit notInCache( requestId, criteria, caller, type, input, customData );
emit notInCache( requestId, criteria, requestData );
return;
}
else if ( newMaxAge > 0 )
@ -148,31 +148,31 @@ InfoSystemCache::getCachedInfoSlot( uint requestId, const Tomahawk::InfoSystem::
if ( !QFile::rename( file.canonicalFilePath(), newFilePath ) )
{
qDebug() << "Failed to move old cache file to new location!";
emit notInCache( requestId, criteria, caller, type, input, customData );
emit notInCache( requestId, criteria, requestData );
return;
}
fileLocationHash[criteriaHashVal] = newFilePath;
m_fileLocationCache[type] = fileLocationHash;
fileLocationHash[ criteriaHashVal ] = newFilePath;
m_fileLocationCache[ requestData.type ] = fileLocationHash;
}
if ( !m_dataCache.contains( criteriaHashVal ) )
{
QSettings cachedSettings( fileLocationHash[criteriaHashVal], QSettings::IniFormat );
QSettings cachedSettings( fileLocationHash[ criteriaHashVal ], QSettings::IniFormat );
QVariant output = cachedSettings.value( "data" );
m_dataCache.insert( criteriaHashVal, new QVariant( output ) );
emit info( requestId, caller, type, input, output, customData );
emit info( requestId, requestData, output );
}
else
{
emit info( requestId, caller, type, input, QVariant( *(m_dataCache[criteriaHashVal]) ), customData );
emit info( requestId, requestData, QVariant( *(m_dataCache[criteriaHashVal]) ) );
}
}
void
InfoSystemCache::updateCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 maxAge, const Tomahawk::InfoSystem::InfoType type, const QVariant output )
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
{
qDebug() << Q_FUNC_INFO;

View File

@ -43,12 +43,12 @@ public:
virtual ~InfoSystemCache();
signals:
void notInCache( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, 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 notInCache( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
void info( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
public slots:
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 getCachedInfoSlot( uint requestId, Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, Tomahawk::InfoSystem::InfoRequestData requestData );
void updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
private slots:
void pruneTimerFired();

View File

@ -94,23 +94,23 @@ InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cac
{
connect(
plugin.data(),
SIGNAL( info( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
SIGNAL( info( uint, Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
this,
SLOT( infoSlot( uint, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
SLOT( infoSlot( uint, Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
Qt::UniqueConnection
);
connect(
plugin.data(),
SIGNAL( getCachedInfo( uint, Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) ),
SIGNAL( getCachedInfo( uint, Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) ),
cache.data(),
SLOT( getCachedInfoSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) )
SLOT( getCachedInfoSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) )
);
connect(
cache.data(),
SIGNAL( notInCache( uint, Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) ),
SIGNAL( notInCache( uint, Tomahawk::InfoSystem::InfoCriteriaHash, Tomahawk::InfoSystem::InfoRequestData ) ),
plugin.data(),
SLOT( notInCacheSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariantMap ) )
SLOT( notInCacheSlot( uint, Tomahawk::InfoSystem::InfoCriteriaHash, Tomahawk::InfoSystem::InfoRequestData ) )
);
connect(
plugin.data(),
@ -154,22 +154,22 @@ InfoSystemWorker::determineOrderedMatches( const InfoType type ) const
void
InfoSystemWorker::getInfo( QString caller, InfoType type, QVariant input, QVariantMap customData, uint timeoutMillis )
InfoSystemWorker::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData, uint timeoutMillis )
{
qDebug() << Q_FUNC_INFO;
QLinkedList< InfoPluginPtr > providers = determineOrderedMatches( type );
QLinkedList< InfoPluginPtr > providers = determineOrderedMatches( requestData.type );
if ( providers.isEmpty() )
{
emit info( caller, type, QVariant(), QVariant(), customData );
checkFinished( caller );
emit info( requestData, QVariant() );
checkFinished( requestData.caller );
return;
}
InfoPluginPtr ptr = providers.first();
if ( !ptr )
{
emit info( caller, type, QVariant(), QVariant(), customData );
checkFinished( caller );
emit info( requestData, QVariant() );
checkFinished( requestData.caller );
return;
}
@ -180,27 +180,27 @@ InfoSystemWorker::getInfo( QString caller, InfoType type, QVariant input, QVaria
qint64 currMs = QDateTime::currentMSecsSinceEpoch();
m_timeRequestMapper.insert( currMs + timeoutMillis, requestId );
}
qDebug() << "assigning request with requestId " << requestId << " and type " << type;
m_dataTracker[ caller ][ type ] = m_dataTracker[ caller ][ type ] + 1;
qDebug() << "current count in dataTracker for type" << type << "is" << m_dataTracker[ caller ][ type ];
qDebug() << "assigning request with requestId " << requestId << " and type " << requestData.type;
m_dataTracker[ requestData.caller ][ requestData.type ] = m_dataTracker[ requestData.caller ][ requestData.type ] + 1;
qDebug() << "current count in dataTracker for type" << requestData.type << "is" << m_dataTracker[ requestData.caller ][ requestData.type ];
InfoRequestData* data = new InfoRequestData;
data->caller = caller;
data->type = type;
data->input = input;
data->customData = customData;
data->caller = requestData.caller;
data->type = requestData.type;
data->input = requestData.input;
data->customData = requestData.customData;
m_savedRequestMap[ requestId ] = data;
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 ) );
QMetaObject::invokeMethod( ptr.data(), "getInfo", Qt::QueuedConnection, Q_ARG( uint, requestId ), Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
}
void
InfoSystemWorker::pushInfo( const QString caller, const InfoType type, const QVariant input )
InfoSystemWorker::pushInfo( QString caller, InfoType type, QVariant input )
{
qDebug() << Q_FUNC_INFO;
Q_FOREACH( InfoPluginPtr ptr, m_infoPushMap[type] )
Q_FOREACH( InfoPluginPtr ptr, m_infoPushMap[ type ] )
{
if( ptr )
QMetaObject::invokeMethod( ptr.data(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ) );
@ -209,10 +209,10 @@ InfoSystemWorker::pushInfo( const QString caller, const InfoType type, const QVa
void
InfoSystemWorker::infoSlot( uint requestId, QString target, InfoType type, QVariant input, QVariant output, QVariantMap customData )
InfoSystemWorker::infoSlot( uint requestId, Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
qDebug() << Q_FUNC_INFO << " with requestId " << requestId;
if ( m_dataTracker[ target ][ type ] == 0 )
if ( m_dataTracker[ requestData.caller ][ requestData.type ] == 0 )
{
qDebug() << Q_FUNC_INFO << " caller was not waiting for that type of data!";
return;
@ -224,13 +224,13 @@ InfoSystemWorker::infoSlot( uint requestId, QString target, InfoType type, QVari
}
m_requestSatisfiedMap[ requestId ] = true;
emit info( target, type, input, output, customData );
emit info( requestData, output );
m_dataTracker[ target ][ type ] = m_dataTracker[ target ][ type ] - 1;
qDebug() << "current count in dataTracker for target " << target << " is " << m_dataTracker[ target ][ type ];
m_dataTracker[ requestData.caller ][ requestData.type ] = m_dataTracker[ requestData.caller ][ requestData.type ] - 1;
qDebug() << "current count in dataTracker for target " << requestData.caller << " is " << m_dataTracker[ requestData.caller ][ requestData.type ];
delete m_savedRequestMap[ requestId ];
m_savedRequestMap.remove( requestId );
checkFinished( target );
checkFinished( requestData.caller );
}
@ -272,22 +272,26 @@ InfoSystemWorker::checkTimeoutsTimerFired()
//doh, timed out
qDebug() << Q_FUNC_INFO << " doh, timed out for requestId " << requestId;
InfoRequestData *savedData = m_savedRequestMap[ requestId ];
QString target = savedData->caller;
InfoType type = savedData->type;
emit info( target, type, savedData->input, QVariant(), savedData->customData );
InfoRequestData returnData;
returnData.caller = savedData->caller;
returnData.type = savedData->type;
returnData.input = savedData->input;
returnData.customData = savedData->customData;
emit info( returnData, QVariant() );
delete savedData;
m_savedRequestMap.remove( requestId );
m_dataTracker[ target ][ type ] = m_dataTracker[ target ][ type ] - 1;
qDebug() << "current count in dataTracker for target " << target << " is " << m_dataTracker[ target ][ type ];
m_dataTracker[ returnData.caller ][ returnData.type ] = m_dataTracker[ returnData.caller ][ returnData.type ] - 1;
qDebug() << "current count in dataTracker for target " << returnData.caller << " is " << m_dataTracker[ returnData.caller ][ returnData.type ];
m_requestSatisfiedMap[ requestId ] = true;
m_timeRequestMapper.remove( time, requestId );
if ( !m_timeRequestMapper.count( time ) )
m_timeRequestMapper.remove( time );
checkFinished( target );
checkFinished( returnData.caller );
}
else
{

View File

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

View File

@ -44,8 +44,8 @@ AlbumModel::AlbumModel( QObject* parent )
.scaled( QSize( 120, 120 ), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ) );
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
}
@ -311,13 +311,12 @@ AlbumModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums )
void
AlbumModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData )
AlbumModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
Q_UNUSED( customData );
qDebug() << Q_FUNC_INFO << " with caller " << caller;
qDebug() << Q_FUNC_INFO << " with caller " << requestData.caller;
if ( caller != s_tmInfoIdentifier ||
( type != Tomahawk::InfoSystem::InfoAlbumCoverArt && type != Tomahawk::InfoSystem::InfoArtistImages ) )
if ( requestData.caller != s_tmInfoIdentifier ||
( requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt && requestData.type != Tomahawk::InfoSystem::InfoArtistImages ) )
{
qDebug() << "Info of wrong type or not with our identifier";
return;
@ -329,7 +328,7 @@ AlbumModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type,
return;
}
Tomahawk::InfoSystem::InfoCriteriaHash pptr = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash pptr = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
QVariantMap returnedData = output.value< QVariantMap >();
const QByteArray ba = returnedData["imgbytes"].toByteArray();
if ( ba.length() )

View File

@ -97,7 +97,7 @@ private slots:
void onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums );
void onDataChanged();
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
private:

View File

@ -162,9 +162,13 @@ AlbumView::onScrollTimeout()
trackInfo["album"] = item->album()->name();
trackInfo["pptr"] = QString::number( (qlonglong)item );
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_tmInfoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ), QVariantMap() );
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_tmInfoIdentifier;
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
}
}

View File

@ -249,9 +249,13 @@ ArtistView::onScrollTimeout()
trackInfo["artist"] = item->artist()->name();
trackInfo["pptr"] = QString::number( (qlonglong)item );
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_tmInfoIdentifier, Tomahawk::InfoSystem::InfoArtistImages,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ), QVariantMap() );
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_tmInfoIdentifier;
requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
}

View File

@ -47,8 +47,8 @@ TreeModel::TreeModel( QObject* parent )
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ), Qt::DirectConnection );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ) );
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
}
@ -542,9 +542,13 @@ TreeModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QVaria
trackInfo["album"] = album->name();
trackInfo["pptr"] = QString::number( (qlonglong)albumitem );
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_tmInfoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ), QVariantMap() );
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_tmInfoIdentifier;
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
if ( !parent.isValid() || crows.second > 0 )
@ -600,13 +604,12 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
void
TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData )
TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
Q_UNUSED( customData );
qDebug() << Q_FUNC_INFO;
if ( caller != s_tmInfoIdentifier ||
( type != Tomahawk::InfoSystem::InfoAlbumCoverArt && type != Tomahawk::InfoSystem::InfoArtistImages ) )
if ( requestData.caller != s_tmInfoIdentifier ||
( requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt && requestData.type != Tomahawk::InfoSystem::InfoArtistImages ) )
{
qDebug() << "Info of wrong type or not with our identifier";
return;
@ -618,7 +621,7 @@ TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type,
return;
}
Tomahawk::InfoSystem::InfoCriteriaHash pptr = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
Tomahawk::InfoSystem::InfoCriteriaHash pptr = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
QVariantMap returnedData = output.value< QVariantMap >();
const QByteArray ba = returnedData["imgbytes"].toByteArray();
qDebug() << "ba.length = " << ba.length();

View File

@ -125,7 +125,7 @@ private slots:
void onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QVariant& data );
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVariant& data );
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
void onPlaybackFinished( const Tomahawk::result_ptr& result );

View File

@ -96,7 +96,6 @@ void
SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& query )
{
qDebug() << Q_FUNC_INFO;
connect( query.data(), SIGNAL( resultsAdded( const QList<Tomahawk::result_ptr>& ) ), SLOT( resolveResultsAdded( const QList<Tomahawk::result_ptr>& ) ) );
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
Pipeline::instance()->resolve( query, true );
m_gotNextItem = true;

View File

@ -64,8 +64,8 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" ).scaledToWidth( 48, Qt::SmoothTransformation );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ) );
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
@ -88,42 +88,39 @@ ArtistInfoWidget::load( const artist_ptr& artist )
Tomahawk::InfoSystem::InfoCriteriaHash artistInfo;
artistInfo["artist"] = artist->name();
InfoSystem::InfoTypeMap infoMap;
QVariantMap hash;
infoMap[InfoSystem::InfoArtistBiography] = artist->name();
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_aiInfoIdentifier;
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_aiInfoIdentifier, infoMap, hash );
requestData.input = artist->name();
requestData.type = Tomahawk::InfoSystem::InfoArtistBiography;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo );
requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_aiInfoIdentifier, Tomahawk::InfoSystem::InfoArtistImages,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo ), QVariantMap() );
requestData.type = Tomahawk::InfoSystem::InfoArtistSimilars;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_aiInfoIdentifier, Tomahawk::InfoSystem::InfoArtistSimilars,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo ), QVariantMap() );
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_aiInfoIdentifier, Tomahawk::InfoSystem::InfoArtistSongs,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo ), QVariantMap() );
requestData.type = Tomahawk::InfoSystem::InfoArtistSongs;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
void
ArtistInfoWidget::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData )
ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
Q_UNUSED( input );
Q_UNUSED( customData );
if ( caller != s_aiInfoIdentifier )
if ( requestData.caller != s_aiInfoIdentifier )
{
// qDebug() << "Info of wrong type or not with our identifier";
return;
}
qDebug() << Q_FUNC_INFO << caller << type << s_aiInfoIdentifier;
qDebug() << Q_FUNC_INFO << requestData.caller << requestData.type << s_aiInfoIdentifier;
InfoSystem::InfoCriteriaHash trackInfo;
trackInfo = input.value< InfoSystem::InfoCriteriaHash >();
trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >();
if ( output.canConvert< QVariantMap >() )
{
@ -135,7 +132,7 @@ ArtistInfoWidget::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType
}
QVariantMap returnedData = output.value< QVariantMap >();
switch ( type )
switch ( requestData.type )
{
case InfoSystem::InfoArtistBiography:
{

View File

@ -86,7 +86,7 @@ protected:
void changeEvent( QEvent* e );
private slots:
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
private:

View File

@ -38,8 +38,8 @@ Scrobbler::Scrobbler( QObject* parent )
SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, QVariantMap ) ) );
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( AudioEngine::instance(), SIGNAL( started( const Tomahawk::result_ptr& ) ),
SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection );
@ -80,9 +80,14 @@ Scrobbler::trackStarted( const Tomahawk::result_ptr& track )
trackInfo["artist"] = track->artist()->name();
trackInfo["album"] = track->album()->name();
trackInfo["duration"] = QString::number( track->duration() );
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_scInfoIdentifier, Tomahawk::InfoSystem::InfoSubmitNowPlaying,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_scInfoIdentifier;
requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
m_scrobblePoint = ScrobblePoint( track->duration() / 2 );
}
@ -135,13 +140,10 @@ Scrobbler::scrobble()
void
Scrobbler::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData )
Scrobbler::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
Q_UNUSED( type );
Q_UNUSED( input );
Q_UNUSED( output );
Q_UNUSED( customData );
if ( caller == s_scInfoIdentifier )
if ( requestData.caller == s_scInfoIdentifier )
qDebug() << Q_FUNC_INFO;
}

View File

@ -45,7 +45,7 @@ public slots:
void trackStopped();
void engineTick( unsigned int secondsElapsed );
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, QVariantMap customData );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
private:

View File

@ -420,6 +420,7 @@ TomahawkApp::registerMetaTypes()
qRegisterMetaType< QMap< QString, QMap< QString, QString > > >( "Tomahawk::InfoSystem::InfoGenericMap" );
qRegisterMetaType< QHash< QString, QString > >( "Tomahawk::InfoSystem::InfoCriteriaHash" );
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
qRegisterMetaType< QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > >( "QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache >" );
qRegisterMetaType< DirLister::Mode >("DirLister::Mode");