mirror of
https://github.com/moparisthebest/FireTray
synced 2024-12-22 13:58:48 -05:00
ignore 'im' server types for now, we'll be handling them later.
This commit is contained in:
parent
c608058971
commit
ee86eeed16
@ -31,4 +31,4 @@ pref("extensions.firetray.folder_count_recursive", true);
|
|||||||
// Ci.nsMsgFolderFlags.Archive|Drafts|Junk|Queue|SentMail|Trash|Virtual
|
// Ci.nsMsgFolderFlags.Archive|Drafts|Junk|Queue|SentMail|Trash|Virtual
|
||||||
pref("extensions.firetray.excluded_folders_flags", 1077956384);
|
pref("extensions.firetray.excluded_folders_flags", 1077956384);
|
||||||
// exposed in 1 tree, hence 2 branches: serverTypes, excludedAccounts
|
// 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
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<Description>
|
<Description>
|
||||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- Firefox -->
|
<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>
|
<em:maxVersion>15.0a1</em:maxVersion>
|
||||||
</Description>
|
</Description>
|
||||||
</em:targetApplication>
|
</em:targetApplication>
|
||||||
@ -26,8 +26,8 @@
|
|||||||
<em:targetApplication> <!-- Thunderbird -->
|
<em:targetApplication> <!-- Thunderbird -->
|
||||||
<Description>
|
<Description>
|
||||||
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
|
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
|
||||||
<em:minVersion>7.0</em:minVersion>
|
<em:minVersion>15.0</em:minVersion>
|
||||||
<em:maxVersion>15.0a1</em:maxVersion>
|
<em:maxVersion>17.0a1</em:maxVersion>
|
||||||
</Description>
|
</Description>
|
||||||
</em:targetApplication>
|
</em:targetApplication>
|
||||||
|
|
||||||
|
@ -36,9 +36,11 @@ firetray.Handler = {
|
|||||||
windows: {},
|
windows: {},
|
||||||
windowsCount: 0,
|
windowsCount: 0,
|
||||||
visibleWindowsCount: 0,
|
visibleWindowsCount: 0,
|
||||||
|
observedTopics: {},
|
||||||
|
|
||||||
appId: (function(){return Services.appinfo.ID;})(),
|
appId: (function(){return Services.appinfo.ID;})(),
|
||||||
appName: (function(){return Services.appinfo.name;})(),
|
appName: (function(){return Services.appinfo.name;})(),
|
||||||
|
appStartupTopic: null,
|
||||||
runtimeABI: (function(){return Services.appinfo.XPCOMABI;})(),
|
runtimeABI: (function(){return Services.appinfo.XPCOMABI;})(),
|
||||||
runtimeOS: (function(){return Services.appinfo.OS;})(), // "WINNT", "Linux", "Darwin"
|
runtimeOS: (function(){return Services.appinfo.OS;})(), // "WINNT", "Linux", "Darwin"
|
||||||
addonRootDir: (function(){
|
addonRootDir: (function(){
|
||||||
@ -74,6 +76,8 @@ firetray.Handler = {
|
|||||||
this.inBrowserApp = true;
|
this.inBrowserApp = true;
|
||||||
F.LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
|
F.LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
|
||||||
|
|
||||||
|
this.appStartupTopic = this.getAppStartupTopic(this.appId);
|
||||||
|
|
||||||
this.FILENAME_BLANK = firetray.Utils.chromeToPath(
|
this.FILENAME_BLANK = firetray.Utils.chromeToPath(
|
||||||
"chrome://firetray/skin/blank-icon.png");
|
"chrome://firetray/skin/blank-icon.png");
|
||||||
|
|
||||||
@ -81,7 +85,6 @@ firetray.Handler = {
|
|||||||
VersionChange.addHook(["install", "upgrade", "reinstall"], firetray.VersionChangeHandler.showReleaseNotes);
|
VersionChange.addHook(["install", "upgrade", "reinstall"], firetray.VersionChangeHandler.showReleaseNotes);
|
||||||
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.tryEraseOldOptions);
|
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.tryEraseOldOptions);
|
||||||
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.correctMailNotificationType);
|
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.correctMailNotificationType);
|
||||||
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.addIMServerTypePrefMaybe);
|
|
||||||
VersionChange.applyHooksAndWatchUninstall();
|
VersionChange.applyHooksAndWatchUninstall();
|
||||||
|
|
||||||
firetray.StatusIcon.init();
|
firetray.StatusIcon.init();
|
||||||
@ -101,9 +104,8 @@ firetray.Handler = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Services.obs.addObserver(this, this.getAppStartupTopic(this.appId), false);
|
firetray.Utils.addObservers(firetray.Handler, [ this.appStartupTopic,
|
||||||
Services.obs.addObserver(this, "xpcom-will-shutdown", false);
|
"xpcom-will-shutdown", "profile-change-teardown" ]);
|
||||||
Services.obs.addObserver(this, "profile-change-teardown", false);
|
|
||||||
|
|
||||||
this.preventWarnOnClose();
|
this.preventWarnOnClose();
|
||||||
|
|
||||||
@ -120,9 +122,7 @@ firetray.Handler = {
|
|||||||
firetray.Window.shutdown();
|
firetray.Window.shutdown();
|
||||||
// watchout order and sufficiency of lib closings (tryCloseLibs())
|
// watchout order and sufficiency of lib closings (tryCloseLibs())
|
||||||
|
|
||||||
Services.obs.removeObserver(this, this.getAppStartupTopic(this.appId), false);
|
firetray.Utils.removeAllObservers(this);
|
||||||
Services.obs.removeObserver(this, "xpcom-will-shutdown", false);
|
|
||||||
Services.obs.removeObserver(this, "profile-change-teardown", false);
|
|
||||||
|
|
||||||
this.appStarted = false;
|
this.appStarted = false;
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
@ -134,6 +134,7 @@ firetray.Handler = {
|
|||||||
case "sessionstore-windows-restored":
|
case "sessionstore-windows-restored":
|
||||||
case "mail-startup-done":
|
case "mail-startup-done":
|
||||||
case "final-ui-startup":
|
case "final-ui-startup":
|
||||||
|
firetray.Utils.addObservers(firetray.Handler, [this.appStartupTopic]);
|
||||||
F.LOG("RECEIVED: "+topic+", launching timer");
|
F.LOG("RECEIVED: "+topic+", launching timer");
|
||||||
// sessionstore-windows-restored does not come after the realization of
|
// sessionstore-windows-restored does not come after the realization of
|
||||||
// all windows... so we wait a little
|
// all windows... so we wait a little
|
||||||
@ -420,19 +421,6 @@ firetray.VersionChangeHandler = {
|
|||||||
FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
|
FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
|
||||||
F.WARN("mail notification type set to 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.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
60
src/modules/FiretrayInstantMessaging.jsm
Normal file
60
src/modules/FiretrayInstantMessaging.jsm
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
@ -9,6 +9,7 @@ const Cu = Components.utils;
|
|||||||
Cu.import("resource:///modules/mailServices.js");
|
Cu.import("resource:///modules/mailServices.js");
|
||||||
Cu.import("resource://gre/modules/PluralForm.jsm");
|
Cu.import("resource://gre/modules/PluralForm.jsm");
|
||||||
Cu.import("resource://firetray/commons.js");
|
Cu.import("resource://firetray/commons.js");
|
||||||
|
Cu.import("resource://firetray/FiretrayInstantMessaging.jsm");
|
||||||
|
|
||||||
const FLDRS_UNINTERESTING = {
|
const FLDRS_UNINTERESTING = {
|
||||||
Archive: Ci.nsMsgFolderFlags.Archive,
|
Archive: Ci.nsMsgFolderFlags.Archive,
|
||||||
@ -43,6 +44,9 @@ firetray.Messaging = {
|
|||||||
MailServices.mailSession.AddFolderListener(that.mailSessionListener,
|
MailServices.mailSession.AddFolderListener(that.mailSessionListener,
|
||||||
that.mailSessionListener.notificationFlags);
|
that.mailSessionListener.notificationFlags);
|
||||||
|
|
||||||
|
if (Services.prefs.getBoolPref("mail.chat.enabled"))
|
||||||
|
firetray.InstantMessaging.init();
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -50,11 +54,11 @@ firetray.Messaging = {
|
|||||||
if (!this.initialized) return;
|
if (!this.initialized) return;
|
||||||
F.LOG("Disabling Messaging");
|
F.LOG("Disabling Messaging");
|
||||||
|
|
||||||
this.cleaningTimer.cancel();
|
|
||||||
|
|
||||||
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
|
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
|
||||||
firetray.Handler.setIconImageDefault();
|
firetray.Handler.setIconImageDefault();
|
||||||
|
|
||||||
|
this.cleaningTimer.cancel();
|
||||||
|
|
||||||
this.initialized = false;
|
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 */
|
/* http://mxr.mozilla.org/comm-central/source/mailnews/base/public/nsIFolderListener.idl */
|
||||||
mailSessionListener: {
|
mailSessionListener: {
|
||||||
notificationFlags:
|
notificationFlags:
|
||||||
@ -233,6 +239,7 @@ firetray.Messaging = {
|
|||||||
try {
|
try {
|
||||||
let accounts = new this.Accounts();
|
let accounts = new this.Accounts();
|
||||||
for (let accountServer in 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));
|
F.LOG("is servertype excluded: "+serverTypes[accountServer.type].excluded+", account exclusion index: "+excludedAccounts.indexOf(accountServer.key));
|
||||||
if (serverTypes[accountServer.type].excluded ||
|
if (serverTypes[accountServer.type].excluded ||
|
||||||
(excludedAccounts.indexOf(accountServer.key) >= 0))
|
(excludedAccounts.indexOf(accountServer.key) >= 0))
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
|
||||||
/* for now, logging facilities (imported from logging.jsm) are automatically
|
/* for now, logging facilities (imported from logging.jsm) and Services are
|
||||||
provided by this module */
|
automatically provided by this module */
|
||||||
var EXPORTED_SYMBOLS =
|
var EXPORTED_SYMBOLS =
|
||||||
[ "firetray", "F", "FIRETRAY_ID", "FIRETRAY_VERSION", "FIRETRAY_PREF_BRANCH",
|
[ "firetray", "F", "Services", "FIRETRAY_ID", "FIRETRAY_VERSION",
|
||||||
"FIRETRAY_SPLASH_PAGE", "FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
|
"FIRETRAY_PREF_BRANCH", "FIRETRAY_SPLASH_PAGE",
|
||||||
|
"FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
|
||||||
"FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM",
|
"FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM",
|
||||||
"FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT",
|
"FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT",
|
||||||
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
|
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
|
||||||
@ -62,6 +63,27 @@ firetray.Utils = {
|
|||||||
prefService: Services.prefs.getBranch(FIRETRAY_PREF_BRANCH),
|
prefService: Services.prefs.getBranch(FIRETRAY_PREF_BRANCH),
|
||||||
strings: Services.strings.createBundle("chrome://firetray/locale/overlay.properties"),
|
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) {
|
getObjPref: function(prefStr) {
|
||||||
try {
|
try {
|
||||||
var objPref = JSON.parse(
|
var objPref = JSON.parse(
|
||||||
|
Loading…
Reference in New Issue
Block a user