more work on search backend, 33101 r=alecf, notify fe of search hits

This commit is contained in:
bienvenu%netscape.com 2000-06-08 21:56:04 +00:00
Родитель bde71a9fe8
Коммит 6ff86afc7f
5 изменённых файлов: 54 добавлений и 0 удалений

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

@ -27,6 +27,8 @@
interface nsMsgResultElement;
interface nsIMsgSearchAdapter;
interface nsIMsgSearchTerm;
interface nsIMsgSearchNotify;
interface nsIMsgHdr;
//////////////////////////////////////////////////////////////////////////////
// The Msg Search Session is an interface designed to make constructing
@ -47,6 +49,9 @@ interface nsIMsgSearchSession : nsISupports {
void CreateSearchTerm (out nsIMsgSearchTerm searchTerm);
void RegisterListener (in nsIMsgSearchNotify listener);
void UnregisterListener (in nsIMsgSearchNotify listener);
readonly attribute unsigned long numSearchTerms;
readonly attribute nsIMsgSearchAdapter runningAdapter;
@ -93,6 +98,8 @@ interface nsIMsgSearchSession : nsISupports {
[noscript] void AddResultElement(in nsMsgResultElement element);
void AddSearchHit(in nsIMsgHdr header);
readonly attribute long numResults;
/* these longs are all actually of type nsMsgSearchBooleanOp */

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

@ -159,7 +159,10 @@ NS_IMETHODIMP nsMsgSearchOnlineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
nsCOMPtr<nsIMsgSearchSession> searchSession;
m_scope->GetSearchSession(getter_AddRefs(searchSession));
if (searchSession)
{
searchSession->AddResultElement(newResult);
searchSession->AddSearchHit(pHeaders);
}
//XXXX alecf do not checkin without fixing! m_scope->m_searchSession->AddResultElement (newResult);
}
return err;

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

@ -818,7 +818,10 @@ NS_IMETHODIMP nsMsgSearchOfflineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
nsCOMPtr<nsIMsgSearchSession> searchSession;
m_scope->GetSearchSession(getter_AddRefs(searchSession));
if (searchSession)
{
searchSession->AddResultElement(newResult);
searchSession->AddSearchHit(pHeaders);
}
}
return err;
}

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

@ -30,6 +30,7 @@
#include "nsIMsgMessageService.h"
#include "nsMsgUtils.h"
#include "nsXPIDLString.h"
#include "nsIMsgSearchNotify.h"
NS_IMPL_ISUPPORTS2(nsMsgSearchSession, nsIMsgSearchSession, nsIUrlListener)
@ -88,6 +89,26 @@ nsMsgSearchSession::CreateSearchTerm(nsIMsgSearchTerm **aResult)
return NS_OK;
}
/* void RegisterListener (in nsIMsgSearchNotify listener); */
NS_IMETHODIMP nsMsgSearchSession::RegisterListener(nsIMsgSearchNotify *listener)
{
nsresult ret = NS_OK;
if (!m_listenerList)
ret = NS_NewISupportsArray(getter_AddRefs(m_listenerList));
if (NS_SUCCEEDED(ret) && m_listenerList)
m_listenerList->AppendElement(listener);
return ret;
}
/* void UnregisterListener (in nsIMsgSearchNotify listener); */
NS_IMETHODIMP nsMsgSearchSession::UnregisterListener(nsIMsgSearchNotify *listener)
{
if (m_listenerList)
m_listenerList->RemoveElement(listener);
return NS_OK;
}
/* readonly attribute long numSearchTerms; */
NS_IMETHODIMP nsMsgSearchSession::GetNumSearchTerms(PRUint32 *aNumSearchTerms)
{
@ -478,6 +499,24 @@ NS_IMETHODIMP nsMsgSearchSession::GetRunningAdapter (nsIMsgSearchAdapter **aSear
return NS_OK;
}
NS_IMETHODIMP nsMsgSearchSession::AddSearchHit(nsIMsgHdr *header)
{
if (m_listenerList)
{
PRUint32 count;
m_listenerList->Count(&count);
for (PRUint32 i = 0; i < count; i++)
{
nsCOMPtr<nsIMsgSearchNotify> pListener;
m_listenerList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchNotify),
(void **)getter_AddRefs(pListener));
if (pListener)
pListener->OnSearchHit(header);
}
}
return NS_OK;
}
NS_IMETHODIMP nsMsgSearchSession::AddResultElement (nsMsgResultElement *element)

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

@ -60,6 +60,8 @@ protected:
nsMsgSearchScopeTermArray m_scopeList;
nsCOMPtr <nsISupportsArray> m_termList;
nsCOMPtr <nsISupportsArray> m_listenerList;
nsMsgResultArray m_resultList;
void DestroyTermList ();