Bug 377319 Convert mailnews/mime to the external API r=Neil sr=Standard8
authorJan Horak <jhorak@redhat.com>
Sun, 11 Apr 2010 20:58:30 +0100
changeset 5428 071ad171572ec1bfbf459ca811fa8418648b3a36
parent 5427 bc6701d5d20c2750e32ec674c46b218ee6ae4a4f
child 5429 bd5814d2286b0e0772923f367f9d1f97b1013074
push idunknown
push userunknown
push dateunknown
reviewersNeil, Standard8
bugs377319
Bug 377319 Convert mailnews/mime to the external API r=Neil sr=Standard8
mailnews/mime/cthandlers/vcard/mimevcrd.cpp
mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
mailnews/mime/src/mimehdrs.cpp
mailnews/mime/src/mimemsg.cpp
mailnews/mime/src/nsMsgHeaderParser.cpp
mailnews/mime/src/nsStreamConverter.cpp
--- a/mailnews/mime/cthandlers/vcard/mimevcrd.cpp
+++ b/mailnews/mime/cthandlers/vcard/mimevcrd.cpp
@@ -39,16 +39,17 @@
  
 #include "mimecth.h"
 #include "mimexpcom.h"
 #include "nsIMsgVCardService.h"
 #include "nsINetUtil.h"
 #include "nsMsgUtils.h"
 #include "prmem.h"
 #include "prprf.h"
+#include "nsServiceManagerUtils.h"
 
 static int MimeInlineTextVCard_parse_line (const char *, PRInt32, MimeObject *);
 static int MimeInlineTextVCard_parse_eof (MimeObject *, PRBool);
 static int MimeInlineTextVCard_parse_begin (MimeObject *obj);
 
 static int s_unique = 0;
 
 static int BeginVCard (MimeObject *obj);
--- a/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
+++ b/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
@@ -47,17 +47,16 @@
 #include "nsIPrefBranch.h"
 #include "nsIMimeStreamConverter.h"
 #include "nsIMsgWindow.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsMimeTypes.h"
 #include "prtime.h"
 #include "prprf.h"
 #include "nsIStringEnumerator.h"
-#include "nsStringEnumerator.h"
 #include "nsServiceManagerUtils.h"
 // hack: include this to fix opening news attachments.
 #include "nsINntpUrl.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIMimeConverter.h"
 #include "nsMsgMimeCID.h"
 #include "nsDateTimeFormatCID.h"
 #include "nsMsgUtils.h"
--- a/mailnews/mime/src/mimehdrs.cpp
+++ b/mailnews/mime/src/mimehdrs.cpp
@@ -51,16 +51,17 @@
 #include "mimemoz2.h"
 #include "nsMsgI18N.h"
 #include "mimehdrs.h"
 #include "nsIMIMEHeaderParam.h"
 #include "nsNetCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMemory.h"
 #include <ctype.h>
+#include "nsMsgUtils.h"
 
 // Forward declares...
 PRInt32 MimeHeaders_build_heads_list(MimeHeaders *hdrs);
 
 void
 MimeHeaders_convert_header_value(MimeDisplayOptions *opt, nsCString &value,
                                  PRBool convert_charset_only)
 {
@@ -595,28 +596,19 @@ MimeHeaders_write_all_headers (MimeHeade
 
     if ( (end - contents) > 0 )
     {
       hdr_value = Substring(contents, end);
     }
 
     // MW Fixme: more?
     PRBool convert_charset_only =
-#ifdef MOZILLA_INTERNAL_API
-          name.LowerCaseEqualsLiteral("to") || name.LowerCaseEqualsLiteral("from") ||
-          name.LowerCaseEqualsLiteral("cc") || name.LowerCaseEqualsLiteral("bcc") ||
-          name.LowerCaseEqualsLiteral("reply-to") || name.LowerCaseEqualsLiteral("sender");
-#else
-          name.Equals("to", CaseInsensitiveCompare) ||
-          name.Equals("from", CaseInsensitiveCompare) ||
-          name.Equals("cc", CaseInsensitiveCompare) ||
-          name.Equals("bcc", CaseInsensitiveCompare) ||
-          name.Equals("reply-to", CaseInsensitiveCompare) ||
-          name.Equals("sender", CaseInsensitiveCompare);
-#endif
+          MsgLowerCaseEqualsLiteral(name, "to") || MsgLowerCaseEqualsLiteral(name, "from") ||
+          MsgLowerCaseEqualsLiteral(name, "cc") || MsgLowerCaseEqualsLiteral(name, "bcc") ||
+          MsgLowerCaseEqualsLiteral(name, "reply-to") || MsgLowerCaseEqualsLiteral(name, "sender");
     MimeHeaders_convert_header_value(opt, hdr_value, convert_charset_only);
     // if we're saving as html, we need to convert headers from utf8 to message charset, if any
     if (opt->format_out == nsMimeOutput::nsMimeMessageSaveAs && charset)
     {
       nsCAutoString convertedStr;
       if (NS_SUCCEEDED(ConvertFromUnicode(charset, NS_ConvertUTF8toUTF16(hdr_value),
                        convertedStr)))
       {
--- a/mailnews/mime/src/mimemsg.cpp
+++ b/mailnews/mime/src/mimemsg.cpp
@@ -823,17 +823,17 @@ MimeMessage_partial_message_html(const c
                   PR_FALSE);
   char *msgIdPtr = PL_strchr(msgId, '<');
   int msgBase;
 
   PRInt32 pos = orig_url.Find("mailbox-message");
   if (pos != -1)
     orig_url.Cut(pos + 7, 8);
 
-  pos = orig_url.Find("#");
+  pos = orig_url.FindChar('#');
   if (pos != -1)
     orig_url.Replace(pos, 1, "?number=", 8);
 
   if (msgIdPtr)
     msgIdPtr++;
   else
     msgIdPtr = msgId;
   char *gtPtr = PL_strchr(msgIdPtr, '>');
--- a/mailnews/mime/src/nsMsgHeaderParser.cpp
+++ b/mailnews/mime/src/nsMsgHeaderParser.cpp
@@ -37,16 +37,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "msgCore.h"    // precompiled header...
 #include "nsMsgHeaderParser.h"
 #include "nsISimpleEnumerator.h"
 #include "comi18n.h"
 #include "prmem.h"
 #include <ctype.h>
+#include "nsAlgorithm.h"
 
 nsresult FillResultsArray(const char * aName, const char *aAddress, PRUnichar ** aOutgoingEmailAddress, PRUnichar ** aOutgoingName,
                           PRUnichar ** aOutgoingFullName, nsIMsgHeaderParser *aParser);
 
 /*
  * Macros used throughout the RFC-822 parsing code.
  */
 
@@ -206,17 +207,19 @@ nsMsgHeaderParser::ReformatHeaderAddress
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgHeaderParser::RemoveDuplicateAddresses(const nsACString &aAddrs,
                                             const nsACString &aOtherAddrs,
                                             nsACString &aResult)
 {
-  aResult.Adopt(msg_remove_duplicate_addresses(aAddrs, aOtherAddrs));
+  nsCString res;
+  res.Adopt(msg_remove_duplicate_addresses(aAddrs, aOtherAddrs));
+  aResult.Assign(res);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgHeaderParser::MakeFullAddressString(const char *aName,
                                          const char *aAddress, char **aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
--- a/mailnews/mime/src/nsStreamConverter.cpp
+++ b/mailnews/mime/src/nsStreamConverter.cpp
@@ -66,16 +66,17 @@
 #include "mozITXTToHTMLConv.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMsgWindow.h"
 #include "nsICategoryManager.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIAsyncInputStream.h"
 #include "nsIAsyncOutputStream.h"
+#include "nsMsgUtils.h"
 
 #define PREF_MAIL_DISPLAY_GLYPH "mail.display_glyph"
 #define PREF_MAIL_DISPLAY_STRUCT "mail.display_struct"
 
 ////////////////////////////////////////////////////////////////
 // Bridge routines for new stream converter XP-COM interface
 ////////////////////////////////////////////////////////////////
 
@@ -389,27 +390,18 @@ nsStreamConverter::DetermineOutputFormat
     if (*format)
     {
       mOverrideFormat = "raw";
 
       // set mOutputFormat to the supplied format, ensure that we replace any
       // %2F strings with the slash character
       const char *nextField = PL_strpbrk(format, "&; ");
       mOutputFormat.Assign(format, nextField ? nextField - format : -1);
-#ifdef MOZILLA_INTERNAL_API
-      mOutputFormat.ReplaceSubstring("%2F", "/");
-      mOutputFormat.ReplaceSubstring("%2f", "/");
-#else
-      PRInt32 pos = mOutputFormat.Find("%2f", CaseInsensitiveCompare);
-      while (pos != -1)
-      {
-        mOutputFormat.Replace(pos, 3, '/');
-        mOutputFormat.Find("%2f", pos + 1, CaseInsensitiveCompare);
-      }
-#endif
+      MsgReplaceSubstring(mOutputFormat, "%2F", "/");
+      MsgReplaceSubstring(mOutputFormat, "%2f", "/");
 
       // Don't muck with this data!
       *aNewType = nsMimeOutput::nsMimeMessageRaw;
       return NS_OK;
     }
   }
 
   // is this is a part that should just come out raw