[Pkg-mozext-commits] [firetray] 267/399: ignore 'im' server types for now, we'll be handling them later.

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:56 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 ee86eeed1644cf9cf2f7d18950273a77beffc87e
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Fri Aug 3 23:52:29 2012 +0200

    ignore 'im' server types for now, we'll be handling them later.
---
 src/defaults/preferences/prefs.js        |    2 +-
 src/install.rdf                          |    6 +--
 src/modules/FiretrayHandler.jsm          |   28 ++++----------
 src/modules/FiretrayInstantMessaging.jsm |   60 ++++++++++++++++++++++++++++++
 src/modules/FiretrayMessaging.jsm        |   11 +++++-
 src/modules/commons.js                   |   30 +++++++++++++--
 6 files changed, 107 insertions(+), 30 deletions(-)

diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index 89e27b5..e02085b 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -31,4 +31,4 @@ pref("extensions.firetray.folder_count_recursive", true);
 // Ci.nsMsgFolderFlags.Archive|Drafts|Junk|Queue|SentMail|Trash|Virtual
 pref("extensions.firetray.excluded_folders_flags", 1077956384);
 // exposed in 1 tree, hence 2 branches: serverTypes, excludedAccounts
-pref("extensions.firetray.mail_accounts", '{ "serverTypes": {"pop3":{"order":1,"excluded":false}, "imap":{"order":1,"excluded":false}, "movemail":{"order":2,"excluded":true}, "none":{"order":3,"excluded":false}, "rss":{"order":4,"excluded":true}, "nntp":{"order":5,"excluded":true}, "im":{"order":6,"excluded":true}}, "excludedAccounts": [] }'); // JSON
+pref("extensions.firetray.mail_accounts", '{ "serverTypes": {"pop3":{"order":1,"excluded":false}, "imap":{"order":1,"excluded":false}, "movemail":{"order":2,"excluded":true}, "none":{"order":3,"excluded":false}, "rss":{"order":4,"excluded":true}, "nntp":{"order":5,"excluded":true}}, "excludedAccounts": [] }'); // JSON
diff --git a/src/install.rdf b/src/install.rdf
index b8f9633..32cb77d 100644
--- a/src/install.rdf
+++ b/src/install.rdf
@@ -18,7 +18,7 @@
     <em:targetApplication>
       <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- Firefox -->
-        <em:minVersion>7.0</em:minVersion>
+        <em:minVersion>13.0</em:minVersion>
         <em:maxVersion>15.0a1</em:maxVersion>
       </Description>
     </em:targetApplication>
@@ -26,8 +26,8 @@
     <em:targetApplication>      <!-- Thunderbird -->
       <Description>
         <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
-        <em:minVersion>7.0</em:minVersion>
-        <em:maxVersion>15.0a1</em:maxVersion>
+        <em:minVersion>15.0</em:minVersion>
+        <em:maxVersion>17.0a1</em:maxVersion>
       </Description>
     </em:targetApplication>
 
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 806318e..d89cec8 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -36,9 +36,11 @@ firetray.Handler = {
   windows: {},
   windowsCount: 0,
   visibleWindowsCount: 0,
+  observedTopics: {},
 
   appId:      (function(){return Services.appinfo.ID;})(),
   appName:    (function(){return Services.appinfo.name;})(),
+  appStartupTopic: null,
   runtimeABI: (function(){return Services.appinfo.XPCOMABI;})(),
   runtimeOS:  (function(){return Services.appinfo.OS;})(), // "WINNT", "Linux", "Darwin"
   addonRootDir: (function(){
@@ -74,6 +76,8 @@ firetray.Handler = {
       this.inBrowserApp = true;
     F.LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
 
+    this.appStartupTopic = this.getAppStartupTopic(this.appId);
+
     this.FILENAME_BLANK = firetray.Utils.chromeToPath(
       "chrome://firetray/skin/blank-icon.png");
 
@@ -81,7 +85,6 @@ firetray.Handler = {
     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.addIMServerTypePrefMaybe);
     VersionChange.applyHooksAndWatchUninstall();
 
     firetray.StatusIcon.init();
@@ -101,9 +104,8 @@ firetray.Handler = {
       }
     }
 
-    Services.obs.addObserver(this, this.getAppStartupTopic(this.appId), false);
-    Services.obs.addObserver(this, "xpcom-will-shutdown", false);
-    Services.obs.addObserver(this, "profile-change-teardown", false);
+    firetray.Utils.addObservers(firetray.Handler, [ this.appStartupTopic,
+      "xpcom-will-shutdown", "profile-change-teardown" ]);
 
     this.preventWarnOnClose();
 
@@ -120,9 +122,7 @@ firetray.Handler = {
     firetray.Window.shutdown();
     // watchout order and sufficiency of lib closings (tryCloseLibs())
 
-    Services.obs.removeObserver(this, this.getAppStartupTopic(this.appId), false);
-    Services.obs.removeObserver(this, "xpcom-will-shutdown", false);
-    Services.obs.removeObserver(this, "profile-change-teardown", false);
+    firetray.Utils.removeAllObservers(this);
 
     this.appStarted = false;
     this.initialized = false;
@@ -134,6 +134,7 @@ firetray.Handler = {
     case "sessionstore-windows-restored":
     case "mail-startup-done":
     case "final-ui-startup":
+      firetray.Utils.addObservers(firetray.Handler, [this.appStartupTopic]);
       F.LOG("RECEIVED: "+topic+", launching timer");
       // sessionstore-windows-restored does not come after the realization of
       // all windows... so we wait a little
@@ -420,19 +421,6 @@ firetray.VersionChangeHandler = {
         FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
       F.WARN("mail notification type set to newmail icon.");
     }
-  },
-
-  addIMServerTypePrefMaybe: function() {
-    let mailAccounts = firetray.Utils.getObjPref('mail_accounts');
-    let serverTypes = mailAccounts["serverTypes"];
-
-    if (!serverTypes["im"])
-      serverTypes["im"] = {"order":6,"excluded":true};
-
-    let prefObj = {"serverTypes":serverTypes, "excludedAccounts":mailAccounts["excludedAccounts"]};
-    firetray.Utils.setObjPref('mail_accounts', prefObj);
-
-    F.WARN("server type 'im' added to prefs.");
   }
 
 };
diff --git a/src/modules/FiretrayInstantMessaging.jsm b/src/modules/FiretrayInstantMessaging.jsm
new file mode 100644
index 0000000..c2edb12
--- /dev/null
+++ b/src/modules/FiretrayInstantMessaging.jsm
@@ -0,0 +1,60 @@
+/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+var EXPORTED_SYMBOLS = [ "firetray", "FLDRS_UNINTERESTING" ];
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://firetray/commons.js");
+
+firetray.InstantMessaging = {
+  initialized: false,
+  observedTopics: {},
+
+  init: function() {
+    if (this.initialized) {
+      F.WARN("InstantMessaging already initialized");
+      return;
+    }
+    F.LOG("Enabling InstantMessaging");
+
+    firetray.Utils.addObservers(firetray.InstantMessaging, [ // "*" for debugging
+      "idle-time-changed", "new-directed-incoming-message", "new-text",
+      "new-ui-conversation", "status-changed", "unread-im-count-changed",
+      "visited-status-resolution"
+    ]);
+
+    this.initialized = true;
+  },
+
+  shutdown: function() {
+    if (!this.initialized) return;
+    F.LOG("Disabling InstantMessaging");
+
+    Services.obs.removeAllObservers(firetray.InstantMessaging);
+
+    this.initialized = false;
+  },
+
+  observe: function(subject, topic, data) {
+    F.WARN("RECEIVED InstantMessaging:");
+    switch (topic) {
+    case "unread-im-count-changed":
+      F.WARN("received unread-im-count-changed: "+subject+" "+data);
+      break;
+    case "new-directed-incoming-message": // when PM or cited in channel: new-directed-incoming-message: [xpconnect wrapped (nsISupports, nsIClassInfo, prplIMessage)] null
+      F.WARN("new-directed-incoming-message: "+subject+" "+data);
+      break;
+    case "visited-status-resolution":
+      F.WARN("visited-status-resolution: "+subject+" "+data);
+      break;
+    case "status-changed":
+    case "idle-time-changed":
+      break;
+    default:
+      F.WARN("unhandled topic: "+topic);
+    }
+  }
+
+};
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 66dcf0e..dfd7acf 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -9,6 +9,7 @@ const Cu = Components.utils;
 Cu.import("resource:///modules/mailServices.js");
 Cu.import("resource://gre/modules/PluralForm.jsm");
 Cu.import("resource://firetray/commons.js");
+Cu.import("resource://firetray/FiretrayInstantMessaging.jsm");
 
 const FLDRS_UNINTERESTING = {
   Archive:   Ci.nsMsgFolderFlags.Archive,
@@ -43,6 +44,9 @@ firetray.Messaging = {
     MailServices.mailSession.AddFolderListener(that.mailSessionListener,
                                                that.mailSessionListener.notificationFlags);
 
+    if (Services.prefs.getBoolPref("mail.chat.enabled"))
+      firetray.InstantMessaging.init();
+
     this.initialized = true;
   },
 
@@ -50,11 +54,11 @@ firetray.Messaging = {
     if (!this.initialized) return;
     F.LOG("Disabling Messaging");
 
-    this.cleaningTimer.cancel();
-
     MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
     firetray.Handler.setIconImageDefault();
 
+    this.cleaningTimer.cancel();
+
     this.initialized = false;
   },
 
@@ -89,6 +93,8 @@ firetray.Messaging = {
     }
   },
 
+  // https://bugzilla.mozilla.org/show_bug.cgi?id=715799 for TB15+
+  // mozINewMailNotificationService (alternative message counting)
   /* http://mxr.mozilla.org/comm-central/source/mailnews/base/public/nsIFolderListener.idl */
   mailSessionListener: {
     notificationFlags:
@@ -233,6 +239,7 @@ firetray.Messaging = {
     try {
       let accounts = new this.Accounts();
       for (let accountServer in accounts) {
+        if (accountServer.type === 'im') continue; // IM messages are counted elsewhere
         F.LOG("is servertype excluded: "+serverTypes[accountServer.type].excluded+", account exclusion index: "+excludedAccounts.indexOf(accountServer.key));
         if (serverTypes[accountServer.type].excluded ||
             (excludedAccounts.indexOf(accountServer.key) >= 0))
diff --git a/src/modules/commons.js b/src/modules/commons.js
index ac64ed6..6e32c04 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -1,10 +1,11 @@
 /* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
-/* for now, logging facilities (imported from logging.jsm) are automatically
-   provided by this module */
+/* for now, logging facilities (imported from logging.jsm) and Services are
+   automatically provided by this module */
 var EXPORTED_SYMBOLS =
-  [ "firetray", "F", "FIRETRAY_ID", "FIRETRAY_VERSION", "FIRETRAY_PREF_BRANCH",
-    "FIRETRAY_SPLASH_PAGE", "FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
+  [ "firetray", "F", "Services", "FIRETRAY_ID", "FIRETRAY_VERSION",
+    "FIRETRAY_PREF_BRANCH", "FIRETRAY_SPLASH_PAGE",
+    "FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
     "FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM",
     "FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT",
     "FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
@@ -62,6 +63,27 @@ firetray.Utils = {
   prefService: Services.prefs.getBranch(FIRETRAY_PREF_BRANCH),
   strings: Services.strings.createBundle("chrome://firetray/locale/overlay.properties"),
 
+  addObservers: function(handler, topics){
+    topics.forEach(function(topic){
+      Services.obs.addObserver(this, topic, false);
+      this.observedTopics[topic] = true;
+      F.LOG("registred "+topic+" for "+handler);
+    }, handler);
+  },
+
+  removeObservers: function(handler, topics) {
+    topics.forEach(function(topic){
+      Services.obs.removeObserver(this, topic);
+      delete this.observedTopics[topic];
+    }, handler);
+  },
+
+  removeAllObservers: function(handler) {
+    for (let topic in handler.observedTopics)
+      Services.obs.removeObserver(handler, topic);
+    handler.observedTopics = {};
+  },
+
   getObjPref: function(prefStr) {
     try {
       var objPref = JSON.parse(

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