Bug 857230 - Convert nsIMsgFilter::searchTerms from nsISupportsArray to nsIMutableArray. r=aceman,jorgk,mkmelin,Ratty a=Ratty

--HG--
extra : amend_source : bbc18e1edd58590834f958ea01f3ce84e0ca6717
This commit is contained in:
Eric Rahm 2016-11-16 12:43:32 -08:00
Родитель 9fa2e528f1
Коммит 41f9037a09
38 изменённых файлов: 172 добавлений и 278 удалений

Просмотреть файл

@ -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<count; i++) {
var searchTerm = gSearchSession.searchTerms.GetElementAt(i).QueryInterface(nsIMsgSearchTerm);
for (let searchTerm of fixIterator(gSearchSession.searchTerms, nsIMsgSearchTerm)) {
// get the "and" / "or" value from the first term
if (i == 0) {
if (searchTerm.booleanAnd)

Просмотреть файл

@ -361,7 +361,7 @@ SearchSpec.prototype = {
let session = this.session;
// clear out our current terms and scope
session.searchTerms.QueryInterface(Ci.nsISupportsArray).Clear();
session.searchTerms.clear();
session.clearScopes();
// the scope logic needs to know if any terms look at the body attribute.

Просмотреть файл

@ -137,9 +137,9 @@ function filterEditorOnLoad()
}
// copy the search terms
for (let i = 0; i < copiedFilter.searchTerms.Count(); i++)
for (let i = 0; i < copiedFilter.searchTerms.length; i++)
{
var searchTerm = copiedFilter.searchTerms.QueryElementAt(i,
let searchTerm = copiedFilter.searchTerms.queryElementAt(i,
Components.interfaces.nsIMsgSearchTerm);
var newTerm = newFilter.createTerm();

Просмотреть файл

@ -173,8 +173,8 @@ function initializeBooleanWidgets()
function initializeSearchRows(scope, searchTerms)
{
for (var i = 0; i < searchTerms.Count(); i++) {
var searchTerm = searchTerms.QueryElementAt(i, nsIMsgSearchTerm);
for (let i = 0; i < searchTerms.length; i++) {
let searchTerm = searchTerms.queryElementAt(i, nsIMsgSearchTerm);
createSearchRow(i, scope, searchTerm, false);
gTotalSearchTerms++;
}
@ -470,19 +470,19 @@ function removeSearchRow(index)
if (searchTermObj.searchTerm) {
gSearchRemovedTerms[gSearchRemovedTerms.length] = searchTermObj.searchTerm;
gSearchRemovedTerms.push(searchTermObj.searchTerm);
} else {
//dump("That wasn't real. ignoring \n");
}
listitem.remove();
// now remove the item from our list of terms
gSearchTerms.splice(index, 1);
}
// save the search terms from the UI back to the actual search terms
// searchTerms: nsISupportsArray of terms
// searchTerms: nsIMutableArray of terms
// termOwner: object which can contain and create the terms
// (will be unnecessary if we just make terms creatable
// via XPCOM)
@ -491,7 +491,7 @@ function saveSearchTerms(searchTerms, termOwner)
var matchAll = gSearchBooleanRadiogroup.value == 'matchAll';
var i;
for (i = 0; i < gSearchRemovedTerms.length; i++)
searchTerms.RemoveElement(gSearchRemovedTerms[i]);
searchTerms.removeElementAt(searchTerms.indexOf(0, gSearchRemovedTerms[i]));
for (i = 0; i<gSearchTerms.length; i++) {
try {
@ -510,7 +510,7 @@ function saveSearchTerms(searchTerms, termOwner)
// but we need to make the array longer anyway
termOwner.appendTerm(searchTerm);
}
searchTerms.SetElementAt(i, searchTerm);
searchTerms.replaceElementAt(searchTerm, i, /* weak */ false);
} catch (ex) {
dump("** Error saving element " + i + ": " + ex + "\n");
}

Просмотреть файл

@ -6,18 +6,9 @@
#include "nsISupports.idl"
#include "nsMsgFilterCore.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 nsIArray;
interface nsIMutableArray;
interface nsIOutputStream;
interface nsIMsgFilterCustomAction;
interface nsIMsgFilterList;
@ -87,7 +78,7 @@ interface nsIMsgFilter : nsISupports {
nsIMsgSearchTerm createTerm();
attribute nsISupportsArray searchTerms;
attribute nsIMutableArray searchTerms;
attribute nsIMsgSearchScopeTerm scope;

Просмотреть файл

@ -6,21 +6,12 @@
#include "nsISupports.idl"
#include "nsIMsgSearchValue.idl"
interface nsIMutableArray;
interface nsIMsgSearchAdapter;
interface nsIMsgSearchTerm;
interface nsIMsgSearchNotify;
interface nsIMsgHdr;
interface nsIMsgDatabase;
// 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 nsIMsgWindow;
//////////////////////////////////////////////////////////////////////////////
@ -50,9 +41,9 @@ interface nsIMsgSearchSession : nsISupports {
in boolean BooleanAND,
in string customString);
readonly attribute nsISupportsArray searchTerms;
attribute nsIMutableArray searchTerms;
nsIMsgSearchTerm createTerm ();
nsIMsgSearchTerm createTerm();
void appendTerm(in nsIMsgSearchTerm term);
/**

Просмотреть файл

@ -5,16 +5,7 @@
#include "nsISupports.idl"
#include "nsMsgSearchCore.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 nsIArray;
[scriptable, uuid(b07f1cb6-fae9-4d92-9edb-03f9ad249c66)]
interface nsIMsgSearchValidityTable : nsISupports {
@ -33,7 +24,7 @@ interface nsIMsgSearchValidityTable : nsISupports {
boolean getValidButNotShown(in nsMsgSearchAttribValue attrib,
in nsMsgSearchOpValue op);
[noscript] void validateTerms(in nsISupportsArray terms);
[noscript] void validateTerms(in nsIArray terms);
readonly attribute long numAvailAttribs;

Просмотреть файл

@ -29,20 +29,20 @@ class nsIMsgSearchScopeTerm;
class nsMsgSearchAdapter : public nsIMsgSearchAdapter
{
public:
nsMsgSearchAdapter (nsIMsgSearchScopeTerm*, nsISupportsArray *);
nsMsgSearchAdapter (nsIMsgSearchScopeTerm*, nsIArray*);
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGSEARCHADAPTER
nsIMsgSearchScopeTerm *m_scope;
nsCOMPtr<nsISupportsArray> m_searchTerms; /* linked list of criteria terms */
nsCOMPtr<nsIArray> 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);

Просмотреть файл

@ -26,7 +26,7 @@ public:
NS_DECL_NSIMSGSEARCHSCOPETERM
nsresult TimeSlice (bool *aDone);
nsresult InitializeAdapter (nsISupportsArray *termList);
nsresult InitializeAdapter (nsIArray *termList);
char *GetStatusBarName ();

Просмотреть файл

@ -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<nsISupports*>(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;

Просмотреть файл

@ -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<nsISupportsArray> m_termList; /* linked list of criteria terms */
nsCOMPtr<nsIMutableArray> m_termList; /* linked list of criteria terms */
nsCOMPtr<nsIMsgSearchScopeTerm> m_scope; /* default for mail rules is inbox, but news rules could
have a newsgroup - LDAP would be invalid */
nsTArray<nsCOMPtr<nsIMsgRuleAction> > m_actionList;

Просмотреть файл

@ -1146,11 +1146,11 @@ nsresult nsMsgFilterList::ComputeArbitraryHeaders()
rv = GetFilterAt(index, getter_AddRefs(filter));
if (!(NS_SUCCEEDED(rv) && filter)) continue;
nsCOMPtr <nsISupportsArray> searchTerms;
uint32_t numSearchTerms=0;
nsCOMPtr<nsIMutableArray> 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);

Просмотреть файл

@ -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 <nsISupportsArray> searchTerms;
nsCOMPtr<nsIMutableArray> 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 <nsIMsgSearchTerm> term;

Просмотреть файл

@ -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++)

Просмотреть файл

@ -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)
{
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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 <algorithm>
#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<nsIMsgSearchTerm> pTerm;

Просмотреть файл

@ -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);

Просмотреть файл

@ -15,14 +15,7 @@
#include "nsIMsgDatabase.h"
#include "nsMemory.h"
#include <ctype.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
@ -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];

Просмотреть файл

@ -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;

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -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<RefPtr<nsMsgSearchScopeTerm>> m_scopeList;
nsCOMPtr <nsISupportsArray> m_termList;
nsCOMPtr<nsIMutableArray> m_termList;
nsTArray<nsCOMPtr<nsIMsgSearchNotify> > m_listenerList;
nsTArray<int32_t> m_listenerFlagList;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsISupportsArray> searchTerms;
nsCOMPtr<nsIMutableArray> 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 <nsIMsgSearchTerm> searchTerm (do_QueryElementAt(searchTerms, i));
nsCOMPtr<nsIMsgSearchTerm> searchTerm(do_QueryElementAt(searchTerms, i));
nsMsgSearchAttribValue attrib;
searchTerm->GetAttrib(&attrib);
if (attrib == nsMsgSearchAttrib::MsgStatus)

Просмотреть файл

@ -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<nsIMutableArray> hdrsToDelete = do_CreateInstance("@mozilla.org/array;1", &rv);
nsCOMPtr<nsIMutableArray> hdrsToDelete = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t cnt;
rv = mJunkHdrs->GetLength(&cnt);

Просмотреть файл

@ -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<nsISupportsArray> searchTerms;
nsCOMPtr<nsIMutableArray> searchTerms;
rv = searchSession->GetSearchTerms(getter_AddRefs(searchTerms));
NS_ENSURE_SUCCESS(rv, rv);
nsCString curSearchAsString;

Просмотреть файл

@ -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 = "";

Просмотреть файл

@ -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<nsISupportsArray> searchTerms;
nsCOMPtr<nsIMutableArray> 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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsISupportsArray**>(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.

Просмотреть файл

@ -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();
};

Просмотреть файл

@ -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<nsISupports*>(aTerm));
return mViewSearchTerms->AppendElement(aTerm, /* weak */ false);
}
NS_IMETHODIMP nsMsgMailView::CreateTerm(nsIMsgSearchTerm **aResult)
@ -222,7 +218,7 @@ nsresult nsMsgMailViewList::ConvertMailViewListToFilterList()
if (!newMailFilter)
continue;
nsCOMPtr<nsISupportsArray> searchTerms;
nsCOMPtr<nsIMutableArray> 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<nsISupportsArray> filterSearchTerms;
nsCOMPtr<nsIMutableArray> filterSearchTerms;
rv = msgFilter->GetSearchTerms(getter_AddRefs(filterSearchTerms));
NS_ENSURE_SUCCESS(rv, rv);
rv = newMailView->SetSearchTerms(filterSearchTerms);

Просмотреть файл

@ -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<nsIStringBundle> mBundle;
nsCOMPtr<nsISupportsArray> mViewSearchTerms;
nsCOMPtr<nsIMutableArray> mViewSearchTerms;
};

Просмотреть файл

@ -691,7 +691,7 @@ NS_IMETHODIMP nsImapMailFolder::UpdateFolderWithListener(nsIMsgWindow *aMsgWindo
filter->GetEnabled(&enabled);
if (!enabled)
continue;
nsCOMPtr<nsISupportsArray> searchTerms;
nsCOMPtr<nsIMutableArray> searchTerms;
uint32_t numSearchTerms = 0;
filter->GetSearchTerms(getter_AddRefs(searchTerms));
if (searchTerms)

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);
}
}
}

Просмотреть файл

@ -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<count; i++) {
var searchTerm = gSearchSession.searchTerms.GetElementAt(i).QueryInterface(nsIMsgSearchTerm);
for (let searchTerm of fixIterator(gSearchSession.searchTerms, nsIMsgSearchTerm)) {
// get the "and" / "or" value from the first term
if (i == 0) {
if (searchTerm.booleanAnd)

Просмотреть файл

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/PluralForm.jsm");
Components.utils.import("resource:///modules/iteratorUtils.jsm");
var gSearchSession = null;
var gPreQuickSearchView = null;
@ -172,7 +173,7 @@ function onEnterInSearchBar()
var addTerms = gDefaultSearchViewTerms || gVirtualFolderTerms || gXFVirtualFolderTerms;
if (addTerms)
{
viewDebug ("addTerms = " + addTerms + " count = " + addTerms.Count() + "\n");
viewDebug ("addTerms = " + addTerms + " count = " + addTerms.length + "\n");
initializeSearchBar();
onSearch(addTerms);
}
@ -291,10 +292,8 @@ function createSearchTermsWithList(aTermsArray)
var nsMsgSearchAttrib = Components.interfaces.nsMsgSearchAttrib;
var nsMsgSearchOp = Components.interfaces.nsMsgSearchOp;
gSearchSession.clear();
gSearchSession.clearScopes();
var searchTerms = gSearchSession.searchTerms;
var searchTermsArray = searchTerms.QueryInterface(Components.interfaces.nsISupportsArray);
searchTermsArray.Clear();
var i;
var selectedFolder = GetThreadPaneFolder();
@ -320,11 +319,11 @@ function createSearchTermsWithList(aTermsArray)
viewDebug ("in createSearchTermsWithList, adding scope term for selected folder\n");
gSearchSession.addScopeTerm(nsMsgSearchScope.offlineMail, selectedFolder);
}
// add each item in termsArray to the search session
var termsArray = aTermsArray.QueryInterface(Components.interfaces.nsISupportsArray);
for (i = 0; i < termsArray.Count(); ++i)
gSearchSession.appendTerm(termsArray.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgSearchTerm));
// Add each item in aTermsArray to the search session.
for (let term of fixIterator(aTermsArray, Components.interfaces.nsIMsgSearchTerm)) {
gSearchSession.appendTerm(term);
}
}
function createSearchTerms()
@ -333,8 +332,9 @@ function createSearchTerms()
var nsMsgSearchAttrib = Components.interfaces.nsMsgSearchAttrib;
var nsMsgSearchOp = Components.interfaces.nsMsgSearchOp;
// create an nsISupportsArray to store our search terms
var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
// create an nsIMutableArray to store our search terms
var searchTermsArray = Components.classes["@mozilla.org/array;1"]
.createInstance(Components.interfaces.nsIMutableArray);
var selectedFolder = GetThreadPaneFolder();
// implement | for QS
@ -356,7 +356,7 @@ function createSearchTerms()
term.attrib = nsMsgSearchAttrib.Subject;
term.op = nsMsgSearchOp.Contains;
term.booleanAnd = false;
searchTermsArray.AppendElement(term);
searchTermsArray.appendElement(term, /* weak = */ false);
// create, fill, and append the AllAddresses term
term = gSearchSession.createTerm();
@ -366,7 +366,7 @@ function createSearchTerms()
term.attrib = nsMsgSearchAttrib.AllAddresses;
term.op = nsMsgSearchOp.Contains;
term.booleanAnd = false;
searchTermsArray.AppendElement(term);
searchTermsArray.appendElement(term, /* weak = */ false);
}
// now append the default view or virtual folder criteria to the quick search
@ -376,14 +376,9 @@ function createSearchTerms()
var defaultSearchTerms = (gDefaultSearchViewTerms || gVirtualFolderTerms || gXFVirtualFolderTerms);
if (defaultSearchTerms)
{
var isupports = null;
var searchTerm;
var termsArray = defaultSearchTerms.QueryInterface(Components.interfaces.nsISupportsArray);
for (i = 0; i < termsArray.Count(); i++)
for (let searchTerm of fixIterator(defaultSearchTerms, Components.interfaces.nsIMsgSearchTerm))
{
isupports = termsArray.GetElementAt(i);
searchTerm = isupports.QueryInterface(Components.interfaces.nsIMsgSearchTerm);
searchTermsArray.AppendElement(searchTerm);
searchTermsArray.appendElement(searchTerm, /* weak = */ false);
}
}