const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+const BOOTSTRAP_JSM = "resource://dactyl/bootstrap.jsm";
+
const BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
JSMLoader = JSMLoader || BOOTSTRAP_CONTRACT in Cc && Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
.getService(Components.interfaces.extIApplication)
.storage.get("dactyl.JSMLoader", null);
-
function reportError(e) {
dump("\ndactyl: bootstrap: " + e + "\n" + (e.stack || Error().stack) + "\n");
Cu.reportError(e);
let chars = "0123456789abcdefghijklmnopqrstuv";
for (let n = Date.now(); n; n = Math.round(n / chars.length))
suffix += chars[n % chars.length];
- suffix = "";
for each (let line in manifest.split("\n")) {
let fields = line.split(/\s+/);
break;
case "resource":
+ var hardSuffix = /^[^\/]*/.exec(fields[2])[0];
+
resources.push(fields[1], fields[1] + suffix);
resourceProto.setSubstitution(fields[1], getURI(fields[2]));
resourceProto.setSubstitution(fields[1] + suffix, getURI(fields[2]));
}
}
+ // Flush the cache if necessary, just to be paranoid
+ let pref = "extensions.dactyl.cacheFlushCheck";
+ let val = addon.version + "-" + hardSuffix;
+ if (!Services.prefs.prefHasUserValue(pref) || Services.prefs.getCharPref(pref) != val) {
+ Services.obs.notifyObservers(null, "startupcache-invalidate", "");
+ Services.prefs.setCharPref(pref, val);
+ }
+
try {
module("resource://dactyl-content/disable-acr.jsm").init(addon.id);
}
reportError(e);
}
- if (JSMLoader && JSMLoader.bump !== 4) // Temporary hack
- Services.scriptloader.loadSubScript("resource://dactyl" + suffix + "/bootstrap.jsm",
- Cu.import("resource://dactyl/bootstrap.jsm", global));
+ if (JSMLoader) {
+ if (Cu.unload) {
+ Cu.unload(BOOTSTRAP_JSM);
+ for (let [name] in Iterator(JSMLoader.globals))
+ Cu.unload(~name.indexOf(":") ? name : "resource://dactyl" + JSMLoader.suffix + "/" + name);
+ }
+ else if (JSMLoader.bump != 5) // Temporary hack
+ Services.scriptloader.loadSubScript("resource://dactyl" + suffix + "/bootstrap.jsm",
+ Cu.import(BOOTSTRAP_JSM, global));
+ }
- if (!JSMLoader || JSMLoader.bump !== 4)
- Cu.import("resource://dactyl/bootstrap.jsm", global);
+ if (!JSMLoader || JSMLoader.bump !== 5 || Cu.unload)
+ Cu.import(BOOTSTRAP_JSM, global);
JSMLoader.bootstrap = this;
- JSMLoader.load("resource://dactyl/bootstrap.jsm", global);
+ JSMLoader.load(BOOTSTRAP_JSM, global);
JSMLoader.init(suffix);
JSMLoader.load("base.jsm", global);
wrappedJSObject: {}
},
createInstance: function () this.instance
- })
+ });
- Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader = JSMLoader;
+ Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader = !Cu.unload && JSMLoader;
for each (let component in components)
component.register();
reportError(e);
}
- if ([ADDON_UPGRADE, ADDON_DOWNGRADE, ADDON_UNINSTALL].indexOf(reason) >= 0)
+ if (~[ADDON_UPGRADE, ADDON_DOWNGRADE, ADDON_UNINSTALL].indexOf(reason))
Services.obs.notifyObservers(null, "dactyl-purge", null);
- Services.obs.notifyObservers(null, "dactyl-cleanup", null);
- Services.obs.notifyObservers(null, "dactyl-cleanup-modules", null);
+ Services.obs.notifyObservers(null, "dactyl-cleanup", reasonToString(reason));
+ Services.obs.notifyObservers(null, "dactyl-cleanup-modules", reasonToString(reason));
JSMLoader.purge();
for each (let [category, entry] in categories)