Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: Shared/PluginConfiguration.cpp

Issue 9998007: Initial libadblockplus integration (Closed)
Patch Set: Whitelisting management Created April 11, 2013, 9:06 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Shared/PluginConfiguration.h ('k') | Shared/PluginSettings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginConfiguration.h" 3 #include "PluginConfiguration.h"
4 #include "PluginClient.h" 4 #include "PluginClient.h"
5 #include "PluginIniFile.h" 5 #include "PluginIniFile.h"
6 #include "PluginSettings.h" 6 #include "PluginSettings.h"
7 #include "PluginSystem.h" 7 #include "PluginSystem.h"
8 #include "PluginHttpRequest.h" 8 #include "PluginHttpRequest.h"
9 9
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 httpRequest.Add("enabled", settings->GetPluginEnabled() ? "true":"false"); 62 httpRequest.Add("enabled", settings->GetPluginEnabled() ? "true":"false");
63 httpRequest.Add("lang", settings->GetString(SETTING_LANGUAGE, "err")); 63 httpRequest.Add("lang", settings->GetString(SETTING_LANGUAGE, "err"));
64 httpRequest.Add("ie", system->GetBrowserVersion()); 64 httpRequest.Add("ie", system->GetBrowserVersion());
65 httpRequest.Add("ielang", system->GetBrowserLanguage()); 65 httpRequest.Add("ielang", system->GetBrowserLanguage());
66 66
67 httpRequest.AddOsInfo(); 67 httpRequest.AddOsInfo();
68 68
69 httpRequest.Add("errors", settings->GetErrorList()); 69 httpRequest.Add("errors", settings->GetErrorList());
70 70
71 #ifdef SUPPORT_WHITELIST
72
73 // White list info
74 CString whiteListCount;
75 whiteListCount.Format(L"%d", settings->GetWhiteListedDomainCount());
76
77 httpRequest.Add("wcount", whiteListCount);
78
79 TDomainList whiteListToGo = settings->GetWhiteListedDomainList(true);
80 TDomainList whiteListToGoSent;
81
82 if (!whiteListToGo.empty())
83 {
84 CString whiteList;
85 int count = 0;
86
87 for (TDomainList::const_iterator it = whiteListToGo.begin(); it != whiteList ToGo.end() && count < 5; count++, ++it)
88 {
89 CString whiteListReason;
90 whiteListReason.Format(L",%d", it->second);
91
92 if (!whiteList.IsEmpty())
93 {
94 whiteList += ',';
95 }
96 whiteList += it->first;
97 whiteList += whiteListReason;
98
99 whiteListToGoSent.insert(std::make_pair(it->first, it->second));
100 }
101
102 httpRequest.Add("wlist", whiteList);
103 }
104
105 #endif // SUPPORT_WHITELIST
106
107 httpRequest.Add("dicv", settings->GetValue(SETTING_DICTIONARY_VERSION, 0)); 71 httpRequest.Add("dicv", settings->GetValue(SETTING_DICTIONARY_VERSION, 0));
108 72
109 #ifdef SUPPORT_CONFIG 73 #ifdef SUPPORT_CONFIG
110 httpRequest.Add("configv", settings->GetValue(SETTING_CONFIG_VERSION, 0)); 74 httpRequest.Add("configv", settings->GetValue(SETTING_CONFIG_VERSION, 0));
111 #endif 75 #endif
112 76
113 if (!isOk) 77 if (!isOk)
114 { 78 {
115 return false; 79 return false;
116 } 80 }
117 81
118 if (!httpRequest.Send(false)) 82 if (!httpRequest.Send(false))
119 { 83 {
120 DEBUG_ERROR("Configuration::Download - Failed downloading settings"); 84 DEBUG_ERROR("Configuration::Download - Failed downloading settings");
121 return false; 85 return false;
122 } 86 }
123 87
124 if (!httpRequest.IsValidResponse()) 88 if (!httpRequest.IsValidResponse())
125 { 89 {
126 DEBUG_ERROR("Configuration::Download - Invalid settings response"); 90 DEBUG_ERROR("Configuration::Download - Invalid settings response");
127 DEBUG_ERROR("Configuration::Download\n\n" + httpRequest.GetResponseText() + "\n"); 91 DEBUG_ERROR("Configuration::Download\n\n" + httpRequest.GetResponseText() + "\n");
128 return false; 92 return false;
129 } 93 }
130 94
131 const std::auto_ptr<CPluginIniFile>& iniFile = httpRequest.GetResponseFile(); 95 const std::auto_ptr<CPluginIniFile>& iniFile = httpRequest.GetResponseFile();
132 96
133 #ifdef SUPPORT_WHITELIST
134
135 // Update whitelists to go
136 if (!whiteListToGoSent.empty())
137 {
138 settings->RemoveWhiteListedDomainsToGo(whiteListToGoSent);
139 }
140
141 #endif // SUPPORT_WHITELIST
142
143 // Unpack settings 97 // Unpack settings
144 CPluginIniFile::TSectionData settingsData = iniFile->GetSectionData("Settings" ); 98 CPluginIniFile::TSectionData settingsData = iniFile->GetSectionData("Settings" );
145 CPluginIniFile::TSectionData::iterator it; 99 CPluginIniFile::TSectionData::iterator it;
146 100
147 it = settingsData.find("pluginupdate"); 101 it = settingsData.find("pluginupdate");
148 if (it != settingsData.end()) 102 if (it != settingsData.end())
149 { 103 {
150 m_pluginUpdateUrl = it->second; 104 m_pluginUpdateUrl = it->second;
151 DEBUG_SETTINGS("Settings::Configuration plugin update url:" + it->second); 105 DEBUG_SETTINGS("Settings::Configuration plugin update url:" + it->second);
152 } 106 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 169
216 DEBUG_SETTINGS("Settings::Configuration file version:" + it->second); 170 DEBUG_SETTINGS("Settings::Configuration file version:" + it->second);
217 } 171 }
218 else 172 else
219 { 173 {
220 m_isValidConfig = false; 174 m_isValidConfig = false;
221 } 175 }
222 176
223 #endif // SUPPORT_CONFIG 177 #endif // SUPPORT_CONFIG
224 178
225 #ifdef SUPPORT_WHITELIST
226
227 // Unpack whitelist domains
228 m_isValidWhiteList = iniFile->HasSection("Whitelist");
229 if (m_isValidWhiteList)
230 {
231 CPluginIniFile::TSectionData whitelist = iniFile->GetSectionData("Whitelist" );
232
233 int domainCount = 0;
234 bool bContinue = true;
235
236 m_whiteList.clear();
237
238 do
239 {
240 CStringA domainCountStr;
241 domainCountStr.Format("%d", ++domainCount);
242
243 CPluginIniFile::TSectionData::iterator domainIt = whitelist.find("domain" + domainCountStr);
244 CPluginIniFile::TSectionData::iterator reasonIt = whitelist.find("domain" + domainCountStr + "r");
245
246 if (bContinue = (domainIt != whitelist.end() && reasonIt != whitelist.end( )))
247 {
248 m_whiteList[CString(domainIt->second)] = atoi(reasonIt->second);
249 }
250
251 } while (bContinue);
252 }
253
254 #endif // #ifdef SUPPORT_WHITELIST
255 it = settingsData.find("registration"); 179 it = settingsData.find("registration");
256 if (it != settingsData.end()) 180 if (it != settingsData.end())
257 { 181 {
258 m_isPluginRegistered = it->second == "true"; 182 m_isPluginRegistered = it->second == "true";
259 DEBUG_SETTINGS("Settings::Configuration registration detected:" + it->second ); 183 DEBUG_SETTINGS("Settings::Configuration registration detected:" + it->second );
260 } 184 }
261 185
262 m_adBlockLimit = -1; 186 m_adBlockLimit = -1;
263 it = settingsData.find("adblocklimit"); 187 it = settingsData.find("adblocklimit");
264 if (it != settingsData.end()) 188 if (it != settingsData.end())
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return m_dictionaryVersion; 321 return m_dictionaryVersion;
398 } 322 }
399 323
400 324
401 CString CPluginConfiguration::GetDictionaryUrl() const 325 CString CPluginConfiguration::GetDictionaryUrl() const
402 { 326 {
403 return m_dictionaryUrl; 327 return m_dictionaryUrl;
404 } 328 }
405 329
406 330
407 #ifdef SUPPORT_FILTER
408
409 int CPluginConfiguration::GetFilterVersion() const
410 {
411 return m_filterVersion;
412 }
413
414
415 TFilterUrlList CPluginConfiguration::GetFilterUrlList() const
416 {
417 return m_filterUrlList;
418 }
419
420 std::map<CString, CString> CPluginConfiguration::GetFilterFileNamesList() const
421 {
422 return m_filterFileNameList;
423 }
424 #endif // SUPPORT_FILTER
425
426 #ifdef SUPPORT_WHITELIST 331 #ifdef SUPPORT_WHITELIST
427 332
428 TDomainList CPluginConfiguration::GetWhiteList() const
429 {
430 return m_whiteList;
431 }
432 333
433 #endif // SUPPORT_WHITELIST 334 #endif // SUPPORT_WHITELIST
434 335
435 #ifdef SUPPORT_CONFIG 336 #ifdef SUPPORT_CONFIG
436 337
437 CString CPluginConfiguration::GetConfigUrl() const 338 CString CPluginConfiguration::GetConfigUrl() const
438 { 339 {
439 return m_configUrl; 340 return m_configUrl;
440 } 341 }
441 342
442 int CPluginConfiguration::GetConfigVersion() const 343 int CPluginConfiguration::GetConfigVersion() const
443 { 344 {
444 return m_configVersion; 345 return m_configVersion;
445 } 346 }
446 347
447 #endif // SUPPORT_CONFIG 348 #endif // SUPPORT_CONFIG
448 349
449 350
450 #ifdef PRODUCT_AIDOINLINE 351 #ifdef PRODUCT_AIDOINLINE
451 CString CPluginConfiguration::GetCollectedStatus() const 352 CString CPluginConfiguration::GetCollectedStatus() const
452 { 353 {
453 return m_collectedStatus; 354 return m_collectedStatus;
454 } 355 }
455 #endif 356 #endif
OLDNEW
« no previous file with comments | « Shared/PluginConfiguration.h ('k') | Shared/PluginSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld