| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include <Wbemidl.h> | 3 #include <Wbemidl.h> |
| 4 #include <time.h> | 4 #include <time.h> |
| 5 #include "PluginIniFileW.h" | 5 #include "PluginIniFileW.h" |
| 6 #include "PluginIniFile.h" | 6 #include "PluginIniFile.h" |
| 7 #include "PluginSettings.h" | 7 #include "PluginSettings.h" |
| 8 #include "PluginDictionary.h" | 8 #include "PluginDictionary.h" |
| 9 #include "PluginClient.h" | 9 #include "PluginClient.h" |
| 10 #include "PluginChecksum.h" | 10 #include "PluginChecksum.h" |
| 11 #include "PluginSystem.h" | 11 #include "PluginSystem.h" |
| 12 #ifdef SUPPORT_FILTER | 12 #ifdef SUPPORT_FILTER |
| 13 #include "PluginFilter.h" | 13 #include "PluginFilter.h" |
| 14 #endif | 14 #endif |
| 15 #include "PluginMutex.h" | 15 #include "PluginMutex.h" |
| 16 #include "PluginHttpRequest.h" | 16 #include "PluginHttpRequest.h" |
| 17 #include "../shared/Utils.h" | |
| 17 #include <memory> | 18 #include <memory> |
| 18 | 19 |
| 19 | 20 |
| 20 // IE functions | 21 // IE functions |
| 21 #pragma comment(lib, "iepmapi.lib") | 22 #pragma comment(lib, "iepmapi.lib") |
| 22 | 23 |
| 23 #include <knownfolders.h> | 24 #include <knownfolders.h> |
| 24 | 25 |
| 25 class TSettings | 26 class TSettings |
| 26 { | 27 { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 50 | 51 |
| 51 class CPluginSettingsWhitelistLock : public CPluginMutex | 52 class CPluginSettingsWhitelistLock : public CPluginMutex |
| 52 { | 53 { |
| 53 public: | 54 public: |
| 54 CPluginSettingsWhitelistLock() : CPluginMutex("SettingsFileWhitelist", PLUGIN_ ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {} | 55 CPluginSettingsWhitelistLock() : CPluginMutex("SettingsFileWhitelist", PLUGIN_ ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {} |
| 55 ~CPluginSettingsWhitelistLock() {} | 56 ~CPluginSettingsWhitelistLock() {} |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 #endif | 59 #endif |
| 59 | 60 |
| 60 WCHAR* CPluginSettings::s_dataPath; | |
| 61 WCHAR* CPluginSettings::s_dataPathParent; | |
| 62 | |
| 63 CPluginSettings* CPluginSettings::s_instance = NULL; | 61 CPluginSettings* CPluginSettings::s_instance = NULL; |
| 64 bool CPluginSettings::s_isLightOnly = false; | 62 bool CPluginSettings::s_isLightOnly = false; |
| 65 | 63 |
| 66 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; | 64 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; |
| 67 #ifdef SUPPORT_WHITELIST | 65 #ifdef SUPPORT_WHITELIST |
| 68 CComAutoCriticalSection CPluginSettings::s_criticalSectionDomainHistory; | 66 CComAutoCriticalSection CPluginSettings::s_criticalSectionDomainHistory; |
| 69 #endif | 67 #endif |
| 70 | 68 |
| 71 | 69 |
| 72 CPluginSettings::CPluginSettings() : | 70 CPluginSettings::CPluginSettings() : |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 this->SetMainThreadId(lightInstance->m_dwMainThreadId); | 140 this->SetMainThreadId(lightInstance->m_dwMainThreadId); |
| 143 this->SetMainUiThreadId(lightInstance->m_dwMainUiThreadId); | 141 this->SetMainUiThreadId(lightInstance->m_dwMainUiThreadId); |
| 144 this->SetWorkingThreadId(lightInstance->m_dwWorkingThreadId); | 142 this->SetWorkingThreadId(lightInstance->m_dwWorkingThreadId); |
| 145 } | 143 } |
| 146 Write(); | 144 Write(); |
| 147 } | 145 } |
| 148 | 146 |
| 149 | 147 |
| 150 CPluginSettings::~CPluginSettings() | 148 CPluginSettings::~CPluginSettings() |
| 151 { | 149 { |
| 152 | |
| 153 if (s_dataPathParent != NULL) | |
| 154 { | |
| 155 delete s_dataPathParent; | |
| 156 } | |
| 157 s_instance = NULL; | 150 s_instance = NULL; |
| 158 } | 151 } |
| 159 | 152 |
| 160 | 153 |
| 161 CPluginSettings* CPluginSettings::GetInstance() | 154 CPluginSettings* CPluginSettings::GetInstance() |
| 162 { | 155 { |
| 163 CPluginSettings* instance = NULL; | 156 CPluginSettings* instance = NULL; |
| 164 | 157 |
| 165 s_criticalSectionLocal.Lock(); | 158 s_criticalSectionLocal.Lock(); |
| 166 { | 159 { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 CString ver(it->second); | 302 CString ver(it->second); |
| 310 SetString(SETTING_PLUGIN_UPDATE_VERSION, ver); | 303 SetString(SETTING_PLUGIN_UPDATE_VERSION, ver); |
| 311 m_isDirty = true; | 304 m_isDirty = true; |
| 312 DEBUG_SETTINGS("Settings::Configuration plugin update version:" + it->seco nd); | 305 DEBUG_SETTINGS("Settings::Configuration plugin update version:" + it->seco nd); |
| 313 } | 306 } |
| 314 } | 307 } |
| 315 | 308 |
| 316 return true; | 309 return true; |
| 317 } | 310 } |
| 318 | 311 |
| 319 CString CPluginSettings::GetDataPathParent() | |
| 320 { | |
| 321 if (s_dataPathParent == NULL) | |
| 322 { | |
| 323 WCHAR* lpData = new WCHAR[MAX_PATH]; | |
| 324 | |
| 325 OSVERSIONINFO osVersionInfo; | |
| 326 ::ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFO)); | |
| 327 | |
| 328 osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | |
| 329 | |
| 330 ::GetVersionEx(&osVersionInfo); | |
| 331 | |
| 332 //Windows Vista - 6.0 | |
| 333 //Windows Server 2003 R2 - 5.2 | |
| 334 //Windows Server 2003 - 5.2 | |
| 335 //Windows XP - 5.1 | |
| 336 if (osVersionInfo.dwMajorVersion >= 6) | |
| 337 { | |
| 338 if (::SHGetSpecialFolderPath(NULL, lpData, CSIDL_LOCAL_APPDATA, TRUE)) | |
| 339 { | |
| 340 wcscat(lpData, L"Low"); | |
| 341 } | |
| 342 else | |
| 343 { | |
| 344 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYS INFO_GET_SPECIAL_FOLDER_LOCAL, "Settings::GetDataPath failed"); | |
| 345 } | |
| 346 } | |
| 347 else | |
| 348 { | |
| 349 if (!SHGetSpecialFolderPath(NULL, lpData, CSIDL_APPDATA, TRUE)) | |
| 350 { | |
| 351 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYS INFO_GET_SPECIAL_FOLDER, "Settings::GetDataPath failed"); | |
| 352 } | |
| 353 } | |
| 354 | |
| 355 ::PathAddBackslash(lpData); | |
| 356 | |
| 357 s_dataPathParent = lpData; | |
| 358 | |
| 359 if (!::CreateDirectory(s_dataPathParent, NULL)) | |
| 360 { | |
| 361 DWORD errorCode = ::GetLastError(); | |
| 362 if (errorCode != ERROR_ALREADY_EXISTS) | |
| 363 { | |
| 364 DEBUG_ERROR_LOG(errorCode, PLUGIN_ERROR_SETTINGS, PLUGIN_ERROR_SETTINGS_ CREATE_FOLDER, "Settings::CreateDirectory failed"); | |
| 365 } | |
| 366 } | |
| 367 } | |
| 368 | |
| 369 return s_dataPathParent; | |
| 370 } | |
| 371 | |
| 372 CString CPluginSettings::GetDataPath(const CString& filename) | 312 CString CPluginSettings::GetDataPath(const CString& filename) |
| 373 { | 313 { |
| 374 if (s_dataPath == NULL) | 314 std::wstring path = ::GetAppDataPath() + L"\\" + (LPCWSTR)filename; |
|
Felix Dahlke
2013/06/04 10:18:09
Shouldn't this be filename.c_str()? I'd prefer a C
Wladimir Palant
2013/06/04 10:39:03
It's CString so - no. Changed it into static_cast.
| |
| 375 { | 315 return CString(path.c_str()); |
| 376 WCHAR* lpData = new WCHAR[MAX_PATH]; | |
| 377 | |
| 378 OSVERSIONINFO osVersionInfo; | |
| 379 ::ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFO)); | |
| 380 | |
| 381 osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | |
| 382 | |
| 383 ::GetVersionEx(&osVersionInfo); | |
| 384 | |
| 385 //Windows Vista - 6.0 | |
| 386 //Windows Server 2003 R2 - 5.2 | |
| 387 //Windows Server 2003 - 5.2 | |
| 388 //Windows XP - 5.1 | |
| 389 if (osVersionInfo.dwMajorVersion >= 6) | |
| 390 { | |
| 391 if (::SHGetSpecialFolderPath(NULL, lpData, CSIDL_LOCAL_APPDATA, TRUE)) | |
| 392 { | |
| 393 wcscat(lpData, L"Low"); | |
| 394 } | |
| 395 else | |
| 396 { | |
| 397 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYS INFO_GET_SPECIAL_FOLDER_LOCAL, "Settings::GetDataPath failed"); | |
| 398 } | |
| 399 } | |
| 400 else | |
| 401 { | |
| 402 if (!SHGetSpecialFolderPath(NULL, lpData, CSIDL_APPDATA, TRUE)) | |
| 403 { | |
| 404 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYS INFO_GET_SPECIAL_FOLDER, "Settings::GetDataPath failed"); | |
| 405 } | |
| 406 } | |
| 407 | |
| 408 ::PathAddBackslash(lpData); | |
| 409 | |
| 410 s_dataPath = lpData; | |
| 411 | |
| 412 if (!::CreateDirectory(s_dataPath + CString(USER_DIR), NULL)) | |
| 413 { | |
| 414 DWORD errorCode = ::GetLastError(); | |
| 415 if (errorCode != ERROR_ALREADY_EXISTS) | |
| 416 { | |
| 417 DEBUG_ERROR_LOG(errorCode, PLUGIN_ERROR_SETTINGS, PLUGIN_ERROR_SETTINGS_ CREATE_FOLDER, "Settings::CreateDirectory failed"); | |
| 418 } | |
| 419 } | |
| 420 } | |
| 421 | |
| 422 return s_dataPath + CString(USER_DIR) + filename; | |
| 423 } | 316 } |
| 424 | 317 |
| 425 CString CPluginSettings::GetSystemLanguage() | 318 CString CPluginSettings::GetSystemLanguage() |
| 426 { | 319 { |
| 427 CString language; | 320 CString language; |
| 428 CString country; | 321 CString country; |
| 429 | 322 |
| 430 DWORD bufSize = 256; | 323 DWORD bufSize = 256; |
| 431 int ccBuf = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME, langu age.GetBufferSetLength(bufSize), bufSize); | 324 int ccBuf = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME, langu age.GetBufferSetLength(bufSize), bufSize); |
| 432 ccBuf = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO3166CTRYNAME, country. GetBufferSetLength(bufSize), bufSize); | 325 ccBuf = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO3166CTRYNAME, country. GetBufferSetLength(bufSize), bufSize); |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1581 return CString(L""); | 1474 return CString(L""); |
| 1582 } | 1475 } |
| 1583 | 1476 |
| 1584 | 1477 |
| 1585 void CPluginSettings::RefreshFilterlist() | 1478 void CPluginSettings::RefreshFilterlist() |
| 1586 { | 1479 { |
| 1587 CPluginClient::GetInstance()->UpdateAllSubscriptions(); | 1480 CPluginClient::GetInstance()->UpdateAllSubscriptions(); |
| 1588 } | 1481 } |
| 1589 | 1482 |
| 1590 #endif // SUPPORT_WHITELIST | 1483 #endif // SUPPORT_WHITELIST |
| OLD | NEW |