NS_IMETHODIMP nsMsgXFVirtualFolderDBView::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *aFolder) { NS_ENSURE_ARG(aMsgHdr); NS_ENSURE_ARG(aFolder); nsCOMPtr<nsIMsgDatabase> dbToUse; nsCOMPtr<nsIDBFolderInfo> folderInfo; aFolder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(dbToUse)); if (m_curFolderGettingHits != aFolder && m_doingSearch && !m_doingQuickSearch) { m_curFolderHasCachedHits = false; // since we've gotten a hit for a new folder, the searches for // any previous folders are done, so deal with stale cached hits // for those folders now. UpdateCacheAndViewForPrevSearchedFolders(aFolder); m_curFolderGettingHits = aFolder; m_hdrHits.Clear(); m_curFolderStartKeyIndex = m_keys.Length(); } bool hdrInCache = false; nsCString searchUri; if (!m_doingQuickSearch) { m_viewFolder->GetURI(searchUri); dbToUse->HdrIsInCache(searchUri.get(), aMsgHdr, &hdrInCache); } if (!m_doingSearch || !m_curFolderHasCachedHits || !hdrInCache) { if (m_viewFlags & nsMsgViewFlagsType::kGroupBySort) nsMsgGroupView::OnNewHeader(aMsgHdr, nsMsgKey_None, true); else if (m_sortValid) InsertHdrFromFolder(aMsgHdr, aFolder); else AddHdrFromFolder(aMsgHdr, aFolder); } m_hdrHits.AppendObject(aMsgHdr); m_totalMessagesInView++; return NS_OK; }
NS_IMETHODIMP nsMsgSearchDBView::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *folder) { NS_ENSURE_ARG(aMsgHdr); NS_ENSURE_ARG(folder); if (m_folders.IndexOf(folder) < 0 ) //do this just for new folder { nsCOMPtr<nsIMsgDatabase> dbToUse; nsCOMPtr<nsIDBFolderInfo> folderInfo; folder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(dbToUse)); if (dbToUse) { dbToUse->AddListener(this); m_dbToUseList.AppendObject(dbToUse); } } m_totalMessagesInView++; if (m_sortValid) return InsertHdrFromFolder(aMsgHdr, folder); else return AddHdrFromFolder(aMsgHdr, folder); }
NS_IMETHODIMP nsMsgXFVirtualFolderDBView::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *folder) { NS_ENSURE_ARG(aMsgHdr); NS_ENSURE_ARG(folder); nsCOMPtr <nsISupports> supports = do_QueryInterface(folder); nsCOMPtr<nsIMsgDatabase> dbToUse; nsCOMPtr<nsIDBFolderInfo> folderInfo; folder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(dbToUse)); if (m_curFolderGettingHits != folder && m_doingSearch) { m_curFolderHasCachedHits = PR_FALSE; // since we've gotten a hit for a new folder, the searches for // any previous folders are done, so deal with stale cached hits // for those folders now. UpdateCacheAndViewForPrevSearchedFolders(folder); m_curFolderGettingHits = folder; m_hdrHits.Clear(); m_curFolderStartKeyIndex = m_keys.Length(); } PRBool hdrInCache = PR_FALSE; nsCString searchUri; m_viewFolder->GetURI(searchUri); dbToUse->HdrIsInCache(searchUri.get(), aMsgHdr, &hdrInCache); if (!m_doingSearch || !m_curFolderHasCachedHits || !hdrInCache) { if (m_sortValid) InsertHdrFromFolder(aMsgHdr, supports); else AddHdrFromFolder(aMsgHdr, supports); } m_hdrHits.AppendObject(aMsgHdr); return NS_OK; }