Bug 467538 Replace nsIMsgRecipientArray with a simple, javascript-compatible array. r=bienvenu,sr=Neil
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 09 Dec 2008 21:03:44 +0000
changeset 1389 43cd29a7832d69443a9245273a3f029a59173a56
parent 1388 74c522b5c9bb6f1184e1a39964637e62525f9c72
child 1390 572b16f25080e3388b5f02cac24bc5c80c173a10
push id1096
push userbugzilla@standard8.plus.com
push dateTue, 09 Dec 2008 21:08:28 +0000
treeherdercomm-central@43cd29a7832d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu, Neil
bugs467538
Bug 467538 Replace nsIMsgRecipientArray with a simple, javascript-compatible array. r=bienvenu,sr=Neil
mail/components/compose/content/addressingWidgetOverlay.js
mailnews/build/nsMailModule.cpp
mailnews/compose/build/nsMsgCompFactory.cpp
mailnews/compose/public/Makefile.in
mailnews/compose/public/nsIMsgCompFields.idl
mailnews/compose/public/nsIMsgRecipientArray.idl
mailnews/compose/public/nsMsgCompCID.h
mailnews/compose/resources/content/addressingWidgetOverlay.js
mailnews/compose/src/Makefile.in
mailnews/compose/src/nsMsgCompFields.cpp
mailnews/compose/src/nsMsgRecipientArray.cpp
mailnews/compose/src/nsMsgRecipientArray.h
mailnews/compose/test/unit/test_splitRecipients.js
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -204,32 +204,32 @@ function CompFields2Recipients(msgCompFi
     var msgTo = msgCompFields.to;
     var msgCC = msgCompFields.cc;
     var msgBCC = msgCompFields.bcc;
     var msgRandomHeaders = msgCompFields.otherRandomHeaders;
     var msgNewsgroups = msgCompFields.newsgroups;
     var msgFollowupTo = msgCompFields.followupTo;
     var havePrimaryRecipient = false;
     if(msgReplyTo)
-      awSetInputAndPopupFromArray(msgCompFields.SplitRecipients(msgReplyTo, false),
+      awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgReplyTo, false, {}),
                                   "addr_reply", newListBoxNode, templateNode);
     if(msgTo)
     {
-      var rcp = msgCompFields.SplitRecipients(msgTo, false)
-      if (rcp.count)
+      var rcp = msgCompFields.splitRecipients(msgTo, false, {});
+      if (rcp.length)
       {
         awSetInputAndPopupFromArray(rcp, "addr_to", newListBoxNode, templateNode);
         havePrimaryRecipient = true;
       }
     }
     if(msgCC)
-      awSetInputAndPopupFromArray(msgCompFields.SplitRecipients(msgCC, false),
+      awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgCC, false, {}),
                                   "addr_cc", newListBoxNode, templateNode);
     if(msgBCC)
-      awSetInputAndPopupFromArray(msgCompFields.SplitRecipients(msgBCC, false),
+      awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgBCC, false, {}),
                                   "addr_bcc", newListBoxNode, templateNode);
     if(msgRandomHeaders)
       awSetInputAndPopup(msgRandomHeaders, "addr_other", newListBoxNode, templateNode);
     if(msgNewsgroups)
     {
       awSetInputAndPopup(msgNewsgroups, "addr_newsgroups", newListBoxNode, templateNode);
       havePrimaryRecipient = true;
     }
@@ -295,68 +295,65 @@ function awSetInputAndPopup(inputValue, 
 
     for ( var index = 0; index < addressArray.length; index++ )
         _awSetInputAndPopup(addressArray[index], popupValue, parentNode, templateNode);
   }
 }
 
 function awSetInputAndPopupFromArray(inputArray, popupValue, parentNode, templateNode)
 {
-  if ( inputArray && popupValue )
+  if (popupValue)
   {
     var recipient;
-    for ( var index = 0; index < inputArray.count; index++ )
+    for (var index = 0; index < inputArray.length; index++)
     {
       recipient = null;
       if (gMimeHeaderParser)
         try {
-          recipient = gMimeHeaderParser.unquotePhraseOrAddrWString(inputArray.StringAt(index), true);
+          recipient =
+            gMimeHeaderParser.unquotePhraseOrAddrWString(inputArray[index], true);
         } catch (ex) {};
       if (!recipient)
-        recipient = inputArray.StringAt(index)
+        recipient = inputArray[index];
       _awSetInputAndPopup(recipient, popupValue, parentNode, templateNode);
     }
   }
 }
 
 function awRemoveRecipients(msgCompFields, recipientType, recipientsList)
 {
   if (!msgCompFields || !recipientsList)
     return;
 
-  var recipientArray = msgCompFields.SplitRecipients(recipientsList, false);
-  if (! recipientArray)
-    return;
+  var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
 
-  for ( var index = 0; index < recipientArray.count; index++ )
+  for (var index = 0; index < recipientArray.length; index++)
     for (var row = 1; row <= top.MAX_RECIPIENTS; row ++)
     {
       var popup = awGetPopupElement(row);
       if (popup.selectedItem.getAttribute("value") == recipientType)
       {
         var input = awGetInputElement(row);
-        if (input.value == recipientArray.StringAt(index))
+        if (input.value == recipientArray[index])
         {
           awSetInputAndPopupValue(input, "", popup, "addr_to", -1);
           break;
         }
       }
     }
 }
 
 function awAddRecipients(msgCompFields, recipientType, recipientsList)
 {
   if (!msgCompFields || !recipientsList)
     return;
-  var recipientArray = msgCompFields.SplitRecipients(recipientsList, false);
-  if (! recipientArray)
-    return;
+  var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
 
-  for ( var index = 0; index < recipientArray.count; index++ )
-    awAddRecipient(recipientType, recipientArray.StringAt(index));
+  for (var index = 0; index < recipientArray.length; index++)
+    awAddRecipient(recipientType, recipientArray[index]);
 }
 
 // this was broken out of awAddRecipients so it can be re-used...adds a new row matching recipientType and
 // drops in the single address.
 function awAddRecipient(recipientType, address)
 {
   for (var row = 1; row <= top.MAX_RECIPIENTS; row ++)
   {
--- a/mailnews/build/nsMailModule.cpp
+++ b/mailnews/build/nsMailModule.cpp
@@ -189,17 +189,16 @@
 #include "nsMsgCompose.h"
 #include "nsMsgComposeParams.h"
 #include "nsMsgComposeProgressParams.h"
 #include "nsMsgAttachment.h"
 #include "nsMsgSend.h"
 #include "nsMsgQuote.h"
 #include "nsURLFetcher.h"
 #include "nsSmtpServer.h"
-#include "nsMsgRecipientArray.h"
 #include "nsMsgCompUtils.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // imap includes
 ////////////////////////////////////////////////////////////////////////////////
 #include "nsMsgImapCID.h"
 #include "nsIMAPHostSessionList.h"
 #include "nsImapIncomingServer.h"
@@ -426,17 +425,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgAtta
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeAndSend)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgSendLater)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgComposeService, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeContentHandler)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgQuote)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgQuoteListener)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSmtpUrl)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMailtoUrl)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgRecipientArray)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsURLFetcher)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgCompUtils)
 
 ////////////////////////////////////////////////////////////////////////////////
 // imap factories
 ////////////////////////////////////////////////////////////////////////////////
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImapUrl)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImapProtocol)
@@ -1046,18 +1044,16 @@ static const nsModuleComponentInfo gComp
     { "SMTP URL", NS_SMTPURL_CID,
       NS_SMTPURL_CONTRACTID, nsSmtpUrlConstructor },
     { "MAILTO URL", NS_MAILTOURL_CID,
       NS_MAILTOURL_CONTRACTID, nsMailtoUrlConstructor },
     { "Msg Quote", NS_MSGQUOTE_CID,
       NS_MSGQUOTE_CONTRACTID, nsMsgQuoteConstructor },
     { "Msg Quote Listener", NS_MSGQUOTELISTENER_CID,
       NS_MSGQUOTELISTENER_CONTRACTID, nsMsgQuoteListenerConstructor },
-    { "Msg Recipient Array", NS_MSGRECIPIENTARRAY_CID,
-      NS_MSGRECIPIENTARRAY_CONTRACTID, nsMsgRecipientArrayConstructor },
     { "URL Fetcher", NS_URLFETCHER_CID,
       NS_URLFETCHER_CONTRACTID, nsURLFetcherConstructor },
     { "Msg Compose Utils", NS_MSGCOMPUTILS_CID,
       NS_MSGCOMPUTILS_CONTRACTID, nsMsgCompUtilsConstructor },
 
      ////////////////////////////////////////////////////////////////////////////////
     // imap components
     ////////////////////////////////////////////////////////////////////////////////
--- a/mailnews/compose/build/nsMsgCompFactory.cpp
+++ b/mailnews/compose/build/nsMsgCompFactory.cpp
@@ -60,17 +60,16 @@
 #include "nsMsgCompose.h"
 #include "nsMsgComposeParams.h"
 #include "nsMsgComposeProgressParams.h"
 #include "nsMsgAttachment.h"
 #include "nsMsgSend.h"
 #include "nsMsgQuote.h"
 #include "nsURLFetcher.h"
 #include "nsSmtpServer.h"
-#include "nsMsgRecipientArray.h"
 #include "nsMsgCompUtils.h"
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSmtpService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSmtpServer)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgCompose)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeParams)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeSendListener)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeProgressParams)
@@ -79,17 +78,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgAtta
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeAndSend)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgSendLater)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgComposeService, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeContentHandler)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgQuote)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgQuoteListener)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSmtpUrl)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMailtoUrl)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgRecipientArray)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsURLFetcher)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgCompUtils)
 
 static NS_METHOD
 RegisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path,
                            const char *location, const char *type,
                            const nsModuleComponentInfo *info)
 {
@@ -190,20 +188,16 @@ static const nsModuleComponentInfo compo
   { "Msg Quote",
     NS_MSGQUOTE_CID,
     NS_MSGQUOTE_CONTRACTID,
     nsMsgQuoteConstructor },
   { "Msg Quote Listener",
     NS_MSGQUOTELISTENER_CID,
     NS_MSGQUOTELISTENER_CONTRACTID,
     nsMsgQuoteListenerConstructor },
-  { "Msg Recipient Array",
-    NS_MSGRECIPIENTARRAY_CID,
-    NS_MSGRECIPIENTARRAY_CONTRACTID,
-    nsMsgRecipientArrayConstructor },
   { "URL Fetcher",
     NS_URLFETCHER_CID,
     NS_URLFETCHER_CONTRACTID,
     nsURLFetcherConstructor },
   { "Msg Compose Utils",
     NS_MSGCOMPUTILS_CID,
     NS_MSGCOMPUTILS_CONTRACTID,
     nsMsgCompUtilsConstructor },
--- a/mailnews/compose/public/Makefile.in
+++ b/mailnews/compose/public/Makefile.in
@@ -60,17 +60,16 @@ XPIDLSRCS	= \
 		nsIMsgCompFields.idl \
 		nsIMsgQuote.idl \
 		nsIMsgQuotingOutputStreamListener.idl \
 		nsIMsgSendListener.idl \
 		nsIMsgSendLaterListener.idl \
 		nsIMsgSend.idl \
 		nsIMsgSendLater.idl \
 		nsIMsgSendReport.idl \
-		nsIMsgRecipientArray.idl \
 		nsISmtpServer.idl \
 		nsISmtpUrl.idl \
 		nsISmtpService.idl \
 		nsIURLFetcher.idl \
 		nsIMsgComposeSecure.idl \
 		nsIMsgCompUtils.idl \
 		$(NULL)
 
--- a/mailnews/compose/public/nsIMsgCompFields.idl
+++ b/mailnews/compose/public/nsIMsgCompFields.idl
@@ -32,21 +32,20 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
-#include "nsIMsgRecipientArray.idl"
 #include "nsIMsgAttachment.idl"
 #include "nsISimpleEnumerator.idl"
 
-[scriptable, uuid(ab598da9-d272-485b-9941-5ce87251a463)]
+[scriptable, uuid(76b9314c-e397-4806-b816-d8531ab02d30)]
 interface nsIMsgCompFields : nsISupports {
 
   attribute AString from;
   attribute AString replyTo;
   attribute AString to;
   attribute AString cc;
   attribute AString bcc;
   
@@ -90,18 +89,29 @@ interface nsIMsgCompFields : nsISupports
    */
   attribute string  temporaryFiles;
   
   readonly attribute nsISimpleEnumerator attachments;
   void addAttachment(in nsIMsgAttachment attachment);
   void removeAttachment(in nsIMsgAttachment attachment);
   void removeAttachments();
 
-  /* some utility functions */
-  nsIMsgRecipientArray SplitRecipients(in AString aRecipients, in boolean aEmailAddressOnly);    
+  /**
+   * This function will split the recipients into an array.
+   *
+   * @param aRecipients       The recipients list to split.
+   * @param aEmailAddressOnly Set to true to drop display names from the results
+   *                          array.
+   * @param aLength           The length of the aResult array.
+   * @param aResult           An array of the recipients.
+   */
+  void splitRecipients(in AString aRecipients, in boolean aEmailAddressOnly,
+                       out unsigned long aLength,
+                       [array, size_is(aLength), retval] out wstring aResult);
+
   void ConvertBodyToPlainText();
 
   // Check if the composing mail headers can be converted to a mail charset.
   boolean checkCharsetConversion(out string fallbackCharset);
 
   /** 
    * Indicates whether we need to check if the current |DocumentCharset|
    * can represent all the characters in the message body. It should be
deleted file mode 100644
--- a/mailnews/compose/public/nsIMsgRecipientArray.idl
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: idl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-
-
-[scriptable, uuid(650c3281-a1bf-11d3-a449-d481b6e12daa)]
-interface nsIMsgRecipientArray : nsISupports {
-
-	/* ... */
-	wstring StringAt(in long index);
-
-	/* ... */
-	boolean AppendString(in wstring aString);
-	
-	/* ... */
-	boolean RemoveStringAt (in long index);
-	
-	/* ... */
-	void Clear();
-
-	/* ... */
-	readonly attribute long count;
-};
-
--- a/mailnews/compose/public/nsMsgCompCID.h
+++ b/mailnews/compose/public/nsMsgCompCID.h
@@ -227,25 +227,16 @@ 0x0b63fb80, 0xbbba, 0x11d4,             
 //
 #define NS_MSGDRAFT_CONTRACTID \
   "@mozilla.org/messengercompose/drafts;1"
 #define NS_MSGDRAFT_CID \
   { 0xa623746c, 0x453b, 0x11d3, \
   { 0x8f, 0xf, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
 
 //
-// nsMsgRecipientArray
-//
-#define NS_MSGRECIPIENTARRAY_CONTRACTID \
-  "@mozilla.org/messengercompose/recipientarray;1"
-#define NS_MSGRECIPIENTARRAY_CID \
-  {0x9d653e00, 0xa1ca, 0x11d3, \
-    { 0xa4, 0x49, 0xf7, 0x9a, 0xb1, 0xc7, 0xd8, 0xfc }}
-
-//
 // nsURLFetcher
 //
 #define NS_URLFETCHER_CONTRACTID  \
   "@mozilla.org/messengercompose/urlfetcher;1"
 
 // {01B8A701-2F52-11D5-9DAA-F78DA781A1FC}
 #define NS_URLFETCHER_CID \
 { 0x01b8a701, 0x2f52, 0x11d5, \
--- a/mailnews/compose/resources/content/addressingWidgetOverlay.js
+++ b/mailnews/compose/resources/content/addressingWidgetOverlay.js
@@ -212,32 +212,32 @@ function CompFields2Recipients(msgCompFi
     var msgTo = msgCompFields.to;
     var msgCC = msgCompFields.cc;
     var msgBCC = msgCompFields.bcc;
     var msgRandomHeaders = msgCompFields.otherRandomHeaders;
     var msgNewsgroups = msgCompFields.newsgroups;
     var msgFollowupTo = msgCompFields.followupTo;
     var havePrimaryRecipient = false;
     if(msgReplyTo)
-      awSetInputAndPopupFromArray(msgCompFields.SplitRecipients(msgReplyTo, false), 
+      awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgReplyTo, false, {}),
                                   "addr_reply", newListBoxNode, templateNode);
     if(msgTo)
     {
-      var rcp = msgCompFields.SplitRecipients(msgTo, false)
-      if (rcp.count)
+      var rcp = msgCompFields.splitRecipients(msgTo, false, {});
+      if (rcp.length)
       {
         awSetInputAndPopupFromArray(rcp, "addr_to", newListBoxNode, templateNode);
         havePrimaryRecipient = true;
       }
     }
     if(msgCC)
-      awSetInputAndPopupFromArray(msgCompFields.SplitRecipients(msgCC, false),
+      awSetInputAndPopupFromArray(msgCompFields.SplitRecipients(msgCC, false, {}),
                                   "addr_cc", newListBoxNode, templateNode);
     if(msgBCC)
-      awSetInputAndPopupFromArray(msgCompFields.SplitRecipients(msgBCC, false),
+      awSetInputAndPopupFromArray(msgCompFields.SplitRecipients(msgBCC, false, {}),
                                   "addr_bcc", newListBoxNode, templateNode);
     if(msgRandomHeaders)
       awSetInputAndPopup(msgRandomHeaders, "addr_other", newListBoxNode, templateNode);
     if(msgNewsgroups)
     {
       awSetInputAndPopup(msgNewsgroups, "addr_newsgroups", newListBoxNode, templateNode);
       havePrimaryRecipient = true;
     }
@@ -303,69 +303,66 @@ function awSetInputAndPopup(inputValue, 
 
     for ( var index = 0; index < addressArray.length; index++ )
         _awSetInputAndPopup(addressArray[index], popupValue, parentNode, templateNode);
   }
 }
 
 function awSetInputAndPopupFromArray(inputArray, popupValue, parentNode, templateNode)
 {
-  if ( inputArray && popupValue )
+  if (popupValue)
   {
     var recipient;
-    for ( var index = 0; index < inputArray.count; index++ )
+    for (var index = 0; index < inputArray.length; index++)
     {
       recipient = null;
       if (gMimeHeaderParser)
         try {
-          recipient = gMimeHeaderParser.unquotePhraseOrAddrWString(inputArray.StringAt(index), true);
+          recipient =
+            gMimeHeaderParser.unquotePhraseOrAddrWString(inputArray[index], true);
         } catch (ex) {};
       if (!recipient)
-        recipient = inputArray.StringAt(index)
+        recipient = inputArray[index];
       _awSetInputAndPopup(recipient, popupValue, parentNode, templateNode);
     }
   }
 }
 
 function awRemoveRecipients(msgCompFields, recipientType, recipientsList)
 {
   if (!msgCompFields)
     return;
 
-  var recipientArray = msgCompFields.SplitRecipients(recipientsList, false);
-  if (! recipientArray)
-    return;
+  var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
 
-  for ( var index = 0; index < recipientArray.count; index++ )
+  for (var index = 0; index < recipientArray.length; index++)
     for (var row = 1; row <= top.MAX_RECIPIENTS; row ++)
     {
       var popup = awGetPopupElement(row);
       if (popup.selectedItem.getAttribute("value") == recipientType)
       {
         var input = awGetInputElement(row);
-        if (input.value == recipientArray.StringAt(index))
+        if (input.value == recipientArray[index])
         {
           awSetInputAndPopupValue(input, "", popup, "addr_to", -1);
           break;
         }
       }
     }
 }
 
 function awAddRecipients(msgCompFields, recipientType, recipientsList)
 {
   if (!msgCompFields)
     return;
 
-  var recipientArray = msgCompFields.SplitRecipients(recipientsList, false);
-  if (! recipientArray)
-    return;
+  var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
 
-  for ( var index = 0; index < recipientArray.count; index++ )
-    awAddRecipient(recipientType, recipientArray.StringAt(index));
+  for (var index = 0; index < recipientArray.length; index++)
+    awAddRecipient(recipientType, recipientArray[index]);
 }
 
 // this was broken out of awAddRecipients so it can be re-used...adds a new row matching recipientType and
 // drops in the single address.
 function awAddRecipient(recipientType, address)
 {
   for (var row = 1; row <= top.MAX_RECIPIENTS; row ++)
   {
--- a/mailnews/compose/src/Makefile.in
+++ b/mailnews/compose/src/Makefile.in
@@ -107,17 +107,16 @@ CPPSRCS		= \
 		nsMsgAttachmentHandler.cpp \
 		nsMsgPrompts.cpp \
 		nsMsgComposeService.cpp \
 		nsMsgComposeParams.cpp \
 		nsMsgComposeProgressParams.cpp \
 		nsMsgComposeContentHandler.cpp \
 		nsMsgCompose.cpp \
 		nsMsgQuote.cpp \
-		nsMsgRecipientArray.cpp \
 		nsURLFetcher.cpp \
 		nsSmtpServer.cpp \
 		$(NULL)
 
 EXPORTS		= \
 		nsComposeStrings.h \
 		$(NULL)
 
--- a/mailnews/compose/src/nsMsgCompFields.cpp
+++ b/mailnews/compose/src/nsMsgCompFields.cpp
@@ -34,17 +34,16 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsMsgCompFields.h"
 #include "nsMsgI18N.h"
-#include "nsMsgRecipientArray.h"
 #include "nsIMsgHeaderParser.h"
 #include "nsMsgCompUtils.h"
 #include "nsMsgUtils.h"
 #include "prmem.h"
 #include "nsIFileChannel.h"
 #include "nsIMsgMdnGenerator.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMsgMimeCID.h"
@@ -531,91 +530,99 @@ NS_IMETHODIMP nsMsgCompFields::RemoveAtt
 {
   m_attachments.Clear();
 
   return NS_OK;
 }
 
 
 // This method is called during the creation of a new window.
-NS_IMETHODIMP nsMsgCompFields::SplitRecipients(const nsAString &aRecipients, PRBool aEmailAddressOnly, nsIMsgRecipientArray **_retval)
+NS_IMETHODIMP
+nsMsgCompFields::SplitRecipients(const nsAString &aRecipients,
+                                 PRBool aEmailAddressOnly,
+                                 PRUint32 *aLength,
+                                 PRUnichar*** aResult)
 {
-  nsresult rv = NS_OK;
-  
-  if (!_retval)
-    return NS_ERROR_NULL_POINTER;
-  *_retval = nsnull;
-		
-  nsMsgRecipientArray* pAddrArray = new nsMsgRecipientArray;
-  if (! pAddrArray)
-    return NS_ERROR_OUT_OF_MEMORY;
-  
-  rv = pAddrArray->QueryInterface(NS_GET_IID(nsIMsgRecipientArray), (void **)_retval);
+  NS_ENSURE_ARG_POINTER(aLength);
+  NS_ENSURE_ARG_POINTER(aResult);
+
+  *aLength = 0;
+  *aResult = nsnull;
+
+  nsresult rv;
+  nsCOMPtr<nsIMsgHeaderParser> parser =
+    do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsCOMPtr<nsIMimeConverter> converter =
+    do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  char * names;
+  char * addresses;
+  PRUint32 numAddresses;
+
+  rv = parser->ParseHeaderAddresses(NS_ConvertUTF16toUTF8(aRecipients).get(),
+                                    &names, &addresses, &numAddresses);
   if (NS_SUCCEEDED(rv))
   {
-    nsCOMPtr<nsIMsgHeaderParser> parser = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID);
-    nsCOMPtr<nsIMimeConverter> converter = do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-    if (parser)
+    PRUint32 i = 0;
+    char * pNames = names;
+    char * pAddresses = addresses;
+    PRUnichar** result = (PRUnichar**) NS_Alloc(sizeof(PRUnichar*) * numAddresses);
+    if (!result)
+      return NS_ERROR_OUT_OF_MEMORY;
+
+    for (i = 0; i < numAddresses; ++i)
     {
-      nsCAutoString recipientsStr;
-      char * names;
-      char * addresses;
-      PRUint32 numAddresses;
-      
-      CopyUTF16toUTF8(aRecipients, recipientsStr);
-      
-      rv= parser->ParseHeaderAddresses(recipientsStr.get(), &names, 
-                                       &addresses, &numAddresses);
-      if (NS_SUCCEEDED(rv))
+      nsCString fullAddress;
+      nsAutoString recipient;
+      if (!aEmailAddressOnly)
       {
-        PRUint32 i=0;
-        char * pNames = names;
-        char * pAddresses = addresses;
-        PRBool aBool;
-        
-        for (i = 0; i < numAddresses; i ++)
-        {
-          nsCString fullAddress;
-          nsAutoString recipient;
-          if (!aEmailAddressOnly) 
-          {
-            nsCString decodedName;
-            converter->DecodeMimeHeaderToCharPtr(pNames, GetCharacterSet(), PR_FALSE, PR_TRUE,
-                                                 getter_Copies(decodedName));
-            rv = parser->MakeFullAddressString((!decodedName.IsEmpty() ? 
-                                                decodedName.get() : pNames), 
-                                               pAddresses, 
-                                               getter_Copies(fullAddress));
-          }
-          if (NS_SUCCEEDED(rv) && !aEmailAddressOnly)
-          {
-            rv = ConvertToUnicode("UTF-8", fullAddress, recipient);
-          }
-          else
-            rv = ConvertToUnicode("UTF-8", nsDependentCString(pAddresses), recipient);
-          if (NS_FAILED(rv))
-            break;
-          
-          rv = pAddrArray->AppendString(recipient.get(), &aBool);
-          if (NS_FAILED(rv))
-            break;
-          
-          pNames += PL_strlen(pNames) + 1;
-          pAddresses += PL_strlen(pAddresses) + 1;
-        }
-        
-        PR_FREEIF(names);
-        PR_FREEIF(addresses);
+        nsCString decodedName;
+        converter->DecodeMimeHeaderToCharPtr(pNames, GetCharacterSet(),
+                                             PR_FALSE, PR_TRUE,
+                                             getter_Copies(decodedName));
+        rv = parser->MakeFullAddressString((!decodedName.IsEmpty() ?
+                                            decodedName.get() : pNames),
+                                           pAddresses,
+                                           getter_Copies(fullAddress));
       }
+      if (NS_SUCCEEDED(rv) && !aEmailAddressOnly)
+        rv = ConvertToUnicode("UTF-8", fullAddress, recipient);
+      else
+        rv = ConvertToUnicode("UTF-8", nsDependentCString(pAddresses), recipient);
+      if (NS_FAILED(rv))
+        break;
+
+      result[i] = ToNewUnicode(recipient);
+      if (!result[i])
+      {
+        rv = NS_ERROR_OUT_OF_MEMORY;
+        break;
+      }
+
+      pNames += PL_strlen(pNames) + 1;
+      pAddresses += PL_strlen(pAddresses) + 1;
+    }
+
+    if (NS_FAILED(rv))
+    {
+      NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, result);
     }
     else
-      rv = NS_ERROR_FAILURE;
+    {
+      *aResult = result;
+      *aLength = numAddresses;
+    }
+
+    PR_FREEIF(names);
+    PR_FREEIF(addresses);
   }
-		
+
   return rv;
 }
 
 
 // This method is called during the sending of message from nsMsgCompose::CheckAndPopulateRecipients()
 nsresult nsMsgCompFields::SplitRecipientsEx(const nsAString &recipients,
                                             nsTArray<nsMsgRecipient> &aResult)
 {
deleted file mode 100644
--- a/mailnews/compose/src/nsMsgRecipientArray.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Pierre Phaneuf <pp@ludusdesign.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#include "nsMsgRecipientArray.h"
-#include "nsString.h"
-#include "nsReadableUtils.h"
-
-nsMsgRecipientArray::nsMsgRecipientArray()
-{
-	m_array = new nsStringArray;
-}
-
-
-nsMsgRecipientArray::~nsMsgRecipientArray()
-{
-  delete m_array;
-}
-
-/* the following macro actually implement addref, release and query interface for our class. */
-NS_IMPL_ISUPPORTS1(nsMsgRecipientArray, nsIMsgRecipientArray)
-
-nsresult nsMsgRecipientArray::StringAt(PRInt32 idx, PRUnichar **_retval)
-{
-  if (!_retval || !m_array)
-    return NS_ERROR_NULL_POINTER;
-  
-  nsString aStr;
-  m_array->StringAt(idx, aStr);
-  *_retval = ToNewUnicode(aStr);
-  return NS_OK;
-}
-
-nsresult nsMsgRecipientArray::AppendString(const PRUnichar *aString, PRBool *_retval)
-{
-	if (!_retval || !m_array)
-		return NS_ERROR_NULL_POINTER;
-		
-	*_retval = m_array->AppendString(nsString(aString));
-
-	return NS_OK;
-}
-
-nsresult nsMsgRecipientArray::RemoveStringAt(PRInt32 idx, PRBool *_retval)
-{
-	if (!_retval || !m_array)
-		return NS_ERROR_NULL_POINTER;
-		
-	*_retval = m_array->RemoveStringAt(idx);
-
-	return NS_OK;
-}
-
-nsresult nsMsgRecipientArray::Clear()
-{
-	if (!m_array)
-		return NS_ERROR_NULL_POINTER;
-	
-	m_array->Clear();
-
-	return NS_OK;
-}
-
-nsresult nsMsgRecipientArray::GetCount(PRInt32 *aCount)
-{
-	if (!aCount || !m_array)
-		return NS_ERROR_NULL_POINTER;
-
-	*aCount = m_array->Count();
-	return NS_OK;
-}
deleted file mode 100644
--- a/mailnews/compose/src/nsMsgRecipientArray.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _nsMsgRecipientArray_H_
-#define _nsMsgRecipientArray_H_
-
-#include "nsIMsgRecipientArray.h"
-#include "nsVoidArray.h"
-
-class nsMsgRecipientArray : public nsIMsgRecipientArray
-{
- public: 
-
-	nsMsgRecipientArray();
-	virtual ~nsMsgRecipientArray();
-
-	/* this macro defines QueryInterface, AddRef and Release for this class */
-	NS_DECL_ISUPPORTS
-
-	/*** nsIMsgCompose pure virtual functions */
-	NS_DECL_NSIMSGRECIPIENTARRAY
-
-
- private:
- 	nsStringArray * 	m_array;
-};
-
-
-#endif /* _nsMsgRecipientArray_H_ */
new file mode 100644
--- /dev/null
+++ b/mailnews/compose/test/unit/test_splitRecipients.js
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Test suite for nsMsgCompFields functions.
+ * Currently only tests nsIMsgCompFields::SplitRecipients
+ */
+
+const splitRecipientsTests =
+  [ { recipients: "me@invalid.com",
+      emailAddressOnly: false,
+      count: 1,
+      result: [ "me@invalid.com" ]
+    },
+    { recipients: "me@invalid.com, me2@invalid.com",
+      emailAddressOnly: false,
+      count: 2,
+      result: [ "me@invalid.com", "me2@invalid.com" ]
+    },
+    { recipients: '"foo bar" <me@invalid.com>',
+      emailAddressOnly: false,
+      count: 1,
+      result: [ '"foo bar" <me@invalid.com>' ]
+    },
+    { recipients: '"foo bar" <me@invalid.com>',
+      emailAddressOnly: true,
+      count: 1,
+      result: [ 'me@invalid.com' ]
+    },
+    { recipients: '"foo bar" <me@invalid.com>, "bar foo" <me2@invalid.com>',
+      emailAddressOnly: false,
+      count: 2,
+      result: [ '"foo bar" <me@invalid.com>', '"bar foo" <me2@invalid.com>' ]
+    },
+    { recipients: '"foo bar" <me@invalid.com>, "bar foo" <me2@invalid.com>',
+      emailAddressOnly: true,
+      count: 2,
+      result: [ "me@invalid.com", "me2@invalid.com" ]
+    },
+    { recipients: "",
+      emailAddressOnly: false,
+      count: 0,
+      result: []
+    } ];
+
+function run_test() {
+  var fields = Cc["@mozilla.org/messengercompose/composefields;1"]
+                 .createInstance(Ci.nsIMsgCompFields);
+
+  // As most of SplitRecipients functionality is in the nsIMsgHeaderParser
+  // functionality, here (at least initially), we're just interested in checking
+  // the basic argument/return combinations.
+
+  for (var part = 0; part < splitRecipientsTests.length; ++part) {
+    var count = {};
+    print("Test: " + splitRecipientsTests[part].recipients);
+    var result = fields.splitRecipients(splitRecipientsTests[part].recipients,
+                                        splitRecipientsTests[part].emailAddressOnly,
+                                        count);
+
+    do_check_eq(splitRecipientsTests[part].count, count.value);
+    do_check_eq(splitRecipientsTests[part].count, result.length);
+
+    for (var item = 0; item < count.value; ++item)
+      do_check_eq(splitRecipientsTests[part].result[item], result[item]);
+  }
+}