|
|
|
@ -14,7 +14,6 @@
|
|
|
|
|
* along with p≡p For Thunderbird. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
|
|
|
|
var { pEp } = ChromeUtils.import("chrome://pEp4Tb/content/modules/pEp.js");
|
|
|
|
|
var { pEpFactory } = ChromeUtils.import("chrome://pEp4Tb/content/pEpFactory.js");
|
|
|
|
|
var { TbHelper } = ChromeUtils.import("chrome://pEp4Tb/content/TbHelper.js");
|
|
|
|
@ -59,10 +58,6 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
this.newMessageKeys = [];
|
|
|
|
|
this.pollSession = null;
|
|
|
|
|
this.clientID = null;
|
|
|
|
|
this.protectSubjects = true;
|
|
|
|
|
|
|
|
|
|
this.MOZ_APP_VERSION = parseInt(AppConstants.MOZ_APP_VERSION, 10);
|
|
|
|
|
this.platform = AppConstants.platform;
|
|
|
|
|
|
|
|
|
|
// Note that the superclass pEp populates this.logger and this.adapter.
|
|
|
|
|
}
|
|
|
|
@ -106,11 +101,11 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
MailServices.mfn.addListener(this, Ci.nsIMsgFolderNotificationService.msgAdded);
|
|
|
|
|
|
|
|
|
|
// Check adapter version.
|
|
|
|
|
const MIN_REQUIRED_VERSION = "0.22.0";
|
|
|
|
|
const MIN_REQUIRED_VERSION = "0.21.0";
|
|
|
|
|
let version = this.synchronise(this.serverVersion());
|
|
|
|
|
this.log.info(`Adapter version ${version.api_version} (${version.name})`);
|
|
|
|
|
let win = Services.wm.getMostRecentWindow("mail:3pane");
|
|
|
|
|
if (Services.vc.compare(version.api_version, MIN_REQUIRED_VERSION) < 0) {
|
|
|
|
|
let win = Services.wm.getMostRecentWindow("mail:3pane");
|
|
|
|
|
Services.prompt.alert(
|
|
|
|
|
win,
|
|
|
|
|
this.localeMessagesMap.get("alerttitle"),
|
|
|
|
@ -129,25 +124,9 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
// Setup protect subjects at startup
|
|
|
|
|
if (Services.prefs.getBoolPref("extensions.pEp.protectSubjects", true)) {
|
|
|
|
|
this.enableprotectSubjects();
|
|
|
|
|
this.protectSubjects = true;
|
|
|
|
|
} else {
|
|
|
|
|
this.disableprotectSubjects();
|
|
|
|
|
this.protectSubjects = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Import keys from RNP starting at Thunderbird 78.
|
|
|
|
|
if (this.MOZ_APP_VERSION >= 78 &&
|
|
|
|
|
Services.prefs.getBoolPref("extensions.pEp.importRNP", false)) {
|
|
|
|
|
let { ImportRNP } = ChromeUtils.import("chrome://pEp4Tb/content/importRNP.js");
|
|
|
|
|
for (let identity of fixIterator(MailServices.accounts.allIdentities, Ci.nsIMsgIdentity)) {
|
|
|
|
|
if (Services.prefs.getStringPref(`mail.identity.${identity.key}.openpgp_key_id`, "")) {
|
|
|
|
|
// Looks like OpenPGP was configured, so let's import.
|
|
|
|
|
ImportRNP.importWithUI(this, win);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Services.prefs.setBoolPref("extensions.pEp.importRNP", false);
|
|
|
|
|
|
|
|
|
|
// The following doesn't start the Sync, it just sets up polling, etc.
|
|
|
|
|
TbSync.setupSync(this);
|
|
|
|
@ -246,11 +225,7 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
this.searchListener = {
|
|
|
|
|
onSearchHit(msgHdr, folder) {
|
|
|
|
|
if (new Date(Date.now() - msgHdr.date / 1000) >= 600 * 1000) {
|
|
|
|
|
if (this.MOZ_APP_VERSION >= 85) {
|
|
|
|
|
this.msgs.push(msgHdr);
|
|
|
|
|
} else {
|
|
|
|
|
this.msgs.appendElement(msgHdr);
|
|
|
|
|
}
|
|
|
|
|
this.msgs.appendElement(msgHdr);
|
|
|
|
|
this.count++;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
@ -259,11 +234,7 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
if (this.count) inbox.deleteMessages(this.msgs, null, true, false, null, false);
|
|
|
|
|
},
|
|
|
|
|
onNewSearch() {
|
|
|
|
|
if (this.MOZ_APP_VERSION >= 85) {
|
|
|
|
|
this.msgs = [];
|
|
|
|
|
} else {
|
|
|
|
|
this.msgs = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
|
|
|
|
}
|
|
|
|
|
this.msgs = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
|
|
|
|
this.count = 0;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
@ -286,20 +257,11 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
if (!pEpFolder) continue;
|
|
|
|
|
|
|
|
|
|
// Check for message older than 10 minutes.
|
|
|
|
|
let msgs;
|
|
|
|
|
if (this.MOZ_APP_VERSION >= 85) {
|
|
|
|
|
msgs = [];
|
|
|
|
|
} else {
|
|
|
|
|
msgs = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
|
|
|
|
}
|
|
|
|
|
let msgs = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
|
|
|
|
let count = 0;
|
|
|
|
|
for (let msgHdr of pEpFolder.messages) {
|
|
|
|
|
if (new Date(Date.now() - msgHdr.date / 1000) < 600 * 1000) continue;
|
|
|
|
|
if (this.MOZ_APP_VERSION >= 85) {
|
|
|
|
|
msgs.push(msgHdr);
|
|
|
|
|
} else {
|
|
|
|
|
msgs.appendElement(msgHdr);
|
|
|
|
|
}
|
|
|
|
|
msgs.appendElement(msgHdr);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
this.log.info(`Deleting ${count} message(s) from pEp folder of ${msgRoot.name}`);
|
|
|
|
@ -475,13 +437,8 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
|
|
|
|
|
moveMsg(folder, msgHdr, pEpFolder) {
|
|
|
|
|
this.movedSyncMessages.push(msgHdr.messageId);
|
|
|
|
|
let message;
|
|
|
|
|
if (this.MOZ_APP_VERSION >= 85) {
|
|
|
|
|
message = [msgHdr];
|
|
|
|
|
} else {
|
|
|
|
|
message = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
|
|
|
|
message.appendElement(msgHdr);
|
|
|
|
|
}
|
|
|
|
|
let message = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
|
|
|
|
message.appendElement(msgHdr);
|
|
|
|
|
// isMove== true, no listener or window, allowUndo==false.
|
|
|
|
|
MailServices.copy.CopyMessages(folder, message, pEpFolder, true, null, null, false);
|
|
|
|
|
}
|
|
|
|
@ -524,7 +481,6 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
if (tree) tree.invalidate();
|
|
|
|
|
|
|
|
|
|
if (isSyncMsg) {
|
|
|
|
|
this.log.info("Processing Sync messsage");
|
|
|
|
|
this.cache_release(decryptedMessage.id);
|
|
|
|
|
|
|
|
|
|
// Mark the message read.
|
|
|
|
@ -545,7 +501,8 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
if (!folder.containsChildNamed("pEp")) {
|
|
|
|
|
try {
|
|
|
|
|
let self = this;
|
|
|
|
|
// For IMAP this is async, so attach listener before creating the folder.
|
|
|
|
|
folder.createSubfolder("pEp", null);
|
|
|
|
|
// For IMAP this is async.
|
|
|
|
|
MailServices.mfn.addListener(
|
|
|
|
|
{
|
|
|
|
|
folderAdded(childFolder) {
|
|
|
|
@ -554,13 +511,11 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
}
|
|
|
|
|
MailServices.mfn.removeListener(this);
|
|
|
|
|
childFolder.setFlag(Ci.nsMsgFolderFlags.CheckNew);
|
|
|
|
|
self.log.info("Moving Sync messsage to pEp folder after creating it");
|
|
|
|
|
self.moveMsg(folder, msgHdr, childFolder);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
MailServices.mfn.folderAdded,
|
|
|
|
|
);
|
|
|
|
|
folder.createSubfolder("pEp", null);
|
|
|
|
|
} catch (ex) {}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -569,7 +524,6 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
try {
|
|
|
|
|
let pEpFolder = folder.getChildNamed("pEp");
|
|
|
|
|
pEpFolder.setFlag(Ci.nsMsgFolderFlags.CheckNew);
|
|
|
|
|
this.log.info("Moving Sync messsage to pEp folder now");
|
|
|
|
|
this.moveMsg(folder, msgHdr, pEpFolder);
|
|
|
|
|
} catch (ex) {}
|
|
|
|
|
return;
|
|
|
|
@ -681,11 +635,10 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
|
|
|
|
|
// Copy some headers from the original to the new message.
|
|
|
|
|
// Starting with https://pep-security.lu/dev/repos/pEp_for_Thunderbird/rev/d3c752abce8c
|
|
|
|
|
// on 7th Sep 2020 in verion 1.1.006-beta we store the references and in-reply-to also
|
|
|
|
|
// in the inner message. Starting on 18th Feb. 2021 in version 1.1.101 we store the
|
|
|
|
|
// messageId in the inner message.
|
|
|
|
|
// we store the references and in-reply-to also in the inner message.
|
|
|
|
|
// Sadly at encryption time, the message ID is not yet available, so it can't be used
|
|
|
|
|
// as ID for the inner message :-(
|
|
|
|
|
if (this.currentMessage.enc_format == ENC_FORMAT_DECRYPTED) {
|
|
|
|
|
// Remove this code soon: Begin >>>>>
|
|
|
|
|
if (message.id) this.currentMessage.id = message.id;
|
|
|
|
|
|
|
|
|
|
// Only use original in_reply_to if decrypted (inner) message has none.
|
|
|
|
@ -699,7 +652,6 @@ class pEpForThunderbird extends pEp {
|
|
|
|
|
(typeof this.currentMessage.references !== "object" || this.currentMessage.references.length == 0)) {
|
|
|
|
|
this.currentMessage.references = message.references;
|
|
|
|
|
}
|
|
|
|
|
// Remove this code soon: End <<<<<
|
|
|
|
|
|
|
|
|
|
// Append decryption details to internet headers in original opt_fields.
|
|
|
|
|
if (message.opt_fields) {
|
|
|
|
|