| Index: src/plugin/PluginSettings.cpp |
| =================================================================== |
| --- a/src/plugin/PluginSettings.cpp |
| +++ b/src/plugin/PluginSettings.cpp |
| @@ -22,7 +22,7 @@ |
| { |
| std::wstring CreateDomainWhitelistingFilter(CString domain) |
| { |
| - return L"@@||" + domain + L"^$document"; |
| + return std::wstring(L"@@||" + domain + L"^$document"); |
|
Wladimir Palant
2013/07/11 12:53:10
What's wrong with the implicit conversion? Instead
|
| } |
| } |
| @@ -64,17 +64,11 @@ |
| CPluginSettings* CPluginSettings::s_instance = NULL; |
| CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; |
| -#ifdef SUPPORT_WHITELIST |
| -CComAutoCriticalSection CPluginSettings::s_criticalSectionDomainHistory; |
| -#endif |
| CPluginSettings::CPluginSettings() : |
| - 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") |
| + m_settingsVersion("1"), m_isFirstRun(false), m_dwWorkingThreadId(0), m_isPluginEnabledTab(true) |
|
Wladimir Palant
2013/07/11 12:53:10
m_settingsVersion property can be removed as well.
|
| { |
| - |
| - CPluginSettings *lightInstance = s_instance; |
| s_instance = NULL; |
| m_WindowsBuildNumber = 0; |
| @@ -157,71 +151,6 @@ |
| } |
| -CString CPluginSettings::GetTempPath(const CString& filename) |
| -{ |
| - CString tempPath; |
| - |
| - LPWSTR pwszCacheDir = NULL; |
| - |
| - HRESULT hr = ::IEGetWriteableFolderPath(FOLDERID_InternetCache, &pwszCacheDir); |
| - if (SUCCEEDED(hr)) |
| - { |
| - tempPath = pwszCacheDir; |
| - } |
| - // Not implemented in IE6 |
| - else if (hr == E_NOTIMPL) |
| - { |
| - TCHAR path[MAX_PATH] = _T(""); |
| - |
| - if (::SHGetSpecialFolderPath(NULL, path, CSIDL_INTERNET_CACHE, TRUE)) |
| - { |
| - tempPath = path; |
| - } |
| - else |
| - { |
| - DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO_GET_SPECIAL_FOLDER_TEMP, "Settings::GetTempPath failed"); |
| - } |
| - } |
| - // Other error |
| - else |
| - { |
| - DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO_TEMP_PATH, "Settings::GetTempPath failed"); |
| - } |
| - |
| - ::CoTaskMemFree(pwszCacheDir); |
| - |
| - return tempPath + "\\" + filename; |
| -} |
| - |
| -CString CPluginSettings::GetTempFile(const CString& prefix, const CString& extension) |
| -{ |
| - TCHAR nameBuffer[MAX_PATH] = _T(""); |
| - |
| - CString tempPath; |
| - |
| - DWORD dwRetVal = ::GetTempFileName(GetTempPath(), prefix, 0, nameBuffer); |
| - if (dwRetVal == 0) |
| - { |
| - DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSINFO_TEMP_FILE, "Settings::GetTempFileName failed"); |
| - |
| - tempPath = GetDataPath(); |
| - } |
| - else |
| - { |
| - tempPath = nameBuffer; |
| - if (!extension.IsEmpty()) |
| - { |
| - int pos = tempPath.ReverseFind(_T('.')); |
| - if (pos >= 0) |
| - { |
| - tempPath = tempPath.Left(pos+1) + extension; |
| - } |
| - } |
| - } |
| - |
| - return tempPath; |
| -} |
| - |
| bool CPluginSettings::IsPluginEnabled() const |
| { |
| @@ -240,63 +169,6 @@ |
| return filterList; |
| } |
| -bool CPluginSettings::IsMainProcess(DWORD dwProcessId) const |
| -{ |
| - if (dwProcessId == 0) |
| - { |
| - dwProcessId = ::GetCurrentProcessId(); |
| - } |
| - return m_dwMainProcessId == dwProcessId; |
| -} |
| - |
| -void CPluginSettings::SetMainProcessId() |
| -{ |
| - m_dwMainProcessId = ::GetCurrentProcessId(); |
| -} |
| - |
| -void CPluginSettings::SetMainProcessId(DWORD id) |
| -{ |
| - m_dwMainProcessId = id; |
| -} |
| - |
| - |
| -bool CPluginSettings::IsMainUiThread(DWORD dwThreadId) const |
| -{ |
| - if (dwThreadId == 0) |
| - { |
| - dwThreadId = ::GetCurrentThreadId(); |
| - } |
| - return m_dwMainUiThreadId == dwThreadId; |
| -} |
| - |
| -void CPluginSettings::SetMainUiThreadId() |
| -{ |
| - m_dwMainUiThreadId = ::GetCurrentThreadId(); |
| -} |
| - |
| -void CPluginSettings::SetMainUiThreadId(DWORD id) |
| -{ |
| - m_dwMainUiThreadId = id; |
| -} |
| -bool CPluginSettings::IsMainThread(DWORD dwThreadId) const |
| -{ |
| - if (dwThreadId == 0) |
| - { |
| - dwThreadId = ::GetCurrentThreadId(); |
| - } |
| - return m_dwMainThreadId == dwThreadId; |
| -} |
| - |
| -void CPluginSettings::SetMainThreadId() |
| -{ |
| - m_dwMainThreadId = ::GetCurrentThreadId(); |
| -} |
| - |
| -void CPluginSettings::SetMainThreadId(DWORD id) |
| -{ |
| - m_dwMainThreadId = id; |
| -} |
| - |
| bool CPluginSettings::IsWorkingThread(DWORD dwThreadId) const |
| { |
| if (dwThreadId == 0) |
| @@ -326,82 +198,6 @@ |
| return m_isFirstRun; |
| } |
| -void CPluginSettings::SetFirstRunUpdate() |
| -{ |
| - m_isFirstRunUpdate = true; |
| -} |
| - |
| -bool CPluginSettings::IsFirstRunUpdate() const |
| -{ |
| - return m_isFirstRunUpdate; |
| -} |
| - |
| -bool CPluginSettings::IsFirstRunAny() const |
| -{ |
| - return m_isFirstRun || m_isFirstRunUpdate; |
| -} |
| - |
| - |
| -bool CPluginSettings::IncrementTabCount() |
| -{ |
| - int tabCount = 1; |
| - |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - SYSTEMTIME systemTime; |
| - ::GetSystemTime(&systemTime); |
| - |
| - CString today; |
| - today.Format(L"%d-%d-%d", systemTime.wYear, systemTime.wMonth, systemTime.wDay); |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - //TODO: Increment tab count in the AdblockPlusEngine |
| - |
| - m_tabNumber.Format(L"%d", tabCount); |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - } |
| - |
| - return tabCount == 1; |
| -} |
| - |
| - |
| -CString CPluginSettings::GetTabNumber() const |
| -{ |
| - CString tabNumber; |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - tabNumber = m_tabNumber; |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - |
| - return tabNumber; |
| -} |
| - |
| - |
| -bool CPluginSettings::DecrementTabCount() |
| -{ |
| - int tabCount = 0; |
| - |
| - CPluginSettingsTabLock lock; |
| - if (lock.IsLocked()) |
| - { |
| - |
| - s_criticalSectionLocal.Lock(); |
| - { |
| - //TODO: Retrieve tab count from the AdblockPlusEngine |
| - m_tabNumber.Format(L"%d", tabCount); |
| - } |
| - s_criticalSectionLocal.Unlock(); |
| - } |
| - |
| - return tabCount == 0; |
| -} |
| - |
| - |
| void CPluginSettings::TogglePluginEnabled() |
| { |
| CPluginSettingsTabLock lock; |
| @@ -450,13 +246,13 @@ |
| bool CPluginSettings::GetStatusBarAsked() |
| { |
| - //TOTO: Get value from the registry; |
| - return false; |
| + std::wstring res = CPluginClient::GetInstance()->GetPref(L"statusbarasked"); |
| + return res == L"true"; |
|
Wladimir Palant
2013/07/11 12:53:10
As mentioned before, the lack of type safety here
|
| } |
| -void CPluginSettings::SetStatusBarAsked(bool asked) |
| +void CPluginSettings::SetStatusBarAsked() |
| { |
| - //TODO: Set value in the registry |
| + CPluginClient::GetInstance()->SetPref(L"statusbarasked", L"true"); |
| } |
| @@ -578,7 +374,6 @@ |
| void CPluginSettings::SetSubscription(const std::wstring& url) |
| { |
| CPluginClient::GetInstance()->SetSubscription(url); |
| - RefreshFilterlist(); |
| RefreshWhitelist(); |
| } |
| @@ -592,9 +387,5 @@ |
| } |
| -void CPluginSettings::RefreshFilterlist() |
| -{ |
| - CPluginClient::GetInstance()->UpdateAllSubscriptions(); |
| -} |
| #endif // SUPPORT_WHITELIST |