| LEFT | RIGHT |
| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #include "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
| 19 #include "AdblockPlusClient.h" |
| 19 #include "PluginSettings.h" | 20 #include "PluginSettings.h" |
| 20 #include "PluginSystem.h" | 21 #include "PluginSystem.h" |
| 21 #include "PluginFilter.h" | 22 #include "PluginFilter.h" |
| 22 #include "PluginClientFactory.h" | |
| 23 #include "PluginMutex.h" | 23 #include "PluginMutex.h" |
| 24 #include "PluginClass.h" | 24 #include "PluginClass.h" |
| 25 | |
| 26 #include "AdblockPlusClient.h" | |
| 27 | |
| 28 #include "../shared/Utils.h" | 25 #include "../shared/Utils.h" |
| 29 | 26 |
| 30 namespace | 27 namespace |
| 31 { | 28 { |
| 32 class ScopedProcessInformation : public PROCESS_INFORMATION { | 29 class ScopedProcessInformation : public PROCESS_INFORMATION { |
| 33 public: | 30 public: |
| 34 ScopedProcessInformation() | 31 ScopedProcessInformation() |
| 35 { | 32 { |
| 36 hProcess = hThread = 0; | 33 hProcess = hThread = 0; |
| 37 dwProcessId = dwThreadId = 0; | 34 dwProcessId = dwThreadId = 0; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 92 |
| 96 std::vector<SubscriptionDescription> ReadSubscriptions(Communication::InputBuf
fer& message) | 93 std::vector<SubscriptionDescription> ReadSubscriptions(Communication::InputBuf
fer& message) |
| 97 { | 94 { |
| 98 int32_t count; | 95 int32_t count; |
| 99 message >> count; | 96 message >> count; |
| 100 | 97 |
| 101 std::vector<SubscriptionDescription> result; | 98 std::vector<SubscriptionDescription> result; |
| 102 for (int32_t i = 0; i < count; i++) | 99 for (int32_t i = 0; i < count; i++) |
| 103 { | 100 { |
| 104 SubscriptionDescription description; | 101 SubscriptionDescription description; |
| 105 message >> description.url; | 102 std::string url; |
| 106 message >> description.title; | 103 message >> url; |
| 107 message >> description.specialization; | 104 description.url = ToUtf16String(url); |
| 105 std::string title; |
| 106 message >> title; |
| 107 description.title = ToUtf16String(title); |
| 108 std::string specialization; |
| 109 message >> specialization; |
| 110 description.specialization = ToUtf16String(specialization); |
| 108 message >> description.listed; | 111 message >> description.listed; |
| 109 result.push_back(description); | 112 result.push_back(description); |
| 110 } | 113 } |
| 111 return result; | 114 return result; |
| 112 } | 115 } |
| 113 } | 116 } |
| 114 | 117 |
| 115 CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL; | 118 CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL; |
| 116 CComAutoCriticalSection CAdblockPlusClient::s_criticalSectionLocal; | 119 CComAutoCriticalSection CAdblockPlusClient::s_criticalSectionLocal; |
| 117 | 120 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 { | 217 { |
| 215 bool isHidden; | 218 bool isHidden; |
| 216 m_criticalSectionFilter.Lock(); | 219 m_criticalSectionFilter.Lock(); |
| 217 { | 220 { |
| 218 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); | 221 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); |
| 219 } | 222 } |
| 220 m_criticalSectionFilter.Unlock(); | 223 m_criticalSectionFilter.Unlock(); |
| 221 return isHidden; | 224 return isHidden; |
| 222 } | 225 } |
| 223 | 226 |
| 224 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url, const std::ve
ctor<std::string>& frameHierarchy) | 227 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) |
| 225 { | 228 { |
| 226 return !GetWhitelistingFilter(url, frameHierarchy).empty(); | 229 return !GetWhitelistingFilter(url).empty(); |
| 227 } | 230 } |
| 228 | 231 |
| 229 std::string CAdblockPlusClient::GetWhitelistingFilter(const std::wstring& url, c
onst std::vector<std::string>& frameHierarchy) | 232 std::string CAdblockPlusClient::GetWhitelistingFilter(const std::wstring& url) |
| 230 { | 233 { |
| 231 DEBUG_GENERAL((L"GetWhitelistingFilter: " + url + L" start").c_str()); | 234 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str()); |
| 232 Communication::OutputBuffer request; | 235 Communication::OutputBuffer request; |
| 233 request << Communication::PROC_GET_WHITELISTING_FITER << url << frameHierarchy
; | 236 request << Communication::PROC_GET_WHITELISTING_FITER << ToUtf8String(url); |
| 234 | 237 |
| 235 Communication::InputBuffer response; | 238 Communication::InputBuffer response; |
| 236 if (!CallEngine(request, response)) | 239 if (!CallEngine(request, response)) |
| 237 return ""; | 240 return ""; |
| 238 | 241 |
| 239 std::string filterText; | 242 std::string filterText; |
| 240 response >> filterText; | 243 response >> filterText; |
| 241 | 244 |
| 242 DEBUG_GENERAL((L"GetWhitelistingFilter: " + url + L" end").c_str()); | 245 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" end").c_str()); |
| 243 return filterText; | 246 return filterText; |
| 244 } | 247 } |
| 245 | 248 |
| 246 bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url,
const std::vector<std::string>& frameHierarchy) | 249 bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url) |
| 247 { | 250 { |
| 248 Communication::OutputBuffer request; | 251 Communication::OutputBuffer request; |
| 249 request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << url << frameH
ierarchy; | 252 request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << ToUtf8String(
url); |
| 250 | 253 |
| 251 Communication::InputBuffer response; | 254 Communication::InputBuffer response; |
| 252 if (!CallEngine(request, response)) | 255 if (!CallEngine(request, response)) |
| 253 return false; | 256 return false; |
| 254 | 257 |
| 255 bool isWhitelisted; | 258 bool isWhitelisted; |
| 256 response >> isWhitelisted; | 259 response >> isWhitelisted; |
| 257 return isWhitelisted; | 260 return isWhitelisted; |
| 258 } | 261 } |
| 259 | 262 |
| 260 bool CAdblockPlusClient::Matches(const std::wstring& url, AdblockPlus::FilterEng
ine::ContentType contentType, const std::wstring& domain) | 263 bool CAdblockPlusClient::Matches(const std::wstring& url, AdblockPlus::FilterEng
ine::ContentType contentType, const std::wstring& domain) |
| 261 { | 264 { |
| 262 Communication::OutputBuffer request; | 265 Communication::OutputBuffer request; |
| 263 request << Communication::PROC_MATCHES << url << contentType << domain; | 266 request << Communication::PROC_MATCHES << ToUtf8String(url) << static_cast<int
32_t>(contentType) << ToUtf8String(domain); |
| 264 | 267 |
| 265 Communication::InputBuffer response; | 268 Communication::InputBuffer response; |
| 266 if (!CallEngine(request, response)) | 269 if (!CallEngine(request, response)) |
| 267 return false; | 270 return false; |
| 268 | 271 |
| 269 bool match; | 272 bool match; |
| 270 response >> match; | 273 response >> match; |
| 271 return match; | 274 return match; |
| 272 } | 275 } |
| 273 | 276 |
| 274 std::vector<std::wstring> CAdblockPlusClient::GetElementHidingSelectors(const st
d::wstring& domain) | 277 std::vector<std::wstring> CAdblockPlusClient::GetElementHidingSelectors(const st
d::wstring& domain) |
| 275 { | 278 { |
| 276 Communication::OutputBuffer request; | 279 Communication::OutputBuffer request; |
| 277 request << Communication::PROC_GET_ELEMHIDE_SELECTORS << domain; | 280 request << Communication::PROC_GET_ELEMHIDE_SELECTORS << ToUtf8String(domain); |
| 278 | 281 |
| 279 Communication::InputBuffer response; | 282 Communication::InputBuffer response; |
| 280 if (!CallEngine(request, response)) | 283 if (!CallEngine(request, response)) |
| 281 return std::vector<std::wstring>(); | 284 return std::vector<std::wstring>(); |
| 282 | 285 |
| 283 std::vector<std::wstring> selectors; | 286 std::vector<std::string> selectors; |
| 284 response >> selectors; | 287 response >> selectors; |
| 285 return selectors; | 288 return ToUtf16Strings(selectors); |
| 286 } | 289 } |
| 287 | 290 |
| 288 std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscript
ions() | 291 std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscript
ions() |
| 289 { | 292 { |
| 290 Communication::InputBuffer response; | 293 Communication::InputBuffer response; |
| 291 if (!CallEngine(Communication::PROC_AVAILABLE_SUBSCRIPTIONS, response)) | 294 if (!CallEngine(Communication::PROC_AVAILABLE_SUBSCRIPTIONS, response)) |
| 292 return std::vector<SubscriptionDescription>(); | 295 return std::vector<SubscriptionDescription>(); |
| 293 return ReadSubscriptions(response); | 296 return ReadSubscriptions(response); |
| 294 } | 297 } |
| 295 | 298 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 312 { | 315 { |
| 313 return true; | 316 return true; |
| 314 } | 317 } |
| 315 } | 318 } |
| 316 return false; | 319 return false; |
| 317 } | 320 } |
| 318 | 321 |
| 319 void CAdblockPlusClient::SetSubscription(const std::wstring& url) | 322 void CAdblockPlusClient::SetSubscription(const std::wstring& url) |
| 320 { | 323 { |
| 321 Communication::OutputBuffer request; | 324 Communication::OutputBuffer request; |
| 322 request << Communication::PROC_SET_SUBSCRIPTION << url; | 325 request << Communication::PROC_SET_SUBSCRIPTION << ToUtf8String(url); |
| 323 CallEngine(request); | 326 CallEngine(request); |
| 324 } | 327 } |
| 325 | 328 |
| 326 void CAdblockPlusClient::AddSubscription(const std::wstring& url) | 329 void CAdblockPlusClient::AddSubscription(const std::wstring& url) |
| 327 { | 330 { |
| 328 Communication::OutputBuffer request; | 331 Communication::OutputBuffer request; |
| 329 request << Communication::PROC_ADD_SUBSCRIPTION << url; | 332 request << Communication::PROC_ADD_SUBSCRIPTION << ToUtf8String(url); |
| 330 CallEngine(request); | 333 CallEngine(request); |
| 331 } | 334 } |
| 332 | 335 |
| 333 void CAdblockPlusClient::RemoveSubscription(const std::wstring& url) | 336 void CAdblockPlusClient::RemoveSubscription(const std::wstring& url) |
| 334 { | 337 { |
| 335 Communication::OutputBuffer request; | 338 Communication::OutputBuffer request; |
| 336 request << Communication::PROC_REMOVE_SUBSCRIPTION << url; | 339 request << Communication::PROC_REMOVE_SUBSCRIPTION << ToUtf8String(url); |
| 337 CallEngine(request); | 340 CallEngine(request); |
| 338 } | 341 } |
| 339 | 342 |
| 340 | 343 |
| 341 void CAdblockPlusClient::UpdateAllSubscriptions() | 344 void CAdblockPlusClient::UpdateAllSubscriptions() |
| 342 { | 345 { |
| 343 CallEngine(Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS); | 346 CallEngine(Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS); |
| 344 } | 347 } |
| 345 | 348 |
| 346 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() | 349 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() |
| 347 { | 350 { |
| 348 Communication::InputBuffer response; | 351 Communication::InputBuffer response; |
| 349 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response)) | 352 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response)) |
| 350 return std::vector<std::wstring>(); | 353 return std::vector<std::wstring>(); |
| 351 | 354 |
| 352 std::vector<std::wstring> domains; | 355 std::vector<std::string> domains; |
| 353 response >> domains; | 356 response >> domains; |
| 354 return domains; | 357 return ToUtf16Strings(domains); |
| 355 } | 358 } |
| 356 | 359 |
| 357 bool CAdblockPlusClient::IsFirstRun() | 360 bool CAdblockPlusClient::IsFirstRun() |
| 358 { | 361 { |
| 359 DEBUG_GENERAL("IsFirstRun"); | 362 DEBUG_GENERAL("IsFirstRun"); |
| 360 Communication::InputBuffer response; | 363 Communication::InputBuffer response; |
| 361 if (!CallEngine(Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED, response)) ret
urn false; | 364 if (!CallEngine(Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED, response)) ret
urn false; |
| 362 bool res; | 365 bool res; |
| 363 response >> res; | 366 response >> res; |
| 364 return res; | 367 return res; |
| 365 } | 368 } |
| 366 | 369 |
| 367 void CAdblockPlusClient::AddFilter(const std::wstring& text) | 370 void CAdblockPlusClient::AddFilter(const std::wstring& text) |
| 368 { | 371 { |
| 369 Communication::OutputBuffer request; | 372 Communication::OutputBuffer request; |
| 370 request << Communication::PROC_ADD_FILTER << text; | 373 request << Communication::PROC_ADD_FILTER << ToUtf8String(text); |
| 371 CallEngine(request); | 374 CallEngine(request); |
| 372 } | 375 } |
| 373 | 376 |
| 374 void CAdblockPlusClient::RemoveFilter(const std::wstring& text) | 377 void CAdblockPlusClient::RemoveFilter(const std::wstring& text) |
| 375 { | 378 { |
| 376 RemoveFilter(ToUtf8String(text)); | 379 RemoveFilter(ToUtf8String(text)); |
| 377 } | 380 } |
| 378 | 381 |
| 379 void CAdblockPlusClient::RemoveFilter(const std::string& text) | 382 void CAdblockPlusClient::RemoveFilter(const std::string& text) |
| 380 { | 383 { |
| 381 Communication::OutputBuffer request; | 384 Communication::OutputBuffer request; |
| 382 request << Communication::PROC_REMOVE_FILTER << text; | 385 request << Communication::PROC_REMOVE_FILTER << text; |
| 383 CallEngine(request); | 386 CallEngine(request); |
| 384 } | 387 } |
| 385 | 388 |
| 386 void CAdblockPlusClient::SetPref(const std::wstring& name, const std::wstring& v
alue) | 389 void CAdblockPlusClient::SetPref(const std::wstring& name, const std::wstring& v
alue) |
| 387 { | 390 { |
| 388 Communication::OutputBuffer request; | 391 Communication::OutputBuffer request; |
| 389 request << Communication::PROC_SET_PREF << name << value; | 392 request << Communication::PROC_SET_PREF << ToUtf8String(name) << ToUtf8String(
value); |
| 390 CallEngine(request); | 393 CallEngine(request); |
| 391 } | 394 } |
| 392 | 395 |
| 393 void CAdblockPlusClient::SetPref(const std::wstring& name, const int64_t & value
) | 396 void CAdblockPlusClient::SetPref(const std::wstring& name, const int64_t & value
) |
| 394 { | 397 { |
| 395 Communication::OutputBuffer request; | 398 Communication::OutputBuffer request; |
| 396 request << Communication::PROC_SET_PREF << name << value; | 399 request << Communication::PROC_SET_PREF << ToUtf8String(name) << value; |
| 397 CallEngine(request); | 400 CallEngine(request); |
| 398 } | 401 } |
| 399 | 402 |
| 400 void CAdblockPlusClient::SetPref(const std::wstring& name, bool value) | 403 void CAdblockPlusClient::SetPref(const std::wstring& name, bool value) |
| 401 { | 404 { |
| 402 Communication::OutputBuffer request; | 405 Communication::OutputBuffer request; |
| 403 request << Communication::PROC_SET_PREF << name << value; | 406 request << Communication::PROC_SET_PREF << ToUtf8String(name) << value; |
| 404 CallEngine(request); | 407 CallEngine(request); |
| 405 } | 408 } |
| 406 | 409 |
| 407 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const wchar_t
* defaultValue) | 410 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const wchar_t
* defaultValue) |
| 408 { | 411 { |
| 409 return GetPref(name, std::wstring(defaultValue)); | 412 return GetPref(name, std::wstring(defaultValue)); |
| 410 } | 413 } |
| 411 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
tring& defaultValue) | 414 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
tring& defaultValue) |
| 412 { | 415 { |
| 413 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); | 416 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); |
| 414 Communication::OutputBuffer request; | 417 Communication::OutputBuffer request; |
| 415 request << Communication::PROC_GET_PREF << name; | 418 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
| 416 | 419 |
| 417 Communication::InputBuffer response; | 420 Communication::InputBuffer response; |
| 418 if (!CallEngine(request, response)) | 421 if (!CallEngine(request, response)) |
| 419 return defaultValue; | 422 return defaultValue; |
| 420 bool success; | 423 bool success; |
| 421 response >> success; | 424 response >> success; |
| 422 if (success) | 425 if (success) |
| 423 { | 426 { |
| 424 std::wstring value; | 427 std::string value; |
| 425 response >> value; | 428 response >> value; |
| 426 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 429 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
| 427 return value; | 430 return ToUtf16String(value); |
| 428 } | 431 } |
| 429 else | 432 else |
| 430 { | 433 { |
| 431 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 434 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
| 432 return defaultValue; | 435 return defaultValue; |
| 433 } | 436 } |
| 434 } | 437 } |
| 435 | 438 |
| 436 bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue) | 439 bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue) |
| 437 { | 440 { |
| 438 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); | 441 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); |
| 439 Communication::OutputBuffer request; | 442 Communication::OutputBuffer request; |
| 440 request << Communication::PROC_GET_PREF << name; | 443 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
| 441 | 444 |
| 442 Communication::InputBuffer response; | 445 Communication::InputBuffer response; |
| 443 if (!CallEngine(request, response)) | 446 if (!CallEngine(request, response)) |
| 444 return defaultValue; | 447 return defaultValue; |
| 445 bool success; | 448 bool success; |
| 446 response >> success; | 449 response >> success; |
| 447 if (success) | 450 if (success) |
| 448 { | 451 { |
| 449 bool value; | 452 bool value; |
| 450 response >> value; | 453 response >> value; |
| 451 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 454 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
| 452 return value; | 455 return value; |
| 453 } | 456 } |
| 454 else | 457 else |
| 455 { | 458 { |
| 456 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); | 459 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
| 457 return defaultValue; | 460 return defaultValue; |
| 458 } | 461 } |
| 459 } | 462 } |
| 460 int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal
ue) | 463 int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal
ue) |
| 461 { | 464 { |
| 462 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); | 465 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); |
| 463 Communication::OutputBuffer request; | 466 Communication::OutputBuffer request; |
| 464 request << Communication::PROC_GET_PREF << name; | 467 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
| 465 | 468 |
| 466 Communication::InputBuffer response; | 469 Communication::InputBuffer response; |
| 467 if (!CallEngine(request, response)) | 470 if (!CallEngine(request, response)) |
| 468 return defaultValue; | 471 return defaultValue; |
| 469 bool success; | 472 bool success; |
| 470 response >> success; | 473 response >> success; |
| 471 if (success) | 474 if (success) |
| 472 { | 475 { |
| 473 int64_t value; | 476 int64_t value; |
| 474 response >> value; | 477 response >> value; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 488 request << Communication::PROC_CHECK_FOR_UPDATES << reinterpret_cast<int32_t>(
callbackWindow); | 491 request << Communication::PROC_CHECK_FOR_UPDATES << reinterpret_cast<int32_t>(
callbackWindow); |
| 489 CallEngine(request); | 492 CallEngine(request); |
| 490 } | 493 } |
| 491 | 494 |
| 492 std::wstring CAdblockPlusClient::GetDocumentationLink() | 495 std::wstring CAdblockPlusClient::GetDocumentationLink() |
| 493 { | 496 { |
| 494 DEBUG_GENERAL("GetDocumentationLink"); | 497 DEBUG_GENERAL("GetDocumentationLink"); |
| 495 Communication::InputBuffer response; | 498 Communication::InputBuffer response; |
| 496 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) | 499 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) |
| 497 return L""; | 500 return L""; |
| 498 std::wstring docLink; | 501 std::string docLink; |
| 499 response >> docLink; | 502 response >> docLink; |
| 500 return docLink; | 503 return ToUtf16String(docLink); |
| 501 } | 504 } |
| 502 | 505 |
| 503 bool CAdblockPlusClient::TogglePluginEnabled() | 506 bool CAdblockPlusClient::TogglePluginEnabled() |
| 504 { | 507 { |
| 505 DEBUG_GENERAL("TogglePluginEnabled"); | 508 DEBUG_GENERAL("TogglePluginEnabled"); |
| 506 Communication::InputBuffer response; | 509 Communication::InputBuffer response; |
| 507 if (!CallEngine(Communication::PROC_TOGGLE_PLUGIN_ENABLED, response)) | 510 if (!CallEngine(Communication::PROC_TOGGLE_PLUGIN_ENABLED, response)) |
| 508 return false; | 511 return false; |
| 509 bool currentEnabledState; | 512 bool currentEnabledState; |
| 510 response >> currentEnabledState; | 513 response >> currentEnabledState; |
| 511 return currentEnabledState; | 514 return currentEnabledState; |
| 512 } | 515 } |
| 513 | 516 |
| 514 std::wstring CAdblockPlusClient::GetHostFromUrl(const std::wstring& url) | 517 std::wstring CAdblockPlusClient::GetHostFromUrl(const std::wstring& url) |
| 515 { | 518 { |
| 516 DEBUG_GENERAL("GetHostFromUrl"); | 519 DEBUG_GENERAL("GetHostFromUrl"); |
| 517 Communication::OutputBuffer request; | 520 Communication::OutputBuffer request; |
| 518 request << Communication::PROC_GET_HOST << url; | 521 request << Communication::PROC_GET_HOST << ToUtf8String(url); |
| 519 | 522 |
| 520 Communication::InputBuffer response; | 523 Communication::InputBuffer response; |
| 521 if (!CallEngine(request, response)) | 524 if (!CallEngine(request, response)) |
| 522 return L""; | 525 return L""; |
| 523 std::wstring host; | 526 std::string host; |
| 524 response >> host; | 527 response >> host; |
| 525 return host; | 528 return ToUtf16String(host); |
| 526 } | 529 } |
| 527 | 530 |
| 528 int CAdblockPlusClient::CompareVersions(const std::wstring& v1, const std::wstri
ng& v2) | 531 int CAdblockPlusClient::CompareVersions(const std::wstring& v1, const std::wstri
ng& v2) |
| 529 { | 532 { |
| 530 DEBUG_GENERAL("CompareVersions"); | 533 DEBUG_GENERAL("CompareVersions"); |
| 531 Communication::OutputBuffer request; | 534 Communication::OutputBuffer request; |
| 532 request << Communication::PROC_COMPARE_VERSIONS << v1 << v2; | 535 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S
tring(v2); |
| 533 Communication::InputBuffer response; | 536 Communication::InputBuffer response; |
| 534 if (!CallEngine(request, response)) | 537 if (!CallEngine(request, response)) |
| 535 return 0; | 538 return 0; |
| 536 int result; | 539 int result; |
| 537 response >> result; | 540 response >> result; |
| 538 return result; | 541 return result; |
| 539 } | 542 } |
| LEFT | RIGHT |