mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-05 00:22:31 +02:00
Requests for cover art from lastfm now go through the infosystem caching mechanism. It's not actually storing a cache yet but the information flow works (at least, for cache misses :-) )
This commit is contained in:
parent
1da0a34d89
commit
2b85beb704
@ -93,7 +93,8 @@ enum InfoType {
|
||||
|
||||
typedef QMap< InfoType, QVariant > InfoMap;
|
||||
typedef QMap< QString, QMap< QString, QString > > InfoGenericMap;
|
||||
typedef QHash< QString, QVariant > InfoCustomDataHash;
|
||||
typedef QHash< QString, QVariant > InfoCustomData;
|
||||
typedef QHash< QString, QString > InfoCacheCriteria;
|
||||
|
||||
class InfoPlugin : public QObject
|
||||
{
|
||||
@ -107,16 +108,17 @@ public:
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomDataHash customData ) = 0;
|
||||
virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData ) = 0;
|
||||
|
||||
signals:
|
||||
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData );
|
||||
void getCachedInfo( QHash< QString, QString > criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData );
|
||||
void getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void updateCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void finished( QString, Tomahawk::InfoSystem::InfoType );
|
||||
|
||||
public slots:
|
||||
//FIXME: Make pure virtual when everything supports it
|
||||
void notInCacheSlot( QHash<QString, QString> criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData )
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||
{
|
||||
}
|
||||
|
||||
@ -137,17 +139,17 @@ public:
|
||||
|
||||
void registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &types );
|
||||
|
||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomDataHash customData );
|
||||
void getInfo( const QString &caller, const InfoMap &input, InfoCustomDataHash customData );
|
||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData );
|
||||
void getInfo( const QString &caller, const InfoMap &input, InfoCustomData customData );
|
||||
|
||||
InfoSystemCache* getCache() { return m_cache; }
|
||||
|
||||
signals:
|
||||
void info( QString caller, Tomahawk::InfoSystem::InfoType, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData );
|
||||
void info( QString caller, Tomahawk::InfoSystem::InfoType, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void finished( QString target );
|
||||
|
||||
public slots:
|
||||
void infoSlot( QString target, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData );
|
||||
void infoSlot( QString target, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void finishedSlot( QString target, Tomahawk::InfoSystem::InfoType type);
|
||||
|
||||
private:
|
||||
@ -169,6 +171,7 @@ private:
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCustomDataHash );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCustomData );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCacheCriteria );
|
||||
|
||||
#endif // TOMAHAWK_INFOSYSTEM_H
|
||||
|
@ -168,8 +168,8 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
||||
|
||||
connect( TomahawkApp::instance()->infoSystem(),
|
||||
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash ) ),
|
||||
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash ) ) );
|
||||
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) );
|
||||
|
||||
connect( TomahawkApp::instance()->infoSystem(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
||||
|
||||
@ -252,17 +252,17 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||
QString artistName = result->artist()->name();
|
||||
QString albumName = result->album()->name();
|
||||
|
||||
Tomahawk::InfoSystem::InfoCustomDataHash trackInfo;
|
||||
Tomahawk::InfoSystem::InfoCustomData trackInfo;
|
||||
|
||||
trackInfo["artist"] = QVariant::fromValue< QString >( result->artist()->name() );
|
||||
trackInfo["album"] = QVariant::fromValue< QString >( result->album()->name() );
|
||||
TomahawkApp::instance()->infoSystem()->getInfo(
|
||||
s_infoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomDataHash >( trackInfo ), Tomahawk::InfoSystem::InfoCustomDataHash() );
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( trackInfo ), Tomahawk::InfoSystem::InfoCustomData() );
|
||||
}
|
||||
|
||||
void
|
||||
AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData )
|
||||
AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( caller != s_infoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
||||
@ -277,13 +277,13 @@ AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType ty
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !output.canConvert< Tomahawk::InfoSystem::InfoCustomDataHash >() )
|
||||
if ( !output.canConvert< Tomahawk::InfoSystem::InfoCustomData >() )
|
||||
{
|
||||
qDebug() << "Cannot convert fetched art from a QByteArray";
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoCustomDataHash returnedData = output.value< Tomahawk::InfoSystem::InfoCustomDataHash >();
|
||||
Tomahawk::InfoSystem::InfoCustomData returnedData = output.value< Tomahawk::InfoSystem::InfoCustomData >();
|
||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
||||
if ( ba.length() )
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ signals:
|
||||
public slots:
|
||||
void onRepeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void onShuffleModeChanged( bool enabled );
|
||||
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData );
|
||||
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
protected:
|
||||
|
@ -41,7 +41,7 @@ EchoNestPlugin::~EchoNestPlugin()
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
void EchoNestPlugin::getInfo(const QString &caller, const InfoType type, const QVariant& data, InfoCustomDataHash customData)
|
||||
void EchoNestPlugin::getInfo(const QString &caller, const InfoType type, const QVariant& data, InfoCustomData customData)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -65,7 +65,7 @@ void EchoNestPlugin::getInfo(const QString &caller, const InfoType type, const Q
|
||||
}
|
||||
}
|
||||
|
||||
void EchoNestPlugin::getSongProfile(const QString &caller, const QVariant& data, InfoCustomDataHash &customData, const QString &item)
|
||||
void EchoNestPlugin::getSongProfile(const QString &caller, const QVariant& data, InfoCustomData &customData, const QString &item)
|
||||
{
|
||||
//WARNING: Totally not implemented yet
|
||||
|
||||
@ -80,7 +80,7 @@ void EchoNestPlugin::getSongProfile(const QString &caller, const QVariant& data,
|
||||
// connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot()));
|
||||
}
|
||||
|
||||
void EchoNestPlugin::getArtistBiography(const QString &caller, const QVariant& data, InfoCustomDataHash &customData)
|
||||
void EchoNestPlugin::getArtistBiography(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
||||
{
|
||||
if( !isValidArtistData( caller, data, customData ) )
|
||||
return;
|
||||
@ -94,7 +94,7 @@ void EchoNestPlugin::getArtistBiography(const QString &caller, const QVariant& d
|
||||
connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot()));
|
||||
}
|
||||
|
||||
void EchoNestPlugin::getArtistFamiliarity(const QString &caller, const QVariant& data, InfoCustomDataHash &customData)
|
||||
void EchoNestPlugin::getArtistFamiliarity(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
||||
{
|
||||
if( !isValidArtistData( caller, data, customData ) )
|
||||
return;
|
||||
@ -109,7 +109,7 @@ void EchoNestPlugin::getArtistFamiliarity(const QString &caller, const QVariant&
|
||||
connect(reply, SIGNAL(finished()), SLOT(getArtistFamiliaritySlot()));
|
||||
}
|
||||
|
||||
void EchoNestPlugin::getArtistHotttnesss(const QString &caller, const QVariant& data, InfoCustomDataHash &customData)
|
||||
void EchoNestPlugin::getArtistHotttnesss(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
||||
{
|
||||
if( !isValidArtistData( caller, data, customData ) )
|
||||
return;
|
||||
@ -123,7 +123,7 @@ void EchoNestPlugin::getArtistHotttnesss(const QString &caller, const QVariant&
|
||||
connect(reply, SIGNAL(finished()), SLOT(getArtistHotttnesssSlot()));
|
||||
}
|
||||
|
||||
void EchoNestPlugin::getArtistTerms(const QString &caller, const QVariant& data, InfoCustomDataHash &customData)
|
||||
void EchoNestPlugin::getArtistTerms(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
||||
{
|
||||
if( !isValidArtistData( caller, data, customData ) )
|
||||
return;
|
||||
@ -137,7 +137,7 @@ void EchoNestPlugin::getArtistTerms(const QString &caller, const QVariant& data,
|
||||
connect(reply, SIGNAL(finished()), SLOT(getArtistTermsSlot()));
|
||||
}
|
||||
|
||||
void EchoNestPlugin::getMiscTopTerms(const QString &caller, const QVariant& data, InfoCustomDataHash& customData)
|
||||
void EchoNestPlugin::getMiscTopTerms(const QString &caller, const QVariant& data, InfoCustomData& customData)
|
||||
{
|
||||
QNetworkReply* reply = Echonest::Artist::topTerms( 20 );
|
||||
m_replyMap[reply] = customData;
|
||||
@ -230,7 +230,7 @@ void EchoNestPlugin::getMiscTopSlot()
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
bool EchoNestPlugin::isValidArtistData(const QString &caller, const QVariant& data, InfoCustomDataHash &customData)
|
||||
bool EchoNestPlugin::isValidArtistData(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
||||
{
|
||||
if (data.isNull() || !data.isValid() || !data.canConvert<QString>())
|
||||
{
|
||||
@ -246,7 +246,7 @@ bool EchoNestPlugin::isValidArtistData(const QString &caller, const QVariant& da
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EchoNestPlugin::isValidTrackData(const QString &caller, const QVariant& data, InfoCustomDataHash &customData)
|
||||
bool EchoNestPlugin::isValidTrackData(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
||||
{
|
||||
if (data.isNull() || !data.isValid() || !data.canConvert<QString>())
|
||||
{
|
||||
|
@ -42,18 +42,18 @@ public:
|
||||
EchoNestPlugin(QObject *parent);
|
||||
virtual ~EchoNestPlugin();
|
||||
|
||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomDataHash customData );
|
||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData );
|
||||
|
||||
private:
|
||||
void getSongProfile( const QString &caller, const QVariant &data, InfoCustomDataHash &customData, const QString &item = QString() );
|
||||
void getArtistBiography ( const QString &caller, const QVariant &data, InfoCustomDataHash &customData );
|
||||
void getArtistFamiliarity( const QString &caller, const QVariant &data, InfoCustomDataHash &customData );
|
||||
void getArtistHotttnesss( const QString &caller, const QVariant &data, InfoCustomDataHash &customData );
|
||||
void getArtistTerms( const QString &caller, const QVariant &data, InfoCustomDataHash &customData );
|
||||
void getMiscTopTerms( const QString &caller, const QVariant &data, InfoCustomDataHash &customData );
|
||||
void getSongProfile( const QString &caller, const QVariant &data, InfoCustomData &customData, const QString &item = QString() );
|
||||
void getArtistBiography ( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
||||
void getArtistFamiliarity( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
||||
void getArtistHotttnesss( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
||||
void getArtistTerms( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
||||
void getMiscTopTerms( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
||||
|
||||
bool isValidArtistData( const QString &caller, const QVariant& data, InfoCustomDataHash& customData );
|
||||
bool isValidTrackData( const QString &caller, const QVariant& data, InfoCustomDataHash& customData );
|
||||
bool isValidArtistData( const QString &caller, const QVariant& data, InfoCustomData& customData );
|
||||
bool isValidTrackData( const QString &caller, const QVariant& data, InfoCustomData& customData );
|
||||
Echonest::Artist artistFromReply( QNetworkReply* );
|
||||
|
||||
private slots:
|
||||
@ -64,7 +64,7 @@ private slots:
|
||||
void getMiscTopSlot();
|
||||
|
||||
private:
|
||||
QHash< QNetworkReply*, InfoCustomDataHash > m_replyMap;
|
||||
QHash< QNetworkReply*, InfoCustomData > m_replyMap;
|
||||
QHash< QNetworkReply*, QString > m_callerMap;
|
||||
};
|
||||
|
||||
|
@ -92,7 +92,7 @@ LastFmPlugin::~LastFmPlugin()
|
||||
}
|
||||
|
||||
void
|
||||
LastFmPlugin::dataError( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash &customData )
|
||||
LastFmPlugin::dataError( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||
{
|
||||
emit info( caller, type, data, QVariant(), customData );
|
||||
emit finished( caller, type );
|
||||
@ -100,7 +100,7 @@ LastFmPlugin::dataError( const QString &caller, const InfoType type, const QVari
|
||||
}
|
||||
|
||||
void
|
||||
LastFmPlugin::getInfo( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash customData )
|
||||
LastFmPlugin::getInfo( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( type == InfoMiscSubmitNowPlaying )
|
||||
@ -114,14 +114,14 @@ LastFmPlugin::getInfo( const QString &caller, const InfoType type, const QVarian
|
||||
}
|
||||
|
||||
void
|
||||
LastFmPlugin::nowPlaying( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash &customData )
|
||||
LastFmPlugin::nowPlaying( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||
{
|
||||
if ( !data.canConvert< Tomahawk::InfoSystem::InfoCustomDataHash >() || !m_scrobbler )
|
||||
if ( !data.canConvert< Tomahawk::InfoSystem::InfoCustomData >() || !m_scrobbler )
|
||||
{
|
||||
dataError( caller, type, data, customData );
|
||||
return;
|
||||
}
|
||||
InfoCustomDataHash hash = data.value< Tomahawk::InfoSystem::InfoCustomDataHash >();
|
||||
InfoCustomData hash = data.value< Tomahawk::InfoSystem::InfoCustomData >();
|
||||
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) || !hash.contains( "duration" ) )
|
||||
{
|
||||
dataError( caller, type, data, customData );
|
||||
@ -143,7 +143,7 @@ LastFmPlugin::nowPlaying( const QString &caller, const InfoType type, const QVar
|
||||
}
|
||||
|
||||
void
|
||||
LastFmPlugin::scrobble( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash &customData )
|
||||
LastFmPlugin::scrobble( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||
{
|
||||
Q_ASSERT( QThread::currentThread() == thread() );
|
||||
|
||||
@ -162,33 +162,50 @@ LastFmPlugin::scrobble( const QString &caller, const InfoType type, const QVaria
|
||||
}
|
||||
|
||||
void
|
||||
LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash &customData )
|
||||
LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( !data.canConvert< Tomahawk::InfoSystem::InfoCustomDataHash >() )
|
||||
if ( !data.canConvert< Tomahawk::InfoSystem::InfoCustomData >() )
|
||||
{
|
||||
dataError( caller, type, data, customData );
|
||||
return;
|
||||
}
|
||||
InfoCustomDataHash hash = data.value< Tomahawk::InfoSystem::InfoCustomDataHash >();
|
||||
InfoCustomData hash = data.value< Tomahawk::InfoSystem::InfoCustomData >();
|
||||
if ( !hash.contains( "artist" ) || !hash.contains( "album" ) )
|
||||
{
|
||||
dataError( caller, type, data, customData );
|
||||
return;
|
||||
}
|
||||
|
||||
QString artistName = hash["artist"].toString();
|
||||
QString albumName = hash["album"].toString();
|
||||
Tomahawk::InfoSystem::InfoCacheCriteria criteria;
|
||||
criteria["artist"] = hash["artist"].toString();
|
||||
criteria["album"] = hash["album"].toString();
|
||||
|
||||
QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=album.imageredirect&artist=%1&album=%2&size=medium&api_key=7a90f6672a04b809ee309af169f34b8b";
|
||||
QNetworkRequest req( imgurl.arg( artistName ).arg( albumName ) );
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
|
||||
reply->setProperty("customData", QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomDataHash>(customData));
|
||||
reply->setProperty("origData", data);
|
||||
reply->setProperty("caller", caller);
|
||||
reply->setProperty("type", (uint)(type) );
|
||||
emit getCachedInfo( criteria, caller, type, data, customData );
|
||||
}
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
|
||||
void
|
||||
LastFmPlugin::notInCacheSlot( QHash<QString, QString> criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( type == InfoAlbumCoverArt )
|
||||
{
|
||||
QString artistName = criteria["artist"];
|
||||
QString albumName = criteria["album"];
|
||||
|
||||
QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=album.imageredirect&artist=%1&album=%2&size=medium&api_key=7a90f6672a04b809ee309af169f34b8b";
|
||||
QNetworkRequest req( imgurl.arg( artistName ).arg( albumName ) );
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
|
||||
reply->setProperty( "customData", QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomData>( customData ) );
|
||||
reply->setProperty( "origData", input );
|
||||
reply->setProperty( "caller", caller );
|
||||
reply->setProperty( "type", (uint)(type) );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( coverArtReturned() ) );
|
||||
return;
|
||||
}
|
||||
else
|
||||
qDebug() << "Couldn't figure out what to do with this type of request after cache miss";
|
||||
}
|
||||
|
||||
void
|
||||
@ -200,17 +217,26 @@ LastFmPlugin::coverArtReturned()
|
||||
if ( redir.isEmpty() )
|
||||
{
|
||||
const QByteArray ba = reply->readAll();
|
||||
Tomahawk::InfoSystem::InfoCustomDataHash returnedData;
|
||||
InfoCustomData returnedData;
|
||||
returnedData["imgbytes"] = ba;
|
||||
returnedData["url"] = reply->url().toString();
|
||||
|
||||
InfoCustomData customData = reply->property( "customData" ).value< Tomahawk::InfoSystem::InfoCustomData >();
|
||||
InfoType type = (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt());
|
||||
emit info(
|
||||
reply->property( "caller" ).toString(),
|
||||
(Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()),
|
||||
type,
|
||||
reply->property( "origData" ),
|
||||
returnedData,
|
||||
reply->property( "customData" ).value< Tomahawk::InfoSystem::InfoCustomDataHash >()
|
||||
customData
|
||||
);
|
||||
emit finished( reply->property( "caller" ).toString(), (Tomahawk::InfoSystem::InfoType)(reply->property( "type" ).toUInt()) );
|
||||
|
||||
InfoCustomData origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCustomData >();
|
||||
Tomahawk::InfoSystem::InfoCacheCriteria criteria;
|
||||
criteria["artist"] = origData["artist"].toString();
|
||||
criteria["album"] = origData["album"].toString();
|
||||
emit updateCache( criteria, type, returnedData );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -43,19 +43,20 @@ public:
|
||||
LastFmPlugin( QObject *parent );
|
||||
virtual ~LastFmPlugin();
|
||||
|
||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomDataHash customData );
|
||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData );
|
||||
|
||||
public slots:
|
||||
void settingsChanged();
|
||||
void onAuthenticated();
|
||||
void coverArtReturned();
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
|
||||
private:
|
||||
void fetchCoverArt( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash &customData );
|
||||
void scrobble( const QString &caller, const InfoType type, const QVariant& data, InfoCustomDataHash &customData );
|
||||
void fetchCoverArt( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData );
|
||||
void scrobble( const QString &caller, const InfoType type, const QVariant& data, InfoCustomData &customData );
|
||||
void createScrobbler();
|
||||
void nowPlaying( const QString &caller, const InfoType type, const QVariant& data, InfoCustomDataHash &customData );
|
||||
void dataError( const QString &caller, const InfoType type, const QVariant& data, InfoCustomDataHash &customData );
|
||||
void nowPlaying( const QString &caller, const InfoType type, const QVariant& data, InfoCustomData &customData );
|
||||
void dataError( const QString &caller, const InfoType type, const QVariant& data, InfoCustomData &customData );
|
||||
|
||||
lastfm::MutableTrack m_track;
|
||||
lastfm::Audioscrobbler* m_scrobbler;
|
||||
|
@ -42,12 +42,12 @@ MusixMatchPlugin::~MusixMatchPlugin()
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash customData)
|
||||
void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData customData)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if( !isValidTrackData(caller, data, customData) || !data.canConvert<Tomahawk::InfoSystem::InfoCustomDataHash>())
|
||||
if( !isValidTrackData(caller, data, customData) || !data.canConvert<Tomahawk::InfoSystem::InfoCustomData>())
|
||||
return;
|
||||
Tomahawk::InfoSystem::InfoCustomDataHash hash = data.value<Tomahawk::InfoSystem::InfoCustomDataHash>();
|
||||
Tomahawk::InfoSystem::InfoCustomData hash = data.value<Tomahawk::InfoSystem::InfoCustomData>();
|
||||
QString artist = hash["artistName"].toString();
|
||||
QString track = hash["trackName"].toString();
|
||||
if( artist.isEmpty() || track.isEmpty() )
|
||||
@ -63,24 +63,24 @@ void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const
|
||||
url.addQueryItem("q_artist", artist);
|
||||
url.addQueryItem("q_track", track);
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get(QNetworkRequest(url));
|
||||
reply->setProperty("customData", QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomDataHash>(customData));
|
||||
reply->setProperty("customData", QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomData>(customData));
|
||||
reply->setProperty("origData", data);
|
||||
reply->setProperty("caller", caller);
|
||||
|
||||
connect(reply, SIGNAL(finished()), SLOT(trackSearchSlot()));
|
||||
}
|
||||
|
||||
bool MusixMatchPlugin::isValidTrackData(const QString &caller, const QVariant& data, Tomahawk::InfoSystem::InfoCustomDataHash &customData)
|
||||
bool MusixMatchPlugin::isValidTrackData(const QString &caller, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if (data.isNull() || !data.isValid() || !data.canConvert<Tomahawk::InfoSystem::InfoCustomDataHash>())
|
||||
if (data.isNull() || !data.isValid() || !data.canConvert<Tomahawk::InfoSystem::InfoCustomData>())
|
||||
{
|
||||
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
|
||||
emit finished(caller, Tomahawk::InfoSystem::InfoTrackLyrics);
|
||||
qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert";
|
||||
return false;
|
||||
}
|
||||
InfoCustomDataHash hash = data.value<Tomahawk::InfoSystem::InfoCustomDataHash>();
|
||||
InfoCustomData hash = data.value<Tomahawk::InfoSystem::InfoCustomData>();
|
||||
if (hash["trackName"].toString().isEmpty() )
|
||||
{
|
||||
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
|
||||
@ -104,7 +104,7 @@ void MusixMatchPlugin::trackSearchSlot()
|
||||
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
|
||||
if (!oldReply)
|
||||
{
|
||||
emit info(QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), Tomahawk::InfoSystem::InfoCustomDataHash());
|
||||
emit info(QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), Tomahawk::InfoSystem::InfoCustomData());
|
||||
return;
|
||||
}
|
||||
QDomDocument doc;
|
||||
@ -113,7 +113,7 @@ void MusixMatchPlugin::trackSearchSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName("track_id");
|
||||
if (domNodeList.isEmpty())
|
||||
{
|
||||
emit info(oldReply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, oldReply->property("origData"), QVariant(), oldReply->property("customData").value<Tomahawk::InfoSystem::InfoCustomDataHash>());
|
||||
emit info(oldReply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, oldReply->property("origData"), QVariant(), oldReply->property("customData").value<Tomahawk::InfoSystem::InfoCustomData>());
|
||||
emit finished(oldReply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics);
|
||||
return;
|
||||
}
|
||||
@ -135,7 +135,7 @@ void MusixMatchPlugin::trackLyricsSlot()
|
||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||
if (!reply)
|
||||
{
|
||||
emit info(QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), Tomahawk::InfoSystem::InfoCustomDataHash());
|
||||
emit info(QString(), Tomahawk::InfoSystem::InfoTrackLyrics, QVariant(), QVariant(), Tomahawk::InfoSystem::InfoCustomData());
|
||||
return;
|
||||
}
|
||||
QDomDocument doc;
|
||||
@ -143,12 +143,12 @@ void MusixMatchPlugin::trackLyricsSlot()
|
||||
QDomNodeList domNodeList = doc.elementsByTagName("lyrics_body");
|
||||
if (domNodeList.isEmpty())
|
||||
{
|
||||
emit info(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property("origData"), QVariant(), reply->property("customData").value<Tomahawk::InfoSystem::InfoCustomDataHash>());
|
||||
emit info(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property("origData"), QVariant(), reply->property("customData").value<Tomahawk::InfoSystem::InfoCustomData>());
|
||||
emit finished(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics);
|
||||
return;
|
||||
}
|
||||
QString lyrics = domNodeList.at(0).toElement().text();
|
||||
qDebug() << "Emitting lyrics: " << lyrics;
|
||||
emit info(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property("origData"), QVariant(lyrics), reply->property("customData").value<Tomahawk::InfoSystem::InfoCustomDataHash>());
|
||||
emit info(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property("origData"), QVariant(lyrics), reply->property("customData").value<Tomahawk::InfoSystem::InfoCustomData>());
|
||||
emit finished(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics);
|
||||
}
|
||||
|
@ -36,10 +36,10 @@ public:
|
||||
MusixMatchPlugin(QObject *parent);
|
||||
virtual ~MusixMatchPlugin();
|
||||
|
||||
void getInfo(const QString &caller, const InfoType type, const QVariant &data, InfoCustomDataHash customData);
|
||||
void getInfo(const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData);
|
||||
|
||||
private:
|
||||
bool isValidTrackData( const QString &caller, const QVariant& data, InfoCustomDataHash &customData );
|
||||
bool isValidTrackData( const QString &caller, const QVariant& data, InfoCustomData &customData );
|
||||
|
||||
public slots:
|
||||
void trackSearchSlot();
|
||||
|
@ -37,12 +37,26 @@ InfoPlugin::InfoPlugin(QObject *parent)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
InfoSystem *system = qobject_cast< InfoSystem* >( parent );
|
||||
if( system )
|
||||
QObject::connect(
|
||||
system->getCache(),
|
||||
SIGNAL( notInCache( QHash< QString, QString >, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash ) ),
|
||||
this,
|
||||
SLOT( notInCacheSlot( QHash< QString, QString >, QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash ) )
|
||||
);
|
||||
{
|
||||
QObject::connect(
|
||||
this,
|
||||
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||
system->getCache(),
|
||||
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
|
||||
);
|
||||
QObject::connect(
|
||||
system->getCache(),
|
||||
SIGNAL( notInCache( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||
this,
|
||||
SLOT( notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
|
||||
);
|
||||
QObject::connect(
|
||||
this,
|
||||
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCacheCriteria, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
||||
system->getCache(),
|
||||
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria, Tomahawk::InfoSystem::InfoType, QVariant ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -50,32 +64,44 @@ InfoSystem::InfoSystem(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qRegisterMetaType<QMap< QString, QMap< QString, QString > > >("Tomahawk::InfoSystem::InfoGenericMap");
|
||||
qRegisterMetaType<QHash<QString, QVariant > >("Tomahawk::InfoSystem::InfoCustomDataHash");
|
||||
qRegisterMetaType< QMap< QString, QMap< QString, QString > > >( "Tomahawk::InfoSystem::InfoGenericMap" );
|
||||
qRegisterMetaType< QHash< QString, QVariant > >( "Tomahawk::InfoSystem::InfoCustomData" );
|
||||
qRegisterMetaType< QHash< QString, QString > >( "Tomahawk::InfoSystem::InfoCacheCriteria" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
|
||||
|
||||
m_infoSystemCacheThreadController = new QThread( this );
|
||||
m_cache = new InfoSystemCache();
|
||||
m_cache->moveToThread( m_infoSystemCacheThreadController );
|
||||
m_infoSystemCacheThreadController->start( QThread::IdlePriority );
|
||||
|
||||
InfoPluginPtr enptr(new EchoNestPlugin(this));
|
||||
m_plugins.append(enptr);
|
||||
InfoPluginPtr mmptr(new MusixMatchPlugin(this));
|
||||
m_plugins.append(mmptr);
|
||||
InfoPluginPtr lfmptr(new LastFmPlugin(this));
|
||||
m_plugins.append(lfmptr);
|
||||
InfoPluginPtr enptr( new EchoNestPlugin( this ) );
|
||||
m_plugins.append( enptr );
|
||||
InfoPluginPtr mmptr( new MusixMatchPlugin( this ) );
|
||||
m_plugins.append( mmptr );
|
||||
InfoPluginPtr lfmptr( new LastFmPlugin( this ) );
|
||||
m_plugins.append( lfmptr );
|
||||
|
||||
Q_FOREACH( InfoPluginPtr plugin, m_plugins )
|
||||
{
|
||||
connect(plugin.data(), SIGNAL(info(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash)),
|
||||
this, SLOT(infoSlot(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash)), Qt::UniqueConnection);
|
||||
connect(plugin.data(), SIGNAL(finished(QString, Tomahawk::InfoSystem::InfoType)),
|
||||
this, SLOT(finishedSlot(QString, Tomahawk::InfoSystem::InfoType)), Qt::UniqueConnection);
|
||||
connect(
|
||||
plugin.data(),
|
||||
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||
this,
|
||||
SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||
Qt::UniqueConnection
|
||||
);
|
||||
|
||||
connect(
|
||||
plugin.data(),
|
||||
SIGNAL( finished( QString, Tomahawk::InfoSystem::InfoType ) ),
|
||||
this,
|
||||
SLOT( finishedSlot( QString, Tomahawk::InfoSystem::InfoType ) ), Qt::UniqueConnection
|
||||
);
|
||||
}
|
||||
connect(m_cache, SIGNAL(info(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash)),
|
||||
this, SLOT(infoSlot(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash)), Qt::UniqueConnection);
|
||||
connect(m_cache, SIGNAL(finished(QString, Tomahawk::InfoSystem::InfoType)),
|
||||
this, SLOT(finishedSlot(QString, Tomahawk::InfoSystem::InfoType)), Qt::UniqueConnection);
|
||||
connect( m_cache, SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||
this, SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ), Qt::UniqueConnection );
|
||||
connect( m_cache, SIGNAL( finished( QString, Tomahawk::InfoSystem::InfoType ) ),
|
||||
this, SLOT( finishedSlot( QString, Tomahawk::InfoSystem::InfoType ) ), Qt::UniqueConnection );
|
||||
}
|
||||
|
||||
InfoSystem::~InfoSystem()
|
||||
@ -125,7 +151,7 @@ QLinkedList< InfoPluginPtr > InfoSystem::determineOrderedMatches(const InfoType
|
||||
return providers;
|
||||
}
|
||||
|
||||
void InfoSystem::getInfo(const QString &caller, const InfoType type, const QVariant& data, InfoCustomDataHash customData)
|
||||
void InfoSystem::getInfo(const QString &caller, const InfoType type, const QVariant& data, InfoCustomData customData)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QLinkedList< InfoPluginPtr > providers = determineOrderedMatches(type);
|
||||
@ -149,13 +175,13 @@ void InfoSystem::getInfo(const QString &caller, const InfoType type, const QVari
|
||||
ptr.data()->getInfo(caller, type, data, customData);
|
||||
}
|
||||
|
||||
void InfoSystem::getInfo(const QString &caller, const InfoMap &input, InfoCustomDataHash customData)
|
||||
void InfoSystem::getInfo(const QString &caller, const InfoMap &input, InfoCustomData customData)
|
||||
{
|
||||
Q_FOREACH( InfoType type, input.keys() )
|
||||
getInfo(caller, type, input[type], customData);
|
||||
}
|
||||
|
||||
void InfoSystem::infoSlot(QString target, InfoType type, QVariant input, QVariant output, InfoCustomDataHash customData)
|
||||
void InfoSystem::infoSlot(QString target, InfoType type, QVariant input, QVariant output, InfoCustomData customData)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "current count in dataTracker is " << m_dataTracker[target][type];
|
||||
|
@ -0,0 +1,34 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#include "infosystemcache.h"
|
||||
|
||||
void
|
||||
Tomahawk::InfoSystem::InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
emit notInCache( criteria, caller, type, input, customData );
|
||||
}
|
||||
|
||||
void
|
||||
Tomahawk::InfoSystem::InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
@ -47,10 +47,14 @@ public:
|
||||
}
|
||||
|
||||
signals:
|
||||
void notInCache( QHash< QString, QString > criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData );
|
||||
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData );
|
||||
void notInCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void finished( QString, Tomahawk::InfoSystem::InfoType );
|
||||
|
||||
public slots:
|
||||
void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||
|
||||
};
|
||||
|
||||
} //namespace InfoSystem
|
||||
|
@ -39,8 +39,8 @@ Scrobbler::Scrobbler( QObject* parent )
|
||||
SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection );
|
||||
|
||||
connect( TomahawkApp::instance()->infoSystem(),
|
||||
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash ) ),
|
||||
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash ) ) );
|
||||
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) );
|
||||
|
||||
connect( TomahawkApp::instance()->infoSystem(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
||||
}
|
||||
@ -63,7 +63,7 @@ Scrobbler::trackStarted( const Tomahawk::result_ptr& track )
|
||||
scrobble();
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoCustomDataHash trackInfo;
|
||||
Tomahawk::InfoSystem::InfoCustomData trackInfo;
|
||||
|
||||
trackInfo["title"] = QVariant::fromValue< QString >( track->track() );
|
||||
trackInfo["artist"] = QVariant::fromValue< QString >( track->artist()->name() );
|
||||
@ -71,7 +71,7 @@ Scrobbler::trackStarted( const Tomahawk::result_ptr& track )
|
||||
trackInfo["duration"] = QVariant::fromValue< uint >( track->duration() );
|
||||
TomahawkApp::instance()->infoSystem()->getInfo(
|
||||
s_infoIdentifier, Tomahawk::InfoSystem::InfoMiscSubmitNowPlaying,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomDataHash >( trackInfo ), Tomahawk::InfoSystem::InfoCustomDataHash() );
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCustomData >( trackInfo ), Tomahawk::InfoSystem::InfoCustomData() );
|
||||
|
||||
m_scrobblePoint = ScrobblePoint( track->duration() / 2 );
|
||||
}
|
||||
@ -119,11 +119,11 @@ Scrobbler::scrobble()
|
||||
|
||||
TomahawkApp::instance()->infoSystem()->getInfo(
|
||||
s_infoIdentifier, Tomahawk::InfoSystem::InfoMiscSubmitScrobble,
|
||||
QVariant(), Tomahawk::InfoSystem::InfoCustomDataHash() );
|
||||
QVariant(), Tomahawk::InfoSystem::InfoCustomData() );
|
||||
}
|
||||
|
||||
void
|
||||
Scrobbler::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData )
|
||||
Scrobbler::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||
{
|
||||
if ( caller == s_infoIdentifier )
|
||||
{
|
||||
|
@ -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, Tomahawk::InfoSystem::InfoCustomDataHash customData );
|
||||
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
private:
|
||||
|
@ -67,8 +67,8 @@ XMPPBot::XMPPBot(QObject *parent)
|
||||
SLOT(newTrackSlot(const Tomahawk::result_ptr &)));
|
||||
|
||||
connect(TomahawkApp::instance()->infoSystem(),
|
||||
SIGNAL(info(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash)),
|
||||
SLOT(infoReturnedSlot(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomDataHash)));
|
||||
SIGNAL(info(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData)),
|
||||
SLOT(infoReturnedSlot(QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData)));
|
||||
|
||||
connect(TomahawkApp::instance()->infoSystem(), SIGNAL(finished(QString)), SLOT(infoFinishedSlot(QString)));
|
||||
|
||||
@ -215,10 +215,10 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session)
|
||||
infoMap[InfoArtistFamiliarity] = m_currTrack.data()->artist()->name();
|
||||
if (token == "lyrics")
|
||||
{
|
||||
InfoCustomDataHash myhash;
|
||||
InfoCustomData myhash;
|
||||
myhash["trackName"] = QVariant::fromValue<QString>(m_currTrack.data()->track());
|
||||
myhash["artistName"] = QVariant::fromValue<QString>(m_currTrack.data()->artist()->name());
|
||||
infoMap[InfoTrackLyrics] = QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomDataHash>(myhash);
|
||||
infoMap[InfoTrackLyrics] = QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomData>(myhash);
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,12 +235,12 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session)
|
||||
QString waitMsg("Please wait...");
|
||||
Message retMsg(Message::Chat, JID(originatingJid.toStdString()), waitMsg.toStdString());
|
||||
m_client.data()->send(retMsg);
|
||||
Tomahawk::InfoSystem::InfoCustomDataHash hash;
|
||||
Tomahawk::InfoSystem::InfoCustomData hash;
|
||||
hash["XMPPBotSendToJID"] = originatingJid;
|
||||
TomahawkApp::instance()->infoSystem()->getInfo(s_infoIdentifier, infoMap, hash);
|
||||
}
|
||||
|
||||
void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData)
|
||||
void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@ -364,13 +364,13 @@ void XMPPBot::infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType ty
|
||||
{
|
||||
qDebug() << "Lyrics requested";
|
||||
if (!output.canConvert<QString>() ||
|
||||
!input.canConvert<Tomahawk::InfoSystem::InfoCustomDataHash>()
|
||||
!input.canConvert<Tomahawk::InfoSystem::InfoCustomData>()
|
||||
)
|
||||
{
|
||||
qDebug() << "Variants failed to be valid";
|
||||
break;
|
||||
}
|
||||
InfoCustomDataHash inHash = input.value<InfoCustomDataHash>();
|
||||
InfoCustomData inHash = input.value<InfoCustomData>();
|
||||
QString artist = inHash["artistName"].toString();
|
||||
QString track = inHash["trackName"].toString();
|
||||
QString lyrics = output.toString();
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual void newTrackSlot(const Tomahawk::result_ptr &track);
|
||||
virtual void infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomDataHash customData);
|
||||
virtual void infoReturnedSlot(QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData);
|
||||
virtual void infoFinishedSlot(QString caller);
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user