From 47529ee4d817a7259299a6b045588af9fca72512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Lindstr=C3=B6m?= Date: Wed, 25 Jan 2012 16:40:59 +0100 Subject: [PATCH] Add version controll to force cacheupdates on new sources. --- .../infosystem/infoplugins/generic/chartsplugin.cpp | 13 +++++++++---- .../infosystem/infoplugins/generic/chartsplugin.h | 5 +---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp index 9d2aeb429..6b19566d5 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.cpp @@ -46,6 +46,8 @@ ChartsPlugin::ChartsPlugin() { /// Add resources here m_chartResources << "billboard" << "itunes" << "rdio" << "wearehunted" << "ex.fm" << "soundcloudwall.com"; + /// If you add resource, update version aswell + m_chartVersion = "1.0"; m_supportedGetTypes << InfoChart << InfoChartCapabilities; } @@ -153,7 +155,8 @@ ChartsPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requ Tomahawk::InfoSystem::InfoStringHash criteria; criteria[ "InfoChartCapabilities" ] = "chartsplugin"; - emit getCachedInfo( criteria, 604800000, requestData ); + criteria[ "InfoChartVersion" ] = m_chartVersion; + emit getCachedInfo( criteria, 864000000, requestData ); } void @@ -182,8 +185,8 @@ ChartsPlugin::notInCacheSlot( QHash criteria, Tomahawk::InfoSy tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChartCapabilities not in cache! Fetching..."; // we never need to re-fetch - if ( !m_allChartsMap.isEmpty() ) - return; + //if ( !m_allChartsMap.isEmpty() ) + // return; /// Then get each chart from resource @@ -333,6 +336,7 @@ ChartsPlugin::chartTypes() if( source == "wearehunted" ){ chartName = "WeAreHunted"; } + } } @@ -422,7 +426,8 @@ ChartsPlugin::chartTypes() // update cache Tomahawk::InfoSystem::InfoStringHash criteria; criteria[ "InfoChartCapabilities" ] = "chartsplugin"; - emit updateCache( criteria, 604800000, request.type, m_allChartsMap ); + criteria[ "InfoChartVersion" ] = m_chartVersion; + emit updateCache( criteria, 864000000, request.type, m_allChartsMap ); } m_cachedRequests.clear(); } diff --git a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h index 0d527d4c9..983c71de5 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h +++ b/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h @@ -72,16 +72,13 @@ private: void dataError( Tomahawk::InfoSystem::InfoRequestData requestData ); QStringList m_chartResources; + QString m_chartVersion; QList< InfoStringHash > m_charts; ChartType m_chartType; - QVariantMap m_allChartsMap; - uint m_chartsFetchJobs; QList< InfoRequestData > m_cachedRequests; - QHash< QString, QString > m_cachedCountries; - QWeakPointer< QNetworkAccessManager > m_nam; };