summaryrefslogtreecommitdiffstats
path: root/comm/mail/extensions/openpgp/content/modules/singletons.jsm
blob: eb1d6f45df3f7c85525a7dfbc8323ed68316150b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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();