Linting: Change indentation to 2 spaces instead of 4. Enforce it. Remove useless "airbnb-base".

master
Jorg Knobloch 3 years ago
parent f7ecc3c16c
commit babdf0a751

@ -3,9 +3,6 @@
"browser": true,
"es6": true
},
"extends": [
"airbnb-base"
],
"globals": {
"ChromeUtils": "readonly",
"Components": "readonly",
@ -20,7 +17,7 @@
"rules": {
"indent": [
"error",
4,
2,
{
"SwitchCase": 1
}
@ -29,7 +26,7 @@
"error",
{
"code": 130,
"tabWidth": 4
"tabWidth": 2
}
],
"quotes": [
@ -60,7 +57,6 @@
"comment will need to look at all the following one-by-one": "off",
"eqeqeq": "off",
"indent": "off",
"no-unused-vars": "off"
}
}

@ -2,35 +2,35 @@ var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm"
var { pEp } = ChromeUtils.import("chrome://pEp4Tb/content/modules/pEp.js");
const TbContacts = {
getCardForEmail(emailAddress) {
// copied from msgHdrViewOverlay.js
const books = MailServices.ab.directories;
const result = { book: null, card: null };
while (!result.card && books.hasMoreElements()) {
const ab = books.getNext().QueryInterface(Ci.nsIAbDirectory);
try {
const card = ab.cardForEmailAddress(emailAddress);
if (card) {
result.book = ab;
result.card = card;
}
} catch (ex) {
console.error("Error fetching user card from address book");
}
getCardForEmail(emailAddress) {
// copied from msgHdrViewOverlay.js
const books = MailServices.ab.directories;
const result = { book: null, card: null };
while (!result.card && books.hasMoreElements()) {
const ab = books.getNext().QueryInterface(Ci.nsIAbDirectory);
try {
const card = ab.cardForEmailAddress(emailAddress);
if (card) {
result.book = ab;
result.card = card;
}
return result;
},
} catch (ex) {
console.error("Error fetching user card from address book");
}
}
return result;
},
getpEpIdentity({ name, email }) {
let card = this.getCardForEmail(email).card;
return new pEp.Identity(email, card && card.UID, name);
},
getpEpIdentity({ name, email }) {
let card = this.getCardForEmail(email).card;
return new pEp.Identity(email, card && card.UID, name);
},
getpEpOwnIdentity({ name, email }) {
const identity = new pEp.Identity(email, "pEp_own_userId", name);
identity.me = true;
return identity;
},
getpEpOwnIdentity({ name, email }) {
const identity = new pEp.Identity(email, "pEp_own_userId", name);
identity.me = true;
return identity;
},
};
const EXPORTED_SYMBOLS = ["TbContacts"];

@ -3,123 +3,123 @@ var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm"
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
const TbHelper = {
getMessagePane(window) {
if (typeof window.GetMessagePaneFrame !== "undefined") return window.GetMessagePaneFrame();
return window.document.getElementById("messagepane").contentWindow;
},
getMessagePane(window) {
if (typeof window.GetMessagePaneFrame !== "undefined") return window.GetMessagePaneFrame();
return window.document.getElementById("messagepane").contentWindow;
},
copyMessageToFolder(msgHdr, newSubject, content) {
// Setting the subject here to the version where the Re: prefix was removed,
// as returned from `updateSubject()`, seems to have a positive effect.
// This is the result of quite some experimentation. In reality
// this appears to be another workaround for
// https://bugzilla.mozilla.org/show_bug.cgi?id=1629555
// as the correct subject should have already been stored in that function.
if (newSubject) msgHdr.subject = newSubject;
copyMessageToFolder(msgHdr, newSubject, content) {
// Setting the subject here to the version where the Re: prefix was removed,
// as returned from `updateSubject()`, seems to have a positive effect.
// This is the result of quite some experimentation. In reality
// this appears to be another workaround for
// https://bugzilla.mozilla.org/show_bug.cgi?id=1629555
// as the correct subject should have already been stored in that function.
if (newSubject) msgHdr.subject = newSubject;
// Copy copied form Header Tools Lite. There is a variation in Enigmail.
// Create the temporary file where the new message will be stored.
const tempFile = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
tempFile.append("pEpMsg.eml");
tempFile.createUnique(0, 0o600);
// Copy copied form Header Tools Lite. There is a variation in Enigmail.
// Create the temporary file where the new message will be stored.
const tempFile = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
tempFile.append("pEpMsg.eml");
tempFile.createUnique(0, 0o600);
const outputStream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
outputStream.init(tempFile, 2, 0x200, false); // open as "write only"
outputStream.write(content, content.length);
outputStream.close();
const outputStream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
outputStream.init(tempFile, 2, 0x200, false); // open as "write only"
outputStream.write(content, content.length);
outputStream.close();
// This is interesting: nsIMsgFolder.copyFileMessage seems to have a bug on Windows, when
// the nsIFile has been already used by outputStream (because of Windows lock system?).
// Header Tools Lite and Enigmail have some code that tries to open another handle to the
// same file in order to delete the file. However, HTL doesn't make any attempt to remove
// the file, and Enigmail fails to delete the file. Also, all attempts of this author here
// were unsucessful, so we just leave it to the clean-up.
// This is interesting: nsIMsgFolder.copyFileMessage seems to have a bug on Windows, when
// the nsIFile has been already used by outputStream (because of Windows lock system?).
// Header Tools Lite and Enigmail have some code that tries to open another handle to the
// same file in order to delete the file. However, HTL doesn't make any attempt to remove
// the file, and Enigmail fails to delete the file. Also, all attempts of this author here
// were unsucessful, so we just leave it to the clean-up.
// Ensure that file gets deleted on exit if something goes wrong.
const extAppLauncher = Cc["@mozilla.org/uriloader/external-helper-app-service;1"]
.getService(Ci.nsPIExternalAppLauncher);
extAppLauncher.deleteTemporaryFileOnExit(tempFile);
// Ensure that file gets deleted on exit if something goes wrong.
const extAppLauncher = Cc["@mozilla.org/uriloader/external-helper-app-service;1"]
.getService(Ci.nsPIExternalAppLauncher);
extAppLauncher.deleteTemporaryFileOnExit(tempFile);
const msgFolder = msgHdr.folder;
const copyListener = {
QueryInterface(iid) {
if (iid.equals(Ci.nsIMsgCopyServiceListener) || iid.equals(Ci.nsISupports)) {
return this;
}
throw Cr.NS_NOINTERFACE;
},
GetMessageId(messageId) {},
SetMessageKey(key) {},
OnStartCopy() {},
OnStopCopy(statusCode) {
console.debug("pepmsghdrview.js: copyListener: OnStopCopy()");
if (statusCode !== 0) {
console.error(`pepmsghdrview.js: Error copying message: ${statusCode}`);
}
console.debug("pepmsghdrview.js: Copy complete");
const msgFolder = msgHdr.folder;
const copyListener = {
QueryInterface(iid) {
if (iid.equals(Ci.nsIMsgCopyServiceListener) || iid.equals(Ci.nsISupports)) {
return this;
}
throw Cr.NS_NOINTERFACE;
},
GetMessageId(messageId) {},
SetMessageKey(key) {},
OnStartCopy() {},
OnStopCopy(statusCode) {
console.debug("pepmsghdrview.js: copyListener: OnStopCopy()");
if (statusCode !== 0) {
console.error(`pepmsghdrview.js: Error copying message: ${statusCode}`);
}
console.debug("pepmsghdrview.js: Copy complete");
try {
const msgArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
msgArray.appendElement(msgHdr, false);
msgFolder.deleteMessages(msgArray, null, true, false, null, false);
} catch (ex) {}
try {
tempFile.remove();
} catch (ex) {}
},
};
try {
const msgArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
msgArray.appendElement(msgHdr, false);
msgFolder.deleteMessages(msgArray, null, true, false, null, false);
} catch (ex) {}
try {
tempFile.remove();
} catch (ex) {}
},
};
const msgCopyService = Cc["@mozilla.org/messenger/messagecopyservice;1"]
.getService(Ci.nsIMsgCopyService);
msgCopyService.CopyFileMessage(tempFile, msgFolder, msgHdr, false, 0, "", copyListener, null);
},
const msgCopyService = Cc["@mozilla.org/messenger/messagecopyservice;1"]
.getService(Ci.nsIMsgCopyService);
msgCopyService.CopyFileMessage(tempFile, msgFolder, msgHdr, false, 0, "", copyListener, null);
},
isOwnIdentity(email) {
const emailToLower = email.toLowerCase();
for (let identity of fixIterator(MailServices.accounts.allIdentities, Ci.nsIMsgIdentity)) {
if (identity.email.toLowerCase() == emailToLower) {
return true;
}
}
return false;
},
isOwnIdentity(email) {
const emailToLower = email.toLowerCase();
for (let identity of fixIterator(MailServices.accounts.allIdentities, Ci.nsIMsgIdentity)) {
if (identity.email.toLowerCase() == emailToLower) {
return true;
}
}
return false;
},
encryptForIdentity(identity) {
return Services.prefs.getBoolPref(`mail.identity.${identity.key}.enableEncryption`, true);
},
encryptForIdentity(identity) {
return Services.prefs.getBoolPref(`mail.identity.${identity.key}.enableEncryption`, true);
},
encryptDraftOrTemplateForIdentity(identity, sendMsgType) {
for (let account of fixIterator(MailServices.accounts.accounts, Ci.nsIMsgAccount)) {
for (let id of fixIterator(account.identities, Ci.nsIMsgIdentity)) {
if (id.key === identity.key) {
let folderURI = (sendMsgType == Ci.nsIMsgCompDeliverMode.SaveAsTemplate)
? id.stationeryFolder : id.draftFolder;
// Check to which account the folder belongs since IMAP users can
// store their drafts in a local folder which may have a different
// security requirement.
let folder = MailServices.folderLookup.getFolderForURL(folderURI);
encryptDraftOrTemplateForIdentity(identity, sendMsgType) {
for (let account of fixIterator(MailServices.accounts.accounts, Ci.nsIMsgAccount)) {
for (let id of fixIterator(account.identities, Ci.nsIMsgIdentity)) {
if (id.key === identity.key) {
let folderURI = (sendMsgType == Ci.nsIMsgCompDeliverMode.SaveAsTemplate)
? id.stationeryFolder : id.draftFolder;
// Check to which account the folder belongs since IMAP users can
// store their drafts in a local folder which may have a different
// security requirement.
let folder = MailServices.folderLookup.getFolderForURL(folderURI);
// Is is possible that the folder doesn't exist yet when the first draft or
// templage is saved. In that case we return the setting for the indentity's account.
if (!folder) {
return Services.prefs.getBoolPref(`mail.account.${account.key}.storeSecurely`, true);
}
// Is is possible that the folder doesn't exist yet when the first draft or
// templage is saved. In that case we return the setting for the indentity's account.
if (!folder) {
return Services.prefs.getBoolPref(`mail.account.${account.key}.storeSecurely`, true);
}
// Find account for the foler.
let folderRoot = folder.server.rootFolder;
for (let account2 of fixIterator(MailServices.accounts.accounts, Ci.nsIMsgAccount)) {
if (folderRoot == account2.incomingServer.rootMsgFolder) {
return Services.prefs.getBoolPref(`mail.account.${account2.key}.storeSecurely`, true);
}
}
}
// Find account for the foler.
let folderRoot = folder.server.rootFolder;
for (let account2 of fixIterator(MailServices.accounts.accounts, Ci.nsIMsgAccount)) {
if (folderRoot == account2.incomingServer.rootMsgFolder) {
return Services.prefs.getBoolPref(`mail.account.${account2.key}.storeSecurely`, true);
}
}
}
// What? Identity not found? Let's be on the safe side.
return true;
},
}
}
// What? Identity not found? Let's be on the safe side.
return true;
},
};
const EXPORTED_SYMBOLS = ["TbHelper"];

@ -9,119 +9,119 @@ const TAG_PRIVACY_NODE_ID = "pEp-msghdr-privacy-label";
const TbMessageView = {
updateSubject(win, msgHdr, tree, content) {
if (content === undefined) return null;
// Strip multiple localised Re: prefixes.
let subject = content;
let prefixes = Services.prefs.getStringPref("mailnews.localizedRe", "");
if (prefixes) {
prefixes = prefixes.split(",");
if (!prefixes.includes("Re")) prefixes.push("Re");
} else {
prefixes = ["Re"];
}
for (let p of prefixes) {
let regEx = new RegExp(`^(${p}: )+`, "i");
subject = subject.replace(regEx, ""); // Remove prefix.
}
let hadRe = (subject != content);
const subjectBox = win.document.getElementById("expandedsubjectBox");
// eslint-disable-next-line prefer-template
if (subjectBox) subjectBox.headerValue = hadRe ? "Re: " + subject : subject;
// The database doesn't like raw UTF apparently.
subject = jsmime.headeremitter.emitStructuredHeader("subject", subject, {}).substring(9);
// We should store the subject without any Re: prefix, but
// https://bugzilla.mozilla.org/show_bug.cgi?id=1629555
// gets in the way. So the correct code is commented out for now.
// Correct would be these two lines ...
// if (hadRe) msgHdr.flags |= Ci.nsMsgMessageFlags.HasRe;
// msgHdr.subject = subject;
// ... and replace the if-else below.
if (msgHdr.flags & Ci.nsMsgMessageFlags.HasRe) {
// If the flag is already set, we can just store the subject.
msgHdr.subject = subject;
} else {
// This is WRONG. Should not prepend "Re: " but instead set the flag. See above.
// eslint-disable-next-line prefer-template
msgHdr.subject = hadRe ? "Re: " + subject : subject;
}
if (tree) tree.invalidate();
return subject;
},
updatePrivacy(win, msgHdr, rating) {
// Remove old display.
const oldNode = win.document.getElementById(TAG_PRIVACY_NODE_ID);
if (oldNode) {
oldNode.parentNode.removeChild(oldNode);
}
if (!rating || rating == 3) {
// Return if there's no status to show
return;
}
// Add privacy bar to message
const newNode = win.document.createXULElement("hbox");
newNode.classList.add("header-privacy-bar");
newNode.classList.add(pEpController.colorFromRating(rating));
newNode.id = TAG_PRIVACY_NODE_ID;
const privacyLabel = win.document.createTextNode(pEpController.textFromRating(rating));
newNode.appendChild(privacyLabel);
const expandedHeadersBox = win.document.getElementById("expandedHeadersBox");
expandedHeadersBox.parentNode.insertBefore(newNode, expandedHeadersBox);
newNode.onclick = () => this.viewPrivacyBarClick(win, msgHdr);
},
// Similar to the function in pepmessengercompose.js.
_parseAddress(address) {
const hdr = Cc["@mozilla.org/messenger/headerparser;1"].createInstance(Ci.nsIMsgHeaderParser);
const mails = hdr.parseEncodedHeader(address, "utf-8");
return mails.filter((mail) => mail.email).map((mail) => ({
email: mail.email,
name: mail.name,
}));
},
viewPrivacyBarClick(win, msgHdr) {
const author = msgHdr.author;
const recipients = msgHdr.recipients;
const ccRecipients = msgHdr.ccList;
const header = msgHdr.messageId;
// We don't know whether this is a sent or received message, or we got it via Bcc.
const author2 = author ? this._parseAddress(author) : [];
const recipients2 = recipients ? this._parseAddress(recipients) : [];
const ccRecipients2 = ccRecipients ? this._parseAddress(ccRecipients) : [];
const allAdresses = author2.concat(recipients2).concat(ccRecipients2);
if (allAdresses.length == 0) return;
// Now divide into myself and anybody else.
const myself = allAdresses.filter((addr) => (TbHelper.isOwnIdentity(addr.email)));
if (myself.length == 0) return;
const others = allAdresses.filter((addr) => (!TbHelper.isOwnIdentity(addr.email)));
if (others.length == 0) return;
const pEpMyself = myself.map((addr) => TbContacts.getpEpOwnIdentity(addr));
const pEpOthers = others.map((addr) => TbContacts.getpEpIdentity(addr));
const handshake = new Handshake(pEpController);
handshake.init(pEpMyself[0], pEpOthers).then(() => {
const [currentIdentity, identities] = handshake.showPrivacyStatusDialog();
const xul = "chrome://pEp4Tb/content/dialogs/privacy_status.xhtml";
const id = "privacy-status-dialog-id";
// This needs to be modal, so the user can't select a different message
// while the panel is up.
const position = "chrome,centerscreen,modal,resizable";
// eslint-disable-next-line prefer-template
win.openDialog(xul, id, position, currentIdentity, identities, "view-" + header);
});
},
updateSubject(win, msgHdr, tree, content) {
if (content === undefined) return null;
// Strip multiple localised Re: prefixes.
let subject = content;
let prefixes = Services.prefs.getStringPref("mailnews.localizedRe", "");
if (prefixes) {
prefixes = prefixes.split(",");
if (!prefixes.includes("Re")) prefixes.push("Re");
} else {
prefixes = ["Re"];
}
for (let p of prefixes) {
let regEx = new RegExp(`^(${p}: )+`, "i");
subject = subject.replace(regEx, ""); // Remove prefix.
}
let hadRe = (subject != content);
const subjectBox = win.document.getElementById("expandedsubjectBox");
// eslint-disable-next-line prefer-template
if (subjectBox) subjectBox.headerValue = hadRe ? "Re: " + subject : subject;
// The database doesn't like raw UTF apparently.
subject = jsmime.headeremitter.emitStructuredHeader("subject", subject, {}).substring(9);
// We should store the subject without any Re: prefix, but
// https://bugzilla.mozilla.org/show_bug.cgi?id=1629555
// gets in the way. So the correct code is commented out for now.
// Correct would be these two lines ...
// if (hadRe) msgHdr.flags |= Ci.nsMsgMessageFlags.HasRe;
// msgHdr.subject = subject;
// ... and replace the if-else below.
if (msgHdr.flags & Ci.nsMsgMessageFlags.HasRe) {
// If the flag is already set, we can just store the subject.
msgHdr.subject = subject;
} else {
// This is WRONG. Should not prepend "Re: " but instead set the flag. See above.
// eslint-disable-next-line prefer-template
msgHdr.subject = hadRe ? "Re: " + subject : subject;
}
if (tree) tree.invalidate();
return subject;
},
updatePrivacy(win, msgHdr, rating) {
// Remove old display.
const oldNode = win.document.getElementById(TAG_PRIVACY_NODE_ID);
if (oldNode) {
oldNode.parentNode.removeChild(oldNode);
}
if (!rating || rating == 3) {
// Return if there's no status to show
return;
}
// Add privacy bar to message
const newNode = win.document.createXULElement("hbox");
newNode.classList.add("header-privacy-bar");
newNode.classList.add(pEpController.colorFromRating(rating));
newNode.id = TAG_PRIVACY_NODE_ID;
const privacyLabel = win.document.createTextNode(pEpController.textFromRating(rating));
newNode.appendChild(privacyLabel);
const expandedHeadersBox = win.document.getElementById("expandedHeadersBox");
expandedHeadersBox.parentNode.insertBefore(newNode, expandedHeadersBox);
newNode.onclick = () => this.viewPrivacyBarClick(win, msgHdr);
},
// Similar to the function in pepmessengercompose.js.
_parseAddress(address) {
const hdr = Cc["@mozilla.org/messenger/headerparser;1"].createInstance(Ci.nsIMsgHeaderParser);
const mails = hdr.parseEncodedHeader(address, "utf-8");
return mails.filter((mail) => mail.email).map((mail) => ({
email: mail.email,
name: mail.name,
}));
},
viewPrivacyBarClick(win, msgHdr) {
const author = msgHdr.author;
const recipients = msgHdr.recipients;
const ccRecipients = msgHdr.ccList;
const header = msgHdr.messageId;
// We don't know whether this is a sent or received message, or we got it via Bcc.
const author2 = author ? this._parseAddress(author) : [];
const recipients2 = recipients ? this._parseAddress(recipients) : [];
const ccRecipients2 = ccRecipients ? this._parseAddress(ccRecipients) : [];
const allAdresses = author2.concat(recipients2).concat(ccRecipients2);
if (allAdresses.length == 0) return;
// Now divide into myself and anybody else.
const myself = allAdresses.filter((addr) => (TbHelper.isOwnIdentity(addr.email)));
if (myself.length == 0) return;
const others = allAdresses.filter((addr) => (!TbHelper.isOwnIdentity(addr.email)));
if (others.length == 0) return;
const pEpMyself = myself.map((addr) => TbContacts.getpEpOwnIdentity(addr));
const pEpOthers = others.map((addr) => TbContacts.getpEpIdentity(addr));
const handshake = new Handshake(pEpController);
handshake.init(pEpMyself[0], pEpOthers).then(() => {
const [currentIdentity, identities] = handshake.showPrivacyStatusDialog();
const xul = "chrome://pEp4Tb/content/dialogs/privacy_status.xhtml";
const id = "privacy-status-dialog-id";
// This needs to be modal, so the user can't select a different message
// while the panel is up.
const position = "chrome,centerscreen,modal,resizable";
// eslint-disable-next-line prefer-template
win.openDialog(xul, id, position, currentIdentity, identities, "view-" + header);
});
},
};
const EXPORTED_SYMBOLS = ["TbMessageView"];

@ -4,16 +4,16 @@ var { wizardBuilder } = ChromeUtils.import("chrome://pEp4Tb/content/syncWizard.j
var { pEpController } = ChromeUtils.import("chrome://pEp4Tb/content/pEpController.js");
function startSync(window) {
function send(message) {
let compFields = sendMessage.messageToCompFields(message);
let sender = sendMessage.makeSender(compFields);
return sender.send();
}
function send(message) {
let compFields = sendMessage.messageToCompFields(message);
let sender = sendMessage.makeSender(compFields);
return sender.send();
}
let Builder = wizardBuilder(window);
let sync = new Sync(pEpController, send, Builder, "random_sec_token");
// Here we could call `sync.init()` when the controller will support listener registration.
return sync;
let Builder = wizardBuilder(window);
let sync = new Sync(pEpController, send, Builder, "random_sec_token");
// Here we could call `sync.init()` when the controller will support listener registration.
return sync;
}
const EXPORTED_SYMBOLS = ["startSync"];

@ -17,20 +17,20 @@ const RATING_COLOR_GREEN = "green";
const RATING_COLOR_YELLOW = "yellow";
const EXPORTED_SYMBOLS = [
"ENC_FORMAT_NONE",
"ENC_FORMAT_PEP",
"ENC_FORMAT_NONE",
"ENC_FORMAT_PEP",
"LEVEL_OFF",
"LEVEL_ERROR",
"LEVEL_WARN",
"LEVEL_INFO",
"LEVEL_DEBUG",
"LEVEL_ALL",
"LEVEL_OFF",
"LEVEL_ERROR",
"LEVEL_WARN",
"LEVEL_INFO",
"LEVEL_DEBUG",
"LEVEL_ALL",
"PEP_ENCRYPTED_SUBJECT",
"PEP_ENCRYPTED_SUBJECT",
"RATING_COLOR_NO_COLOR",
"RATING_COLOR_RED",
"RATING_COLOR_GREEN",
"RATING_COLOR_YELLOW",
"RATING_COLOR_NO_COLOR",
"RATING_COLOR_RED",
"RATING_COLOR_GREEN",
"RATING_COLOR_YELLOW",
];

@ -9,49 +9,49 @@ var { pEpLogger } = ChromeUtils.import("chrome://pEp4Tb/content/pEpLogger.js");
* @return String - URL to connect with pEp JSON Server
*/
const detectAdapter = () => {
const logger = new pEpLogger(LEVEL_ALL);
logger.info("detectJsonAdapter()");
const logger = new pEpLogger(LEVEL_ALL);
logger.info("detectJsonAdapter()");
const os = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
const os = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
let tokenFile;
// Developer option.
let pEpHome = Services.prefs.getStringPref("extensions.pEp.pEpHome", ""); // Undocumented pref.
if (pEpHome) {
// eslint-disable-next-line prefer-template
tokenFile = pEpHome + (os == "WINNT" ? "\\" : "/") + "json-token";
} else if (os == "WINNT") {
// Since JSON-142, the adapter honours the registry setting, let's do the same.
let path = null;
let registry = Cc["@mozilla.org/windows-registry-key;1"].createInstance(Ci.nsIWindowsRegKey);
try {
// HKCU\Software\pEp - UserFolder needs to be a REG_EXPAND_SZ or the Mozilla library won't expand it.
registry.open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, "Software\\pEp", Ci.nsIWindowsRegKey.ACCESS_READ);
if (registry.hasValue("UserFolder")) {
path = registry.readStringValue("UserFolder");
}
} catch (ex) {
} finally {
registry.close();
}
// eslint-disable-next-line prefer-template
if (!path) path = env.get("LocalAppData") + "\\pEp";
// eslint-disable-next-line prefer-template
tokenFile = path + "\\json-token";
} else {
tokenFile = `${env.get("HOME")}/.pEp/json-token`;
let tokenFile;
// Developer option.
let pEpHome = Services.prefs.getStringPref("extensions.pEp.pEpHome", ""); // Undocumented pref.
if (pEpHome) {
// eslint-disable-next-line prefer-template
tokenFile = pEpHome + (os == "WINNT" ? "\\" : "/") + "json-token";
} else if (os == "WINNT") {
// Since JSON-142, the adapter honours the registry setting, let's do the same.
let path = null;
let registry = Cc["@mozilla.org/windows-registry-key;1"].createInstance(Ci.nsIWindowsRegKey);
try {
// HKCU\Software\pEp - UserFolder needs to be a REG_EXPAND_SZ or the Mozilla library won't expand it.
registry.open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, "Software\\pEp", Ci.nsIWindowsRegKey.ACCESS_READ);
if (registry.hasValue("UserFolder")) {
path = registry.readStringValue("UserFolder");
}
} catch (ex) {
} finally {
registry.close();
}
// eslint-disable-next-line prefer-template
if (!path) path = env.get("LocalAppData") + "\\pEp";
// eslint-disable-next-line prefer-template
tokenFile = path + "\\json-token";
} else {
tokenFile = `${env.get("HOME")}/.pEp/json-token`;
}
let connectionInfo = null;
const files = new pEpFiles();
connectionInfo = JSON.parse(files.readFileSync(tokenFile));
logger.info("detectJsonAdapter()", connectionInfo, tokenFile);
if (!connectionInfo) {
throw new Error(`Cannot read ${tokenFile}`);
}
let connectionInfo = null;
const files = new pEpFiles();
connectionInfo = JSON.parse(files.readFileSync(tokenFile));
logger.info("detectJsonAdapter()", connectionInfo, tokenFile);
if (!connectionInfo) {
throw new Error(`Cannot read ${tokenFile}`);
}
return connectionInfo;
return connectionInfo;
};
const EXPORTED_SYMBOLS = ["detectAdapter"];

@ -7,16 +7,16 @@ var { pEpController } = ChromeUtils.import("chrome://pEp4Tb/content/pEpControlle
// Add preferences info (see developer.thunderbird.net/add-ons/updates/tb68).
Preferences.addAll([
{ id: "extensions.pEp.storeAllSecurely", type: "bool" },
{ id: "extensions.pEp.warnUnencrypted", type: "bool" },
{ id: "extensions.pEp.protectSubjects", type: "bool" },
{ id: "extensions.pEp.passiveMode", type: "bool" },
{ id: "extensions.pEp.pEpSync", type: "bool" },
{ id: "extensions.pEp.keyFingerprint", type: "string" },
{ id: "extensions.pEp.keyLocation", type: "string" },
// examples with different types
// { id: "extensions.nameOfAddon.pref2", type: "string" },
// { id: "extensions.nameOfAddon.pref3", type: "int" },
{ id: "extensions.pEp.storeAllSecurely", type: "bool" },
{ id: "extensions.pEp.warnUnencrypted", type: "bool" },
{ id: "extensions.pEp.protectSubjects", type: "bool" },
{ id: "extensions.pEp.passiveMode", type: "bool" },
{ id: "extensions.pEp.pEpSync", type: "bool" },
{ id: "extensions.pEp.keyFingerprint", type: "string" },
{ id: "extensions.pEp.keyLocation", type: "string" },
// examples with different types
// { id: "extensions.nameOfAddon.pref2", type: "string" },
// { id: "extensions.nameOfAddon.pref3", type: "int" },
]);
Preferences.get("extensions.pEp.protectSubjects").on(
"change",
@ -32,189 +32,189 @@ Preferences.get("extensions.pEp.storeAllSecurely").on(
);
function protectSubjectsChange() {
if (Services.prefs.getBoolPref("extensions.pEp.protectSubjects", true)) {
pEpController.enableprotectSubjects();
} else {
pEpController.disableprotectSubjects();
}
if (Services.prefs.getBoolPref("extensions.pEp.protectSubjects", true)) {
pEpController.enableprotectSubjects();
} else {
pEpController.disableprotectSubjects();
}
}
function passiveModeChange() {
if (Services.prefs.getBoolPref("extensions.pEp.passiveMode", true)) {
pEpController.enablePassiveMode();
} else {
pEpController.disablePassiveMode();
}
if (Services.prefs.getBoolPref("extensions.pEp.passiveMode", true)) {
pEpController.enablePassiveMode();
} else {
pEpController.disablePassiveMode();
}
}
function storeAllSecurelyChange() {
const storeAllSecurely = Services.prefs.getBoolPref("extensions.pEp.storeAllSecurely", true);
const root = document.getElementById("root");
let checkboxes = root.querySelectorAll(".account-storeSecurely");
for (let checkbox of checkboxes) {
checkbox.setAttribute("disabled", storeAllSecurely);
if (storeAllSecurely) {
// Override.
let accountKey = checkbox.getAttribute("id");
let id = `mail.account.${accountKey}.storeSecurely`;
Services.prefs.setBoolPref(id, true);
}
const storeAllSecurely = Services.prefs.getBoolPref("extensions.pEp.storeAllSecurely", true);
const root = document.getElementById("root");
let checkboxes = root.querySelectorAll(".account-storeSecurely");
for (let checkbox of checkboxes) {
checkbox.setAttribute("disabled", storeAllSecurely);
if (storeAllSecurely) {
// Override.
let accountKey = checkbox.getAttribute("id");
let id = `mail.account.${accountKey}.storeSecurely`;
Services.prefs.setBoolPref(id, true);
}
}
}
function loadAccounts() {
function makeIdentityFragment(identity) {
const fragment = new pEpUtils.Fragment("#identity-options", document);
const root = fragment.getRoot();
const [delim, delim2] = identity.fullName ? [" <", ">"] : ["", ""];
root.querySelector(".identity-title").textContent = `${identity.fullName}${delim}${identity.email}${delim2}`;
let checkbox = root.querySelector(".identity-enableEncryption");
let id = `mail.identity.${identity.key}.enableEncryption`;
// Get prior value, if any. Default to true.
let value = Services.prefs.getBoolPref(id, true);
Preferences.add({ id, type: "bool" });
checkbox.setAttribute("preference", id);
Services.prefs.setBoolPref(id, value);
return root;
function makeIdentityFragment(identity) {
const fragment = new pEpUtils.Fragment("#identity-options", document);
const root = fragment.getRoot();
const [delim, delim2] = identity.fullName ? [" <", ">"] : ["", ""];
root.querySelector(".identity-title").textContent = `${identity.fullName}${delim}${identity.email}${delim2}`;
let checkbox = root.querySelector(".identity-enableEncryption");
let id = `mail.identity.${identity.key}.enableEncryption`;
// Get prior value, if any. Default to true.
let value = Services.prefs.getBoolPref(id, true);
Preferences.add({ id, type: "bool" });
checkbox.setAttribute("preference", id);
Services.prefs.setBoolPref(id, value);
return root;
}
function makeAccountFragment(account) {
const fragment = new pEpUtils.Fragment("#account-options", document);
const root = fragment.getRoot();
let accName = account.key;
const server = Services.prefs.getStringPref(`mail.account.${account.key}.server`);
if (server) {
accName = Services.prefs.getStringPref(`mail.server.${server}.name`, accName);
}
function makeAccountFragment(account) {
const fragment = new pEpUtils.Fragment("#account-options", document);
const root = fragment.getRoot();
let accName = account.key;
const server = Services.prefs.getStringPref(`mail.account.${account.key}.server`);
if (server) {
accName = Services.prefs.getStringPref(`mail.server.${server}.name`, accName);
}
root.querySelector(".account-title").textContent = accName;
// Check global override.
let storeAllSecurely = Services.prefs.getBoolPref("extensions.pEp.storeAllSecurely", true);
let checkbox = root.querySelector(".account-storeSecurely");
let id = `mail.account.${account.key}.storeSecurely`;
// Get prior value, if any. Default to true.
let value = storeAllSecurely ? true : Services.prefs.getBoolPref(id, true);
Preferences.add({ id, type: "bool" });
checkbox.setAttribute("preference", id);
Services.prefs.setBoolPref(id, value);
checkbox.setAttribute("disabled", storeAllSecurely);
checkbox.setAttribute("id", account.key);
let identities = [];
for (let identity of fixIterator(account.identities, Ci.nsIMsgIdentity)) {
identities.push({ key: identity.key, fullName: identity.fullName, email: identity.email });
}
identities
.map(makeIdentityFragment)
.map((r) => root.querySelector(".insert-here").insertBefore(r, null));
return root;
}
const root = document.getElementById("root");
pEpUtils.removeChildren(root);
let accounts = [];
for (let account of fixIterator(MailServices.accounts.accounts, Ci.nsIMsgAccount)) {
const server = Services.prefs.getStringPref(`mail.account.${account.key}.server`);
if (!server) continue;
const type = Services.prefs.getStringPref(`mail.server.${server}.type`, "badtype");
if (["rss", "im", "nntp", "badtype"].includes(type)) continue; // Skip Feeds, Chat and News.
accounts.push({ key: account.key, identities: account.identities });
root.querySelector(".account-title").textContent = accName;
// Check global override.
let storeAllSecurely = Services.prefs.getBoolPref("extensions.pEp.storeAllSecurely", true);
let checkbox = root.querySelector(".account-storeSecurely");
let id = `mail.account.${account.key}.storeSecurely`;
// Get prior value, if any. Default to true.
let value = storeAllSecurely ? true : Services.prefs.getBoolPref(id, true);
Preferences.add({ id, type: "bool" });
checkbox.setAttribute("preference", id);
Services.prefs.setBoolPref(id, value);
checkbox.setAttribute("disabled", storeAllSecurely);
checkbox.setAttribute("id", account.key);
let identities = [];
for (let identity of fixIterator(account.identities, Ci.nsIMsgIdentity)) {
identities.push({ key: identity.key, fullName: identity.fullName, email: identity.email });
}
accounts
.map(makeAccountFragment)
.map(root.appendChild.bind(root));
identities
.map(makeIdentityFragment)
.map((r) => root.querySelector(".insert-here").insertBefore(r, null));
return root;
}
const root = document.getElementById("root");
pEpUtils.removeChildren(root);
let accounts = [];
for (let account of fixIterator(MailServices.accounts.accounts, Ci.nsIMsgAccount)) {
const server = Services.prefs.getStringPref(`mail.account.${account.key}.server`);
if (!server) continue;
const type = Services.prefs.getStringPref(`mail.server.${server}.type`, "badtype");
if (["rss", "im", "nntp", "badtype"].includes(type)) continue; // Skip Feeds, Chat and News.
accounts.push({ key: account.key, identities: account.identities });
}
accounts
.map(makeAccountFragment)
.map(root.appendChild.bind(root));
}
function convertURLToLocalFile(aFileURL) {
// convert the file url into a nsIFile
if (aFileURL) {
return Services.io.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler)
.getFileFromURLSpec(aFileURL);
}
return null;
// convert the file url into a nsIFile
if (aFileURL) {
return Services.io.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler)
.getFileFromURLSpec(aFileURL);
}
return null;
}
function browseForKey() {
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
// if we already have a key, then use the path.
var localFile = convertURLToLocalFile(document.getElementById("keyLocation").value);
if (localFile) {
fp.displayDirectory = localFile.parent;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
// if we already have a key, then use the path.
var localFile = convertURLToLocalFile(document.getElementById("keyLocation").value);
if (localFile) {
fp.displayDirectory = localFile.parent;
}
fp.init(
window,
"Select ASCII-armored file", // L10N
Ci.nsIFilePicker.modeOpen,
);
fp.appendFilter("ASC File", "*.asc"); // L10N
fp.appendFilters(Ci.nsIFilePicker.filterAll);
fp.open((rv) => {
if (rv != Ci.nsIFilePicker.returnOK || !fp.file) {
return;
}
fp.init(
window,
"Select ASCII-armored file", // L10N
Ci.nsIFilePicker.modeOpen,
);
fp.appendFilter("ASC File", "*.asc"); // L10N
fp.appendFilters(Ci.nsIFilePicker.filterAll);
fp.open((rv) => {
if (rv != Ci.nsIFilePicker.returnOK || !fp.file) {
return;
}
// convert the nsIFile into a nsIFile url
Preferences.get("extensions.pEp.keyLocation").value = fp.fileURL.spec;
});
// convert the nsIFile into a nsIFile url
Preferences.get("extensions.pEp.keyLocation").value = fp.fileURL.spec;
});
}
function importKey() {
let location = Preferences.get("extensions.pEp.keyLocation").value;
let channel = Services.io.newChannelFromURI(Services.io.newURI(location), null,
Services.scriptSecurityManager.getSystemPrincipal(), null,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
let inputStream = channel.open();
let stream = Cc["@mozilla.org/binaryinputstream;1"]
.createInstance(Ci.nsIBinaryInputStream);
stream.setInputStream(inputStream);
let streamData = "";
try {
while (stream.available() > 0) {
streamData += stream.readBytes(stream.available());
}
} catch (e) {
stream.close();
// eslint-disable-next-line prefer-template
throw new Error("Couldn't read all data from location " + location + " (" + e + ")");
let location = Preferences.get("extensions.pEp.keyLocation").value;
let channel = Services.io.newChannelFromURI(Services.io.newURI(location), null,
Services.scriptSecurityManager.getSystemPrincipal(), null,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
let inputStream = channel.open();
let stream = Cc["@mozilla.org/binaryinputstream;1"]
.createInstance(Ci.nsIBinaryInputStream);
stream.setInputStream(inputStream);
let streamData = "";
try {
while (stream.available() > 0) {
streamData += stream.readBytes(stream.available());
}
} catch (e) {
stream.close();
// Send to the engine.
pEpController.importKey(streamData).then((result) => {
let msg;
// If we get identites returned, we imported a private key,
// if we get empty identities, we imported a public key.
// Anything else is an error.
if (typeof result !== "object") {
console.log(`Key import error ${result}`);
msg = "Key import failed"; // L10N
} else if (result.length == 0) {
console.log("Public key import not supported");
msg = "Public key import not supported"; // L10N
} else {
result[0].user_id = "pEp_own_userId";
pEpController.setOwnKey(result[0]);
// TODO: Check error.
const username = result[0].username;
const [delim, delim2] = username ? [" <", ">"] : ["", ""];
msg = `Key successfully imported for ${username}${delim}${result[0].address}${delim2}`; // L10N
}
Services.prompt.alert(
null,
"Key import", // L10N
msg,
);
});
// eslint-disable-next-line prefer-template
throw new Error("Couldn't read all data from location " + location + " (" + e + ")");
}
stream.close();
// Send to the engine.
pEpController.importKey(streamData).then((result) => {
let msg;
// If we get identites returned, we imported a private key,
// if we get empty identities, we imported a public key.
// Anything else is an error.
if (typeof result !== "object") {
console.log(`Key import error ${result}`);
msg = "Key import failed"; // L10N
} else if (result.length == 0) {
console.log("Public key import not supported");
msg = "Public key import not supported"; // L10N
} else {
result[0].user_id = "pEp_own_userId";
pEpController.setOwnKey(result[0]);
// TODO: Check error.
const username = result[0].username;
const [delim, delim2] = username ? [" <", ">"] : ["", ""];
msg = `Key successfully imported for ${username}${delim}${result[0].address}${delim2}`; // L10N
}
Services.prompt.alert(
null,
"Key import", // L10N
msg,
);
});
}
window.addEventListener("load", () => {
loadAccounts();
loadAccounts();
});

@ -9,81 +9,81 @@ const caller = window.arguments[2]; // "compose" or ("view-" + messageID)
const handshake = new Handshake(pEpController);
function executeHandler(handler) {
return () => {
handler();
Services.obs.notifyObservers(null, "pEp-trust-changed", caller);
window.close();
};
return () => {
handler();
Services.obs.notifyObservers(null, "pEp-trust-changed", caller);
window.close();
};
}
function fetchData(otherIdentity) {
let template;
let promise;
let template;
let promise;
const color = pEpController.colorFromRating(otherIdentity.rating);
const color = pEpController.colorFromRating(otherIdentity.rating);
// We will get colors green, yellow and no-color. Red won't happen, since
// a communication partner isn't red. If their trustwords are rejected, they
// go back to untrusted/no-color.
if (color == "green") {
template = "#green";
promise = Promise.resolve({
data: {
"full-name": otherIdentity.username,
},
handlers: {
"reset-trust": executeHandler(handshake.actionResetTrust.bind(handshake, otherIdentity)),
"reset-data": executeHandler(handshake.actionResetUserData.bind(handshake, otherIdentity)),
},
});
} else if (color == "yellow") {
template = "#yellow";
const language = "en";
promise = handshake
.actionShowTrustWords(ownIdentity, otherIdentity, language)
.then((trustwords) => ({
data: {
"full-name": otherIdentity.username,
trustwords,
},
handlers: {
"accept-trust": executeHandler(handshake.actionTrustKey.bind(handshake, otherIdentity)),
"reject-trust": executeHandler(handshake.actionMistrustKey.bind(handshake, otherIdentity)),
"reset-data": executeHandler(handshake.actionResetUserData.bind(handshake, otherIdentity)),
},
}));
} else {
template = "#no-color";
const language = "en";
promise = Promise.resolve({
data: {
"full-name": otherIdentity.username,
},
handlers: {
"reset-data": executeHandler(handshake.actionResetUserData.bind(handshake, otherIdentity)),
},
});
}
return [template, promise];
// We will get colors green, yellow and no-color. Red won't happen, since
// a communication partner isn't red. If their trustwords are rejected, they
// go back to untrusted/no-color.
if (color == "green") {
template = "#green";
promise = Promise.resolve({
data: {
"full-name": otherIdentity.username,
},
handlers: {
"reset-trust": executeHandler(handshake.actionResetTrust.bind(handshake, otherIdentity)),
"reset-data": executeHandler(handshake.actionResetUserData.bind(handshake, otherIdentity)),
},
});
} else if (color == "yellow") {
template = "#yellow";
const language = "en";
promise = handshake
.actionShowTrustWords(ownIdentity, otherIdentity, language)
.then((trustwords) => ({
data: {
"full-name": otherIdentity.username,
trustwords,
},
handlers: {
"accept-trust": executeHandler(handshake.actionTrustKey.bind(handshake, otherIdentity)),
"reject-trust": executeHandler(handshake.actionMistrustKey.bind(handshake, otherIdentity)),
"reset-data": executeHandler(handshake.actionResetUserData.bind(handshake, otherIdentity)),
},
}));
} else {
template = "#no-color";
const language = "en";
promise = Promise.resolve({
data: {
"full-name": otherIdentity.username,
},
handlers: {
"reset-data": executeHandler(handshake.actionResetUserData.bind(handshake, otherIdentity)),
},
});
}
return [template, promise];
}
function onLoad() {
const root = document.getElementById("root");
pEpUtils.removeChildren(root);
allIdentities
.map(fetchData)
.map(([template, promise]) => {
const fragment = new pEpUtils.Fragment(template, document);
promise.then(({ data, handlers }) => {
fragment
.populate(data)
.attach("click", handlers);
});
/* we append nodes synchronously and fill the details
const root = document.getElementById("root");
pEpUtils.removeChildren(root);
allIdentities
.map(fetchData)
.map(([template, promise]) => {
const fragment = new pEpUtils.Fragment(template, document);
promise.then(({ data, handlers }) => {
fragment
.populate(data)
.attach("click", handlers);
});
/* we append nodes synchronously and fill the details
* asynchronously above. Otherwise attaching nodes
* asynchronously i found an overflowing error since the
* dialog window did not adapt its height */
root.appendChild(fragment.getRoot());
});
root.appendChild(fragment.getRoot());
});
}

@ -1,15 +1,15 @@
var { pEpUtils } = ChromeUtils.import("chrome://pEp4Tb/content/modules/utils.js");
function onLoad() {
let template = window.arguments[0];
let updateArray = window.arguments[1];
let root = document.getElementById("root");
pEpUtils.removeChildren(root);
let fragment = new pEpUtils.Fragment(template, document);
updateArray.map(fragment.update.bind(fragment));
root.appendChild(fragment.getRoot());
root.addEventListener("close", window.close.bind(window));
// windows open with default sizes equal to the former window, so
// we make sure to adapt to the current contents
window.sizeToContent();
let template = window.arguments[0];
let updateArray = window.arguments[1];
let root = document.getElementById("root");
pEpUtils.removeChildren(root);
let fragment = new pEpUtils.Fragment(template, document);
updateArray.map(fragment.update.bind(fragment));
root.appendChild(fragment.getRoot());
root.addEventListener("close", window.close.bind(window));
// windows open with default sizes equal to the former window, so
// we make sure to adapt to the current contents
window.sizeToContent();
}

@ -1,97 +1,97 @@
class Handshake {
constructor(pEpController) {
this.controller = pEpController;
this.ownIdentity;
this.allIdentities;
}
actionMistrustKey(identity) {
this.controller.key_mistrusted(identity);
}
actionTrustKey(identity) {
this.controller.trust_personal_key(identity);
}
actionShowTrustWords(ownIdentity, otherIdentity, language = "en") {
return this.controller.get_trustwords(ownIdentity, otherIdentity, language);
}
actionResetTrust(identity) {
this.controller.key_reset_trust(identity);
}
actionResetUserData(identity) {
this.controller.key_reset_user(identity);
}
showPrivacyStatusDialog() {
return [this.ownIdentity, this.allIdentities];
}
destroy() {
console.log("Handshake: destroy()");
}
async init(ownIdentity, allIdentities) {
// ownIdentity is an address
// allIdentities is an array of addresses
console.log("Handshake: init()");
this.ownIdentity = ownIdentity;
this.allIdentities = allIdentities;
return this.controller.myself(ownIdentity, "pEp_user_Id", "", "")
.then((myselfIdentity) => {
this.ownIdentity = myselfIdentity;
return this.filterIdentity(this.allIdentities, this.ownIdentity);
})
.then((identitiesArray) => this.updateAllIdentities(identitiesArray))
.then((identitiesArray) => this.identityRatings(identitiesArray))
.then((identitiesArray) => this.are_pEp_user(identitiesArray))
.then((this.getPrivacyColors).bind(this))
.then(this.sortByColor)
// eslint-disable-next-line no-return-assign
.then((identities) => this.allIdentities = identities)
.catch((err) => console.log(err));
}
// Private methods
filterIdentity(identityArray = [], identityToFilter) {
// remove identity from identityArray
return identityArray.filter((identity) => identity.address !== identityToFilter.address);
}
updateAllIdentities(identitiesArray) {
return Promise.all(identitiesArray.map((identity) => this.controller.update_identity(identity, "mockId")));
}
identityRatings(identitiesArray) {
return Promise.all(identitiesArray.map((identity) => this.controller.identity_rating(identity)));
}
are_pEp_user(identitiesArray) {
return Promise.all(identitiesArray.map((identity) => this.controller.is_pEp_user(identity)));
}
getPrivacyColors(identitiesArray) {
identitiesArray.map((identity) => {
identity.color = this.controller.colorFromRating(identity.rating);
return identity;
});
return identitiesArray;
}
sortByColor(array) {
array.sort((a, b) => ((a.color > b.color) ? 1 : -1));
return array;
}
constructor(pEpController) {
this.controller = pEpController;
this.ownIdentity;
this.allIdentities;
}
actionMistrustKey(identity) {
this.controller.key_mistrusted(identity);
}
actionTrustKey(identity) {
this.controller.trust_personal_key(identity);
}
actionShowTrustWords(ownIdentity, otherIdentity, language = "en") {
return this.controller.get_trustwords(ownIdentity, otherIdentity, language);
}
actionResetTrust(identity) {
this.controller.key_reset_trust(identity);
}
actionResetUserData(identity) {
this.controller.key_reset_user(identity);
}
showPrivacyStatusDialog() {
return [this.ownIdentity, this.allIdentities];