diff --git a/mailnews/mime/src/mimebuf.cpp b/mailnews/mime/src/mimebuf.cpp
index 021413d6c00..728c400d12c 100644
--- a/mailnews/mime/src/mimebuf.cpp
+++ b/mailnews/mime/src/mimebuf.cpp
@@ -30,7 +30,7 @@ extern "C" int
mime_GrowBuffer (PRUint32 desired_size, PRUint32 element_size, PRUint32 quantum,
char **buffer, PRInt32 *size)
{
- if (*size <= desired_size)
+ if ((PRUint32) *size <= desired_size)
{
char *new_buf;
PRUint32 increment = desired_size - *size;
@@ -66,7 +66,7 @@ mime_ReBuffer (const char *net_buffer, PRInt32 net_buffer_size,
{
int status = 0;
- if (desired_buffer_size >= (*buffer_sizeP))
+ if (desired_buffer_size >= (PRUint32) (*buffer_sizeP))
{
status = mime_GrowBuffer (desired_buffer_size, sizeof(char), 1024,
bufferP, buffer_sizeP);
@@ -161,8 +161,8 @@ mime_LineBuffer (const char *net_buffer, PRInt32 net_buffer_size,
net_buffer_size > 0 && net_buffer[0] != LF) {
/* The last buffer ended with a CR. The new buffer does not start
with a LF. This old buffer should be shipped out and discarded. */
- PR_ASSERT(*buffer_sizeP > *buffer_fpP);
- if (*buffer_sizeP <= *buffer_fpP) return -1;
+ PR_ASSERT((PRUint32) *buffer_sizeP > *buffer_fpP);
+ if ((PRUint32) *buffer_sizeP <= *buffer_fpP) return -1;
status = convert_and_send_buffer(*bufferP, *buffer_fpP,
convert_newlines_p,
per_line_fn, closure);
@@ -211,7 +211,7 @@ mime_LineBuffer (const char *net_buffer, PRInt32 net_buffer_size,
const char *end = (newline ? newline : net_buffer_end);
PRUint32 desired_size = (end - net_buffer) + (*buffer_fpP) + 1;
- if (desired_size >= (*buffer_sizeP))
+ if (desired_size >= (PRUint32) (*buffer_sizeP))
{
status = mime_GrowBuffer (desired_size, sizeof(char), 1024,
bufferP, buffer_sizeP);
diff --git a/mailnews/mime/src/mimecth.h b/mailnews/mime/src/mimecth.h
index 9fbd51ce7eb..c18d830f192 100644
--- a/mailnews/mime/src/mimecth.h
+++ b/mailnews/mime/src/mimecth.h
@@ -93,24 +93,7 @@
|--- MimeExternalBody
*/
-/*
- * These are used by libmime to locate the plugins. It uses
- * a directory under the bin directory for libmime to contain
- * the plugins. This directory is defined by MIME_PLUGIN_DIR and
- * mime content handler plugins have a name prefixed by the
- * MIME_PLUGIN_PREFIX.
- */
-#ifdef XP_WIN
-#define MIME_PLUGIN_PREFIX "mimect-"
-#else
-#define MIME_PLUGIN_PREFIX "libmimect-"
-#endif
-
-#define MIME_PLUGIN_DIR "mimeplugins"
-
-typedef struct {
- PRBool force_inline_display;
-} contentTypeHandlerInitStruct;
+#include "nsIMimeContentTypeHandler.h"
/*
* These functions are exposed by libmime to be used by content type
diff --git a/mailnews/mime/src/mimedrft.cpp b/mailnews/mime/src/mimedrft.cpp
index cd6b597cc16..e81bacc3b81 100644
--- a/mailnews/mime/src/mimedrft.cpp
+++ b/mailnews/mime/src/mimedrft.cpp
@@ -28,6 +28,8 @@
#include "plstr.h"
#include "prio.h"
#include "nsIPref.h"
+#include "msgCore.h"
+#include "nsCRT.h"
#define HEADER_NNTP_POSTING_HOST "NNTP-Posting-Host"
@@ -231,7 +233,7 @@ static void mime_fix_up_html_address( char **addr)
PR_ASSERT (*addr);
lt = PL_strchr(*addr, '<');
PR_ASSERT(lt);
- XP_MEMMOVE(lt+4, lt+1, newLen - 4 - (lt - *addr));
+ nsCRT::memmove(lt+4, lt+1, newLen - 4 - (lt - *addr));
*lt++ = '&';
*lt++ = 'l';
*lt++ = 't';
@@ -369,18 +371,18 @@ static void mime_insert_all_headers(char **body,
/* Back up over whitespace before the colon. */
ocolon = colon;
- for (; colon > head && XP_IS_SPACE(colon[-1]); colon--)
+ for (; colon > head && IS_SPACE(colon[-1]); colon--)
;
contents = ocolon + 1;
}
/* Skip over whitespace after colon. */
- while (contents <= end && XP_IS_SPACE(*contents))
+ while (contents <= end && IS_SPACE(*contents))
contents++;
/* Take off trailing whitespace... */
- while (end > contents && XP_IS_SPACE(end[-1]))
+ while (end > contents && IS_SPACE(end[-1]))
end--;
name = PR_MALLOC(colon - head + 1);
diff --git a/mailnews/mime/src/mimehdrs.cpp b/mailnews/mime/src/mimehdrs.cpp
index 1c75f4cc6c4..f2001b888e9 100644
--- a/mailnews/mime/src/mimehdrs.cpp
+++ b/mailnews/mime/src/mimehdrs.cpp
@@ -36,6 +36,7 @@
#include "nsMimeAddress.h"
#include "comi18n.h"
#include "nsMailHeaders.h"
+#include "msgCore.h"
extern "C" int MK_OUT_OF_MEMORY;
extern "C" int MK_MSG_NO_HEADERS;
@@ -432,7 +433,7 @@ MimeHeaders_get (MimeHeaders *hdrs, const char *header_name,
/* Back up over whitespace before the colon. */
ocolon = colon;
- for (; colon > head && XP_IS_SPACE(colon[-1]); colon--)
+ for (; colon > head && IS_SPACE(colon[-1]); colon--)
;
/* If the strings aren't the same length, it doesn't match. */
@@ -449,7 +450,7 @@ MimeHeaders_get (MimeHeaders *hdrs, const char *header_name,
char *s;
/* Skip over whitespace after colon. */
- while (contents <= end && XP_IS_SPACE(*contents))
+ while (contents <= end && IS_SPACE(*contents))
contents++;
/* If we're supposed to strip at the frist token, pull `end' back to
@@ -458,7 +459,7 @@ MimeHeaders_get (MimeHeaders *hdrs, const char *header_name,
if (strip_p)
{
for (s = contents;
- s <= end && *s != ';' && *s != ',' && !XP_IS_SPACE(*s);
+ s <= end && *s != ';' && *s != ',' && !IS_SPACE(*s);
s++)
;
end = s;
@@ -501,7 +502,7 @@ MimeHeaders_get (MimeHeaders *hdrs, const char *header_name,
}
/* Take off trailing whitespace... */
- while (end > contents && XP_IS_SPACE(end[-1]))
+ while (end > contents && IS_SPACE(end[-1]))
end--;
if (end > contents)
@@ -556,7 +557,7 @@ MimeHeaders_get_parameter (const char *header_value, const char *parm_name,
if (*str)
str++;
/* Skip over following whitespace */
- for (; *str && XP_IS_SPACE(*str); str++)
+ for (; *str && IS_SPACE(*str); str++)
;
if (!*str)
return 0;
@@ -568,24 +569,24 @@ MimeHeaders_get_parameter (const char *header_value, const char *parm_name,
const char *value_start = str;
const char *value_end = 0;
- PR_ASSERT(!XP_IS_SPACE(*str)); /* should be after whitespace already */
+ PR_ASSERT(!IS_SPACE(*str)); /* should be after whitespace already */
/* Skip forward to the end of this token. */
- for (; *str && !XP_IS_SPACE(*str) && *str != '=' && *str != ';'; str++)
+ for (; *str && !IS_SPACE(*str) && *str != '=' && *str != ';'; str++)
;
token_end = str;
/* Skip over whitespace, '=', and whitespace */
- while (XP_IS_SPACE (*str)) str++;
+ while (IS_SPACE (*str)) str++;
if (*str == '=') str++;
- while (XP_IS_SPACE (*str)) str++;
+ while (IS_SPACE (*str)) str++;
if (*str != '"')
{
/* The value is a token, not a quoted string. */
value_start = str;
for (value_end = str;
- *value_end && !XP_IS_SPACE (*value_end) && *value_end != ';';
+ *value_end && !IS_SPACE (*value_end) && *value_end != ';';
value_end++)
;
str = value_end;
@@ -711,9 +712,9 @@ MimeHeaders_get_parameter (const char *header_value, const char *parm_name,
/* str now points after the end of the value.
skip over whitespace, ';', whitespace. */
- while (XP_IS_SPACE (*str)) str++;
+ while (IS_SPACE (*str)) str++;
if (*str == ';') str++;
- while (XP_IS_SPACE (*str)) str++;
+ while (IS_SPACE (*str)) str++;
}
return s;
}
@@ -1199,7 +1200,7 @@ MimeHeaders_write_grouped_header_1 (MimeHeaders *hdrs, const char *name,
/* Skip over whitespace and commas. */
while (this_start < data_end &&
- (XP_IS_SPACE (*this_start) || *this_start == ','))
+ (IS_SPACE (*this_start) || *this_start == ','))
this_start++;
this_end = this_start;
@@ -1522,7 +1523,7 @@ MimeHeaders_write_id_header_1 (MimeHeaders *hdrs, const char *name,
while (this_end < data_end)
{
/* Skip over whitespace. */
- while (this_start < data_end && XP_IS_SPACE (*this_start))
+ while (this_start < data_end && IS_SPACE (*this_start))
this_start++;
this_end = this_start;
@@ -1616,7 +1617,7 @@ MimeHeaders_write_id_header_1 (MimeHeaders *hdrs, const char *name,
else
{
char buf[50];
- XP_SPRINTF(buf, "%d", ++id_count);
+ PR_snprintf(buf, sizeof(buf), "%d", ++id_count);
s = PL_strdup(buf);
if (!s)
{
@@ -1942,18 +1943,18 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
/* Back up over whitespace before the colon. */
ocolon = colon;
- for (; colon > head && XP_IS_SPACE(colon[-1]); colon--)
+ for (; colon > head && IS_SPACE(colon[-1]); colon--)
;
contents = ocolon + 1;
}
/* Skip over whitespace after colon. */
- while (contents <= end && XP_IS_SPACE(*contents))
+ while (contents <= end && IS_SPACE(*contents))
contents++;
/* Take off trailing whitespace... */
- while (end > contents && XP_IS_SPACE(end[-1]))
+ while (end > contents && IS_SPACE(end[-1]))
end--;
name = (char *)PR_MALLOC(colon - head + 1);
@@ -2078,7 +2079,7 @@ MimeHeaders_write_microscopic_headers (MimeHeaders *hdrs,
out = hdrs->obuffer;
- XP_SPRINTF(out, "\
+ PR_snprintf(out, sizeof(out), "\
%s: | \
\
\
@@ -2229,9 +2230,9 @@ MimeHeaders_write_citation_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt)
}
if (id)
- XP_SPRINTF(hdrs->obuffer, fmt, id, name);
+ PR_snprintf(hdrs->obuffer, sizeof(hdrs->obuffer), fmt, id, name);
else
- XP_SPRINTF(hdrs->obuffer, fmt, name);
+ PR_snprintf(hdrs->obuffer, sizeof(hdrs->obuffer), fmt, name);
status = MimeHeaders_convert_rfc1522(opt, hdrs->obuffer,
PL_strlen(hdrs->obuffer),
@@ -2414,7 +2415,7 @@ MimeHeaders_write_headers_html (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBo
64 + /* 64 counts for two long number*/
412); /* 412 counts for the following constant
string. It is less than 412 */
- XP_SPRINTF(hdrs->obuffer + PL_strlen(hdrs->obuffer),
+ PR_snprintf(hdrs->obuffer + PL_strlen(hdrs->obuffer), ( sizeof(hdrs->obuffer) - PL_strlen(hdrs->obuffer)),
/* We set a CLIP=0,0,30,30 so that the attachment icon's layer cannot*/
/* be exploited for header spoofing. This means that if the attachment */
/* icon changes size, then we have to change this size too */
@@ -2449,7 +2450,7 @@ MimeHeaders_write_headers_html (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBo
if (status >= 0) {
#define MHTML_TITLE "%s\n"
- XP_SPRINTF(hdrs->obuffer, MHTML_TITLE, t2);
+ PR_snprintf(hdrs->obuffer, sizeof(hdrs->obuffer), MHTML_TITLE, t2);
status = MimeHeaders_write(opt, hdrs->obuffer,
PL_strlen(hdrs->obuffer));
}
@@ -2521,7 +2522,7 @@ MIME_StripContinuations(char *original)
{
p2++;
}
- while((*p2 == CR) || (*p2 == LF) || XP_IS_SPACE(*p2));
+ while((*p2 == CR) || (*p2 == LF) || IS_SPACE(*p2));
if (*p2 == '\0') continue; /* drop out of loop at end of string*/
}
diff --git a/mailnews/mime/src/mimei.cpp b/mailnews/mime/src/mimei.cpp
index 64d713452d8..d644bec8de9 100644
--- a/mailnews/mime/src/mimei.cpp
+++ b/mailnews/mime/src/mimei.cpp
@@ -50,10 +50,6 @@
#include "mimetenr.h" /* | | | |--- MimeInlineTextEnriched */
/* SUPPORTED VIA PLUGIN | | |--------- MimeInlineTextCalendar */
-#ifdef RICHIE_VCARD
-#include "mimevcrd.h" /* | | |--------- MimeInlineTextVCard */
-#endif
-
#include "prefapi.h"
#include "mimeiimg.h" /* | |--- MimeInlineImage */
#include "mimeeobj.h" /* | |--- MimeExternalObject */
@@ -68,8 +64,12 @@
#include "nsIPref.h"
#include "nsCRT.h"
#include "mimemoz2.h"
+#include "nsIMimeContentTypeHandler.h"
+#include "nsIComponentManager.h"
+#include "nsVoidArray.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
+static NS_DEFINE_IID(kIMimeContentTypeHandlerIID, NS_IMIME_CONTENT_TYPE_HANDLER_IID);
/* ==========================================================================
Allocation and destruction
@@ -82,229 +82,80 @@ static int mime_classinit(MimeObjectClass *clazz);
* content type handlers in external plugins.
*/
typedef struct {
- char *content_type;
+ char content_type[128];
PRBool force_inline_display;
- char *file_name;
- PRLibrary *ct_handler;
} cthandler_struct;
-cthandler_struct *cthandler_list = NULL;
-PRInt32 plugin_count = -1;
+nsVoidArray *ctHandlerList = NULL;
+PRBool foundIt = PR_FALSE;
+PRBool force_display = PR_FALSE;
-/*
- * This will find the directory for content type handler plugins.
- */
-PRBool
-find_plugin_directory(char *path, PRInt32 size)
+PRBool
+EnumFunction(void* aElement, void *aData)
{
-#ifdef XP_PC
- char *ptr;
+ cthandler_struct *ptr = (cthandler_struct *) aElement;
+ char *ctPtr = (char *)aData;
- if (!GetModuleFileName(NULL, path, size))
+ if ( (!aElement) || (!aData) )
+ return PR_TRUE;
+
+ if (PL_strcasecmp(ctPtr, ptr->content_type) == 0)
+ {
+ foundIt = PR_TRUE;
+ force_display = ptr->force_inline_display;
return PR_FALSE;
- ptr = PL_strrchr(path, '\\');
- if (ptr)
- *ptr = '\0';
- PL_strcat(path, "\\");
- PL_strcat(path, MIME_PLUGIN_DIR);
- return PR_TRUE;
-#else
- // First, find the home directory from the env.
- char *homedir = PR_GetEnv("MOZILLA_FIVE_HOME");
- if (homedir)
- {
- PL_strcat(path, homedir);
- PR_FREEIF(homedir);
- }
- else
- PL_strcat(path, ".");
-
- PL_strcat(path, "/components");
- return PR_TRUE;
-#endif
-}
-
-PRBool
-create_file_name(const char *path, const char *name, char *fullName)
-{
- if ((!path) || (!name))
- return PR_FALSE;
-
-#ifdef XP_PC
- PL_strcpy(fullName, path);
- PL_strcat(fullName, "\\");
- PL_strcat(fullName, name);
- return PR_TRUE;
-#else
- PL_strcpy(fullName, path);
- PL_strcat(fullName, "/");
- PL_strcat(fullName, name);
- return PR_TRUE;
-#endif
-}
-
-/*
- * This will locate the number of content type handler plugins.
- */
-PRInt32
-get_plugin_count(void)
-{
- PRDirEntry *dirEntry;
- PRInt32 count = 0;
- PRDir *dir;
- char path[1024] = "";
-
- if (!find_plugin_directory(path, sizeof(path)))
- return 0;
-
- dir = PR_OpenDir(path);
- if (!dir)
- return count;
-
- do
- {
- dirEntry = PR_ReadDir(dir, PR_SKIP_BOTH);
- if (!dirEntry)
- break;
-
- if (PL_strncasecmp(MIME_PLUGIN_PREFIX, dirEntry->name, PL_strlen(MIME_PLUGIN_PREFIX)) == 0)
- ++count;
- } while (dirEntry != NULL);
-
- PR_CloseDir(dir);
- return count;
-}
-
-char *
-get_content_type(cthandler_struct *ct)
-{
- mime_get_ct_fn_type getct_fn;
-
- if (!ct)
- return NULL;
-
- getct_fn = (mime_get_ct_fn_type) PR_FindSymbol(ct->ct_handler, "MIME_GetContentType");
- if (!getct_fn)
- return NULL;
-
- return ( (getct_fn) () );
-}
-
-MimeObjectClass *
-create_content_type_handler_class(cthandler_struct *ct)
-{
- contentTypeHandlerInitStruct ctHandlerInfo;
- mime_create_class_fn_type class_fn;
- MimeObjectClass *retClass = NULL;
-
- if (!ct)
- return NULL;
-
- class_fn = (mime_create_class_fn_type) PR_FindSymbol(ct->ct_handler, "MIME_CreateContentTypeHandlerClass");
- if (class_fn)
- {
- retClass = (class_fn)(ct->content_type, &ctHandlerInfo);
- ct->force_inline_display = ctHandlerInfo.force_inline_display;
}
- return retClass;
+ return PR_TRUE;
}
/*
- * We need to initialize a table of external modules and
- * the content type that it will process. What we will do is check
- * the directory "mimeplugins" under the location where this DLL is
- * running. Any DLL in that directory will have the naming convention:
- *
- * mimect-mycontenttype.dll - where mycontenttype is the content type being
- * processed.
- *
- * This DLL will have specifically defined entry points to be used by
- * libmime for processing the data stream.
+ * This will return TRUE if the content_type is found in the
+ * list, FALSE if it is not found.
*/
-PRInt32
-do_plugin_discovery(void)
+PRBool
+find_content_type_attribs(const char *content_type,
+ PRBool *force_inline_display)
{
- PRDirEntry *dirEntry;
- PRInt32 count = 0;
- PRDir *dir;
- char path[1024] = "";
- char full_name[1024] = "";
+ *force_inline_display = PR_FALSE;
+ if (!ctHandlerList)
+ return PR_FALSE;
- if (!find_plugin_directory(path, sizeof(path)))
- return 0;
+ foundIt = PR_FALSE;
+ force_display = PR_FALSE;
+ ctHandlerList->EnumerateForwards(EnumFunction, (void *)content_type);
+ if (foundIt)
+ *force_inline_display = force_display;
- count = get_plugin_count();
- if (count <= 0)
- return 0;
-
- cthandler_list = (cthandler_struct *) PR_MALLOC(count * sizeof(cthandler_struct));
- if (!cthandler_list)
- return 0;
- XP_MEMSET(cthandler_list, 0, (count * sizeof(cthandler_struct)));
-
- dir = PR_OpenDir(path);
- if (!dir)
- return 0;
-
- count = 0;
- do
- {
- dirEntry = PR_ReadDir(dir, PR_SKIP_BOTH );
- if (!dirEntry)
- break;
-
- if (PL_strncasecmp(MIME_PLUGIN_PREFIX, dirEntry->name, PL_strlen(MIME_PLUGIN_PREFIX)) == 0)
- {
- if (!create_file_name(path, dirEntry->name, full_name))
- continue;
-
- cthandler_list[count].ct_handler = PR_LoadLibrary(full_name);
- if (!cthandler_list[count].ct_handler)
- continue;
-
- cthandler_list[count].file_name = PL_strdup(full_name);
- if (!cthandler_list[count].file_name)
- {
- PR_UnloadLibrary(cthandler_list[count].ct_handler);
- continue;
- }
-
- cthandler_list[count].content_type = PL_strdup(get_content_type(&(cthandler_list[count])));
- if (!cthandler_list[count].content_type)
- {
- PR_UnloadLibrary(cthandler_list[count].ct_handler);
- PR_FREEIF(cthandler_list[count].file_name);
- continue;
- }
-
- ++count;
- }
- } while (dirEntry != NULL);
-
- PR_CloseDir(dir);
- return count;
+ return (foundIt);
}
-/*
- * This routine will find all content type handler for a specifc content
- * type (if it exists)
- */
-MimeObjectClass *
-mime_locate_external_content_handler(const char *content_type)
+void
+add_content_type_attribs(const char *content_type,
+ contentTypeHandlerInitStruct *ctHandlerInfo)
{
- PRInt32 i;
+ cthandler_struct *ptr = NULL;
+ PRBool force_inline_display;
- if (plugin_count < 0)
- plugin_count = do_plugin_discovery();
+ if (find_content_type_attribs(content_type, &force_inline_display))
+ return;
- for (i=0; icontent_type, content_type, sizeof(ptr->content_type));
+ ptr->force_inline_display = ctHandlerInfo->force_inline_display;
+ ctHandlerList->AppendElement(ptr);
}
/*
@@ -314,17 +165,40 @@ mime_locate_external_content_handler(const char *content_type)
PRBool
force_inline_display(const char *content_type)
{
- PRInt32 i;
+ PRBool force_inline_display;
- for (i=0; iCreateContentTypeHandlerClass(content_type, ctHandlerInfo, &newObj))
+ return NULL;
+
+ add_content_type_attribs(content_type, ctHandlerInfo);
+ return newObj;
+}
/* This is necessary to expose the MimeObject method outside of this DLL */
int
@@ -399,13 +273,13 @@ mime_free (MimeObject *object)
PR_Free(object);
}
-
MimeObjectClass *
mime_find_class (const char *content_type, MimeHeaders *hdrs,
MimeDisplayOptions *opts, PRBool exact_match_p)
{
MimeObjectClass *clazz = 0;
MimeObjectClass *tempClass = 0;
+ contentTypeHandlerInitStruct ctHandlerInfo;
/*
* What we do first is check for an external content handler plugin.
@@ -414,7 +288,7 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs,
* for specific content types. If one is not found, we will drop back
* to the default handler.
*/
- if ((tempClass = mime_locate_external_content_handler(content_type)) != NULL)
+ if ((tempClass = mime_locate_external_content_handler(content_type, &ctHandlerInfo)) != NULL)
{
clazz = (MimeObjectClass *)tempClass;
}
@@ -436,12 +310,6 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs,
clazz = (MimeObjectClass *)&mimeInlineTextRichtextClass;
else if (!PL_strcasecmp(content_type+5, "plain"))
clazz = (MimeObjectClass *)&mimeInlineTextPlainClass;
-
-#ifdef RICHIE_VCARD
- else if (!PL_strcasecmp(content_type+5, "x-vcard"))
- clazz = (MimeObjectClass *)&mimeInlineTextVCardClass;
-#endif
-
else if (!exact_match_p)
clazz = (MimeObjectClass *)&mimeInlineTextPlainClass;
}
@@ -701,14 +569,6 @@ mime_create (const char *content_type, MimeHeaders *hdrs,
else
{
- /* change content-Disposition for vcards to be inline so */
- /* we can see a nice html display */
-#ifdef RICHIE_VCARD
- if (mime_subclass_p(clazz,(MimeObjectClass *)&mimeInlineTextVCardClass))
- mime_SACopy(&content_disposition, "inline");
- else
-#endif
-
/* Check to see if the plugin should override the content disposition
to make it appear inline. One example is a vcard which has a content
disposition of an "attachment;" */
@@ -848,7 +708,7 @@ mime_part_address(MimeObject *obj)
return 0;
}
- XP_SPRINTF(buf, "%ld", j);
+ PR_snprintf(buf, sizeof(buf), "%ld", j);
if (obj->parent->parent)
{
higher = mime_part_address(obj->parent);
diff --git a/mailnews/mime/src/mimemoz2.cpp b/mailnews/mime/src/mimemoz2.cpp
index 29b2d136248..83d451c61b8 100644
--- a/mailnews/mime/src/mimemoz2.cpp
+++ b/mailnews/mime/src/mimemoz2.cpp
@@ -198,8 +198,20 @@ mime_convert_rfc1522 (const char *input_line, PRInt32 input_length,
if (converted)
{
- *output_ret = converted;
- *output_size_ret = PL_strlen(converted);
+ char *convertedString = NULL;
+
+ PRInt32 res = MIME_ConvertString(charset, "UTF-8", converted, &convertedString);
+ if ( (res != 0) || (!convertedString) )
+ {
+ *output_ret = converted;
+ *output_size_ret = PL_strlen(converted);
+ }
+ else
+ {
+ PR_Free(converted);
+ *output_ret = convertedString;
+ *output_size_ret = PL_strlen(converted);
+ }
}
else
{
@@ -973,16 +985,6 @@ extern int MIME_HasAttachments(MWContext *context)
return (context->mime_data && context->mime_data->last_parsed_object->showAttachmentIcon);
}
-/* RICHIE
- * HOW WILL THIS BE HANDLED GOING FORWARD????
- */
-PRBool
-ValidateDocData(MWContext *window_id)
-{
- printf("ValidateDocData not implemented, stubbed in webshell/tests/viewer/nsStubs.cpp\n");
- return PR_TRUE;
-}
-
/**************************************************************
**************************************************************
**************************************************************
@@ -1155,8 +1157,8 @@ mime_bridge_create_stream(MimePluginInstance *newPluginObj,
msd->options->headers = MimeHeadersAll;
// Get the libmime prefs...
- MIME_NoInlineAttachments = PR_TRUE; // false - no attachment display
- // true - attachment display
+ MIME_NoInlineAttachments = PR_TRUE; // false - display as links
+ // true - display attachment
if (msd->prefs)
msd->prefs->GetBoolPref("mail.inline_attachments", &MIME_NoInlineAttachments);
MIME_NoInlineAttachments = !MIME_NoInlineAttachments;
@@ -1266,7 +1268,28 @@ mime_bridge_create_stream(MimePluginInstance *newPluginObj,
msd->options->image_write_buffer = mime_image_write_buffer;
msd->options->variable_width_plaintext_p = MIME_VariableWidthPlaintext;
-
+
+ //
+ // Charset overrides takes place here
+ //
+ // We have a bool pref (mail.override_charset) to deal with incorrectly labeled mails.
+ // 1) If false and the part header is specified then use the charset in the header.
+ // 2) If false and the part header has no charset the use the charset in the pref.
+ // We may also apply the charset detection.
+ // 3) If false then only use the charset in pref and ignore all other information.
+ //
+ PRBool overrideCharset = FALSE;
+
+ msd->prefs->GetBoolPref("mail.force_charset", &overrideCharset);
+ if (overrideCharset)
+ {
+ char charset[256];
+ int length = sizeof(charset);
+
+ msd->prefs->GetCharPref("mail.charset", charset, &length);
+ msd->options->override_charset = PL_strdup(charset);
+ }
+
/* ### mwelch We want FO_EDT_SAVE_IMAGE to behave like *_SAVE_AS here
because we're spooling untranslated raw data. */
if (format_out == FO_SAVE_AS ||
diff --git a/mailnews/mime/src/mimetext.cpp b/mailnews/mime/src/mimetext.cpp
index 0127b537891..27e0a113457 100644
--- a/mailnews/mime/src/mimetext.cpp
+++ b/mailnews/mime/src/mimetext.cpp
@@ -87,15 +87,13 @@ MimeInlineText_initialize (MimeObject *obj)
HEADER_X_SUN_CHARSET,
PR_FALSE, PR_FALSE);
}
-
+
if (!text->charset)
{
if (obj->options && obj->options->default_charset)
text->charset = PL_strdup(obj->options->default_charset);
-
- /* Do not label US-ASCII if the app default charset is multibyte.
- Perhaps US-ASCII label should be removed for all cases.
- */
+ // Do not label US-ASCII if the app default charset is multibyte.
+ // Perhaps US-ASCII label should be removed for all cases.
else if (MULTIBYTE & INTL_DefaultDocCharSetID(0))
;
else
diff --git a/mailnews/mime/src/nsMimeFactory.cpp b/mailnews/mime/src/nsMimeFactory.cpp
index 27ddecf79a0..146a5048618 100644
--- a/mailnews/mime/src/nsMimeFactory.cpp
+++ b/mailnews/mime/src/nsMimeFactory.cpp
@@ -221,8 +221,10 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
+#ifdef DEBUG
printf("*** The NEW and Improved Mime being registered\n");
-
+#endif
+
// Content type handler object class access interface
rv = compMgr->RegisterComponent(kCMimeMimeObjectClassAccessCID, NULL, NULL, path,
PR_TRUE, PR_TRUE);
|