nsresult nsMsgSearchSession::GetNextUrl() { nsCString nextUrl; nsCOMPtr <nsIMsgMessageService> msgService; PRBool stopped = PR_FALSE; nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (msgWindow) msgWindow->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) { nsCString folderUri; folder->GetURI(folderUri); nsresult rv = GetMessageServiceFromURI(folderUri, getter_AddRefs(msgService)); if (NS_SUCCEEDED(rv) && msgService && currentTerm) msgService->Search(this, msgWindow, currentTerm->m_folder, nextUrl.get()); return rv; } return NS_OK; }
nsresult nsMsgSearchSession::GetNextUrl() { nsCString nextUrl; nsCOMPtr<nsIMsgMessageService> msgService; bool stopped = false; nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (msgWindow) msgWindow->GetStopped(&stopped); if (stopped) return NS_OK; nextUrl = m_urlQueue[m_urlQueueIndex]; nsMsgSearchScopeTerm *currentTerm = GetRunningScope(); NS_ENSURE_TRUE(currentTerm, NS_ERROR_NULL_POINTER); EnableFolderNotifications(false); nsCOMPtr<nsIMsgFolder> folder = currentTerm->m_folder; if (folder) { nsCString folderUri; folder->GetURI(folderUri); nsresult rv = GetMessageServiceFromURI(folderUri, getter_AddRefs(msgService)); if (NS_SUCCEEDED(rv) && msgService && currentTerm) msgService->Search(this, msgWindow, currentTerm->m_folder, nextUrl.get()); return rv; } return NS_OK; }
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); 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; } }
void nsMsgSearchSession::EnableFolderNotifications(PRBool aEnable) { 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); } }
NS_IMETHODIMP nsMsgSearchSession::GetRunningAdapter (nsIMsgSearchAdapter **aSearchAdapter) { NS_ENSURE_ARG(aSearchAdapter); nsMsgSearchScopeTerm *scope = GetRunningScope(); if (scope) { NS_ADDREF(*aSearchAdapter = scope->m_adapter); return NS_OK; } *aSearchAdapter = nsnull; return NS_OK; }
void nsMsgSearchSession::ReleaseFolderDBRef() { 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 && !(nsMsgFolderFlags::Inbox & flags)) folder->SetMsgDatabase(nsnull); } } }