LEFT | RIGHT |
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 m_criticalSectionFilter.Unlock(); | 215 m_criticalSectionFilter.Unlock(); |
216 return isHidden; | 216 return isHidden; |
217 } | 217 } |
218 | 218 |
219 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) | 219 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) |
220 { | 220 { |
221 Communication::OutputBuffer request; | 221 Communication::OutputBuffer request; |
222 request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url); | 222 request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url); |
223 | 223 |
224 Communication::InputBuffer response; | 224 Communication::InputBuffer response; |
225 if (!CallEngine(request, response)) return false; | 225 if (!CallEngine(request, response)) |
| 226 return false; |
226 | 227 |
227 bool isWhitelisted; | 228 bool isWhitelisted; |
228 response >> isWhitelisted; | 229 response >> isWhitelisted; |
229 return isWhitelisted; | 230 return isWhitelisted; |
230 } | 231 } |
231 | 232 |
232 int CAdblockPlusClient::GetIEVersion() | 233 int CAdblockPlusClient::GetIEVersion() |
233 { | 234 { |
234 //HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer | 235 //HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer |
235 HKEY hKey; | 236 HKEY hKey; |
(...skipping 13 matching lines...) Expand all Loading... |
249 RegCloseKey(hKey); | 250 RegCloseKey(hKey); |
250 return (int)(version[0] - 48); | 251 return (int)(version[0] - 48); |
251 } | 252 } |
252 | 253 |
253 bool CAdblockPlusClient::Matches(const std::wstring& url, const std::wstring& co
ntentType, const std::wstring& domain) | 254 bool CAdblockPlusClient::Matches(const std::wstring& url, const std::wstring& co
ntentType, const std::wstring& domain) |
254 { | 255 { |
255 Communication::OutputBuffer request; | 256 Communication::OutputBuffer request; |
256 request << Communication::PROC_MATCHES << ToUtf8String(url) << ToUtf8String(co
ntentType) << ToUtf8String(domain); | 257 request << Communication::PROC_MATCHES << ToUtf8String(url) << ToUtf8String(co
ntentType) << ToUtf8String(domain); |
257 | 258 |
258 Communication::InputBuffer response; | 259 Communication::InputBuffer response; |
259 if (!CallEngine(request, response)) return false; | 260 if (!CallEngine(request, response)) |
| 261 return false; |
260 | 262 |
261 bool match; | 263 bool match; |
262 response >> match; | 264 response >> match; |
263 return match; | 265 return match; |
264 } | 266 } |
265 | 267 |
266 std::vector<std::wstring> CAdblockPlusClient::GetElementHidingSelectors(const st
d::wstring& domain) | 268 std::vector<std::wstring> CAdblockPlusClient::GetElementHidingSelectors(const st
d::wstring& domain) |
267 { | 269 { |
268 Communication::OutputBuffer request; | 270 Communication::OutputBuffer request; |
269 request << Communication::PROC_GET_ELEMHIDE_SELECTORS << ToUtf8String(domain); | 271 request << Communication::PROC_GET_ELEMHIDE_SELECTORS << ToUtf8String(domain); |
270 | 272 |
271 Communication::InputBuffer response; | 273 Communication::InputBuffer response; |
272 if (!CallEngine(request, response)) return std::vector<std::wstring>(); | 274 if (!CallEngine(request, response)) |
| 275 return std::vector<std::wstring>(); |
273 return ReadStrings(response); | 276 return ReadStrings(response); |
274 } | 277 } |
275 | 278 |
276 std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscript
ions() | 279 std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscript
ions() |
277 { | 280 { |
278 Communication::InputBuffer response; | 281 Communication::InputBuffer response; |
279 if (!CallEngine(Communication::PROC_AVAILABLE_SUBSCRIPTIONS, response)) return
std::vector<SubscriptionDescription>(); | 282 if (!CallEngine(Communication::PROC_AVAILABLE_SUBSCRIPTIONS, response)) |
| 283 return std::vector<SubscriptionDescription>(); |
280 return ReadSubscriptions(response); | 284 return ReadSubscriptions(response); |
281 } | 285 } |
282 | 286 |
283 std::vector<SubscriptionDescription> CAdblockPlusClient::GetListedSubscriptions(
) | 287 std::vector<SubscriptionDescription> CAdblockPlusClient::GetListedSubscriptions(
) |
284 { | 288 { |
285 Communication::InputBuffer response; | 289 Communication::InputBuffer response; |
286 if (!CallEngine(Communication::PROC_LISTED_SUBSCRIPTIONS, response)) return st
d::vector<SubscriptionDescription>(); | 290 if (!CallEngine(Communication::PROC_LISTED_SUBSCRIPTIONS, response)) |
| 291 return std::vector<SubscriptionDescription>(); |
287 return ReadSubscriptions(response); | 292 return ReadSubscriptions(response); |
288 } | 293 } |
289 | 294 |
290 void CAdblockPlusClient::SetSubscription(const std::wstring& url) | 295 void CAdblockPlusClient::SetSubscription(const std::wstring& url) |
291 { | 296 { |
292 Communication::OutputBuffer request; | 297 Communication::OutputBuffer request; |
293 request << Communication::PROC_SET_SUBSCRIPTION << ToUtf8String(url); | 298 request << Communication::PROC_SET_SUBSCRIPTION << ToUtf8String(url); |
294 CallEngine(request); | 299 CallEngine(request); |
295 } | 300 } |
296 | 301 |
297 void CAdblockPlusClient::UpdateAllSubscriptions() | 302 void CAdblockPlusClient::UpdateAllSubscriptions() |
298 { | 303 { |
299 CallEngine(Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS); | 304 CallEngine(Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS); |
300 } | 305 } |
301 | 306 |
302 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() | 307 std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains() |
303 { | 308 { |
304 Communication::InputBuffer response; | 309 Communication::InputBuffer response; |
305 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS)) return std::vector
<std::wstring>(); | 310 if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS)) |
| 311 return std::vector<std::wstring>(); |
306 return ReadStrings(response); | 312 return ReadStrings(response); |
307 } | 313 } |
308 | 314 |
309 void CAdblockPlusClient::AddFilter(const std::wstring& text) | 315 void CAdblockPlusClient::AddFilter(const std::wstring& text) |
310 { | 316 { |
311 Communication::OutputBuffer request; | 317 Communication::OutputBuffer request; |
312 request << Communication::PROC_ADD_FILTER << ToUtf8String(text); | 318 request << Communication::PROC_ADD_FILTER << ToUtf8String(text); |
313 CallEngine(request); | 319 CallEngine(request); |
314 } | 320 } |
315 | 321 |
(...skipping 28 matching lines...) Expand all Loading... |
344 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const wchar_t
* defaultValue) | 350 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const wchar_t
* defaultValue) |
345 { | 351 { |
346 return GetPref(name, std::wstring(defaultValue)); | 352 return GetPref(name, std::wstring(defaultValue)); |
347 } | 353 } |
348 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
tring& defaultValue) | 354 std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
tring& defaultValue) |
349 { | 355 { |
350 Communication::OutputBuffer request; | 356 Communication::OutputBuffer request; |
351 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 357 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
352 | 358 |
353 Communication::InputBuffer response; | 359 Communication::InputBuffer response; |
354 if (!CallEngine(request, response)) return defaultValue; | 360 if (!CallEngine(request, response)) |
| 361 return defaultValue; |
355 bool success; | 362 bool success; |
356 response >> success; | 363 response >> success; |
357 if (success) | 364 if (success) |
358 { | 365 { |
359 std::string value; | 366 std::string value; |
360 response >> value; | 367 response >> value; |
361 return ToUtf16String(value); | 368 return ToUtf16String(value); |
362 } | 369 } |
363 else | 370 else |
364 return defaultValue; | 371 return defaultValue; |
365 } | 372 } |
366 | 373 |
367 bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue) | 374 bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue) |
368 { | 375 { |
369 Communication::OutputBuffer request; | 376 Communication::OutputBuffer request; |
370 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 377 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
371 | 378 |
372 Communication::InputBuffer response; | 379 Communication::InputBuffer response; |
373 if (!CallEngine(request, response)) return defaultValue; | 380 if (!CallEngine(request, response)) |
| 381 return defaultValue; |
374 bool success; | 382 bool success; |
375 response >> success; | 383 response >> success; |
376 if (success) | 384 if (success) |
377 { | 385 { |
378 bool value; | 386 bool value; |
379 response >> value; | 387 response >> value; |
380 return value; | 388 return value; |
381 } | 389 } |
382 else | 390 else |
383 return defaultValue; | 391 return defaultValue; |
384 } | 392 } |
385 int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal
ue) | 393 int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal
ue) |
386 { | 394 { |
387 Communication::OutputBuffer request; | 395 Communication::OutputBuffer request; |
388 request << Communication::PROC_GET_PREF << ToUtf8String(name); | 396 request << Communication::PROC_GET_PREF << ToUtf8String(name); |
389 | 397 |
390 Communication::InputBuffer response; | 398 Communication::InputBuffer response; |
391 if (!CallEngine(request, response)) return defaultValue; | 399 if (!CallEngine(request, response)) |
392 bool success; | 400 return defaultValue; |
| 401 bool success; |
393 response >> success; | 402 response >> success; |
394 if (success) | 403 if (success) |
395 { | 404 { |
396 int64_t value; | 405 int64_t value; |
397 response >> value; | 406 response >> value; |
398 return value; | 407 return value; |
399 } | 408 } |
400 else | 409 else |
401 return defaultValue; | 410 return defaultValue; |
402 } | 411 } |
LEFT | RIGHT |