| OLD | NEW |
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include <Wbemidl.h> | 3 #include <Wbemidl.h> |
| 4 | 4 |
| 5 #include "PluginIniFileW.h" | 5 #include "PluginIniFileW.h" |
| 6 #include "PluginSettings.h" | 6 #include "PluginSettings.h" |
| 7 #include "PluginDictionary.h" | 7 #include "PluginDictionary.h" |
| 8 #include "PluginClient.h" | 8 #include "PluginClient.h" |
| 9 #include "PluginChecksum.h" | 9 #include "PluginChecksum.h" |
| 10 #ifdef SUPPORT_FILTER | 10 #ifdef SUPPORT_FILTER |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 | 227 |
| 228 CPluginSettingsLock lock; | 228 CPluginSettingsLock lock; |
| 229 if (lock.IsLocked()) | 229 if (lock.IsLocked()) |
| 230 { | 230 { |
| 231 isRead = m_settingsFile->Read(); | 231 isRead = m_settingsFile->Read(); |
| 232 if (isRead) | 232 if (isRead) |
| 233 { | 233 { |
| 234 if (m_settingsFile->IsValidChecksum()) | 234 if (m_settingsFile->IsValidChecksum()) |
| 235 { | 235 { |
| 236 s_criticalSectionLocal.Lock(); | |
| 237 { | |
| 238 m_properties = m_settingsFile->GetSectionDat
a("Settings"); | |
| 239 | |
| 240 // Delete obsolete properties | |
| 241 TProperties::iterator it = m_properties.find
("pluginupdate"); | |
| 242 if (it != m_properties.end()) | |
| 243 { | |
| 244 m_properties.erase(it); | |
| 245 m_isDirty = true; | |
| 246 } | |
| 247 | |
| 248 it = m_properties.find("pluginerrors"); | |
| 249 if (it != m_properties.end()) | |
| 250 { | |
| 251 m_properties.erase(it); | |
| 252 m_isDirty = true; | |
| 253 } | |
| 254 | |
| 255 it = m_properties.find("pluginerrorcodes"); | |
| 256 if (it != m_properties.end()) | |
| 257 { | |
| 258 m_properties.erase(it); | |
| 259 m_isDirty = true; | |
| 260 } | |
| 261 | |
| 262 it = m_properties.find("pluginenabled"); | |
| 263 if (it != m_properties.end()) | |
| 264 { | |
| 265 m_properties.erase(it); | |
| 266 m_isDirty = true; | |
| 267 } | |
| 268 | |
| 269 // Convert property 'pluginid' to 'userid' | |
| 270 if (m_properties.find(SETTING_USER_ID) == m_
properties.end()) | |
| 271 { | |
| 272 it = m_properties.find("pluginid"); | |
| 273 if (it != m_properties.end()) | |
| 274 { | |
| 275 m_properties[SETTING_USER_ID
] = it->second; | |
| 276 | |
| 277 m_properties.erase(it); | |
| 278 m_isDirty = true; | |
| 279 } | |
| 280 } | |
| 281 } | |
| 282 s_criticalSectionLocal.Unlock(); | |
| 283 | |
| 284 #ifdef SUPPORT_FILTER | 236 #ifdef SUPPORT_FILTER |
| 285 // Unpack filter URLs | 237 // Unpack filter URLs |
| 286 CPluginIniFileW::TSectionData filters = m_settingsFile->GetS
ectionData("Filters"); | 238 CPluginIniFileW::TSectionData filters = m_settingsFile->GetS
ectionData("Filters"); |
| 287 int filterCount = 0; | 239 int filterCount = 0; |
| 288 bool bContinue = true; | 240 bool bContinue = true; |
| 289 | 241 |
| 290 s_criticalSectionFilters.Lock(); | 242 s_criticalSectionFilters.Lock(); |
| 291 { | 243 { |
| 292 m_filterUrlList.clear(); | 244 m_filterUrlList.clear(); |
| 293 | 245 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 305 } |
| 354 | 306 |
| 355 | 307 |
| 356 void CPluginSettings::Clear() | 308 void CPluginSettings::Clear() |
| 357 { | 309 { |
| 358 // Default settings | 310 // Default settings |
| 359 s_criticalSectionLocal.Lock(); | 311 s_criticalSectionLocal.Lock(); |
| 360 { | 312 { |
| 361 m_properties.clear(); | 313 m_properties.clear(); |
| 362 | 314 |
| 363 m_properties[SETTING_PLUGIN_EXPIRED] = "false"; | |
| 364 m_properties[SETTING_PLUGIN_VERSION] = IEPLUGIN_VERSION; | 315 m_properties[SETTING_PLUGIN_VERSION] = IEPLUGIN_VERSION; |
| 365 m_properties[SETTING_LANGUAGE] = "en"; | 316 m_properties[SETTING_LANGUAGE] = "en"; |
| 366 m_properties[SETTING_DICTIONARY_VERSION] = "1"; | 317 m_properties[SETTING_DICTIONARY_VERSION] = "1"; |
| 367 m_properties[SETTING_PLUGIN_REGISTRATION] = "false"; | |
| 368 } | 318 } |
| 369 s_criticalSectionLocal.Unlock(); | 319 s_criticalSectionLocal.Unlock(); |
| 370 | 320 |
| 371 // Default filters | 321 // Default filters |
| 372 #ifdef SUPPORT_FILTER | 322 #ifdef SUPPORT_FILTER |
| 373 | 323 |
| 374 s_criticalSectionFilters.Lock(); | 324 s_criticalSectionFilters.Lock(); |
| 375 { | 325 { |
| 376 m_filterUrlList.clear(); | 326 m_filterUrlList.clear(); |
| 377 m_filterUrlList[CString(FILTERS_PROTOCOL) + CString(FILTERS_HOST
) + "/easylist.txt"] = 1; | 327 m_filterUrlList[CString(FILTERS_PROTOCOL) + CString(FILTERS_HOST
) + "/easylist.txt"] = 1; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 s_criticalSectionLocal.Unlock(); | 536 s_criticalSectionLocal.Unlock(); |
| 587 } | 537 } |
| 588 | 538 |
| 589 | 539 |
| 590 CString CPluginSettings::GetString(const CString& key, const CString& defaultVal
ue) const | 540 CString CPluginSettings::GetString(const CString& key, const CString& defaultVal
ue) const |
| 591 { | 541 { |
| 592 CString val = defaultValue; | 542 CString val = defaultValue; |
| 593 | 543 |
| 594 s_criticalSectionLocal.Lock(); | 544 s_criticalSectionLocal.Lock(); |
| 595 { | 545 { |
| 596 | |
| 597 if (key == SETTING_PLUGIN_ID) | |
| 598 { | |
| 599 #ifdef CONFIG_IN_REGISTRY | |
| 600 DWORD dwResult = NULL; | |
| 601 HKEY hKey; | |
| 602 RegOpenKey(HKEY_CURRENT_USER, L"SOFTWARE\\SimpleAdblock"
, &hKey); | |
| 603 DWORD type = 0; | |
| 604 WCHAR pid[250]; | |
| 605 DWORD cbData; | |
| 606 dwResult = ::RegQueryValueEx(hKey, L"PluginId", NULL, &t
ype, (BYTE*)pid, &cbData); | |
| 607 if (dwResult == ERROR_SUCCESS) | |
| 608 { | |
| 609 CString pluginId = pid; | |
| 610 ::RegCloseKey(hKey); | |
| 611 s_criticalSectionLocal.Unlock(); | |
| 612 return pluginId; | |
| 613 } | |
| 614 #endif | |
| 615 } | |
| 616 | |
| 617 if (key == SETTING_USER_ID) | |
| 618 { | |
| 619 #ifdef CONFIG_IN_REGISTRY | |
| 620 DWORD dwResult = NULL; | |
| 621 HKEY hKey; | |
| 622 RegOpenKey(HKEY_CURRENT_USER, L"SOFTWARE\\SimpleAdblock"
, &hKey); | |
| 623 DWORD type = 0; | |
| 624 WCHAR pid[250]; | |
| 625 DWORD cbData; | |
| 626 dwResult = ::RegQueryValueEx(hKey, L"UserId", NULL, &typ
e, (BYTE*)pid, &cbData); | |
| 627 if (dwResult == ERROR_SUCCESS) | |
| 628 { | |
| 629 CString userId = pid; | |
| 630 ::RegCloseKey(hKey); | |
| 631 s_criticalSectionLocal.Unlock(); | |
| 632 return userId; | |
| 633 } | |
| 634 #endif | |
| 635 } | |
| 636 | |
| 637 TProperties::const_iterator it = m_properties.find(key); | 546 TProperties::const_iterator it = m_properties.find(key); |
| 638 if (it != m_properties.end()) | 547 if (it != m_properties.end()) |
| 639 { | 548 { |
| 640 val = it->second; | 549 val = it->second; |
| 641 } | 550 } |
| 642 } | 551 } |
| 643 s_criticalSectionLocal.Unlock(); | 552 s_criticalSectionLocal.Unlock(); |
| 644 | 553 |
| 645 DEBUG_SETTINGS("Settings::GetString key:" + key + " value:" + val) | 554 DEBUG_SETTINGS("Settings::GetString key:" + key + " value:" + val) |
| 646 | 555 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 652 |
| 744 | 653 |
| 745 void CPluginSettings::SetBool(const CString& key, bool value) | 654 void CPluginSettings::SetBool(const CString& key, bool value) |
| 746 { | 655 { |
| 747 SetString(key, value ? "true":"false"); | 656 SetString(key, value ? "true":"false"); |
| 748 } | 657 } |
| 749 | 658 |
| 750 | 659 |
| 751 bool CPluginSettings::IsPluginEnabled() const | 660 bool CPluginSettings::IsPluginEnabled() const |
| 752 { | 661 { |
| 753 » return m_isPluginEnabledTab && !GetBool(SETTING_PLUGIN_EXPIRED, false); | 662 » return m_isPluginEnabledTab; |
| 754 } | 663 } |
| 755 | 664 |
| 756 | 665 |
| 757 #ifdef SUPPORT_FILTER | 666 #ifdef SUPPORT_FILTER |
| 758 | 667 |
| 759 void CPluginSettings::SetFilterUrlList(const TFilterUrlList& filters) | 668 void CPluginSettings::SetFilterUrlList(const TFilterUrlList& filters) |
| 760 { | 669 { |
| 761 DEBUG_SETTINGS(L"Settings::SetFilterUrlList") | 670 DEBUG_SETTINGS(L"Settings::SetFilterUrlList") |
| 762 | 671 |
| 763 s_criticalSectionFilters.Lock(); | 672 s_criticalSectionFilters.Lock(); |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 m_propertiesTab[SETTING_TAB_PLUGIN_ENABLED] = "true"; | 1354 m_propertiesTab[SETTING_TAB_PLUGIN_ENABLED] = "true"; |
| 1446 m_isDirtyTab = true; | 1355 m_isDirtyTab = true; |
| 1447 } | 1356 } |
| 1448 s_criticalSectionLocal.Unlock(); | 1357 s_criticalSectionLocal.Unlock(); |
| 1449 | 1358 |
| 1450 WriteTab(false); | 1359 WriteTab(false); |
| 1451 } | 1360 } |
| 1452 } | 1361 } |
| 1453 bool CPluginSettings::GetPluginEnabled() const | 1362 bool CPluginSettings::GetPluginEnabled() const |
| 1454 { | 1363 { |
| 1455 //Display plugin as disabled if limit is passed | |
| 1456 CPluginSettings* settings = CPluginSettings::GetInstance(); | |
| 1457 if (!settings->GetBool(SETTING_PLUGIN_REGISTRATION, false) && | |
| 1458 (settings->GetValue(SETTING_PLUGIN_ADBLOCKCOUNT, 0) >= settings-
>GetValue(SETTING_PLUGIN_ADBLOCKLIMIT, 0)) && | |
| 1459 (settings->GetValue(SETTING_PLUGIN_ADBLOCKLIMIT, 0) > 0)) | |
| 1460 { | |
| 1461 return false; | |
| 1462 } | |
| 1463 return m_isPluginEnabledTab; | 1364 return m_isPluginEnabledTab; |
| 1464 } | 1365 } |
| 1465 | 1366 |
| 1466 | 1367 |
| 1467 void CPluginSettings::AddError(const CString& error, const CString& errorCode) | 1368 void CPluginSettings::AddError(const CString& error, const CString& errorCode) |
| 1468 { | 1369 { |
| 1469 DEBUG_SETTINGS(L"SettingsTab::AddError error:" + error + " code:" + errorCod
e) | 1370 DEBUG_SETTINGS(L"SettingsTab::AddError error:" + error + " code:" + errorCod
e) |
| 1470 | 1371 |
| 1471 CPluginSettingsTabLock lock; | 1372 CPluginSettingsTabLock lock; |
| 1472 if (lock.IsLocked()) | 1373 if (lock.IsLocked()) |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); | 2010 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
| 2110 bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi); | 2011 bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi); |
| 2111 | 2012 |
| 2112 m_WindowsBuildNumber = osvi.dwBuildNumber; | 2013 m_WindowsBuildNumber = osvi.dwBuildNumber; |
| 2113 } | 2014 } |
| 2114 | 2015 |
| 2115 return m_WindowsBuildNumber; | 2016 return m_WindowsBuildNumber; |
| 2116 } | 2017 } |
| 2117 | 2018 |
| 2118 #endif // SUPPORT_WHITELIST | 2019 #endif // SUPPORT_WHITELIST |
| OLD | NEW |