зеркало из https://github.com/mozilla/pjs.git
fix running search twice, send notification on search done, add support for interrupting search , 33101 r=sspitzer
This commit is contained in:
Родитель
3377684929
Коммит
d8bb834fce
|
@ -34,6 +34,8 @@ interface nsIMsgSearchNotify : nsISupports
|
|||
{
|
||||
void onSearchHit(in nsIMsgDBHdr header, in nsIMsgFolder folder);
|
||||
|
||||
// notification that a search has finished.
|
||||
void onSearchDone(in nsresult status);
|
||||
/*
|
||||
* until we can encode searches with a URI, this will be an
|
||||
* out-of-bound way to connect a set of search terms to a datasource
|
||||
|
|
|
@ -100,6 +100,13 @@ nsMsgSearchDataSource::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *folder)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::OnSearchDone(nsresult status)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// for now also acts as a way of resetting the search datasource
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::OnNewSearch()
|
||||
|
|
|
@ -326,7 +326,19 @@ NS_IMETHODIMP nsMsgSearchSession::Search(nsIMsgWindow *aWindow)
|
|||
/* void InterruptSearch (); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::InterruptSearch()
|
||||
{
|
||||
return NS_OK;
|
||||
if (m_window)
|
||||
{
|
||||
m_idxRunningScope = m_scopeList.Count(); // this'll make us not run another url
|
||||
m_window->StopUrls();
|
||||
}
|
||||
if (m_backgroundTimer)
|
||||
{
|
||||
m_backgroundTimer->Cancel();
|
||||
NotifyListenersDone(NS_OK); // ### is there a cancelled status?
|
||||
|
||||
m_backgroundTimer = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgSearchSession::PauseSearch()
|
||||
|
@ -408,6 +420,8 @@ NS_IMETHODIMP nsMsgSearchSession::OnStopRunningUrl(nsIURI *url, nsresult aExitCo
|
|||
m_idxRunningScope++;
|
||||
if (m_idxRunningScope < m_scopeList.Count())
|
||||
GetNextUrl();
|
||||
else
|
||||
NotifyListenersDone(aExitCode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -436,6 +450,9 @@ nsresult nsMsgSearchSession::Initialize()
|
|||
if (m_scopeList.Count() == 0)
|
||||
return NS_MSG_ERROR_INVALID_SEARCH_SCOPE;
|
||||
|
||||
m_urlQueue.Clear(); // clear out old urls, if any.
|
||||
m_idxRunningScope = 0;
|
||||
|
||||
// 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);
|
||||
|
@ -534,6 +551,7 @@ nsresult nsMsgSearchSession::AddUrl(const char *url)
|
|||
{
|
||||
aTimer->Cancel();
|
||||
searchSession->m_backgroundTimer = nsnull;
|
||||
searchSession->NotifyListenersDone(NS_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,6 +604,25 @@ NS_IMETHODIMP nsMsgSearchSession::AddSearchHit(nsIMsgDBHdr *header, nsIMsgFolder
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgSearchSession::NotifyListenersDone(nsresult status)
|
||||
{
|
||||
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->OnSearchDone(status);
|
||||
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMsgSearchSession::AddResultElement (nsMsgResultElement *element)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,7 @@ protected:
|
|||
nsresult AddUrl(const char *url);
|
||||
nsresult SearchWOUrls ();
|
||||
nsresult GetNextUrl();
|
||||
nsresult NotifyListenersDone(nsresult status);
|
||||
|
||||
nsMsgSearchScopeTermArray m_scopeList;
|
||||
nsCOMPtr <nsISupportsArray> m_termList;
|
||||
|
@ -69,6 +70,7 @@ protected:
|
|||
void DestroyScopeList ();
|
||||
void DestroyResultList ();
|
||||
|
||||
|
||||
static void TimerCallback(nsITimer *aTimer, void *aClosure);
|
||||
// support for searching multiple scopes in serial
|
||||
nsresult TimeSliceSerial (PRBool *aDone);
|
||||
|
|
Загрузка…
Ссылка в новой задаче