mirror of
https://github.com/moparisthebest/FireTray
synced 2024-08-13 15:53:47 -04:00
add 'im' to mail server types and have VersionChange hooks applied synchronously
This forces us to hard code the addon version :(
This commit is contained in:
parent
d8448f421b
commit
c608058971
@ -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}}, "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}, "im":{"order":6,"excluded":true}}, "excludedAccounts": [] }'); // JSON
|
||||
|
@ -5,7 +5,7 @@
|
||||
<em:unpack>true</em:unpack> <!-- needed for embedded icons -->
|
||||
<em:type>2</em:type>
|
||||
<em:name>FireTray</em:name>
|
||||
<em:version>0.4.2</em:version>
|
||||
<em:version>0.4.2</em:version> <!-- change FIRETRAY_VERSION accordingly ! -->
|
||||
<em:creator>Hua Luo, Francesco Solero, Foudil BRÉTEL</em:creator>
|
||||
<em:contributor>Hua Luo, Francesco Solero (Firetray original authors)</em:contributor>
|
||||
<em:homepageURL>https://github.com/foudfou/firetray</em:homepageURL>
|
||||
|
@ -27,10 +27,7 @@ if ("undefined" == typeof(firetray)) {
|
||||
// other global functions
|
||||
// (https://developer.mozilla.org/en/XUL_School/JavaScript_Object_Management)
|
||||
firetray.Handler = {
|
||||
FILENAME_DEFAULT: null,
|
||||
FILENAME_SUFFIX: "32.png",
|
||||
FILENAME_BLANK: null,
|
||||
FILENAME_NEWMAIL: null,
|
||||
|
||||
initialized: false,
|
||||
inMailApp: false,
|
||||
@ -77,12 +74,15 @@ firetray.Handler = {
|
||||
this.inBrowserApp = true;
|
||||
F.LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
|
||||
|
||||
this.FILENAME_DEFAULT = firetray.Utils.chromeToPath(
|
||||
"chrome://firetray/skin/" + this.appName.toLowerCase() + this.FILENAME_SUFFIX);
|
||||
this.FILENAME_BLANK = firetray.Utils.chromeToPath(
|
||||
"chrome://firetray/skin/blank-icon.png");
|
||||
this.FILENAME_NEWMAIL = firetray.Utils.chromeToPath(
|
||||
"chrome://firetray/skin/message-mail-new.png");
|
||||
|
||||
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.addIMServerTypePrefMaybe);
|
||||
VersionChange.applyHooksAndWatchUninstall();
|
||||
|
||||
firetray.StatusIcon.init();
|
||||
firetray.Handler.showHideIcon();
|
||||
@ -105,11 +105,6 @@ firetray.Handler = {
|
||||
Services.obs.addObserver(this, "xpcom-will-shutdown", false);
|
||||
Services.obs.addObserver(this, "profile-change-teardown", false);
|
||||
|
||||
VersionChange.addHook(["install", "upgrade", "reinstall"], firetray.VersionChangeHandler.showReleaseNotes);
|
||||
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.tryEraseOldOptions);
|
||||
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.correctMailNotificationType);
|
||||
VersionChange.watch();
|
||||
|
||||
this.preventWarnOnClose();
|
||||
|
||||
this.initialized = true;
|
||||
@ -348,10 +343,10 @@ firetray.PrefListener = new PrefListener(
|
||||
|
||||
firetray.VersionChangeHandler = {
|
||||
|
||||
showReleaseNotes: function(ver) {
|
||||
firetray.Handler.openTab(FIRETRAY_SPLASH_PAGE+"#v"+ver);
|
||||
firetray.Handler.tryEraseOldOptions();
|
||||
firetray.Handler.correctMailNotificationType();
|
||||
showReleaseNotes: function() {
|
||||
firetray.VersionChangeHandler.openTab(FIRETRAY_SPLASH_PAGE+"#v"+FIRETRAY_VERSION);
|
||||
firetray.VersionChangeHandler.tryEraseOldOptions();
|
||||
firetray.VersionChangeHandler.correctMailNotificationType();
|
||||
},
|
||||
|
||||
openTab: function(url) {
|
||||
@ -412,16 +407,32 @@ firetray.VersionChangeHandler = {
|
||||
|
||||
for (let i = 0, length = oldOptions.length; i<length; ++i) {
|
||||
try {
|
||||
firetray.Utils.prefService.clearUserPref(oldOptions[i]);
|
||||
let option = oldOptions[i];
|
||||
firetray.Utils.prefService.clearUserPref(option);
|
||||
} catch (x) {}
|
||||
}
|
||||
},
|
||||
|
||||
correctMailNotificationType: function() {
|
||||
if (firetray.Utils.prefService.getIntPref('message_count_type') ===
|
||||
FIRETRAY_MESSAGE_COUNT_TYPE_NEW)
|
||||
FIRETRAY_MESSAGE_COUNT_TYPE_NEW) {
|
||||
firetray.Utils.prefService.setIntPref('mail_notification_type',
|
||||
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.");
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -234,8 +234,8 @@ firetray.Messaging = {
|
||||
let accounts = new this.Accounts();
|
||||
for (let accountServer in accounts) {
|
||||
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) )
|
||||
if (serverTypes[accountServer.type].excluded ||
|
||||
(excludedAccounts.indexOf(accountServer.key) >= 0))
|
||||
continue;
|
||||
|
||||
let rootFolder = accountServer.rootFolder; // nsIMsgFolder
|
||||
|
@ -5,7 +5,8 @@ const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/AddonManager.jsm");
|
||||
Cu.import("resource://firetray/commons.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://firetray/logging.jsm");
|
||||
|
||||
|
||||
/**
|
||||
@ -14,14 +15,27 @@ Cu.import("resource://firetray/commons.js");
|
||||
*/
|
||||
var VersionChange = {
|
||||
|
||||
curVersion: null,
|
||||
initialized: false,
|
||||
addonId: null,
|
||||
addonVersion: null,
|
||||
addOnPrefs: null,
|
||||
|
||||
init: function(id, version, prefBranch) {
|
||||
F.LOG("VersionChange got: id="+id+" ver="+version+" prefBranch="+prefBranch);
|
||||
this.addOnId = id;
|
||||
this.addonVersion = version;
|
||||
this.addOnPrefs = Services.prefs.getBranch(prefBranch);
|
||||
|
||||
this.initialized = true;
|
||||
},
|
||||
|
||||
versionComparator: Cc["@mozilla.org/xpcom/version-comparator;1"]
|
||||
.getService(Ci.nsIVersionComparator),
|
||||
|
||||
watch: function() {
|
||||
applyHooksAndWatchUninstall: function() {
|
||||
if (!this.initialized) throw "VersionChange not initialized";
|
||||
this.onVersionChange(this.addonVersion); // AddonManager.getAddonByID() async, whereas we need sync call
|
||||
AddonManager.addAddonListener(this.uninstallListener);
|
||||
AddonManager.getAddonByID(FIRETRAY_ID, this.onVersionChange.bind(this));
|
||||
F.LOG("version change watching enabled");
|
||||
},
|
||||
|
||||
@ -29,22 +43,21 @@ var VersionChange = {
|
||||
// detect reinstall later
|
||||
uninstallListener: {
|
||||
onUninstalling: function(addon) {
|
||||
if (addon.id !== FIRETRAY_ID) return;
|
||||
firetray.Utils.prefService.clearUserPref("installedVersion");
|
||||
if (addon.id !== this.addonId) return;
|
||||
this.addOnPrefs.clearUserPref("installedVersion");
|
||||
},
|
||||
onOperationCancelled: function(addon) {
|
||||
if (addon.id !== FIRETRAY_ID) return;
|
||||
if (addon.id !== this.addonId) return;
|
||||
let beingUninstalled = (addon.pendingOperations & AddonManager.PENDING_UNINSTALL) != 0;
|
||||
if (beingUninstalled)
|
||||
firetray.Utils.prefService.clearUserPref("installedVersion");
|
||||
this.addOnPrefs.clearUserPref("installedVersion");
|
||||
}
|
||||
},
|
||||
|
||||
onVersionChange: function(addon) {
|
||||
F.LOG("VERSION: "+addon.version);
|
||||
onVersionChange: function() {
|
||||
F.LOG("VERSION: "+this.addonVersion);
|
||||
|
||||
this.curVersion = addon.version;
|
||||
var firstrun = firetray.Utils.prefService.getBoolPref("firstrun");
|
||||
var firstrun = this.addOnPrefs.getBoolPref("firstrun");
|
||||
|
||||
if (firstrun) {
|
||||
F.LOG("FIRST RUN");
|
||||
@ -53,10 +66,10 @@ var VersionChange = {
|
||||
|
||||
} else {
|
||||
try {
|
||||
var installedVersion = firetray.Utils.prefService.getCharPref("installedVersion");
|
||||
var versionDelta = this.versionComparator.compare(this.curVersion, installedVersion);
|
||||
var installedVersion = this.addOnPrefs.getCharPref("installedVersion");
|
||||
var versionDelta = this.versionComparator.compare(this.addonVersion, installedVersion);
|
||||
if (versionDelta > 0) {
|
||||
firetray.Utils.prefService.setCharPref("installedVersion", this.curVersion);
|
||||
this.addOnPrefs.setCharPref("installedVersion", this.addonVersion);
|
||||
F.LOG("UPGRADE");
|
||||
this._applyHooks("upgrade");
|
||||
}
|
||||
@ -67,17 +80,18 @@ var VersionChange = {
|
||||
this._applyHooks("reinstall");
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
initPrefs: function() {
|
||||
firetray.Utils.prefService.setBoolPref("firstrun", false);
|
||||
firetray.Utils.prefService.setCharPref("installedVersion", VersionChange.curVersion);
|
||||
this.addOnPrefs.setBoolPref("firstrun", false);
|
||||
this.addOnPrefs.setCharPref("installedVersion", VersionChange.addonVersion);
|
||||
},
|
||||
|
||||
_hooks: [], // collection of callbacks {id: 1, categories: [], fun: function}
|
||||
_hooks: [], // collection of callbacks {id: 1, categories: [], fun: function}
|
||||
|
||||
addHook: function(categories, fun) {
|
||||
if (!firetray.js.isArray(categories)) throw new CategoryError();
|
||||
if (Object.prototype.toString.call(categories) !== "[object Array]") throw new TypeError();
|
||||
let id = this._hooks.push({})-1;
|
||||
this._hooks[id] = {id: id, categories: categories, fun: fun};
|
||||
return id;
|
||||
@ -89,10 +103,14 @@ var VersionChange = {
|
||||
},
|
||||
|
||||
_applyHooks: function(category) {
|
||||
for (let i=0,len=this._hooks.length; i<len; ++i) {
|
||||
let cb = this._hooks[i];
|
||||
if (cb.categories.indexOf(category)) cb.fun(this.curVersion);
|
||||
}
|
||||
try {
|
||||
F.LOG("_hooks.len="+this._hooks.length+" category="+category);
|
||||
for (let i=0,len=this._hooks.length; i<len; ++i) {
|
||||
let cb = this._hooks[i];
|
||||
if (cb.categories.indexOf(category) > -1) cb.fun();
|
||||
else F.LOG("cb id="+cb.id+" not in category: "+cb.categories+"\n"+cb.fun);
|
||||
}
|
||||
} catch(x){F.ERROR(x);}
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -3,8 +3,8 @@
|
||||
/* for now, logging facilities (imported from logging.jsm) are automatically
|
||||
provided by this module */
|
||||
var EXPORTED_SYMBOLS =
|
||||
[ "firetray", "F", "FIRETRAY_ID", "FIRETRAY_SPLASH_PAGE",
|
||||
"FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
|
||||
[ "firetray", "F", "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",
|
||||
@ -20,11 +20,16 @@ const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://firetray/logging.jsm");
|
||||
|
||||
const FIRETRAY_VERSION = "0.4.2"; // needed for sync call of onVersionChange() :(
|
||||
const FIRETRAY_PREF_BRANCH = "extensions.firetray.";
|
||||
const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
|
||||
const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
|
||||
|
||||
const FIRETRAY_APPLICATION_ICON_TYPE_THEMED = 0;
|
||||
const FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM = 1;
|
||||
const FIRETRAY_APPLICATION_ICON_TYPE_THEMED = 0;
|
||||
const FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM = 1;
|
||||
|
||||
const FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD = 0;
|
||||
const FIRETRAY_MESSAGE_COUNT_TYPE_NEW = 1;
|
||||
|
||||
const FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT = 0;
|
||||
const FIRETRAY_NOTIFICATION_NEWMAIL_ICON = 1;
|
||||
@ -34,9 +39,6 @@ const FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS = 500;
|
||||
const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0;
|
||||
const FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS = 15*60*1000;
|
||||
|
||||
const FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD = 0;
|
||||
const FIRETRAY_MESSAGE_COUNT_TYPE_NEW = 1;
|
||||
|
||||
if ("undefined" == typeof(F)) {
|
||||
var F = {}; // helper wrapper
|
||||
};
|
||||
@ -57,7 +59,7 @@ if ("undefined" == typeof(firetray)) {
|
||||
};
|
||||
|
||||
firetray.Utils = {
|
||||
prefService: Services.prefs.getBranch("extensions.firetray."),
|
||||
prefService: Services.prefs.getBranch(FIRETRAY_PREF_BRANCH),
|
||||
strings: Services.strings.createBundle("chrome://firetray/locale/overlay.properties"),
|
||||
|
||||
getObjPref: function(prefStr) {
|
||||
@ -70,7 +72,7 @@ firetray.Utils = {
|
||||
return objPref;
|
||||
},
|
||||
setObjPref: function(prefStr, obj) {
|
||||
F.LOG(obj);
|
||||
F.LOG("setObjPref: "+obj);
|
||||
try {
|
||||
firetray.Utils.prefService.setCharPref(prefStr, JSON.stringify(obj));
|
||||
} catch (x) {
|
||||
|
Loading…
Reference in New Issue
Block a user