Changes for using string bundles

This commit is contained in:
rhp%netscape.com 1999-05-28 20:00:32 +00:00
Родитель eca3a2bdd1
Коммит 6bb7d9366f
32 изменённых файлов: 452 добавлений и 411 удалений

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

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

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

@ -159,6 +159,8 @@ LINCS=$(LINCS) -I. \
-I$(PUBLIC)\uconv \
-I$(PUBLIC)\netcnvts \
-I$(PUBLIC)\plugin \
-I$(PUBLIC)\intl \
-I$(PUBLIC)\locale \
$(NULL)
#//------------------------------------------------------------------------

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

@ -23,8 +23,7 @@
#include "prlog.h"
#include "nsCRT.h"
#include "msgCore.h"
extern "C" int MK_OUT_OF_MEMORY;
#include "nsMimeStringResources.h"
extern "C" int
mime_GrowBuffer (PRUint32 desired_size, PRUint32 element_size, PRUint32 quantum,
@ -43,7 +42,7 @@ mime_GrowBuffer (PRUint32 desired_size, PRUint32 element_size, PRUint32 quantum,
: (char *) PR_MALLOC ((*size + increment)
* (element_size / sizeof(char))));
if (! new_buf)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
*buffer = new_buf;
*size += increment;
}

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

@ -21,6 +21,7 @@
#include "nsCRT.h"
#include "prio.h"
#include "mimecont.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeObjectClass
MimeDefClass(MimeContainer, MimeContainerClass,
@ -167,7 +168,7 @@ MimeContainer_add_child (MimeObject *parent, MimeObject *child)
old_kids = cont->children;
new_kids = (MimeObject **)PR_MALLOC(sizeof(MimeObject *) * (cont->nchildren + 1));
if (!new_kids) return MK_OUT_OF_MEMORY;
if (!new_kids) return MIME_OUT_OF_MEMORY;
if (cont->nchildren > 0)
nsCRT::memcpy(new_kids, old_kids, sizeof(MimeObject *) * cont->nchildren);

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

@ -30,6 +30,8 @@
#include "nsIPref.h"
#include "msgCore.h"
#include "nsCRT.h"
#include "nsMimeStringResources.h"
#define HEADER_NNTP_POSTING_HOST "NNTP-Posting-Host"
@ -38,31 +40,6 @@
#define HEADER_MIDDLE_JUNK ": </TH><TD>"
#define HEADER_END_JUNK "</TD></TR>"
extern "C" int MK_MIMEHTML_DISP_SUBJECT;
extern "C" int MK_MIMEHTML_DISP_RESENT_COMMENTS;
extern "C" int MK_MIMEHTML_DISP_RESENT_DATE;
extern "C" int MK_MIMEHTML_DISP_RESENT_SENDER;
extern "C" int MK_MIMEHTML_DISP_RESENT_FROM;
extern "C" int MK_MIMEHTML_DISP_RESENT_TO;
extern "C" int MK_MIMEHTML_DISP_RESENT_CC;
extern "C" int MK_MIMEHTML_DISP_DATE;
extern "C" int MK_MIMEHTML_DISP_SENDER;
extern "C" int MK_MIMEHTML_DISP_FROM;
extern "C" int MK_MIMEHTML_DISP_REPLY_TO;
extern "C" int MK_MIMEHTML_DISP_ORGANIZATION;
extern "C" int MK_MIMEHTML_DISP_TO;
extern "C" int MK_MIMEHTML_DISP_CC;
extern "C" int MK_MIMEHTML_DISP_BCC;
extern "C" int MK_MIMEHTML_DISP_NEWSGROUPS;
extern "C" int MK_MIMEHTML_DISP_FOLLOWUP_TO;
extern "C" int MK_MIMEHTML_DISP_REFERENCES;
extern "C" int MK_MIMEHTML_DISP_NAME;
extern "C" int MK_MIMEHTML_DISP_TYPE;
extern "C" int MK_MIMEHTML_DISP_ENCODING;
extern "C" int MK_MIMEHTML_DISP_DESCRIPTION;
extern "C" int MK_UNABLE_TO_OPEN_TMP_FILE;
extern "C" int MK_MIME_ERROR_WRITING_FILE;
extern "C" char *
MIME_StripContinuations(char *original);
@ -174,7 +151,7 @@ mime_draft_process_attachments ( struct mime_draft_data *mdd,
return -1;
attachData = PR_MALLOC( ( (mdd->attachments_count+1) * sizeof (MSG_AttachmentData) ) );
if ( !attachData ) return MK_OUT_OF_MEMORY;
if ( !attachData ) return MIME_OUT_OF_MEMORY;
memset ( attachData, 0, (mdd->attachments_count+1) * sizeof (MSG_AttachmentData) );
@ -293,18 +270,6 @@ static void mime_intl_insert_message_header_1(char **body, char **hdr_value,
mime_SACat(*body, HEADER_END_JUNK);
}
static void mime_intl_insert_message_header(char **body, char**hdr_value,
char *hdr_str,
int html_hdr_id,
PRInt16 mailcsid,
PRBool htmlEdit)
{
const char *newName = NULL;
newName = XP_GetStringForHTML(html_hdr_id, mailcsid, hdr_str);
mime_intl_insert_message_header_1(body, hdr_value, hdr_str, newName,
mailcsid, htmlEdit);
}
static void mime_insert_all_headers(char **body,
MimeHeaders *headers,
MSG_EditorType editorType,
@ -386,7 +351,7 @@ static void mime_insert_all_headers(char **body,
end--;
name = PR_MALLOC(colon - head + 1);
if (!name) return /* MK_OUT_OF_MEMORY */;
if (!name) return /* MIME_OUT_OF_MEMORY */;
nsCRT::memcpy(name, head, colon - head);
name[colon - head] = 0;
@ -394,7 +359,7 @@ static void mime_insert_all_headers(char **body,
if (!c2)
{
PR_Free(name);
return /* MK_OUT_OF_MEMORY */;
return /* MIME_OUT_OF_MEMORY */;
}
nsCRT::memcpy(c2, contents, end - contents);
c2[end - contents] = 0;
@ -478,105 +443,105 @@ static void mime_insert_normal_headers(char **body,
MSG_LINEBREAK MSG_LINEBREAK "-------- Original Message --------");
}
if (subject)
mime_intl_insert_message_header(&newBody, &subject, HEADER_SUBJECT,
MK_MIMEHTML_DISP_SUBJECT,
mime_intl_insert_message_header_1(&newBody, &subject, HEADER_SUBJECT,
MimeGetNamedString(MIME_MHTML_SUBJECT),
mailcsid, htmlEdit);
if (resent_comments)
mime_intl_insert_message_header(&newBody, &resent_comments,
mime_intl_insert_message_header_1(&newBody, &resent_comments,
HEADER_RESENT_COMMENTS,
MK_MIMEHTML_DISP_RESENT_COMMENTS,
MimeGetNamedString(MIME_MHTML_RESENT_COMMENTS),
mailcsid, htmlEdit);
if (resent_date)
mime_intl_insert_message_header(&newBody, &resent_date,
mime_intl_insert_message_header_1(&newBody, &resent_date,
HEADER_RESENT_DATE,
MK_MIMEHTML_DISP_RESENT_DATE,
MimeGetNamedString(MIME_MHTML_RESENT_DATE),
mailcsid, htmlEdit);
if (resent_from)
{
if (htmlEdit) mime_fix_up_html_address(&resent_from);
mime_intl_insert_message_header(&newBody, &resent_from,
mime_intl_insert_message_header_1(&newBody, &resent_from,
HEADER_RESENT_FROM,
MK_MIMEHTML_DISP_RESENT_FROM,
MimeGetNamedString(MIME_MHTML_RESENT_FROM),
mailcsid, htmlEdit);
}
if (resent_to)
{
if (htmlEdit) mime_fix_up_html_address(&resent_to);
mime_intl_insert_message_header(&newBody, &resent_to,
mime_intl_insert_message_header_1(&newBody, &resent_to,
HEADER_RESENT_TO,
MK_MIMEHTML_DISP_RESENT_TO,
MimeGetNamedString(MIME_MHTML_RESENT_TO),
mailcsid, htmlEdit);
}
if (resent_cc)
{
if (htmlEdit) mime_fix_up_html_address(&resent_cc);
mime_intl_insert_message_header(&newBody, &resent_cc,
mime_intl_insert_message_header_1(&newBody, &resent_cc,
HEADER_RESENT_CC,
MK_MIMEHTML_DISP_RESENT_CC,
MimeGetNamedString(MIME_MHTML_RESENT_CC),
mailcsid, htmlEdit);
}
if (date)
mime_intl_insert_message_header(&newBody, &date, HEADER_DATE,
MK_MIMEHTML_DISP_DATE,
mime_intl_insert_message_header_1(&newBody, &date, HEADER_DATE,
MimeGetNamedString(MIME_MHTML_DATE),
mailcsid, htmlEdit);
if (from)
{
if (htmlEdit) mime_fix_up_html_address(&from);
mime_intl_insert_message_header(&newBody, &from, HEADER_FROM,
MK_MIMEHTML_DISP_FROM,
mime_intl_insert_message_header_1(&newBody, &from, HEADER_FROM,
MimeGetNamedString(MIME_MHTML_FROM),
mailcsid, htmlEdit);
}
if (reply_to)
{
if (htmlEdit) mime_fix_up_html_address(&reply_to);
mime_intl_insert_message_header(&newBody, &reply_to, HEADER_REPLY_TO,
MK_MIMEHTML_DISP_REPLY_TO,
mime_intl_insert_message_header_1(&newBody, &reply_to, HEADER_REPLY_TO,
MimeGetNamedString(MIME_MHTML_REPLY_TO),
mailcsid, htmlEdit);
}
if (organization)
mime_intl_insert_message_header(&newBody, &organization,
mime_intl_insert_message_header_1(&newBody, &organization,
HEADER_ORGANIZATION,
MK_MIMEHTML_DISP_ORGANIZATION,
MimeGetNamedString(MIME_MHTML_ORGANIZATION),
mailcsid, htmlEdit);
if (to)
{
if (htmlEdit) mime_fix_up_html_address(&to);
mime_intl_insert_message_header(&newBody, &to, HEADER_TO,
MK_MIMEHTML_DISP_TO,
mime_intl_insert_message_header_1(&newBody, &to, HEADER_TO,
MimeGetNamedString(MIME_MHTML_TO),
mailcsid, htmlEdit);
}
if (cc)
{
if (htmlEdit) mime_fix_up_html_address(&cc);
mime_intl_insert_message_header(&newBody, &cc, HEADER_CC,
MK_MIMEHTML_DISP_CC,
mime_intl_insert_message_header_1(&newBody, &cc, HEADER_CC,
MimeGetNamedString(MIME_MHTML_CC),
mailcsid, htmlEdit);
}
if (bcc)
{
if (htmlEdit) mime_fix_up_html_address(&bcc);
mime_intl_insert_message_header(&newBody, &bcc, HEADER_BCC,
MK_MIMEHTML_DISP_BCC,
mime_intl_insert_message_header_1(&newBody, &bcc, HEADER_BCC,
MimeGetNamedString(MIME_MHTML_BCC),
mailcsid, htmlEdit);
}
if (newsgroups)
mime_intl_insert_message_header(&newBody, &newsgroups, HEADER_NEWSGROUPS,
MK_MIMEHTML_DISP_NEWSGROUPS,
mime_intl_insert_message_header_1(&newBody, &newsgroups, HEADER_NEWSGROUPS,
MimeGetNamedString(MIME_MHTML_NEWSGROUPS),
mailcsid, htmlEdit);
if (followup_to)
{
if (htmlEdit) mime_fix_up_html_address(&followup_to);
mime_intl_insert_message_header(&newBody, &followup_to,
mime_intl_insert_message_header_1(&newBody, &followup_to,
HEADER_FOLLOWUP_TO,
MK_MIMEHTML_DISP_FOLLOWUP_TO,
MimeGetNamedString(MIME_MHTML_FOLLOWUP_TO),
mailcsid, htmlEdit);
}
if (references)
{
if (htmlEdit) mime_fix_up_html_address(&references);
mime_intl_insert_message_header(&newBody, &references,
mime_intl_insert_message_header_1(&newBody, &references,
HEADER_REFERENCES,
MK_MIMEHTML_DISP_REFERENCES,
MimeGetNamedString(MIME_MHTML_REFERENCES),
mailcsid, htmlEdit);
}
if (htmlEdit)
@ -657,52 +622,52 @@ static void mime_insert_micro_headers(char **body,
if (from)
{
if (htmlEdit) mime_fix_up_html_address(&from);
mime_intl_insert_message_header(&newBody, &from, HEADER_FROM,
MK_MIMEHTML_DISP_FROM,
mime_intl_insert_message_header_1(&newBody, &from, HEADER_FROM,
MimeGetNamedString(MIME_MHTML_FROM),
mailcsid, htmlEdit);
}
if (subject)
mime_intl_insert_message_header(&newBody, &subject, HEADER_SUBJECT,
MK_MIMEHTML_DISP_SUBJECT,
mime_intl_insert_message_header_1(&newBody, &subject, HEADER_SUBJECT,
MimeGetNamedString(MIME_MHTML_SUBJECT),
mailcsid, htmlEdit);
/*
if (date)
mime_intl_insert_message_header(&newBody, &date, HEADER_DATE,
MK_MIMEHTML_DISP_DATE,
mime_intl_insert_message_header_1(&newBody, &date, HEADER_DATE,
MimeGetNamedString(MIME_MHTML_DATE),
mailcsid, htmlEdit);
*/
if (resent_from)
{
if (htmlEdit) mime_fix_up_html_address(&resent_from);
mime_intl_insert_message_header(&newBody, &resent_from,
mime_intl_insert_message_header_1(&newBody, &resent_from,
HEADER_RESENT_FROM,
MK_MIMEHTML_DISP_RESENT_FROM,
MimeGetNamedString(MIME_MHTML_RESENT_FROM),
mailcsid, htmlEdit);
}
if (to)
{
if (htmlEdit) mime_fix_up_html_address(&to);
mime_intl_insert_message_header(&newBody, &to, HEADER_TO,
MK_MIMEHTML_DISP_TO,
mime_intl_insert_message_header_1(&newBody, &to, HEADER_TO,
MimeGetNamedString(MIME_MHTML_TO),
mailcsid, htmlEdit);
}
if (cc)
{
if (htmlEdit) mime_fix_up_html_address(&cc);
mime_intl_insert_message_header(&newBody, &cc, HEADER_CC,
MK_MIMEHTML_DISP_CC,
mime_intl_insert_message_header_1(&newBody, &cc, HEADER_CC,
MimeGetNamedString(MIME_MHTML_CC),
mailcsid, htmlEdit);
}
if (bcc)
{
if (htmlEdit) mime_fix_up_html_address(&bcc);
mime_intl_insert_message_header(&newBody, &bcc, HEADER_BCC,
MK_MIMEHTML_DISP_BCC,
mime_intl_insert_message_header_1(&newBody, &bcc, HEADER_BCC,
MimeGetNamedString(MIME_MHTML_BCC),
mailcsid, htmlEdit);
}
if (newsgroups)
mime_intl_insert_message_header(&newBody, &newsgroups, HEADER_NEWSGROUPS,
MK_MIMEHTML_DISP_NEWSGROUPS,
mime_intl_insert_message_header_1(&newBody, &newsgroups, HEADER_NEWSGROUPS,
MimeGetNamedString(MIME_MHTML_NEWSGROUPS),
mailcsid, htmlEdit);
if (htmlEdit)
{
@ -1187,7 +1152,7 @@ mime_decompose_file_init_fn ( void *stream_closure,
mdd->messageBody = PR_NEWZAP (MSG_AttachedFile);
PR_ASSERT (mdd->messageBody);
if (!mdd->messageBody)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
newAttachment = mdd->messageBody;
creatingMsgBody = PR_TRUE;
}
@ -1201,7 +1166,7 @@ mime_decompose_file_init_fn ( void *stream_closure,
sizeof (MSG_AttachedFile) *
(nAttachments + 2));
if (!attachments)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
mdd->attachments = attachments;
mdd->attachments_count++;
}
@ -1210,7 +1175,7 @@ mime_decompose_file_init_fn ( void *stream_closure,
attachments = PR_MALLOC ( sizeof (MSG_AttachedFile) * 2);
if (!attachments)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
mdd->attachments_count++;
mdd->attachments = attachments;
}
@ -1270,12 +1235,12 @@ mime_decompose_file_init_fn ( void *stream_closure,
mdd->tmp_file_name = GetOSTempFile("nsmail");
if (!mdd->tmp_file_name)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
mime_SACopy (&(newAttachment->file_name), mdd->tmp_file_name);
mdd->tmp_file = PR_Open ( mdd->tmp_file_name, PR_RDWR | PR_CREATE_FILE, 493 );
if (!mdd->tmp_file)
return MK_UNABLE_TO_OPEN_TMP_FILE;
return MIME_UNABLE_TO_OPEN_TMP_FILE;
/* if need an URL and we don't have one, let's fake one */
if (needURL && !newAttachment->orig_url) {
@ -1308,7 +1273,7 @@ mime_decompose_file_init_fn ( void *stream_closure,
mdd->tmp_file);
if (!mdd->decoder_data)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
}
return 0;
@ -1339,7 +1304,7 @@ mime_decompose_file_output_fn ( char *buf,
else {
ret = PR_Write(mdd->tmp_file, buf, size);
if (ret < size)
return MK_MIME_ERROR_WRITING_FILE;
return MIME_ERROR_WRITING_FILE;
}
return 0;

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

@ -15,6 +15,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsCOMPtr.h"
#include "mimeebod.h"
#include "prmem.h"
#include "nsCRT.h"
@ -24,14 +25,13 @@
#include "nsEscape.h"
#include "msgCore.h"
#include "nsMimeTransition.h"
#include "nsMimeStringResources.h"
#include "mimemoz2.h"
#define MIME_SUPERCLASS mimeObjectClass
MimeDefClass(MimeExternalBody, MimeExternalBodyClass,
mimeExternalBodyClass, &MIME_SUPERCLASS);
extern "C" int MK_MSG_LINK_TO_DOCUMENT;
extern "C" int MK_MSG_DOCUMENT_INFO;
#ifdef XP_MAC
extern MimeObjectClass mimeMultipartAppleDoubleClass;
#endif
@ -116,7 +116,7 @@ MimeExternalBody_parse_line (char *line, PRInt32 length, MimeObject *obj)
{
int L = PL_strlen(bod->body);
char *new_str = (char *)PR_Realloc(bod->body, L + length + 1);
if (!new_str) return MK_OUT_OF_MEMORY;
if (!new_str) return MIME_OUT_OF_MEMORY;
bod->body = new_str;
nsCRT::memcpy(bod->body + L, line, length);
bod->body[L + length] = 0;
@ -129,7 +129,7 @@ MimeExternalBody_parse_line (char *line, PRInt32 length, MimeObject *obj)
if (!bod->hdrs)
{
bod->hdrs = MimeHeaders_new();
if (!bod->hdrs) return MK_OUT_OF_MEMORY;
if (!bod->hdrs) return MIME_OUT_OF_MEMORY;
}
status = MimeHeaders_parse_line(line, length, bod->hdrs);
@ -141,7 +141,7 @@ MimeExternalBody_parse_line (char *line, PRInt32 length, MimeObject *obj)
if (*line == CR || *line == LF)
{
bod->body = PL_strdup("");
if (!bod->body) return MK_OUT_OF_MEMORY;
if (!bod->body) return MIME_OUT_OF_MEMORY;
}
return 0;
@ -285,7 +285,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
char *h = 0, *lname = 0, *lurl = 0, *body = 0;
MimeHeaders *hdrs = 0;
if (!ct) return MK_OUT_OF_MEMORY;
if (!ct) return MIME_OUT_OF_MEMORY;
at = MimeHeaders_get_parameter(ct, "access-type", NULL, NULL);
lexp = MimeHeaders_get_parameter(ct, "expiration", NULL, NULL);
@ -317,7 +317,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
(url ? PL_strlen(url) : 0) + 100);
if (!h)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
@ -339,7 +339,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
hdrs = MimeHeaders_new();
if (!hdrs)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
@ -373,11 +373,11 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
name, url, site, svr, subj, bod->body);
if (lurl)
{
lname = PL_strdup(XP_GetString(MK_MSG_LINK_TO_DOCUMENT));
lname = MimeGetStringByID(MIME_MSG_LINK_TO_DOCUMENT);
}
else
{
lname = PL_strdup(XP_GetString(MK_MSG_DOCUMENT_INFO));
lname = MimeGetStringByID(MIME_MSG_DOCUMENT_INFO);
all_headers_p = PR_TRUE;
}

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

@ -16,18 +16,19 @@
* Reserved.
*/
#include "nsCOMPtr.h"
#include "mimeeobj.h"
#include "prmem.h"
#include "plstr.h"
#include "prlog.h"
#include "nsMimeTransition.h"
#include "nsMimeStringResources.h"
#include "mimemoz2.h"
#define MIME_SUPERCLASS mimeLeafClass
MimeDefClass(MimeExternalObject, MimeExternalObjectClass,
mimeExternalObjectClass, &MIME_SUPERCLASS);
extern "C" int MK_MSG_ATTACHMENT;
#ifdef XP_MAC
extern MimeObjectClass mimeMultipartAppleDoubleClass;
#endif
@ -119,7 +120,7 @@ MimeExternalObject_parse_begin (MimeObject *obj)
id = mime_part_address (obj);
if (obj->options->missing_parts)
id_imap = mime_imap_part_address (obj);
if (! id) return MK_OUT_OF_MEMORY;
if (! id) return MIME_OUT_OF_MEMORY;
if (obj->options && obj->options->url)
{
@ -137,14 +138,14 @@ MimeExternalObject_parse_begin (MimeObject *obj)
if (!id_url)
{
PR_Free(id);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
}
if (!PL_strcmp (id, "0"))
{
PR_Free(id);
id = PL_strdup(XP_GetString(MK_MSG_ATTACHMENT));
id = MimeGetStringByID(MIME_MSG_ATTACHMENT);
}
else
{
@ -154,7 +155,7 @@ MimeExternalObject_parse_begin (MimeObject *obj)
{
PR_Free(id);
PR_Free(id_url);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
/* we have a valid id */
if (id)

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

@ -56,7 +56,7 @@
#include "secrng.h"
#include "secmod.h"
#include "pk11func.h"
#include "nsMimeStringResources.h"
#ifndef XP_UNIX
ERROR! This is a unix-only file for the "mimefilt" standalone program.
@ -256,7 +256,7 @@ test(FILE *in, FILE *out,
if (status < 0)
{
PR_Free(opt);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
opt->url = url;
@ -286,7 +286,7 @@ test(FILE *in, FILE *out,
if (!obj)
{
PR_Free(opt);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
obj->options = opt;
@ -297,7 +297,7 @@ test(FILE *in, FILE *out,
{
PR_Free(opt);
PR_Free(obj);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
while (1)

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

@ -39,58 +39,8 @@
#include "nsMailHeaders.h"
#include "msgCore.h"
#include "nsMimeURLUtils.h"
extern "C" int MK_OUT_OF_MEMORY;
extern "C" int MK_MSG_NO_HEADERS;
extern "C" int MK_MSG_MIME_MAC_FILE;
extern "C" int MK_MSG_IN_MSG_X_USER_WROTE;
extern "C" int MK_MSG_USER_WROTE;
extern "C" int MK_MSG_UNSPECIFIED_TYPE;
extern "C" int MK_MSG_XSENDER_INTERNAL;
extern "C" int MK_MSG_ADDBOOK_MOUSEOVER_TEXT;
extern "C" int MK_MSG_SHOW_ATTACHMENT_PANE;
extern "C" int MK_MIMEHTML_DISP_SUBJECT;
extern "C" int MK_MIMEHTML_DISP_RESENT_COMMENTS;
extern "C" int MK_MIMEHTML_DISP_RESENT_DATE;
extern "C" int MK_MIMEHTML_DISP_RESENT_SENDER;
extern "C" int MK_MIMEHTML_DISP_RESENT_FROM;
extern "C" int MK_MIMEHTML_DISP_RESENT_TO;
extern "C" int MK_MIMEHTML_DISP_RESENT_CC;
extern "C" int MK_MIMEHTML_DISP_DATE;
extern "C" int MK_MIMEHTML_DISP_SUBJECT;
extern "C" int MK_MIMEHTML_DISP_SENDER;
extern "C" int MK_MIMEHTML_DISP_FROM;
extern "C" int MK_MIMEHTML_DISP_REPLY_TO;
extern "C" int MK_MIMEHTML_DISP_ORGANIZATION;
extern "C" int MK_MIMEHTML_DISP_TO;
extern "C" int MK_MIMEHTML_DISP_CC;
extern "C" int MK_MIMEHTML_DISP_NEWSGROUPS;
extern "C" int MK_MIMEHTML_DISP_FOLLOWUP_TO;
extern "C" int MK_MIMEHTML_DISP_REFERENCES;
extern "C" int MK_MIMEHTML_DISP_MESSAGE_ID;
extern "C" int MK_MIMEHTML_DISP_RESENT_MESSAGE_ID;
extern "C" int MK_MIMEHTML_DISP_BCC;
extern "C" int MK_MIMEHTML_SHOW_SECURITY_ADVISOR;
extern "C" int MK_MIMEHTML_VERIFY_SIGNATURE;
extern "C" int MK_MIMEHTML_DOWNLOAD_STATUS_HEADER;
extern "C" int MK_MIMEHTML_DOWNLOAD_STATUS_NOT_DOWNLOADED;
extern "C" int MK_MIMEHTML_ENC_AND_SIGNED;
extern "C" int MK_MIMEHTML_SIGNED;
extern "C" int MK_MIMEHTML_XLATED;
extern "C" int MK_MIMEHTML_CERTIFICATES;
extern "C" int MK_MIMEHTML_ENC_SIGNED_BAD;
extern "C" int MK_MIMEHTML_SIGNED_BAD;
extern "C" int MK_MIMEHTML_XLATED_BAD;
extern "C" int MK_MIMEHTML_CERTIFICATES_BAD;
extern "C" int MK_MIMEHTML_SIGNED_UNVERIFIED;
#ifdef RICHIE
extern "C" int MK_MSG_SHOW_ALL_RECIPIENTS;
extern "C" int MK_MSG_SHOW_SHORT_RECIPIENTS;
#endif /* RICHIE */
#include "nsMimeStringResources.h"
#include "mimemoz2.h"
extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset);
@ -317,7 +267,7 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
*/
hdrs->heads = (char **) PR_MALLOC((hdrs->heads_size + 1) * sizeof(char *));
if (!hdrs->heads)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
memset(hdrs->heads, 0, (hdrs->heads_size + 1) * sizeof(char *));
@ -615,7 +565,7 @@ MimeHeaders_get_parameter (const char *header_value, const char *parm_name,
!PL_strncasecmp(token_start, parm_name, parm_len))
{
s = (char *) PR_MALLOC ((value_end - value_start) + 1);
if (! s) return 0; /* MK_OUT_OF_MEMORY */
if (! s) return 0; /* MIME_OUT_OF_MEMORY */
nsCRT::memcpy (s, value_start, value_end - value_start);
s [value_end - value_start] = 0;
/* if the parameter spans across multiple lines we have to strip out the
@ -847,7 +797,9 @@ MimeHeaders_default_addbook_link_generator (const char *dest, void *closure,
char *jsSafeName = mime_escape_quotes ((unquotedName && *unquotedName) ? unquotedName : unquotedAddr);
if (jsSafeName)
{
char *localizedPart = PR_smprintf (XP_GetString (MK_MSG_ADDBOOK_MOUSEOVER_TEXT), jsSafeName);
char *mouseText = MimeGetStringByID(MIME_MSG_ADDBOOK_MOUSEOVER_TEXT);
char *localizedPart = PR_smprintf (mouseText, jsSafeName);
PR_FREEIF(mouseText);
if (localizedPart)
{
mouseOverText = PR_smprintf ("onMouseOver=\"window.status='%s'; return true\" onMouseOut=\"window.status=''\"", localizedPart);
@ -916,53 +868,59 @@ MimeHeaders_convert_rfc1522(MimeDisplayOptions *opt,
static const char *
MimeHeaders_localize_header_name(const char *name, MimeDisplayOptions *opt)
static char *
MimeHeaders_localize_header_name(char *name, MimeDisplayOptions *opt)
{
const char *new_name = 0;
PRInt16 output_csid = 0;
int display_key = (!PL_strcasecmp(name,HEADER_BCC) ? MK_MIMEHTML_DISP_BCC :
!PL_strcasecmp(name,HEADER_CC) ? MK_MIMEHTML_DISP_CC :
!PL_strcasecmp(name,HEADER_DATE) ? MK_MIMEHTML_DISP_DATE :
!PL_strcasecmp(name,HEADER_FOLLOWUP_TO) ? MK_MIMEHTML_DISP_FOLLOWUP_TO :
!PL_strcasecmp(name,HEADER_FROM) ? MK_MIMEHTML_DISP_FROM :
!PL_strcasecmp(name,HEADER_MESSAGE_ID) ? MK_MIMEHTML_DISP_MESSAGE_ID :
!PL_strcasecmp(name,HEADER_NEWSGROUPS) ? MK_MIMEHTML_DISP_NEWSGROUPS :
!PL_strcasecmp(name,HEADER_ORGANIZATION) ? MK_MIMEHTML_DISP_ORGANIZATION :
!PL_strcasecmp(name,HEADER_REFERENCES) ? MK_MIMEHTML_DISP_REFERENCES :
!PL_strcasecmp(name,HEADER_REPLY_TO) ? MK_MIMEHTML_DISP_REPLY_TO :
!PL_strcasecmp(name,HEADER_RESENT_CC) ? MK_MIMEHTML_DISP_RESENT_CC :
!PL_strcasecmp(name,HEADER_RESENT_COMMENTS)
? MK_MIMEHTML_DISP_RESENT_COMMENTS :
!PL_strcasecmp(name,HEADER_RESENT_DATE) ? MK_MIMEHTML_DISP_RESENT_DATE :
!PL_strcasecmp(name,HEADER_RESENT_FROM) ? MK_MIMEHTML_DISP_RESENT_FROM :
!PL_strcasecmp(name,HEADER_RESENT_MESSAGE_ID)
? MK_MIMEHTML_DISP_RESENT_MESSAGE_ID :
!PL_strcasecmp(name,HEADER_RESENT_SENDER)? MK_MIMEHTML_DISP_RESENT_SENDER :
!PL_strcasecmp(name,HEADER_RESENT_TO) ? MK_MIMEHTML_DISP_RESENT_TO :
!PL_strcasecmp(name,HEADER_SENDER) ? MK_MIMEHTML_DISP_SENDER :
!PL_strcasecmp(name,HEADER_SUBJECT) ? MK_MIMEHTML_DISP_SUBJECT :
!PL_strcasecmp(name,HEADER_TO) ? MK_MIMEHTML_DISP_TO :
!PL_strcasecmp(name,HEADER_SUBJECT) ? MK_MIMEHTML_DISP_SUBJECT :
0);
if (!display_key)
return name;
output_csid = INTL_CharSetNameToID((opt->override_charset
? opt->override_charset
: opt->default_charset));
new_name = XP_GetStringForHTML(display_key, output_csid, (char*)name);
if (new_name)
return new_name;
else
return name;
if (!PL_strcasecmp(name,HEADER_BCC))
return MimeGetStringByID(MIME_MHTML_BCC);
if (!PL_strcasecmp(name,HEADER_CC))
return MimeGetStringByID(MIME_MHTML_CC);
if (!PL_strcasecmp(name,HEADER_DATE))
return MimeGetStringByID(MIME_MHTML_DATE);
if (!PL_strcasecmp(name,HEADER_FOLLOWUP_TO))
return MimeGetStringByID(MIME_MHTML_FOLLOWUP_TO);
if (!PL_strcasecmp(name,HEADER_FROM))
return MimeGetStringByID(MIME_MHTML_FROM);
if (!PL_strcasecmp(name,HEADER_MESSAGE_ID))
return MimeGetStringByID(MIME_MHTML_MESSAGE_ID);
if (!PL_strcasecmp(name,HEADER_NEWSGROUPS))
return MimeGetStringByID(MIME_MHTML_NEWSGROUPS);
if (!PL_strcasecmp(name,HEADER_ORGANIZATION))
return MimeGetStringByID(MIME_MHTML_ORGANIZATION);
if (!PL_strcasecmp(name,HEADER_REFERENCES))
return MimeGetStringByID(MIME_MHTML_REFERENCES);
if (!PL_strcasecmp(name,HEADER_REPLY_TO))
return MimeGetStringByID(MIME_MHTML_REPLY_TO);
if (!PL_strcasecmp(name,HEADER_RESENT_CC))
return MimeGetStringByID(MIME_MHTML_RESENT_CC);
if (!PL_strcasecmp(name,HEADER_RESENT_COMMENTS))
return MimeGetStringByID(MIME_MHTML_RESENT_COMMENTS);
if (!PL_strcasecmp(name,HEADER_RESENT_DATE))
return MimeGetStringByID(MIME_MHTML_RESENT_DATE);
if (!PL_strcasecmp(name,HEADER_RESENT_FROM))
return MimeGetStringByID(MIME_MHTML_RESENT_FROM);
if (!PL_strcasecmp(name,HEADER_RESENT_MESSAGE_ID))
return MimeGetStringByID(MIME_MHTML_RESENT_MESSAGE_ID);
if (!PL_strcasecmp(name,HEADER_RESENT_SENDER))
return MimeGetStringByID(MIME_MHTML_RESENT_SENDER);
if (!PL_strcasecmp(name,HEADER_RESENT_TO))
return MimeGetStringByID(MIME_MHTML_RESENT_TO);
if (!PL_strcasecmp(name,HEADER_SENDER))
return MimeGetStringByID(MIME_MHTML_SENDER);
if (!PL_strcasecmp(name,HEADER_SUBJECT))
return MimeGetStringByID(MIME_MHTML_SUBJECT);
if (!PL_strcasecmp(name,HEADER_TO))
return MimeGetStringByID(MIME_MHTML_TO);
if (!PL_strcasecmp(name,HEADER_SUBJECT))
return MimeGetStringByID(MIME_MHTML_SUBJECT);
return NULL;
}
static int
MimeHeaders_write_random_header_1 (MimeHeaders *hdrs,
const char *name, const char *contents,
char *name, const char *contents,
MimeDisplayOptions *opt,
PRBool subject_p)
{
@ -971,7 +929,8 @@ MimeHeaders_write_random_header_1 (MimeHeaders *hdrs,
char *out;
char *converted = 0;
PRInt32 converted_length = 0;
char *cleanName = NULL; /* To make sure there is no nasty HTML/JavaScript in Headers */
char *cleanName = NULL; /* To make sure there is no nasty HTML/JavaScript in Headers */
char *orig_name = name;
PR_ASSERT(hdrs);
if (!hdrs) return -1;
@ -987,7 +946,7 @@ MimeHeaders_write_random_header_1 (MimeHeaders *hdrs,
{
cleanName = nsEscapeHTML(name);
if (!cleanName)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
else
name = cleanName;
}
@ -1000,6 +959,8 @@ MimeHeaders_write_random_header_1 (MimeHeaders *hdrs,
if (status < 0)
{
PR_FREEIF(cleanName);
if (orig_name != name)
PR_FREEIF(name);
return status;
}
if (converted)
@ -1014,6 +975,8 @@ MimeHeaders_write_random_header_1 (MimeHeaders *hdrs,
{
PR_FREEIF(converted);
PR_FREEIF(cleanName);
if (orig_name != name)
PR_FREEIF(name);
return status;
}
@ -1055,7 +1018,11 @@ MimeHeaders_write_random_header_1 (MimeHeaders *hdrs,
hdrs->obuffer_size - (out - hdrs->obuffer) -10,
PR_TRUE);
if (status != NS_OK)
{
if (orig_name != name)
PR_FREEIF(name);
return status;
}
out += PL_strlen(out);
PR_ASSERT(out < (hdrs->obuffer + hdrs->obuffer_size));
@ -1100,6 +1067,9 @@ MimeHeaders_write_random_header_1 (MimeHeaders *hdrs,
status = MimeHeaders_write(opt, hdrs->obuffer, out - hdrs->obuffer);
PR_FREEIF(converted);
PR_FREEIF(cleanName);
if (orig_name != name)
PR_FREEIF(name);
if (status < 0)
return status;
else
@ -1108,7 +1078,7 @@ MimeHeaders_write_random_header_1 (MimeHeaders *hdrs,
static int
MimeHeaders_write_random_header (MimeHeaders *hdrs, const char *name,
MimeHeaders_write_random_header (MimeHeaders *hdrs, char *name,
PRBool all_p, MimeDisplayOptions *opt)
{
int status = 0;
@ -1120,7 +1090,7 @@ MimeHeaders_write_random_header (MimeHeaders *hdrs, const char *name,
}
static int
MimeHeaders_write_subject_header_1 (MimeHeaders *hdrs, const char *name,
MimeHeaders_write_subject_header_1 (MimeHeaders *hdrs, char *name,
const char *contents,
MimeDisplayOptions *opt)
{
@ -1128,7 +1098,7 @@ MimeHeaders_write_subject_header_1 (MimeHeaders *hdrs, const char *name,
}
static int
MimeHeaders_write_subject_header (MimeHeaders *hdrs, const char *name,
MimeHeaders_write_subject_header (MimeHeaders *hdrs, char *name,
MimeDisplayOptions *opt)
{
int status = 0;
@ -1139,7 +1109,7 @@ MimeHeaders_write_subject_header (MimeHeaders *hdrs, const char *name,
}
static int
MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, const char *name,
MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, char *name,
const char *contents,
MimeDisplayOptions *opt,
PRBool mail_header_p)
@ -1171,7 +1141,13 @@ MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, const char *name,
PRInt32 converted_length = 0;
status = MimeHeaders_convert_rfc1522(opt, contents, contents_length,
&converted, &converted_length);
if (status < 0) return status;
if (status < 0)
{
if (orig_name != name)
PR_FREEIF(name);
return status;
}
if (converted)
{
contents = converted;
@ -1180,10 +1156,12 @@ MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, const char *name,
}
/* grow obuffer with potential XSENDER AUTH string */
char *tString = MimeGetStringByID(MIME_MSG_XSENDER_INTERNAL);
status = MimeHeaders_grow_obuffer (hdrs, (name ? PL_strlen (name) : 0)
+ 100 + 2 *
PL_strlen(XP_GetString(MK_MSG_XSENDER_INTERNAL)) +
PL_strlen(tString) +
(contents_length * 4));
PR_FREEIF(tString);
if (status < 0) goto FAIL;
out = hdrs->obuffer;
@ -1257,7 +1235,7 @@ MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, const char *name,
s = nsEscapeHTML (hdrs->obuffer);
if (!s)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
status = MimeHeaders_write(opt, s, PL_strlen (s));
@ -1287,7 +1265,7 @@ MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, const char *name,
s = nsEscapeHTML (hdrs->obuffer);
if (!s)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
mail_p = (mail_header_p || !PL_strcasecmp ("poster", hdrs->obuffer));
@ -1379,7 +1357,9 @@ MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, const char *name,
}
if (flags & MSG_FLAG_SENDER_AUTHED) {
PL_strcpy (out, XP_GetString(MK_MSG_XSENDER_INTERNAL));
char *tString = MimeGetStringByID(MIME_MSG_XSENDER_INTERNAL);
PL_strcpy (out, tString);
PR_FREEIF(tString);
out += PL_strlen (out);
}
}
@ -1464,12 +1444,14 @@ MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, const char *name,
else status = 1;
FAIL:
if (orig_name != name)
PR_FREEIF(name);
PR_FREEIF(converted);
return status;
}
static int
MimeHeaders_write_grouped_header (MimeHeaders *hdrs, const char *name,
MimeHeaders_write_grouped_header (MimeHeaders *hdrs, char *name,
MimeDisplayOptions *opt,
PRBool mail_header_p)
{
@ -1494,13 +1476,14 @@ MimeHeaders_write_grouped_header (MimeHeaders *hdrs, const char *name,
static int
MimeHeaders_write_id_header_1 (MimeHeaders *hdrs, const char *name,
MimeHeaders_write_id_header_1 (MimeHeaders *hdrs, char *name,
const char *contents, PRBool show_ids,
MimeDisplayOptions *opt)
{
int status = 0;
PRInt32 contents_length;
char *out;
const char *orig_name = name;
PR_ASSERT(hdrs);
if (!hdrs) return -1;
@ -1571,7 +1554,7 @@ MimeHeaders_write_id_header_1 (MimeHeaders *hdrs, const char *name,
s = nsEscapeHTML (hdrs->obuffer);
if (!s)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
status = MimeHeaders_write(opt, s, PL_strlen (s));
@ -1622,7 +1605,7 @@ MimeHeaders_write_id_header_1 (MimeHeaders *hdrs, const char *name,
s = nsEscapeHTML (hdrs->obuffer);
if (!s)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
}
@ -1633,7 +1616,7 @@ MimeHeaders_write_id_header_1 (MimeHeaders *hdrs, const char *name,
s = PL_strdup(buf);
if (!s)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
}
@ -1684,11 +1667,13 @@ MimeHeaders_write_id_header_1 (MimeHeaders *hdrs, const char *name,
else status = 1;
FAIL:
if (orig_name != name)
PR_FREEIF(name);
return status;
}
static int
MimeHeaders_write_id_header (MimeHeaders *hdrs, const char *name,
MimeHeaders_write_id_header (MimeHeaders *hdrs, char *name,
PRBool show_ids, MimeDisplayOptions *opt)
{
int status = 0;
@ -1721,7 +1706,7 @@ static int MimeHeaders_write_citation_headers (MimeHeaders *,
#### We should come up with some secret way to set this from a user
preference, perhaps from a special file in the ~/.netscape/ directory.
*/
static const char *mime_interesting_headers[] = {
static char *mime_interesting_headers[] = {
HEADER_SUBJECT,
HEADER_RESENT_COMMENTS,
HEADER_RESENT_DATE,
@ -1756,7 +1741,7 @@ MimeHeaders_write_interesting_headers (MimeHeaders *hdrs,
{
PRBool wrote_any_p = PR_FALSE;
int status = 0;
const char **rest;
char **rest;
PRBool did_from = PR_FALSE;
PRBool did_resent_from = PR_FALSE;
@ -1768,7 +1753,7 @@ MimeHeaders_write_interesting_headers (MimeHeaders *hdrs,
for (rest = mime_interesting_headers; *rest; rest++)
{
const char *name = *rest;
char *name = *rest;
/* The Subject header gets written in bold.
*/
@ -1970,7 +1955,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
end--;
name = (char *)PR_MALLOC(colon - head + 1);
if (!name) return MK_OUT_OF_MEMORY;
if (!name) return MIME_OUT_OF_MEMORY;
nsCRT::memcpy(name, head, colon - head);
name[colon - head] = 0;
@ -1978,7 +1963,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
if (!c2)
{
PR_Free(name);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
nsCRT::memcpy(c2, contents, end - contents);
c2[end - contents] = 0;
@ -2035,6 +2020,8 @@ MimeHeaders_write_microscopic_headers (MimeHeaders *hdrs,
char *from = MimeHeaders_get (hdrs, HEADER_FROM, PR_FALSE, PR_TRUE);
char *date = MimeHeaders_get (hdrs, HEADER_DATE, PR_FALSE, PR_TRUE);
char *out;
char *tString = NULL;
char *tString2 = NULL;
if (!from)
from = MimeHeaders_get (hdrs, HEADER_SENDER, PR_FALSE, PR_TRUE);
@ -2091,11 +2078,13 @@ MimeHeaders_write_microscopic_headers (MimeHeaders *hdrs,
out = hdrs->obuffer;
tString = MimeGetStringByID(MIME_MHTML_FROM);
PR_snprintf(out, sizeof(out), "\
<TR><TD VALIGN=TOP BGCOLOR=\"#CCCCCC\" ALIGN=RIGHT><B>%s: </B></TD>\
<TD VALIGN=TOP BGCOLOR=\"#CCCCCC\" width=100%%>\
<table border=0 cellspacing=0 cellpadding=0 width=100%%><tr>\
<td valign=top>", XP_GetString(MK_MIMEHTML_DISP_FROM));
<td valign=top>", tString);
PR_FREEIF(tString);
out += PL_strlen(out);
if (from) {
@ -2118,7 +2107,9 @@ MimeHeaders_write_microscopic_headers (MimeHeaders *hdrs,
PL_strcpy(out,
"</TR><TR><TD VALIGN=TOP BGCOLOR=\"#CCCCCC\" ALIGN=RIGHT><B>");
out += PL_strlen(out);
PL_strcpy(out, XP_GetString(MK_MIMEHTML_DISP_SUBJECT));
tString2 = MimeGetStringByID(MIME_MHTML_SUBJECT);
PL_strcpy(out, tString2);
PR_FREEIF(tString2);
out += PL_strlen(out);
PL_strcpy(out, ": </B></TD><TD VALIGN=TOP BGCOLOR=\"#CCCCCC\">");
out += PL_strlen(out);
@ -2185,7 +2176,6 @@ MimeHeaders_write_citation_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt)
nsIPref *pref = GetPrefServiceManager(opt); // Pref service manager
int status;
char *from = 0, *name = 0, *id = 0;
const char *fmt = 0;
char *converted = 0;
PRInt32 converted_length = 0;
@ -2202,7 +2192,7 @@ MimeHeaders_write_citation_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt)
from = PL_strdup("Unknown");
if (!from)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
@ -2218,14 +2208,20 @@ MimeHeaders_write_citation_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt)
}
PR_FREEIF(from);
fmt = (id
? XP_GetString(MK_MSG_IN_MSG_X_USER_WROTE)
: XP_GetString(MK_MSG_USER_WROTE));
char *tString;
if (id)
tString = MimeGetStringByID(MIME_MSG_X_USER_WROTE);
else
tString = MimeGetStringByID(MIME_MSG_USER_WROTE);
status = MimeHeaders_grow_obuffer (hdrs,
PL_strlen(fmt) + PL_strlen(name) +
PL_strlen(tString) + PL_strlen(name) +
(id ? PL_strlen(id) : 0) + 58);
if (status < 0) return status;
if (status < 0)
{
PR_FREEIF(tString);
return status;
}
if (opt->nice_html_only_p) {
PRBool nReplyWithExtraLines = PR_FALSE, eReplyOnTop = PR_FALSE;
@ -2238,20 +2234,28 @@ MimeHeaders_write_citation_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt)
// for (; nReplyWithExtraLines > 0; nReplyWithExtraLines--) {
if (nReplyWithExtraLines) {
status = MimeHeaders_write(opt, "<BR>", 4);
if (status < 0) return status;
if (status < 0)
{
PR_FREEIF(tString);
return status;
}
}
}
}
if (id)
PR_snprintf(hdrs->obuffer, sizeof(hdrs->obuffer), fmt, id, name);
PR_snprintf(hdrs->obuffer, sizeof(hdrs->obuffer), tString, id, name);
else
PR_snprintf(hdrs->obuffer, sizeof(hdrs->obuffer), fmt, name);
PR_snprintf(hdrs->obuffer, sizeof(hdrs->obuffer), tString, name);
status = MimeHeaders_convert_rfc1522(opt, hdrs->obuffer,
PL_strlen(hdrs->obuffer),
&converted, &converted_length);
if (status < 0) return status;
if (status < 0)
{
PR_FREEIF(tString);
return status;
}
if (converted)
{
@ -2272,6 +2276,7 @@ MimeHeaders_write_citation_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt)
FAIL:
PR_FREEIF(tString);
PR_FREEIF(from);
PR_FREEIF(name);
PR_FREEIF(id);
@ -2389,11 +2394,12 @@ MimeHeaders_write_headers_html (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBo
#define MHTML_TABLE_COLUMN_BEGIN "<TR><TD><B><I>"
#define MHTML_TABLE_COLUMN_END "</I></B></TD></TR>"
const char *msg = XP_GetString(MK_MSG_NO_HEADERS);
char *msg = MimeGetStringByID(MIME_MSG_NO_HEADERS);
PL_strcpy (hdrs->obuffer, MHTML_TABLE_COLUMN_BEGIN);
PL_strcat (hdrs->obuffer, msg);
PL_strcat (hdrs->obuffer, MHTML_TABLE_COLUMN_END);
status = MimeHeaders_write(opt, hdrs->obuffer, PL_strlen(hdrs->obuffer));
PR_FREEIF(msg);
if (status < 0) goto FAIL;
}
@ -2406,7 +2412,7 @@ MimeHeaders_write_headers_html (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBo
if (!opt->nice_html_only_p && opt->fancy_links_p) {
if (opt->attachment_icon_layer_id == 0) {
static PRInt32 randomid = 1; /* Not very random. ### */
char *mouseOverStatusString = XP_GetString(MK_MSG_SHOW_ATTACHMENT_PANE);
char *mouseOverStatusString = MimeGetStringByID(MIME_MSG_SHOW_ATTACHMENT_PANE);
opt->attachment_icon_layer_id = randomid;
#define MHTML_CLIP_START "</TD><TD VALIGN=TOP><DIV "
@ -2444,6 +2450,7 @@ MimeHeaders_write_headers_html (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBo
MHTML_CLIP_END,
(long) randomid, (long) randomid, mouseOverStatusString);
PR_FREEIF(mouseOverStatusString);
randomid++;
}
}

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

@ -68,6 +68,7 @@
#include "nsIMimeContentTypeHandler.h"
#include "nsIComponentManager.h"
#include "nsVoidArray.h"
#include "nsMimeStringResources.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_IID(kIMimeContentTypeHandlerIID, NS_IMIME_CONTENT_TYPE_HANDLER_IID);
@ -715,7 +716,7 @@ mime_part_address(MimeObject *obj)
if (obj->parent->parent)
{
higher = mime_part_address(obj->parent);
if (!higher) return 0; /* MK_OUT_OF_MEMORY */
if (!higher) return 0; /* MIME_OUT_OF_MEMORY */
}
if (!higher)
@ -726,7 +727,7 @@ mime_part_address(MimeObject *obj)
if (!s)
{
PR_Free(higher);
return 0; /* MK_OUT_OF_MEMORY */
return 0; /* MIME_OUT_OF_MEMORY */
}
PL_strcpy(s, higher);
PL_strcat(s, ".");
@ -889,7 +890,7 @@ mime_address_to_part(const char *part, MimeObject *obj)
else
{
char *part2 = mime_part_address(obj);
if (!part2) return 0; /* MK_OUT_OF_MEMORY */
if (!part2) return 0; /* MIME_OUT_OF_MEMORY */
match = !PL_strcmp(part, part2);
PR_Free(part2);
}
@ -1084,7 +1085,7 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options)
{
options->part_to_load = (char *) PR_MALLOC(end - value + 1);
if (!options->part_to_load)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
nsCRT::memcpy(options->part_to_load, value, end-value);
options->part_to_load[end-value] = 0;
}
@ -1178,14 +1179,14 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options)
PR_Free(options->part_to_load);
options->part_to_load = PL_strdup("1");
if (!options->part_to_load)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
else if (PL_strcmp(options->part_to_load, "1")) /* not 1 */
{
const char *prefix = "1.";
char *s = (char *) PR_MALLOC(PL_strlen(options->part_to_load) +
PL_strlen(prefix) + 1);
if (!s) return MK_OUT_OF_MEMORY;
if (!s) return MIME_OUT_OF_MEMORY;
PL_strcpy(s, prefix);
PL_strcat(s, options->part_to_load);
PR_Free(options->part_to_load);

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

@ -357,12 +357,6 @@ extern int MimeOptions_write(MimeDisplayOptions *,
extern int MimeObject_write_separator(MimeObject *);
/* Random junk
*/
extern "C" int MK_OUT_OF_MEMORY;
/* Turn this on if you want to play with the idea of displaying icons in the
headers to represent attachments, and put icons next to each attachment so
you can easily save them without having to bring up the "as links" view.

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

@ -21,6 +21,7 @@
#include "plstr.h"
#include "prlog.h"
#include "nsMimeTypes.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeLeafClass
MimeDefClass(MimeInlineImage, MimeInlineImageClass,
@ -90,12 +91,12 @@ MimeInlineImage_parse_begin (MimeObject *obj)
const char *ct;
part = mime_part_address(obj);
if (!part) return MK_OUT_OF_MEMORY;
if (!part) return MIME_OUT_OF_MEMORY;
image_url = mime_set_url_part(obj->options->url, part, PR_TRUE);
if (!image_url)
{
PR_Free(part);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
PR_Free(part);
@ -106,10 +107,10 @@ MimeInlineImage_parse_begin (MimeObject *obj)
obj->options->image_begin(image_url, ct, obj->options->stream_closure);
PR_Free(image_url);
if (!img->image_data) return MK_OUT_OF_MEMORY;
if (!img->image_data) return MIME_OUT_OF_MEMORY;
html = obj->options->make_image_html(img->image_data);
if (!html) return MK_OUT_OF_MEMORY;
if (!html) return MIME_OUT_OF_MEMORY;
status = MimeObject_write(obj, html, PL_strlen(html), PR_TRUE);
PR_Free(html);

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

@ -22,6 +22,7 @@
#include "prmem.h"
#include "plstr.h"
#include "prlog.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeObjectClass
MimeDefClass(MimeLeaf, MimeLeafClass, mimeLeafClass, &MIME_SUPERCLASS);
@ -118,7 +119,7 @@ MimeLeaf_parse_begin (MimeObject *obj)
obj);
if (!leaf->decoder_data)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj);

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

@ -21,6 +21,7 @@
#include "plstr.h"
#include "prlog.h"
#include "nsMimeTypes.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeMultipartClass
MimeDefClass(MimeMultipartAlternative, MimeMultipartAlternativeClass,
@ -63,7 +64,7 @@ MimeMultipartAlternative_initialize (MimeObject *obj)
PR_ASSERT(!malt->part_buffer);
malt->part_buffer = MimePartBufferCreate();
if (!malt->part_buffer)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(obj);
}
@ -140,7 +141,7 @@ MimeMultipartAlternative_create_child(MimeObject *obj)
PR_ASSERT(!malt->buffered_hdrs);
malt->buffered_hdrs = MimeHeaders_copy(mult->hdrs);
if (!malt->buffered_hdrs) return MK_OUT_OF_MEMORY;
if (!malt->buffered_hdrs) return MIME_OUT_OF_MEMORY;
return 0;
}
else
@ -254,7 +255,7 @@ MimeMultipartAlternative_display_cached_part(MimeObject *obj)
malt->buffered_hdrs, obj->options);
PR_FREEIF(ct);
if (!body) return MK_OUT_OF_MEMORY;
if (!body) return MIME_OUT_OF_MEMORY;
multipart_p = mime_typep(body, (MimeObjectClass *) &mimeMultipartClass);

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

@ -16,17 +16,18 @@
* Reserved.
*/
#include "nsCOMPtr.h"
#include "mimemapl.h"
#include "prmem.h"
#include "plstr.h"
#include "nsMimeTransition.h"
#include "nsMimeStringResources.h"
#include "mimemoz2.h"
#define MIME_SUPERCLASS mimeMultipartClass
MimeDefClass(MimeMultipartAppleDouble, MimeMultipartAppleDoubleClass,
mimeMultipartAppleDoubleClass, &MIME_SUPERCLASS);
extern "C" int MK_MSG_ATTACHMENT;
static int MimeMultipartAppleDouble_parse_begin (MimeObject *);
static PRBool MimeMultipartAppleDouble_output_child_p(MimeObject *,
MimeObject *);
@ -96,7 +97,7 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
PRBool all_headers_p = obj->options->headers == MimeHeadersAll;
id = mime_part_address (obj);
if (! id) return MK_OUT_OF_MEMORY;
if (! id) return MIME_OUT_OF_MEMORY;
if (obj->options->missing_parts)
id_imap = mime_imap_part_address (obj);
@ -116,14 +117,14 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
if (!id_url)
{
PR_Free(id);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
}
if (!PL_strcmp (id, "0"))
{
PR_Free(id);
id = PL_strdup(XP_GetString(MK_MSG_ATTACHMENT));
id = MimeGetStringByID(MIME_MSG_ATTACHMENT);
}
else
{
@ -133,7 +134,7 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
{
PR_Free(id);
PR_Free(id_url);
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
PL_strcpy(s, p);
PL_strcat(s, id);

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

@ -45,6 +45,11 @@
#include "nsFileSpec.h"
#include "nsMimeTransition.h"
#include "comi18n.h"
#include "nsIStringBundle.h"
#include "nsINetService.h"
#include "nsString.h"
#include "nsIEventQueueService.h"
#include "nsMimeStringResources.h"
#ifdef MOZ_SECURITY
#include HG01944
@ -60,9 +65,6 @@
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
extern "C" int MK_UNABLE_TO_OPEN_TMP_FILE;
extern "C" int XP_FORWARDED_MESSAGE_ATTACHMENT;
/* Arrgh. Why isn't this in a reasonable header file somewhere??? ###tw */
extern char * NET_ExplainErrorDetails (int code, ...);
@ -187,7 +189,7 @@ mime_convert_rfc1522 (const char *input_line, PRInt32 input_length,
else
{
line = (char *) PR_MALLOC(input_length+1);
if (!line) return MK_OUT_OF_MEMORY;
if (!line) return MIME_OUT_OF_MEMORY;
nsCRT::memcpy(line, input_line, input_length);
line[input_length] = 0;
}
@ -832,7 +834,7 @@ MimeGetAttachmentList(MWContext* context, MSG_AttachmentData** data)
n = cobj->nchildren; /* This is often too big, but that's OK. */
if (n <= 0) return n;
*data = (MSG_AttachmentData *) PR_Calloc(n + 1, sizeof(MSG_AttachmentData));
if (!*data) return MK_OUT_OF_MEMORY;
if (!*data) return MIME_OUT_OF_MEMORY;
tmp = *data;
c = '?';
if (PL_strchr(context->mime_data->last_parsed_url, '?')) {
@ -849,7 +851,7 @@ MimeGetAttachmentList(MWContext* context, MSG_AttachmentData** data)
MimeObject* child = cobj->children[i];
char* part = mime_part_address(child);
char* imappart = NULL;
if (!part) return MK_OUT_OF_MEMORY;
if (!part) return MIME_OUT_OF_MEMORY;
if (obj->options->missing_parts)
imappart = mime_imap_part_address (child);
if (imappart)
@ -864,7 +866,7 @@ MimeGetAttachmentList(MWContext* context, MSG_AttachmentData** data)
tmp->url = PR_smprintf("%s%cpart=%s", context->mime_data->last_parsed_url,
c, part);
*/
if (!tmp->url) return MK_OUT_OF_MEMORY;
if (!tmp->url) return MIME_OUT_OF_MEMORY;
tmp->real_type = child->content_type ?
PL_strdup(child->content_type) : NULL;
tmp->real_encoding = child->encoding ? PL_strdup(child->encoding) : NULL;
@ -913,7 +915,9 @@ MimeGetAttachmentList(MWContext* context, MSG_AttachmentData** data)
if (tmp->real_type && !PL_strcasecmp(tmp->real_type, MESSAGE_RFC822) &&
(!tmp->real_name || *tmp->real_name == 0))
{
mime_SACopy(&(tmp->real_name), XP_GetString(XP_FORWARDED_MESSAGE_ATTACHMENT));
char *tString = MimeGetStringByID(MIME_FORWARDED_MESSAGE_ATTACHMENT);
mime_SACopy(&(tmp->real_name), tString);
PR_FREEIF(tString);
}
}
return 0;
@ -1057,7 +1061,7 @@ mime_bridge_create_stream(MimePluginInstance *newPluginObj,
/***
* SHERRY - MAKE THESE GO AWAY!
***/
if (format_out == FO_MAIL_MESSAGE_TO || format_out == FO_CACHE_AND_MAIL_MESSAGE_TO)
{
/* Bad news -- this would cause an endless loop. */
@ -1361,3 +1365,142 @@ mime_bridge_create_stream(MimePluginInstance *newPluginObj,
return stream;
}
/* This is the next generation string retrieval call */
static NS_DEFINE_IID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
#define MIME_URL "resource:/res/mailnews/messenger/mime.properties"
extern "C"
char *
MimeGetStringByIDREAL(PRInt32 stringID)
{
nsresult res;
char propertyURL[256];
PRInt32 bufLen = sizeof(propertyURL);
/***************************************
// Father forgive me...
NS_WITH_SERVICE(nsIEventQueueService, pEventQueueService, kEventQueueServiceCID, &res);
// nsresult ret = nsServiceManager::GetService(kEventQueueServiceCID,
// kIEventQueueServiceIID, (nsISupports**) &pEventQueueService);
if (NS_FAILED(res)) {
printf("cannot get event queue service\n");
return "xx";
}
res = pEventQueueService->CreateThreadEventQueue();
if (NS_FAILED(res))
{
printf("CreateThreadEventQueue failed\n");
return "xx";
}
****************************************/
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &res);
if (NS_SUCCEEDED(res) && prefs)
res = prefs->GetCharPref("mail.strings.mime", propertyURL, &bufLen);
if (!NS_SUCCEEDED(res) || !prefs)
PR_snprintf(propertyURL, sizeof(propertyURL), "%s", MIME_URL);
NS_WITH_SERVICE(nsINetService, pNetService, kNetServiceCID, &res);
if (!NS_SUCCEEDED(res) || (nsnull == pNetService))
{
return PL_strdup("???"); // Don't I18N this string...failsafe return value
}
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res);
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
{
nsIURL *url = nsnull;
nsILocale *locale = nsnull;
res = pNetService->CreateURL(&url, nsString(MIME_URL), nsnull, nsnull, nsnull);
if (NS_FAILED(res))
{
return PL_strdup("???"); // Don't I18N this string...failsafe return value
}
nsIStringBundle* sBundle = nsnull;
res = sBundleService->CreateBundle(url, locale, &sBundle);
if (NS_FAILED(res))
{
return PL_strdup("???"); // Don't I18N this string...failsafe return value
}
nsAutoString v("");
res = sBundle->GetStringFromID(stringID, v);
if (NS_FAILED(res))
{
char buf[128];
PR_snprintf(buf, sizeof(buf), "[StringID %d?]", stringID);
return PL_strdup(buf);
}
// Here we need to return a new copy of the string
char *returnBuffer = NULL;
PRInt32 bufferLen = v.Length() + 1;
returnBuffer = (char *)PR_MALLOC(bufferLen);
if (returnBuffer)
{
v.ToCString(returnBuffer, bufferLen);
return returnBuffer;
}
}
return PL_strdup("???"); // Don't I18N this string...failsafe return value
}
extern "C"
char *
MimeGetStringByID(PRInt32 stringID)
{
if (-1000 == stringID) return PL_strdup("Application is out of memory.");
if (-1001 == stringID) return PL_strdup("Unable to open the temporary file\n.\n%s\nCheck your `Temporary Directory' setting and try again.");
if (-1002 == stringID) return PL_strdup("Error writing temporary file.");
if (1000 == stringID) return PL_strdup("Subject");
if (1001 == stringID) return PL_strdup("Resent-Comments");
if (1002 == stringID) return PL_strdup("Resent-Date");
if (1003 == stringID) return PL_strdup("Resent-Sender");
if (1004 == stringID) return PL_strdup("Resent-From");
if (1005 == stringID) return PL_strdup("Resent-To");
if (1006 == stringID) return PL_strdup("Resent-CC");
if (1007 == stringID) return PL_strdup("Date");
if (1008 == stringID) return PL_strdup("Sender");
if (1009 == stringID) return PL_strdup("From");
if (1010 == stringID) return PL_strdup("Reply-To");
if (1011 == stringID) return PL_strdup("Organization");
if (1012 == stringID) return PL_strdup("To");
if (1013 == stringID) return PL_strdup("CC");
if (1014 == stringID) return PL_strdup("Newsgroups");
if (1015 == stringID) return PL_strdup("Followup-To");
if (1016 == stringID) return PL_strdup("References");
if (1017 == stringID) return PL_strdup("Name");
if (1018 == stringID) return PL_strdup("Type");
if (1019 == stringID) return PL_strdup("Encoding");
if (1020 == stringID) return PL_strdup("Description");
if (1021 == stringID) return PL_strdup("Message-ID");
if (1022 == stringID) return PL_strdup("Resent-Message-ID");
if (1023 == stringID) return PL_strdup("BCC");
if (1024 == stringID) return PL_strdup("Download Status");
if (1025 == stringID) return PL_strdup("Not Downloaded Inline");
if (1026 == stringID) return PL_strdup("Link to Document");
if (1027 == stringID) return PL_strdup("<B>Document Info:</B>");
if (1028 == stringID) return PL_strdup("Attachment");
if (1029 == stringID) return PL_strdup("forward.msg");
if (1030 == stringID) return PL_strdup("Add %s to your Address Book");
if (1031 == stringID) return PL_strdup("<B><FONT COLOR=\042#808080\042>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Internal</FONT></B>");
if (1032 == stringID) return PL_strdup("In message wrote:<P>");
if (1033 == stringID) return PL_strdup(" wrote:<P>");
if (1034 == stringID) return PL_strdup("(no headers)");
if (1035 == stringID) return PL_strdup("Toggle Attachment Pane");
char buf[128];
PR_snprintf(buf, sizeof(buf), "[StringID %d?]", stringID);
return PL_strdup(buf);
}

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

@ -134,6 +134,8 @@ extern "C" nsIPref *GetPrefServiceManager(MimeDisplayOptions *opt);
extern "C" char *GetOSTempFile(const char *name);
/* This is the next generation string retrieval call */
extern "C" char *MimeGetStringByID(PRInt32 stringID);
#ifdef __cplusplus
}

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

@ -112,8 +112,7 @@
#include "nsCRT.h"
#include "msgCore.h"
#include "nsMimeURLUtils.h"
extern "C" int MK_UNABLE_TO_OPEN_TMP_FILE;
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeMultipartClass
MimeDefClass(MimeMultipartRelated, MimeMultipartRelatedClass,
@ -159,7 +158,7 @@ MimeMultipartRelated_initialize(MimeObject* obj)
relobj->hash = PL_NewHashTable(20, PL_HashString, PL_CompareStrings, PL_CompareValues,
(PLHashAllocOps *)NULL, NULL);
if (!relobj->hash) return MK_OUT_OF_MEMORY;
if (!relobj->hash) return MIME_OUT_OF_MEMORY;
return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(obj);
}
@ -549,13 +548,13 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj,
make a file buffer. */
if (!relobj->head_buffer && !relobj->file_buffer_name) {
relobj->file_buffer_name = GetOSTempFile("nsma");
if (!relobj->file_buffer_name) return MK_OUT_OF_MEMORY;
if (!relobj->file_buffer_name) return MIME_OUT_OF_MEMORY;
relobj->file_stream = PR_Open(relobj->file_buffer_name,
PR_RDWR | PR_CREATE_FILE,
0);
if (!relobj->file_stream) {
return MK_UNABLE_TO_OPEN_TMP_FILE;
return MIME_UNABLE_TO_OPEN_TMP_FILE;
}
}
@ -577,13 +576,13 @@ MimeMultipartRelated_parse_child_line (MimeObject *obj,
if (!relobj->file_buffer_name) {
relobj->file_buffer_name = GetOSTempFile("nsma");
}
if (!relobj->file_buffer_name) return MK_OUT_OF_MEMORY;
if (!relobj->file_buffer_name) return MIME_OUT_OF_MEMORY;
relobj->file_stream = PR_Open(relobj->file_buffer_name,
PR_RDWR | PR_CREATE_FILE,
0);
if (!relobj->file_stream) {
return MK_UNABLE_TO_OPEN_TMP_FILE;
return MIME_UNABLE_TO_OPEN_TMP_FILE;
}
if (relobj->head_buffer && relobj->head_buffer_fp) {
@ -647,7 +646,7 @@ push_tag(MimeMultipartRelated* relobj, const char* buf, PRInt32 size)
relobj->curtag = (char*) PR_Realloc(relobj->curtag,
relobj->curtag_max);
}
if (!relobj->curtag) return MK_OUT_OF_MEMORY;
if (!relobj->curtag) return MIME_OUT_OF_MEMORY;
}
nsCRT::memcpy(relobj->curtag + relobj->curtag_length, buf, size);
relobj->curtag_length += size;
@ -867,7 +866,7 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p)
body = mime_create(((ct && *ct) ? ct : (dct ? dct : TEXT_HTML)),
relobj->buffered_hdrs, obj->options);
if (!body) {
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
status = ((MimeContainerClass *) obj->clazz)->add_child(obj, body);
@ -917,7 +916,7 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p)
buf = (char *) PR_MALLOC(buf_size);
if (!buf) {
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
@ -928,7 +927,7 @@ MimeMultipartRelated_parse_eof (MimeObject *obj, PRBool abort_p)
PR_RDONLY, 0);
if (!relobj->file_stream) {
PR_Free(buf);
status = MK_UNABLE_TO_OPEN_TMP_FILE;
status = MIME_UNABLE_TO_OPEN_TMP_FILE;
goto FAIL;
}

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

@ -27,6 +27,7 @@
#include "msgCore.h"
#include "prlog.h"
#include "nsCRT.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeContainerClass
MimeDefClass(MimeMessage, MimeMessageClass, mimeMessageClass,
@ -169,7 +170,7 @@ MimeMessage_parse_line (char *line, PRInt32 length, MimeObject *obj)
{
/* Hack a newline onto the end. */
char *s = (char *)PR_MALLOC(length + MSG_LINEBREAK_LEN + 1);
if (!s) return MK_OUT_OF_MEMORY;
if (!s) return MIME_OUT_OF_MEMORY;
nsCRT::memcpy(s, line, length);
PL_strcpy(s + length, MSG_LINEBREAK);
status = kid->clazz->parse_buffer (s, length + MSG_LINEBREAK_LEN, kid);
@ -184,7 +185,7 @@ MimeMessage_parse_line (char *line, PRInt32 length, MimeObject *obj)
if (!msg->hdrs)
{
msg->hdrs = MimeHeaders_new();
if (!msg->hdrs) return MK_OUT_OF_MEMORY;
if (!msg->hdrs) return MIME_OUT_OF_MEMORY;
}
#ifdef MIME_DRAFTS
@ -377,7 +378,7 @@ HG09091
body = mime_create(ct, msg->hdrs, obj->options);
PR_FREEIF(ct);
if (!body) return MK_OUT_OF_MEMORY;
if (!body) return MIME_OUT_OF_MEMORY;
status = ((MimeContainerClass *) obj->clazz)->add_child (obj, body);
if (status < 0)
{

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

@ -26,6 +26,8 @@
#include "prerror.h"
#include "nsMimeTypes.h"
#include "msgCore.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeMultipartClass
MimeDefClass(MimeMultipartSigned, MimeMultipartSignedClass,
@ -386,7 +388,7 @@ MimeMultipartSigned_parse_line (char *line, PRInt32 length, MimeObject *obj)
->xlation_signature_hash)),
sig->xlation_closure);
if (!sig->sig_decoder_data)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
}
@ -497,7 +499,7 @@ MimeMultipartSigned_parse_child_line (MimeObject *obj,
{
sig->part_buffer = MimePartBufferCreate();
if (!sig->part_buffer)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
/* fall through */
@ -591,7 +593,7 @@ MimeMultipartSigned_emit_child (MimeObject *obj)
{
char *html = (((MimeMultipartSignedClass *) obj->clazz)
->xlation_generate_html (sig->xlation_closure));
if (!html) return -1; /* MK_OUT_OF_MEMORY? */
if (!html) return -1; /* MIME_OUT_OF_MEMORY? */
status = MimeObject_write(obj, html, PL_strlen(html), PR_FALSE);
PR_Free(html);

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

@ -23,6 +23,7 @@
#include "prmem.h"
#include "plstr.h"
#include "prio.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeContainerClass
MimeDefClass(MimeMultipart, MimeMultipartClass,
@ -161,7 +162,7 @@ MimeMultipart_parse_line (char *line, PRInt32 length, MimeObject *obj)
MimeHeaders_free(mult->hdrs);
mult->hdrs = MimeHeaders_new();
if (!mult->hdrs)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
}
/* Now return, to ignore the boundary line itself. */
@ -289,7 +290,7 @@ MimeMultipart_create_child(MimeObject *obj)
body = mime_create(((ct && *ct) ? ct : (dct ? dct: TEXT_PLAIN)),
mult->hdrs, obj->options);
PR_FREEIF(ct);
if (!body) return MK_OUT_OF_MEMORY;
if (!body) return MIME_OUT_OF_MEMORY;
status = ((MimeContainerClass *) obj->clazz)->add_child(obj, body);
if (status < 0)
{

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

@ -24,6 +24,7 @@
#include "prlog.h"
#include "nsMimeTypes.h"
#include "nsCRT.h"
#include "nsMimeStringResources.h"
/* Way to destroy any notions of modularity or class hierarchy, Terry! */
# include "mimetpla.h"
@ -169,7 +170,7 @@ MimeObject_parse_begin (MimeObject *obj)
PR_ASSERT(!obj->headers); /* should be the outermost object. */
obj->options->state = PR_NEW(MimeParseStateObject);
if (!obj->options->state) return MK_OUT_OF_MEMORY;
if (!obj->options->state) return MIME_OUT_OF_MEMORY;
nsCRT::memset(obj->options->state, 0, sizeof(*obj->options->state));
obj->options->state->root = obj;
obj->options->state->separator_suppressed_p = PR_TRUE; /* no first sep */
@ -183,7 +184,7 @@ MimeObject_parse_begin (MimeObject *obj)
else
{
char *id = mime_part_address(obj);
if (!id) return MK_OUT_OF_MEMORY;
if (!id) return MIME_OUT_OF_MEMORY;
obj->output_p = !PL_strcmp(id, obj->options->part_to_load);
PR_Free(id);
}

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

@ -21,6 +21,7 @@
#include "prmem.h"
#include "plstr.h"
#include "nsCRT.h"
#include "nsMimeStringResources.h"
/* See mimepbuf.h for a description of the mission of this file.
@ -49,8 +50,6 @@
buffer; or blocks read from the disk file.
*/
extern "C" int MK_UNABLE_TO_OPEN_TMP_FILE;
#define TARGET_MEMORY_BUFFER_SIZE (1024 * 50) /* try for 50k mem buffer */
#define TARGET_MEMORY_BUFFER_QUANTUM (1024 * 5) /* decrease in steps of 5k */
#define DISK_BUFFER_SIZE (1024 * 10) /* read disk in 10k chunks */
@ -162,11 +161,11 @@ MimePartBufferWrite (MimePartBufferData *data,
if (!data->part_buffer && !data->file_buffer_name)
{
data->file_buffer_name = GetOSTempFile("nsma");
if (!data->file_buffer_name) return MK_OUT_OF_MEMORY;
if (!data->file_buffer_name) return MIME_OUT_OF_MEMORY;
data->file_stream = PR_Open(data->file_buffer_name, PR_RDWR | PR_CREATE_FILE, 493);
if (!data->file_stream)
return MK_UNABLE_TO_OPEN_TMP_FILE;
return MIME_UNABLE_TO_OPEN_TMP_FILE;
}
PR_ASSERT(data->part_buffer || data->file_stream);
@ -191,11 +190,11 @@ MimePartBufferWrite (MimePartBufferData *data,
{
if (!data->file_buffer_name)
data->file_buffer_name = GetOSTempFile("nsma");
if (!data->file_buffer_name) return MK_OUT_OF_MEMORY;
if (!data->file_buffer_name) return MIME_OUT_OF_MEMORY;
data->file_stream = PR_Open(data->file_buffer_name, PR_RDWR | PR_CREATE_FILE, 493);
if (!data->file_stream)
return MK_UNABLE_TO_OPEN_TMP_FILE;
return MIME_UNABLE_TO_OPEN_TMP_FILE;
if (data->part_buffer && data->part_buffer_fp)
{
@ -249,7 +248,7 @@ MimePartBufferRead (MimePartBufferData *data,
if (!data->file_buffer_name) return -1;
buf = (char *) PR_MALLOC(buf_size);
if (!buf) return MK_OUT_OF_MEMORY;
if (!buf) return MIME_OUT_OF_MEMORY;
if (data->file_stream)
PR_Close(data->file_stream);
@ -257,7 +256,7 @@ MimePartBufferRead (MimePartBufferData *data,
if (!data->file_stream)
{
PR_Free(buf);
return MK_UNABLE_TO_OPEN_TMP_FILE;
return MIME_UNABLE_TO_OPEN_TMP_FILE;
}
while(1)

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

@ -22,6 +22,7 @@
#include "prlog.h"
#include "nsMimeTypes.h"
#include "msgCore.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeMultipartClass
MimeDefClass(MimeSunAttachment, MimeSunAttachmentClass,
@ -292,7 +293,7 @@ MimeSunAttachment_create_child(MimeObject *obj)
child = mime_create(mime_ct, mult->hdrs, obj->options);
if (!child)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}

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

@ -21,6 +21,7 @@
#include "plstr.h"
#include "prlog.h"
#include "msgCore.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeInlineTextClass
MimeDefClass(MimeInlineTextHTML, MimeInlineTextHTMLClass,
@ -87,7 +88,7 @@ MimeInlineTextHTML_parse_begin (MimeObject *obj)
const char *in;
char *out;
if (!buf)
return MK_OUT_OF_MEMORY;
return MIME_OUT_OF_MEMORY;
/* The value of the Content-Base header is a number of "words".
Whitespace in this header is not significant -- it is assumed

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

@ -23,6 +23,7 @@
#include "nsMimeTransition.h"
#include "nsMimeURLUtils.h"
#include "nsCRT.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeInlineTextClass
MimeDefClass(MimeInlineTextPlain, MimeInlineTextPlainClass,
@ -65,7 +66,7 @@ MimeInlineTextPlain_parse_begin (MimeObject *obj)
strs[3] = "<PRE VARIABLE WRAP>";
s = PL_strdup(strs[(obj->options->variable_width_plaintext_p ? 1 : 0) +
(obj->options->wrap_long_lines_p ? 2 : 0)]);
if (!s) return MK_OUT_OF_MEMORY;
if (!s) return MIME_OUT_OF_MEMORY;
status = MimeObject_write(obj, s, PL_strlen(s), PR_FALSE);
PR_Free(s);
if (status < 0) return status;

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

@ -23,6 +23,7 @@
#include "prlog.h"
#include "nsMimeTypes.h"
#include "msgCore.h"
#include "nsMimeStringResources.h"
#define MIME_SUPERCLASS mimeContainerClass
MimeDefClass(MimeUntypedText, MimeUntypedTextClass,
@ -262,14 +263,14 @@ MimeUntypedText_open_subpart (MimeObject *obj,
*/
uty->open_hdrs = MimeHeaders_new();
if (!uty->open_hdrs) return MK_OUT_OF_MEMORY;
if (!uty->open_hdrs) return MIME_OUT_OF_MEMORY;
h = (char *) PR_MALLOC(PL_strlen(type) +
(enc ? PL_strlen(enc) : 0) +
(desc ? PL_strlen(desc) : 0) +
(name ? PL_strlen(name) : 0) +
100);
if (!h) return MK_OUT_OF_MEMORY;
if (!h) return MIME_OUT_OF_MEMORY;
PL_strcpy(h, HEADER_CONTENT_TYPE ": ");
PL_strcat(h, type);
@ -323,7 +324,7 @@ MimeUntypedText_open_subpart (MimeObject *obj,
if (!uty->open_subpart)
{
status = MK_OUT_OF_MEMORY;
status = MIME_OUT_OF_MEMORY;
goto FAIL;
}
}

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

@ -25,8 +25,6 @@
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
extern int MK_OUT_OF_MEMORY;
int
ParseRFC822Addresses (const char *line,
char **names,

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

@ -20,64 +20,20 @@
#include "prmem.h"
#include "plstr.h"
#include "nsCRT.h"
#include "nsMimeTransition.h"
#ifndef XP_MAC
#include "nsTextFragment.h"
#endif
#include "msgCore.h"
#include "mimebuf.h"
extern "C" int XP_FORWARDED_MESSAGE_ATTACHMENT = 100;
extern "C" int MK_UNABLE_TO_OPEN_TMP_FILE = 101;
extern "C" int MK_OUT_OF_MEMORY = 102;
extern "C" int MK_MSG_XSENDER_INTERNAL = 103;
extern "C" int MK_MSG_USER_WROTE = 104;
extern "C" int MK_MSG_SHOW_ATTACHMENT_PANE = 105;
extern "C" int MK_MSG_NO_HEADERS = 106;
extern "C" int MK_MSG_LINK_TO_DOCUMENT = 107;
extern "C" int MK_MSG_IN_MSG_X_USER_WROTE = 108;
extern "C" int MK_MSG_DOCUMENT_INFO = 109;
extern "C" int MK_MSG_ATTACHMENT = 110;
extern "C" int MK_MSG_ADDBOOK_MOUSEOVER_TEXT = 111;
extern "C" int MK_MIMEHTML_DISP_TO = 112;
extern "C" int MK_MIMEHTML_DISP_SUBJECT = 113;
extern "C" int MK_MIMEHTML_DISP_SENDER = 114;
extern "C" int MK_MIMEHTML_DISP_RESENT_TO = 115;
extern "C" int MK_MIMEHTML_DISP_RESENT_SENDER = 116;
extern "C" int MK_MIMEHTML_DISP_RESENT_MESSAGE_ID = 117;
extern "C" int MK_MIMEHTML_DISP_RESENT_FROM = 118;
extern "C" int MK_MIMEHTML_DISP_RESENT_DATE = 119;
extern "C" int MK_MIMEHTML_DISP_RESENT_COMMENTS = 120;
extern "C" int MK_MIMEHTML_DISP_RESENT_CC = 121;
extern "C" int MK_MIMEHTML_DISP_REPLY_TO = 122;
extern "C" int MK_MIMEHTML_DISP_REFERENCES = 123;
extern "C" int MK_MIMEHTML_DISP_ORGANIZATION = 124;
extern "C" int MK_MIMEHTML_DISP_NEWSGROUPS = 125;
extern "C" int MK_MIMEHTML_DISP_MESSAGE_ID = 126;
extern "C" int MK_MIMEHTML_DISP_FROM = 127;
extern "C" int MK_MIMEHTML_DISP_FOLLOWUP_TO = 128;
extern "C" int MK_MIMEHTML_DISP_DATE = 129;
extern "C" int MK_MIMEHTML_DISP_CC = 130;
extern "C" int MK_MIMEHTML_DISP_BCC = 131;
/*
* This is a transitional file that will help with the various message
* ID definitions and the functions to retrieve the error string
*/
extern "C" char
*XP_GetStringForHTML (int i, PRInt16 wincsid, char* english)
{
return english;
}
extern "C" char
*XP_GetString (int i)
{
return PL_strdup("Error condition");
}
extern "C" NET_cinfo *
NET_cinfo_find_type (char *uri)
{

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

@ -23,50 +23,11 @@
#include "plstr.h"
#include "net.h"
extern "C" int XP_FORWARDED_MESSAGE_ATTACHMENT;
extern "C" int MK_UNABLE_TO_OPEN_TMP_FILE;
extern "C" int MK_OUT_OF_MEMORY;
extern "C" int MK_MSG_XSENDER_INTERNAL;
extern "C" int MK_MSG_USER_WROTE;
extern "C" int MK_MSG_SHOW_ATTACHMENT_PANE;
extern "C" int MK_MSG_NO_HEADERS;
extern "C" int MK_MSG_LINK_TO_DOCUMENT;
extern "C" int MK_MSG_IN_MSG_X_USER_WROTE;
extern "C" int MK_MSG_DOCUMENT_INFO;
extern "C" int MK_MSG_ATTACHMENT;
extern "C" int MK_MSG_ADDBOOK_MOUSEOVER_TEXT;
extern "C" int MK_MIMEHTML_DISP_TO;
extern "C" int MK_MIMEHTML_DISP_SUBJECT;
extern "C" int MK_MIMEHTML_DISP_SENDER;
extern "C" int MK_MIMEHTML_DISP_RESENT_TO;
extern "C" int MK_MIMEHTML_DISP_RESENT_SENDER;
extern "C" int MK_MIMEHTML_DISP_RESENT_MESSAGE_ID;
extern "C" int MK_MIMEHTML_DISP_RESENT_FROM;
extern "C" int MK_MIMEHTML_DISP_RESENT_DATE;
extern "C" int MK_MIMEHTML_DISP_RESENT_COMMENTS;
extern "C" int MK_MIMEHTML_DISP_RESENT_CC;
extern "C" int MK_MIMEHTML_DISP_REPLY_TO;
extern "C" int MK_MIMEHTML_DISP_REFERENCES;
extern "C" int MK_MIMEHTML_DISP_ORGANIZATION;
extern "C" int MK_MIMEHTML_DISP_NEWSGROUPS;
extern "C" int MK_MIMEHTML_DISP_MESSAGE_ID;
extern "C" int MK_MIMEHTML_DISP_FROM;
extern "C" int MK_MIMEHTML_DISP_FOLLOWUP_TO;
extern "C" int MK_MIMEHTML_DISP_DATE;
extern "C" int MK_MIMEHTML_DISP_CC;
extern "C" int MK_MIMEHTML_DISP_BCC;
/*
* This is a transitional file that will help with the various message
* ID definitions and the functions to retrieve the error string
*/
extern "C" char
*XP_GetStringForHTML (int i, PRInt16 wincsid, char* english);
extern "C" char
*XP_GetString (int i);
extern "C" NET_cinfo *
NET_cinfo_find_type (char *uri);

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

@ -637,7 +637,7 @@ nsMimeURLUtils::ScanForURLs(const char *input, int32 input_size,
if (!invalidHit)
{
if ((ambitiousHit) && ((cp2-cp) < PL_strlen(mailToTag)))
if ((ambitiousHit) && ((cp2-cp) < (PRInt32)PL_strlen(mailToTag)))
invalidHit = PR_TRUE;
if ( (!ambitiousHit) && (cp2-cp < 7) )
invalidHit = PR_TRUE;