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; }
/* void InterruptSearch (); */ NS_IMETHODIMP nsMsgSearchSession::InterruptSearch() { nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (msgWindow) { EnableFolderNotifications(PR_TRUE); if (m_idxRunningScope < m_scopeList.Count()) msgWindow->StopUrls(); while (m_idxRunningScope < m_scopeList.Count()) { ReleaseFolderDBRef(); m_idxRunningScope++; } //m_idxRunningScope = m_scopeList.Count() so it will make us not run another url } if (m_backgroundTimer) { m_backgroundTimer->Cancel(); NotifyListenersDone(NS_OK); // ### is there a cancelled status? m_backgroundTimer = nsnull; } 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; }
NS_IMETHODIMP nsMsgSearchSession::GetWindow(nsIMsgWindow **aWindow) { NS_ENSURE_ARG(aWindow); *aWindow = nsnull; nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); msgWindow.swap(*aWindow); return NS_OK; }
NS_IMETHODIMP MsgMailNewsUrlBase::GetMsgWindow(nsIMsgWindow **aMsgWindow) { NS_ENSURE_ARG_POINTER(aMsgWindow); *aMsgWindow = nullptr; nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); msgWindow.swap(*aMsgWindow); return *aMsgWindow ? NS_OK : NS_ERROR_NULL_POINTER; }
NS_IMETHODIMP nsMsgMailNewsUrl::GetMsgWindow(nsIMsgWindow **aMsgWindow) { NS_ENSURE_ARG_POINTER(aMsgWindow); *aMsgWindow = nsnull; // note: it is okay to return a null msg window and not return an error // it's possible the url really doesn't have msg window nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); msgWindow.swap(*aMsgWindow); return NS_OK; }
nsresult nsMsgSearchSession::BeginSearching() { // 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 nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (msgWindow) msgWindow->SetStopped(PR_FALSE); return DoNextSearch(); }
NS_IMETHODIMP nsMsgSearchDBView::OnStopCopy(nsresult aStatus) { if (NS_SUCCEEDED(aStatus)) { mCurIndex++; if ((int32_t) mCurIndex < m_uniqueFoldersSelected.Count()) { nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(mMsgWindowWeak)); ProcessRequestsInOneFolder(msgWindow); } } return NS_OK; }
NS_IMETHODIMP nsMsgGroupView::LoadMessageByViewIndex(nsMsgViewIndex aViewIndex) { if (m_flags[aViewIndex] & MSG_VIEW_FLAG_DUMMY) { // if we used to have one item selected, and now we have more than one, we should clear the message pane. nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(mMsgWindowWeak)); nsCOMPtr <nsIMsgWindowCommands> windowCommands; if (msgWindow && NS_SUCCEEDED(msgWindow->GetWindowCommands(getter_AddRefs(windowCommands))) && windowCommands) windowCommands->ClearMsgPane(); // since we are selecting a dummy row, we should also clear out m_currentlyDisplayedMsgUri m_currentlyDisplayedMsgUri.Truncate(); return NS_OK; } else return nsMsgDBView::LoadMessageByViewIndex(aViewIndex); }
nsresult nsMailboxUrl::GetMsgHdrForKey(nsMsgKey msgKey, nsIMsgDBHdr ** aMsgHdr) { nsresult rv = NS_OK; if (aMsgHdr && m_filePath) { nsCOMPtr<nsIMsgDatabase> mailDBFactory; nsCOMPtr<nsIMsgDatabase> mailDB; nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv); if (msgDBService) rv = msgDBService->OpenMailDBFromFile(m_filePath, nullptr, false, false, getter_AddRefs(mailDB)); if (NS_SUCCEEDED(rv) && mailDB) // did we get a db back? rv = mailDB->GetMsgHdrForKey(msgKey, aMsgHdr); else { nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (!msgWindow) { nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow)); } // maybe this is .eml file we're trying to read. See if we can get a header from the header sink. if (msgWindow) { nsCOMPtr<nsIMsgHeaderSink> headerSink; msgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink)); if (headerSink) { rv = headerSink->GetDummyMsgHeader(aMsgHdr); if (NS_SUCCEEDED(rv)) { int64_t fileSize = 0; m_filePath->GetFileSize(&fileSize); (*aMsgHdr)->SetMessageSize(fileSize); } } } } } else rv = NS_ERROR_NULL_POINTER; return rv; }
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */ NS_IMETHODIMP nsMsgProgress::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) { m_pendingStateFlags = aStateFlags; m_pendingStateValue = aStatus; nsCOMPtr<nsIMsgWindow> msgWindow (do_QueryReferent(m_msgWindow)); if (aStateFlags == nsIWebProgressListener::STATE_STOP && msgWindow && NS_FAILED(aStatus)) { msgWindow->StopUrls(); msgWindow->SetStatusFeedback(nsnull); } for (PRInt32 i = m_listenerList.Count() - 1; i >= 0; i --) m_listenerList[i]->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus); return NS_OK; }
NS_IMETHODIMP MsgMailNewsUrlBase::GetStatusFeedback(nsIMsgStatusFeedback **aMsgFeedback) { // note: it is okay to return a null status feedback and not return an error // it's possible the url really doesn't have status feedback *aMsgFeedback = nullptr; if (!m_statusFeedbackWeak) { nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (msgWindow) msgWindow->GetStatusFeedback(aMsgFeedback); } else { nsCOMPtr<nsIMsgStatusFeedback> statusFeedback(do_QueryReferent(m_statusFeedbackWeak)); statusFeedback.swap(*aMsgFeedback); } return *aMsgFeedback ? NS_OK : NS_ERROR_NULL_POINTER; }
/* static */ void nsMsgSearchSession::TimerCallback(nsITimer *aTimer, void *aClosure) { nsMsgSearchSession *searchSession = (nsMsgSearchSession *) aClosure; PRBool done; PRBool stopped = PR_FALSE; searchSession->TimeSlice(&done); nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(searchSession->m_msgWindowWeak)); if (msgWindow) msgWindow->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); } }
NS_IMETHODIMP MsgMailNewsUrlBase::GetLoadGroup(nsILoadGroup **aLoadGroup) { *aLoadGroup = nullptr; // note: it is okay to return a null load group and not return an error // it's possible the url really doesn't have load group nsCOMPtr<nsILoadGroup> loadGroup (do_QueryReferent(m_loadGroupWeak)); if (!loadGroup) { nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (msgWindow) { // XXXbz This is really weird... why are we getting some // random loadgroup we're not really a part of? nsCOMPtr<nsIDocShell> docShell; msgWindow->GetRootDocShell(getter_AddRefs(docShell)); loadGroup = do_GetInterface(docShell); m_loadGroupWeak = do_GetWeakReference(loadGroup); } } loadGroup.swap(*aLoadGroup); return *aLoadGroup ? NS_OK : NS_ERROR_NULL_POINTER; }
NS_IMETHODIMP nsMsgMailNewsUrl::Clone(nsIURI **_retval) { nsresult rv; nsCAutoString urlSpec; nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = GetSpec(urlSpec); NS_ENSURE_SUCCESS(rv, rv); rv = ioService->NewURI(urlSpec, nsnull, nsnull, _retval); NS_ENSURE_SUCCESS(rv, rv); // add the msg window to the cloned url nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (msgWindow) { nsCOMPtr<nsIMsgMailNewsUrl> msgMailNewsUrl = do_QueryInterface(*_retval, &rv); NS_ENSURE_SUCCESS(rv, rv); msgMailNewsUrl->SetMsgWindow(msgWindow); } return rv; }
NS_IMETHODIMP MsgMailNewsUrlBase::Clone(nsIURI **_retval) { nsresult rv; nsAutoCString urlSpec; nsCOMPtr<nsIIOService> ioService = mozilla::services::GetIOService(); NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED); rv = GetSpec(urlSpec); NS_ENSURE_SUCCESS(rv, rv); rv = ioService->NewURI(urlSpec, nullptr, nullptr, _retval); NS_ENSURE_SUCCESS(rv, rv); // add the msg window to the cloned url nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak)); if (msgWindow) { nsCOMPtr<nsIMsgMailNewsUrl> msgMailNewsUrl = do_QueryInterface(*_retval, &rv); NS_ENSURE_SUCCESS(rv, rv); msgMailNewsUrl->SetMsgWindow(msgWindow); } return rv; }