summaryrefslogtreecommitdiffstats
path: root/mailnews/mime
diff options
context:
space:
mode:
Diffstat (limited to 'mailnews/mime')
-rw-r--r--mailnews/mime/src/mimedrft.cpp206
1 files changed, 103 insertions, 103 deletions
diff --git a/mailnews/mime/src/mimedrft.cpp b/mailnews/mime/src/mimedrft.cpp
index 3293d8b96..90ca027d8 100644
--- a/mailnews/mime/src/mimedrft.cpp
+++ b/mailnews/mime/src/mimedrft.cpp
@@ -65,9 +65,9 @@ using namespace mozilla::mailnews;
// Forward declarations...
//
extern "C" char *MIME_StripContinuations(char *original);
-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_close_fn ( void *stream_closure );
+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_close_fn(void *stream_closure);
extern int MimeHeaders_build_heads_list(MimeHeaders *hdrs);
// CID's
@@ -97,7 +97,7 @@ mime_draft_data::mime_draft_data() : url_name(nullptr), format_out(0),
nsresult
nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile)
{
- if ((!tFileName) || (!*tFileName))
+ if (!tFileName || !*tFileName)
tFileName = SAFE_TMP_FILENAME;
nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR,
@@ -132,16 +132,16 @@ typedef enum {
#ifdef NS_DEBUG
extern "C" void
-mime_dump_attachments ( nsMsgAttachmentData *attachData )
+mime_dump_attachments(nsMsgAttachmentData *attachData)
{
int32_t i = 0;
class nsMsgAttachmentData *tmp = attachData;
- while ( (tmp) && (tmp->m_url) )
+ while (tmp && tmp->m_url)
{
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());
@@ -170,7 +170,7 @@ nsresult CreateComposeParams(nsCOMPtr<nsIMsgComposeParams> &pMsgComposeParams,
nsIMsgDBHdr *origMsgHdr)
{
#ifdef NS_DEBUG
- mime_dump_attachments ( attachmentList );
+ mime_dump_attachments(attachmentList);
#endif
nsresult rv;
@@ -254,7 +254,7 @@ CreateTheComposeWindow(nsIMsgCompFields * compFields,
nsIMsgIdentity * identity,
const char * originalMsgURI,
nsIMsgDBHdr * origMsgHdr
- )
+ )
{
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams;
nsresult rv = CreateComposeParams(pMsgComposeParams, compFields,
@@ -295,7 +295,7 @@ ForwardMsgInline(nsIMsgCompFields *compFields,
do_GetService(kCMsgComposeServiceCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// 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);
/** initialize nsIMsgCompose, Send the message, wait for send completion response **/
@@ -424,27 +424,27 @@ CreateCompositionFields(const char *from,
}
static int
-dummy_file_write( char *buf, int32_t size, void *fileHandle )
+dummy_file_write(char *buf, int32_t size, void *fileHandle)
{
if (!fileHandle)
return -1;
- nsIOutputStream *tStream = (nsIOutputStream *) fileHandle;
+ nsIOutputStream *tStream = (nsIOutputStream *)fileHandle;
uint32_t bytesWritten;
tStream->Write(buf, size, &bytesWritten);
- return (int) bytesWritten;
+ return (int)bytesWritten;
}
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;
- NS_ASSERTION ( mdd, "null mime draft data!" );
+ mime_draft_data *mdd = (mime_draft_data *)stream->data_object;
+ NS_ASSERTION(mdd, "null mime draft data!");
- if ( !mdd || !mdd->obj )
+ if (!mdd || !mdd->obj)
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
@@ -489,7 +489,7 @@ mime_draft_process_attachments(mime_draft_data *mdd)
if (bodyAsAttachment)
totalCount++;
attachData = new nsMsgAttachmentData[totalCount + 1];
- if ( !attachData )
+ if (!attachData)
return nullptr;
tmp = attachData;
@@ -504,7 +504,7 @@ mime_draft_process_attachments(mime_draft_data *mdd)
if (tmpFile->m_type.LowerCaseEqualsLiteral("text/x-vcard"))
tmp->m_realName = tmpFile->m_description;
- if ( tmpFile->m_origUrl )
+ if (tmpFile->m_origUrl)
{
nsAutoCString tmpSpec;
if (NS_FAILED(tmpFile->m_origUrl->GetSpec(tmpSpec)))
@@ -768,7 +768,7 @@ mime_insert_all_headers(char **body,
static void
mime_insert_normal_headers(char **body,
MimeHeaders *headers,
- MSG_ComposeFormat composeFormat,
+ MSG_ComposeFormat composeFormat,
char *mailcharset)
{
char *newBody = nullptr;
@@ -1088,9 +1088,9 @@ mime_insert_forwarded_message_headers(char **body,
}
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;
int htmlAction = 0;
int lineWidth = 0;
@@ -1121,7 +1121,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
bool bodyAsAttachment = false;
bool charsetOverride = false;
- NS_ASSERTION (mdd, "null mime draft data");
+ NS_ASSERTION(mdd, "null mime draft data");
if (!mdd) return;
@@ -1129,8 +1129,8 @@ mime_parse_stream_complete (nsMIMESession *stream)
{
int status;
- status = mdd->obj->clazz->parse_eof ( mdd->obj, false );
- mdd->obj->clazz->parse_end( mdd->obj, status < 0 ? true : false );
+ status = mdd->obj->clazz->parse_eof(mdd->obj, false);
+ mdd->obj->clazz->parse_end(mdd->obj, status < 0 ? true : false);
// RICHIE
// 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->forwardInline;
- NS_ASSERTION ( mdd->options == mdd->obj->options, "mime draft options not same as obj->options" );
- mime_free (mdd->obj);
+ NS_ASSERTION(mdd->options == mdd->obj->options, "mime draft options not same as obj->options");
+ mime_free(mdd->obj);
mdd->obj = 0;
if (mdd->options)
{
@@ -1158,8 +1158,8 @@ mime_parse_stream_complete (nsMIMESession *stream)
}
if (mdd->stream)
{
- mdd->stream->complete ((nsMIMESession *)mdd->stream->data_object);
- PR_Free( mdd->stream );
+ mdd->stream->complete((nsMIMESession *)mdd->stream->data_object);
+ PR_Free(mdd->stream);
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
//
- if ( mdd->headers )
+ if (mdd->headers)
{
subj = MimeHeaders_get(mdd->headers, HEADER_SUBJECT, false, false);
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,
mdd->mailcharset,
getter_AddRefs(fields));
@@ -1305,15 +1305,15 @@ mime_parse_stream_complete (nsMIMESession *stream)
// identity to prefer when opening the message in the compose window?
identityKey = MimeHeaders_get(mdd->headers, HEADER_X_MOZILLA_IDENTITY_KEY, false, false);
- if ( identityKey && *identityKey )
+ if (identityKey && *identityKey)
{
nsresult rv = NS_OK;
- nsCOMPtr< nsIMsgAccountManager > accountManager =
- do_GetService( NS_MSGACCOUNTMANAGER_CONTRACTID, &rv );
- if ( NS_SUCCEEDED(rv) && accountManager )
+ nsCOMPtr<nsIMsgAccountManager> accountManager =
+ do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+ if (NS_SUCCEEDED(rv) && accountManager)
{
- nsCOMPtr< nsIMsgIdentity > overrulingIdentity;
- rv = accountManager->GetIdentity( nsDependentCString(identityKey), getter_AddRefs( overrulingIdentity ) );
+ nsCOMPtr<nsIMsgIdentity> overrulingIdentity;
+ rv = accountManager->GetIdentity(nsDependentCString(identityKey), getter_AddRefs(overrulingIdentity));
if (NS_SUCCEEDED(rv) && overrulingIdentity) {
mdd->identity = overrulingIdentity;
@@ -1361,10 +1361,10 @@ mime_parse_stream_complete (nsMIMESession *stream)
}
if (body)
{
- memset (body, 0, bodyLen+1);
+ memset(body, 0, bodyLen+1);
uint32_t bytesRead;
- nsCOMPtr <nsIInputStream> inputStream;
+ nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), mdd->messageBody->m_tmpFile);
if (NS_FAILED(rv))
@@ -1378,7 +1378,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
char *mimeCharset = nullptr;
// Get a charset from the header if no override is set.
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.
char *bodyCharset = mimeCharset ? mimeCharset : mdd->mailcharset;
if (bodyCharset)
@@ -1547,7 +1547,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
}
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,
mdd->mailcharset,
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);
}
- if ( mdd->headers )
- MimeHeaders_free ( mdd->headers );
+ if (mdd->headers)
+ MimeHeaders_free(mdd->headers);
//
// Free the original attachment structure...
@@ -1602,10 +1602,10 @@ mime_parse_stream_complete (nsMIMESession *stream)
}
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;
- NS_ASSERTION (mdd, "null mime draft data");
+ mime_draft_data *mdd = (mime_draft_data *)stream->data_object;
+ NS_ASSERTION(mdd, "null mime draft data");
if (!mdd)
return;
@@ -1614,12 +1614,12 @@ mime_parse_stream_abort (nsMIMESession *stream, int status )
{
int status=0;
- if ( !mdd->obj->closed_p )
- status = mdd->obj->clazz->parse_eof ( mdd->obj, true );
- if ( !mdd->obj->parsed_p )
- mdd->obj->clazz->parse_end( mdd->obj, true );
+ if (!mdd->obj->closed_p)
+ status = mdd->obj->clazz->parse_eof(mdd->obj, true);
+ if (!mdd->obj->parsed_p)
+ 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);
mdd->obj = 0;
if (mdd->options)
@@ -1630,52 +1630,52 @@ mime_parse_stream_abort (nsMIMESession *stream, int status )
if (mdd->stream)
{
- mdd->stream->abort ((nsMIMESession *)mdd->stream->data_object, status);
- PR_Free( mdd->stream );
+ mdd->stream->abort((nsMIMESession *)mdd->stream->data_object, status);
+ PR_Free(mdd->stream);
mdd->stream = 0;
}
}
- if ( mdd->headers )
- MimeHeaders_free (mdd->headers);
+ if (mdd->headers)
+ MimeHeaders_free(mdd->headers);
mime_free_attachments(mdd->attachments);
PR_FREEIF(mdd->mailcharset);
- PR_Free (mdd);
+ PR_Free(mdd);
}
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;
- 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;
return 0;
}
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;
int nAttachments = 0;
//char *hdr_value = NULL;
char *parm_value = NULL;
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)
return -1;
@@ -1730,24 +1730,24 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
char *contLoc = nullptr;
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)
- contLoc = MimeHeaders_get( headers, HEADER_CONTENT_BASE, false, false );
+ contLoc = MimeHeaders_get(headers, HEADER_CONTENT_BASE, false, false);
if (!contLoc && !newAttachment->m_realName.IsEmpty())
workURLSpec = ToNewCString(newAttachment->m_realName);
- if ( (contLoc) && (!workURLSpec) )
+ if (contLoc && !workURLSpec)
workURLSpec = strdup(contLoc);
PR_FREEIF(contLoc);
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.
//
- parm_value = MimeHeaders_get( headers, HEADER_CONTENT_TYPE, false, false );
+ parm_value = MimeHeaders_get(headers, HEADER_CONTENT_TYPE, false, false);
if (parm_value)
{
char *boundary = NULL;
@@ -1767,10 +1767,10 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
}
newAttachment->m_size = 0;
- newAttachment->m_encoding.Adopt(MimeHeaders_get (headers, HEADER_CONTENT_TRANSFER_ENCODING,
- false, false));
+ newAttachment->m_encoding.Adopt(MimeHeaders_get(headers, HEADER_CONTENT_TRANSFER_ENCODING,
+ false, false));
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.
//
@@ -1797,20 +1797,20 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
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>
- nsAutoCString newAttachName ("nsmail");
+ nsAutoCString newAttachName("nsmail");
bool extensionAdded = false;
// 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.
- nsAutoCString contentType (newAttachment->m_type);
+ nsAutoCString contentType(newAttachment->m_type);
int32_t pos = contentType.FindChar(';');
if (pos > 0)
contentType.SetLength(pos);
- nsresult rv = NS_OK;
- nsCOMPtr<nsIMIMEService> mimeFinder (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
+ nsresult rv = NS_OK;
+ nsCOMPtr<nsIMIMEService> mimeFinder(do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && mimeFinder)
{
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))
{
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);
if (!mdd->decoder_data)
return MIME_OUT_OF_MEMORY;
@@ -1897,18 +1897,18 @@ 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 )
+mime_decompose_file_output_fn(const char *buf,
+ int32_t size,
+ void *stream_closure)
{
- mime_draft_data *mdd = (mime_draft_data *) stream_closure;
+ mime_draft_data *mdd = (mime_draft_data *)stream_closure;
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 (!size) return 0;
- if ( !mdd->tmpFileStream )
+ if (!mdd->tmpFileStream)
return 0;
if (mdd->decoder_data) {
@@ -1930,14 +1930,14 @@ mime_decompose_file_output_fn (const char *buf,
}
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)
return -1;
- if ( --mdd->options->decompose_init_count > 0 )
+ if (--mdd->options->decompose_init_count > 0)
return 0;
if (mdd->decoder_data) {
@@ -1972,7 +1972,7 @@ mime_bridge_create_draft_stream(
mime_draft_data *mdd = nullptr;
MimeObject *obj = nullptr;
- if ( !uri )
+ if (!uri)
return nullptr;
mdd = new mime_draft_data;
@@ -1980,7 +1980,7 @@ mime_bridge_create_draft_stream(
return nullptr;
nsAutoCString turl;
- nsCOMPtr <nsIMsgMessageService> msgService;
+ nsCOMPtr<nsIMsgMessageService> msgService;
nsCOMPtr<nsIURI> aURL;
nsAutoCString urlString;
nsresult rv;
@@ -2016,7 +2016,7 @@ mime_bridge_create_draft_stream(
newPluginObj2->GetOriginalMsgURI(&mdd->originalMsgURI);
newPluginObj2->GetOrigMsgHdr(getter_AddRefs(mdd->origMsgHdr));
mdd->format_out = format_out;
- mdd->options = new MimeDisplayOptions ;
+ mdd->options = new MimeDisplayOptions ;
if (!mdd->options)
goto FAIL;
@@ -2043,15 +2043,15 @@ mime_bridge_create_draft_stream(
mdd->options->decrypt_p = true;
#endif /* ENABLE_SMIME */
- obj = mime_new ( (MimeObjectClass *) &mimeMessageClass, (MimeHeaders *) NULL, MESSAGE_RFC822 );
- if ( !obj )
+ obj = mime_new((MimeObjectClass *)&mimeMessageClass, (MimeHeaders *)NULL, MESSAGE_RFC822);
+ if (!obj)
goto FAIL;
obj->options = mdd->options;
mdd->obj = obj;
- stream = PR_NEWZAP ( nsMIMESession );
- if ( !stream )
+ stream = PR_NEWZAP(nsMIMESession);
+ if (!stream)
goto FAIL;
stream->name = "MIME To Draft Converter Stream";
@@ -2060,10 +2060,10 @@ mime_bridge_create_draft_stream(
stream->put_block = mime_parse_stream_write;
stream->data_object = mdd;
- status = obj->clazz->initialize ( obj );
- if ( status >= 0 )
- status = obj->clazz->parse_begin ( obj );
- if ( status < 0 )
+ status = obj->clazz->initialize(obj);
+ if (status >= 0)
+ status = obj->clazz->parse_begin(obj);
+ if (status < 0)
goto FAIL;
return stream;
@@ -2075,10 +2075,10 @@ FAIL:
PR_Free(mdd->originalMsgURI);
if (mdd->options)
delete mdd->options;
- PR_Free ( mdd );
+ PR_Free(mdd);
}
- PR_Free ( stream );
- PR_Free ( obj );
+ PR_Free(stream);
+ PR_Free(obj);
return nullptr;
}