Bug 377319 Provide and use external API version of CaseInsensitiveFindInReadable r=Neil sr=bienvenu
authorJan Horak <jhorak@redhat.com>
Sat, 12 Jun 2010 22:00:56 +0100
changeset 5811 606f1ecc69d9bb5fe4b4b27e439a983de280c180
parent 5810 4dce3652e4874f7b91e9b690825a337a7de38dca
child 5812 86fd73da95aa428b5f1663c8fcd0da1960448159
push idunknown
push userunknown
push dateunknown
reviewersNeil, bienvenu
bugs377319
Bug 377319 Provide and use external API version of CaseInsensitiveFindInReadable r=Neil sr=bienvenu
mailnews/base/src/nsMessenger.cpp
mailnews/base/util/nsMsgUtils.h
mailnews/news/src/nsNewsDownloader.cpp
mailnews/news/src/nsNewsFolder.cpp
mailnews/news/src/nsNntpIncomingServer.cpp
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -634,17 +634,17 @@ nsMessenger::LoadURL(nsIDOMWindowInterna
     NS_ENSURE_SUCCESS(rv, rv);
     file->GetFileSize(&fileSize);
     uriString.Replace(0, 5, NS_LITERAL_STRING("mailbox:"));
     uriString.Append(NS_LITERAL_STRING("&number=0"));
     loadingFromFile = PR_TRUE;
     getDummyMsgHdr = PR_TRUE;
   }
   else if (StringBeginsWith(uriString, NS_LITERAL_STRING("mailbox:")) &&
-           (uriString.Find(NS_LITERAL_STRING(".eml?"), CaseInsensitiveCompare) != -1))
+           (CaseInsensitiveFindInReadable(NS_LITERAL_STRING(".eml?"), uriString)))
   {
     // if we have a mailbox:// url that points to an .eml file, we have to read
     // the file size as well
     uriString.Replace(0, 8, NS_LITERAL_STRING("file:"));
     nsCOMPtr<nsIURI> fileUri;
     rv = NS_NewURI(getter_AddRefs(fileUri), uriString);
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr <nsIFileURL> fileUrl = do_QueryInterface(fileUri, &rv);
--- a/mailnews/base/util/nsMsgUtils.h
+++ b/mailnews/base/util/nsMsgUtils.h
@@ -370,16 +370,18 @@ NS_MSG_BASE PRUint64 ParseUint64Str(cons
 #define AppendUTF16toUTF8(source, dest) \
         (dest).Append(NS_ConvertUTF16toUTF8(source))
 #define AppendUTF8toUTF16(source, dest) \
         (dest).Append(NS_ConvertUTF8toUTF16(source))
 #define AppendASCIItoUTF16(source, dest) \
         (dest).Append(NS_ConvertASCIItoUTF16(source))
 #define Compare(str1, str2, comp) \
         (str1).Compare(str2, comp)
+#define CaseInsensitiveFindInReadable(what, str) \
+        ((str).Find(what, CaseInsensitiveCompare) != kNotFound)
 #define LossyAppendUTF16toASCII(source, dest) \
         (dest).Append(NS_LossyConvertUTF16toASCII(source))
 #define Last() \
         EndReading()[-1]
 #define SetCharAt(ch, index) \
         Replace(index, 1, ch)
 #define NS_NewISupportsArray(result) \
         CallCreateInstance(NS_SUPPORTSARRAY_CONTRACTID, static_cast<nsISupportsArray**>(result))
--- a/mailnews/news/src/nsNewsDownloader.cpp
+++ b/mailnews/news/src/nsNewsDownloader.cpp
@@ -499,17 +499,17 @@ nsresult nsMsgDownloadAllNewsgroups::Adv
     m_currentFolder = nsnull;
   }
 
   *done = PR_FALSE;
 
   if (!m_currentServer)
      rv = AdvanceToNextServer(done);
   else
-    rv = m_serverEnumerator->Next();
+     rv = m_serverEnumerator->Next();
   if (NS_FAILED(rv))
     rv = AdvanceToNextServer(done);
 
   if (NS_SUCCEEDED(rv) && !*done && m_serverEnumerator)
   {
     nsCOMPtr <nsISupports> supports;
     rv = m_serverEnumerator->CurrentItem(getter_AddRefs(supports));
     m_currentFolder = do_QueryInterface(supports);
--- a/mailnews/news/src/nsNewsFolder.cpp
+++ b/mailnews/news/src/nsNewsFolder.cpp
@@ -1863,17 +1863,17 @@ NS_IMETHODIMP nsMsgNewsFolder::GetMessag
   return rv;
 }
 
 NS_IMETHODIMP nsMsgNewsFolder::SetSortOrder(PRInt32 order)
 {
   PRInt32 oldOrder = mSortOrder;
   
   mSortOrder = order;
-  nsCOMPtr<nsIAtom> sortOrderAtom = do_GetAtom("SortOrder");
+  nsCOMPtr<nsIAtom> sortOrderAtom = MsgGetAtom("SortOrder");
   // What to do if the atom can't be allocated?
   NotifyIntPropertyChanged(sortOrderAtom, oldOrder, order);
   
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgNewsFolder::GetSortOrder(PRInt32 *order)
 {
--- a/mailnews/news/src/nsNntpIncomingServer.cpp
+++ b/mailnews/news/src/nsNntpIncomingServer.cpp
@@ -61,16 +61,17 @@
 #include "nsIDOMElement.h"
 #include "nsMsgFolderFlags.h"
 #include "nsMsgI18N.h"
 #include "nsUnicharUtils.h"
 #include "nsISupportsObsolete.h"
 #include "nsILineInputStream.h"
 #include "nsNetUtil.h"
 #include "nsISimpleEnumerator.h"
+#include "nsMsgUtils.h"
 
 #define INVALID_VERSION         0
 #define VALID_VERSION           1
 #define NEW_NEWS_DIR_NAME       "News"
 #define PREF_MAIL_NEWSRC_ROOT   "mail.newsrc_root"
 #define PREF_MAIL_NEWSRC_ROOT_REL "mail.newsrc_root-rel"
 #define PREF_MAILNEWS_VIEW_DEFAULT_CHARSET "mailnews.view_default_charset"
 #define HOSTINFO_FILE_NAME      "hostinfo.dat"
@@ -126,18 +127,18 @@ nsNntpIncomingServer::nsNntpIncomingServ
   mLastGroupDate = 0;
   mUniqueId = 0;
   mHasSeenBeginGroups = PR_FALSE;
   mPostingAllowed = PR_FALSE;
   m_userAuthenticated = PR_FALSE;
   mLastUpdatedTime = 0;
 
   // these atoms are used for subscribe search
-  mSubscribedAtom = do_GetAtom("subscribed");
-  mNntpAtom = do_GetAtom("nntp");
+  mSubscribedAtom = MsgGetAtom("subscribed");
+  mNntpAtom = MsgGetAtom("nntp");
 
   // we have server wide and per group filters
   m_canHaveFilters = PR_TRUE;
 
   SetupNewsrcSaveTimer();
 }
 
 nsNntpIncomingServer::~nsNntpIncomingServer()
@@ -1703,17 +1704,17 @@ buildSubscribeSearchResult(nsCString &aE
     NS_ASSERTION(NS_SUCCEEDED(rv),"AddSubscribeSearchResult failed");
     return PR_TRUE;
 }
 
 nsresult
 nsNntpIncomingServer::AppendIfSearchMatch(nsCString& newsgroupName)
 {
   NS_ConvertUTF8toUTF16 groupName(newsgroupName);
-  if (groupName.Find(mSearchValue, CaseInsensitiveCompare) != kNotFound)
+  if (CaseInsensitiveFindInReadable(mSearchValue, groupName))
       mSubscribeSearchResult.AppendCString(newsgroupName);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNntpIncomingServer::SetSearchValue(const nsAString &searchValue)
 {
     mSearchValue = searchValue;