[Pkg-mozext-commits] [firetray] 214/399: periodically clean prefs by removing removed accounts from excludedAccounts
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:23:45 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch dfsg-clean
in repository firetray.
commit 756367230cd6c20fa3f28c96019c9869ad45a2dc
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Tue Mar 20 22:06:19 2012 +0100
periodically clean prefs by removing removed accounts from excludedAccounts
---
src/modules/FiretrayMessaging.jsm | 47 +++++++++++++++++++++++++++++++++----
src/modules/commons.js | 3 +++
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 2728eae..b2928a6 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -23,14 +23,20 @@ const FLDRS_UNINTERESTING = {
firetray.Messaging = {
initialized: false,
+ cleaningTimer: null,
init: function() {
if (this.initialized) {
- firetray.WARN("Messaging already initialized");
+ firetray.LOG("Messaging already initialized");
return;
}
firetray.LOG("Enabling Messaging");
+ // there is no means to detect account-removed event
+ this.cleaningTimer = firetray.Utils.timer(firetray.Messaging.cleanExcludedAccounts,
+ FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS, Ci.nsITimer.TYPE_REPEATING_SLACK);
+ firetray.WARN(this.cleaningTimer+"="+FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS);
+
let that = this;
MailServices.mailSession.AddFolderListener(that.mailSessionListener,
that.mailSessionListener.notificationFlags);
@@ -43,15 +49,48 @@ firetray.Messaging = {
return;
firetray.LOG("Disabling Messaging");
+ this.cleaningTimer.cancel();
+
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
firetray.Handler.setIconImageDefault();
this.initialized = false;
},
- /**
- * http://mxr.mozilla.org/comm-central/source/mailnews/base/public/nsIFolderListener.idl
- */
+ /* removes removed accounts from excludedAccounts pref. NOTE: Can't be called
+ at shutdown because MailServices.accounts no longer available */
+ cleanExcludedAccounts: function() {
+ try {
+ firetray.LOG("* cleaning *");
+ let mailAccounts = firetray.Utils.getObjPref('mail_accounts');
+ let excludedAccounts = mailAccounts["excludedAccounts"];
+
+ // build current list of account server keys
+ let accounts = MailServices.accounts.accounts;
+ let accountServerKeys = [];
+ for (let i=0, len=accounts.Count(); i<len; ++i) {
+ let account = accounts.QueryElementAt(i, Ci.nsIMsgAccount);
+ let accountServer = account.incomingServer;
+ accountServerKeys[i] = accountServer;
+ }
+
+ let newExcludedAccounts = [], cleaningNeeded = 0;
+ for (let excludedAccount in excludedAccounts) {
+ if (accountServerKeys.indexOf(excludedAccount) >= 0)
+ newExcludedAccounts.push(excludedAccount);
+ else
+ cleaningNeeded += 1;
+ }
+
+ if (cleaningNeeded) {
+ firetray.LOG("cleaning excluded accounts");
+ let prefObj = {"serverTypes":mailAccounts["serverTypes"], "excludedAccounts":newExcludedAccounts};
+ firetray.Utils.setObjPref('mail_accounts', prefObj);
+ }
+ } catch(x) { firetray.ERROR(x); }
+ },
+
+ /* http://mxr.mozilla.org/comm-central/source/mailnews/base/public/nsIFolderListener.idl */
mailSessionListener: {
notificationFlags:
// Ci.nsIFolderListener.propertyChanged |
diff --git a/src/modules/commons.js b/src/modules/commons.js
index d45ace7..9230421 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -8,6 +8,7 @@ var EXPORTED_SYMBOLS =
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
"FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS",
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS", "FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD",
+ "FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS",
"FIRETRAY_MESSAGE_COUNT_TYPE_NEW" ];
const Cc = Components.classes;
@@ -26,6 +27,7 @@ const FIRETRAY_NOTIFICATION_CUSTOM_ICON = 3;
const FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS = 500;
const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0;
+const FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS = 15*60*1000;
const FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD = 0;
const FIRETRAY_MESSAGE_COUNT_TYPE_NEW = 1;
@@ -174,6 +176,7 @@ firetray.Utils = {
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.initWithCallback({ notify: callback },
delay, timerType);
+ return timer;
},
tryCloseLibs: function(libs) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git
More information about the Pkg-mozext-commits
mailing list