1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

Rename TomahawkUtils::TomahawkCache to TomahawkUtils::Cache

This commit is contained in:
Casey Link
2012-04-12 17:01:50 -05:00
parent 08fa4bacd1
commit 67d943bce3
3 changed files with 18 additions and 16 deletions

View File

@@ -25,17 +25,17 @@
using namespace TomahawkUtils; using namespace TomahawkUtils;
TomahawkCache*TomahawkCache::s_instance = 0; Cache*Cache::s_instance = 0;
TomahawkCache* TomahawkCache::instance() Cache* Cache::instance()
{ {
if ( !s_instance ) if ( !s_instance )
s_instance = new TomahawkCache(); s_instance = new Cache();
return s_instance; return s_instance;
} }
TomahawkCache::TomahawkCache() Cache::Cache()
: QObject ( 0 ) : QObject ( 0 )
, m_cacheBaseDir ( TomahawkSettings::instance()->storageCacheLocation() + "/GenericCache/" ) , m_cacheBaseDir ( TomahawkSettings::instance()->storageCacheLocation() + "/GenericCache/" )
, m_cacheManifest ( m_cacheBaseDir + "cachemanifest.ini", QSettings::IniFormat ) , m_cacheManifest ( m_cacheBaseDir + "cachemanifest.ini", QSettings::IniFormat )
@@ -46,12 +46,12 @@ TomahawkCache::TomahawkCache()
m_pruneTimer.start(); m_pruneTimer.start();
} }
TomahawkCache::~TomahawkCache() Cache::~Cache()
{ {
} }
void TomahawkCache::pruneTimerFired() void Cache::pruneTimerFired()
{ {
qDebug() << Q_FUNC_INFO << "Pruning tomahawkcache"; qDebug() << Q_FUNC_INFO << "Pruning tomahawkcache";
qlonglong currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); qlonglong currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
@@ -77,7 +77,7 @@ void TomahawkCache::pruneTimerFired()
} }
QVariant TomahawkCache::getData ( const QString& identifier, const QString& key ) QVariant Cache::getData ( const QString& identifier, const QString& key )
{ {
const QString cacheDir = m_cacheBaseDir + identifier; const QString cacheDir = m_cacheBaseDir + identifier;
QSettings cached_settings ( cacheDir, QSettings::IniFormat ); QSettings cached_settings ( cacheDir, QSettings::IniFormat );
@@ -96,15 +96,17 @@ QVariant TomahawkCache::getData ( const QString& identifier, const QString& key
return QVariant(); return QVariant();
} }
void TomahawkCache::putData ( const QString& identifier, qint64 maxAge, const QString& key, const QVariant& value ) void Cache::putData ( const QString& identifier, qint64 maxAge, const QString& key, const QVariant& value )
{ {
QMutexLocker mutex_locker( &m_mutex );
const QString cacheDir = m_cacheBaseDir + identifier; const QString cacheDir = m_cacheBaseDir + identifier;
addClient ( identifier ); addClient ( identifier );
QSettings cached_settings ( cacheDir, QSettings::IniFormat ); QSettings cached_settings ( cacheDir, QSettings::IniFormat );
cached_settings.setValue ( key, QVariant::fromValue ( CacheData ( maxAge, value ) ) ); cached_settings.setValue ( key, QVariant::fromValue ( CacheData ( maxAge, value ) ) );
} }
void TomahawkCache::addClient ( const QString& identifier ) void Cache::addClient ( const QString& identifier )
{ {
QVariantList clients = m_cacheManifest.value ( "clients" ).toList(); QVariantList clients = m_cacheManifest.value ( "clients" ).toList();
foreach ( const QVariant &client, clients ) { foreach ( const QVariant &client, clients ) {
@@ -118,7 +120,7 @@ void TomahawkCache::addClient ( const QString& identifier )
m_cacheManifest.sync(); m_cacheManifest.sync();
} }
void TomahawkCache::removeClient ( const QString& identifier ) void Cache::removeClient ( const QString& identifier )
{ {
QVariantList clients = m_cacheManifest.value ( "clients" ).toList(); QVariantList clients = m_cacheManifest.value ( "clients" ).toList();
QVariantList::iterator it = clients.begin(); QVariantList::iterator it = clients.begin();

View File

@@ -39,13 +39,13 @@ struct CacheData {
QVariant data; QVariant data;
}; };
class DLLEXPORT TomahawkCache : public QObject class DLLEXPORT Cache : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static TomahawkCache* instance(); static Cache* instance();
virtual ~TomahawkCache(); virtual ~Cache();
void putData( const QString &identifier, qint64 maxAge, const QString &key, const QVariant& value ); void putData( const QString &identifier, qint64 maxAge, const QString &key, const QVariant& value );
QVariant getData( const QString &identifier, const QString &key ); QVariant getData( const QString &identifier, const QString &key );
@@ -54,8 +54,8 @@ private slots:
void pruneTimerFired(); void pruneTimerFired();
private: private:
TomahawkCache(); Cache();
static TomahawkCache* s_instance; static Cache* s_instance;
void addClient( const QString &identifier ); void addClient( const QString &identifier );
void removeClient( const QString &identifier ); void removeClient( const QString &identifier );

View File

@@ -319,7 +319,7 @@ TomahawkApp::~TomahawkApp()
delete m_audioEngine.data(); delete m_audioEngine.data();
delete Tomahawk::Accounts::AccountManager::instance(); delete Tomahawk::Accounts::AccountManager::instance();
delete TomahawkUtils::TomahawkCache::instance(); delete TomahawkUtils::Cache::instance();
#ifndef ENABLE_HEADLESS #ifndef ENABLE_HEADLESS
delete m_mainwindow; delete m_mainwindow;