зеркало из https://github.com/mozilla/gecko-dev.git
update search datasource for #33101 - allow nsIMessages to be created from nsIMsgDBHdrs, and get rid of extraneous attribute from the search hit notify listener
r=sspitzer
This commit is contained in:
Родитель
b974494f9b
Коммит
1124ed9e8c
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<nsIRDFResource> 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<nsIMessage> message;
|
||||
folder->CreateMessageFromMsgDBHdr(aMsgHdr, getter_AddRefs(message));
|
||||
|
||||
// this probably wont work. Need to convert nsMsgDBHdr -> nsMessage
|
||||
// probably through a URI or something
|
||||
nsCOMPtr<nsIRDFResource> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,10 @@ private:
|
|||
nsCOMPtr<nsIRDFResource> mSearchRoot;
|
||||
nsCOMPtr<nsIMsgSearchSession> mSearchSession;
|
||||
|
||||
PRUint32 mURINum;
|
||||
|
||||
static nsrefcnt gInstanceCount;
|
||||
static PRUint32 gCurrentURINum;
|
||||
static nsCOMPtr<nsIRDFResource> kNC_MessageChild;
|
||||
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче