mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
Rename some values and make slots and other functions use const values,
for sanity checking
This commit is contained in:
@@ -39,22 +39,23 @@ EchoNestPlugin::~EchoNestPlugin()
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getInfo(const QString &caller, const InfoType type, const QVariant& data, InfoCustomData customData)
|
void
|
||||||
|
EchoNestPlugin::getInfo(const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case Tomahawk::InfoSystem::InfoArtistBiography:
|
case Tomahawk::InfoSystem::InfoArtistBiography:
|
||||||
return getArtistBiography(caller, data, customData);
|
return getArtistBiography(caller, input, customData);
|
||||||
case Tomahawk::InfoSystem::InfoArtistFamiliarity:
|
case Tomahawk::InfoSystem::InfoArtistFamiliarity:
|
||||||
return getArtistFamiliarity(caller, data, customData);
|
return getArtistFamiliarity(caller, input, customData);
|
||||||
case Tomahawk::InfoSystem::InfoArtistHotttness:
|
case Tomahawk::InfoSystem::InfoArtistHotttness:
|
||||||
return getArtistHotttnesss(caller, data, customData);
|
return getArtistHotttnesss(caller, input, customData);
|
||||||
case Tomahawk::InfoSystem::InfoArtistTerms:
|
case Tomahawk::InfoSystem::InfoArtistTerms:
|
||||||
return getArtistTerms(caller, data, customData);
|
return getArtistTerms(caller, input, customData);
|
||||||
case Tomahawk::InfoSystem::InfoTrackEnergy:
|
case Tomahawk::InfoSystem::InfoTrackEnergy:
|
||||||
return getSongProfile(caller, data, customData, "energy");
|
return getSongProfile(caller, input, customData, "energy");
|
||||||
case Tomahawk::InfoSystem::InfoMiscTopTerms:
|
case Tomahawk::InfoSystem::InfoMiscTopTerms:
|
||||||
return getMiscTopTerms(caller, data, customData);
|
return getMiscTopTerms(caller, input, customData);
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
||||||
@@ -63,82 +64,88 @@ void EchoNestPlugin::getInfo(const QString &caller, const InfoType type, const Q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getSongProfile(const QString &caller, const QVariant& data, InfoCustomData &customData, const QString &item)
|
void
|
||||||
|
EchoNestPlugin::getSongProfile(const QString &caller, const QVariant &input, const InfoCustomData &customData, const QString &item)
|
||||||
{
|
{
|
||||||
//WARNING: Totally not implemented yet
|
//WARNING: Totally not implemented yet
|
||||||
Q_UNUSED( item );
|
Q_UNUSED( item );
|
||||||
|
|
||||||
if( !isValidTrackData( caller, data, customData ) )
|
if( !isValidTrackData( caller, input, customData ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Track track( data.toString() );
|
// Track track( input.toString() );
|
||||||
// Artist artist( customData.data()->property("artistName").toString() );
|
// Artist artist( customData.input()->property("artistName").toString() );
|
||||||
// reply->setProperty("artist", QVariant::fromValue<Artist>(artist));
|
// reply->setProperty("artist", QVariant::fromValue<Artist>(artist));
|
||||||
// reply->setProperty( "data", data );
|
// reply->setProperty( "input", input );
|
||||||
// m_replyMap[reply] = customData;
|
// m_replyMap[reply] = customData;
|
||||||
// connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot()));
|
// connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getArtistBiography(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
void
|
||||||
|
EchoNestPlugin::getArtistBiography(const QString &caller, const QVariant &input, const InfoCustomData &customData)
|
||||||
{
|
{
|
||||||
if( !isValidArtistData( caller, data, customData ) )
|
if( !isValidArtistData( caller, input, customData ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Echonest::Artist artist( data.toString() );
|
Echonest::Artist artist( input.toString() );
|
||||||
QNetworkReply *reply = artist.fetchBiographies();
|
QNetworkReply *reply = artist.fetchBiographies();
|
||||||
reply->setProperty("artist", QVariant::fromValue<Echonest::Artist>(artist));
|
reply->setProperty("artist", QVariant::fromValue<Echonest::Artist>(artist));
|
||||||
reply->setProperty( "data", data );
|
reply->setProperty( "input", input );
|
||||||
m_replyMap[reply] = customData;
|
m_replyMap[reply] = customData;
|
||||||
m_callerMap[reply] = caller;
|
m_callerMap[reply] = caller;
|
||||||
connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot()));
|
connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getArtistFamiliarity(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
void
|
||||||
|
EchoNestPlugin::getArtistFamiliarity(const QString &caller, const QVariant &input, const InfoCustomData &customData)
|
||||||
{
|
{
|
||||||
if( !isValidArtistData( caller, data, customData ) )
|
if( !isValidArtistData( caller, input, customData ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "Fetching artist familiarity!" << data;
|
qDebug() << "Fetching artist familiarity!" << input;
|
||||||
Echonest::Artist artist( data.toString() );
|
Echonest::Artist artist( input.toString() );
|
||||||
QNetworkReply* reply = artist.fetchFamiliarity();
|
QNetworkReply* reply = artist.fetchFamiliarity();
|
||||||
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist));
|
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist));
|
||||||
reply->setProperty( "data", data );
|
reply->setProperty( "input", input );
|
||||||
m_replyMap[reply] = customData;
|
m_replyMap[reply] = customData;
|
||||||
m_callerMap[reply] = caller;
|
m_callerMap[reply] = caller;
|
||||||
connect(reply, SIGNAL(finished()), SLOT(getArtistFamiliaritySlot()));
|
connect(reply, SIGNAL(finished()), SLOT(getArtistFamiliaritySlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getArtistHotttnesss(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
void
|
||||||
|
EchoNestPlugin::getArtistHotttnesss(const QString &caller, const QVariant &input, const InfoCustomData &customData)
|
||||||
{
|
{
|
||||||
if( !isValidArtistData( caller, data, customData ) )
|
if( !isValidArtistData( caller, input, customData ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Echonest::Artist artist( data.toString() );
|
Echonest::Artist artist( input.toString() );
|
||||||
QNetworkReply* reply = artist.fetchHotttnesss();
|
QNetworkReply* reply = artist.fetchHotttnesss();
|
||||||
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist));
|
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist));
|
||||||
reply->setProperty( "data", data );
|
reply->setProperty( "input", input );
|
||||||
m_replyMap[reply] = customData;
|
m_replyMap[reply] = customData;
|
||||||
m_callerMap[reply] = caller;
|
m_callerMap[reply] = caller;
|
||||||
connect(reply, SIGNAL(finished()), SLOT(getArtistHotttnesssSlot()));
|
connect(reply, SIGNAL(finished()), SLOT(getArtistHotttnesssSlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getArtistTerms(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
void
|
||||||
|
EchoNestPlugin::getArtistTerms(const QString &caller, const QVariant &input, const InfoCustomData &customData)
|
||||||
{
|
{
|
||||||
if( !isValidArtistData( caller, data, customData ) )
|
if( !isValidArtistData( caller, input, customData ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Echonest::Artist artist( data.toString() );
|
Echonest::Artist artist( input.toString() );
|
||||||
QNetworkReply* reply = artist.fetchTerms( Echonest::Artist::Weight );
|
QNetworkReply* reply = artist.fetchTerms( Echonest::Artist::Weight );
|
||||||
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist));
|
reply->setProperty( "artist", QVariant::fromValue<Echonest::Artist>(artist));
|
||||||
reply->setProperty( "data", data );
|
reply->setProperty( "input", input );
|
||||||
m_replyMap[reply] = customData;
|
m_replyMap[reply] = customData;
|
||||||
m_callerMap[reply] = caller;
|
m_callerMap[reply] = caller;
|
||||||
connect(reply, SIGNAL(finished()), SLOT(getArtistTermsSlot()));
|
connect(reply, SIGNAL(finished()), SLOT(getArtistTermsSlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getMiscTopTerms(const QString &caller, const QVariant& data, InfoCustomData& customData)
|
void
|
||||||
|
EchoNestPlugin::getMiscTopTerms(const QString &caller, const QVariant &input, const InfoCustomData& customData)
|
||||||
{
|
{
|
||||||
Q_UNUSED( data );
|
Q_UNUSED( input );
|
||||||
QNetworkReply* reply = Echonest::Artist::topTerms( 20 );
|
QNetworkReply* reply = Echonest::Artist::topTerms( 20 );
|
||||||
m_replyMap[reply] = customData;
|
m_replyMap[reply] = customData;
|
||||||
m_callerMap[reply] = caller;
|
m_callerMap[reply] = caller;
|
||||||
@@ -146,7 +153,8 @@ void EchoNestPlugin::getMiscTopTerms(const QString &caller, const QVariant& data
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EchoNestPlugin::getArtistBiographySlot()
|
void
|
||||||
|
EchoNestPlugin::getArtistBiographySlot()
|
||||||
{
|
{
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
Echonest::Artist artist = artistFromReply( reply );
|
Echonest::Artist artist = artistFromReply( reply );
|
||||||
@@ -162,35 +170,38 @@ void EchoNestPlugin::getArtistBiographySlot()
|
|||||||
biographyMap[biography.site()]["attribution"] = biography.license().url.toString();
|
biographyMap[biography.site()]["attribution"] = biography.license().url.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistBiography, reply->property( "data" ), QVariant::fromValue<Tomahawk::InfoSystem::InfoGenericMap>(biographyMap), m_replyMap[reply] );
|
emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistBiography, reply->property( "input" ), QVariant::fromValue<Tomahawk::InfoSystem::InfoGenericMap>(biographyMap), m_replyMap[reply] );
|
||||||
m_replyMap.remove(reply);
|
m_replyMap.remove(reply);
|
||||||
m_callerMap.remove(reply);
|
m_callerMap.remove(reply);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getArtistFamiliaritySlot()
|
void
|
||||||
|
EchoNestPlugin::getArtistFamiliaritySlot()
|
||||||
{
|
{
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
Echonest::Artist artist = artistFromReply( reply );
|
Echonest::Artist artist = artistFromReply( reply );
|
||||||
qreal familiarity = artist.familiarity();
|
qreal familiarity = artist.familiarity();
|
||||||
emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistFamiliarity, reply->property( "data" ), familiarity, m_replyMap[reply] );
|
emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistFamiliarity, reply->property( "input" ), familiarity, m_replyMap[reply] );
|
||||||
m_replyMap.remove(reply);
|
m_replyMap.remove(reply);
|
||||||
m_callerMap.remove(reply);
|
m_callerMap.remove(reply);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getArtistHotttnesssSlot()
|
void
|
||||||
|
EchoNestPlugin::getArtistHotttnesssSlot()
|
||||||
{
|
{
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
Echonest::Artist artist = artistFromReply( reply );
|
Echonest::Artist artist = artistFromReply( reply );
|
||||||
qreal hotttnesss = artist.hotttnesss();
|
qreal hotttnesss = artist.hotttnesss();
|
||||||
emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistHotttness, reply->property( "data" ), hotttnesss, m_replyMap[reply] );
|
emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistHotttness, reply->property( "input" ), hotttnesss, m_replyMap[reply] );
|
||||||
m_replyMap.remove(reply);
|
m_replyMap.remove(reply);
|
||||||
m_callerMap.remove(reply);
|
m_callerMap.remove(reply);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getArtistTermsSlot()
|
void
|
||||||
|
EchoNestPlugin::getArtistTermsSlot()
|
||||||
{
|
{
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
Echonest::Artist artist = artistFromReply( reply );
|
Echonest::Artist artist = artistFromReply( reply );
|
||||||
@@ -202,13 +213,14 @@ void EchoNestPlugin::getArtistTermsSlot()
|
|||||||
termMap[ "frequency" ] = QString::number(term.frequency());
|
termMap[ "frequency" ] = QString::number(term.frequency());
|
||||||
termsMap[ term.name() ] = termMap;
|
termsMap[ term.name() ] = termMap;
|
||||||
}
|
}
|
||||||
emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistTerms, reply->property( "data" ), QVariant::fromValue<Tomahawk::InfoSystem::InfoGenericMap>(termsMap), m_replyMap[reply] );
|
emit info( m_callerMap[reply], Tomahawk::InfoSystem::InfoArtistTerms, reply->property( "input" ), QVariant::fromValue<Tomahawk::InfoSystem::InfoGenericMap>(termsMap), m_replyMap[reply] );
|
||||||
m_replyMap.remove(reply);
|
m_replyMap.remove(reply);
|
||||||
m_callerMap.remove(reply);
|
m_callerMap.remove(reply);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoNestPlugin::getMiscTopSlot()
|
void
|
||||||
|
EchoNestPlugin::getMiscTopSlot()
|
||||||
{
|
{
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
TermList terms = Echonest::Artist::parseTopTerms( reply );
|
TermList terms = Echonest::Artist::parseTopTerms( reply );
|
||||||
@@ -225,14 +237,15 @@ void EchoNestPlugin::getMiscTopSlot()
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EchoNestPlugin::isValidArtistData(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
bool
|
||||||
|
EchoNestPlugin::isValidArtistData(const QString &caller, const QVariant &input, const InfoCustomData &customData)
|
||||||
{
|
{
|
||||||
if (data.isNull() || !data.isValid() || !data.canConvert<QString>())
|
if (input.isNull() || !input.isValid() || !input.canConvert<QString>())
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QString artistName = data.toString();
|
QString artistName = input.toString();
|
||||||
if (artistName.isEmpty() )
|
if (artistName.isEmpty() )
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
||||||
@@ -241,14 +254,15 @@ bool EchoNestPlugin::isValidArtistData(const QString &caller, const QVariant& da
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EchoNestPlugin::isValidTrackData(const QString &caller, const QVariant& data, InfoCustomData &customData)
|
bool
|
||||||
|
EchoNestPlugin::isValidTrackData(const QString &caller, const QVariant &input, const InfoCustomData &customData)
|
||||||
{
|
{
|
||||||
if (data.isNull() || !data.isValid() || !data.canConvert<QString>())
|
if (input.isNull() || !input.isValid() || !input.canConvert<QString>())
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QString trackName = data.toString();
|
QString trackName = input.toString();
|
||||||
if (trackName.isEmpty() )
|
if (trackName.isEmpty() )
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariant(), customData);
|
||||||
@@ -260,7 +274,8 @@ bool EchoNestPlugin::isValidTrackData(const QString &caller, const QVariant& dat
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Artist EchoNestPlugin::artistFromReply(QNetworkReply* reply)
|
Artist
|
||||||
|
EchoNestPlugin::artistFromReply(QNetworkReply* reply)
|
||||||
{
|
{
|
||||||
Echonest::Artist artist = reply->property("artist").value<Echonest::Artist>();
|
Echonest::Artist artist = reply->property("artist").value<Echonest::Artist>();
|
||||||
try {
|
try {
|
||||||
|
@@ -42,18 +42,19 @@ public:
|
|||||||
EchoNestPlugin(QObject *parent);
|
EchoNestPlugin(QObject *parent);
|
||||||
virtual ~EchoNestPlugin();
|
virtual ~EchoNestPlugin();
|
||||||
|
|
||||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData );
|
protected slots:
|
||||||
|
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void getSongProfile( const QString &caller, const QVariant &data, InfoCustomData &customData, const QString &item = QString() );
|
void getSongProfile( const QString &caller, const QVariant &input, const InfoCustomData &customData, const QString &item = QString() );
|
||||||
void getArtistBiography ( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
void getArtistBiography ( const QString &caller, const QVariant &input, const InfoCustomData &customData );
|
||||||
void getArtistFamiliarity( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
void getArtistFamiliarity( const QString &caller, const QVariant &input, const InfoCustomData &customData );
|
||||||
void getArtistHotttnesss( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
void getArtistHotttnesss( const QString &caller, const QVariant &input, const InfoCustomData &customData );
|
||||||
void getArtistTerms( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
void getArtistTerms( const QString &caller, const QVariant &input, const InfoCustomData &customData );
|
||||||
void getMiscTopTerms( const QString &caller, const QVariant &data, InfoCustomData &customData );
|
void getMiscTopTerms( const QString &caller, const QVariant &input, const InfoCustomData &customData );
|
||||||
|
|
||||||
bool isValidArtistData( const QString &caller, const QVariant& data, InfoCustomData& customData );
|
bool isValidArtistData( const QString &caller, const QVariant &input, const InfoCustomData& customData );
|
||||||
bool isValidTrackData( const QString &caller, const QVariant& data, InfoCustomData& customData );
|
bool isValidTrackData( const QString &caller, const QVariant &input, const InfoCustomData& customData );
|
||||||
Echonest::Artist artistFromReply( QNetworkReply* );
|
Echonest::Artist artistFromReply( QNetworkReply* );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@@ -95,54 +95,54 @@ LastFmPlugin::~LastFmPlugin()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmPlugin::dataError( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
LastFmPlugin::dataError( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||||
{
|
{
|
||||||
emit info( caller, type, data, QVariant(), customData );
|
emit info( caller, type, input, QVariant(), customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmPlugin::getInfo( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData customData )
|
LastFmPlugin::getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
switch ( type )
|
switch ( type )
|
||||||
{
|
{
|
||||||
case InfoMiscSubmitNowPlaying:
|
case InfoMiscSubmitNowPlaying:
|
||||||
nowPlaying( caller, type, data, customData );
|
nowPlaying( caller, type, input, customData );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InfoMiscSubmitScrobble:
|
case InfoMiscSubmitScrobble:
|
||||||
scrobble( caller, type, data, customData );
|
scrobble( caller, type, input, customData );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InfoArtistImages:
|
case InfoArtistImages:
|
||||||
fetchArtistImages( caller, type, data, customData );
|
fetchArtistImages( caller, type, input, customData );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InfoAlbumCoverArt:
|
case InfoAlbumCoverArt:
|
||||||
fetchCoverArt( caller, type, data, customData );
|
fetchCoverArt( caller, type, input, customData );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dataError( caller, type, data, customData );
|
dataError( caller, type, input, customData );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmPlugin::nowPlaying( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
LastFmPlugin::nowPlaying( const QString &caller, const InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||||
{
|
{
|
||||||
if ( !data.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() || !m_scrobbler )
|
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() || !m_scrobbler )
|
||||||
{
|
{
|
||||||
dataError( caller, type, data, customData );
|
dataError( caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InfoCriteriaHash hash = data.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
||||||
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) || !hash.contains( "duration" ) )
|
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) || !hash.contains( "duration" ) )
|
||||||
{
|
{
|
||||||
dataError( caller, type, data, customData );
|
dataError( caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,18 +157,18 @@ LastFmPlugin::nowPlaying( const QString &caller, const InfoType type, const QVar
|
|||||||
m_track.setSource( lastfm::Track::Player );
|
m_track.setSource( lastfm::Track::Player );
|
||||||
|
|
||||||
m_scrobbler->nowPlaying( m_track );
|
m_scrobbler->nowPlaying( m_track );
|
||||||
emit info( caller, type, data, QVariant(), customData );
|
emit info( caller, type, input, QVariant(), customData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmPlugin::scrobble( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
LastFmPlugin::scrobble( const QString &caller, const InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||||
{
|
{
|
||||||
Q_ASSERT( QThread::currentThread() == thread() );
|
Q_ASSERT( QThread::currentThread() == thread() );
|
||||||
|
|
||||||
if ( !m_scrobbler || m_track.isNull() )
|
if ( !m_scrobbler || m_track.isNull() )
|
||||||
{
|
{
|
||||||
dataError( caller, type, data, customData );
|
dataError( caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,23 +176,23 @@ LastFmPlugin::scrobble( const QString &caller, const InfoType type, const QVaria
|
|||||||
m_scrobbler->cache( m_track );
|
m_scrobbler->cache( m_track );
|
||||||
m_scrobbler->submit();
|
m_scrobbler->submit();
|
||||||
|
|
||||||
emit info( caller, type, data, QVariant(), customData );
|
emit info( caller, type, input, QVariant(), customData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( !data.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
|
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
|
||||||
{
|
{
|
||||||
dataError( caller, type, data, customData );
|
dataError( caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InfoCriteriaHash hash = data.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
||||||
if ( !hash.contains( "artist" ) || !hash.contains( "album" ) )
|
if ( !hash.contains( "artist" ) || !hash.contains( "album" ) )
|
||||||
{
|
{
|
||||||
dataError( caller, type, data, customData );
|
dataError( caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,35 +200,35 @@ LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const Q
|
|||||||
criteria["artist"] = hash["artist"];
|
criteria["artist"] = hash["artist"];
|
||||||
criteria["album"] = hash["album"];
|
criteria["album"] = hash["album"];
|
||||||
|
|
||||||
emit getCachedInfo( criteria, 2419200000, caller, type, data, customData );
|
emit getCachedInfo( criteria, 2419200000, caller, type, input, customData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmPlugin::fetchArtistImages( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData )
|
LastFmPlugin::fetchArtistImages( const QString &caller, const InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( !data.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
|
if ( !input.canConvert< Tomahawk::InfoSystem::InfoCriteriaHash >() )
|
||||||
{
|
{
|
||||||
dataError( caller, type, data, customData );
|
dataError( caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InfoCriteriaHash hash = data.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
InfoCriteriaHash hash = input.value< Tomahawk::InfoSystem::InfoCriteriaHash >();
|
||||||
if ( !hash.contains( "artist" ) )
|
if ( !hash.contains( "artist" ) )
|
||||||
{
|
{
|
||||||
dataError( caller, type, data, customData );
|
dataError( caller, type, input, customData );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
|
Tomahawk::InfoSystem::InfoCriteriaHash criteria;
|
||||||
criteria["artist"] = hash["artist"];
|
criteria["artist"] = hash["artist"];
|
||||||
|
|
||||||
emit getCachedInfo( criteria, 2419200000, caller, type, data, customData );
|
emit getCachedInfo( criteria, 2419200000, caller, type, input, customData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmPlugin::notInCacheSlot( QHash<QString, QString> criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
LastFmPlugin::notInCacheSlot( const QHash<QString, QString> criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
@@ -43,8 +43,6 @@ public:
|
|||||||
LastFmPlugin( QObject *parent );
|
LastFmPlugin( QObject *parent );
|
||||||
virtual ~LastFmPlugin();
|
virtual ~LastFmPlugin();
|
||||||
|
|
||||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData );
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
@@ -52,17 +50,19 @@ public slots:
|
|||||||
void coverArtReturned();
|
void coverArtReturned();
|
||||||
void artistImagesReturned();
|
void artistImagesReturned();
|
||||||
|
|
||||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
protected slots:
|
||||||
|
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
|
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fetchCoverArt( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData );
|
void fetchCoverArt( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData );
|
||||||
void fetchArtistImages( const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData );
|
void fetchArtistImages( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData );
|
||||||
|
|
||||||
void createScrobbler();
|
void createScrobbler();
|
||||||
void scrobble( const QString &caller, const InfoType type, const QVariant& data, InfoCustomData &customData );
|
void scrobble( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData );
|
||||||
void nowPlaying( const QString &caller, const InfoType type, const QVariant& data, InfoCustomData &customData );
|
void nowPlaying( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData );
|
||||||
|
|
||||||
void dataError( const QString &caller, const InfoType type, const QVariant& data, InfoCustomData &customData );
|
void dataError( const QString &caller, const Tomahawk::InfoSystem::InfoType type, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData );
|
||||||
|
|
||||||
lastfm::MutableTrack m_track;
|
lastfm::MutableTrack m_track;
|
||||||
lastfm::Audioscrobbler* m_scrobbler;
|
lastfm::Audioscrobbler* m_scrobbler;
|
||||||
|
@@ -42,17 +42,18 @@ MusixMatchPlugin::~MusixMatchPlugin()
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData customData)
|
void
|
||||||
|
MusixMatchPlugin::getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if( !isValidTrackData(caller, data, customData) || !data.canConvert<Tomahawk::InfoSystem::InfoCustomData>())
|
if( !isValidTrackData(caller, input, customData) || !input.canConvert<Tomahawk::InfoSystem::InfoCustomData>())
|
||||||
return;
|
return;
|
||||||
Tomahawk::InfoSystem::InfoCustomData hash = data.value<Tomahawk::InfoSystem::InfoCustomData>();
|
Tomahawk::InfoSystem::InfoCustomData hash = input.value<Tomahawk::InfoSystem::InfoCustomData>();
|
||||||
QString artist = hash["artistName"].toString();
|
QString artist = hash["artistName"].toString();
|
||||||
QString track = hash["trackName"].toString();
|
QString track = hash["trackName"].toString();
|
||||||
if( artist.isEmpty() || track.isEmpty() )
|
if( artist.isEmpty() || track.isEmpty() )
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "artist is " << artist << ", track is " << track;
|
qDebug() << "artist is " << artist << ", track is " << track;
|
||||||
@@ -63,38 +64,40 @@ void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const
|
|||||||
url.addQueryItem("q_track", track);
|
url.addQueryItem("q_track", track);
|
||||||
QNetworkReply* reply = TomahawkUtils::nam()->get(QNetworkRequest(url));
|
QNetworkReply* reply = TomahawkUtils::nam()->get(QNetworkRequest(url));
|
||||||
reply->setProperty("customData", QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomData>(customData));
|
reply->setProperty("customData", QVariant::fromValue<Tomahawk::InfoSystem::InfoCustomData>(customData));
|
||||||
reply->setProperty("origData", data);
|
reply->setProperty("origData", input);
|
||||||
reply->setProperty("caller", caller);
|
reply->setProperty("caller", caller);
|
||||||
|
|
||||||
connect(reply, SIGNAL(finished()), SLOT(trackSearchSlot()));
|
connect(reply, SIGNAL(finished()), SLOT(trackSearchSlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MusixMatchPlugin::isValidTrackData(const QString &caller, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData)
|
bool
|
||||||
|
MusixMatchPlugin::isValidTrackData( const QString &caller, const QVariant &input, const Tomahawk::InfoSystem::InfoCustomData &customData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if (data.isNull() || !data.isValid() || !data.canConvert<Tomahawk::InfoSystem::InfoCustomData>())
|
if (input.isNull() || !input.isValid() || !input.canConvert<Tomahawk::InfoSystem::InfoCustomData>())
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData);
|
||||||
qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert";
|
qDebug() << "MusixMatchPlugin::isValidTrackData: Data null, invalid, or can't convert";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
InfoCustomData hash = data.value<Tomahawk::InfoSystem::InfoCustomData>();
|
InfoCustomData hash = input.value<Tomahawk::InfoSystem::InfoCustomData>();
|
||||||
if (hash["trackName"].toString().isEmpty() )
|
if (hash["trackName"].toString().isEmpty() )
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData);
|
||||||
qDebug() << "MusixMatchPlugin::isValidTrackData: Track name is empty";
|
qDebug() << "MusixMatchPlugin::isValidTrackData: Track name is empty";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (hash["artistName"].toString().isEmpty() )
|
if (hash["artistName"].toString().isEmpty() )
|
||||||
{
|
{
|
||||||
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, data, QVariant(), customData);
|
emit info(caller, Tomahawk::InfoSystem::InfoTrackLyrics, input, QVariant(), customData);
|
||||||
qDebug() << "MusixMatchPlugin::isValidTrackData: No artist name found";
|
qDebug() << "MusixMatchPlugin::isValidTrackData: No artist name found";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MusixMatchPlugin::trackSearchSlot()
|
void
|
||||||
|
MusixMatchPlugin::trackSearchSlot()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
|
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
@@ -124,7 +127,8 @@ void MusixMatchPlugin::trackSearchSlot()
|
|||||||
connect(newReply, SIGNAL(finished()), SLOT(trackLyricsSlot()));
|
connect(newReply, SIGNAL(finished()), SLOT(trackLyricsSlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MusixMatchPlugin::trackLyricsSlot()
|
void
|
||||||
|
MusixMatchPlugin::trackLyricsSlot()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||||
|
@@ -34,19 +34,19 @@ class MusixMatchPlugin : public InfoPlugin
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MusixMatchPlugin(QObject *parent);
|
MusixMatchPlugin( QObject *parent );
|
||||||
virtual ~MusixMatchPlugin();
|
virtual ~MusixMatchPlugin();
|
||||||
|
|
||||||
void getInfo(const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool isValidTrackData( const QString &caller, const QVariant& data, InfoCustomData &customData );
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void trackSearchSlot();
|
void trackSearchSlot();
|
||||||
void trackLyricsSlot();
|
void trackLyricsSlot();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool isValidTrackData( const QString &caller, const QVariant &input, const InfoCustomData &customData );
|
||||||
|
|
||||||
QString m_apiKey;
|
QString m_apiKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -148,7 +148,7 @@ QLinkedList< InfoPluginPtr > InfoSystem::determineOrderedMatches(const InfoType
|
|||||||
return providers;
|
return providers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoSystem::getInfo(const QString &caller, const InfoType type, const QVariant& data, InfoCustomData customData)
|
void InfoSystem::getInfo(const QString &caller, const InfoType type, const QVariant& input, InfoCustomData customData)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
QLinkedList< InfoPluginPtr > providers = determineOrderedMatches(type);
|
QLinkedList< InfoPluginPtr > providers = determineOrderedMatches(type);
|
||||||
@@ -169,7 +169,7 @@ void InfoSystem::getInfo(const QString &caller, const InfoType type, const QVari
|
|||||||
|
|
||||||
m_dataTracker[caller][type] = m_dataTracker[caller][type] + 1;
|
m_dataTracker[caller][type] = m_dataTracker[caller][type] + 1;
|
||||||
qDebug() << "current count in dataTracker for type" << type << "is" << m_dataTracker[caller][type];
|
qDebug() << "current count in dataTracker for type" << type << "is" << m_dataTracker[caller][type];
|
||||||
ptr.data()->getInfo(caller, type, data, customData);
|
QMetaObject::invokeMethod( ptr.data(), "getInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ), Q_ARG( Tomahawk::InfoSystem::InfoCustomData, customData ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoSystem::getInfo(const QString &caller, const InfoMap &input, InfoCustomData customData)
|
void InfoSystem::getInfo(const QString &caller, const InfoMap &input, InfoCustomData customData)
|
||||||
|
@@ -111,17 +111,17 @@ public:
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData ) = 0;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
void getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
void updateCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
void updateCache( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||||
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, 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 );
|
void finished( QString, Tomahawk::InfoSystem::InfoType );
|
||||||
|
|
||||||
public slots:
|
protected slots:
|
||||||
|
virtual void getInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data, const Tomahawk::InfoSystem::InfoCustomData customData ) = 0;
|
||||||
|
|
||||||
//FIXME: Make pure virtual when everything supports it
|
//FIXME: Make pure virtual when everything supports it
|
||||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData )
|
||||||
{
|
{
|
||||||
Q_UNUSED( criteria );
|
Q_UNUSED( criteria );
|
||||||
Q_UNUSED( caller );
|
Q_UNUSED( caller );
|
||||||
@@ -132,6 +132,10 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
InfoType m_type;
|
InfoType m_type;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class InfoSystem;
|
||||||
|
friend class InfoSystemCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QWeakPointer< InfoPlugin > InfoPluginPtr;
|
typedef QWeakPointer< InfoPlugin > InfoPluginPtr;
|
||||||
@@ -148,7 +152,7 @@ public:
|
|||||||
|
|
||||||
void registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &types );
|
void registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &types );
|
||||||
|
|
||||||
void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData );
|
void getInfo( const QString &caller, const InfoType type, const QVariant &input, InfoCustomData customData );
|
||||||
void getInfo( const QString &caller, const InfoMap &input, InfoCustomData customData );
|
void getInfo( const QString &caller, const InfoMap &input, InfoCustomData customData );
|
||||||
|
|
||||||
InfoSystemCache* getCache() { return m_cache; }
|
InfoSystemCache* getCache() { return m_cache; }
|
||||||
@@ -158,7 +162,7 @@ signals:
|
|||||||
void finished( QString target );
|
void finished( QString target );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void infoSlot( QString target, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
void infoSlot( const QString target, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const QVariant output, const Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLinkedList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
|
QLinkedList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
|
||||||
|
@@ -98,7 +98,7 @@ InfoSystemCache::syncTimerFired()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
InfoSystemCache::getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 newMaxAge, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
if ( !m_dataCache.contains( type ) || !m_dataCache[type].contains( criteria ) )
|
if ( !m_dataCache.contains( type ) || !m_dataCache[type].contains( criteria ) )
|
||||||
@@ -110,7 +110,7 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash crite
|
|||||||
if ( m_cacheRemainingToLoad > 0 )
|
if ( m_cacheRemainingToLoad > 0 )
|
||||||
{
|
{
|
||||||
qDebug() << "Cache not fully loaded, punting request for a bit";
|
qDebug() << "Cache not fully loaded, punting request for a bit";
|
||||||
QMetaObject::invokeMethod( this, "getCachedInfoSlot", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoCriteriaHash, criteria ), Q_ARG( qint64, newMaxAge ), Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::InfoCustomData, customData ) );
|
QMetaObject::invokeMethod( this, "getCachedInfoSlot", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoCriteriaHash, criteria ), Q_ARG( qint64, newMaxAge ), Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ), Q_ARG( Tomahawk::InfoSystem::InfoCustomData, customData ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash crite
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
InfoSystemCache::updateCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 maxAge, const Tomahawk::InfoSystem::InfoType type, const QVariant output )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
QHash< InfoCriteriaHash, QVariant > typedatacache = m_dataCache[type];
|
QHash< InfoCriteriaHash, QVariant > typedatacache = m_dataCache[type];
|
||||||
@@ -160,7 +160,7 @@ InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteri
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoSystemCache::loadCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheDir )
|
InfoSystemCache::loadCache( const Tomahawk::InfoSystem::InfoType type, const QString cacheDir )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ InfoSystemCache::loadCache( Tomahawk::InfoSystem::InfoType type, const QString &
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoSystemCache::saveCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheDir )
|
InfoSystemCache::saveCache( const Tomahawk::InfoSystem::InfoType type, const QString cacheDir )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
QDir dir( cacheDir );
|
QDir dir( cacheDir );
|
||||||
|
@@ -46,13 +46,13 @@ signals:
|
|||||||
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
void getCachedInfoSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 newMaxAge, const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input, const Tomahawk::InfoSystem::InfoCustomData customData );
|
||||||
void updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
void updateCacheSlot( const Tomahawk::InfoSystem::InfoCriteriaHash criteria, const qint64 maxAge, const Tomahawk::InfoSystem::InfoType type, const QVariant output );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void syncTimerFired();
|
void syncTimerFired();
|
||||||
void loadCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheDir );
|
void loadCache( const Tomahawk::InfoSystem::InfoType type, const QString cacheDir );
|
||||||
void saveCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheDir );
|
void saveCache( const Tomahawk::InfoSystem::InfoType type, const QString cacheDir );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash< InfoType, QHash< InfoCriteriaHash, QVariant > > m_dataCache;
|
QHash< InfoType, QHash< InfoCriteriaHash, QVariant > > m_dataCache;
|
||||||
|
Reference in New Issue
Block a user