13 |
13 |
14 from .AdBlockNetwork import AdBlockNetwork |
14 from .AdBlockNetwork import AdBlockNetwork |
15 from .AdBlockPage import AdBlockPage |
15 from .AdBlockPage import AdBlockPage |
16 from .AdBlockSubscription import AdBlockSubscription |
16 from .AdBlockSubscription import AdBlockSubscription |
17 from .AdBlockDialog import AdBlockDialog |
17 from .AdBlockDialog import AdBlockDialog |
|
18 from .AdBlockExceptionsDialog import AdBlockExceptionsDialog |
18 |
19 |
19 import Helpviewer.HelpWindow |
20 import Helpviewer.HelpWindow |
20 |
21 |
21 from Utilities.AutoSaver import AutoSaver |
22 from Utilities.AutoSaver import AutoSaver |
22 import Utilities |
23 import Utilities |
42 |
43 |
43 self.__loaded = False |
44 self.__loaded = False |
44 self.__subscriptionsLoaded = False |
45 self.__subscriptionsLoaded = False |
45 self.__enabled = False |
46 self.__enabled = False |
46 self.__adBlockDialog = None |
47 self.__adBlockDialog = None |
|
48 self.__adBlockExceptionsDialog = None |
47 self.__adBlockNetwork = None |
49 self.__adBlockNetwork = None |
48 self.__adBlockPage = None |
50 self.__adBlockPage = None |
49 self.__subscriptions = [] |
51 self.__subscriptions = [] |
|
52 self.__exceptedHosts = Preferences.getHelp("AdBlockExceptions") |
50 self.__saveTimer = AutoSaver(self, self.save) |
53 self.__saveTimer = AutoSaver(self, self.save) |
51 |
54 |
52 self.__defaultSubscriptionUrlString = \ |
55 self.__defaultSubscriptionUrlString = \ |
53 "abp:subscribe?location=" \ |
56 "abp:subscribe?location=" \ |
54 "https://easylist-downloads.adblockplus.org/easylist.txt&title=EasyList" |
57 "https://easylist-downloads.adblockplus.org/easylist.txt&title=EasyList" |
336 return subscriptions |
340 return subscriptions |
337 |
341 |
338 def showDialog(self): |
342 def showDialog(self): |
339 """ |
343 """ |
340 Public slot to show the AdBlock subscription management dialog. |
344 Public slot to show the AdBlock subscription management dialog. |
|
345 |
|
346 @return reference to the dialog (AdBlockDialog) |
341 """ |
347 """ |
342 if self.__adBlockDialog is None: |
348 if self.__adBlockDialog is None: |
343 self.__adBlockDialog = AdBlockDialog() |
349 self.__adBlockDialog = AdBlockDialog() |
344 |
350 |
345 self.__adBlockDialog.show() |
351 self.__adBlockDialog.show() |
396 if rules: |
402 if rules: |
397 # remove last ", |
403 # remove last ", |
398 rules = rules[:-1] |
404 rules = rules[:-1] |
399 |
405 |
400 return rules |
406 return rules |
|
407 |
|
408 def exceptions(self): |
|
409 """ |
|
410 Public method to get a list of excepted hosts. |
|
411 |
|
412 @return list of excepted hosts (list of string) |
|
413 """ |
|
414 return self.__exceptedHosts |
|
415 |
|
416 def setExceptions(self, hosts): |
|
417 """ |
|
418 Public method to set the list of excepted hosts. |
|
419 |
|
420 @param hosts list of excepted hosts (list of string) |
|
421 """ |
|
422 self.__exceptedHosts = hosts[:] |
|
423 Preferences.setHelp("AdBlockExceptions", self.__exceptedHosts) |
|
424 |
|
425 def addException(self, host): |
|
426 """ |
|
427 Public method to add an exception. |
|
428 |
|
429 @param host to be excepted (string) |
|
430 """ |
|
431 if host and host not in self.__exceptedHosts: |
|
432 self.__exceptedHosts.append(host) |
|
433 Preferences.setHelp("AdBlockExceptions", self.__exceptedHosts) |
|
434 |
|
435 def removeException(self, host): |
|
436 """ |
|
437 Public method to remove an exception. |
|
438 |
|
439 @param host to be removed from the list of exceptions (string) |
|
440 """ |
|
441 if host in self.__exceptedHosts: |
|
442 self.__exceptedHosts.remove(host) |
|
443 Preferences.setHelp("AdBlockExceptions", self.__exceptedHosts) |
|
444 |
|
445 def isHostExcepted(self, host): |
|
446 """ |
|
447 Public slot to check, if a host is excepted. |
|
448 |
|
449 @param host host to check (string) |
|
450 @return flag indicating an exception (boolean) |
|
451 """ |
|
452 return host in self.__exceptedHosts |
|
453 |
|
454 def showExceptionsDialog(self): |
|
455 """ |
|
456 Public method to show the AdBlock Exceptions dialog. |
|
457 |
|
458 @return reference to the exceptions dialog (AdBlockExceptionsDialog) |
|
459 """ |
|
460 if self.__adBlockExceptionsDialog is None: |
|
461 self.__adBlockExceptionsDialog = AdBlockExceptionsDialog() |
|
462 |
|
463 self.__adBlockExceptionsDialog.load(self.__exceptedHosts) |
|
464 self.__adBlockExceptionsDialog.show() |
|
465 return self.__adBlockExceptionsDialog |