| 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 |
| (...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) |
| 222 result.downloadCount = parseInt(obj.downloadCount, 10) || 0; |
| 221 } | 223 } |
| 222 catch (e) | 224 catch (e) |
| 223 { | 225 { |
| 224 // Invalid URL - custom filter group | 226 // Invalid URL - custom filter group |
| 225 if (!("title" in obj)) | 227 if (!("title" in obj)) |
| 226 { | 228 { |
| 227 // Backwards compatibility - titles and filter types were originally | 229 // Backwards compatibility - titles and filter types were originally |
| 228 // determined by group identifier. | 230 // determined by group identifier. |
| 229 if (obj.url == "~wl~") | 231 if (obj.url == "~wl~") |
| 230 obj.defaults = "whitelist"; | 232 obj.defaults = "whitelist"; |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 * Minimal Adblock Plus version required for this subscription | 555 * Minimal Adblock Plus version required for this subscription |
| 554 * @type String | 556 * @type String |
| 555 */ | 557 */ |
| 556 requiredVersion: null, | 558 requiredVersion: null, |
| 557 | 559 |
| 558 /** | 560 /** |
| 559 * 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 |
| 560 * @type Boolean | 562 * @type Boolean |
| 561 */ | 563 */ |
| 562 upgradeRequired: false, | 564 upgradeRequired: false, |
| 565 |
| 566 /** |
| 567 * Number indicating how often the object was downloaded. |
| 568 * @type Number |
| 569 */ |
| 570 downloadCount: 0, |
| 563 | 571 |
| 564 /** | 572 /** |
| 565 * See Subscription.serialize() | 573 * See Subscription.serialize() |
| 566 */ | 574 */ |
| 567 serialize: function(buffer) | 575 serialize: function(buffer) |
| 568 { | 576 { |
| 569 RegularSubscription.prototype.serialize.call(this, buffer); | 577 RegularSubscription.prototype.serialize.call(this, buffer); |
| 570 if (this.downloadStatus) | 578 if (this.downloadStatus) |
| 571 buffer.push("downloadStatus=" + this.downloadStatus); | 579 buffer.push("downloadStatus=" + this.downloadStatus); |
| 572 if (this.lastSuccess) | 580 if (this.lastSuccess) |
| 573 buffer.push("lastSuccess=" + this.lastSuccess); | 581 buffer.push("lastSuccess=" + this.lastSuccess); |
| 574 if (this.lastCheck) | 582 if (this.lastCheck) |
| 575 buffer.push("lastCheck=" + this.lastCheck); | 583 buffer.push("lastCheck=" + this.lastCheck); |
| 576 if (this.expires) | 584 if (this.expires) |
| 577 buffer.push("expires=" + this.expires); | 585 buffer.push("expires=" + this.expires); |
| 578 if (this.softExpiration) | 586 if (this.softExpiration) |
| 579 buffer.push("softExpiration=" + this.softExpiration); | 587 buffer.push("softExpiration=" + this.softExpiration); |
| 580 if (this.errors) | 588 if (this.errors) |
| 581 buffer.push("errors=" + this.errors); | 589 buffer.push("errors=" + this.errors); |
| 582 if (this.version) | 590 if (this.version) |
| 583 buffer.push("version=" + this.version); | 591 buffer.push("version=" + this.version); |
| 584 if (this.requiredVersion) | 592 if (this.requiredVersion) |
| 585 buffer.push("requiredVersion=" + this.requiredVersion); | 593 buffer.push("requiredVersion=" + this.requiredVersion); |
| 594 if (this.downloadCount) |
| 595 buffer.push("downloadCount=" + this.downloadCount); |
| 586 } | 596 } |
| 587 }; | 597 }; |
| OLD | NEW |