Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes
nsMsgSearchSession Class Reference

#include <nsMsgSearchSession.h>

Inheritance diagram for nsMsgSearchSession:
Inheritance graph
[legend]
Collaboration diagram for nsMsgSearchSession:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIMSGSEARCHSESSION
NS_DECL_NSIURLLISTENER 
nsMsgSearchSession ()
virtual ~nsMsgSearchSession ()
void addSearchTerm (in nsMsgSearchAttribValue attrib, in nsMsgSearchOpValue op, in nsIMsgSearchValue value, in boolean BooleanAND, in string arbitraryHeader)
nsIMsgSearchTerm createTerm ()
void appendTerm (in nsIMsgSearchTerm term)
void registerListener (in nsIMsgSearchNotify listener)
void unregisterListener (in nsIMsgSearchNotify listener)
void getNthSearchTerm (in long whichTerm, in nsMsgSearchAttribValue attrib, in nsMsgSearchOpValue op, in nsIMsgSearchValue value)
long countSearchScopes ()
void getNthSearchScope (in long which, out nsMsgSearchScopeValue scopeId, out nsIMsgFolder folder)
void addScopeTerm (in nsMsgSearchScopeValue scope, in nsIMsgFolder folder)
void addDirectoryScopeTerm (in nsMsgSearchScopeValue scope)
void clearScopes ()
boolean ScopeUsesCustomHeaders (in nsMsgSearchScopeValue scope, in voidPtr selection, in boolean forFilters)
boolean IsStringAttribute (in nsMsgSearchAttribValue attrib)
void AddAllScopes (in nsMsgSearchScopeValue attrib)
void search (in nsIMsgWindow aWindow)
void interruptSearch ()
void pauseSearch ()
void resumeSearch ()
nsMsgSearchType SetSearchParam (in nsMsgSearchType type, in voidPtr param)
void AddResultElement (in nsMsgResultElement element)
boolean MatchHdr (in nsIMsgDBHdr aMsgHdr, in nsIMsgDatabase aDatabase)
void addSearchHit (in nsIMsgDBHdr header, in nsIMsgFolder folder)
void OnStartRunningUrl (in nsIURI url)
void OnStopRunningUrl (in nsIURI url, in nsresult aExitCode)

Public Attributes

readonly attribute nsISupportsArray searchTerms
readonly attribute unsigned long numSearchTerms
readonly attribute
nsIMsgSearchAdapter 
runningAdapter
readonly attribute voidPtr searchParam
readonly attribute nsMsgSearchType searchType
readonly attribute long numResults
attribute nsIMsgWindow window
const long BooleanOR = 0
const long BooleanAND = 1

Protected Member Functions

nsresult Initialize ()
nsresult StartTimer ()
nsresult TimeSlice (PRBool *aDone)
nsMsgSearchScopeTermGetRunningScope ()
void StopRunning ()
nsresult BeginSearching ()
nsresult DoNextSearch ()
nsresult BuildUrlQueue ()
nsresult AddUrl (const char *url)
nsresult SearchWOUrls ()
nsresult GetNextUrl ()
nsresult NotifyListenersDone (nsresult status)
void EnableFolderNotifications (PRBool aEnable)
void ReleaseFolderDBRef ()
void DestroyTermList ()
void DestroyScopeList ()
void DestroyResultList ()
nsresult TimeSliceSerial (PRBool *aDone)
nsresult TimeSliceParallel ()

Static Protected Member Functions

static void TimerCallback (nsITimer *aTimer, void *aClosure)

Protected Attributes

nsCOMPtr< nsIMsgWindowm_window
nsMsgSearchScopeTermArray m_scopeList
nsCOMPtr< nsISupportsArraym_termList
nsCOMPtr< nsISupportsArraym_listenerList
nsMsgResultArray m_resultList
nsMsgSearchAttribValue m_sortAttribute
PRInt32 m_idxRunningScope
nsMsgSearchType m_searchType
PRBool m_handlingError
PRInt32 m_urlQueueIndex
nsCStringArray m_urlQueue
nsCOMPtr< nsITimerm_backgroundTimer
PRBool m_searchPaused
nsMsgSearchBoolExpressionm_expressionTree

Detailed Description

Definition at line 55 of file nsMsgSearchSession.h.


Constructor & Destructor Documentation

Definition at line 69 of file nsMsgSearchSession.cpp.

{
  InterruptSearch();
  delete m_expressionTree;
  DestroyResultList ();
  DestroyScopeList ();
  DestroyTermList ();
}

Here is the call graph for this function:


Member Function Documentation

void nsIMsgSearchSession::addSearchHit ( in nsIMsgDBHdr  header,
in nsIMsgFolder  folder 
) [inherited]
void nsIMsgSearchSession::addSearchTerm ( in nsMsgSearchAttribValue  attrib,
in nsMsgSearchOpValue  op,
in nsIMsgSearchValue  value,
in boolean  BooleanAND,
in string  arbitraryHeader 
) [inherited]
nsresult nsMsgSearchSession::AddUrl ( const char *  url) [protected]

Definition at line 516 of file nsMsgSearchSession.cpp.

{
  nsCString urlCString(url);
  m_urlQueue.AppendCString(urlCString);
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 437 of file nsMsgSearchSession.cpp.

{
  // 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
  
  if (m_window)
    m_window->SetStopped(PR_FALSE);
  return DoNextSearch();
}

Here is the call graph for this function:

Definition at line 460 of file nsMsgSearchSession.cpp.

{
  PRInt32 i;
  for (i = m_idxRunningScope; i < m_scopeList.Count(); i++)
  {
    nsMsgSearchScopeTerm *scope = m_scopeList.ElementAt(i);
    if (scope->m_attribute != nsMsgSearchScope::onlineMail && 
      (scope->m_attribute != nsMsgSearchScope::news && scope->m_searchServer))
      break;
    nsCOMPtr <nsIMsgSearchAdapter> adapter = do_QueryInterface((m_scopeList.ElementAt(i))->m_adapter);
    nsXPIDLCString url;
    if (adapter)
    {
      adapter->GetEncoding(getter_Copies(url));
      AddUrl (url);
    }
  }
  
  if (i > 0)
    GetNextUrl();
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 624 of file nsMsgSearchSession.cpp.

{
  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;
  }
  m_resultList.Clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 637 of file nsMsgSearchSession.cpp.

{
  nsMsgSearchScopeTerm *scope = NULL;
  PRInt32 count = m_scopeList.Count();
  
  for (PRInt32 i = count-1; i >= 0; i--)
  {
    scope = m_scopeList.ElementAt(i);
    //        NS_ASSERTION (scope->IsValid(), "invalid search scope");
    delete scope;
  }
  m_scopeList.Clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 652 of file nsMsgSearchSession.cpp.

{
    m_termList->Clear();
}

Here is the caller graph for this function:

Definition at line 449 of file nsMsgSearchSession.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 733 of file nsMsgSearchSession.cpp.

{
  nsMsgSearchScopeTerm *scope = GetRunningScope();
  if (scope)
  {
    nsCOMPtr<nsIMsgFolder> folder;
    scope->GetFolder(getter_AddRefs(folder));
    if (folder)  //enable msg count notifications
      folder->EnableNotifications(nsIMsgFolder::allMessageCountNotifications, aEnable, PR_FALSE);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 485 of file nsMsgSearchSession.cpp.

{
  nsCString nextUrl;
  nsCOMPtr <nsIMsgMessageService> msgService;


  PRBool stopped = PR_FALSE;

  if (m_window)
    m_window->GetStopped(&stopped);
  if (stopped)
    return NS_OK;

  m_urlQueue.CStringAt(m_urlQueueIndex, nextUrl);
  nsMsgSearchScopeTerm *currentTerm = GetRunningScope();
  EnableFolderNotifications(PR_FALSE);
  nsCOMPtr <nsIMsgFolder> folder = currentTerm->m_folder;
  if (folder)
  {
    nsXPIDLCString folderUri;
    folder->GetURI(getter_Copies(folderUri));
    nsresult rv = GetMessageServiceFromURI(folderUri.get(), getter_AddRefs(msgService));

    if (NS_SUCCEEDED(rv) && msgService && currentTerm)
      msgService->Search(this, m_window, currentTerm->m_folder, nextUrl.get());

    return rv;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 657 of file nsMsgSearchSession.cpp.

{
    return (nsMsgSearchScopeTerm *) m_scopeList.SafeElementAt(m_idxRunningScope); 
}

Here is the caller graph for this function:

Definition at line 396 of file nsMsgSearchSession.cpp.

{
  // 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;

  PRUint32 numTerms;
  m_termList->Count(&numTerms);
  // Ensure that the FE has added scopes and terms to this search
  NS_ASSERTION(numTerms > 0, "no terms to search!");
  if (numTerms == 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;

  m_urlQueue.Clear(); // clear out old urls, if any.
  m_idxRunningScope = 0; 
  m_urlQueueIndex = 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
  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);
  }
  
  return err;
}

Here is the call graph for this function:

boolean nsIMsgSearchSession::MatchHdr ( in nsIMsgDBHdr  aMsgHdr,
in nsIMsgDatabase  aDatabase 
) [inherited]

Definition at line 594 of file nsMsgSearchSession.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

void nsIUrlListener::OnStopRunningUrl ( in nsIURI  url,
in nsresult  aExitCode 
) [inherited]

Here is the caller graph for this function:

Definition at line 668 of file nsMsgSearchSession.cpp.

{
  nsMsgSearchScopeTerm *scope = GetRunningScope();
  if (scope)
  {
    PRBool isOpen =PR_FALSE;
    PRUint32 flags;
    nsCOMPtr <nsIMsgFolder> folder;
    scope->GetFolder(getter_AddRefs(folder));
    nsCOMPtr <nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID);
    if (mailSession && folder)
    {
      mailSession->IsFolderOpenInWindow(folder, &isOpen);
      folder->GetFlags(&flags);

      /*we don't null out the db reference for inbox because inbox is like the "main" folder
       and performance outweighs footprint */
      if (!isOpen && !(MSG_FOLDER_FLAG_INBOX & flags)) 
        folder->SetMsgDatabase(nsnull);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIMsgSearchSession::ScopeUsesCustomHeaders ( in nsMsgSearchScopeValue  scope,
in voidPtr  selection,
in boolean  forFilters 
) [inherited]
void nsIMsgSearchSession::search ( in nsIMsgWindow  aWindow) [inherited]

Definition at line 556 of file nsMsgSearchSession.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsMsgSearchType nsIMsgSearchSession::SetSearchParam ( in nsMsgSearchType  type,
in voidPtr  param 
) [inherited]

Definition at line 544 of file nsMsgSearchSession.cpp.

{
  nsresult err;
  PRBool done;

  m_backgroundTimer = do_CreateInstance("@mozilla.org/timer;1", &err);
  m_backgroundTimer->InitWithFuncCallback(TimerCallback, (void *) this, 0, 
                                          nsITimer::TYPE_REPEATING_SLACK);
  // ### start meteors?
  return TimeSlice(&done);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMsgSearchSession::TimerCallback ( nsITimer aTimer,
void aClosure 
) [static, protected]

Definition at line 523 of file nsMsgSearchSession.cpp.

{
  nsMsgSearchSession *searchSession = (nsMsgSearchSession *) aClosure;
  PRBool done;
  PRBool stopped = PR_FALSE;

  searchSession->TimeSlice(&done);
  if (searchSession->m_window)
    searchSession->m_window->GetStopped(&stopped);

  if (done || stopped)
  {
    aTimer->Cancel();
    searchSession->m_backgroundTimer = nsnull;
    if (searchSession->m_idxRunningScope < searchSession->m_scopeList.Count())
      searchSession->DoNextSearch();
    else
      searchSession->NotifyListenersDone(NS_OK);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgSearchSession::TimeSlice ( PRBool aDone) [protected]

Definition at line 662 of file nsMsgSearchSession.cpp.

{
  // we only do serial for now.
  return TimeSliceSerial(aDone);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 690 of file nsMsgSearchSession.cpp.

{
  // 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);
  nsresult rv = NS_OK;
  nsMsgSearchScopeTerm *scope = GetRunningScope();
  if (scope)
  {
    rv = scope->TimeSlice (aDone);
    if (NS_FAILED(rv))
      *aDone = PR_TRUE;
    if (*aDone || NS_FAILED(rv))
    {
      EnableFolderNotifications(PR_TRUE);
      ReleaseFolderDBRef();
      m_idxRunningScope++;
      EnableFolderNotifications(PR_FALSE);
      // check if the next scope is an online search; if so,
      // set *aDone to true so that we'll try to run the next
      // search in TimerCallback.
      scope = GetRunningScope();
      if (scope && (scope->m_attribute == nsMsgSearchScope::onlineMail || 
        (scope->m_attribute == nsMsgSearchScope::news && scope->m_searchServer)))
      {
        *aDone = PR_TRUE;
        return rv;
      }

    }
    *aDone = PR_FALSE;
    return rv;
  }
  else
  {
    *aDone = PR_TRUE;
    return NS_OK;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 134 of file nsIMsgSearchSession.idl.

Definition at line 133 of file nsIMsgSearchSession.idl.

Definition at line 105 of file nsMsgSearchSession.h.

Definition at line 107 of file nsMsgSearchSession.h.

Definition at line 102 of file nsMsgSearchSession.h.

Definition at line 100 of file nsMsgSearchSession.h.

Definition at line 86 of file nsMsgSearchSession.h.

Definition at line 88 of file nsMsgSearchSession.h.

Definition at line 84 of file nsMsgSearchSession.h.

Definition at line 106 of file nsMsgSearchSession.h.

Definition at line 101 of file nsMsgSearchSession.h.

Definition at line 99 of file nsMsgSearchSession.h.

Definition at line 85 of file nsMsgSearchSession.h.

nsCStringArray nsMsgSearchSession::m_urlQueue [protected]

Definition at line 104 of file nsMsgSearchSession.h.

Definition at line 103 of file nsMsgSearchSession.h.

Definition at line 67 of file nsMsgSearchSession.h.

Definition at line 129 of file nsIMsgSearchSession.idl.

readonly attribute unsigned long nsIMsgSearchSession::numSearchTerms [inherited]

Definition at line 72 of file nsIMsgSearchSession.idl.

Definition at line 74 of file nsIMsgSearchSession.idl.

readonly attribute voidPtr nsIMsgSearchSession::searchParam [inherited]

Definition at line 118 of file nsIMsgSearchSession.idl.

Definition at line 64 of file nsIMsgSearchSession.idl.

Definition at line 119 of file nsIMsgSearchSession.idl.

Definition at line 130 of file nsIMsgSearchSession.idl.


The documentation for this class was generated from the following files: