OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 package org.adblockplus.brazil; | 18 package org.adblockplus.android; |
19 | 19 |
20 import java.io.IOException; | 20 import org.adblockplus.libadblockplus.FilterChangeCallback; |
| 21 import org.adblockplus.libadblockplus.JsValue; |
| 22 import org.adblockplus.libadblockplus.Subscription; |
21 | 23 |
22 import sunlabs.brazil.server.Handler; | 24 import android.content.Context; |
23 import sunlabs.brazil.server.Request; | |
24 import sunlabs.brazil.server.Server; | |
25 | 25 |
26 /** | 26 public class AndroidFilterChangeCallback extends FilterChangeCallback |
27 * Reconstructs request url to comply with proxy specification if transparent | |
28 * proxy is used. | |
29 */ | |
30 public class TransparentProxyHandler implements Handler | |
31 { | 27 { |
| 28 private final Context context; |
32 | 29 |
33 @Override | 30 public AndroidFilterChangeCallback(final Context context) |
34 public boolean init(Server server, String prefix) | |
35 { | 31 { |
36 return true; | 32 this.context = context; |
37 } | 33 } |
38 | 34 |
39 @Override | 35 @Override |
40 public boolean respond(Request request) throws IOException | 36 public void filterChangeCallback(final String action, final JsValue jsValue) |
41 { | 37 { |
42 if (!request.url.contains("://")) | 38 if (action.equals("subscription.lastDownload") || action.equals("subscriptio
n.downloadStatus")) |
43 { | 39 { |
44 request.url = "http://" + request.headers.get("host") + request.url; | 40 final Subscription sub = new Subscription(jsValue); |
| 41 |
| 42 Utils.updateSubscriptionStatus(this.context, sub); |
45 } | 43 } |
46 return false; | |
47 } | 44 } |
48 | |
49 } | 45 } |
OLD | NEW |