| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 dispatchID_SetLanguage, | 34 dispatchID_SetLanguage, |
| 35 dispatchID_GetLanguage, | 35 dispatchID_GetLanguage, |
| 36 dispatchID_GetWhitelistDomains, | 36 dispatchID_GetWhitelistDomains, |
| 37 dispatchID_AddWhitelistDomain, | 37 dispatchID_AddWhitelistDomain, |
| 38 dispatchID_RemoveWhitelistDomain, | 38 dispatchID_RemoveWhitelistDomain, |
| 39 dispatchID_GetAppLocale, | 39 dispatchID_GetAppLocale, |
| 40 dispatchID_GetDocumentationLink, | 40 dispatchID_GetDocumentationLink, |
| 41 dispatchID_IsAcceptableAdsEnabled, | 41 dispatchID_IsAcceptableAdsEnabled, |
| 42 dispatchID_SetAcceptableAdsEnabled, | 42 dispatchID_SetAcceptableAdsEnabled, |
| 43 dispatchID_IsUpdate, | 43 dispatchID_IsUpdate, |
| 44 dispatchID_GetConversion | |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 /** | 47 /** |
| 47 * Auxiliary for static initialization | 48 * Auxiliary for static initialization |
| 48 */ | 49 */ |
| 49 std::unordered_map<std::wstring, DISPID> InitMethodIndex() | 50 std::unordered_map<std::wstring, DISPID> InitMethodIndex() |
| 50 { | 51 { |
| 51 std::unordered_map<std::wstring, DISPID> m; | 52 std::unordered_map<std::wstring, DISPID> m; |
| 52 // try-block for safety during static initialization | 53 // try-block for safety during static initialization |
| 53 try | 54 try |
| 54 { | 55 { |
| 55 m.emplace(L"GetMessage", dispatchID_GetMessage); | 56 m.emplace(L"GetMessage", dispatchID_GetMessage); |
| 56 m.emplace(L"GetLanguageCount", dispatchID_GetLanguageCount); | 57 m.emplace(L"GetLanguageCount", dispatchID_GetLanguageCount); |
| 57 m.emplace(L"GetLanguageByIndex", dispatchID_GetLanguageByIndex); | 58 m.emplace(L"GetLanguageByIndex", dispatchID_GetLanguageByIndex); |
| 58 m.emplace(L"GetLanguageTitleByIndex", dispatchID_GetLanguageTitleByIndex); | 59 m.emplace(L"GetLanguageTitleByIndex", dispatchID_GetLanguageTitleByIndex); |
| 59 m.emplace(L"SetLanguage", dispatchID_SetLanguage); | 60 m.emplace(L"SetLanguage", dispatchID_SetLanguage); |
| 60 m.emplace(L"GetLanguage", dispatchID_GetLanguage); | 61 m.emplace(L"GetLanguage", dispatchID_GetLanguage); |
| 61 m.emplace(L"GetWhitelistDomains", dispatchID_GetWhitelistDomains); | 62 m.emplace(L"GetWhitelistDomains", dispatchID_GetWhitelistDomains); |
| 62 m.emplace(L"AddWhitelistDomain", dispatchID_AddWhitelistDomain); | 63 m.emplace(L"AddWhitelistDomain", dispatchID_AddWhitelistDomain); |
| 63 m.emplace(L"RemoveWhitelistDomain", dispatchID_RemoveWhitelistDomain); | 64 m.emplace(L"RemoveWhitelistDomain", dispatchID_RemoveWhitelistDomain); |
| 64 m.emplace(L"GetAppLocale", dispatchID_GetAppLocale); | 65 m.emplace(L"GetAppLocale", dispatchID_GetAppLocale); |
| 65 m.emplace(L"GetDocumentationLink", dispatchID_GetDocumentationLink); | 66 m.emplace(L"GetDocumentationLink", dispatchID_GetDocumentationLink); |
| 66 m.emplace(L"IsAcceptableAdsEnabled", dispatchID_IsAcceptableAdsEnabled); | 67 m.emplace(L"IsAcceptableAdsEnabled", dispatchID_IsAcceptableAdsEnabled); |
| 67 m.emplace(L"SetAcceptableAdsEnabled", dispatchID_SetAcceptableAdsEnabled); | 68 m.emplace(L"SetAcceptableAdsEnabled", dispatchID_SetAcceptableAdsEnabled); |
| 68 m.emplace(L"IsUpdate", dispatchID_IsUpdate); | 69 m.emplace(L"IsUpdate", dispatchID_IsUpdate); |
| 70 m.emplace(L"GetConversion", dispatchID_GetConversion); | |
| 69 } | 71 } |
| 70 catch(...) | 72 catch(...) |
| 71 { | 73 { |
| 72 } | 74 } |
| 73 return m; | 75 return m; |
| 74 } | 76 } |
| 75 | 77 |
| 76 /** | 78 /** |
| 77 * Static map from method names to dispatch identifiers. | 79 * Static map from method names to dispatch identifiers. |
| 78 */ | 80 */ |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 return DISP_E_TYPEMISMATCH; | 420 return DISP_E_TYPEMISMATCH; |
| 419 } | 421 } |
| 420 if (pDispparams->rgvarg[0].boolVal != VARIANT_FALSE) | 422 if (pDispparams->rgvarg[0].boolVal != VARIANT_FALSE) |
| 421 { | 423 { |
| 422 CPluginClient* client = CPluginClient::GetInstance(); | 424 CPluginClient* client = CPluginClient::GetInstance(); |
| 423 client->AddSubscription(client->GetPref(L"subscriptions_exceptionsurl" , L"")); | 425 client->AddSubscription(client->GetPref(L"subscriptions_exceptionsurl" , L"")); |
| 424 } | 426 } |
| 425 else | 427 else |
| 426 { | 428 { |
| 427 CPluginClient* client = CPluginClient::GetInstance(); | 429 CPluginClient* client = CPluginClient::GetInstance(); |
| 428 client->RemoveSubscription(client->GetPref(L"subscriptions_exceptionsu rl", L"")); | 430 client->RemoveSubscription(client->GetPref(L"subscriptions_exceptionsu rl", L"")); |
|
Eric
2015/05/17 00:29:25
See here, for example, of why explicit conversions
| |
| 429 } | 431 } |
| 430 } | 432 } |
| 431 break; | 433 break; |
| 432 case dispatchID_IsUpdate: | 434 case dispatchID_IsUpdate: |
| 433 { | 435 { |
| 434 if (pDispparams->cArgs != 0) | 436 if (pDispparams->cArgs != 0) |
| 435 { | 437 { |
| 436 return DISP_E_BADPARAMCOUNT; | 438 return DISP_E_BADPARAMCOUNT; |
| 437 } | 439 } |
| 438 if (pVarResult) | 440 if (pVarResult) |
| 439 { | 441 { |
| 440 pVarResult->vt = VT_BOOL; | 442 pVarResult->vt = VT_BOOL; |
| 441 pVarResult->boolVal = CPluginClient::GetInstance()->GetPref(L"displayU pdatePage", false) ? VARIANT_TRUE : VARIANT_FALSE; | 443 pVarResult->boolVal = CPluginClient::GetInstance()->GetPref(L"displayU pdatePage", false) ? VARIANT_TRUE : VARIANT_FALSE; |
| 442 } | 444 } |
| 443 } | 445 } |
| 444 break; | 446 break; |
| 447 case dispatchID_GetConversion: | |
| 448 { | |
| 449 if (pDispparams->cArgs != 0) | |
| 450 { | |
| 451 return DISP_E_BADPARAMCOUNT; | |
| 452 } | |
| 453 if (pVarResult) | |
| 454 { | |
| 455 pVarResult->vt = VT_BSTR; | |
| 456 pVarResult->bstrVal = CComBSTR(CPluginClient::GetInstance()->GetPref(s td::wstring(L"convertedFrom"), std::wstring(L"")).c_str()); | |
|
sergei
2015/04/28 14:41:15
Is it necessary to explicitly construct std::wstri
Eric
2015/05/17 00:29:25
It's not. There's an explicit pass through functio
| |
| 457 } | |
| 458 } | |
| 459 break; | |
| 445 default: | 460 default: |
| 446 return DISP_E_MEMBERNOTFOUND; | 461 return DISP_E_MEMBERNOTFOUND; |
| 447 break; | 462 break; |
| 448 } | 463 } |
| 449 } | 464 } |
| 450 catch (...) | 465 catch (...) |
| 451 { | 466 { |
| 452 return E_FAIL; | 467 return E_FAIL; |
| 453 } | 468 } |
| 454 return S_OK; | 469 return S_OK; |
| 455 } | 470 } |
| OLD | NEW |