diff --git a/mail/base/content/ABSearchDialog.js b/mail/base/content/ABSearchDialog.js index c49e21e37a..a13c1f1f05 100644 --- a/mail/base/content/ABSearchDialog.js +++ b/mail/base/content/ABSearchDialog.js @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Components.utils.import("resource:///modules/ABQueryUtils.jsm"); +Components.utils.import("resource:///modules/iteratorUtils.js"); Components.utils.import("resource:///modules/mailServices.js"); Components.utils.import("resource://gre/modules/PluralForm.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); @@ -178,11 +179,7 @@ function onSearch() var searchUri = currentAbURI + "?("; - var count = gSearchSession.searchTerms.Count(); - - for (var i=0; i m_searchTerms; /* linked list of criteria terms */ + nsCOMPtr m_searchTerms; /* linked list of criteria terms */ bool m_abortCalled; nsString m_defaultCharset; bool m_forceAsciiSearch; static nsresult EncodeImap (char **ppEncoding, - nsISupportsArray *searchTerms, + nsIArray *searchTerms, const char16_t *srcCharset, const char16_t *destCharset, bool reallyDredd = false); diff --git a/mailnews/base/search/public/nsMsgSearchScopeTerm.h b/mailnews/base/search/public/nsMsgSearchScopeTerm.h index 74afd8d19d..a02e3f1445 100644 --- a/mailnews/base/search/public/nsMsgSearchScopeTerm.h +++ b/mailnews/base/search/public/nsMsgSearchScopeTerm.h @@ -26,7 +26,7 @@ public: NS_DECL_NSIMSGSEARCHSCOPETERM nsresult TimeSlice (bool *aDone); - nsresult InitializeAdapter (nsISupportsArray *termList); + nsresult InitializeAdapter (nsIArray *termList); char *GetStatusBarName (); diff --git a/mailnews/base/search/src/nsMsgFilter.cpp b/mailnews/base/search/src/nsMsgFilter.cpp index e94240f299..df1882980c 100644 --- a/mailnews/base/search/src/nsMsgFilter.cpp +++ b/mailnews/base/search/src/nsMsgFilter.cpp @@ -6,6 +6,7 @@ // this file implements the nsMsgFilter interface #include "msgCore.h" +#include "nsArray.h" #include "nsMsgBaseCID.h" #include "nsIMsgHdr.h" #include "nsMsgFilterList.h" // for kFileVersion @@ -17,13 +18,13 @@ #include "nsIMsgIncomingServer.h" #include "nsMsgSearchValue.h" #include "nsMsgI18N.h" +#include "nsIMutableArray.h" #include "nsIOutputStream.h" #include "nsIStringBundle.h" #include "nsDateTimeFormatCID.h" #include "nsComponentManagerUtils.h" #include "nsServiceManagerUtils.h" #include "nsIMsgFilterService.h" -#include "nsIMutableArray.h" #include "prmem.h" #include "mozilla/ArrayUtils.h" #include "mozilla/Services.h" @@ -172,9 +173,8 @@ nsMsgFilter::nsMsgFilter(): m_filterList(nullptr), m_expressionTree(nullptr) { - nsresult rv = NS_NewISupportsArray(getter_AddRefs(m_termList)); - if (NS_FAILED(rv)) - NS_ASSERTION(false, "Failed to allocate a nsISupportsArray for nsMsgFilter"); + m_termList = nsArray::Create(); + NS_ASSERTION(m_termList, "Failed to allocate a nsIMutableArray for m_termList"); m_type = nsMsgFilterType::InboxRule | nsMsgFilterType::Manual; } @@ -245,7 +245,7 @@ NS_IMETHODIMP nsMsgFilter::AppendTerm(nsIMsgSearchTerm * aTerm) // invalidate expression tree if we're changing the terms delete m_expressionTree; m_expressionTree = nullptr; - return m_termList->AppendElement(static_cast(aTerm)); + return m_termList->AppendElement(aTerm, /* weak = */ false); } NS_IMETHODIMP @@ -442,7 +442,7 @@ NS_IMETHODIMP nsMsgFilter::GetTerm(int32_t termIndex, return NS_OK; } -NS_IMETHODIMP nsMsgFilter::GetSearchTerms(nsISupportsArray **aResult) +NS_IMETHODIMP nsMsgFilter::GetSearchTerms(nsIMutableArray **aResult) { NS_ENSURE_ARG_POINTER(aResult); // caller can change m_termList, which can invalidate m_expressionTree. @@ -452,7 +452,7 @@ NS_IMETHODIMP nsMsgFilter::GetSearchTerms(nsISupportsArray **aResult) return NS_OK; } -NS_IMETHODIMP nsMsgFilter::SetSearchTerms(nsISupportsArray *aSearchList) +NS_IMETHODIMP nsMsgFilter::SetSearchTerms(nsIMutableArray *aSearchList) { delete m_expressionTree; m_expressionTree = nullptr; diff --git a/mailnews/base/search/src/nsMsgFilter.h b/mailnews/base/search/src/nsMsgFilter.h index 077baa2ffd..09d05da511 100644 --- a/mailnews/base/search/src/nsMsgFilter.h +++ b/mailnews/base/search/src/nsMsgFilter.h @@ -11,6 +11,7 @@ #include "nsIMsgFilter.h" #include "nsIMsgSearchScopeTerm.h" #include "nsMsgSearchBoolExpression.h" +#include "nsIMutableArray.h" #include "nsIDateTimeFormat.h" #include "nsIMsgFilterCustomAction.h" @@ -92,7 +93,7 @@ protected: bool m_temporary; bool m_unparseable; nsIMsgFilterList *m_filterList; /* owning filter list */ - nsCOMPtr m_termList; /* linked list of criteria terms */ + nsCOMPtr m_termList; /* linked list of criteria terms */ nsCOMPtr m_scope; /* default for mail rules is inbox, but news rules could have a newsgroup - LDAP would be invalid */ nsTArray > m_actionList; diff --git a/mailnews/base/search/src/nsMsgFilterList.cpp b/mailnews/base/search/src/nsMsgFilterList.cpp index d5b93fdc26..c4e8b0daf6 100644 --- a/mailnews/base/search/src/nsMsgFilterList.cpp +++ b/mailnews/base/search/src/nsMsgFilterList.cpp @@ -1146,11 +1146,11 @@ nsresult nsMsgFilterList::ComputeArbitraryHeaders() rv = GetFilterAt(index, getter_AddRefs(filter)); if (!(NS_SUCCEEDED(rv) && filter)) continue; - nsCOMPtr searchTerms; - uint32_t numSearchTerms=0; + nsCOMPtr searchTerms; + uint32_t numSearchTerms = 0; filter->GetSearchTerms(getter_AddRefs(searchTerms)); if (searchTerms) - searchTerms->Count(&numSearchTerms); + searchTerms->GetLength(&numSearchTerms); for (uint32_t i = 0; i < numSearchTerms; i++) { filter->GetTerm(i, &attrib, nullptr, nullptr, nullptr, arbitraryHeader); diff --git a/mailnews/base/search/src/nsMsgFilterService.cpp b/mailnews/base/search/src/nsMsgFilterService.cpp index 9b2d50d029..a07dd84873 100644 --- a/mailnews/base/search/src/nsMsgFilterService.cpp +++ b/mailnews/base/search/src/nsMsgFilterService.cpp @@ -383,7 +383,7 @@ nsresult nsMsgFilterAfterTheFact::RunNextFilter() rv = m_filters->GetFilterAt(m_curFilterIndex++, getter_AddRefs(m_curFilter)); CONTINUE_IF_FAILURE(rv, "Could not get filter at index"); - nsCOMPtr searchTerms; + nsCOMPtr searchTerms; rv = m_curFilter->GetSearchTerms(getter_AddRefs(searchTerms)); CONTINUE_IF_FAILURE(rv, "Could not get searchTerms"); @@ -393,8 +393,8 @@ nsresult nsMsgFilterAfterTheFact::RunNextFilter() BREAK_IF_FAILURE(rv, "Failed to get search session"); nsMsgSearchScopeValue searchScope = nsMsgSearchScope::offlineMail; - uint32_t termCount; - searchTerms->Count(&termCount); + uint32_t termCount = 0; + searchTerms->GetLength(&termCount); for (uint32_t termIndex = 0; termIndex < termCount; termIndex++) { nsCOMPtr term; diff --git a/mailnews/base/search/src/nsMsgImapSearch.cpp b/mailnews/base/search/src/nsMsgImapSearch.cpp index 5b3b2698ad..cb828195ee 100644 --- a/mailnews/base/search/src/nsMsgImapSearch.cpp +++ b/mailnews/base/search/src/nsMsgImapSearch.cpp @@ -10,18 +10,11 @@ #include "nsIMsgHdr.h" #include "nsMsgSearchImap.h" #include "prmem.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIArray.h" // Implementation of search for IMAP mail folders -nsMsgSearchOnlineMail::nsMsgSearchOnlineMail (nsMsgSearchScopeTerm *scope, nsISupportsArray *termList) : nsMsgSearchAdapter (scope, termList) +nsMsgSearchOnlineMail::nsMsgSearchOnlineMail (nsMsgSearchScopeTerm *scope, nsIArray *termList) : nsMsgSearchAdapter (scope, termList) { } @@ -83,7 +76,7 @@ nsresult nsMsgSearchOnlineMail::Search (bool *aDone) } nsresult nsMsgSearchOnlineMail::Encode (nsCString& pEncoding, - nsISupportsArray *searchTerms, + nsIArray *searchTerms, const char16_t *destCharset) { nsCString imapTerms; @@ -95,7 +88,7 @@ nsresult nsMsgSearchOnlineMail::Encode (nsCString& pEncoding, if (true) // !(srcCharset & CODESET_MASK == STATEFUL || srcCharset & CODESET_MASK == WIDECHAR) ) //assume all single/multiple bytes charset has ascii as subset { uint32_t termCount; - searchTerms->Count(&termCount); + searchTerms->GetLength(&termCount); uint32_t i = 0; for (i = 0; i < termCount && asciiOnly; i++) diff --git a/mailnews/base/search/src/nsMsgLocalSearch.cpp b/mailnews/base/search/src/nsMsgLocalSearch.cpp index 3ce510b6dd..888928b34e 100644 --- a/mailnews/base/search/src/nsMsgLocalSearch.cpp +++ b/mailnews/base/search/src/nsMsgLocalSearch.cpp @@ -14,14 +14,7 @@ #include "nsMsgSearchTerm.h" #include "nsMsgResultElement.h" #include "nsIDBFolderInfo.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIArray.h" #include "nsMsgBaseCID.h" #include "nsMsgSearchValue.h" #include "nsIMsgLocalMailFolder.h" @@ -237,7 +230,7 @@ void nsMsgSearchBoolExpression::GenerateEncodeStr(nsCString * buffer) NS_IMPL_ISUPPORTS_INHERITED(nsMsgSearchOfflineMail, nsMsgSearchAdapter, nsIUrlListener) -nsMsgSearchOfflineMail::nsMsgSearchOfflineMail (nsIMsgSearchScopeTerm *scope, nsISupportsArray *termList) : nsMsgSearchAdapter (scope, termList) +nsMsgSearchOfflineMail::nsMsgSearchOfflineMail (nsIMsgSearchScopeTerm *scope, nsIArray *termList) : nsMsgSearchAdapter (scope, termList) { } @@ -310,7 +303,7 @@ nsresult nsMsgSearchOfflineMail::OpenSummaryFile () nsresult nsMsgSearchOfflineMail::MatchTermsForFilter(nsIMsgDBHdr *msgToMatch, - nsISupportsArray *termList, + nsIArray *termList, const char *defaultCharset, nsIMsgSearchScopeTerm * scope, nsIMsgDatabase * db, @@ -325,7 +318,7 @@ nsMsgSearchOfflineMail::MatchTermsForFilter(nsIMsgDBHdr *msgToMatch, // static method which matches a header against a list of search terms. nsresult nsMsgSearchOfflineMail::MatchTermsForSearch(nsIMsgDBHdr *msgToMatch, - nsISupportsArray* termList, + nsIArray* termList, const char *defaultCharset, nsIMsgSearchScopeTerm *scope, nsIMsgDatabase *db, @@ -336,7 +329,7 @@ nsMsgSearchOfflineMail::MatchTermsForSearch(nsIMsgDBHdr *msgToMatch, return MatchTerms(msgToMatch, termList, defaultCharset, scope, db, nullptr, 0, false, aExpressionTree, pResult); } -nsresult nsMsgSearchOfflineMail::ConstructExpressionTree(nsISupportsArray * termList, +nsresult nsMsgSearchOfflineMail::ConstructExpressionTree(nsIArray *termList, uint32_t termCount, uint32_t &aStartPosInList, nsMsgSearchBoolExpression ** aExpressionTree) @@ -664,7 +657,7 @@ nsresult nsMsgSearchOfflineMail::ProcessSearchTerm(nsIMsgDBHdr *msgToMatch, } nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch, - nsISupportsArray * termList, + nsIArray *termList, const char *defaultCharset, nsIMsgSearchScopeTerm * scope, nsIMsgDatabase * db, @@ -681,7 +674,7 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch, { uint32_t initialPos = 0; uint32_t count; - termList->Count(&count); + termList->GetLength(&count); err = ConstructExpressionTree(termList, count, initialPos, aExpressionTree); if (NS_FAILED(err)) return err; @@ -824,7 +817,7 @@ NS_IMETHODIMP nsMsgSearchOfflineMail::OnStopRunningUrl(nsIURI *url, nsresult aEx return NS_OK; } -nsMsgSearchOfflineNews::nsMsgSearchOfflineNews (nsIMsgSearchScopeTerm *scope, nsISupportsArray *termList) : nsMsgSearchOfflineMail (scope, termList) +nsMsgSearchOfflineNews::nsMsgSearchOfflineNews (nsIMsgSearchScopeTerm *scope, nsIArray *termList) : nsMsgSearchOfflineMail (scope, termList) { } diff --git a/mailnews/base/search/src/nsMsgLocalSearch.h b/mailnews/base/search/src/nsMsgLocalSearch.h index 020d7b5797..1ea2377a86 100644 --- a/mailnews/base/search/src/nsMsgLocalSearch.h +++ b/mailnews/base/search/src/nsMsgLocalSearch.h @@ -24,7 +24,7 @@ class nsMsgSearchBoolExpression; class nsMsgSearchOfflineMail : public nsMsgSearchAdapter, public nsIUrlListener { public: - nsMsgSearchOfflineMail (nsIMsgSearchScopeTerm*, nsISupportsArray *); + nsMsgSearchOfflineMail (nsIMsgSearchScopeTerm*, nsIArray *); NS_DECL_ISUPPORTS_INHERITED @@ -36,7 +36,7 @@ public: NS_IMETHOD AddResultElement (nsIMsgDBHdr *) override; static nsresult MatchTermsForFilter(nsIMsgDBHdr * msgToMatch, - nsISupportsArray *termList, + nsIArray *termList, const char *defaultCharset, nsIMsgSearchScopeTerm *scope, nsIMsgDatabase * db, @@ -46,7 +46,7 @@ public: bool *pResult); static nsresult MatchTermsForSearch(nsIMsgDBHdr * msgTomatch, - nsISupportsArray * termList, + nsIArray *termList, const char *defaultCharset, nsIMsgSearchScopeTerm *scope, nsIMsgDatabase *db, @@ -67,7 +67,7 @@ public: protected: virtual ~nsMsgSearchOfflineMail(); static nsresult MatchTerms(nsIMsgDBHdr *msgToMatch, - nsISupportsArray *termList, + nsIArray *termList, const char *defaultCharset, nsIMsgSearchScopeTerm *scope, nsIMsgDatabase * db, @@ -77,7 +77,7 @@ protected: nsMsgSearchBoolExpression ** aExpressionTree, bool *pResult); - static nsresult ConstructExpressionTree(nsISupportsArray * termList, + static nsresult ConstructExpressionTree(nsIArray *termList, uint32_t termCount, uint32_t &aStartPosInList, nsMsgSearchBoolExpression ** aExpressionTree); @@ -91,7 +91,7 @@ protected: class nsMsgSearchOfflineNews : public nsMsgSearchOfflineMail { public: - nsMsgSearchOfflineNews (nsIMsgSearchScopeTerm*, nsISupportsArray *); + nsMsgSearchOfflineNews (nsIMsgSearchScopeTerm*, nsIArray*); virtual ~nsMsgSearchOfflineNews (); NS_IMETHOD ValidateTerms () override; diff --git a/mailnews/base/search/src/nsMsgSearchAdapter.cpp b/mailnews/base/search/src/nsMsgSearchAdapter.cpp index a6f8778305..e0d94b3699 100644 --- a/mailnews/base/search/src/nsMsgSearchAdapter.cpp +++ b/mailnews/base/search/src/nsMsgSearchAdapter.cpp @@ -24,14 +24,7 @@ #include "nsServiceManagerUtils.h" #include "nsMemory.h" #include "nsMsgMessageFlags.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIArray.h" #include "nsAlgorithm.h" #include #include "mozilla/Attributes.h" @@ -89,7 +82,7 @@ NS_IMETHODIMP nsMsgSearchAdapter::OpenResultElement(nsMsgResultElement *) NS_IMPL_ISUPPORTS(nsMsgSearchAdapter, nsIMsgSearchAdapter) -nsMsgSearchAdapter::nsMsgSearchAdapter(nsIMsgSearchScopeTerm *scope, nsISupportsArray *searchTerms) +nsMsgSearchAdapter::nsMsgSearchAdapter(nsIMsgSearchScopeTerm *scope, nsIArray *searchTerms) : m_searchTerms(searchTerms) { m_scope = scope; @@ -667,7 +660,7 @@ nsresult nsMsgSearchAdapter::EncodeImapValue(char *encoding, const char *value, } -nsresult nsMsgSearchAdapter::EncodeImap (char **ppOutEncoding, nsISupportsArray *searchTerms, const char16_t *srcCharset, const char16_t *destCharset, bool reallyDredd) +nsresult nsMsgSearchAdapter::EncodeImap (char **ppOutEncoding, nsIArray *searchTerms, const char16_t *srcCharset, const char16_t *destCharset, bool reallyDredd) { // i've left the old code (before using CBoolExpression for debugging purposes to make sure that // the new code generates the same encoding string as the old code..... @@ -676,7 +669,7 @@ nsresult nsMsgSearchAdapter::EncodeImap (char **ppOutEncoding, nsISupportsArray *ppOutEncoding = nullptr; uint32_t termCount; - searchTerms->Count(&termCount); + searchTerms->GetLength(&termCount); uint32_t i = 0; // create our expression @@ -823,14 +816,14 @@ nsMsgSearchValidityTable::GetNumAvailAttribs(int32_t *aResult) } nsresult -nsMsgSearchValidityTable::ValidateTerms (nsISupportsArray *searchTerms) +nsMsgSearchValidityTable::ValidateTerms (nsIArray *searchTerms) { nsresult err = NS_OK; uint32_t count; NS_ENSURE_ARG(searchTerms); - searchTerms->Count(&count); + searchTerms->GetLength(&count); for (uint32_t i = 0; i < count; i++) { nsCOMPtr pTerm; diff --git a/mailnews/base/search/src/nsMsgSearchImap.h b/mailnews/base/search/src/nsMsgSearchImap.h index 8f2849da6c..eacb76e6a8 100644 --- a/mailnews/base/search/src/nsMsgSearchImap.h +++ b/mailnews/base/search/src/nsMsgSearchImap.h @@ -14,7 +14,7 @@ class nsMsgSearchOnlineMail : public nsMsgSearchAdapter { public: - nsMsgSearchOnlineMail (nsMsgSearchScopeTerm *scope, nsISupportsArray *termList); + nsMsgSearchOnlineMail (nsMsgSearchScopeTerm *scope, nsIArray *termList); virtual ~nsMsgSearchOnlineMail (); NS_IMETHOD ValidateTerms () override; @@ -23,7 +23,7 @@ public: NS_IMETHOD AddResultElement (nsIMsgDBHdr *) override; static nsresult Encode (nsCString& ppEncoding, - nsISupportsArray *searchTerms, + nsIArray *searchTerms, const char16_t *destCharset); diff --git a/mailnews/base/search/src/nsMsgSearchNews.cpp b/mailnews/base/search/src/nsMsgSearchNews.cpp index 72d2bd6488..99f1d39344 100644 --- a/mailnews/base/search/src/nsMsgSearchNews.cpp +++ b/mailnews/base/search/src/nsMsgSearchNews.cpp @@ -15,14 +15,7 @@ #include "nsIMsgDatabase.h" #include "nsMemory.h" #include -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIArray.h" // Implementation of search for IMAP mail folders @@ -40,7 +33,7 @@ const char *nsMsgSearchNews::m_kNntpSubject = "SUBJECT "; const char *nsMsgSearchNews::m_kTermSeparator = "/"; -nsMsgSearchNews::nsMsgSearchNews (nsMsgSearchScopeTerm *scope, nsISupportsArray *termList) : nsMsgSearchAdapter (scope, termList) +nsMsgSearchNews::nsMsgSearchNews (nsMsgSearchScopeTerm *scope, nsIArray *termList) : nsMsgSearchAdapter (scope, termList) { } @@ -223,7 +216,7 @@ nsresult nsMsgSearchNews::Encode (nsCString *outEncoding) uint32_t numTerms; - m_searchTerms->Count(&numTerms); + m_searchTerms->GetLength(&numTerms); char **intermediateEncodings = new char * [numTerms]; if (intermediateEncodings) { @@ -252,7 +245,7 @@ nsresult nsMsgSearchNews::Encode (nsCString *outEncoding) { PL_strcpy (encoding, "?search"); - m_searchTerms->Count(&numTerms); + m_searchTerms->GetLength(&numTerms); for (i = 0; i < numTerms; i++) { @@ -335,7 +328,7 @@ void nsMsgSearchNews::CollateHits() // in the results of each XPAT command. So if we fire 3 XPAT commands (one // per search term), the article number must appear 3 times. If it appears // fewer than 3 times, it matched some search terms, but not all. - m_searchTerms->Count(&termCount); + m_searchTerms->GetLength(&termCount); } uint32_t candidateCount = 0; uint32_t candidate = m_candidateHits[0]; diff --git a/mailnews/base/search/src/nsMsgSearchNews.h b/mailnews/base/search/src/nsMsgSearchNews.h index 5c5c1ec31a..07d65ea31f 100644 --- a/mailnews/base/search/src/nsMsgSearchNews.h +++ b/mailnews/base/search/src/nsMsgSearchNews.h @@ -15,7 +15,7 @@ class nsMsgSearchNews : public nsMsgSearchAdapter { public: - nsMsgSearchNews (nsMsgSearchScopeTerm *scope, nsISupportsArray *termList); + nsMsgSearchNews (nsMsgSearchScopeTerm *scope, nsIArray *termList); virtual ~nsMsgSearchNews (); NS_IMETHOD ValidateTerms () override; diff --git a/mailnews/base/search/src/nsMsgSearchSession.cpp b/mailnews/base/search/src/nsMsgSearchSession.cpp index 422e17c404..c64a0b303f 100644 --- a/mailnews/base/search/src/nsMsgSearchSession.cpp +++ b/mailnews/base/search/src/nsMsgSearchSession.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "msgCore.h" +#include "nsArray.h" #include "nsMsgSearchCore.h" #include "nsMsgSearchAdapter.h" #include "nsMsgSearchBoolExpression.h" @@ -32,9 +33,8 @@ nsMsgSearchSession::nsMsgSearchSession() m_handlingError = false; m_expressionTree = nullptr; m_searchPaused = false; - nsresult rv = NS_NewISupportsArray(getter_AddRefs(m_termList)); - if (NS_FAILED(rv)) - NS_ASSERTION(false, "Failed to allocate a nsISupportsArray for nsMsgFilter"); + m_termList = nsArray::Create(); + NS_ASSERTION(m_termList, "Failed to allocate a nsIMutableArray for m_termList"); } nsMsgSearchSession::~nsMsgSearchSession() @@ -62,7 +62,7 @@ nsMsgSearchSession::AddSearchTerm(nsMsgSearchAttribValue attrib, boolOp, customString); NS_ENSURE_TRUE(pTerm, NS_ERROR_OUT_OF_MEMORY); - m_termList->AppendElement(pTerm); + m_termList->AppendElement(pTerm, /* weak = */ false); // force the expression tree to rebuild whenever we change the terms delete m_expressionTree; m_expressionTree = nullptr; @@ -76,11 +76,11 @@ nsMsgSearchSession::AppendTerm(nsIMsgSearchTerm *aTerm) NS_ENSURE_TRUE(m_termList, NS_ERROR_NOT_INITIALIZED); delete m_expressionTree; m_expressionTree = nullptr; - return m_termList->AppendElement(aTerm); + return m_termList->AppendElement(aTerm, /* weak = */ false); } NS_IMETHODIMP -nsMsgSearchSession::GetSearchTerms(nsISupportsArray **aResult) +nsMsgSearchSession::GetSearchTerms(nsIMutableArray **aResult) { NS_ENSURE_ARG_POINTER(aResult); *aResult = m_termList; @@ -88,6 +88,13 @@ nsMsgSearchSession::GetSearchTerms(nsISupportsArray **aResult) return NS_OK; } +NS_IMETHODIMP +nsMsgSearchSession::SetSearchTerms(nsIMutableArray *aSearchTerms) +{ + m_termList = aSearchTerms; + return NS_OK; +} + NS_IMETHODIMP nsMsgSearchSession::CreateTerm(nsIMsgSearchTerm **aResult) { diff --git a/mailnews/base/search/src/nsMsgSearchSession.h b/mailnews/base/search/src/nsMsgSearchSession.h index d5d62654fe..c31d91dfd9 100644 --- a/mailnews/base/search/src/nsMsgSearchSession.h +++ b/mailnews/base/search/src/nsMsgSearchSession.h @@ -12,14 +12,7 @@ #include "nsIUrlListener.h" #include "nsIMsgWindow.h" #include "nsITimer.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIMutableArray.h" #include "nsCOMArray.h" #include "nsWeakReference.h" #include "nsTObserverArray.h" @@ -55,7 +48,7 @@ protected: void ReleaseFolderDBRef(); nsTArray> m_scopeList; - nsCOMPtr m_termList; + nsCOMPtr m_termList; nsTArray > m_listenerList; nsTArray m_listenerFlagList; diff --git a/mailnews/base/search/src/nsMsgSearchTerm.cpp b/mailnews/base/search/src/nsMsgSearchTerm.cpp index f19491d127..2c6f930425 100644 --- a/mailnews/base/search/src/nsMsgSearchTerm.cpp +++ b/mailnews/base/search/src/nsMsgSearchTerm.cpp @@ -1906,7 +1906,7 @@ nsresult nsMsgSearchScopeTerm::TimeSlice (bool *aDone) return m_adapter->Search(aDone); } -nsresult nsMsgSearchScopeTerm::InitializeAdapter (nsISupportsArray *termList) +nsresult nsMsgSearchScopeTerm::InitializeAdapter (nsIArray *termList) { if (m_adapter) return NS_OK; diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp index 5dd3893b67..7bc25f0b96 100644 --- a/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mailnews/base/src/nsMsgAccountManager.cpp @@ -9,14 +9,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIMutableArray.h" #include "nsIArray.h" #include "nsArrayUtils.h" #include "nsMsgAccountManager.h" @@ -2559,7 +2552,7 @@ nsresult VirtualFolderChangeListener::Init() m_searchSession = do_CreateInstance(NS_MSGSEARCHSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr searchTerms; + nsCOMPtr searchTerms; rv = tempFilter->GetSearchTerms(getter_AddRefs(searchTerms)); NS_ENSURE_SUCCESS(rv, rv); @@ -2573,7 +2566,7 @@ nsresult VirtualFolderChangeListener::Init() searchTerms->Count(&numTerms); for (uint32_t i = 0; i < numTerms; i++) { - nsCOMPtr searchTerm (do_QueryElementAt(searchTerms, i)); + nsCOMPtr searchTerm(do_QueryElementAt(searchTerms, i)); nsMsgSearchAttribValue attrib; searchTerm->GetAttrib(&attrib); if (attrib == nsMsgSearchAttrib::MsgStatus) diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index 6ade749dce..e244f93f03 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -3593,7 +3593,7 @@ nsMsgDBView::PerformActionsOnJunkMsgs(bool msgsAreJunk) // a delete toggle. So what we have to do is to assemble a new delete // array, keeping only those that are not deleted. // - nsCOMPtr hdrsToDelete = do_CreateInstance("@mozilla.org/array;1", &rv); + nsCOMPtr hdrsToDelete = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); uint32_t cnt; rv = mJunkHdrs->GetLength(&cnt); diff --git a/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp b/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp index cdc4f0b5a7..06d064b51e 100644 --- a/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp +++ b/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp @@ -18,6 +18,7 @@ #include "nsMsgDBCID.h" #include "nsMsgMessageFlags.h" #include "nsServiceManagerUtils.h" +#include "nsIMutableArray.h" nsMsgXFVirtualFolderDBView::nsMsgXFVirtualFolderDBView() { @@ -383,7 +384,7 @@ nsMsgXFVirtualFolderDBView::OnNewSearch() nsCString terms; dbFolderInfo->GetCharProperty("searchStr", terms); - nsCOMPtr searchTerms; + nsCOMPtr searchTerms; rv = searchSession->GetSearchTerms(getter_AddRefs(searchTerms)); NS_ENSURE_SUCCESS(rv, rv); nsCString curSearchAsString; diff --git a/mailnews/base/src/virtualFolderWrapper.js b/mailnews/base/src/virtualFolderWrapper.js index efb4ed68af..f1cdf38169 100644 --- a/mailnews/base/src/virtualFolderWrapper.js +++ b/mailnews/base/src/virtualFolderWrapper.js @@ -29,9 +29,8 @@ var VirtualFolderHelper = { * @param aSearchFolders A list of nsIMsgFolders that you want to use as the * sources for the virtual folder OR a string that is the already '|' * delimited list of folder URIs to use. - * @param aSearchTerms The search terms to use for the virtual folder. This - * should be a JS list/nsIMutableArray/nsISupportsArray of - * nsIMsgSearchTermbs. + * @param aSearchTerms The search terms to use for the virtual folder. This + * should be a JS list/nsIMutableArray of nsIMsgSearchTerms. * @param aOnlineSearch Should the search attempt to use the server's search * capabilities when possible and appropriate? * @@ -133,8 +132,7 @@ VirtualFolderWrapper.prototype = { * Set the search folders that back this virtual folder. * * @param aFolders Either a "|"-delimited string of folder URIs or a list of - * nsIMsgFolders that fixIterator can traverse (JS array/nsIMutableArray/ - * nsISupportsArray). + * nsIMsgFolders that fixIterator can traverse (JS array/nsIMutableArray). */ set searchFolders(aFolders) { if (typeof(aFolders) == "string") { @@ -183,7 +181,7 @@ VirtualFolderWrapper.prototype = { * directly. * * @param aTerms Some collection that fixIterator can traverse. A JS list or - * XPCOM array (nsIMutableArray or nsISupportsArray) should work. + * XPCOM array (nsIMutableArray) should work. */ set searchTerms(aTerms) { let condition = ""; diff --git a/mailnews/base/util/nsMsgIncomingServer.cpp b/mailnews/base/util/nsMsgIncomingServer.cpp index a1e897f12f..74079044a6 100644 --- a/mailnews/base/util/nsMsgIncomingServer.cpp +++ b/mailnews/base/util/nsMsgIncomingServer.cpp @@ -24,6 +24,7 @@ #include "nsIMsgWindow.h" #include "nsIMsgFilterService.h" #include "nsIMsgProtocolInfo.h" +#include "nsIMutableArray.h" #include "nsIPrefService.h" #include "nsIRelativeFilePref.h" #include "nsIDocShell.h" @@ -1875,7 +1876,7 @@ nsMsgIncomingServer::ConfigureTemporaryServerSpamFilters(nsIMsgFilterList *filte */ // get the list of search terms from the filter - nsCOMPtr searchTerms; + nsCOMPtr searchTerms; rv = newFilter->GetSearchTerms(getter_AddRefs(searchTerms)); NS_ENSURE_SUCCESS(rv, rv); uint32_t count = 0; @@ -1911,7 +1912,7 @@ nsMsgIncomingServer::ConfigureTemporaryServerSpamFilters(nsIMsgFilterList *filte searchValue->SetStr(NS_LITERAL_STRING("user")); searchTerm->SetValue(searchValue); - searchTerms->InsertElementAt(searchTerm, count); + searchTerms->InsertElementAt(searchTerm, count, /* weak = */ false); bool moveOnSpam, markAsReadOnSpam; spamSettings->GetMoveOnSpam(&moveOnSpam); diff --git a/mailnews/base/util/nsMsgUtils.cpp b/mailnews/base/util/nsMsgUtils.cpp index 55be45f982..3ace389e3e 100644 --- a/mailnews/base/util/nsMsgUtils.cpp +++ b/mailnews/base/util/nsMsgUtils.cpp @@ -58,14 +58,7 @@ #include "nsIMsgWindow.h" #include "nsIWindowWatcher.h" #include "nsIPrompt.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIArray.h" #include "nsIMsgSearchTerm.h" #include "nsTextFormatter.h" #include "nsIAtomService.h" @@ -2237,10 +2230,10 @@ NS_MSG_BASE PRTime MsgConvertAgeInDaysToCutoffDate(int32_t ageInDays) return now - PR_USEC_PER_DAY * ageInDays; } -NS_MSG_BASE nsresult MsgTermListToString(nsISupportsArray *aTermList, nsCString &aOutString) +NS_MSG_BASE nsresult MsgTermListToString(nsIArray *aTermList, nsCString &aOutString) { uint32_t count; - aTermList->Count(&count); + aTermList->GetLength(&count); nsresult rv = NS_OK; for (uint32_t searchIndex = 0; searchIndex < count; diff --git a/mailnews/base/util/nsMsgUtils.h b/mailnews/base/util/nsMsgUtils.h index 5cc9c1ddda..265ed77b05 100644 --- a/mailnews/base/util/nsMsgUtils.h +++ b/mailnews/base/util/nsMsgUtils.h @@ -14,14 +14,7 @@ #include "nsTArray.h" #include "nsInterfaceRequestorAgg.h" #include "nsILoadGroup.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIArray.h" #include "nsIAtom.h" #include "nsINetUtil.h" #include "nsIRequest.h" @@ -42,7 +35,6 @@ class nsIMsgDatabase; class nsIMutableArray; class nsIProxyInfo; class nsIMsgWindow; -class nsISupportsArray; class nsIStreamListener; #define FILE_IO_BUFFER_SIZE (16*1024) @@ -287,7 +279,7 @@ NS_MSG_BASE PRTime MsgConvertAgeInDaysToCutoffDate(int32_t ageInDays); * @param[out] aOutString result representation of search terms. * */ -NS_MSG_BASE nsresult MsgTermListToString(nsISupportsArray *aTermList, nsCString &aOutString); +NS_MSG_BASE nsresult MsgTermListToString(nsIArray *aTermList, nsCString &aOutString); NS_MSG_BASE nsresult MsgStreamMsgHeaders(nsIInputStream *aInputStream, nsIStreamListener *aConsumer); @@ -404,8 +396,7 @@ ConvertBufToPlainText(nsString &aConBuf, bool formatFlowed, bool delsp, EndReading()[-1] #define SetCharAt(ch, index) \ Replace(index, 1, ch) -#define NS_NewISupportsArray(result) \ - CallCreateInstance(NS_SUPPORTSARRAY_CONTRACTID, static_cast(result)) + /** * The internal and external methods expect the parameters in a different order. * The internal API also always expects a flag rather than a comparator. diff --git a/mailnews/extensions/mailviews/public/nsIMsgMailView.idl b/mailnews/extensions/mailviews/public/nsIMsgMailView.idl index 54f22e76f1..fdbe06db9b 100644 --- a/mailnews/extensions/mailviews/public/nsIMsgMailView.idl +++ b/mailnews/extensions/mailviews/public/nsIMsgMailView.idl @@ -5,31 +5,21 @@ #include "nsISupports.idl" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -%{C++ -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -%} -interface nsISupportsArray; +interface nsIMutableArray; interface nsIMsgSearchTerm; [scriptable, uuid(28AC84DF-CBE5-430d-A5C0-4FA63B5424DF)] interface nsIMsgMailView : nsISupports { attribute wstring mailViewName; - readonly attribute wstring prettyName; // localized pretty name + readonly attribute wstring prettyName; // localized pretty name - // the array of search terms - attribute nsISupportsArray searchTerms; + // the array of search terms + attribute nsIMutableArray searchTerms; // these two helper methods are required to allow searchTermsOverlay.js to // manipulate a mail view without knowing it is dealing with a mail view. nsIMsgFilter // and nsIMsgSearchSession have the same two methods....we should probably make an interface around them. - void appendTerm(in nsIMsgSearchTerm term); - nsIMsgSearchTerm createTerm(); - + void appendTerm(in nsIMsgSearchTerm term); + nsIMsgSearchTerm createTerm(); }; diff --git a/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp b/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp index 8e5e04a3f3..d7fdd6722d 100644 --- a/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp +++ b/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp @@ -4,14 +4,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsMsgMailViewList.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsArray.h" +#include "nsIMutableArray.h" #include "nsIFileChannel.h" #include "nsIMsgFilterService.h" #include "nsIMsgMailSession.h" @@ -23,16 +17,18 @@ #include "nsComponentManagerUtils.h" #include "mozilla/Services.h" #include "nsIMsgFilter.h" +#include "nsArrayUtils.h" #define kDefaultViewPeopleIKnow "People I Know" #define kDefaultViewRecent "Recent Mail" #define kDefaultViewFiveDays "Last 5 Days" #define kDefaultViewNotJunk "Not Junk" #define kDefaultViewHasAttachments "Has Attachments" - + nsMsgMailView::nsMsgMailView() { - mViewSearchTerms = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); + mViewSearchTerms = nsArray::Create(); + NS_ASSERTION(mViewSearchTerms, "Failed to allocate a nsIMutableArray for mViewSearchTerms"); } NS_IMPL_ADDREF(nsMsgMailView) @@ -93,24 +89,24 @@ NS_IMETHODIMP nsMsgMailView::GetPrettyName(char16_t ** aMailViewName) return rv; } -NS_IMETHODIMP nsMsgMailView::GetSearchTerms(nsISupportsArray ** aSearchTerms) +NS_IMETHODIMP nsMsgMailView::GetSearchTerms(nsIMutableArray **aSearchTerms) { NS_ENSURE_ARG_POINTER(aSearchTerms); NS_IF_ADDREF(*aSearchTerms = mViewSearchTerms); return NS_OK; } -NS_IMETHODIMP nsMsgMailView::SetSearchTerms(nsISupportsArray * aSearchTerms) +NS_IMETHODIMP nsMsgMailView::SetSearchTerms(nsIMutableArray *aSearchTerms) { mViewSearchTerms = aSearchTerms; return NS_OK; } -NS_IMETHODIMP nsMsgMailView::AppendTerm(nsIMsgSearchTerm * aTerm) +NS_IMETHODIMP nsMsgMailView::AppendTerm(nsIMsgSearchTerm *aTerm) { NS_ENSURE_TRUE(aTerm, NS_ERROR_NULL_POINTER); - - return mViewSearchTerms->AppendElement(static_cast(aTerm)); + + return mViewSearchTerms->AppendElement(aTerm, /* weak */ false); } NS_IMETHODIMP nsMsgMailView::CreateTerm(nsIMsgSearchTerm **aResult) @@ -222,7 +218,7 @@ nsresult nsMsgMailViewList::ConvertMailViewListToFilterList() if (!newMailFilter) continue; - nsCOMPtr searchTerms; + nsCOMPtr searchTerms; mailView->GetSearchTerms(getter_AddRefs(searchTerms)); newMailFilter->SetSearchTerms(searchTerms); mFilterList->InsertFilterAt(index, newMailFilter); @@ -298,7 +294,7 @@ nsresult nsMsgMailViewList::ConvertFilterListToMailViews() msgFilter->GetFilterName(filterName); newMailView->SetMailViewName(filterName.get()); - nsCOMPtr filterSearchTerms; + nsCOMPtr filterSearchTerms; rv = msgFilter->GetSearchTerms(getter_AddRefs(filterSearchTerms)); NS_ENSURE_SUCCESS(rv, rv); rv = newMailView->SetSearchTerms(filterSearchTerms); diff --git a/mailnews/extensions/mailviews/src/nsMsgMailViewList.h b/mailnews/extensions/mailviews/src/nsMsgMailViewList.h index 3218033929..e180458de7 100644 --- a/mailnews/extensions/mailviews/src/nsMsgMailViewList.h +++ b/mailnews/extensions/mailviews/src/nsMsgMailViewList.h @@ -11,14 +11,7 @@ #include "nsIMsgMailViewList.h" #include "nsCOMPtr.h" #include "nsCOMArray.h" -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" +#include "nsIMutableArray.h" #include "nsIStringBundle.h" #include "nsStringGlue.h" #include "nsIMsgFilterList.h" @@ -36,7 +29,7 @@ protected: virtual ~nsMsgMailView(); nsString mName; nsCOMPtr mBundle; - nsCOMPtr mViewSearchTerms; + nsCOMPtr mViewSearchTerms; }; diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index fd5f9f17d0..5cb3a1eedd 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -691,7 +691,7 @@ NS_IMETHODIMP nsImapMailFolder::UpdateFolderWithListener(nsIMsgWindow *aMsgWindo filter->GetEnabled(&enabled); if (!enabled) continue; - nsCOMPtr searchTerms; + nsCOMPtr searchTerms; uint32_t numSearchTerms = 0; filter->GetSearchTerms(getter_AddRefs(searchTerms)); if (searchTerms) diff --git a/suite/mailnews/commandglue.js b/suite/mailnews/commandglue.js index 77965c7330..bfa19591a8 100644 --- a/suite/mailnews/commandglue.js +++ b/suite/mailnews/commandglue.js @@ -880,7 +880,7 @@ function getSearchTermString(searchTerms) var count = searchTerms.Count(); for (searchIndex = 0; searchIndex < count; ) { - var term = searchTerms.QueryElementAt(searchIndex++, Components.interfaces.nsIMsgSearchTerm); + var term = searchTerms.queryElementAt(searchIndex++, Components.interfaces.nsIMsgSearchTerm); if (condition.length > 1) condition += ' '; @@ -978,26 +978,33 @@ function setupXFVirtualFolderSearch(folderUrisToSearch, searchTerms, searchOnlin gSearchSession.addScopeTerm(!searchOnline ? nsMsgSearchScope.offlineMail : GetScopeForFolder(realFolder), realFolder); } - var termsArray = searchTerms.QueryInterface(Components.interfaces.nsISupportsArray); const nsIMsgSearchTerm = Components.interfaces.nsIMsgSearchTerm; - for (let term in fixIterator(termsArray, nsIMsgSearchTerm)) { + for (let term of fixIterator(searchTerms, nsIMsgSearchTerm)) { gSearchSession.appendTerm(term); } } +/** + * Uses an array of search terms to produce a new list usable from quick search. + * + * @param searchTermsArray A nsIArray of terms to copy. + * + * @return nsIMutableArray of search terms + */ function CreateGroupedSearchTerms(searchTermsArray) { var searchSession = gSearchSession || Components.classes[searchSessionContractID].createInstance(Components.interfaces.nsIMsgSearchSession); - // create a temporary isupports array to store our search terms - // since we will be modifying the terms so they work with quick search - var searchTermsArrayForQS = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray); + // Create a temporary nsIMutableArray to store our search terms + // since we will be modifying the terms so they work with quick search. + var searchTermsArrayForQS = Components.classes["@mozilla.org/array;1"] + .createInstance(Components.interfaces.nsIMutableArray); - var numEntries = searchTermsArray.Count(); - for (var i = 0; i < numEntries; i++) { - var searchTerm = searchTermsArray.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgSearchTerm); + var numEntries = searchTermsArray.length; + for (let i = 0; i < numEntries; i++) { + let searchTerm = searchTermsArray.queryElementAt(i, Components.interfaces.nsIMsgSearchTerm); // clone the term, since we might be modifying it var searchTermForQS = searchSession.createTerm(); @@ -1017,7 +1024,7 @@ function CreateGroupedSearchTerms(searchTermsArray) // turn the first term to true to work with quick search... searchTermForQS.booleanAnd = i ? searchTerm.booleanAnd : true; - searchTermsArrayForQS.AppendElement(searchTermForQS); + searchTermsArrayForQS.appendElement(searchTermForQS, /* weak = */ false); } return searchTermsArrayForQS; } diff --git a/suite/mailnews/msgViewPickerOverlay.js b/suite/mailnews/msgViewPickerOverlay.js index c579f09478..adbd2f2c10 100644 --- a/suite/mailnews/msgViewPickerOverlay.js +++ b/suite/mailnews/msgViewPickerOverlay.js @@ -210,8 +210,8 @@ function ViewTagKeyword(keyword) PrepareForViewChange(); // create an i supports array to store our search terms - var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"] - .createInstance(Components.interfaces.nsISupportsArray); + var searchTermsArray = Components.classes["@mozilla.org/array;1"] + .createInstance(Components.interfaces.nsIMutableArray); var term = gSearchSession.createTerm(); var value = term.value; @@ -222,7 +222,7 @@ function ViewTagKeyword(keyword) term.op = nsMsgSearchOp.Contains; term.booleanAnd = true; - searchTermsArray.AppendElement(term); + searchTermsArray.appendElement(term, /* weak = */ false); AddVirtualFolderTerms(searchTermsArray); createSearchTermsWithList(searchTermsArray); gDefaultSearchViewTerms = searchTermsArray; @@ -234,8 +234,8 @@ function ViewNewMail() PrepareForViewChange(); // create an i supports array to store our search terms - var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"] - .createInstance(Components.interfaces.nsISupportsArray); + var searchTermsArray = Components.classes["@mozilla.org/array;1"] + .createInstance(Components.interfaces.nsIMutableArray); var term = gSearchSession.createTerm(); var value = term.value; @@ -245,7 +245,7 @@ function ViewNewMail() term.attrib = nsMsgSearchAttrib.MsgStatus; term.op = nsMsgSearchOp.Isnt; term.booleanAnd = true; - searchTermsArray.AppendElement(term); + searchTermsArray.appendElement(term, /* weak = */ false); AddVirtualFolderTerms(searchTermsArray); @@ -260,8 +260,8 @@ function ViewNotDeletedMail() PrepareForViewChange(); // create an i supports array to store our search terms - var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"] - .createInstance(Components.interfaces.nsISupportsArray); + var searchTermsArray = Components.classes["@mozilla.org/array;1"] + .createInstance(Components.interfaces.nsIMutableArray); var term = gSearchSession.createTerm(); var value = term.value; @@ -271,7 +271,7 @@ function ViewNotDeletedMail() term.attrib = nsMsgSearchAttrib.MsgStatus; term.op = nsMsgSearchOp.Isnt; term.booleanAnd = true; - searchTermsArray.AppendElement(term); + searchTermsArray.appendElement(term, /* weak = */ false); AddVirtualFolderTerms(searchTermsArray); @@ -287,14 +287,10 @@ function AddVirtualFolderTerms(searchTermsArray) var virtualFolderSearchTerms = (gVirtualFolderTerms || gXFVirtualFolderTerms); if (virtualFolderSearchTerms) { - var isupports = null; - var searchTerm; - var termsArray = virtualFolderSearchTerms.QueryInterface(Components.interfaces.nsISupportsArray); - for (var i = 0; i < termsArray.Count(); i++) + for (let i = 0; i < termsArray.length; i++) { - isupports = termsArray.GetElementAt(i); - searchTerm = isupports.QueryInterface(Components.interfaces.nsIMsgSearchTerm); - searchTermsArray.AppendElement(searchTerm); + let searchTerm = virtualFolderSearchTerms.queryElementAt(i, Components.interfaces.nsIMsgSearchTerm); + searchTermsArray.appendElement(searchTerm, /* weak = */ false); } } } diff --git a/suite/mailnews/search/ABSearchDialog.js b/suite/mailnews/search/ABSearchDialog.js index 2649ec6bbf..ba1eb79796 100644 --- a/suite/mailnews/search/ABSearchDialog.js +++ b/suite/mailnews/search/ABSearchDialog.js @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Components.utils.import("resource:///modules/ABQueryUtils.jsm"); +Components.utils.import("resource:///modules/iteratorUtils.js"); Components.utils.import("resource:///modules/mailServices.js"); Components.utils.import("resource://gre/modules/PluralForm.jsm"); @@ -165,11 +166,7 @@ function onSearch() var searchUri = currentAbURI + "?("; - var count = gSearchSession.searchTerms.Count(); - - for (var i=0; i