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

Delta Between Two Patch Sets: Shared/PluginUserSettings.cpp

Issue 9998007: Initial libadblockplus integration (Closed)
Left Patch Set: Subscription changes and filter management cleanup Created April 5, 2013, 1:56 a.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Shared/PluginTypedef.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 #include "PluginUserSettings.h" 2 #include "PluginUserSettings.h"
3 #include <algorithm> 3 #include <algorithm>
4 #include "PluginSettings.h" 4 #include "PluginSettings.h"
5 #include "PluginClient.h" 5 #include "PluginClient.h"
6 #include "PluginIniFileW.h" 6 #include "PluginIniFileW.h"
7 #include "PluginDictionary.h" 7 #include "PluginDictionary.h"
8 8
9 static const CString s_GetMessage = L"GetMessage"; 9 static const CString s_GetMessage = L"GetMessage";
10 static const CString s_GetLanguageCount = L"GetLanguageCount"; 10 static const CString s_GetLanguageCount = L"GetLanguageCount";
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 } 246 }
247 else if (s_SetLanguage == method) 247 else if (s_SetLanguage == method)
248 { 248 {
249 if (1 != pDispparams->cArgs) 249 if (1 != pDispparams->cArgs)
250 return DISP_E_BADPARAMCOUNT; 250 return DISP_E_BADPARAMCOUNT;
251 251
252 if (VT_BSTR != pDispparams->rgvarg[0].vt) 252 if (VT_BSTR != pDispparams->rgvarg[0].vt)
253 return DISP_E_TYPEMISMATCH; 253 return DISP_E_TYPEMISMATCH;
254 254
255 CComBSTR language = pDispparams->rgvarg[0].bstrVal; 255 CComBSTR url = pDispparams->rgvarg[0].bstrVal;
256 256
257 settings->SetString(SETTING_LANGUAGE, (BSTR)language); 257 settings->SetSubscription((BSTR)url);
258 settings->Write();
259 settings->SetSubscription((BSTR)language);
260 } 258 }
261 else if (s_GetLanguage == method) 259 else if (s_GetLanguage == method)
262 { 260 {
263 if (pDispparams->cArgs) 261 if (pDispparams->cArgs)
264 return DISP_E_BADPARAMCOUNT; 262 return DISP_E_BADPARAMCOUNT;
265 263
266 if (pVarResult) 264 if (pVarResult)
267 { 265 {
268 CString language = settings->GetString(SETTING_LANGUAGE); 266 CString url = settings->GetSubscription();
269 267
270 pVarResult->vt = VT_BSTR; 268 pVarResult->vt = VT_BSTR;
271 pVarResult->bstrVal = SysAllocString(language); 269 pVarResult->bstrVal = SysAllocString(url);
272 } 270 }
273 } 271 }
274 else if (s_GetWhitelistDomains == method) 272 else if (s_GetWhitelistDomains == method)
275 { 273 {
276 if (pDispparams->cArgs) 274 if (pDispparams->cArgs)
277 return DISP_E_BADPARAMCOUNT; 275 return DISP_E_BADPARAMCOUNT;
278 276
279 if (pVarResult) 277 if (pVarResult)
280 { 278 {
281 TDomainList whiteList = settings->GetWhiteListedDomainList(true); 279 std::vector<std::string> whiteList = settings->GetWhiteListedDomainList(tr ue);
282 CString sWhiteList; 280 CString sWhiteList;
283 for (TDomainList::const_iterator it = whiteList.begin(); it != whiteList.e nd(); ++it) 281 for (int i = 0; i < whiteList.size(); i++)
284 { 282 {
285 if (!sWhiteList.IsEmpty()) 283 if (!sWhiteList.IsEmpty())
286 { 284 {
287 sWhiteList += ','; 285 sWhiteList += ',';
288 } 286 }
289 sWhiteList += it->first; 287 sWhiteList += CString(CA2W(whiteList[i].c_str(), CP_UTF8));
290 } 288 }
291 289
292 pVarResult->vt = VT_BSTR; 290 pVarResult->vt = VT_BSTR;
293 pVarResult->bstrVal = SysAllocString(sWhiteList); 291 pVarResult->bstrVal = SysAllocString(sWhiteList);
294 } 292 }
295 } 293 }
296 else if (s_AddWhitelistDomain == method) 294 else if (s_AddWhitelistDomain == method)
297 { 295 {
298 if (1 != pDispparams->cArgs) 296 if (1 != pDispparams->cArgs)
299 return DISP_E_BADPARAMCOUNT; 297 return DISP_E_BADPARAMCOUNT;
300 298
301 if (VT_BSTR != pDispparams->rgvarg[0].vt) 299 if (VT_BSTR != pDispparams->rgvarg[0].vt)
302 return DISP_E_TYPEMISMATCH; 300 return DISP_E_TYPEMISMATCH;
303 301
304 CComBSTR domain = pDispparams->rgvarg[0].bstrVal; 302 CComBSTR domain = pDispparams->rgvarg[0].bstrVal;
305 if (domain.Length()) 303 if (domain.Length())
306 { 304 {
307 if (!settings->IsWhiteListedDomain((BSTR)domain)) 305 settings->AddWhiteListedDomain((BSTR)domain);
308 {
309 settings->AddWhiteListedDomain((BSTR)domain, 1, true);
310 }
311 } 306 }
312 } 307 }
313 else if (s_RemoveWhitelistDomain == method) 308 else if (s_RemoveWhitelistDomain == method)
314 { 309 {
315 if (1 != pDispparams->cArgs) 310 if (1 != pDispparams->cArgs)
316 return DISP_E_BADPARAMCOUNT; 311 return DISP_E_BADPARAMCOUNT;
317 312
318 if (VT_BSTR != pDispparams->rgvarg[0].vt) 313 if (VT_BSTR != pDispparams->rgvarg[0].vt)
319 return DISP_E_TYPEMISMATCH; 314 return DISP_E_TYPEMISMATCH;
320 315
321 CComBSTR domain = pDispparams->rgvarg[0].bstrVal; 316 CComBSTR domain = pDispparams->rgvarg[0].bstrVal;
322 if (settings->IsWhiteListedDomain((BSTR)domain)) 317 if (settings->IsWhiteListedDomain((BSTR)domain))
323 { 318 {
324 settings->AddWhiteListedDomain((BSTR)domain, 3, true); 319 settings->AddWhiteListedDomain((BSTR)domain);
325 CPluginClient::GetInstance()->ClearWhiteListCache(); 320 CPluginClient::GetInstance()->ClearWhiteListCache();
326 } 321 }
327 } 322 }
328 else 323 else
329 return DISP_E_MEMBERNOTFOUND; 324 return DISP_E_MEMBERNOTFOUND;
330 325
331 return S_OK; 326 return S_OK;
332 } 327 }
333 328
LEFTRIGHT

Powered by Google App Engine
This is Rietveld