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

Side by Side Diff: src/plugin/PluginUserSettings.cpp

Issue 6650591174459392: Issues #276, #1163 - introduce class IncomingParam (Closed)
Patch Set: Created July 25, 2014, 11:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/plugin/COM_Value.h ('K') | « src/plugin/COM_Value.cpp ('k') | no next file » | 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 #include "PluginUserSettings.h" 2 #include "PluginUserSettings.h"
3 #include <algorithm> 3 #include <algorithm>
4 #include "COM_Value.h"
4 #include "PluginSettings.h" 5 #include "PluginSettings.h"
5 #include "PluginClient.h" 6 #include "PluginClient.h"
6 #include "../shared/Dictionary.h" 7 #include "../shared/Dictionary.h"
7 8
8 static const CString s_GetMessage = L"GetMessage"; 9 static const CString s_GetMessage = L"GetMessage";
9 static const CString s_GetLanguageCount = L"GetLanguageCount"; 10 static const CString s_GetLanguageCount = L"GetLanguageCount";
10 static const CString s_GetLanguageByIndex = L"GetLanguageByIndex"; 11 static const CString s_GetLanguageByIndex = L"GetLanguageByIndex";
11 static const CString s_GetLanguageTitleByIndex = L"GetLanguageTitleByIndex"; 12 static const CString s_GetLanguageTitleByIndex = L"GetLanguageTitleByIndex";
12 static const CString s_SetLanguage = L"SetLanguage"; 13 static const CString s_SetLanguage = L"SetLanguage";
13 static const CString s_GetLanguage = L"GetLanguage"; 14 static const CString s_GetLanguage = L"GetLanguage";
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (s_GetMessage == method) 136 if (s_GetMessage == method)
136 { 137 {
137 if (2 != pDispparams->cArgs) 138 if (2 != pDispparams->cArgs)
138 return DISP_E_BADPARAMCOUNT; 139 return DISP_E_BADPARAMCOUNT;
139 140
140 if (VT_BSTR != pDispparams->rgvarg[0].vt) 141 if (VT_BSTR != pDispparams->rgvarg[0].vt)
141 return DISP_E_TYPEMISMATCH; 142 return DISP_E_TYPEMISMATCH;
142 143
143 if (pVarResult) 144 if (pVarResult)
144 { 145 {
145 CComBSTR key = pDispparams->rgvarg[0].bstrVal; 146 AdblockPlus::COM::Incoming_Param key(pDispparams->rgvarg[0].bstrVal);
146 CComBSTR section = pDispparams->rgvarg[1].bstrVal; 147 AdblockPlus::COM::Incoming_Param section(pDispparams->rgvarg[1].bstrVal);
147 CStringW message = sGetMessage((BSTR)section, (BSTR)key); 148 CStringW message = sGetMessage(to_CString(section), to_CString(key));
148 149
149 pVarResult->vt = VT_BSTR; 150 pVarResult->vt = VT_BSTR;
150 pVarResult->bstrVal = SysAllocString(message); 151 pVarResult->bstrVal = SysAllocString(message);
151 } 152 }
152 } 153 }
153 else if (s_GetLanguageCount == method) 154 else if (s_GetLanguageCount == method)
154 { 155 {
155 if (pDispparams->cArgs) 156 if (pDispparams->cArgs)
156 return DISP_E_BADPARAMCOUNT; 157 return DISP_E_BADPARAMCOUNT;
157 158
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 235 }
235 } 236 }
236 else if (s_SetLanguage == method) 237 else if (s_SetLanguage == method)
237 { 238 {
238 if (1 != pDispparams->cArgs) 239 if (1 != pDispparams->cArgs)
239 return DISP_E_BADPARAMCOUNT; 240 return DISP_E_BADPARAMCOUNT;
240 241
241 if (VT_BSTR != pDispparams->rgvarg[0].vt) 242 if (VT_BSTR != pDispparams->rgvarg[0].vt)
242 return DISP_E_TYPEMISMATCH; 243 return DISP_E_TYPEMISMATCH;
243 244
244 CComBSTR url = pDispparams->rgvarg[0].bstrVal; 245 AdblockPlus::COM::Incoming_Param url(pDispparams->rgvarg[0].bstrVal);
245 246 settings->SetSubscription(url);
246 settings->SetSubscription((BSTR)url);
247 } 247 }
248 else if (s_GetLanguage == method) 248 else if (s_GetLanguage == method)
249 { 249 {
250 if (pDispparams->cArgs) 250 if (pDispparams->cArgs)
251 return DISP_E_BADPARAMCOUNT; 251 return DISP_E_BADPARAMCOUNT;
252 252
253 if (pVarResult) 253 if (pVarResult)
254 { 254 {
255 CString url = settings->GetSubscription(); 255 CString url = settings->GetSubscription();
256 256
(...skipping 24 matching lines...) Expand all
281 } 281 }
282 } 282 }
283 else if (s_AddWhitelistDomain == method) 283 else if (s_AddWhitelistDomain == method)
284 { 284 {
285 if (1 != pDispparams->cArgs) 285 if (1 != pDispparams->cArgs)
286 return DISP_E_BADPARAMCOUNT; 286 return DISP_E_BADPARAMCOUNT;
287 287
288 if (VT_BSTR != pDispparams->rgvarg[0].vt) 288 if (VT_BSTR != pDispparams->rgvarg[0].vt)
289 return DISP_E_TYPEMISMATCH; 289 return DISP_E_TYPEMISMATCH;
290 290
291 CComBSTR domain = pDispparams->rgvarg[0].bstrVal; 291 AdblockPlus::COM::Incoming_Param domain(pDispparams->rgvarg[0].bstrVal);
292 if (domain.Length()) 292 if (!domain.empty())
293 { 293 {
294 settings->AddWhiteListedDomain((BSTR)domain); 294 settings->AddWhiteListedDomain(to_CString(domain));
295 } 295 }
296 } 296 }
297 else if (s_RemoveWhitelistDomain == method) 297 else if (s_RemoveWhitelistDomain == method)
298 { 298 {
299 if (1 != pDispparams->cArgs) 299 if (1 != pDispparams->cArgs)
300 return DISP_E_BADPARAMCOUNT; 300 return DISP_E_BADPARAMCOUNT;
301 301
302 if (VT_BSTR != pDispparams->rgvarg[0].vt) 302 if (VT_BSTR != pDispparams->rgvarg[0].vt)
303 return DISP_E_TYPEMISMATCH; 303 return DISP_E_TYPEMISMATCH;
304 304
305 CComBSTR domain = pDispparams->rgvarg[0].bstrVal; 305 AdblockPlus::COM::Incoming_Param domain(pDispparams->rgvarg[0].bstrVal);
306 if (domain.Length()) 306 if (!domain.empty())
307 { 307 {
308 settings->RemoveWhiteListedDomain((BSTR)domain); 308 settings->RemoveWhiteListedDomain(to_CString(domain));
309 } 309 }
310 } 310 }
311 else if (s_GetAppLocale == method) 311 else if (s_GetAppLocale == method)
312 { 312 {
313 if (0 != pDispparams->cArgs) 313 if (0 != pDispparams->cArgs)
314 return DISP_E_BADPARAMCOUNT; 314 return DISP_E_BADPARAMCOUNT;
315 315
316 pVarResult->vt = VT_BSTR; 316 pVarResult->vt = VT_BSTR;
317 pVarResult->bstrVal = SysAllocString(settings->GetAppLocale()); 317 pVarResult->bstrVal = SysAllocString(settings->GetAppLocale());
318 } 318 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 CPluginClient* client = CPluginClient::GetInstance(); 352 CPluginClient* client = CPluginClient::GetInstance();
353 client->RemoveSubscription(client->GetPref(L"subscriptions_exceptionsurl", L"")); 353 client->RemoveSubscription(client->GetPref(L"subscriptions_exceptionsurl", L""));
354 } 354 }
355 } 355 }
356 else 356 else
357 return DISP_E_MEMBERNOTFOUND; 357 return DISP_E_MEMBERNOTFOUND;
358 358
359 return S_OK; 359 return S_OK;
360 } 360 }
361 361
OLDNEW
« src/plugin/COM_Value.h ('K') | « src/plugin/COM_Value.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld