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 "PluginClient.h" | 8 #include "PluginClient.h" |
9 #include "PluginChecksum.h" | 9 #include "PluginChecksum.h" |
10 #include "PluginSystem.h" | 10 #include "PluginSystem.h" |
11 #ifdef SUPPORT_FILTER | 11 #ifdef SUPPORT_FILTER |
12 #include "PluginFilter.h" | 12 #include "PluginFilter.h" |
13 #endif | 13 #endif |
14 #include "PluginMutex.h" | 14 #include "PluginMutex.h" |
15 #include "PluginHttpRequest.h" | 15 #include "PluginHttpRequest.h" |
16 #include "../shared/Utils.h" | 16 #include "../shared/Utils.h" |
17 #include <memory> | 17 #include <memory> |
18 | 18 |
19 | 19 |
20 // IE functions | 20 // IE functions |
21 #pragma comment(lib, "iepmapi.lib") | 21 #pragma comment(lib, "iepmapi.lib") |
22 | 22 |
23 #include <knownfolders.h> | 23 #include <knownfolders.h> |
24 | 24 |
25 namespace | 25 namespace |
26 { | 26 { |
27 std::string CreateDomainWhitelistingFilter(CString domain) | 27 std::wstring CreateDomainWhitelistingFilter(CString domain) |
28 { | 28 { |
29 return std::string("@@||").append(CW2A(domain)).append("^$document"); | 29 return L"@@||" + domain + L"^$document"; |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 class TSettings | 33 class TSettings |
34 { | 34 { |
35 DWORD processorId; | 35 DWORD processorId; |
36 | 36 |
37 char sPluginId[44]; | 37 char sPluginId[44]; |
38 }; | 38 }; |
39 | 39 |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 return m_isPluginEnabledTab; | 515 return m_isPluginEnabledTab; |
516 } | 516 } |
517 | 517 |
518 | 518 |
519 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const | 519 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const |
520 { | 520 { |
521 std::map<CString, CString> filterList; | 521 std::map<CString, CString> filterList; |
522 for (size_t i = 0; i < m_subscriptions.size(); i ++) | 522 for (size_t i = 0; i < m_subscriptions.size(); i ++) |
523 { | 523 { |
524 SubscriptionDescription it = m_subscriptions[i]; | 524 SubscriptionDescription it = m_subscriptions[i]; |
525 filterList.insert(std::make_pair(CString(CA2T(it.url.c_str(), CP_UTF8)), CSt
ring(CA2T(it.title.c_str(), CP_UTF8)))); | 525 filterList.insert(std::make_pair(CString(it.url.c_str()), CString(it.title.c
_str()))); |
526 } | 526 } |
527 return filterList; | 527 return filterList; |
528 } | 528 } |
529 | 529 |
530 | 530 |
531 bool CPluginSettings::Write(bool isDebug) | 531 bool CPluginSettings::Write(bool isDebug) |
532 { | 532 { |
533 bool isWritten = true; | 533 bool isWritten = true; |
534 | 534 |
535 if (!m_isDirty) | 535 if (!m_isDirty) |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 s_criticalSectionLocal.Lock(); | 1293 s_criticalSectionLocal.Lock(); |
1294 { | 1294 { |
1295 count = (int)m_whitelistedDomains.size(); | 1295 count = (int)m_whitelistedDomains.size(); |
1296 } | 1296 } |
1297 s_criticalSectionLocal.Unlock(); | 1297 s_criticalSectionLocal.Unlock(); |
1298 | 1298 |
1299 return count; | 1299 return count; |
1300 } | 1300 } |
1301 | 1301 |
1302 | 1302 |
1303 std::vector<std::string> CPluginSettings::GetWhiteListedDomainList() | 1303 std::vector<std::wstring> CPluginSettings::GetWhiteListedDomainList() |
1304 { | 1304 { |
1305 bool r = ReadWhitelist(false); | 1305 bool r = ReadWhitelist(false); |
1306 return m_whitelistedDomains; | 1306 return m_whitelistedDomains; |
1307 } | 1307 } |
1308 | 1308 |
1309 | 1309 |
1310 bool CPluginSettings::RefreshWhitelist() | 1310 bool CPluginSettings::RefreshWhitelist() |
1311 { | 1311 { |
1312 CPluginSettingsWhitelistLock lock; | 1312 CPluginSettingsWhitelistLock lock; |
1313 if (lock.IsLocked()) | 1313 if (lock.IsLocked()) |
(...skipping 17 matching lines...) Expand all Loading... |
1331 | 1331 |
1332 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); | 1332 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
1333 bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi); | 1333 bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi); |
1334 | 1334 |
1335 m_WindowsBuildNumber = osvi.dwBuildNumber; | 1335 m_WindowsBuildNumber = osvi.dwBuildNumber; |
1336 } | 1336 } |
1337 | 1337 |
1338 return m_WindowsBuildNumber; | 1338 return m_WindowsBuildNumber; |
1339 } | 1339 } |
1340 | 1340 |
1341 void CPluginSettings::SetSubscription(BSTR url) | 1341 void CPluginSettings::SetSubscription(const std::wstring& url) |
1342 { | |
1343 std::string urlConverted = CT2A(url, CP_UTF8); | |
1344 SetSubscription(urlConverted); | |
1345 } | |
1346 | |
1347 void CPluginSettings::SetSubscription(std::string url) | |
1348 { | 1342 { |
1349 CPluginClient::GetInstance()->SetSubscription(url); | 1343 CPluginClient::GetInstance()->SetSubscription(url); |
1350 RefreshFilterlist(); | 1344 RefreshFilterlist(); |
1351 RefreshWhitelist(); | 1345 RefreshWhitelist(); |
1352 } | 1346 } |
1353 | 1347 |
1354 std::vector<std::string> split(const std::string& s, char delim) { | |
1355 std::vector<std::string> retTokens; | |
1356 std::stringstream ss(s); | |
1357 std::string item; | |
1358 while (std::getline(ss, item, delim)) { | |
1359 retTokens.push_back(item); | |
1360 } | |
1361 return retTokens; | |
1362 } | |
1363 | |
1364 | |
1365 CString CPluginSettings::GetSubscription() | 1348 CString CPluginSettings::GetSubscription() |
1366 { | 1349 { |
1367 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc
e()->GetListedSubscriptions(); | 1350 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc
e()->GetListedSubscriptions(); |
1368 if (subscriptions.size() > 0) | 1351 if (subscriptions.size() > 0) |
1369 return CString(CA2T(subscriptions.front().url.c_str(), CP_UTF8)); | 1352 return CString(subscriptions.front().url.c_str()); |
1370 else | 1353 else |
1371 return CString(L""); | 1354 return CString(L""); |
1372 } | 1355 } |
1373 | 1356 |
1374 | 1357 |
1375 void CPluginSettings::RefreshFilterlist() | 1358 void CPluginSettings::RefreshFilterlist() |
1376 { | 1359 { |
1377 CPluginClient::GetInstance()->UpdateAllSubscriptions(); | 1360 CPluginClient::GetInstance()->UpdateAllSubscriptions(); |
1378 } | 1361 } |
1379 | 1362 |
1380 #endif // SUPPORT_WHITELIST | 1363 #endif // SUPPORT_WHITELIST |
OLD | NEW |