Bug 1393219 - Code clean-up: Style nits, typos and trailing spaces

Tag #1273
This commit is contained in:
Matt A. Tobin 2019-11-10 19:32:24 -05:00 • committed by Roy Tam
commit c021f0c983
4 changed files with 107 additions and 109 deletions

View file

@ -2506,15 +2506,15 @@ nsAutoCString MsgExtractQueryPart(nsAutoCString spec, const char* queryToExtract
if (queryIndex == kNotFound) if (queryIndex == kNotFound)
return queryPart; return queryPart;
int32_t queryEnd = Substring(spec, queryIndex + 1).FindChar('&'); int32_t queryEnd = spec.FindChar('&', queryIndex + 1);
if (queryEnd == kNotFound) if (queryEnd == kNotFound)
queryEnd = Substring(spec, queryIndex + 1).FindChar('?'); queryEnd = spec.FindChar('?', queryIndex + 1);
if (queryEnd == kNotFound) { if (queryEnd == kNotFound) {
// Nothing follows, so return from where the query qualifier started. // Nothing follows, so return from where the query qualifier started.
queryPart.Assign(Substring(spec, queryIndex)); queryPart.Assign(Substring(spec, queryIndex));
} else { } else {
// Return the substring that represents the query qualifier. // Return the substring that represents the query qualifier.
queryPart.Assign(Substring(spec, queryIndex, queryEnd + 1)); queryPart.Assign(Substring(spec, queryIndex, queryEnd - queryIndex));
} }
return queryPart; return queryPart;
} }

View file

@ -95,7 +95,7 @@ nsresult nsMailtoUrl::ParseMailtoUrl(char * searchPart)
nsCString decodedName; nsCString decodedName;
MsgUnescapeString(nsDependentCString(token), 0, decodedName); MsgUnescapeString(nsDependentCString(token), 0, decodedName);
if (decodedName.Length() == 0) if (decodedName.IsEmpty())
break; break;
switch (NS_ToUpper(decodedName.First())) switch (NS_ToUpper(decodedName.First()))

View file

@ -751,10 +751,8 @@ nsMsgBrkMBoxStore::GetMsgInputStream(nsIMsgFolder *aMsgFolder,
else else
*aOffset = ParseUint64Str(PromiseFlatCString(aMsgToken).get()); *aOffset = ParseUint64Str(PromiseFlatCString(aMsgToken).get());
*aReusable = true; *aReusable = true;
nsCString URI;
nsCOMPtr<nsIFile> mboxFile; nsCOMPtr<nsIFile> mboxFile;
aMsgFolder->GetURI(URI);
aMsgFolder->GetFilePath(getter_AddRefs(mboxFile)); aMsgFolder->GetFilePath(getter_AddRefs(mboxFile));
return NS_NewLocalFileInputStream(aResult, mboxFile); return NS_NewLocalFileInputStream(aResult, mboxFile);
} }

View file

@ -65,9 +65,9 @@ using namespace mozilla::mailnews;
// Forward declarations... // Forward declarations...
// //
extern "C" char *MIME_StripContinuations(char *original); extern "C" char *MIME_StripContinuations(char *original);
int mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers ); int mime_decompose_file_init_fn(void *stream_closure, MimeHeaders *headers);
int mime_decompose_file_output_fn ( const char *buf, int32_t size, void *stream_closure ); int mime_decompose_file_output_fn(const char *buf, int32_t size, void *stream_closure);
int mime_decompose_file_close_fn ( void *stream_closure ); int mime_decompose_file_close_fn(void *stream_closure);
extern int MimeHeaders_build_heads_list(MimeHeaders *hdrs); extern int MimeHeaders_build_heads_list(MimeHeaders *hdrs);
// CID's // CID's
@ -97,7 +97,7 @@ mime_draft_data::mime_draft_data() : url_name(nullptr), format_out(0),
nsresult nsresult
nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile) nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile)
{ {
if ((!tFileName) || (!*tFileName)) if (!tFileName || !*tFileName)
tFileName = SAFE_TMP_FILENAME; tFileName = SAFE_TMP_FILENAME;
nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR,
@ -132,16 +132,16 @@ typedef enum {
#ifdef NS_DEBUG #ifdef NS_DEBUG
extern "C" void extern "C" void
mime_dump_attachments ( nsMsgAttachmentData *attachData ) mime_dump_attachments(nsMsgAttachmentData *attachData)
{ {
int32_t i = 0; int32_t i = 0;
class nsMsgAttachmentData *tmp = attachData; class nsMsgAttachmentData *tmp = attachData;
while ( (tmp) && (tmp->m_url) ) while (tmp && tmp->m_url)
{ {
printf("Real Name : %s\n", tmp->m_realName.get()); printf("Real Name : %s\n", tmp->m_realName.get());
if ( tmp->m_url ) if (tmp->m_url)
{ {
; ;
printf("URL : %s\n", tmp->m_url->GetSpecOrDefault().get()); printf("URL : %s\n", tmp->m_url->GetSpecOrDefault().get());
@ -170,7 +170,7 @@ nsresult CreateComposeParams(nsCOMPtr<nsIMsgComposeParams> &pMsgComposeParams,
nsIMsgDBHdr *origMsgHdr) nsIMsgDBHdr *origMsgHdr)
{ {
#ifdef NS_DEBUG #ifdef NS_DEBUG
mime_dump_attachments ( attachmentList ); mime_dump_attachments(attachmentList);
#endif #endif
nsresult rv; nsresult rv;
@ -254,7 +254,7 @@ CreateTheComposeWindow(nsIMsgCompFields * compFields,
nsIMsgIdentity * identity, nsIMsgIdentity * identity,
const char * originalMsgURI, const char * originalMsgURI,
nsIMsgDBHdr * origMsgHdr nsIMsgDBHdr * origMsgHdr
) )
{ {
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams; nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams;
nsresult rv = CreateComposeParams(pMsgComposeParams, compFields, nsresult rv = CreateComposeParams(pMsgComposeParams, compFields,
@ -295,7 +295,7 @@ ForwardMsgInline(nsIMsgCompFields *compFields,
do_GetService(kCMsgComposeServiceCID, &rv); do_GetService(kCMsgComposeServiceCID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// create the nsIMsgCompose object to send the object // create the nsIMsgCompose object to send the object
nsCOMPtr<nsIMsgCompose> pMsgCompose (do_CreateInstance(NS_MSGCOMPOSE_CONTRACTID, &rv)); nsCOMPtr<nsIMsgCompose> pMsgCompose(do_CreateInstance(NS_MSGCOMPOSE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
/** initialize nsIMsgCompose, Send the message, wait for send completion response **/ /** initialize nsIMsgCompose, Send the message, wait for send completion response **/
@ -424,27 +424,27 @@ CreateCompositionFields(const char *from,
} }
static int static int
dummy_file_write( char *buf, int32_t size, void *fileHandle ) dummy_file_write(char *buf, int32_t size, void *fileHandle)
{ {
if (!fileHandle) if (!fileHandle)
return -1; return -1;
nsIOutputStream *tStream = (nsIOutputStream *) fileHandle; nsIOutputStream *tStream = (nsIOutputStream *)fileHandle;
uint32_t bytesWritten; uint32_t bytesWritten;
tStream->Write(buf, size, &bytesWritten); tStream->Write(buf, size, &bytesWritten);
return (int) bytesWritten; return (int)bytesWritten;
} }
static int static int
mime_parse_stream_write ( nsMIMESession *stream, const char *buf, int32_t size ) mime_parse_stream_write(nsMIMESession *stream, const char *buf, int32_t size)
{ {
mime_draft_data *mdd = (mime_draft_data *) stream->data_object; mime_draft_data *mdd = (mime_draft_data *)stream->data_object;
NS_ASSERTION ( mdd, "null mime draft data!" ); NS_ASSERTION(mdd, "null mime draft data!");
if ( !mdd || !mdd->obj ) if (!mdd || !mdd->obj)
return -1; return -1;
return mdd->obj->clazz->parse_buffer ((char *) buf, size, mdd->obj); return mdd->obj->clazz->parse_buffer((char *)buf, size, mdd->obj);
} }
static void static void
@ -489,7 +489,7 @@ mime_draft_process_attachments(mime_draft_data *mdd)
if (bodyAsAttachment) if (bodyAsAttachment)
totalCount++; totalCount++;
attachData = new nsMsgAttachmentData[totalCount + 1]; attachData = new nsMsgAttachmentData[totalCount + 1];
if ( !attachData ) if (!attachData)
return nullptr; return nullptr;
tmp = attachData; tmp = attachData;
@ -504,7 +504,7 @@ mime_draft_process_attachments(mime_draft_data *mdd)
if (tmpFile->m_type.LowerCaseEqualsLiteral("text/x-vcard")) if (tmpFile->m_type.LowerCaseEqualsLiteral("text/x-vcard"))
tmp->m_realName = tmpFile->m_description; tmp->m_realName = tmpFile->m_description;
if ( tmpFile->m_origUrl ) if (tmpFile->m_origUrl)
{ {
nsAutoCString tmpSpec; nsAutoCString tmpSpec;
if (NS_FAILED(tmpFile->m_origUrl->GetSpec(tmpSpec))) if (NS_FAILED(tmpFile->m_origUrl->GetSpec(tmpSpec)))
@ -768,7 +768,7 @@ mime_insert_all_headers(char **body,
static void static void
mime_insert_normal_headers(char **body, mime_insert_normal_headers(char **body,
MimeHeaders *headers, MimeHeaders *headers,
MSG_ComposeFormat composeFormat, MSG_ComposeFormat composeFormat,
char *mailcharset) char *mailcharset)
{ {
char *newBody = nullptr; char *newBody = nullptr;
@ -1088,9 +1088,9 @@ mime_insert_forwarded_message_headers(char **body,
} }
static void static void
mime_parse_stream_complete (nsMIMESession *stream) mime_parse_stream_complete(nsMIMESession *stream)
{ {
mime_draft_data *mdd = (mime_draft_data *) stream->data_object; mime_draft_data *mdd = (mime_draft_data *)stream->data_object;
nsCOMPtr<nsIMsgCompFields> fields; nsCOMPtr<nsIMsgCompFields> fields;
int htmlAction = 0; int htmlAction = 0;
int lineWidth = 0; int lineWidth = 0;
@ -1121,7 +1121,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
bool bodyAsAttachment = false; bool bodyAsAttachment = false;
bool charsetOverride = false; bool charsetOverride = false;
NS_ASSERTION (mdd, "null mime draft data"); NS_ASSERTION(mdd, "null mime draft data");
if (!mdd) return; if (!mdd) return;
@ -1129,8 +1129,8 @@ mime_parse_stream_complete (nsMIMESession *stream)
{ {
int status; int status;
status = mdd->obj->clazz->parse_eof ( mdd->obj, false ); status = mdd->obj->clazz->parse_eof(mdd->obj, false);
mdd->obj->clazz->parse_end( mdd->obj, status < 0 ? true : false ); mdd->obj->clazz->parse_end(mdd->obj, status < 0 ? true : false);
// RICHIE // RICHIE
// We need to figure out how to pass the forwarded flag along with this // We need to figure out how to pass the forwarded flag along with this
@ -1139,8 +1139,8 @@ mime_parse_stream_complete (nsMIMESession *stream)
//forward_inline = (mdd->format_out != FO_CMDLINE_ATTACHMENTS); //forward_inline = (mdd->format_out != FO_CMDLINE_ATTACHMENTS);
forward_inline = mdd->forwardInline; forward_inline = mdd->forwardInline;
NS_ASSERTION ( mdd->options == mdd->obj->options, "mime draft options not same as obj->options" ); NS_ASSERTION(mdd->options == mdd->obj->options, "mime draft options not same as obj->options");
mime_free (mdd->obj); mime_free(mdd->obj);
mdd->obj = 0; mdd->obj = 0;
if (mdd->options) if (mdd->options)
{ {
@ -1158,8 +1158,8 @@ mime_parse_stream_complete (nsMIMESession *stream)
} }
if (mdd->stream) if (mdd->stream)
{ {
mdd->stream->complete ((nsMIMESession *)mdd->stream->data_object); mdd->stream->complete((nsMIMESession *)mdd->stream->data_object);
PR_Free( mdd->stream ); PR_Free(mdd->stream);
mdd->stream = 0; mdd->stream = 0;
} }
} }
@ -1173,7 +1173,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
// //
// time to bring up the compose windows with all the info gathered // time to bring up the compose windows with all the info gathered
// //
if ( mdd->headers ) if (mdd->headers)
{ {
subj = MimeHeaders_get(mdd->headers, HEADER_SUBJECT, false, false); subj = MimeHeaders_get(mdd->headers, HEADER_SUBJECT, false, false);
if (forward_inline) if (forward_inline)
@ -1236,7 +1236,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
} }
CreateCompositionFields( from, repl, to, cc, bcc, fcc, grps, foll, CreateCompositionFields(from, repl, to, cc, bcc, fcc, grps, foll,
org, subj, refs, priority, news_host, org, subj, refs, priority, news_host,
mdd->mailcharset, mdd->mailcharset,
getter_AddRefs(fields)); getter_AddRefs(fields));
@ -1305,15 +1305,15 @@ mime_parse_stream_complete (nsMIMESession *stream)
// identity to prefer when opening the message in the compose window? // identity to prefer when opening the message in the compose window?
identityKey = MimeHeaders_get(mdd->headers, HEADER_X_MOZILLA_IDENTITY_KEY, false, false); identityKey = MimeHeaders_get(mdd->headers, HEADER_X_MOZILLA_IDENTITY_KEY, false, false);
if ( identityKey && *identityKey ) if (identityKey && *identityKey)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr< nsIMsgAccountManager > accountManager = nsCOMPtr<nsIMsgAccountManager> accountManager =
do_GetService( NS_MSGACCOUNTMANAGER_CONTRACTID, &rv ); do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if ( NS_SUCCEEDED(rv) && accountManager ) if (NS_SUCCEEDED(rv) && accountManager)
{ {
nsCOMPtr< nsIMsgIdentity > overrulingIdentity; nsCOMPtr<nsIMsgIdentity> overrulingIdentity;
rv = accountManager->GetIdentity( nsDependentCString(identityKey), getter_AddRefs( overrulingIdentity ) ); rv = accountManager->GetIdentity(nsDependentCString(identityKey), getter_AddRefs(overrulingIdentity));
if (NS_SUCCEEDED(rv) && overrulingIdentity) { if (NS_SUCCEEDED(rv) && overrulingIdentity) {
mdd->identity = overrulingIdentity; mdd->identity = overrulingIdentity;
@ -1361,10 +1361,10 @@ mime_parse_stream_complete (nsMIMESession *stream)
} }
if (body) if (body)
{ {
memset (body, 0, bodyLen+1); memset(body, 0, bodyLen+1);
uint32_t bytesRead; uint32_t bytesRead;
nsCOMPtr <nsIInputStream> inputStream; nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), mdd->messageBody->m_tmpFile); nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), mdd->messageBody->m_tmpFile);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
@ -1378,7 +1378,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
char *mimeCharset = nullptr; char *mimeCharset = nullptr;
// Get a charset from the header if no override is set. // Get a charset from the header if no override is set.
if (!charsetOverride) if (!charsetOverride)
mimeCharset = MimeHeaders_get_parameter (mdd->messageBody->m_type.get(), "charset", nullptr, nullptr); mimeCharset = MimeHeaders_get_parameter(mdd->messageBody->m_type.get(), "charset", nullptr, nullptr);
// If no charset is specified in the header then use the default. // If no charset is specified in the header then use the default.
char *bodyCharset = mimeCharset ? mimeCharset : mdd->mailcharset; char *bodyCharset = mimeCharset ? mimeCharset : mdd->mailcharset;
if (bodyCharset) if (bodyCharset)
@ -1547,7 +1547,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
} }
else else
{ {
CreateCompositionFields( from, repl, to, cc, bcc, fcc, grps, foll, CreateCompositionFields(from, repl, to, cc, bcc, fcc, grps, foll,
org, subj, refs, priority, news_host, org, subj, refs, priority, news_host,
mdd->mailcharset, mdd->mailcharset,
getter_AddRefs(fields)); getter_AddRefs(fields));
@ -1555,8 +1555,8 @@ mime_parse_stream_complete (nsMIMESession *stream)
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::New, nsIMsgCompFormat::Default, mdd->identity, nullptr, mdd->origMsgHdr); CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::New, nsIMsgCompFormat::Default, mdd->identity, nullptr, mdd->origMsgHdr);
} }
if ( mdd->headers ) if (mdd->headers)
MimeHeaders_free ( mdd->headers ); MimeHeaders_free(mdd->headers);
// //
// Free the original attachment structure... // Free the original attachment structure...
@ -1602,10 +1602,10 @@ mime_parse_stream_complete (nsMIMESession *stream)
} }
static void static void
mime_parse_stream_abort (nsMIMESession *stream, int status ) mime_parse_stream_abort(nsMIMESession *stream, int status)
{ {
mime_draft_data *mdd = (mime_draft_data *) stream->data_object; mime_draft_data *mdd = (mime_draft_data *)stream->data_object;
NS_ASSERTION (mdd, "null mime draft data"); NS_ASSERTION(mdd, "null mime draft data");
if (!mdd) if (!mdd)
return; return;
@ -1614,12 +1614,12 @@ mime_parse_stream_abort (nsMIMESession *stream, int status )
{ {
int status=0; int status=0;
if ( !mdd->obj->closed_p ) if (!mdd->obj->closed_p)
status = mdd->obj->clazz->parse_eof ( mdd->obj, true ); status = mdd->obj->clazz->parse_eof(mdd->obj, true);
if ( !mdd->obj->parsed_p ) if (!mdd->obj->parsed_p)
mdd->obj->clazz->parse_end( mdd->obj, true ); mdd->obj->clazz->parse_end(mdd->obj, true);
NS_ASSERTION ( mdd->options == mdd->obj->options, "draft display options not same as mime obj" ); NS_ASSERTION(mdd->options == mdd->obj->options, "draft display options not same as mime obj");
mime_free (mdd->obj); mime_free (mdd->obj);
mdd->obj = 0; mdd->obj = 0;
if (mdd->options) if (mdd->options)
@ -1630,52 +1630,52 @@ mime_parse_stream_abort (nsMIMESession *stream, int status )
if (mdd->stream) if (mdd->stream)
{ {
mdd->stream->abort ((nsMIMESession *)mdd->stream->data_object, status); mdd->stream->abort((nsMIMESession *)mdd->stream->data_object, status);
PR_Free( mdd->stream ); PR_Free(mdd->stream);
mdd->stream = 0; mdd->stream = 0;
} }
} }
if ( mdd->headers ) if (mdd->headers)
MimeHeaders_free (mdd->headers); MimeHeaders_free(mdd->headers);
mime_free_attachments(mdd->attachments); mime_free_attachments(mdd->attachments);
PR_FREEIF(mdd->mailcharset); PR_FREEIF(mdd->mailcharset);
PR_Free (mdd); PR_Free(mdd);
} }
static int static int
make_mime_headers_copy ( void *closure, MimeHeaders *headers ) make_mime_headers_copy(void *closure, MimeHeaders *headers)
{ {
mime_draft_data *mdd = (mime_draft_data *) closure; mime_draft_data *mdd = (mime_draft_data *)closure;
NS_ASSERTION ( mdd && headers, "null mime draft data and/or headers" ); NS_ASSERTION(mdd && headers, "null mime draft data and/or headers");
if ( !mdd || ! headers ) if (!mdd || ! headers)
return 0; return 0;
NS_ASSERTION ( mdd->headers == NULL , "non null mime draft data headers"); NS_ASSERTION(mdd->headers == NULL , "non null mime draft data headers");
mdd->headers = MimeHeaders_copy ( headers ); mdd->headers = MimeHeaders_copy(headers);
mdd->options->done_parsing_outer_headers = true; mdd->options->done_parsing_outer_headers = true;
return 0; return 0;
} }
int int
mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers ) mime_decompose_file_init_fn(void *stream_closure, MimeHeaders *headers)
{ {
mime_draft_data *mdd = (mime_draft_data *) stream_closure; mime_draft_data *mdd = (mime_draft_data *)stream_closure;
nsMsgAttachedFile *newAttachment = 0; nsMsgAttachedFile *newAttachment = 0;
int nAttachments = 0; int nAttachments = 0;
//char *hdr_value = NULL; //char *hdr_value = NULL;
char *parm_value = NULL; char *parm_value = NULL;
bool creatingMsgBody = true; bool creatingMsgBody = true;
NS_ASSERTION (mdd && headers, "null mime draft data and/or headers"); NS_ASSERTION(mdd && headers, "null mime draft data and/or headers");
if (!mdd || !headers) if (!mdd || !headers)
return -1; return -1;
@ -1730,24 +1730,24 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
char *contLoc = nullptr; char *contLoc = nullptr;
newAttachment->m_realName.Adopt(MimeHeaders_get_name(headers, mdd->options)); newAttachment->m_realName.Adopt(MimeHeaders_get_name(headers, mdd->options));
contLoc = MimeHeaders_get( headers, HEADER_CONTENT_LOCATION, false, false ); contLoc = MimeHeaders_get(headers, HEADER_CONTENT_LOCATION, false, false);
if (!contLoc) if (!contLoc)
contLoc = MimeHeaders_get( headers, HEADER_CONTENT_BASE, false, false ); contLoc = MimeHeaders_get(headers, HEADER_CONTENT_BASE, false, false);
if (!contLoc && !newAttachment->m_realName.IsEmpty()) if (!contLoc && !newAttachment->m_realName.IsEmpty())
workURLSpec = ToNewCString(newAttachment->m_realName); workURLSpec = ToNewCString(newAttachment->m_realName);
if ( (contLoc) && (!workURLSpec) ) if (contLoc && !workURLSpec)
workURLSpec = strdup(contLoc); workURLSpec = strdup(contLoc);
PR_FREEIF(contLoc); PR_FREEIF(contLoc);
mdd->curAttachment = newAttachment; mdd->curAttachment = newAttachment;
newAttachment->m_type.Adopt(MimeHeaders_get ( headers, HEADER_CONTENT_TYPE, false, false )); newAttachment->m_type.Adopt(MimeHeaders_get(headers, HEADER_CONTENT_TYPE, false, false));
// //
// This is to handle the degenerated Apple Double attachment. // This is to handle the degenerated Apple Double attachment.
// //
parm_value = MimeHeaders_get( headers, HEADER_CONTENT_TYPE, false, false ); parm_value = MimeHeaders_get(headers, HEADER_CONTENT_TYPE, false, false);
if (parm_value) if (parm_value)
{ {
char *boundary = NULL; char *boundary = NULL;
@ -1767,10 +1767,10 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
} }
newAttachment->m_size = 0; newAttachment->m_size = 0;
newAttachment->m_encoding.Adopt(MimeHeaders_get (headers, HEADER_CONTENT_TRANSFER_ENCODING, newAttachment->m_encoding.Adopt(MimeHeaders_get(headers, HEADER_CONTENT_TRANSFER_ENCODING,
false, false)); false, false));
newAttachment->m_description.Adopt(MimeHeaders_get(headers, HEADER_CONTENT_DESCRIPTION, newAttachment->m_description.Adopt(MimeHeaders_get(headers, HEADER_CONTENT_DESCRIPTION,
false, false )); false, false));
// //
// If we came up empty for description or the orig URL, we should do something about it. // If we came up empty for description or the orig URL, we should do something about it.
// //
@ -1797,20 +1797,20 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
return 0; return 0;
} }
nsCOMPtr <nsIFile> tmpFile = nullptr; nsCOMPtr<nsIFile> tmpFile = nullptr;
{ {
// Let's build a temp file with an extension based on the content-type: nsmail.<extension> // Let's build a temp file with an extension based on the content-type: nsmail.<extension>
nsAutoCString newAttachName ("nsmail"); nsAutoCString newAttachName("nsmail");
bool extensionAdded = false; bool extensionAdded = false;
// the content type may contain a charset. i.e. text/html; ISO-2022-JP...we want to strip off the charset // the content type may contain a charset. i.e. text/html; ISO-2022-JP...we want to strip off the charset
// before we ask the mime service for a mime info for this content type. // before we ask the mime service for a mime info for this content type.
nsAutoCString contentType (newAttachment->m_type); nsAutoCString contentType(newAttachment->m_type);
int32_t pos = contentType.FindChar(';'); int32_t pos = contentType.FindChar(';');
if (pos > 0) if (pos > 0)
contentType.SetLength(pos); contentType.SetLength(pos);
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIMIMEService> mimeFinder (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); nsCOMPtr<nsIMIMEService> mimeFinder(do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && mimeFinder) if (NS_SUCCEEDED(rv) && mimeFinder)
{ {
nsAutoCString fileExtension; nsAutoCString fileExtension;
@ -1869,7 +1869,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
else if (newAttachment->m_encoding.LowerCaseEqualsLiteral(ENCODING_QUOTED_PRINTABLE)) else if (newAttachment->m_encoding.LowerCaseEqualsLiteral(ENCODING_QUOTED_PRINTABLE))
{ {
mdd->decoder_data = MimeQPDecoderInit (/* The (MimeConverterOutputCallback) cast is to turn the `void' argument into `MimeObject'. */ mdd->decoder_data = MimeQPDecoderInit (/* The (MimeConverterOutputCallback) cast is to turn the `void' argument into `MimeObject'. */
((MimeConverterOutputCallback) dummy_file_write), ((MimeConverterOutputCallback)dummy_file_write),
mdd->tmpFileStream); mdd->tmpFileStream);
if (!mdd->decoder_data) if (!mdd->decoder_data)
return MIME_OUT_OF_MEMORY; return MIME_OUT_OF_MEMORY;
@ -1897,18 +1897,18 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
} }
int int
mime_decompose_file_output_fn (const char *buf, mime_decompose_file_output_fn(const char *buf,
int32_t size, int32_t size,
void *stream_closure ) void *stream_closure)
{ {
mime_draft_data *mdd = (mime_draft_data *) stream_closure; mime_draft_data *mdd = (mime_draft_data *)stream_closure;
int ret = 0; int ret = 0;
NS_ASSERTION (mdd && buf, "missing mime draft data and/or buf"); NS_ASSERTION(mdd && buf, "missing mime draft data and/or buf");
if (!mdd || !buf) return -1; if (!mdd || !buf) return -1;
if (!size) return 0; if (!size) return 0;
if ( !mdd->tmpFileStream ) if (!mdd->tmpFileStream)
return 0; return 0;
if (mdd->decoder_data) { if (mdd->decoder_data) {
@ -1930,14 +1930,14 @@ mime_decompose_file_output_fn (const char *buf,
} }
int int
mime_decompose_file_close_fn ( void *stream_closure ) mime_decompose_file_close_fn(void *stream_closure)
{ {
mime_draft_data *mdd = (mime_draft_data *) stream_closure; mime_draft_data *mdd = (mime_draft_data *)stream_closure;
if (!mdd) if (!mdd)
return -1; return -1;
if ( --mdd->options->decompose_init_count > 0 ) if (--mdd->options->decompose_init_count > 0)
return 0; return 0;
if (mdd->decoder_data) { if (mdd->decoder_data) {
@ -1972,7 +1972,7 @@ mime_bridge_create_draft_stream(
mime_draft_data *mdd = nullptr; mime_draft_data *mdd = nullptr;
MimeObject *obj = nullptr; MimeObject *obj = nullptr;
if ( !uri ) if (!uri)
return nullptr; return nullptr;
mdd = new mime_draft_data; mdd = new mime_draft_data;
@ -1980,7 +1980,7 @@ mime_bridge_create_draft_stream(
return nullptr; return nullptr;
nsAutoCString turl; nsAutoCString turl;
nsCOMPtr <nsIMsgMessageService> msgService; nsCOMPtr<nsIMsgMessageService> msgService;
nsCOMPtr<nsIURI> aURL; nsCOMPtr<nsIURI> aURL;
nsAutoCString urlString; nsAutoCString urlString;
nsresult rv; nsresult rv;
@ -2016,7 +2016,7 @@ mime_bridge_create_draft_stream(
newPluginObj2->GetOriginalMsgURI(&mdd->originalMsgURI); newPluginObj2->GetOriginalMsgURI(&mdd->originalMsgURI);
newPluginObj2->GetOrigMsgHdr(getter_AddRefs(mdd->origMsgHdr)); newPluginObj2->GetOrigMsgHdr(getter_AddRefs(mdd->origMsgHdr));
mdd->format_out = format_out; mdd->format_out = format_out;
mdd->options = new MimeDisplayOptions ; mdd->options = new MimeDisplayOptions ;
if (!mdd->options) if (!mdd->options)
goto FAIL; goto FAIL;
@ -2043,15 +2043,15 @@ mime_bridge_create_draft_stream(
mdd->options->decrypt_p = true; mdd->options->decrypt_p = true;
#endif /* ENABLE_SMIME */ #endif /* ENABLE_SMIME */
obj = mime_new ( (MimeObjectClass *) &mimeMessageClass, (MimeHeaders *) NULL, MESSAGE_RFC822 ); obj = mime_new((MimeObjectClass *)&mimeMessageClass, (MimeHeaders *)NULL, MESSAGE_RFC822);
if ( !obj ) if (!obj)
goto FAIL; goto FAIL;
obj->options = mdd->options; obj->options = mdd->options;
mdd->obj = obj; mdd->obj = obj;
stream = PR_NEWZAP ( nsMIMESession ); stream = PR_NEWZAP(nsMIMESession);
if ( !stream ) if (!stream)
goto FAIL; goto FAIL;
stream->name = "MIME To Draft Converter Stream"; stream->name = "MIME To Draft Converter Stream";
@ -2060,10 +2060,10 @@ mime_bridge_create_draft_stream(
stream->put_block = mime_parse_stream_write; stream->put_block = mime_parse_stream_write;
stream->data_object = mdd; stream->data_object = mdd;
status = obj->clazz->initialize ( obj ); status = obj->clazz->initialize(obj);
if ( status >= 0 ) if (status >= 0)
status = obj->clazz->parse_begin ( obj ); status = obj->clazz->parse_begin(obj);
if ( status < 0 ) if (status < 0)
goto FAIL; goto FAIL;
return stream; return stream;
@ -2075,10 +2075,10 @@ FAIL:
PR_Free(mdd->originalMsgURI); PR_Free(mdd->originalMsgURI);
if (mdd->options) if (mdd->options)
delete mdd->options; delete mdd->options;
PR_Free ( mdd ); PR_Free(mdd);
} }
PR_Free ( stream ); PR_Free(stream);
PR_Free ( obj ); PR_Free(obj);
return nullptr; return nullptr;
} }