mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 18:07:58 +01:00
Add +purgecaches startup flag. Process startup flags in :restart. Don't purge caches on :rehash.
This commit is contained in:
@@ -853,7 +853,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @param {number} level The logging level 0 - 15.
|
* @param {number} level The logging level 0 - 15.
|
||||||
*/
|
*/
|
||||||
log: function (msg, level) {
|
log: function (msg, level) {
|
||||||
let verbose = localPrefs.get("loglevel", 0);
|
let verbose = config.prefs.get("loglevel", 0);
|
||||||
|
|
||||||
if (!level || level <= verbose) {
|
if (!level || level <= verbose) {
|
||||||
if (isObject(msg) && !isinstance(msg, _))
|
if (isObject(msg) && !isinstance(msg, _))
|
||||||
@@ -1110,10 +1110,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
/**
|
/**
|
||||||
* Restart the host application.
|
* Restart the host application.
|
||||||
*/
|
*/
|
||||||
restart: function () {
|
restart: function (args) {
|
||||||
if (!this.confirmQuit())
|
if (!this.confirmQuit())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
config.prefs.set("commandline-args", args);
|
||||||
|
|
||||||
services.appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
services.appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1579,17 +1581,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
bang: true
|
bang: true
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["reh[ash]"],
|
let startupOptions = [
|
||||||
"Reload the " + config.appName + " add-on",
|
|
||||||
function (args) {
|
|
||||||
if (args.trailing)
|
|
||||||
storage.session.rehashCmd = args.trailing; // Hack.
|
|
||||||
args.break = true;
|
|
||||||
util.rehash(args);
|
|
||||||
},
|
|
||||||
{
|
|
||||||
argCount: "0", // FIXME
|
|
||||||
options: [
|
|
||||||
{
|
{
|
||||||
names: ["+u"],
|
names: ["+u"],
|
||||||
description: "The initialization file to execute at startup",
|
description: "The initialization file to execute at startup",
|
||||||
@@ -1610,14 +1602,34 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
description: "Ex commands to execute after initialization",
|
description: "Ex commands to execute after initialization",
|
||||||
type: CommandOption.STRING,
|
type: CommandOption.STRING,
|
||||||
multiple: true
|
multiple: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
names: ["+purgecaches"],
|
||||||
|
description: "Purge " + config.appName + " caches at startup",
|
||||||
|
type: CommandOption.NOARG
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
|
commands.add(["reh[ash]"],
|
||||||
|
"Reload the " + config.appName + " add-on",
|
||||||
|
function (args) {
|
||||||
|
if (args.trailing)
|
||||||
|
storage.session.rehashCmd = args.trailing; // Hack.
|
||||||
|
args.break = true;
|
||||||
|
util.rehash(args);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
argCount: "0", // FIXME
|
||||||
|
options: startupOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["res[tart]"],
|
commands.add(["res[tart]"],
|
||||||
"Force " + config.host + " to restart",
|
"Force " + config.host + " to restart",
|
||||||
function () { dactyl.restart(); },
|
function (args) { dactyl.restart(args.string); },
|
||||||
{ argCount: "0" });
|
{
|
||||||
|
argCount: "0",
|
||||||
|
options: startupOptions
|
||||||
|
});
|
||||||
|
|
||||||
function findToolbar(name) DOM.XPath(
|
function findToolbar(name) DOM.XPath(
|
||||||
"//*[@toolbarname=" + util.escapeString(name, "'") + " or " +
|
"//*[@toolbarname=" + util.escapeString(name, "'") + " or " +
|
||||||
@@ -1821,7 +1833,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
|
|
||||||
dactyl.timeout(function () {
|
dactyl.timeout(function () {
|
||||||
try {
|
try {
|
||||||
var args = storage.session.commandlineArgs || services.commandLineHandler.optionValue;
|
var args = config.prefs.get("commandline-args")
|
||||||
|
|| storage.session.commandlineArgs
|
||||||
|
|| services.commandLineHandler.optionValue;
|
||||||
|
|
||||||
|
config.prefs.reset("commandline-args");
|
||||||
|
|
||||||
if (isString(args))
|
if (isString(args))
|
||||||
args = dactyl.parseCommandLine(args);
|
args = dactyl.parseCommandLine(args);
|
||||||
|
|
||||||
@@ -1839,9 +1856,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
|
|
||||||
dactyl.log(_("dactyl.commandlineOpts", util.objectToString(dactyl.commandLineOptions)), 3);
|
dactyl.log(_("dactyl.commandlineOpts", util.objectToString(dactyl.commandLineOptions)), 3);
|
||||||
|
|
||||||
if (localPrefs.get("first-run", true))
|
if (config.prefs.get("first-run", true))
|
||||||
dactyl.timeout(function () {
|
dactyl.timeout(function () {
|
||||||
localPrefs.set("first-run", false);
|
config.prefs.set("first-run", false);
|
||||||
this.withSavedValues(["forceTarget"], function () {
|
this.withSavedValues(["forceTarget"], function () {
|
||||||
this.forceTarget = dactyl.NEW_TAB;
|
this.forceTarget = dactyl.NEW_TAB;
|
||||||
help.help();
|
help.help();
|
||||||
|
|||||||
@@ -76,6 +76,18 @@
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags>+purgecaches</tags>
|
||||||
|
<strut/>
|
||||||
|
<spec>+purgecaches</spec>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Purges &dactyl.appName; caches at startup. May occasionally be
|
||||||
|
necessary after making local changes to the source tree.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<h2 tag="initialization startup">Initialization</h2>
|
<h2 tag="initialization startup">Initialization</h2>
|
||||||
|
|
||||||
<p>At startup, &dactyl.appName; completes the following tasks in order. </p>
|
<p>At startup, &dactyl.appName; completes the following tasks in order. </p>
|
||||||
@@ -182,10 +194,12 @@
|
|||||||
repository, this is a good way to update to the latest version or
|
repository, this is a good way to update to the latest version or
|
||||||
to test your changes.
|
to test your changes.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Any arguments supplied are parsed as command-line arguments as
|
Any arguments supplied are parsed as command-line arguments as
|
||||||
specified in <t>startup-options</t>.
|
specified in <t>startup-options</t>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<warning>
|
<warning>
|
||||||
Not all plugins are designed to cleanly un-apply during a rehash.
|
Not all plugins are designed to cleanly un-apply during a rehash.
|
||||||
While official plugins are safe, beware of possible instability
|
While official plugins are safe, beware of possible instability
|
||||||
@@ -196,9 +210,14 @@
|
|||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>:res :restart</tags>
|
<tags>:res :restart</tags>
|
||||||
<spec>:res<oa>tart</oa></spec>
|
<spec>:res<oa>tart</oa> <oa>arg</oa> …</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Force &dactyl.host; to restart. Useful when installing extensions.</p>
|
<p>Force &dactyl.host; to restart. Useful when installing extensions.</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Any arguments supplied are parsed as command-line arguments as
|
||||||
|
specified in <t>startup-options</t>.
|
||||||
|
</p>
|
||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ this.lazyRequire("addons", ["AddonManager"]);
|
|||||||
this.lazyRequire("cache", ["cache"]);
|
this.lazyRequire("cache", ["cache"]);
|
||||||
this.lazyRequire("highlight", ["highlight"]);
|
this.lazyRequire("highlight", ["highlight"]);
|
||||||
this.lazyRequire("messages", ["_"]);
|
this.lazyRequire("messages", ["_"]);
|
||||||
|
this.lazyRequire("prefs", ["localPrefs", "prefs"]);
|
||||||
|
|
||||||
function AboutHandler() {}
|
function AboutHandler() {}
|
||||||
AboutHandler.prototype = {
|
AboutHandler.prototype = {
|
||||||
@@ -66,6 +67,8 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get prefs() localPrefs,
|
||||||
|
|
||||||
get has() Set.has(this.features),
|
get has() Set.has(this.features),
|
||||||
|
|
||||||
configFiles: [
|
configFiles: [
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ var HelpBuilder = Class("HelpBuilder", {
|
|||||||
let result = [];
|
let result = [];
|
||||||
for (let base in values(this.bases)) {
|
for (let base in values(this.bases)) {
|
||||||
let url = [base, file, ".xml"].join("");
|
let url = [base, file, ".xml"].join("");
|
||||||
let res = util.httpGet(url);
|
let res = util.httpGet(url, { quiet: true });
|
||||||
if (res) {
|
if (res) {
|
||||||
if (res.responseXML.documentElement.localName == "document")
|
if (res.responseXML.documentElement.localName == "document")
|
||||||
this.files[file] = url;
|
this.files[file] = url;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ defineModule("options", {
|
|||||||
require: ["contexts", "messages", "storage"]
|
require: ["contexts", "messages", "storage"]
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
this.lazyRequire("config", ["config"]);
|
||||||
|
|
||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
let ValueError = Class("ValueError", ErrorBase);
|
let ValueError = Class("ValueError", ErrorBase);
|
||||||
@@ -947,7 +949,7 @@ var Options = Module("options", {
|
|||||||
setPref: deprecated("prefs.set", function setPref() prefs.set.apply(prefs, arguments)),
|
setPref: deprecated("prefs.set", function setPref() prefs.set.apply(prefs, arguments)),
|
||||||
withContext: deprecated("prefs.withContext", function withContext() prefs.withContext.apply(prefs, arguments)),
|
withContext: deprecated("prefs.withContext", function withContext() prefs.withContext.apply(prefs, arguments)),
|
||||||
|
|
||||||
cleanupPrefs: Class.Memoize(function () localPrefs.Branch("cleanup.option.")),
|
cleanupPrefs: Class.Memoize(function () config.prefs.Branch("cleanup.option.")),
|
||||||
|
|
||||||
cleanup: function cleanup(reason) {
|
cleanup: function cleanup(reason) {
|
||||||
if (~["disable", "uninstall"].indexOf(reason))
|
if (~["disable", "uninstall"].indexOf(reason))
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ var Item = Class("SanitizeItem", {
|
|||||||
shouldSanitize: function (shutdown) (!shutdown || this.builtin || this.persistent) &&
|
shouldSanitize: function (shutdown) (!shutdown || this.builtin || this.persistent) &&
|
||||||
prefs.get(shutdown ? this.shutdownPref : this.pref)
|
prefs.get(shutdown ? this.shutdownPref : this.pref)
|
||||||
}, {
|
}, {
|
||||||
PREFIX: localPrefs.branch.root,
|
PREFIX: config.prefs.branch.root,
|
||||||
BRANCH: "privacy.cpd.",
|
BRANCH: "privacy.cpd.",
|
||||||
SHUTDOWN_BRANCH: "privacy.clearOnShutdown."
|
SHUTDOWN_BRANCH: "privacy.clearOnShutdown."
|
||||||
});
|
});
|
||||||
@@ -290,8 +290,8 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get ranAtShutdown() localPrefs.get("didSanitizeOnShutdown"),
|
get ranAtShutdown() config.prefs.get("didSanitizeOnShutdown"),
|
||||||
set ranAtShutdown(val) localPrefs.set("didSanitizeOnShutdown", Boolean(val)),
|
set ranAtShutdown(val) config.prefs.set("didSanitizeOnShutdown", Boolean(val)),
|
||||||
get runAtShutdown() prefs.get("privacy.sanitize.sanitizeOnShutdown"),
|
get runAtShutdown() prefs.get("privacy.sanitize.sanitizeOnShutdown"),
|
||||||
set runAtShutdown(val) prefs.set("privacy.sanitize.sanitizeOnShutdown", Boolean(val)),
|
set runAtShutdown(val) prefs.set("privacy.sanitize.sanitizeOnShutdown", Boolean(val)),
|
||||||
|
|
||||||
|
|||||||
@@ -739,6 +739,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
return xmlhttp;
|
return xmlhttp;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
if (!params.quiet)
|
||||||
util.dactyl.log(_("error.cantOpen", String.quote(url), e), 1);
|
util.dactyl.log(_("error.cantOpen", String.quote(url), e), 1);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1183,7 +1184,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
rehash: function (args) {
|
rehash: function (args) {
|
||||||
storage.session.commandlineArgs = args;
|
storage.session.commandlineArgs = args;
|
||||||
this.timeout(function () {
|
this.timeout(function () {
|
||||||
cache.flushAll();
|
this.flushCache();
|
||||||
this.rehashing = true;
|
this.rehashing = true;
|
||||||
let addon = config.addon;
|
let addon = config.addon;
|
||||||
addon.userDisabled = true;
|
addon.userDisabled = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user