diff options
author | Armada <jules.blok@gmail.com> | 2013-09-22 18:51:53 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2013-10-12 21:25:44 +0400 |
commit | db844c4e1366574469fcb4d0f919545fcb16a1e8 (patch) | |
tree | da972e741a5c1e704044e112bbc7e141bfed642c | |
parent | a02a60cd850bb0017511fc6990bbf43e50f4ca52 (diff) |
CAppSettings: Add versioning to settings and update any old versions.
-rw-r--r-- | src/mpc-hc/AppSettings.cpp | 61 | ||||
-rw-r--r-- | src/mpc-hc/AppSettings.h | 3 | ||||
-rw-r--r-- | src/mpc-hc/SettingsDefines.h | 1 | ||||
-rw-r--r-- | src/mpc-hc/mplayerc.cpp | 1 |
4 files changed, 66 insertions, 0 deletions
diff --git a/src/mpc-hc/AppSettings.cpp b/src/mpc-hc/AppSettings.cpp index ce7d7724d..b31b4a5d0 100644 --- a/src/mpc-hc/AppSettings.cpp +++ b/src/mpc-hc/AppSettings.cpp @@ -2002,3 +2002,64 @@ bool CAppSettings::HasEVR() {
return IsCLSIDRegistered(CLSID_EnhancedVideoRenderer);
}
+
+void CAppSettings::UpdateSettings()
+{
+ CWinApp* pApp = AfxGetApp();
+ ASSERT(pApp);
+
+ UINT version = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_R_VERSION, 0);
+ if (version >= APPSETTINGS_VERSION) {
+ return; // Nothing to update
+ }
+
+ // Use lambda expressions to copy data entries
+ auto copyInt = [pApp](LPCTSTR oldSection, LPCTSTR oldEntry, LPCTSTR newSection, LPCTSTR newEntry) {
+ int old = pApp->GetProfileInt(oldSection, oldEntry, 0);
+ VERIFY(pApp->WriteProfileInt(newSection, newEntry, old));
+ };
+ auto copyString = [pApp](LPCTSTR oldSection, LPCTSTR oldEntry, LPCTSTR newSection, LPCTSTR newEntry) {
+ CString old = pApp->GetProfileString(oldSection, oldEntry);
+ VERIFY(pApp->WriteProfileString(newSection, newEntry, old));
+ };
+ auto copyBin = [pApp](LPCTSTR oldSection, LPCTSTR oldEntry, LPCTSTR newSection, LPCTSTR newEntry) {
+ UINT len;
+ BYTE* old;
+ if (pApp->GetProfileBinary(oldSection, oldEntry, &old, &len)) {
+ VERIFY(pApp->WriteProfileBinary(newSection, newEntry, old, len));
+ delete [] old;
+ }
+ };
+
+
+ // Migrate to the latest version, these cases should fall through
+ // so that all incremental updates are applied.
+ switch (version) {
+ case 0:
+ copyInt(_T("Settings"), _T("Remember DVD Pos"), _T("Settings"), _T("RememberDVDPos"));
+ copyInt(_T("Settings"), _T("Remember File Pos"), _T("Settings"), _T("RememberFilePos"));
+ copyInt(_T("Settings"), _T("Show OSD"), _T("Settings"), _T("ShowOSD"));
+ copyString(_T("Settings"), _T("Shaders List"), _T("Settings"), _T("ShadersList"));
+ copyInt(_T("Settings"), _T("OSD_Size"), _T("Settings"), _T("OSDSize"));
+ copyString(_T("Settings"), _T("OSD_Font"), _T("Settings"), _T("OSDFont"));
+ copyInt(_T("Settings"), _T("gotoluf"), _T("Settings"), _T("GoToLastUsed"));
+ copyInt(_T("Settings"), _T("fps"), _T("Settings"), _T("GoToFPS"));
+
+ // Move DVB section
+ copyString(_T("DVB configuration"), _T("BDANetworkProvider"), _T("DVBConfiguration"), _T("BDANetworkProvider"));
+ copyString(_T("DVB configuration"), _T("BDATuner"), _T("DVBConfiguration"), _T("BDATuner"));
+ copyString(_T("DVB configuration"), _T("BDAReceiver"), _T("DVBConfiguration"), _T("BDAReceiver"));
+ copyInt(_T("DVB configuration"), _T("BDAScanFreqStart"), _T("DVBConfiguration"), _T("BDAScanFreqStart"));
+ copyInt(_T("DVB configuration"), _T("BDAScanFreqEnd"), _T("DVBConfiguration"), _T("BDAScanFreqEnd"));
+ copyInt(_T("DVB configuration"), _T("BDABandWidth"), _T("DVBConfiguration"), _T("BDABandWidth"));
+ copyInt(_T("DVB configuration"), _T("BDAUseOffset"), _T("DVBConfiguration"), _T("BDAUseOffset"));
+ copyInt(_T("DVB configuration"), _T("BDAOffset"), _T("DVBConfiguration"), _T("BDAOffset"));
+ copyInt(_T("DVB configuration"), _T("BDAIgnoreEncryptedChannels"), _T("DVBConfiguration"), _T("BDAIgnoreEncryptedChannels"));
+ copyInt(_T("DVB configuration"), _T("LastChannel"), _T("DVBConfiguration"), _T("LastChannel"));
+ copyInt(_T("DVB configuration"), _T("RebuildFilterGraph"), _T("DVBConfiguration"), _T("RebuildFilterGraph"));
+ copyInt(_T("DVB configuration"), _T("StopFilterGraph"), _T("DVBConfiguration"), _T("StopFilterGraph"));
+
+ default:
+ pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_R_VERSION, APPSETTINGS_VERSION);
+ }
+}
diff --git a/src/mpc-hc/AppSettings.h b/src/mpc-hc/AppSettings.h index 2acd391b3..861e81499 100644 --- a/src/mpc-hc/AppSettings.h +++ b/src/mpc-hc/AppSettings.h @@ -320,6 +320,8 @@ public: CUIceClient();
};
+#define APPSETTINGS_VERSION 1
+
class CAppSettings
{
bool fInitialized;
@@ -635,6 +637,7 @@ public: void SaveSettings();
void LoadSettings();
void SaveExternalFilters() { if (fInitialized) { SaveExternalFilters(m_filters); } };
+ void UpdateSettings();
void GetFav(favtype ft, CAtlList<CString>& sl) const;
void SetFav(favtype ft, CAtlList<CString>& sl);
diff --git a/src/mpc-hc/SettingsDefines.h b/src/mpc-hc/SettingsDefines.h index f4a19b0c2..83a5980e5 100644 --- a/src/mpc-hc/SettingsDefines.h +++ b/src/mpc-hc/SettingsDefines.h @@ -21,6 +21,7 @@ #pragma once
#define IDS_R_SETTINGS _T("Settings")
+#define IDS_R_VERSION _T("SettingsVersion")
#define IDS_R_FILTERS _T("Filters")
#define IDS_R_EXTERNAL_FILTERS_x86 _T("Filters\\x86")
#define IDS_R_EXTERNAL_FILTERS_x64 _T("Filters\\x64")
diff --git a/src/mpc-hc/mplayerc.cpp b/src/mpc-hc/mplayerc.cpp index 88706869c..e4f6d1d90 100644 --- a/src/mpc-hc/mplayerc.cpp +++ b/src/mpc-hc/mplayerc.cpp @@ -1371,6 +1371,7 @@ BOOL CMPlayerCApp::InitInstance() }
}
+ m_s.UpdateSettings(); // update settings
m_s.LoadSettings(); // read settings
m_AudioRendererDisplayName_CL = _T("");
|