OLD | NEW |
| (Empty) |
1 /* | |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | |
3 * Copyright (C) 2006-2014 Eyeo GmbH | |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * Adblock Plus is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
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/>. | |
16 */ | |
17 | |
18 | |
19 // | |
20 // This file has been generated automatically from Adblock Plus source code | |
21 // | |
22 | |
23 (function (_patchFunc2) { | |
24 function Subscription(url, title) { | |
25 this.url = url; | |
26 this.filters = []; | |
27 this._title = title || Utils.getString("newGroup_title"); | |
28 Subscription.knownSubscriptions[url] = this; | |
29 } | |
30 Subscription.prototype = { | |
31 url: null, | |
32 filters: null, | |
33 _title: null, | |
34 _disabled: false, | |
35 get title() { | |
36 return this._title; | |
37 }, | |
38 set title(value) { | |
39 if (value != this._title) { | |
40 var oldValue = this._title; | |
41 this._title = value; | |
42 FilterNotifier.triggerListeners("subscription.title", this, value, oldVa
lue); | |
43 } | |
44 return this._title; | |
45 } | |
46 , | |
47 get disabled() { | |
48 return this._disabled; | |
49 }, | |
50 set disabled(value) { | |
51 if (value != this._disabled) { | |
52 var oldValue = this._disabled; | |
53 this._disabled = value; | |
54 FilterNotifier.triggerListeners("subscription.disabled", this, value, ol
dValue); | |
55 } | |
56 return this._disabled; | |
57 } | |
58 , | |
59 serialize: function (buffer) { | |
60 buffer.push("[Subscription]"); | |
61 buffer.push("url=" + this.url); | |
62 buffer.push("title=" + this._title); | |
63 if (this._disabled) | |
64 buffer.push("disabled=true"); | |
65 } | |
66 , | |
67 serializeFilters: function (buffer) { | |
68 for (var _loopIndex0 = 0; | |
69 _loopIndex0 < this.filters.length; ++ _loopIndex0) { | |
70 var filter = this.filters[_loopIndex0]; | |
71 buffer.push(filter.text.replace(/\[/g, "\\[")); | |
72 } | |
73 } | |
74 , | |
75 toString: function () { | |
76 var buffer = []; | |
77 this.serialize(buffer); | |
78 return buffer.join("\n"); | |
79 } | |
80 | |
81 }; | |
82 Subscription.knownSubscriptions = { | |
83 __proto__: null | |
84 }; | |
85 Subscription.fromURL = (function (url) { | |
86 if (url in Subscription.knownSubscriptions) | |
87 return Subscription.knownSubscriptions[url]; | |
88 try { | |
89 url = Utils.ioService.newURI(url, null, null).spec; | |
90 return new DownloadableSubscription(url, null); | |
91 } | |
92 catch (e){ | |
93 return new SpecialSubscription(url); | |
94 } | |
95 } | |
96 ); | |
97 Subscription.fromObject = (function (obj) { | |
98 var result; | |
99 try { | |
100 obj.url = Utils.ioService.newURI(obj.url, null, null).spec; | |
101 result = new DownloadableSubscription(obj.url, obj.title); | |
102 if ("nextURL" in obj) | |
103 result.nextURL = obj.nextURL; | |
104 if ("downloadStatus" in obj) | |
105 result._downloadStatus = obj.downloadStatus; | |
106 if ("lastModified" in obj) | |
107 result.lastModified = obj.lastModified; | |
108 if ("lastSuccess" in obj) | |
109 result.lastSuccess = parseInt(obj.lastSuccess) || 0; | |
110 if ("lastCheck" in obj) | |
111 result._lastCheck = parseInt(obj.lastCheck) || 0; | |
112 if ("expires" in obj) | |
113 result.expires = parseInt(obj.expires) || 0; | |
114 if ("softExpiration" in obj) | |
115 result.softExpiration = parseInt(obj.softExpiration) || 0; | |
116 if ("errors" in obj) | |
117 result._errors = parseInt(obj.errors) || 0; | |
118 if ("requiredVersion" in obj) { | |
119 result.requiredVersion = obj.requiredVersion; | |
120 if (Utils.versionComparator.compare(result.requiredVersion, Utils.addonV
ersion) > 0) | |
121 result.upgradeRequired = true; | |
122 } | |
123 if ("alternativeLocations" in obj) | |
124 result.alternativeLocations = obj.alternativeLocations; | |
125 if ("homepage" in obj) | |
126 result._homepage = obj.homepage; | |
127 if ("lastDownload" in obj) | |
128 result._lastDownload = parseInt(obj.lastDownload) || 0; | |
129 } | |
130 catch (e){ | |
131 if (!("title" in obj)) { | |
132 if (obj.url == "~wl~") | |
133 obj.defaults = "whitelist"; | |
134 else | |
135 if (obj.url == "~fl~") | |
136 obj.defaults = "blocking"; | |
137 else | |
138 if (obj.url == "~eh~") | |
139 obj.defaults = "elemhide"; | |
140 if ("defaults" in obj) | |
141 obj.title = Utils.getString(obj.defaults + "Group_title"); | |
142 } | |
143 result = new SpecialSubscription(obj.url, obj.title); | |
144 if ("defaults" in obj) | |
145 result.defaults = obj.defaults.split(" "); | |
146 } | |
147 if ("disabled" in obj) | |
148 result._disabled = (obj.disabled == "true"); | |
149 return result; | |
150 } | |
151 ); | |
152 function SpecialSubscription(url, title) { | |
153 Subscription.call(this, url, title); | |
154 } | |
155 SpecialSubscription.prototype = { | |
156 __proto__: Subscription.prototype, | |
157 defaults: null, | |
158 isDefaultFor: function (filter) { | |
159 if (this.defaults && this.defaults.length) { | |
160 for (var _loopIndex1 = 0; | |
161 _loopIndex1 < this.defaults.length; ++ _loopIndex1) { | |
162 var type = this.defaults[_loopIndex1]; | |
163 if (filter instanceof SpecialSubscription.defaultsMap[type]) | |
164 return true; | |
165 if (!(filter instanceof ActiveFilter) && type == "blacklist") | |
166 return true; | |
167 } | |
168 } | |
169 return false; | |
170 } | |
171 , | |
172 serialize: function (buffer) { | |
173 Subscription.prototype.serialize.call(this, buffer); | |
174 if (this.defaults && this.defaults.length) | |
175 buffer.push("defaults=" + this.defaults.filter(function (type) { | |
176 return type in SpecialSubscription.defaultsMap; | |
177 }).join(" ")); | |
178 if (this._lastDownload) | |
179 buffer.push("lastDownload=" + this._lastDownload); | |
180 } | |
181 | |
182 }; | |
183 SpecialSubscription.defaultsMap = { | |
184 __proto__: null, | |
185 "whitelist": WhitelistFilter, | |
186 "blocking": BlockingFilter, | |
187 "elemhide": ElemHideFilter | |
188 }; | |
189 SpecialSubscription.create = (function (title) { | |
190 var url; | |
191 do { | |
192 url = "~user~" + Math.round(Math.random() * 1000000); | |
193 } | |
194 while (url in Subscription.knownSubscriptions); | |
195 return new SpecialSubscription(url, title); | |
196 } | |
197 ); | |
198 SpecialSubscription.createForFilter = (function (filter) { | |
199 var subscription = SpecialSubscription.create(); | |
200 subscription.filters.push(filter); | |
201 for (var type in SpecialSubscription.defaultsMap) { | |
202 if (filter instanceof SpecialSubscription.defaultsMap[type]) | |
203 subscription.defaults = [type]; | |
204 } | |
205 if (!subscription.defaults) | |
206 subscription.defaults = ["blocking"]; | |
207 subscription.title = Utils.getString(subscription.defaults[0] + "Group_title
"); | |
208 return subscription; | |
209 } | |
210 ); | |
211 function RegularSubscription(url, title) { | |
212 Subscription.call(this, url, title || url); | |
213 } | |
214 RegularSubscription.prototype = { | |
215 __proto__: Subscription.prototype, | |
216 _homepage: null, | |
217 _lastDownload: 0, | |
218 get homepage() { | |
219 return this._homepage; | |
220 }, | |
221 set homepage(value) { | |
222 if (value != this._homepage) { | |
223 var oldValue = this._homepage; | |
224 this._homepage = value; | |
225 FilterNotifier.triggerListeners("subscription.homepage", this, value, ol
dValue); | |
226 } | |
227 return this._homepage; | |
228 } | |
229 , | |
230 get lastDownload() { | |
231 return this._lastDownload; | |
232 }, | |
233 set lastDownload(value) { | |
234 if (value != this._lastDownload) { | |
235 var oldValue = this._lastDownload; | |
236 this._lastDownload = value; | |
237 FilterNotifier.triggerListeners("subscription.lastDownload", this, value
, oldValue); | |
238 } | |
239 return this._lastDownload; | |
240 } | |
241 , | |
242 serialize: function (buffer) { | |
243 Subscription.prototype.serialize.call(this, buffer); | |
244 if (this._homepage) | |
245 buffer.push("homepage=" + this._homepage); | |
246 if (this._lastDownload) | |
247 buffer.push("lastDownload=" + this._lastDownload); | |
248 } | |
249 | |
250 }; | |
251 function ExternalSubscription(url, title) { | |
252 RegularSubscription.call(this, url, title); | |
253 } | |
254 ExternalSubscription.prototype = { | |
255 __proto__: RegularSubscription.prototype, | |
256 serialize: function (buffer) { | |
257 throw new Error("Unexpected call, external subscriptions should not be ser
ialized"); | |
258 } | |
259 | |
260 }; | |
261 function DownloadableSubscription(url, title) { | |
262 RegularSubscription.call(this, url, title); | |
263 } | |
264 DownloadableSubscription.prototype = { | |
265 __proto__: RegularSubscription.prototype, | |
266 _downloadStatus: null, | |
267 _lastCheck: 0, | |
268 _errors: 0, | |
269 nextURL: null, | |
270 get downloadStatus() { | |
271 return this._downloadStatus; | |
272 }, | |
273 set downloadStatus(value) { | |
274 var oldValue = this._downloadStatus; | |
275 this._downloadStatus = value; | |
276 FilterNotifier.triggerListeners("subscription.downloadStatus", this, value
, oldValue); | |
277 return this._downloadStatus; | |
278 } | |
279 , | |
280 lastModified: null, | |
281 lastSuccess: 0, | |
282 get lastCheck() { | |
283 return this._lastCheck; | |
284 }, | |
285 set lastCheck(value) { | |
286 if (value != this._lastCheck) { | |
287 var oldValue = this._lastCheck; | |
288 this._lastCheck = value; | |
289 FilterNotifier.triggerListeners("subscription.lastCheck", this, value, o
ldValue); | |
290 } | |
291 return this._lastCheck; | |
292 } | |
293 , | |
294 expires: 0, | |
295 softExpiration: 0, | |
296 get errors() { | |
297 return this._errors; | |
298 }, | |
299 set errors(value) { | |
300 if (value != this._errors) { | |
301 var oldValue = this._errors; | |
302 this._errors = value; | |
303 FilterNotifier.triggerListeners("subscription.errors", this, value, oldV
alue); | |
304 } | |
305 return this._errors; | |
306 } | |
307 , | |
308 requiredVersion: null, | |
309 upgradeRequired: false, | |
310 alternativeLocations: null, | |
311 serialize: function (buffer) { | |
312 RegularSubscription.prototype.serialize.call(this, buffer); | |
313 if (this.nextURL) | |
314 buffer.push("nextURL=" + this.nextURL); | |
315 if (this.downloadStatus) | |
316 buffer.push("downloadStatus=" + this.downloadStatus); | |
317 if (this.lastModified) | |
318 buffer.push("lastModified=" + this.lastModified); | |
319 if (this.lastSuccess) | |
320 buffer.push("lastSuccess=" + this.lastSuccess); | |
321 if (this.lastCheck) | |
322 buffer.push("lastCheck=" + this.lastCheck); | |
323 if (this.expires) | |
324 buffer.push("expires=" + this.expires); | |
325 if (this.softExpiration) | |
326 buffer.push("softExpiration=" + this.softExpiration); | |
327 if (this.errors) | |
328 buffer.push("errors=" + this.errors); | |
329 if (this.requiredVersion) | |
330 buffer.push("requiredVersion=" + this.requiredVersion); | |
331 if (this.alternativeLocations) | |
332 buffer.push("alternativeLocations=" + this.alternativeLocations); | |
333 } | |
334 | |
335 }; | |
336 if (typeof _patchFunc2 != "undefined") | |
337 eval("(" + _patchFunc2.toString() + ")()"); | |
338 window.Subscription = Subscription; | |
339 window.SpecialSubscription = SpecialSubscription; | |
340 window.RegularSubscription = RegularSubscription; | |
341 window.ExternalSubscription = ExternalSubscription; | |
342 window.DownloadableSubscription = DownloadableSubscription; | |
343 } | |
344 )(window.SubscriptionClassesPatch); | |
OLD | NEW |