Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java

Issue 29760569: Issue 6238 - Download/store notifications.json (Closed)
Patch Set: Created May 15, 2018, 9:57 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 import java.io.OutputStreamWriter; 24 import java.io.OutputStreamWriter;
25 import java.nio.charset.StandardCharsets; 25 import java.nio.charset.StandardCharsets;
26 import java.util.ArrayList; 26 import java.util.ArrayList;
27 import java.util.HashMap; 27 import java.util.HashMap;
28 import java.util.HashSet; 28 import java.util.HashSet;
29 import java.util.List; 29 import java.util.List;
30 import java.util.Locale; 30 import java.util.Locale;
31 import java.util.Map; 31 import java.util.Map;
32 32
33 import org.adblockplus.sbrowser.contentblocker.engine.Subscription.Type; 33 import org.adblockplus.sbrowser.contentblocker.engine.Subscription.Type;
34 import org.adblockplus.sbrowser.contentblocker.util.SubscriptionUtils;
34 35
35 import android.util.Log; 36 import android.util.Log;
36 37
37 /** 38 /**
38 * This class holds all listed subscriptions and manages the subscription 39 * This class holds all listed subscriptions and manages the subscription
39 * aggregation cache folder. 40 * aggregation cache folder.
40 */ 41 */
41 final class Subscriptions 42 final class Subscriptions
42 { 43 {
43 private static final String TAG = Subscriptions.class.getSimpleName(); 44 private static final String TAG = Subscriptions.class.getSimpleName();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 filtersFile = new File(this.subscriptionFolder, "user_" + sub.getTitle() + ".sub"); 138 filtersFile = new File(this.subscriptionFolder, "user_" + sub.getTitle() + ".sub");
138 } 139 }
139 else 140 else
140 { 141 {
141 filtersFile = new File(this.subscriptionFolder, "url_" 142 filtersFile = new File(this.subscriptionFolder, "url_"
142 + new File(sub.getURL().getPath()).getName() + ".sub"); 143 + new File(sub.getURL().getPath()).getName() + ".sub");
143 } 144 }
144 return filtersFile; 145 return filtersFile;
145 } 146 }
146 147
148 File getNotificationDataFile()
149 {
150 return new File (this.subscriptionFolder, Notification.NOTIFICATION_DATA_FIL E_NAME);
151 }
152
147 File getMetaFile(final Subscription sub) 153 File getMetaFile(final Subscription sub)
148 { 154 {
149 return new File(getFiltersFile(sub).getAbsolutePath() + ".meta"); 155 return new File(getFiltersFile(sub).getAbsolutePath() + ".meta");
150 } 156 }
151 157
152 void persistSubscription(final Subscription sub) throws IOException 158 void persistSubscription(final Subscription sub) throws IOException
153 { 159 {
154 sub.serializeSubscription(this.getMetaFile(sub), this.getFiltersFile(sub)); 160 sub.serializeSubscription(this.getMetaFile(sub), this.getFiltersFile(sub));
155 } 161 }
156 162
(...skipping 10 matching lines...) Expand all
167 * one text file. 173 * one text file.
168 * 174 *
169 * @param output 175 * @param output
170 * @throws IOException 176 * @throws IOException
171 */ 177 */
172 private void writeFile(final File output) throws IOException 178 private void writeFile(final File output) throws IOException
173 { 179 {
174 final HashSet<String> filters = new HashSet<>(); 180 final HashSet<String> filters = new HashSet<>();
175 for (final Subscription s : this.subscriptions.values()) 181 for (final Subscription s : this.subscriptions.values())
176 { 182 {
177 if (s.isEnabled()) 183 if (s.isEnabled() && !SubscriptionUtils.isNotificationSubscription(s.getId ()))
178 { 184 {
179 Log.d(TAG, "Adding filters for '" + s.getId() + "'"); 185 Log.d(TAG, "Adding filters for '" + s.getId() + "'");
180 s.deserializeFilters(this.getFiltersFile(s)); 186 s.deserializeFilters(this.getFiltersFile(s));
181 s.copyFilters(filters); 187 s.copyFilters(filters);
182 s.clearFilters(); 188 s.clearFilters();
183 } 189 }
184 if ((!s.isMetaDataValid() || !s.isFiltersValid()) && s.getURL() != null) 190 if ((!s.isMetaDataValid() || !s.isFiltersValid()) && s.getURL() != null)
185 { 191 {
186 this.engine.enqueueDownload(s, true, false); 192 this.engine.enqueueDownload(s, true, false);
187 } 193 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (sub != null) 295 if (sub != null)
290 { 296 {
291 if (sub.updateSubscription(responseCode, text, httpHeaders, this.getMetaFi le(sub), 297 if (sub.updateSubscription(responseCode, text, httpHeaders, this.getMetaFi le(sub),
292 this.getFiltersFile(sub))) 298 this.getFiltersFile(sub)))
293 { 299 {
294 this.engine.requestUpdateBroadcast(); 300 this.engine.requestUpdateBroadcast();
295 } 301 }
296 } 302 }
297 } 303 }
298 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld