diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mail/base/content/msgSecurityPane.js | |
parent | Initial commit. (diff) | |
download | thunderbird-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/base/content/msgSecurityPane.js')
-rw-r--r-- | comm/mail/base/content/msgSecurityPane.js | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/comm/mail/base/content/msgSecurityPane.js b/comm/mail/base/content/msgSecurityPane.js new file mode 100644 index 0000000000..e8887363ce --- /dev/null +++ b/comm/mail/base/content/msgSecurityPane.js @@ -0,0 +1,111 @@ +/* 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 http://mozilla.org/MPL/2.0/. */ + +/** + * Functions related to the msgSecurityPane.inc.xhtml file, used in the message + * header to display S/MIME and OpenPGP encryption and signature info. + */ + +/* import-globals-from ../../../mailnews/extensions/smime/msgReadSMIMEOverlay.js */ +/* import-globals-from ../../extensions/openpgp/content/ui/enigmailMessengerOverlay.js */ +/* import-globals-from aboutMessage.js */ + +var { XPCOMUtils } = ChromeUtils.importESModule( + "resource://gre/modules/XPCOMUtils.sys.mjs" +); + +XPCOMUtils.defineLazyModuleGetters(this, { + EnigmailConstants: "chrome://openpgp/content/modules/constants.jsm", + EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.jsm", + EnigmailWindows: "chrome://openpgp/content/modules/windows.jsm", +}); + +var gSigKeyId = null; +var gEncKeyId = null; + +/** + * Reveal message security popup panel with updated OpenPGP or S/MIME info. + */ +function showMessageReadSecurityInfo() { + // Interrupt if no message is selected or no encryption technology was used. + if (!gMessage || document.getElementById("cryptoBox").hidden) { + return; + } + + // OpenPGP. + if (document.getElementById("cryptoBox").getAttribute("tech") === "OpenPGP") { + Enigmail.msg.loadOpenPgpMessageSecurityInfo(); + showMessageSecurityPanel(); + return; + } + + // S/MIME. + if (gSignatureStatus === Ci.nsICMSMessageErrors.VERIFY_NOT_YET_ATTEMPTED) { + showImapSignatureUnknown(); + return; + } + + loadSmimeMessageSecurityInfo(); + showMessageSecurityPanel(); +} + +/** + * Reveal the popup panel with the populated message security info. + */ +function showMessageSecurityPanel() { + document + .getElementById("messageSecurityPanel") + .openPopup( + document.getElementById("encryptionTechBtn"), + "bottomright topright", + 0, + 0, + false + ); +} + +/** + * Reset all values and clear the text of the message security popup panel. + */ +function onMessageSecurityPopupHidden() { + // Clear the variables for signature and encryption. + gSigKeyId = null; + gEncKeyId = null; + + // Hide the UI elements. + document.getElementById("signatureHeader").collapsed = true; + document.getElementById("encryptionHeader").collapsed = true; + document.getElementById("signatureCert").collapsed = true; + document.getElementById("signatureKey").collapsed = true; + document.getElementById("viewSignatureKey").collapsed = true; + document.getElementById("encryptionKey").collapsed = true; + document.getElementById("encryptionCert").collapsed = true; + document.getElementById("viewEncryptionKey").collapsed = true; + document.getElementById("otherEncryptionKeys").collapsed = true; + + let keyList = document.getElementById("otherEncryptionKeysList"); + // Clear any possible existing key previously appended to the DOM. + for (let node of keyList.children) { + keyList.removeChild(node); + } +} + +async function viewSignatureKey() { + if (!gSigKeyId) { + return; + } + + // If the signature acceptance was edited, reload the current message. + if (await EnigmailWindows.openKeyDetails(window, gSigKeyId, false)) { + ReloadMessage(); + } +} + +function viewEncryptionKey() { + if (!gEncKeyId) { + return; + } + + EnigmailWindows.openKeyDetails(window, gEncKeyId, false); +} |