Bug 1594890 - Remove xpidl [array] use in nsIMsgCompFields. r=mkmelin

This commit is contained in:
Ben Campbell 2019-12-03 20:11:24 +02:00
Родитель e2b7471fd9
Коммит 7f7c240f08
10 изменённых файлов: 37 добавлений и 56 удалений

Просмотреть файл

@ -146,7 +146,7 @@ var calemail = {
Ci.nsIMsgCompFields
);
// Resolve the list considering also configured common names
let members = compFields.splitRecipients(aRecipients, false, {});
let members = compFields.splitRecipients(aRecipients, false);
let list = [];
let prefix = "";
for (let member of members) {

Просмотреть файл

@ -482,7 +482,7 @@ var calitip = {
let compFields = Cc["@mozilla.org/messengercompose/composefields;1"].createInstance(
Ci.nsIMsgCompFields
);
let addresses = compFields.splitRecipients(author, true, {});
let addresses = compFields.splitRecipients(author, true);
if (addresses.length != 1) {
cal.LOG("No unique email address for lookup in message.\r\n" + cal.STACK(20));
}
@ -1264,7 +1264,7 @@ var calitip = {
let compFields = Cc["@mozilla.org/messengercompose/composefields;1"].createInstance(
Ci.nsIMsgCompFields
);
let addresses = compFields.splitRecipients(aEmailAddress, true, {});
let addresses = compFields.splitRecipients(aEmailAddress, true);
if (addresses.length == 1) {
let searchFor = cal.email.prependMailTo(addresses[0]);
aAttendees.forEach(aAttendee => {

Просмотреть файл

@ -3905,8 +3905,7 @@ function CheckValidEmailAddress(aMsgCompFields) {
for (let type of ["to", "cc", "bcc"]) {
let recipients = aMsgCompFields.splitRecipients(
aMsgCompFields[type],
false,
{}
false
);
// MsgCompFields contains only non-empty recipients.
recipientCount += recipients.length;
@ -6301,10 +6300,10 @@ function LoadIdentity(startup) {
}
let toAddrs = new Set(
msgCompFields.splitRecipients(msgCompFields.to, true, {})
msgCompFields.splitRecipients(msgCompFields.to, true)
);
let ccAddrs = new Set(
msgCompFields.splitRecipients(msgCompFields.cc, true, {})
msgCompFields.splitRecipients(msgCompFields.cc, true)
);
if (newCc != prevCc) {
@ -6314,7 +6313,7 @@ function LoadIdentity(startup) {
}
if (newCc) {
// Ensure none of the Ccs are already in To.
let cc2 = msgCompFields.splitRecipients(newCc, true, {});
let cc2 = msgCompFields.splitRecipients(newCc, true);
newCc = cc2.filter(x => !toAddrs.has(x)).join(", ");
awAddRecipients(msgCompFields, "addr_cc", newCc);
}
@ -6327,7 +6326,7 @@ function LoadIdentity(startup) {
}
if (newBcc) {
// Ensure none of the Bccs are already in To or Cc.
let bcc2 = msgCompFields.splitRecipients(newBcc, true, {});
let bcc2 = msgCompFields.splitRecipients(newBcc, true);
let toCcAddrs = new Set([...toAddrs, ...ccAddrs]);
newBcc = bcc2.filter(x => !toCcAddrs.has(x)).join(", ");
awAddRecipients(msgCompFields, "addr_bcc", newBcc);

Просмотреть файл

@ -203,14 +203,14 @@ function CompFields2Recipients(msgCompFields) {
let havePrimaryRecipient = false;
if (msgReplyTo) {
awSetInputAndPopupFromArray(
msgCompFields.splitRecipients(msgReplyTo, false, {}),
msgCompFields.splitRecipients(msgReplyTo, false),
"addr_reply",
listbox,
templateNode
);
}
if (msgTo) {
let rcp = msgCompFields.splitRecipients(msgTo, false, {});
let rcp = msgCompFields.splitRecipients(msgTo, false);
if (rcp.length) {
awSetInputAndPopupFromArray(rcp, "addr_to", listbox, templateNode);
havePrimaryRecipient = true;
@ -218,7 +218,7 @@ function CompFields2Recipients(msgCompFields) {
}
if (msgCC) {
awSetInputAndPopupFromArray(
msgCompFields.splitRecipients(msgCC, false, {}),
msgCompFields.splitRecipients(msgCC, false),
"addr_cc",
listbox,
templateNode
@ -226,7 +226,7 @@ function CompFields2Recipients(msgCompFields) {
}
if (msgBCC) {
awSetInputAndPopupFromArray(
msgCompFields.splitRecipients(msgBCC, false, {}),
msgCompFields.splitRecipients(msgBCC, false),
"addr_bcc",
listbox,
templateNode
@ -359,7 +359,7 @@ function awRemoveRecipients(msgCompFields, recipientType, recipientsList) {
return;
}
var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
var recipientArray = msgCompFields.splitRecipients(recipientsList, false);
for (var index = 0; index < recipientArray.length; index++) {
for (var row = 1; row <= top.MAX_RECIPIENTS; row++) {
@ -388,7 +388,7 @@ function awAddRecipients(msgCompFields, recipientType, recipientsList) {
return;
}
var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
var recipientArray = msgCompFields.splitRecipients(recipientsList, false);
awAddRecipientsArray(recipientType, recipientArray);
}

Просмотреть файл

@ -1350,11 +1350,10 @@ function convertMessage(msgHdr, extension) {
author: msgHdr.mime2DecodedAuthor,
recipients: composeFields.splitRecipients(
msgHdr.mime2DecodedRecipients,
false,
{}
false
),
ccList: composeFields.splitRecipients(msgHdr.ccList, false, {}),
bccList: composeFields.splitRecipients(msgHdr.bccList, false, {}),
ccList: composeFields.splitRecipients(msgHdr.ccList, false),
bccList: composeFields.splitRecipients(msgHdr.bccList, false),
subject: msgHdr.mime2DecodedSubject,
read: msgHdr.isRead,
flagged: msgHdr.isFlagged,

Просмотреть файл

@ -77,12 +77,11 @@ interface nsIMsgCompFields : msgIWritableStructuredHeaders {
* @param aRecipients The recipients list to split.
* @param aEmailAddressOnly Set to true to drop display names from the results
* array.
* @param aLength The length of the aResult array.
* @param aResult An array of the recipients.
*
* @return An array of the recipients.
*/
void splitRecipients(in AString aRecipients, in boolean aEmailAddressOnly,
out unsigned long aLength,
[array, size_is(aLength), retval] out wstring aResult);
Array<AString> splitRecipients(in AString aRecipients,
in boolean aEmailAddressOnly);
void ConvertBodyToPlainText();

Просмотреть файл

@ -519,27 +519,14 @@ NS_IMETHODIMP nsMsgCompFields::RemoveAttachments() {
// This method is called during the creation of a new window.
NS_IMETHODIMP
nsMsgCompFields::SplitRecipients(const nsAString &aRecipients,
bool aEmailAddressOnly, uint32_t *aLength,
char16_t ***aResult) {
NS_ENSURE_ARG_POINTER(aLength);
NS_ENSURE_ARG_POINTER(aResult);
*aLength = 0;
*aResult = nullptr;
bool aEmailAddressOnly,
nsTArray<nsString> &aResult) {
nsCOMArray<msgIAddressObject> header(EncodedHeaderW(aRecipients));
nsTArray<nsString> results;
if (aEmailAddressOnly)
ExtractEmails(header, results);
ExtractEmails(header, aResult);
else
ExtractDisplayAddresses(header, results);
ExtractDisplayAddresses(header, aResult);
uint32_t count = results.Length();
char16_t **result = (char16_t **)moz_xmalloc(sizeof(char16_t *) * count);
for (uint32_t i = 0; i < count; ++i) result[i] = ToNewUnicode(results[i]);
*aResult = result;
*aLength = count;
return NS_OK;
}

Просмотреть файл

@ -148,18 +148,15 @@ function run_test() {
// the basic argument/return combinations.
for (var part = 0; part < splitRecipientsTests.length; ++part) {
var count = {};
print("Test: " + splitRecipientsTests[part].recipients);
var result = fields.splitRecipients(
splitRecipientsTests[part].recipients,
splitRecipientsTests[part].emailAddressOnly,
count
splitRecipientsTests[part].emailAddressOnly
);
Assert.equal(splitRecipientsTests[part].count, count.value);
Assert.equal(splitRecipientsTests[part].count, result.length);
for (var item = 0; item < count.value; ++item) {
for (var item = 0; item < result.length; ++item) {
Assert.equal(splitRecipientsTests[part].result[item], result[item]);
}
}

Просмотреть файл

@ -2863,8 +2863,8 @@ function LoadIdentity(startup)
awAddRecipients(msgCompFields, "addr_reply", newReplyTo);
}
let toAddrs = new Set(msgCompFields.splitRecipients(msgCompFields.to, true, {}));
let ccAddrs = new Set(msgCompFields.splitRecipients(msgCompFields.cc, true, {}));
let toAddrs = new Set(msgCompFields.splitRecipients(msgCompFields.to, true));
let ccAddrs = new Set(msgCompFields.splitRecipients(msgCompFields.cc, true));
if (newCc != prevCc)
{
@ -2873,7 +2873,7 @@ function LoadIdentity(startup)
awRemoveRecipients(msgCompFields, "addr_cc", prevCc);
if (newCc) {
// Ensure none of the Ccs are already in To.
let cc2 = msgCompFields.splitRecipients(newCc, true, {});
let cc2 = msgCompFields.splitRecipients(newCc, true);
newCc = cc2.filter(x => !toAddrs.has(x)).join(", ");
awAddRecipients(msgCompFields, "addr_cc", newCc);
}
@ -2886,7 +2886,7 @@ function LoadIdentity(startup)
awRemoveRecipients(msgCompFields, "addr_bcc", prevBcc);
if (newBcc) {
// Ensure none of the Bccs are already in To or Cc.
let bcc2 = msgCompFields.splitRecipients(newBcc, true, {});
let bcc2 = msgCompFields.splitRecipients(newBcc, true);
let toCcAddrs = new Set([...toAddrs, ...ccAddrs]);
newBcc = bcc2.filter(x => !toCcAddrs.has(x)).join(", ");
awAddRecipients(msgCompFields, "addr_bcc", newBcc);

Просмотреть файл

@ -176,11 +176,11 @@ function CompFields2Recipients(msgCompFields)
var msgFollowupTo = msgCompFields.followupTo;
var havePrimaryRecipient = false;
if(msgReplyTo)
awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgReplyTo, false, {}),
awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgReplyTo, false),
"addr_reply", newListBoxNode, templateNode);
if(msgTo)
{
var rcp = msgCompFields.splitRecipients(msgTo, false, {});
var rcp = msgCompFields.splitRecipients(msgTo, false);
if (rcp.length)
{
awSetInputAndPopupFromArray(rcp, "addr_to", newListBoxNode, templateNode);
@ -188,10 +188,10 @@ function CompFields2Recipients(msgCompFields)
}
}
if(msgCC)
awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgCC, false, {}),
awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgCC, false),
"addr_cc", newListBoxNode, templateNode);
if(msgBCC)
awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgBCC, false, {}),
awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgBCC, false),
"addr_bcc", newListBoxNode, templateNode);
if(msgNewsgroups)
{
@ -276,7 +276,7 @@ function awRemoveRecipients(msgCompFields, recipientType, recipientsList)
if (!msgCompFields)
return;
var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
var recipientArray = msgCompFields.splitRecipients(recipientsList, false);
for (var index = 0; index < recipientArray.length; index++)
for (var row = 1; row <= top.MAX_RECIPIENTS; row ++)
@ -299,7 +299,7 @@ function awAddRecipients(msgCompFields, recipientType, recipientsList)
if (!msgCompFields)
return;
var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
var recipientArray = msgCompFields.splitRecipients(recipientsList, false);
for (var index = 0; index < recipientArray.length; index++)
awAddRecipient(recipientType, recipientArray[index]);