Bug 377319 Convert mailnews/local to the external API r=Neil sr=bienvenu
authorJan Horak <jhorak@redhat.com>
Sun, 25 Jul 2010 15:44:24 +0100
changeset 6016 96a50f5a6b2d1b145d0a7f7cfc22c049c4c1f9b5
parent 6015 a0e75bd610cfbce6ab3cf60c2fe7e4b7a969780a
child 6017 6368a42a985ad7ad15cb0dd1f014001e5ed80a8b
push idunknown
push userunknown
push dateunknown
reviewersNeil, bienvenu
bugs377319
Bug 377319 Convert mailnews/local to the external API r=Neil sr=bienvenu
mailnews/local/src/nsLocalMailFolder.cpp
mailnews/local/src/nsLocalUndoTxn.cpp
mailnews/local/src/nsLocalUtils.cpp
mailnews/local/src/nsNoIncomingServer.cpp
mailnews/local/src/nsParseMailbox.cpp
mailnews/local/src/nsPop3IncomingServer.cpp
mailnews/local/src/nsPop3Protocol.cpp
mailnews/local/src/nsPop3Service.cpp
mailnews/local/src/nsPop3Sink.cpp
mailnews/local/src/nsRssIncomingServer.cpp
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -742,25 +742,17 @@ nsMsgLocalMailFolder::CreateSubfolderInt
   rv = CreateDirectoryForFolder(getter_AddRefs(path));
   if (NS_FAILED(rv))
     return rv;
 
   //Now we have a valid directory or we have returned.
   //Make sure the new folder name is valid
   nsAutoString safeFolderName(folderName);
   NS_MsgHashIfNecessary(safeFolderName);
-  nsCAutoString nativeFolderName;
-  rv = NS_CopyUnicodeToNative(safeFolderName, nativeFolderName);
-  if (NS_FAILED(rv) || nativeFolderName.IsEmpty()) {
-    ThrowAlertMsg("folderCreationFailed", msgWindow);
-    // I'm returning this value so the dialog stays up
-    return NS_MSG_FOLDER_EXISTS;
-  }
-
-  path->AppendNative(nativeFolderName);
+  path->Append(safeFolderName);
   PRBool exists;
   path->Exists(&exists);
   if (exists) //check this because localized names are different from disk names
   {
     ThrowAlertMsg("folderExists", msgWindow);
     return NS_MSG_FOLDER_EXISTS;
   }
 
@@ -830,28 +822,27 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Comp
     rootFolder->ListDescendents(allDescendents);
     PRUint32 cnt =0;
     rv = allDescendents->Count(&cnt);
     NS_ENSURE_SUCCESS(rv, rv);
     folderArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
     PRUint32 expungedBytes = 0;
     for (PRUint32 i = 0; i < cnt; i++)
     {
-      nsCOMPtr<nsISupports> supports = dont_AddRef(allDescendents->ElementAt(i));
-      nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
+      nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(allDescendents, i);
       NS_ENSURE_SUCCESS(rv, rv);
 
       expungedBytes = 0;
       if (folder)
         rv = folder->GetExpungedBytes(&expungedBytes);
 
       NS_ENSURE_SUCCESS(rv, rv);
 
       if (expungedBytes > 0)
-        rv = folderArray->AppendElement(supports, PR_FALSE);
+        rv = folderArray->AppendElement(folder, PR_FALSE);
     }
     rv = folderArray->GetLength(&cnt);
     NS_ENSURE_SUCCESS(rv,rv);
     if (cnt == 0)
       return NotifyCompactCompleted();
   }
   nsCOMPtr <nsIMsgFolderCompactor> folderCompactor =  do_CreateInstance(NS_MSGLOCALFOLDERCOMPACTOR_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1143,22 +1134,16 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rena
   if (count > 0)
     rv = CreateDirectoryForFolder(getter_AddRefs(dirFile));
 
   // Convert from nsAString to nsCAutoString, as we will call moveToNative(),
   // not moveTo().
 
   nsAutoString safeName(aNewName);
   NS_MsgHashIfNecessary(safeName);
-  nsCAutoString newDiskName;
-  if (NS_FAILED(NS_CopyUnicodeToNative(safeName, newDiskName)))
-    return NS_ERROR_FAILURE;
-
-  nsCAutoString oldLeafName;
-  oldPathFile->GetNativeLeafName(oldLeafName);
 
   if (mName.Equals(aNewName, nsCaseInsensitiveStringComparator()))
   {
     if (msgWindow)
       rv = ThrowAlertMsg("folderExists", msgWindow);
     return NS_MSG_FOLDER_EXISTS;
   }
 
@@ -1171,32 +1156,32 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rena
   if (!isDirectory)
     AddDirectorySeparator(parentPathFile);
 
   rv = CheckIfFolderExists(aNewName, parentFolder, msgWindow);
   if (NS_FAILED(rv))
     return rv;
 
   ForceDBClosed();
-  nsCAutoString newNameDirStr = newDiskName;  //save of dir name before appending .msf
-  rv = oldPathFile->MoveToNative(nsnull, newDiskName);
+  nsAutoString newNameDirStr = safeName;  //save dir name before appending .msf
+  rv = oldPathFile->MoveTo(nsnull, safeName);
   if (NS_FAILED(rv))
   {
     ThrowAlertMsg("folderRenameFailed", msgWindow);
     return rv;
   }
 
-  newDiskName += SUMMARY_SUFFIX;
-  oldSummaryFile->MoveToNative(nsnull, newDiskName);
+  safeName.AppendLiteral(SUMMARY_SUFFIX);
+  oldSummaryFile->MoveTo(nsnull, safeName);
 
   if (count > 0)
   {
     // rename "*.sbd" directory
-    newNameDirStr += ".sbd";
-    dirFile->MoveToNative(nsnull, newNameDirStr);
+    newNameDirStr.AppendLiteral(".sbd");
+    dirFile->MoveTo(nsnull, newNameDirStr);
   }
 
   nsCOMPtr<nsIMsgFolder> newFolder;
   if (parentSupport)
   {
     rv = parentFolder->AddSubfolder(safeName, getter_AddRefs(newFolder));
     if (newFolder)
     {
@@ -1223,17 +1208,17 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rena
       newFolder->SetFlags(mFlags);
       if (parentFolder)
       {
         SetParent(nsnull);
         parentFolder->PropagateDelete(this, PR_FALSE, msgWindow);
         parentFolder->NotifyItemAdded(newFolder);
       }
       SetFilePath(nsnull); // forget our path, since this folder object renamed itself
-      nsCOMPtr<nsIAtom> folderRenameAtom = do_GetAtom("RenameCompleted");
+      nsCOMPtr<nsIAtom> folderRenameAtom = MsgGetAtom("RenameCompleted");
       newFolder->NotifyFolderEvent(folderRenameAtom);
 
       nsCOMPtr<nsIMsgFolderNotificationService> notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
       if (notifier)
         notifier->NotifyFolderRenamed(this, newFolder);
     }
   }
   return rv;
@@ -1684,25 +1669,19 @@ nsMsgLocalMailFolder::CopyMessages(nsIMs
 
   if (!(mFlags & (nsMsgFolderFlags::Trash|nsMsgFolderFlags::Junk)))
     SetMRUTime();
 
   nsCString protocolType;
   rv = srcFolder->GetURI(protocolType);
   protocolType.SetLength(protocolType.FindChar(':'));
 
-#ifdef MOZILLA_INTERNAL_API
   PRBool needOfflineBody = (WeAreOffline() &&
-    (protocolType.LowerCaseEqualsLiteral("imap") ||
-     protocolType.LowerCaseEqualsLiteral("news")));
-#else
-  PRBool needOfflineBody  = (WeAreOffline() &&
-    (protocolType.Equals("imap", CaseInsensitiveCompare) ||
-     protocolType.Equals("news", CaseInsensitiveCompare)));
-#endif
+    (MsgLowerCaseEqualsLiteral(protocolType, "imap") ||
+     MsgLowerCaseEqualsLiteral(protocolType, "news")));
   PRInt64 totalMsgSize = 0;
   PRUint32 numMessages = 0;
   messages->GetLength(&numMessages);
   for (PRUint32 i = 0; i < numMessages; i++)
   {
     nsCOMPtr<nsIMsgDBHdr> message(do_QueryElementAt(messages, i, &rv));
     if (NS_SUCCEEDED(rv) && message)
     {
@@ -1781,21 +1760,17 @@ nsMsgLocalMailFolder::CopyMessages(nsIMs
 
   if (NS_FAILED(rv))
   {
     ThrowAlertMsg("operationFailedFolderBusy", msgWindow);
     (void) OnCopyCompleted(srcSupport, PR_FALSE);
     return rv;
   }
 
-#ifdef MOZILLA_INTERNAL_API
-  if (!protocolType.LowerCaseEqualsLiteral("mailbox"))
-#else
-  if (!protocolType.Equals("mailbox", CaseInsensitiveCompare))
-#endif
+  if (!MsgLowerCaseEqualsLiteral(protocolType, "mailbox"))
   {
     mCopyState->m_dummyEnvelopeNeeded = PR_TRUE;
     nsParseMailMessageState* parseMsgState = new nsParseMailMessageState();
     if (parseMsgState)
     {
       nsCOMPtr<nsIMsgDatabase> msgDb;
       mCopyState->m_parseMsgState = parseMsgState;
       GetDatabaseWOReparse(getter_AddRefs(msgDb));
@@ -1819,23 +1794,18 @@ nsMsgLocalMailFolder::CopyMessages(nsIMs
           msgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
       }
       else
         msgTxn->SetTransactionType(nsIMessenger::eCopyMsg);
       msgTxn.swap(mCopyState->m_undoMsgTxn);
     }
   }
 
-#ifdef MOZILLA_INTERNAL_API
-  if (numMsgs > 1 && ((protocolType.LowerCaseEqualsLiteral("imap") && !WeAreOffline()) || 
-                      protocolType.LowerCaseEqualsLiteral("mailbox")))
-#else
-  if (numMsgs > 1 && ((protocolType.Equals("imap", CaseInsensitiveCompare) && !WeAreOffline()) || 
-                      protocolType.Equals("mailbox", CaseInsensitiveCompare)))
-#endif
+  if (numMsgs > 1 && ((MsgLowerCaseEqualsLiteral(protocolType, "imap") && !WeAreOffline()) ||
+                      MsgLowerCaseEqualsLiteral(protocolType, "mailbox")))
   {
     mCopyState->m_copyingMultipleMessages = PR_TRUE;
     rv = CopyMessagesTo(mCopyState->m_messages, keyArray, msgWindow, this, isMove);
     if (NS_FAILED(rv))
     {
       NS_ERROR("copy message failed");
       (void) OnCopyCompleted(srcSupport, PR_FALSE);
     }
@@ -3617,17 +3587,17 @@ nsMsgLocalMailFolder::NotifyCompactCompl
 {
   mExpungedBytes = 0;
   m_newMsgs.Clear(); // if compacted, m_newMsgs probably aren't valid.
   // if compacted, processing flags probably also aren't valid.
   ClearProcessingFlags();
   (void) RefreshSizeOnDisk();
   (void) CloseDBIfFolderNotOpen();
   nsCOMPtr <nsIAtom> compactCompletedAtom;
-  compactCompletedAtom = do_GetAtom("CompactCompleted");
+  compactCompletedAtom = MsgGetAtom("CompactCompleted");
   NotifyFolderEvent(compactCompletedAtom);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgLocalMailFolder::Shutdown(PRBool shutdownChildren)
 {
   mInitialized = PR_FALSE;
   return nsMsgDBFolder::Shutdown(shutdownChildren);
--- a/mailnews/local/src/nsLocalUndoTxn.cpp
+++ b/mailnews/local/src/nsLocalUndoTxn.cpp
@@ -46,16 +46,17 @@
 #include "nsIMsgLocalMailFolder.h"
 #include "nsIMsgMailSession.h"
 #include "nsIMsgFolderNotificationService.h"
 #include "nsThreadUtils.h"
 #include "nsIMsgDatabase.h"
 #include "nsIMutableArray.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
+#include "nsMsgUtils.h"
 
 nsLocalMoveCopyMsgTxn::nsLocalMoveCopyMsgTxn()  : m_srcIsImap4(PR_FALSE)
 {
 }
 
 nsLocalMoveCopyMsgTxn::~nsLocalMoveCopyMsgTxn()
 {
 }
@@ -69,21 +70,17 @@ nsLocalMoveCopyMsgTxn::Init(nsIMsgFolder
     rv = SetDstFolder(dstFolder);
     m_isMove = isMove;
 
     mUndoFolderListener = nsnull;
 
     nsCString protocolType;
     rv = srcFolder->GetURI(protocolType);
     protocolType.SetLength(protocolType.FindChar(':'));
-#ifdef MOZILLA_INTERNAL_API
-    if (protocolType.LowerCaseEqualsLiteral("imap"))
-#else
-    if (protocolType.Equals("imap", CaseInsensitiveCompare))
-#endif
+    if (MsgLowerCaseEqualsLiteral(protocolType, "imap"))
       m_srcIsImap4 = PR_TRUE;
     return nsMsgTxn::Init();
 }
 nsresult 
 nsLocalMoveCopyMsgTxn::GetSrcIsImap(PRBool *isImap)
 {
   *isImap = m_srcIsImap4;
   return NS_OK;
@@ -150,22 +147,17 @@ nsLocalMoveCopyMsgTxn::UndoImapDeleteFla
     PRUint32 i, count = keyArray.Length();
     urlListener = do_QueryInterface(folder, &rv);
     for (i=0; i < count; i++)
     {
       if (!msgIds.IsEmpty())
           msgIds.Append(',');
       msgIds.AppendInt((PRInt32) keyArray[i]);
     }
-    nsIThread *thread;
-#ifdef MOZILLA_INTERNAL_API    
-    thread = NS_GetCurrentThread();
-#else
-    NS_GetCurrentThread(&thread);
-#endif
+    nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
     if (thread)
     {
       // This is to make sure that we are in the selected state
       // when executing the imap url; we don't want to load the
       // folder so use lite select to do the trick
       rv = imapService->LiteSelectFolder(thread, folder,
                                          urlListener, nsnull, nsnull);
       if (!deleteFlag)
--- a/mailnews/local/src/nsLocalUtils.cpp
+++ b/mailnews/local/src/nsLocalUtils.cpp
@@ -268,13 +268,13 @@ nsresult nsCreateLocalBaseMessageURI(con
 
   return NS_OK;
 }
 
 void nsEscapeNativePath(nsCString& nativePath)
 {
 #if defined(XP_WIN) || defined(XP_OS2)
   nativePath.Insert('/', 0);
-  nativePath.ReplaceChar('\\', '/');
+  MsgReplaceChar(nativePath, '\\', '/');
   if (nativePath.CharAt(2) == ':')
     nativePath.SetCharAt('|', 2);
 #endif
 }
--- a/mailnews/local/src/nsNoIncomingServer.cpp
+++ b/mailnews/local/src/nsNoIncomingServer.cpp
@@ -44,16 +44,17 @@
 #include "nsMsgLocalCID.h"
 #include "nsMsgFolderFlags.h"
 #include "nsIMsgLocalMailFolder.h"
 #include "nsIMsgMailSession.h"
 #include "nsMsgBaseCID.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIPop3IncomingServer.h"
 #include "nsServiceManagerUtils.h"
+#include "nsMsgUtils.h"
 
 NS_IMPL_ISUPPORTS_INHERITED2(nsNoIncomingServer,
                             nsMsgIncomingServer,
                             nsINoIncomingServer,
                             nsILocalMailIncomingServer)
 
 nsNoIncomingServer::nsNoIncomingServer()
 {
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -1129,17 +1129,17 @@ SEARCH_NEWLINE:
         // parse Received: header for date.
         // We trust the first header as that is closest to recipient,
         // and less likely to be spoofed.
         nsCAutoString receivedHdr(header->value, header->length);
         PRInt32 lastSemicolon = receivedHdr.RFindChar(';');
         if (lastSemicolon != -1)
         {
           nsCAutoString receivedDate;
-          receivedDate = StringTail(receivedHdr, receivedHdr.Length() - lastSemicolon - 1);
+          receivedDate = Substring(receivedHdr, lastSemicolon + 1);
           receivedDate.Trim(" \t\b\r\n");
           PRTime resultTime;
           if (PR_ParseTimeString (receivedDate.get(), PR_FALSE, &resultTime) == PR_SUCCESS)
             m_receivedTime = resultTime;
         }
       }
     }
   }
@@ -2010,23 +2010,18 @@ NS_IMETHODIMP nsParseNewMailState::Apply
           if (NS_SUCCEEDED(rv) && trash)
             rv = trash->GetURI(actionTargetFolderUri);
 
           msgHdr->OrFlags(nsMsgMessageFlags::Read, &newFlags); // mark read in trash.
           msgIsNew = PR_FALSE;
         }
       case nsMsgFilterAction::MoveToFolder:
         // if moving to a different file, do it.
-#ifdef MOZILLA_INTERNAL_API
         if (actionTargetFolderUri.get() && !m_inboxUri.Equals(actionTargetFolderUri,
                                                               nsCaseInsensitiveCStringComparator()))
-#else
-        if (actionTargetFolderUri.get() && !m_inboxUri.Equals(actionTargetFolderUri,
-                                                              CaseInsensitiveCompare))
-#endif
         {
           nsresult err;
           nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &err));
           NS_ENSURE_SUCCESS(err, err);
           nsCOMPtr<nsIRDFResource> res;
           err = rdf->GetResource(actionTargetFolderUri, getter_AddRefs(res));
           if (NS_FAILED(err))
             return err;
--- a/mailnews/local/src/nsPop3IncomingServer.cpp
+++ b/mailnews/local/src/nsPop3IncomingServer.cpp
@@ -49,16 +49,17 @@
 #include "nsMsgFolderFlags.h"
 #include "nsPop3Protocol.h"
 #include "nsIMsgLocalMailFolder.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIMutableArray.h"
 #include "nsMsgUtils.h"
+#include "nsComponentManagerUtils.h"
 
 static NS_DEFINE_CID(kCPop3ServiceCID, NS_POP3SERVICE_CID);
 
 class nsPop3GetMailChainer : public nsIUrlListener
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIURLLISTENER
@@ -249,18 +250,18 @@ NS_IMETHODIMP nsPop3IncomingServer::SetD
     // use GetRootFolder, because that returns the real
     // root, not the deferred to root.
     rv = GetRootFolder(getter_AddRefs(rootFolder));
     if (rootFolder)
     {
       // if isDeferred state has changed, send notification
       if (aAccountKey.IsEmpty() != deferredToAccount.IsEmpty())
       {
-        nsCOMPtr <nsIAtom> deferAtom = getter_AddRefs(NS_NewAtom("isDeferred"));
-        nsCOMPtr <nsIAtom> canFileAtom = getter_AddRefs(NS_NewAtom("CanFileMessages"));
+        nsCOMPtr <nsIAtom> deferAtom = MsgGetAtom("isDeferred");
+        nsCOMPtr <nsIAtom> canFileAtom = MsgGetAtom("CanFileMessages");
         folderListenerManager->OnItemBoolPropertyChanged(rootFolder, deferAtom,
                   !deferredToAccount.IsEmpty(), deferredToAccount.IsEmpty());
         folderListenerManager->OnItemBoolPropertyChanged(rootFolder, canFileAtom,
                   deferredToAccount.IsEmpty(), !deferredToAccount.IsEmpty());
 
         // this hack causes the account manager ds to send notifications to the
         // xul content builder that make the changed acct appear or disappear
         // from the folder pane and related menus.
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -555,17 +555,17 @@ nsresult nsPop3Protocol::Initialize(nsIU
         nsCOMPtr<nsIDocShell> docshell;
         msgwin->GetRootDocShell(getter_AddRefs(docshell));
         ir = do_QueryInterface(docshell);
         nsCOMPtr<nsIInterfaceRequestor> notificationCallbacks;
         msgwin->GetNotificationCallbacks(getter_AddRefs(notificationCallbacks));
         if (notificationCallbacks)
         {
           nsCOMPtr<nsIInterfaceRequestor> aggregrateIR;
-          NS_NewInterfaceRequestorAggregation(notificationCallbacks, ir, getter_AddRefs(aggregrateIR));
+          MsgNewInterfaceRequestorAggregation(notificationCallbacks, ir, getter_AddRefs(aggregrateIR));
           ir = aggregrateIR;
         }
       }
     }
 
     PRInt32 port = 0;
     nsCString hostName;
     aURL->GetPort(&port);
@@ -1487,37 +1487,37 @@ PRInt32 nsPop3Protocol::CapaResponse(nsI
     }
     else
     // see RFC 2449, chapter 6.3
     if (!PL_strncasecmp(line, "SASL", 4) && strlen(line) > 6)
     {
         nsCAutoString responseLine;
         responseLine.Assign(line + 5);
 
-        if (responseLine.Find("PLAIN", PR_TRUE) >= 0)
+        if (responseLine.Find("PLAIN", CaseInsensitiveCompare) >= 0)
             SetCapFlag(POP3_HAS_AUTH_PLAIN);
 
-        if (responseLine.Find("LOGIN", PR_TRUE) >= 0)
+        if (responseLine.Find("LOGIN", CaseInsensitiveCompare) >= 0)
             SetCapFlag(POP3_HAS_AUTH_LOGIN);
 
-        if (responseLine.Find("GSSAPI", PR_TRUE) >= 0)
+        if (responseLine.Find("GSSAPI", CaseInsensitiveCompare) >= 0)
             SetCapFlag(POP3_HAS_AUTH_GSSAPI);
 
         nsresult rv;
         nsCOMPtr<nsISignatureVerifier> verifier = do_GetService(SIGNATURE_VERIFIER_CONTRACTID, &rv);
         // this checks if psm is installed...
         if (NS_SUCCEEDED(rv))
         {
-            if (responseLine.Find("CRAM-MD5", PR_TRUE) >= 0)
+            if (responseLine.Find("CRAM-MD5", CaseInsensitiveCompare) >= 0)
                 SetCapFlag(POP3_HAS_AUTH_CRAM_MD5);
 
-            if (responseLine.Find("NTLM", PR_TRUE) >= 0)
+            if (responseLine.Find("NTLM", CaseInsensitiveCompare) >= 0)
                 SetCapFlag(POP3_HAS_AUTH_NTLM);
 
-            if (responseLine.Find("MSN", PR_TRUE) >= 0)
+            if (responseLine.Find("MSN", CaseInsensitiveCompare) >= 0)
                 SetCapFlag(POP3_HAS_AUTH_NTLM|POP3_HAS_AUTH_MSN);
         }
 
         m_pop3Server->SetPop3CapabilityFlags(m_pop3ConData->capability_flags);
     }
 
     PR_Free(line);
     PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("capa processed"));
@@ -4153,17 +4153,17 @@ NS_IMETHODIMP nsPop3Protocol::CheckMessa
    contains the validated substring of m_commandResponse. */
 nsresult nsPop3Protocol::GetApopTimestamp()
 {
   PRInt32 startMark = m_commandResponse.Length(), endMark = -1;
 
   while (PR_TRUE)
   {
     // search for previous <
-    if ((startMark = m_commandResponse.RFindChar('<', startMark - 1)) < 0)
+    if ((startMark = MsgRFindChar(m_commandResponse, '<', startMark - 1)) < 0)
       return NS_ERROR_FAILURE;
 
     // search for next >
     if ((endMark = m_commandResponse.FindChar('>', startMark)) < 0)
       continue;
 
     // look for an @ between start and end as a raw test
     PRInt32 at = m_commandResponse.FindChar('@', startMark);
--- a/mailnews/local/src/nsPop3Service.cpp
+++ b/mailnews/local/src/nsPop3Service.cpp
@@ -347,17 +347,17 @@ NS_IMETHODIMP nsPop3Service::NewURI(cons
                                     const char *aOriginCharset, // ignored
                                     nsIURI *aBaseURI,
                                     nsIURI **_retval)
 {
     nsresult rv = NS_ERROR_FAILURE;
     if (!_retval) return rv;
     nsCAutoString folderUri(aSpec);
     nsCOMPtr<nsIRDFResource> resource;
-    PRInt32 offset = folderUri.Find("?");
+    PRInt32 offset = folderUri.FindChar('?');
     if (offset != -1)
         folderUri.SetLength(offset);
 
     const char *uidl = PL_strstr(nsCString(aSpec).get(), "uidl=");
     if (!uidl) return NS_ERROR_FAILURE;
 
     nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv));
     if (NS_FAILED(rv)) return rv;
@@ -445,17 +445,17 @@ NS_IMETHODIMP nsPop3Service::NewURI(cons
         if (NS_SUCCEEDED(rv))
         {
           nsCAutoString messageUri (aSpec);
           if (!strncmp(messageUri.get(), "mailbox:", 8))
             messageUri.Replace(0, 8, "mailbox-message:");
           offset = messageUri.Find("?number=");
           if (offset != -1)
             messageUri.Replace(offset, 8, "#");
-          offset = messageUri.Find("&");
+          offset = messageUri.FindChar('&');
           if (offset != -1)
             messageUri.SetLength(offset);
           popurl->SetMessageUri(messageUri.get());
           nsCOMPtr<nsIPop3Sink> pop3Sink;
           rv = popurl->GetPop3Sink(getter_AddRefs(pop3Sink));
           if (NS_SUCCEEDED(rv))
             pop3Sink->SetBuildMessageUri(PR_TRUE);
         }
--- a/mailnews/local/src/nsPop3Sink.cpp
+++ b/mailnews/local/src/nsPop3Sink.cpp
@@ -800,17 +800,17 @@ nsresult nsPop3Sink::HandleTempDownloadF
 
 NS_IMETHODIMP
 nsPop3Sink::IncorporateComplete(nsIMsgWindow *aMsgWindow, PRInt32 aSize)
 {
   if (m_buildMessageUri && !m_baseMessageUri.IsEmpty())
   {
     PRUint32 msgKey;
     m_newMailParser->GetEnvelopePos(&msgKey);
-    m_messageUri.SetLength(0);
+    m_messageUri.Truncate();
     nsBuildLocalMessageURI(m_baseMessageUri.get(), msgKey, m_messageUri);
   }
 
   nsresult rv = WriteLineToMailbox(MSG_LINEBREAK);
   if (NS_FAILED(rv)) return rv;
   PRBool leaveOnServer = PR_FALSE;
   m_popServer->GetLeaveMessagesOnServer(&leaveOnServer);
   // aSize is only set for partial messages. Skip the flush for partials.
--- a/mailnews/local/src/nsRssIncomingServer.cpp
+++ b/mailnews/local/src/nsRssIncomingServer.cpp
@@ -42,16 +42,18 @@
 #include "nsINewsBlogFeedDownloader.h"
 #include "nsMsgBaseCID.h"
 #include "nsILocalFile.h"
 #include "nsIMsgFolderNotificationService.h"
 
 #include "nsIMsgLocalMailFolder.h"
 #include "nsIDBFolderInfo.h"
 #include "nsServiceManagerUtils.h"
+#include "nsComponentManagerUtils.h"
+#include "nsMsgUtils.h"
 
 nsrefcnt nsRssIncomingServer::gInstanceCount    = 0;
 
 NS_IMPL_ISUPPORTS_INHERITED3(nsRssIncomingServer,
                              nsMsgIncomingServer,
                              nsIRssIncomingServer,
                              nsIMsgFolderListener,
                              nsILocalMailIncomingServer)
@@ -166,18 +168,17 @@ NS_IMETHODIMP nsRssIncomingServer::Perfo
   allDescendents->Count(&cnt);
 
   nsCOMPtr<nsISupports> supports;
   nsCOMPtr<nsIUrlListener> urlListener;
   nsCOMPtr<nsIMsgFolder> rssFolder;
 
   for (PRUint32 index = 0; index < cnt; index++)
   {
-    supports = getter_AddRefs(allDescendents->ElementAt(index));
-    rssFolder = do_QueryInterface(supports, &rv);
+    supports = do_QueryElementAt(allDescendents, index);
     if (rssFolder)
     {
       urlListener = do_QueryInterface(rssFolder);
       // WARNING: Never call GetNewMail with the root folder or you will trigger an infinite loop...
       GetNewMail(aMsgWindow, urlListener, rssFolder, nsnull);
     }
   }
 
@@ -339,17 +340,16 @@ nsresult nsRssIncomingServer::FolderChan
       PRUint32 cnt = 0;
       allDescendents->Count(&cnt);
 
       nsCOMPtr<nsISupports> supports;
       nsCOMPtr<nsIMsgFolder> rssFolder;
 
       for (PRUint32 index = 0; index < cnt; index++)
       {
-        supports = getter_AddRefs(allDescendents->ElementAt(index));
-        rssFolder = do_QueryInterface(supports, &rv);
+        rssFolder = do_QueryElementAt(allDescendents, index, &rv);
         if (rssFolder)
           rssDownloader->UpdateSubscriptionsDS(rssFolder, aUnsubscribe);
       }
     }
   }
   return rv;
 }