mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-04 18:17:59 -05:00
Revert "attempt to asynchronously get addon version from AddonManager"
This reverts commit 747ab637d9
.
This commit is contained in:
parent
747ab637d9
commit
c7b23ad718
@ -78,11 +78,12 @@ firetray.Handler = {
|
|||||||
|
|
||||||
this.appStartupTopic = this.getAppStartupTopic(this.appId);
|
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(["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.correctMailServerTypes);
|
VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.correctMailServerTypes);
|
||||||
VersionChange.launch();
|
VersionChange.applyHooksAndWatchUninstall();
|
||||||
|
|
||||||
firetray.StatusIcon.init();
|
firetray.StatusIcon.init();
|
||||||
firetray.Handler.showHideIcon();
|
firetray.Handler.showHideIcon();
|
||||||
|
@ -6,7 +6,8 @@ const Cu = Components.utils;
|
|||||||
|
|
||||||
Cu.import("resource://gre/modules/AddonManager.jsm");
|
Cu.import("resource://gre/modules/AddonManager.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://firetray/commons.js");
|
Cu.import("resource://firetray/logging.jsm");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handles version changes.
|
* handles version changes.
|
||||||
@ -14,21 +15,26 @@ Cu.import("resource://firetray/commons.js");
|
|||||||
*/
|
*/
|
||||||
var VersionChange = {
|
var VersionChange = {
|
||||||
|
|
||||||
initialized: false,
|
initialized: false,
|
||||||
addonId: FIRETRAY_ID,
|
addonId: null,
|
||||||
addonVersion: null,
|
addonVersion: null,
|
||||||
addonPrefs: (function(){return Services.prefs.getBranch(FIRETRAY_PREF_BRANCH);})(),
|
addOnPrefs: null,
|
||||||
|
|
||||||
launch: function() {
|
init: function(id, version, prefBranch) {
|
||||||
AddonManager.getAddonByID(FIRETRAY_ID, this.applyHooksAndWatchUninstall.bind(this));
|
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"]
|
versionComparator: Cc["@mozilla.org/xpcom/version-comparator;1"]
|
||||||
.getService(Ci.nsIVersionComparator),
|
.getService(Ci.nsIVersionComparator),
|
||||||
|
|
||||||
applyHooksAndWatchUninstall: function(addon) {
|
applyHooksAndWatchUninstall: function() {
|
||||||
this.addonVersion = addon.version;
|
if (!this.initialized) throw "VersionChange not initialized";
|
||||||
this.onVersionChange(this.addonVersion);
|
this.onVersionChange(this.addonVersion); // AddonManager.getAddonByID() async, whereas we need sync call
|
||||||
AddonManager.addAddonListener(this.uninstallListener);
|
AddonManager.addAddonListener(this.uninstallListener);
|
||||||
F.LOG("version change watching enabled");
|
F.LOG("version change watching enabled");
|
||||||
},
|
},
|
||||||
@ -38,20 +44,20 @@ var VersionChange = {
|
|||||||
uninstallListener: {
|
uninstallListener: {
|
||||||
onUninstalling: function(addon) {
|
onUninstalling: function(addon) {
|
||||||
if (addon.id !== this.addonId) return;
|
if (addon.id !== this.addonId) return;
|
||||||
this.addonPrefs.clearUserPref("installedVersion");
|
this.addOnPrefs.clearUserPref("installedVersion");
|
||||||
},
|
},
|
||||||
onOperationCancelled: function(addon) {
|
onOperationCancelled: function(addon) {
|
||||||
if (addon.id !== this.addonId) return;
|
if (addon.id !== this.addonId) return;
|
||||||
let beingUninstalled = (addon.pendingOperations & AddonManager.PENDING_UNINSTALL) != 0;
|
let beingUninstalled = (addon.pendingOperations & AddonManager.PENDING_UNINSTALL) != 0;
|
||||||
if (beingUninstalled)
|
if (beingUninstalled)
|
||||||
this.addonPrefs.clearUserPref("installedVersion");
|
this.addOnPrefs.clearUserPref("installedVersion");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onVersionChange: function() {
|
onVersionChange: function() {
|
||||||
F.LOG("VERSION: "+this.addonVersion);
|
F.LOG("VERSION: "+this.addonVersion);
|
||||||
|
|
||||||
var firstrun = this.addonPrefs.getBoolPref("firstrun");
|
var firstrun = this.addOnPrefs.getBoolPref("firstrun");
|
||||||
|
|
||||||
if (firstrun) {
|
if (firstrun) {
|
||||||
F.LOG("FIRST RUN");
|
F.LOG("FIRST RUN");
|
||||||
@ -60,10 +66,10 @@ var VersionChange = {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
var installedVersion = this.addonPrefs.getCharPref("installedVersion");
|
var installedVersion = this.addOnPrefs.getCharPref("installedVersion");
|
||||||
var versionDelta = this.versionComparator.compare(this.addonVersion, installedVersion);
|
var versionDelta = this.versionComparator.compare(this.addonVersion, installedVersion);
|
||||||
if (versionDelta > 0) {
|
if (versionDelta > 0) {
|
||||||
this.addonPrefs.setCharPref("installedVersion", this.addonVersion);
|
this.addOnPrefs.setCharPref("installedVersion", this.addonVersion);
|
||||||
F.LOG("UPGRADE");
|
F.LOG("UPGRADE");
|
||||||
this._applyHooks("upgrade");
|
this._applyHooks("upgrade");
|
||||||
}
|
}
|
||||||
@ -78,8 +84,8 @@ var VersionChange = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
initPrefs: function() {
|
initPrefs: function() {
|
||||||
this.addonPrefs.setBoolPref("firstrun", false);
|
this.addOnPrefs.setBoolPref("firstrun", false);
|
||||||
this.addonPrefs.setCharPref("installedVersion", VersionChange.addonVersion);
|
this.addOnPrefs.setCharPref("installedVersion", VersionChange.addonVersion);
|
||||||
},
|
},
|
||||||
|
|
||||||
_hooks: [], // collection of callbacks {id: 1, categories: [], fun: function}
|
_hooks: [], // collection of callbacks {id: 1, categories: [], fun: function}
|
||||||
|
Loading…
Reference in New Issue
Block a user