summaryrefslogtreecommitdiffstats
path: root/comm/mail/extensions/openpgp/content/ui/enigmailCommon.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mail/extensions/openpgp/content/ui/enigmailCommon.js
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/mail/extensions/openpgp/content/ui/enigmailCommon.js')
-rw-r--r--comm/mail/extensions/openpgp/content/ui/enigmailCommon.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/comm/mail/extensions/openpgp/content/ui/enigmailCommon.js b/comm/mail/extensions/openpgp/content/ui/enigmailCommon.js
new file mode 100644
index 0000000000..ea02824856
--- /dev/null
+++ b/comm/mail/extensions/openpgp/content/ui/enigmailCommon.js
@@ -0,0 +1,69 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ */
+
+"use strict";
+
+var { EnigmailCore } = ChromeUtils.import(
+ "chrome://openpgp/content/modules/core.jsm"
+);
+var { RNP } = ChromeUtils.import("chrome://openpgp/content/modules/RNP.jsm");
+
+var l10nCommon = new Localization(["messenger/openpgp/openpgp.ftl"], true);
+
+var gEnigmailSvc;
+function GetEnigmailSvc() {
+ if (!gEnigmailSvc) {
+ gEnigmailSvc = EnigmailCore.getService(window);
+ }
+ return gEnigmailSvc;
+}
+
+async function EnigRevokeKey(keyObj, callbackFunc) {
+ var enigmailSvc = GetEnigmailSvc();
+ if (!enigmailSvc) {
+ return;
+ }
+
+ if (keyObj.keyTrust == "r") {
+ Services.prompt.alert(
+ null,
+ document.title,
+ l10nCommon.formatValueSync("already-revoked")
+ );
+ return;
+ }
+
+ let promptFlags =
+ Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
+ Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL;
+
+ let confirm = Services.prompt.confirmEx(
+ window,
+ l10nCommon.formatValueSync("openpgp-key-revoke-title"),
+ l10nCommon.formatValueSync("revoke-key-question", {
+ identity: `0x${keyObj.keyId} - ${keyObj.userId}`,
+ }),
+ promptFlags,
+ l10nCommon.formatValueSync("key-man-button-revoke-key"),
+ null,
+ null,
+ null,
+ {}
+ );
+
+ if (confirm != 0) {
+ return;
+ }
+
+ await RNP.revokeKey(keyObj.fpr);
+ callbackFunc(true);
+
+ Services.prompt.alert(
+ null,
+ l10nCommon.formatValueSync("openpgp-key-revoke-success"),
+ l10nCommon.formatValueSync("after-revoke-info")
+ );
+}