зеркало из https://github.com/mozilla/pjs.git
update search datasource to have a search session URI, and derive
from the base nsMsgRDFDataSource (not yet part of build)
This commit is contained in:
Родитель
7eda727f84
Коммит
d72fce8c1d
|
@ -1,33 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIMsgHdr.idl"
|
||||
|
||||
// when a search is run, this interface is passed in as a listener
|
||||
// on the search.
|
||||
[scriptable, uuid(ca37784d-352b-4c39-8ccb-0abc1a93f681)]
|
||||
interface nsIMsgSearchHitNotify : nsISupports
|
||||
{
|
||||
void onSearchHit(in nsIMsgHdr header);
|
||||
};
|
||||
|
|
@ -25,10 +25,13 @@
|
|||
#include "nsIRDFService.h"
|
||||
#include "nsMsgRDFUtils.h"
|
||||
|
||||
#include "nsIMsgHdr.h"
|
||||
#include "nsIMsgSearchSession.h"
|
||||
|
||||
typedef struct _notifyStruct {
|
||||
nsIRDFResource *source;
|
||||
nsIRDFResource *property;
|
||||
nsIRDFResource *target;
|
||||
nsIRDFResource *source;
|
||||
nsIRDFResource *property;
|
||||
nsIRDFResource *target;
|
||||
} notifyStruct;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> nsMsgSearchDataSource::kNC_MessageChild;
|
||||
|
@ -37,104 +40,82 @@ nsrefcnt nsMsgSearchDataSource::gInstanceCount = 0;
|
|||
|
||||
nsMsgSearchDataSource::nsMsgSearchDataSource()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgSearchDataSource::Init()
|
||||
{
|
||||
if (gInstanceCount++ == 0) {
|
||||
if (gInstanceCount++ == 0) {
|
||||
|
||||
getRDFService()->GetResource(NC_RDF_MESSAGECHILD, getter_AddRefs(kNC_MessageChild));
|
||||
}
|
||||
getRDFService()->GetResource(NC_RDF_MESSAGECHILD, getter_AddRefs(kNC_MessageChild));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsMsgSearchDataSource::~nsMsgSearchDataSource()
|
||||
{
|
||||
if (--gInstanceCount == 0) {
|
||||
kNC_MessageChild = nsnull;
|
||||
}
|
||||
if (--gInstanceCount == 0) {
|
||||
kNC_MessageChild = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsMsgSearchDataSource,
|
||||
nsIRDFDataSource,
|
||||
nsIMsgSearchHitNotify)
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::OnSearchHit(nsIMsgHdr* aMessage)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> messageResource = do_QueryInterface(aMessage, &rv);
|
||||
nsresult rv;
|
||||
// this probably wont work. Need to convert nsMsgDBHdr -> nsMessage
|
||||
// probably through a URI or something
|
||||
nsCOMPtr<nsIRDFResource> messageResource =
|
||||
do_QueryInterface(aMessage, &rv);
|
||||
|
||||
notifyObserversAssert(mSearchRoot, kNC_MessageChild, messageResource);
|
||||
return NS_OK;
|
||||
NotifyObservers(mSearchRoot, kNC_MessageChild, messageResource, PR_TRUE, PR_FALSE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgSearchDataSource::notifyObserversAssert(nsIRDFResource *aSource,
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFResource *aTarget)
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::SetSearchSession(nsIMsgSearchSession* aSession)
|
||||
{
|
||||
// no observers to notify, that's ok
|
||||
if (!mObservers) return NS_OK;
|
||||
|
||||
notifyStruct notifyMessage;
|
||||
notifyMessage.source = aSource;
|
||||
notifyMessage.property = aProperty;
|
||||
notifyMessage.target = aTarget;
|
||||
|
||||
mObservers->EnumerateForwards(notifyAssert, (void *)¬ifyMessage);
|
||||
|
||||
return NS_OK;
|
||||
mSearchSession = aSession;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMsgSearchDataSource::notifyAssert(nsISupports* aElement, void *aData)
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::GetSearchSession(nsIMsgSearchSession** aResult)
|
||||
{
|
||||
nsIRDFObserver *observer = (nsIRDFObserver*)aElement;
|
||||
notifyStruct *notifyMessage = (notifyStruct *)aData;
|
||||
|
||||
observer->OnAssert(notifyMessage->source,
|
||||
notifyMessage->property,
|
||||
notifyMessage->target);
|
||||
return PR_TRUE;
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
(*aResult) = mSearchSession;
|
||||
NS_IF_ADDREF(*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");
|
||||
return NS_OK;
|
||||
*aURI = nsCRT::strdup("NC:msgsearch");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::GetSource(nsIRDFResource *aProperty,
|
||||
nsIRDFNode *aTarget,
|
||||
PRBool aTruthValue, nsIRDFResource **aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsISimpleEnumerator **aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsIRDFNode **aResult)
|
||||
{
|
||||
// hopefully the message datasource will answer all these questions for us
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
|
@ -143,44 +124,10 @@ nsMsgSearchDataSource::GetTargets(nsIRDFResource *aSource,
|
|||
PRBool aTruthValue,
|
||||
nsISimpleEnumerator **aResult)
|
||||
{
|
||||
// decode the search results?
|
||||
// decode the search results?
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::Assert(nsIRDFResource *aSource,
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFNode *aTarget, PRBool aTruthValue)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::Unassert(nsIRDFResource *aSource,
|
||||
nsIRDFResource *aProperty, nsIRDFNode *aTarget)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void Change (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aOldTarget, in nsIRDFNode aNewTarget); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::Change(nsIRDFResource *aSource,
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFNode *aOldTarget, nsIRDFNode *aNewTarget)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void Move (in nsIRDFResource aOldSource, in nsIRDFResource aNewSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::Move(nsIRDFResource *aOldSource,
|
||||
nsIRDFResource *aNewSource,
|
||||
nsIRDFResource *aProperty, nsIRDFNode *aTarget)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
|
@ -193,36 +140,6 @@ nsMsgSearchDataSource::HasAssertion(nsIRDFResource *aSource,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void AddObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::AddObserver(nsIRDFObserver *aObserver)
|
||||
{
|
||||
nsresult rv;
|
||||
if (!mObservers) {
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
mObservers->AppendElement(aObserver);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void RemoveObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::RemoveObserver(nsIRDFObserver *aObserver)
|
||||
{
|
||||
NS_ENSURE_TRUE(mObservers, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
return mObservers->RemoveElement(aObserver);
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::ArcLabelsIn(nsIRDFNode *aNode,
|
||||
nsISimpleEnumerator **aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */
|
||||
NS_IMETHODIMP
|
||||
|
@ -232,42 +149,3 @@ nsMsgSearchDataSource::ArcLabelsOut(nsIRDFResource *aSource,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator GetAllResources (); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::GetAllResources(nsISimpleEnumerator **aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::IsCommandEnabled(nsISupportsArray *aSources,
|
||||
nsIRDFResource *aCommand,
|
||||
nsISupportsArray *aArguments, PRBool *aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::DoCommand(nsISupportsArray *aSources,
|
||||
nsIRDFResource *aCommand,
|
||||
nsISupportsArray *aArguments)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator GetAllCmds (in nsIRDFResource aSource); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDataSource::GetAllCmds(nsIRDFResource *aSource,
|
||||
nsISimpleEnumerator **aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче