| OLD | NEW |
| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 let {Prefs} = require("prefs"); | 24 let {Prefs} = require("prefs"); |
| 25 let {Downloader, Downloadable, MILLIS_IN_MINUTE, MILLIS_IN_HOUR, MILLIS_IN_DAY}
= require("downloader"); | 25 let {Downloader, Downloadable, MILLIS_IN_MINUTE, MILLIS_IN_HOUR, MILLIS_IN_DAY}
= require("downloader"); |
| 26 let {Utils} = require("utils"); | 26 let {Utils} = require("utils"); |
| 27 let {Matcher} = require("matcher"); | 27 let {Matcher} = require("matcher"); |
| 28 let {Filter} = require("filterClasses"); | 28 let {Filter} = require("filterClasses"); |
| 29 | 29 |
| 30 let INITIAL_DELAY = 12 * MILLIS_IN_MINUTE; | 30 let INITIAL_DELAY = 12 * MILLIS_IN_MINUTE; |
| 31 let CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; | 31 let CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; |
| 32 let EXPIRATION_INTERVAL = 1 * MILLIS_IN_DAY; | 32 let EXPIRATION_INTERVAL = 1 * MILLIS_IN_DAY; |
| 33 let STARTUP_SHOW_DELAY = 3 * MILLIS_IN_MINUTE; | |
| 34 let TYPE = { | 33 let TYPE = { |
| 35 information: 0, | 34 information: 0, |
| 36 question: 1, | 35 question: 1, |
| 37 critical: 2 | 36 critical: 2 |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 let showListeners = []; | 39 let showListeners = []; |
| 41 let questionListeners = {}; | 40 let questionListeners = {}; |
| 42 | 41 |
| 43 function getNumericalSeverity(notification) | 42 function getNumericalSeverity(notification) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 /** | 79 /** |
| 81 * Called on module startup. | 80 * Called on module startup. |
| 82 */ | 81 */ |
| 83 init: function() | 82 init: function() |
| 84 { | 83 { |
| 85 downloader = new Downloader(this._getDownloadables.bind(this), INITIAL_DELAY
, CHECK_INTERVAL); | 84 downloader = new Downloader(this._getDownloadables.bind(this), INITIAL_DELAY
, CHECK_INTERVAL); |
| 86 downloader.onExpirationChange = this._onExpirationChange.bind(this); | 85 downloader.onExpirationChange = this._onExpirationChange.bind(this); |
| 87 downloader.onDownloadSuccess = this._onDownloadSuccess.bind(this); | 86 downloader.onDownloadSuccess = this._onDownloadSuccess.bind(this); |
| 88 downloader.onDownloadError = this._onDownloadError.bind(this); | 87 downloader.onDownloadError = this._onDownloadError.bind(this); |
| 89 onShutdown.add(() => downloader.cancel()); | 88 onShutdown.add(() => downloader.cancel()); |
| 90 | |
| 91 notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); | |
| 92 notificationTimer.initWithCallback(Notification.showNext.bind(this), | |
| 93 STARTUP_SHOW_DELAY, | |
| 94 Ci.nsITimer.TYPE_ONE_SHOT); | |
| 95 onShutdown.add(() => notificationTimer.cancel()); | |
| 96 }, | 89 }, |
| 97 | 90 |
| 98 /** | 91 /** |
| 99 * Yields a Downloadable instances for the notifications download. | 92 * Yields a Downloadable instances for the notifications download. |
| 100 */ | 93 */ |
| 101 _getDownloadables: function*() | 94 _getDownloadables: function*() |
| 102 { | 95 { |
| 103 let downloadable = new Downloadable(Prefs.notificationurl); | 96 let downloadable = new Downloadable(Prefs.notificationurl); |
| 104 if (typeof Prefs.notificationdata.lastError === "number") | 97 if (typeof Prefs.notificationdata.lastError === "number") |
| 105 downloadable.lastError = Prefs.notificationdata.lastError; | 98 downloadable.lastError = Prefs.notificationdata.lastError; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 Cu.reportError(e); | 138 Cu.reportError(e); |
| 146 errorCallback("synchronize_invalid_data"); | 139 errorCallback("synchronize_invalid_data"); |
| 147 return; | 140 return; |
| 148 } | 141 } |
| 149 | 142 |
| 150 Prefs.notificationdata.lastError = 0; | 143 Prefs.notificationdata.lastError = 0; |
| 151 Prefs.notificationdata.downloadStatus = "synchronize_ok"; | 144 Prefs.notificationdata.downloadStatus = "synchronize_ok"; |
| 152 [Prefs.notificationdata.softExpiration, Prefs.notificationdata.hardExpiratio
n] = downloader.processExpirationInterval(EXPIRATION_INTERVAL); | 145 [Prefs.notificationdata.softExpiration, Prefs.notificationdata.hardExpiratio
n] = downloader.processExpirationInterval(EXPIRATION_INTERVAL); |
| 153 Prefs.notificationdata.downloadCount = downloadable.downloadCount; | 146 Prefs.notificationdata.downloadCount = downloadable.downloadCount; |
| 154 saveNotificationData(); | 147 saveNotificationData(); |
| 148 |
| 149 Notification.showNext(); |
| 155 }, | 150 }, |
| 156 | 151 |
| 157 _onDownloadError: function(downloadable, downloadURL, error, channelStatus, re
sponseStatus, redirectCallback) | 152 _onDownloadError: function(downloadable, downloadURL, error, channelStatus, re
sponseStatus, redirectCallback) |
| 158 { | 153 { |
| 159 Prefs.notificationdata.lastError = Date.now(); | 154 Prefs.notificationdata.lastError = Date.now(); |
| 160 Prefs.notificationdata.downloadStatus = error; | 155 Prefs.notificationdata.downloadStatus = error; |
| 161 saveNotificationData(); | 156 saveNotificationData(); |
| 162 }, | 157 }, |
| 163 | 158 |
| 164 /** | 159 /** |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 Prefs.notifications_showui = true; | 392 Prefs.notifications_showui = true; |
| 398 } | 393 } |
| 399 else if (index != -1 && forceValue !== true) | 394 else if (index != -1 && forceValue !== true) |
| 400 categories.splice(index, 1); | 395 categories.splice(index, 1); |
| 401 | 396 |
| 402 // HACK: JSON values aren't saved unless they are assigned a different objec
t. | 397 // HACK: JSON values aren't saved unless they are assigned a different objec
t. |
| 403 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories
)); | 398 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories
)); |
| 404 } | 399 } |
| 405 }; | 400 }; |
| 406 Notification.init(); | 401 Notification.init(); |
| OLD | NEW |