OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginSettings.h" | 3 #include "PluginSettings.h" |
4 #include "PluginSystem.h" | 4 #include "PluginSystem.h" |
5 #include "PluginFilter.h" | 5 #include "PluginFilter.h" |
6 #include "PluginClientFactory.h" | 6 #include "PluginClientFactory.h" |
7 #include "PluginMutex.h" | 7 #include "PluginMutex.h" |
8 #include "PluginClass.h" | 8 #include "PluginClass.h" |
9 | 9 |
10 #include "AdblockPlusClient.h" | 10 #include "AdblockPlusClient.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL; | 107 CAdblockPlusClient* CAdblockPlusClient::s_instance = NULL; |
108 | 108 |
109 CAdblockPlusClient::CAdblockPlusClient() : CPluginClientBase() | 109 CAdblockPlusClient::CAdblockPlusClient() : CPluginClientBase() |
110 { | 110 { |
111 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); | 111 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); |
112 } | 112 } |
113 | 113 |
114 bool CAdblockPlusClient::CallEngine(Communication::OutputBuffer& message, Commun
ication::InputBuffer& inputBuffer) | 114 bool CAdblockPlusClient::CallEngine(Communication::OutputBuffer& message, Commun
ication::InputBuffer& inputBuffer) |
115 { | 115 { |
| 116 DEBUG_GENERAL("CallEngine start"); |
116 CriticalSection::Lock lock(enginePipeLock); | 117 CriticalSection::Lock lock(enginePipeLock); |
117 try | 118 try |
118 { | 119 { |
119 if (!enginePipe) | 120 if (!enginePipe) |
120 enginePipe.reset(OpenEnginePipe()); | 121 enginePipe.reset(OpenEnginePipe()); |
121 enginePipe->WriteMessage(message); | 122 enginePipe->WriteMessage(message); |
122 inputBuffer = enginePipe->ReadMessage(); | 123 inputBuffer = enginePipe->ReadMessage(); |
123 } | 124 } |
124 catch (const std::exception& e) | 125 catch (const std::exception& e) |
125 { | 126 { |
126 DEBUG_GENERAL(e.what()); | 127 DEBUG_GENERAL(e.what()); |
127 return false; | 128 return false; |
128 } | 129 } |
| 130 DEBUG_GENERAL("CallEngine end"); |
129 return true; | 131 return true; |
130 } | 132 } |
131 | 133 |
132 bool CAdblockPlusClient::CallEngine(Communication::ProcType proc, Communication:
:InputBuffer& inputBuffer) | 134 bool CAdblockPlusClient::CallEngine(Communication::ProcType proc, Communication:
:InputBuffer& inputBuffer) |
133 { | 135 { |
134 Communication::OutputBuffer message; | 136 Communication::OutputBuffer message; |
135 message << proc; | 137 message << proc; |
136 return CallEngine(message, inputBuffer); | 138 return CallEngine(message, inputBuffer); |
137 } | 139 } |
138 | 140 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 m_criticalSectionFilter.Lock(); | 215 m_criticalSectionFilter.Lock(); |
214 { | 216 { |
215 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); | 217 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); |
216 } | 218 } |
217 m_criticalSectionFilter.Unlock(); | 219 m_criticalSectionFilter.Unlock(); |
218 return isHidden; | 220 return isHidden; |
219 } | 221 } |
220 | 222 |
221 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) | 223 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) |
222 { | 224 { |
| 225 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str()); |
223 Communication::OutputBuffer request; | 226 Communication::OutputBuffer request; |
224 request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url); | 227 request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url); |
225 | 228 |
226 Communication::InputBuffer response; | 229 Communication::InputBuffer response; |
227 if (!CallEngine(request, response)) | 230 if (!CallEngine(request, response)) |
228 return false; | 231 return false; |
229 | 232 |
230 bool isWhitelisted; | 233 bool isWhitelisted; |
231 response >> isWhitelisted; | 234 response >> isWhitelisted; |
| 235 |
| 236 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" end").c_str()); |
232 return isWhitelisted; | 237 return isWhitelisted; |
233 } | 238 } |
234 | 239 |
235 int CAdblockPlusClient::GetIEVersion() | 240 int CAdblockPlusClient::GetIEVersion() |
236 { | 241 { |
237 //HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer | 242 //HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer |
238 HKEY hKey; | 243 HKEY hKey; |
239 LSTATUS status = RegOpenKey(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Interne
t Explorer", &hKey); | 244 LSTATUS status = RegOpenKey(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Interne
t Explorer", &hKey); |
240 if (status != 0) | 245 if (status != 0) |
241 { | 246 { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() | 314 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() |
310 { | 315 { |
311 Communication::InputBuffer response; | 316 Communication::InputBuffer response; |
312 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response)) | 317 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response)) |
313 return std::vector<std::wstring>(); | 318 return std::vector<std::wstring>(); |
314 return ReadStrings(response); | 319 return ReadStrings(response); |
315 } | 320 } |
316 | 321 |
317 bool CAdblockPlusClient::IsFirstRun() | 322 bool CAdblockPlusClient::IsFirstRun() |
318 { | 323 { |
| 324 DEBUG_GENERAL("IsFirstRun"); |
319 Communication::InputBuffer response; | 325 Communication::InputBuffer response; |
320 if (!CallEngine(Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED, response)) ret
urn false; | 326 if (!CallEngine(Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED, response)) ret
urn false; |
321 bool res; | 327 bool res; |
322 response >> res; | 328 response >> res; |
323 return res; | 329 return res; |
324 } | 330 } |
325 void CAdblockPlusClient::AddFilter(const std::wstring& text) | 331 void CAdblockPlusClient::AddFilter(const std::wstring& text) |
326 { | 332 { |
327 Communication::OutputBuffer request; | 333 Communication::OutputBuffer request; |
328 request << Communication::PROC_ADD_FILTER << ToUtf8String(text); | 334 request << Communication::PROC_ADD_FILTER << ToUtf8String(text); |
(...skipping 27 matching lines...) Expand all Loading... |
356 request << Communication::PROC_SET_PREF << ToUtf8String(name) << value; | 362 request << Communication::PROC_SET_PREF << ToUtf8String(name) << value; |
357 CallEngine(request); | 363 CallEngine(request); |
358 } | 364 } |
359 | 365 |
360 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const wchar_t
* defaultValue) | 366 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const wchar_t
* defaultValue) |
361 { | 367 { |
362 return GetPref(name, std::wstring(defaultValue)); | 368 return GetPref(name, std::wstring(defaultValue)); |
363 } | 369 } |
364 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
tring& defaultValue) | 370 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
tring& defaultValue) |
365 { | 371 { |
| 372 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); |
366 Communication::OutputBuffer request; | 373 Communication::OutputBuffer request; |
367 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 374 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
368 | 375 |
369 Communication::InputBuffer response; | 376 Communication::InputBuffer response; |
370 if (!CallEngine(request, response)) | 377 if (!CallEngine(request, response)) |
371 return defaultValue; | 378 return defaultValue; |
372 bool success; | 379 bool success; |
373 response >> success; | 380 response >> success; |
374 if (success) | 381 if (success) |
375 { | 382 { |
376 std::string value; | 383 std::string value; |
377 response >> value; | 384 response >> value; |
| 385 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
378 return ToUtf16String(value); | 386 return ToUtf16String(value); |
379 } | 387 } |
380 else | 388 else |
| 389 { |
| 390 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
381 return defaultValue; | 391 return defaultValue; |
| 392 } |
382 } | 393 } |
383 | 394 |
384 bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue) | 395 bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue) |
385 { | 396 { |
| 397 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); |
386 Communication::OutputBuffer request; | 398 Communication::OutputBuffer request; |
387 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 399 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
388 | 400 |
389 Communication::InputBuffer response; | 401 Communication::InputBuffer response; |
390 if (!CallEngine(request, response)) | 402 if (!CallEngine(request, response)) |
391 return defaultValue; | 403 return defaultValue; |
392 bool success; | 404 bool success; |
393 response >> success; | 405 response >> success; |
394 if (success) | 406 if (success) |
395 { | 407 { |
396 bool value; | 408 bool value; |
397 response >> value; | 409 response >> value; |
| 410 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
398 return value; | 411 return value; |
399 } | 412 } |
400 else | 413 else |
| 414 { |
| 415 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
401 return defaultValue; | 416 return defaultValue; |
| 417 } |
402 } | 418 } |
403 int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal
ue) | 419 int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal
ue) |
404 { | 420 { |
| 421 DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str()); |
405 Communication::OutputBuffer request; | 422 Communication::OutputBuffer request; |
406 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 423 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
407 | 424 |
408 Communication::InputBuffer response; | 425 Communication::InputBuffer response; |
409 if (!CallEngine(request, response)) | 426 if (!CallEngine(request, response)) |
410 return defaultValue; | 427 return defaultValue; |
411 bool success; | 428 bool success; |
412 response >> success; | 429 response >> success; |
413 if (success) | 430 if (success) |
414 { | 431 { |
415 int64_t value; | 432 int64_t value; |
416 response >> value; | 433 response >> value; |
| 434 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
417 return value; | 435 return value; |
418 } | 436 } |
419 else | 437 else |
| 438 { |
| 439 DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str()); |
420 return defaultValue; | 440 return defaultValue; |
| 441 } |
421 } | 442 } |
422 | 443 |
423 void CAdblockPlusClient::CheckForUpdates() | 444 void CAdblockPlusClient::CheckForUpdates() |
424 { | 445 { |
425 CallEngine(Communication::PROC_CHECK_FOR_UPDATES); | 446 CallEngine(Communication::PROC_CHECK_FOR_UPDATES); |
426 } | 447 } |
427 | 448 |
428 std::wstring CAdblockPlusClient::GetDocumentationLink() | 449 std::wstring CAdblockPlusClient::GetDocumentationLink() |
429 { | 450 { |
| 451 DEBUG_GENERAL("GetDocumentationLink"); |
430 Communication::InputBuffer response; | 452 Communication::InputBuffer response; |
431 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) | 453 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) |
432 return L""; | 454 return L""; |
433 std::wstring docLink; | 455 std::wstring docLink; |
434 response >> docLink; | 456 response >> docLink; |
435 return docLink; | 457 return docLink; |
436 } | 458 } |
OLD | NEW |