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

Side by Side Diff: lib/subscriptionClasses.js

Issue 29824575: Issue 6689 - Add type property to Subscription class (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created July 6, 2018, 2:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/subscriptionClasses.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 Subscription.prototype = 46 Subscription.prototype =
47 { 47 {
48 /** 48 /**
49 * Download location of the subscription 49 * Download location of the subscription
50 * @type {string} 50 * @type {string}
51 */ 51 */
52 url: null, 52 url: null,
53 53
54 /** 54 /**
55 * Type of the subscription
56 * @type {?string}
57 */
58 type: null,
59
60 /**
55 * Filters contained in the filter subscription 61 * Filters contained in the filter subscription
56 * @type {Filter[]} 62 * @type {Filter[]}
57 */ 63 */
58 filters: null, 64 filters: null,
59 65
60 _title: null, 66 _title: null,
61 _fixedTitle: false, 67 _fixedTitle: false,
62 _disabled: false, 68 _disabled: false,
63 69
64 /** 70 /**
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 129
124 /** 130 /**
125 * Serializes the subscription to an array of strings for writing 131 * Serializes the subscription to an array of strings for writing
126 * out on the disk. 132 * out on the disk.
127 * @param {string[]} buffer buffer to push the serialization results into 133 * @param {string[]} buffer buffer to push the serialization results into
128 */ 134 */
129 serialize(buffer) 135 serialize(buffer)
130 { 136 {
131 buffer.push("[Subscription]"); 137 buffer.push("[Subscription]");
132 buffer.push("url=" + this.url); 138 buffer.push("url=" + this.url);
139 if (this.type)
140 buffer.push("type=" + this.type);
133 if (this._title) 141 if (this._title)
134 buffer.push("title=" + this._title); 142 buffer.push("title=" + this._title);
135 if (this._fixedTitle) 143 if (this._fixedTitle)
136 buffer.push("fixedTitle=true"); 144 buffer.push("fixedTitle=true");
137 if (this._disabled) 145 if (this._disabled)
138 buffer.push("disabled=true"); 146 buffer.push("disabled=true");
139 }, 147 },
140 148
141 serializeFilters(buffer) 149 serializeFilters(buffer)
142 { 150 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 * @return {Subscription} 192 * @return {Subscription}
185 * subscription or null if the subscription couldn't be created 193 * subscription or null if the subscription couldn't be created
186 */ 194 */
187 Subscription.fromObject = function(obj) 195 Subscription.fromObject = function(obj)
188 { 196 {
189 let result; 197 let result;
190 if (obj.url[0] != "~") 198 if (obj.url[0] != "~")
191 { 199 {
192 // URL is valid - this is a downloadable subscription 200 // URL is valid - this is a downloadable subscription
193 result = new DownloadableSubscription(obj.url, obj.title); 201 result = new DownloadableSubscription(obj.url, obj.title);
202 if ("type" in obj)
203 result.type = obj.type;
194 if ("downloadStatus" in obj) 204 if ("downloadStatus" in obj)
195 result._downloadStatus = obj.downloadStatus; 205 result._downloadStatus = obj.downloadStatus;
196 if ("lastSuccess" in obj) 206 if ("lastSuccess" in obj)
197 result.lastSuccess = parseInt(obj.lastSuccess, 10) || 0; 207 result.lastSuccess = parseInt(obj.lastSuccess, 10) || 0;
198 if ("lastCheck" in obj) 208 if ("lastCheck" in obj)
199 result._lastCheck = parseInt(obj.lastCheck, 10) || 0; 209 result._lastCheck = parseInt(obj.lastCheck, 10) || 0;
200 if ("expires" in obj) 210 if ("expires" in obj)
201 result.expires = parseInt(obj.expires, 10) || 0; 211 result.expires = parseInt(obj.expires, 10) || 0;
202 if ("softExpiration" in obj) 212 if ("softExpiration" in obj)
203 result.softExpiration = parseInt(obj.softExpiration, 10) || 0; 213 result.softExpiration = parseInt(obj.softExpiration, 10) || 0;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 if (this.errors) 576 if (this.errors)
567 buffer.push("errors=" + this.errors); 577 buffer.push("errors=" + this.errors);
568 if (this.version) 578 if (this.version)
569 buffer.push("version=" + this.version); 579 buffer.push("version=" + this.version);
570 if (this.requiredVersion) 580 if (this.requiredVersion)
571 buffer.push("requiredVersion=" + this.requiredVersion); 581 buffer.push("requiredVersion=" + this.requiredVersion);
572 if (this.downloadCount) 582 if (this.downloadCount)
573 buffer.push("downloadCount=" + this.downloadCount); 583 buffer.push("downloadCount=" + this.downloadCount);
574 } 584 }
575 }); 585 });
OLDNEW
« no previous file with comments | « no previous file | test/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld