| Index: src/plugin/PluginSettings.cpp |
| =================================================================== |
| --- a/src/plugin/PluginSettings.cpp |
| +++ b/src/plugin/PluginSettings.cpp |
| @@ -2,17 +2,13 @@ |
| #include <Wbemidl.h> |
| #include <time.h> |
| -#include "PluginIniFileW.h" |
| -#include "PluginIniFile.h" |
| #include "PluginSettings.h" |
| #include "PluginClient.h" |
| -#include "PluginChecksum.h" |
| #include "PluginSystem.h" |
| #ifdef SUPPORT_FILTER |
| #include "PluginFilter.h" |
| #endif |
| #include "PluginMutex.h" |
| -#include "PluginHttpRequest.h" |
| #include "../shared/Utils.h" |
| #include <memory> |
| @@ -66,7 +62,6 @@ |
| #endif |
| CPluginSettings* CPluginSettings::s_instance = NULL; |
| -bool CPluginSettings::s_isLightOnly = false; |
| CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; |
| #ifdef SUPPORT_WHITELIST |
| @@ -75,80 +70,18 @@ |
| CPluginSettings::CPluginSettings() : |
| - m_settingsVersion("1"), m_isDirty(false), m_isFirstRun(false), m_isFirstRunUpdate(false), m_dwMainProcessId(0), m_dwMainThreadId(0), m_dwWorkingThreadId(0), |
| - m_isDirtyTab(false), m_isPluginEnabledTab(true), m_tabNumber("1") |
| + m_settingsVersion("1"), m_isDirty(false), m_isFirstRun(false), m_isFirstRunUpdate(false), m_dwMainProcessId(0), m_dwMainThreadId(0), m_dwWorkingThreadId(0), |
| + m_isPluginEnabledTab(true), m_tabNumber("1") |
| { |
| CPluginSettings *lightInstance = s_instance; |
| s_instance = NULL; |
| - m_settingsFile = std::auto_ptr<CPluginIniFileW>(new CPluginIniFileW(GetDataPath(SETTINGS_INI_FILE), false)); |
| - m_settingsFileTab = std::auto_ptr<CPluginIniFileW>(new CPluginIniFileW(GetDataPath(SETTINGS_INI_FILE_TAB), true)); |
| - |
| m_WindowsBuildNumber = 0; |
| - Clear(); |
| - ClearTab(); |
| #ifdef SUPPORT_WHITELIST |
| ClearWhitelist(); |
| #endif |
| - |
| - // Check existence of settings file |
| - bool isFileExisting = false; |
| - { |
| - CPluginSettingsLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - std::ifstream is; |
| - is.open(GetDataPath(SETTINGS_INI_FILE), std::ios_base::in); |
| - if (!is.is_open()) |
| - { |
| - TCHAR pf[MAX_PATH]; |
| - SHGetSpecialFolderPath( |
| - 0, |
| - pf, |
| - CSIDL_PROGRAM_FILESX86, |
| - FALSE ); |
| - is.open(GetDataPath(SETTINGS_INI_FILE), std::ios_base::in); |
| - if (!is.is_open()) |
| - { |
| - m_isDirty = true; |
| - } |
| - else |
| - { |
| - is.close(); |
| - isFileExisting = true; |
| - |
| - } |
| - |
| - } |
| - else |
| - { |
| - is.close(); |
| - |
| - isFileExisting = true; |
| - } |
| - } |
| - } |
| - |
| - // Read or convert file |
| - if (isFileExisting) |
| - { |
| - Read(false); |
| - } |
| - else |
| - { |
| - m_isDirty = true; |
| - } |
| - |
| - if (s_isLightOnly) |
| - { |
| - this->SetMainProcessId(lightInstance->m_dwMainProcessId); |
| - this->SetMainThreadId(lightInstance->m_dwMainThreadId); |
| - this->SetMainUiThreadId(lightInstance->m_dwMainUiThreadId); |
| - this->SetWorkingThreadId(lightInstance->m_dwWorkingThreadId); |
| - } |
| - Write(); |
| } |
| @@ -164,14 +97,13 @@ |
| s_criticalSectionLocal.Lock(); |
| { |
| - if ((!s_instance) || (s_isLightOnly)) |
| + if (!s_instance) |
| { |
| s_instance = new CPluginSettings(); |
| #ifdef USE_CONSOLE |
| CONSOLE("Fetching Available Subscription\n"); |
| #endif |
| CPluginSettings::GetInstance()->m_subscriptions = CPluginClient::GetInstance()->FetchAvailableSubscriptions(); |
| - s_isLightOnly = false; |
| } |
| instance = s_instance; |
| @@ -196,76 +128,6 @@ |
| } |
| -bool CPluginSettings::Read(bool bDebug) |
| -{ |
| - bool isRead = true; |
| - |
| - DEBUG_SETTINGS(L"Settings::Read") |
| - { |
| - if (bDebug) |
| - { |
| - DEBUG_GENERAL(L"*** Loading settings:" + m_settingsFile->GetFilePath()); |
| - } |
| - |
| - CPluginSettingsLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - isRead = m_settingsFile->Read(); |
| - if (isRead) |
| - { |
| - if (m_settingsFile->IsValidChecksum()) |
| - { |
| - m_properties = m_settingsFile->GetSectionData("Settings"); |
| - } |
| - else |
| - { |
| - DEBUG_SETTINGS("Settings:Invalid checksum - Deleting file") |
| - |
| - Clear(); |
| - |
| - DEBUG_ERROR_LOG(m_settingsFile->GetLastError(), PLUGIN_ERROR_SETTINGS, PLUGIN_ERROR_SETTINGS_FILE_READ_CHECKSUM, "Settings::Read - Checksum") |
| - isRead = false; |
| - m_isDirty = true; |
| - } |
| - } |
| - else if (m_settingsFile->GetLastError() == ERROR_FILE_NOT_FOUND) |
| - { |
| - DEBUG_ERROR_LOG(m_settingsFile->GetLastError(), PLUGIN_ERROR_SETTINGS, PLUGIN_ERROR_SETTINGS_FILE_READ, "Settings::Read") |
| - m_isDirty = true; |
| - } |
| - else |
| - { |
| - DEBUG_ERROR_LOG(m_settingsFile->GetLastError(), PLUGIN_ERROR_SETTINGS, PLUGIN_ERROR_SETTINGS_FILE_READ, "Settings::Read") |
| - } |
| - } |
| - else |
| - { |
| - isRead = false; |
| - } |
| - } |
| - |
| - // Write file in case it is dirty |
| - if (isRead) |
| - { |
| - isRead = Write(); |
| - } |
| - |
| - return isRead; |
| -} |
| - |
| - |
| -void CPluginSettings::Clear() |
| -{ |
| - // Default settings |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - m_properties.clear(); |
| - |
| - m_properties[SETTING_PLUGIN_VERSION] = IEPLUGIN_VERSION; |
| - m_properties[SETTING_LANGUAGE] = "en"; |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| -} |
| CString CPluginSettings::GetDataPath(const CString& filename) |
| { |
| @@ -361,155 +223,6 @@ |
| } |
| -bool CPluginSettings::Has(const CString& key) const |
| -{ |
| - bool hasKey; |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - hasKey = m_properties.find(key) != m_properties.end(); |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - return hasKey; |
| -} |
| - |
| - |
| -void CPluginSettings::Remove(const CString& key) |
| -{ |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - TProperties::iterator it = m_properties.find(key); |
| - if (it != m_properties.end()) |
| - { |
| - m_properties.erase(it); |
| - m_isDirty = true; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| -} |
| - |
| - |
| -CString CPluginSettings::GetString(const CString& key, const CString& defaultValue) const |
| -{ |
| - CString val = defaultValue; |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - TProperties::const_iterator it = m_properties.find(key); |
| - if (it != m_properties.end()) |
| - { |
| - val = it->second; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - DEBUG_SETTINGS("Settings::GetString key:" + key + " value:" + val) |
| - |
| - return val; |
| -} |
| - |
| - |
| -void CPluginSettings::SetString(const CString& key, const CString& value) |
| -{ |
| - if (value.IsEmpty()) return; |
| - |
| - DEBUG_SETTINGS("Settings::SetString key:" + key + " value:" + value) |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - TProperties::iterator it = m_properties.find(key); |
| - if (it != m_properties.end() && it->second != value) |
| - { |
| - it->second = value; |
| - m_isDirty = true; |
| - } |
| - else if (it == m_properties.end()) |
| - { |
| - m_properties[key] = value; |
| - m_isDirty = true; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| -} |
| - |
| - |
| -int CPluginSettings::GetValue(const CString& key, int defaultValue) const |
| -{ |
| - int val = defaultValue; |
| - |
| - CString sValue; |
| - sValue.Format(L"%d", defaultValue); |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - TProperties::const_iterator it = m_properties.find(key); |
| - if (it != m_properties.end()) |
| - { |
| - sValue = it->second; |
| - val = _wtoi(it->second); |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - DEBUG_SETTINGS("Settings::GetValue key:" + key + " value:" + sValue) |
| - |
| - return val; |
| -} |
| - |
| - |
| -void CPluginSettings::SetValue(const CString& key, int value) |
| -{ |
| - CString sValue; |
| - sValue.Format(L"%d", value); |
| - |
| - DEBUG_SETTINGS("Settings::SetValue key:" + key + " value:" + sValue) |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - TProperties::iterator it = m_properties.find(key); |
| - if (it != m_properties.end() && it->second != sValue) |
| - { |
| - it->second = sValue; |
| - m_isDirty = true; |
| - } |
| - else if (it == m_properties.end()) |
| - { |
| - m_properties[key] = sValue; |
| - m_isDirty = true; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| -} |
| - |
| - |
| -bool CPluginSettings::GetBool(const CString& key, bool defaultValue) const |
| -{ |
| - bool value = defaultValue; |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - TProperties::const_iterator it = m_properties.find(key); |
| - if (it != m_properties.end()) |
| - { |
| - if (it->second == "true") value = true; |
| - if (it->second == "false") value = false; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - DEBUG_SETTINGS("Settings::GetBool key:" + key + " value:" + (value ? "true":"false")) |
| - |
| - return value; |
| -} |
| - |
| - |
| -void CPluginSettings::SetBool(const CString& key, bool value) |
| -{ |
| - SetString(key, value ? "true":"false"); |
| -} |
| - |
| - |
| bool CPluginSettings::IsPluginEnabled() const |
| { |
| return m_isPluginEnabledTab; |
| @@ -527,60 +240,6 @@ |
| return filterList; |
| } |
| - |
| -bool CPluginSettings::Write(bool isDebug) |
| -{ |
| - bool isWritten = true; |
| - |
| - if (!m_isDirty) |
| - { |
| - return isWritten; |
| - } |
| - |
| - if (isDebug) |
| - { |
| - DEBUG_GENERAL(L"*** Writing changed settings") |
| - } |
| - |
| - CPluginSettingsLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - m_settingsFile->Clear(); |
| - |
| - // Properties |
| - CPluginIniFileW::TSectionData settings; |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - for (TProperties::iterator it = m_properties.begin(); it != m_properties.end(); ++it) |
| - { |
| - settings[it->first] = it->second; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - m_settingsFile->UpdateSection("Settings", settings); |
| - |
| - // Write file |
| - isWritten = m_settingsFile->Write(); |
| - if (!isWritten) |
| - { |
| - DEBUG_ERROR_LOG(m_settingsFile->GetLastError(), PLUGIN_ERROR_SETTINGS, PLUGIN_ERROR_SETTINGS_FILE_WRITE, "Settings::Write") |
| - } |
| - |
| - m_isDirty = false; |
| - |
| - IncrementTabVersion(SETTING_TAB_SETTINGS_VERSION); |
| - } |
| - else |
| - { |
| - isWritten = false; |
| - } |
| - |
| - return isWritten; |
| -} |
| - |
| - |
| bool CPluginSettings::IsMainProcess(DWORD dwProcessId) const |
| { |
| if (dwProcessId == 0) |
| @@ -682,153 +341,11 @@ |
| return m_isFirstRun || m_isFirstRunUpdate; |
| } |
| -// ============================================================================ |
| -// Tab settings |
| -// ============================================================================ |
| - |
| -void CPluginSettings::ClearTab() |
| -{ |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - m_isPluginEnabledTab = true; |
| - |
| - m_errorsTab.clear(); |
| - |
| - m_propertiesTab.clear(); |
| - |
| - m_propertiesTab[SETTING_TAB_PLUGIN_ENABLED] = "true"; |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| -} |
| - |
| - |
| -bool CPluginSettings::ReadTab(bool bDebug) |
| -{ |
| - bool isRead = true; |
| - |
| - DEBUG_SETTINGS(L"SettingsTab::Read tab") |
| - |
| - if (bDebug) |
| - { |
| - DEBUG_GENERAL(L"*** Loading tab settings:" + m_settingsFileTab->GetFilePath()); |
| - } |
| - |
| - isRead = m_settingsFileTab->Read(); |
| - if (isRead) |
| - { |
| - ClearTab(); |
| - |
| - if (m_settingsFileTab->IsValidChecksum()) |
| - { |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - m_propertiesTab = m_settingsFileTab->GetSectionData("Settings"); |
| - |
| - m_errorsTab = m_settingsFileTab->GetSectionData("Errors"); |
| - |
| - TProperties::iterator it = m_propertiesTab.find(SETTING_TAB_PLUGIN_ENABLED); |
| - if (it != m_propertiesTab.end()) |
| - { |
| - m_isPluginEnabledTab = it->second != "false"; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - } |
| - else |
| - { |
| - DEBUG_SETTINGS("SettingsTab:Invalid checksum - Deleting file") |
| - |
| - DEBUG_ERROR_LOG(m_settingsFileTab->GetLastError(), PLUGIN_ERROR_SETTINGS_TAB, PLUGIN_ERROR_SETTINGS_FILE_READ_CHECKSUM, "SettingsTab::Read - Checksum") |
| - isRead = false; |
| - m_isDirtyTab = true; |
| - } |
| - } |
| - else if (m_settingsFileTab->GetLastError() == ERROR_FILE_NOT_FOUND) |
| - { |
| - m_isDirtyTab = true; |
| - } |
| - else |
| - { |
| - DEBUG_ERROR_LOG(m_settingsFileTab->GetLastError(), PLUGIN_ERROR_SETTINGS_TAB, PLUGIN_ERROR_SETTINGS_FILE_READ, "SettingsTab::Read") |
| - } |
| - |
| - |
| - // Write file in case it is dirty or does not exist |
| - WriteTab(); |
| - |
| - return isRead; |
| -} |
| - |
| -bool CPluginSettings::WriteTab(bool isDebug) |
| -{ |
| - bool isWritten = true; |
| - |
| - if (!m_isDirtyTab) |
| - { |
| - return isWritten; |
| - } |
| - |
| - if (isDebug) |
| - { |
| - DEBUG_GENERAL(L"*** Writing changed tab settings") |
| - } |
| - |
| - m_settingsFileTab->Clear(); |
| - |
| - // Properties & errors |
| - CPluginIniFileW::TSectionData settings; |
| - CPluginIniFileW::TSectionData errors; |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - for (TProperties::iterator it = m_propertiesTab.begin(); it != m_propertiesTab.end(); ++it) |
| - { |
| - settings[it->first] = it->second; |
| - } |
| - |
| - for (TProperties::iterator it = m_errorsTab.begin(); it != m_errorsTab.end(); ++it) |
| - { |
| - errors[it->first] = it->second; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - m_settingsFileTab->UpdateSection("Settings", settings); |
| - m_settingsFileTab->UpdateSection("Errors", errors); |
| - |
| - // Write file |
| - isWritten = m_settingsFileTab->Write(); |
| - if (!isWritten) |
| - { |
| - DEBUG_ERROR_LOG(m_settingsFileTab->GetLastError(), PLUGIN_ERROR_SETTINGS_TAB, PLUGIN_ERROR_SETTINGS_FILE_WRITE, "SettingsTab::Write") |
| - } |
| - |
| - m_isDirtyTab = !isWritten; |
| - |
| - return isWritten; |
| -} |
| - |
| - |
| -void CPluginSettings::EraseTab() |
| -{ |
| - ClearTab(); |
| - |
| - m_isDirtyTab = true; |
| - |
| - WriteTab(); |
| -} |
| - |
| bool CPluginSettings::IncrementTabCount() |
| { |
|
Oleksandr
2013/07/05 03:33:55
Instead of storing current tab count in settings_t
|
| int tabCount = 1; |
| - |
| - if (s_isLightOnly) |
| - { |
| - return false; |
| - } |
| - |
| CPluginSettingsTabLock lock; |
| if (lock.IsLocked()) |
| { |
| @@ -838,55 +355,13 @@ |
| CString today; |
| today.Format(L"%d-%d-%d", systemTime.wYear, systemTime.wMonth, systemTime.wDay); |
| - ReadTab(false); |
| - |
| s_criticalSectionLocal.Lock(); |
| { |
| - TProperties::iterator it = m_propertiesTab.find(SETTING_TAB_COUNT); |
| - if (it != m_propertiesTab.end()) |
| - { |
| - tabCount = _wtoi(it->second) + 1; |
| - } |
| + //TODO: Increment tab count in the AdblockPlusEngine |
| - it = m_propertiesTab.find(SETTING_TAB_START_TIME); |
| - |
| - //Is this a first IE instance? |
| - HWND ieWnd = FindWindow(L"IEFrame", NULL); |
| - if (ieWnd != NULL) |
| - { |
| - ieWnd = FindWindowEx(NULL, ieWnd, L"IEFrame", NULL); |
| - |
| - } |
| - if ((it != m_propertiesTab.end() && it->second != today)) |
| - { |
| - tabCount = 1; |
| - } |
| m_tabNumber.Format(L"%d", tabCount); |
| - |
| - m_propertiesTab[SETTING_TAB_COUNT] = m_tabNumber; |
| - m_propertiesTab[SETTING_TAB_START_TIME] = today; |
| - |
| - // Main tab? |
| - if (tabCount == 1) |
| - { |
| - m_propertiesTab[SETTING_TAB_DICTIONARY_VERSION] = "1"; |
| - m_propertiesTab[SETTING_TAB_SETTINGS_VERSION] = "1"; |
| -#ifdef SUPPORT_WHITELIST |
| - m_propertiesTab[SETTING_TAB_WHITELIST_VERSION] = "1"; |
| -#endif |
| -#ifdef SUPPORT_FILTER |
| - m_propertiesTab[SETTING_TAB_FILTER_VERSION] = "1"; |
| -#endif |
| -#ifdef SUPPORT_CONFIG |
| - m_propertiesTab[SETTING_TAB_CONFIG_VERSION] = "1"; |
| -#endif |
| - } |
| } |
| s_criticalSectionLocal.Unlock(); |
| - |
| - m_isDirtyTab = true; |
| - |
| - WriteTab(false); |
| } |
| return tabCount == 1; |
| @@ -914,42 +389,13 @@ |
| CPluginSettingsTabLock lock; |
| if (lock.IsLocked()) |
| { |
| - ReadTab(false); |
| s_criticalSectionLocal.Lock(); |
| { |
| - TProperties::iterator it = m_propertiesTab.find(SETTING_TAB_COUNT); |
| - if (it != m_propertiesTab.end()) |
| - { |
| - tabCount = max(_wtoi(it->second) - 1, 0); |
| - |
| - if (tabCount > 0) |
| - { |
| - m_tabNumber.Format(L"%d", tabCount); |
| - |
| - m_propertiesTab[SETTING_TAB_COUNT] = m_tabNumber; |
| - } |
| - else |
| - { |
| - it = m_propertiesTab.find(SETTING_TAB_START_TIME); |
| - if (it != m_propertiesTab.end()) |
| - { |
| - m_propertiesTab.erase(it); |
| - } |
| - |
| - it = m_propertiesTab.find(SETTING_TAB_COUNT); |
| - if (it != m_propertiesTab.end()) |
| - { |
| - m_propertiesTab.erase(it); |
| - } |
| - } |
| - |
| - m_isDirtyTab = true; |
| - } |
| + //TODO: Retrieve tab count from the AdblockPlusEngine |
| + m_tabNumber.Format(L"%d", tabCount); |
| } |
| s_criticalSectionLocal.Unlock(); |
| - |
| - WriteTab(false); |
| } |
| return tabCount == 0; |
| @@ -961,17 +407,13 @@ |
| CPluginSettingsTabLock lock; |
| if (lock.IsLocked()) |
| { |
| - ReadTab(false); |
| - |
| s_criticalSectionLocal.Lock(); |
| { |
| + //TODO: Query if plugin is enabled from the AdblockPlusEngine |
| m_isPluginEnabledTab = m_isPluginEnabledTab ? false : true; |
| - m_propertiesTab[SETTING_TAB_PLUGIN_ENABLED] = m_isPluginEnabledTab ? "true" : "false"; |
| - m_isDirtyTab = true; |
| + //TODO: Set plugin enabled/disabled in AdblockPlusEngine |
| } |
| s_criticalSectionLocal.Unlock(); |
| - |
| - WriteTab(false); |
| } |
| } |
| void CPluginSettings::SetPluginDisabled() |
| @@ -979,17 +421,12 @@ |
| CPluginSettingsTabLock lock; |
| if (lock.IsLocked()) |
| { |
| - ReadTab(false); |
| - |
| s_criticalSectionLocal.Lock(); |
| { |
| m_isPluginEnabledTab = false; |
| - m_propertiesTab[SETTING_TAB_PLUGIN_ENABLED] = "false"; |
| - m_isDirtyTab = true; |
| + //TODO: Set plugin disabled in AdblockPlusEngine |
| } |
| s_criticalSectionLocal.Unlock(); |
| - |
| - WriteTab(false); |
| } |
| } |
| void CPluginSettings::SetPluginEnabled() |
| @@ -997,235 +434,35 @@ |
| CPluginSettingsTabLock lock; |
| if (lock.IsLocked()) |
| { |
| - ReadTab(false); |
| - |
| s_criticalSectionLocal.Lock(); |
| { |
| m_isPluginEnabledTab = true; |
| - m_propertiesTab[SETTING_TAB_PLUGIN_ENABLED] = "true"; |
| - m_isDirtyTab = true; |
| + //TODO: Set plugin enabled in AdblockPlusEngine |
| } |
| s_criticalSectionLocal.Unlock(); |
| - |
| - WriteTab(false); |
| } |
| } |
| bool CPluginSettings::GetPluginEnabled() const |
| { |
| + //TODO: Query AdblockPlusEngine |
| return m_isPluginEnabledTab; |
| } |
| +bool CPluginSettings::GetStatusBarAsked() |
| +{ |
| + //TOTO: Get value from the registry; |
|
Wladimir Palant
2013/07/05 09:26:45
TOTO => TODO and please fix indentation
|
| + return false; |
| +} |
| + |
| +void CPluginSettings::SetStatusBarAsked(bool asked) |
|
Wladimir Palant
2013/07/05 09:26:45
The parameter can probably be removed here - we wo
|
| +{ |
| + //TODO: Set value in the registry |
| +} |
| + |
| void CPluginSettings::AddError(const CString& error, const CString& errorCode) |
| { |
| DEBUG_SETTINGS(L"SettingsTab::AddError error:" + error + " code:" + errorCode) |
| - |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - ReadTab(false); |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - if (m_errorsTab.find(error) == m_errorsTab.end()) |
| - { |
| - m_errorsTab[error] = errorCode; |
| - m_isDirtyTab = true; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - WriteTab(false); |
| - } |
| -} |
| - |
| - |
| -CString CPluginSettings::GetErrorList() const |
| -{ |
| - CString errors; |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - for (TProperties::const_iterator it = m_errorsTab.begin(); it != m_errorsTab.end(); ++it) |
| - { |
| - if (!errors.IsEmpty()) |
| - { |
| - errors += ','; |
| - } |
| - |
| - errors += it->first + '.' + it->second; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - return errors; |
| -} |
| - |
| - |
| -void CPluginSettings::RemoveErrors() |
| -{ |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - ReadTab(false); |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - if (m_errorsTab.size() > 0) |
| - { |
| - m_isDirtyTab = true; |
| - } |
| - m_errorsTab.clear(); |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - WriteTab(false); |
| - } |
| -} |
| - |
| - |
| -bool CPluginSettings::GetForceConfigurationUpdateOnStart() const |
| -{ |
| - bool isUpdating = false; |
| - |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - isUpdating = m_propertiesTab.find(SETTING_TAB_UPDATE_ON_START) != m_propertiesTab.end(); |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - } |
| - |
| - return isUpdating; |
| -} |
| - |
| - |
| -void CPluginSettings::ForceConfigurationUpdateOnStart(bool isUpdating) |
| -{ |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - ReadTab(false); |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - TProperties::iterator it = m_propertiesTab.find(SETTING_TAB_UPDATE_ON_START); |
| - |
| - if (isUpdating && it == m_propertiesTab.end()) |
| - { |
| - m_propertiesTab[SETTING_TAB_UPDATE_ON_START] = "true"; |
| - m_propertiesTab[SETTING_TAB_UPDATE_ON_START_REMOVE] = "false"; |
| - |
| - m_isDirtyTab = true; |
| - } |
| - else if (!isUpdating) |
| - { |
| - // OK to remove? |
| - TProperties::iterator itRemove = m_propertiesTab.find(SETTING_TAB_UPDATE_ON_START_REMOVE); |
| - |
| - if (itRemove == m_propertiesTab.end() || itRemove->second == "true") |
| - { |
| - if (it != m_propertiesTab.end()) |
| - { |
| - m_propertiesTab.erase(it); |
| - } |
| - |
| - if (itRemove != m_propertiesTab.end()) |
| - { |
| - m_propertiesTab.erase(itRemove); |
| - } |
| - |
| - m_isDirtyTab = true; |
| - } |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - WriteTab(false); |
| - } |
| -} |
| - |
| -void CPluginSettings::RemoveForceConfigurationUpdateOnStart() |
| -{ |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - ReadTab(false); |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - // OK to remove? |
| - TProperties::iterator itRemove = m_propertiesTab.find(SETTING_TAB_UPDATE_ON_START_REMOVE); |
| - |
| - if (itRemove != m_propertiesTab.end()) |
| - { |
| - m_propertiesTab.erase(itRemove); |
| - m_isDirtyTab = true; |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - WriteTab(false); |
| - } |
| -} |
| - |
| -void CPluginSettings::RefreshTab() |
| -{ |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - ReadTab(); |
| - } |
| -} |
| - |
| - |
| -int CPluginSettings::GetTabVersion(const CString& key) const |
| -{ |
| - int version = 0; |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - TProperties::const_iterator it = m_propertiesTab.find(key); |
| - if (it != m_propertiesTab.end()) |
| - { |
| - version = _wtoi(it->second); |
| - } |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - return version; |
| -} |
| - |
| -void CPluginSettings::IncrementTabVersion(const CString& key) |
| -{ |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - ReadTab(false); |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - int version = 1; |
| - |
| - TProperties::iterator it = m_propertiesTab.find(key); |
| - if (it != m_propertiesTab.end()) |
| - { |
| - version = _wtoi(it->second) + 1; |
| - } |
| - |
| - CString versionString; |
| - versionString.Format(L"%d", version); |
| - |
| - m_propertiesTab[key] = versionString; |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - m_isDirtyTab = true; |
| - |
| - WriteTab(false); |
| - } |
| } |