diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index 430c0b8..2063186 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -86,13 +86,6 @@ firetray.Handler = { log.info('inMailApp='+this.inMailApp+', inBrowserApp='+this.inBrowserApp+ ', appHasChat='+this.appHasChat); - VersionChange.init(FIRETRAY_ID, FIRETRAY_VERSION, FIRETRAY_PREF_BRANCH); - VersionChange.addHook(["install", "upgrade", "reinstall"], firetray.VersionChangeHandler.showReleaseNotes); - VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.tryEraseOldOptions); - VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.correctMailNotificationType); - VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.correctMailServerTypes); - VersionChange.applyHooksAndWatchUninstall(); - firetray.Window.init(); firetray.StatusIcon.init(); firetray.Handler.showHideIcon(); @@ -142,6 +135,17 @@ firetray.Handler = { this.preventWarnOnClose(); + VersionChange.init(FIRETRAY_ID, FIRETRAY_VERSION, FIRETRAY_PREF_BRANCH); + let vc = VersionChange, vch = firetray.VersionChangeHandler; + vc.addHook(["install", "upgrade", "reinstall"], vch.showReleaseNotes); + vc.addHook(["upgrade", "reinstall"], vch.tryEraseOldOptions); + vc.addHook(["upgrade", "reinstall"], vch.correctMailNotificationType); + vc.addHook(["upgrade", "reinstall"], vch.correctMailServerTypes); + if (this.inMailApp) { + vc.addHook(["upgrade", "reinstall"], firetray.Messaging.cleanExcludedAccounts); + } + vc.applyHooksAndWatchUninstall(); + this.initialized = true; return true; }, diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm index d58945b..f340674 100644 --- a/src/modules/FiretrayMessaging.jsm +++ b/src/modules/FiretrayMessaging.jsm @@ -7,6 +7,7 @@ const Ci = Components.interfaces; const Cu = Components.utils; Cu.import("resource:///modules/mailServices.js"); +Cu.import("resource://gre/modules/iteratorUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/PluralForm.jsm"); Cu.import("resource://firetray/commons.js"); @@ -29,7 +30,6 @@ firetray.Messaging = { initialized: false, currentMsgCount: null, newMsgCount: null, - observedTopics: {}, init: function() { if (this.initialized) { @@ -38,7 +38,9 @@ firetray.Messaging = { } log.debug("Enabling Messaging"); - firetray.Utils.addObservers(firetray.Messaging, ["account-removed"]); + // includes IM accounts + Services.prefs.addObserver("mail.accountmanager.accounts", + firetray.Messaging.cleanExcludedAccounts, false); let that = this; MailServices.mailSession.AddFolderListener(that.mailSessionListener, @@ -53,35 +55,23 @@ firetray.Messaging = { MailServices.mailSession.RemoveFolderListener(this.mailSessionListener); - firetray.Utils.removeAllObservers(firetray.Messaging); + Services.prefs.removeObserver("mail.accountmanager.accounts", this); this.initialized = false; }, - observe: function(subject, topic, data) { - log.debug("RECEIVED Messaging: "+topic+" subject="+subject+" data="+data); - switch (topic) { - case "account-removed": - this.cleanExcludedAccounts(); - break; - default: - log.warn("unhandled topic: "+topic); - } - }, - /* removes removed accounts from excludedAccounts pref. NOTE: Can't be called at shutdown because MailServices.accounts no longer available */ cleanExcludedAccounts: function() { - log.debug("* cleaning *"); + log.info("* 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