Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._downloadFile(asset.browser_download_url, function(file)
{
log.debug("Importing " + file + " as scheme " + pkg.name);
var schemeName = asset.browser_download_url.split(/\/|\./).slice(-2)[0];
var schemeService = Cc['@activestate.com/koKeybindingSchemeService;1'].getService();
// Refresh the list of known schemes.
schemeService.reloadAvailableSchemes();
keybindings.manager.reloadConfigurations(true); // refresh
callback(); // indicate success before potentially restarting
// Prompt the user to apply the new scheme.
if (dialog.confirm(l.get("applyKeybinds.prompt")))
{
log.debug("Applying scheme " + schemeName);
keybindings.manager.revertToPref(schemeName); // probably not the intended use, but it works
require("notify/notify").interact(l.get("keybindingsApplied", pkg.name), "packages", {id: "packageInstall"});
}
commando.focus();
}, errorCallback, OS.Path.join(dirService.userDataDir, 'schemes'));
break;
this._downloadFile(asset.browser_download_url, function(file)
{
log.debug("Importing " + file + " as scheme " + pkg.name);
var schemeService = Cc['@activestate.com/koScintillaSchemeService;1'].getService();
var scheme = schemeService.loadSchemeFromURI(file, pkg.name);
// Ask the user if the scheme should be applied immediately.
if (dialog.confirm(l.get("applyScheme.prompt"),
{
yes: l.get("applySchemeNow.label"),
no: l.get("applySchemeLater.label"),
response: l.get("applySchemeNow.label")
}))
{
schemeService.activateScheme(scheme);
require("notify/notify").interact(l.get("schemeApplied", pkg.name), "packages", {id: "packageInstall"});
}
commando.focus();
// TODO: delete temporary file.
callback();
}, errorCallback);
break;
addon.uninstall();
}
catch (e)
{
log.exception(e, "addon uninstall failed for " + pkg.name);
errorCallback();
return;
}
// Prompt for restart if necessary.
log.debug("Package pending operations: " + addon.pendingOperations);
callback(); // indicate success before potentially restarting
if ((addon.pendingOperations & AddonManager.PENDING_DISABLE) ||
(addon.pendingOperations & AddonManager.PENDING_UNINSTALL))
{
log.debug("Package requires Komodo restart.");
if (dialog.confirm(l.get("restartKomodoAfterUninstall.prompt"),
{
yes: l.get("restartNow.label"),
no: l.get("restartLater.label"),
response: l.get("restartLater.label")
}))
{
utils.restart(true);
}
commando.focus();
}
}
break;
case TOOLBOX:
case MACROS:
// TODO: differentiate between the two.
// Uninstall the tool via Komodo's toolbox manager.
this._downloadFile(asset.browser_download_url, function(file)
{
log.debug("Importing " + file + " as scheme " + pkg.name);
var schemeService = Cc['@activestate.com/koScintillaSchemeService;1'].getService();
var scheme = schemeService.loadSchemeFromURI(file, pkg.name);
// Ask the user if the scheme should be applied immediately.
if (dialog.confirm(l.get("applyScheme.prompt"),
{
yes: l.get("applySchemeNow.label"),
no: l.get("applySchemeLater.label"),
response: l.get("applySchemeNow.label")
}))
{
schemeService.activateScheme(scheme);
require("notify/notify").interact(l.get("schemeApplied", pkg.name), "packages", {id: "packageInstall"});
}
commando.focus();
// TODO: delete temporary file.
callback();
}, errorCallback);
break;
onInstallEnded: function(aInstall, addon) {
log.info("Package successfully installed.");
this.callback(); // indicate success before potentially restarting
log.debug("Package pending operations: " + addon.pendingOperations);
if ((addon.pendingOperations & AddonManager.PENDING_ENABLE) ||
(addon.pendingOperations & AddonManager.PENDING_INSTALL) ||
(addon.pendingOperations & AddonManager.PENDING_UPGRADE))
{
log.debug("Package requires Komodo restart.");
var locale;
if (this.package.kind == SKINS)
locale = l.get("restartKomodoAfterSkinInstall.prompt", this.package.name)
else if (this.package.kind == LANGS)
locale = l.get("restartKomodoAfterLangInstall.prompt", this.package.name)
else
locale = l.get("restartKomodoAfterInstall.prompt");
if (dialog.confirm(locale,
{
yes: l.get("restartNow.label"),
no: l.get("restartLater.label"),
response: l.get("restartLater.label")
}))
{
utils.restart(true);
}
commando.focus();
}
else
{
if (this.package.kind == SKINS)
{
if (dialog.confirm(l.get("skinInstalledOpenPrefs.prompt", this.package.name)))
var done = function(locale, priority = "notification")
{
window.clearTimeout(timeout);
require("notify/notify").interact(l.get(locale, "addon"), "packages", {id: "packageInstall", priority: priority});
if (commando.isOpen()) commando.unblock();
packages.clearCaches();
if (callback)
callback();
else
{
if (commando.isOpen()) commando.refresh();
}
};
locale: l.get(SCHEMES),
icon: "koicon://ko-svg/chrome/icomoon/skin/text-color.svg?size=16",
weight: 7
};
results[SKINS] = {
locale: l.get(SKINS),
icon: "koicon://ko-svg/chrome/icomoon/skin/palette.svg?size=16",
weight: 6
};
results[LANGS] = {
locale: l.get(LANGS),
icon: "koicon://ko-svg/chrome/icomoon/skin/globe2.svg?size=16",
weight: 5
};
results[KEYBINDS] = {
locale: l.get(KEYBINDS),
icon: "koicon://ko-svg/chrome/icomoon/skin/keyboard.svg?size=16",
weight: 4
};
this.getPackageKinds.__cached = results;
return results;
}
locale: l.get(TOOLBOX),
icon: "koicon://ko-svg/chrome/icomoon/skin/briefcase3.svg?size=16",
weight: 8
};
results[SCHEMES] = {
locale: l.get(SCHEMES),
icon: "koicon://ko-svg/chrome/icomoon/skin/text-color.svg?size=16",
weight: 7
};
results[SKINS] = {
locale: l.get(SKINS),
icon: "koicon://ko-svg/chrome/icomoon/skin/palette.svg?size=16",
weight: 6
};
results[LANGS] = {
locale: l.get(LANGS),
icon: "koicon://ko-svg/chrome/icomoon/skin/globe2.svg?size=16",
weight: 5
};
results[KEYBINDS] = {
locale: l.get(KEYBINDS),
icon: "koicon://ko-svg/chrome/icomoon/skin/keyboard.svg?size=16",
weight: 4
};
this.getPackageKinds.__cached = results;
return results;
}
locale: l.get(MACROS),
icon: "koicon://ko-svg/chrome/icomoon/skin/play3.svg?size=16",
weight: 9
};
results[TOOLBOX] = {
locale: l.get(TOOLBOX),
icon: "koicon://ko-svg/chrome/icomoon/skin/briefcase3.svg?size=16",
weight: 8
};
results[SCHEMES] = {
locale: l.get(SCHEMES),
icon: "koicon://ko-svg/chrome/icomoon/skin/text-color.svg?size=16",
weight: 7
};
results[SKINS] = {
locale: l.get(SKINS),
icon: "koicon://ko-svg/chrome/icomoon/skin/palette.svg?size=16",
weight: 6
};
results[LANGS] = {
locale: l.get(LANGS),
icon: "koicon://ko-svg/chrome/icomoon/skin/globe2.svg?size=16",
weight: 5
};
results[KEYBINDS] = {
locale: l.get(KEYBINDS),
icon: "koicon://ko-svg/chrome/icomoon/skin/keyboard.svg?size=16",
weight: 4
};
this.getPackageKinds.__cached = results;
var done = function(locale, priority = "notification")
{
window.clearTimeout(timeout);
require("notify/notify").interact(l.get(locale, pkg.name), "packages", {id: "packageInstall", priority: priority});
commando.unblock();
packages.clearCaches();
if (callback)
callback();
else
commando.refresh();
};