1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 05:37:29 +02:00

Merge remote-tracking branch 'origin/master' into sourcelistrefactor

This commit is contained in:
Leo Franchi
2011-04-21 11:22:33 -04:00
6 changed files with 40 additions and 40 deletions

View File

@@ -195,7 +195,7 @@ LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const Q
return; return;
} }
Tomahawk::InfoSystem::InfoCacheCriteria criteria; Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = hash["artist"].toString(); criteria["artist"] = hash["artist"].toString();
criteria["album"] = hash["album"].toString(); criteria["album"] = hash["album"].toString();
@@ -219,7 +219,7 @@ LastFmPlugin::fetchArtistImages( const QString &caller, const InfoType type, con
return; return;
} }
Tomahawk::InfoSystem::InfoCacheCriteria criteria; Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = hash["artist"].toString(); criteria["artist"] = hash["artist"].toString();
emit getCachedInfo( criteria, 2419200000, caller, type, data, customData ); emit getCachedInfo( criteria, 2419200000, caller, type, data, customData );
@@ -302,7 +302,7 @@ LastFmPlugin::coverArtReturned()
); );
InfoCustomData origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCustomData >(); InfoCustomData origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCustomData >();
Tomahawk::InfoSystem::InfoCacheCriteria criteria; Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = origData["artist"].toString(); criteria["artist"] = origData["artist"].toString();
criteria["album"] = origData["album"].toString(); criteria["album"] = origData["album"].toString();
emit updateCache( criteria, 2419200000, type, returnedData ); emit updateCache( criteria, 2419200000, type, returnedData );
@@ -353,7 +353,7 @@ LastFmPlugin::artistImagesReturned()
); );
InfoCustomData origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCustomData >(); InfoCustomData origData = reply->property( "origData" ).value< Tomahawk::InfoSystem::InfoCustomData >();
Tomahawk::InfoSystem::InfoCacheCriteria criteria; Tomahawk::InfoSystem::InfoCriteriaHash criteria;
criteria["artist"] = origData["artist"].toString(); criteria["artist"] = origData["artist"].toString();
emit updateCache( criteria, 2419200000, type, returnedData ); emit updateCache( criteria, 2419200000, type, returnedData );
} }

View File

@@ -52,7 +52,7 @@ public slots:
void coverArtReturned(); void coverArtReturned();
void artistImagesReturned(); void artistImagesReturned();
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ); virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, 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 InfoType type, const QVariant& data, Tomahawk::InfoSystem::InfoCustomData &customData );

View File

@@ -40,21 +40,21 @@ InfoPlugin::InfoPlugin(QObject *parent)
{ {
QObject::connect( QObject::connect(
this, this,
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ), SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
system->getCache(), system->getCache(),
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
); );
QObject::connect( QObject::connect(
system->getCache(), system->getCache(),
SIGNAL( notInCache( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ), SIGNAL( notInCache( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
this, this,
SLOT( notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) SLOT( notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
); );
QObject::connect( QObject::connect(
this, this,
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ), SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
system->getCache(), system->getCache(),
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ) SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) )
); );
} }
} }
@@ -76,7 +76,7 @@ InfoSystem::InfoSystem(QObject *parent)
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
qRegisterMetaType< QMap< QString, QMap< QString, QString > > >( "Tomahawk::InfoSystem::InfoGenericMap" ); qRegisterMetaType< QMap< QString, QMap< QString, QString > > >( "Tomahawk::InfoSystem::InfoGenericMap" );
qRegisterMetaType< QHash< QString, QVariant > >( "Tomahawk::InfoSystem::InfoCustomData" ); qRegisterMetaType< QHash< QString, QVariant > >( "Tomahawk::InfoSystem::InfoCustomData" );
qRegisterMetaType< QHash< QString, QString > >( "Tomahawk::InfoSystem::InfoCacheCriteria" ); qRegisterMetaType< QHash< QString, QString > >( "Tomahawk::InfoSystem::InfoCriteriaHash" );
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" ); qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
m_infoSystemCacheThreadController = new QThread( this ); m_infoSystemCacheThreadController = new QThread( this );
@@ -209,4 +209,4 @@ void InfoSystem::infoSlot(QString target, InfoType type, QVariant input, QVarian
} //namespace InfoSystem } //namespace InfoSystem
} //namespace Tomahawk } //namespace Tomahawk

View File

@@ -97,7 +97,7 @@ enum InfoType {
typedef QMap< InfoType, QVariant > InfoMap; typedef QMap< InfoType, QVariant > InfoMap;
typedef QMap< QString, QMap< QString, QString > > InfoGenericMap; typedef QMap< QString, QMap< QString, QString > > InfoGenericMap;
typedef QHash< QString, QVariant > InfoCustomData; typedef QHash< QString, QVariant > InfoCustomData;
typedef QHash< QString, QString > InfoCacheCriteria; typedef QHash< QString, QString > InfoCriteriaHash;
class DLLEXPORT InfoPlugin : public QObject class DLLEXPORT InfoPlugin : public QObject
{ {
@@ -114,14 +114,14 @@ public:
virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData ) = 0; virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData ) = 0;
signals: signals:
void getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria 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::InfoCacheCriteria 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: public slots:
//FIXME: Make pure virtual when everything supports it //FIXME: Make pure virtual when everything supports it
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ) virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
{ {
Q_UNUSED( criteria ); Q_UNUSED( criteria );
Q_UNUSED( caller ); Q_UNUSED( caller );
@@ -180,7 +180,7 @@ private:
} }
inline uint qHash( Tomahawk::InfoSystem::InfoCacheCriteria hash ) inline uint qHash( Tomahawk::InfoSystem::InfoCriteriaHash hash )
{ {
QCryptographicHash md5( QCryptographicHash::Md5 ); QCryptographicHash md5( QCryptographicHash::Md5 );
foreach( QString key, hash.keys() ) foreach( QString key, hash.keys() )
@@ -200,6 +200,6 @@ inline uint qHash( Tomahawk::InfoSystem::InfoCacheCriteria hash )
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap ); Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoGenericMap );
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCustomData ); Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCustomData );
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCacheCriteria ); Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoCriteriaHash );
#endif // TOMAHAWK_INFOSYSTEM_H #endif // TOMAHAWK_INFOSYSTEM_H

View File

@@ -70,7 +70,7 @@ InfoSystemCache::~InfoSystemCache()
void void
InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ) InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, 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 ) )
@@ -82,16 +82,16 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria crit
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::InfoCacheCriteria, 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( Tomahawk::InfoSystem::InfoCustomData, customData ) );
return; return;
} }
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type]; QHash< InfoCriteriaHash, QDateTime > typemaxtimecache = m_maxTimeCache[type];
if ( typemaxtimecache[criteria].toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() ) if ( typemaxtimecache[criteria].toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() )
{ {
QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type]; QHash< InfoCriteriaHash, QVariant > typedatacache = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type]; QHash< InfoCriteriaHash, QDateTime > typeinserttimecache = m_insertTimeCache[type];
typemaxtimecache.remove( criteria ); typemaxtimecache.remove( criteria );
m_maxTimeCache[type] = typemaxtimecache; m_maxTimeCache[type] = typemaxtimecache;
typedatacache.remove( criteria ); typedatacache.remove( criteria );
@@ -105,7 +105,7 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria crit
if ( newMaxAge > 0 ) if ( newMaxAge > 0 )
{ {
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type]; QHash< InfoCriteriaHash, QDateTime > typemaxtimecache = m_maxTimeCache[type];
typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + newMaxAge ); typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + newMaxAge );
m_maxTimeCache[type] = typemaxtimecache; m_maxTimeCache[type] = typemaxtimecache;
m_dirtySet.insert( type ); m_dirtySet.insert( type );
@@ -116,12 +116,12 @@ InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria crit
void void
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output ) InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type]; QHash< InfoCriteriaHash, QVariant > typedatacache = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type]; QHash< InfoCriteriaHash, QDateTime > typeinserttimecache = m_insertTimeCache[type];
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type]; QHash< InfoCriteriaHash, QDateTime > typemaxtimecache = m_maxTimeCache[type];
typedatacache[criteria] = output; typedatacache[criteria] = output;
typeinserttimecache[criteria] = QDateTime::currentDateTimeUtc(); typeinserttimecache[criteria] = QDateTime::currentDateTimeUtc();
typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + maxAge ); typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + maxAge );
@@ -143,10 +143,10 @@ InfoSystemCache::loadCache( Tomahawk::InfoSystem::InfoType type, const QString &
cachedSettings.beginGroup( group ); cachedSettings.beginGroup( group );
if ( cachedSettings.value( "maxtime" ).toDateTime().toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() ) if ( cachedSettings.value( "maxtime" ).toDateTime().toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() )
continue; continue;
QHash< InfoCacheCriteria, QVariant > dataHash = m_dataCache[type]; QHash< InfoCriteriaHash, QVariant > dataHash = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > insertDateHash = m_insertTimeCache[type]; QHash< InfoCriteriaHash, QDateTime > insertDateHash = m_insertTimeCache[type];
QHash< InfoCacheCriteria, QDateTime > maxDateHash = m_maxTimeCache[type]; QHash< InfoCriteriaHash, QDateTime > maxDateHash = m_maxTimeCache[type];
InfoCacheCriteria criteria; InfoCriteriaHash criteria;
int numCriteria = cachedSettings.beginReadArray( "criteria" ); int numCriteria = cachedSettings.beginReadArray( "criteria" );
for ( int i = 0; i < numCriteria; i++ ) for ( int i = 0; i < numCriteria; i++ )
{ {
@@ -187,7 +187,7 @@ InfoSystemCache::saveCache( Tomahawk::InfoSystem::InfoType type, const QString &
int criteriaNumber = 0; int criteriaNumber = 0;
foreach( InfoCacheCriteria criteria, m_dataCache[type].keys() ) foreach( InfoCriteriaHash criteria, m_dataCache[type].keys() )
{ {
cachedSettings.beginGroup( "group_" + QString::number( criteriaNumber ) ); cachedSettings.beginGroup( "group_" + QString::number( criteriaNumber ) );
cachedSettings.beginWriteArray( "criteria" ); cachedSettings.beginWriteArray( "criteria" );

View File

@@ -41,21 +41,21 @@ public:
virtual ~InfoSystemCache(); virtual ~InfoSystemCache();
signals: signals:
void notInCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ); void notInCache( Tomahawk::InfoSystem::InfoCriteriaHash 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 info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
public slots: public slots:
void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ); void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output ); void updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
private slots: private slots:
void loadCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheFile ); void loadCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheFile );
void saveCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheDir ); void saveCache( Tomahawk::InfoSystem::InfoType type, const QString &cacheDir );
private: private:
QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_dataCache; QHash< InfoType, QHash< InfoCriteriaHash, QVariant > > m_dataCache;
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_insertTimeCache; QHash< InfoType, QHash< InfoCriteriaHash, QDateTime > > m_insertTimeCache;
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_maxTimeCache; QHash< InfoType, QHash< InfoCriteriaHash, QDateTime > > m_maxTimeCache;
QSet< InfoType > m_dirtySet; QSet< InfoType > m_dirtySet;
int m_cacheRemainingToLoad; int m_cacheRemainingToLoad;
}; };