//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
-"use strict";
+/* use strict */
try {
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("addons", {
exports: ["AddonManager", "Addons", "Addon", "addons"],
- require: ["services"],
- use: ["completion", "config", "io", "messages", "prefs", "template", "util"]
+ require: ["services"]
}, this);
var callResult = function callResult(method) {
},
onUpdateAvailable: function (addon, install) {
- util.dump("onUpdateAvailable");
this.upgrade.push(addon);
install.addListener(this);
install.install();
var actions = {
delete: {
- name: "extde[lete]",
+ name: ["extde[lete]", "extrm"],
description: "Uninstall an extension",
action: callResult("uninstall"),
perm: "uninstall"
name: "extr[ehash]",
description: "Reload an extension",
action: function (addon) {
- util.assert(util.haveGecko("2b"), _("command.notUseful", config.host));
+ util.assert(config.haveGecko("2b"), _("command.notUseful", config.host));
+ util.flushCache();
util.timeout(function () {
addon.userDisabled = true;
addon.userDisabled = false;
});
},
get filter() {
- let ids = Set(keys(JSON.parse(prefs.get("extensions.bootstrappedAddons", "{}"))));
- return function ({ item }) !item.userDisabled && Set.has(ids, item.id);
+ return function ({ item }) !item.userDisabled &&
+ !(item.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE | AddonManager.OP_NEEDS_RESTART_DISABLE))
},
perm: "disable"
},
<tr highlight="Addon" key="row" xmlns:dactyl={NS} xmlns={XHTML}>
<td highlight="AddonName" key="name"/>
<td highlight="AddonVersion" key="version"/>
- <td highlight="AddonStatus" key="status"/>
<td highlight="AddonButtons Buttons">
<a highlight="Button" href="javascript:0" key="enable">{_("addon.action.On")}</a>
<a highlight="Button" href="javascript:0" key="disable">{_("addon.action.Off")}</a>
<a highlight="Button" href="javascript:0" key="update">{_("addon.action.Update")}</a>
<a highlight="Button" href="javascript:0" key="options">{_("addon.action.Options")}</a>
</td>
+ <td highlight="AddonStatus" key="status"/>
<td highlight="AddonDescription" key="description"/>
</tr>,
this.list.document, this.nodes);
this.nodes.version.textContent = this.version;
update("status", this.statusInfo);
this.nodes.description.textContent = this.description;
+ DOM(this.nodes.row).attr("active", this.isActive || null);
for (let node in values(this.nodes))
if (node.update && node.update !== callee)
this.update();
},
- message: Class.memoize(function () {
+ message: Class.Memoize(function () {
XML.ignoreWhitespace = true;
util.xmlToDom(<table highlight="Addons" key="list" xmlns={XHTML}>
<tr highlight="AddonHead">
<td>{_("title.Name")}</td>
<td>{_("title.Version")}</td>
- <td>{_("title.Status")}</td>
<td/>
+ <td>{_("title.Status")}</td>
<td>{_("title.Description")}</td>
</tr>
</table>, this.document, this.nodes);
});
var Addons = Module("addons", {
- errors: Class.memoize(function ()
+ errors: Class.Memoize(function ()
array(["ERROR_NETWORK_FAILURE", "ERROR_INCORRECT_HASH",
"ERROR_CORRUPT_FILE", "ERROR_FILE_ACCESS"])
.map(function (e) [AddonManager[e], _("AddonManager." + e)])
AddonManager.getAddonsByTypes(args["-types"], dactyl.wrapCallback(function (list) {
if (!args.bang || command.bang) {
- list = list.filter(function (extension) extension.name == name);
- if (list.length == 0)
- return void dactyl.echoerr(_("error.invalidArgument", name));
- if (!list.every(ok))
- return void dactyl.echoerr(_("error.invalidOperation"));
+ list = list.filter(function (addon) addon.id == name || addon.name == name);
+ dactyl.assert(list.length, _("error.invalidArgument", name));
+ dactyl.assert(list.some(ok), _("error.invalidOperation"));
+ list = list.filter(ok);
}
if (command.actions)
command.actions(list, this.modules);
argCount: "?", // FIXME: should be "1"
bang: true,
completer: function (context, args) {
- completion.extension(context, args["-types"]);
+ completion.addon(context, args["-types"]);
context.filters.push(function ({ item }) ok(item));
if (command.filter)
context.filters.push(command.filter);
};
};
- completion.extension = function extension(context, types) {
- context.title = ["Extension"];
+ completion.addon = function addon(context, types) {
+ context.title = ["Add-on"];
context.anchored = false;
- context.keys = { text: "name", description: "description", icon: "iconURL" },
+ context.keys = {
+ text: function (addon) [addon.name, addon.id],
+ description: "description",
+ icon: "iconURL"
+ };
context.generate = function () {
context.incomplete = true;
AddonManager.getAddonsByTypes(types || ["extension"], function (addons) {
return "";
},
- installLocation: Class.memoize(function () services.extensionManager.getInstallLocation(this.id)),
+ installLocation: Class.Memoize(function () services.extensionManager.getInstallLocation(this.id)),
getResourceURI: function getResourceURI(path) {
let file = this.installLocation.getItemFile(this.id, path);
return services.io.newFileURI(file);