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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 | 250 |
251 public void subscriptionStateChanged() | 251 public void subscriptionStateChanged() |
252 { | 252 { |
253 if (this.subscriptionUpdateCallback != null) | 253 if (this.subscriptionUpdateCallback != null) |
254 { | 254 { |
255 subscriptionUpdateCallback.subscriptionUpdatedApplied(); | 255 subscriptionUpdateCallback.subscriptionUpdatedApplied(); |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
| 259 public void createAndAddSubscriptionFromUrl(final String url, final Subscripti
onAddedCallback callback) throws IOException |
| 260 { |
| 261 final Subscription sub = Subscription.create(url); |
| 262 sub.putMeta(Subscription.KEY_TITLE, url); |
| 263 sub.setEnabled(true); |
| 264 subscriptions.add(sub); |
| 265 subscriptions.persistSubscription(sub); |
| 266 callback.subscriptionAdded(); |
| 267 } |
| 268 |
| 269 public void removeSubscriptionById(final String subscriptionId) |
| 270 { |
| 271 subscriptions.remove(subscriptionId); |
| 272 } |
| 273 |
259 void downloadFinished(final String id, final int responseCode, final String re
sponse, | 274 void downloadFinished(final String id, final int responseCode, final String re
sponse, |
260 final Map<String, String> headers) | 275 final Map<String, String> headers) |
261 { | 276 { |
262 this.engineEvents.add(new DownloadFinishedEvent(id, responseCode, response,
headers)); | 277 this.engineEvents.add(new DownloadFinishedEvent(id, responseCode, response,
headers)); |
263 } | 278 } |
264 | 279 |
265 private void createAndWriteFile() | 280 private void createAndWriteFile() |
266 { | 281 { |
267 this.lock(); | 282 this.lock(); |
268 try | 283 try |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 sb.append(downloadCount); | 619 sb.append(downloadCount); |
605 } | 620 } |
606 else | 621 else |
607 { | 622 { |
608 sb.append("4%2B"); // "4+" URL encoded | 623 sb.append("4%2B"); // "4+" URL encoded |
609 } | 624 } |
610 | 625 |
611 return new URL(sb.toString()); | 626 return new URL(sb.toString()); |
612 } | 627 } |
613 | 628 |
| 629 public boolean isAcceptableAdsUrl(final SubscriptionInfo subscriptionInfo) |
| 630 { |
| 631 return getPrefsDefault(SUBSCRIPTIONS_EXCEPTIONSURL).equals(subscriptionInfo.
getUrl()); |
| 632 } |
| 633 |
614 private static class EventHandler implements Runnable | 634 private static class EventHandler implements Runnable |
615 { | 635 { |
616 private static final String TAG = EventHandler.class.getSimpleName(); | 636 private static final String TAG = EventHandler.class.getSimpleName(); |
617 private final Engine engine; | 637 private final Engine engine; |
618 | 638 |
619 public EventHandler(final Engine engine) | 639 public EventHandler(final Engine engine) |
620 { | 640 { |
621 this.engine = engine; | 641 this.engine = engine; |
622 } | 642 } |
623 | 643 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 public void connectivityChanged() | 800 public void connectivityChanged() |
781 { | 801 { |
782 this.downloader.connectivityChanged(); | 802 this.downloader.connectivityChanged(); |
783 } | 803 } |
784 | 804 |
785 public interface SubscriptionUpdateCallback | 805 public interface SubscriptionUpdateCallback |
786 { | 806 { |
787 void subscriptionUpdateRequested(boolean enabled); | 807 void subscriptionUpdateRequested(boolean enabled); |
788 void subscriptionUpdatedApplied(); | 808 void subscriptionUpdatedApplied(); |
789 } | 809 } |
| 810 |
| 811 public interface SubscriptionAddedCallback |
| 812 { |
| 813 void subscriptionAdded(); |
| 814 } |
790 } | 815 } |
OLD | NEW |