summaryrefslogtreecommitdiffstats
path: root/comm/mail/extensions/openpgp/content/modules/singletons.jsm
diff options
context:
space:
mode:
Diffstat (limited to 'comm/mail/extensions/openpgp/content/modules/singletons.jsm')
-rw-r--r--comm/mail/extensions/openpgp/content/modules/singletons.jsm54
1 files changed, 54 insertions, 0 deletions
diff --git a/comm/mail/extensions/openpgp/content/modules/singletons.jsm b/comm/mail/extensions/openpgp/content/modules/singletons.jsm
new file mode 100644
index 0000000000..eb1d6f45df
--- /dev/null
+++ b/comm/mail/extensions/openpgp/content/modules/singletons.jsm
@@ -0,0 +1,54 @@
+/* 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 EXPORTED_SYMBOLS = ["EnigmailSingletons"];
+
+var EnigmailSingletons = {
+ // handle to most recent message reader window
+ messageReader: null,
+
+ // information about the last PGP/MIME decrypted message (mimeDecrypt)
+ lastDecryptedMessage: {},
+ lastMessageDecryptTime: 0,
+
+ clearLastDecryptedMessage() {
+ let lm = this.lastDecryptedMessage;
+ lm.lastMessageData = "";
+ lm.lastMessageURI = null;
+ lm.mimePartNumber = "";
+ lm.lastStatus = {};
+ lm.gossip = [];
+ },
+
+ isLastDecryptedMessagePart(folder, msgNum, mimePartNumber) {
+ let reval =
+ this.lastDecryptedMessage.lastMessageURI &&
+ this.lastDecryptedMessage.lastMessageURI.folder == folder &&
+ this.lastDecryptedMessage.lastMessageURI.msgNum == msgNum &&
+ this.lastDecryptedMessage.mimePartNumber == mimePartNumber;
+ return reval;
+ },
+
+ urisWithNestedEncryptedParts: [],
+
+ maxRecentSubEncryptionUrisToRemember: 10,
+
+ addUriWithNestedEncryptedPart(uri) {
+ if (
+ this.urisWithNestedEncryptedParts.length >
+ this.maxRecentSubEncryptionUrisToRemember
+ ) {
+ this.urisWithNestedEncryptedParts.shift(); // remove oldest
+ }
+ this.urisWithNestedEncryptedParts.push(uri);
+ },
+
+ isRecentUriWithNestedEncryptedPart(uri) {
+ return this.urisWithNestedEncryptedParts.includes(uri);
+ },
+};
+
+EnigmailSingletons.clearLastDecryptedMessage();