mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 08:27:59 +01:00
Do away with services.(get|create), and move the prefs module to its own file.
This commit is contained in:
@@ -61,7 +61,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
if (bmark.url == uri.spec) {
|
||||
var id = bmark.id;
|
||||
if (title)
|
||||
services.get("bookmarks").setItemTitle(id, title);
|
||||
services.bookmarks.setItemTitle(id, title);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ const Bookmarks = Module("bookmarks", {
|
||||
PlacesUtils.tagging.tagURI(uri, tags);
|
||||
}
|
||||
if (id == undefined)
|
||||
id = services.get("bookmarks").insertBookmark(
|
||||
services.get("bookmarks")[unfiled ? "unfiledBookmarksFolder" : "bookmarksMenuFolder"],
|
||||
id = services.bookmarks.insertBookmark(
|
||||
services.bookmarks[unfiled ? "unfiledBookmarksFolder" : "bookmarksMenuFolder"],
|
||||
uri, -1, title || url);
|
||||
if (!id)
|
||||
return false;
|
||||
@@ -79,7 +79,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
if (post !== undefined)
|
||||
PlacesUtils.setPostDataForBookmark(id, post);
|
||||
if (keyword)
|
||||
services.get("bookmarks").setKeywordForBookmark(id, keyword);
|
||||
services.bookmarks.setKeywordForBookmark(id, keyword);
|
||||
}
|
||||
catch (e) {
|
||||
dactyl.log(e, 0);
|
||||
@@ -141,7 +141,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
*/
|
||||
isBookmarked: function isBookmarked(url) {
|
||||
try {
|
||||
return services.get("bookmarks")
|
||||
return services.bookmarks
|
||||
.getBookmarkIdsForURI(makeURI(url), {})
|
||||
.some(bookmarkcache.closure.isRegularBookmark);
|
||||
}
|
||||
@@ -163,7 +163,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
try {
|
||||
if (!isArray(ids)) {
|
||||
let uri = util.newURI(ids);
|
||||
ids = services.get("bookmarks")
|
||||
ids = services.bookmarks
|
||||
.getBookmarkIdsForURI(uri, {})
|
||||
.filter(bookmarkcache.closure.isRegularBookmark);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
let bmark = bookmarkcache.bookmarks[id];
|
||||
if (bmark)
|
||||
PlacesUtils.tagging.untagURI(util.newURI(bmark.url), null);
|
||||
services.get("bookmarks").removeItem(id);
|
||||
services.bookmarks.removeItem(id);
|
||||
});
|
||||
return ids.length;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
get searchEngines() {
|
||||
let searchEngines = [];
|
||||
let aliases = {};
|
||||
return services.get("browserSearch").getVisibleEngines({}).map(function (engine) {
|
||||
return services.browserSearch.getVisibleEngines({}).map(function (engine) {
|
||||
let alias = engine.alias;
|
||||
if (!alias || !/^[a-z_-]+$/.test(alias))
|
||||
alias = engine.name.replace(/^\W*([a-zA-Z_-]+).*/, "$1").toLowerCase();
|
||||
@@ -290,7 +290,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
param = url.substr(offset + 1);
|
||||
}
|
||||
|
||||
var engine = services.get("browserSearch").getEngineByAlias(keyword);
|
||||
var engine = services.browserSearch.getEngineByAlias(keyword);
|
||||
if (engine) {
|
||||
var submission = engine.getSubmission(param, null);
|
||||
return [submission.uri.spec, submission.postData];
|
||||
@@ -308,7 +308,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
[, shortcutURL, charset] = matches;
|
||||
else {
|
||||
try {
|
||||
charset = services.get("history").getCharsetForURI(window.makeURI(shortcutURL));
|
||||
charset = services.history.getCharsetForURI(window.makeURI(shortcutURL));
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
@@ -499,7 +499,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
commandline.input("This will delete all bookmarks. Would you like to continue? (yes/[no]) ",
|
||||
function (resp) {
|
||||
if (resp && resp.match(/^y(es)?$/i)) {
|
||||
Object.keys(bookmarkcache.bookmarks).forEach(function (id) { services.get("bookmarks").removeItem(id); });
|
||||
Object.keys(bookmarkcache.bookmarks).forEach(function (id) { services.bookmarks.removeItem(id); });
|
||||
dactyl.echomsg("All bookmarks deleted", 1, commandline.FORCE_SINGLELINE);
|
||||
}
|
||||
});
|
||||
@@ -632,7 +632,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
};
|
||||
|
||||
completion.searchEngine = function searchEngine(context, suggest) {
|
||||
let engines = services.get("browserSearch").getEngines({});
|
||||
let engines = services.browserSearch.getEngines({});
|
||||
if (suggest)
|
||||
engines = engines.filter(function (e) e.supportsResponseType("application/x-suggestions+json"));
|
||||
|
||||
@@ -647,7 +647,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
let engineList = (engineAliases || options["suggestengines"].join(",") || "google").split(",");
|
||||
|
||||
engineList.forEach(function (name) {
|
||||
let engine = services.get("browserSearch").getEngineByAlias(name);
|
||||
let engine = services.browserSearch.getEngineByAlias(name);
|
||||
if (!engine)
|
||||
return;
|
||||
let [, word] = /^\s*(\S+)/.exec(context.filter) || [];
|
||||
|
||||
@@ -89,7 +89,7 @@ const Buffer = Module("buffer", {
|
||||
|
||||
for (let proto in array.iterValues(["HTTP", "FTP"])) {
|
||||
try {
|
||||
var cacheEntryDescriptor = services.get("cache").createSession(proto, 0, true)
|
||||
var cacheEntryDescriptor = services.cache.createSession(proto, 0, true)
|
||||
.openCacheEntry(cacheKey, ACCESS_READ, false);
|
||||
break;
|
||||
}
|
||||
@@ -977,7 +977,7 @@ const Buffer = Module("buffer", {
|
||||
|
||||
if (!isString(doc))
|
||||
return io.withTempFiles(function (temp) {
|
||||
let encoder = services.create("htmlEncoder");
|
||||
let encoder = services.HtmlEncoder();
|
||||
encoder.init(doc, "text/unicode", encoder.OutputRaw|encoder.OutputPreformatted);
|
||||
temp.write(encoder.encodeToString(), ">");
|
||||
this.callback(temp);
|
||||
|
||||
@@ -666,8 +666,8 @@ const CommandLine = Module("commandline", {
|
||||
}
|
||||
|
||||
if ((flags & this.ACTIVE_WINDOW) &&
|
||||
window != services.get("windowWatcher").activeWindow &&
|
||||
services.get("windowWatcher").activeWindow.dactyl)
|
||||
window != services.windowWatcher.activeWindow &&
|
||||
services.windowWatcher.activeWindow.dactyl)
|
||||
return;
|
||||
|
||||
if ((flags & this.DISALLOW_MULTILINE) && !this.widgets.mowContainer.collapsed)
|
||||
|
||||
@@ -12,10 +12,10 @@ const ConfigBase = Class(ModuleBase, {
|
||||
* initialization code. Must call superclass's init function.
|
||||
*/
|
||||
init: function () {
|
||||
this.name = services.get("dactyl:").name;
|
||||
this.idName = services.get("dactyl:").idName;
|
||||
this.appName = services.get("dactyl:").appName;
|
||||
this.host = services.get("dactyl:").host;
|
||||
this.name = services["dactyl:"].name;
|
||||
this.idName = services["dactyl:"].idName;
|
||||
this.appName = services["dactyl:"].appName;
|
||||
this.host = services["dactyl:"].host;
|
||||
|
||||
highlight.styleableChrome = this.styleableChrome;
|
||||
highlight.loadCSS(this.CSS);
|
||||
|
||||
@@ -53,10 +53,11 @@
|
||||
let prefix = [BASE];
|
||||
|
||||
modules.load("services");
|
||||
prefix.unshift("chrome://" + modules.services.get("dactyl:").name + "/content/");
|
||||
prefix.unshift("chrome://" + modules.services["dactyl:"].name + "/content/");
|
||||
|
||||
["base",
|
||||
"modules",
|
||||
"prefs",
|
||||
"storage",
|
||||
"util",
|
||||
"dactyl",
|
||||
|
||||
@@ -52,14 +52,14 @@ const Dactyl = Module("dactyl", {
|
||||
|
||||
/** @property {string} The name of the current user profile. */
|
||||
profileName: Class.memoize(function () {
|
||||
// NOTE: services.get("profile").selectedProfile.name doesn't return
|
||||
// NOTE: services.profile.selectedProfile.name doesn't return
|
||||
// what you might expect. It returns the last _actively_ selected
|
||||
// profile (i.e. via the Profile Manager or -P option) rather than the
|
||||
// current profile. These will differ if the current process was run
|
||||
// without explicitly selecting a profile.
|
||||
|
||||
let dir = services.get("directory").get("ProfD", Ci.nsIFile);
|
||||
for (let prof in iter(services.get("profile").profiles))
|
||||
let dir = services.directory.get("ProfD", Ci.nsIFile);
|
||||
for (let prof in iter(services.profile.profiles))
|
||||
if (prof.QueryInterface(Ci.nsIToolkitProfile).localDir.path === dir.path)
|
||||
return prof.name;
|
||||
return "unknown";
|
||||
@@ -297,7 +297,7 @@ const Dactyl = Module("dactyl", {
|
||||
* should be loaded.
|
||||
*/
|
||||
loadScript: function (uri, context) {
|
||||
services.get("subscriptLoader").loadSubScript(uri, context, File.defaultEncoding);
|
||||
services.subscriptLoader.loadSubScript(uri, context, File.defaultEncoding);
|
||||
},
|
||||
|
||||
userEval: function (str, context, fileName, lineNumber) {
|
||||
@@ -359,7 +359,7 @@ const Dactyl = Module("dactyl", {
|
||||
* element.
|
||||
*/
|
||||
focusContent: function (clearFocusedElement) {
|
||||
if (window != services.get("windowWatcher").activeWindow)
|
||||
if (window != services.windowWatcher.activeWindow)
|
||||
return;
|
||||
|
||||
let win = document.commandDispatcher.focusedWindow;
|
||||
@@ -412,7 +412,7 @@ const Dactyl = Module("dactyl", {
|
||||
* @returns {string}
|
||||
*/
|
||||
findHelp: function (topic, unchunked) {
|
||||
if (!unchunked && topic in services.get("dactyl:").FILE_MAP)
|
||||
if (!unchunked && topic in services["dactyl:"].FILE_MAP)
|
||||
return topic;
|
||||
unchunked = !!unchunked;
|
||||
let items = completion._runCompleter("help", topic, null, unchunked).items;
|
||||
@@ -444,11 +444,11 @@ const Dactyl = Module("dactyl", {
|
||||
}
|
||||
|
||||
let namespaces = [config.name, "dactyl"];
|
||||
services.get("dactyl:").init({});
|
||||
services["dactyl:"].init({});
|
||||
|
||||
let tagMap = services.get("dactyl:").HELP_TAGS;
|
||||
let fileMap = services.get("dactyl:").FILE_MAP;
|
||||
let overlayMap = services.get("dactyl:").OVERLAY_MAP;
|
||||
let tagMap = services["dactyl:"].HELP_TAGS;
|
||||
let fileMap = services["dactyl:"].FILE_MAP;
|
||||
let overlayMap = services["dactyl:"].OVERLAY_MAP;
|
||||
|
||||
// Find help and overlay files with the given name.
|
||||
function findHelpFile(file) {
|
||||
@@ -544,11 +544,11 @@ const Dactyl = Module("dactyl", {
|
||||
const TIME = Date.now();
|
||||
|
||||
dactyl.initHelp();
|
||||
let zip = services.create("zipWriter");
|
||||
let zip = services.ZipWriter();
|
||||
zip.open(FILE, File.MODE_CREATE | File.MODE_WRONLY | File.MODE_TRUNCATE);
|
||||
function addURIEntry(file, uri)
|
||||
zip.addEntryChannel(PATH + file, TIME, 9,
|
||||
services.get("io").newChannel(uri, null, null), false);
|
||||
services.io.newChannel(uri, null, null), false);
|
||||
function addDataEntry(file, data) // Unideal to an extreme.
|
||||
addURIEntry(file, "data:text/plain;charset=UTF-8," + encodeURI(data));
|
||||
|
||||
@@ -557,7 +557,7 @@ const Dactyl = Module("dactyl", {
|
||||
|
||||
let chrome = {};
|
||||
let styles = {};
|
||||
for (let [file, ] in Iterator(services.get("dactyl:").FILE_MAP)) {
|
||||
for (let [file, ] in Iterator(services["dactyl:"].FILE_MAP)) {
|
||||
dactyl.open("dactyl://help/" + file);
|
||||
dactyl.modules.events.waitForPageLoad();
|
||||
let data = [
|
||||
@@ -584,7 +584,7 @@ const Dactyl = Module("dactyl", {
|
||||
if (name == "href") {
|
||||
value = node.href;
|
||||
if (value.indexOf("dactyl://help-tag/") == 0) {
|
||||
let uri = services.get("io").newChannel(value, null, null).originalURI;
|
||||
let uri = services.io.newChannel(value, null, null).originalURI;
|
||||
value = uri.spec == value ? "javascript:;" : uri.path.substr(1);
|
||||
}
|
||||
if (!/^#|[\/](#|$)|^[a-z]+:/.test(value))
|
||||
@@ -725,7 +725,7 @@ const Dactyl = Module("dactyl", {
|
||||
if (!topic) {
|
||||
let helpFile = unchunked ? "all" : options["helpfile"];
|
||||
|
||||
if (helpFile in services.get("dactyl:").FILE_MAP)
|
||||
if (helpFile in services["dactyl:"].FILE_MAP)
|
||||
dactyl.open("dactyl://help/" + helpFile, { from: "help" });
|
||||
else
|
||||
dactyl.echomsg("Sorry, help file " + helpFile.quote() + " not found");
|
||||
@@ -803,7 +803,7 @@ const Dactyl = Module("dactyl", {
|
||||
if (isObject(msg))
|
||||
msg = util.objectToString(msg, false);
|
||||
|
||||
services.get("console").logStringMessage(config.name + ": " + msg);
|
||||
services.console.logStringMessage(config.name + ": " + msg);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -891,7 +891,7 @@ const Dactyl = Module("dactyl", {
|
||||
|
||||
case dactyl.NEW_WINDOW:
|
||||
window.open();
|
||||
let win = services.get("windowMediator").getMostRecentWindow("navigator:browser");
|
||||
let win = services.windowMediator.getMostRecentWindow("navigator:browser");
|
||||
win.loadURI(url, null, postdata);
|
||||
browser = win.getBrowser();
|
||||
break;
|
||||
@@ -944,7 +944,7 @@ const Dactyl = Module("dactyl", {
|
||||
if (!saveSession && prefs.get(pref) >= 2)
|
||||
prefs.safeSet(pref, 1);
|
||||
|
||||
services.get("appStartup").quit(Ci.nsIAppStartup[force ? "eForceQuit" : "eAttemptQuit"]);
|
||||
services.appStartup.quit(Ci.nsIAppStartup[force ? "eForceQuit" : "eAttemptQuit"]);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -971,7 +971,7 @@ const Dactyl = Module("dactyl", {
|
||||
// Try to find a matching file.
|
||||
let file = io.File(url);
|
||||
if (file.exists() && file.isReadable())
|
||||
return services.get("io").newFileURI(file).spec;
|
||||
return services.io.newFileURI(file).spec;
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
@@ -1052,7 +1052,7 @@ const Dactyl = Module("dactyl", {
|
||||
if (!canQuitApplication())
|
||||
return;
|
||||
|
||||
services.get("appStartup").quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||
services.appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1103,7 +1103,7 @@ const Dactyl = Module("dactyl", {
|
||||
* @property {Window[]} Returns an array of all the host application's
|
||||
* open windows.
|
||||
*/
|
||||
get windows() [win for (win in iter(services.get("windowMediator").getEnumerator("navigator:browser")))],
|
||||
get windows() [win for (win in iter(services.windowMediator.getEnumerator("navigator:browser")))],
|
||||
|
||||
}, {
|
||||
// initially hide all GUI elements, they are later restored unless the user
|
||||
@@ -1269,14 +1269,14 @@ const Dactyl = Module("dactyl", {
|
||||
|
||||
// TODO: remove this FF3.5 test when we no longer support 3.0
|
||||
// : make this a config feature
|
||||
if (services.get("privateBrowsing")) {
|
||||
if (services.privateBrowsing) {
|
||||
let oldValue = win.getAttribute("titlemodifier_normal");
|
||||
let suffix = win.getAttribute("titlemodifier_privatebrowsing").substr(oldValue.length);
|
||||
|
||||
win.setAttribute("titlemodifier_normal", value);
|
||||
win.setAttribute("titlemodifier_privatebrowsing", value + suffix);
|
||||
|
||||
if (services.get("privateBrowsing").privateBrowsingEnabled) {
|
||||
if (services.privateBrowsing.privateBrowsingEnabled) {
|
||||
updateTitle(oldValue + suffix, value + suffix);
|
||||
return value;
|
||||
}
|
||||
@@ -1399,18 +1399,18 @@ const Dactyl = Module("dactyl", {
|
||||
callback = callback || util.identity;
|
||||
let addon = id;
|
||||
if (!isObject(addon))
|
||||
addon = services.get("extensionManager").getItemForID(id);
|
||||
addon = services.extensionManager.getItemForID(id);
|
||||
if (!addon)
|
||||
return callback(null);
|
||||
addon = Object.create(addon);
|
||||
|
||||
function getRdfProperty(item, property) {
|
||||
let resource = services.get("rdf").GetResource("urn:mozilla:item:" + item.id);
|
||||
let resource = services.rdf.GetResource("urn:mozilla:item:" + item.id);
|
||||
let value = "";
|
||||
|
||||
if (resource) {
|
||||
let target = services.get("extensionManager").datasource.GetTarget(resource,
|
||||
services.get("rdf").GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true);
|
||||
let target = services.extensionManager.datasource.GetTarget(resource,
|
||||
services.rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true);
|
||||
if (target && target instanceof Ci.nsIRDFLiteral)
|
||||
value = target.Value;
|
||||
}
|
||||
@@ -1426,12 +1426,12 @@ const Dactyl = Module("dactyl", {
|
||||
addon.isActive = getRdfProperty(addon, "isDisabled") != "true";
|
||||
|
||||
addon.uninstall = function () {
|
||||
services.get("extensionManager").uninstallItem(this.id);
|
||||
services.extensionManager.uninstallItem(this.id);
|
||||
};
|
||||
addon.appDisabled = false;
|
||||
addon.__defineGetter__("userDisabled", function () getRdfProperty(addon, "userDisabled") === "true");
|
||||
addon.__defineSetter__("userDisabled", function (val) {
|
||||
services.get("extensionManager")[val ? "disableItem" : "enableItem"](this.id);
|
||||
services.extensionManager[val ? "disableItem" : "enableItem"](this.id);
|
||||
});
|
||||
|
||||
return callback(addon);
|
||||
@@ -1439,7 +1439,7 @@ const Dactyl = Module("dactyl", {
|
||||
getAddonsByTypes: function (types, callback) {
|
||||
let res = [];
|
||||
for (let [, type] in Iterator(types))
|
||||
for (let [, item] in Iterator(services.get("extensionManager")
|
||||
for (let [, item] in Iterator(services.extensionManager
|
||||
.getItemList(Ci.nsIUpdateItem["TYPE_" + type.toUpperCase()], {})))
|
||||
res.push(this.getAddonByID(item));
|
||||
callback(res);
|
||||
@@ -1448,7 +1448,7 @@ const Dactyl = Module("dactyl", {
|
||||
callback({
|
||||
addListener: function () {},
|
||||
install: function () {
|
||||
services.get("extensionManager").installItemFromFile(file, "app-profile");
|
||||
services.extensionManager.installItemFromFile(file, "app-profile");
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -1486,7 +1486,7 @@ const Dactyl = Module("dactyl", {
|
||||
const updateAddons = Class("UpgradeListener", {
|
||||
init: function init(addons) {
|
||||
dactyl.assert(!addons.length || addons[0].findUpdates,
|
||||
"Not available on " + config.host + " " + services.get("runtime").version);
|
||||
"Not available on " + config.host + " " + services.runtime.version);
|
||||
this.remaining = addons;
|
||||
this.upgrade = [];
|
||||
dactyl.echomsg("Checking updates for addons: " + addons.map(function (a) a.name).join(", "));
|
||||
@@ -1953,7 +1953,7 @@ const Dactyl = Module("dactyl", {
|
||||
dactyl.initHelp();
|
||||
context.title = ["Help"];
|
||||
context.anchored = false;
|
||||
context.completions = services.get("dactyl:").HELP_TAGS;
|
||||
context.completions = services["dactyl:"].HELP_TAGS;
|
||||
if (unchunked)
|
||||
context.keys = { text: 0, description: function () "all" };
|
||||
};
|
||||
@@ -1983,17 +1983,17 @@ const Dactyl = Module("dactyl", {
|
||||
|
||||
dactyl.log("All modules loaded", 3);
|
||||
|
||||
AddonManager.getAddonByID(services.get("dactyl:").addonID, function (addon) {
|
||||
AddonManager.getAddonByID(services["dactyl:"].addonID, function (addon) {
|
||||
// @DATE@ token replaced by the Makefile
|
||||
// TODO: Find it automatically
|
||||
prefs.set("extensions.dactyl.version", addon.version);
|
||||
dactyl.version = addon.version + " (created: @DATE@)";
|
||||
});
|
||||
|
||||
if (!services.get("commandLineHandler"))
|
||||
if (!services.commandLineHandler)
|
||||
services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=" + config.name);
|
||||
|
||||
let commandline = services.get("commandLineHandler").optionValue;
|
||||
let commandline = services.commandLineHandler.optionValue;
|
||||
if (commandline) {
|
||||
let args = dactyl.parseCommandLine(commandline);
|
||||
dactyl.commandLineOptions.rcFile = args["+u"];
|
||||
@@ -2028,7 +2028,7 @@ const Dactyl = Module("dactyl", {
|
||||
// finally, read the RC file and source plugins
|
||||
// make sourcing asynchronous, otherwise commands that open new tabs won't work
|
||||
util.timeout(function () {
|
||||
let init = services.get("environment").get(config.idName + "_INIT");
|
||||
let init = services.environment.get(config.idName + "_INIT");
|
||||
let rcFile = io.getRCFile("~");
|
||||
|
||||
if (dactyl.userEval('typeof document') === "undefined")
|
||||
@@ -2046,7 +2046,7 @@ const Dactyl = Module("dactyl", {
|
||||
else {
|
||||
if (rcFile) {
|
||||
io.source(rcFile.path, false);
|
||||
services.get("environment").set("MY_" + config.idName + "RC", rcFile.path);
|
||||
services.environment.set("MY_" + config.idName + "RC", rcFile.path);
|
||||
}
|
||||
else
|
||||
dactyl.log("No user RC file found", 3);
|
||||
|
||||
@@ -306,7 +306,7 @@ const Editor = Module("editor", {
|
||||
}
|
||||
}
|
||||
|
||||
let timer = services.create("timer");
|
||||
let timer = services.Timer();
|
||||
timer.initWithCallback({ notify: update }, 100, timer.TYPE_REPEATING_SLACK);
|
||||
|
||||
try {
|
||||
|
||||
@@ -264,7 +264,7 @@ const RangeFind = Class("RangeFind", {
|
||||
this.elementPath = elementPath || null;
|
||||
this.reverse = Boolean(backward);
|
||||
|
||||
this.finder = services.create("find");
|
||||
this.finder = services.Find();
|
||||
this.matchCase = Boolean(matchCase);
|
||||
this.regexp = Boolean(regexp);
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
const History = Module("history", {
|
||||
get format() bookmarks.format,
|
||||
|
||||
get service() services.get("history"),
|
||||
get service() services.history,
|
||||
|
||||
get: function get(filter, maxItems) {
|
||||
// no query parameters will get all history
|
||||
let query = services.get("history").getNewQuery();
|
||||
let options = services.get("history").getNewQueryOptions();
|
||||
let query = services.history.getNewQuery();
|
||||
let options = services.history.getNewQueryOptions();
|
||||
|
||||
if (typeof filter == "string")
|
||||
filter = { searchTerms: filter };
|
||||
@@ -26,7 +26,7 @@ const History = Module("history", {
|
||||
options.maxResults = maxItems;
|
||||
|
||||
// execute the query
|
||||
let root = services.get("history").executeQuery(query, options).root;
|
||||
let root = services.history.executeQuery(query, options).root;
|
||||
root.containerOpen = true;
|
||||
let items = util.map(util.range(0, root.childCount), function (i) {
|
||||
let node = root.getChild(i);
|
||||
@@ -50,7 +50,7 @@ const History = Module("history", {
|
||||
obj[i] = update(Object.create(sh.getEntryAtIndex(i, false)),
|
||||
{ index: i });
|
||||
memoize(obj[i], "icon",
|
||||
function () services.get("favicon").getFaviconImageForPage(this.URI).spec);
|
||||
function () services.favicon.getFaviconImageForPage(this.URI).spec);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
@@ -213,7 +213,7 @@ const History = Module("history", {
|
||||
// FIXME: Schema-specific
|
||||
context.generate = function () [
|
||||
Array.slice(row.rev_host).reverse().join("").slice(1)
|
||||
for (row in iter(services.get("history").DBConnection
|
||||
for (row in iter(services.history.DBConnection
|
||||
.createStatement("SELECT DISTINCT rev_host FROM moz_places;")))
|
||||
].slice(2);
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ function Script(file) {
|
||||
*/
|
||||
const IO = Module("io", {
|
||||
init: function () {
|
||||
this._processDir = services.get("directory").get("CurWorkD", Ci.nsIFile);
|
||||
this._processDir = services.directory.get("CurWorkD", Ci.nsIFile);
|
||||
this._cwd = this._processDir.path;
|
||||
this._oldcwd = null;
|
||||
|
||||
@@ -48,7 +48,7 @@ const IO = Module("io", {
|
||||
|
||||
this.downloadListener = {
|
||||
onDownloadStateChange: function (state, download) {
|
||||
if (download.state == services.get("downloadManager").DOWNLOAD_FINISHED) {
|
||||
if (download.state == services.downloadManager.DOWNLOAD_FINISHED) {
|
||||
let url = download.source.spec;
|
||||
let title = download.displayName;
|
||||
let file = download.targetFile.path;
|
||||
@@ -64,7 +64,7 @@ const IO = Module("io", {
|
||||
onSecurityChange: function () {}
|
||||
};
|
||||
|
||||
services.get("downloadManager").addListener(this.downloadListener);
|
||||
services.downloadManager.addListener(this.downloadListener);
|
||||
},
|
||||
|
||||
// TODO: there seems to be no way, short of a new component, to change
|
||||
@@ -112,7 +112,7 @@ const IO = Module("io", {
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
services.get("downloadManager").removeListener(this.downloadListener);
|
||||
services.downloadManager.removeListener(this.downloadListener);
|
||||
for (let [, plugin] in Iterator(plugins.contexts))
|
||||
if (plugin.onUnload)
|
||||
plugin.onUnload();
|
||||
@@ -199,7 +199,7 @@ const IO = Module("io", {
|
||||
* @returns {File}
|
||||
*/
|
||||
createTempFile: function () {
|
||||
let file = services.get("directory").get("TmpD", Ci.nsIFile);
|
||||
let file = services.directory.get("TmpD", Ci.nsIFile);
|
||||
|
||||
file.append(config.tempFile);
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt('0600', 8));
|
||||
@@ -230,7 +230,7 @@ const IO = Module("io", {
|
||||
if (File.isAbsolutePath(program))
|
||||
file = io.File(program, true);
|
||||
else {
|
||||
let dirs = services.get("environment").get("PATH").split(util.OS.isWindows ? ";" : ":");
|
||||
let dirs = services.environment.get("PATH").split(util.OS.isWindows ? ";" : ":");
|
||||
// Windows tries the CWD first TODO: desirable?
|
||||
if (util.OS.isWindows)
|
||||
dirs = [io.cwd].concat(dirs);
|
||||
@@ -245,7 +245,7 @@ lookup:
|
||||
// TODO: couldn't we just palm this off to the start command?
|
||||
// automatically try to add the executable path extensions on windows
|
||||
if (util.OS.isWindows) {
|
||||
let extensions = services.get("environment").get("PATHEXT").split(";");
|
||||
let extensions = services.environment.get("PATHEXT").split(";");
|
||||
for (let [, extension] in Iterator(extensions)) {
|
||||
file = File.joinPaths(dir, program + extension, io.cwd);
|
||||
if (file.exists())
|
||||
@@ -262,7 +262,7 @@ lookup:
|
||||
return -1;
|
||||
}
|
||||
|
||||
let process = services.create("process");
|
||||
let process = services.Process();
|
||||
|
||||
process.init(file);
|
||||
process.run(false, args.map(String), args.length);
|
||||
@@ -338,7 +338,7 @@ lookup:
|
||||
|
||||
dactyl.echomsg("sourcing " + filename.quote(), 2);
|
||||
|
||||
let uri = services.get("io").newFileURI(file);
|
||||
let uri = services.io.newFileURI(file);
|
||||
|
||||
// handle pure JavaScript files specially
|
||||
if (/\.js$/.test(filename)) {
|
||||
@@ -455,10 +455,10 @@ lookup:
|
||||
*/
|
||||
get runtimePath() {
|
||||
const rtpvar = config.idName + "_RUNTIME";
|
||||
let rtp = services.get("environment").get(rtpvar);
|
||||
let rtp = services.environment.get(rtpvar);
|
||||
if (!rtp) {
|
||||
rtp = "~/" + (util.OS.isWindows ? "" : ".") + config.name;
|
||||
services.get("environment").set(rtpvar, rtp);
|
||||
services.environment.set(rtpvar, rtp);
|
||||
}
|
||||
return rtp;
|
||||
},
|
||||
@@ -629,9 +629,9 @@ lookup:
|
||||
context.anchored = false;
|
||||
context.keys = {
|
||||
text: util.identity,
|
||||
description: services.get("charset").getCharsetTitle
|
||||
description: services.charset.getCharsetTitle
|
||||
};
|
||||
context.generate = function () iter(services.get("charset").getDecoderList());
|
||||
context.generate = function () iter(services.charset.getDecoderList());
|
||||
};
|
||||
|
||||
completion.directory = function directory(context, full) {
|
||||
@@ -695,7 +695,7 @@ lookup:
|
||||
completion.shellCommand = function shellCommand(context) {
|
||||
context.title = ["Shell Command", "Path"];
|
||||
context.generate = function () {
|
||||
let dirNames = services.get("environment").get("PATH").split(util.OS.isWindows ? ";" : ":");
|
||||
let dirNames = services.environment.get("PATH").split(util.OS.isWindows ? ";" : ":");
|
||||
let commands = [];
|
||||
|
||||
for (let [, dirName] in Iterator(dirNames)) {
|
||||
@@ -730,7 +730,7 @@ lookup:
|
||||
shellcmdflag = "/c";
|
||||
}
|
||||
else {
|
||||
shell = services.get("environment").get("SHELL") || "sh";
|
||||
shell = services.environment.get("SHELL") || "sh";
|
||||
shellcmdflag = "-c";
|
||||
}
|
||||
|
||||
@@ -747,7 +747,7 @@ lookup:
|
||||
});
|
||||
options.add(["cdpath", "cd"],
|
||||
"List of directories searched when executing :cd",
|
||||
"stringlist", ["."].concat(services.get("environment").get("CDPATH").split(/[:;]/).filter(util.identity)).join(","),
|
||||
"stringlist", ["."].concat(services.environment.get("CDPATH").split(/[:;]/).filter(util.identity)).join(","),
|
||||
{ setter: function (value) File.expandPathList(value) });
|
||||
|
||||
options.add(["runtimepath", "rtp"],
|
||||
|
||||
@@ -666,10 +666,10 @@ const JavaScript = Module("javascript", {
|
||||
"Use the JavaScript debugger service for JavaScript completion",
|
||||
"boolean", false, {
|
||||
setter: function (value) {
|
||||
if (services.get("debugger").isOn != value)
|
||||
services.get("debugger")[value ? "on" : "off"]();
|
||||
if (services.debugger.isOn != value)
|
||||
services.debugger[value ? "on" : "off"]();
|
||||
},
|
||||
getter: function () services.get("debugger").isOn
|
||||
getter: function () services.debugger.isOn
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -120,7 +120,7 @@ const Tabs = Module("tabs", {
|
||||
* @property {Object[]} The array of closed tabs for the current
|
||||
* session.
|
||||
*/
|
||||
get closedTabs() services.get("json").decode(services.get("sessionStore").getClosedTabData(window)),
|
||||
get closedTabs() services.json.decode(services.sessionStore.getClosedTabData(window)),
|
||||
|
||||
/**
|
||||
* Clones the specified *tab* and append it to the tab list.
|
||||
@@ -148,7 +148,7 @@ const Tabs = Module("tabs", {
|
||||
if (!tab)
|
||||
tab = config.tabbrowser.mTabContainer.selectedItem;
|
||||
|
||||
services.get("windowWatcher")
|
||||
services.windowWatcher
|
||||
.openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab);
|
||||
},
|
||||
|
||||
@@ -490,8 +490,8 @@ const Tabs = Module("tabs", {
|
||||
if (!from)
|
||||
from = config.tabbrowser.mTabContainer.selectedItem;
|
||||
|
||||
let tabState = services.get("sessionStore").getTabState(from);
|
||||
services.get("sessionStore").setTabState(to, tabState);
|
||||
let tabState = services.sessionStore.getTabState(from);
|
||||
services.sessionStore.setTabState(to, tabState);
|
||||
}
|
||||
}, {
|
||||
commands: function () {
|
||||
|
||||
@@ -124,7 +124,7 @@ defineModule.dump = function dump_() {
|
||||
msg = util.objectToString(msg);
|
||||
return msg;
|
||||
}).join(", ");
|
||||
let name = loaded.services ? services.get("dactyl:").name : "dactyl";
|
||||
let name = loaded.services ? services["dactyl:"].name : "dactyl";
|
||||
dump(String.replace(msg, /\n?$/, "\n")
|
||||
.replace(/^./gm, name + ": $&"));
|
||||
}
|
||||
@@ -199,9 +199,9 @@ Runnable.prototype.QueryInterface = XPCOMUtils.generateQI([Ci.nsIRunnable]);
|
||||
* @returns [jsdIProperty]
|
||||
*/
|
||||
function debuggerProperties(obj) {
|
||||
if (loaded.services && services.get("debugger").isOn) {
|
||||
if (loaded.services && services.debugger.isOn) {
|
||||
let ret = {};
|
||||
services.get("debugger").wrapValue(obj).getProperties(ret, {});
|
||||
services.debugger.wrapValue(obj).getProperties(ret, {});
|
||||
return ret.value;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ function properties(obj, prototypes, debugger_) {
|
||||
|
||||
for (; obj; obj = prototypes && prototype(obj)) {
|
||||
try {
|
||||
if (sandbox.Object.getOwnPropertyNames || !debugger_ || !services.get("debugger").isOn)
|
||||
if (sandbox.Object.getOwnPropertyNames || !debugger_ || !services.debugger.isOn)
|
||||
var iter = values(Object.getOwnPropertyNames(obj));
|
||||
}
|
||||
catch (e) {}
|
||||
@@ -798,7 +798,7 @@ Class.prototype = {
|
||||
timeout: function (callback, timeout) {
|
||||
const self = this;
|
||||
let notify = { notify: function notify(timer) { try { callback.apply(self); } catch (e) { util.reportError(e); } } };
|
||||
let timer = services.create("timer");
|
||||
let timer = services.Timer();
|
||||
timer.initWithCallback(notify, timeout || 0, timer.TYPE_ONE_SHOT);
|
||||
return timer;
|
||||
}
|
||||
@@ -939,7 +939,7 @@ let StructBase = Class("StructBase", Array, {
|
||||
|
||||
const Timer = Class("Timer", {
|
||||
init: function (minInterval, maxInterval, callback) {
|
||||
this._timer = services.create("timer");
|
||||
this._timer = services.Timer();
|
||||
this.callback = callback;
|
||||
this.minInterval = minInterval;
|
||||
this.maxInterval = maxInterval;
|
||||
|
||||
@@ -18,10 +18,10 @@ Bookmark.prototype.__defineGetter__("extra", function () [
|
||||
["tags", this.tags.join(", "), "Tag"]
|
||||
].filter(function (item) item[1]));
|
||||
|
||||
const annotation = services.get("annotation");
|
||||
const bookmarks = services.get("bookmarks");
|
||||
const history = services.get("history");
|
||||
const tagging = services.get("tagging");
|
||||
const annotation = services.annotation;
|
||||
const bookmarks = services.bookmarks;
|
||||
const history = services.history;
|
||||
const tagging = services.tagging;
|
||||
const name = "bookmark-cache";
|
||||
|
||||
const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
|
||||
@@ -85,7 +85,7 @@ const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver),
|
||||
isRegularBookmark: function isRegularBookmark(id) {
|
||||
do {
|
||||
var root = id;
|
||||
if (services.get("livemark") && services.get("livemark").isLivemark(id))
|
||||
if (services.livemark && services.livemark.isLivemark(id))
|
||||
return false;
|
||||
id = bookmarks.getFolderIdForItem(id);
|
||||
} while (id != bookmarks.placesRoot && id != root);
|
||||
|
||||
346
common/modules/prefs.jsm
Normal file
346
common/modules/prefs.jsm
Normal file
@@ -0,0 +1,346 @@
|
||||
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
||||
// Copyright (c) 2007-2010 by Doug Kearns <dougkearns@gmail.com>
|
||||
// Copyright (c) 2008-2010 by Kris Maglione <maglione.k@gmail.com>
|
||||
//
|
||||
// This work is licensed for reuse under an MIT license. Details are
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
defineModule("prefs", {
|
||||
exports: ["Prefs", "prefs"],
|
||||
require: ["services", "util"],
|
||||
use: ["template"]
|
||||
});
|
||||
|
||||
const Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
SAVED: "extensions.dactyl.saved.",
|
||||
RESTORE: "extensions.dactyl.restore.",
|
||||
|
||||
init: function () {
|
||||
this._prefContexts = [];
|
||||
|
||||
util.addObserver(this);
|
||||
this._branch = services.pref.getBranch("").QueryInterface(Ci.nsIPrefBranch2);
|
||||
this._branch.addObserver("", this, false);
|
||||
this._observers = {};
|
||||
|
||||
this.restore();
|
||||
},
|
||||
|
||||
observe: {
|
||||
"nsPref:changed": function (subject, data) {
|
||||
let observers = this._observers[data];
|
||||
if (observers) {
|
||||
let value = this.get(data, false);
|
||||
this._observers[data] = observers.filter(function (callback) {
|
||||
if (!callback.get())
|
||||
return false;
|
||||
util.trapErrors(callback.get(), null, value);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a new preference observer for the given preference.
|
||||
*
|
||||
* @param {string} pref The preference to observe.
|
||||
* @param {function(object)} callback The callback, called with the
|
||||
* new value of the preference whenever it changes.
|
||||
*/
|
||||
watch: function (pref, callback, strong) {
|
||||
if (!this._observers[pref])
|
||||
this._observers[pref] = [];
|
||||
this._observers[pref].push(!strong ? Cu.getWeakReference(callback) : { get: function () callback });
|
||||
},
|
||||
|
||||
/**
|
||||
* Lists all preferences matching *filter* or only those with changed
|
||||
* values if *onlyNonDefault* is specified.
|
||||
*
|
||||
* @param {boolean} onlyNonDefault Limit the list to prefs with a
|
||||
* non-default value.
|
||||
* @param {string} filter The list filter. A null filter lists all
|
||||
* prefs.
|
||||
* @optional
|
||||
*/
|
||||
list: function list(onlyNonDefault, filter) {
|
||||
if (!filter)
|
||||
filter = "";
|
||||
|
||||
let prefArray = this.getNames();
|
||||
prefArray.sort();
|
||||
function prefs() {
|
||||
for (let [, pref] in Iterator(prefArray)) {
|
||||
let userValue = services.pref.prefHasUserValue(pref);
|
||||
if (onlyNonDefault && !userValue || pref.indexOf(filter) == -1)
|
||||
continue;
|
||||
|
||||
let value = this.get(pref);
|
||||
|
||||
let option = {
|
||||
isDefault: !userValue,
|
||||
default: this._load(pref, null, true),
|
||||
value: <>={template.highlight(value, true, 100)}</>,
|
||||
name: pref,
|
||||
pre: "\u00a0\u00a0" // Unicode nonbreaking space.
|
||||
};
|
||||
|
||||
yield option;
|
||||
}
|
||||
};
|
||||
|
||||
return template.options(services["dactyl:"].host + " Preferences", prefs.call(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the value of a preference.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} defaultValue The value to return if the preference
|
||||
* is unset.
|
||||
*/
|
||||
get: function (name, defaultValue) this._load(name, defaultValue),
|
||||
|
||||
/**
|
||||
* Returns the default value of a preference
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} defaultValue The value to return if the preference
|
||||
* has no default value.
|
||||
*/
|
||||
getDefault: function (name, defaultValue) this._load(name, defaultValue, true),
|
||||
|
||||
/**
|
||||
* Returns the names of all preferences.
|
||||
*
|
||||
* @param {string} branch The branch in which to search preferences.
|
||||
* @default ""
|
||||
*/
|
||||
getNames: function (branch) services.pref.getChildList(branch || "", { value: 0 }),
|
||||
|
||||
_checkSafe: function (name, message, value) {
|
||||
let curval = this._load(name, null, false);
|
||||
if (arguments.length > 2 && curval === value)
|
||||
return;
|
||||
let defval = this._load(name, null, true);
|
||||
let saved = this._load(this.SAVED + name);
|
||||
|
||||
if (saved == null && curval != defval || curval != saved) {
|
||||
let msg = "Warning: setting preference " + name + ", but it's changed from its default value.";
|
||||
if (message)
|
||||
msg += " " + message;
|
||||
util.dactyl.echomsg(msg);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the preference *name* to *value* but warns the user if the value
|
||||
* is changed from its default.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} value The new preference value.
|
||||
*/
|
||||
safeReset: function (name, message) {
|
||||
this._checkSafe(name, message);
|
||||
this.reset(name);
|
||||
this.reset(this.SAVED + name);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the preference *name* to *value* but warns the user if the value is
|
||||
* changed from its default.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} value The new preference value.
|
||||
*/
|
||||
safeSet: function (name, value, message, skipSave) {
|
||||
this._checkSafe(name, message, value);
|
||||
this._store(name, value);
|
||||
this[skipSave ? "reset" : "_store"](this.SAVED + name, value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the preference *name* to *value*.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} value The new preference value.
|
||||
*/
|
||||
set: function (name, value) {
|
||||
this._store(name, value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Saves the current value of a preference to be restored at next
|
||||
* startup.
|
||||
*
|
||||
* @param {string} name The preference to save.
|
||||
*/
|
||||
save: function (name) {
|
||||
let val = this.get(name);
|
||||
this.set(this.RESTORE + name, val);
|
||||
this.safeSet(name, val);
|
||||
},
|
||||
|
||||
/**
|
||||
* Restores saved preferences in the given branch.
|
||||
*
|
||||
* @param {string} branch The branch from which to restore
|
||||
* preferences. @optional
|
||||
*/
|
||||
restore: function (branch) {
|
||||
this.getNames(this.RESTORE + (branch || "")).forEach(function (pref) {
|
||||
this.safeSet(pref.substr(this.RESTORE.length), this.get(pref), null, true)
|
||||
this.reset(pref);
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the preference *name* to its default value.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
*/
|
||||
reset: function (name) {
|
||||
try {
|
||||
services.pref.clearUserPref(name);
|
||||
}
|
||||
catch (e) {} // ignore - thrown if not a user set value
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles the value of the boolean preference *name*.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
*/
|
||||
toggle: function (name) {
|
||||
util.assert(services.pref.getPrefType(name) === Ci.nsIPrefBranch.PREF_BOOL,
|
||||
"E488: Trailing characters: " + name + "!");
|
||||
this.set(name, !this.get(name));
|
||||
},
|
||||
|
||||
/**
|
||||
* Pushes a new preference context onto the context stack.
|
||||
*
|
||||
* @see #withContext
|
||||
*/
|
||||
pushContext: function () {
|
||||
this._prefContexts.push({});
|
||||
},
|
||||
|
||||
/**
|
||||
* Pops the top preference context from the stack.
|
||||
*
|
||||
* @see #withContext
|
||||
*/
|
||||
popContext: function () {
|
||||
for (let [k, v] in Iterator(this._prefContexts.pop()))
|
||||
this._store(k, v);
|
||||
},
|
||||
|
||||
/**
|
||||
* Executes *func* with a new preference context. When *func* returns, the
|
||||
* context is popped and any preferences set via {@link #setPref} or
|
||||
* {@link #invertPref} are restored to their previous values.
|
||||
*
|
||||
* @param {function} func The function to call.
|
||||
* @param {Object} func The 'this' object with which to call *func*
|
||||
* @see #pushContext
|
||||
* @see #popContext
|
||||
*/
|
||||
withContext: function (func, self) {
|
||||
try {
|
||||
this.pushContext();
|
||||
return func.call(self);
|
||||
}
|
||||
finally {
|
||||
this.popContext();
|
||||
}
|
||||
},
|
||||
|
||||
_store: function (name, value) {
|
||||
if (this._prefContexts.length) {
|
||||
let val = this._load(name, null);
|
||||
if (val != null)
|
||||
this._prefContexts[this._prefContexts.length - 1][name] = val;
|
||||
}
|
||||
|
||||
function assertType(needType)
|
||||
util.assert(type === Ci.nsIPrefBranch.PREF_INVALID || type === needType,
|
||||
type === Ci.nsIPrefBranch.PREF_INT
|
||||
? "E521: Number required after =: " + name + "=" + value
|
||||
: "E474: Invalid argument: " + name + "=" + value);
|
||||
|
||||
let type = services.pref.getPrefType(name);
|
||||
switch (typeof value) {
|
||||
case "string":
|
||||
assertType(Ci.nsIPrefBranch.PREF_STRING);
|
||||
|
||||
let supportString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
|
||||
supportString.data = value;
|
||||
services.pref.setComplexValue(name, Ci.nsISupportsString, supportString);
|
||||
break;
|
||||
case "number":
|
||||
assertType(Ci.nsIPrefBranch.PREF_INT);
|
||||
|
||||
services.pref.setIntPref(name, value);
|
||||
break;
|
||||
case "boolean":
|
||||
assertType(Ci.nsIPrefBranch.PREF_BOOL);
|
||||
|
||||
services.pref.setBoolPref(name, value);
|
||||
break;
|
||||
default:
|
||||
throw FailedAssertion("Unknown preference type: " + typeof value + " (" + name + "=" + value + ")");
|
||||
}
|
||||
},
|
||||
|
||||
_load: function (name, defaultValue, defaultBranch) {
|
||||
if (defaultValue == null)
|
||||
defaultValue = null;
|
||||
|
||||
let branch = defaultBranch ? services.pref.getDefaultBranch("") : services.pref;
|
||||
let type = services.pref.getPrefType(name);
|
||||
try {
|
||||
switch (type) {
|
||||
case Ci.nsIPrefBranch.PREF_STRING:
|
||||
let value = branch.getComplexValue(name, Ci.nsISupportsString).data;
|
||||
// try in case it's a localized string (will throw an exception if not)
|
||||
if (!services.pref.prefIsLocked(name) && !services.pref.prefHasUserValue(name) &&
|
||||
RegExp("chrome://.+/locale/.+\\.properties").test(value))
|
||||
value = branch.getComplexValue(name, Ci.nsIPrefLocalizedString).data;
|
||||
return value;
|
||||
case Ci.nsIPrefBranch.PREF_INT:
|
||||
return branch.getIntPref(name);
|
||||
case Ci.nsIPrefBranch.PREF_BOOL:
|
||||
return branch.getBoolPref(name);
|
||||
default:
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
}, {
|
||||
completion: function (dactyl, modules) {
|
||||
modules.completion.preference = function preference(context) {
|
||||
context.anchored = false;
|
||||
context.title = [services["dactyl:"].host + " Preference", "Value"];
|
||||
context.keys = { text: function (item) item, description: function (item) prefs.get(item) };
|
||||
context.completions = prefs.getNames();
|
||||
};
|
||||
},
|
||||
javascript: function (dactyl, modules) {
|
||||
modules.JavaScript.setCompleter([this.get, this.safeSet, this.set, this.reset, this.toggle],
|
||||
[function (context) (context.anchored=false, prefs.getNames().map(function (pref) [pref, ""]))]);
|
||||
}
|
||||
});
|
||||
|
||||
endModule();
|
||||
|
||||
// catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);}
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
|
||||
@@ -15,11 +15,11 @@
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
defineModule("sanitizer", {
|
||||
exports: ["Range", "Sanitizer", "sanitizer"],
|
||||
require: ["services", "storage", "template", "util"]
|
||||
require: ["prefs", "services", "storage", "template", "util"]
|
||||
});
|
||||
|
||||
let tmp = {};
|
||||
services.get("subscriptLoader").loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||
services.subscriptLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||
tmp.Sanitizer.prototype.__proto__ = Class.prototype;
|
||||
|
||||
const Range = Struct("min", "max");
|
||||
@@ -92,7 +92,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
action: function (range, host) {
|
||||
for (let c in Sanitizer.iterCookies(host))
|
||||
if (range.contains(c.creationTime) || timespan.isSession && c.isSession)
|
||||
services.get("cookies").remove(c.host, c.name, c.path, false);
|
||||
services.cookies.remove(c.host, c.name, c.path, false);
|
||||
},
|
||||
override: true
|
||||
});
|
||||
@@ -105,23 +105,23 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
return;
|
||||
if (host) {
|
||||
for (let p in Sanitizer.iterPermissions(host)) {
|
||||
services.get("permissions").remove(util.createURI(p.host), p.type);
|
||||
services.get("permissions").add(util.createURI(p.host), p.type, 0);
|
||||
services.permissions.remove(util.createURI(p.host), p.type);
|
||||
services.permissions.add(util.createURI(p.host), p.type, 0);
|
||||
}
|
||||
for (let p in iter(services.get("contentprefs").getPrefs(util.createURI(host))))
|
||||
services.get("contentprefs").removePref(util.createURI(host), p.QueryInterface(Ci.nsIProperty).name);
|
||||
for (let p in iter(services.contentprefs.getPrefs(util.createURI(host))))
|
||||
services.contentprefs.removePref(util.createURI(host), p.QueryInterface(Ci.nsIProperty).name);
|
||||
}
|
||||
else {
|
||||
// "Allow this site to open popups" ...
|
||||
services.get("permissions").removeAll();
|
||||
services.permissions.removeAll();
|
||||
// Zoom level, ...
|
||||
services.get("contentprefs").removeGroupedPrefs();
|
||||
services.contentprefs.removeGroupedPrefs();
|
||||
}
|
||||
|
||||
// "Never remember passwords" ...
|
||||
for each (let domain in services.get("loginmanager").getAllDisabledHosts())
|
||||
for each (let domain in services.loginmanager.getAllDisabledHosts())
|
||||
if (!host || util.isSubdomain(domain, host))
|
||||
services.get("loginmanager").setLoginSavingEnabled(host, true);
|
||||
services.loginmanager.setLoginSavingEnabled(host, true);
|
||||
},
|
||||
override: true
|
||||
});
|
||||
@@ -153,7 +153,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
append: {
|
||||
SanitizeDialogPane:
|
||||
<groupbox orient="horizontal" xmlns={XUL}>
|
||||
<caption label={services.get("dactyl:").appName + " (see :help privacy)"}/>
|
||||
<caption label={services["dactyl:"].appName + " (see :help privacy)"}/>
|
||||
<grid flex="1">
|
||||
<columns><column flex="1"/><column flex="1"/></columns>
|
||||
<rows>{
|
||||
@@ -178,7 +178,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
{
|
||||
template.map(ourItems(), function ([item, desc])
|
||||
<listitem xmlns={XUL} type="checkbox"
|
||||
label={services.get("dactyl:").appName + " " + desc}
|
||||
label={services["dactyl:"].appName + " " + desc}
|
||||
preference={branch + item}
|
||||
onsyncfrompreference="return gSanitizePromptDialog.onReadGeneric();"/>)
|
||||
}
|
||||
@@ -328,14 +328,14 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
prefToArg: function (pref) pref.replace(/.*\./, "").toLowerCase(),
|
||||
|
||||
iterCookies: function iterCookies(host) {
|
||||
for (let c in iter(services.get("cookies"))) {
|
||||
for (let c in iter(services.cookies)) {
|
||||
c.QueryInterface(Ci.nsICookie2);
|
||||
if (!host || util.isSubdomain(c.rawHost, host))
|
||||
yield c;
|
||||
}
|
||||
},
|
||||
iterPermissions: function iterPermissions(host) {
|
||||
for (let p in iter(services.get("permissions"))) {
|
||||
for (let p in iter(services.permissions)) {
|
||||
p.QueryInterface(Ci.nsIPermission);
|
||||
if (!host || util.isSubdomain(p.host, host))
|
||||
yield p;
|
||||
@@ -393,7 +393,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
args["-host"].forEach(function (host) {
|
||||
sanitizer.sanitizing = true;
|
||||
if (items.indexOf("history") > -1)
|
||||
services.get("privateBrowsing").removeDataFromDomain(host);
|
||||
services.privateBrowsing.removeDataFromDomain(host);
|
||||
sanitizer.sanitizeItems(items, range, host)
|
||||
});
|
||||
}
|
||||
@@ -438,13 +438,13 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
function getPerms(host) {
|
||||
let uri = util.createURI(host);
|
||||
if (uri)
|
||||
return Sanitizer.UNPERMS[services.get("permissions").testPermission(uri, "cookie")];
|
||||
return Sanitizer.UNPERMS[services.permissions.testPermission(uri, "cookie")];
|
||||
return "unset";
|
||||
}
|
||||
function setPerms(host, perm) {
|
||||
let uri = util.createURI(host);
|
||||
services.get("permissions").remove(uri, "cookie");
|
||||
services.get("permissions").add(uri, "cookie", Sanitizer.PERMS[perm]);
|
||||
services.permissions.remove(uri, "cookie");
|
||||
services.permissions.add(uri, "cookie", Sanitizer.PERMS[perm]);
|
||||
}
|
||||
commands.add(["cookies", "ck"],
|
||||
"Change cookie permissions for sites",
|
||||
@@ -458,14 +458,14 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
switch (cmd) {
|
||||
case "clear":
|
||||
for (let c in Sanitizer.iterCookies(host))
|
||||
services.get("cookies").remove(c.host, c.name, c.path, false);
|
||||
services.cookies.remove(c.host, c.name, c.path, false);
|
||||
break;
|
||||
case "clear-persistent":
|
||||
session = false;
|
||||
case "clear-session":
|
||||
for (let c in Sanitizer.iterCookies(host))
|
||||
if (c.isSession == session)
|
||||
services.get("cookies").remove(c.host, c.name, c.path, false);
|
||||
services.cookies.remove(c.host, c.name, c.path, false);
|
||||
return;
|
||||
|
||||
case "list":
|
||||
@@ -524,16 +524,16 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
},
|
||||
options: function (dactyl, modules) {
|
||||
const options = modules.options;
|
||||
if (services.get("privateBrowsing"))
|
||||
if (services.privateBrowsing)
|
||||
options.add(["private", "pornmode"],
|
||||
"Set the 'private browsing' option",
|
||||
"boolean", false,
|
||||
{
|
||||
initialValue: true,
|
||||
getter: function () services.get("privateBrowsing").privateBrowsingEnabled,
|
||||
getter: function () services.privateBrowsing.privateBrowsingEnabled,
|
||||
setter: function (value) {
|
||||
if (services.get("privateBrowsing").privateBrowsingEnabled != value)
|
||||
services.get("privateBrowsing").privateBrowsingEnabled = value
|
||||
if (services.privateBrowsing.privateBrowsingEnabled != value)
|
||||
services.privateBrowsing.privateBrowsingEnabled = value
|
||||
},
|
||||
persist: false
|
||||
});
|
||||
|
||||
@@ -56,16 +56,16 @@ const Services = Module("Services", {
|
||||
this.add("windowMediator", "@mozilla.org/appshell/window-mediator;1", Ci.nsIWindowMediator);
|
||||
this.add("windowWatcher", "@mozilla.org/embedcomp/window-watcher;1", Ci.nsIWindowWatcher);
|
||||
|
||||
this.addClass("file", "@mozilla.org/file/local;1", Ci.nsILocalFile);
|
||||
this.addClass("file:", "@mozilla.org/network/protocol;1?name=file", Ci.nsIFileProtocolHandler);
|
||||
this.addClass("find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
|
||||
this.addClass("htmlConverter","@mozilla.org/widget/htmlformatconverter;1", Ci.nsIFormatConverter);
|
||||
this.addClass("htmlEncoder", "@mozilla.org/layout/htmlCopyEncoder;1", Ci.nsIDocumentEncoder);
|
||||
this.addClass("process", "@mozilla.org/process/util;1", Ci.nsIProcess);
|
||||
this.addClass("string", "@mozilla.org/supports-string;1", Ci.nsISupportsString);
|
||||
this.addClass("timer", "@mozilla.org/timer;1", Ci.nsITimer);
|
||||
this.addClass("xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", Ci.nsIXMLHttpRequest);
|
||||
this.addClass("zipWriter", "@mozilla.org/zipwriter;1", Ci.nsIZipWriter);
|
||||
this.addClass("File", "@mozilla.org/file/local;1", Ci.nsILocalFile);
|
||||
this.addClass("File:", "@mozilla.org/network/protocol;1?name=file", Ci.nsIFileProtocolHandler);
|
||||
this.addClass("Find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
|
||||
this.addClass("HtmlConverter","@mozilla.org/widget/htmlformatconverter;1", Ci.nsIFormatConverter);
|
||||
this.addClass("HtmlEncoder", "@mozilla.org/layout/htmlCopyEncoder;1", Ci.nsIDocumentEncoder);
|
||||
this.addClass("Process", "@mozilla.org/process/util;1", Ci.nsIProcess);
|
||||
this.addClass("String", "@mozilla.org/supports-string;1", Ci.nsISupportsString);
|
||||
this.addClass("Timer", "@mozilla.org/timer;1", Ci.nsITimer);
|
||||
this.addClass("Xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", Ci.nsIXMLHttpRequest);
|
||||
this.addClass("ZipWriter", "@mozilla.org/zipwriter;1", Ci.nsIZipWriter);
|
||||
},
|
||||
|
||||
_create: function (classes, ifaces, meth) {
|
||||
@@ -102,7 +102,9 @@ const Services = Module("Services", {
|
||||
*/
|
||||
add: function (name, class_, ifaces, meth) {
|
||||
const self = this;
|
||||
this.services.__defineGetter__(name, function () {
|
||||
if (name in this && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
|
||||
throw TypeError();
|
||||
this.__defineGetter__(name, function () {
|
||||
delete this[name];
|
||||
return this[name] = self._create(class_, ifaces, meth);
|
||||
});
|
||||
@@ -118,7 +120,7 @@ const Services = Module("Services", {
|
||||
*/
|
||||
addClass: function (name, class_, ifaces) {
|
||||
const self = this;
|
||||
return this.classes[name] = function () self._create(class_, ifaces, "createInstance");
|
||||
return this[name] = function () self._create(class_, ifaces, "createInstance");
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -126,14 +128,14 @@ const Services = Module("Services", {
|
||||
*
|
||||
* @param {string} name The class's cache key.
|
||||
*/
|
||||
create: function (name) this.classes[name](),
|
||||
create: function (name) this[name[0].toUpperCase() + name.substr(1)],
|
||||
|
||||
/**
|
||||
* Returns the cached service with the specified name.
|
||||
*
|
||||
* @param {string} name The service's cache key.
|
||||
*/
|
||||
get: function (name) this.services[name],
|
||||
get: function (name) this[name],
|
||||
}, {
|
||||
}, {
|
||||
init: function (dactyl, modules) {
|
||||
|
||||
@@ -14,7 +14,7 @@ defineModule("storage", {
|
||||
require: ["services", "util"]
|
||||
});
|
||||
|
||||
const win32 = /^win(32|nt)$/i.test(services.get("runtime").OS);
|
||||
const win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||
|
||||
function getFile(name) {
|
||||
let file = storage.infoPath.clone();
|
||||
@@ -27,7 +27,7 @@ function loadData(name, store, type) {
|
||||
if (storage.infoPath)
|
||||
var file = getFile(name).read();
|
||||
if (file)
|
||||
var result = services.get("json").decode(file);
|
||||
var result = services.json.decode(file);
|
||||
if (result instanceof type)
|
||||
return result;
|
||||
}
|
||||
@@ -265,12 +265,12 @@ const Storage = Module("Storage", {
|
||||
*/
|
||||
const File = Class("File", {
|
||||
init: function (path, checkPWD) {
|
||||
let file = services.create("file");
|
||||
let file = services.File();
|
||||
|
||||
if (path instanceof Ci.nsIFile)
|
||||
file = path.QueryInterface(Ci.nsIFile);
|
||||
else if (/file:\/\//.test(path))
|
||||
file = services.create("file:").getFileFromURLSpec(path);
|
||||
file = services["File:"]().getFileFromURLSpec(path);
|
||||
else {
|
||||
try {
|
||||
let expandedPath = File.expandPath(path);
|
||||
@@ -484,7 +484,7 @@ const File = Class("File", {
|
||||
*/
|
||||
get PATH_SEP() {
|
||||
delete this.PATH_SEP;
|
||||
let f = services.get("directory").get("CurProcD", Ci.nsIFile);
|
||||
let f = services.directory.get("CurProcD", Ci.nsIFile);
|
||||
f.append("foo");
|
||||
return this.PATH_SEP = f.path.substr(f.parent.path.length, 1);
|
||||
},
|
||||
@@ -497,6 +497,7 @@ const File = Class("File", {
|
||||
defaultEncoding: "UTF-8",
|
||||
|
||||
expandPath: function (path, relative) {
|
||||
function getenv(name) services.environment.get(name);
|
||||
|
||||
// expand any $ENV vars - this is naive but so is Vim and we like to be compatible
|
||||
// TODO: Vim does not expand variables set to an empty string (and documents it).
|
||||
@@ -505,7 +506,7 @@ const File = Class("File", {
|
||||
function expand(path) path.replace(
|
||||
!win32 ? /\$(\w+)\b|\${(\w+)}/g
|
||||
: /\$(\w+)\b|\${(\w+)}|%(\w+)%/g,
|
||||
function (m, n1, n2, n3) services.get("environment").get(n1 || n2 || n3) || m
|
||||
function (m, n1, n2, n3) getenv(n1 || n2 || n3) || m
|
||||
);
|
||||
path = expand(path);
|
||||
|
||||
@@ -513,12 +514,12 @@ const File = Class("File", {
|
||||
// Yuck.
|
||||
if (!relative && RegExp("~(?:$|[/" + util.escapeRegexp(File.PATH_SEP) + "])").test(path)) {
|
||||
// Try $HOME first, on all systems
|
||||
let home = services.get("environment").get("HOME");
|
||||
let home = getenv("HOME");
|
||||
|
||||
// Windows has its own idiosyncratic $HOME variables.
|
||||
if (win32 && (!home || !File(home) || !File(home).exists()))
|
||||
home = services.get("environment").get("USERPROFILE") ||
|
||||
services.get("environment").get("HOMEDRIVE") + services.get("environment").get("HOMEPATH");
|
||||
if (win32 && (!home || !File(home).exists()))
|
||||
home = getenv("USERPROFILE") ||
|
||||
getenv("HOMEDRIVE") + getenv("HOMEPATH");
|
||||
|
||||
path = home + path.substr(1);
|
||||
}
|
||||
@@ -533,7 +534,7 @@ const File = Class("File", {
|
||||
|
||||
isAbsolutePath: function (path) {
|
||||
try {
|
||||
services.create("file").initWithPath(path);
|
||||
services.File().initWithPath(path);
|
||||
return true;
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
@@ -11,7 +11,7 @@ defineModule("styles", {
|
||||
use: ["template"]
|
||||
});
|
||||
|
||||
const sss = services.get("stylesheet");
|
||||
const sss = services.stylesheet;
|
||||
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
||||
const namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
|
||||
"@namespace xul " + XUL.uri.quote() + ";\n" +
|
||||
@@ -219,7 +219,7 @@ const Styles = Module("Styles", {
|
||||
* already registered.
|
||||
*/
|
||||
registerSheet: function registerSheet(url, agent, reload) {
|
||||
let uri = services.get("io").newURI(url, null, null);
|
||||
let uri = services.io.newURI(url, null, null);
|
||||
if (reload)
|
||||
this.unregisterSheet(url, agent);
|
||||
if (reload || !sss.sheetRegistered(uri, agent ? sss.AGENT_SHEET : sss.USER_SHEET))
|
||||
@@ -233,7 +233,7 @@ const Styles = Module("Styles", {
|
||||
* @param {boolean} agent If true, sheet is registered as an agent sheet.
|
||||
*/
|
||||
unregisterSheet: function unregisterSheet(url, agent) {
|
||||
let uri = services.get("io").newURI(url, null, null);
|
||||
let uri = services.io.newURI(url, null, null);
|
||||
if (sss.sheetRegistered(uri, agent ? sss.AGENT_SHEET : sss.USER_SHEET))
|
||||
sss.unregisterSheet(uri, agent ? sss.AGENT_SHEET : sss.USER_SHEET);
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
||||
// Copyright (c) 2007-2009 by Doug Kearns <dougkearns@gmail.com>
|
||||
// Copyright (c) 2007-2010 by Doug Kearns <dougkearns@gmail.com>
|
||||
// Copyright (c) 2008-2010 by Kris Maglione <maglione.k@gmail.com>
|
||||
//
|
||||
// This work is licensed for reuse under an MIT license. Details are
|
||||
@@ -10,7 +10,7 @@ try {
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
defineModule("util", {
|
||||
exports: ["FailedAssertion", "Math", "NS", "Prefs", "Util", "XHTML", "XUL", "prefs", "util"],
|
||||
exports: ["FailedAssertion", "Math", "NS", "Util", "XHTML", "XUL", "util"],
|
||||
require: ["services"],
|
||||
use: ["highlight", "template"]
|
||||
});
|
||||
@@ -46,7 +46,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
},
|
||||
|
||||
// FIXME: Only works for Pentadactyl
|
||||
get activeWindow() services.get("windowMediator").getMostRecentWindow("navigator:browser"),
|
||||
get activeWindow() services.windowMediator.getMostRecentWindow("navigator:browser"),
|
||||
dactyl: {
|
||||
__noSuchMethod__: function (meth, args) {
|
||||
let win = util.activeWindow;
|
||||
@@ -69,9 +69,9 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
addObserver: function (obj) {
|
||||
let observers = obj.observe;
|
||||
function register(meth) {
|
||||
services.get("observer")[meth](obj, "quit-application", true);
|
||||
services.observer[meth](obj, "quit-application", true);
|
||||
for (let target in keys(observers))
|
||||
services.get("observer")[meth](obj, target, true);
|
||||
services.observer[meth](obj, target, true);
|
||||
}
|
||||
Class.replaceProperty(obj, "observe",
|
||||
function (subject, target, data) {
|
||||
@@ -155,7 +155,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
*/
|
||||
createURI: function createURI(str) {
|
||||
try {
|
||||
return services.get("urifixup").createFixupURI(str, services.get("urifixup").FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP);
|
||||
return services.urifixup.createFixupURI(str, services.urifixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP);
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
@@ -225,20 +225,20 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
}
|
||||
let doc = (node.getRangeAt ? node.getRangeAt(0) : node).startContainer.ownerDocument;
|
||||
|
||||
let encoder = services.create("htmlEncoder");
|
||||
let encoder = services.HtmlEncoder();
|
||||
encoder.init(doc, "text/unicode", encoder.OutputRaw|encoder.OutputPreformatted);
|
||||
if (node instanceof Ci.nsISelection)
|
||||
encoder.setSelection(node);
|
||||
else if (node instanceof Ci.nsIDOMRange)
|
||||
encoder.setRange(node);
|
||||
|
||||
let str = services.create("string");
|
||||
let str = services.String();
|
||||
str.data = encoder.encodeToString();
|
||||
if (html)
|
||||
return str.data;
|
||||
|
||||
let [result, length] = [{}, {}];
|
||||
services.create("htmlConverter").convert("text/html", str, str.data.length*2, "text/unicode", result, length);
|
||||
services.HtmlConverter().convert("text/html", str, str.data.length*2, "text/unicode", result, length);
|
||||
return result.value.QueryInterface(Ci.nsISupportsString).data;
|
||||
},
|
||||
|
||||
@@ -424,7 +424,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
*
|
||||
* @param {string} ver The required version.
|
||||
*/
|
||||
haveGecko: function (ver) services.get("versionCompare").compare(services.get("runtime").platformVersion, ver) >= 0,
|
||||
haveGecko: function (ver) services.versionCompare.compare(services.runtime.platformVersion, ver) >= 0,
|
||||
|
||||
/**
|
||||
* Sends a synchronous or asynchronous HTTP request to *url* and returns
|
||||
@@ -438,7 +438,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
*/
|
||||
httpGet: function httpGet(url, callback) {
|
||||
try {
|
||||
let xmlhttp = services.create("xmlhttp");
|
||||
let xmlhttp = services.Xmlhttp();
|
||||
xmlhttp.mozBackgroundRequest = true;
|
||||
if (callback)
|
||||
xmlhttp.onreadystatechange = function () {
|
||||
@@ -490,7 +490,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
|
||||
/** Dactyl's notion of the current operating system platform. */
|
||||
OS: {
|
||||
_arch: services.get("runtime").OS,
|
||||
_arch: services.runtime.OS,
|
||||
/**
|
||||
* @property {string} The normalised name of the OS. This is one of
|
||||
* "Windows", "Mac OS X" or "Unix".
|
||||
@@ -564,7 +564,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
* @returns {nsIURI}
|
||||
*/
|
||||
// FIXME: createURI needed too?
|
||||
newURI: function (uri, charset, base) services.get("io").newURI(uri, charset, base),
|
||||
newURI: function (uri, charset, base) services.io.newURI(uri, charset, base),
|
||||
|
||||
/**
|
||||
* Pretty print a JavaScript object. Use HTML markup to color certain items
|
||||
@@ -873,7 +873,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
|
||||
let base = host.replace(/.*\.(.+?\..+?)$/, "$1");
|
||||
try {
|
||||
base = services.get("tld").getBaseDomainFromHost(host);
|
||||
base = services.tld.getBaseDomainFromHost(host);
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
@@ -915,7 +915,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
* @param {number} delay The time period for which to sleep in milliseconds.
|
||||
*/
|
||||
sleep: function (delay) {
|
||||
let mainThread = services.get("threading").mainThread;
|
||||
let mainThread = services.threading.mainThread;
|
||||
|
||||
let end = Date.now() + delay;
|
||||
while (Date.now() < end)
|
||||
@@ -994,7 +994,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
},
|
||||
|
||||
threadYield: function (flush, interruptable) {
|
||||
let mainThread = services.get("threading").mainThread;
|
||||
let mainThread = services.threading.mainThread;
|
||||
/* FIXME */
|
||||
util.interrupted = false;
|
||||
do {
|
||||
@@ -1067,332 +1067,6 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
Array: array
|
||||
});
|
||||
|
||||
const Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
SAVED: "extensions.dactyl.saved.",
|
||||
RESTORE: "extensions.dactyl.restore.",
|
||||
|
||||
|
||||
init: function () {
|
||||
this._prefContexts = [];
|
||||
|
||||
util.addObserver(this);
|
||||
this._branch = services.get("pref").getBranch("").QueryInterface(Ci.nsIPrefBranch2);
|
||||
this._branch.addObserver("", this, false);
|
||||
this._observers = {};
|
||||
|
||||
this.restore();
|
||||
},
|
||||
|
||||
observe: {
|
||||
"nsPref:changed": function (subject, data) {
|
||||
let observers = this._observers[data];
|
||||
if (observers) {
|
||||
let value = this.get(data, false);
|
||||
this._observers[data] = observers.filter(function (callback) {
|
||||
if (!callback.get())
|
||||
return false;
|
||||
util.trapErrors(callback.get(), null, value);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a new preference observer for the given preference.
|
||||
*
|
||||
* @param {string} pref The preference to observe.
|
||||
* @param {function(object)} callback The callback, called with the
|
||||
* new value of the preference whenever it changes.
|
||||
*/
|
||||
watch: function (pref, callback, strong) {
|
||||
if (!this._observers[pref])
|
||||
this._observers[pref] = [];
|
||||
this._observers[pref].push(!strong ? Cu.getWeakReference(callback) : { get: function () callback });
|
||||
},
|
||||
|
||||
/**
|
||||
* Lists all preferences matching *filter* or only those with changed
|
||||
* values if *onlyNonDefault* is specified.
|
||||
*
|
||||
* @param {boolean} onlyNonDefault Limit the list to prefs with a
|
||||
* non-default value.
|
||||
* @param {string} filter The list filter. A null filter lists all
|
||||
* prefs.
|
||||
* @optional
|
||||
*/
|
||||
list: function list(onlyNonDefault, filter) {
|
||||
if (!filter)
|
||||
filter = "";
|
||||
|
||||
let prefArray = this.getNames();
|
||||
prefArray.sort();
|
||||
function prefs() {
|
||||
for (let [, pref] in Iterator(prefArray)) {
|
||||
let userValue = services.get("pref").prefHasUserValue(pref);
|
||||
if (onlyNonDefault && !userValue || pref.indexOf(filter) == -1)
|
||||
continue;
|
||||
|
||||
let value = this.get(pref);
|
||||
|
||||
let option = {
|
||||
isDefault: !userValue,
|
||||
default: this._load(pref, null, true),
|
||||
value: <>={template.highlight(value, true, 100)}</>,
|
||||
name: pref,
|
||||
pre: "\u00a0\u00a0" // Unicode nonbreaking space.
|
||||
};
|
||||
|
||||
yield option;
|
||||
}
|
||||
};
|
||||
|
||||
return template.options(services.get("dactyl:").host + " Preferences", prefs.call(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the value of a preference.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} defaultValue The value to return if the preference
|
||||
* is unset.
|
||||
*/
|
||||
get: function (name, defaultValue) this._load(name, defaultValue),
|
||||
|
||||
/**
|
||||
* Returns the default value of a preference
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} defaultValue The value to return if the preference
|
||||
* has no default value.
|
||||
*/
|
||||
getDefault: function (name, defaultValue) this._load(name, defaultValue, true),
|
||||
|
||||
/**
|
||||
* Returns the names of all preferences.
|
||||
*
|
||||
* @param {string} branch The branch in which to search preferences.
|
||||
* @default ""
|
||||
*/
|
||||
getNames: function (branch) services.get("pref").getChildList(branch || "", { value: 0 }),
|
||||
|
||||
_checkSafe: function (name, message, value) {
|
||||
let curval = this._load(name, null, false);
|
||||
if (arguments.length > 2 && curval === value)
|
||||
return;
|
||||
let defval = this._load(name, null, true);
|
||||
let saved = this._load(this.SAVED + name);
|
||||
|
||||
if (saved == null && curval != defval || curval != saved) {
|
||||
let msg = "Warning: setting preference " + name + ", but it's changed from its default value.";
|
||||
if (message)
|
||||
msg += " " + message;
|
||||
util.dactyl.echomsg(msg);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the preference *name* to *value* but warns the user if the value
|
||||
* is changed from its default.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} value The new preference value.
|
||||
*/
|
||||
safeReset: function (name, message) {
|
||||
this._checkSafe(name, message);
|
||||
this.reset(name);
|
||||
this.reset(this.SAVED + name);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the preference *name* to *value* but warns the user if the value is
|
||||
* changed from its default.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} value The new preference value.
|
||||
*/
|
||||
safeSet: function (name, value, message, skipSave) {
|
||||
this._checkSafe(name, message, value);
|
||||
this._store(name, value);
|
||||
this[skipSave ? "reset" : "_store"](this.SAVED + name, value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the preference *name* to *value*.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
* @param {value} value The new preference value.
|
||||
*/
|
||||
set: function (name, value) {
|
||||
this._store(name, value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Saves the current value of a preference to be restored at next
|
||||
* startup.
|
||||
*
|
||||
* @param {string} name The preference to save.
|
||||
*/
|
||||
save: function (name) {
|
||||
let val = this.get(name);
|
||||
this.set(this.RESTORE + name, val);
|
||||
this.safeSet(name, val);
|
||||
},
|
||||
|
||||
/**
|
||||
* Restores saved preferences in the given branch.
|
||||
*
|
||||
* @param {string} branch The branch from which to restore
|
||||
* preferences. @optional
|
||||
*/
|
||||
restore: function (branch) {
|
||||
this.getNames(this.RESTORE + (branch || "")).forEach(function (pref) {
|
||||
this.safeSet(pref.substr(this.RESTORE.length), this.get(pref), null, true)
|
||||
this.reset(pref);
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the preference *name* to its default value.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
*/
|
||||
reset: function (name) {
|
||||
try {
|
||||
services.get("pref").clearUserPref(name);
|
||||
}
|
||||
catch (e) {} // ignore - thrown if not a user set value
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles the value of the boolean preference *name*.
|
||||
*
|
||||
* @param {string} name The preference name.
|
||||
*/
|
||||
toggle: function (name) {
|
||||
util.assert(services.get("pref").getPrefType(name) === Ci.nsIPrefBranch.PREF_BOOL,
|
||||
"E488: Trailing characters: " + name + "!");
|
||||
this.set(name, !this.get(name));
|
||||
},
|
||||
|
||||
/**
|
||||
* Pushes a new preference context onto the context stack.
|
||||
*
|
||||
* @see #withContext
|
||||
*/
|
||||
pushContext: function () {
|
||||
this._prefContexts.push({});
|
||||
},
|
||||
|
||||
/**
|
||||
* Pops the top preference context from the stack.
|
||||
*
|
||||
* @see #withContext
|
||||
*/
|
||||
popContext: function () {
|
||||
for (let [k, v] in Iterator(this._prefContexts.pop()))
|
||||
this._store(k, v);
|
||||
},
|
||||
|
||||
/**
|
||||
* Executes *func* with a new preference context. When *func* returns, the
|
||||
* context is popped and any preferences set via {@link #setPref} or
|
||||
* {@link #invertPref} are restored to their previous values.
|
||||
*
|
||||
* @param {function} func The function to call.
|
||||
* @param {Object} func The 'this' object with which to call *func*
|
||||
* @see #pushContext
|
||||
* @see #popContext
|
||||
*/
|
||||
withContext: function (func, self) {
|
||||
try {
|
||||
this.pushContext();
|
||||
return func.call(self);
|
||||
}
|
||||
finally {
|
||||
this.popContext();
|
||||
}
|
||||
},
|
||||
|
||||
_store: function (name, value) {
|
||||
if (this._prefContexts.length) {
|
||||
let val = this._load(name, null);
|
||||
if (val != null)
|
||||
this._prefContexts[this._prefContexts.length - 1][name] = val;
|
||||
}
|
||||
|
||||
function assertType(needType)
|
||||
util.assert(type === Ci.nsIPrefBranch.PREF_INVALID || type === needType,
|
||||
type === Ci.nsIPrefBranch.PREF_INT
|
||||
? "E521: Number required after =: " + name + "=" + value
|
||||
: "E474: Invalid argument: " + name + "=" + value);
|
||||
|
||||
let type = services.get("pref").getPrefType(name);
|
||||
switch (typeof value) {
|
||||
case "string":
|
||||
assertType(Ci.nsIPrefBranch.PREF_STRING);
|
||||
|
||||
let supportString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
|
||||
supportString.data = value;
|
||||
services.get("pref").setComplexValue(name, Ci.nsISupportsString, supportString);
|
||||
break;
|
||||
case "number":
|
||||
assertType(Ci.nsIPrefBranch.PREF_INT);
|
||||
|
||||
services.get("pref").setIntPref(name, value);
|
||||
break;
|
||||
case "boolean":
|
||||
assertType(Ci.nsIPrefBranch.PREF_BOOL);
|
||||
|
||||
services.get("pref").setBoolPref(name, value);
|
||||
break;
|
||||
default:
|
||||
throw FailedAssertion("Unknown preference type: " + typeof value + " (" + name + "=" + value + ")");
|
||||
}
|
||||
},
|
||||
|
||||
_load: function (name, defaultValue, defaultBranch) {
|
||||
if (defaultValue == null)
|
||||
defaultValue = null;
|
||||
|
||||
let branch = defaultBranch ? services.get("pref").getDefaultBranch("") : services.get("pref");
|
||||
let type = services.get("pref").getPrefType(name);
|
||||
try {
|
||||
switch (type) {
|
||||
case Ci.nsIPrefBranch.PREF_STRING:
|
||||
let value = branch.getComplexValue(name, Ci.nsISupportsString).data;
|
||||
// try in case it's a localized string (will throw an exception if not)
|
||||
if (!services.get("pref").prefIsLocked(name) && !services.get("pref").prefHasUserValue(name) &&
|
||||
RegExp("chrome://.+/locale/.+\\.properties").test(value))
|
||||
value = branch.getComplexValue(name, Ci.nsIPrefLocalizedString).data;
|
||||
return value;
|
||||
case Ci.nsIPrefBranch.PREF_INT:
|
||||
return branch.getIntPref(name);
|
||||
case Ci.nsIPrefBranch.PREF_BOOL:
|
||||
return branch.getBoolPref(name);
|
||||
default:
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
}, {
|
||||
completion: function (dactyl, modules) {
|
||||
modules.completion.preference = function preference(context) {
|
||||
context.anchored = false;
|
||||
context.title = [services.get("dactyl:").host + " Preference", "Value"];
|
||||
context.keys = { text: function (item) item, description: function (item) prefs.get(item) };
|
||||
context.completions = prefs.getNames();
|
||||
};
|
||||
},
|
||||
javascript: function (dactyl, modules) {
|
||||
modules.JavaScript.setCompleter([this.get, this.safeSet, this.set, this.reset, this.toggle],
|
||||
[function (context) (context.anchored=false, prefs.getNames().map(function (pref) [pref, ""]))]);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Math utility methods.
|
||||
|
||||
@@ -172,7 +172,7 @@ const Config = Module("config", ConfigBase, {
|
||||
this.showServicePane(true);
|
||||
else {
|
||||
let pane = document.getElementById(id);
|
||||
let manager = services.get("displayPaneManager");
|
||||
let manager = services.displayPaneManager;
|
||||
let paneinfo = manager.getPaneInfo(pane._lastURL.stringValue);
|
||||
|
||||
if (!paneinfo)
|
||||
@@ -272,12 +272,12 @@ const Config = Module("config", ConfigBase, {
|
||||
"boolean", true,
|
||||
{
|
||||
setter: function (value) {
|
||||
const ioService = services.get("io");
|
||||
const ioService = services.io;
|
||||
ioService.offline = !value;
|
||||
prefs.set("browser.offline", ioService.offline);
|
||||
return value;
|
||||
},
|
||||
getter: function () !services.get("io").offline
|
||||
getter: function () !services.io.offline
|
||||
});
|
||||
},
|
||||
services: function () {
|
||||
|
||||
@@ -49,7 +49,7 @@ const Library = Module("library", {
|
||||
* @returns {string[]}
|
||||
*/
|
||||
getTracks: function getTracks(artist, album) {
|
||||
let properties = services.create("mutablePropertyArray");
|
||||
let properties = services.MutablePropertyArray();
|
||||
|
||||
properties.appendProperty(SBProperties.artistName, artist);
|
||||
properties.appendProperty(SBProperties.albumName, album);
|
||||
|
||||
@@ -370,7 +370,7 @@ const Player = Module("player", {
|
||||
*/
|
||||
getMediaPages: function getMediaPages() {
|
||||
let list = SBGetBrowser().currentMediaPage.mediaListView.mediaList;
|
||||
let pages = services.get("mediaPageManager").getAvailablePages(list);
|
||||
let pages = services.mediaPageManager.getAvailablePages(list);
|
||||
return ArrayConverter.JSArray(pages).map(function (page) page.QueryInterface(Ci.sbIMediaPageInfo));
|
||||
},
|
||||
|
||||
@@ -383,7 +383,7 @@ const Player = Module("player", {
|
||||
* @param {sbIMediaView} view
|
||||
*/
|
||||
loadMediaPage: function loadMediaPage(page, list, view) {
|
||||
services.get("mediaPageManager").setPage(list, page);
|
||||
services.mediaPageManager.setPage(list, page);
|
||||
SBGetBrowser().loadMediaList(list, null, null, view, null);
|
||||
},
|
||||
|
||||
@@ -409,7 +409,7 @@ const Player = Module("player", {
|
||||
*/
|
||||
sortBy: function sortBy(field, ascending) {
|
||||
let order = ascending ? "a" : "d";
|
||||
let properties = services.create("mutablePropertyArray");
|
||||
let properties = services.MutablePropertyArray();
|
||||
properties.strict = false;
|
||||
|
||||
switch (field) {
|
||||
@@ -594,7 +594,7 @@ const Player = Module("player", {
|
||||
commands.add(["qu[eue]"],
|
||||
"Queue tracks by artist/album/track",
|
||||
function (args) {
|
||||
let properties = services.create("mutablePropertyArray");
|
||||
let properties = services.MutablePropertyArray();
|
||||
|
||||
// args
|
||||
switch (args.length) {
|
||||
|
||||
@@ -247,7 +247,7 @@ const Config = Module("config", ConfigBase, {
|
||||
completion: function () {
|
||||
var searchRunning = false; // only until Firefox fixes https://bugzilla.mozilla.org/show_bug.cgi?id=510589
|
||||
completion.location = function location(context) {
|
||||
if (!services.get("autoCompleteSearch"))
|
||||
if (!services.autoCompleteSearch)
|
||||
return;
|
||||
|
||||
context.anchored = false;
|
||||
@@ -262,12 +262,12 @@ const Config = Module("config", ConfigBase, {
|
||||
|
||||
context.cancel = function () {
|
||||
if (searchRunning) {
|
||||
services.get("autoCompleteSearch").stopSearch();
|
||||
services.autoCompleteSearch.stopSearch();
|
||||
searchRunning = false;
|
||||
}
|
||||
};
|
||||
if (searchRunning)
|
||||
services.get("autoCompleteSearch").stopSearch();
|
||||
services.autoCompleteSearch.stopSearch();
|
||||
let timer = new Timer(50, 100, function (result) {
|
||||
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
||||
context.completions = [
|
||||
@@ -275,7 +275,7 @@ const Config = Module("config", ConfigBase, {
|
||||
for (i in util.range(0, result.matchCount))
|
||||
];
|
||||
});
|
||||
services.get("autoCompleteSearch").startSearch(context.filter, "", context.result, {
|
||||
services.autoCompleteSearch.startSearch(context.filter, "", context.result, {
|
||||
onSearchResult: function onSearchResult(search, result) {
|
||||
timer.tell(result);
|
||||
if (result.searchResult <= result.RESULT_SUCCESS) {
|
||||
@@ -312,12 +312,12 @@ const Config = Module("config", ConfigBase, {
|
||||
"boolean", true,
|
||||
{
|
||||
setter: function (value) {
|
||||
const ioService = services.get("io");
|
||||
const ioService = services.io;
|
||||
if (ioService.offline == value)
|
||||
BrowserOffline.toggleOfflineStatus();
|
||||
return value;
|
||||
},
|
||||
getter: function () !services.get("io").offline
|
||||
getter: function () !services.io.offline
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ const Addressbook = Module("addressbook", {
|
||||
return "";
|
||||
},
|
||||
|
||||
getDirectoryFromURI: function (uri) services.get("rdf").GetResource(uri).QueryInterface(Ci.nsIAbDirectory),
|
||||
getDirectoryFromURI: function (uri) services.rdf.GetResource(uri).QueryInterface(Ci.nsIAbDirectory),
|
||||
|
||||
add: function (address, firstName, lastName, displayName) {
|
||||
const personalAddressbookURI = "moz-abmdbdirectory://abook.mab";
|
||||
|
||||
@@ -133,7 +133,7 @@ const Mail = Module("mail", {
|
||||
|
||||
/** @property {nsISmtpServer[]} The list of configured SMTP servers. */
|
||||
get smtpServers() {
|
||||
let servers = services.get("smtpService").smtpServers;
|
||||
let servers = services.smtpService.smtpServers;
|
||||
let ret = [];
|
||||
|
||||
while (servers.hasMoreElements()) {
|
||||
@@ -914,12 +914,12 @@ const Mail = Module("mail", {
|
||||
|
||||
options.add(["smtpserver", "smtp"],
|
||||
"Set the default SMTP server",
|
||||
"string", services.get("smtpService").defaultServer.key, // TODO: how should we handle these persistent external defaults - "inherit" or null?
|
||||
"string", services.smtpService.defaultServer.key, // TODO: how should we handle these persistent external defaults - "inherit" or null?
|
||||
{
|
||||
getter: function () services.get("smtpService").defaultServer.key,
|
||||
getter: function () services.smtpService.defaultServer.key,
|
||||
setter: function (value) {
|
||||
let server = mail.smtpServers.filter(function (s) s.key == value)[0];
|
||||
services.get("smtpService").defaultServer = server;
|
||||
services.smtpService.defaultServer = server;
|
||||
return value;
|
||||
},
|
||||
completer: function (context) [[s.key, s.serverURI] for ([, s] in Iterator(mail.smtpServers))]
|
||||
|
||||
Reference in New Issue
Block a user