Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 let result; | 189 let result; |
190 try | 190 try |
191 { | 191 { |
192 obj.url = Services.io.newURI(obj.url, null, null).spec; | 192 obj.url = Services.io.newURI(obj.url, null, null).spec; |
193 | 193 |
194 // URL is valid - this is a downloadable subscription | 194 // URL is valid - this is a downloadable subscription |
195 result = new DownloadableSubscription(obj.url, obj.title); | 195 result = new DownloadableSubscription(obj.url, obj.title); |
196 if ("downloadStatus" in obj) | 196 if ("downloadStatus" in obj) |
197 result._downloadStatus = obj.downloadStatus; | 197 result._downloadStatus = obj.downloadStatus; |
198 if ("lastSuccess" in obj) | 198 if ("lastSuccess" in obj) |
199 result.lastSuccess = parseInt(obj.lastSuccess) || 0; | 199 result.lastSuccess = parseInt(obj.lastSuccess, 10) || 0; |
200 if ("lastCheck" in obj) | 200 if ("lastCheck" in obj) |
201 result._lastCheck = parseInt(obj.lastCheck) || 0; | 201 result._lastCheck = parseInt(obj.lastCheck, 10) || 0; |
202 if ("expires" in obj) | 202 if ("expires" in obj) |
203 result.expires = parseInt(obj.expires) || 0; | 203 result.expires = parseInt(obj.expires, 10) || 0; |
204 if ("softExpiration" in obj) | 204 if ("softExpiration" in obj) |
205 result.softExpiration = parseInt(obj.softExpiration) || 0; | 205 result.softExpiration = parseInt(obj.softExpiration, 10) || 0; |
206 if ("errors" in obj) | 206 if ("errors" in obj) |
207 result._errors = parseInt(obj.errors) || 0; | 207 result._errors = parseInt(obj.errors, 10) || 0; |
208 if ("version" in obj) | 208 if ("version" in obj) |
209 result.version = parseInt(obj.version) || 0; | 209 result.version = parseInt(obj.version, 10) || 0; |
210 if ("requiredVersion" in obj) | 210 if ("requiredVersion" in obj) |
211 { | 211 { |
212 let {addonVersion} = require("info"); | 212 let {addonVersion} = require("info"); |
213 result.requiredVersion = obj.requiredVersion; | 213 result.requiredVersion = obj.requiredVersion; |
214 if (Services.vc.compare(result.requiredVersion, addonVersion) > 0) | 214 if (Services.vc.compare(result.requiredVersion, addonVersion) > 0) |
215 result.upgradeRequired = true; | 215 result.upgradeRequired = true; |
216 } | 216 } |
217 if ("homepage" in obj) | 217 if ("homepage" in obj) |
218 result._homepage = obj.homepage; | 218 result._homepage = obj.homepage; |
219 if ("lastDownload" in obj) | 219 if ("lastDownload" in obj) |
220 result._lastDownload = parseInt(obj.lastDownload) || 0; | 220 result._lastDownload = parseInt(obj.lastDownload, 10) || 0; |
221 if ("downloadCount" in obj) | 221 if ("downloadCount" in obj) |
222 result.downloadCount = obj.downloadCount; | 222 result.downloadCount = parseInt(obj.downloadCount, 10) || 0; |
Wladimir Palant
2014/11/10 19:18:15
Should be a number with the comments above address
Thomas Greiner
2014/11/11 17:17:18
Done.
| |
223 } | 223 } |
224 catch (e) | 224 catch (e) |
225 { | 225 { |
226 // Invalid URL - custom filter group | 226 // Invalid URL - custom filter group |
227 if (!("title" in obj)) | 227 if (!("title" in obj)) |
228 { | 228 { |
229 // Backwards compatibility - titles and filter types were originally | 229 // Backwards compatibility - titles and filter types were originally |
230 // determined by group identifier. | 230 // determined by group identifier. |
231 if (obj.url == "~wl~") | 231 if (obj.url == "~wl~") |
232 obj.defaults = "whitelist"; | 232 obj.defaults = "whitelist"; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 /** | 560 /** |
561 * Should be true if requiredVersion is higher than current Adblock Plus versi on | 561 * Should be true if requiredVersion is higher than current Adblock Plus versi on |
562 * @type Boolean | 562 * @type Boolean |
563 */ | 563 */ |
564 upgradeRequired: false, | 564 upgradeRequired: false, |
565 | 565 |
566 /** | 566 /** |
567 * Number indicating how often the object was downloaded. | 567 * Number indicating how often the object was downloaded. |
568 * @type Number | 568 * @type Number |
569 */ | 569 */ |
570 downloadCount: 1, | 570 downloadCount: 0, |
Wladimir Palant
2014/11/10 19:18:15
Again, I think that the default should be 0.
Thomas Greiner
2014/11/11 17:17:18
Done.
| |
571 | 571 |
572 /** | 572 /** |
573 * See Subscription.serialize() | 573 * See Subscription.serialize() |
574 */ | 574 */ |
575 serialize: function(buffer) | 575 serialize: function(buffer) |
576 { | 576 { |
577 RegularSubscription.prototype.serialize.call(this, buffer); | 577 RegularSubscription.prototype.serialize.call(this, buffer); |
578 if (this.downloadStatus) | 578 if (this.downloadStatus) |
579 buffer.push("downloadStatus=" + this.downloadStatus); | 579 buffer.push("downloadStatus=" + this.downloadStatus); |
580 if (this.lastSuccess) | 580 if (this.lastSuccess) |
581 buffer.push("lastSuccess=" + this.lastSuccess); | 581 buffer.push("lastSuccess=" + this.lastSuccess); |
582 if (this.lastCheck) | 582 if (this.lastCheck) |
583 buffer.push("lastCheck=" + this.lastCheck); | 583 buffer.push("lastCheck=" + this.lastCheck); |
584 if (this.expires) | 584 if (this.expires) |
585 buffer.push("expires=" + this.expires); | 585 buffer.push("expires=" + this.expires); |
586 if (this.softExpiration) | 586 if (this.softExpiration) |
587 buffer.push("softExpiration=" + this.softExpiration); | 587 buffer.push("softExpiration=" + this.softExpiration); |
588 if (this.errors) | 588 if (this.errors) |
589 buffer.push("errors=" + this.errors); | 589 buffer.push("errors=" + this.errors); |
590 if (this.version) | 590 if (this.version) |
591 buffer.push("version=" + this.version); | 591 buffer.push("version=" + this.version); |
592 if (this.requiredVersion) | 592 if (this.requiredVersion) |
593 buffer.push("requiredVersion=" + this.requiredVersion); | 593 buffer.push("requiredVersion=" + this.requiredVersion); |
594 if (this.downloadCount) | 594 if (this.downloadCount) |
595 buffer.push("downloadCount=" + this.downloadCount); | 595 buffer.push("downloadCount=" + this.downloadCount); |
596 } | 596 } |
597 }; | 597 }; |
LEFT | RIGHT |