From 22de1d3fcc435a0e19a1707422909acc56966367 Mon Sep 17 00:00:00 2001 From: foudfou Date: Fri, 7 Sep 2012 15:06:01 +0200 Subject: [PATCH] * fix Makefile for including .svg into xpi * minor fixes --- src/Makefile | 3 ++- src/modules/FiretrayChat.jsm | 31 +++++++++++++++++++++------- src/modules/FiretrayHandler.jsm | 16 +++++++------- src/modules/FiretrayMessaging.jsm | 1 + src/modules/linux/FiretrayWindow.jsm | 5 ++--- src/modules/logging.jsm | 4 +++- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/Makefile b/src/Makefile index 908f59b..df4378d 100755 --- a/src/Makefile +++ b/src/Makefile @@ -76,8 +76,9 @@ chrome_sources := $(chrome_sources_js) \ $(wildcard $(chrome_source_root)/content/*.xml) \ $(wildcard $(chrome_source_root)/content/*.css) \ $(wildcard $(chrome_source_root)/skin/*.css) \ - $(wildcard $(chrome_source_root)/skin/*.png) \ $(wildcard $(chrome_source_root)/skin/*.gif) \ + $(wildcard $(chrome_source_root)/skin/*.png) \ + $(wildcard $(chrome_source_root)/skin/*.svg) \ $(wildcard $(chrome_source_root)/skin/linux/icons/hicolor/22x22/apps/*.png) \ $(wildcard $(chrome_source_root)/skin/linux/icons/hicolor/32x32/apps/*.png) \ $(wildcard $(chrome_source_root)/locale/*/*.dtd) \ diff --git a/src/modules/FiretrayChat.jsm b/src/modules/FiretrayChat.jsm index 33c7e00..c3d5361 100644 --- a/src/modules/FiretrayChat.jsm +++ b/src/modules/FiretrayChat.jsm @@ -30,6 +30,7 @@ firetray.Chat = { "new-directed-incoming-message", "status-changed", "unread-im-count-changed" ]); + firetray.ChatStatusIcon.init(); this.updateIcon(); @@ -156,15 +157,29 @@ firetray.Chat = { }, globalConnectedStatus: function() { - let accounts = Services.accounts.getAccounts(); - let globalConnected = false; - while (accounts.hasMoreElements()) { - let account = accounts.getNext().QueryInterface(Ci.imIAccount); - log.debug("account="+account+" STATUS="+account.statusInfo.statusType+" connected="+account.connected); - globalConnected = globalConnected || account.connected; + /* Because we may already be connected during init (for ex. when toggling + the chat_icon_enable pref), we need to updateIcon() during init(). But IM + accounts' list is not initialized at early stage... */ + try { + + let accounts = Services.accounts.getAccounts(); + let globalConnected = false; + + while (accounts.hasMoreElements()) { + let account = accounts.getNext().QueryInterface(Ci.imIAccount); + log.debug("account="+account+" STATUS="+account.statusInfo.statusType+" connected="+account.connected); + globalConnected = globalConnected || account.connected; + } + log.debug("globalConnected="+globalConnected); + return globalConnected; + + } catch (e if e instanceof Components.Exception && + e.result === Components.results.NS_ERROR_XPC_JS_THREW_JS_OBJECT && + /_items is undefined/.test(e.message)) { + return false; // ignore + } catch(e) { + log.error(e); return false; } - log.debug("globalConnected="+globalConnected); - return globalConnected; } }; diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index 80f9b6e..8f4f41b 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -81,8 +81,6 @@ firetray.Handler = { this.appHasChat = true; log.info('inMailApp='+this.inMailApp+', inBrowserApp='+this.inBrowserApp+', appHasChat='+this.appHasChat); - this.appStartupTopic = this.getAppStartupTopic(this.appId); - VersionChange.init(FIRETRAY_ID, FIRETRAY_VERSION, FIRETRAY_PREF_BRANCH); VersionChange.addHook(["install", "upgrade", "reinstall"], firetray.VersionChangeHandler.showReleaseNotes); VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.tryEraseOldOptions); @@ -110,14 +108,14 @@ firetray.Handler = { if (this.appHasChat && Services.prefs.getBoolPref("mail.chat.enabled") && firetray.Utils.prefService.getBoolPref("chat_icon_enable")) { Cu.import("resource://firetray/FiretrayMessaging.jsm"); // needed for existsChatAccount - if (this.existsChatAccount()) { - Cu.import("resource://firetray/FiretrayChat.jsm"); + Cu.import("resource://firetray/FiretrayChat.jsm"); + firetray.Utils.addObservers(firetray.Handler, [ + "account-added", "account-removed"]); + if (this.existsChatAccount()) firetray.Chat.init(); - firetray.Utils.addObservers(firetray.Handler, [ - "account-added", "account-removed"]); - } } + this.appStartupTopic = this.getAppStartupTopic(this.appId); firetray.Utils.addObservers(firetray.Handler, [ this.appStartupTopic, "xpcom-will-shutdown", "profile-change-teardown" ]); @@ -165,7 +163,7 @@ firetray.Handler = { }, // FIXME: this should definetely be done in Chat, but IM accounts - // seem not be initialized at this stage (Exception... "'TypeError: + // seem not be initialized at early stage (Exception... "'TypeError: // this._items is undefined' when calling method: // [nsISimpleEnumerator::hasMoreElements]"), and we're unsure if we should // initAccounts() ourselves... @@ -197,7 +195,7 @@ firetray.Handler = { log.debug("xpcom-will-shutdown"); this.shutdown(); break; - case "profile-change-teardown": + case "profile-change-teardown": // also found "quit-application-granted" if (data === 'shutdown-persist') this.restoreWarnOnClose(); break; diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm index 108824f..0b64ac1 100644 --- a/src/modules/FiretrayMessaging.jsm +++ b/src/modules/FiretrayMessaging.jsm @@ -64,6 +64,7 @@ firetray.Messaging = { switch (topic) { case "account-removed": this.cleanExcludedAccounts(); + break; default: log.warn("unhandled topic: "+topic); } diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm index a892fb7..b8e1d98 100644 --- a/src/modules/linux/FiretrayWindow.jsm +++ b/src/modules/linux/FiretrayWindow.jsm @@ -196,8 +196,7 @@ firetray.Window = { getXIDFromChromeWindow: function(win) { for (let xid in firetray.Handler.windows) - if (firetray.Handler.windows[xid].chromeWin === win) - return xid; + if (firetray.Handler.windows[xid].chromeWin === win) return xid; log.error("unknown window while lookup"); return null; }, @@ -547,7 +546,7 @@ firetray.Window = { /** debug facility */ firetray.Handler.dumpWindows = function() { log.debug(firetray.Handler.windowsCount); - for (let winId in firetray.Handler.windows) log.debug(winId+"="+firetray.Handler.gtkWindows.get(winId)); + for (let winId in firetray.Handler.windows) log.info(winId+"="+firetray.Handler.gtkWindows.get(winId)); }; firetray.Handler.getWindowIdFromChromeWindow = firetray.Window.getXIDFromChromeWindow; diff --git a/src/modules/logging.jsm b/src/modules/logging.jsm index b54b46e..28ce0d1 100644 --- a/src/modules/logging.jsm +++ b/src/modules/logging.jsm @@ -2,6 +2,8 @@ var EXPORTED_SYMBOLS = [ "firetray" ]; +const FIRETRAY_LOG_LEVEL = "All"; // "All" for debugging + const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; @@ -137,7 +139,7 @@ firetray.Logging = { // Loggers are hierarchical, affiliation is handled by a '.' in the name. this._logger = Log4Moz.repository.getLogger(loggerName); // Lowering this log level will affect all of our addon output - this._logger.level = Log4Moz.Level["All"]; + this._logger.level = Log4Moz.Level[FIRETRAY_LOG_LEVEL]; // A console appender outputs to the JS Error Console let dateFormat = "%T";