I have the following code snippet to enable the extension after exiting Firefox,
observe: function (subject, topic, data) { if (topic == "quit-application") { LOG("inside quit-application Testing "); var os = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); //os.addObserver(this, "http-on-examine-cached-response", false); os.addObserver(this, "quit-application", false); var appInfo = Components.classes["@mozilla.org/xre/app-info;1"] .getService(Components.interfaces.nsIXULAppInfo); var tempappVersion = appInfo.version; var appVersion = tempappVersion.split("."); // adding add-on listener dsable event on add-on for FF4 and later versions. if (appVersion[0] >= 4) { setAddonEnableListener(); LOG("\napp-startup Testing from javascript file...."); } return; } }
And inside setAddonEnableListener I am trying to enable the extension as follows:
function setAddonEnableListener() { try { alert("setAddonEnableListener akbar nsListener called from "); Components.utils.import("resource://gre/modules/AddonManager.jsm"); AddonManager.getAddonByID(" somename@extension.com ", function(addon) { if (addon.userDisabled) addon.userDisabled = false; }); } catch (ex) { } }
And I am logging the quit-application var event as follows:
myModule = { registerSelf: function (compMgr, fileSpec, location, type) { var compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar); compMgr.registerFactoryLocation(this.myCID, this.myName, this.myProgID, fileSpec, location, type); var catMgr = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager); catMgr.addCategoryEntry("app-startup", this.myName, this.myProgID, true, true); catMgr.addCategoryEntry("quit-application", this.myName, this.myProgID, true, true); }
When Firefox shuts down, the inside quit-application Testing message is not displayed. What am I doing wrong here?