diff --git a/mozilla/mailnews/base/search/public/nsIMsgSearchNotify.idl b/mozilla/mailnews/base/search/public/nsIMsgSearchNotify.idl index eac79f82d80..a2df6767bff 100644 --- a/mozilla/mailnews/base/search/public/nsIMsgSearchNotify.idl +++ b/mozilla/mailnews/base/search/public/nsIMsgSearchNotify.idl @@ -23,7 +23,7 @@ #include "nsISupports.idl" -interface nsIMsgHdr; +interface nsIMsgDBHdr; interface nsIMsgSearchSession; interface nsIMsgFolder; @@ -32,7 +32,7 @@ interface nsIMsgFolder; [scriptable, uuid(ca37784d-352b-4c39-8ccb-0abc1a93f681)] interface nsIMsgSearchNotify : nsISupports { - void onSearchHit(in nsIMsgHdr header, in nsIMsgFolder folder); + void onSearchHit(in nsIMsgDBHdr header, in nsIMsgFolder folder); /* * until we can encode searches with a URI, this will be an @@ -45,9 +45,5 @@ interface nsIMsgSearchNotify : nsISupports */ attribute nsIMsgSearchSession searchSession; - /** - * a unique URI that refers to the search session - */ - readonly attribute string searchSessionURI; }; diff --git a/mozilla/mailnews/base/search/public/nsIMsgSearchSession.idl b/mozilla/mailnews/base/search/public/nsIMsgSearchSession.idl index 219d4d508a5..61c1049347d 100644 --- a/mozilla/mailnews/base/search/public/nsIMsgSearchSession.idl +++ b/mozilla/mailnews/base/search/public/nsIMsgSearchSession.idl @@ -98,7 +98,7 @@ interface nsIMsgSearchSession : nsISupports { [noscript] void AddResultElement(in nsMsgResultElement element); - void AddSearchHit(in nsIMsgHdr header, in nsIMsgFolder folder); + void AddSearchHit(in nsIMsgDBHdr header, in nsIMsgFolder folder); readonly attribute long numResults; diff --git a/mozilla/mailnews/base/search/src/nsMsgSearchDataSource.cpp b/mozilla/mailnews/base/search/src/nsMsgSearchDataSource.cpp index 7cb02447fe9..5def182f11b 100644 --- a/mozilla/mailnews/base/search/src/nsMsgSearchDataSource.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgSearchDataSource.cpp @@ -25,17 +25,13 @@ #include "nsIRDFService.h" #include "nsMsgRDFUtils.h" +#include "nsIMessage.h" #include "nsIMsgHdr.h" #include "nsIMsgSearchSession.h" -typedef struct _notifyStruct { - nsIRDFResource *source; - nsIRDFResource *property; - nsIRDFResource *target; -} notifyStruct; - nsCOMPtr nsMsgSearchDataSource::kNC_MessageChild; nsrefcnt nsMsgSearchDataSource::gInstanceCount = 0; +PRUint32 nsMsgSearchDataSource::gCurrentURINum = 0; nsMsgSearchDataSource::nsMsgSearchDataSource() @@ -52,6 +48,7 @@ nsMsgSearchDataSource::Init() getRDFService()->GetResource(NC_RDF_MESSAGECHILD, getter_AddRefs(kNC_MessageChild)); } + mURINum = gCurrentURINum++; return NS_OK; } @@ -67,14 +64,20 @@ NS_IMPL_ISUPPORTS2(nsMsgSearchDataSource, nsIMsgSearchNotify) NS_IMETHODIMP -nsMsgSearchDataSource::OnSearchHit(nsIMsgHdr* aMessage, nsIMsgFolder *folder) +nsMsgSearchDataSource::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *folder) { nsresult rv; + + nsCOMPtr message; + folder->CreateMessageFromMsgDBHdr(aMsgHdr, getter_AddRefs(message)); + // this probably wont work. Need to convert nsMsgDBHdr -> nsMessage // probably through a URI or something nsCOMPtr messageResource = - do_QueryInterface(aMessage, &rv); + do_QueryInterface(message, &rv); + // should probably try to cache this with an in-memory datasource + // or something NotifyObservers(mSearchRoot, kNC_MessageChild, messageResource, PR_TRUE, PR_FALSE); return NS_OK; } @@ -95,24 +98,15 @@ nsMsgSearchDataSource::GetSearchSession(nsIMsgSearchSession** aResult) return NS_OK; } -NS_IMETHODIMP -nsMsgSearchDataSource::GetSearchSessionURI(char ** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - NS_ENSURE_TRUE(mSearchSession, NS_ERROR_NOT_INITIALIZED); - - nsCAutoString searchSessionUri("mailsearch:$"); - searchSessionUri.AppendInt((PRInt32)mSearchSession.get(), 16); - - *aResult = searchSessionUri.ToNewCString(); - return NS_OK; -} /* readonly attribute string URI; */ NS_IMETHODIMP nsMsgSearchDataSource::GetURI(char * *aURI) { - *aURI = nsCRT::strdup("NC:msgsearch"); + nsCAutoString uri("mailsearch:#"); + uri.AppendInt(mURINum); + + *aURI = uri.ToNewCString(); return NS_OK; } diff --git a/mozilla/mailnews/base/search/src/nsMsgSearchDataSource.h b/mozilla/mailnews/base/search/src/nsMsgSearchDataSource.h index 16e5896eeb8..5a035bf0c73 100644 --- a/mozilla/mailnews/base/search/src/nsMsgSearchDataSource.h +++ b/mozilla/mailnews/base/search/src/nsMsgSearchDataSource.h @@ -58,7 +58,10 @@ private: nsCOMPtr mSearchRoot; nsCOMPtr mSearchSession; + PRUint32 mURINum; + static nsrefcnt gInstanceCount; + static PRUint32 gCurrentURINum; static nsCOMPtr kNC_MessageChild; }; diff --git a/mozilla/mailnews/base/search/src/nsMsgSearchSession.cpp b/mozilla/mailnews/base/search/src/nsMsgSearchSession.cpp index eccdedcceb4..dea9e12f8f9 100644 --- a/mozilla/mailnews/base/search/src/nsMsgSearchSession.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgSearchSession.cpp @@ -507,7 +507,7 @@ NS_IMETHODIMP nsMsgSearchSession::GetRunningAdapter (nsIMsgSearchAdapter **aSear return NS_OK; } -NS_IMETHODIMP nsMsgSearchSession::AddSearchHit(nsIMsgHdr *header, nsIMsgFolder *folder) +NS_IMETHODIMP nsMsgSearchSession::AddSearchHit(nsIMsgDBHdr *header, nsIMsgFolder *folder) { if (m_listenerList) {