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

undo oops

This commit is contained in:
Leo Franchi
2011-04-10 21:03:21 -04:00
parent a9a9ffa40f
commit 41c553fac7
5 changed files with 69 additions and 33 deletions

View File

@@ -53,31 +53,32 @@ include( CheckTagLibFileName )
check_taglib_filename( COMPLEX_TAGLIB_FILENAME ) check_taglib_filename( COMPLEX_TAGLIB_FILENAME )
# optional # optional
macro_optional_find_package(Jreen) IF( ENABLE_JREEN )
IF( ENABLE_JREEN AND NOT LIBJREEN_FOUND ) macro_optional_find_package(Jreen)
IF( LIBJREEN_FOUND )
macro_log_feature(JREEN_FOUND "Jreen" "Qt XMPP library" "http://gitorious.org/jreen" FALSE "" "Jreen is needed for the alternative/new Jabber SIP plugin. Built automatically inside Tomahawk, if not installed systemwide and ENABLE_JREEN is true")
ELSE( LIBJREEN_FOUND )
ADD_SUBDIRECTORY( thirdparty/jreen ) ADD_SUBDIRECTORY( thirdparty/jreen )
SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include ) SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include )
IF( UNIX AND NOT APPLE ) IF( UNIX AND NOT APPLE )
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.so ) SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.so )
ENDIF( UNIX AND NOT APPLE ) ENDIF( UNIX AND NOT APPLE )
IF( WIN32 ) IF( WIN32 )
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.dll ) SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.dll )
ENDIF( WIN32 ) ENDIF( WIN32 )
SET( LIBJREEN_FOUND true ) SET( LIBJREEN_FOUND true )
MESSAGE(STATUS "Internal libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}") MESSAGE(STATUS "Internal libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}")
ENDIF( ENABLE_JREEN AND NOT LIBJREEN_FOUND ) ENDIF( LIBJREEN_FOUND )
ELSE( LIBJREEN_FOUND )
macro_optional_find_package(Gloox 1.0)
macro_log_feature(GLOOX_FOUND "Gloox" "A portable high-level Jabber/XMPP library for C++" "http://camaya.net/gloox" FALSE "" "Gloox is needed for the Jabber SIP plugin and the XMPP-Bot")
ENDIF( ENABLE_JREEN )
IF( WIN32 ) IF( WIN32 )
find_library(QTSPARKLE_LIBRARIES qtsparkle) find_library(QTSPARKLE_LIBRARIES qtsparkle)
ENDIF( WIN32 ) ENDIF( WIN32 )
macro_log_feature(JREEN_FOUND "Jreen" "Qt XMPP library" "http://gitorious.org/jreen" FALSE "" "Jreen is needed for the alternative/new Jabber SIP plugin. Built automatically inside Tomahawk, if not installed systemwide and ENABLE_JREEN is true")
macro_optional_find_package(Gloox 1.0)
IF( ENABLE_JREEN )
set( GLOOX_FOUND false )
ENDIF( ENABLE_JREEN)
macro_log_feature(GLOOX_FOUND "Gloox" "A portable high-level Jabber/XMPP library for C++" "http://camaya.net/gloox" FALSE "" "Gloox is needed for the Jabber SIP plugin and the XMPP-Bot")
#show dep log #show dep log
macro_display_feature_log() macro_display_feature_log()
MESSAGE("WARNING!") MESSAGE("WARNING!")

View File

@@ -112,7 +112,7 @@ 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, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ); void getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, 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 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 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 );

View File

@@ -178,7 +178,7 @@ LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const Q
criteria["artist"] = hash["artist"].toString(); criteria["artist"] = hash["artist"].toString();
criteria["album"] = hash["album"].toString(); criteria["album"] = hash["album"].toString();
emit getCachedInfo( criteria, caller, type, data, customData ); emit getCachedInfo( criteria, 2419200000, caller, type, data, customData );
} }
void void

View File

@@ -53,10 +53,10 @@ InfoSystemCache::~InfoSystemCache()
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
qDebug() << "Saving infosystemcache to disk"; qDebug() << "Saving infosystemcache to disk";
QString cacheBaseDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation ); QString cacheBaseDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
for( int i = 0; i <= InfoNoInfo; i++ ) for ( int i = 0; i <= InfoNoInfo; i++ )
{ {
InfoType type = (InfoType)(i); InfoType type = (InfoType)(i);
if( m_dirtySet.contains( type ) && m_dataCache.contains( type ) ) if ( m_dirtySet.contains( type ) && m_dataCache.contains( type ) )
{ {
QString cacheDir = cacheBaseDir + "/InfoSystemCache/" + QString::number( i ); QString cacheDir = cacheBaseDir + "/InfoSystemCache/" + QString::number( i );
saveCache( type, cacheDir ); saveCache( type, cacheDir );
@@ -66,29 +66,57 @@ InfoSystemCache::~InfoSystemCache()
void void
InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ) InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria 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 ) )
{ {
emit notInCache( criteria, caller, type, input, customData ); emit notInCache( criteria, caller, type, input, customData );
return; return;
} }
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
if ( typemaxtimecache[criteria].toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() )
{
QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type];
typemaxtimecache.remove( criteria );
m_maxTimeCache[type] = typemaxtimecache;
typedatacache.remove( criteria );
m_dataCache[type] = typedatacache;
typeinserttimecache.remove( criteria );
m_insertTimeCache[type] = typeinserttimecache;
m_dirtySet.insert( type );
emit notInCache( criteria, caller, type, input, customData );
return;
}
if ( newMaxAge > 0 )
{
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + newMaxAge );
m_maxTimeCache[type] = typemaxtimecache;
m_dirtySet.insert( type );
}
emit info( caller, type, input, m_dataCache[type][criteria], customData ); emit info( caller, type, input, m_dataCache[type][criteria], customData );
} }
void void
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output ) InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria 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< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > typetimecache = m_timeCache[type]; QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type];
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
typedatacache[criteria] = output; typedatacache[criteria] = output;
typetimecache[criteria] = QDateTime::currentDateTimeUtc(); typeinserttimecache[criteria] = QDateTime::currentDateTimeUtc();
typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + maxAge );
m_dataCache[type] = typedatacache; m_dataCache[type] = typedatacache;
m_timeCache[type] = typetimecache; m_insertTimeCache[type] = typeinserttimecache;
m_maxTimeCache[type] = typemaxtimecache;
m_dirtySet.insert( type ); m_dirtySet.insert( type );
} }
@@ -99,26 +127,31 @@ InfoSystemCache::loadCache( InfoType type, const QString &cacheFile )
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
QSettings cachedSettings( cacheFile, QSettings::IniFormat ); QSettings cachedSettings( cacheFile, QSettings::IniFormat );
foreach( QString group, cachedSettings.childGroups() ) foreach ( QString group, cachedSettings.childGroups() )
{ {
QHash< InfoCacheCriteria, QVariant > dataHash = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > dateHash = m_timeCache[type];
InfoCacheCriteria criteria;
cachedSettings.beginGroup( group ); cachedSettings.beginGroup( group );
if ( cachedSettings.value( "maxtime" ).toDateTime().toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() )
continue;
QHash< InfoCacheCriteria, QVariant > dataHash = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > insertDateHash = m_insertTimeCache[type];
QHash< InfoCacheCriteria, QDateTime > maxDateHash = m_maxTimeCache[type];
InfoCacheCriteria 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++ )
{ {
cachedSettings.setArrayIndex( i ); cachedSettings.setArrayIndex( i );
QStringList criteriaValues = cachedSettings.value( QString::number( i ) ).toStringList(); QStringList criteriaValues = cachedSettings.value( QString::number( i ) ).toStringList();
for( int j = 0; j < criteriaValues.length(); j += 2 ) for ( int j = 0; j < criteriaValues.length(); j += 2 )
criteria[criteriaValues.at( j )] = criteriaValues.at( j + 1 ); criteria[criteriaValues.at( j )] = criteriaValues.at( j + 1 );
} }
cachedSettings.endArray(); cachedSettings.endArray();
dataHash[criteria] = cachedSettings.value( "data" ); dataHash[criteria] = cachedSettings.value( "data" );
dateHash[criteria] = cachedSettings.value( "time" ).toDateTime(); insertDateHash[criteria] = cachedSettings.value( "inserttime" ).toDateTime();
maxDateHash[criteria] = cachedSettings.value( "maxtime" ).toDateTime();
cachedSettings.endGroup(); cachedSettings.endGroup();
m_dataCache[type] = dataHash; m_dataCache[type] = dataHash;
m_timeCache[type] = dateHash; m_insertTimeCache[type] = insertDateHash;
m_maxTimeCache[type] = maxDateHash;
} }
} }
@@ -156,7 +189,8 @@ InfoSystemCache::saveCache( InfoType type, const QString &cacheDir )
} }
cachedSettings.endArray(); cachedSettings.endArray();
cachedSettings.setValue( "data", m_dataCache[type][criteria] ); cachedSettings.setValue( "data", m_dataCache[type][criteria] );
cachedSettings.setValue( "time", m_timeCache[type][criteria] ); cachedSettings.setValue( "inserttime", m_insertTimeCache[type][criteria] );
cachedSettings.setValue( "maxtime", m_maxTimeCache[type][criteria] );
cachedSettings.endGroup(); cachedSettings.endGroup();
++criteriaNumber; ++criteriaNumber;
} }

View File

@@ -45,15 +45,16 @@ 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::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ); void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output ); void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
private: private:
void loadCache( InfoType type, const QString &cacheFile ); void loadCache( InfoType type, const QString &cacheFile );
void saveCache( InfoType type, const QString &cacheDir ); void saveCache( InfoType type, const QString &cacheDir );
QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_dataCache; QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_dataCache;
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_timeCache; QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_insertTimeCache;
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_maxTimeCache;
QSet< InfoType > m_dirtySet; QSet< InfoType > m_dirtySet;
}; };