[Pkg-mozext-commits] [firetray] 251/399: cleaning

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:53 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 8c362f89f2a9e5ce9cf22c1fd6fae7bd4f656b3a
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Fri May 25 08:04:18 2012 +0200

    cleaning
---
 src/chrome/content/options.js     |    4 ++--
 src/modules/FiretrayHandler.jsm   |    6 +++---
 src/modules/FiretrayMessaging.jsm |   39 +++++++++++++++++--------------------
 3 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index b655b8c..96402cd 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -352,7 +352,7 @@ var firetrayUIOptions = {
     firetray.Utils.prefService.setIntPref("excluded_folders_flags",
                                           excludedFoldersFlags);
 
-    firetray.Messaging.updateMsgCount();
+    firetray.Messaging.updateMsgCountWithCb();
   },
 
   /**
@@ -395,7 +395,7 @@ var firetrayUIOptions = {
     document.getElementById("pane1")
       .userChangedValue(document.getElementById("ui_tree_mail_accounts"));
 
-    firetray.Messaging.updateMsgCount();
+    firetray.Messaging.updateMsgCountWithCb();
   },
 
   _userChangeValueTreeServerTypes: function(event) {
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 5dbb3fe..e339c38 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -86,7 +86,7 @@ firetray.Handler = {
         Cu.import("resource://firetray/FiretrayMessaging.jsm");
         if (firetray.Utils.prefService.getBoolPref("mail_notification_enabled")) {
           firetray.Messaging.init();
-          firetray.Messaging.updateMsgCount();
+          firetray.Messaging.updateMsgCountWithCb();
         }
       } catch (x) {
         F.ERROR(x);
@@ -396,7 +396,7 @@ firetray.PrefListener = new PrefListener(
       firetray.StatusIcon.loadThemedIcons();
     case 'message_count_type':
     case 'folder_count_recursive':
-      firetray.Messaging.updateMsgCount();
+      firetray.Messaging.updateMsgCountWithCb();
       break;
     case 'app_mail_icon_names':
     case 'app_browser_icon_names':
@@ -404,7 +404,7 @@ firetray.PrefListener = new PrefListener(
       firetray.StatusIcon.loadThemedIcons();
     case 'app_icon_type':
       if (firetray.Handler.inMailApp)
-        firetray.Messaging.updateMsgCount();
+        firetray.Messaging.updateMsgCountWithCb();
       else
         firetray.Handler.setIconImageDefault();
       break;
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 82bc4b0..c362a39 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -47,8 +47,7 @@ firetray.Messaging = {
   },
 
   shutdown: function() {
-    if (!this.initialized)
-      return;
+    if (!this.initialized) return;
     F.LOG("Disabling Messaging");
 
     this.cleaningTimer.cancel();
@@ -105,12 +104,12 @@ firetray.Messaging = {
 
     OnItemIntPropertyChanged: function(item, property, oldValue, newValue) { // TotalUnreadMessages, BiffState (per server)
       F.LOG("OnItemIntPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
-      this.updateMsgCount(item, property, oldValue, newValue);
+      this.onMsgCountChange(item, property, oldValue, newValue);
     },
 
     OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) { // NewMessages (per folder)
       F.LOG("OnItemBoolPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
-      this.updateMsgCount(item, property, oldValue, newValue);
+      this.onMsgCountChange(item, property, oldValue, newValue);
     },
 
     OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {
@@ -121,7 +120,7 @@ firetray.Messaging = {
       F.LOG("OnItemEvent"+event+" for folder "+item.prettyName);
     },
 
-    updateMsgCount: function(item, property, oldValue, newValue) {
+    onMsgCountChange: function(item, property, oldValue, newValue) {
       let excludedFoldersFlags = firetray.Utils.prefService.getIntPref("excluded_folders_flags");
       let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
 
@@ -129,27 +128,32 @@ firetray.Messaging = {
         let prop = property.toString();
         if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD &&
             prop === "TotalUnreadMessages") {
-          firetray.Messaging.updateMsgCount();
+          firetray.Messaging.updateMsgCountWithCb();
         } else if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW &&
                    prop === "NewMessages") {
           if (oldValue === true && newValue === false)
             item.setNumNewMessages(0); // https://bugzilla.mozilla.org/show_bug.cgi?id=727460
-          firetray.Messaging.updateMsgCount();
+          firetray.Messaging.updateMsgCountWithCb();
         }
       }
     }
   },
 
   /**
-   * computes and display new msg count
+   * @param callback: optional callback to call when msgCount changed.
    */
-  updateMsgCount: function() {
-    F.LOG("updateMsgCount");
+  updateMsgCountWithCb: function(callback) {
+    F.LOG("updateMsgCountWithCb");
+    if (!this.initialized) return;
 
-    if (!this.initialized)
-      return;
+    if ("undefined" === typeof(callback) || !callback) callback = function() { // default
+      firetray.Messaging.updateIcon(msgCount);
+
+      let mailChangeTriggerFile = firetray.Utils.prefService.getCharPref("mail_change_trigger");
+      if (mailChangeTriggerFile)
+        firetray.Messaging.runProcess(mailChangeTriggerFile, [msgCount.toString()]);
+    };
 
-    // initialize
     let msgCount;
     let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
     F.LOG("msgCountType="+msgCountType);
@@ -161,15 +165,8 @@ firetray.Messaging = {
       F.ERROR('unknown message count type');
 
     if (msgCount !== this.currentMsgCount) {
-
-      this.updateIcon(msgCount);
-
-      let mailChangeTriggerFile = firetray.Utils.prefService.getCharPref("mail_change_trigger");
-      if (mailChangeTriggerFile)
-        this.runProcess(mailChangeTriggerFile, [msgCount.toString()]);
-
+      callback.call(this);
       this.currentMsgCount = msgCount;
-
     } else {
       F.LOG("message count unchanged");
     }

-- 
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