Bug 1682943 - Remove nsISimpleEnumerator use in nsIMsgCompFields.idl. r=mkmelin

This commit is contained in:
Ben Campbell 2020-12-17 11:03:34 +13:00
Родитель 49deaec6f2
Коммит d6bb465ae8
6 изменённых файлов: 229 добавлений и 295 удалений

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

@ -5844,17 +5844,15 @@ function FileToAttachment(file) {
}
/**
* Add a list of attachment objects as attachments. The attachment URLs must be
* set.
* Add a list of attachment objects as attachments. The attachment URLs must
* be set.
*
* @param aAttachments an iterable list of nsIMsgAttachment objects to add as
* attachments. Anything iterable with fixIterator is
* accepted.
* @param aCallback an optional callback function called immediately after
* adding each attachment. Takes one argument:
* the newly-added <attachmentitem> node.
* @param aContentChanged {Boolean} optional value to assign to gContentChanged
* after adding attachments; defaults to true.
* @param {nsIMsgAttachment[]} aAttachments - Objects to add as attachments.
* @param {function} [aCallback] - An optional callback function called after
* adding each attachment. Takes one argument: the newly-added
* <attachmentitem> node.
* @param {Boolean} [aContentChanged=true] - Optional value to assign gContentChanged
* after adding attachments.
*/
function AddAttachments(aAttachments, aCallback, aContentChanged = true) {
let bucket = document.getElementById("attachmentBucket");

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

@ -261,8 +261,8 @@ add_task(function test_attachment_reminder_with_attachment() {
file.exists(),
"The required file panacea.dat was not found in the profile."
);
let attachment = [cwc.window.FileToAttachment(file)];
cwc.window.AddAttachments(attachment);
let attachments = [cwc.window.FileToAttachment(file)];
cwc.window.AddAttachments(attachments);
// The notification should hide.
wait_for_reminder_state(cwc, false);

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

@ -6,7 +6,6 @@
#include "msgIStructuredHeaders.idl"
interface nsIMsgAttachment;
interface nsISimpleEnumerator;
interface nsIMsgComposeSecure;
/**
@ -64,7 +63,7 @@ interface nsIMsgCompFields : msgIWritableStructuredHeaders {
*/
attribute AString body;
readonly attribute nsISimpleEnumerator attachments;
readonly attribute Array<nsIMsgAttachment> attachments;
void addAttachment(in nsIMsgAttachment attachment);
void removeAttachment(in nsIMsgAttachment attachment);
void removeAttachments();

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

@ -449,41 +449,30 @@ nsresult nsMsgCompFields::SetBody(const char* value) {
const char* nsMsgCompFields::GetBody() { return m_body.get(); }
/* readonly attribute nsISimpleEnumerator attachmentsArray; */
NS_IMETHODIMP nsMsgCompFields::GetAttachments(
nsISimpleEnumerator** aAttachmentsEnum) {
return aAttachmentsEnum
? NS_NewArrayEnumerator(aAttachmentsEnum, m_attachments,
NS_GET_IID(nsIMsgAttachment))
: NS_ERROR_NULL_POINTER;
nsTArray<RefPtr<nsIMsgAttachment>>& attachments) {
attachments = m_attachments.Clone();
return NS_OK;
}
/* void addAttachment (in nsIMsgAttachment attachment); */
NS_IMETHODIMP nsMsgCompFields::AddAttachment(nsIMsgAttachment* attachment) {
int32_t attachmentCount = m_attachments.Count();
// Don't add twice the same attachment.
nsCOMPtr<nsIMsgAttachment> element;
bool sameUrl;
for (int32_t i = 0; i < attachmentCount; i++) {
m_attachments[i]->EqualsUrl(attachment, &sameUrl);
// Don't add the same attachment twice.
for (nsIMsgAttachment* a : m_attachments) {
bool sameUrl;
a->EqualsUrl(attachment, &sameUrl);
if (sameUrl) return NS_OK;
}
m_attachments.AppendObject(attachment);
m_attachments.AppendElement(attachment);
return NS_OK;
}
/* void removeAttachment (in nsIMsgAttachment attachment); */
NS_IMETHODIMP nsMsgCompFields::RemoveAttachment(nsIMsgAttachment* attachment) {
int32_t attachmentCount = m_attachments.Count();
nsCOMPtr<nsIMsgAttachment> element;
bool sameUrl;
for (int32_t i = 0; i < attachmentCount; i++) {
for (uint32_t i = 0; i < m_attachments.Length(); i++) {
bool sameUrl;
m_attachments[i]->EqualsUrl(attachment, &sameUrl);
if (sameUrl) {
m_attachments.RemoveObjectAt(i);
m_attachments.RemoveElementAt(i);
break;
}
}

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

@ -193,7 +193,7 @@ class nsMsgCompFields : public nsIMsgCompFields {
virtual ~nsMsgCompFields();
nsCString m_headers[MSG_MAX_HEADERS];
nsCString m_body;
nsCOMArray<nsIMsgAttachment> m_attachments;
nsTArray<RefPtr<nsIMsgAttachment>> m_attachments;
bool m_attachVCard;
bool m_attachmentReminder;
int32_t m_deliveryFormat;

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

@ -1625,36 +1625,21 @@ nsresult nsMsgComposeAndSend::CountCompFieldAttachments() {
mCompFieldLocalAttachments = 0;
mCompFieldRemoteAttachments = 0;
// Get the attachments array
nsCOMPtr<nsISimpleEnumerator> attachments;
mCompFields->GetAttachments(getter_AddRefs(attachments));
if (!attachments) return NS_OK;
nsresult rv;
// Parse the attachments array
bool moreAttachments;
nsCString url;
nsCOMPtr<nsISupports> element;
while (NS_SUCCEEDED(attachments->HasMoreElements(&moreAttachments)) &&
moreAttachments) {
rv = attachments->GetNext(getter_AddRefs(element));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
if (NS_SUCCEEDED(rv) && attachment) {
attachment->GetUrl(url);
if (!url.IsEmpty()) {
// Check to see if this is a file URL, if so, don't retrieve
// like a remote URL...
if (PL_strncasecmp(url.get(), "file://", 7) == 0)
mCompFieldLocalAttachments++;
else // This is a remote URL...
mCompFieldRemoteAttachments++;
}
nsTArray<RefPtr<nsIMsgAttachment>> attachments;
mCompFields->GetAttachments(attachments);
for (nsIMsgAttachment* attachment : attachments) {
nsCString url;
attachment->GetUrl(url);
if (!url.IsEmpty()) {
// Check to see if this is a file URL, if so, don't retrieve
// like a remote URL...
if (PL_strncasecmp(url.get(), "file://", 7) == 0)
mCompFieldLocalAttachments++;
else // This is a remote URL...
mCompFieldRemoteAttachments++;
}
}
return NS_OK;
}
@ -1665,183 +1650,169 @@ nsresult nsMsgComposeAndSend::AddCompFieldLocalAttachments() {
// If none, just return...
if (mCompFieldLocalAttachments <= 0) return NS_OK;
// Get the attachments array
nsCOMPtr<nsISimpleEnumerator> attachments;
mCompFields->GetAttachments(getter_AddRefs(attachments));
if (!attachments) return NS_OK;
uint32_t newLoc = 0;
nsresult rv;
nsCString url;
// Parse the attachments array
bool moreAttachments;
nsCOMPtr<nsISupports> element;
while (NS_SUCCEEDED(attachments->HasMoreElements(&moreAttachments)) &&
moreAttachments) {
rv = attachments->GetNext(getter_AddRefs(element));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
if (NS_SUCCEEDED(rv) && attachment) {
bool sendViaCloud = false;
nsTArray<RefPtr<nsIMsgAttachment>> attachments;
mCompFields->GetAttachments(attachments);
uint32_t newLoc = 0;
for (nsIMsgAttachment* attachment : attachments) {
bool sendViaCloud = false;
attachment->GetSendViaCloud(&sendViaCloud);
m_attachments[newLoc]->mSendViaCloud = sendViaCloud;
nsCString url;
attachment->GetUrl(url);
if (!url.IsEmpty()) {
bool sendViaCloud;
attachment->GetSendViaCloud(&sendViaCloud);
m_attachments[newLoc]->mSendViaCloud = sendViaCloud;
attachment->GetUrl(url);
if (!url.IsEmpty()) {
bool sendViaCloud;
attachment->GetSendViaCloud(&sendViaCloud);
if (sendViaCloud) {
nsCString cloudFileAccountKey;
// We'd like to output a part for the attachment, just an html part
// with information about how to download the attachment.
// m_attachments[newLoc]->m_done = true;
attachment->GetHtmlAnnotation(m_attachments[newLoc]->mHtmlAnnotation);
m_attachments[newLoc]->m_type.AssignLiteral("text/html");
attachment->GetCloudFileAccountKey(
m_attachments[newLoc]->mCloudFileAccountKey);
attachment->GetContentLocation(m_attachments[newLoc]->mCloudUrl);
if (sendViaCloud) {
nsCString cloudFileAccountKey;
// We'd like to output a part for the attachment, just an html part
// with information about how to download the attachment.
// m_attachments[newLoc]->m_done = true;
attachment->GetHtmlAnnotation(m_attachments[newLoc]->mHtmlAnnotation);
m_attachments[newLoc]->m_type.AssignLiteral("text/html");
attachment->GetCloudFileAccountKey(
m_attachments[newLoc]->mCloudFileAccountKey);
attachment->GetContentLocation(m_attachments[newLoc]->mCloudUrl);
}
// Just look for local file:// attachments and do the right thing.
if (PL_strncasecmp(url.get(), "file://", 7) == 0) {
//
// Now we have to setup the m_attachments entry for the file://
// URL that is passed in...
//
m_attachments[newLoc]->mDeleteFile = false;
nsMsgNewURL(getter_AddRefs(m_attachments[newLoc]->mURL), url);
if (m_attachments[newLoc]->mTmpFile) {
if (m_attachments[newLoc]->mDeleteFile)
m_attachments[newLoc]->mTmpFile->Remove(false);
m_attachments[newLoc]->mTmpFile = nullptr;
}
nsresult rv;
nsCOMPtr<nsIIOService> ioService = mozilla::services::GetIOService();
NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIURI> uri;
rv = ioService->NewURI(url, nullptr, nullptr, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> fileURLFile;
fileURL->GetFile(getter_AddRefs(fileURLFile));
m_attachments[newLoc]->mTmpFile = fileURLFile;
m_attachments[newLoc]->mDeleteFile = false;
if (m_attachments[newLoc]->mURL) {
nsAutoString proposedName;
attachment->GetName(proposedName);
msg_pick_real_name(m_attachments[newLoc], proposedName.get());
}
// Just look for local file:// attachments and do the right thing.
if (PL_strncasecmp(url.get(), "file://", 7) == 0) {
//
// Now we have to setup the m_attachments entry for the file://
// URL that is passed in...
//
m_attachments[newLoc]->mDeleteFile = false;
nsMsgNewURL(getter_AddRefs(m_attachments[newLoc]->mURL), url);
if (m_attachments[newLoc]->mTmpFile) {
if (m_attachments[newLoc]->mDeleteFile)
m_attachments[newLoc]->mTmpFile->Remove(false);
m_attachments[newLoc]->mTmpFile = nullptr;
}
nsresult rv;
nsCOMPtr<nsIIOService> ioService = mozilla::services::GetIOService();
NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIURI> uri;
rv = ioService->NewURI(url, nullptr, nullptr, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> fileURLFile;
fileURL->GetFile(getter_AddRefs(fileURLFile));
m_attachments[newLoc]->mTmpFile = fileURLFile;
m_attachments[newLoc]->mDeleteFile = false;
if (m_attachments[newLoc]->mURL) {
nsAutoString proposedName;
attachment->GetName(proposedName);
msg_pick_real_name(m_attachments[newLoc], proposedName.get());
}
// Now, most importantly, we need to figure out what the content type
// is for this attachment... If we can't, then just make it
// application/octet-stream.
// Now, most importantly, we need to figure out what the content type
// is for this attachment... If we can't, then just make it
// application/octet-stream.
#ifdef MAC_OSX
// Mac always need to snarf the file to figure out how to send it,
// maybe we need to use apple double...
// unless caller has already set the content type, in which case,
// trust them.
bool mustSnarfAttachment = true;
// Mac always need to snarf the file to figure out how to send it,
// maybe we need to use apple double...
// unless caller has already set the content type, in which case,
// trust them.
bool mustSnarfAttachment = true;
#else
bool mustSnarfAttachment = false;
bool mustSnarfAttachment = false;
#endif
if (sendViaCloud) mustSnarfAttachment = false;
if (sendViaCloud) mustSnarfAttachment = false;
attachment->GetContentType(
getter_Copies(m_attachments[newLoc]->m_type));
if (m_attachments[newLoc]->m_type.IsEmpty()) {
nsresult rv = NS_OK;
nsCOMPtr<nsIMIMEService> mimeFinder(
do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && mimeFinder) {
nsCOMPtr<nsIURL> fileUrl;
rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.Apply(NS_MutatorMethod(
&nsIURLMutator::SetFileName,
m_attachments[newLoc]->m_realName, nullptr))
.Finalize(fileUrl);
if (NS_SUCCEEDED(rv)) {
nsAutoCString fileExt;
// First try using the real file name.
rv = fileUrl->GetFileExtension(fileExt);
if (NS_SUCCEEDED(rv) && !fileExt.IsEmpty()) {
nsAutoCString type;
mimeFinder->GetTypeFromExtension(fileExt, type);
attachment->GetContentType(
getter_Copies(m_attachments[newLoc]->m_type));
if (m_attachments[newLoc]->m_type.IsEmpty()) {
nsresult rv = NS_OK;
nsCOMPtr<nsIMIMEService> mimeFinder(
do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && mimeFinder) {
nsCOMPtr<nsIURL> fileUrl;
rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.Apply(NS_MutatorMethod(&nsIURLMutator::SetFileName,
m_attachments[newLoc]->m_realName,
nullptr))
.Finalize(fileUrl);
if (NS_SUCCEEDED(rv)) {
nsAutoCString fileExt;
// First try using the real file name.
rv = fileUrl->GetFileExtension(fileExt);
if (NS_SUCCEEDED(rv) && !fileExt.IsEmpty()) {
nsAutoCString type;
mimeFinder->GetTypeFromExtension(fileExt, type);
#ifndef XP_MACOSX
if (!type.EqualsLiteral(
"multipart/appledouble")) // can't do apple double on
// non-macs
if (!type.EqualsLiteral(
"multipart/appledouble")) // can't do apple double on
// non-macs
#endif
m_attachments[newLoc]->m_type = type;
}
m_attachments[newLoc]->m_type = type;
}
// Then try using the url if we still haven't figured out the
// content type
if (m_attachments[newLoc]->m_type.IsEmpty()) {
rv = NS_MutateURI(fileUrl).SetSpec(url).Finalize(fileUrl);
if (NS_SUCCEEDED(rv)) {
rv = fileUrl->GetFileExtension(fileExt);
if (NS_SUCCEEDED(rv) && !fileExt.IsEmpty()) {
nsAutoCString type;
mimeFinder->GetTypeFromExtension(fileExt, type);
// Then try using the url if we still haven't figured out the
// content type
if (m_attachments[newLoc]->m_type.IsEmpty()) {
rv = NS_MutateURI(fileUrl).SetSpec(url).Finalize(fileUrl);
if (NS_SUCCEEDED(rv)) {
rv = fileUrl->GetFileExtension(fileExt);
if (NS_SUCCEEDED(rv) && !fileExt.IsEmpty()) {
nsAutoCString type;
mimeFinder->GetTypeFromExtension(fileExt, type);
#ifndef XP_MACOSX
if (!type.EqualsLiteral(
"multipart/appledouble")) // can't do apple
// double on non-macs
if (!type.EqualsLiteral(
"multipart/appledouble")) // can't do apple
// double on non-macs
#endif
m_attachments[newLoc]->m_type = type;
// rtf and vcs files may look like text to sniffers,
// but they're not human readable.
if (type.IsEmpty() && !fileExt.IsEmpty() &&
(fileExt.LowerCaseEqualsLiteral("rtf") ||
fileExt.LowerCaseEqualsLiteral("vcs")))
m_attachments[newLoc]->m_type =
APPLICATION_OCTET_STREAM;
}
m_attachments[newLoc]->m_type = type;
// rtf and vcs files may look like text to sniffers,
// but they're not human readable.
if (type.IsEmpty() && !fileExt.IsEmpty() &&
(fileExt.LowerCaseEqualsLiteral("rtf") ||
fileExt.LowerCaseEqualsLiteral("vcs")))
m_attachments[newLoc]->m_type = APPLICATION_OCTET_STREAM;
}
}
}
}
} else {
attachment->GetContentTypeParam(
getter_Copies(m_attachments[newLoc]->m_typeParam));
mustSnarfAttachment = false;
if (m_attachments[newLoc]->m_type.EqualsLiteral("application/pgp-keys")) {
m_attachments[newLoc]->m_description = nsLiteralCString("OpenPGP public key");
}
}
// We need to snarf the file to figure out how to send it only if we
// don't have a content type...
if (mustSnarfAttachment || m_attachments[newLoc]->m_type.IsEmpty()) {
m_attachments[newLoc]->m_done = false;
m_attachments[newLoc]->SetMimeDeliveryState(this);
} else {
m_attachments[newLoc]->m_done = true;
m_attachments[newLoc]->SetMimeDeliveryState(nullptr);
} else {
attachment->GetContentTypeParam(
getter_Copies(m_attachments[newLoc]->m_typeParam));
mustSnarfAttachment = false;
if (m_attachments[newLoc]->m_type.EqualsLiteral(
"application/pgp-keys")) {
m_attachments[newLoc]->m_description =
nsLiteralCString("OpenPGP public key");
}
// For local files, if they are HTML docs and we don't have a charset,
// we should sniff the file and see if we can figure it out.
if (!m_attachments[newLoc]->m_type.IsEmpty()) {
if (m_attachments[newLoc]->m_type.LowerCaseEqualsLiteral(
TEXT_HTML)) {
char* tmpCharset = (char*)nsMsgI18NParseMetaCharset(
m_attachments[newLoc]->mTmpFile);
if (tmpCharset[0] != '\0')
m_attachments[newLoc]->m_charset = tmpCharset;
}
}
attachment->GetMacType(
getter_Copies(m_attachments[newLoc]->m_xMacType));
attachment->GetMacCreator(
getter_Copies(m_attachments[newLoc]->m_xMacCreator));
++newLoc;
}
// We need to snarf the file to figure out how to send it only if we
// don't have a content type...
if (mustSnarfAttachment || m_attachments[newLoc]->m_type.IsEmpty()) {
m_attachments[newLoc]->m_done = false;
m_attachments[newLoc]->SetMimeDeliveryState(this);
} else {
m_attachments[newLoc]->m_done = true;
m_attachments[newLoc]->SetMimeDeliveryState(nullptr);
}
// For local files, if they are HTML docs and we don't have a charset,
// we should sniff the file and see if we can figure it out.
if (!m_attachments[newLoc]->m_type.IsEmpty()) {
if (m_attachments[newLoc]->m_type.LowerCaseEqualsLiteral(TEXT_HTML)) {
char* tmpCharset = (char*)nsMsgI18NParseMetaCharset(
m_attachments[newLoc]->mTmpFile);
if (tmpCharset[0] != '\0')
m_attachments[newLoc]->m_charset = tmpCharset;
}
}
attachment->GetMacType(
getter_Copies(m_attachments[newLoc]->m_xMacType));
attachment->GetMacCreator(
getter_Copies(m_attachments[newLoc]->m_xMacCreator));
++newLoc;
}
}
}
@ -1854,75 +1825,62 @@ nsresult nsMsgComposeAndSend::AddCompFieldRemoteAttachments(
if (mCompFieldRemoteAttachments <= 0) return NS_OK;
// Get the attachments array
nsCOMPtr<nsISimpleEnumerator> attachments;
mCompFields->GetAttachments(getter_AddRefs(attachments));
if (!attachments) return NS_OK;
nsTArray<RefPtr<nsIMsgAttachment>> attachments;
mCompFields->GetAttachments(attachments);
uint32_t newLoc = aStartLocation;
for (nsIMsgAttachment* attachment : attachments) {
nsCString url;
attachment->GetUrl(url);
if (!url.IsEmpty()) {
// Just look for files that are NOT local file attachments and do
// the right thing.
if (PL_strncasecmp(url.get(), "file://", 7) != 0) {
// Check for message attachment, see
// nsMsgMailNewsUrl::GetIsMessageUri.
nsCOMPtr<nsIURI> nsiuri;
nsresult rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.SetSpec(url)
.Finalize(nsiuri);
NS_ENSURE_SUCCESS(rv, rv);
nsresult rv;
bool moreAttachments;
nsCString url;
nsCOMPtr<nsISupports> element;
while (NS_SUCCEEDED(attachments->HasMoreElements(&moreAttachments)) &&
moreAttachments) {
rv = attachments->GetNext(getter_AddRefs(element));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString scheme;
nsiuri->GetScheme(scheme);
bool isAMessageAttachment = StringEndsWith(scheme, "-message"_ns);
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
if (NS_SUCCEEDED(rv) && attachment) {
attachment->GetUrl(url);
if (!url.IsEmpty()) {
// Just look for files that are NOT local file attachments and do
// the right thing.
if (PL_strncasecmp(url.get(), "file://", 7) != 0) {
// Check for message attachment, see
// nsMsgMailNewsUrl::GetIsMessageUri.
nsCOMPtr<nsIURI> nsiuri;
rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.SetSpec(url)
.Finalize(nsiuri);
NS_ENSURE_SUCCESS(rv, rv);
m_attachments[newLoc]->mDeleteFile = true;
m_attachments[newLoc]->m_done = false;
m_attachments[newLoc]->SetMimeDeliveryState(this);
nsAutoCString scheme;
nsiuri->GetScheme(scheme);
bool isAMessageAttachment = StringEndsWith(scheme, "-message"_ns);
if (!isAMessageAttachment)
nsMsgNewURL(getter_AddRefs(m_attachments[newLoc]->mURL), url);
m_attachments[newLoc]->mDeleteFile = true;
m_attachments[newLoc]->m_done = false;
m_attachments[newLoc]->SetMimeDeliveryState(this);
m_attachments[newLoc]->m_encoding = ENCODING_7BIT;
if (!isAMessageAttachment)
nsMsgNewURL(getter_AddRefs(m_attachments[newLoc]->mURL), url);
attachment->GetMacType(
getter_Copies(m_attachments[newLoc]->m_xMacType));
attachment->GetMacCreator(
getter_Copies(m_attachments[newLoc]->m_xMacCreator));
m_attachments[newLoc]->m_encoding = ENCODING_7BIT;
/* Count up attachments which are going to come from mail folders
and from NNTP servers. */
bool do_add_attachment = false;
if (isAMessageAttachment) {
do_add_attachment = true;
if (!PL_strncasecmp(url.get(), "news-message://", 15))
(*aNewsCount)++;
else
(*aMailboxCount)++;
attachment->GetMacType(
getter_Copies(m_attachments[newLoc]->m_xMacType));
attachment->GetMacCreator(
getter_Copies(m_attachments[newLoc]->m_xMacCreator));
/* Count up attachments which are going to come from mail folders
and from NNTP servers. */
bool do_add_attachment = false;
if (isAMessageAttachment) {
do_add_attachment = true;
if (!PL_strncasecmp(url.get(), "news-message://", 15))
(*aNewsCount)++;
else
(*aMailboxCount)++;
m_attachments[newLoc]->m_uri = url;
m_attachments[newLoc]->mURL = nullptr;
} else
do_add_attachment = (nullptr != m_attachments[newLoc]->mURL);
m_attachments[newLoc]->mSendViaCloud = false;
if (do_add_attachment) {
nsAutoString proposedName;
attachment->GetName(proposedName);
msg_pick_real_name(m_attachments[newLoc], proposedName.get());
++newLoc;
}
m_attachments[newLoc]->m_uri = url;
m_attachments[newLoc]->mURL = nullptr;
} else
do_add_attachment = (nullptr != m_attachments[newLoc]->mURL);
m_attachments[newLoc]->mSendViaCloud = false;
if (do_add_attachment) {
nsAutoString proposedName;
attachment->GetName(proposedName);
msg_pick_real_name(m_attachments[newLoc], proposedName.get());
++newLoc;
}
}
}
@ -2270,20 +2228,10 @@ nsresult nsMsgComposeAndSend::InitCompositionFields(
rv = mCompFields->AddAllHeaders(fields);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISimpleEnumerator> srcAttachments;
fields->GetAttachments(getter_AddRefs(srcAttachments));
if (srcAttachments) {
bool moreAttachments;
nsCOMPtr<nsISupports> element;
while (NS_SUCCEEDED(srcAttachments->HasMoreElements(&moreAttachments)) &&
moreAttachments) {
rv = srcAttachments->GetNext(getter_AddRefs(element));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mCompFields->AddAttachment(attachment);
}
nsTArray<RefPtr<nsIMsgAttachment>> srcAttachments;
fields->GetAttachments(srcAttachments);
for (nsIMsgAttachment* attachment : srcAttachments) {
mCompFields->AddAttachment(attachment);
}
AddDefaultCustomHeaders();