mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Add notify observer related functions.
This commit is contained in:
parent
ec4f295a6d
commit
32cb66b89e
@ -21,6 +21,7 @@
|
||||
#include "rdf.h"
|
||||
#include "plstr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsMsgRDFUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
@ -269,3 +270,43 @@ nsMsgRDFDataSource::getRDFService()
|
||||
|
||||
return mRDFService;
|
||||
}
|
||||
|
||||
nsresult nsMsgRDFDataSource::NotifyObservers(nsIRDFResource *subject,
|
||||
nsIRDFResource *property,
|
||||
nsIRDFNode *object,
|
||||
PRBool assert)
|
||||
{
|
||||
if(mObservers)
|
||||
{
|
||||
nsMsgRDFNotification note = { subject, property, object };
|
||||
if (assert)
|
||||
mObservers->EnumerateForwards(assertEnumFunc, ¬e);
|
||||
else
|
||||
mObservers->EnumerateForwards(unassertEnumFunc, ¬e);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMsgRDFDataSource::assertEnumFunc(void *aElement, void *aData)
|
||||
{
|
||||
nsMsgRDFNotification *note = (nsMsgRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
||||
observer->OnAssert(note->subject,
|
||||
note->property,
|
||||
note->object);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMsgRDFDataSource::unassertEnumFunc(void *aElement, void *aData)
|
||||
{
|
||||
nsMsgRDFNotification* note = (nsMsgRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
||||
observer->OnUnassert(note->subject,
|
||||
note->property,
|
||||
note->object);
|
||||
return PR_TRUE;
|
||||
}
|
@ -143,8 +143,12 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
||||
protected:
|
||||
char *mURI;
|
||||
|
||||
nsIRDFService *getRDFService();
|
||||
|
||||
nsIRDFService *getRDFService();
|
||||
static PRBool assertEnumFunc(void *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(void *aElement, void *aData);
|
||||
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property,
|
||||
nsIRDFNode *object, PRBool assert);
|
||||
|
||||
private:
|
||||
nsIRDFService *mRDFService;
|
||||
nsVoidArray *mObservers;
|
||||
|
Loading…
x
Reference in New Issue
Block a user