mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-29 03:45:46 +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 () {
|
||||
|
||||
Reference in New Issue
Block a user