mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 18:27:57 +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.
|
||||
*/
|
||||
log: function (msg, level) {
|
||||
let verbose = localPrefs.get("loglevel", 0);
|
||||
let verbose = config.prefs.get("loglevel", 0);
|
||||
|
||||
if (!level || level <= verbose) {
|
||||
if (isObject(msg) && !isinstance(msg, _))
|
||||
@@ -1110,10 +1110,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
/**
|
||||
* Restart the host application.
|
||||
*/
|
||||
restart: function () {
|
||||
restart: function (args) {
|
||||
if (!this.confirmQuit())
|
||||
return;
|
||||
|
||||
config.prefs.set("commandline-args", args);
|
||||
|
||||
services.appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||
},
|
||||
|
||||
@@ -1579,6 +1581,35 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
bang: true
|
||||
});
|
||||
|
||||
let startupOptions = [
|
||||
{
|
||||
names: ["+u"],
|
||||
description: "The initialization file to execute at startup",
|
||||
type: CommandOption.STRING
|
||||
},
|
||||
{
|
||||
names: ["++noplugin"],
|
||||
description: "Do not automatically load plugins"
|
||||
},
|
||||
{
|
||||
names: ["++cmd"],
|
||||
description: "Ex commands to execute prior to initialization",
|
||||
type: CommandOption.STRING,
|
||||
multiple: true
|
||||
},
|
||||
{
|
||||
names: ["+c"],
|
||||
description: "Ex commands to execute after initialization",
|
||||
type: CommandOption.STRING,
|
||||
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) {
|
||||
@@ -1589,35 +1620,16 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
},
|
||||
{
|
||||
argCount: "0", // FIXME
|
||||
options: [
|
||||
{
|
||||
names: ["+u"],
|
||||
description: "The initialization file to execute at startup",
|
||||
type: CommandOption.STRING
|
||||
},
|
||||
{
|
||||
names: ["++noplugin"],
|
||||
description: "Do not automatically load plugins"
|
||||
},
|
||||
{
|
||||
names: ["++cmd"],
|
||||
description: "Ex commands to execute prior to initialization",
|
||||
type: CommandOption.STRING,
|
||||
multiple: true
|
||||
},
|
||||
{
|
||||
names: ["+c"],
|
||||
description: "Ex commands to execute after initialization",
|
||||
type: CommandOption.STRING,
|
||||
multiple: true
|
||||
}
|
||||
]
|
||||
options: startupOptions
|
||||
});
|
||||
|
||||
commands.add(["res[tart]"],
|
||||
"Force " + config.host + " to restart",
|
||||
function () { dactyl.restart(); },
|
||||
{ argCount: "0" });
|
||||
function (args) { dactyl.restart(args.string); },
|
||||
{
|
||||
argCount: "0",
|
||||
options: startupOptions
|
||||
});
|
||||
|
||||
function findToolbar(name) DOM.XPath(
|
||||
"//*[@toolbarname=" + util.escapeString(name, "'") + " or " +
|
||||
@@ -1821,7 +1833,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
dactyl.timeout(function () {
|
||||
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))
|
||||
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);
|
||||
|
||||
if (localPrefs.get("first-run", true))
|
||||
if (config.prefs.get("first-run", true))
|
||||
dactyl.timeout(function () {
|
||||
localPrefs.set("first-run", false);
|
||||
config.prefs.set("first-run", false);
|
||||
this.withSavedValues(["forceTarget"], function () {
|
||||
this.forceTarget = dactyl.NEW_TAB;
|
||||
help.help();
|
||||
|
||||
@@ -76,6 +76,18 @@
|
||||
</description>
|
||||
</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>
|
||||
|
||||
<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
|
||||
to test your changes.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Any arguments supplied are parsed as command-line arguments as
|
||||
specified in <t>startup-options</t>.
|
||||
</p>
|
||||
|
||||
<warning>
|
||||
Not all plugins are designed to cleanly un-apply during a rehash.
|
||||
While official plugins are safe, beware of possible instability
|
||||
@@ -196,9 +210,14 @@
|
||||
|
||||
<item>
|
||||
<tags>:res :restart</tags>
|
||||
<spec>:res<oa>tart</oa></spec>
|
||||
<spec>:res<oa>tart</oa> <oa>arg</oa> …</spec>
|
||||
<description short="true">
|
||||
<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>
|
||||
</item>
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ this.lazyRequire("addons", ["AddonManager"]);
|
||||
this.lazyRequire("cache", ["cache"]);
|
||||
this.lazyRequire("highlight", ["highlight"]);
|
||||
this.lazyRequire("messages", ["_"]);
|
||||
this.lazyRequire("prefs", ["localPrefs", "prefs"]);
|
||||
|
||||
function AboutHandler() {}
|
||||
AboutHandler.prototype = {
|
||||
@@ -66,6 +67,8 @@ var ConfigBase = Class("ConfigBase", {
|
||||
});
|
||||
},
|
||||
|
||||
get prefs() localPrefs,
|
||||
|
||||
get has() Set.has(this.features),
|
||||
|
||||
configFiles: [
|
||||
|
||||
@@ -57,7 +57,7 @@ var HelpBuilder = Class("HelpBuilder", {
|
||||
let result = [];
|
||||
for (let base in values(this.bases)) {
|
||||
let url = [base, file, ".xml"].join("");
|
||||
let res = util.httpGet(url);
|
||||
let res = util.httpGet(url, { quiet: true });
|
||||
if (res) {
|
||||
if (res.responseXML.documentElement.localName == "document")
|
||||
this.files[file] = url;
|
||||
|
||||
@@ -14,6 +14,8 @@ defineModule("options", {
|
||||
require: ["contexts", "messages", "storage"]
|
||||
}, this);
|
||||
|
||||
this.lazyRequire("config", ["config"]);
|
||||
|
||||
/** @scope modules */
|
||||
|
||||
let ValueError = Class("ValueError", ErrorBase);
|
||||
@@ -947,7 +949,7 @@ var Options = Module("options", {
|
||||
setPref: deprecated("prefs.set", function setPref() prefs.set.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) {
|
||||
if (~["disable", "uninstall"].indexOf(reason))
|
||||
|
||||
@@ -55,7 +55,7 @@ var Item = Class("SanitizeItem", {
|
||||
shouldSanitize: function (shutdown) (!shutdown || this.builtin || this.persistent) &&
|
||||
prefs.get(shutdown ? this.shutdownPref : this.pref)
|
||||
}, {
|
||||
PREFIX: localPrefs.branch.root,
|
||||
PREFIX: config.prefs.branch.root,
|
||||
BRANCH: "privacy.cpd.",
|
||||
SHUTDOWN_BRANCH: "privacy.clearOnShutdown."
|
||||
});
|
||||
@@ -290,8 +290,8 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
}
|
||||
},
|
||||
|
||||
get ranAtShutdown() localPrefs.get("didSanitizeOnShutdown"),
|
||||
set ranAtShutdown(val) localPrefs.set("didSanitizeOnShutdown", Boolean(val)),
|
||||
get ranAtShutdown() config.prefs.get("didSanitizeOnShutdown"),
|
||||
set ranAtShutdown(val) config.prefs.set("didSanitizeOnShutdown", Boolean(val)),
|
||||
get runAtShutdown() prefs.get("privacy.sanitize.sanitizeOnShutdown"),
|
||||
set runAtShutdown(val) prefs.set("privacy.sanitize.sanitizeOnShutdown", Boolean(val)),
|
||||
|
||||
|
||||
@@ -739,7 +739,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
return xmlhttp;
|
||||
}
|
||||
catch (e) {
|
||||
util.dactyl.log(_("error.cantOpen", String.quote(url), e), 1);
|
||||
if (!params.quiet)
|
||||
util.dactyl.log(_("error.cantOpen", String.quote(url), e), 1);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
@@ -1183,7 +1184,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
rehash: function (args) {
|
||||
storage.session.commandlineArgs = args;
|
||||
this.timeout(function () {
|
||||
cache.flushAll();
|
||||
this.flushCache();
|
||||
this.rehashing = true;
|
||||
let addon = config.addon;
|
||||
addon.userDisabled = true;
|
||||
|
||||
Reference in New Issue
Block a user