зеркало из https://github.com/mozilla/pjs.git
more work on search, not part of build
This commit is contained in:
Родитель
5ce6f6a715
Коммит
a753f15877
|
@ -54,7 +54,7 @@ interface nsIMsgSearchSession : nsISupports {
|
|||
in nsMsgSearchScope scopeId);
|
||||
|
||||
/* add a scope (e.g. a mail folder) to the search */
|
||||
void AddScopeTerm(in nsMsgSearchScope attrib,
|
||||
void AddScopeTerm(in nsMsgSearchScopeAttribute attrib,
|
||||
in nsIMsgFolder folder);
|
||||
|
||||
/* special cases for LDAP since LDAP isn't really a folderInfo */
|
||||
|
@ -64,7 +64,7 @@ interface nsIMsgSearchSession : nsISupports {
|
|||
/* Call this function everytime the scope changes! It informs the FE if
|
||||
the current scope support custom header use. FEs should not display the
|
||||
custom header dialog if custom headers are not supported */
|
||||
[noscript] boolean ScopeUsesCustomHeaders(in nsMsgSearchScope scope,
|
||||
[noscript] boolean ScopeUsesCustomHeaders(in nsMsgSearchScopeAttribute scope,
|
||||
/* could be a folder or server based on scope */
|
||||
in voidStar selection,
|
||||
in boolean forFilters);
|
||||
|
@ -73,9 +73,9 @@ interface nsIMsgSearchSession : nsISupports {
|
|||
boolean IsStringAttribute(in nsMsgSearchAttribute attrib);
|
||||
|
||||
/* add all scopes of a given type to the search */
|
||||
void AddAllScopes(in nsMsgSearchScope attrib);
|
||||
void AddAllScopes(in nsMsgSearchScopeAttribute attrib);
|
||||
|
||||
void Search();
|
||||
void Search(in nsIMsgWindow aWindow);
|
||||
void InterruptSearch();
|
||||
|
||||
[noscript] readonly attribute voidStar searchParam;
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
// represent a search hit without requiring a message header or server connection
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
class nsMsgResultElement
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsMsgResultElement;
|
||||
class nsMsgSearchTerm;
|
||||
class nsMsgSearchScopeTerm;
|
||||
struct nsMsgSearchValue;
|
||||
|
@ -47,5 +48,11 @@ public:
|
|||
nsMsgSearchScopeTerm *ElementAt(PRUint32 i) const { return (nsMsgSearchScopeTerm*) nsVoidArray::ElementAt(i); }
|
||||
};
|
||||
|
||||
class nsMsgResultArray : public nsVoidArray
|
||||
{
|
||||
public:
|
||||
nsMsgResultElement *ElementAt(PRUint32 i) const { return (nsMsgResultElement *) nsVoidArray::ElementAt(i); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,12 +29,13 @@
|
|||
#include "nsIMsgFolder.h"
|
||||
#include "nsIMsgSearchAdapter.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsIMsgSearchSession.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsMsgSearchScopeTerm
|
||||
{
|
||||
public:
|
||||
nsMsgSearchScopeTerm (nsMsgSearchScopeAttribute, nsIMsgFolder *);
|
||||
nsMsgSearchScopeTerm (nsIMsgSearchSession *, nsMsgSearchScopeAttribute, nsIMsgFolder *);
|
||||
nsMsgSearchScopeTerm ();
|
||||
virtual ~nsMsgSearchScopeTerm ();
|
||||
|
||||
|
@ -42,7 +43,7 @@ public:
|
|||
PRBool IsOfflineMail ();
|
||||
PRBool IsOfflineIMAPMail(); // added by mscott
|
||||
nsresult GetMailPath(nsIFileSpec **aFileSpec);
|
||||
nsresult TimeSlice ();
|
||||
nsresult TimeSlice (PRBool *aDone);
|
||||
|
||||
nsresult InitializeAdapter (nsMsgSearchTermArray &termList);
|
||||
|
||||
|
@ -53,6 +54,7 @@ public:
|
|||
nsCOMPtr <nsIMsgFolder> m_folder;
|
||||
nsInputFileStream *m_fileStream;
|
||||
nsCOMPtr <nsIMsgSearchAdapter> m_adapter;
|
||||
nsCOMPtr <nsIMsgSearchSession> m_searchSession;
|
||||
PRBool m_searchServer;
|
||||
|
||||
};
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
#if 0
|
||||
nsMsgSearchTerm (nsMsgSearchAttribute, nsMsgSearchOperator, nsMsgSearchValue *, PRBool, char * arbitraryHeader); // the bool is true if AND, PR_FALSE if OR
|
||||
#endif
|
||||
nsMsgSearchTerm (nsMsgSearchAttribute, nsMsgSearchOperator, nsMsgSearchValue *, nsMsgSearchBooleanOperator, char * arbitraryHeader);
|
||||
nsMsgSearchTerm (nsMsgSearchAttribute, nsMsgSearchOperator, nsMsgSearchValue *, nsMsgSearchBooleanOperator, const char * arbitraryHeader);
|
||||
|
||||
virtual ~nsMsgSearchTerm ();
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ NS_IMETHODIMP nsMsgFilter::MatchHdr(nsIMsgDBHdr *msgHdr, nsIMsgFolder *folder, n
|
|||
const char *headers, PRUint32 headersSize, PRBool *pResult)
|
||||
{
|
||||
|
||||
nsMsgSearchScopeTerm scope (nsMsgSearchScope::MailFolder, folder);
|
||||
nsMsgSearchScopeTerm scope (nsnull, nsMsgSearchScope::MailFolder, folder);
|
||||
return nsMsgSearchOfflineMail::MatchTermsForFilter(msgHdr, m_termList,
|
||||
&scope,
|
||||
db,
|
||||
|
|
|
@ -24,32 +24,50 @@
|
|||
#include "nsMsgSearchCore.h"
|
||||
#include "nsMsgSearchAdapter.h"
|
||||
#include "nsMsgSearchSession.h"
|
||||
#include "nsMsgResultElement.h"
|
||||
#include "nsMsgSearchTerm.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS1(nsMsgSearchSession, nsIMsgSearchSession)
|
||||
NS_IMPL_ISUPPORTS2(nsMsgSearchSession, nsIMsgSearchSession, nsIUrlListener)
|
||||
|
||||
nsMsgSearchSession::nsMsgSearchSession()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
m_sortAttribute = nsMsgSearchAttrib::Sender;
|
||||
m_descending = PR_FALSE;
|
||||
m_idxRunningScope = 0;
|
||||
m_parallel = PR_FALSE;
|
||||
// m_calledStartingUpdate = PR_FALSE;
|
||||
m_handlingError = PR_FALSE;
|
||||
m_pSearchParam = nsnull;
|
||||
|
||||
}
|
||||
|
||||
nsMsgSearchSession::~nsMsgSearchSession()
|
||||
{
|
||||
/* destructor code */
|
||||
DestroyResultList ();
|
||||
DestroyScopeList ();
|
||||
DestroyTermList ();
|
||||
|
||||
PR_FREEIF (m_pSearchParam);
|
||||
}
|
||||
|
||||
/* [noscript] void AddSearchTerm (in nsMsgSearchAttribute attrib, in nsMsgSearchOperator op, in nsMsgSearchValue value, in boolean BooleanAND, in string arbitraryHeader); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::AddSearchTerm(nsMsgSearchAttribute attrib, nsMsgSearchOperator op, nsMsgSearchValue * value, PRBool BooleanAND, const char *arbitraryHeader)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsMsgSearchTerm *pTerm = new nsMsgSearchTerm (attrib, op, value, nsMsgSearchBooleanOp::BooleanAND, arbitraryHeader);
|
||||
if (nsnull == pTerm)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
m_termList.AppendElement (pTerm);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute long numSearchTerms; */
|
||||
NS_IMETHODIMP nsMsgSearchSession::GetNumSearchTerms(PRInt32 *aNumSearchTerms)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
NS_ENSURE_ARG(aNumSearchTerms);
|
||||
*aNumSearchTerms = m_termList.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] void GetNthSearchTerm (in long whichTerm, in nsMsgSearchAttribute attrib, in nsMsgSearchOperator op, in nsMsgSearchValue value); */
|
||||
|
@ -61,6 +79,7 @@ NS_IMETHODIMP nsMsgSearchSession::GetNthSearchTerm(PRInt32 whichTerm, nsMsgSearc
|
|||
/* long MSG_CountSearchScopes (); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::MSG_CountSearchScopes(PRInt32 *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(_retval);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -71,9 +90,96 @@ NS_IMETHODIMP nsMsgSearchSession::MSG_GetNthSearchScope(PRInt32 which, nsMsgSear
|
|||
}
|
||||
|
||||
/* void AddScopeTerm (in nsMsgSearchScope attrib, in nsIMsgFolder folder); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::AddScopeTerm(nsMsgSearchScope attrib, nsIMsgFolder *folder)
|
||||
NS_IMETHODIMP nsMsgSearchSession::AddScopeTerm(nsMsgSearchScopeAttribute attrib, nsIMsgFolder *folder)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (attrib != nsMsgSearchScope::AllSearchableGroups)
|
||||
{
|
||||
NS_ASSERTION(folder, "need folder if not searching all groups");
|
||||
if (!folder)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult err = NS_OK;
|
||||
|
||||
if (attrib == nsMsgSearchScope::MailFolder)
|
||||
{
|
||||
#if 0
|
||||
// It's legal to have a folderInfo which is only a directory, but has no
|
||||
// mail folder or summary file. However, such a folderInfo isn't a legal
|
||||
// scopeTerm, so turn it away here
|
||||
if (mailFolder && !XP_Stat(mailFolder->GetPathname(), &fileStat, xpMailFolder) && S_ISDIR(fileStat.st_mode))
|
||||
err = SearchError_InvalidFolder;
|
||||
|
||||
// IMAP folders can have a \NOSELECT flag which means that they can't
|
||||
// ever be opened. Since we have to SELECT a folder in order to search
|
||||
// it, we'll just omit this folder from the list of search scopes
|
||||
MSG_IMAPFolderInfoMail *imapFolder = folder->GetIMAPFolderInfoMail();
|
||||
if (imapFolder && !imapFolder->GetCanIOpenThisFolder())
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((attrib == nsMsgSearchScope::Newsgroup || attrib == nsMsgSearchScope::OfflineNewsgroup) /* && folder->IsNews() */)
|
||||
{
|
||||
#if 0
|
||||
// Even unsubscribed newsgroups have a folderInfo, so filter them
|
||||
// out here, adding only the newsgroups we are subscribed to
|
||||
if (!newsFolder->IsSubscribed())
|
||||
return NS_OK;
|
||||
|
||||
// It would be nice if the FEs did this, but I guess no one knows
|
||||
// that offline news searching is supposed to work
|
||||
if (NET_IsOffline())
|
||||
attrib = nsMsgSearchScope::OfflineNewsgroup;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (attrib == nsMsgSearchScope::AllSearchableGroups)
|
||||
{
|
||||
#if 0
|
||||
// Try to be flexible about what we get here. It could be a news group,
|
||||
// news host, or NULL, which uses the default host.
|
||||
if (folder == nsnull)
|
||||
{
|
||||
// I dunno how much of this can be NULL, so I'm not assuming anything
|
||||
MSG_NewsHost *host = NULL;
|
||||
msg_HostTable *table = m_pane->GetMaster()->GetHostTable();
|
||||
if (table)
|
||||
{
|
||||
host = table->GetDefaultHost(FALSE /*###tw*/);
|
||||
if (host)
|
||||
folder = host->GetHostInfo();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (folder->GetType())
|
||||
{
|
||||
case FOLDER_CONTAINERONLY:
|
||||
break; // this is what we want -- nothing to do
|
||||
case FOLDER_NEWSGROUP:
|
||||
case FOLDER_CATEGORYCONTAINER:
|
||||
{
|
||||
MSG_NewsHost *host = ((MSG_FolderInfoNews*) folder)->GetHost();
|
||||
folder = host->GetHostInfo();
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
nsMsgSearchScopeTerm *pScope = new nsMsgSearchScopeTerm (this, attrib, folder);
|
||||
if (pScope)
|
||||
m_scopeList.AppendElement (pScope);
|
||||
else
|
||||
err = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* [noscript] void AddLdapScope (in nsMsgDIRServer server); */
|
||||
|
@ -83,7 +189,7 @@ NS_IMETHODIMP nsMsgSearchSession::AddLdapScope(nsMsgDIRServer * server)
|
|||
}
|
||||
|
||||
/* [noscript] boolean ScopeUsesCustomHeaders (in nsMsgSearchScope scope, in voidStar selection, in boolean forFilters); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::ScopeUsesCustomHeaders(nsMsgSearchScope scope, void * selection, PRBool forFilters, PRBool *_retval)
|
||||
NS_IMETHODIMP nsMsgSearchSession::ScopeUsesCustomHeaders(nsMsgSearchScopeAttribute scope, void * selection, PRBool forFilters, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -91,25 +197,31 @@ NS_IMETHODIMP nsMsgSearchSession::ScopeUsesCustomHeaders(nsMsgSearchScope scope,
|
|||
/* boolean IsStringAttribute (in nsMsgSearchAttribute attrib); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::IsStringAttribute(nsMsgSearchAttribute attrib, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(_retval);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void AddAllScopes (in nsMsgSearchScope attrib); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::AddAllScopes(nsMsgSearchScope attrib)
|
||||
NS_IMETHODIMP nsMsgSearchSession::AddAllScopes(nsMsgSearchScopeAttribute attrib)
|
||||
{
|
||||
// don't think this is needed.
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void Search (); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::Search()
|
||||
NS_IMETHODIMP nsMsgSearchSession::Search(nsIMsgWindow *aWindow)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsresult err = Initialize ();
|
||||
m_window = aWindow;
|
||||
if (NS_SUCCEEDED(err))
|
||||
err = BeginSearching ();
|
||||
return err;
|
||||
}
|
||||
|
||||
/* void InterruptSearch (); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::InterruptSearch()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] readonly attribute voidStar searchParam; */
|
||||
|
@ -136,3 +248,233 @@ NS_IMETHODIMP nsMsgSearchSession::GetNumResults(PRInt32 *aNumResults)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void OnStartRunningUrl (in nsIURI url); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::OnStartRunningUrl(nsIURI *url)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void OnStopRunningUrl (in nsIURI url, in nsresult aExitCode); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::OnStopRunningUrl(nsIURI *url, nsresult aExitCode)
|
||||
{
|
||||
GetNextUrl();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgSearchSession::Initialize()
|
||||
{
|
||||
// Loop over scope terms, initializing an adapter per term. This
|
||||
// architecture is necessitated by two things:
|
||||
// 1. There might be more than one kind of adapter per if online
|
||||
// *and* offline mail mail folders are selected, or if newsgroups
|
||||
// belonging to Dredd *and* INN are selected
|
||||
// 2. Most of the protocols are only capable of searching one scope at a
|
||||
// time, so we'll do each scope in a separate adapter on the client
|
||||
|
||||
nsMsgSearchScopeTerm *scopeTerm = nsnull;
|
||||
nsresult err = NS_OK;
|
||||
|
||||
// Ensure that the FE has added scopes and terms to this search
|
||||
NS_ASSERTION(m_termList.Count() > 0, "no terms to search!");
|
||||
if (m_termList.Count() == 0)
|
||||
return NS_MSG_ERROR_NO_SEARCH_VALUES;
|
||||
|
||||
// if we don't have any search scopes to search, return that code.
|
||||
if (m_scopeList.Count() == 0)
|
||||
return NS_MSG_ERROR_INVALID_SEARCH_SCOPE;
|
||||
|
||||
// If this term list (loosely specified here by the first term) should be
|
||||
// scheduled in parallel, build up a list of scopes to do the round-robin scheduling
|
||||
scopeTerm = m_scopeList.ElementAt(0);
|
||||
|
||||
for (int i = 0; i < m_scopeList.Count() && NS_SUCCEEDED(err); i++)
|
||||
{
|
||||
scopeTerm = m_scopeList.ElementAt(i);
|
||||
// NS_ASSERTION(scopeTerm->IsValid());
|
||||
|
||||
err = scopeTerm->InitializeAdapter (m_termList);
|
||||
|
||||
// if (scopeTerm->m_folder->GetType() == FOLDER_MAIL)
|
||||
// m_offlineProgressTotal += scopeTerm->m_folder->GetTotalMessages();
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
nsresult nsMsgSearchSession::BeginSearching()
|
||||
{
|
||||
nsresult err = NS_OK;;
|
||||
|
||||
// Here's a sloppy way to start the URL, but I don't really have time to
|
||||
// unify the scheduling mechanisms. If the first scope is a newsgroup, and
|
||||
// it's not Dredd-capable, we build the URL queue. All other searches can be
|
||||
// done with one URL
|
||||
|
||||
nsMsgSearchScopeTerm *scope = m_scopeList.ElementAt(0);
|
||||
if (scope->m_attribute == nsMsgSearchScope::Newsgroup /* && !scope->m_folder->KnowsSearchNntpExtension() */ && scope->m_searchServer)
|
||||
err = BuildUrlQueue ();
|
||||
else if (scope->m_attribute == nsMsgSearchScope::MailFolder && !scope->IsOfflineMail())
|
||||
err = BuildUrlQueue ();
|
||||
else
|
||||
err = SearchWOUrls();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgSearchSession::BuildUrlQueue ()
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i = 0; i < m_scopeList.Count(); i++)
|
||||
{
|
||||
nsCOMPtr <nsIMsgSearchAdapter> adapter = do_QueryInterface((m_scopeList.ElementAt(i))->m_adapter);
|
||||
nsXPIDLCString url;
|
||||
adapter->GetEncoding(getter_Copies(url));
|
||||
AddUrl (url);
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
GetNextUrl();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgSearchSession::GetNextUrl()
|
||||
{
|
||||
nsCString nextUrl;
|
||||
m_urlQueue.CStringAt(0, nextUrl);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMsgSearchSession::AddUrl(const char *url)
|
||||
{
|
||||
nsCString urlCString(url);
|
||||
m_urlQueue.AppendCString(urlCString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ void nsMsgSearchSession::TimerCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
nsMsgSearchSession *searchSession = (nsMsgSearchSession *) aClosure;
|
||||
PRBool done;
|
||||
searchSession->TimeSlice(&done);
|
||||
if (done)
|
||||
aTimer->Cancel();
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgSearchSession::SearchWOUrls ()
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
PRBool done;
|
||||
|
||||
NS_NewTimer(getter_AddRefs(m_backgroundTimer));
|
||||
m_backgroundTimer->Init(TimerCallback, (void *) this, 0, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK);
|
||||
// ### start meteors?
|
||||
err = TimeSlice(&done);
|
||||
#if 0
|
||||
if (!m_urlStruct)
|
||||
m_urlStruct = NET_CreateURLStruct ("search-libmsg:", NET_DONT_RELOAD);
|
||||
|
||||
if (m_urlStruct)
|
||||
{
|
||||
// Set the internal_url flag so just in case someone else happens to have
|
||||
// a search-libmsg URL, it won't fire my code, and surely crash.
|
||||
m_urlStruct->internal_url = TRUE;
|
||||
|
||||
// Initiate the asynchronous search
|
||||
int getUrlErr = m_pane->GetURL (m_urlStruct, FALSE);
|
||||
if (getUrlErr)
|
||||
err = (MSG_SearchError) -1; //###phil impedance mismatch
|
||||
else
|
||||
if (!XP_STRNCMP(m_urlStruct->address, "news:", 5) || !XP_STRNCMP(m_urlStruct->address, "snews:", 6))
|
||||
BeginCylonMode();
|
||||
}
|
||||
else
|
||||
err = NS_ERROR_OUT_OF_MEMORY;
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void nsMsgSearchSession::DestroyResultList ()
|
||||
{
|
||||
nsMsgResultElement *result = nsnull;
|
||||
for (int i = 0; i < m_resultList.Count(); i++)
|
||||
{
|
||||
result = m_resultList.ElementAt(i);
|
||||
// NS_ASSERTION (result->IsValid(), "invalid search result");
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nsMsgSearchSession::DestroyScopeList()
|
||||
{
|
||||
nsMsgSearchScopeTerm *scope = NULL;
|
||||
for (int i = 0; i < m_scopeList.Count(); i++)
|
||||
{
|
||||
scope = m_scopeList.ElementAt(i);
|
||||
// NS_ASSERTION (scope->IsValid(), "invalid search scope");
|
||||
delete scope;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nsMsgSearchSession::DestroyTermList ()
|
||||
{
|
||||
nsMsgSearchTerm *term = NULL;
|
||||
for (int i = 0; i < m_termList.Count(); i++)
|
||||
{
|
||||
term = m_termList.ElementAt(i);
|
||||
// NS_ASSERTION (term->IsValid(), "invalid search term");
|
||||
delete term;
|
||||
}
|
||||
}
|
||||
|
||||
nsMsgSearchScopeTerm *nsMsgSearchSession::GetRunningScope()
|
||||
{
|
||||
if (m_idxRunningScope < m_scopeList.Count())
|
||||
return m_scopeList.ElementAt (m_idxRunningScope);
|
||||
return nsnull;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMsgSearchSession::TimeSlice (PRBool *aDone)
|
||||
{
|
||||
// we only do serial for now.
|
||||
return TimeSliceSerial(aDone);
|
||||
}
|
||||
|
||||
nsresult nsMsgSearchSession::TimeSliceSerial (PRBool *aDone)
|
||||
{
|
||||
// This version of TimeSlice runs each scope term one at a time, and waits until one
|
||||
// scope term is finished before starting another one. When we're searching the local
|
||||
// disk, this is the fastest way to do it.
|
||||
|
||||
NS_ENSURE_ARG(aDone);
|
||||
|
||||
nsMsgSearchScopeTerm *scope = GetRunningScope();
|
||||
if (scope)
|
||||
{
|
||||
nsresult err = scope->TimeSlice (aDone);
|
||||
if (*aDone)
|
||||
{
|
||||
m_idxRunningScope++;
|
||||
// if (m_idxRunningScope < m_scopeList.Count())
|
||||
// UpdateStatusBar (MK_MSG_SEARCH_STATUS);
|
||||
}
|
||||
*aDone = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
*aDone = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -26,47 +26,61 @@
|
|||
#include "nscore.h"
|
||||
#include "nsMsgSearchCore.h"
|
||||
#include "nsIMsgSearchSession.h"
|
||||
#include "nsIUrlListener.h"
|
||||
#include "nsIMsgWindow.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
/* Use the code below as a template for the implementation class for this interface. */
|
||||
class nsMsgSearchAdapter;
|
||||
|
||||
/* Header file */
|
||||
class nsMsgSearchSession : public nsIMsgSearchSession
|
||||
class nsMsgSearchSession : public nsIMsgSearchSession, public nsIUrlListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMSGSEARCHSESSION
|
||||
NS_DECL_NSIURLLISTENER
|
||||
|
||||
nsMsgSearchSession();
|
||||
virtual ~nsMsgSearchSession();
|
||||
/* additional members */
|
||||
|
||||
protected:
|
||||
|
||||
NS_IMETHOD AddSearchTerm (nsMsgSearchAttribute attrib, /* attribute for this term */
|
||||
nsMsgSearchOperator op, /* operator e.g. opContains */
|
||||
nsMsgSearchValue *value, /* value e.g. "Dogbert" */
|
||||
PRBool BooleanAND, /* set to true if associated boolean operator is AND */
|
||||
char * arbitraryHeader); /* user defined arbitrary header. ignored unless attrib = attribOtherHeader */
|
||||
nsCOMPtr <nsIMsgWindow> m_window;
|
||||
|
||||
/* add a scope (e.g. a mail folder) to the search */
|
||||
NS_IMETHOD AddScopeTerm (
|
||||
nsMsgSearchScope attrib, /* what kind of scope term is this */
|
||||
nsIMsgFolder *folder); /* which folder to search */
|
||||
nsresult Initialize();
|
||||
nsresult TimeSlice (PRBool *aDone);
|
||||
nsMsgSearchAdapter *GetRunningAdapter ();
|
||||
nsMsgSearchScopeTerm *GetRunningScope();
|
||||
void StopRunning();
|
||||
nsresult BeginSearching();
|
||||
nsresult BuildUrlQueue ();
|
||||
nsresult AddUrl(const char *url);
|
||||
nsresult SearchWOUrls ();
|
||||
nsresult GetNextUrl();
|
||||
|
||||
/* Call this function everytime the scope changes! It informs the FE if
|
||||
the current scope support custom header use. FEs should not display the
|
||||
custom header dialog if custom headers are not supported */
|
||||
nsMsgSearchScopeTermArray m_scopeList;
|
||||
nsMsgSearchTermArray m_termList;
|
||||
nsMsgResultArray m_resultList;
|
||||
|
||||
NS_IMETHOD ScopeUsesCustomHeaders(nsMsgSearchScope scope,
|
||||
void * selection, /* could be a folder or server based on scope */
|
||||
PRBool forFilters, PRBool *result) ;
|
||||
void DestroyTermList ();
|
||||
void DestroyScopeList ();
|
||||
void DestroyResultList ();
|
||||
|
||||
/* add all scopes of a given type to the search */
|
||||
NS_IMETHOD AddAllScopes (nsMsgSearchScope attrib) ; /* what kind of scopes to add */
|
||||
static void TimerCallback(nsITimer *aTimer, void *aClosure);
|
||||
// support for searching multiple scopes in serial
|
||||
nsresult TimeSliceSerial (PRBool *aDone);
|
||||
nsresult TimeSliceParallel ();
|
||||
|
||||
NS_IMETHOD GetSearchType (nsMsgSearchType *aResult) ;
|
||||
NS_IMETHOD SetSearchParam (nsMsgSearchType type, /* type of specialized search to perform */
|
||||
void *param) ; /* extended search parameter */
|
||||
NS_IMETHOD GetNumResults (PRUint32 *numResults) ;
|
||||
nsMsgSearchAttribute m_sortAttribute;
|
||||
PRBool m_descending;
|
||||
// support for searching multiple scopes in parallel
|
||||
PRBool m_parallel;
|
||||
PRInt32 m_idxRunningScope;
|
||||
nsMsgSearchScopeTermArray m_parallelScopes;
|
||||
nsMsgSearchType m_searchType;
|
||||
void *m_pSearchParam;
|
||||
PRBool m_handlingError;
|
||||
nsCStringArray m_urlQueue;
|
||||
nsCOMPtr <nsITimer> m_backgroundTimer;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -254,7 +254,7 @@ nsMsgSearchTerm::nsMsgSearchTerm (
|
|||
nsMsgSearchOperator op,
|
||||
nsMsgSearchValue *val,
|
||||
nsMsgSearchBooleanOperator boolOp,
|
||||
char * arbitraryHeader)
|
||||
const char * arbitraryHeader)
|
||||
{
|
||||
m_operator = op;
|
||||
m_attribute = attrib;
|
||||
|
@ -1126,12 +1126,13 @@ nsresult nsMsgSearchTerm::InitHeaderAddressParser()
|
|||
//-----------------------------------------------------------------------------
|
||||
// nsMsgSearchScopeTerm implementation
|
||||
//-----------------------------------------------------------------------------
|
||||
nsMsgSearchScopeTerm::nsMsgSearchScopeTerm (nsMsgSearchScopeAttribute attribute, nsIMsgFolder *folder)
|
||||
nsMsgSearchScopeTerm::nsMsgSearchScopeTerm (nsIMsgSearchSession *session, nsMsgSearchScopeAttribute attribute, nsIMsgFolder *folder)
|
||||
{
|
||||
m_attribute = attribute;
|
||||
m_folder = folder;
|
||||
m_searchServer = PR_TRUE;
|
||||
m_fileStream = nsnull;
|
||||
m_searchSession = session;
|
||||
}
|
||||
|
||||
nsMsgSearchScopeTerm::nsMsgSearchScopeTerm ()
|
||||
|
@ -1190,7 +1191,7 @@ nsresult nsMsgSearchScopeTerm::GetMailPath(nsIFileSpec **aFileSpec)
|
|||
return (m_folder) ? m_folder->GetPath(aFileSpec) : NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult nsMsgSearchScopeTerm::TimeSlice ()
|
||||
nsresult nsMsgSearchScopeTerm::TimeSlice (PRBool *aDone)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче