Bug 1854255 - Enforce prefer-const eslint rule in the whole mailnews/ directory. r=freaktechnik
Differential Revision: https://phabricator.services.mozilla.com/D191006 --HG-- extra : amend_source : fcf7dfdeb120778e28649841631a92a2dfc57062
This commit is contained in:
Родитель
89f11ad153
Коммит
aa951e8283
|
@ -0,0 +1,12 @@
|
|||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
rules: {
|
||||
// Enforce using `let` only when variables are reassigned.
|
||||
"prefer-const": ["error", { destructuring: "all" }],
|
||||
},
|
||||
};
|
|
@ -36,7 +36,7 @@ function abNameOnLoad() {
|
|||
var bundle = document.getElementById("bundle_addressBook");
|
||||
|
||||
if (gDirectory) {
|
||||
let oldListName = gDirectory.dirName;
|
||||
const oldListName = gDirectory.dirName;
|
||||
document.title = bundle.getFormattedString("addressBookTitleEdit", [
|
||||
oldListName,
|
||||
]);
|
||||
|
@ -62,7 +62,7 @@ function abNameOnLoad() {
|
|||
}
|
||||
|
||||
function abNameOKButton(event) {
|
||||
let newDirName = gNameInput.value.trim();
|
||||
const newDirName = gNameInput.value.trim();
|
||||
|
||||
// Do not allow an already existing name.
|
||||
if (
|
||||
|
@ -85,12 +85,12 @@ function abNameOKButton(event) {
|
|||
if (gDirectory) {
|
||||
gDirectory.dirName = newDirName;
|
||||
} else {
|
||||
let dirPrefId = MailServices.ab.newAddressBook(
|
||||
const dirPrefId = MailServices.ab.newAddressBook(
|
||||
newDirName,
|
||||
"",
|
||||
Ci.nsIAbManager.JS_DIRECTORY_TYPE
|
||||
);
|
||||
let directory = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
const directory = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
window.arguments[0].newDirectoryUID = directory.UID;
|
||||
if ("onNewDirectory" in window.arguments[0]) {
|
||||
window.arguments[0].onNewDirectory(directory);
|
||||
|
|
|
@ -25,7 +25,7 @@ var userContextId;
|
|||
window.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
() => {
|
||||
for (let id of [
|
||||
for (const id of [
|
||||
"username",
|
||||
"location",
|
||||
"statusArea",
|
||||
|
@ -55,8 +55,8 @@ window.addEventListener(
|
|||
* the default placeholder.
|
||||
*/
|
||||
function fillLocationPlaceholder() {
|
||||
let parts = uiElements.username.value.split("@");
|
||||
let domain = parts.length == 2 && parts[1] ? parts[1] : null;
|
||||
const parts = uiElements.username.value.split("@");
|
||||
const domain = parts.length == 2 && parts[1] ? parts[1] : null;
|
||||
|
||||
if (domain) {
|
||||
uiElements.location.setAttribute("placeholder", domain);
|
||||
|
@ -90,7 +90,7 @@ async function check() {
|
|||
// We might be accepting the dialog by pressing Enter in the URL input.
|
||||
handleCardDAVURLBlur();
|
||||
|
||||
let username = uiElements.username.value;
|
||||
const username = uiElements.username.value;
|
||||
|
||||
if (!uiElements.location.validity.valid && !username.split("@")[1]) {
|
||||
log.error(`Invalid URL: "${uiElements.location.value}"`);
|
||||
|
@ -128,8 +128,8 @@ async function check() {
|
|||
}
|
||||
|
||||
// Create a list of CardDAV directories that already exist.
|
||||
let existing = [];
|
||||
for (let d of MailServices.ab.directories) {
|
||||
const existing = [];
|
||||
for (const d of MailServices.ab.directories) {
|
||||
if (d.dirType == Ci.nsIAbManager.CARDDAV_DIRECTORY_TYPE) {
|
||||
existing.push(d.getStringValue("carddav.url", ""));
|
||||
}
|
||||
|
@ -137,12 +137,12 @@ async function check() {
|
|||
|
||||
// Display a checkbox for each directory that doesn't already exist.
|
||||
let alreadyAdded = 0;
|
||||
for (let book of foundBooks) {
|
||||
for (const book of foundBooks) {
|
||||
if (existing.includes(book.url.href)) {
|
||||
alreadyAdded++;
|
||||
continue;
|
||||
}
|
||||
let checkbox = uiElements.availableBooks.appendChild(
|
||||
const checkbox = uiElements.availableBooks.appendChild(
|
||||
document.createXULElement("checkbox")
|
||||
);
|
||||
checkbox.setAttribute("label", book.name);
|
||||
|
@ -217,9 +217,9 @@ window.addEventListener("dialogaccept", async event => {
|
|||
return;
|
||||
}
|
||||
|
||||
for (let checkbox of uiElements.availableBooks.children) {
|
||||
for (const checkbox of uiElements.availableBooks.children) {
|
||||
if (checkbox.checked) {
|
||||
let book = await checkbox._book.create();
|
||||
const book = await checkbox._book.create();
|
||||
if (window.arguments[0]) {
|
||||
// Pass the UID of the book back to the opening window.
|
||||
window.arguments[0].newDirectoryUID = book.UID;
|
||||
|
|
|
@ -53,18 +53,19 @@ window.addEventListener(
|
|||
);
|
||||
|
||||
window.addEventListener("dialogaccept", event => {
|
||||
let newDirName = gNameInput.value.trim();
|
||||
let newSyncInterval = gRefreshActiveInput.checked
|
||||
const newDirName = gNameInput.value.trim();
|
||||
const newSyncInterval = gRefreshActiveInput.checked
|
||||
? gRefreshMenulist.value
|
||||
: 0;
|
||||
|
||||
if (newDirName != gDirectory.dirName) {
|
||||
// Do not allow an already existing name.
|
||||
if (MailServices.ab.directoryNameExists(newDirName)) {
|
||||
let alertTitle = gStringBundle.GetStringFromName("duplicateNameTitle");
|
||||
let alertText = gStringBundle.formatStringFromName("duplicateNameText", [
|
||||
newDirName,
|
||||
]);
|
||||
const alertTitle = gStringBundle.GetStringFromName("duplicateNameTitle");
|
||||
const alertText = gStringBundle.formatStringFromName(
|
||||
"duplicateNameText",
|
||||
[newDirName]
|
||||
);
|
||||
Services.prompt.alert(window, alertTitle, alertText);
|
||||
event.preventDefault();
|
||||
return;
|
||||
|
@ -84,7 +85,7 @@ window.addEventListener("dialogaccept", event => {
|
|||
|
||||
function initRefreshInterval() {
|
||||
function createMenuItem(minutes) {
|
||||
let menuitem = document.createXULElement("menuitem");
|
||||
const menuitem = document.createXULElement("menuitem");
|
||||
menuitem.setAttribute("value", minutes);
|
||||
menuitem.setAttribute("data-l10n-attrs", "label");
|
||||
if (minutes < 60) {
|
||||
|
@ -121,7 +122,7 @@ function initRefreshInterval() {
|
|||
|
||||
let foundValue = false;
|
||||
|
||||
for (let min of [1, 5, 15, 30, 60, 120, 240, 360, 720, 1440]) {
|
||||
for (const min of [1, 5, 15, 30, 60, 120, 240, 360, 720, 1440]) {
|
||||
createMenuItem(min);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,27 +45,27 @@ var abFlavorDataProvider = {
|
|||
},
|
||||
};
|
||||
|
||||
let abResultsPaneObserver = {
|
||||
const abResultsPaneObserver = {
|
||||
onDragStart(event) {
|
||||
let selectedRows = GetSelectedRows();
|
||||
const selectedRows = GetSelectedRows();
|
||||
|
||||
if (!selectedRows) {
|
||||
return;
|
||||
}
|
||||
|
||||
let selectedAddresses = GetSelectedAddresses();
|
||||
const selectedAddresses = GetSelectedAddresses();
|
||||
|
||||
event.dataTransfer.setData("moz/abcard", selectedRows);
|
||||
event.dataTransfer.setData("moz/abcard", selectedRows);
|
||||
event.dataTransfer.setData("text/x-moz-address", selectedAddresses);
|
||||
event.dataTransfer.setData("text/plain", selectedAddresses);
|
||||
|
||||
let card = GetSelectedCard();
|
||||
const card = GetSelectedCard();
|
||||
if (card && card.displayName && !card.isMailList) {
|
||||
try {
|
||||
// A card implementation may throw NS_ERROR_NOT_IMPLEMENTED.
|
||||
// Don't break drag-and-drop if that happens.
|
||||
let vCard = card.translateTo("vcard");
|
||||
const vCard = card.translateTo("vcard");
|
||||
event.dataTransfer.setData("text/vcard", decodeURIComponent(vCard));
|
||||
event.dataTransfer.setData(
|
||||
"application/x-moz-file-promise-dest-filename",
|
||||
|
|
|
@ -46,7 +46,7 @@ function getLoadContext() {
|
|||
|
||||
function mailingListExists(listname) {
|
||||
if (MailServices.ab.mailListNameExists(listname)) {
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/addressbook/addressBook.properties"
|
||||
);
|
||||
Services.prompt.alert(
|
||||
|
@ -69,10 +69,10 @@ function mailingListExists(listname) {
|
|||
* @returns {boolean} - Whether the operation succeeded or not.
|
||||
*/
|
||||
function updateMailList(mailList, isNewList) {
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/addressbook/addressBook.properties"
|
||||
);
|
||||
let listname = document.getElementById("ListName").value.trim();
|
||||
const listname = document.getElementById("ListName").value.trim();
|
||||
|
||||
if (listname.length == 0) {
|
||||
alert(bundle.GetStringFromName("emptyListName"));
|
||||
|
@ -84,15 +84,15 @@ function updateMailList(mailList, isNewList) {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (let char of ',;"<>') {
|
||||
for (const char of ',;"<>') {
|
||||
if (listname.includes(char)) {
|
||||
alert(bundle.GetStringFromName("badListNameCharacters"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let canonicalNewListName = listname.toLowerCase();
|
||||
let canonicalOldListName = gOldListName.toLowerCase();
|
||||
const canonicalNewListName = listname.toLowerCase();
|
||||
const canonicalOldListName = gOldListName.toLowerCase();
|
||||
if (isNewList || canonicalOldListName != canonicalNewListName) {
|
||||
if (mailingListExists(listname)) {
|
||||
// After showing the "Mailing List Already Exists" error alert,
|
||||
|
@ -120,7 +120,7 @@ function updateMailList(mailList, isNewList) {
|
|||
*/
|
||||
function updateMailListMembers(mailList, parentDirectory) {
|
||||
// Gather email address inputs into a single string (comma-separated).
|
||||
let addresses = Array.from(
|
||||
const addresses = Array.from(
|
||||
document.querySelectorAll(".textbox-addressingWidget"),
|
||||
element => element.value
|
||||
)
|
||||
|
@ -128,23 +128,23 @@ function updateMailListMembers(mailList, parentDirectory) {
|
|||
.join();
|
||||
|
||||
// Convert the addresses string into address objects.
|
||||
let addressObjects =
|
||||
const addressObjects =
|
||||
MailServices.headerParser.makeFromDisplayAddress(addresses);
|
||||
let existingCards = mailList.childCards;
|
||||
const existingCards = mailList.childCards;
|
||||
|
||||
// Work out which addresses need to be added...
|
||||
let existingCardAddresses = existingCards.map(card => card.primaryEmail);
|
||||
let addressObjectsToAdd = addressObjects.filter(
|
||||
const existingCardAddresses = existingCards.map(card => card.primaryEmail);
|
||||
const addressObjectsToAdd = addressObjects.filter(
|
||||
aObj => !existingCardAddresses.includes(aObj.email)
|
||||
);
|
||||
|
||||
// ... and which need to be removed.
|
||||
let addressObjectAddresses = addressObjects.map(aObj => aObj.email);
|
||||
let cardsToRemove = existingCards.filter(
|
||||
const addressObjectAddresses = addressObjects.map(aObj => aObj.email);
|
||||
const cardsToRemove = existingCards.filter(
|
||||
card => !addressObjectAddresses.includes(card.primaryEmail)
|
||||
);
|
||||
|
||||
for (let { email, name } of addressObjectsToAdd) {
|
||||
for (const { email, name } of addressObjectsToAdd) {
|
||||
let card = parentDirectory.cardForEmailAddress(email);
|
||||
if (!card) {
|
||||
card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
|
@ -210,15 +210,15 @@ function OnLoadNewMailList() {
|
|||
}
|
||||
}
|
||||
|
||||
let cards = window.arguments[0].cards;
|
||||
const cards = window.arguments[0].cards;
|
||||
if (cards && cards.length > 0) {
|
||||
let listbox = document.getElementById("addressingWidget");
|
||||
let newListBoxNode = listbox.cloneNode(false);
|
||||
let templateNode = listbox.querySelector("richlistitem");
|
||||
const listbox = document.getElementById("addressingWidget");
|
||||
const newListBoxNode = listbox.cloneNode(false);
|
||||
const templateNode = listbox.querySelector("richlistitem");
|
||||
|
||||
top.MAX_RECIPIENTS = 0;
|
||||
for (let card of cards) {
|
||||
let address = MailServices.headerParser
|
||||
for (const card of cards) {
|
||||
const address = MailServices.headerParser
|
||||
.makeMailboxObject(card.displayName, card.primaryEmail)
|
||||
.toString();
|
||||
SetInputValue(address, newListBoxNode, templateNode);
|
||||
|
@ -255,7 +255,7 @@ function OnLoadNewMailList() {
|
|||
);
|
||||
}
|
||||
|
||||
let input = document.getElementById("addressCol1#1");
|
||||
const input = document.getElementById("addressCol1#1");
|
||||
input.popup.addEventListener("click", () => {
|
||||
awReturnHit(input);
|
||||
});
|
||||
|
@ -266,8 +266,8 @@ function OnLoadNewMailList() {
|
|||
function EditListOKButton(event) {
|
||||
// edit mailing list in database
|
||||
if (updateMailList(gEditList, false)) {
|
||||
let parentURI = GetParentDirectoryFromMailingListURI(gEditList.URI);
|
||||
let parentDirectory = GetDirectoryFromURI(parentURI);
|
||||
const parentURI = GetParentDirectoryFromMailingListURI(gEditList.URI);
|
||||
const parentDirectory = GetDirectoryFromURI(parentURI);
|
||||
updateMailListMembers(gEditList, parentDirectory);
|
||||
if (gListCard) {
|
||||
// modify the list card (for the results pane) from the mailing list
|
||||
|
@ -296,22 +296,22 @@ function OnLoadEditList() {
|
|||
document.getElementById("ListDescription").value = gEditList.description;
|
||||
gOldListName = gEditList.dirName;
|
||||
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/addressbook/addressBook.properties"
|
||||
);
|
||||
document.title = bundle.formatStringFromName("mailingListTitleEdit", [
|
||||
gOldListName,
|
||||
]);
|
||||
|
||||
let cards = gEditList.childCards;
|
||||
const cards = gEditList.childCards;
|
||||
if (cards.length > 0) {
|
||||
let listbox = document.getElementById("addressingWidget");
|
||||
let newListBoxNode = listbox.cloneNode(false);
|
||||
let templateNode = listbox.querySelector("richlistitem");
|
||||
const listbox = document.getElementById("addressingWidget");
|
||||
const newListBoxNode = listbox.cloneNode(false);
|
||||
const templateNode = listbox.querySelector("richlistitem");
|
||||
|
||||
top.MAX_RECIPIENTS = 0;
|
||||
for (let card of cards) {
|
||||
let address = MailServices.headerParser
|
||||
for (const card of cards) {
|
||||
const address = MailServices.headerParser
|
||||
.makeMailboxObject(card.displayName, card.primaryEmail)
|
||||
.toString();
|
||||
SetInputValue(address, newListBoxNode, templateNode);
|
||||
|
@ -361,14 +361,14 @@ function AppendLastRow() {
|
|||
awFitDummyRows(1);
|
||||
|
||||
// focus on first name
|
||||
let listName = document.getElementById("ListName");
|
||||
const listName = document.getElementById("ListName");
|
||||
if (listName) {
|
||||
listName.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function AppendNewRowAndSetFocus() {
|
||||
let lastInput = awGetInputElement(top.MAX_RECIPIENTS);
|
||||
const lastInput = awGetInputElement(top.MAX_RECIPIENTS);
|
||||
if (lastInput && lastInput.value) {
|
||||
awAppendNewRow(true);
|
||||
} else {
|
||||
|
@ -383,7 +383,7 @@ function SetInputValue(inputValue, parentNode, templateNode) {
|
|||
parentNode.appendChild(newNode); // we need to insert the new node before we set the value of the select element!
|
||||
|
||||
var input = newNode.querySelector(`input[is="autocomplete-input"]`);
|
||||
let label = newNode.querySelector(`label.person-icon`);
|
||||
const label = newNode.querySelector(`label.person-icon`);
|
||||
if (input) {
|
||||
input.value = inputValue;
|
||||
input.setAttribute("id", "addressCol1#" + top.MAX_RECIPIENTS);
|
||||
|
@ -399,7 +399,7 @@ function awClickEmptySpace(target, setFocus) {
|
|||
return;
|
||||
}
|
||||
|
||||
let lastInput = awGetInputElement(top.MAX_RECIPIENTS);
|
||||
const lastInput = awGetInputElement(top.MAX_RECIPIENTS);
|
||||
|
||||
if (lastInput && lastInput.value) {
|
||||
awAppendNewRow(setFocus);
|
||||
|
@ -409,9 +409,9 @@ function awClickEmptySpace(target, setFocus) {
|
|||
}
|
||||
|
||||
function awReturnHit(inputElement) {
|
||||
let row = awGetRowByInputElement(inputElement);
|
||||
const row = awGetRowByInputElement(inputElement);
|
||||
if (inputElement.value) {
|
||||
let nextInput = awGetInputElement(row + 1);
|
||||
const nextInput = awGetInputElement(row + 1);
|
||||
if (!nextInput) {
|
||||
awAppendNewRow(true);
|
||||
} else {
|
||||
|
@ -445,14 +445,14 @@ function awDeleteRow(rowToDelete) {
|
|||
* @returns {Element?} The input element from the new row.
|
||||
*/
|
||||
function awAppendNewRow(setFocus) {
|
||||
let body = document.getElementById("addressingWidget");
|
||||
let listitem1 = awGetListItem(1);
|
||||
const body = document.getElementById("addressingWidget");
|
||||
const listitem1 = awGetListItem(1);
|
||||
let input;
|
||||
let label;
|
||||
|
||||
if (body && listitem1) {
|
||||
let nextDummy = awGetNextDummyRow();
|
||||
let newNode = listitem1.cloneNode(true);
|
||||
const nextDummy = awGetNextDummyRow();
|
||||
const newNode = listitem1.cloneNode(true);
|
||||
if (nextDummy) {
|
||||
body.replaceChild(newNode, nextDummy);
|
||||
} else {
|
||||
|
@ -531,7 +531,7 @@ function DragOverAddressListTree(event) {
|
|||
}
|
||||
|
||||
function DropOnAddressListTree(event) {
|
||||
let dragSession = gDragService.getCurrentSession();
|
||||
const dragSession = gDragService.getCurrentSession();
|
||||
let trans;
|
||||
|
||||
try {
|
||||
|
@ -547,7 +547,7 @@ function DropOnAddressListTree(event) {
|
|||
for (let i = 0; i < dragSession.numDropItems; ++i) {
|
||||
dragSession.getData(trans, i);
|
||||
let dataObj = {};
|
||||
let bestFlavor = {};
|
||||
const bestFlavor = {};
|
||||
trans.getAnyTransferData(bestFlavor, dataObj);
|
||||
if (dataObj) {
|
||||
dataObj = dataObj.value.QueryInterface(Ci.nsISupportsString);
|
||||
|
@ -557,7 +557,7 @@ function DropOnAddressListTree(event) {
|
|||
}
|
||||
|
||||
// pull the URL out of the data object
|
||||
let address = dataObj.data.substring(0, dataObj.length);
|
||||
const address = dataObj.data.substring(0, dataObj.length);
|
||||
if (!address) {
|
||||
continue;
|
||||
}
|
||||
|
@ -575,9 +575,9 @@ function DropListAddress(target, address) {
|
|||
|
||||
// Break apart the MIME-ready header address into individual addressees to
|
||||
// add to the dialog.
|
||||
let addresses = MailServices.headerParser.parseEncodedHeader(address);
|
||||
for (let addr of addresses) {
|
||||
let lastInput = awGetInputElement(top.MAX_RECIPIENTS);
|
||||
const addresses = MailServices.headerParser.parseEncodedHeader(address);
|
||||
for (const addr of addresses) {
|
||||
const lastInput = awGetInputElement(top.MAX_RECIPIENTS);
|
||||
lastInput.value = addr.toString();
|
||||
awAppendNewRow(true);
|
||||
}
|
||||
|
@ -604,9 +604,9 @@ function awAbRecipientKeyPress(event, element) {
|
|||
}
|
||||
} else {
|
||||
let inputElement = element;
|
||||
let originalRow = awGetRowByInputElement(element);
|
||||
const originalRow = awGetRowByInputElement(element);
|
||||
let row;
|
||||
let addresses = MailServices.headerParser.makeFromDisplayAddress(
|
||||
const addresses = MailServices.headerParser.makeFromDisplayAddress(
|
||||
element.value
|
||||
);
|
||||
|
||||
|
@ -630,7 +630,7 @@ function awAbRecipientKeyPress(event, element) {
|
|||
row = originalRow;
|
||||
let needNewRows = false;
|
||||
|
||||
for (let address of addresses) {
|
||||
for (const address of addresses) {
|
||||
if (needNewRows) {
|
||||
inputElement = awAppendNewRow(false);
|
||||
} else {
|
||||
|
@ -653,7 +653,7 @@ function awAbRecipientKeyPress(event, element) {
|
|||
awReturnHit(inputElement);
|
||||
} else if (event.key == "Tab") {
|
||||
// Focus the last row to let "Tab" move focus to the "Cancel" button.
|
||||
let lastRow = row - 1;
|
||||
const lastRow = row - 1;
|
||||
awGetInputElement(lastRow).focus();
|
||||
}
|
||||
}
|
||||
|
@ -693,7 +693,7 @@ function awRecipientKeyDown(event, inputElement) {
|
|||
top.awRecipientInlineDelete = false;
|
||||
}
|
||||
if (!top.awRecipientInlineDelete) {
|
||||
let deleteForward = event.key == "Delete";
|
||||
const deleteForward = event.key == "Delete";
|
||||
awDeleteHit(inputElement, deleteForward);
|
||||
}
|
||||
}
|
||||
|
@ -704,11 +704,11 @@ function awRecipientKeyDown(event, inputElement) {
|
|||
case "ArrowUp":
|
||||
// Only browse recipients if the autocomplete popup is not open.
|
||||
if (!inputElement.popupOpen) {
|
||||
let row = awGetRowByInputElement(inputElement);
|
||||
let down = event.key == "ArrowDown";
|
||||
let noEdgeRow = down ? row < top.MAX_RECIPIENTS : row > 1;
|
||||
const row = awGetRowByInputElement(inputElement);
|
||||
const down = event.key == "ArrowDown";
|
||||
const noEdgeRow = down ? row < top.MAX_RECIPIENTS : row > 1;
|
||||
if (noEdgeRow) {
|
||||
let targetRow = down ? row + 1 : row - 1;
|
||||
const targetRow = down ? row + 1 : row - 1;
|
||||
awSetFocusTo(awGetInputElement(targetRow));
|
||||
}
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ function awRecipientKeyDown(event, inputElement) {
|
|||
* false: focus previous row after deleting the row
|
||||
*/
|
||||
function awDeleteHit(inputElement, deleteForward = false) {
|
||||
let row = awGetRowByInputElement(inputElement);
|
||||
const row = awGetRowByInputElement(inputElement);
|
||||
|
||||
// Don't delete the row if it's the last one remaining; just reset it.
|
||||
if (top.MAX_RECIPIENTS <= 1) {
|
||||
|
@ -770,18 +770,18 @@ function awTestRowSequence() {
|
|||
|
||||
// Debug code to verify the sequence is still good.
|
||||
|
||||
let listbox = document.getElementById("addressingWidget");
|
||||
let listitems = listbox.itemChildren;
|
||||
const listbox = document.getElementById("addressingWidget");
|
||||
const listitems = listbox.itemChildren;
|
||||
if (listitems.length >= top.MAX_RECIPIENTS) {
|
||||
for (let i = 1; i <= listitems.length; i++) {
|
||||
let item = listitems[i - 1];
|
||||
let inputID = item
|
||||
const item = listitems[i - 1];
|
||||
const inputID = item
|
||||
.querySelector(`input[is="autocomplete-input"]`)
|
||||
.id.split("#")[1];
|
||||
let menulist = item.querySelector("menulist");
|
||||
const menulist = item.querySelector("menulist");
|
||||
// In some places like the mailing list dialog there is no menulist,
|
||||
// and so no popupID that needs to be kept in sequence.
|
||||
let popupID = menulist && menulist.id.split("#")[1];
|
||||
const popupID = menulist && menulist.id.split("#")[1];
|
||||
if (inputID != i || (popupID && popupID != i)) {
|
||||
dump(
|
||||
`#ERROR: sequence broken at row ${i}, ` +
|
||||
|
@ -833,7 +833,7 @@ function awCreateDummyItem(aParent) {
|
|||
titem.style.height = item.getBoundingClientRect().height + "px";
|
||||
|
||||
for (let i = 0; i < awGetNumberOfCols(); i++) {
|
||||
let cell = awCreateDummyCell(titem);
|
||||
const cell = awCreateDummyCell(titem);
|
||||
if (item.children[i].hasAttribute("style")) {
|
||||
cell.setAttribute("style", item.children[i].getAttribute("style"));
|
||||
}
|
||||
|
@ -855,11 +855,11 @@ function awFitDummyRows() {
|
|||
}
|
||||
|
||||
function awCreateOrRemoveDummyRows() {
|
||||
let listbox = document.getElementById("addressingWidget");
|
||||
let listboxHeight = listbox.getBoundingClientRect().height;
|
||||
const listbox = document.getElementById("addressingWidget");
|
||||
const listboxHeight = listbox.getBoundingClientRect().height;
|
||||
|
||||
// remove rows to remove scrollbar
|
||||
let kids = listbox.querySelectorAll("[_isDummyRow]");
|
||||
const kids = listbox.querySelectorAll("[_isDummyRow]");
|
||||
for (
|
||||
let i = kids.length - 1;
|
||||
gAWContentHeight > listboxHeight && i >= 0;
|
||||
|
|
|
@ -84,9 +84,9 @@ function SetAbView(aURI, aSearchQuery, aSearchString) {
|
|||
|
||||
// If the selected address book is LDAP and the search box is empty,
|
||||
// inform the user of the empty results pane.
|
||||
let abResultsTree = document.getElementById("abResultsTree");
|
||||
let cardViewOuterBox = document.getElementById("CardViewOuterBox");
|
||||
let blankResultsPaneMessageBox = document.getElementById(
|
||||
const abResultsTree = document.getElementById("abResultsTree");
|
||||
const cardViewOuterBox = document.getElementById("CardViewOuterBox");
|
||||
const blankResultsPaneMessageBox = document.getElementById(
|
||||
"blankResultsPaneMessageBox"
|
||||
);
|
||||
if (aURI.startsWith("moz-abldapdirectory://") && !aSearchQuery) {
|
||||
|
@ -204,17 +204,17 @@ function GetSelectedAbCards() {
|
|||
return [];
|
||||
}
|
||||
|
||||
let cards = [];
|
||||
const cards = [];
|
||||
var count = abView.selection.getRangeCount();
|
||||
for (let i = 0; i < count; ++i) {
|
||||
let start = {};
|
||||
let end = {};
|
||||
const start = {};
|
||||
const end = {};
|
||||
|
||||
abView.selection.getRangeAt(i, start, end);
|
||||
|
||||
for (let j = start.value; j <= end.value; ++j) {
|
||||
// avoid inserting null element into the list. GetRangeAt() may be buggy.
|
||||
let tmp = abView.getCardFromRow(j);
|
||||
const tmp = abView.getCardFromRow(j);
|
||||
if (tmp) {
|
||||
cards.push(tmp);
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ var ResultsPaneController = {
|
|||
// cmd_print is currently only used in SeaMonkey.
|
||||
// Prevent printing when we don't have an opener (browserDOMWindow is
|
||||
// null).
|
||||
let enabled = window.browserDOMWindow && GetNumSelectedCards() > 0;
|
||||
const enabled = window.browserDOMWindow && GetNumSelectedCards() > 0;
|
||||
document.querySelectorAll("[command=cmd_print]").forEach(e => {
|
||||
e.disabled = !enabled;
|
||||
});
|
||||
|
@ -426,12 +426,12 @@ function updateDeleteControls(
|
|||
goSetAccessKey("cmd_delete", accessKeyAttribute);
|
||||
|
||||
// The toolbar button doesn't update itself from the command. Do that now.
|
||||
let button = document.getElementById("button-abdelete");
|
||||
const button = document.getElementById("button-abdelete");
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
|
||||
let command = document.getElementById("cmd_delete");
|
||||
const command = document.getElementById("cmd_delete");
|
||||
button.label = command.getAttribute("label");
|
||||
button.setAttribute(
|
||||
"tooltiptext",
|
||||
|
@ -473,7 +473,7 @@ function makeMimeAddressFromCard(card) {
|
|||
|
||||
let email;
|
||||
if (card.isMailList) {
|
||||
let directory = GetDirectoryFromURI(card.mailListURI);
|
||||
const directory = GetDirectoryFromURI(card.mailListURI);
|
||||
email = directory.description || card.displayName;
|
||||
} else {
|
||||
email = card.emailAddresses[0];
|
||||
|
|
|
@ -16,15 +16,15 @@ function ABView(
|
|||
this.directory = directory;
|
||||
this.listener = listener;
|
||||
|
||||
let directories = directory ? [directory] : MailServices.ab.directories;
|
||||
const directories = directory ? [directory] : MailServices.ab.directories;
|
||||
if (searchQuery) {
|
||||
searchQuery = searchQuery.replace(/^\?+/, "");
|
||||
for (let dir of directories) {
|
||||
for (const dir of directories) {
|
||||
dir.search(searchQuery, searchString, this);
|
||||
}
|
||||
} else {
|
||||
for (let dir of directories) {
|
||||
for (let card of dir.childCards) {
|
||||
for (const dir of directories) {
|
||||
for (const card of dir.childCards) {
|
||||
this._rowMap.push(new abViewCard(card, dir));
|
||||
}
|
||||
}
|
||||
|
@ -66,13 +66,13 @@ ABView.prototype = {
|
|||
collator: new Intl.Collator(undefined, { numeric: true }),
|
||||
|
||||
deleteSelectedCards() {
|
||||
let directoryMap = new Map();
|
||||
const directoryMap = new Map();
|
||||
for (let i = 0; i < this.selection.getRangeCount(); i++) {
|
||||
let start = {};
|
||||
let finish = {};
|
||||
const start = {};
|
||||
const finish = {};
|
||||
this.selection.getRangeAt(i, start, finish);
|
||||
for (let j = start.value; j <= finish.value; j++) {
|
||||
let card = this.getCardFromRow(j);
|
||||
const card = this.getCardFromRow(j);
|
||||
let cardSet = directoryMap.get(card.directoryUID);
|
||||
if (!cardSet) {
|
||||
cardSet = new Set();
|
||||
|
@ -93,7 +93,7 @@ ABView.prototype = {
|
|||
|
||||
cardSet = [...cardSet];
|
||||
directory.deleteCards(cardSet.filter(card => !card.isMailList));
|
||||
for (let card of cardSet.filter(card => card.isMailList)) {
|
||||
for (const card of cardSet.filter(card => card.isMailList)) {
|
||||
MailServices.ab.deleteAddressBook(card.mailListURI);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ ABView.prototype = {
|
|||
},
|
||||
sortBy(sortColumn, sortDirection, resort) {
|
||||
// Remember what was selected.
|
||||
let selection = this.selection;
|
||||
const selection = this.selection;
|
||||
if (selection) {
|
||||
for (let i = 0; i < this._rowMap.length; i++) {
|
||||
this._rowMap[i].wasSelected = selection.isSelected(i);
|
||||
|
@ -122,8 +122,8 @@ ABView.prototype = {
|
|||
this._rowMap.reverse();
|
||||
} else {
|
||||
this._rowMap.sort((a, b) => {
|
||||
let aText = a.getText(sortColumn);
|
||||
let bText = b.getText(sortColumn);
|
||||
const aText = a.getText(sortColumn);
|
||||
const bText = b.getText(sortColumn);
|
||||
if (sortDirection == "descending") {
|
||||
return this.collator.compare(bText, aText);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ ABView.prototype = {
|
|||
},
|
||||
setTree(tree) {
|
||||
this.tree = tree;
|
||||
for (let topic of this._notifications) {
|
||||
for (const topic of this._notifications) {
|
||||
if (tree) {
|
||||
Services.obs.addObserver(this, topic, true);
|
||||
} else {
|
||||
|
@ -191,10 +191,10 @@ ABView.prototype = {
|
|||
let offerCertException = false;
|
||||
try {
|
||||
// If code is not an NSS error, getErrorClass() will fail.
|
||||
let nssErrorsService = Cc["@mozilla.org/nss_errors_service;1"].getService(
|
||||
Ci.nsINSSErrorsService
|
||||
);
|
||||
let errorClass = nssErrorsService.getErrorClass(status);
|
||||
const nssErrorsService = Cc[
|
||||
"@mozilla.org/nss_errors_service;1"
|
||||
].getService(Ci.nsINSSErrorsService);
|
||||
const errorClass = nssErrorsService.getErrorClass(status);
|
||||
if (errorClass == Ci.nsINSSErrorsService.ERROR_CLASS_BAD_CERT) {
|
||||
offerCertException = true;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ ABView.prototype = {
|
|||
|
||||
if (offerCertException) {
|
||||
// Give the user the option of adding an exception for the bad cert.
|
||||
let params = {
|
||||
const params = {
|
||||
exceptionAdded: false,
|
||||
securityInfo: secInfo,
|
||||
prefetchCert: true,
|
||||
|
@ -226,7 +226,7 @@ ABView.prototype = {
|
|||
"mail.addr_book.lastnamefirst",
|
||||
0
|
||||
);
|
||||
for (let card of this._rowMap) {
|
||||
for (const card of this._rowMap) {
|
||||
delete card._getTextCache.GeneratedName;
|
||||
}
|
||||
if (this.tree) {
|
||||
|
@ -252,7 +252,7 @@ ABView.prototype = {
|
|||
}
|
||||
|
||||
subject.QueryInterface(Ci.nsIAbDirectory);
|
||||
let scrollPosition = this.tree?.getFirstVisibleRow();
|
||||
const scrollPosition = this.tree?.getFirstVisibleRow();
|
||||
for (let i = this._rowMap.length - 1; i >= 0; i--) {
|
||||
if (this._rowMap[i].directory.UID == subject.UID) {
|
||||
this._rowMap.splice(i, 1);
|
||||
|
@ -273,7 +273,7 @@ ABView.prototype = {
|
|||
subject.QueryInterface(Ci.nsIAbDirectory);
|
||||
if (subject == this.directory) {
|
||||
this._rowMap.length = 0;
|
||||
for (let card of this.directory.childCards) {
|
||||
for (const card of this.directory.childCards) {
|
||||
this._rowMap.push(new abViewCard(card, this.directory));
|
||||
}
|
||||
this.sortBy(this.sortColumn, this.sortDirection, true);
|
||||
|
@ -283,10 +283,10 @@ ABView.prototype = {
|
|||
}
|
||||
break;
|
||||
case "addrbook-list-created": {
|
||||
let parentDir = MailServices.ab.getDirectoryFromUID(data);
|
||||
const parentDir = MailServices.ab.getDirectoryFromUID(data);
|
||||
// `subject` is an nsIAbDirectory, make it the matching card instead.
|
||||
subject.QueryInterface(Ci.nsIAbDirectory);
|
||||
for (let card of parentDir.childCards) {
|
||||
for (const card of parentDir.childCards) {
|
||||
if (card.UID == subject.UID) {
|
||||
subject = card;
|
||||
break;
|
||||
|
@ -301,11 +301,11 @@ ABView.prototype = {
|
|||
}
|
||||
|
||||
subject.QueryInterface(Ci.nsIAbCard);
|
||||
let viewCard = new abViewCard(subject);
|
||||
let sortText = viewCard.getText(this.sortColumn);
|
||||
const viewCard = new abViewCard(subject);
|
||||
const sortText = viewCard.getText(this.sortColumn);
|
||||
let addIndex = null;
|
||||
for (let i = 0; addIndex === null && i < this._rowMap.length; i++) {
|
||||
let comparison = this.collator.compare(
|
||||
const comparison = this.collator.compare(
|
||||
sortText,
|
||||
this._rowMap[i].getText(this.sortColumn)
|
||||
);
|
||||
|
@ -335,7 +335,7 @@ ABView.prototype = {
|
|||
}
|
||||
// `subject` is an nsIAbDirectory, make it the matching card instead.
|
||||
subject.QueryInterface(Ci.nsIAbDirectory);
|
||||
for (let card of parentDir.childCards) {
|
||||
for (const card of parentDir.childCards) {
|
||||
if (card.UID == subject.UID) {
|
||||
subject = card;
|
||||
break;
|
||||
|
@ -363,7 +363,7 @@ ABView.prototype = {
|
|||
|
||||
case "addrbook-list-deleted": {
|
||||
subject.QueryInterface(Ci.nsIAbDirectory);
|
||||
let scrollPosition = this.tree?.getFirstVisibleRow();
|
||||
const scrollPosition = this.tree?.getFirstVisibleRow();
|
||||
for (let i = this._rowMap.length - 1; i >= 0; i--) {
|
||||
if (this._rowMap[i].card.UID == subject.UID) {
|
||||
this._rowMap.splice(i, 1);
|
||||
|
@ -387,7 +387,7 @@ ABView.prototype = {
|
|||
// Falls through.
|
||||
case "addrbook-contact-deleted": {
|
||||
subject.QueryInterface(Ci.nsIAbCard);
|
||||
let scrollPosition = this.tree?.getFirstVisibleRow();
|
||||
const scrollPosition = this.tree?.getFirstVisibleRow();
|
||||
for (let i = this._rowMap.length - 1; i >= 0; i--) {
|
||||
if (
|
||||
this._rowMap[i].card.equals(subject) &&
|
||||
|
@ -436,7 +436,7 @@ abViewCard.listFormatter = new Services.intl.ListFormat(
|
|||
abViewCard.prototype = {
|
||||
_getText(columnID) {
|
||||
try {
|
||||
let { getProperty, supportsVCard, vCardProperties } = this.card;
|
||||
const { getProperty, supportsVCard, vCardProperties } = this.card;
|
||||
|
||||
if (this.card.isMailList) {
|
||||
if (columnID == "GeneratedName") {
|
||||
|
@ -483,7 +483,7 @@ abViewCard.prototype = {
|
|||
return getProperty("JobTitle", "");
|
||||
case "Department":
|
||||
if (supportsVCard) {
|
||||
let vCardValue = vCardProperties.getFirstValue("org");
|
||||
const vCardValue = vCardProperties.getFirstValue("org");
|
||||
if (Array.isArray(vCardValue)) {
|
||||
return vCardValue[1] || "";
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ abViewCard.prototype = {
|
|||
case "Company":
|
||||
case "Organization":
|
||||
if (supportsVCard) {
|
||||
let vCardValue = vCardProperties.getFirstValue("org");
|
||||
const vCardValue = vCardProperties.getFirstValue("org");
|
||||
if (Array.isArray(vCardValue)) {
|
||||
return vCardValue[0] || "";
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
* to make the map use either HomeAddress or WorkAddress.
|
||||
*/
|
||||
initMapAddressFromCard(card, addrPrefix) {
|
||||
let mapItURLFormat = this._getMapURLPref();
|
||||
let doNotShowMap = !mapItURLFormat || !addrPrefix || !card;
|
||||
const mapItURLFormat = this._getMapURLPref();
|
||||
const doNotShowMap = !mapItURLFormat || !addrPrefix || !card;
|
||||
this._setWidgetDisabled(doNotShowMap);
|
||||
if (doNotShowMap) {
|
||||
return;
|
||||
|
@ -102,16 +102,16 @@
|
|||
let itemFound = true;
|
||||
let defaultFound = false;
|
||||
const kUserIndex = 100;
|
||||
let mapList = this;
|
||||
const mapList = this;
|
||||
while (mapList.hasChildNodes()) {
|
||||
mapList.lastChild.remove();
|
||||
}
|
||||
|
||||
let defaultUrl = this._getMapURLPref();
|
||||
const defaultUrl = this._getMapURLPref();
|
||||
|
||||
// Creates the menuitem with supplied data.
|
||||
function addMapService(url, name) {
|
||||
let item = document.createXULElement("menuitem");
|
||||
const item = document.createXULElement("menuitem");
|
||||
item.setAttribute("url", url);
|
||||
item.setAttribute("label", name);
|
||||
item.setAttribute("type", "radio");
|
||||
|
@ -130,7 +130,7 @@
|
|||
// Add all defined map services as menuitems.
|
||||
while (itemFound) {
|
||||
let urlName;
|
||||
let urlTemplate = this._getMapURLPref(index);
|
||||
const urlTemplate = this._getMapURLPref(index);
|
||||
if (!urlTemplate) {
|
||||
itemFound = false;
|
||||
} else {
|
||||
|
@ -160,7 +160,7 @@
|
|||
// If user had put a customized map URL into mail.addr_book.mapit_url.format
|
||||
// preserve it as a new map service named with the URL.
|
||||
// 'index' now points to the first unused entry in prefs.
|
||||
let defaultName = generateName(defaultUrl);
|
||||
const defaultName = generateName(defaultUrl);
|
||||
addMapService(defaultUrl, defaultName);
|
||||
Services.prefs.setCharPref(
|
||||
"mail.addr_book.mapit_url." + index + ".format",
|
||||
|
@ -180,9 +180,9 @@
|
|||
*/
|
||||
_chooseMapService(item) {
|
||||
// Save selected URL as the default.
|
||||
let defaultUrl = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
|
||||
Ci.nsIPrefLocalizedString
|
||||
);
|
||||
const defaultUrl = Cc[
|
||||
"@mozilla.org/pref-localizedstring;1"
|
||||
].createInstance(Ci.nsIPrefLocalizedString);
|
||||
defaultUrl.data = item.getAttribute("url");
|
||||
Services.prefs.setComplexValue(
|
||||
"mail.addr_book.mapit_url.format",
|
||||
|
|
|
@ -39,16 +39,16 @@ function AddrBookCard() {
|
|||
|
||||
this._hasVCard = true;
|
||||
|
||||
let vCard = this.getProperty("_vCard", "");
|
||||
const vCard = this.getProperty("_vCard", "");
|
||||
try {
|
||||
if (vCard) {
|
||||
let vCardProperties = lazy.VCardProperties.fromVCard(vCard, {
|
||||
const vCardProperties = lazy.VCardProperties.fromVCard(vCard, {
|
||||
isGoogleCardDAV: this._isGoogleCardDAV,
|
||||
});
|
||||
// Custom1..4 properties could still exist as nsIAbCard properties.
|
||||
// Migrate them now.
|
||||
for (let key of ["Custom1", "Custom2", "Custom3", "Custom4"]) {
|
||||
let value = this.getProperty(key, "");
|
||||
for (const key of ["Custom1", "Custom2", "Custom3", "Custom4"]) {
|
||||
const value = this.getProperty(key, "");
|
||||
if (
|
||||
value &&
|
||||
vCardProperties.getFirstEntry(`x-${key.toLowerCase()}`) === null
|
||||
|
@ -91,7 +91,7 @@ AddrBookCard.prototype = {
|
|||
|
||||
case Ci.nsIAbCard.GENERATE_LAST_FIRST_ORDER:
|
||||
if (this.lastName) {
|
||||
let otherNames = [
|
||||
const otherNames = [
|
||||
this.prefixName,
|
||||
this.firstName,
|
||||
this.middleName,
|
||||
|
@ -114,10 +114,10 @@ AddrBookCard.prototype = {
|
|||
break;
|
||||
|
||||
default:
|
||||
let startNames = [this.prefixName, this.firstName, this.middleName]
|
||||
const startNames = [this.prefixName, this.firstName, this.middleName]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
let endNames = [this.lastName, this.suffixName]
|
||||
const endNames = [this.lastName, this.suffixName]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
result =
|
||||
|
@ -184,7 +184,7 @@ AddrBookCard.prototype = {
|
|||
this._uid = value;
|
||||
},
|
||||
get properties() {
|
||||
let props = [];
|
||||
const props = [];
|
||||
for (const [name, value] of this._properties) {
|
||||
props.push({
|
||||
get name() {
|
||||
|
@ -219,7 +219,7 @@ AddrBookCard.prototype = {
|
|||
return name;
|
||||
},
|
||||
set firstName(value) {
|
||||
let n = this._vCardProperties.getFirstEntry("n");
|
||||
const n = this._vCardProperties.getFirstEntry("n");
|
||||
if (n) {
|
||||
n.value[1] = value;
|
||||
} else {
|
||||
|
@ -243,7 +243,7 @@ AddrBookCard.prototype = {
|
|||
return name;
|
||||
},
|
||||
set lastName(value) {
|
||||
let n = this._vCardProperties.getFirstEntry("n");
|
||||
const n = this._vCardProperties.getFirstEntry("n");
|
||||
if (n) {
|
||||
n.value[0] = value;
|
||||
} else {
|
||||
|
@ -259,7 +259,7 @@ AddrBookCard.prototype = {
|
|||
return this._vCardProperties.getFirstValue("fn") || "";
|
||||
},
|
||||
set displayName(value) {
|
||||
let fn = this._vCardProperties.getFirstEntry("fn");
|
||||
const fn = this._vCardProperties.getFirstEntry("fn");
|
||||
if (fn) {
|
||||
fn.value = value;
|
||||
} else {
|
||||
|
@ -275,14 +275,14 @@ AddrBookCard.prototype = {
|
|||
return this._vCardProperties.getAllValuesSorted("email")[0] ?? "";
|
||||
},
|
||||
set primaryEmail(value) {
|
||||
let entries = this._vCardProperties.getAllEntriesSorted("email");
|
||||
const entries = this._vCardProperties.getAllEntriesSorted("email");
|
||||
if (entries.length && entries[0].value != value) {
|
||||
this._vCardProperties.removeEntry(entries[0]);
|
||||
entries.shift();
|
||||
}
|
||||
|
||||
if (value) {
|
||||
let existing = entries.find(e => e.value == value);
|
||||
const existing = entries.find(e => e.value == value);
|
||||
if (existing) {
|
||||
existing.params.pref = "1";
|
||||
} else {
|
||||
|
@ -304,7 +304,7 @@ AddrBookCard.prototype = {
|
|||
return this._vCardProperties.getAllValuesSorted("email");
|
||||
},
|
||||
get photoURL() {
|
||||
let photoEntry = this.vCardProperties.getFirstEntry("photo");
|
||||
const photoEntry = this.vCardProperties.getFirstEntry("photo");
|
||||
if (photoEntry?.value) {
|
||||
if (photoEntry.value?.startsWith("data:image/")) {
|
||||
// This is a version 4.0 card
|
||||
|
@ -328,9 +328,9 @@ AddrBookCard.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
let photoName = this.getProperty("PhotoName", "");
|
||||
const photoName = this.getProperty("PhotoName", "");
|
||||
if (photoName) {
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
const file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append("Photos");
|
||||
file.append(photoName);
|
||||
return Services.io.newFileURI(file).spec;
|
||||
|
@ -358,7 +358,7 @@ AddrBookCard.prototype = {
|
|||
return this.getProperty(name);
|
||||
},
|
||||
getPropertyAsUint32(name) {
|
||||
let value = this.getProperty(name);
|
||||
const value = this.getProperty(name);
|
||||
if (!isNaN(parseInt(value, 10))) {
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ AddrBookCard.prototype = {
|
|||
);
|
||||
},
|
||||
getPropertyAsBool(name, defaultValue) {
|
||||
let value = this.getProperty(name);
|
||||
const value = this.getProperty(name);
|
||||
switch (value) {
|
||||
case false:
|
||||
case 0:
|
||||
|
@ -432,9 +432,9 @@ AddrBookCard.prototype = {
|
|||
return encodeURIComponent(this._vCardProperties.toVCard());
|
||||
}
|
||||
// Get nsAbCardProperty to do the work, the code is in C++ anyway.
|
||||
let cardCopy = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
const cardCopy = Cc[
|
||||
"@mozilla.org/addressbook/cardproperty;1"
|
||||
].createInstance(Ci.nsIAbCard);
|
||||
cardCopy.UID = this.UID;
|
||||
cardCopy.copy(this);
|
||||
return cardCopy.translateTo(type);
|
||||
|
@ -452,7 +452,7 @@ AddrBookCard.prototype = {
|
|||
);
|
||||
},
|
||||
generateChatName() {
|
||||
for (let name of [
|
||||
for (const name of [
|
||||
"_GoogleTalk",
|
||||
"_AimScreenName",
|
||||
"_Yahoo",
|
||||
|
|
|
@ -92,7 +92,7 @@ class AddrBookDirectory {
|
|||
}
|
||||
|
||||
getCard(uid) {
|
||||
let card = new lazy.AddrBookCard();
|
||||
const card = new lazy.AddrBookCard();
|
||||
card.directoryUID = this.UID;
|
||||
card._uid = uid;
|
||||
card._properties = this.loadCardProperties(uid);
|
||||
|
@ -143,10 +143,10 @@ class AddrBookDirectory {
|
|||
* @returns {Map<string, string>}
|
||||
*/
|
||||
prepareToSaveCard(card, uid) {
|
||||
let propertyMap = new Map(
|
||||
const propertyMap = new Map(
|
||||
Array.from(card.properties, p => [p.name, p.value])
|
||||
);
|
||||
let newProperties = new Map();
|
||||
const newProperties = new Map();
|
||||
|
||||
// Get a VCardProperties object for the card.
|
||||
let vCardProperties;
|
||||
|
@ -166,7 +166,7 @@ class AddrBookDirectory {
|
|||
}
|
||||
|
||||
// Collect only the properties we intend to keep.
|
||||
for (let [name, value] of propertyMap) {
|
||||
for (const [name, value] of propertyMap) {
|
||||
if (lazy.BANISHED_PROPERTIES.includes(name)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -178,23 +178,23 @@ class AddrBookDirectory {
|
|||
// Add the vCard and the properties from it we want to cache.
|
||||
newProperties.set("_vCard", vCardProperties.toVCard());
|
||||
|
||||
let displayName = vCardProperties.getFirstValue("fn");
|
||||
const displayName = vCardProperties.getFirstValue("fn");
|
||||
newProperties.set("DisplayName", displayName || "");
|
||||
|
||||
let flatten = value => {
|
||||
const flatten = value => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.join(" ");
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
let name = vCardProperties.getFirstValue("n");
|
||||
const name = vCardProperties.getFirstValue("n");
|
||||
if (Array.isArray(name)) {
|
||||
newProperties.set("FirstName", flatten(name[1]));
|
||||
newProperties.set("LastName", flatten(name[0]));
|
||||
}
|
||||
|
||||
let email = vCardProperties.getAllValuesSorted("email");
|
||||
const email = vCardProperties.getAllValuesSorted("email");
|
||||
if (email[0]) {
|
||||
newProperties.set("PrimaryEmail", email[0]);
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class AddrBookDirectory {
|
|||
newProperties.set("SecondEmail", email[1]);
|
||||
}
|
||||
|
||||
let nickname = vCardProperties.getFirstValue("nickname");
|
||||
const nickname = vCardProperties.getFirstValue("nickname");
|
||||
if (nickname) {
|
||||
newProperties.set("NickName", flatten(nickname));
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ class AddrBookDirectory {
|
|||
return this._prefBranch.getIntPref("position", 1);
|
||||
}
|
||||
get childNodes() {
|
||||
let lists = Array.from(
|
||||
const lists = Array.from(
|
||||
this.lists.values(),
|
||||
list =>
|
||||
new lazy.AddrBookMailingList(
|
||||
|
@ -286,7 +286,7 @@ class AddrBookDirectory {
|
|||
);
|
||||
}
|
||||
get childCards() {
|
||||
let results = Array.from(
|
||||
const results = Array.from(
|
||||
this.lists.values(),
|
||||
list =>
|
||||
new lazy.AddrBookMailingList(
|
||||
|
@ -329,13 +329,13 @@ class AddrBookDirectory {
|
|||
).concat(Array.from(this.cards.keys(), this.getCard, this));
|
||||
|
||||
// Process the query string into a tree of conditions to match.
|
||||
let lispRegexp = /^\((and|or|not|([^\)]*)(\)+))/;
|
||||
const lispRegexp = /^\((and|or|not|([^\)]*)(\)+))/;
|
||||
let index = 0;
|
||||
let rootQuery = { children: [], op: "or" };
|
||||
const rootQuery = { children: [], op: "or" };
|
||||
let currentQuery = rootQuery;
|
||||
|
||||
while (true) {
|
||||
let match = lispRegexp.exec(query.substring(index));
|
||||
const match = lispRegexp.exec(query.substring(index));
|
||||
if (!match) {
|
||||
break;
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ class AddrBookDirectory {
|
|||
|
||||
if (["and", "or", "not"].includes(match[1])) {
|
||||
// For the opening bracket, step down a level.
|
||||
let child = {
|
||||
const child = {
|
||||
parent: currentQuery,
|
||||
children: [],
|
||||
op: match[1],
|
||||
|
@ -351,7 +351,7 @@ class AddrBookDirectory {
|
|||
currentQuery.children.push(child);
|
||||
currentQuery = child;
|
||||
} else {
|
||||
let [name, condition, value] = match[2].split(",");
|
||||
const [name, condition, value] = match[2].split(",");
|
||||
currentQuery.children.push({
|
||||
name,
|
||||
condition,
|
||||
|
@ -381,7 +381,7 @@ class AddrBookDirectory {
|
|||
console.error(ex);
|
||||
properties = new Map();
|
||||
}
|
||||
for (let [key, value] of card._properties) {
|
||||
for (const [key, value] of card._properties) {
|
||||
if (!properties.has(key)) {
|
||||
properties.set(key, value);
|
||||
}
|
||||
|
@ -389,9 +389,9 @@ class AddrBookDirectory {
|
|||
} else {
|
||||
properties = card._properties;
|
||||
}
|
||||
let matches = b => {
|
||||
const matches = b => {
|
||||
if ("condition" in b) {
|
||||
let { name, condition, value } = b;
|
||||
const { name, condition, value } = b;
|
||||
if (name == "IsMailList" && condition == "=") {
|
||||
return card.isMailList == (value == "true");
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ class AddrBookDirectory {
|
|||
return matches(rootQuery);
|
||||
}, this);
|
||||
|
||||
for (let card of results) {
|
||||
for (const card of results) {
|
||||
listener.onSearchFoundCard(card);
|
||||
}
|
||||
listener.onSearchFinished(Cr.NS_OK, true, null, "");
|
||||
|
@ -469,8 +469,8 @@ class AddrBookDirectory {
|
|||
// Nothing so far? Go through all the cards checking all of the addresses.
|
||||
// This could be slow.
|
||||
emailAddress = emailAddress.toLowerCase();
|
||||
for (let [uid, properties] of this.cards) {
|
||||
let vCard = properties.get("_vCard");
|
||||
for (const [uid, properties] of this.cards) {
|
||||
const vCard = properties.get("_vCard");
|
||||
// If the vCard string doesn't include the email address, the parsed
|
||||
// vCard won't include it either, so don't waste time parsing it.
|
||||
if (!vCard?.toLowerCase().includes(emailAddress)) {
|
||||
|
@ -499,7 +499,7 @@ class AddrBookDirectory {
|
|||
);
|
||||
}
|
||||
getMailListFromName(name) {
|
||||
for (let list of this.lists.values()) {
|
||||
for (const list of this.lists.values()) {
|
||||
if (list.name.toLowerCase() == name.toLowerCase()) {
|
||||
return new lazy.AddrBookMailingList(
|
||||
list.uid,
|
||||
|
@ -557,11 +557,11 @@ class AddrBookDirectory {
|
|||
);
|
||||
}
|
||||
|
||||
let oldProperties = this.loadCardProperties(card.UID);
|
||||
let newProperties = this.prepareToSaveCard(card);
|
||||
const oldProperties = this.loadCardProperties(card.UID);
|
||||
const newProperties = this.prepareToSaveCard(card);
|
||||
|
||||
let allProperties = new Set(oldProperties.keys());
|
||||
for (let key of newProperties.keys()) {
|
||||
const allProperties = new Set(oldProperties.keys());
|
||||
for (const key of newProperties.keys()) {
|
||||
allProperties.add(key);
|
||||
}
|
||||
|
||||
|
@ -570,14 +570,14 @@ class AddrBookDirectory {
|
|||
}
|
||||
this.saveCardProperties(card.UID, newProperties);
|
||||
|
||||
let changeData = {};
|
||||
for (let name of allProperties) {
|
||||
const changeData = {};
|
||||
for (const name of allProperties) {
|
||||
if (name == "LastModifiedDate") {
|
||||
continue;
|
||||
}
|
||||
|
||||
let oldValue = oldProperties.get(name) || null;
|
||||
let newValue = newProperties.get(name) || null;
|
||||
const oldValue = oldProperties.get(name) || null;
|
||||
const newValue = newProperties.get(name) || null;
|
||||
if (oldValue != newValue) {
|
||||
changeData[name] = { oldValue, newValue };
|
||||
}
|
||||
|
@ -593,7 +593,7 @@ class AddrBookDirectory {
|
|||
}
|
||||
|
||||
// Send the card as it is in this directory, not as passed to this function.
|
||||
let newCard = this.getCard(card.UID);
|
||||
const newCard = this.getCard(card.UID);
|
||||
Services.obs.notifyObservers(newCard, "addrbook-contact-updated", this.UID);
|
||||
|
||||
Services.obs.notifyObservers(
|
||||
|
@ -619,7 +619,7 @@ class AddrBookDirectory {
|
|||
}
|
||||
|
||||
let updateDisplayNameVersion = false;
|
||||
for (let card of cards) {
|
||||
for (const card of cards) {
|
||||
updateDisplayNameVersion = updateDisplayNameVersion || card.displayName;
|
||||
// TODO: delete photo if there is one
|
||||
this.deleteCard(card.UID);
|
||||
|
@ -637,14 +637,14 @@ class AddrBookDirectory {
|
|||
);
|
||||
}
|
||||
|
||||
for (let card of cards) {
|
||||
for (const card of cards) {
|
||||
Services.obs.notifyObservers(card, "addrbook-contact-deleted", this.UID);
|
||||
card.directoryUID = null;
|
||||
}
|
||||
|
||||
// We could just delete all non-existent cards from list_cards, but a
|
||||
// notification should be fired for each one. Let the list handle that.
|
||||
for (let list of this.childNodes) {
|
||||
for (const list of this.childNodes) {
|
||||
list.deleteCards(cards);
|
||||
}
|
||||
}
|
||||
|
@ -660,8 +660,8 @@ class AddrBookDirectory {
|
|||
throw new Error("Card must have a UID to be added to this directory.");
|
||||
}
|
||||
|
||||
let uid = needToCopyCard ? lazy.newUID() : card.UID;
|
||||
let newProperties = this.prepareToSaveCard(card, uid);
|
||||
const uid = needToCopyCard ? lazy.newUID() : card.UID;
|
||||
const newProperties = this.prepareToSaveCard(card, uid);
|
||||
if (card.directoryUID && card.directoryUID != this._uid) {
|
||||
// These properties belong to a different directory. Don't keep them.
|
||||
newProperties.delete("_etag");
|
||||
|
@ -682,7 +682,7 @@ class AddrBookDirectory {
|
|||
);
|
||||
}
|
||||
|
||||
let newCard = this.getCard(uid);
|
||||
const newCard = this.getCard(uid);
|
||||
Services.obs.notifyObservers(newCard, "addrbook-contact-created", this.UID);
|
||||
return newCard;
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ class AddrBookDirectory {
|
|||
}
|
||||
|
||||
// Check if the new name contains the following special characters.
|
||||
for (let char of ',;"<>') {
|
||||
for (const char of ',;"<>') {
|
||||
if (list.dirName.includes(char)) {
|
||||
throw new Components.Exception(
|
||||
`Invalid mail list name: ${list.dirName}`,
|
||||
|
@ -733,7 +733,7 @@ class AddrBookDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
let newList = new lazy.AddrBookMailingList(
|
||||
const newList = new lazy.AddrBookMailingList(
|
||||
lazy.newUID(),
|
||||
this,
|
||||
list.dirName || "",
|
||||
|
@ -742,7 +742,7 @@ class AddrBookDirectory {
|
|||
);
|
||||
this.saveList(newList);
|
||||
|
||||
let newListDirectory = newList.asDirectory;
|
||||
const newListDirectory = newList.asDirectory;
|
||||
Services.obs.notifyObservers(
|
||||
newListDirectory,
|
||||
"addrbook-list-created",
|
||||
|
@ -804,7 +804,7 @@ class AddrBookDirectory {
|
|||
this._prefBranch.setStringPref(name, value);
|
||||
}
|
||||
setLocalizedStringValue(name, value) {
|
||||
let valueLocal = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
|
||||
const valueLocal = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
|
||||
Ci.nsIPrefLocalizedString
|
||||
);
|
||||
valueLocal.data = value;
|
||||
|
|
|
@ -18,7 +18,7 @@ function AddrBookMailingList(uid, parent, name, nickName, description) {
|
|||
}
|
||||
AddrBookMailingList.prototype = {
|
||||
get asDirectory() {
|
||||
let self = this;
|
||||
const self = this;
|
||||
return {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIAbDirectory"]),
|
||||
classID: Components.ID("{e96ee804-0bd3-472f-81a6-8a9d65277ad3}"),
|
||||
|
@ -66,11 +66,11 @@ AddrBookMailingList.prototype = {
|
|||
return [];
|
||||
},
|
||||
get childCards() {
|
||||
let selectStatement = self._parent._dbConnection.createStatement(
|
||||
const selectStatement = self._parent._dbConnection.createStatement(
|
||||
"SELECT card FROM list_cards WHERE list = :list ORDER BY oid"
|
||||
);
|
||||
selectStatement.params.list = self._uid;
|
||||
let results = [];
|
||||
const results = [];
|
||||
while (selectStatement.executeStep()) {
|
||||
results.push(self._parent.getCard(selectStatement.row.card));
|
||||
}
|
||||
|
@ -96,13 +96,13 @@ AddrBookMailingList.prototype = {
|
|||
let results = this.childCards;
|
||||
|
||||
// Process the query string into a tree of conditions to match.
|
||||
let lispRegexp = /^\((and|or|not|([^\)]*)(\)+))/;
|
||||
const lispRegexp = /^\((and|or|not|([^\)]*)(\)+))/;
|
||||
let index = 0;
|
||||
let rootQuery = { children: [], op: "or" };
|
||||
const rootQuery = { children: [], op: "or" };
|
||||
let currentQuery = rootQuery;
|
||||
|
||||
while (true) {
|
||||
let match = lispRegexp.exec(query.substring(index));
|
||||
const match = lispRegexp.exec(query.substring(index));
|
||||
if (!match) {
|
||||
break;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ AddrBookMailingList.prototype = {
|
|||
|
||||
if (["and", "or", "not"].includes(match[1])) {
|
||||
// For the opening bracket, step down a level.
|
||||
let child = {
|
||||
const child = {
|
||||
parent: currentQuery,
|
||||
children: [],
|
||||
op: match[1],
|
||||
|
@ -118,7 +118,7 @@ AddrBookMailingList.prototype = {
|
|||
currentQuery.children.push(child);
|
||||
currentQuery = child;
|
||||
} else {
|
||||
let [name, condition, value] = match[2].split(",");
|
||||
const [name, condition, value] = match[2].split(",");
|
||||
currentQuery.children.push({
|
||||
name,
|
||||
condition,
|
||||
|
@ -133,10 +133,10 @@ AddrBookMailingList.prototype = {
|
|||
}
|
||||
|
||||
results = results.filter(card => {
|
||||
let properties = card._properties;
|
||||
let matches = b => {
|
||||
const properties = card._properties;
|
||||
const matches = b => {
|
||||
if ("condition" in b) {
|
||||
let { name, condition, value } = b;
|
||||
const { name, condition, value } = b;
|
||||
if (name == "IsMailList" && condition == "=") {
|
||||
return value == "true";
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ AddrBookMailingList.prototype = {
|
|||
return true;
|
||||
}
|
||||
|
||||
let cardValue = properties.get(name).toLowerCase();
|
||||
const cardValue = properties.get(name).toLowerCase();
|
||||
switch (condition) {
|
||||
case "=":
|
||||
return cardValue == value;
|
||||
|
@ -187,7 +187,7 @@ AddrBookMailingList.prototype = {
|
|||
return matches(rootQuery);
|
||||
}, this);
|
||||
|
||||
for (let card of results) {
|
||||
for (const card of results) {
|
||||
listener.onSearchFoundCard(card);
|
||||
}
|
||||
listener.onSearchFinished(Cr.NS_OK, true, null, "");
|
||||
|
@ -206,7 +206,7 @@ AddrBookMailingList.prototype = {
|
|||
if (!self._parent.hasCard(card)) {
|
||||
card = self._parent.addCard(card);
|
||||
}
|
||||
let insertStatement = self._parent._dbConnection.createStatement(
|
||||
const insertStatement = self._parent._dbConnection.createStatement(
|
||||
"REPLACE INTO list_cards (list, card) VALUES (:list, :card)"
|
||||
);
|
||||
insertStatement.params.list = self._uid;
|
||||
|
@ -228,10 +228,10 @@ AddrBookMailingList.prototype = {
|
|||
);
|
||||
}
|
||||
|
||||
let deleteCardStatement = self._parent._dbConnection.createStatement(
|
||||
const deleteCardStatement = self._parent._dbConnection.createStatement(
|
||||
"DELETE FROM list_cards WHERE list = :list AND card = :card"
|
||||
);
|
||||
for (let card of cards) {
|
||||
for (const card of cards) {
|
||||
deleteCardStatement.params.list = self._uid;
|
||||
deleteCardStatement.params.card = card.UID;
|
||||
deleteCardStatement.execute();
|
||||
|
@ -289,7 +289,7 @@ AddrBookMailingList.prototype = {
|
|||
}
|
||||
|
||||
// Check if the new name contains the following special characters.
|
||||
for (let char of ',;"<>') {
|
||||
for (const char of ',;"<>') {
|
||||
if (self._name.includes(char)) {
|
||||
throw new Components.Exception(
|
||||
"Invalid mailing list name",
|
||||
|
@ -314,7 +314,7 @@ AddrBookMailingList.prototype = {
|
|||
};
|
||||
},
|
||||
get asCard() {
|
||||
let self = this;
|
||||
const self = this;
|
||||
return {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIAbCard"]),
|
||||
classID: Components.ID("{1143991d-31cd-4ea6-9c97-c587d990d724}"),
|
||||
|
@ -386,7 +386,7 @@ AddrBookMailingList.prototype = {
|
|||
["NickName", this.getProperty("NickName", "")],
|
||||
["Notes", this.getProperty("Notes", "")],
|
||||
];
|
||||
let props = [];
|
||||
const props = [];
|
||||
for (const [name, value] of entries) {
|
||||
props.push({
|
||||
get name() {
|
||||
|
@ -408,7 +408,7 @@ AddrBookMailingList.prototype = {
|
|||
},
|
||||
translateTo(type) {
|
||||
// Get nsAbCardProperty to do the work, the code is in C++ anyway.
|
||||
let cardCopy = Cc[
|
||||
const cardCopy = Cc[
|
||||
"@mozilla.org/addressbook/cardproperty;1"
|
||||
].createInstance(Ci.nsIAbCard);
|
||||
cardCopy.UID = this.UID;
|
||||
|
|
|
@ -33,7 +33,7 @@ const URI_REGEXP = /^([\w-]+):\/\/([\w\.-]*)([/:].*|$)/;
|
|||
let store = null;
|
||||
|
||||
/** Valid address book types. This differs by operating system. */
|
||||
let types = ["jsaddrbook", "jscarddav", "moz-abldapdirectory"];
|
||||
const types = ["jsaddrbook", "jscarddav", "moz-abldapdirectory"];
|
||||
if (AppConstants.platform == "macosx") {
|
||||
types.push("moz-abosxdirectory");
|
||||
} else if (AppConstants.platform == "win") {
|
||||
|
@ -63,7 +63,7 @@ function updateSortedDirectoryList() {
|
|||
* @returns {nsIAbDirectory}
|
||||
*/
|
||||
function createDirectoryObject(uri, shouldStore = false) {
|
||||
let uriParts = URI_REGEXP.exec(uri);
|
||||
const uriParts = URI_REGEXP.exec(uri);
|
||||
if (!uriParts) {
|
||||
throw Components.Exception(
|
||||
`Unexpected uri: ${uri}`,
|
||||
|
@ -71,8 +71,8 @@ function createDirectoryObject(uri, shouldStore = false) {
|
|||
);
|
||||
}
|
||||
|
||||
let [, scheme] = uriParts;
|
||||
let dir = Cc[
|
||||
const [, scheme] = uriParts;
|
||||
const dir = Cc[
|
||||
`@mozilla.org/addressbook/directory;1?type=${scheme}`
|
||||
].createInstance(Ci.nsIAbDirectory);
|
||||
|
||||
|
@ -112,21 +112,24 @@ function ensureInitialized() {
|
|||
|
||||
store = new Map();
|
||||
|
||||
for (let pref of Services.prefs.getChildList("ldap_2.servers.")) {
|
||||
for (const pref of Services.prefs.getChildList("ldap_2.servers.")) {
|
||||
try {
|
||||
if (pref.endsWith(".uri")) {
|
||||
let uri = Services.prefs.getStringPref(pref);
|
||||
if (uri.startsWith("ldap://") || uri.startsWith("ldaps://")) {
|
||||
let prefName = pref.substring(0, pref.length - 4);
|
||||
const prefName = pref.substring(0, pref.length - 4);
|
||||
|
||||
uri = `moz-abldapdirectory://${prefName}`;
|
||||
createDirectoryObject(uri, true);
|
||||
}
|
||||
} else if (pref.endsWith(".dirType")) {
|
||||
let prefName = pref.substring(0, pref.length - 8);
|
||||
let dirType = Services.prefs.getIntPref(pref);
|
||||
let fileName = Services.prefs.getStringPref(`${prefName}.filename`, "");
|
||||
let uri = Services.prefs.getStringPref(`${prefName}.uri`, "");
|
||||
const prefName = pref.substring(0, pref.length - 8);
|
||||
const dirType = Services.prefs.getIntPref(pref);
|
||||
const fileName = Services.prefs.getStringPref(
|
||||
`${prefName}.filename`,
|
||||
""
|
||||
);
|
||||
const uri = Services.prefs.getStringPref(`${prefName}.uri`, "");
|
||||
|
||||
switch (dirType) {
|
||||
case Ci.nsIAbManager.MAPI_DIRECTORY_TYPE:
|
||||
|
@ -147,23 +150,23 @@ function ensureInitialized() {
|
|||
if (AppConstants.platform == "macosx") {
|
||||
createDirectoryObject(uri, true);
|
||||
} else if (AppConstants.platform == "win") {
|
||||
let outlookInterface = Cc[
|
||||
const outlookInterface = Cc[
|
||||
"@mozilla.org/addressbook/outlookinterface;1"
|
||||
].getService(Ci.nsIAbOutlookInterface);
|
||||
for (let folderURI of outlookInterface.getFolderURIs(uri)) {
|
||||
for (const folderURI of outlookInterface.getFolderURIs(uri)) {
|
||||
createDirectoryObject(folderURI, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Ci.nsIAbManager.JS_DIRECTORY_TYPE:
|
||||
if (fileName) {
|
||||
let uri = `jsaddrbook://${fileName}`;
|
||||
const uri = `jsaddrbook://${fileName}`;
|
||||
createDirectoryObject(uri, true);
|
||||
}
|
||||
break;
|
||||
case Ci.nsIAbManager.CARDDAV_DIRECTORY_TYPE:
|
||||
if (fileName) {
|
||||
let uri = `jscarddav://${fileName}`;
|
||||
const uri = `jscarddav://${fileName}`;
|
||||
createDirectoryObject(uri, true);
|
||||
}
|
||||
break;
|
||||
|
@ -180,7 +183,7 @@ function ensureInitialized() {
|
|||
// Force the manager to shut down. For tests only.
|
||||
Services.obs.addObserver(async () => {
|
||||
// Allow directories to tidy up.
|
||||
for (let directory of store.values()) {
|
||||
for (const directory of store.values()) {
|
||||
await directory.cleanUp();
|
||||
}
|
||||
// Clear the store. The next call to ensureInitialized will recreate it.
|
||||
|
@ -189,7 +192,7 @@ Services.obs.addObserver(async () => {
|
|||
}, "addrbook-reload");
|
||||
|
||||
/** Cache for the cardForEmailAddress function, and timer to clear it. */
|
||||
let addressCache = new Map();
|
||||
const addressCache = new Map();
|
||||
let addressCacheTimer = null;
|
||||
|
||||
// Throw away cached cards if the display name properties change, so we can
|
||||
|
@ -241,14 +244,14 @@ AddrBookManager.prototype = {
|
|||
return store.get(uri);
|
||||
}
|
||||
|
||||
let uriParts = URI_REGEXP.exec(uri);
|
||||
const uriParts = URI_REGEXP.exec(uri);
|
||||
if (!uriParts) {
|
||||
throw Components.Exception(
|
||||
`Unexpected uri: ${uri}`,
|
||||
Cr.NS_ERROR_MALFORMED_URI
|
||||
);
|
||||
}
|
||||
let [, scheme, fileName, tail] = uriParts;
|
||||
const [, scheme, fileName, tail] = uriParts;
|
||||
if (tail && types.includes(scheme)) {
|
||||
if (
|
||||
(scheme == "jsaddrbook" && tail.startsWith("/")) ||
|
||||
|
@ -260,7 +263,7 @@ AddrBookManager.prototype = {
|
|||
} else {
|
||||
parent = this.getDirectory(`${scheme}:///${tail.split("/")[1]}`);
|
||||
}
|
||||
for (let list of parent.childNodes) {
|
||||
for (const list of parent.childNodes) {
|
||||
list.QueryInterface(Ci.nsIAbDirectory);
|
||||
if (list.URI == uri) {
|
||||
return list;
|
||||
|
@ -286,7 +289,7 @@ AddrBookManager.prototype = {
|
|||
},
|
||||
getDirectoryFromId(dirPrefId) {
|
||||
ensureInitialized();
|
||||
for (let dir of store.values()) {
|
||||
for (const dir of store.values()) {
|
||||
if (dir.dirPrefId == dirPrefId) {
|
||||
return dir;
|
||||
}
|
||||
|
@ -295,7 +298,7 @@ AddrBookManager.prototype = {
|
|||
},
|
||||
getDirectoryFromUID(uid) {
|
||||
ensureInitialized();
|
||||
for (let dir of store.values()) {
|
||||
for (const dir of store.values()) {
|
||||
if (dir.UID == uid) {
|
||||
return dir;
|
||||
}
|
||||
|
@ -304,8 +307,8 @@ AddrBookManager.prototype = {
|
|||
},
|
||||
getMailListFromName(name) {
|
||||
ensureInitialized();
|
||||
for (let dir of store.values()) {
|
||||
let hit = dir.getMailListFromName(name);
|
||||
for (const dir of store.values()) {
|
||||
const hit = dir.getMailListFromName(name);
|
||||
if (hit) {
|
||||
return hit;
|
||||
}
|
||||
|
@ -319,7 +322,7 @@ AddrBookManager.prototype = {
|
|||
leafName = "_nonascii";
|
||||
}
|
||||
|
||||
let existingNames = Array.from(store.values(), dir => dir.dirPrefId);
|
||||
const existingNames = Array.from(store.values(), dir => dir.dirPrefId);
|
||||
let uniqueCount = 0;
|
||||
prefName = `ldap_2.servers.${leafName}`;
|
||||
while (existingNames.includes(prefName)) {
|
||||
|
@ -345,7 +348,7 @@ AddrBookManager.prototype = {
|
|||
|
||||
switch (type) {
|
||||
case Ci.nsIAbManager.LDAP_DIRECTORY_TYPE: {
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
const file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append("ldap.sqlite");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||
|
||||
|
@ -358,7 +361,7 @@ AddrBookManager.prototype = {
|
|||
}
|
||||
|
||||
uri = `moz-abldapdirectory://${prefName}`;
|
||||
let dir = createDirectoryObject(uri, true);
|
||||
const dir = createDirectoryObject(uri, true);
|
||||
updateSortedDirectoryList();
|
||||
Services.obs.notifyObservers(dir, "addrbook-directory-created");
|
||||
break;
|
||||
|
@ -403,15 +406,15 @@ AddrBookManager.prototype = {
|
|||
}
|
||||
|
||||
if (AppConstants.platform == "macosx") {
|
||||
let dir = createDirectoryObject(uri, true);
|
||||
const dir = createDirectoryObject(uri, true);
|
||||
updateSortedDirectoryList();
|
||||
Services.obs.notifyObservers(dir, "addrbook-directory-created");
|
||||
} else if (AppConstants.platform == "win") {
|
||||
let outlookInterface = Cc[
|
||||
const outlookInterface = Cc[
|
||||
"@mozilla.org/addressbook/outlookinterface;1"
|
||||
].getService(Ci.nsIAbOutlookInterface);
|
||||
for (let folderURI of outlookInterface.getFolderURIs(uri)) {
|
||||
let dir = createDirectoryObject(folderURI, true);
|
||||
for (const folderURI of outlookInterface.getFolderURIs(uri)) {
|
||||
const dir = createDirectoryObject(folderURI, true);
|
||||
updateSortedDirectoryList();
|
||||
Services.obs.notifyObservers(dir, "addrbook-directory-created");
|
||||
}
|
||||
|
@ -420,7 +423,7 @@ AddrBookManager.prototype = {
|
|||
}
|
||||
case Ci.nsIAbManager.JS_DIRECTORY_TYPE:
|
||||
case Ci.nsIAbManager.CARDDAV_DIRECTORY_TYPE: {
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
const file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append("abook.sqlite");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
|
||||
|
||||
|
@ -432,12 +435,12 @@ AddrBookManager.prototype = {
|
|||
Services.prefs.setStringPref(`${prefName}.uid`, uid);
|
||||
}
|
||||
|
||||
let scheme =
|
||||
const scheme =
|
||||
type == Ci.nsIAbManager.JS_DIRECTORY_TYPE
|
||||
? "jsaddrbook"
|
||||
: "jscarddav";
|
||||
uri = `${scheme}://${file.leafName}`;
|
||||
let dir = createDirectoryObject(uri, true);
|
||||
const dir = createDirectoryObject(uri, true);
|
||||
updateSortedDirectoryList();
|
||||
Services.obs.notifyObservers(dir, "addrbook-directory-created");
|
||||
break;
|
||||
|
@ -479,7 +482,7 @@ AddrBookManager.prototype = {
|
|||
Services.obs.notifyObservers(dir, "addrbook-directory-created");
|
||||
},
|
||||
deleteAddressBook(uri) {
|
||||
let uriParts = URI_REGEXP.exec(uri);
|
||||
const uriParts = URI_REGEXP.exec(uri);
|
||||
if (!uriParts) {
|
||||
throw Components.Exception("", Cr.NS_ERROR_MALFORMED_URI);
|
||||
}
|
||||
|
@ -492,14 +495,14 @@ AddrBookManager.prototype = {
|
|||
} else if (scheme == "moz-aboutlookdirectory") {
|
||||
dir = store.get(`${scheme}:///${tail.split("/")[1]}`);
|
||||
}
|
||||
let list = this.getDirectory(uri);
|
||||
const list = this.getDirectory(uri);
|
||||
if (dir && list) {
|
||||
dir.deleteDirectory(list);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let dir = store.get(uri);
|
||||
const dir = store.get(uri);
|
||||
if (!dir) {
|
||||
throw new Components.Exception(
|
||||
`Address book not found: ${uri}`,
|
||||
|
@ -507,9 +510,9 @@ AddrBookManager.prototype = {
|
|||
);
|
||||
}
|
||||
|
||||
let prefName = dir.dirPrefId;
|
||||
const prefName = dir.dirPrefId;
|
||||
if (prefName) {
|
||||
let dirType = Services.prefs.getIntPref(`${prefName}.dirType`, 0);
|
||||
const dirType = Services.prefs.getIntPref(`${prefName}.dirType`, 0);
|
||||
fileName = dir.fileName;
|
||||
|
||||
// Deleting the built-in address books is very bad.
|
||||
|
@ -520,7 +523,7 @@ AddrBookManager.prototype = {
|
|||
);
|
||||
}
|
||||
|
||||
for (let name of Services.prefs.getChildList(`${prefName}.`)) {
|
||||
for (const name of Services.prefs.getChildList(`${prefName}.`)) {
|
||||
Services.prefs.clearUserPref(name);
|
||||
}
|
||||
if (dirType == Ci.nsIAbManager.MAPI_DIRECTORY_TYPE) {
|
||||
|
@ -540,7 +543,7 @@ AddrBookManager.prototype = {
|
|||
|
||||
dir.cleanUp().then(() => {
|
||||
if (fileName) {
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
const file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append(fileName);
|
||||
if (file.exists()) {
|
||||
file.remove(false);
|
||||
|
@ -552,7 +555,7 @@ AddrBookManager.prototype = {
|
|||
},
|
||||
mailListNameExists(name) {
|
||||
ensureInitialized();
|
||||
for (let dir of store.values()) {
|
||||
for (const dir of store.values()) {
|
||||
if (dir.hasMailListWithName(name)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -566,7 +569,7 @@ AddrBookManager.prototype = {
|
|||
*/
|
||||
directoryNameExists(name) {
|
||||
ensureInitialized();
|
||||
for (let dir of store.values()) {
|
||||
for (const dir of store.values()) {
|
||||
if (dir.dirName.toLowerCase() === name.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -590,9 +593,9 @@ AddrBookManager.prototype = {
|
|||
return addressCache.get(emailAddress);
|
||||
}
|
||||
|
||||
for (let directory of sortedDirectoryList) {
|
||||
for (const directory of sortedDirectoryList) {
|
||||
try {
|
||||
let card = directory.cardForEmailAddress(emailAddress);
|
||||
const card = directory.cardForEmailAddress(emailAddress);
|
||||
if (card) {
|
||||
addressCache.set(emailAddress, card);
|
||||
return card;
|
||||
|
|
|
@ -35,14 +35,14 @@ function newUID() {
|
|||
return Services.uuid.generateUUID().toString().substring(1, 37);
|
||||
}
|
||||
|
||||
let abSortOrder = {
|
||||
const abSortOrder = {
|
||||
[Ci.nsIAbManager.JS_DIRECTORY_TYPE]: 1,
|
||||
[Ci.nsIAbManager.CARDDAV_DIRECTORY_TYPE]: 2,
|
||||
[Ci.nsIAbManager.LDAP_DIRECTORY_TYPE]: 3,
|
||||
[Ci.nsIAbManager.ASYNC_DIRECTORY_TYPE]: 3,
|
||||
[Ci.nsIAbManager.MAPI_DIRECTORY_TYPE]: 4,
|
||||
};
|
||||
let abNameComparer = new Intl.Collator(undefined, { numeric: true });
|
||||
const abNameComparer = new Intl.Collator(undefined, { numeric: true });
|
||||
|
||||
/**
|
||||
* Comparator for address books. Any UI that lists address books should use
|
||||
|
@ -70,8 +70,8 @@ function compareAddressBooks(a, b) {
|
|||
}
|
||||
|
||||
// The Personal Address Book is first and Collected Addresses last.
|
||||
let aPrefId = a.dirPrefId;
|
||||
let bPrefId = b.dirPrefId;
|
||||
const aPrefId = a.dirPrefId;
|
||||
const bPrefId = b.dirPrefId;
|
||||
|
||||
if (aPrefId == "ldap_2.servers.pab" || bPrefId == "ldap_2.servers.history") {
|
||||
return -1;
|
||||
|
@ -81,8 +81,8 @@ function compareAddressBooks(a, b) {
|
|||
}
|
||||
|
||||
// Order remaining directories by type.
|
||||
let aType = a.dirType;
|
||||
let bType = b.dirType;
|
||||
const aType = a.dirType;
|
||||
const bType = b.dirType;
|
||||
|
||||
if (aType != bType) {
|
||||
return abSortOrder[aType] - abSortOrder[bType];
|
||||
|
@ -152,7 +152,7 @@ var AddrBookUtils = {
|
|||
// Some Windows applications (notably Outlook) still don't understand
|
||||
// UTF-8 encoding when importing address books and instead use the current
|
||||
// operating system encoding. We can get that encoding from the registry.
|
||||
let registryKey = Cc[
|
||||
const registryKey = Cc[
|
||||
"@mozilla.org/windows-registry-key;1"
|
||||
].createInstance(Ci.nsIWindowsRegKey);
|
||||
registryKey.open(
|
||||
|
@ -160,7 +160,7 @@ var AddrBookUtils = {
|
|||
"SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage",
|
||||
Ci.nsIWindowsRegKey.ACCESS_READ
|
||||
);
|
||||
let acpValue = registryKey.readStringValue("ACP");
|
||||
const acpValue = registryKey.readStringValue("ACP");
|
||||
|
||||
// This data converts the registry key value into encodings that
|
||||
// nsIConverterOutputStream understands. It is from
|
||||
|
@ -207,14 +207,14 @@ var AddrBookUtils = {
|
|||
}[acpValue] || systemCharset;
|
||||
}
|
||||
|
||||
let filePicker = Cc["@mozilla.org/filepicker;1"].createInstance(
|
||||
const filePicker = Cc["@mozilla.org/filepicker;1"].createInstance(
|
||||
Ci.nsIFilePicker
|
||||
);
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/addressbook/addressBook.properties"
|
||||
);
|
||||
|
||||
let title = bundle.formatStringFromName("ExportAddressBookNameTitle", [
|
||||
const title = bundle.formatStringFromName("ExportAddressBookNameTitle", [
|
||||
directory.dirName,
|
||||
]);
|
||||
filePicker.init(Services.ww.activeWindow, title, Ci.nsIFilePicker.modeSave);
|
||||
|
@ -223,7 +223,7 @@ var AddrBookUtils = {
|
|||
let filterString;
|
||||
// Since the list of file picker filters isn't fixed, keep track of which
|
||||
// ones are added, so we can use them in the switch block below.
|
||||
let activeFilters = [];
|
||||
const activeFilters = [];
|
||||
|
||||
// CSV
|
||||
if (systemCharset != "utf-8") {
|
||||
|
@ -255,7 +255,7 @@ var AddrBookUtils = {
|
|||
filePicker.appendFilter(filterString, "*.ldi; *.ldif");
|
||||
activeFilters.push("LDIFFiles");
|
||||
|
||||
let rv = await new Promise(resolve => filePicker.open(resolve));
|
||||
const rv = await new Promise(resolve => filePicker.open(resolve));
|
||||
if (
|
||||
rv == Ci.nsIFilePicker.returnCancel ||
|
||||
!filePicker.file ||
|
||||
|
@ -270,8 +270,8 @@ var AddrBookUtils = {
|
|||
}
|
||||
}
|
||||
|
||||
let exportFile = filePicker.file.clone();
|
||||
let leafName = exportFile.leafName;
|
||||
const exportFile = filePicker.file.clone();
|
||||
const leafName = exportFile.leafName;
|
||||
let output = "";
|
||||
let charset = "utf-8";
|
||||
|
||||
|
@ -312,11 +312,11 @@ var AddrBookUtils = {
|
|||
await IOUtils.writeUTF8(exportFile.path, output);
|
||||
} else {
|
||||
// Main thread file IO!
|
||||
let outputFileStream = Cc[
|
||||
const outputFileStream = Cc[
|
||||
"@mozilla.org/network/file-output-stream;1"
|
||||
].createInstance(Ci.nsIFileOutputStream);
|
||||
outputFileStream.init(exportFile, -1, -1, 0);
|
||||
let outputStream = Cc[
|
||||
const outputStream = Cc[
|
||||
"@mozilla.org/intl/converter-output-stream;1"
|
||||
].createInstance(Ci.nsIConverterOutputStream);
|
||||
outputStream.init(outputFileStream, charset);
|
||||
|
@ -331,12 +331,12 @@ var AddrBookUtils = {
|
|||
);
|
||||
},
|
||||
exportDirectoryToDelimitedText(directory, delimiter) {
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/importMsgs.properties"
|
||||
);
|
||||
let output = "";
|
||||
for (let i = 0; i < exportAttributes.length; i++) {
|
||||
let [, plainTextStringID] = exportAttributes[i];
|
||||
const [, plainTextStringID] = exportAttributes[i];
|
||||
if (plainTextStringID != 0) {
|
||||
if (i != 0) {
|
||||
output += delimiter;
|
||||
|
@ -345,17 +345,17 @@ var AddrBookUtils = {
|
|||
}
|
||||
}
|
||||
output += LINEBREAK;
|
||||
for (let card of directory.childCards) {
|
||||
for (const card of directory.childCards) {
|
||||
if (card.isMailList) {
|
||||
// .tab, .txt and .csv aren't able to export mailing lists.
|
||||
// Use LDIF for that.
|
||||
continue;
|
||||
}
|
||||
let propertyMap = card.supportsVCard
|
||||
const propertyMap = card.supportsVCard
|
||||
? card.vCardProperties.toPropertyMap()
|
||||
: null;
|
||||
for (let i = 0; i < exportAttributes.length; i++) {
|
||||
let [abPropertyName, plainTextStringID] = exportAttributes[i];
|
||||
const [abPropertyName, plainTextStringID] = exportAttributes[i];
|
||||
if (plainTextStringID == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ var AddrBookUtils = {
|
|||
) {
|
||||
// Convert 16bit JavaScript string to a byteString, to make it work with
|
||||
// btoa().
|
||||
let byteString = MailStringUtils.stringToByteString(value);
|
||||
const byteString = MailStringUtils.stringToByteString(value);
|
||||
output += name + ":: " + btoa(byteString) + LINEBREAK;
|
||||
} else {
|
||||
output += name + ": " + value + LINEBREAK;
|
||||
|
@ -430,11 +430,11 @@ var AddrBookUtils = {
|
|||
}
|
||||
|
||||
let output = "";
|
||||
let attrMap = lazy.attrMapService.getMapForPrefBranch(
|
||||
const attrMap = lazy.attrMapService.getMapForPrefBranch(
|
||||
"ldap_2.servers.default.attrmap"
|
||||
);
|
||||
|
||||
for (let card of directory.childCards) {
|
||||
for (const card of directory.childCards) {
|
||||
if (card.isMailList) {
|
||||
appendDNForCard("dn", card, attrMap);
|
||||
appendProperty("objectclass", "top");
|
||||
|
@ -455,8 +455,8 @@ var AddrBookUtils = {
|
|||
card.getProperty("Notes", "")
|
||||
);
|
||||
}
|
||||
let listAsDirectory = MailServices.ab.getDirectory(card.mailListURI);
|
||||
for (let childCard of listAsDirectory.childCards) {
|
||||
const listAsDirectory = MailServices.ab.getDirectory(card.mailListURI);
|
||||
for (const childCard of listAsDirectory.childCards) {
|
||||
appendDNForCard("member", childCard, attrMap);
|
||||
}
|
||||
} else {
|
||||
|
@ -467,11 +467,11 @@ var AddrBookUtils = {
|
|||
appendProperty("objectclass", "inetOrgPerson");
|
||||
appendProperty("objectclass", "mozillaAbPersonAlpha");
|
||||
|
||||
let propertyMap = card.supportsVCard
|
||||
const propertyMap = card.supportsVCard
|
||||
? card.vCardProperties.toPropertyMap()
|
||||
: null;
|
||||
for (let [abPropertyName] of exportAttributes) {
|
||||
let attrName = attrMap.getFirstAttribute(abPropertyName);
|
||||
for (const [abPropertyName] of exportAttributes) {
|
||||
const attrName = attrMap.getFirstAttribute(abPropertyName);
|
||||
if (attrName) {
|
||||
let attrValue;
|
||||
if (propertyMap) {
|
||||
|
@ -491,7 +491,7 @@ var AddrBookUtils = {
|
|||
},
|
||||
exportDirectoryToVCard(directory) {
|
||||
let output = "";
|
||||
for (let card of directory.childCards) {
|
||||
for (const card of directory.childCards) {
|
||||
if (!card.isMailList) {
|
||||
// We don't know how to export mailing lists to vcf.
|
||||
// Use LDIF for that.
|
||||
|
|
|
@ -53,7 +53,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
init(uri) {
|
||||
super.init(uri);
|
||||
|
||||
let serverURL = this._serverURL;
|
||||
const serverURL = this._serverURL;
|
||||
if (serverURL) {
|
||||
// Google's server enforces some vCard 3.0-isms (or just fails badly if
|
||||
// you don't provide exactly what it wants) so we use this property to
|
||||
|
@ -78,7 +78,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
let uidsToSync = this.getStringValue("carddav.uidsToSync", "");
|
||||
const uidsToSync = this.getStringValue("carddav.uidsToSync", "");
|
||||
if (uidsToSync) {
|
||||
this._uidsToSync = new Set(uidsToSync.split(" ").filter(Boolean));
|
||||
this.setStringValue("carddav.uidsToSync", "");
|
||||
|
@ -87,7 +87,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
this._uidsToSync = new Set();
|
||||
}
|
||||
|
||||
let hrefsToRemove = this.getStringValue("carddav.hrefsToRemove", "");
|
||||
const hrefsToRemove = this.getStringValue("carddav.hrefsToRemove", "");
|
||||
if (hrefsToRemove) {
|
||||
this._hrefsToRemove = new Set(hrefsToRemove.split(" ").filter(Boolean));
|
||||
this.setStringValue("carddav.hrefsToRemove", "");
|
||||
|
@ -105,12 +105,12 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
}
|
||||
|
||||
if (this._uidsToSync.size) {
|
||||
let uidsToSync = [...this._uidsToSync].join(" ");
|
||||
const uidsToSync = [...this._uidsToSync].join(" ");
|
||||
this.setStringValue("carddav.uidsToSync", uidsToSync);
|
||||
log.debug(`Stored list of cards to sync: ${uidsToSync}`);
|
||||
}
|
||||
if (this._hrefsToRemove.size) {
|
||||
let hrefsToRemove = [...this._hrefsToRemove].join(" ");
|
||||
const hrefsToRemove = [...this._hrefsToRemove].join(" ");
|
||||
this.setStringValue("carddav.hrefsToRemove", hrefsToRemove);
|
||||
log.debug(`Stored list of cards to remove: ${hrefsToRemove}`);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
modifyCard(card) {
|
||||
// Well this is awkward. Because it's defined in nsIAbDirectory,
|
||||
// modifyCard must not be async, but we need to do async operations.
|
||||
let newCard = super.modifyCard(card);
|
||||
const newCard = super.modifyCard(card);
|
||||
this._modifyCard(newCard);
|
||||
}
|
||||
async _modifyCard(card) {
|
||||
|
@ -144,7 +144,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
this._deleteCards(cards);
|
||||
}
|
||||
async _deleteCards(cards) {
|
||||
for (let card of cards) {
|
||||
for (const card of cards) {
|
||||
try {
|
||||
await this._deleteCardFromServer(card);
|
||||
} catch (ex) {
|
||||
|
@ -153,14 +153,14 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
for (let card of cards) {
|
||||
for (const card of cards) {
|
||||
this._uidsToSync.delete(card.UID);
|
||||
}
|
||||
}
|
||||
dropCard(card, needToCopyCard) {
|
||||
// Ideally, we'd not add the card until it was on the server, but we have
|
||||
// to return newCard synchronously.
|
||||
let newCard = super.dropCard(card, needToCopyCard);
|
||||
const newCard = super.dropCard(card, needToCopyCard);
|
||||
this._sendCardToServer(newCard).catch(console.error);
|
||||
return newCard;
|
||||
}
|
||||
|
@ -203,8 +203,8 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
* @returns {Promise<object>} - See CardDAVUtils.makeRequest.
|
||||
*/
|
||||
async _makeRequest(path, details = {}) {
|
||||
let serverURI = Services.io.newURI(this._serverURL);
|
||||
let uri = serverURI.resolve(path);
|
||||
const serverURI = Services.io.newURI(this._serverURL);
|
||||
const uri = serverURI.resolve(path);
|
||||
|
||||
if (!("_oAuth" in this)) {
|
||||
if (lazy.OAuth2Providers.getHostnameDetails(serverURI.host)) {
|
||||
|
@ -216,8 +216,8 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
}
|
||||
details.oAuth = this._oAuth;
|
||||
|
||||
let username = this.getStringValue("carddav.username", "");
|
||||
let callbacks = new lazy.NotificationCallbacks(username);
|
||||
const username = this.getStringValue("carddav.username", "");
|
||||
const callbacks = new lazy.NotificationCallbacks(username);
|
||||
details.callbacks = callbacks;
|
||||
|
||||
details.userContextId =
|
||||
|
@ -276,7 +276,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
hrefsToFetch = hrefsToFetch.map(
|
||||
href => ` <d:href>${xmlEncode(href)}</d:href>`
|
||||
);
|
||||
let data = `<card:addressbook-multiget ${NAMESPACE_STRING}>
|
||||
const data = `<card:addressbook-multiget ${NAMESPACE_STRING}>
|
||||
<d:prop>
|
||||
<d:getetag/>
|
||||
<card:address-data/>
|
||||
|
@ -305,7 +305,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
return;
|
||||
}
|
||||
|
||||
let response = await this._multigetRequest(hrefsToFetch);
|
||||
const response = await this._multigetRequest(hrefsToFetch);
|
||||
|
||||
// If this directory is set to read-only, the following operations would
|
||||
// throw NS_ERROR_FAILURE, but sync operations are allowed on a read-only
|
||||
|
@ -316,17 +316,17 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
|
||||
try {
|
||||
this._overrideReadOnly = true;
|
||||
for (let { href, properties } of this._readResponse(response.dom)) {
|
||||
for (const { href, properties } of this._readResponse(response.dom)) {
|
||||
if (!properties) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let etag = properties.querySelector("getetag")?.textContent;
|
||||
let vCard = normalizeLineEndings(
|
||||
const etag = properties.querySelector("getetag")?.textContent;
|
||||
const vCard = normalizeLineEndings(
|
||||
properties.querySelector("address-data")?.textContent
|
||||
);
|
||||
|
||||
let abCard = lazy.VCardUtils.vCardToAbCard(vCard);
|
||||
const abCard = lazy.VCardUtils.vCardToAbCard(vCard);
|
||||
abCard.setProperty("_etag", etag);
|
||||
abCard.setProperty("_href", href);
|
||||
|
||||
|
@ -360,20 +360,20 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
);
|
||||
}
|
||||
|
||||
for (let r of dom.querySelectorAll("response")) {
|
||||
let response = {
|
||||
for (const r of dom.querySelectorAll("response")) {
|
||||
const response = {
|
||||
href: r.querySelector("href")?.textContent,
|
||||
};
|
||||
|
||||
let responseStatus = r.querySelector("response > status");
|
||||
const responseStatus = r.querySelector("response > status");
|
||||
if (responseStatus?.textContent.startsWith("HTTP/1.1 404")) {
|
||||
response.notFound = true;
|
||||
yield response;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let p of r.querySelectorAll("response > propstat")) {
|
||||
let status = p.querySelector("propstat > status").textContent;
|
||||
for (const p of r.querySelectorAll("response > propstat")) {
|
||||
const status = p.querySelector("propstat > status").textContent;
|
||||
if (status == "HTTP/1.1 200 OK") {
|
||||
response.properties = p.querySelector("propstat > prop");
|
||||
}
|
||||
|
@ -395,16 +395,16 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
* conflict status code.
|
||||
*/
|
||||
async _sendCardToServer(card) {
|
||||
let href = this._getCardHref(card);
|
||||
let requestDetails = {
|
||||
const href = this._getCardHref(card);
|
||||
const requestDetails = {
|
||||
method: "PUT",
|
||||
contentType: "text/vcard",
|
||||
};
|
||||
|
||||
let vCard = card.getProperty("_vCard", "");
|
||||
const vCard = card.getProperty("_vCard", "");
|
||||
if (this._isGoogleCardDAV) {
|
||||
// There must be an `N` property, even if empty.
|
||||
let vCardProperties = lazy.VCardProperties.fromVCard(vCard);
|
||||
const vCardProperties = lazy.VCardProperties.fromVCard(vCard);
|
||||
if (!vCardProperties.getFirstEntry("n")) {
|
||||
vCardProperties.addValue("n", ["", "", "", "", ""]);
|
||||
}
|
||||
|
@ -437,17 +437,17 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
|
||||
response = await this._multigetRequest([href]);
|
||||
|
||||
for (let { href, properties } of this._readResponse(response.dom)) {
|
||||
for (const { href, properties } of this._readResponse(response.dom)) {
|
||||
if (!properties) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let etag = properties.querySelector("getetag")?.textContent;
|
||||
let vCard = normalizeLineEndings(
|
||||
const etag = properties.querySelector("getetag")?.textContent;
|
||||
const vCard = normalizeLineEndings(
|
||||
properties.querySelector("address-data")?.textContent
|
||||
);
|
||||
|
||||
let abCard = lazy.VCardUtils.vCardToAbCard(vCard);
|
||||
const abCard = lazy.VCardUtils.vCardToAbCard(vCard);
|
||||
abCard.setProperty("_etag", etag);
|
||||
abCard.setProperty("_href", href);
|
||||
|
||||
|
@ -499,7 +499,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
this._syncTimer = null;
|
||||
}
|
||||
|
||||
let interval = this.getIntValue("carddav.syncinterval", 30);
|
||||
const interval = this.getIntValue("carddav.syncinterval", 30);
|
||||
if (interval <= 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
log.log("Fetching all cards from the server.");
|
||||
this._syncInProgress = true;
|
||||
|
||||
let data = `<propfind xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>
|
||||
const data = `<propfind xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>
|
||||
<prop>
|
||||
<resourcetype/>
|
||||
<getetag/>
|
||||
|
@ -539,20 +539,20 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
|
||||
// A map of all existing hrefs and etags. If the etag for an href matches
|
||||
// what we already have, we won't fetch it.
|
||||
let currentHrefs = new Map(
|
||||
const currentHrefs = new Map(
|
||||
Array.from(this.cards.values(), c => [c.get("_href"), c.get("_etag")])
|
||||
);
|
||||
|
||||
let hrefsToFetch = [];
|
||||
for (let { href, properties } of this._readResponse(response.dom)) {
|
||||
const hrefsToFetch = [];
|
||||
for (const { href, properties } of this._readResponse(response.dom)) {
|
||||
if (!properties || properties.querySelector("resourcetype collection")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let currentEtag = currentHrefs.get(href);
|
||||
const currentEtag = currentHrefs.get(href);
|
||||
currentHrefs.delete(href);
|
||||
|
||||
let etag = properties.querySelector("getetag")?.textContent;
|
||||
const etag = properties.querySelector("getetag")?.textContent;
|
||||
if (etag && currentEtag == etag) {
|
||||
continue;
|
||||
}
|
||||
|
@ -562,8 +562,8 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
|
||||
// Delete any existing cards we didn't see. They're not on the server so
|
||||
// they shouldn't be on the client.
|
||||
let cardsToDelete = [];
|
||||
for (let href of currentHrefs.keys()) {
|
||||
const cardsToDelete = [];
|
||||
for (const href of currentHrefs.keys()) {
|
||||
cardsToDelete.push(this.getCardFromProperty("_href", href, true));
|
||||
}
|
||||
if (cardsToDelete.length > 0) {
|
||||
|
@ -574,20 +574,20 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
if (hrefsToFetch.length > 0) {
|
||||
response = await this._multigetRequest(hrefsToFetch);
|
||||
|
||||
let abCards = [];
|
||||
const abCards = [];
|
||||
|
||||
for (let { href, properties } of this._readResponse(response.dom)) {
|
||||
for (const { href, properties } of this._readResponse(response.dom)) {
|
||||
if (!properties) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let etag = properties.querySelector("getetag")?.textContent;
|
||||
let vCard = normalizeLineEndings(
|
||||
const etag = properties.querySelector("getetag")?.textContent;
|
||||
const vCard = normalizeLineEndings(
|
||||
properties.querySelector("address-data")?.textContent
|
||||
);
|
||||
|
||||
try {
|
||||
let abCard = lazy.VCardUtils.vCardToAbCard(vCard);
|
||||
const abCard = lazy.VCardUtils.vCardToAbCard(vCard);
|
||||
abCard.setProperty("_etag", etag);
|
||||
abCard.setProperty("_href", href);
|
||||
abCards.push(abCard);
|
||||
|
@ -627,14 +627,14 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
try {
|
||||
// First perform all pending removals. We don't want to have deleted cards
|
||||
// reappearing when we sync.
|
||||
for (let href of this._hrefsToRemove) {
|
||||
for (const href of this._hrefsToRemove) {
|
||||
await this._deleteCardFromServer(href);
|
||||
}
|
||||
this._hrefsToRemove.clear();
|
||||
|
||||
// Now update any cards that were modified while not connected to the server.
|
||||
for (let uid of this._uidsToSync) {
|
||||
let card = this.getCard(uid);
|
||||
for (const uid of this._uidsToSync) {
|
||||
const card = this.getCard(uid);
|
||||
// The card may no longer exist. It shouldn't still be listed to send,
|
||||
// but it might be.
|
||||
if (card) {
|
||||
|
@ -664,7 +664,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
* directory to match what is on the server.
|
||||
*/
|
||||
async updateAllFromServerV1() {
|
||||
let data = `<propfind xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>
|
||||
const data = `<propfind xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>
|
||||
<prop>
|
||||
<resourcetype/>
|
||||
<getetag/>
|
||||
|
@ -672,7 +672,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
</prop>
|
||||
</propfind>`;
|
||||
|
||||
let response = await this._makeRequest("", {
|
||||
const response = await this._makeRequest("", {
|
||||
method: "PROPFIND",
|
||||
body: data,
|
||||
headers: {
|
||||
|
@ -681,8 +681,8 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
expectedStatuses: [207],
|
||||
});
|
||||
|
||||
let hrefMap = new Map();
|
||||
for (let { href, properties } of this._readResponse(response.dom)) {
|
||||
const hrefMap = new Map();
|
||||
for (const { href, properties } of this._readResponse(response.dom)) {
|
||||
if (
|
||||
!properties ||
|
||||
!properties.querySelector("resourcetype") ||
|
||||
|
@ -691,16 +691,16 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
continue;
|
||||
}
|
||||
|
||||
let etag = properties.querySelector("getetag").textContent;
|
||||
const etag = properties.querySelector("getetag").textContent;
|
||||
hrefMap.set(href, etag);
|
||||
}
|
||||
|
||||
let cardMap = new Map();
|
||||
let hrefsToFetch = [];
|
||||
let cardsToDelete = [];
|
||||
for (let card of this.childCards) {
|
||||
let href = card.getProperty("_href", "");
|
||||
let etag = card.getProperty("_etag", "");
|
||||
const cardMap = new Map();
|
||||
const hrefsToFetch = [];
|
||||
const cardsToDelete = [];
|
||||
for (const card of this.childCards) {
|
||||
const href = card.getProperty("_href", "");
|
||||
const etag = card.getProperty("_etag", "");
|
||||
|
||||
if (!href || !etag) {
|
||||
// Not sure how we got here. Ignore it.
|
||||
|
@ -718,7 +718,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
for (let href of hrefMap.keys()) {
|
||||
for (const href of hrefMap.keys()) {
|
||||
if (!cardMap.has(href)) {
|
||||
// The card is new on the server.
|
||||
hrefsToFetch.push(href);
|
||||
|
@ -755,7 +755,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
async _getSyncToken() {
|
||||
log.log("Fetching new sync token");
|
||||
|
||||
let data = `<propfind xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>
|
||||
const data = `<propfind xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>
|
||||
<prop>
|
||||
<displayname/>
|
||||
<cs:getctag/>
|
||||
|
@ -763,7 +763,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
</prop>
|
||||
</propfind>`;
|
||||
|
||||
let response = await this._makeRequest("", {
|
||||
const response = await this._makeRequest("", {
|
||||
method: "PROPFIND",
|
||||
body: data,
|
||||
headers: {
|
||||
|
@ -772,8 +772,8 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
});
|
||||
|
||||
if (response.status == 207) {
|
||||
for (let { properties } of this._readResponse(response.dom)) {
|
||||
let token = properties?.querySelector("prop sync-token");
|
||||
for (const { properties } of this._readResponse(response.dom)) {
|
||||
const token = properties?.querySelector("prop sync-token");
|
||||
if (token) {
|
||||
this._syncToken = token.textContent;
|
||||
return;
|
||||
|
@ -792,12 +792,12 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
* @see RFC 6578
|
||||
*/
|
||||
async updateAllFromServerV2() {
|
||||
let syncToken = this._syncToken;
|
||||
const syncToken = this._syncToken;
|
||||
if (!syncToken) {
|
||||
throw new Components.Exception("No sync token", Cr.NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
let data = `<sync-collection xmlns="${
|
||||
const data = `<sync-collection xmlns="${
|
||||
PREFIX_BINDINGS.d
|
||||
}" ${NAMESPACE_STRING}>
|
||||
<sync-token>${xmlEncode(syncToken)}</sync-token>
|
||||
|
@ -808,7 +808,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
</prop>
|
||||
</sync-collection>`;
|
||||
|
||||
let response = await this._makeRequest("", {
|
||||
const response = await this._makeRequest("", {
|
||||
method: "REPORT",
|
||||
body: data,
|
||||
headers: {
|
||||
|
@ -825,7 +825,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
return;
|
||||
}
|
||||
|
||||
let dom = response.dom;
|
||||
const dom = response.dom;
|
||||
|
||||
// If this directory is set to read-only, the following operations would
|
||||
// throw NS_ERROR_FAILURE, but sync operations are allowed on a read-only
|
||||
|
@ -834,12 +834,12 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
// Do not use await while it is set, and use a try/finally block to ensure
|
||||
// it is cleared.
|
||||
|
||||
let hrefsToFetch = [];
|
||||
const hrefsToFetch = [];
|
||||
try {
|
||||
this._overrideReadOnly = true;
|
||||
let cardsToDelete = [];
|
||||
for (let { href, notFound, properties } of this._readResponse(dom)) {
|
||||
let card = this.getCardFromProperty("_href", href, true);
|
||||
const cardsToDelete = [];
|
||||
for (const { href, notFound, properties } of this._readResponse(dom)) {
|
||||
const card = this.getCardFromProperty("_href", href, true);
|
||||
if (notFound) {
|
||||
if (card) {
|
||||
cardsToDelete.push(card);
|
||||
|
@ -850,7 +850,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
continue;
|
||||
}
|
||||
|
||||
let etag = properties.querySelector("getetag")?.textContent;
|
||||
const etag = properties.querySelector("getetag")?.textContent;
|
||||
if (!etag) {
|
||||
continue;
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
}
|
||||
vCard = normalizeLineEndings(vCard);
|
||||
|
||||
let abCard = lazy.VCardUtils.vCardToAbCard(vCard);
|
||||
const abCard = lazy.VCardUtils.vCardToAbCard(vCard);
|
||||
abCard.setProperty("_etag", etag);
|
||||
abCard.setProperty("_href", href);
|
||||
|
||||
|
@ -890,7 +890,7 @@ class CardDAVDirectory extends SQLiteDirectory {
|
|||
}
|
||||
|
||||
static forFile(fileName) {
|
||||
let directory = super.forFile(fileName);
|
||||
const directory = super.forFile(fileName);
|
||||
if (directory instanceof CardDAVDirectory) {
|
||||
return directory;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ var CardDAVUtils = {
|
|||
}
|
||||
|
||||
// This could be any 32-bit integer, as long as it isn't already in use.
|
||||
let nextId = 25000 + CardDAVUtils._contextMap.size;
|
||||
const nextId = 25000 + CardDAVUtils._contextMap.size;
|
||||
lazy.ContextualIdentityService.remove(nextId);
|
||||
CardDAVUtils._contextMap.set(username, nextId);
|
||||
return nextId;
|
||||
|
@ -103,7 +103,7 @@ var CardDAVUtils = {
|
|||
if (typeof uri == "string") {
|
||||
uri = Services.io.newURI(uri);
|
||||
}
|
||||
let {
|
||||
const {
|
||||
method = "GET",
|
||||
headers = {},
|
||||
body = null,
|
||||
|
@ -130,12 +130,12 @@ var CardDAVUtils = {
|
|||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
const principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
uri,
|
||||
{ userContextId }
|
||||
);
|
||||
|
||||
let channel = Services.io.newChannelFromURI(
|
||||
const channel = Services.io.newChannelFromURI(
|
||||
uri,
|
||||
null,
|
||||
principal,
|
||||
|
@ -144,13 +144,13 @@ var CardDAVUtils = {
|
|||
Ci.nsIContentPolicy.TYPE_OTHER
|
||||
);
|
||||
channel.QueryInterface(Ci.nsIHttpChannel);
|
||||
for (let [name, value] of Object.entries(headers)) {
|
||||
for (const [name, value] of Object.entries(headers)) {
|
||||
channel.setRequestHeader(name, value, false);
|
||||
}
|
||||
if (body !== null) {
|
||||
let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
|
||||
Ci.nsIStringInputStream
|
||||
);
|
||||
const stream = Cc[
|
||||
"@mozilla.org/io/string-input-stream;1"
|
||||
].createInstance(Ci.nsIStringInputStream);
|
||||
stream.setUTF8Data(body, body.length);
|
||||
|
||||
channel.QueryInterface(Ci.nsIUploadChannel);
|
||||
|
@ -159,16 +159,16 @@ var CardDAVUtils = {
|
|||
channel.requestMethod = method; // Must go after setUploadStream.
|
||||
channel.notificationCallbacks = callbacks;
|
||||
|
||||
let listener = Cc["@mozilla.org/network/stream-loader;1"].createInstance(
|
||||
Ci.nsIStreamLoader
|
||||
);
|
||||
const listener = Cc[
|
||||
"@mozilla.org/network/stream-loader;1"
|
||||
].createInstance(Ci.nsIStreamLoader);
|
||||
listener.init({
|
||||
onStreamComplete(loader, context, status, resultLength, result) {
|
||||
let finalChannel = loader.request.QueryInterface(Ci.nsIHttpChannel);
|
||||
const finalChannel = loader.request.QueryInterface(Ci.nsIHttpChannel);
|
||||
if (!Components.isSuccessCode(status)) {
|
||||
let isCertError = false;
|
||||
try {
|
||||
let errorType = lazy.nssErrorsService.getErrorClass(status);
|
||||
const errorType = lazy.nssErrorsService.getErrorClass(status);
|
||||
if (errorType == Ci.nsINSSErrorsService.ERROR_CLASS_BAD_CERT) {
|
||||
isCertError = true;
|
||||
}
|
||||
|
@ -178,10 +178,10 @@ var CardDAVUtils = {
|
|||
}
|
||||
|
||||
if (isCertError && finalChannel.securityInfo) {
|
||||
let secInfo = finalChannel.securityInfo.QueryInterface(
|
||||
const secInfo = finalChannel.securityInfo.QueryInterface(
|
||||
Ci.nsITransportSecurityInfo
|
||||
);
|
||||
let params = {
|
||||
const params = {
|
||||
exceptionAdded: false,
|
||||
securityInfo: secInfo,
|
||||
prefetchCert: true,
|
||||
|
@ -266,14 +266,14 @@ var CardDAVUtils = {
|
|||
* @returns {foundBook[]} - An array of found address books.
|
||||
*/
|
||||
async detectAddressBooks(username, password, location, forcePrompt = false) {
|
||||
let log = console.createInstance({
|
||||
const log = console.createInstance({
|
||||
prefix: "carddav.setup",
|
||||
maxLogLevel: "Warn",
|
||||
maxLogLevelPref: "carddav.setup.loglevel",
|
||||
});
|
||||
|
||||
// Use a unique context for each attempt, so a prompt is always shown.
|
||||
let userContextId = Math.floor(Date.now() / 1000);
|
||||
const userContextId = Math.floor(Date.now() / 1000);
|
||||
|
||||
let url = new URL(location);
|
||||
|
||||
|
@ -290,8 +290,8 @@ var CardDAVUtils = {
|
|||
|
||||
if (url.pathname == "/" && !(url.hostname in PRESETS)) {
|
||||
log.log(`Looking up DNS record for ${url.hostname}`);
|
||||
let domain = `_carddavs._tcp.${url.hostname}`;
|
||||
let srvRecords = await DNS.srv(domain);
|
||||
const domain = `_carddavs._tcp.${url.hostname}`;
|
||||
const srvRecords = await DNS.srv(domain);
|
||||
srvRecords.sort((a, b) => a.prio - b.prio || b.weight - a.weight);
|
||||
|
||||
if (srvRecords[0]) {
|
||||
|
@ -309,7 +309,7 @@ var CardDAVUtils = {
|
|||
log.log(`Found a DNS TXT record pointing to ${url.href}`);
|
||||
}
|
||||
} else {
|
||||
let mxRecords = await DNS.mx(url.hostname);
|
||||
const mxRecords = await DNS.mx(url.hostname);
|
||||
if (mxRecords.some(r => /\bgoogle\.com$/.test(r.host))) {
|
||||
log.log(
|
||||
`Found a DNS MX record for Google, using preset URL for ${url}`
|
||||
|
@ -320,9 +320,13 @@ var CardDAVUtils = {
|
|||
}
|
||||
|
||||
let oAuth = null;
|
||||
let callbacks = new NotificationCallbacks(username, password, forcePrompt);
|
||||
const callbacks = new NotificationCallbacks(
|
||||
username,
|
||||
password,
|
||||
forcePrompt
|
||||
);
|
||||
|
||||
let requestParams = {
|
||||
const requestParams = {
|
||||
method: "PROPFIND",
|
||||
callbacks,
|
||||
userContextId,
|
||||
|
@ -339,16 +343,16 @@ var CardDAVUtils = {
|
|||
</propfind>`,
|
||||
};
|
||||
|
||||
let details = lazy.OAuth2Providers.getHostnameDetails(url.host);
|
||||
const details = lazy.OAuth2Providers.getHostnameDetails(url.host);
|
||||
if (details) {
|
||||
let [issuer, scope] = details;
|
||||
let issuerDetails = lazy.OAuth2Providers.getIssuerDetails(issuer);
|
||||
const [issuer, scope] = details;
|
||||
const issuerDetails = lazy.OAuth2Providers.getIssuerDetails(issuer);
|
||||
|
||||
oAuth = new lazy.OAuth2(scope, issuerDetails);
|
||||
oAuth._isNew = true;
|
||||
oAuth._loginOrigin = `oauth://${issuer}`;
|
||||
oAuth._scope = scope;
|
||||
for (let login of Services.logins.findLogins(
|
||||
for (const login of Services.logins.findLogins(
|
||||
oAuth._loginOrigin,
|
||||
null,
|
||||
""
|
||||
|
@ -387,7 +391,7 @@ var CardDAVUtils = {
|
|||
}
|
||||
|
||||
let response;
|
||||
let triedURLs = new Set();
|
||||
const triedURLs = new Set();
|
||||
async function tryURL(url) {
|
||||
if (triedURLs.has(url)) {
|
||||
return;
|
||||
|
@ -438,7 +442,7 @@ var CardDAVUtils = {
|
|||
}
|
||||
|
||||
if (!response.dom.querySelector("resourcetype addressbook")) {
|
||||
let userPrincipal = response.dom.querySelector(
|
||||
const userPrincipal = response.dom.querySelector(
|
||||
"current-user-principal href"
|
||||
);
|
||||
if (!userPrincipal) {
|
||||
|
@ -475,8 +479,8 @@ var CardDAVUtils = {
|
|||
|
||||
// Find any directories in the response.
|
||||
|
||||
let foundBooks = [];
|
||||
for (let r of response.dom.querySelectorAll("response")) {
|
||||
const foundBooks = [];
|
||||
for (const r of response.dom.querySelectorAll("response")) {
|
||||
if (r.querySelector("status")?.textContent != "HTTP/1.1 200 OK") {
|
||||
continue;
|
||||
}
|
||||
|
@ -486,13 +490,13 @@ var CardDAVUtils = {
|
|||
|
||||
// If the server provided ACL information, skip address books that we do
|
||||
// not have read privileges to.
|
||||
let privNode = r.querySelector("current-user-privilege-set");
|
||||
const privNode = r.querySelector("current-user-privilege-set");
|
||||
let isWritable = false;
|
||||
let isReadable = false;
|
||||
if (privNode) {
|
||||
let privs = Array.from(privNode.querySelectorAll("privilege > *")).map(
|
||||
node => node.localName
|
||||
);
|
||||
const privs = Array.from(
|
||||
privNode.querySelectorAll("privilege > *")
|
||||
).map(node => node.localName);
|
||||
|
||||
isWritable = writePrivs.some(priv => privs.includes(priv));
|
||||
isReadable = readPrivs.some(priv => privs.includes(priv));
|
||||
|
@ -516,13 +520,13 @@ var CardDAVUtils = {
|
|||
url,
|
||||
name,
|
||||
async create() {
|
||||
let dirPrefId = MailServices.ab.newAddressBook(
|
||||
const dirPrefId = MailServices.ab.newAddressBook(
|
||||
this.name,
|
||||
null,
|
||||
Ci.nsIAbManager.CARDDAV_DIRECTORY_TYPE,
|
||||
null
|
||||
);
|
||||
let book = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
const book = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
book.setStringValue("carddav.url", this.url);
|
||||
|
||||
if (!isWritable && isReadable) {
|
||||
|
@ -532,7 +536,7 @@ var CardDAVUtils = {
|
|||
if (oAuth) {
|
||||
if (oAuth._isNew) {
|
||||
log.log(`Saving refresh token for ${username}`);
|
||||
let newLoginInfo = Cc[
|
||||
const newLoginInfo = Cc[
|
||||
"@mozilla.org/login-manager/loginInfo;1"
|
||||
].createInstance(Ci.nsILoginInfo);
|
||||
newLoginInfo.init(
|
||||
|
@ -561,7 +565,7 @@ var CardDAVUtils = {
|
|||
callbacks.saveAuth();
|
||||
}
|
||||
|
||||
let dir = lazy.CardDAVDirectory.forFile(book.fileName);
|
||||
const dir = lazy.CardDAVDirectory.forFile(book.fileName);
|
||||
// Pass the context to the created address book. This prevents asking
|
||||
// for a username/password again in the case that we didn't save it.
|
||||
// The user won't be prompted again until Thunderbird is restarted.
|
||||
|
@ -623,8 +627,8 @@ class NotificationCallbacks {
|
|||
return true;
|
||||
}
|
||||
|
||||
let logins = Services.logins.findLogins(channel.URI.prePath, null, "");
|
||||
for (let l of logins) {
|
||||
const logins = Services.logins.findLogins(channel.URI.prePath, null, "");
|
||||
for (const l of logins) {
|
||||
if (l.username == this.username) {
|
||||
authInfo.username = l.username;
|
||||
authInfo.password = l.password;
|
||||
|
@ -637,7 +641,7 @@ class NotificationCallbacks {
|
|||
authInfo.password = this.password;
|
||||
|
||||
let savePasswordLabel = null;
|
||||
let savePassword = {};
|
||||
const savePassword = {};
|
||||
if (Services.prefs.getBoolPref("signon.rememberSignons", true)) {
|
||||
savePasswordLabel = Services.strings
|
||||
.createBundle("chrome://passwordmgr/locale/passwordmgr.properties")
|
||||
|
@ -645,7 +649,7 @@ class NotificationCallbacks {
|
|||
savePassword.value = true;
|
||||
}
|
||||
|
||||
let returnValue = new lazy.MsgAuthPrompt().promptAuth(
|
||||
const returnValue = new lazy.MsgAuthPrompt().promptAuth(
|
||||
channel,
|
||||
level,
|
||||
authInfo,
|
||||
|
@ -659,7 +663,7 @@ class NotificationCallbacks {
|
|||
}
|
||||
async saveAuth() {
|
||||
if (this.shouldSaveAuth) {
|
||||
let newLoginInfo = Cc[
|
||||
const newLoginInfo = Cc[
|
||||
"@mozilla.org/login-manager/loginInfo;1"
|
||||
].createInstance(Ci.nsILoginInfo);
|
||||
newLoginInfo.init(
|
||||
|
@ -686,7 +690,7 @@ class NotificationCallbacks {
|
|||
*/
|
||||
function copyHeader(header) {
|
||||
try {
|
||||
let headerValue = oldChannel.getRequestHeader(header);
|
||||
const headerValue = oldChannel.getRequestHeader(header);
|
||||
if (headerValue) {
|
||||
newChannel.setRequestHeader(header, headerValue, false);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class LDAPClient {
|
|||
}
|
||||
|
||||
connect() {
|
||||
let hostname = this._host.toLowerCase();
|
||||
const hostname = this._host.toLowerCase();
|
||||
this._logger.debug(
|
||||
`Connecting to ${
|
||||
this._useSecureTransport ? "ldaps" : "ldap"
|
||||
|
@ -69,7 +69,7 @@ class LDAPClient {
|
|||
*/
|
||||
bind(dn, password, callback) {
|
||||
this._logger.debug(`Binding ${dn}`);
|
||||
let req = new BindRequest(dn || "", password || "");
|
||||
const req = new BindRequest(dn || "", password || "");
|
||||
return this._send(req, callback);
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class LDAPClient {
|
|||
);
|
||||
}
|
||||
// getNextToken expects a base64 string.
|
||||
let token = this._authModule.getNextToken(
|
||||
const token = this._authModule.getNextToken(
|
||||
serverCredentials
|
||||
? btoa(
|
||||
CommonUtils.arrayBufferToByteString(
|
||||
|
@ -112,8 +112,8 @@ class LDAPClient {
|
|||
: ""
|
||||
);
|
||||
// token is a base64 string, convert it to Uint8Array.
|
||||
let credentials = CommonUtils.byteStringToArrayBuffer(atob(token));
|
||||
let req = new BindRequest("", "", { mechanism, credentials });
|
||||
const credentials = CommonUtils.byteStringToArrayBuffer(atob(token));
|
||||
const req = new BindRequest("", "", { mechanism, credentials });
|
||||
return this._send(req, callback);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,14 @@ class LDAPClient {
|
|||
*/
|
||||
search(dn, scope, filter, attributes, timeout, limit, callback) {
|
||||
this._logger.debug(`Searching dn="${dn}" filter="${filter}"`);
|
||||
let req = new SearchRequest(dn, scope, filter, attributes, timeout, limit);
|
||||
const req = new SearchRequest(
|
||||
dn,
|
||||
scope,
|
||||
filter,
|
||||
attributes,
|
||||
timeout,
|
||||
limit
|
||||
);
|
||||
return this._send(req, callback);
|
||||
}
|
||||
|
||||
|
@ -150,7 +157,7 @@ class LDAPClient {
|
|||
abandon(messageId) {
|
||||
this._logger.debug(`Abandoning ${messageId}`);
|
||||
this._callbackMap.delete(messageId);
|
||||
let req = new AbandonRequest(messageId);
|
||||
const req = new AbandonRequest(messageId);
|
||||
this._send(req);
|
||||
}
|
||||
|
||||
|
@ -179,7 +186,7 @@ class LDAPClient {
|
|||
let data = event.data;
|
||||
if (this._buffer) {
|
||||
// Concatenate left over data from the last event with the new data.
|
||||
let arr = new Uint8Array(this._buffer.byteLength + data.byteLength);
|
||||
const arr = new Uint8Array(this._buffer.byteLength + data.byteLength);
|
||||
arr.set(new Uint8Array(this._buffer));
|
||||
arr.set(new Uint8Array(data), this._buffer.byteLength);
|
||||
data = arr.buffer;
|
||||
|
@ -215,7 +222,7 @@ class LDAPClient {
|
|||
if (res.constructor.name == "SearchResultReference") {
|
||||
this._logger.debug("References=", res.result);
|
||||
}
|
||||
let callback = this._callbackMap.get(res.messageId);
|
||||
const callback = this._callbackMap.get(res.messageId);
|
||||
if (callback) {
|
||||
callback(res);
|
||||
if (
|
||||
|
@ -240,7 +247,7 @@ class LDAPClient {
|
|||
*/
|
||||
_handleNextDataEvent() {
|
||||
this._processingData = false;
|
||||
let next = this._dataEventsQueue.shift();
|
||||
const next = this._dataEventsQueue.shift();
|
||||
if (next) {
|
||||
this._onData(next);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class LDAPConnection {
|
|||
}
|
||||
|
||||
init(url, bindName, listener, closure, version) {
|
||||
let useSecureTransport = url.scheme == "ldaps";
|
||||
const useSecureTransport = url.scheme == "ldaps";
|
||||
let port = url.port;
|
||||
if (port == -1) {
|
||||
// -1 corresponds to the protocol's default port.
|
||||
|
|
|
@ -38,7 +38,7 @@ class LDAPDirectory extends AddrBookDirectory {
|
|||
init(uri) {
|
||||
this._uri = uri;
|
||||
|
||||
let searchIndex = uri.indexOf("?");
|
||||
const searchIndex = uri.indexOf("?");
|
||||
this._dirPrefId = uri.substr(
|
||||
"moz-abldapdirectory://".length,
|
||||
searchIndex == -1 ? undefined : searchIndex
|
||||
|
@ -119,14 +119,14 @@ class LDAPDirectory extends AddrBookDirectory {
|
|||
}
|
||||
|
||||
get attributeMap() {
|
||||
let mapSvc = Cc[
|
||||
const mapSvc = Cc[
|
||||
"@mozilla.org/addressbook/ldap-attribute-map-service;1"
|
||||
].createInstance(Ci.nsIAbLDAPAttributeMapService);
|
||||
return mapSvc.getMapForPrefBranch(this._dirPrefId);
|
||||
}
|
||||
|
||||
get lDAPURL() {
|
||||
let uri = this.getStringValue("uri") || `ldap://${this._uri.slice(22)}`;
|
||||
const uri = this.getStringValue("uri") || `ldap://${this._uri.slice(22)}`;
|
||||
return Services.io.newURI(uri).QueryInterface(Ci.nsILDAPURL);
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ class LDAPDirectory extends AddrBookDirectory {
|
|||
"@mozilla.org/addressbook/ldap-directory-query;1"
|
||||
].createInstance(Ci.nsIAbDirectoryQuery);
|
||||
|
||||
let args = Cc[
|
||||
const args = Cc[
|
||||
"@mozilla.org/addressbook/directory/query-arguments;1"
|
||||
].createInstance(Ci.nsIAbDirectoryQueryArguments);
|
||||
args.expression = lazy.QueryStringToExpression.convert(queryString);
|
||||
|
@ -194,7 +194,7 @@ class LDAPDirectory extends AddrBookDirectory {
|
|||
useForAutocomplete(identityKey) {
|
||||
// If we're online, then don't allow search during local autocomplete - must
|
||||
// use the separate LDAP autocomplete session due to the current interfaces
|
||||
let useDirectory = Services.prefs.getBoolPref(
|
||||
const useDirectory = Services.prefs.getBoolPref(
|
||||
"ldap_2.autoComplete.useDirectory",
|
||||
false
|
||||
);
|
||||
|
@ -206,7 +206,7 @@ class LDAPDirectory extends AddrBookDirectory {
|
|||
if (identityKey) {
|
||||
// If we have an identity string, try and find out the required directory
|
||||
// server.
|
||||
let identity = MailServices.accounts.getIdentity(identityKey);
|
||||
const identity = MailServices.accounts.getIdentity(identityKey);
|
||||
if (identity.overrideGlobalPref) {
|
||||
prefName = identity.directoryServer;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ function boolExpressionToFilter(attrMap, exp) {
|
|||
}[exp.operation] || "";
|
||||
|
||||
if (exp.expressions) {
|
||||
for (let childExp of exp.expressions) {
|
||||
for (const childExp of exp.expressions) {
|
||||
if (childExp instanceof Ci.nsIAbBooleanExpression) {
|
||||
filter += boolExpressionToFilter(attrMap, childExp);
|
||||
} else if (childExp instanceof Ci.nsIAbBooleanConditionString) {
|
||||
|
@ -48,7 +48,7 @@ function boolExpressionToFilter(attrMap, exp) {
|
|||
* @returns {string}
|
||||
*/
|
||||
function boolConditionToFilter(attrMap, exp) {
|
||||
let attr = attrMap.getFirstAttribute(exp.name);
|
||||
const attr = attrMap.getFirstAttribute(exp.name);
|
||||
if (!attr) {
|
||||
return "";
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ class LDAPDirectoryQuery extends LDAPListenerBase {
|
|||
* @see LDAPListenerBase
|
||||
*/
|
||||
_actionOnBindSuccess() {
|
||||
let ldapUrl = this._directory.lDAPURL;
|
||||
const ldapUrl = this._directory.lDAPURL;
|
||||
this._operation.searchExt(
|
||||
ldapUrl.dn,
|
||||
ldapUrl.scope,
|
||||
|
@ -185,9 +185,9 @@ class LDAPDirectoryQuery extends LDAPListenerBase {
|
|||
* @param {nsILDAPMessage} msg - The received LDAP message.
|
||||
*/
|
||||
_onLDAPSearchEntry(msg) {
|
||||
let newCard = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
const newCard = Cc[
|
||||
"@mozilla.org/addressbook/cardproperty;1"
|
||||
].createInstance(Ci.nsIAbCard);
|
||||
this._attrMap.setCardPropertiesFromLDAPMessage(msg, newCard);
|
||||
newCard.directoryUID = this._directory.UID;
|
||||
this._listener.onSearchFoundCard(newCard);
|
||||
|
|
|
@ -13,14 +13,14 @@ class LDAPListenerBase {
|
|||
* @see nsILDAPMessageListener
|
||||
*/
|
||||
async onLDAPInit() {
|
||||
let outPassword = {};
|
||||
const outPassword = {};
|
||||
if (this._directory.authDn && this._directory.saslMechanism != "GSSAPI") {
|
||||
// If authDn is set, we're expected to use it to get a password.
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://mozldap/locale/ldap.properties"
|
||||
);
|
||||
|
||||
let authPrompt = Services.ww.getNewAuthPrompter(
|
||||
const authPrompt = Services.ww.getNewAuthPrompter(
|
||||
Services.wm.getMostRecentWindow(null)
|
||||
);
|
||||
await authPrompt.asyncPromptPassword(
|
||||
|
@ -54,19 +54,19 @@ class LDAPListenerBase {
|
|||
* @param {nsILDAPMessage} msg - The received LDAP message.
|
||||
*/
|
||||
_onLDAPBind(msg) {
|
||||
let errCode = msg.errorCode;
|
||||
const errCode = msg.errorCode;
|
||||
if (
|
||||
errCode == Ci.nsILDAPErrors.INAPPROPRIATE_AUTH ||
|
||||
errCode == Ci.nsILDAPErrors.INVALID_CREDENTIALS
|
||||
) {
|
||||
// Login failed, remove any existing login(s).
|
||||
let ldapUrl = this._directory.lDAPURL;
|
||||
let logins = Services.logins.findLogins(
|
||||
const ldapUrl = this._directory.lDAPURL;
|
||||
const logins = Services.logins.findLogins(
|
||||
ldapUrl.prePath,
|
||||
"",
|
||||
ldapUrl.spec
|
||||
);
|
||||
for (let login of logins) {
|
||||
for (const login of logins) {
|
||||
Services.logins.removeLogin(login);
|
||||
}
|
||||
// Trigger the auth prompt.
|
||||
|
|
|
@ -28,7 +28,7 @@ class LDAPMessage {
|
|||
* @returns {ArrayBuffer} BER encoded message.
|
||||
*/
|
||||
toBER(messageId = this.messageId) {
|
||||
let msg = new asn1js.Sequence({
|
||||
const msg = new asn1js.Sequence({
|
||||
value: [new asn1js.Integer({ value: messageId }), this.protocolOp],
|
||||
});
|
||||
return msg.toBER();
|
||||
|
@ -220,10 +220,10 @@ class SearchRequest extends LDAPMessage {
|
|||
* [number, string, string]
|
||||
*/
|
||||
_parseFilterValue(filter) {
|
||||
for (let cond of [">=", "<=", "~=", ":=", "="]) {
|
||||
let index = filter.indexOf(cond);
|
||||
for (const cond of [">=", "<=", "~=", ":=", "="]) {
|
||||
const index = filter.indexOf(cond);
|
||||
if (index > 0) {
|
||||
let k = filter.slice(0, index);
|
||||
const k = filter.slice(0, index);
|
||||
let v = filter.slice(index + cond.length);
|
||||
let filterId = {
|
||||
">=": this.FILTER_GREATER_OR_EQUAL,
|
||||
|
@ -276,8 +276,8 @@ class SearchRequest extends LDAPMessage {
|
|||
);
|
||||
}
|
||||
filter = filter.slice(1);
|
||||
let nextOpen = filter.indexOf("(");
|
||||
let nextClose = filter.indexOf(")");
|
||||
const nextOpen = filter.indexOf("(");
|
||||
const nextClose = filter.indexOf(")");
|
||||
|
||||
if (nextOpen != -1 && nextOpen < nextClose) {
|
||||
// Case: "OP("
|
||||
|
@ -315,9 +315,9 @@ class SearchRequest extends LDAPMessage {
|
|||
// Make sure filter is wrapped in parens, see rfc2254#section-4.
|
||||
filter = `(${filter})`;
|
||||
}
|
||||
let tokens = this._parseFilter(filter);
|
||||
let stack = [];
|
||||
for (let { type, depth, value } of tokens) {
|
||||
const tokens = this._parseFilter(filter);
|
||||
const stack = [];
|
||||
for (const { type, depth, value } of tokens) {
|
||||
while (depth < stack.length) {
|
||||
// We are done with the current block, go one level up.
|
||||
stack.pop();
|
||||
|
@ -328,8 +328,8 @@ class SearchRequest extends LDAPMessage {
|
|||
stack.pop();
|
||||
}
|
||||
// Found a new block, go one level down.
|
||||
let parent = stack.slice(-1)[0];
|
||||
let curBlock = new asn1js.Constructed({
|
||||
const parent = stack.slice(-1)[0];
|
||||
const curBlock = new asn1js.Constructed({
|
||||
idBlock: this._getContextId(value),
|
||||
});
|
||||
stack.push(curBlock);
|
||||
|
@ -337,9 +337,9 @@ class SearchRequest extends LDAPMessage {
|
|||
parent.valueBlock.value.push(curBlock);
|
||||
}
|
||||
} else if (type == "field") {
|
||||
let [tagNumber, field, fieldValue] = value;
|
||||
const [tagNumber, field, fieldValue] = value;
|
||||
let block;
|
||||
let idBlock = this._getContextId(tagNumber);
|
||||
const idBlock = this._getContextId(tagNumber);
|
||||
if (tagNumber == this.FILTER_PRESENT) {
|
||||
// A present filter.
|
||||
block = new asn1js.Primitive({
|
||||
|
@ -349,7 +349,7 @@ class SearchRequest extends LDAPMessage {
|
|||
} else if (tagNumber == this.FILTER_EXTENSIBLE_MATCH) {
|
||||
// An extensibleMatch filter is in the form of
|
||||
// <type>:dn:<rule>:=<value>. We need to further parse the field.
|
||||
let parts = field.split(":");
|
||||
const parts = field.split(":");
|
||||
let value = [];
|
||||
if (parts.length == 3) {
|
||||
// field is <type>:dn:<rule>.
|
||||
|
@ -367,7 +367,7 @@ class SearchRequest extends LDAPMessage {
|
|||
this._contextStringBlock(this.MATCHING_VALUE, fieldValue)
|
||||
);
|
||||
if (parts[1] == "dn") {
|
||||
let dn = new asn1js.Boolean({
|
||||
const dn = new asn1js.Boolean({
|
||||
value: true,
|
||||
});
|
||||
dn.idBlock.tagClass = LDAPMessage.TAG_CLASS_CONTEXT;
|
||||
|
@ -416,7 +416,7 @@ class SearchRequest extends LDAPMessage {
|
|||
});
|
||||
} else {
|
||||
// A substrings filter.
|
||||
let substringsSeq = new asn1js.Sequence();
|
||||
const substringsSeq = new asn1js.Sequence();
|
||||
block = new asn1js.Constructed({
|
||||
idBlock,
|
||||
value: [
|
||||
|
@ -427,7 +427,7 @@ class SearchRequest extends LDAPMessage {
|
|||
],
|
||||
});
|
||||
for (let i = 0; i < fieldValue.length; i++) {
|
||||
let v = fieldValue[i];
|
||||
const v = fieldValue[i];
|
||||
if (!v.length) {
|
||||
// Case: *
|
||||
continue;
|
||||
|
@ -452,7 +452,7 @@ class SearchRequest extends LDAPMessage {
|
|||
}
|
||||
}
|
||||
}
|
||||
let curBlock = stack.slice(-1)[0];
|
||||
const curBlock = stack.slice(-1)[0];
|
||||
if (curBlock) {
|
||||
curBlock.valueBlock.value.push(block);
|
||||
} else {
|
||||
|
@ -534,22 +534,22 @@ class LDAPResponse extends LDAPMessage {
|
|||
* @returns {LDAPResponse} A concrete instance of LDAPResponse subclass.
|
||||
*/
|
||||
static fromBER(buffer) {
|
||||
let decoded = asn1js.fromBER(buffer);
|
||||
const decoded = asn1js.fromBER(buffer);
|
||||
if (decoded.offset == -1 || decoded.result.error) {
|
||||
throw Components.Exception(
|
||||
decoded.result.error,
|
||||
Cr.NS_ERROR_CANNOT_CONVERT_DATA
|
||||
);
|
||||
}
|
||||
let value = decoded.result.valueBlock.value;
|
||||
let protocolOp = value[1];
|
||||
const value = decoded.result.valueBlock.value;
|
||||
const protocolOp = value[1];
|
||||
if (protocolOp.idBlock.tagClass != this.TAG_CLASS_APPLICATION) {
|
||||
throw Components.Exception(
|
||||
`Unexpected tagClass ${protocolOp.idBlock.tagClass}`,
|
||||
Cr.NS_ERROR_ILLEGAL_VALUE
|
||||
);
|
||||
}
|
||||
let ProtocolOp = this._getResponseClassFromTagNumber(
|
||||
const ProtocolOp = this._getResponseClassFromTagNumber(
|
||||
protocolOp.idBlock.tagNumber
|
||||
);
|
||||
if (!ProtocolOp) {
|
||||
|
@ -558,7 +558,7 @@ class LDAPResponse extends LDAPMessage {
|
|||
Cr.NS_ERROR_ILLEGAL_VALUE
|
||||
);
|
||||
}
|
||||
let op = new ProtocolOp(
|
||||
const op = new ProtocolOp(
|
||||
value[0].valueBlock.valueDec,
|
||||
protocolOp,
|
||||
decoded.offset
|
||||
|
@ -573,10 +573,10 @@ class LDAPResponse extends LDAPMessage {
|
|||
* need to implement this function.
|
||||
*/
|
||||
parse() {
|
||||
let value = this.protocolOp.valueBlock.value;
|
||||
let resultCode = value[0].valueBlock.valueDec;
|
||||
let matchedDN = new TextDecoder().decode(value[1].valueBlock.valueHex);
|
||||
let diagnosticMessage = new TextDecoder().decode(
|
||||
const value = this.protocolOp.valueBlock.value;
|
||||
const resultCode = value[0].valueBlock.valueDec;
|
||||
const matchedDN = new TextDecoder().decode(value[1].valueBlock.valueHex);
|
||||
const diagnosticMessage = new TextDecoder().decode(
|
||||
value[2].valueBlock.valueHex
|
||||
);
|
||||
this.result = new LDAPResult(resultCode, matchedDN, diagnosticMessage);
|
||||
|
@ -588,7 +588,7 @@ class BindResponse extends LDAPResponse {
|
|||
|
||||
parse() {
|
||||
super.parse();
|
||||
let serverSaslCredsBlock = this.protocolOp.valueBlock.value[3];
|
||||
const serverSaslCredsBlock = this.protocolOp.valueBlock.value[3];
|
||||
if (serverSaslCredsBlock) {
|
||||
this.result.serverSaslCreds = serverSaslCredsBlock.valueBlock.valueHex;
|
||||
}
|
||||
|
@ -599,13 +599,15 @@ class SearchResultEntry extends LDAPResponse {
|
|||
static APPLICATION = 4;
|
||||
|
||||
parse() {
|
||||
let value = this.protocolOp.valueBlock.value;
|
||||
let objectName = new TextDecoder().decode(value[0].valueBlock.valueHex);
|
||||
let attributes = {};
|
||||
for (let attr of value[1].valueBlock.value) {
|
||||
let attrValue = attr.valueBlock.value;
|
||||
let type = new TextDecoder().decode(attrValue[0].valueBlock.valueHex);
|
||||
let vals = attrValue[1].valueBlock.value.map(v => v.valueBlock.valueHex);
|
||||
const value = this.protocolOp.valueBlock.value;
|
||||
const objectName = new TextDecoder().decode(value[0].valueBlock.valueHex);
|
||||
const attributes = {};
|
||||
for (const attr of value[1].valueBlock.value) {
|
||||
const attrValue = attr.valueBlock.value;
|
||||
const type = new TextDecoder().decode(attrValue[0].valueBlock.valueHex);
|
||||
const vals = attrValue[1].valueBlock.value.map(
|
||||
v => v.valueBlock.valueHex
|
||||
);
|
||||
attributes[type] = vals;
|
||||
}
|
||||
this.result = { objectName, attributes };
|
||||
|
@ -620,7 +622,7 @@ class SearchResultReference extends LDAPResponse {
|
|||
static APPLICATION = 19;
|
||||
|
||||
parse() {
|
||||
let value = this.protocolOp.valueBlock.value;
|
||||
const value = this.protocolOp.valueBlock.value;
|
||||
this.result = value.map(block =>
|
||||
new TextDecoder().decode(block.valueBlock.valueHex)
|
||||
);
|
||||
|
|
|
@ -164,9 +164,9 @@ class LDAPOperation {
|
|||
*/
|
||||
_searchReference(urlStr) {
|
||||
this._searchingReference = true;
|
||||
let urlParser = Cc["@mozilla.org/network/ldap-url-parser;1"].createInstance(
|
||||
Ci.nsILDAPURLParser
|
||||
);
|
||||
const urlParser = Cc[
|
||||
"@mozilla.org/network/ldap-url-parser;1"
|
||||
].createInstance(Ci.nsILDAPURLParser);
|
||||
let url;
|
||||
try {
|
||||
url = urlParser.parse(urlStr);
|
||||
|
|
|
@ -13,7 +13,7 @@ class LDAPProtocolHandler {
|
|||
scheme = "ldap";
|
||||
|
||||
newChannel(aURI, aLoadInfo) {
|
||||
let channel = Cc["@mozilla.org/network/ldap-channel;1"].createInstance(
|
||||
const channel = Cc["@mozilla.org/network/ldap-channel;1"].createInstance(
|
||||
Ci.nsIChannel
|
||||
);
|
||||
channel.init(aURI);
|
||||
|
|
|
@ -95,7 +95,7 @@ class LDAPReplicationService extends LDAPListenerBase {
|
|||
*/
|
||||
_actionOnBindSuccess() {
|
||||
this._openABForReplicationDir();
|
||||
let ldapUrl = this._directory.lDAPURL;
|
||||
const ldapUrl = this._directory.lDAPURL;
|
||||
this._operation.init(this._connection, this, null);
|
||||
this._listener.onStateChange(
|
||||
null,
|
||||
|
@ -126,9 +126,9 @@ class LDAPReplicationService extends LDAPListenerBase {
|
|||
* @param {nsILDAPMessage} msg - The received LDAP message.
|
||||
*/
|
||||
async _onLDAPSearchEntry(msg) {
|
||||
let newCard = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
const newCard = Cc[
|
||||
"@mozilla.org/addressbook/cardproperty;1"
|
||||
].createInstance(Ci.nsIAbCard);
|
||||
this._attrMap.setCardPropertiesFromLDAPMessage(msg, newCard);
|
||||
this._cards.push(newCard);
|
||||
this._count++;
|
||||
|
|
|
@ -11,7 +11,7 @@ class LDAPService {
|
|||
QueryInterface = ChromeUtils.generateQI(["nsILDAPService"]);
|
||||
|
||||
createFilter(maxSize, pattern, prefix, suffix, attr, value) {
|
||||
let words = value.split(" ");
|
||||
const words = value.split(" ");
|
||||
// Get the Mth to Nth words.
|
||||
function getMtoN(m, n) {
|
||||
n = n || m;
|
||||
|
@ -21,14 +21,14 @@ class LDAPService {
|
|||
let filter = prefix;
|
||||
pattern.replaceAll("%a", attr);
|
||||
while (pattern) {
|
||||
let index = pattern.indexOf("%v");
|
||||
const index = pattern.indexOf("%v");
|
||||
if (index == -1) {
|
||||
filter += pattern;
|
||||
pattern = "";
|
||||
} else {
|
||||
filter += pattern.slice(0, index);
|
||||
// Get the three characters after %v.
|
||||
let [c1, c2, c3] = pattern.slice(index + 2, index + 5);
|
||||
const [c1, c2, c3] = pattern.slice(index + 2, index + 5);
|
||||
if (c1 >= "1" && c1 <= "9") {
|
||||
if (c2 == "$") {
|
||||
// %v$: means the last word
|
||||
|
|
|
@ -94,8 +94,8 @@ class LDAPSyncQuery {
|
|||
* @param {nsILDAPMessage} msg - The received LDAP message.
|
||||
*/
|
||||
_onLDAPSearchEntry(msg) {
|
||||
for (let attr of msg.getAttributes()) {
|
||||
for (let value of msg.getValues(attr)) {
|
||||
for (const attr of msg.getAttributes()) {
|
||||
for (const value of msg.getValues(attr)) {
|
||||
this._result += `\n${attr}=${value}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class LDAPURLParser {
|
|||
parse(spec) {
|
||||
// The url is in the form of scheme://hostport/dn?attributes?scope?filter,
|
||||
// see RFC2255.
|
||||
let matches =
|
||||
const matches =
|
||||
/^(ldaps?):\/\/\[?([^\s\]/]+)\]?:?(\d*)\/([^\s?]*)\??(.*)$/.exec(spec);
|
||||
if (!matches) {
|
||||
throw Components.Exception(
|
||||
|
@ -21,9 +21,9 @@ class LDAPURLParser {
|
|||
Cr.NS_ERROR_ILLEGAL_VALUE
|
||||
);
|
||||
}
|
||||
let [, scheme, host, port, dn, query] = matches;
|
||||
let [attributes, scopeString, filter] = query.split("?");
|
||||
let scope =
|
||||
const [, scheme, host, port, dn, query] = matches;
|
||||
const [attributes, scopeString, filter] = query.split("?");
|
||||
const scope =
|
||||
{
|
||||
one: Ci.nsILDAPURL.SCOPE_ONELEVEL,
|
||||
sub: Ci.nsILDAPURL.SCOPE_SUBTREE,
|
||||
|
|
|
@ -28,12 +28,12 @@ var QueryStringToExpression = {
|
|||
* @returns {nsIAbBooleanExpression}
|
||||
*/
|
||||
convert(qs) {
|
||||
let tokens = this.parse(qs);
|
||||
const tokens = this.parse(qs);
|
||||
|
||||
// An array of nsIAbBooleanExpression, the first element is the root exp,
|
||||
// the last element is the current operating exp.
|
||||
let stack = [];
|
||||
for (let { type, depth, value } of tokens) {
|
||||
const stack = [];
|
||||
for (const { type, depth, value } of tokens) {
|
||||
while (depth < stack.length) {
|
||||
// We are done with the current exp, go one level up.
|
||||
stack.pop();
|
||||
|
@ -44,16 +44,16 @@ var QueryStringToExpression = {
|
|||
stack.pop();
|
||||
}
|
||||
// Found a new exp, go one level down.
|
||||
let parent = stack.slice(-1)[0];
|
||||
let exp = this.createBooleanExpression(value);
|
||||
const parent = stack.slice(-1)[0];
|
||||
const exp = this.createBooleanExpression(value);
|
||||
stack.push(exp);
|
||||
if (parent) {
|
||||
parent.expressions = [...parent.expressions, exp];
|
||||
}
|
||||
} else if (type == "field") {
|
||||
// Add a new nsIAbBooleanConditionString to the current exp.
|
||||
let condition = this.createBooleanConditionString(...value);
|
||||
let exp = stack.slice(-1)[0];
|
||||
const condition = this.createBooleanConditionString(...value);
|
||||
const exp = stack.slice(-1)[0];
|
||||
exp.expressions = [...exp.expressions, condition];
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ var QueryStringToExpression = {
|
|||
);
|
||||
}
|
||||
qs = qs.slice(1);
|
||||
let nextOpen = qs.indexOf("(");
|
||||
let nextClose = qs.indexOf(")");
|
||||
const nextOpen = qs.indexOf("(");
|
||||
const nextClose = qs.indexOf(")");
|
||||
|
||||
if (nextOpen != -1 && nextOpen < nextClose) {
|
||||
// Case: "OP("
|
||||
|
@ -121,7 +121,7 @@ var QueryStringToExpression = {
|
|||
* @returns {nsIAbBooleanExpression}
|
||||
*/
|
||||
createBooleanExpression(operation) {
|
||||
let op = {
|
||||
const op = {
|
||||
and: Ci.nsIAbBooleanOperationTypes.AND,
|
||||
or: Ci.nsIAbBooleanOperationTypes.OR,
|
||||
not: Ci.nsIAbBooleanOperationTypes.NOT,
|
||||
|
@ -132,7 +132,7 @@ var QueryStringToExpression = {
|
|||
Cr.NS_ERROR_ILLEGAL_VALUE
|
||||
);
|
||||
}
|
||||
let exp = Cc["@mozilla.org/boolean-expression/n-peer;1"].createInstance(
|
||||
const exp = Cc["@mozilla.org/boolean-expression/n-peer;1"].createInstance(
|
||||
Ci.nsIAbBooleanExpression
|
||||
);
|
||||
exp.operation = op;
|
||||
|
@ -149,7 +149,7 @@ var QueryStringToExpression = {
|
|||
*/
|
||||
createBooleanConditionString(name, condition, value) {
|
||||
value = decodeURIComponent(value);
|
||||
let cond = {
|
||||
const cond = {
|
||||
"=": Ci.nsIAbBooleanConditionTypes.Is,
|
||||
"!=": Ci.nsIAbBooleanConditionTypes.IsNot,
|
||||
lt: Ci.nsIAbBooleanConditionTypes.LessThan,
|
||||
|
@ -169,7 +169,7 @@ var QueryStringToExpression = {
|
|||
Cr.NS_ERROR_ILLEGAL_VALUE
|
||||
);
|
||||
}
|
||||
let cs = Cc[
|
||||
const cs = Cc[
|
||||
"@mozilla.org/boolean-expression/condition-string;1"
|
||||
].createInstance(Ci.nsIAbBooleanConditionString);
|
||||
cs.condition = cond;
|
||||
|
|
|
@ -48,11 +48,11 @@ function openConnectionTo(file) {
|
|||
let connection = connections.get(file.path);
|
||||
if (!connection) {
|
||||
connection = Services.storage.openDatabase(file);
|
||||
let fileVersion = connection.schemaVersion;
|
||||
const fileVersion = connection.schemaVersion;
|
||||
|
||||
// If we're upgrading the version, first create a backup.
|
||||
if (fileVersion > 0 && fileVersion < CURRENT_VERSION) {
|
||||
let backupFile = file.clone();
|
||||
const backupFile = file.clone();
|
||||
backupFile.leafName = backupFile.leafName.replace(
|
||||
/\.sqlite$/,
|
||||
`.v${fileVersion}.sqlite`
|
||||
|
@ -104,7 +104,7 @@ function openConnectionTo(file) {
|
|||
* Closes the SQLite connection to `file` and removes it from the cache.
|
||||
*/
|
||||
function closeConnectionTo(file) {
|
||||
let connection = connections.get(file.path);
|
||||
const connection = connections.get(file.path);
|
||||
if (connection) {
|
||||
return new Promise(resolve => {
|
||||
connection.asyncClose({
|
||||
|
@ -122,8 +122,8 @@ function closeConnectionTo(file) {
|
|||
AsyncShutdown.profileBeforeChange.addBlocker(
|
||||
"Address Book: closing databases",
|
||||
async () => {
|
||||
let promises = [];
|
||||
for (let directory of directories.values()) {
|
||||
const promises = [];
|
||||
for (const directory of directories.values()) {
|
||||
promises.push(directory.cleanUp());
|
||||
}
|
||||
await Promise.allSettled(promises);
|
||||
|
@ -142,7 +142,7 @@ Services.obs.addObserver(async file => {
|
|||
*/
|
||||
class SQLiteDirectory extends AddrBookDirectory {
|
||||
init(uri) {
|
||||
let uriParts = /^[\w-]+:\/\/([\w\.-]+\.\w+)$/.exec(uri);
|
||||
const uriParts = /^[\w-]+:\/\/([\w\.-]+\.\w+)$/.exec(uri);
|
||||
if (!uriParts) {
|
||||
throw new Components.Exception(
|
||||
`Unexpected uri: ${uri}`,
|
||||
|
@ -156,7 +156,7 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
fileName = fileName.substring(0, fileName.indexOf("/"));
|
||||
}
|
||||
|
||||
for (let child of Services.prefs.getChildList("ldap_2.servers.")) {
|
||||
for (const child of Services.prefs.getChildList("ldap_2.servers.")) {
|
||||
if (
|
||||
child.endsWith(".filename") &&
|
||||
Services.prefs.getStringPref(child) == fileName
|
||||
|
@ -174,7 +174,7 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
|
||||
// Make sure we always have a file. If a file is not created, the
|
||||
// filename may be accidentally reused.
|
||||
let file = new lazy.FileUtils.File(
|
||||
const file = new lazy.FileUtils.File(
|
||||
PathUtils.join(PathUtils.profileDir, fileName)
|
||||
);
|
||||
if (!file.exists()) {
|
||||
|
@ -204,7 +204,7 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
this._file = new lazy.FileUtils.File(
|
||||
PathUtils.join(PathUtils.profileDir, this.fileName)
|
||||
);
|
||||
let connection = openConnectionTo(this._file);
|
||||
const connection = openConnectionTo(this._file);
|
||||
|
||||
// SQLite cache size can be set by the cacheSize preference, in KiB.
|
||||
// The default is 5 MiB but this can be lowered to 1 MiB if wanted.
|
||||
|
@ -221,8 +221,8 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
return connection;
|
||||
}
|
||||
get lists() {
|
||||
let listCache = new Map();
|
||||
let selectStatement = this._dbConnection.createStatement(
|
||||
const listCache = new Map();
|
||||
const selectStatement = this._dbConnection.createStatement(
|
||||
"SELECT uid, name, nickName, description FROM lists"
|
||||
);
|
||||
while (selectStatement.executeStep()) {
|
||||
|
@ -243,16 +243,16 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
return listCache;
|
||||
}
|
||||
get cards() {
|
||||
let cardCache = new Map();
|
||||
let propertiesStatement = this._dbConnection.createStatement(
|
||||
const cardCache = new Map();
|
||||
const propertiesStatement = this._dbConnection.createStatement(
|
||||
"SELECT card, name, value FROM properties"
|
||||
);
|
||||
while (propertiesStatement.executeStep()) {
|
||||
let uid = propertiesStatement.row.card;
|
||||
const uid = propertiesStatement.row.card;
|
||||
if (!cardCache.has(uid)) {
|
||||
cardCache.set(uid, new Map());
|
||||
}
|
||||
let card = cardCache.get(uid);
|
||||
const card = cardCache.get(uid);
|
||||
if (card) {
|
||||
card.set(propertiesStatement.row.name, propertiesStatement.row.value);
|
||||
}
|
||||
|
@ -269,13 +269,13 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
|
||||
loadCardProperties(uid) {
|
||||
if (this.hasOwnProperty("cards")) {
|
||||
let cachedCard = this.cards.get(uid);
|
||||
const cachedCard = this.cards.get(uid);
|
||||
if (cachedCard) {
|
||||
return new Map(cachedCard);
|
||||
}
|
||||
}
|
||||
let properties = new Map();
|
||||
let propertyStatement = this._dbConnection.createStatement(
|
||||
const properties = new Map();
|
||||
const propertyStatement = this._dbConnection.createStatement(
|
||||
"SELECT name, value FROM properties WHERE card = :card"
|
||||
);
|
||||
propertyStatement.params.card = uid;
|
||||
|
@ -288,16 +288,16 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
saveCardProperties(uid, properties) {
|
||||
try {
|
||||
this._dbConnection.beginTransaction();
|
||||
let deleteStatement = this._dbConnection.createStatement(
|
||||
const deleteStatement = this._dbConnection.createStatement(
|
||||
"DELETE FROM properties WHERE card = :card"
|
||||
);
|
||||
deleteStatement.params.card = uid;
|
||||
deleteStatement.execute();
|
||||
let insertStatement = this._dbConnection.createStatement(
|
||||
const insertStatement = this._dbConnection.createStatement(
|
||||
"INSERT INTO properties VALUES (:card, :name, :value)"
|
||||
);
|
||||
|
||||
for (let [name, value] of properties) {
|
||||
for (const [name, value] of properties) {
|
||||
if (value !== null && value !== undefined && value !== "") {
|
||||
insertStatement.params.card = uid;
|
||||
insertStatement.params.name = name;
|
||||
|
@ -316,7 +316,7 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
}
|
||||
}
|
||||
deleteCard(uid) {
|
||||
let deleteStatement = this._dbConnection.createStatement(
|
||||
const deleteStatement = this._dbConnection.createStatement(
|
||||
"DELETE FROM properties WHERE card = :cardUID"
|
||||
);
|
||||
deleteStatement.params.cardUID = uid;
|
||||
|
@ -327,7 +327,7 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
// Ensure list cache exists.
|
||||
this.lists;
|
||||
|
||||
let replaceStatement = this._dbConnection.createStatement(
|
||||
const replaceStatement = this._dbConnection.createStatement(
|
||||
"REPLACE INTO lists (uid, name, nickName, description) " +
|
||||
"VALUES (:uid, :name, :nickName, :description)"
|
||||
);
|
||||
|
@ -346,7 +346,7 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
});
|
||||
}
|
||||
deleteList(uid) {
|
||||
let deleteListStatement = this._dbConnection.createStatement(
|
||||
const deleteListStatement = this._dbConnection.createStatement(
|
||||
"DELETE FROM lists WHERE uid = :uid"
|
||||
);
|
||||
deleteListStatement.params.uid = uid;
|
||||
|
@ -366,12 +366,12 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
return;
|
||||
}
|
||||
|
||||
let usedUIDs = new Set();
|
||||
let propertiesStatement = this._dbConnection.createStatement(
|
||||
const usedUIDs = new Set();
|
||||
const propertiesStatement = this._dbConnection.createStatement(
|
||||
"INSERT INTO properties VALUES (:card, :name, :value)"
|
||||
);
|
||||
let propertiesArray = propertiesStatement.newBindingParamsArray();
|
||||
for (let card of cards) {
|
||||
const propertiesArray = propertiesStatement.newBindingParamsArray();
|
||||
for (const card of cards) {
|
||||
let uid = card.UID;
|
||||
if (!uid || usedUIDs.has(uid)) {
|
||||
// A card cannot have the same UID as one that already exists.
|
||||
|
@ -386,8 +386,8 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
this.cards.set(uid, cachedCard);
|
||||
}
|
||||
|
||||
for (let [name, value] of this.prepareToSaveCard(card)) {
|
||||
let propertiesParams = propertiesArray.newBindingParams();
|
||||
for (const [name, value] of this.prepareToSaveCard(card)) {
|
||||
const propertiesParams = propertiesArray.newBindingParams();
|
||||
propertiesParams.bindByName("card", uid);
|
||||
propertiesParams.bindByName("name", name);
|
||||
propertiesParams.bindByName("value", value);
|
||||
|
@ -432,19 +432,19 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
/* nsIAbDirectory */
|
||||
|
||||
get childCardCount() {
|
||||
let countStatement = this._dbConnection.createStatement(
|
||||
const countStatement = this._dbConnection.createStatement(
|
||||
"SELECT COUNT(DISTINCT card) AS card_count FROM properties"
|
||||
);
|
||||
countStatement.executeStep();
|
||||
let count = countStatement.row.card_count;
|
||||
const count = countStatement.row.card_count;
|
||||
countStatement.finalize();
|
||||
return count;
|
||||
}
|
||||
getCardFromProperty(property, value, caseSensitive) {
|
||||
let sql = caseSensitive
|
||||
const sql = caseSensitive
|
||||
? "SELECT card FROM properties WHERE name = :name AND value = :value LIMIT 1"
|
||||
: "SELECT card FROM properties WHERE name = :name AND LOWER(value) = LOWER(:value) LIMIT 1";
|
||||
let selectStatement = this._dbConnection.createStatement(sql);
|
||||
const selectStatement = this._dbConnection.createStatement(sql);
|
||||
selectStatement.params.name = property;
|
||||
selectStatement.params.value = value;
|
||||
let result = null;
|
||||
|
@ -455,13 +455,13 @@ class SQLiteDirectory extends AddrBookDirectory {
|
|||
return result;
|
||||
}
|
||||
getCardsFromProperty(property, value, caseSensitive) {
|
||||
let sql = caseSensitive
|
||||
const sql = caseSensitive
|
||||
? "SELECT card FROM properties WHERE name = :name AND value = :value"
|
||||
: "SELECT card FROM properties WHERE name = :name AND LOWER(value) = LOWER(:value)";
|
||||
let selectStatement = this._dbConnection.createStatement(sql);
|
||||
const selectStatement = this._dbConnection.createStatement(sql);
|
||||
selectStatement.params.name = property;
|
||||
selectStatement.params.value = value;
|
||||
let results = [];
|
||||
const results = [];
|
||||
while (selectStatement.executeStep()) {
|
||||
results.push(this.getCard(selectStatement.row.card));
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
|
|||
|
||||
var VCardUtils = {
|
||||
_decodeQuotedPrintable(value) {
|
||||
let bytes = [];
|
||||
const bytes = [];
|
||||
for (let b = 0; b < value.length; b++) {
|
||||
if (value[b] == "=") {
|
||||
bytes.push(parseInt(value.substr(b + 1, 2), 16));
|
||||
|
@ -44,7 +44,7 @@ var VCardUtils = {
|
|||
return new TextDecoder().decode(new Uint8Array(bytes));
|
||||
},
|
||||
_parse(vProps) {
|
||||
let vPropMap = new Map();
|
||||
const vPropMap = new Map();
|
||||
for (let index = 0; index < vProps.length; index++) {
|
||||
let { name, params, value } = vProps[index];
|
||||
|
||||
|
@ -67,7 +67,7 @@ var VCardUtils = {
|
|||
}
|
||||
if (name == "tel") {
|
||||
name = "tel.work";
|
||||
for (let t of type) {
|
||||
for (const t of type) {
|
||||
if (["home", "work", "cell", "pager", "fax"].includes(t)) {
|
||||
name = `tel.${t}`;
|
||||
break;
|
||||
|
@ -87,7 +87,7 @@ var VCardUtils = {
|
|||
|
||||
// The preference param is 1-100, lower numbers indicate higher
|
||||
// preference. If not specified, the value is least preferred.
|
||||
let pref = parseInt(params.pref, 10) || 101;
|
||||
const pref = parseInt(params.pref, 10) || 101;
|
||||
|
||||
if (!vPropMap.has(name)) {
|
||||
vPropMap.set(name, []);
|
||||
|
@ -102,7 +102,7 @@ var VCardUtils = {
|
|||
// AbCard only supports Work Web Page or Home Web Page. Get rid of the URL without type.
|
||||
vPropMap.delete("url");
|
||||
|
||||
for (let props of vPropMap.values()) {
|
||||
for (const props of vPropMap.values()) {
|
||||
// Sort the properties by preference, or by the order they appeared.
|
||||
props.sort((a, b) => {
|
||||
if (a.pref == b.pref) {
|
||||
|
@ -129,8 +129,8 @@ var VCardUtils = {
|
|||
|
||||
// Convert known type parameters to valid vCard 4.0, ignore unknown ones.
|
||||
vCard = vCard.replace(/\n(([A-Z]+)(;[\w-]*)+):/gi, (match, key) => {
|
||||
let parts = key.split(";");
|
||||
let newParts = [parts[0]];
|
||||
const parts = key.split(";");
|
||||
const newParts = [parts[0]];
|
||||
for (let i = 1; i < parts.length; i++) {
|
||||
if (parts[i] == "") {
|
||||
continue;
|
||||
|
@ -152,7 +152,8 @@ var VCardUtils = {
|
|||
|
||||
// Join quoted-printable wrapped lines together. This regular expression
|
||||
// only matches lines that are quoted-printable and end with `=`.
|
||||
let quotedNewLineRegExp = /(;ENCODING=QUOTED-PRINTABLE[;:][^\r\n]*)=\r?\n/i;
|
||||
const quotedNewLineRegExp =
|
||||
/(;ENCODING=QUOTED-PRINTABLE[;:][^\r\n]*)=\r?\n/i;
|
||||
while (vCard.match(quotedNewLineRegExp)) {
|
||||
vCard = vCard.replace(quotedNewLineRegExp, "$1");
|
||||
}
|
||||
|
@ -171,10 +172,10 @@ var VCardUtils = {
|
|||
vCardToAbCard(vCard, uid) {
|
||||
vCard = this.translateVCard21(vCard);
|
||||
|
||||
let abCard = new lazy.AddrBookCard();
|
||||
const abCard = new lazy.AddrBookCard();
|
||||
abCard.setProperty("_vCard", vCard);
|
||||
|
||||
let vCardUID = abCard.vCardProperties.getFirstValue("uid");
|
||||
const vCardUID = abCard.vCardProperties.getFirstValue("uid");
|
||||
if (uid || vCardUID) {
|
||||
abCard.UID = uid || vCardUID;
|
||||
if (abCard.UID != vCardUID) {
|
||||
|
@ -191,7 +192,7 @@ var VCardUtils = {
|
|||
}
|
||||
|
||||
// Collect all of the AB card properties into a Map.
|
||||
let abProps = new Map(
|
||||
const abProps = new Map(
|
||||
Array.from(abCard.properties, p => [p.name, p.value])
|
||||
);
|
||||
abProps.set("UID", abCard.UID);
|
||||
|
@ -199,11 +200,11 @@ var VCardUtils = {
|
|||
return this.propertyMapToVCard(abProps, version);
|
||||
},
|
||||
propertyMapToVCard(abProps, version = "4.0") {
|
||||
let vProps = [["version", {}, "text", version]];
|
||||
const vProps = [["version", {}, "text", version]];
|
||||
|
||||
// Add the properties to the vCard.
|
||||
for (let vPropName of Object.keys(typeMap)) {
|
||||
for (let vProp of typeMap[vPropName].fromAbCard(abProps, vPropName)) {
|
||||
for (const vPropName of Object.keys(typeMap)) {
|
||||
for (const vProp of typeMap[vPropName].fromAbCard(abProps, vPropName)) {
|
||||
if (vProp[3] !== null && vProp[3] !== undefined && vProp[3] !== "") {
|
||||
vProps.push(vProp);
|
||||
}
|
||||
|
@ -211,11 +212,11 @@ var VCardUtils = {
|
|||
}
|
||||
|
||||
// If there's only one address or telephone number, don't specify type.
|
||||
let adrProps = vProps.filter(p => p[0] == "adr");
|
||||
const adrProps = vProps.filter(p => p[0] == "adr");
|
||||
if (adrProps.length == 1) {
|
||||
delete adrProps[0][1].type;
|
||||
}
|
||||
let telProps = vProps.filter(p => p[0] == "tel");
|
||||
const telProps = vProps.filter(p => p[0] == "tel");
|
||||
if (telProps.length == 1) {
|
||||
delete telProps[0][1].type;
|
||||
}
|
||||
|
@ -252,7 +253,7 @@ VCardMimeConverter.prototype = {
|
|||
uri: null,
|
||||
convertToHTML(contentType, data) {
|
||||
function escapeHTML(template, ...parts) {
|
||||
let arr = [];
|
||||
const arr = [];
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
arr.push(template[i]);
|
||||
arr.push(
|
||||
|
@ -275,7 +276,7 @@ VCardMimeConverter.prototype = {
|
|||
return "";
|
||||
}
|
||||
|
||||
let escapedVCard = encodeURIComponent(data);
|
||||
const escapedVCard = encodeURIComponent(data);
|
||||
|
||||
let propertiesTable = `<table class="moz-vcard-properties-table">`;
|
||||
propertiesTable += escapeHTML`<tr><td class="moz-vcard-title-property">${abCard.displayName}`;
|
||||
|
@ -283,8 +284,8 @@ VCardMimeConverter.prototype = {
|
|||
propertiesTable += escapeHTML` <<a href="mailto:${abCard.primaryEmail}" private>${abCard.primaryEmail}</a>>`;
|
||||
}
|
||||
propertiesTable += `</td></tr>`;
|
||||
for (let propName of ["JobTitle", "Department", "Company"]) {
|
||||
let propValue = abCard.getProperty(propName, "");
|
||||
for (const propName of ["JobTitle", "Department", "Company"]) {
|
||||
const propValue = abCard.getProperty(propName, "");
|
||||
if (propValue) {
|
||||
propertiesTable += escapeHTML`<tr><td class="moz-vcard-property">${propValue}</td></tr>`;
|
||||
}
|
||||
|
@ -391,15 +392,15 @@ function singleTextProperty(
|
|||
function dateProperty(abCardPrefix, vPropName) {
|
||||
return {
|
||||
*fromAbCard(map) {
|
||||
let year = map.get(`${abCardPrefix}Year`);
|
||||
let month = map.get(`${abCardPrefix}Month`);
|
||||
let day = map.get(`${abCardPrefix}Day`);
|
||||
const year = map.get(`${abCardPrefix}Year`);
|
||||
const month = map.get(`${abCardPrefix}Month`);
|
||||
const day = map.get(`${abCardPrefix}Day`);
|
||||
|
||||
if (!year && !month && !day) {
|
||||
return;
|
||||
}
|
||||
|
||||
let dateValue = new ICAL.VCardTime({}, null, "date");
|
||||
const dateValue = new ICAL.VCardTime({}, null, "date");
|
||||
// Set the properties directly instead of using the VCardTime
|
||||
// constructor argument, which causes null values to become 0.
|
||||
dateValue.year = year ? Number(year) : null;
|
||||
|
@ -410,7 +411,7 @@ function dateProperty(abCardPrefix, vPropName) {
|
|||
},
|
||||
*toAbCard(value) {
|
||||
try {
|
||||
let dateValue = ICAL.VCardTime.fromDateAndOrTimeString(value);
|
||||
const dateValue = ICAL.VCardTime.fromDateAndOrTimeString(value);
|
||||
yield [`${abCardPrefix}Year`, String(dateValue.year ?? "")];
|
||||
yield [`${abCardPrefix}Month`, String(dateValue.month ?? "")];
|
||||
yield [`${abCardPrefix}Day`, String(dateValue.day ?? "")];
|
||||
|
@ -426,15 +427,15 @@ function multiTextProperty(abPropNames, vPropName, vPropParams = {}) {
|
|||
if (abPropNames.every(name => !map.has(name))) {
|
||||
return;
|
||||
}
|
||||
let vPropValues = abPropNames.map(name => map.get(name) || "");
|
||||
const vPropValues = abPropNames.map(name => map.get(name) || "");
|
||||
if (vPropValues.some(Boolean)) {
|
||||
yield [vPropName, { ...vPropParams }, "text", vPropValues];
|
||||
}
|
||||
},
|
||||
*toAbCard(value) {
|
||||
if (Array.isArray(value)) {
|
||||
for (let abPropName of abPropNames) {
|
||||
let valuePart = value.shift();
|
||||
for (const abPropName of abPropNames) {
|
||||
const valuePart = value.shift();
|
||||
if (abPropName && valuePart) {
|
||||
yield [
|
||||
abPropName,
|
||||
|
@ -613,7 +614,7 @@ class VCardPropertyEntry {
|
|||
cloneValue = this.#value;
|
||||
}
|
||||
|
||||
let clone = new VCardPropertyEntry(
|
||||
const clone = new VCardPropertyEntry(
|
||||
this.#name,
|
||||
{ ...this.#params },
|
||||
this.#type,
|
||||
|
@ -667,9 +668,9 @@ class VCardProperties {
|
|||
static fromVCard(vCard, { isGoogleCardDAV = false } = {}) {
|
||||
vCard = VCardUtils.translateVCard21(vCard);
|
||||
|
||||
let rv = new VCardProperties();
|
||||
let [, properties] = ICAL.parse(vCard);
|
||||
for (let property of properties) {
|
||||
const rv = new VCardProperties();
|
||||
const [, properties] = ICAL.parse(vCard);
|
||||
for (const property of properties) {
|
||||
let [name, params, type, value] = property;
|
||||
if (property.length > 4) {
|
||||
// The jCal format stores multiple values as the 4th...nth items.
|
||||
|
@ -704,10 +705,13 @@ class VCardProperties {
|
|||
* @returns {VCardProperties}
|
||||
*/
|
||||
static fromPropertyMap(propertyMap, version = "4.0") {
|
||||
let rv = new VCardProperties(version);
|
||||
const rv = new VCardProperties(version);
|
||||
|
||||
for (let vPropName of Object.keys(typeMap)) {
|
||||
for (let vProp of typeMap[vPropName].fromAbCard(propertyMap, vPropName)) {
|
||||
for (const vPropName of Object.keys(typeMap)) {
|
||||
for (const vProp of typeMap[vPropName].fromAbCard(
|
||||
propertyMap,
|
||||
vPropName
|
||||
)) {
|
||||
if (vProp[3] !== null && vProp[3] !== undefined && vProp[3] !== "") {
|
||||
rv.addEntry(new VCardPropertyEntry(...vProp));
|
||||
}
|
||||
|
@ -767,13 +771,13 @@ class VCardProperties {
|
|||
* @returns {VCardPropertyEntry}
|
||||
*/
|
||||
addValue(name, value) {
|
||||
for (let entry of this.getAllEntries(name)) {
|
||||
for (const entry of this.getAllEntries(name)) {
|
||||
if (entry.value == value) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
let newEntry = new VCardPropertyEntry(
|
||||
const newEntry = new VCardPropertyEntry(
|
||||
name,
|
||||
{},
|
||||
this.designSet.property[name].defaultType,
|
||||
|
@ -794,7 +798,7 @@ class VCardProperties {
|
|||
throw new Error("Not a VCardPropertyEntry");
|
||||
}
|
||||
|
||||
let index = this.entries.findIndex(e => e.equals(entry));
|
||||
const index = this.entries.findIndex(e => e.equals(entry));
|
||||
if (index >= 0) {
|
||||
this.entries.splice(index, 1);
|
||||
return true;
|
||||
|
@ -810,7 +814,7 @@ class VCardProperties {
|
|||
* @param {string} value
|
||||
*/
|
||||
removeValue(name, value) {
|
||||
for (let entry of this.getAllEntries(name)) {
|
||||
for (const entry of this.getAllEntries(name)) {
|
||||
if (entry.value == value) {
|
||||
this.removeEntry(entry);
|
||||
}
|
||||
|
@ -824,7 +828,7 @@ class VCardProperties {
|
|||
* @param {string} name
|
||||
*/
|
||||
clearValues(name) {
|
||||
for (let entry of this.getAllEntries(name)) {
|
||||
for (const entry of this.getAllEntries(name)) {
|
||||
this.removeEntry(entry);
|
||||
}
|
||||
}
|
||||
|
@ -836,7 +840,7 @@ class VCardProperties {
|
|||
* @returns {?vCardValue}
|
||||
*/
|
||||
getFirstValue(name) {
|
||||
let entry = this.entries.find(e => e.name == name);
|
||||
const entry = this.entries.find(e => e.name == name);
|
||||
if (entry) {
|
||||
return entry.value;
|
||||
}
|
||||
|
@ -895,7 +899,7 @@ class VCardProperties {
|
|||
*/
|
||||
getAllEntriesSorted(name) {
|
||||
let nextPref = 101;
|
||||
let entries = this.getAllEntries(name).map(e => {
|
||||
const entries = this.getAllEntries(name).map(e => {
|
||||
return { entry: e, pref: e.params.pref || nextPref++ };
|
||||
});
|
||||
entries.sort((a, b) => a.pref - b.pref);
|
||||
|
@ -918,7 +922,7 @@ class VCardProperties {
|
|||
* @returns {VCardProperties}
|
||||
*/
|
||||
clone() {
|
||||
let copy = new VCardProperties();
|
||||
const copy = new VCardProperties();
|
||||
copy.entries = this.entries.map(e => e.clone());
|
||||
return copy;
|
||||
}
|
||||
|
@ -929,12 +933,12 @@ class VCardProperties {
|
|||
* @returns {Map<string, string>} propertyMap
|
||||
*/
|
||||
toPropertyMap() {
|
||||
let vPropMap = VCardUtils._parse(this.entries.map(e => e.clone()));
|
||||
let propertyMap = new Map();
|
||||
const vPropMap = VCardUtils._parse(this.entries.map(e => e.clone()));
|
||||
const propertyMap = new Map();
|
||||
|
||||
for (let [name, props] of vPropMap) {
|
||||
for (const [name, props] of vPropMap) {
|
||||
// Store the value(s) on the abCard.
|
||||
for (let [abPropName, abPropValue] of typeMap[name].toAbCard(
|
||||
for (const [abPropName, abPropValue] of typeMap[name].toAbCard(
|
||||
props[0].value
|
||||
)) {
|
||||
if (abPropValue) {
|
||||
|
@ -956,9 +960,9 @@ class VCardProperties {
|
|||
* @returns {string} vCard
|
||||
*/
|
||||
toVCard() {
|
||||
let jCal = this.entries.map(e => {
|
||||
const jCal = this.entries.map(e => {
|
||||
if (Array.isArray(e.value)) {
|
||||
let design = this.designSet.property[e.name];
|
||||
const design = this.designSet.property[e.name];
|
||||
if (design.multiValue == "," && !design.structuredValue) {
|
||||
// The jCal format stores multiple values as the 4th...nth items,
|
||||
// but VCardPropertyEntry stores them as an array. This applies to
|
||||
|
|
|
@ -63,7 +63,7 @@ function Startup() {
|
|||
);
|
||||
}
|
||||
|
||||
let oldListName = gCurrentDirectory.dirName;
|
||||
const oldListName = gCurrentDirectory.dirName;
|
||||
document.title = gReplicationBundle.getFormattedString(
|
||||
"directoryTitleEdit",
|
||||
[oldListName]
|
||||
|
@ -284,7 +284,9 @@ function DisableElementIfPrefIsLocked(aPrefName, aElementId) {
|
|||
// disables all the text fields corresponding to the .uri pref.
|
||||
function DisableUriFields(aPrefName) {
|
||||
if (Services.prefs.prefIsLocked(aPrefName)) {
|
||||
let lockedElements = document.querySelectorAll('[disableiflocked="true"]');
|
||||
const lockedElements = document.querySelectorAll(
|
||||
'[disableiflocked="true"]'
|
||||
);
|
||||
for (let i = 0; i < lockedElements.length; i++) {
|
||||
lockedElements[i].setAttribute("disabled", "true");
|
||||
}
|
||||
|
@ -322,18 +324,18 @@ function hasCharacters(number) {
|
|||
|
||||
function onAccept(event) {
|
||||
try {
|
||||
let description = document.getElementById("description").value.trim();
|
||||
const description = document.getElementById("description").value.trim();
|
||||
let hostname = cleanUpHostName(document.getElementById("hostname").value);
|
||||
let port = document.getElementById("port").value;
|
||||
let secure = document.getElementById("secure");
|
||||
let results = document.getElementById("results").value;
|
||||
const secure = document.getElementById("secure");
|
||||
const results = document.getElementById("results").value;
|
||||
let errorValue = null;
|
||||
let errorArg = null;
|
||||
let saslMechanism = "";
|
||||
|
||||
let findDupeName = function (newName) {
|
||||
const findDupeName = function (newName) {
|
||||
// Do not allow an already existing name.
|
||||
for (let ab of MailServices.ab.directories) {
|
||||
for (const ab of MailServices.ab.directories) {
|
||||
if (
|
||||
ab.dirName.toLowerCase() == newName.toLowerCase() &&
|
||||
(!gCurrentDirectory || ab.URI != gCurrentDirectory.URI)
|
||||
|
@ -365,7 +367,7 @@ function onAccept(event) {
|
|||
// Wrap IPv6 address in [].
|
||||
hostname = `[${hostname}]`;
|
||||
}
|
||||
let ldapUrl = Services.io
|
||||
const ldapUrl = Services.io
|
||||
.newURI(`${secure.checked ? "ldaps" : "ldap"}://${hostname}:${port}`)
|
||||
.QueryInterface(Ci.nsILDAPURL);
|
||||
|
||||
|
@ -414,7 +416,7 @@ function onAccept(event) {
|
|||
window.arguments[0].onNewDirectory(theDirectory);
|
||||
}
|
||||
} else {
|
||||
let addressBookBundle = document.getElementById("bundle_addressBook");
|
||||
const addressBookBundle = document.getElementById("bundle_addressBook");
|
||||
|
||||
let errorText;
|
||||
if (errorArg) {
|
||||
|
|
|
@ -20,7 +20,7 @@ var gAddressBookAbListener = {
|
|||
]),
|
||||
|
||||
init() {
|
||||
for (let topic of [
|
||||
for (const topic of [
|
||||
"addrbook-directory-created",
|
||||
"addrbook-directory-updated",
|
||||
"addrbook-directory-deleted",
|
||||
|
@ -57,8 +57,8 @@ function fillDirectoryList(aItem = null) {
|
|||
}
|
||||
|
||||
// Init the address book list
|
||||
let holdingArray = [];
|
||||
for (let ab of MailServices.ab.directories) {
|
||||
const holdingArray = [];
|
||||
for (const ab of MailServices.ab.directories) {
|
||||
if (ab.isRemote) {
|
||||
holdingArray.push(ab);
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ function fillDirectoryList(aItem = null) {
|
|||
});
|
||||
|
||||
holdingArray.forEach(function (ab) {
|
||||
let item = document.createXULElement("richlistitem");
|
||||
let label = document.createXULElement("label");
|
||||
const item = document.createXULElement("richlistitem");
|
||||
const label = document.createXULElement("label");
|
||||
label.setAttribute("value", ab.dirName);
|
||||
item.appendChild(label);
|
||||
item.setAttribute("value", ab.URI);
|
||||
|
@ -98,8 +98,8 @@ function selectDirectory() {
|
|||
|
||||
// If the disable delete button pref for the selected directory is set,
|
||||
// disable the delete button for that directory.
|
||||
let ab = MailServices.ab.getDirectory(abList.value);
|
||||
let disable = Services.prefs.getBoolPref(
|
||||
const ab = MailServices.ab.getDirectory(abList.value);
|
||||
const disable = Services.prefs.getBoolPref(
|
||||
ab.dirPrefId + ".disable_delete",
|
||||
false
|
||||
);
|
||||
|
@ -134,8 +134,8 @@ function editDirectory() {
|
|||
var abList = document.getElementById("directoriesList");
|
||||
|
||||
if (abList && abList.selectedItem) {
|
||||
let abURI = abList.value;
|
||||
let ab = MailServices.ab.getDirectory(abURI);
|
||||
const abURI = abList.value;
|
||||
const ab = MailServices.ab.getDirectory(abURI);
|
||||
|
||||
parent.gSubDialog.open(
|
||||
"chrome://messenger/content/addressbook/pref-directory-add.xhtml",
|
||||
|
@ -146,13 +146,13 @@ function editDirectory() {
|
|||
}
|
||||
|
||||
async function removeDirectory() {
|
||||
let abList = document.getElementById("directoriesList");
|
||||
const abList = document.getElementById("directoriesList");
|
||||
|
||||
if (!abList.selectedItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
let directory = GetDirectoryFromURI(abList.value);
|
||||
const directory = GetDirectoryFromURI(abList.value);
|
||||
if (
|
||||
!directory ||
|
||||
["ldap_2.servers.history", "ldap_2.servers.pab"].includes(
|
||||
|
@ -174,7 +174,7 @@ async function removeDirectory() {
|
|||
action = "remove-remote-book";
|
||||
}
|
||||
|
||||
let [title, message] = await document.l10n.formatValues([
|
||||
const [title, message] = await document.l10n.formatValues([
|
||||
{ id: `about-addressbook-confirm-${action}-title`, args: { count: 1 } },
|
||||
{
|
||||
id: `about-addressbook-confirm-${action}`,
|
||||
|
|
|
@ -19,8 +19,8 @@ AbAutoCompleteMyDomain.prototype = {
|
|||
applicableHeaders: new Set(["addr_to", "addr_cc", "addr_bcc", "addr_reply"]),
|
||||
|
||||
startSearch(aString, aSearchParam, aResult, aListener) {
|
||||
let params = aSearchParam ? JSON.parse(aSearchParam) : {};
|
||||
let applicable =
|
||||
const params = aSearchParam ? JSON.parse(aSearchParam) : {};
|
||||
const applicable =
|
||||
"type" in params && this.applicableHeaders.has(params.type);
|
||||
const ACR = Ci.nsIAutoCompleteResult;
|
||||
var address = null;
|
||||
|
|
|
@ -122,7 +122,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
* @param {nsIAbCard} aCard - The card to return the popularity index for.
|
||||
*/
|
||||
_getPopularityIndex(aDirectory, aCard) {
|
||||
let popularityValue = aCard.getProperty("PopularityIndex", "0");
|
||||
const popularityValue = aCard.getProperty("PopularityIndex", "0");
|
||||
let popularityIndex = parseInt(popularityValue);
|
||||
|
||||
// If we haven't parsed it the first time round, parse it as hexadecimal
|
||||
|
@ -164,7 +164,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
|
||||
// We will firstly check if the search term provided by the user
|
||||
// is the nick name for the card or at least in the beginning of it.
|
||||
let nick = aCard.getProperty("NickName", "").toLocaleLowerCase();
|
||||
const nick = aCard.getProperty("NickName", "").toLocaleLowerCase();
|
||||
aSearchString = aSearchString.toLocaleLowerCase();
|
||||
if (nick == aSearchString) {
|
||||
return BEST + 1;
|
||||
|
@ -174,12 +174,12 @@ AbAutoCompleteSearch.prototype = {
|
|||
}
|
||||
|
||||
// We'll do this case-insensitively and ignore the domain.
|
||||
let atIdx = aAddress.lastIndexOf("@");
|
||||
const atIdx = aAddress.lastIndexOf("@");
|
||||
if (atIdx != -1) {
|
||||
// mail lists don't have an @
|
||||
aAddress = aAddress.substr(0, atIdx);
|
||||
}
|
||||
let idx = aAddress.indexOf(aSearchString);
|
||||
const idx = aAddress.indexOf(aSearchString);
|
||||
if (idx == 0) {
|
||||
return BEST;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
// the email address the same. E.g. for "John Doe (:xx) <jd.who@example.com>"
|
||||
// all of these should score the same: "John", "Doe", "xx",
|
||||
// ":xx", "jd", "who".
|
||||
let prevCh = aAddress.charAt(idx - 1);
|
||||
const prevCh = aAddress.charAt(idx - 1);
|
||||
if (/[ :."'(\-_<&]/.test(prevCh)) {
|
||||
return BEST;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
*/
|
||||
_searchCards(searchQuery, searchString, directory, result) {
|
||||
// Cache this values to save going through xpconnect each time
|
||||
let commentColumn = this._commentColumn == 1 ? directory.dirName : "";
|
||||
const commentColumn = this._commentColumn == 1 ? directory.dirName : "";
|
||||
|
||||
if (searchQuery[0] == "?") {
|
||||
searchQuery = searchQuery.substring(1);
|
||||
|
@ -225,7 +225,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
this._addToResult(commentColumn, directory, card, "", true, result);
|
||||
} else {
|
||||
let first = true;
|
||||
for (let emailAddress of card.emailAddresses) {
|
||||
for (const emailAddress of card.emailAddresses) {
|
||||
this._addToResult(
|
||||
commentColumn,
|
||||
directory,
|
||||
|
@ -297,12 +297,12 @@ AbAutoCompleteSearch.prototype = {
|
|||
* @param {nsIAbAutoCompleteResult} currentResults - The current results list.
|
||||
*/
|
||||
_checkDuplicate(directory, card, lcEmailAddress, currentResults) {
|
||||
let existingResult = currentResults._collectedValues.get(lcEmailAddress);
|
||||
const existingResult = currentResults._collectedValues.get(lcEmailAddress);
|
||||
if (!existingResult) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let popIndex = this._getPopularityIndex(directory, card);
|
||||
const popIndex = this._getPopularityIndex(directory, card);
|
||||
// It's a duplicate, is the new one more popular?
|
||||
if (popIndex > existingResult.popularity) {
|
||||
// Yes it is, so delete this element, return false and allow
|
||||
|
@ -337,7 +337,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
isPrimaryEmail,
|
||||
result
|
||||
) {
|
||||
let mbox = this._parser.makeMailboxObject(
|
||||
const mbox = this._parser.makeMailboxObject(
|
||||
card.displayName,
|
||||
card.isMailList
|
||||
? card.getProperty("Notes", "") || card.displayName
|
||||
|
@ -347,8 +347,8 @@ AbAutoCompleteSearch.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
let emailAddress = mbox.toString();
|
||||
let lcEmailAddress = emailAddress.toLocaleLowerCase();
|
||||
const emailAddress = mbox.toString();
|
||||
const lcEmailAddress = emailAddress.toLocaleLowerCase();
|
||||
|
||||
// If it is a duplicate, then just return and don't add it. The
|
||||
// _checkDuplicate function deals with it all for us.
|
||||
|
@ -379,7 +379,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
* for determining if an address book should be autocompleted against.
|
||||
*/
|
||||
async startSearch(aSearchString, aSearchParam, aPreviousResult, aListener) {
|
||||
let params = aSearchParam ? JSON.parse(aSearchParam) : {};
|
||||
const params = aSearchParam ? JSON.parse(aSearchParam) : {};
|
||||
var result = new nsAbAutoCompleteResult(aSearchString);
|
||||
if ("type" in params && !this.applicableHeaders.has(params.type)) {
|
||||
result.searchResult = ACR.RESULT_IGNORED;
|
||||
|
@ -387,7 +387,8 @@ AbAutoCompleteSearch.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
let fullString = aSearchString && aSearchString.trim().toLocaleLowerCase();
|
||||
const fullString =
|
||||
aSearchString && aSearchString.trim().toLocaleLowerCase();
|
||||
|
||||
// If the search string is empty, or the user hasn't enabled autocomplete,
|
||||
// then just return no matches or the result ignored.
|
||||
|
@ -400,7 +401,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
// Array of all the terms from the fullString search query
|
||||
// (separated on the basis of spaces or exact terms on the
|
||||
// basis of quotes).
|
||||
let searchWords = getSearchTokens(fullString);
|
||||
const searchWords = getSearchTokens(fullString);
|
||||
|
||||
// Find out about the comment column
|
||||
this._commentColumn = Services.prefs.getIntPref(
|
||||
|
@ -430,8 +431,8 @@ AbAutoCompleteSearch.prototype = {
|
|||
// At least we now allow users to customize their autocomplete model query...
|
||||
for (let i = 0; i < aPreviousResult.matchCount; ++i) {
|
||||
if (aPreviousResult.isCompleteResult(i)) {
|
||||
let card = aPreviousResult.getCardAt(i);
|
||||
let email = aPreviousResult.getEmailToUse(i);
|
||||
const card = aPreviousResult.getCardAt(i);
|
||||
const email = aPreviousResult.getEmailToUse(i);
|
||||
if (this._checkEntry(card, email, searchWords)) {
|
||||
// Add matches into the results array. We re-sort as needed later.
|
||||
result._searchResults.push({
|
||||
|
@ -463,15 +464,15 @@ AbAutoCompleteSearch.prototype = {
|
|||
// (see bug 558931 for explanations).
|
||||
// Use helper method to split up search query to multi-word search
|
||||
// query against multiple fields.
|
||||
let searchWords = getSearchTokens(fullString);
|
||||
let searchQuery = generateQueryURI(result.modelQuery, searchWords);
|
||||
const searchWords = getSearchTokens(fullString);
|
||||
const searchQuery = generateQueryURI(result.modelQuery, searchWords);
|
||||
|
||||
// Now do the searching
|
||||
// We're not going to bother searching sub-directories, currently the
|
||||
// architecture forces all cards that are in mailing lists to be in ABs as
|
||||
// well, therefore by searching sub-directories (aka mailing lists) we're
|
||||
// just going to find duplicates.
|
||||
for (let dir of this._abManager.directories) {
|
||||
for (const dir of this._abManager.directories) {
|
||||
// A failure in one address book should no break the whole search.
|
||||
try {
|
||||
if (dir.useForAutocomplete("idKey" in params ? params.idKey : null)) {
|
||||
|
@ -491,7 +492,7 @@ AbAutoCompleteSearch.prototype = {
|
|||
|
||||
result._searchResults = [...result._collectedValues.values()];
|
||||
// Make sure a result with direct email match will be the one used.
|
||||
for (let sr of result._searchResults) {
|
||||
for (const sr of result._searchResults) {
|
||||
if (sr.emailToUse == fullString.replace(/.*<(.+@.+)>$/, "$1")) {
|
||||
sr.score = 100;
|
||||
}
|
||||
|
@ -538,11 +539,11 @@ AbAutoCompleteSearch.prototype = {
|
|||
|
||||
// Start searching our asynchronous autocomplete directories.
|
||||
this._result = result;
|
||||
let searches = new Set();
|
||||
for (let dir of asyncDirectories) {
|
||||
let comment = this._commentColumn == 1 ? dir.dirName : "";
|
||||
let cards = [];
|
||||
let searchListener = {
|
||||
const searches = new Set();
|
||||
for (const dir of asyncDirectories) {
|
||||
const comment = this._commentColumn == 1 ? dir.dirName : "";
|
||||
const cards = [];
|
||||
const searchListener = {
|
||||
onSearchFoundCard: card => {
|
||||
cards.push(card);
|
||||
},
|
||||
|
@ -560,9 +561,9 @@ AbAutoCompleteSearch.prototype = {
|
|||
}
|
||||
// We can't guarantee to score the extension's results accurately so
|
||||
// we assume that the extension has sorted the results appropriately
|
||||
for (let card of cards) {
|
||||
let emailToUse = card.primaryEmail;
|
||||
let value = MailServices.headerParser
|
||||
for (const card of cards) {
|
||||
const emailToUse = card.primaryEmail;
|
||||
const value = MailServices.headerParser
|
||||
.makeMailboxObject(card.displayName, emailToUse)
|
||||
.toString();
|
||||
result._searchResults.push({
|
||||
|
|
|
@ -75,7 +75,7 @@ AbLDAPAttributeMap.prototype = {
|
|||
|
||||
getAllCardAttributes() {
|
||||
var attrs = [];
|
||||
for (let attrArray of Object.entries(this.mPropertyMap)) {
|
||||
for (const attrArray of Object.entries(this.mPropertyMap)) {
|
||||
for (let attrName of attrArray) {
|
||||
attrName = attrName.toString().replace(/\[(\d+)\]$/, "");
|
||||
if (attrs.includes(attrName)) {
|
||||
|
@ -102,7 +102,7 @@ AbLDAPAttributeMap.prototype = {
|
|||
|
||||
setFromPrefs(aPrefBranchName) {
|
||||
// get the right pref branch
|
||||
let branch = Services.prefs.getBranch(aPrefBranchName + ".");
|
||||
const branch = Services.prefs.getBranch(aPrefBranchName + ".");
|
||||
|
||||
// get the list of children
|
||||
var children = branch.getChildList("");
|
||||
|
@ -171,7 +171,7 @@ AbLDAPAttributeMap.prototype = {
|
|||
var attrsSeen = [];
|
||||
|
||||
for (var prop in this.mPropertyMap) {
|
||||
let attrArray = this.mPropertyMap[prop];
|
||||
const attrArray = this.mPropertyMap[prop];
|
||||
for (var attr of attrArray) {
|
||||
// multiple attributes that mapped to the empty string are permitted
|
||||
if (!attr.length) {
|
||||
|
|
|
@ -115,7 +115,7 @@ AbLDAPAutoCompleteSearch.prototype = {
|
|||
},
|
||||
|
||||
_addToResult(card, address) {
|
||||
let mbox = this._parser.makeMailboxObject(
|
||||
const mbox = this._parser.makeMailboxObject(
|
||||
card.displayName,
|
||||
card.isMailList
|
||||
? card.getProperty("Notes", "") || card.displayName
|
||||
|
@ -125,7 +125,7 @@ AbLDAPAutoCompleteSearch.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
let emailAddress = mbox.toString();
|
||||
const emailAddress = mbox.toString();
|
||||
|
||||
// If it is a duplicate, then just return and don't add it. The
|
||||
// _checkDuplicate function deals with it all for us.
|
||||
|
@ -171,8 +171,8 @@ AbLDAPAutoCompleteSearch.prototype = {
|
|||
// nsIAutoCompleteSearch
|
||||
|
||||
startSearch(aSearchString, aParam, aPreviousResult, aListener) {
|
||||
let params = JSON.parse(aParam) || {};
|
||||
let applicable =
|
||||
const params = JSON.parse(aParam) || {};
|
||||
const applicable =
|
||||
!("type" in params) || this.applicableHeaders.has(params.type);
|
||||
|
||||
this._result = new nsAbLDAPAutoCompleteResult(aSearchString);
|
||||
|
@ -340,7 +340,7 @@ AbLDAPAutoCompleteSearch.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
for (let emailAddress of aCard.emailAddresses) {
|
||||
for (const emailAddress of aCard.emailAddresses) {
|
||||
this._addToResult(aCard, emailAddress);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ var CardDAVServer = {
|
|||
|
||||
// Address book interaction.
|
||||
|
||||
for (let path of Object.keys(this.books)) {
|
||||
for (const path of Object.keys(this.books)) {
|
||||
this.server.registerPathHandler(path, this.directoryHandler.bind(this));
|
||||
this.server.registerPrefixHandler(path, this.cardHandler.bind(this));
|
||||
}
|
||||
|
@ -130,14 +130,14 @@ var CardDAVServer = {
|
|||
return false;
|
||||
}
|
||||
|
||||
let value = request.getHeader("Authorization");
|
||||
const value = request.getHeader("Authorization");
|
||||
if (!value.startsWith("Basic ")) {
|
||||
response.setStatusLine("1.1", 401, "Unauthorized");
|
||||
response.setHeader("WWW-Authenticate", `Basic realm="test"`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let [username, password] = atob(value.substring(6)).split(":");
|
||||
const [username, password] = atob(value.substring(6)).split(":");
|
||||
if (username != this.username || password != this.password) {
|
||||
response.setStatusLine("1.1", 401, "Unauthorized");
|
||||
response.setHeader("WWW-Authenticate", `Basic realm="test"`);
|
||||
|
@ -163,13 +163,13 @@ var CardDAVServer = {
|
|||
return;
|
||||
}
|
||||
|
||||
let input = new DOMParser().parseFromString(
|
||||
const input = new DOMParser().parseFromString(
|
||||
CommonUtils.readBytesFromInputStream(request.bodyInputStream),
|
||||
"text/xml"
|
||||
);
|
||||
|
||||
let propNames = this._inputProps(input);
|
||||
let propValues = {
|
||||
const propNames = this._inputProps(input);
|
||||
const propValues = {
|
||||
"d:current-user-principal": "<href>/principals/me/</href>",
|
||||
};
|
||||
|
||||
|
@ -190,13 +190,13 @@ var CardDAVServer = {
|
|||
return;
|
||||
}
|
||||
|
||||
let input = new DOMParser().parseFromString(
|
||||
const input = new DOMParser().parseFromString(
|
||||
CommonUtils.readBytesFromInputStream(request.bodyInputStream),
|
||||
"text/xml"
|
||||
);
|
||||
|
||||
let propNames = this._inputProps(input);
|
||||
let propValues = {
|
||||
const propNames = this._inputProps(input);
|
||||
const propValues = {
|
||||
"d:resourcetype": "<principal/>",
|
||||
"card:addressbook-home-set": "<href>/addressbooks/me/</href>",
|
||||
};
|
||||
|
@ -218,12 +218,12 @@ var CardDAVServer = {
|
|||
return;
|
||||
}
|
||||
|
||||
let input = new DOMParser().parseFromString(
|
||||
const input = new DOMParser().parseFromString(
|
||||
CommonUtils.readBytesFromInputStream(request.bodyInputStream),
|
||||
"text/xml"
|
||||
);
|
||||
|
||||
let propNames = this._inputProps(input);
|
||||
const propNames = this._inputProps(input);
|
||||
|
||||
response.setStatusLine("1.1", 207, "Multi-Status");
|
||||
response.setHeader("Content-Type", "text/xml");
|
||||
|
@ -237,7 +237,7 @@ var CardDAVServer = {
|
|||
})}
|
||||
</response>`;
|
||||
|
||||
for (let [path, name] of Object.entries(this.books)) {
|
||||
for (const [path, name] of Object.entries(this.books)) {
|
||||
output += `<response>
|
||||
<href>${path}</href>
|
||||
${this._outputProps(propNames, {
|
||||
|
@ -260,8 +260,8 @@ var CardDAVServer = {
|
|||
return;
|
||||
}
|
||||
|
||||
let isRealDirectory = request.path == this.path;
|
||||
let input = new DOMParser().parseFromString(
|
||||
const isRealDirectory = request.path == this.path;
|
||||
const input = new DOMParser().parseFromString(
|
||||
CommonUtils.readBytesFromInputStream(request.bodyInputStream),
|
||||
"text/xml"
|
||||
);
|
||||
|
@ -306,10 +306,10 @@ var CardDAVServer = {
|
|||
return;
|
||||
}
|
||||
|
||||
let propNames = this._inputProps(input);
|
||||
const propNames = this._inputProps(input);
|
||||
let output = `<multistatus xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>`;
|
||||
if (isRealDirectory) {
|
||||
for (let [href, card] of this.cards) {
|
||||
for (const [href, card] of this.cards) {
|
||||
output += this._cardResponse(href, card, propNames);
|
||||
}
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ var CardDAVServer = {
|
|||
},
|
||||
|
||||
addressBookMultiGet(input, response, isRealDirectory) {
|
||||
let propNames = this._inputProps(input);
|
||||
const propNames = this._inputProps(input);
|
||||
let output = `<multistatus xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>`;
|
||||
if (isRealDirectory) {
|
||||
for (let href of input.querySelectorAll("href")) {
|
||||
|
@ -329,7 +329,7 @@ var CardDAVServer = {
|
|||
if (this.movedCards.has(href)) {
|
||||
href = this.movedCards.get(href);
|
||||
}
|
||||
let card = this.cards.get(href);
|
||||
const card = this.cards.get(href);
|
||||
if (card) {
|
||||
output += this._cardResponse(href, card, propNames);
|
||||
}
|
||||
|
@ -343,14 +343,14 @@ var CardDAVServer = {
|
|||
},
|
||||
|
||||
propFind(input, depth, response, isRealDirectory) {
|
||||
let propNames = this._inputProps(input);
|
||||
const propNames = this._inputProps(input);
|
||||
|
||||
if (this.mimicYahoo && !propNames.includes("cs:getctag")) {
|
||||
response.setStatusLine("1.1", 400, "Bad Request");
|
||||
return;
|
||||
}
|
||||
|
||||
let propValues = {
|
||||
const propValues = {
|
||||
"cs:getctag": this.changeCount,
|
||||
"d:displayname": isRealDirectory ? "CardDAV Test" : "Not This One",
|
||||
"d:resourcetype": "<collection/><card:addressbook/>",
|
||||
|
@ -366,7 +366,7 @@ var CardDAVServer = {
|
|||
${this._outputProps(propNames, propValues)}
|
||||
</response>`;
|
||||
if (depth == 1 && isRealDirectory) {
|
||||
for (let [href, card] of this.cards) {
|
||||
for (const [href, card] of this.cards) {
|
||||
output += this._cardResponse(href, card, propNames);
|
||||
}
|
||||
}
|
||||
|
@ -378,18 +378,18 @@ var CardDAVServer = {
|
|||
},
|
||||
|
||||
syncCollection(input, response, isRealDirectory) {
|
||||
let token = input
|
||||
const token = input
|
||||
.querySelector("sync-token")
|
||||
.textContent.replace(/\D/g, "");
|
||||
if (!token) {
|
||||
response.setStatusLine("1.1", 400, "Bad Request");
|
||||
return;
|
||||
}
|
||||
let propNames = this._inputProps(input);
|
||||
const propNames = this._inputProps(input);
|
||||
|
||||
let output = `<multistatus xmlns="${PREFIX_BINDINGS.d}" ${NAMESPACE_STRING}>`;
|
||||
if (isRealDirectory) {
|
||||
for (let [href, card] of this.cards) {
|
||||
for (const [href, card] of this.cards) {
|
||||
if (card.changed > token) {
|
||||
output += this._cardResponse(
|
||||
href,
|
||||
|
@ -399,7 +399,7 @@ var CardDAVServer = {
|
|||
);
|
||||
}
|
||||
}
|
||||
for (let [href, deleted] of this.deletedCards) {
|
||||
for (const [href, deleted] of this.deletedCards) {
|
||||
if (deleted > token) {
|
||||
output += `<response>
|
||||
<status>HTTP/1.1 404 Not Found</status>
|
||||
|
@ -421,7 +421,7 @@ var CardDAVServer = {
|
|||
},
|
||||
|
||||
_cardResponse(href, card, propNames, includeAddressData = true) {
|
||||
let propValues = {
|
||||
const propValues = {
|
||||
"d:getetag": card.etag,
|
||||
"d:resourcetype": null,
|
||||
};
|
||||
|
@ -430,7 +430,7 @@ var CardDAVServer = {
|
|||
propValues["card:address-data"] = card.vCard;
|
||||
}
|
||||
|
||||
let outString = `<response>
|
||||
const outString = `<response>
|
||||
<href>${href}</href>
|
||||
${this._outputProps(propNames, propValues)}
|
||||
</response>`;
|
||||
|
@ -438,10 +438,10 @@ var CardDAVServer = {
|
|||
},
|
||||
|
||||
_inputProps(input) {
|
||||
let props = input.querySelectorAll("prop > *");
|
||||
let propNames = [];
|
||||
const props = input.querySelectorAll("prop > *");
|
||||
const propNames = [];
|
||||
|
||||
for (let p of props) {
|
||||
for (const p of props) {
|
||||
Assert.equal(p.childElementCount, 0);
|
||||
switch (p.localName) {
|
||||
case "address-data":
|
||||
|
@ -479,9 +479,9 @@ var CardDAVServer = {
|
|||
_outputProps(propNames, propValues) {
|
||||
let output = "";
|
||||
|
||||
let found = [];
|
||||
let notFound = [];
|
||||
for (let p of propNames) {
|
||||
const found = [];
|
||||
const notFound = [];
|
||||
for (const p of propNames) {
|
||||
if (p in propValues && propValues[p] !== undefined) {
|
||||
found.push(`<${p}>${propValues[p]}</${p}>`);
|
||||
} else {
|
||||
|
@ -516,7 +516,7 @@ var CardDAVServer = {
|
|||
return;
|
||||
}
|
||||
|
||||
let isRealDirectory = request.path.startsWith(this.path);
|
||||
const isRealDirectory = request.path.startsWith(this.path);
|
||||
if (!isRealDirectory || !/\/[\w-]+\.vcf$/.test(request.path)) {
|
||||
response.setStatusLine("1.1", 404, "Not Found");
|
||||
response.setHeader("Content-Type", "text/plain");
|
||||
|
@ -543,7 +543,7 @@ var CardDAVServer = {
|
|||
},
|
||||
|
||||
getCard(request, response) {
|
||||
let card = this.cards.get(request.path);
|
||||
const card = this.cards.get(request.path);
|
||||
if (!card) {
|
||||
response.setStatusLine("1.1", 404, "Not Found");
|
||||
response.setHeader("Content-Type", "text/plain");
|
||||
|
@ -559,14 +559,14 @@ var CardDAVServer = {
|
|||
|
||||
putCard(request, response) {
|
||||
if (request.hasHeader("If-Match")) {
|
||||
let card = this.cards.get(request.path);
|
||||
const card = this.cards.get(request.path);
|
||||
if (!card || card.etag != request.getHeader("If-Match")) {
|
||||
response.setStatusLine("1.1", 412, "Precondition Failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let vCard = CommonUtils.readBytesFromInputStream(request.bodyInputStream);
|
||||
const vCard = CommonUtils.readBytesFromInputStream(request.bodyInputStream);
|
||||
if (this.mimicGoogle && !/^N[;:]/im.test(vCard)) {
|
||||
response.setStatusLine("1.1", 400, "Bad Request");
|
||||
return;
|
||||
|
@ -590,17 +590,17 @@ var CardDAVServer = {
|
|||
}
|
||||
if (this.modifyCardOnPut && !this.cards.has(name)) {
|
||||
vCard = vCard.replace(/UID:(\S+)/, (match, uid) => {
|
||||
let newUID = [...uid].reverse().join("");
|
||||
let newName = this.path + newUID + ".vcf";
|
||||
const newUID = [...uid].reverse().join("");
|
||||
const newName = this.path + newUID + ".vcf";
|
||||
this.movedCards.set(name, newName);
|
||||
name = newName;
|
||||
return "UID:" + newUID + "\r\nX-MODIFIED-BY-SERVER:1";
|
||||
});
|
||||
}
|
||||
if (this.mimicGoogle && vCard.includes("\nPHOTO")) {
|
||||
let [, version] = vCard.match(/VERSION:([34]\.0)/);
|
||||
const [, version] = vCard.match(/VERSION:([34]\.0)/);
|
||||
if (version && version != "3.0") {
|
||||
let start = vCard.indexOf("\nPHOTO") + 1;
|
||||
const start = vCard.indexOf("\nPHOTO") + 1;
|
||||
let end = vCard.indexOf("\n", start) + 1;
|
||||
while (vCard[end] == " ") {
|
||||
end = vCard.indexOf("\n", end) + 1;
|
||||
|
@ -608,7 +608,7 @@ var CardDAVServer = {
|
|||
vCard = vCard.substring(0, start) + vCard.substring(end);
|
||||
}
|
||||
}
|
||||
let etag = "" + vCard.length;
|
||||
const etag = "" + vCard.length;
|
||||
this.cards.set(name, { etag, vCard, changed: ++this.changeCount });
|
||||
this.deletedCards.delete(name);
|
||||
},
|
||||
|
|
|
@ -89,7 +89,7 @@ var LDAPServer = {
|
|||
this._lastMessageID = data[index];
|
||||
|
||||
if (expectedOperation) {
|
||||
let actualOperation = data[index + 1];
|
||||
const actualOperation = data[index + 1];
|
||||
|
||||
// Unbind and abandon requests can happen at any point, when an
|
||||
// nsLDAPConnection is destroyed. This is unpredictable, and irrelevant
|
||||
|
@ -132,8 +132,8 @@ var LDAPServer = {
|
|||
* See section 4.2.2 of the RFC.
|
||||
*/
|
||||
writeBindResponse() {
|
||||
let message = new Sequence(0x30, new IntegerValue(this._lastMessageID));
|
||||
let person = new Sequence(
|
||||
const message = new Sequence(0x30, new IntegerValue(this._lastMessageID));
|
||||
const person = new Sequence(
|
||||
0x61,
|
||||
new EnumeratedValue(0),
|
||||
new StringValue(""),
|
||||
|
@ -152,20 +152,20 @@ var LDAPServer = {
|
|||
* object representing the person.
|
||||
*/
|
||||
writeSearchResultEntry({ dn, attributes }) {
|
||||
let message = new Sequence(0x30, new IntegerValue(this._lastMessageID));
|
||||
const message = new Sequence(0x30, new IntegerValue(this._lastMessageID));
|
||||
|
||||
let person = new Sequence(0x64, new StringValue(dn));
|
||||
const person = new Sequence(0x64, new StringValue(dn));
|
||||
message.children.push(person);
|
||||
|
||||
let attributeSequence = new Sequence(0x30);
|
||||
const attributeSequence = new Sequence(0x30);
|
||||
person.children.push(attributeSequence);
|
||||
|
||||
for (let [key, value] of Object.entries(attributes)) {
|
||||
let seq = new Sequence(0x30, new StringValue(key), new Sequence(0x31));
|
||||
const seq = new Sequence(0x30, new StringValue(key), new Sequence(0x31));
|
||||
if (typeof value == "string") {
|
||||
value = [value];
|
||||
}
|
||||
for (let v of value) {
|
||||
for (const v of value) {
|
||||
seq.children[1].children.push(new StringValue(v));
|
||||
}
|
||||
attributeSequence.children.push(seq);
|
||||
|
@ -178,8 +178,8 @@ var LDAPServer = {
|
|||
* See RFC 4511 section 4.5.2.
|
||||
*/
|
||||
writeSearchResultDone() {
|
||||
let message = new Sequence(0x30, new IntegerValue(this._lastMessageID));
|
||||
let person = new Sequence(
|
||||
const message = new Sequence(0x30, new IntegerValue(this._lastMessageID));
|
||||
const person = new Sequence(
|
||||
0x65,
|
||||
new EnumeratedValue(0),
|
||||
new StringValue(""),
|
||||
|
@ -193,11 +193,11 @@ var LDAPServer = {
|
|||
* nsIServerSocketListener.onSocketAccepted
|
||||
*/
|
||||
onSocketAccepted(socket, transport) {
|
||||
let inputStream = transport
|
||||
const inputStream = transport
|
||||
.openInputStream(0, 8192, 1024)
|
||||
.QueryInterface(Ci.nsIAsyncInputStream);
|
||||
|
||||
let outputStream = transport.openOutputStream(0, 0, 0);
|
||||
const outputStream = transport.openOutputStream(0, 0, 0);
|
||||
this._outputStream = Cc["@mozilla.org/binaryoutputstream;1"].createInstance(
|
||||
Ci.nsIBinaryOutputStream
|
||||
);
|
||||
|
@ -232,11 +232,11 @@ var LDAPServer = {
|
|||
throw ex;
|
||||
}
|
||||
|
||||
let binaryInputStream = Cc[
|
||||
const binaryInputStream = Cc[
|
||||
"@mozilla.org/binaryinputstream;1"
|
||||
].createInstance(Ci.nsIBinaryInputStream);
|
||||
binaryInputStream.setInputStream(stream);
|
||||
let data = binaryInputStream.readByteArray(available);
|
||||
const data = binaryInputStream.readByteArray(available);
|
||||
if (PRINT_DEBUG) {
|
||||
console.log(
|
||||
"<<< " + data.map(b => b.toString(16).padStart(2, 0)).join(" ")
|
||||
|
@ -265,7 +265,7 @@ class Sequence {
|
|||
}
|
||||
getBytes() {
|
||||
let bytes = [];
|
||||
for (let c of this.children) {
|
||||
for (const c of this.children) {
|
||||
bytes = bytes.concat(c.getBytes());
|
||||
}
|
||||
return [this.number].concat(getLengthBytes(bytes.length), bytes);
|
||||
|
@ -278,7 +278,7 @@ class IntegerValue {
|
|||
}
|
||||
getBytes() {
|
||||
let temp = this.int;
|
||||
let bytes = [];
|
||||
const bytes = [];
|
||||
|
||||
while (temp >= 128) {
|
||||
bytes.unshift(temp & 255);
|
||||
|
@ -312,7 +312,7 @@ function getLengthBytes(int) {
|
|||
}
|
||||
|
||||
let temp = int;
|
||||
let bytes = [];
|
||||
const bytes = [];
|
||||
|
||||
while (temp >= 128) {
|
||||
bytes.unshift(temp & 255);
|
||||
|
|
|
@ -17,7 +17,7 @@ var { LDAPResponse, SearchRequest } = ChromeUtils.import(
|
|||
* Test filter string is converted to asn1 blocks correctly.
|
||||
*/
|
||||
add_task(function test_SearchRequest_filter() {
|
||||
let req = new SearchRequest(
|
||||
const req = new SearchRequest(
|
||||
"ou=people,dc=planetexpress,dc=com",
|
||||
Ci.nsILDAPURL.SCOPE_SUBTREE,
|
||||
"(memberof=cn=ship_crew,ou=people,dc=planetexpress,dc=com)",
|
||||
|
@ -25,10 +25,12 @@ add_task(function test_SearchRequest_filter() {
|
|||
0,
|
||||
0
|
||||
);
|
||||
let filterBlock = req.protocolOp.valueBlock.value[6];
|
||||
let [filterKeyBlock, filterValueBlock] = filterBlock.valueBlock.value;
|
||||
let filterKey = new TextDecoder().decode(filterKeyBlock.valueBlock.valueHex);
|
||||
let filterValue = new TextDecoder().decode(
|
||||
const filterBlock = req.protocolOp.valueBlock.value[6];
|
||||
const [filterKeyBlock, filterValueBlock] = filterBlock.valueBlock.value;
|
||||
const filterKey = new TextDecoder().decode(
|
||||
filterKeyBlock.valueBlock.valueHex
|
||||
);
|
||||
const filterValue = new TextDecoder().decode(
|
||||
filterValueBlock.valueBlock.valueHex
|
||||
);
|
||||
Assert.equal(filterKey, "memberof", "Filter key should be correct");
|
||||
|
@ -45,7 +47,7 @@ add_task(function test_SearchRequest_filter() {
|
|||
add_task(function test_extensibleMatchFilter() {
|
||||
// Test data is from https://ldap.com/ldapv3-wire-protocol-reference-search/.
|
||||
// filter string, BER payload, description
|
||||
let filterBER = [
|
||||
const filterBER = [
|
||||
[
|
||||
"(uid:dn:caseIgnoreMatch:=jdoe)",
|
||||
"a91f810f6361736549676e6f72654d61746368820375696483046a646f658401ff",
|
||||
|
@ -64,8 +66,8 @@ add_task(function test_extensibleMatchFilter() {
|
|||
"<type>:<rule>:=<value>",
|
||||
],
|
||||
];
|
||||
for (let [filter, ber, description] of filterBER) {
|
||||
let req = new SearchRequest(
|
||||
for (const [filter, ber, description] of filterBER) {
|
||||
const req = new SearchRequest(
|
||||
"ou=people,dc=planetexpress,dc=com",
|
||||
Ci.nsILDAPURL.SCOPE_SUBTREE,
|
||||
filter,
|
||||
|
@ -73,7 +75,7 @@ add_task(function test_extensibleMatchFilter() {
|
|||
0,
|
||||
0
|
||||
);
|
||||
let filterBlock = req.protocolOp.valueBlock.value[6];
|
||||
const filterBlock = req.protocolOp.valueBlock.value[6];
|
||||
Assert.equal(
|
||||
CommonUtils.bufferToHex(new Uint8Array(filterBlock.toBER())),
|
||||
ber,
|
||||
|
@ -88,9 +90,9 @@ add_task(function test_extensibleMatchFilter() {
|
|||
add_task(function test_SearchResultReference() {
|
||||
// A BER payload representing a SearchResultReference with two urls, test data
|
||||
// is from https://ldap.com/ldapv3-wire-protocol-reference-search/.
|
||||
let hex =
|
||||
const hex =
|
||||
"306d020102736804326c6461703a2f2f6473312e6578616d706c652e636f6d3a3338392f64633d6578616d706c652c64633d636f6d3f3f7375623f04326c6461703a2f2f6473322e6578616d706c652e636f6d3a3338392f64633d6578616d706c652c64633d636f6d3f3f7375623f";
|
||||
let res = LDAPResponse.fromBER(CommonUtils.hexToArrayBuffer(hex).buffer);
|
||||
const res = LDAPResponse.fromBER(CommonUtils.hexToArrayBuffer(hex).buffer);
|
||||
|
||||
// Should be correctly parsed.
|
||||
Assert.equal(res.constructor.name, "SearchResultReference");
|
||||
|
|
|
@ -12,28 +12,28 @@ const { BinaryServer } = ChromeUtils.import(
|
|||
);
|
||||
|
||||
function getLDAPAttributes(urlSpec) {
|
||||
let url = Services.io.newURI(urlSpec).QueryInterface(Ci.nsILDAPURL);
|
||||
let ldapquery = Cc["@mozilla.org/ldapsyncquery;1"].createInstance(
|
||||
const url = Services.io.newURI(urlSpec).QueryInterface(Ci.nsILDAPURL);
|
||||
const ldapquery = Cc["@mozilla.org/ldapsyncquery;1"].createInstance(
|
||||
Ci.nsILDAPSyncQuery
|
||||
);
|
||||
let payload = ldapquery.getQueryResults(url, Ci.nsILDAPConnection.VERSION3);
|
||||
const payload = ldapquery.getQueryResults(url, Ci.nsILDAPConnection.VERSION3);
|
||||
// Returns a string with one attr per line.
|
||||
return payload;
|
||||
}
|
||||
|
||||
add_task(async function test_LDAPSyncQuery() {
|
||||
// Set up fake LDAP server, loaded with some contacts.
|
||||
let daemon = new LDAPDaemon();
|
||||
let raw = await IOUtils.readUTF8(
|
||||
const daemon = new LDAPDaemon();
|
||||
const raw = await IOUtils.readUTF8(
|
||||
do_get_file(
|
||||
"../../../../mailnews/addrbook/test/unit/data/ldap_contacts.json"
|
||||
).path
|
||||
);
|
||||
let testContacts = JSON.parse(raw);
|
||||
const testContacts = JSON.parse(raw);
|
||||
daemon.add(...Object.values(testContacts));
|
||||
// daemon.setDebug(true);
|
||||
|
||||
let server = new BinaryServer(LDAPHandlerFn, daemon);
|
||||
const server = new BinaryServer(LDAPHandlerFn, daemon);
|
||||
server.start();
|
||||
|
||||
// Fetch only the Holmes family.
|
||||
|
|
|
@ -15,7 +15,7 @@ var kEmailReducedValue = "testEmail\u00D2";
|
|||
var kCompanyValue = "Test\u00D0 Company";
|
||||
|
||||
add_task(function testAbCardProperty() {
|
||||
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
const card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
|
||||
|
@ -109,7 +109,7 @@ add_task(function testAbCardProperty() {
|
|||
card.firstName = kFNValue;
|
||||
card.lastName = kLNValue;
|
||||
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/addressbook/addressBook.properties"
|
||||
);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ var kEmailValue2 = "test@test.foo.invalid";
|
|||
var kEmailReducedValue = "testEmail\u00D2";
|
||||
|
||||
add_task(function testAddrBookCard() {
|
||||
let card = new AddrBookCard();
|
||||
const card = new AddrBookCard();
|
||||
|
||||
// Test - Set First, Last and Display Names and Email Address
|
||||
// via setProperty, and check correctly saved via their
|
||||
|
@ -107,7 +107,7 @@ add_task(function testAddrBookCard() {
|
|||
card.firstName = kFNValue;
|
||||
card.lastName = kLNValue;
|
||||
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/addressbook/addressBook.properties"
|
||||
);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
function check_ab(abConfig) {
|
||||
// Test - Get the directory
|
||||
|
||||
let AB = MailServices.ab.getDirectory(abConfig.URI);
|
||||
const AB = MailServices.ab.getDirectory(abConfig.URI);
|
||||
|
||||
// Test - Is it the right type?
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ add_task(async function () {
|
|||
list.addCard(contact3);
|
||||
|
||||
// book.childCards should contain the list and all three contacts.
|
||||
let bookCards = book.childCards;
|
||||
const bookCards = book.childCards;
|
||||
equal(bookCards.length, 1 + 3);
|
||||
equal(list.UID, bookCards[0].UID);
|
||||
equal(contact1.UID, bookCards[1].UID);
|
||||
|
@ -56,7 +56,7 @@ add_task(async function () {
|
|||
equal(contact3.UID, listCards[1].UID);
|
||||
|
||||
// Reload the address book manager.
|
||||
let reloadPromise = TestUtils.topicObserved("addrbook-reloaded");
|
||||
const reloadPromise = TestUtils.topicObserved("addrbook-reloaded");
|
||||
Services.obs.notifyObservers(null, "addrbook-reload");
|
||||
await reloadPromise;
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@ var { VCardUtils } = ChromeUtils.import("resource:///modules/VCardUtils.jsm");
|
|||
|
||||
add_task(async function testMultiValueLast() {
|
||||
// Multiple last names.
|
||||
let vCard = formatVCard`
|
||||
const vCard = formatVCard`
|
||||
BEGIN:VCARD
|
||||
N:second-last,last;first;;;
|
||||
END:VCARD
|
||||
`;
|
||||
|
||||
let book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
let card = book.addCard(VCardUtils.vCardToAbCard(vCard));
|
||||
const book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const card = book.addCard(VCardUtils.vCardToAbCard(vCard));
|
||||
|
||||
Assert.deepEqual(card.vCardProperties.getFirstValue("n"), [
|
||||
["second-last", "last"],
|
||||
|
@ -36,14 +36,14 @@ add_task(async function testMultiValueLast() {
|
|||
|
||||
add_task(async function testMultiValueFirst() {
|
||||
// Multiple first names.
|
||||
let vCard = formatVCard`
|
||||
const vCard = formatVCard`
|
||||
BEGIN:VCARD
|
||||
N:last;first,second;;;
|
||||
END:VCARD
|
||||
`;
|
||||
|
||||
let book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
let card = book.addCard(VCardUtils.vCardToAbCard(vCard));
|
||||
const book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const card = book.addCard(VCardUtils.vCardToAbCard(vCard));
|
||||
|
||||
Assert.deepEqual(card.vCardProperties.getFirstValue("n"), [
|
||||
"last",
|
||||
|
@ -60,14 +60,14 @@ add_task(async function testMultiValueFirst() {
|
|||
|
||||
add_task(async function testNotEnoughValues() {
|
||||
// The name field doesn't have enough components. That's okay.
|
||||
let vCard = formatVCard`
|
||||
const vCard = formatVCard`
|
||||
BEGIN:VCARD
|
||||
N:last;first
|
||||
END:VCARD
|
||||
`;
|
||||
|
||||
let book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
let card = book.addCard(VCardUtils.vCardToAbCard(vCard));
|
||||
const book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const card = book.addCard(VCardUtils.vCardToAbCard(vCard));
|
||||
|
||||
Assert.deepEqual(card.vCardProperties.getFirstValue("n"), ["last", "first"]);
|
||||
Assert.equal(card.firstName, "first");
|
||||
|
@ -78,14 +78,14 @@ add_task(async function testNotEnoughValues() {
|
|||
|
||||
add_task(async function testStringValue() {
|
||||
// This is a bad value. Let's just ignore it for first/last name purposes.
|
||||
let vCard = formatVCard`
|
||||
const vCard = formatVCard`
|
||||
BEGIN:VCARD
|
||||
N:first last
|
||||
END:VCARD
|
||||
`;
|
||||
|
||||
let book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
let card = book.addCard(VCardUtils.vCardToAbCard(vCard));
|
||||
const book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const card = book.addCard(VCardUtils.vCardToAbCard(vCard));
|
||||
|
||||
Assert.deepEqual(card.vCardProperties.getFirstValue("n"), "first last");
|
||||
Assert.equal(card.firstName, "");
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
function run_test() {
|
||||
// get the Personal Address Book
|
||||
let pab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const pab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
Assert.ok(pab instanceof Ci.nsIAbDirectory);
|
||||
try {
|
||||
pab.deleteCards(null); // this should throw an error
|
||||
|
|
|
@ -17,13 +17,13 @@ function run_test() {
|
|||
Services.prefs.readUserPrefsFromFile(specialPrefs);
|
||||
|
||||
// Now load the ABs and check we've got all of them.
|
||||
let results = [
|
||||
const results = [
|
||||
{ name: "extension", result: false },
|
||||
{ name: kPABData.dirName, result: false },
|
||||
{ name: kCABData.dirName, result: false },
|
||||
];
|
||||
|
||||
for (let dir of MailServices.ab.directories) {
|
||||
for (const dir of MailServices.ab.directories) {
|
||||
for (let i = 0; i < results.length; ++i) {
|
||||
if (results[i].name == dir.dirName) {
|
||||
Assert.ok(!results[i].result);
|
||||
|
|
|
@ -81,7 +81,7 @@ add_task(async function moveCardToLocal() {
|
|||
* CardDAV directory.
|
||||
*/
|
||||
add_task(async function () {
|
||||
let deletedPromise = observer.waitFor("addrbook-contact-deleted");
|
||||
const deletedPromise = observer.waitFor("addrbook-contact-deleted");
|
||||
cardDAVDirectory.deleteCards(cardDAVDirectory.childCards);
|
||||
await deletedPromise;
|
||||
Assert.equal(cardDAVDirectory.childCards.length, 0);
|
||||
|
@ -92,7 +92,7 @@ add_task(async function copyCardToCardDAV() {
|
|||
cardDAVDirectory.dropCard(localCard, true);
|
||||
Assert.equal(cardDAVDirectory.childCards.length, 1);
|
||||
|
||||
let newCard = cardDAVDirectory.childCards[0];
|
||||
const newCard = cardDAVDirectory.childCards[0];
|
||||
Assert.notEqual(newCard.UID, "copyme");
|
||||
Assert.equal(localCard.getProperty("_etag", "EMPTY"), "EMPTY");
|
||||
Assert.equal(localCard.getProperty("_href", "EMPTY"), "EMPTY");
|
||||
|
@ -102,7 +102,7 @@ add_task(async function copyCardToCardDAV() {
|
|||
);
|
||||
|
||||
await observer.waitFor("addrbook-contact-updated");
|
||||
let newCardAfterSync = cardDAVDirectory.childCards[0];
|
||||
const newCardAfterSync = cardDAVDirectory.childCards[0];
|
||||
Assert.equal(newCardAfterSync.getProperty("_etag", "EMPTY"), "85");
|
||||
Assert.equal(
|
||||
newCardAfterSync.getProperty("_href", "EMPTY"),
|
||||
|
@ -116,7 +116,7 @@ add_task(async function copyCardToCardDAV() {
|
|||
|
||||
/** Remove the card from the CardDAV directory again. */
|
||||
add_task(async function () {
|
||||
let deletedPromise = observer.waitFor("addrbook-contact-deleted");
|
||||
const deletedPromise = observer.waitFor("addrbook-contact-deleted");
|
||||
cardDAVDirectory.deleteCards(cardDAVDirectory.childCards);
|
||||
await deletedPromise;
|
||||
Assert.equal(cardDAVDirectory.childCards.length, 0);
|
||||
|
@ -127,7 +127,7 @@ add_task(async function moveCardToCardDAV() {
|
|||
cardDAVDirectory.addCard(localCard);
|
||||
Assert.equal(cardDAVDirectory.childCards.length, 1);
|
||||
|
||||
let newCard = cardDAVDirectory.childCards[0];
|
||||
const newCard = cardDAVDirectory.childCards[0];
|
||||
// UID should not change
|
||||
Assert.equal(newCard.UID, "copyme");
|
||||
Assert.equal(localCard.getProperty("_etag", "EMPTY"), "EMPTY");
|
||||
|
@ -136,7 +136,7 @@ add_task(async function moveCardToCardDAV() {
|
|||
vCardEqual(localCard.getProperty("_vCard", "EMPTY"), initialVCard);
|
||||
|
||||
await observer.waitFor("addrbook-contact-updated");
|
||||
let newCardAfterSync = cardDAVDirectory.childCards[0];
|
||||
const newCardAfterSync = cardDAVDirectory.childCards[0];
|
||||
Assert.equal(newCardAfterSync.getProperty("_etag", "EMPTY"), "55");
|
||||
Assert.equal(
|
||||
newCardAfterSync.getProperty("_href", "EMPTY"),
|
||||
|
|
|
@ -96,7 +96,7 @@ async function subtestCreateCard() {
|
|||
await CardDAVServer.close();
|
||||
|
||||
let contactPromise = TestUtils.topicObserved("addrbook-contact-created");
|
||||
let syncFailedPromise = promiseSyncFailed();
|
||||
const syncFailedPromise = promiseSyncFailed();
|
||||
let newCard = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
|
@ -132,10 +132,10 @@ async function subtestCreateCard() {
|
|||
);
|
||||
|
||||
contactPromise = TestUtils.topicObserved("addrbook-contact-updated");
|
||||
let syncSucceededPromise = promiseSyncSucceeded();
|
||||
const syncSucceededPromise = promiseSyncSucceeded();
|
||||
await directory.syncWithServer();
|
||||
await syncSucceededPromise;
|
||||
let [notificationCard] = await contactPromise;
|
||||
const [notificationCard] = await contactPromise;
|
||||
notificationCard.QueryInterface(Ci.nsIAbCard);
|
||||
Assert.equal(
|
||||
notificationCard.UID,
|
||||
|
@ -194,7 +194,7 @@ async function subtestUpdateCard() {
|
|||
await CardDAVServer.close();
|
||||
|
||||
let contactPromise = TestUtils.topicObserved("addrbook-contact-updated");
|
||||
let syncFailedPromise = promiseSyncFailed();
|
||||
const syncFailedPromise = promiseSyncFailed();
|
||||
let cardToChange = directory.childCards.find(c => c.UID == "change-me");
|
||||
cardToChange.displayName = "I'm a new man!";
|
||||
cardToChange = directory.modifyCard(cardToChange);
|
||||
|
@ -223,10 +223,10 @@ async function subtestUpdateCard() {
|
|||
);
|
||||
|
||||
contactPromise = TestUtils.topicObserved("addrbook-contact-updated");
|
||||
let syncSucceededPromise = promiseSyncSucceeded();
|
||||
const syncSucceededPromise = promiseSyncSucceeded();
|
||||
await directory.syncWithServer();
|
||||
await syncSucceededPromise;
|
||||
let [notificationCard] = await contactPromise;
|
||||
const [notificationCard] = await contactPromise;
|
||||
notificationCard.QueryInterface(Ci.nsIAbCard);
|
||||
Assert.equal(
|
||||
notificationCard.UID,
|
||||
|
@ -284,9 +284,9 @@ async function subtestDeleteCard() {
|
|||
info("Going offline, deleting a card.");
|
||||
await CardDAVServer.close();
|
||||
|
||||
let contactPromise = TestUtils.topicObserved("addrbook-contact-deleted");
|
||||
let syncFailedPromise = promiseSyncFailed();
|
||||
let cardToDelete = directory.childCards.find(c => c.UID == "delete-me");
|
||||
const contactPromise = TestUtils.topicObserved("addrbook-contact-deleted");
|
||||
const syncFailedPromise = promiseSyncFailed();
|
||||
const cardToDelete = directory.childCards.find(c => c.UID == "delete-me");
|
||||
directory.deleteCards([cardToDelete]);
|
||||
await contactPromise;
|
||||
await syncFailedPromise;
|
||||
|
@ -316,7 +316,7 @@ async function subtestDeleteCard() {
|
|||
"card should NOT have been removed on server before syncing"
|
||||
);
|
||||
|
||||
let syncSucceededPromise = promiseSyncSucceeded();
|
||||
const syncSucceededPromise = promiseSyncSucceeded();
|
||||
await directory.syncWithServer();
|
||||
await syncSucceededPromise;
|
||||
|
||||
|
@ -349,7 +349,7 @@ async function subtestCreateDeleteCard() {
|
|||
await CardDAVServer.close();
|
||||
|
||||
let contactPromise = TestUtils.topicObserved("addrbook-contact-created");
|
||||
let syncFailedPromise = promiseSyncFailed();
|
||||
const syncFailedPromise = promiseSyncFailed();
|
||||
let newCard = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
|
@ -404,7 +404,7 @@ async function subtestCreateDeleteCard() {
|
|||
await pretendToRestart(directory);
|
||||
CardDAVServer.reopen();
|
||||
|
||||
let syncSucceededPromise = promiseSyncSucceeded();
|
||||
const syncSucceededPromise = promiseSyncSucceeded();
|
||||
await directory.syncWithServer();
|
||||
await syncSucceededPromise;
|
||||
|
||||
|
@ -470,7 +470,7 @@ async function subtestStillOffline() {
|
|||
);
|
||||
|
||||
info("Still offline, deleting a card.");
|
||||
let cardToDelete = directory.childCards.find(c => c.UID == "a-new-card");
|
||||
const cardToDelete = directory.childCards.find(c => c.UID == "a-new-card");
|
||||
contactPromise = TestUtils.topicObserved("addrbook-contact-deleted");
|
||||
syncFailedPromise = promiseSyncFailed();
|
||||
directory.deleteCards([cardToDelete]);
|
||||
|
@ -505,7 +505,7 @@ async function subtestStillOffline() {
|
|||
await pretendToRestart(directory);
|
||||
CardDAVServer.reopen();
|
||||
|
||||
let syncSucceededPromise = promiseSyncSucceeded();
|
||||
const syncSucceededPromise = promiseSyncSucceeded();
|
||||
await directory.syncWithServer();
|
||||
await syncSucceededPromise;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
add_task(async () => {
|
||||
CardDAVServer.modifyCardOnPut = true;
|
||||
|
||||
let directory = await initDirectory();
|
||||
const directory = await initDirectory();
|
||||
await directory.fetchAllFromServer();
|
||||
|
||||
observer.init();
|
||||
|
@ -34,7 +34,7 @@ add_task(async () => {
|
|||
|
||||
// Wait for notifications. Both arrive at once so we listen for the first.
|
||||
|
||||
let newUID = await observer.waitFor("addrbook-contact-created");
|
||||
const newUID = await observer.waitFor("addrbook-contact-created");
|
||||
Assert.equal(newUID, "drac-wen-a");
|
||||
|
||||
// Check the original card was deleted.
|
||||
|
@ -48,7 +48,7 @@ add_task(async () => {
|
|||
// Check we have the card as modified by the server.
|
||||
|
||||
Assert.equal(directory.childCards.length, 1);
|
||||
let modifiedCard = directory.childCards[0];
|
||||
const modifiedCard = directory.childCards[0];
|
||||
Assert.equal(modifiedCard.UID, "drac-wen-a");
|
||||
Assert.equal(modifiedCard.getProperty("_etag", ""), "92");
|
||||
Assert.equal(
|
||||
|
|
|
@ -18,7 +18,7 @@ async function subtest() {
|
|||
"BEGIN:VCARD\r\nUID:delete-me\r\nFN:I'm going to be deleted.\r\nEND:VCARD\r\n"
|
||||
);
|
||||
|
||||
let directory = await initDirectory();
|
||||
const directory = await initDirectory();
|
||||
|
||||
// We'll only use this for the initial sync, so I think it's okay to use
|
||||
// bulkAddCards and not get a notification for every contact.
|
||||
|
@ -26,9 +26,9 @@ async function subtest() {
|
|||
await directory.fetchAllFromServer();
|
||||
|
||||
info("Cards:");
|
||||
let cardMap = new Map();
|
||||
let oldETags = new Map();
|
||||
for (let card of directory.childCards) {
|
||||
const cardMap = new Map();
|
||||
const oldETags = new Map();
|
||||
for (const card of directory.childCards) {
|
||||
info(card.displayName);
|
||||
info(card.getProperty("_href", ""));
|
||||
info(card.getProperty("_etag", ""));
|
||||
|
@ -74,7 +74,7 @@ async function subtest() {
|
|||
|
||||
info("Cards:");
|
||||
cardMap.clear();
|
||||
for (let card of directory.childCards) {
|
||||
for (const card of directory.childCards) {
|
||||
info(card.displayName);
|
||||
info(card.getProperty("_href", ""));
|
||||
info(card.getProperty("_etag", ""));
|
||||
|
|
|
@ -18,7 +18,7 @@ async function subtest() {
|
|||
"BEGIN:VCARD\r\nUID:delete-me\r\nFN:I'm going to be deleted.\r\nEND:VCARD\r\n"
|
||||
);
|
||||
|
||||
let directory = await initDirectory();
|
||||
const directory = await initDirectory();
|
||||
|
||||
// We'll only use this for the initial sync, so I think it's okay to use
|
||||
// bulkAddCards and not get a notification for every contact.
|
||||
|
@ -29,9 +29,9 @@ async function subtest() {
|
|||
info(`Token is: ${lastSyncToken}`);
|
||||
|
||||
info("Cards:");
|
||||
let cardMap = new Map();
|
||||
let oldETags = new Map();
|
||||
for (let card of directory.childCards) {
|
||||
const cardMap = new Map();
|
||||
const oldETags = new Map();
|
||||
for (const card of directory.childCards) {
|
||||
info(
|
||||
` ${card.displayName} [${card.getProperty(
|
||||
"_href",
|
||||
|
@ -82,7 +82,7 @@ async function subtest() {
|
|||
|
||||
info("Cards:");
|
||||
cardMap.clear();
|
||||
for (let card of directory.childCards) {
|
||||
for (const card of directory.childCards) {
|
||||
info(
|
||||
` ${card.displayName} [${card.getProperty(
|
||||
"_href",
|
||||
|
@ -318,7 +318,7 @@ add_task(async function testExpiredToken() {
|
|||
"BEGIN:VCARD\r\nUID:third\r\nFN:Third Person\r\nEND:VCARD\r\n"
|
||||
);
|
||||
|
||||
let directory = await initDirectory();
|
||||
const directory = await initDirectory();
|
||||
|
||||
info("Initial sync with server.");
|
||||
await directory.fetchAllFromServer();
|
||||
|
@ -326,7 +326,7 @@ add_task(async function testExpiredToken() {
|
|||
info(`Token is: ${directory._syncToken}`);
|
||||
|
||||
info("Cards:");
|
||||
for (let card of directory.childCards) {
|
||||
for (const card of directory.childCards) {
|
||||
info(
|
||||
` ${card.displayName} [${card.getProperty(
|
||||
"_href",
|
||||
|
@ -363,7 +363,7 @@ add_task(async function testExpiredToken() {
|
|||
|
||||
info("Sync with server.");
|
||||
|
||||
let notificationPromise = TestUtils.topicObserved(
|
||||
const notificationPromise = TestUtils.topicObserved(
|
||||
"addrbook-directory-invalidated"
|
||||
);
|
||||
observer.init();
|
||||
|
@ -381,7 +381,7 @@ add_task(async function testExpiredToken() {
|
|||
info(`Token is now: ${directory._syncToken}`);
|
||||
|
||||
info("Cards:");
|
||||
for (let card of directory.childCards) {
|
||||
for (const card of directory.childCards) {
|
||||
info(
|
||||
` ${card.displayName} [${card.getProperty(
|
||||
"_href",
|
||||
|
|
|
@ -24,7 +24,7 @@ function run_test() {
|
|||
loadABFile("data/cardForEmail", kPABData.fileName);
|
||||
|
||||
// Test - Get the directory
|
||||
let AB = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const AB = MailServices.ab.getDirectory(kPABData.URI);
|
||||
|
||||
// Test - Check that a null string succeeds and does not
|
||||
// return a card (bug 404264)
|
||||
|
|
|
@ -27,7 +27,7 @@ function run_test() {
|
|||
|
||||
addressCollect.collectAddress("Other Book <other@book.invalid>", true);
|
||||
|
||||
let PAB = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const PAB = MailServices.ab.getDirectory(kPABData.URI);
|
||||
|
||||
var cards = PAB.childCards;
|
||||
|
||||
|
@ -37,6 +37,6 @@ function run_test() {
|
|||
Assert.equal(cards[0].primaryEmail, "other@book.invalid");
|
||||
|
||||
// Check the CAB has no cards.
|
||||
let CAB = MailServices.ab.getDirectory(kCABData.URI);
|
||||
const CAB = MailServices.ab.getDirectory(kCABData.URI);
|
||||
Assert.equal(CAB.childCards.length, 0);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ book.init("jsaddrbook://conversion.sqlite");
|
|||
|
||||
/** Tests an instance of nsAbCardProperty. */
|
||||
add_task(function testCardProperty() {
|
||||
let cardProperty = Cc[
|
||||
const cardProperty = Cc[
|
||||
"@mozilla.org/addressbook/cardproperty;1"
|
||||
].createInstance(Ci.nsIAbCard);
|
||||
cardProperty.UID = "99999999-8888-7777-6666-555555555555";
|
||||
|
@ -55,7 +55,7 @@ add_task(function testCardProperty() {
|
|||
* is therefore the same as a card that hasn't yet been migrated to vCard.
|
||||
*/
|
||||
add_task(function testABCard() {
|
||||
let abCard = new AddrBookCard();
|
||||
const abCard = new AddrBookCard();
|
||||
abCard._uid = "99999999-8888-7777-6666-555555555555";
|
||||
abCard._properties = new Map([
|
||||
["PopularityIndex", 0], // NO
|
||||
|
@ -81,7 +81,7 @@ add_task(function testABCard() {
|
|||
* created from storage. This instance *does* contain a vCard.
|
||||
*/
|
||||
add_task(function testABCardWithVCard() {
|
||||
let abCard = new AddrBookCard();
|
||||
const abCard = new AddrBookCard();
|
||||
abCard._uid = "99999999-8888-7777-6666-555555555555";
|
||||
abCard._properties = new Map([
|
||||
["PopularityIndex", 0], // NO
|
||||
|
@ -119,7 +119,7 @@ add_task(function testABCardWithVCard() {
|
|||
* created from storage. This instance *does* contain a vCard.
|
||||
*/
|
||||
add_task(function testABCardWithVCardOnly() {
|
||||
let abCard = new AddrBookCard();
|
||||
const abCard = new AddrBookCard();
|
||||
abCard._uid = "99999999-8888-7777-6666-555555555555";
|
||||
abCard._properties = new Map([
|
||||
["FakeProperty", "fake value"], // NO
|
||||
|
@ -152,7 +152,7 @@ add_task(function testABCardWithVCardOnly() {
|
|||
* properties that shouldn't exist because their value is stored in the vCard.
|
||||
*/
|
||||
add_task(function testABCardWithVCardAndExtraProps() {
|
||||
let abCard = new AddrBookCard();
|
||||
const abCard = new AddrBookCard();
|
||||
abCard._uid = "99999999-8888-7777-6666-555555555555";
|
||||
abCard._properties = new Map([
|
||||
["PopularityIndex", 0], // NO
|
||||
|
@ -191,7 +191,7 @@ add_task(function testABCardWithVCardAndExtraProps() {
|
|||
|
||||
/** Tests an instance of AddrBookCard, created from scratch. */
|
||||
add_task(function testABCardConstructed() {
|
||||
let abCard = new AddrBookCard();
|
||||
const abCard = new AddrBookCard();
|
||||
abCard.UID = "99999999-8888-7777-6666-555555555555";
|
||||
abCard.displayName = "display name";
|
||||
abCard.firstName = "first";
|
||||
|
@ -213,7 +213,7 @@ add_task(function testABCardConstructed() {
|
|||
|
||||
/** Tests an instance of AddrBookCard, created from scratch. */
|
||||
add_task(function testABCardConstructionThrows() {
|
||||
let abCard = new AddrBookCard();
|
||||
const abCard = new AddrBookCard();
|
||||
abCard.UID = "99999999-8888-7777-6666-555555555555";
|
||||
abCard.displayName = "display name";
|
||||
abCard.firstName = "first";
|
||||
|
@ -252,7 +252,7 @@ function saveCardAndTest(card, useNewUID) {
|
|||
|
||||
Assert.equal(book.childCardCount, 0);
|
||||
|
||||
let savedCard = book.dropCard(card, useNewUID);
|
||||
const savedCard = book.dropCard(card, useNewUID);
|
||||
Assert.deepEqual(Array.from(savedCard.properties, p => p.name).sort(), [
|
||||
"DisplayName",
|
||||
"FakeProperty",
|
||||
|
@ -281,7 +281,7 @@ function saveCardAndTest(card, useNewUID) {
|
|||
Assert.equal(savedCard.getProperty("FakeProperty", "WRONG"), "fake value");
|
||||
Assert.equal(savedCard.getProperty("PopularityIndex", "WRONG"), "0");
|
||||
|
||||
let vCard = savedCard.getProperty("_vCard", "WRONG");
|
||||
const vCard = savedCard.getProperty("_vCard", "WRONG");
|
||||
Assert.stringContains(vCard, "\r\nEMAIL;PREF=1:primary@email\r\n");
|
||||
Assert.stringContains(vCard, "\r\nEMAIL:second@email\r\n");
|
||||
Assert.stringContains(vCard, "\r\nFN:display name\r\n");
|
||||
|
@ -291,7 +291,7 @@ function saveCardAndTest(card, useNewUID) {
|
|||
Assert.stringContains(vCard, "\r\nTEL;TYPE=fax;VALUE=TEXT:1234567\r\n");
|
||||
Assert.stringContains(vCard, `\r\nUID:${savedCard.UID}\r\n`);
|
||||
|
||||
let modifiedDate = parseInt(
|
||||
const modifiedDate = parseInt(
|
||||
savedCard.getProperty("LastModifiedDate", ""),
|
||||
10
|
||||
);
|
||||
|
|
|
@ -15,7 +15,7 @@ function bug_537815_fixture_setup() {
|
|||
let i, key;
|
||||
|
||||
for (i = 1; i <= max_addressbooks; i++) {
|
||||
let ab_name = ab_prefix + i;
|
||||
const ab_name = ab_prefix + i;
|
||||
MailServices.ab.newAddressBook(
|
||||
ab_name,
|
||||
"",
|
||||
|
@ -24,9 +24,9 @@ function bug_537815_fixture_setup() {
|
|||
dump("created: " + ab_name + "\n");
|
||||
|
||||
for (var j = 1; j < 2; j++) {
|
||||
for (let elem of MailServices.ab.directories) {
|
||||
let uri = elem.URI;
|
||||
let dir = MailServices.ab.getDirectory(uri);
|
||||
for (const elem of MailServices.ab.directories) {
|
||||
const uri = elem.URI;
|
||||
const dir = MailServices.ab.getDirectory(uri);
|
||||
|
||||
dump("considering: j: " + j + " " + elem.dirName + "\n");
|
||||
|
||||
|
@ -50,12 +50,12 @@ function bug_537815_fixture_setup() {
|
|||
}
|
||||
|
||||
function bug_537815_test() {
|
||||
for (let elem of MailServices.ab.directories) {
|
||||
let uri = elem.URI;
|
||||
let dir = MailServices.ab.getDirectory(uri);
|
||||
for (const elem of MailServices.ab.directories) {
|
||||
const uri = elem.URI;
|
||||
const dir = MailServices.ab.getDirectory(uri);
|
||||
if (elem.dirName.startsWith(ab_prefix)) {
|
||||
for (let abCard of dir.childCards) {
|
||||
for (let key in card_properties) {
|
||||
for (const abCard of dir.childCards) {
|
||||
for (const key in card_properties) {
|
||||
abCard.getProperty(key, null);
|
||||
}
|
||||
}
|
||||
|
@ -71,15 +71,15 @@ function test_bug_537815() {
|
|||
}
|
||||
|
||||
function bug_537815_fixture_tear_down() {
|
||||
let a_uri = {};
|
||||
for (let elem of MailServices.ab.directories) {
|
||||
const a_uri = {};
|
||||
for (const elem of MailServices.ab.directories) {
|
||||
if (elem.dirName.startsWith(ab_prefix)) {
|
||||
a_uri[elem.URI] = true;
|
||||
dump("to be deleted: " + elem.dirName + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
for (let uri in a_uri) {
|
||||
for (const uri in a_uri) {
|
||||
MailServices.ab.deleteAddressBook(uri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ add_task(async function clearPref() {
|
|||
"jsaddrbook://history.sqlite"
|
||||
);
|
||||
|
||||
let dirPrefId = MailServices.ab.newAddressBook(
|
||||
const dirPrefId = MailServices.ab.newAddressBook(
|
||||
"delete me",
|
||||
"",
|
||||
Ci.nsIAbManager.JS_DIRECTORY_TYPE
|
||||
);
|
||||
let book = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
const book = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
|
||||
Assert.deepEqual(getExistingDirectories(), [
|
||||
"ldap_2.servers.pab",
|
||||
|
|
|
@ -21,12 +21,12 @@ var { VCardPropertyEntry } = ChromeUtils.import(
|
|||
);
|
||||
|
||||
async function subtest(cardConstructor) {
|
||||
let dirPrefId = MailServices.ab.newAddressBook(
|
||||
const dirPrefId = MailServices.ab.newAddressBook(
|
||||
"new book",
|
||||
"",
|
||||
Ci.nsIAbManager.JS_DIRECTORY_TYPE
|
||||
);
|
||||
let book = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
const book = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
|
||||
let contact1 = cardConstructor();
|
||||
contact1.UID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
|
||||
|
@ -104,7 +104,7 @@ async function compareAgainstFile(fileName, actual) {
|
|||
// exportDirectoryTo* functions are platform-dependent, except for VCard
|
||||
// which always uses Windows line endings.
|
||||
|
||||
let file = do_get_file(`data/${fileName}`);
|
||||
const file = do_get_file(`data/${fileName}`);
|
||||
let expected = await IOUtils.readUTF8(file.path);
|
||||
|
||||
if (AppConstants.platform != "win" && fileName != "export.vcf") {
|
||||
|
@ -113,8 +113,8 @@ async function compareAgainstFile(fileName, actual) {
|
|||
|
||||
// From here on, \r is just another character. It will be the last character
|
||||
// on lines where Windows line endings exist.
|
||||
let expectedLines = expected.split("\n");
|
||||
let actualLines = actual.split("\n");
|
||||
const expectedLines = expected.split("\n");
|
||||
const actualLines = actual.split("\n");
|
||||
info(actual);
|
||||
Assert.deepEqual(actualLines.sort(), expectedLines.sort());
|
||||
// equal(actualLines.length, expectedLines.length, "correct number of lines");
|
||||
|
|
|
@ -31,12 +31,12 @@ var observer = {
|
|||
"addrbook-list-member-removed",
|
||||
],
|
||||
setUp() {
|
||||
for (let topic of this.topics) {
|
||||
for (const topic of this.topics) {
|
||||
Services.obs.addObserver(observer, topic);
|
||||
}
|
||||
},
|
||||
cleanUp() {
|
||||
for (let topic of this.topics) {
|
||||
for (const topic of this.topics) {
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
}
|
||||
},
|
||||
|
@ -64,12 +64,12 @@ var observer = {
|
|||
);
|
||||
equal(observer.events.length, events.length);
|
||||
|
||||
let actualEvents = observer.events.slice();
|
||||
const actualEvents = observer.events.slice();
|
||||
observer.events.length = 0;
|
||||
|
||||
for (let j = 0; j < events.length; j++) {
|
||||
let expectedEvent = events[j];
|
||||
let actualEvent = actualEvents[j];
|
||||
const expectedEvent = events[j];
|
||||
const actualEvent = actualEvents[j];
|
||||
|
||||
for (let i = 0; i < expectedEvent.length; i++) {
|
||||
try {
|
||||
|
@ -94,10 +94,10 @@ var observer = {
|
|||
var baseAddressBookCount;
|
||||
|
||||
add_setup(function () {
|
||||
let profileDir = do_get_profile();
|
||||
const profileDir = do_get_profile();
|
||||
observer.setUp();
|
||||
|
||||
let dirs = MailServices.ab.directories;
|
||||
const dirs = MailServices.ab.directories;
|
||||
// On Mac we might be loading the OS X Address Book. If we are, then we
|
||||
// need to take acccount of that here, so that the test still pass on
|
||||
// development machines.
|
||||
|
@ -118,18 +118,18 @@ add_setup(function () {
|
|||
baseAddressBookCount = dirs.length;
|
||||
|
||||
// Check the PAB file was created.
|
||||
let pabFile = profileDir.clone();
|
||||
const pabFile = profileDir.clone();
|
||||
pabFile.append(kPABData.fileName);
|
||||
ok(pabFile.exists());
|
||||
|
||||
// Check the CAB file was created.
|
||||
let cabFile = profileDir.clone();
|
||||
const cabFile = profileDir.clone();
|
||||
cabFile.append(kCABData.fileName);
|
||||
ok(cabFile.exists());
|
||||
});
|
||||
|
||||
add_task(async function createAddressBook() {
|
||||
let dirPrefId = MailServices.ab.newAddressBook(
|
||||
const dirPrefId = MailServices.ab.newAddressBook(
|
||||
"new book",
|
||||
"",
|
||||
Ci.nsIAbManager.JS_DIRECTORY_TYPE
|
||||
|
@ -171,7 +171,7 @@ add_task(async function createAddressBook() {
|
|||
equal(MailServices.ab.directories.length, baseAddressBookCount + 1);
|
||||
|
||||
// Check the file was created.
|
||||
let dbFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
const dbFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
dbFile.append(FILE_NAME);
|
||||
ok(dbFile.exists());
|
||||
});
|
||||
|
@ -198,7 +198,7 @@ add_task(async function createContact() {
|
|||
contact = book.addCard(contact);
|
||||
observer.checkEvents(["addrbook-contact-created", contact, book.UID]);
|
||||
|
||||
let cards = book.childCards;
|
||||
const cards = book.childCards;
|
||||
equal(cards.length, 1);
|
||||
ok(cards[0].equals(contact));
|
||||
|
||||
|
@ -211,7 +211,10 @@ add_task(async function createContact() {
|
|||
equal(contact.primaryEmail, "test@invalid");
|
||||
equal(contact.getProperty("Foo", ""), "This will be deleted later.");
|
||||
equal(contact.isMailList, false);
|
||||
let modifiedDate = parseInt(contact.getProperty("LastModifiedDate", ""), 10);
|
||||
const modifiedDate = parseInt(
|
||||
contact.getProperty("LastModifiedDate", ""),
|
||||
10
|
||||
);
|
||||
Assert.lessOrEqual(modifiedDate, Date.now() / 1000);
|
||||
Assert.greater(modifiedDate, Date.now() / 1000 - 10);
|
||||
|
||||
|
@ -239,7 +242,7 @@ add_task(async function editContact() {
|
|||
contact.setProperty("Bar2", "");
|
||||
contact.setProperty("LastModifiedDate", 0);
|
||||
book.modifyCard(contact);
|
||||
let [, propertyEvent] = observer.checkEvents(
|
||||
const [, propertyEvent] = observer.checkEvents(
|
||||
["addrbook-contact-updated", contact, book.UID],
|
||||
["addrbook-contact-properties-updated", contact]
|
||||
);
|
||||
|
@ -286,7 +289,10 @@ add_task(async function editContact() {
|
|||
equal(contact.getProperty("Foo", "empty"), "empty");
|
||||
equal(contact.getProperty("Bar1", ""), "a new property");
|
||||
equal(contact.getProperty("Bar2", "no value"), "no value");
|
||||
let modifiedDate = parseInt(contact.getProperty("LastModifiedDate", ""), 10);
|
||||
const modifiedDate = parseInt(
|
||||
contact.getProperty("LastModifiedDate", ""),
|
||||
10
|
||||
);
|
||||
Assert.lessOrEqual(modifiedDate, Date.now() / 1000);
|
||||
Assert.greater(modifiedDate, Date.now() / 1000 - 10);
|
||||
});
|
||||
|
@ -301,10 +307,10 @@ add_task(async function createMailingList() {
|
|||
// Skip checking events temporarily, until listCard is defined.
|
||||
|
||||
// Check enumerations.
|
||||
let childNodes = book.childNodes;
|
||||
const childNodes = book.childNodes;
|
||||
equal(childNodes.length, 1);
|
||||
equal(childNodes[0].UID, list.UID); // TODO Object equality doesn't work because of XPCOM.
|
||||
let childCards = book.childCards;
|
||||
const childCards = book.childCards;
|
||||
equal(childCards.length, 2);
|
||||
if (childCards[0].isMailList) {
|
||||
listCard = childCards[0];
|
||||
|
@ -348,7 +354,7 @@ add_task(async function addMailingListMember() {
|
|||
|
||||
// Check list enumerations.
|
||||
equal(Array.from(list.childNodes).length, 0);
|
||||
let childCards = list.childCards;
|
||||
const childCards = list.childCards;
|
||||
equal(childCards.length, 1);
|
||||
ok(childCards[0].equals(contact));
|
||||
});
|
||||
|
@ -405,7 +411,7 @@ add_task(async function deleteAddressBook() {
|
|||
ok(!Services.prefs.prefHasUserValue("ldap_2.servers.newbook.description"));
|
||||
ok(!Services.prefs.prefHasUserValue("ldap_2.servers.newbook.filename"));
|
||||
ok(!Services.prefs.prefHasUserValue("ldap_2.servers.newbook.uid"));
|
||||
let dbFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
const dbFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
dbFile.append(FILE_NAME);
|
||||
ok(!dbFile.exists());
|
||||
equal(MailServices.ab.directories.length, baseAddressBookCount);
|
||||
|
|
|
@ -13,20 +13,20 @@ function run_test() {
|
|||
return;
|
||||
}
|
||||
|
||||
let abCountBeforeStart = MailServices.ab.directories.length;
|
||||
const abCountBeforeStart = MailServices.ab.directories.length;
|
||||
|
||||
// Test - Create an LDAP directory
|
||||
let abUri = MailServices.ab.newAddressBook(
|
||||
const abUri = MailServices.ab.newAddressBook(
|
||||
"test",
|
||||
kLDAPTestSpec,
|
||||
Ci.nsIAbManager.LDAP_DIRECTORY_TYPE
|
||||
);
|
||||
|
||||
let abCountAfterCreate = MailServices.ab.directories.length;
|
||||
const abCountAfterCreate = MailServices.ab.directories.length;
|
||||
Assert.equal(abCountAfterCreate, abCountBeforeStart + 1);
|
||||
|
||||
// Test - Check we have the directory.
|
||||
let abDir = MailServices.ab
|
||||
const abDir = MailServices.ab
|
||||
.getDirectory(kLDAPUriPrefix + abUri)
|
||||
.QueryInterface(Ci.nsIAbLDAPDirectory);
|
||||
|
||||
|
@ -43,7 +43,7 @@ function run_test() {
|
|||
// Test - searchDuringLocalAutocomplete
|
||||
|
||||
// Set up an account and identity in the account manager
|
||||
let identity = MailServices.accounts.createIdentity();
|
||||
const identity = MailServices.accounts.createIdentity();
|
||||
|
||||
const localAcTests = [
|
||||
// Online checks
|
||||
|
@ -200,6 +200,6 @@ function run_test() {
|
|||
|
||||
MailServices.ab.deleteAddressBook(abDir.URI);
|
||||
|
||||
let abCountAfterDelete = MailServices.ab.directories.length;
|
||||
const abCountAfterDelete = MailServices.ab.directories.length;
|
||||
Assert.equal(abCountAfterDelete, abCountBeforeStart);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ function run_test() {
|
|||
);
|
||||
|
||||
// Test - Check we have the directory.
|
||||
let abDir = MailServices.ab
|
||||
const abDir = MailServices.ab
|
||||
.getDirectory(kLDAPUriPrefix + abUri)
|
||||
.QueryInterface(Ci.nsIAbLDAPDirectory);
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ function run_test() {
|
|||
}
|
||||
|
||||
// Test set-up
|
||||
let abUri = MailServices.ab.newAddressBook(
|
||||
const abUri = MailServices.ab.newAddressBook(
|
||||
"test",
|
||||
kLDAPTestSpec,
|
||||
Ci.nsIAbManager.LDAP_DIRECTORY_TYPE
|
||||
);
|
||||
|
||||
let abDir = MailServices.ab
|
||||
const abDir = MailServices.ab
|
||||
.getDirectory(kLDAPUriPrefix + abUri)
|
||||
.QueryInterface(Ci.nsIAbLDAPDirectory);
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ const replicationService = Cc[
|
|||
|
||||
add_task(async () => {
|
||||
LDAPServer.open();
|
||||
let ldapContacts = await IOUtils.readJSON(jsonFile.path);
|
||||
const ldapContacts = await IOUtils.readJSON(jsonFile.path);
|
||||
|
||||
let bookPref = MailServices.ab.newAddressBook(
|
||||
const bookPref = MailServices.ab.newAddressBook(
|
||||
"XPCShell",
|
||||
`ldap://localhost:${LDAPServer.port}/people??sub?(objectclass=*)`,
|
||||
0
|
||||
);
|
||||
let book = MailServices.ab.getDirectoryFromId(bookPref);
|
||||
const book = MailServices.ab.getDirectoryFromId(bookPref);
|
||||
book.QueryInterface(Ci.nsIAbLDAPDirectory);
|
||||
equal(book.replicationFileName, "ldap.sqlite");
|
||||
|
||||
|
@ -36,7 +36,7 @@ add_task(async () => {
|
|||
|
||||
let progressResolve;
|
||||
let progressPromise = new Promise(resolve => (progressResolve = resolve));
|
||||
let progressListener = {
|
||||
const progressListener = {
|
||||
onStateChange(webProgress, request, stateFlags, status) {
|
||||
if (stateFlags & Ci.nsIWebProgressListener.STATE_START) {
|
||||
info("replication started");
|
||||
|
@ -66,7 +66,7 @@ add_task(async () => {
|
|||
LDAPServer.writeBindResponse();
|
||||
|
||||
await LDAPServer.read(LDAPServer.SearchRequest);
|
||||
for (let contact of Object.values(ldapContacts)) {
|
||||
for (const contact of Object.values(ldapContacts)) {
|
||||
LDAPServer.writeSearchResultEntry(contact);
|
||||
}
|
||||
LDAPServer.writeSearchResultDone();
|
||||
|
|
|
@ -96,35 +96,35 @@ class PromiseSearchListener extends PromiseListener {
|
|||
|
||||
add_task(async function test_basic_query() {
|
||||
// Load in some test contact data (characters from Sherlock Holmes).
|
||||
let raw = await IOUtils.readUTF8(
|
||||
const raw = await IOUtils.readUTF8(
|
||||
do_get_file(
|
||||
"../../../../mailnews/addrbook/test/unit/data/ldap_contacts.json"
|
||||
).path
|
||||
);
|
||||
let testContacts = JSON.parse(raw);
|
||||
const testContacts = JSON.parse(raw);
|
||||
|
||||
// Set up fake LDAP server, loaded with the test contacts.
|
||||
let daemon = new LDAPDaemon();
|
||||
const daemon = new LDAPDaemon();
|
||||
daemon.add(...Object.values(testContacts));
|
||||
// daemon.setDebug(true);
|
||||
let server = new BinaryServer(LDAPHandlerFn, daemon);
|
||||
const server = new BinaryServer(LDAPHandlerFn, daemon);
|
||||
server.start();
|
||||
|
||||
// Connect to the fake server.
|
||||
let url = `ldap://localhost:${server.port}`;
|
||||
let ldapURL = Services.io.newURI(url).QueryInterface(Ci.nsILDAPURL);
|
||||
let conn = Cc["@mozilla.org/network/ldap-connection;1"]
|
||||
const url = `ldap://localhost:${server.port}`;
|
||||
const ldapURL = Services.io.newURI(url).QueryInterface(Ci.nsILDAPURL);
|
||||
const conn = Cc["@mozilla.org/network/ldap-connection;1"]
|
||||
.createInstance()
|
||||
.QueryInterface(Ci.nsILDAPConnection);
|
||||
|
||||
// Initialisation is async.
|
||||
let initListener = new PromiseInitListener();
|
||||
const initListener = new PromiseInitListener();
|
||||
conn.init(ldapURL, null, initListener, null, Ci.nsILDAPConnection.VERSION3);
|
||||
await initListener.promise;
|
||||
|
||||
// Perform bind.
|
||||
let bindListener = new PromiseBindListener();
|
||||
let bindOp = Cc["@mozilla.org/network/ldap-operation;1"].createInstance(
|
||||
const bindListener = new PromiseBindListener();
|
||||
const bindOp = Cc["@mozilla.org/network/ldap-operation;1"].createInstance(
|
||||
Ci.nsILDAPOperation
|
||||
);
|
||||
bindOp.init(conn, bindListener, null);
|
||||
|
@ -132,8 +132,8 @@ add_task(async function test_basic_query() {
|
|||
await bindListener.promise;
|
||||
|
||||
// Run a search.
|
||||
let searchListener = new PromiseSearchListener();
|
||||
let searchOp = Cc["@mozilla.org/network/ldap-operation;1"].createInstance(
|
||||
const searchListener = new PromiseSearchListener();
|
||||
const searchOp = Cc["@mozilla.org/network/ldap-operation;1"].createInstance(
|
||||
Ci.nsILDAPOperation
|
||||
);
|
||||
searchOp.init(conn, searchListener, null);
|
||||
|
@ -145,7 +145,7 @@ add_task(async function test_basic_query() {
|
|||
0, // timeOut
|
||||
100 // maxEntriesWanted
|
||||
);
|
||||
let matches = await searchListener.promise;
|
||||
const matches = await searchListener.promise;
|
||||
|
||||
// Make sure we got the contacts we expected (just use cn for comparing):
|
||||
const holmesCNs = ["Eurus Holmes", "Mycroft Holmes", "Sherlock Holmes"];
|
||||
|
@ -159,7 +159,7 @@ add_task(async function test_basic_query() {
|
|||
"Molly Hooper",
|
||||
"Mrs Hudson",
|
||||
];
|
||||
let cns = matches.map(ent => ent.getValues("cn")[0]);
|
||||
const cns = matches.map(ent => ent.getValues("cn")[0]);
|
||||
cns.sort();
|
||||
Assert.deepEqual(cns, holmesCNs);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
function checkLists(childNodes, number) {
|
||||
let count = 0;
|
||||
// See comment above for matching requirements
|
||||
for (let list of childNodes) {
|
||||
for (const list of childNodes) {
|
||||
if (list.isMailList && list.dirName.startsWith("TestList")) {
|
||||
Assert.equal(list.URI, `${kPABData.URI}/${list.UID}`);
|
||||
count++;
|
||||
|
@ -29,7 +29,7 @@ function run_test() {
|
|||
// lists need help initialising themselves
|
||||
MailServices.ab.directories;
|
||||
|
||||
let AB = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const AB = MailServices.ab.getDirectory(kPABData.URI);
|
||||
|
||||
// Test - Check all the expected mailing lists exist.
|
||||
|
||||
|
|
|
@ -25,23 +25,23 @@ function run_test() {
|
|||
);
|
||||
|
||||
var obs = new acObserver();
|
||||
let obsNews = new acObserver();
|
||||
let obsFollowup = new acObserver();
|
||||
const obsNews = new acObserver();
|
||||
const obsFollowup = new acObserver();
|
||||
|
||||
// Set up an identity in the account manager with the default settings
|
||||
let identity = MailServices.accounts.createIdentity();
|
||||
const identity = MailServices.accounts.createIdentity();
|
||||
|
||||
// Initially disable autocomplete
|
||||
identity.autocompleteToMyDomain = false;
|
||||
identity.email = "myemail@foo.invalid";
|
||||
|
||||
// Set up autocomplete parameters
|
||||
let params = JSON.stringify({ idKey: identity.key, type: "addr_to" });
|
||||
let paramsNews = JSON.stringify({
|
||||
const params = JSON.stringify({ idKey: identity.key, type: "addr_to" });
|
||||
const paramsNews = JSON.stringify({
|
||||
idKey: identity.key,
|
||||
type: "addr_newsgroups",
|
||||
});
|
||||
let paramsFollowup = JSON.stringify({
|
||||
const paramsFollowup = JSON.stringify({
|
||||
idKey: identity.key,
|
||||
type: "addr_followup",
|
||||
});
|
||||
|
|
|
@ -205,18 +205,18 @@ var CAB_CARD_DATA = [
|
|||
var CAB_LIST_DATA = [];
|
||||
|
||||
function setupAddressBookData(aDirURI, aCardData, aMailListData) {
|
||||
let ab = MailServices.ab.getDirectory(aDirURI);
|
||||
const ab = MailServices.ab.getDirectory(aDirURI);
|
||||
|
||||
// Getting all directories ensures we create all ABs because mailing
|
||||
// lists need help initialising themselves
|
||||
MailServices.ab.directories;
|
||||
|
||||
for (let card of ab.childCards) {
|
||||
for (const card of ab.childCards) {
|
||||
ab.dropCard(card, false);
|
||||
}
|
||||
|
||||
aCardData.forEach(function (cd) {
|
||||
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
const card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
for (var prop in cd) {
|
||||
|
@ -226,7 +226,7 @@ function setupAddressBookData(aDirURI, aCardData, aMailListData) {
|
|||
});
|
||||
|
||||
aMailListData.forEach(function (ld) {
|
||||
let list = Cc[
|
||||
const list = Cc[
|
||||
"@mozilla.org/addressbook/directoryproperty;1"
|
||||
].createInstance(Ci.nsIAbDirectory);
|
||||
list.isMailList = true;
|
||||
|
@ -250,16 +250,16 @@ add_task(async () => {
|
|||
);
|
||||
|
||||
var obs = new acObserver();
|
||||
let obsNews = new acObserver();
|
||||
let obsFollowup = new acObserver();
|
||||
const obsNews = new acObserver();
|
||||
const obsFollowup = new acObserver();
|
||||
|
||||
// Test - Check disabling of autocomplete
|
||||
|
||||
Services.prefs.setBoolPref("mail.enable_autocomplete", false);
|
||||
|
||||
let param = JSON.stringify({ type: "addr_to" });
|
||||
let paramNews = JSON.stringify({ type: "addr_newsgroups" });
|
||||
let paramFollowup = JSON.stringify({ type: "addr_followup" });
|
||||
const param = JSON.stringify({ type: "addr_to" });
|
||||
const paramNews = JSON.stringify({ type: "addr_newsgroups" });
|
||||
const paramFollowup = JSON.stringify({ type: "addr_followup" });
|
||||
|
||||
let resultPromise = obs.waitForResult();
|
||||
acs.startSearch("abc", param, null, obs);
|
||||
|
@ -371,7 +371,7 @@ add_task(async () => {
|
|||
|
||||
// Now check multiple matches
|
||||
async function checkInputItem(element, index) {
|
||||
let prevRes = obs._result;
|
||||
const prevRes = obs._result;
|
||||
print("Search #" + index + ": search=" + element.search);
|
||||
resultPromise = obs.waitForResult();
|
||||
acs.startSearch(element.search, param, prevRes, obs);
|
||||
|
@ -417,7 +417,7 @@ add_task(async () => {
|
|||
}
|
||||
}
|
||||
|
||||
for (let inputSet of inputs) {
|
||||
for (const inputSet of inputs) {
|
||||
for (let i = 0; i < inputSet.length; i++) {
|
||||
await checkInputItem(inputSet[i], i);
|
||||
}
|
||||
|
@ -425,9 +425,9 @@ add_task(async () => {
|
|||
|
||||
// Test - Popularity Index
|
||||
print("Checking by popularity index:");
|
||||
let pab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const pab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
|
||||
for (let card of pab.childCards) {
|
||||
for (const card of pab.childCards) {
|
||||
if (card.isMailList) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ add_task(async () => {
|
|||
|
||||
// Now check multiple matches
|
||||
async function checkInputItem(element, index) {
|
||||
let resultPromise = obs.waitForResult();
|
||||
const resultPromise = obs.waitForResult();
|
||||
acs.startSearch(
|
||||
element.search,
|
||||
JSON.stringify({ type: "addr_to", idKey: "" }),
|
||||
|
@ -185,7 +185,7 @@ add_task(async () => {
|
|||
}
|
||||
}
|
||||
|
||||
for (let inputSet of inputs) {
|
||||
for (const inputSet of inputs) {
|
||||
for (let i = 0; i < inputSet.length; i++) {
|
||||
await checkInputItem(inputSet[i], i);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ add_task(async () => {
|
|||
// Ensure all the directories are initialised.
|
||||
MailServices.ab.directories;
|
||||
|
||||
let ab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const ab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
|
||||
function createAndAddCard(element) {
|
||||
var card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
|
@ -114,7 +114,7 @@ add_task(async () => {
|
|||
|
||||
async function checkInputItem(element, index) {
|
||||
print("Search #" + index + ": search=" + element.search);
|
||||
let resultPromise = obs.waitForResult();
|
||||
const resultPromise = obs.waitForResult();
|
||||
acs.startSearch(
|
||||
element.search,
|
||||
JSON.stringify({ type: "addr_to" }),
|
||||
|
|
|
@ -147,7 +147,7 @@ add_task(async () => {
|
|||
// Ensure all the directories are initialised.
|
||||
MailServices.ab.directories;
|
||||
|
||||
let ab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const ab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
|
||||
function createAndAddCard(element) {
|
||||
var card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
|
@ -179,7 +179,7 @@ add_task(async () => {
|
|||
|
||||
async function checkSearch(element, index) {
|
||||
print("Search #" + index + ": search=" + element);
|
||||
let resultPromise = obs.waitForResult();
|
||||
const resultPromise = obs.waitForResult();
|
||||
acs.startSearch(
|
||||
element,
|
||||
JSON.stringify({ type: "addr_to", idKey: "" }),
|
||||
|
@ -217,7 +217,7 @@ add_task(async () => {
|
|||
var lastResult = null;
|
||||
|
||||
async function checkReductionSearch(element, index) {
|
||||
let resultPromise = obs.waitForResult();
|
||||
const resultPromise = obs.waitForResult();
|
||||
acs.startSearch(
|
||||
element,
|
||||
JSON.stringify({ type: "addr_to", idKey: "" }),
|
||||
|
|
|
@ -42,11 +42,11 @@ add_task(async () => {
|
|||
|
||||
// Test - Create a new search component
|
||||
|
||||
let acs = Cc["@mozilla.org/autocomplete/search;1?name=addrbook"].getService(
|
||||
const acs = Cc["@mozilla.org/autocomplete/search;1?name=addrbook"].getService(
|
||||
Ci.nsIAutoCompleteSearch
|
||||
);
|
||||
|
||||
let obs = new acObserver();
|
||||
const obs = new acObserver();
|
||||
|
||||
// Ensure we've got the comment column set up for extra checking.
|
||||
Services.prefs.setIntPref("mail.autoComplete.commentColumn", 1);
|
||||
|
@ -56,7 +56,7 @@ add_task(async () => {
|
|||
// Now check multiple matches
|
||||
async function checkInputItem(element, index) {
|
||||
print("Search #" + index + ": search=" + element.search);
|
||||
let resultPromise = obs.waitForResult();
|
||||
const resultPromise = obs.waitForResult();
|
||||
acs.startSearch(
|
||||
element.search,
|
||||
JSON.stringify({ type: "addr_to" }),
|
||||
|
@ -103,7 +103,7 @@ add_task(async () => {
|
|||
// in the file, so check that we're now setting the popularity to 10
|
||||
// and hence future tests don't have to convert it.
|
||||
if (element.expected[i] == 4) {
|
||||
let result = obs._result.QueryInterface(Ci.nsIAbAutoCompleteResult);
|
||||
const result = obs._result.QueryInterface(Ci.nsIAbAutoCompleteResult);
|
||||
Assert.equal(
|
||||
result.getCardAt(i).getProperty("PopularityIndex", -1),
|
||||
10
|
||||
|
@ -112,7 +112,7 @@ add_task(async () => {
|
|||
}
|
||||
}
|
||||
|
||||
for (let inputSet of inputs) {
|
||||
for (const inputSet of inputs) {
|
||||
for (let i = 0; i < inputSet.length; i++) {
|
||||
await checkInputItem(inputSet[i], i);
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ add_task(async () => {
|
|||
// Ensure all the directories are initialised.
|
||||
MailServices.ab.directories;
|
||||
|
||||
let ab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const ab = MailServices.ab.getDirectory(kPABData.URI);
|
||||
|
||||
function createAndAddCard(element) {
|
||||
var card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
|
@ -206,7 +206,7 @@ add_task(async () => {
|
|||
|
||||
async function checkInputItem(element, index) {
|
||||
print("Search #" + index + ": search=" + element.search);
|
||||
let resultPromise = obs.waitForResult();
|
||||
const resultPromise = obs.waitForResult();
|
||||
acs.startSearch(
|
||||
element.search,
|
||||
JSON.stringify({ type: "addr_to" }),
|
||||
|
|
|
@ -64,18 +64,18 @@ var PAB_CARD_DATA = [
|
|||
];
|
||||
|
||||
function setupAddressBookData(aDirURI, aCardData, aMailListData) {
|
||||
let ab = MailServices.ab.getDirectory(aDirURI);
|
||||
const ab = MailServices.ab.getDirectory(aDirURI);
|
||||
|
||||
// Getting all directories ensures we create all ABs because mailing
|
||||
// lists need help initialising themselves
|
||||
MailServices.ab.directories;
|
||||
|
||||
for (let card of ab.childCards) {
|
||||
for (const card of ab.childCards) {
|
||||
ab.dropCard(card, false);
|
||||
}
|
||||
|
||||
aCardData.forEach(function (cd) {
|
||||
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
const card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
for (var prop in cd) {
|
||||
|
@ -85,7 +85,7 @@ function setupAddressBookData(aDirURI, aCardData, aMailListData) {
|
|||
});
|
||||
|
||||
aMailListData.forEach(function (ld) {
|
||||
let list = Cc[
|
||||
const list = Cc[
|
||||
"@mozilla.org/addressbook/directoryproperty;1"
|
||||
].createInstance(Ci.nsIAbDirectory);
|
||||
list.isMailList = true;
|
||||
|
@ -108,13 +108,13 @@ add_task(async () => {
|
|||
|
||||
var obs = new acObserver();
|
||||
|
||||
let param = JSON.stringify({ type: "addr_to" });
|
||||
const param = JSON.stringify({ type: "addr_to" });
|
||||
|
||||
// Now check multiple matches
|
||||
async function checkInputItem(element, index) {
|
||||
let prevRes = obs._result;
|
||||
const prevRes = obs._result;
|
||||
print("Search #" + index + ": search=" + element.search);
|
||||
let resultPromise = obs.waitForResult();
|
||||
const resultPromise = obs.waitForResult();
|
||||
acs.startSearch(element.search, param, prevRes, obs);
|
||||
await resultPromise;
|
||||
|
||||
|
@ -154,7 +154,7 @@ add_task(async () => {
|
|||
}
|
||||
}
|
||||
|
||||
for (let inputSet of inputs) {
|
||||
for (const inputSet of inputs) {
|
||||
for (let i = 0; i < inputSet.length; i++) {
|
||||
await checkInputItem(inputSet[i], i);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ function checkDirs(aDirs, aDirArray) {
|
|||
// Don't modify the passed in array.
|
||||
var dirArray = aDirArray.concat();
|
||||
|
||||
for (let dir of aDirs) {
|
||||
for (const dir of aDirs) {
|
||||
var loc = dirArray.indexOf(dir.URI);
|
||||
|
||||
Assert.equal(MailServices.ab.getDirectory(dir.URI), dir);
|
||||
|
@ -29,7 +29,11 @@ function checkDirs(aDirs, aDirArray) {
|
|||
|
||||
function addDirectory(dirName) {
|
||||
// Add the directory
|
||||
let dirPrefId = MailServices.ab.newAddressBook(dirName, "", kPABData.dirType);
|
||||
const dirPrefId = MailServices.ab.newAddressBook(
|
||||
dirName,
|
||||
"",
|
||||
kPABData.dirType
|
||||
);
|
||||
return MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
*/
|
||||
|
||||
function addDirectory(dirName) {
|
||||
let dirPrefId = MailServices.ab.newAddressBook(dirName, "", kPABData.dirType);
|
||||
const dirPrefId = MailServices.ab.newAddressBook(
|
||||
dirName,
|
||||
"",
|
||||
kPABData.dirType
|
||||
);
|
||||
return MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
}
|
||||
|
||||
|
@ -20,23 +24,23 @@ function renameDirectory(directory, newName) {
|
|||
* the third one. Check if their names are still correct. (bug 745664)
|
||||
*/
|
||||
async function run_test() {
|
||||
let dirNames = ["testAb0", "testAb1", "testAb2", "testAb3"];
|
||||
let directories = [];
|
||||
const dirNames = ["testAb0", "testAb1", "testAb2", "testAb3"];
|
||||
const directories = [];
|
||||
|
||||
for (let dirName of dirNames) {
|
||||
for (const dirName of dirNames) {
|
||||
directories.push(addDirectory(dirName));
|
||||
}
|
||||
|
||||
dirNames[1] = "newTestAb1";
|
||||
renameDirectory(directories[1], dirNames[1]);
|
||||
for (let dir in dirNames) {
|
||||
for (const dir in dirNames) {
|
||||
Assert.equal(dirNames[dir], directories[dir].dirName);
|
||||
}
|
||||
await promiseDirectoryRemoved(directories[2].URI);
|
||||
dirNames.splice(2, 1);
|
||||
directories.splice(2, 1);
|
||||
|
||||
for (let dir in dirNames) {
|
||||
for (const dir in dirNames) {
|
||||
Assert.equal(dirNames[dir], directories[dir].dirName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
* always produce a unique preference branch. Check that it does.
|
||||
*/
|
||||
add_task(function testSameName() {
|
||||
let name0 = MailServices.ab.newAddressBook("name", null, kPABData.dirType);
|
||||
const name0 = MailServices.ab.newAddressBook("name", null, kPABData.dirType);
|
||||
equal(name0, "ldap_2.servers.name");
|
||||
|
||||
let name1 = MailServices.ab.newAddressBook("name", null, kPABData.dirType);
|
||||
const name1 = MailServices.ab.newAddressBook("name", null, kPABData.dirType);
|
||||
equal(name1, "ldap_2.servers.name_1");
|
||||
|
||||
let name2 = MailServices.ab.newAddressBook("name", null, kPABData.dirType);
|
||||
const name2 = MailServices.ab.newAddressBook("name", null, kPABData.dirType);
|
||||
equal(name2, "ldap_2.servers.name_2");
|
||||
|
||||
let name3 = MailServices.ab.newAddressBook("name", null, kPABData.dirType);
|
||||
const name3 = MailServices.ab.newAddressBook("name", null, kPABData.dirType);
|
||||
equal(name3, "ldap_2.servers.name_3");
|
||||
});
|
||||
|
||||
|
@ -25,7 +25,7 @@ add_task(function testSameName() {
|
|||
* that book and stores it in the preferences.
|
||||
*/
|
||||
function subtestCreateWithUID(type, uidValue) {
|
||||
let prefID = MailServices.ab.newAddressBook(
|
||||
const prefID = MailServices.ab.newAddressBook(
|
||||
"Got a UID",
|
||||
null,
|
||||
type,
|
||||
|
@ -37,7 +37,7 @@ function subtestCreateWithUID(type, uidValue) {
|
|||
"UID is saved to the preferences"
|
||||
);
|
||||
|
||||
let book = MailServices.ab.getDirectoryFromId(prefID);
|
||||
const book = MailServices.ab.getDirectoryFromId(prefID);
|
||||
Assert.equal(book.UID, uidValue, "created book has the right UID");
|
||||
}
|
||||
|
||||
|
|
|
@ -7,30 +7,32 @@
|
|||
add_task(async function createAddressBook() {
|
||||
Assert.ok(!MailServices.ab.getDirectoryFromUID("nonsense"));
|
||||
|
||||
let pabFromURI = MailServices.ab.getDirectory(kPABData.URI);
|
||||
let pabFromId = MailServices.ab.getDirectoryFromId(kPABData.dirPrefID);
|
||||
let pabFromUID = MailServices.ab.getDirectoryFromUID(pabFromURI.UID);
|
||||
const pabFromURI = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const pabFromId = MailServices.ab.getDirectoryFromId(kPABData.dirPrefID);
|
||||
const pabFromUID = MailServices.ab.getDirectoryFromUID(pabFromURI.UID);
|
||||
|
||||
Assert.equal(pabFromId, pabFromURI);
|
||||
Assert.equal(pabFromUID, pabFromURI);
|
||||
|
||||
let historyFromURI = MailServices.ab.getDirectory(kCABData.URI);
|
||||
let historyFromId = MailServices.ab.getDirectoryFromId(kCABData.dirPrefID);
|
||||
let historyFromUID = MailServices.ab.getDirectoryFromUID(historyFromURI.UID);
|
||||
const historyFromURI = MailServices.ab.getDirectory(kCABData.URI);
|
||||
const historyFromId = MailServices.ab.getDirectoryFromId(kCABData.dirPrefID);
|
||||
const historyFromUID = MailServices.ab.getDirectoryFromUID(
|
||||
historyFromURI.UID
|
||||
);
|
||||
|
||||
Assert.equal(historyFromId, historyFromURI);
|
||||
Assert.equal(historyFromUID, historyFromURI);
|
||||
Assert.notEqual(historyFromUID, pabFromUID);
|
||||
|
||||
let newPrefId = MailServices.ab.newAddressBook(
|
||||
const newPrefId = MailServices.ab.newAddressBook(
|
||||
"new book",
|
||||
"",
|
||||
kPABData.dirType
|
||||
);
|
||||
let newFromId = MailServices.ab.getDirectoryFromId(newPrefId);
|
||||
const newFromId = MailServices.ab.getDirectoryFromId(newPrefId);
|
||||
|
||||
let newFromURI = MailServices.ab.getDirectory(newFromId.URI);
|
||||
let newFromUID = MailServices.ab.getDirectoryFromUID(newFromId.UID);
|
||||
const newFromURI = MailServices.ab.getDirectory(newFromId.URI);
|
||||
const newFromUID = MailServices.ab.getDirectoryFromUID(newFromId.UID);
|
||||
|
||||
Assert.equal(newFromId, newFromURI);
|
||||
Assert.equal(newFromUID, newFromURI);
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
add_task(function testGetMailListFromName() {
|
||||
loadABFile("../../../data/abLists1", kPABData.fileName);
|
||||
|
||||
for (let listName of ["TestList1", "TestList2", "TestList3"]) {
|
||||
for (const listName of ["TestList1", "TestList2", "TestList3"]) {
|
||||
Assert.ok(
|
||||
MailServices.ab.mailListNameExists(listName),
|
||||
`AddrBookManager has ${listName}`
|
||||
);
|
||||
|
||||
let list = MailServices.ab.getMailListFromName(listName);
|
||||
const list = MailServices.ab.getMailListFromName(listName);
|
||||
Assert.ok(list, `"${listName}" is not null`);
|
||||
Assert.equal(
|
||||
list.dirName,
|
||||
|
|
|
@ -14,10 +14,10 @@ function run_test() {
|
|||
loadABFile("data/cardForEmail", kPABData.fileName);
|
||||
|
||||
// Test - Get the directory
|
||||
let AB = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const AB = MailServices.ab.getDirectory(kPABData.URI);
|
||||
var fullCard = null;
|
||||
|
||||
for (let tempCard of AB.childCards) {
|
||||
for (const tempCard of AB.childCards) {
|
||||
// We want the one with the right email...
|
||||
if (tempCard.primaryEmail == "PrimaryEmail1@test.invalid") {
|
||||
fullCard = tempCard;
|
||||
|
@ -28,11 +28,11 @@ function run_test() {
|
|||
|
||||
// Test - VCard.
|
||||
|
||||
let actual = fullCard.translateTo("vcard");
|
||||
const actual = fullCard.translateTo("vcard");
|
||||
Assert.ok(actual.startsWith("BEGIN%3AVCARD%0D%0A"));
|
||||
Assert.ok(actual.endsWith("%0D%0AEND%3AVCARD%0D%0A"));
|
||||
|
||||
let lines = decodeURIComponent(actual).split("\r\n");
|
||||
const lines = decodeURIComponent(actual).split("\r\n");
|
||||
// The theory, the lines of the vCard are valid in any order, so just check
|
||||
// that they exist. In practice they are in this order.
|
||||
Assert.ok(lines.includes("EMAIL;PREF=1:PrimaryEmail1@test.invalid"), "EMAIL");
|
||||
|
@ -88,13 +88,13 @@ function run_test() {
|
|||
// is obviously less than ideal, and we should fix this in a follow-up patch
|
||||
// in bug 761304
|
||||
|
||||
let tbXml =
|
||||
const tbXml =
|
||||
"<GeneratedName>\nDisplayName1</GeneratedName>\n<table><tr><td><section><labelrow><label>Display Name: </label><DisplayName>DisplayName1</DisplayName></labelrow><labelrow><label>Nickname: </label><NickName>NickName1</NickName></labelrow><PrimaryEmail>PrimaryEmail1@test.invalid</PrimaryEmail><SecondEmail>SecondEmail1\u00D0@test.invalid</SecondEmail></section></td></tr><tr><td><section><sectiontitle>Phone</sectiontitle><labelrow><label>Work: </label><WorkPhone>WorkPhone1</WorkPhone></labelrow><labelrow><label>Home: </label><HomePhone>HomePhone1</HomePhone></labelrow><labelrow><label>Fax: </label><FaxNumber>FaxNumber1</FaxNumber></labelrow><labelrow><label>Pager: </label><PagerNumber>PagerNumber1</PagerNumber></labelrow><labelrow><label>Mobile: </label><CellularNumber>CellularNumber1</CellularNumber></labelrow></section><section><sectiontitle>Other</sectiontitle><labelrow><label>Custom 1: </label><Custom1>Custom11</Custom1></labelrow><labelrow><label>Custom 2: </label><Custom2>Custom21</Custom2></labelrow><labelrow><label>Custom 3: </label><Custom3>Custom31</Custom3></labelrow><labelrow><label>Custom 4: </label><Custom4>Custom41</Custom4></labelrow><Notes>Notes1</Notes></section><section><sectiontitle>Chat</sectiontitle><labelrow><label>AIM: </label><_AimScreenName>ScreenName1</_AimScreenName></labelrow></section></td><td><section><sectiontitle>Home</sectiontitle><HomeAddress>HomeAddress11</HomeAddress><HomeAddress2>HomeAddress21</HomeAddress2><HomeCity>HomeCity1</HomeCity>, <HomeState>HomeState1</HomeState> <HomeZipCode>HomeZipCode1</HomeZipCode><HomeCountry>HomeCountry1</HomeCountry><WebPage2>http://WebPage11</WebPage2></section><section><sectiontitle>Work</sectiontitle><JobTitle>JobTitle1</JobTitle><Department>Department1</Department><Company>Organization1</Company><WorkAddress>WorkAddress1</WorkAddress><WorkAddress2>WorkAddress21</WorkAddress2><WorkCity>WorkCity1</WorkCity>, <WorkState>WorkState1</WorkState> <WorkZipCode>WorkZipCode1</WorkZipCode><WorkCountry>WorkCountry1</WorkCountry><WebPage1>http://WebPage21</WebPage1></section></td></tr></table>";
|
||||
|
||||
let smXml =
|
||||
const smXml =
|
||||
"<GeneratedName>\nDisplayName1</GeneratedName>\n<table><tr><td><section><labelrow><label>Display Name: </label><DisplayName>DisplayName1</DisplayName></labelrow><labelrow><label>Nickname: </label><NickName>NickName1</NickName></labelrow><PrimaryEmail>PrimaryEmail1@test.invalid</PrimaryEmail><SecondEmail>SecondEmail1\u00D0@test.invalid</SecondEmail><labelrow><label>Screen Name: </label><_AimScreenName>ScreenName1</_AimScreenName></labelrow></section></td></tr><tr><td><section><sectiontitle>Phone</sectiontitle><labelrow><label>Work: </label><WorkPhone>WorkPhone1</WorkPhone></labelrow><labelrow><label>Home: </label><HomePhone>HomePhone1</HomePhone></labelrow><labelrow><label>Fax: </label><FaxNumber>FaxNumber1</FaxNumber></labelrow><labelrow><label>Pager: </label><PagerNumber>PagerNumber1</PagerNumber></labelrow><labelrow><label>Mobile: </label><CellularNumber>CellularNumber1</CellularNumber></labelrow></section><section><sectiontitle>Other</sectiontitle><labelrow><label>Custom 1: </label><Custom1>Custom11</Custom1></labelrow><labelrow><label>Custom 2: </label><Custom2>Custom21</Custom2></labelrow><labelrow><label>Custom 3: </label><Custom3>Custom31</Custom3></labelrow><labelrow><label>Custom 4: </label><Custom4>Custom41</Custom4></labelrow><Notes>Notes1</Notes></section></td><td><section><sectiontitle>Home</sectiontitle><HomeAddress>HomeAddress11</HomeAddress><HomeAddress2>HomeAddress21</HomeAddress2><HomeCity>HomeCity1</HomeCity>, <HomeState>HomeState1</HomeState> <HomeZipCode>HomeZipCode1</HomeZipCode><HomeCountry>HomeCountry1</HomeCountry><WebPage2>http://WebPage11</WebPage2></section><section><sectiontitle>Work</sectiontitle><JobTitle>JobTitle1</JobTitle><Department>Department1</Department><Company>Organization1</Company><WorkAddress>WorkAddress1</WorkAddress><WorkAddress2>WorkAddress21</WorkAddress2><WorkCity>WorkCity1</WorkCity>, <WorkState>WorkState1</WorkState> <WorkZipCode>WorkZipCode1</WorkZipCode><WorkCountry>WorkCountry1</WorkCountry><WebPage1>http://WebPage21</WebPage1></section></td></tr></table>";
|
||||
|
||||
let XmlTrans = fullCard.translateTo("xml");
|
||||
const XmlTrans = fullCard.translateTo("xml");
|
||||
Assert.ok(XmlTrans == tbXml || XmlTrans == smXml);
|
||||
|
||||
// Test - base 64
|
||||
|
@ -103,7 +103,7 @@ function run_test() {
|
|||
// difference between Thunderbird and SeaMonkey. We'll deal with this in a
|
||||
// follow-up to bug 761304.
|
||||
|
||||
let tbXmlBase64 = btoa(`<?xml version="1.0"?>
|
||||
const tbXmlBase64 = btoa(`<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://messagebody/skin/abPrint.css"?>
|
||||
<directory>
|
||||
<title xmlns="http://www.w3.org/1999/xhtml">Address Book</title>
|
||||
|
@ -112,7 +112,7 @@ DisplayName1</GeneratedName>
|
|||
<table><tr><td><section><labelrow><label>Display Name: </label><DisplayName>DisplayName1</DisplayName></labelrow><labelrow><label>Nickname: </label><NickName>NickName1</NickName></labelrow><PrimaryEmail>PrimaryEmail1@test.invalid</PrimaryEmail><SecondEmail>SecondEmail1\xC3\x90@test.invalid</SecondEmail></section></td></tr><tr><td><section><sectiontitle>Phone</sectiontitle><labelrow><label>Work: </label><WorkPhone>WorkPhone1</WorkPhone></labelrow><labelrow><label>Home: </label><HomePhone>HomePhone1</HomePhone></labelrow><labelrow><label>Fax: </label><FaxNumber>FaxNumber1</FaxNumber></labelrow><labelrow><label>Pager: </label><PagerNumber>PagerNumber1</PagerNumber></labelrow><labelrow><label>Mobile: </label><CellularNumber>CellularNumber1</CellularNumber></labelrow></section><section><sectiontitle>Other</sectiontitle><labelrow><label>Custom 1: </label><Custom1>Custom11</Custom1></labelrow><labelrow><label>Custom 2: </label><Custom2>Custom21</Custom2></labelrow><labelrow><label>Custom 3: </label><Custom3>Custom31</Custom3></labelrow><labelrow><label>Custom 4: </label><Custom4>Custom41</Custom4></labelrow><Notes>Notes1</Notes></section><section><sectiontitle>Chat</sectiontitle><labelrow><label>AIM: </label><_AimScreenName>ScreenName1</_AimScreenName></labelrow></section></td><td><section><sectiontitle>Home</sectiontitle><HomeAddress>HomeAddress11</HomeAddress><HomeAddress2>HomeAddress21</HomeAddress2><HomeCity>HomeCity1</HomeCity>, <HomeState>HomeState1</HomeState> <HomeZipCode>HomeZipCode1</HomeZipCode><HomeCountry>HomeCountry1</HomeCountry><WebPage2>http://WebPage11</WebPage2></section><section><sectiontitle>Work</sectiontitle><JobTitle>JobTitle1</JobTitle><Department>Department1</Department><Company>Organization1</Company><WorkAddress>WorkAddress1</WorkAddress><WorkAddress2>WorkAddress21</WorkAddress2><WorkCity>WorkCity1</WorkCity>, <WorkState>WorkState1</WorkState> <WorkZipCode>WorkZipCode1</WorkZipCode><WorkCountry>WorkCountry1</WorkCountry><WebPage1>http://WebPage21</WebPage1></section></td></tr></table></directory>
|
||||
`);
|
||||
|
||||
let smXmlBase64 = btoa(`<?xml version="1.0"?>
|
||||
const smXmlBase64 = btoa(`<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://messagebody/skin/abPrint.css"?>
|
||||
<directory>
|
||||
<title xmlns="http://www.w3.org/1999/xhtml">Address Book</title>
|
||||
|
@ -121,7 +121,7 @@ DisplayName1</GeneratedName>
|
|||
<table><tr><td><section><labelrow><label>Display Name: </label><DisplayName>DisplayName1</DisplayName></labelrow><labelrow><label>Nickname: </label><NickName>NickName1</NickName></labelrow><PrimaryEmail>PrimaryEmail1@test.invalid</PrimaryEmail><SecondEmail>SecondEmail1\xC3\x90@test.invalid</SecondEmail><labelrow><label>Screen Name: </label><_AimScreenName>ScreenName1</_AimScreenName></labelrow></section></td></tr><tr><td><section><sectiontitle>Phone</sectiontitle><labelrow><label>Work: </label><WorkPhone>WorkPhone1</WorkPhone></labelrow><labelrow><label>Home: </label><HomePhone>HomePhone1</HomePhone></labelrow><labelrow><label>Fax: </label><FaxNumber>FaxNumber1</FaxNumber></labelrow><labelrow><label>Pager: </label><PagerNumber>PagerNumber1</PagerNumber></labelrow><labelrow><label>Mobile: </label><CellularNumber>CellularNumber1</CellularNumber></labelrow></section><section><sectiontitle>Other</sectiontitle><labelrow><label>Custom 1: </label><Custom1>Custom11</Custom1></labelrow><labelrow><label>Custom 2: </label><Custom2>Custom21</Custom2></labelrow><labelrow><label>Custom 3: </label><Custom3>Custom31</Custom3></labelrow><labelrow><label>Custom 4: </label><Custom4>Custom41</Custom4></labelrow><Notes>Notes1</Notes></section></td><td><section><sectiontitle>Home</sectiontitle><HomeAddress>HomeAddress11</HomeAddress><HomeAddress2>HomeAddress21</HomeAddress2><HomeCity>HomeCity1</HomeCity>, <HomeState>HomeState1</HomeState> <HomeZipCode>HomeZipCode1</HomeZipCode><HomeCountry>HomeCountry1</HomeCountry><WebPage2>http://WebPage11</WebPage2></section><section><sectiontitle>Work</sectiontitle><JobTitle>JobTitle1</JobTitle><Department>Department1</Department><Company>Organization1</Company><WorkAddress>WorkAddress1</WorkAddress><WorkAddress2>WorkAddress21</WorkAddress2><WorkCity>WorkCity1</WorkCity>, <WorkState>WorkState1</WorkState> <WorkZipCode>WorkZipCode1</WorkZipCode><WorkCountry>WorkCountry1</WorkCountry><WebPage1>http://WebPage21</WebPage1></section></td></tr></table></directory>
|
||||
`);
|
||||
|
||||
let XmlBase64Trans = fullCard.translateTo("base64xml");
|
||||
const XmlBase64Trans = fullCard.translateTo("base64xml");
|
||||
|
||||
Assert.ok(XmlBase64Trans == tbXmlBase64 || XmlBase64Trans == smXmlBase64);
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ add_task(function testGetMailListFromName() {
|
|||
loadABFile("../../../data/abLists1", kPABData.fileName);
|
||||
|
||||
// Test all top level lists are returned.
|
||||
let root = MailServices.ab.getDirectory(kPABData.URI);
|
||||
for (let listName of ["TestList1", "TestList2", "TestList3"]) {
|
||||
const root = MailServices.ab.getDirectory(kPABData.URI);
|
||||
for (const listName of ["TestList1", "TestList2", "TestList3"]) {
|
||||
Assert.ok(root.hasMailListWithName(listName), `parent has "${listName}"`);
|
||||
|
||||
let list = root.getMailListFromName(listName);
|
||||
const list = root.getMailListFromName(listName);
|
||||
Assert.ok(list, `"${listName}" is not null`);
|
||||
Assert.equal(
|
||||
list.dirName,
|
||||
|
|
|
@ -8,10 +8,10 @@ var { VCardUtils } = ChromeUtils.import("resource:///modules/VCardUtils.jsm");
|
|||
* Tests that vCard photo data is correctly translated into a URL for display.
|
||||
*/
|
||||
add_task(async function testVCardPhotoURL() {
|
||||
let jpegPrefix = "data:image/jpeg;base64,/9j/4AAQSkZJRgABA";
|
||||
let pngPrefix = "data:image/png;base64,iVBORw0KGgoAAAANSU";
|
||||
const jpegPrefix = "data:image/jpeg;base64,/9j/4AAQSkZJRgABA";
|
||||
const pngPrefix = "data:image/png;base64,iVBORw0KGgoAAAANSU";
|
||||
|
||||
for (let [fileName, expectedURL] of [
|
||||
for (const [fileName, expectedURL] of [
|
||||
// Version 3, binary data, binary value type
|
||||
["v3-binary-jpeg.vcf", jpegPrefix],
|
||||
["v3-binary-png.vcf", pngPrefix],
|
||||
|
@ -26,9 +26,9 @@ add_task(async function testVCardPhotoURL() {
|
|||
["v4-uri-png.vcf", pngPrefix],
|
||||
]) {
|
||||
info(`testing ${fileName}`);
|
||||
let file = do_get_file(`data/${fileName}`);
|
||||
let vCard = await IOUtils.readUTF8(file.path);
|
||||
let card = VCardUtils.vCardToAbCard(vCard);
|
||||
const file = do_get_file(`data/${fileName}`);
|
||||
const vCard = await IOUtils.readUTF8(file.path);
|
||||
const card = VCardUtils.vCardToAbCard(vCard);
|
||||
|
||||
Assert.equal(card.photoURL.substring(0, 40), expectedURL);
|
||||
}
|
||||
|
|
|
@ -21,19 +21,19 @@ add_task(async function () {
|
|||
* cleared when the preference changes.
|
||||
*/
|
||||
function getDisplayNameInAddressBook() {
|
||||
let card = MailServices.ab.cardForEmailAddress("first.last@invalid");
|
||||
const card = MailServices.ab.cardForEmailAddress("first.last@invalid");
|
||||
if (!card) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let preferDisplayName = card.getPropertyAsBool("PreferDisplayName", true);
|
||||
const preferDisplayName = card.getPropertyAsBool("PreferDisplayName", true);
|
||||
return preferDisplayName ? card.displayName : card.primaryEmail;
|
||||
}
|
||||
|
||||
Assert.equal(getPrefValue(), -999, "pref has no initial value");
|
||||
Assert.equal(getDisplayNameInAddressBook(), null, "card doesn't exist yet");
|
||||
|
||||
let book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
const book = MailServices.ab.getDirectory(kPABData.URI);
|
||||
let card = new AddrBookCard();
|
||||
card.firstName = "first";
|
||||
card.lastName = "last";
|
||||
|
|
|
@ -11,17 +11,17 @@ const { getModelQuery, generateQueryURI } = ChromeUtils.import(
|
|||
const jsonFile = do_get_file("data/ldap_contacts.json");
|
||||
|
||||
add_task(async () => {
|
||||
let contacts = await IOUtils.readJSON(jsonFile.path);
|
||||
const contacts = await IOUtils.readJSON(jsonFile.path);
|
||||
|
||||
let dirPrefId = MailServices.ab.newAddressBook(
|
||||
const dirPrefId = MailServices.ab.newAddressBook(
|
||||
"new book",
|
||||
"",
|
||||
Ci.nsIAbManager.JS_DIRECTORY_TYPE
|
||||
);
|
||||
let book = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
const book = MailServices.ab.getDirectoryFromId(dirPrefId);
|
||||
|
||||
for (let [name, { attributes }] of Object.entries(contacts)) {
|
||||
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
for (const [name, { attributes }] of Object.entries(contacts)) {
|
||||
const card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
card.displayName = attributes.cn;
|
||||
|
@ -31,9 +31,9 @@ add_task(async () => {
|
|||
contacts[name] = book.addCard(card);
|
||||
}
|
||||
|
||||
let doSearch = async function (searchString, ...expectedContacts) {
|
||||
let foundCards = await new Promise(resolve => {
|
||||
let listener = {
|
||||
const doSearch = async function (searchString, ...expectedContacts) {
|
||||
const foundCards = await new Promise(resolve => {
|
||||
const listener = {
|
||||
cards: [],
|
||||
onSearchFoundCard(card) {
|
||||
this.cards.push(card);
|
||||
|
@ -46,14 +46,14 @@ add_task(async () => {
|
|||
});
|
||||
|
||||
Assert.equal(foundCards.length, expectedContacts.length);
|
||||
for (let name of expectedContacts) {
|
||||
for (const name of expectedContacts) {
|
||||
Assert.ok(foundCards.find(c => c.equals(contacts[name])));
|
||||
}
|
||||
};
|
||||
|
||||
await doSearch("(DisplayName,c,watson)", "john", "mary");
|
||||
|
||||
let modelQuery = getModelQuery("mail.addr_book.autocompletequery.format");
|
||||
const modelQuery = getModelQuery("mail.addr_book.autocompletequery.format");
|
||||
await doSearch(
|
||||
generateQueryURI(modelQuery, ["holmes"]),
|
||||
"eurus",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
let { VCardProperties, VCardUtils } = ChromeUtils.import(
|
||||
const { VCardProperties, VCardUtils } = ChromeUtils.import(
|
||||
"resource:///modules/VCardUtils.jsm"
|
||||
);
|
||||
|
||||
|
@ -10,12 +10,12 @@ const ANY_UID = "UID:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
|
|||
|
||||
add_task(function testVCardToPropertyMap() {
|
||||
function check(vCardLine, expectedProps) {
|
||||
let vCard = `BEGIN:VCARD\r\n${vCardLine}\r\nEND:VCARD\r\n`;
|
||||
const vCard = `BEGIN:VCARD\r\n${vCardLine}\r\nEND:VCARD\r\n`;
|
||||
info(vCard);
|
||||
let properties = VCardProperties.fromVCard(vCard).toPropertyMap();
|
||||
const properties = VCardProperties.fromVCard(vCard).toPropertyMap();
|
||||
// Check that every property in expectedProps is present in `properties`.
|
||||
// No other property can be present unless it is in `propWhitelist`.
|
||||
for (let [name, value] of properties) {
|
||||
for (const [name, value] of properties) {
|
||||
if (name in expectedProps) {
|
||||
Assert.equal(value, expectedProps[name], `expected ${name}`);
|
||||
delete expectedProps[name];
|
||||
|
@ -24,7 +24,7 @@ add_task(function testVCardToPropertyMap() {
|
|||
}
|
||||
}
|
||||
|
||||
for (let name of Object.keys(expectedProps)) {
|
||||
for (const name of Object.keys(expectedProps)) {
|
||||
Assert.ok(false, `expected ${name} not found`);
|
||||
}
|
||||
}
|
||||
|
@ -292,10 +292,10 @@ add_task(function testVCardToPropertyMap() {
|
|||
|
||||
add_task(function testAbCardToVCard() {
|
||||
function check(abCardProps, ...expectedLines) {
|
||||
let abCard = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
const abCard = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
for (let [name, value] of Object.entries(abCardProps)) {
|
||||
for (const [name, value] of Object.entries(abCardProps)) {
|
||||
if (name == "UID") {
|
||||
abCard.UID = abCardProps.UID;
|
||||
continue;
|
||||
|
@ -303,9 +303,9 @@ add_task(function testAbCardToVCard() {
|
|||
abCard.setProperty(name, value);
|
||||
}
|
||||
|
||||
let vCard = VCardUtils.abCardToVCard(abCard);
|
||||
const vCard = VCardUtils.abCardToVCard(abCard);
|
||||
info(vCard);
|
||||
let vCardLines = vCard.split("\r\n");
|
||||
const vCardLines = vCard.split("\r\n");
|
||||
if (expectedLines.includes(ANY_UID)) {
|
||||
for (let i = 0; i < vCardLines.length; i++) {
|
||||
if (vCardLines[i].startsWith("UID:")) {
|
||||
|
@ -314,7 +314,7 @@ add_task(function testAbCardToVCard() {
|
|||
}
|
||||
}
|
||||
|
||||
for (let line of expectedLines) {
|
||||
for (const line of expectedLines) {
|
||||
Assert.ok(vCardLines.includes(line), line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
let { VCardUtils } = ChromeUtils.import("resource:///modules/VCardUtils.jsm");
|
||||
const { VCardUtils } = ChromeUtils.import("resource:///modules/VCardUtils.jsm");
|
||||
|
||||
add_task(async () => {
|
||||
function check(vCardLines, expectedProps) {
|
||||
|
@ -25,19 +25,19 @@ add_task(async () => {
|
|||
vCard = vCard.toLowerCase();
|
||||
}
|
||||
info(vCard);
|
||||
let abCard = VCardUtils.vCardToAbCard(vCard);
|
||||
for (let propertyEntry of abCard.vCardProperties.entries) {
|
||||
let index = expectedProps.findIndex(
|
||||
const abCard = VCardUtils.vCardToAbCard(vCard);
|
||||
for (const propertyEntry of abCard.vCardProperties.entries) {
|
||||
const index = expectedProps.findIndex(
|
||||
p =>
|
||||
p.name == propertyEntry.name &&
|
||||
p.value.toString() == propertyEntry.value.toString()
|
||||
);
|
||||
Assert.greater(index, -1);
|
||||
let [prop] = expectedProps.splice(index, 1);
|
||||
const [prop] = expectedProps.splice(index, 1);
|
||||
Assert.deepEqual(propertyEntry.params, prop.params ?? {});
|
||||
}
|
||||
|
||||
for (let { name, value } of expectedProps) {
|
||||
for (const { name, value } of expectedProps) {
|
||||
ok(false, `expected ${name}=${value} not found`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ var { VCardProperties, VCardPropertyEntry } = ChromeUtils.import(
|
|||
);
|
||||
|
||||
function propertyEqual(actual, expected, message) {
|
||||
let actualAsObject = {
|
||||
const actualAsObject = {
|
||||
name: actual.name,
|
||||
params: actual.params,
|
||||
type: actual.type,
|
||||
|
@ -40,7 +40,7 @@ function propertyArrayEqual(actual, expected, message) {
|
|||
* Tests that AddrBookCard supports vCard.
|
||||
*/
|
||||
add_task(function testAddrBookCard() {
|
||||
let card = new AddrBookCard();
|
||||
const card = new AddrBookCard();
|
||||
Assert.equal(card.supportsVCard, true, "AddrBookCard supports vCard");
|
||||
Assert.ok(card.vCardProperties, "AddrBookCard has vCardProperties");
|
||||
Assert.equal(card.vCardProperties.constructor.name, "VCardProperties");
|
||||
|
@ -50,7 +50,7 @@ add_task(function testAddrBookCard() {
|
|||
* Tests that nsAbCardProperty does not support vCard.
|
||||
*/
|
||||
add_task(function testABCardProperty() {
|
||||
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
const card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
|
||||
Ci.nsIAbCard
|
||||
);
|
||||
Assert.equal(
|
||||
|
@ -70,8 +70,8 @@ add_task(function testABCardProperty() {
|
|||
* simple value type.
|
||||
*/
|
||||
add_task(function testPropertyEntrySingleValue() {
|
||||
let entry = new VCardPropertyEntry("fn", {}, "text", "Juliet");
|
||||
let clone = entry.clone();
|
||||
const entry = new VCardPropertyEntry("fn", {}, "text", "Juliet");
|
||||
const clone = entry.clone();
|
||||
|
||||
Assert.ok(entry.equals(entry), "original is equal to itself");
|
||||
Assert.ok(entry.equals(clone), "original is equal to cloned object");
|
||||
|
@ -80,7 +80,7 @@ add_task(function testPropertyEntrySingleValue() {
|
|||
|
||||
Assert.equal(clone.value, entry.value, "values are identical");
|
||||
|
||||
let other = new VCardPropertyEntry("n", {}, "text", "Romeo");
|
||||
const other = new VCardPropertyEntry("n", {}, "text", "Romeo");
|
||||
Assert.ok(!entry.equals(other), "original is not equal to another object");
|
||||
Assert.ok(!other.equals(entry), "another object is not equal to original");
|
||||
});
|
||||
|
@ -91,14 +91,14 @@ add_task(function testPropertyEntrySingleValue() {
|
|||
*/
|
||||
add_task(function testPropertyEntryMultiValue() {
|
||||
// A name entry for somebody named "Mr One Two Three Four Senior".
|
||||
let entry = new VCardPropertyEntry("n", {}, "text", [
|
||||
const entry = new VCardPropertyEntry("n", {}, "text", [
|
||||
"Four",
|
||||
"One",
|
||||
["Two", "Three"],
|
||||
"Mr",
|
||||
"Senior",
|
||||
]);
|
||||
let clone = entry.clone();
|
||||
const clone = entry.clone();
|
||||
|
||||
Assert.ok(entry.equals(entry), "original is equal to itself");
|
||||
Assert.ok(entry.equals(clone), "original is equal to cloned object");
|
||||
|
@ -119,7 +119,7 @@ add_task(function testPropertyEntryMultiValue() {
|
|||
);
|
||||
|
||||
// A name entry for somebody named "Mr One Two Three Four Junior".
|
||||
let other = new VCardPropertyEntry("n", {}, "text", [
|
||||
const other = new VCardPropertyEntry("n", {}, "text", [
|
||||
"Four",
|
||||
"One",
|
||||
["Two", "Three"],
|
||||
|
@ -135,7 +135,7 @@ add_task(function testPropertyEntryMultiValue() {
|
|||
* then recreating the vCard.
|
||||
*/
|
||||
add_task(function testFromToVCard() {
|
||||
let inVCard = formatVCard`
|
||||
const inVCard = formatVCard`
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
FN:Mike Test
|
||||
|
@ -144,7 +144,7 @@ add_task(function testFromToVCard() {
|
|||
NICKNAME:Testing Mike
|
||||
CATEGORIES:testers,quality control,QA
|
||||
END:VCARD`;
|
||||
let properties = VCardProperties.fromVCard(inVCard);
|
||||
const properties = VCardProperties.fromVCard(inVCard);
|
||||
|
||||
Assert.equal(properties.entries.length, 6, "entry count");
|
||||
propertyEqual(
|
||||
|
@ -208,7 +208,7 @@ add_task(function testFromToVCard() {
|
|||
"multivalue entry with multiple values"
|
||||
);
|
||||
|
||||
let outVCard = properties.toVCard();
|
||||
const outVCard = properties.toVCard();
|
||||
Assert.equal(outVCard, inVCard, "vCard reproduction");
|
||||
});
|
||||
|
||||
|
@ -217,7 +217,7 @@ add_task(function testFromToVCard() {
|
|||
* properties, then recreating the Map.
|
||||
*/
|
||||
add_task(function testFromToPropertyMap() {
|
||||
let inProperties = [
|
||||
const inProperties = [
|
||||
["DisplayName", "Mike Test"],
|
||||
["LastName", "Test"],
|
||||
["FirstName", "Mike"],
|
||||
|
@ -314,9 +314,9 @@ add_task(function testFromToPropertyMap() {
|
|||
"custom4 entry"
|
||||
);
|
||||
|
||||
let outProperties = properties.toPropertyMap();
|
||||
const outProperties = properties.toPropertyMap();
|
||||
Assert.equal(outProperties.size, 8, "property count");
|
||||
for (let [key, value] of inProperties) {
|
||||
for (const [key, value] of inProperties) {
|
||||
Assert.equal(outProperties.get(key), value, `${key} property`);
|
||||
}
|
||||
|
||||
|
@ -341,19 +341,19 @@ add_task(function testFromToPropertyMap() {
|
|||
add_task(function testEntryMethods() {
|
||||
// Sanity check.
|
||||
|
||||
let props = new VCardProperties();
|
||||
const props = new VCardProperties();
|
||||
Assert.deepEqual(props.entries, [], "props has no entries");
|
||||
|
||||
// Add property entries.
|
||||
|
||||
// Real VCardPropertyEntry objects.
|
||||
let charlie = new VCardPropertyEntry(
|
||||
const charlie = new VCardPropertyEntry(
|
||||
"email",
|
||||
{ type: "home" },
|
||||
"text",
|
||||
"charlie@invalid"
|
||||
);
|
||||
let delta = new VCardPropertyEntry(
|
||||
const delta = new VCardPropertyEntry(
|
||||
"email",
|
||||
{ type: "work" },
|
||||
"text",
|
||||
|
@ -362,7 +362,7 @@ add_task(function testEntryMethods() {
|
|||
|
||||
// Ordinary objects for Assert.deepEqual comparison. Use these objects to be
|
||||
// sure of the values being tested.
|
||||
let data = {
|
||||
const data = {
|
||||
charlie: {
|
||||
name: "email",
|
||||
params: { type: "home" },
|
||||
|
@ -456,7 +456,7 @@ add_task(function testEntryMethods() {
|
|||
|
||||
// Clone a property entry.
|
||||
|
||||
let juliet = charlie.clone();
|
||||
const juliet = charlie.clone();
|
||||
Assert.notEqual(
|
||||
juliet,
|
||||
charlie,
|
||||
|
@ -499,11 +499,11 @@ add_task(function testEntryMethods() {
|
|||
* Uses the vCard 3 default entry types.
|
||||
*/
|
||||
add_task(function testValueMethods3() {
|
||||
let props = new VCardProperties();
|
||||
const props = new VCardProperties();
|
||||
|
||||
// Add a value.
|
||||
|
||||
let first = props.addValue("tel", "1234567");
|
||||
const first = props.addValue("tel", "1234567");
|
||||
propertyEqual(first, {
|
||||
name: "tel",
|
||||
params: {},
|
||||
|
@ -516,7 +516,7 @@ add_task(function testValueMethods3() {
|
|||
|
||||
// Add a second value.
|
||||
|
||||
let second = props.addValue("tel", "2345678");
|
||||
const second = props.addValue("tel", "2345678");
|
||||
propertyEqual(second, {
|
||||
name: "tel",
|
||||
params: {},
|
||||
|
@ -530,7 +530,7 @@ add_task(function testValueMethods3() {
|
|||
|
||||
// Add a value that already exists. The existing property should be returned.
|
||||
|
||||
let secondCopy = props.addValue("tel", "2345678");
|
||||
const secondCopy = props.addValue("tel", "2345678");
|
||||
Assert.equal(secondCopy, second);
|
||||
propertyArrayEqual(props.entries, [
|
||||
{ name: "tel", params: {}, type: "phone-number", value: "1234567" },
|
||||
|
@ -539,7 +539,7 @@ add_task(function testValueMethods3() {
|
|||
|
||||
// Add a third value.
|
||||
|
||||
let third = props.addValue("tel", "3456789");
|
||||
const third = props.addValue("tel", "3456789");
|
||||
propertyEqual(third, {
|
||||
name: "tel",
|
||||
params: {},
|
||||
|
@ -594,11 +594,11 @@ add_task(function testValueMethods3() {
|
|||
* Uses the vCard 4 default entry types.
|
||||
*/
|
||||
add_task(function testValueMethods4() {
|
||||
let props = new VCardProperties("4.0");
|
||||
const props = new VCardProperties("4.0");
|
||||
|
||||
// Add a value.
|
||||
|
||||
let first = props.addValue("tel", "tel:1234567");
|
||||
const first = props.addValue("tel", "tel:1234567");
|
||||
propertyEqual(first, {
|
||||
name: "tel",
|
||||
params: {},
|
||||
|
@ -612,7 +612,7 @@ add_task(function testValueMethods4() {
|
|||
|
||||
// Add a second value.
|
||||
|
||||
let second = props.addValue("tel", "tel:2345678");
|
||||
const second = props.addValue("tel", "tel:2345678");
|
||||
propertyEqual(second, {
|
||||
name: "tel",
|
||||
params: {},
|
||||
|
@ -627,7 +627,7 @@ add_task(function testValueMethods4() {
|
|||
|
||||
// Add a value that already exists. The existing property should be returned.
|
||||
|
||||
let secondCopy = props.addValue("tel", "tel:2345678");
|
||||
const secondCopy = props.addValue("tel", "tel:2345678");
|
||||
Assert.equal(secondCopy, second);
|
||||
propertyArrayEqual(props.entries, [
|
||||
{ name: "version", params: {}, type: "text", value: "4.0" },
|
||||
|
@ -637,7 +637,7 @@ add_task(function testValueMethods4() {
|
|||
|
||||
// Add a third value.
|
||||
|
||||
let third = props.addValue("tel", "tel:3456789");
|
||||
const third = props.addValue("tel", "tel:3456789");
|
||||
propertyEqual(third, {
|
||||
name: "tel",
|
||||
params: {},
|
||||
|
@ -698,7 +698,7 @@ add_task(function testValueMethods4() {
|
|||
* Tests retrieving entries and values in preference order.
|
||||
*/
|
||||
add_task(function testSortMethods() {
|
||||
let props = new VCardProperties();
|
||||
const props = new VCardProperties();
|
||||
props.addEntry(new VCardPropertyEntry("email", {}, "text", "third@invalid"));
|
||||
props.addEntry(
|
||||
new VCardPropertyEntry("email", { pref: 2 }, "text", "second@invalid")
|
||||
|
@ -737,7 +737,7 @@ add_task(function testSortMethods() {
|
|||
* Tests the `clone` method of VCardProperties.
|
||||
*/
|
||||
add_task(function testClone() {
|
||||
let properties = VCardProperties.fromVCard(
|
||||
const properties = VCardProperties.fromVCard(
|
||||
formatVCard`
|
||||
BEGIN:VCARD
|
||||
FN:this is a test
|
||||
|
@ -746,7 +746,7 @@ add_task(function testClone() {
|
|||
EMAIL:test@test.invalid
|
||||
END:VCARD`
|
||||
);
|
||||
let clone = properties.clone();
|
||||
const clone = properties.clone();
|
||||
|
||||
Assert.deepEqual(clone.entries, properties.entries);
|
||||
Assert.notEqual(clone.entries, properties.entries);
|
||||
|
@ -765,16 +765,16 @@ add_task(function testClone() {
|
|||
* `getGroupedEntries` method of VCardProperties.
|
||||
*/
|
||||
add_task(function testGroupEntries() {
|
||||
let vCard = formatVCard`
|
||||
const vCard = formatVCard`
|
||||
BEGIN:VCARD
|
||||
GROUP1.FN:test
|
||||
GROUP1.X-FOO:bar
|
||||
NOTE:this doesn't have a group
|
||||
END:VCARD`;
|
||||
|
||||
let properties = VCardProperties.fromVCard(vCard);
|
||||
const properties = VCardProperties.fromVCard(vCard);
|
||||
|
||||
let data = [
|
||||
const data = [
|
||||
{
|
||||
name: "fn",
|
||||
params: {
|
||||
|
@ -803,7 +803,7 @@ add_task(function testGroupEntries() {
|
|||
Assert.equal(properties.toVCard(), vCard);
|
||||
propertyArrayEqual(properties.getGroupedEntries("group1"), data.slice(0, 2));
|
||||
|
||||
let clone = properties.clone();
|
||||
const clone = properties.clone();
|
||||
propertyArrayEqual(clone.entries, data);
|
||||
Assert.equal(clone.toVCard(), vCard);
|
||||
propertyArrayEqual(clone.getGroupedEntries("group1"), data.slice(0, 2));
|
||||
|
@ -814,7 +814,7 @@ add_task(function testGroupEntries() {
|
|||
* other characters in URI values.
|
||||
*/
|
||||
add_task(function testGoogleEscaping() {
|
||||
let vCard = formatVCard`
|
||||
const vCard = formatVCard`
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
N:test;en\\\\c\\:oding;;;
|
||||
|
@ -826,7 +826,7 @@ add_task(function testGoogleEscaping() {
|
|||
URL:http\\://host/url\\:url\\;url\\,url\\\\url
|
||||
END:VCARD`;
|
||||
|
||||
let goodVCard = formatVCard`
|
||||
const goodVCard = formatVCard`
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
N:test;en\\\\c:oding;;;
|
||||
|
@ -838,7 +838,7 @@ add_task(function testGoogleEscaping() {
|
|||
URL:http://host/url:url;url,url\\url
|
||||
END:VCARD`;
|
||||
|
||||
let data = [
|
||||
const data = [
|
||||
{
|
||||
name: "version",
|
||||
params: {},
|
||||
|
@ -889,11 +889,13 @@ add_task(function testGoogleEscaping() {
|
|||
},
|
||||
];
|
||||
|
||||
let properties = VCardProperties.fromVCard(vCard, { isGoogleCardDAV: true });
|
||||
const properties = VCardProperties.fromVCard(vCard, {
|
||||
isGoogleCardDAV: true,
|
||||
});
|
||||
propertyArrayEqual(properties.entries, data);
|
||||
Assert.equal(properties.toVCard(), goodVCard);
|
||||
|
||||
let goodProperties = VCardProperties.fromVCard(goodVCard);
|
||||
const goodProperties = VCardProperties.fromVCard(goodVCard);
|
||||
propertyArrayEqual(goodProperties.entries, data);
|
||||
Assert.equal(goodProperties.toVCard(), goodVCard);
|
||||
});
|
||||
|
|
|
@ -6,8 +6,4 @@
|
|||
|
||||
module.exports = {
|
||||
extends: ["plugin:mozilla/valid-jsdoc"],
|
||||
rules: {
|
||||
// Enforce using `let` only when variables are reassigned.
|
||||
"prefer-const": ["error", { destructuring: "all" }],
|
||||
},
|
||||
};
|
||||
|
|
|
@ -122,7 +122,7 @@ function onLoad() {
|
|||
|
||||
let subject = "";
|
||||
if (window.arguments[1]) {
|
||||
let progressParams = window.arguments[1].QueryInterface(
|
||||
const progressParams = window.arguments[1].QueryInterface(
|
||||
Ci.nsIMsgComposeProgressParams
|
||||
);
|
||||
if (progressParams) {
|
||||
|
@ -133,12 +133,12 @@ function onLoad() {
|
|||
}
|
||||
|
||||
if (subject) {
|
||||
let title = itsASaveOperation
|
||||
const title = itsASaveOperation
|
||||
? "titleSaveMsgSubject"
|
||||
: "titleSendMsgSubject";
|
||||
document.title = gBundle.formatStringFromName(title, [subject]);
|
||||
} else {
|
||||
let title = itsASaveOperation ? "titleSaveMsg" : "titleSendMsg";
|
||||
const title = itsASaveOperation ? "titleSaveMsg" : "titleSendMsg";
|
||||
document.title = gBundle.GetStringFromName(title);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,18 +17,18 @@ class MailtoProtocolHandler {
|
|||
|
||||
newChannel(uri, loadInfo) {
|
||||
// Create an empty pipe to get an inputStream.
|
||||
let pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
|
||||
const pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
|
||||
pipe.init(true, true, 0, 0);
|
||||
pipe.outputStream.close();
|
||||
|
||||
// Create a channel so that we can set contentType onto it.
|
||||
let streamChannel = Cc[
|
||||
const streamChannel = Cc[
|
||||
"@mozilla.org/network/input-stream-channel;1"
|
||||
].createInstance(Ci.nsIInputStreamChannel);
|
||||
streamChannel.setURI(uri);
|
||||
streamChannel.contentStream = pipe.inputStream;
|
||||
|
||||
let channel = streamChannel.QueryInterface(Ci.nsIChannel);
|
||||
const channel = streamChannel.QueryInterface(Ci.nsIChannel);
|
||||
// With this set, a nsIContentHandler instance will take over to open a
|
||||
// compose window.
|
||||
channel.contentType = "application/x-mailto";
|
||||
|
|
|
@ -96,7 +96,7 @@ class MessageSend {
|
|||
originalMsgURI,
|
||||
compType
|
||||
);
|
||||
let { embeddedAttachments, embeddedObjects } =
|
||||
const { embeddedAttachments, embeddedObjects } =
|
||||
this._gatherEmbeddedAttachments(editor);
|
||||
|
||||
let bodyText = this._getBodyFromEditor(editor) || body;
|
||||
|
@ -232,14 +232,14 @@ class MessageSend {
|
|||
|
||||
// Initialize the error reporting mechanism.
|
||||
this.sendReport.reset();
|
||||
let deliverMode = isDraft
|
||||
const deliverMode = isDraft
|
||||
? Ci.nsIMsgSend.nsMsgSaveAsDraft
|
||||
: Ci.nsIMsgSend.nsMsgDeliverNow;
|
||||
this.sendReport.deliveryMode = deliverMode;
|
||||
|
||||
// Convert nsIMsgAttachedFile[] to nsIMsgAttachment[]
|
||||
for (let file of attachedFiles) {
|
||||
let attachment = Cc[
|
||||
for (const file of attachedFiles) {
|
||||
const attachment = Cc[
|
||||
"@mozilla.org/messengercompose/attachment;1"
|
||||
].createInstance(Ci.nsIMsgAttachment);
|
||||
attachment.name = file.realName;
|
||||
|
@ -249,8 +249,8 @@ class MessageSend {
|
|||
}
|
||||
|
||||
// Convert nsIMsgEmbeddedImageData[] to nsIMsgAttachment[]
|
||||
let embeddedAttachments = embeddedObjects.map(obj => {
|
||||
let attachment = Cc[
|
||||
const embeddedAttachments = embeddedObjects.map(obj => {
|
||||
const attachment = Cc[
|
||||
"@mozilla.org/messengercompose/attachment;1"
|
||||
].createInstance(Ci.nsIMsgAttachment);
|
||||
attachment.name = obj.name;
|
||||
|
@ -399,7 +399,7 @@ class MessageSend {
|
|||
this._msgCopy = null;
|
||||
|
||||
if (!this._isRetry) {
|
||||
let statusMsgEntry = Components.isSuccessCode(status)
|
||||
const statusMsgEntry = Components.isSuccessCode(status)
|
||||
? "copyMessageComplete"
|
||||
: "copyMessageFailed";
|
||||
this._setStatusMessage(
|
||||
|
@ -414,16 +414,16 @@ class MessageSend {
|
|||
}
|
||||
|
||||
if (!Components.isSuccessCode(status)) {
|
||||
let localFoldersAccountName =
|
||||
const localFoldersAccountName =
|
||||
MailServices.accounts.localFoldersServer.prettyName;
|
||||
let folder = lazy.MailUtils.getOrCreateFolder(this._folderUri);
|
||||
let accountName = folder?.server.prettyName;
|
||||
const folder = lazy.MailUtils.getOrCreateFolder(this._folderUri);
|
||||
const accountName = folder?.server.prettyName;
|
||||
if (!this._fcc || !localFoldersAccountName || !accountName) {
|
||||
this.fail(Cr.NS_OK, null);
|
||||
return;
|
||||
}
|
||||
|
||||
let params = [folder.name, accountName, localFoldersAccountName];
|
||||
const params = [folder.name, accountName, localFoldersAccountName];
|
||||
let promptMsg;
|
||||
switch (this._deliverMode) {
|
||||
case Ci.nsIMsgSend.nsMsgDeliverNow:
|
||||
|
@ -447,16 +447,16 @@ class MessageSend {
|
|||
break;
|
||||
}
|
||||
if (promptMsg) {
|
||||
let showCheckBox = { value: false };
|
||||
let buttonFlags =
|
||||
const showCheckBox = { value: false };
|
||||
const buttonFlags =
|
||||
Ci.nsIPrompt.BUTTON_POS_0 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING +
|
||||
Ci.nsIPrompt.BUTTON_POS_1 * Ci.nsIPrompt.BUTTON_TITLE_DONT_SAVE +
|
||||
Ci.nsIPrompt.BUTTON_POS_2 * Ci.nsIPrompt.BUTTON_TITLE_SAVE;
|
||||
let dialogTitle =
|
||||
const dialogTitle =
|
||||
this._composeBundle.GetStringFromName("SaveDialogTitle");
|
||||
let buttonLabelRety =
|
||||
const buttonLabelRety =
|
||||
this._composeBundle.GetStringFromName("buttonLabelRetry2");
|
||||
let buttonPressed = Services.prompt.confirmEx(
|
||||
const buttonPressed = Services.prompt.confirmEx(
|
||||
this._parentWindow,
|
||||
dialogTitle,
|
||||
promptMsg,
|
||||
|
@ -474,11 +474,11 @@ class MessageSend {
|
|||
this._sendProgress.processCanceledByUser &&
|
||||
Services.prefs.getBoolPref("mailnews.show_send_progress")
|
||||
) {
|
||||
let progress = Cc[
|
||||
const progress = Cc[
|
||||
"@mozilla.org/messenger/progress;1"
|
||||
].createInstance(Ci.nsIMsgProgress);
|
||||
|
||||
let params = Cc[
|
||||
const params = Cc[
|
||||
"@mozilla.org/messengercompose/composeprogressparameters;1"
|
||||
].createInstance(Ci.nsIMsgComposeProgressParams);
|
||||
params.subject = this._parentWindow.gMsgCompose.compFields.subject;
|
||||
|
@ -608,7 +608,7 @@ class MessageSend {
|
|||
);
|
||||
if (!Components.isSuccessCode(exitCode)) {
|
||||
let isNSSError = false;
|
||||
let errorName = lazy.MsgUtils.getErrorStringName(exitCode);
|
||||
const errorName = lazy.MsgUtils.getErrorStringName(exitCode);
|
||||
let errorMsg;
|
||||
if (
|
||||
[
|
||||
|
@ -632,7 +632,7 @@ class MessageSend {
|
|||
errorName
|
||||
);
|
||||
} else {
|
||||
let nssErrorsService = Cc[
|
||||
const nssErrorsService = Cc[
|
||||
"@mozilla.org/nss_errors_service;1"
|
||||
].getService(Ci.nsINSSErrorsService);
|
||||
try {
|
||||
|
@ -675,7 +675,7 @@ class MessageSend {
|
|||
}
|
||||
}
|
||||
if (isNSSError) {
|
||||
let u = url.QueryInterface(Ci.nsIMsgMailNewsUrl);
|
||||
const u = url.QueryInterface(Ci.nsIMsgMailNewsUrl);
|
||||
this.notifyListenerOnTransportSecurityError(
|
||||
null,
|
||||
exitCode,
|
||||
|
@ -793,14 +793,14 @@ class MessageSend {
|
|||
return;
|
||||
}
|
||||
|
||||
let warningSize = Services.prefs.getIntPref(
|
||||
const warningSize = Services.prefs.getIntPref(
|
||||
"mailnews.message_warning_size"
|
||||
);
|
||||
if (warningSize > 0 && file.fileSize > warningSize) {
|
||||
let messenger = Cc["@mozilla.org/messenger;1"].createInstance(
|
||||
const messenger = Cc["@mozilla.org/messenger;1"].createInstance(
|
||||
Ci.nsIMessenger
|
||||
);
|
||||
let msg = this._composeBundle.formatStringFromName(
|
||||
const msg = this._composeBundle.formatStringFromName(
|
||||
"largeMessageSendWarning",
|
||||
[messenger.formatFileSize(file.fileSize)]
|
||||
);
|
||||
|
@ -830,11 +830,11 @@ class MessageSend {
|
|||
if (!this._compFields.bcc) {
|
||||
return this._messageFile;
|
||||
}
|
||||
let deliveryFile = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
const deliveryFile = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
deliveryFile.append("nsemail.tmp");
|
||||
deliveryFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
|
||||
let content = await IOUtils.read(this._messageFile.path);
|
||||
let bodyIndex = content.findIndex(
|
||||
const content = await IOUtils.read(this._messageFile.path);
|
||||
const bodyIndex = content.findIndex(
|
||||
(el, index) =>
|
||||
// header and body are separated by \r\n\r\n
|
||||
el == 13 &&
|
||||
|
@ -842,10 +842,10 @@ class MessageSend {
|
|||
content[index + 2] == 13 &&
|
||||
content[index + 3] == 10
|
||||
);
|
||||
let header = new TextDecoder("UTF-8").decode(content.slice(0, bodyIndex));
|
||||
const header = new TextDecoder("UTF-8").decode(content.slice(0, bodyIndex));
|
||||
let lastLinePruned = false;
|
||||
let headerToWrite = "";
|
||||
for (let line of header.split("\r\n")) {
|
||||
for (const line of header.split("\r\n")) {
|
||||
if (line.startsWith("Bcc") || (line.startsWith(" ") && lastLinePruned)) {
|
||||
lastLinePruned = true;
|
||||
continue;
|
||||
|
@ -853,10 +853,10 @@ class MessageSend {
|
|||
lastLinePruned = false;
|
||||
headerToWrite += `${line}\r\n`;
|
||||
}
|
||||
let encodedHeader = new TextEncoder().encode(headerToWrite);
|
||||
const encodedHeader = new TextEncoder().encode(headerToWrite);
|
||||
// Prevent extra \r\n, which was already added to the last head line.
|
||||
let body = content.slice(bodyIndex + 2);
|
||||
let combinedContent = new Uint8Array(encodedHeader.length + body.length);
|
||||
const body = content.slice(bodyIndex + 2);
|
||||
const combinedContent = new Uint8Array(encodedHeader.length + body.length);
|
||||
combinedContent.set(encodedHeader);
|
||||
combinedContent.set(body, encodedHeader.length);
|
||||
await IOUtils.write(deliveryFile.path, combinedContent);
|
||||
|
@ -878,8 +878,8 @@ class MessageSend {
|
|||
// dummy envelope. The date string will be parsed by PR_ParseTimeString.
|
||||
// TODO: this should not be added to Maildir, see bug 1686852.
|
||||
let contentToWrite = `From - ${new Date().toUTCString()}\r\n`;
|
||||
let xMozillaStatus = lazy.MsgUtils.getXMozillaStatus(this._deliverMode);
|
||||
let xMozillaStatus2 = lazy.MsgUtils.getXMozillaStatus2(this._deliverMode);
|
||||
const xMozillaStatus = lazy.MsgUtils.getXMozillaStatus(this._deliverMode);
|
||||
const xMozillaStatus2 = lazy.MsgUtils.getXMozillaStatus2(this._deliverMode);
|
||||
if (xMozillaStatus) {
|
||||
contentToWrite += `X-Mozilla-Status: ${xMozillaStatus}\r\n`;
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ class MessageSend {
|
|||
}
|
||||
|
||||
// Create a separate copy file when there are extra headers.
|
||||
let copyFile = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
const copyFile = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
copyFile.append("nscopy.tmp");
|
||||
copyFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
|
||||
await IOUtils.writeUTF8(copyFile.path, contentToWrite);
|
||||
|
@ -946,7 +946,7 @@ class MessageSend {
|
|||
// Set fcc_header to a special folder in Local Folders "account" since can't
|
||||
// save to Sent mbox, typically because imap connection is down. This
|
||||
// folder is created if it doesn't yet exist.
|
||||
let rootFolder = MailServices.accounts.localFoldersServer.rootMsgFolder;
|
||||
const rootFolder = MailServices.accounts.localFoldersServer.rootMsgFolder;
|
||||
folderUri = rootFolder.URI + "/";
|
||||
|
||||
// Now append the special folder name folder to the local folder uri.
|
||||
|
@ -960,12 +960,12 @@ class MessageSend {
|
|||
) {
|
||||
// Typically, this appends "Sent-", "Drafts-" or "Templates-" to folder
|
||||
// and then has the account name appended, e.g., .../Sent-MyImapAccount.
|
||||
let folder = lazy.MailUtils.getOrCreateFolder(this._folderUri);
|
||||
const folder = lazy.MailUtils.getOrCreateFolder(this._folderUri);
|
||||
folderUri += folder.name + "-";
|
||||
}
|
||||
if (this._fcc) {
|
||||
// Get the account name where the "save to" failed.
|
||||
let accountName = lazy.MailUtils.getOrCreateFolder(this._fcc).server
|
||||
const accountName = lazy.MailUtils.getOrCreateFolder(this._fcc).server
|
||||
.prettyName;
|
||||
|
||||
// Now append the imap account name (escaped) to the folder uri.
|
||||
|
@ -984,7 +984,7 @@ class MessageSend {
|
|||
this._compFields.templateId)
|
||||
) {
|
||||
// Turn the draft/template ID into a folder URI string.
|
||||
let messenger = Cc["@mozilla.org/messenger;1"].createInstance(
|
||||
const messenger = Cc["@mozilla.org/messenger;1"].createInstance(
|
||||
Ci.nsIMessenger
|
||||
);
|
||||
try {
|
||||
|
@ -1021,7 +1021,7 @@ class MessageSend {
|
|||
);
|
||||
}
|
||||
folder = lazy.MailUtils.getOrCreateFolder(this._folderUri);
|
||||
let statusMsg = this._composeBundle.formatStringFromName(
|
||||
const statusMsg = this._composeBundle.formatStringFromName(
|
||||
"copyMessageStart",
|
||||
[folder?.name || "?"]
|
||||
);
|
||||
|
@ -1087,9 +1087,9 @@ class MessageSend {
|
|||
*/
|
||||
_filterSentMessage() {
|
||||
this.sendReport.currentProcess = Ci.nsIMsgSendReport.process_Filter;
|
||||
let folder = lazy.MailUtils.getExistingFolder(this._folderUri);
|
||||
let msgHdr = folder.GetMessageHeader(this._messageKey);
|
||||
let msgWindow = this._sendProgress?.msgWindow;
|
||||
const folder = lazy.MailUtils.getExistingFolder(this._folderUri);
|
||||
const msgHdr = folder.GetMessageHeader(this._messageKey);
|
||||
const msgWindow = this._sendProgress?.msgWindow;
|
||||
return MailServices.filters.applyFilters(
|
||||
Ci.nsMsgFilterType.PostOutgoing,
|
||||
[msgHdr],
|
||||
|
@ -1123,16 +1123,16 @@ class MessageSend {
|
|||
this._setStatusMessage(
|
||||
this._composeBundle.GetStringFromName("sendingMessage")
|
||||
);
|
||||
let recipients = [
|
||||
const recipients = [
|
||||
this._compFields.to,
|
||||
this._compFields.cc,
|
||||
this._compFields.bcc,
|
||||
].filter(Boolean);
|
||||
this._collectAddressesToAddressBook(recipients);
|
||||
let converter = Cc["@mozilla.org/messenger/mimeconverter;1"].getService(
|
||||
const converter = Cc["@mozilla.org/messenger/mimeconverter;1"].getService(
|
||||
Ci.nsIMimeConverter
|
||||
);
|
||||
let encodedRecipients = encodeURIComponent(
|
||||
const encodedRecipients = encodeURIComponent(
|
||||
converter.encodeMimePartIIStr_UTF8(
|
||||
recipients.join(","),
|
||||
true,
|
||||
|
@ -1143,8 +1143,8 @@ class MessageSend {
|
|||
lazy.MsgUtils.sendLogger.debug(
|
||||
`Delivering mail message <${this._compFields.messageId}>`
|
||||
);
|
||||
let deliveryListener = new MsgDeliveryListener(this, false);
|
||||
let msgStatus =
|
||||
const deliveryListener = new MsgDeliveryListener(this, false);
|
||||
const msgStatus =
|
||||
this._sendProgress instanceof Ci.nsIMsgStatusFeedback
|
||||
? this._sendProgress
|
||||
: this._statusFeedback;
|
||||
|
@ -1171,7 +1171,7 @@ class MessageSend {
|
|||
_deliverAsNews() {
|
||||
this.sendReport.currentProcess = Ci.nsIMsgSendReport.process_NNTP;
|
||||
lazy.MsgUtils.sendLogger.debug("Delivering news message");
|
||||
let deliveryListener = new MsgDeliveryListener(this, true);
|
||||
const deliveryListener = new MsgDeliveryListener(this, true);
|
||||
let msgWindow;
|
||||
try {
|
||||
msgWindow =
|
||||
|
@ -1194,15 +1194,15 @@ class MessageSend {
|
|||
* @param {string[]} recipients - Outgoing addresses including to/cc/bcc.
|
||||
*/
|
||||
_collectAddressesToAddressBook(recipients) {
|
||||
let createCard = Services.prefs.getBoolPref(
|
||||
const createCard = Services.prefs.getBoolPref(
|
||||
"mail.collect_email_address_outgoing",
|
||||
false
|
||||
);
|
||||
|
||||
let addressCollector = Cc[
|
||||
const addressCollector = Cc[
|
||||
"@mozilla.org/addressbook/services/addressCollector;1"
|
||||
].getService(Ci.nsIAbAddressCollector);
|
||||
for (let recipient of recipients) {
|
||||
for (const recipient of recipients) {
|
||||
addressCollector.collectAddress(recipient, createCard);
|
||||
}
|
||||
}
|
||||
|
@ -1235,22 +1235,22 @@ class MessageSend {
|
|||
* @returns {object[]} collected.embeddedObjects objects {element, url}
|
||||
*/
|
||||
_gatherEmbeddedAttachments(editor) {
|
||||
let embeddedAttachments = [];
|
||||
let embeddedObjects = [];
|
||||
const embeddedAttachments = [];
|
||||
const embeddedObjects = [];
|
||||
|
||||
if (!editor || !editor.document) {
|
||||
return { embeddedAttachments, embeddedObjects };
|
||||
}
|
||||
let nodes = [];
|
||||
const nodes = [];
|
||||
nodes.push(...editor.document.querySelectorAll("img"));
|
||||
nodes.push(...editor.document.querySelectorAll("a"));
|
||||
let body = editor.document.querySelector("body[background]");
|
||||
const body = editor.document.querySelector("body[background]");
|
||||
if (body) {
|
||||
nodes.push(body);
|
||||
}
|
||||
|
||||
let urlCidCache = {};
|
||||
for (let element of nodes) {
|
||||
const urlCidCache = {};
|
||||
for (const element of nodes) {
|
||||
if (element.tagName == "A" && element.href) {
|
||||
if (this._isLinkFreeText(element.innerHTML, element.href)) {
|
||||
// Set this special classname, which is recognized by nsIParserUtils,
|
||||
|
@ -1261,7 +1261,7 @@ class MessageSend {
|
|||
let isImage = false;
|
||||
let url;
|
||||
let name;
|
||||
let mozDoNotSend = element.getAttribute("moz-do-not-send");
|
||||
const mozDoNotSend = element.getAttribute("moz-do-not-send");
|
||||
if (mozDoNotSend && mozDoNotSend != "false") {
|
||||
// Only empty or moz-do-not-send="false" may be accepted later.
|
||||
continue;
|
||||
|
@ -1310,7 +1310,7 @@ class MessageSend {
|
|||
);
|
||||
urlCidCache[url] = cid;
|
||||
|
||||
let attachment = Cc[
|
||||
const attachment = Cc[
|
||||
"@mozilla.org/messengercompose/attachment;1"
|
||||
].createInstance(Ci.nsIMsgAttachment);
|
||||
attachment.name = name || lazy.MsgUtils.pickFileNameFromUrl(url);
|
||||
|
@ -1323,7 +1323,7 @@ class MessageSend {
|
|||
url,
|
||||
});
|
||||
|
||||
let newUrl = `cid:${cid}`;
|
||||
const newUrl = `cid:${cid}`;
|
||||
if (element.tagName == "BODY") {
|
||||
element.background = newUrl;
|
||||
} else if (element.tagName == "IMG") {
|
||||
|
@ -1343,7 +1343,7 @@ class MessageSend {
|
|||
* @param {string} embeddedObjects.url
|
||||
*/
|
||||
_restoreEditorContent(embeddedObjects) {
|
||||
for (let { element, url } of embeddedObjects) {
|
||||
for (const { element, url } of embeddedObjects) {
|
||||
if (element.tagName == "BODY") {
|
||||
element.background = url;
|
||||
} else if (element.tagName == "IMG") {
|
||||
|
@ -1365,7 +1365,7 @@ class MessageSend {
|
|||
return "";
|
||||
}
|
||||
|
||||
let flags =
|
||||
const flags =
|
||||
Ci.nsIDocumentEncoder.OutputFormatted |
|
||||
Ci.nsIDocumentEncoder.OutputNoFormattingInPre |
|
||||
Ci.nsIDocumentEncoder.OutputDisallowLineBreaking;
|
||||
|
@ -1374,7 +1374,7 @@ class MessageSend {
|
|||
|
||||
// No need to do conversion if forcing plain text.
|
||||
if (!this._compFields.forcePlainText) {
|
||||
let cs = Cc["@mozilla.org/txttohtmlconv;1"].getService(
|
||||
const cs = Cc["@mozilla.org/txttohtmlconv;1"].getService(
|
||||
Ci.mozITXTToHTMLConv
|
||||
);
|
||||
let csFlags = Ci.mozITXTToHTMLConv.kURLs;
|
||||
|
@ -1394,7 +1394,7 @@ class MessageSend {
|
|||
* @returns {string}
|
||||
*/
|
||||
_accountKeyForIdentity(identity) {
|
||||
let servers = MailServices.accounts.getServersForIdentity(identity);
|
||||
const servers = MailServices.accounts.getServersForIdentity(identity);
|
||||
return servers.length
|
||||
? MailServices.accounts.FindAccountForServer(servers[0])?.key
|
||||
: null;
|
||||
|
@ -1424,7 +1424,7 @@ class MsgDeliveryListener {
|
|||
|
||||
OnStopRunningUrl(url, exitCode) {
|
||||
lazy.MsgUtils.sendLogger.debug(`OnStopRunningUrl; exitCode=${exitCode}`);
|
||||
let mailUrl = url.QueryInterface(Ci.nsIMsgMailNewsUrl);
|
||||
const mailUrl = url.QueryInterface(Ci.nsIMsgMailNewsUrl);
|
||||
mailUrl.UnRegisterListener(this);
|
||||
|
||||
this._msgSend.sendDeliveryCallback(url, this._isNewsDelivery, exitCode);
|
||||
|
|
|
@ -58,13 +58,13 @@ class MimeEncoder {
|
|||
pickEncoding() {
|
||||
this._analyzeBody();
|
||||
|
||||
let strictlyMime = Services.prefs.getBoolPref("mail.strictly_mime");
|
||||
const strictlyMime = Services.prefs.getBoolPref("mail.strictly_mime");
|
||||
let needsB64 = false;
|
||||
let isUsingQP = false;
|
||||
|
||||
// Allow users to override our percentage-wise guess on whether
|
||||
// the file is text or binary.
|
||||
let forceB64 = Services.prefs.getBoolPref("mail.file_attach_binary");
|
||||
const forceB64 = Services.prefs.getBoolPref("mail.file_attach_binary");
|
||||
|
||||
// If the content-type is "image/" or something else known to be binary or
|
||||
// several flavors of newlines are present, use base64 unless we're attaching
|
||||
|
@ -110,7 +110,7 @@ class MimeEncoder {
|
|||
encodeP = false;
|
||||
}
|
||||
|
||||
let manager = Cc["@mozilla.org/charset-converter-manager;1"].getService(
|
||||
const manager = Cc["@mozilla.org/charset-converter-manager;1"].getService(
|
||||
Ci.nsICharsetConverterManager
|
||||
);
|
||||
let isCharsetMultiByte = false;
|
||||
|
@ -195,8 +195,8 @@ class MimeEncoder {
|
|||
let prevCharWasCr = false;
|
||||
|
||||
for (let i = 0; i < this._bodySize; i++) {
|
||||
let ch = this._body.charAt(i);
|
||||
let charCode = this._body.charCodeAt(i);
|
||||
const ch = this._body.charAt(i);
|
||||
const charCode = this._body.charCodeAt(i);
|
||||
if (charCode > 126) {
|
||||
this._highBitCount++;
|
||||
this._unPrintableCount++;
|
||||
|
@ -328,11 +328,11 @@ class MimeEncoder {
|
|||
* line width is no more than 72.
|
||||
*/
|
||||
_encodeBase64() {
|
||||
let encoded = btoa(this._body);
|
||||
const encoded = btoa(this._body);
|
||||
let ret = "";
|
||||
let length = encoded.length;
|
||||
const length = encoded.length;
|
||||
let i = 0;
|
||||
let limit = 72;
|
||||
const limit = 72;
|
||||
while (true) {
|
||||
if (i * limit > length) {
|
||||
break;
|
||||
|
@ -348,12 +348,12 @@ class MimeEncoder {
|
|||
*/
|
||||
_encodeQP() {
|
||||
let currentColumn = 0;
|
||||
let hexdigits = "0123456789ABCDEF";
|
||||
const hexdigits = "0123456789ABCDEF";
|
||||
let white = false;
|
||||
let out = "";
|
||||
|
||||
function encodeChar(ch) {
|
||||
let charCode = ch.charCodeAt(0);
|
||||
const charCode = ch.charCodeAt(0);
|
||||
let ret = "=";
|
||||
ret += hexdigits[charCode >> 4];
|
||||
ret += hexdigits[charCode & 0xf];
|
||||
|
@ -361,8 +361,8 @@ class MimeEncoder {
|
|||
}
|
||||
|
||||
for (let i = 0; i < this._bodySize; i++) {
|
||||
let ch = this._body.charAt(i);
|
||||
let charCode = this._body.charCodeAt(i);
|
||||
const ch = this._body.charAt(i);
|
||||
const charCode = this._body.charCodeAt(i);
|
||||
if (ch == "\r" || ch == "\n") {
|
||||
// If it's CRLF, swallow two chars instead of one.
|
||||
if (i + 1 < this._bodySize && ch == "\r" && this._body[i + 1] == "\n") {
|
||||
|
@ -372,7 +372,7 @@ class MimeEncoder {
|
|||
// Whitespace cannot be allowed to occur at the end of the line, so we
|
||||
// back up and replace the whitespace with its code.
|
||||
if (white) {
|
||||
let whiteChar = out.slice(-1);
|
||||
const whiteChar = out.slice(-1);
|
||||
out = out.slice(0, -1);
|
||||
out += encodeChar(whiteChar);
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@ const EXPORTED_SYMBOLS = ["MimeMessage"];
|
|||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
let { MimeMultiPart, MimePart } = ChromeUtils.import(
|
||||
const { MimeMultiPart, MimePart } = ChromeUtils.import(
|
||||
"resource:///modules/MimePart.jsm"
|
||||
);
|
||||
let { MsgUtils } = ChromeUtils.import(
|
||||
const { MsgUtils } = ChromeUtils.import(
|
||||
"resource:///modules/MimeMessageUtils.jsm"
|
||||
);
|
||||
let { jsmime } = ChromeUtils.import("resource:///modules/jsmime.jsm");
|
||||
const { jsmime } = ChromeUtils.import("resource:///modules/jsmime.jsm");
|
||||
|
||||
/**
|
||||
* A class to create a top MimePart and write to a tmp file. It works like this:
|
||||
|
@ -70,12 +70,12 @@ class MimeMessage {
|
|||
* @returns {nsIFile}
|
||||
*/
|
||||
async createMessageFile() {
|
||||
let topPart = this._initMimePart();
|
||||
let file = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
const topPart = this._initMimePart();
|
||||
const file = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
file.append("nsemail.eml");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
|
||||
|
||||
let fstream = Cc[
|
||||
const fstream = Cc[
|
||||
"@mozilla.org/network/file-output-stream;1"
|
||||
].createInstance(Ci.nsIFileOutputStream);
|
||||
this._fstream = Cc[
|
||||
|
@ -104,9 +104,9 @@ class MimeMessage {
|
|||
* @returns {MimePart}
|
||||
*/
|
||||
_initMimePart() {
|
||||
let { plainPart, htmlPart } = this._gatherMainParts();
|
||||
let embeddedParts = this._gatherEmbeddedParts();
|
||||
let attachmentParts = this._gatherAttachmentParts();
|
||||
const { plainPart, htmlPart } = this._gatherMainParts();
|
||||
const embeddedParts = this._gatherEmbeddedParts();
|
||||
const attachmentParts = this._gatherAttachmentParts();
|
||||
|
||||
let relatedPart = htmlPart;
|
||||
if (htmlPart && embeddedParts.length > 0) {
|
||||
|
@ -114,14 +114,14 @@ class MimeMessage {
|
|||
relatedPart.addPart(htmlPart);
|
||||
relatedPart.addParts(embeddedParts);
|
||||
}
|
||||
let mainParts = [plainPart, relatedPart].filter(Boolean);
|
||||
const mainParts = [plainPart, relatedPart].filter(Boolean);
|
||||
let topPart;
|
||||
if (attachmentParts.length > 0) {
|
||||
// Use multipart/mixed as long as there is at least one attachment.
|
||||
topPart = new MimeMultiPart("mixed");
|
||||
if (plainPart && relatedPart) {
|
||||
// Wrap mainParts inside a multipart/alternative MimePart.
|
||||
let alternativePart = new MimeMultiPart("alternative");
|
||||
const alternativePart = new MimeMultiPart("alternative");
|
||||
alternativePart.addParts(mainParts);
|
||||
topPart.addPart(alternativePart);
|
||||
} else {
|
||||
|
@ -176,7 +176,7 @@ class MimeMessage {
|
|||
|
||||
this._compFields.messageId = messageId;
|
||||
}
|
||||
let headers = new Map([
|
||||
const headers = new Map([
|
||||
["message-id", messageId],
|
||||
["date", new Date()],
|
||||
["mime-version", "1.0"],
|
||||
|
@ -200,20 +200,20 @@ class MimeMessage {
|
|||
}
|
||||
}
|
||||
|
||||
for (let headerName of [...this._compFields.headerNames]) {
|
||||
let headerContent = this._compFields.getRawHeader(headerName);
|
||||
for (const headerName of [...this._compFields.headerNames]) {
|
||||
const headerContent = this._compFields.getRawHeader(headerName);
|
||||
if (headerContent) {
|
||||
headers.set(headerName, headerContent);
|
||||
}
|
||||
}
|
||||
let isDraft = [
|
||||
const isDraft = [
|
||||
Ci.nsIMsgSend.nsMsgQueueForLater,
|
||||
Ci.nsIMsgSend.nsMsgDeliverBackground,
|
||||
Ci.nsIMsgSend.nsMsgSaveAsDraft,
|
||||
Ci.nsIMsgSend.nsMsgSaveAsTemplate,
|
||||
].includes(this._deliverMode);
|
||||
|
||||
let undisclosedRecipients = MsgUtils.getUndisclosedRecipients(
|
||||
const undisclosedRecipients = MsgUtils.getUndisclosedRecipients(
|
||||
this._compFields,
|
||||
this._deliverMode
|
||||
);
|
||||
|
@ -248,13 +248,13 @@ class MimeMessage {
|
|||
);
|
||||
}
|
||||
|
||||
for (let { headerName, headerValue } of MsgUtils.getDefaultCustomHeaders(
|
||||
for (const { headerName, headerValue } of MsgUtils.getDefaultCustomHeaders(
|
||||
this._userIdentity
|
||||
)) {
|
||||
headers.set(headerName, headerValue);
|
||||
}
|
||||
|
||||
let rawMftHeader = headers.get("mail-followup-to");
|
||||
const rawMftHeader = headers.get("mail-followup-to");
|
||||
// If there's already a Mail-Followup-To header, don't need to do anything.
|
||||
if (!rawMftHeader) {
|
||||
headers.set(
|
||||
|
@ -263,7 +263,7 @@ class MimeMessage {
|
|||
);
|
||||
}
|
||||
|
||||
let rawMrtHeader = headers.get("mail-reply-to");
|
||||
const rawMrtHeader = headers.get("mail-reply-to");
|
||||
// If there's already a Mail-Reply-To header, don't need to do anything.
|
||||
if (!rawMrtHeader) {
|
||||
headers.set(
|
||||
|
@ -276,14 +276,14 @@ class MimeMessage {
|
|||
);
|
||||
}
|
||||
|
||||
let rawPriority = headers.get("x-priority");
|
||||
const rawPriority = headers.get("x-priority");
|
||||
if (rawPriority) {
|
||||
headers.set("x-priority", MsgUtils.getXPriority(rawPriority));
|
||||
}
|
||||
|
||||
let rawReferences = headers.get("references");
|
||||
const rawReferences = headers.get("references");
|
||||
if (rawReferences) {
|
||||
let references = MsgUtils.getReferences(rawReferences);
|
||||
const references = MsgUtils.getReferences(rawReferences);
|
||||
// Don't reset "references" header if references is undefined.
|
||||
if (references) {
|
||||
headers.set("references", references);
|
||||
|
@ -300,9 +300,9 @@ class MimeMessage {
|
|||
headers.set("x-forwarded-message-id", rawReferences);
|
||||
}
|
||||
|
||||
let rawNewsgroups = headers.get("newsgroups");
|
||||
const rawNewsgroups = headers.get("newsgroups");
|
||||
if (rawNewsgroups) {
|
||||
let { newsgroups, newshost } = MsgUtils.getNewsgroups(
|
||||
const { newsgroups, newshost } = MsgUtils.getNewsgroups(
|
||||
this._deliverMode,
|
||||
rawNewsgroups
|
||||
);
|
||||
|
@ -322,7 +322,7 @@ class MimeMessage {
|
|||
* @returns {{plainPart: MimePart, htmlPart: MimePart}}
|
||||
*/
|
||||
_gatherMainParts() {
|
||||
let formatFlowed = Services.prefs.getBoolPref(
|
||||
const formatFlowed = Services.prefs.getBoolPref(
|
||||
"mailnews.send_plaintext_flowed"
|
||||
);
|
||||
let formatParam = "";
|
||||
|
@ -333,7 +333,7 @@ class MimeMessage {
|
|||
|
||||
let htmlPart = null;
|
||||
let plainPart = null;
|
||||
let parts = {};
|
||||
const parts = {};
|
||||
|
||||
if (this._bodyType === "text/html") {
|
||||
htmlPart = new MimePart(
|
||||
|
@ -374,7 +374,7 @@ class MimeMessage {
|
|||
`text/plain; charset=UTF-8${formatParam}`
|
||||
);
|
||||
// nsIParserUtils.convertToPlainText expects unicode string.
|
||||
let plainUnicode = MsgUtils.convertToPlainText(
|
||||
const plainUnicode = MsgUtils.convertToPlainText(
|
||||
new TextDecoder().decode(
|
||||
jsmime.mimeutils.stringToTypedArray(this._bodyText)
|
||||
),
|
||||
|
@ -408,19 +408,19 @@ class MimeMessage {
|
|||
* @returns {MimePart[]}
|
||||
*/
|
||||
_gatherAttachmentParts() {
|
||||
let attachments = [...this._compFields.attachments];
|
||||
let cloudParts = [];
|
||||
let localParts = [];
|
||||
const attachments = [...this._compFields.attachments];
|
||||
const cloudParts = [];
|
||||
const localParts = [];
|
||||
|
||||
for (let attachment of attachments) {
|
||||
for (const attachment of attachments) {
|
||||
let part;
|
||||
if (attachment.htmlAnnotation) {
|
||||
part = new MimePart();
|
||||
part.bodyText = attachment.htmlAnnotation;
|
||||
part.setHeader("content-type", "text/html; charset=utf-8");
|
||||
|
||||
let suffix = /\.html$/i.test(attachment.name) ? "" : ".html";
|
||||
let encodedFilename = MsgUtils.rfc2231ParamFolding(
|
||||
const suffix = /\.html$/i.test(attachment.name) ? "" : ".html";
|
||||
const encodedFilename = MsgUtils.rfc2231ParamFolding(
|
||||
"filename",
|
||||
`${attachment.name}${suffix}`
|
||||
);
|
||||
|
@ -430,7 +430,7 @@ class MimeMessage {
|
|||
part.setBodyAttachment(attachment);
|
||||
}
|
||||
|
||||
let cloudPartHeader = MsgUtils.getXMozillaCloudPart(
|
||||
const cloudPartHeader = MsgUtils.getXMozillaCloudPart(
|
||||
this._deliverMode,
|
||||
attachment
|
||||
);
|
||||
|
@ -452,7 +452,7 @@ class MimeMessage {
|
|||
*/
|
||||
_gatherEmbeddedParts() {
|
||||
return this._embeddedAttachments.map(attachment => {
|
||||
let part = new MimePart(null, this._compFields.forceMsgEncoding, false);
|
||||
const part = new MimePart(null, this._compFields.forceMsgEncoding, false);
|
||||
part.setBodyAttachment(attachment, "inline", attachment.contentId);
|
||||
return part;
|
||||
});
|
||||
|
@ -464,7 +464,7 @@ class MimeMessage {
|
|||
* @returns {nsIMsgComposeSecure}
|
||||
*/
|
||||
_getComposeSecure() {
|
||||
let secureCompose = this._compFields.composeSecure;
|
||||
const secureCompose = this._compFields.composeSecure;
|
||||
if (!secureCompose) {
|
||||
return null;
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ class MimeMessage {
|
|||
* encapsulation.
|
||||
*/
|
||||
_startCryptoEncapsulation() {
|
||||
let recipients = [
|
||||
const recipients = [
|
||||
this._compFields.to,
|
||||
this._compFields.cc,
|
||||
this._compFields.bcc,
|
||||
|
@ -536,7 +536,7 @@ class MimeMessage {
|
|||
if (curPart.parts.length > 1) {
|
||||
// Move child parts one layer deeper so that the message is still well
|
||||
// formed after crypto encapsulation.
|
||||
let newChild = new MimeMultiPart(curPart.subtype);
|
||||
const newChild = new MimeMultiPart(curPart.subtype);
|
||||
newChild.parts = curPart._parts;
|
||||
curPart.parts = [newChild];
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ class MimeMessage {
|
|||
}
|
||||
|
||||
// multipart message
|
||||
for (let part of curPart.parts) {
|
||||
for (const part of curPart.parts) {
|
||||
this._writeString(`--${curPart.separator}\r\n`);
|
||||
await this._writePart(part, depth + 1);
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ var MsgUtils = {
|
|||
flags |= Ci.nsIDocumentEncoder.OutputFormatFlowed;
|
||||
}
|
||||
|
||||
let parserUtils = Cc["@mozilla.org/parserutils;1"].getService(
|
||||
const parserUtils = Cc["@mozilla.org/parserutils;1"].getService(
|
||||
Ci.nsIParserUtils
|
||||
);
|
||||
return parserUtils.convertToPlainText(input, flags, wrapWidth);
|
||||
|
@ -158,15 +158,15 @@ var MsgUtils = {
|
|||
getDefaultCustomHeaders(userIdentity) {
|
||||
// mail.identity.<id#>.headers pref is a comma separated value of pref names
|
||||
// containing headers to add headers are stored in
|
||||
let headerAttributes = userIdentity
|
||||
const headerAttributes = userIdentity
|
||||
.getUnicharAttribute("headers")
|
||||
.split(",");
|
||||
let headers = [];
|
||||
for (let attr of headerAttributes) {
|
||||
const headers = [];
|
||||
for (const attr of headerAttributes) {
|
||||
// mail.identity.<id#>.header.<header name> grab all the headers
|
||||
let attrValue = userIdentity.getUnicharAttribute(`header.${attr}`);
|
||||
const attrValue = userIdentity.getUnicharAttribute(`header.${attr}`);
|
||||
if (attrValue) {
|
||||
let colonIndex = attrValue.indexOf(":");
|
||||
const colonIndex = attrValue.indexOf(":");
|
||||
headers.push({
|
||||
headerName: attrValue.slice(0, colonIndex),
|
||||
headerValue: attrValue.slice(colonIndex + 1).trim(),
|
||||
|
@ -194,7 +194,7 @@ var MsgUtils = {
|
|||
useDefaultFcc = false;
|
||||
fcc = "";
|
||||
} else {
|
||||
let folder = MailUtils.getExistingFolder(compFields.fcc);
|
||||
const folder = MailUtils.getExistingFolder(compFields.fcc);
|
||||
if (folder) {
|
||||
useDefaultFcc = false;
|
||||
fcc = compFields.fcc;
|
||||
|
@ -237,7 +237,7 @@ var MsgUtils = {
|
|||
);
|
||||
}
|
||||
if (msgHdr) {
|
||||
let folder = msgHdr.folder;
|
||||
const folder = msgHdr.folder;
|
||||
if (
|
||||
folder &&
|
||||
folder.canFileMessages &&
|
||||
|
@ -252,7 +252,7 @@ var MsgUtils = {
|
|||
}
|
||||
|
||||
if (useDefaultFcc) {
|
||||
let uri = this.getMsgFolderURIFromPrefs(
|
||||
const uri = this.getMsgFolderURIFromPrefs(
|
||||
userIdentity,
|
||||
Ci.nsIMsgSend.nsMsgDeliverNow
|
||||
);
|
||||
|
@ -264,7 +264,7 @@ var MsgUtils = {
|
|||
},
|
||||
|
||||
canSaveToFolder(folderUri) {
|
||||
let folder = MailUtils.getOrCreateFolder(folderUri);
|
||||
const folder = MailUtils.getOrCreateFolder(folderUri);
|
||||
if (folder.server) {
|
||||
return folder.server.canFileMessagesOnServer;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ var MsgUtils = {
|
|||
*/
|
||||
getUndisclosedRecipients(compFields, deliverMode) {
|
||||
// Newsgroups count as recipients.
|
||||
let hasDisclosedRecipient =
|
||||
const hasDisclosedRecipient =
|
||||
compFields.to || compFields.cc || compFields.newsgroups;
|
||||
// If we are saving the message as a draft, don't bother inserting the
|
||||
// undisclosed recipients field. We'll take care of that when we really send
|
||||
|
@ -298,13 +298,13 @@ var MsgUtils = {
|
|||
) {
|
||||
return "";
|
||||
}
|
||||
let composeBundle = Services.strings.createBundle(
|
||||
const composeBundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/messengercompose/composeMsgs.properties"
|
||||
);
|
||||
let undisclosedRecipients = composeBundle.GetStringFromName(
|
||||
const undisclosedRecipients = composeBundle.GetStringFromName(
|
||||
"undisclosedRecipients"
|
||||
);
|
||||
let recipients = MailServices.headerParser.makeGroupObject(
|
||||
const recipients = MailServices.headerParser.makeGroupObject(
|
||||
undisclosedRecipients,
|
||||
[]
|
||||
);
|
||||
|
@ -320,7 +320,7 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
getMailFollowupToHeader(compFields, userIdentity) {
|
||||
let mailLists = userIdentity.getUnicharAttribute(
|
||||
const mailLists = userIdentity.getUnicharAttribute(
|
||||
"subscribed_mailing_lists"
|
||||
);
|
||||
if (!mailLists || !(compFields.to || compFields.cc)) {
|
||||
|
@ -334,9 +334,9 @@ var MsgUtils = {
|
|||
} else {
|
||||
recipients = compFields.cc;
|
||||
}
|
||||
let recipientsDedup =
|
||||
const recipientsDedup =
|
||||
MailServices.headerParser.removeDuplicateAddresses(recipients);
|
||||
let recipientsWithoutMailList =
|
||||
const recipientsWithoutMailList =
|
||||
MailServices.headerParser.removeDuplicateAddresses(
|
||||
recipientsDedup,
|
||||
mailLists
|
||||
|
@ -356,7 +356,7 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
getMailReplyToHeader(compFields, userIdentity) {
|
||||
let mailLists = userIdentity.getUnicharAttribute(
|
||||
const mailLists = userIdentity.getUnicharAttribute(
|
||||
"replyto_mangling_mailing_lists"
|
||||
);
|
||||
if (
|
||||
|
@ -374,9 +374,9 @@ var MsgUtils = {
|
|||
} else {
|
||||
recipients = compFields.cc;
|
||||
}
|
||||
let recipientsDedup =
|
||||
const recipientsDedup =
|
||||
MailServices.headerParser.removeDuplicateAddresses(recipients);
|
||||
let recipientsWithoutMailList =
|
||||
const recipientsWithoutMailList =
|
||||
MailServices.headerParser.removeDuplicateAddresses(
|
||||
recipientsDedup,
|
||||
mailLists
|
||||
|
@ -394,8 +394,8 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
getXMozillaDraftInfo(compFields) {
|
||||
let getCompField = (property, key) => {
|
||||
let value = compFields[property] ? 1 : 0;
|
||||
const getCompField = (property, key) => {
|
||||
const value = compFields[property] ? 1 : 0;
|
||||
return `${key}=${value}; `;
|
||||
};
|
||||
let draftInfo = "internal/draft; ";
|
||||
|
@ -617,11 +617,11 @@ var MsgUtils = {
|
|||
// The References header should be kept under 998 characters: if it's too
|
||||
// long, trim out the earliest references to make it smaller.
|
||||
let newReferences = "";
|
||||
let firstRef = references.indexOf("<");
|
||||
let secondRef = references.indexOf("<", firstRef + 1);
|
||||
const firstRef = references.indexOf("<");
|
||||
const secondRef = references.indexOf("<", firstRef + 1);
|
||||
if (secondRef > 0) {
|
||||
newReferences = references.slice(0, secondRef);
|
||||
let bracket = references.indexOf(
|
||||
const bracket = references.indexOf(
|
||||
"<",
|
||||
references.length + newReferences.length - 986
|
||||
);
|
||||
|
@ -640,7 +640,7 @@ var MsgUtils = {
|
|||
*/
|
||||
getInReplyTo(references) {
|
||||
// The In-Reply-To header is the last entry in the references header...
|
||||
let bracket = references.lastIndexOf("<");
|
||||
const bracket = references.lastIndexOf("<");
|
||||
if (bracket >= 0) {
|
||||
return references.slice(bracket);
|
||||
}
|
||||
|
@ -655,11 +655,11 @@ var MsgUtils = {
|
|||
* @returns {{newsgroups: string, newshost: string}}
|
||||
*/
|
||||
getNewsgroups(deliverMode, newsgroups) {
|
||||
let nntpService = Cc["@mozilla.org/messenger/nntpservice;1"].getService(
|
||||
const nntpService = Cc["@mozilla.org/messenger/nntpservice;1"].getService(
|
||||
Ci.nsINntpService
|
||||
);
|
||||
let newsgroupsHeaderVal = {};
|
||||
let newshostHeaderVal = {};
|
||||
const newsgroupsHeaderVal = {};
|
||||
const newshostHeaderVal = {};
|
||||
nntpService.generateNewsHeaderValsForPosting(
|
||||
newsgroups,
|
||||
newsgroupsHeaderVal,
|
||||
|
@ -693,7 +693,7 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
getContentLocation(baseUrl) {
|
||||
let lowerBaseUrl = baseUrl.toLowerCase();
|
||||
const lowerBaseUrl = baseUrl.toLowerCase();
|
||||
if (
|
||||
!baseUrl.includes(":") ||
|
||||
lowerBaseUrl.startsWith("news:") ||
|
||||
|
@ -704,14 +704,14 @@ var MsgUtils = {
|
|||
) {
|
||||
return "";
|
||||
}
|
||||
let transformMap = {
|
||||
const transformMap = {
|
||||
" ": "%20",
|
||||
"\t": "%09",
|
||||
"\n": "%0A",
|
||||
"\r": "%0D",
|
||||
};
|
||||
let value = "";
|
||||
for (let char of baseUrl) {
|
||||
for (const char of baseUrl) {
|
||||
value += transformMap[char] || char;
|
||||
}
|
||||
return value;
|
||||
|
@ -722,10 +722,10 @@ var MsgUtils = {
|
|||
* purposes.
|
||||
*/
|
||||
makeFilenameQtext(srcText, stripCRLFs) {
|
||||
let size = srcText.length;
|
||||
const size = srcText.length;
|
||||
let ret = "";
|
||||
for (let i = 0; i < size; i++) {
|
||||
let char = srcText.charAt(i);
|
||||
const char = srcText.charAt(i);
|
||||
if (
|
||||
char == "\\" ||
|
||||
char == '"' ||
|
||||
|
@ -759,11 +759,11 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
rfc2047EncodeParam(value) {
|
||||
let converter = Cc["@mozilla.org/messenger/mimeconverter;1"].getService(
|
||||
const converter = Cc["@mozilla.org/messenger/mimeconverter;1"].getService(
|
||||
Ci.nsIMimeConverter
|
||||
);
|
||||
|
||||
let encoded = converter.encodeMimePartIIStr_UTF8(
|
||||
const encoded = converter.encodeMimePartIIStr_UTF8(
|
||||
value,
|
||||
false,
|
||||
0,
|
||||
|
@ -786,7 +786,7 @@ var MsgUtils = {
|
|||
const PR_MAX_FOLDING_LEN = 75;
|
||||
|
||||
let needsEscape = false;
|
||||
let encoder = new TextEncoder();
|
||||
const encoder = new TextEncoder();
|
||||
let dupParamValue = jsmime.mimeutils.typedArrayToString(
|
||||
encoder.encode(paramValue)
|
||||
);
|
||||
|
@ -887,7 +887,7 @@ var MsgUtils = {
|
|||
deliverMode == Ci.nsIMsgSend.nsMsgQueueForLater ||
|
||||
deliverMode == Ci.nsIMsgSend.nsMsgDeliverBackground
|
||||
) {
|
||||
let uri = Services.prefs.getCharPref("mail.default_sendlater_uri");
|
||||
const uri = Services.prefs.getCharPref("mail.default_sendlater_uri");
|
||||
// check if uri is unescaped, and if so, escape it and reset the pef.
|
||||
if (!uri) {
|
||||
return "anyfolder://";
|
||||
|
@ -915,7 +915,7 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
getErrorStringName(exitCode) {
|
||||
let codeNameMap = {
|
||||
const codeNameMap = {
|
||||
[this.NS_MSG_UNABLE_TO_OPEN_FILE]: "unableToOpenFile",
|
||||
[this.NS_MSG_UNABLE_TO_OPEN_TMP_FILE]: "unableToOpenTmpFile",
|
||||
[this.NS_MSG_UNABLE_TO_SAVE_TEMPLATE]: "unableToSaveTemplate",
|
||||
|
@ -980,8 +980,8 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
formatStringWithSMTPHostName(userIdentity, composeBundle, errorName) {
|
||||
let smtpServer = MailServices.smtp.getServerByIdentity(userIdentity);
|
||||
let smtpHostname = smtpServer.hostname;
|
||||
const smtpServer = MailServices.smtp.getServerByIdentity(userIdentity);
|
||||
const smtpHostname = smtpServer.hostname;
|
||||
return composeBundle.formatStringFromName(errorName, [smtpHostname]);
|
||||
},
|
||||
|
||||
|
@ -992,7 +992,7 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
randomString(size) {
|
||||
let length = Math.round((size * 3) / 4);
|
||||
const length = Math.round((size * 3) / 4);
|
||||
return btoa(
|
||||
String.fromCharCode(
|
||||
...[...Array(length)].map(() => Math.floor(Math.random() * 256))
|
||||
|
@ -1010,7 +1010,7 @@ var MsgUtils = {
|
|||
* @returns {string}
|
||||
*/
|
||||
makeContentId(userIdentity, partNum) {
|
||||
let domain = userIdentity.email.split("@")[1];
|
||||
const domain = userIdentity.email.split("@")[1];
|
||||
return `part${partNum}.${this.randomString(8)}.${this.randomString(
|
||||
8
|
||||
)}@${domain}`;
|
||||
|
@ -1028,11 +1028,11 @@ var MsgUtils = {
|
|||
return "";
|
||||
}
|
||||
if (/^data:/i.test(url)) {
|
||||
let matches = /filename=(.*);/.exec(url);
|
||||
const matches = /filename=(.*);/.exec(url);
|
||||
if (matches && matches[1]) {
|
||||
return decodeURIComponent(matches[1]);
|
||||
}
|
||||
let mimeType = url.slice(5, url.indexOf(";"));
|
||||
const mimeType = url.slice(5, url.indexOf(";"));
|
||||
let extname = "";
|
||||
try {
|
||||
extname = Cc["@mozilla.org/mime;1"]
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
const EXPORTED_SYMBOLS = ["MimePart", "MimeMultiPart"];
|
||||
|
||||
let { jsmime } = ChromeUtils.import("resource:///modules/jsmime.jsm");
|
||||
let { MimeEncoder } = ChromeUtils.import("resource:///modules/MimeEncoder.jsm");
|
||||
let { MsgUtils } = ChromeUtils.import(
|
||||
const { jsmime } = ChromeUtils.import("resource:///modules/jsmime.jsm");
|
||||
const { MimeEncoder } = ChromeUtils.import(
|
||||
"resource:///modules/MimeEncoder.jsm"
|
||||
);
|
||||
const { MsgUtils } = ChromeUtils.import(
|
||||
"resource:///modules/MimeMessageUtils.jsm"
|
||||
);
|
||||
var { MailServices } = ChromeUtils.import(
|
||||
|
@ -117,7 +119,7 @@ class MimePart {
|
|||
* @param {Iterable.<string, string>} entries - The header entries.
|
||||
*/
|
||||
setHeaders(entries) {
|
||||
for (let [name, content] of entries) {
|
||||
for (const [name, content] of entries) {
|
||||
this.setHeader(name, content);
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +184,7 @@ class MimePart {
|
|||
}
|
||||
}
|
||||
if (bodyString) {
|
||||
let encoder = new MimeEncoder(
|
||||
const encoder = new MimeEncoder(
|
||||
this._charset,
|
||||
this._contentType,
|
||||
this._forceMsgEncoding,
|
||||
|
@ -219,11 +221,11 @@ class MimePart {
|
|||
* @returns {string}
|
||||
*/
|
||||
async _fetchMsgAttachment() {
|
||||
let msgService = MailServices.messageServiceFromURI(
|
||||
const msgService = MailServices.messageServiceFromURI(
|
||||
this._bodyAttachment.url
|
||||
);
|
||||
return new Promise((resolve, reject) => {
|
||||
let streamListener = {
|
||||
const streamListener = {
|
||||
_data: "",
|
||||
_stream: null,
|
||||
onDataAvailable(request, inputStream, offset, count) {
|
||||
|
@ -268,7 +270,7 @@ class MimePart {
|
|||
* @returns {string}
|
||||
*/
|
||||
async _fetchAttachment() {
|
||||
let url = this._bodyAttachment.url;
|
||||
const url = this._bodyAttachment.url;
|
||||
MsgUtils.sendLogger.debug(`Fetching ${url}`);
|
||||
|
||||
let content = "";
|
||||
|
@ -280,7 +282,7 @@ class MimePart {
|
|||
}
|
||||
this._contentType = "message/rfc822";
|
||||
} else {
|
||||
let channel = Services.io.newChannelFromURI(
|
||||
const channel = Services.io.newChannelFromURI(
|
||||
Services.io.newURI(url),
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
|
@ -307,7 +309,7 @@ class MimePart {
|
|||
this._bodyAttachment.contentType || channel.contentType;
|
||||
}
|
||||
|
||||
let parmFolding = Services.prefs.getIntPref(
|
||||
const parmFolding = Services.prefs.getIntPref(
|
||||
"mail.strictly_mime.parm_folding",
|
||||
2
|
||||
);
|
||||
|
@ -342,7 +344,7 @@ class MimePart {
|
|||
this.setHeader("content-id", `<${this._contentId}>`);
|
||||
}
|
||||
if (this._contentType == "text/html") {
|
||||
let contentLocation = MsgUtils.getContentLocation(
|
||||
const contentLocation = MsgUtils.getContentLocation(
|
||||
this._bodyAttachment.url
|
||||
);
|
||||
this.setHeader("content-location", contentLocation);
|
||||
|
|
|
@ -118,8 +118,8 @@ class SmtpClient {
|
|||
this.logger.debug("Reusing a connection");
|
||||
this.onidle();
|
||||
} else {
|
||||
let hostname = this._server.hostname.toLowerCase();
|
||||
let port = this._server.port || (this.options.requireTLS ? 465 : 587);
|
||||
const hostname = this._server.hostname.toLowerCase();
|
||||
const port = this._server.port || (this.options.requireTLS ? 465 : 587);
|
||||
this.logger.debug(`Connecting to smtp://${hostname}:${port}`);
|
||||
this._secureTransport = this.options.requireTLS;
|
||||
this.socket = new TCPSocket(hostname, port, {
|
||||
|
@ -189,14 +189,14 @@ class SmtpClient {
|
|||
// If server doesn't support SMTPUTF8, check if addresses contain invalid
|
||||
// characters.
|
||||
|
||||
let recipients = this._envelope.to;
|
||||
const recipients = this._envelope.to;
|
||||
this._envelope.to = [];
|
||||
|
||||
for (let recipient of recipients) {
|
||||
let lastAt = null;
|
||||
let firstInvalid = null;
|
||||
for (let i = 0; i < recipient.length; i++) {
|
||||
let ch = recipient[i];
|
||||
const ch = recipient[i];
|
||||
if (ch == "@") {
|
||||
lastAt = i;
|
||||
} else if ((ch < " " || ch > "~") && ch != "\t") {
|
||||
|
@ -211,10 +211,12 @@ class SmtpClient {
|
|||
return;
|
||||
}
|
||||
// Invalid char found in the domainpart, convert it to ACE.
|
||||
let idnService = Cc["@mozilla.org/network/idn-service;1"].getService(
|
||||
Ci.nsIIDNService
|
||||
const idnService = Cc[
|
||||
"@mozilla.org/network/idn-service;1"
|
||||
].getService(Ci.nsIIDNService);
|
||||
const domain = idnService.convertUTF8toACE(
|
||||
recipient.slice(lastAt + 1)
|
||||
);
|
||||
let domain = idnService.convertUTF8toACE(recipient.slice(lastAt + 1));
|
||||
recipient = `${recipient.slice(0, lastAt)}@${domain}`;
|
||||
}
|
||||
this._envelope.to.push(recipient);
|
||||
|
@ -242,7 +244,7 @@ class SmtpClient {
|
|||
if (this._capabilities.includes("SMTPUTF8")) {
|
||||
// Should not send SMTPUTF8 if all ascii, see RFC6531.
|
||||
// eslint-disable-next-line no-control-regex
|
||||
let ascii = /^[\x00-\x7F]+$/;
|
||||
const ascii = /^[\x00-\x7F]+$/;
|
||||
if ([envelope.from, ...envelope.to].some(x => !ascii.test(x))) {
|
||||
cmd += " SMTPUTF8";
|
||||
}
|
||||
|
@ -251,7 +253,7 @@ class SmtpClient {
|
|||
cmd += ` SIZE=${this._envelope.size}`;
|
||||
}
|
||||
if (this._capabilities.includes("DSN") && this._envelope.requestDSN) {
|
||||
let ret = Services.prefs.getBoolPref("mail.dsn.ret_full_on")
|
||||
const ret = Services.prefs.getBoolPref("mail.dsn.ret_full_on")
|
||||
? "FULL"
|
||||
: "HDRS";
|
||||
cmd += ` RET=${ret} ENVID=${envelope.messageId}`;
|
||||
|
@ -411,7 +413,7 @@ class SmtpClient {
|
|||
* @param {Event} evt - Event object. See `evt.data` for the chunk received
|
||||
*/
|
||||
_onData = async evt => {
|
||||
let stringPayload = new TextDecoder("UTF-8").decode(
|
||||
const stringPayload = new TextDecoder("UTF-8").decode(
|
||||
new Uint8Array(evt.data)
|
||||
);
|
||||
// "S: " to denote that this is data from the Server.
|
||||
|
@ -457,7 +459,7 @@ class SmtpClient {
|
|||
if (secInfo) {
|
||||
this.logger.error(`SecurityError info: ${secInfo.errorCodeString}`);
|
||||
if (secInfo.failedCertChain.length) {
|
||||
let chain = secInfo.failedCertChain.map(c => {
|
||||
const chain = secInfo.failedCertChain.map(c => {
|
||||
return c.commonName + "; serial# " + c.serialNumber;
|
||||
});
|
||||
this.logger.error(`SecurityError cert chain: ${chain.join(" <- ")}`);
|
||||
|
@ -479,7 +481,7 @@ class SmtpClient {
|
|||
* @param {string} [extra] - Some messages take two arguments to format.
|
||||
*/
|
||||
_onNsError(nsError, errorParam, extra) {
|
||||
let errorName = MsgUtils.getErrorStringName(nsError);
|
||||
const errorName = MsgUtils.getErrorStringName(nsError);
|
||||
let errorMessage = "";
|
||||
if (
|
||||
[
|
||||
|
@ -493,7 +495,7 @@ class SmtpClient {
|
|||
MsgUtils.NS_ERROR_ILLEGAL_LOCALPART,
|
||||
].includes(nsError)
|
||||
) {
|
||||
let bundle = Services.strings.createBundle(
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/messengercompose/composeMsgs.properties"
|
||||
);
|
||||
if (nsError == MsgUtils.NS_ERROR_ILLEGAL_LOCALPART) {
|
||||
|
@ -690,7 +692,7 @@ class SmtpClient {
|
|||
// See https://developers.google.com/gmail/xoauth2_protocol#smtp_protocol_exchange
|
||||
this.logger.debug("Authentication via AUTH XOAUTH2");
|
||||
this._currentAction = this._actionAUTH_XOAUTH2;
|
||||
let oauthToken = await this._authenticator.getOAuthToken();
|
||||
const oauthToken = await this._authenticator.getOAuthToken();
|
||||
this._sendCommand("AUTH XOAUTH2 " + oauthToken, true);
|
||||
return;
|
||||
case "GSSAPI": {
|
||||
|
@ -769,7 +771,7 @@ class SmtpClient {
|
|||
}
|
||||
|
||||
// Ask user what to do.
|
||||
let action = this._authenticator.promptAuthFailed();
|
||||
const action = this._authenticator.promptAuthFailed();
|
||||
if (action == 1) {
|
||||
// Cancel button pressed.
|
||||
this.logger.error(`Authentication failed: ${command.data}`);
|
||||
|
@ -796,15 +798,15 @@ class SmtpClient {
|
|||
}
|
||||
|
||||
_getHelloArgument() {
|
||||
let helloArgument = this._server.helloArgument;
|
||||
const helloArgument = this._server.helloArgument;
|
||||
if (helloArgument) {
|
||||
return helloArgument;
|
||||
}
|
||||
|
||||
try {
|
||||
// The address format follows rfc5321#section-4.1.3.
|
||||
let netAddr = this.socket?.transport.getScriptableSelfAddr();
|
||||
let address = netAddr.address;
|
||||
const netAddr = this.socket?.transport.getScriptableSelfAddr();
|
||||
const address = netAddr.address;
|
||||
if (netAddr.family === Ci.nsINetAddr.FAMILY_INET6) {
|
||||
return `[IPV6:${address}]`;
|
||||
}
|
||||
|
@ -880,9 +882,9 @@ class SmtpClient {
|
|||
|
||||
this._supportedAuthMethods = [];
|
||||
|
||||
let lines = command.data.toUpperCase().split("\n");
|
||||
const lines = command.data.toUpperCase().split("\n");
|
||||
// Skip the first greeting line.
|
||||
for (let line of lines.slice(1)) {
|
||||
for (const line of lines.slice(1)) {
|
||||
if (line.startsWith("AUTH ")) {
|
||||
this._supportedAuthMethods = line.slice(5).split(" ");
|
||||
} else {
|
||||
|
@ -1090,7 +1092,7 @@ class SmtpClient {
|
|||
this._onNsError(MsgUtils.NS_ERROR_SMTP_AUTH_GSSAPI, command.data);
|
||||
return;
|
||||
}
|
||||
let token = this._authenticator.getNextGssapiToken(command.data);
|
||||
const token = this._authenticator.getNextGssapiToken(command.data);
|
||||
this._currentAction = this._actionAUTH_GSSAPI;
|
||||
this._sendCommand(token, true);
|
||||
}
|
||||
|
@ -1111,7 +1113,7 @@ class SmtpClient {
|
|||
this._onNsError(MsgUtils.NS_ERROR_SMTP_AUTH_FAILURE, command.data);
|
||||
return;
|
||||
}
|
||||
let token = this._authenticator.getNextNtlmToken(command.data);
|
||||
const token = this._authenticator.getNextNtlmToken(command.data);
|
||||
this._currentAction = this._actionAUTH_NTLM;
|
||||
this._sendCommand(token, true);
|
||||
}
|
||||
|
@ -1182,7 +1184,7 @@ class SmtpClient {
|
|||
*/
|
||||
_getRCPTParameters() {
|
||||
if (this._capabilities.includes("DSN") && this._envelope.requestDSN) {
|
||||
let notify = [];
|
||||
const notify = [];
|
||||
if (Services.prefs.getBoolPref("mail.dsn.request_never_on")) {
|
||||
notify.push("NEVER");
|
||||
} else {
|
||||
|
|
|
@ -94,7 +94,7 @@ class SmtpServer {
|
|||
}
|
||||
|
||||
get UID() {
|
||||
let uid = this._prefs.getStringPref("uid", "");
|
||||
const uid = this._prefs.getStringPref("uid", "");
|
||||
if (uid) {
|
||||
return uid;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ class SmtpServer {
|
|||
}
|
||||
|
||||
get maximumConnectionsNumber() {
|
||||
let maxConnections = this._getIntPrefWithDefault(
|
||||
const maxConnections = this._getIntPrefWithDefault(
|
||||
"max_cached_connections",
|
||||
3
|
||||
);
|
||||
|
@ -221,16 +221,16 @@ class SmtpServer {
|
|||
if (this._password) {
|
||||
return this._password;
|
||||
}
|
||||
let incomingAccountKey = this._prefs.getCharPref("incomingAccount", "");
|
||||
const incomingAccountKey = this._prefs.getCharPref("incomingAccount", "");
|
||||
let incomingServer;
|
||||
if (incomingAccountKey) {
|
||||
incomingServer =
|
||||
MailServices.accounts.getIncomingServer(incomingAccountKey);
|
||||
} else {
|
||||
let useMatchingHostNameServer = Services.prefs.getBoolPref(
|
||||
const useMatchingHostNameServer = Services.prefs.getBoolPref(
|
||||
"mail.smtp.useMatchingHostNameServer"
|
||||
);
|
||||
let useMatchingDomainServer = Services.prefs.getBoolPref(
|
||||
const useMatchingDomainServer = Services.prefs.getBoolPref(
|
||||
"mail.smtp.useMatchingDomainServer"
|
||||
);
|
||||
if (useMatchingHostNameServer || useMatchingDomainServer) {
|
||||
|
@ -248,10 +248,13 @@ class SmtpServer {
|
|||
useMatchingDomainServer &&
|
||||
this.hostname.includes(".")
|
||||
) {
|
||||
let newHostname = this.hostname.slice(0, this.hostname.indexOf("."));
|
||||
for (let server of MailServices.accounts.allServers) {
|
||||
const newHostname = this.hostname.slice(
|
||||
0,
|
||||
this.hostname.indexOf(".")
|
||||
);
|
||||
for (const server of MailServices.accounts.allServers) {
|
||||
if (server.username == this.username) {
|
||||
let serverHostName = server.hostName;
|
||||
const serverHostName = server.hostName;
|
||||
if (
|
||||
serverHostName.includes(".") &&
|
||||
serverHostName.slice(0, serverHostName.indexOf(".")) ==
|
||||
|
@ -283,13 +286,13 @@ class SmtpServer {
|
|||
// Often happens in tests. This prompt has no checkbox for saving password.
|
||||
authPrompt = Services.ww.getNewAuthPrompter(null);
|
||||
}
|
||||
let password = this._getPasswordWithoutUI();
|
||||
const password = this._getPasswordWithoutUI();
|
||||
if (password) {
|
||||
this.password = password;
|
||||
return this.password;
|
||||
}
|
||||
let outUsername = {};
|
||||
let outPassword = {};
|
||||
const outUsername = {};
|
||||
const outPassword = {};
|
||||
let ok;
|
||||
if (this.username) {
|
||||
ok = authPrompt.promptPassword(
|
||||
|
@ -321,9 +324,9 @@ class SmtpServer {
|
|||
}
|
||||
|
||||
forgetPassword() {
|
||||
let serverURI = this._getServerURI();
|
||||
let logins = Services.logins.findLogins(serverURI, "", serverURI);
|
||||
for (let login of logins) {
|
||||
const serverURI = this._getServerURI();
|
||||
const logins = Services.logins.findLogins(serverURI, "", serverURI);
|
||||
for (const login of logins) {
|
||||
if (login.username == this.username) {
|
||||
Services.logins.removeLogin(login);
|
||||
}
|
||||
|
@ -336,7 +339,7 @@ class SmtpServer {
|
|||
}
|
||||
|
||||
clearAllValues() {
|
||||
for (let prefName of this._prefs.getChildList("")) {
|
||||
for (const prefName of this._prefs.getChildList("")) {
|
||||
this._prefs.clearUserPref(prefName);
|
||||
}
|
||||
}
|
||||
|
@ -345,9 +348,9 @@ class SmtpServer {
|
|||
* @returns {string}
|
||||
*/
|
||||
_getPasswordWithoutUI() {
|
||||
let serverURI = this._getServerURI();
|
||||
let logins = Services.logins.findLogins(serverURI, "", serverURI);
|
||||
for (let login of logins) {
|
||||
const serverURI = this._getServerURI();
|
||||
const logins = Services.logins.findLogins(serverURI, "", serverURI);
|
||||
for (const login of logins) {
|
||||
if (login.username == this.username) {
|
||||
return login.password;
|
||||
}
|
||||
|
@ -363,7 +366,7 @@ class SmtpServer {
|
|||
*/
|
||||
_getServerURI(includeUsername) {
|
||||
// When constructing nsIURI, need to wrap IPv6 address in [].
|
||||
let hostname = this.hostname.includes(":")
|
||||
const hostname = this.hostname.includes(":")
|
||||
? `[${this.hostname}]`
|
||||
: this.hostname;
|
||||
return (
|
||||
|
@ -440,11 +443,11 @@ class SmtpServer {
|
|||
|
||||
closeCachedConnections() {
|
||||
// Close all connections.
|
||||
for (let client of [...this._freeConnections, ...this._busyConnections]) {
|
||||
for (const client of [...this._freeConnections, ...this._busyConnections]) {
|
||||
client.quit();
|
||||
}
|
||||
// Cancel all waitings in queue.
|
||||
for (let resolve of this._connectionWaitingQueue) {
|
||||
for (const resolve of this._connectionWaitingQueue) {
|
||||
resolve(false);
|
||||
}
|
||||
this._freeConnections = [];
|
||||
|
@ -483,7 +486,7 @@ class SmtpServer {
|
|||
* instance, and do some actions.
|
||||
*/
|
||||
async withClient(handler) {
|
||||
let client = await this._getNextClient();
|
||||
const client = await this._getNextClient();
|
||||
client.onFree = () => {
|
||||
this._busyConnections = this._busyConnections.filter(c => c != client);
|
||||
this._freeConnections.push(client);
|
||||
|
|
|
@ -37,7 +37,7 @@ class SmtpService {
|
|||
* @see nsISmtpService
|
||||
*/
|
||||
get defaultServer() {
|
||||
let defaultServerKey = Services.prefs.getCharPref(
|
||||
const defaultServerKey = Services.prefs.getCharPref(
|
||||
"mail.smtp.defaultserver",
|
||||
""
|
||||
);
|
||||
|
@ -86,11 +86,11 @@ class SmtpService {
|
|||
outRequest
|
||||
) {
|
||||
this._logger.debug(`Sending message ${messageId}`);
|
||||
let server = this.getServerByIdentity(userIdentity);
|
||||
const server = this.getServerByIdentity(userIdentity);
|
||||
if (password) {
|
||||
server.password = password;
|
||||
}
|
||||
let runningUrl = this._getRunningUri(server);
|
||||
const runningUrl = this._getRunningUri(server);
|
||||
server.wrappedJSObject.withClient(client => {
|
||||
deliveryListener?.OnStartRunningUrl(runningUrl, 0);
|
||||
let fresh = true;
|
||||
|
@ -102,7 +102,7 @@ class SmtpService {
|
|||
}
|
||||
fresh = false;
|
||||
let from = sender;
|
||||
let to = MailServices.headerParser
|
||||
const to = MailServices.headerParser
|
||||
.parseEncodedHeaderW(decodeURIComponent(recipients))
|
||||
.map(rec => rec.email);
|
||||
|
||||
|
@ -131,26 +131,26 @@ class SmtpService {
|
|||
};
|
||||
let socketOnDrain;
|
||||
client.onready = async () => {
|
||||
let fstream = Cc[
|
||||
const fstream = Cc[
|
||||
"@mozilla.org/network/file-input-stream;1"
|
||||
].createInstance(Ci.nsIFileInputStream);
|
||||
// PR_RDONLY
|
||||
fstream.init(messageFile, 0x01, 0, 0);
|
||||
|
||||
let sstream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
|
||||
Ci.nsIScriptableInputStream
|
||||
);
|
||||
const sstream = Cc[
|
||||
"@mozilla.org/scriptableinputstream;1"
|
||||
].createInstance(Ci.nsIScriptableInputStream);
|
||||
sstream.init(fstream);
|
||||
|
||||
let sentSize = 0;
|
||||
let totalSize = messageFile.fileSize;
|
||||
let progressListener = statusListener?.QueryInterface(
|
||||
const totalSize = messageFile.fileSize;
|
||||
const progressListener = statusListener?.QueryInterface(
|
||||
Ci.nsIWebProgressListener
|
||||
);
|
||||
|
||||
while (sstream.available()) {
|
||||
let chunk = sstream.read(65536);
|
||||
let canSendMore = client.send(chunk);
|
||||
const chunk = sstream.read(65536);
|
||||
const canSendMore = client.send(chunk);
|
||||
if (!canSendMore) {
|
||||
// Socket buffer is full, wait for the ondrain event.
|
||||
await new Promise(resolve => (socketOnDrain = resolve));
|
||||
|
@ -207,9 +207,9 @@ class SmtpService {
|
|||
* @see nsISmtpService
|
||||
*/
|
||||
verifyLogon(server, urlListener, msgWindow) {
|
||||
let client = new lazy.SmtpClient(server);
|
||||
const client = new lazy.SmtpClient(server);
|
||||
client.connect();
|
||||
let runningUrl = this._getRunningUri(server);
|
||||
const runningUrl = this._getRunningUri(server);
|
||||
client.onerror = (nsError, errorMessage, secInfo) => {
|
||||
runningUrl.QueryInterface(Ci.nsIMsgMailNewsUrl);
|
||||
if (secInfo) {
|
||||
|
@ -245,7 +245,7 @@ class SmtpService {
|
|||
* @see nsISmtpService
|
||||
*/
|
||||
createServer() {
|
||||
let serverKeys = this._getSmtpServerKeys();
|
||||
const serverKeys = this._getSmtpServerKeys();
|
||||
let i = 1;
|
||||
let key;
|
||||
do {
|
||||
|
@ -262,7 +262,7 @@ class SmtpService {
|
|||
* @see nsISmtpService
|
||||
*/
|
||||
deleteServer(server) {
|
||||
let serverKeys = this._getSmtpServerKeys().filter(k => k != server.key);
|
||||
const serverKeys = this._getSmtpServerKeys().filter(k => k != server.key);
|
||||
this._servers = this.servers.filter(s => s.key != server.key);
|
||||
this._saveSmtpServerKeys(serverKeys);
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ class SmtpService {
|
|||
* @returns {nsISmtpServer}
|
||||
*/
|
||||
_keyToServer(key) {
|
||||
let server = Cc["@mozilla.org/messenger/smtp/server;1"].createInstance(
|
||||
const server = Cc["@mozilla.org/messenger/smtp/server;1"].createInstance(
|
||||
Ci.nsISmtpServer
|
||||
);
|
||||
// Setting the server key will set up all of its other properties by
|
||||
|
@ -328,7 +328,7 @@ class SmtpService {
|
|||
* @returns {nsIURI}
|
||||
*/
|
||||
_getRunningUri(server) {
|
||||
let spec = server.serverURI + (server.port ? `:${server.port}` : "");
|
||||
const spec = server.serverURI + (server.port ? `:${server.port}` : "");
|
||||
return Services.io.newURI(spec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
let MockNntpService = {
|
||||
const MockNntpService = {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsINntpService"]),
|
||||
postMessage(messageFile, groupNames, accountKey, urlListener, msgWindow) {
|
||||
this.messageFile = messageFile;
|
||||
|
@ -11,14 +11,14 @@ let MockNntpService = {
|
|||
},
|
||||
};
|
||||
|
||||
let MockNntpServiceFactory = {
|
||||
const MockNntpServiceFactory = {
|
||||
createInstance(aIID) {
|
||||
return MockNntpService;
|
||||
},
|
||||
};
|
||||
|
||||
add_setup(async function () {
|
||||
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
const registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
registrar.registerFactory(
|
||||
Components.ID("{4816dd44-fe15-4719-8cfb-a2f8ee46d787}"),
|
||||
"Mock NntpService",
|
||||
|
@ -33,12 +33,12 @@ add_setup(async function () {
|
|||
*/
|
||||
add_task(async function testAccountKey() {
|
||||
// Set up the servers.
|
||||
let server = setupServerDaemon();
|
||||
const server = setupServerDaemon();
|
||||
localAccountUtils.loadLocalMailAccount();
|
||||
server.start();
|
||||
let smtpServer = getBasicSmtpServer(server.port);
|
||||
let identity = getSmtpIdentity("from@foo.invalid", smtpServer);
|
||||
let account = MailServices.accounts.createAccount();
|
||||
const smtpServer = getBasicSmtpServer(server.port);
|
||||
const identity = getSmtpIdentity("from@foo.invalid", smtpServer);
|
||||
const account = MailServices.accounts.createAccount();
|
||||
account.addIdentity(identity);
|
||||
account.incomingServer = MailServices.accounts.createIncomingServer(
|
||||
"test",
|
||||
|
@ -47,17 +47,17 @@ add_task(async function testAccountKey() {
|
|||
);
|
||||
|
||||
// Init nsIMsgSend and fields.
|
||||
let msgSend = Cc["@mozilla.org/messengercompose/send;1"].createInstance(
|
||||
const msgSend = Cc["@mozilla.org/messengercompose/send;1"].createInstance(
|
||||
Ci.nsIMsgSend
|
||||
);
|
||||
let compFields = Cc[
|
||||
const compFields = Cc[
|
||||
"@mozilla.org/messengercompose/composefields;1"
|
||||
].createInstance(Ci.nsIMsgCompFields);
|
||||
compFields.from = identity.email;
|
||||
// Set the newsgroups filed so that the message will be passed to NntpService.
|
||||
compFields.newsgroups = "foo.test";
|
||||
|
||||
let testFile = do_get_file("data/message1.eml");
|
||||
const testFile = do_get_file("data/message1.eml");
|
||||
// Notice the second argument is accountKey.
|
||||
await msgSend.sendMessageFile(
|
||||
identity,
|
||||
|
|
|
@ -123,7 +123,7 @@ function checkAttachment(expectedCD, expectedCT) {
|
|||
}
|
||||
|
||||
async function testInput0() {
|
||||
for (let folding in ParamFoldingPref) {
|
||||
for (const folding in ParamFoldingPref) {
|
||||
Services.prefs.setIntPref(
|
||||
"mail.strictly_mime.parm_folding",
|
||||
ParamFoldingPref[folding]
|
||||
|
@ -134,7 +134,7 @@ async function testInput0() {
|
|||
}
|
||||
|
||||
async function testInput1() {
|
||||
for (let folding in ParamFoldingPref) {
|
||||
for (const folding in ParamFoldingPref) {
|
||||
Services.prefs.setIntPref(
|
||||
"mail.strictly_mime.parm_folding",
|
||||
ParamFoldingPref[folding]
|
||||
|
@ -156,9 +156,9 @@ function run_test() {
|
|||
* Test that the full attachment content is used to pick the CTE.
|
||||
*/
|
||||
add_task(async function testBinaryAfterPlainTextAttachment() {
|
||||
let testFile = do_get_file("data/binary-after-plain.txt");
|
||||
const testFile = do_get_file("data/binary-after-plain.txt");
|
||||
await createMessage(testFile);
|
||||
let msgData = mailTestUtils.loadMessageToString(
|
||||
const msgData = mailTestUtils.loadMessageToString(
|
||||
gDraftFolder,
|
||||
mailTestUtils.firstMsgHdr(gDraftFolder)
|
||||
);
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче