зеркало из https://github.com/mozilla/pjs.git
Land RDF_19990617_BRANCH. Add Change() and Move() methods to nsIRDFDataSource; add OnChange() and OnMove() methods to nsIRDFObserver. Factor nsIRDFDatasource::Init() and ::Flush() into nsIRDFRemoteDataSource. Change ownership model s.t. a datasource reference counts its observers. Miscellaneous XPCOM fixage -- NS_ISUPPORTS_DECL_INHERITED where appropriate.
This commit is contained in:
Родитель
f008503b2f
Коммит
2c513b5198
|
@ -155,17 +155,17 @@ void nsABCardDataSource::createNode(PRUint32 value, nsIRDFNode **node)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsABCardDataSource::nsABCardDataSource():
|
nsABCardDataSource::nsABCardDataSource():
|
||||||
mURI(nsnull),
|
|
||||||
mObservers(nsnull),
|
mObservers(nsnull),
|
||||||
mInitialized(PR_FALSE),
|
mInitialized(PR_FALSE),
|
||||||
mRDFService(nsnull)
|
mRDFService(nsnull)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
|
|
||||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||||
nsIRDFService::GetIID(),
|
// method that the factory calls, so that failure to construct
|
||||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
// will return an error code instead of returning a partially
|
||||||
|
// initialized object.
|
||||||
|
nsresult rv = Init();
|
||||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,16 +173,6 @@ nsABCardDataSource::~nsABCardDataSource (void)
|
||||||
{
|
{
|
||||||
mRDFService->UnregisterDataSource(this);
|
mRDFService->UnregisterDataSource(this);
|
||||||
|
|
||||||
PL_strfree(mURI);
|
|
||||||
if (mObservers) {
|
|
||||||
|
|
||||||
PRInt32 i;
|
|
||||||
for (i = mObservers->Count() - 1; i >= 0; --i) {
|
|
||||||
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
|
||||||
NS_RELEASE(obs);
|
|
||||||
}
|
|
||||||
delete mObservers;
|
|
||||||
}
|
|
||||||
nsrefcnt refcnt;
|
nsrefcnt refcnt;
|
||||||
|
|
||||||
NS_RELEASE2(kNC_PersonName, refcnt);
|
NS_RELEASE2(kNC_PersonName, refcnt);
|
||||||
|
@ -200,6 +190,36 @@ nsABCardDataSource::~nsABCardDataSource (void)
|
||||||
mRDFService = nsnull;
|
mRDFService = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult nsABCardDataSource::Init()
|
||||||
|
{
|
||||||
|
if (mInitialized)
|
||||||
|
return NS_ERROR_ALREADY_INITIALIZED;
|
||||||
|
|
||||||
|
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
|
nsIRDFService::GetIID(),
|
||||||
|
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||||
|
|
||||||
|
if (! kNC_PersonName) {
|
||||||
|
|
||||||
|
mRDFService->GetResource(kURINC_PersonName, &kNC_PersonName);
|
||||||
|
mRDFService->GetResource(kURINC_ListName, &kNC_ListName);
|
||||||
|
mRDFService->GetResource(kURINC_Email, &kNC_Email);
|
||||||
|
mRDFService->GetResource(kURINC_City, &kNC_City);
|
||||||
|
mRDFService->GetResource(kURINC_Organization, &kNC_Organization);
|
||||||
|
mRDFService->GetResource(kURINC_WorkPhone, &kNC_WorkPhone);
|
||||||
|
mRDFService->GetResource(kURINC_Nickname, &kNC_Nickname);
|
||||||
|
|
||||||
|
mRDFService->GetResource(kURINC_Delete, &kNC_Delete);
|
||||||
|
mRDFService->GetResource(kURINC_NewCard, &kNC_NewCard);
|
||||||
|
}
|
||||||
|
mInitialized = PR_TRUE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsABCardDataSource)
|
NS_IMPL_ADDREF(nsABCardDataSource)
|
||||||
NS_IMPL_RELEASE(nsABCardDataSource)
|
NS_IMPL_RELEASE(nsABCardDataSource)
|
||||||
|
@ -228,36 +248,9 @@ nsABCardDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHODIMP nsABCardDataSource::Init(const char* uri)
|
|
||||||
{
|
|
||||||
if (mInitialized)
|
|
||||||
return NS_ERROR_ALREADY_INITIALIZED;
|
|
||||||
|
|
||||||
if ((mURI = PL_strdup(uri)) == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
|
||||||
|
|
||||||
if (! kNC_PersonName) {
|
|
||||||
|
|
||||||
mRDFService->GetResource(kURINC_PersonName, &kNC_PersonName);
|
|
||||||
mRDFService->GetResource(kURINC_ListName, &kNC_ListName);
|
|
||||||
mRDFService->GetResource(kURINC_Email, &kNC_Email);
|
|
||||||
mRDFService->GetResource(kURINC_City, &kNC_City);
|
|
||||||
mRDFService->GetResource(kURINC_Organization, &kNC_Organization);
|
|
||||||
mRDFService->GetResource(kURINC_WorkPhone, &kNC_WorkPhone);
|
|
||||||
mRDFService->GetResource(kURINC_Nickname, &kNC_Nickname);
|
|
||||||
|
|
||||||
mRDFService->GetResource(kURINC_Delete, &kNC_Delete);
|
|
||||||
mRDFService->GetResource(kURINC_NewCard, &kNC_NewCard);
|
|
||||||
}
|
|
||||||
mInitialized = PR_TRUE;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsABCardDataSource::GetURI(char* *uri)
|
NS_IMETHODIMP nsABCardDataSource::GetURI(char* *uri)
|
||||||
{
|
{
|
||||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
if ((*uri = nsXPIDLCString::Copy("rdf:addresscard")) == nsnull)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
else
|
else
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -357,6 +350,21 @@ NS_IMETHODIMP nsABCardDataSource::Unassert(nsIRDFResource* source,
|
||||||
return NS_RDF_ASSERTION_REJECTED;//NS_ERROR_NOT_IMPLEMENTED;
|
return NS_RDF_ASSERTION_REJECTED;//NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsABCardDataSource::Change(nsIRDFResource *aSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aOldTarget,
|
||||||
|
nsIRDFNode *aNewTarget)
|
||||||
|
{
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsABCardDataSource::Move(nsIRDFResource *aOldSource,
|
||||||
|
nsIRDFResource *aNewSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aTarget)
|
||||||
|
{
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsABCardDataSource::HasAssertion(nsIRDFResource* source,
|
NS_IMETHODIMP nsABCardDataSource::HasAssertion(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
|
@ -371,8 +379,8 @@ NS_IMETHODIMP nsABCardDataSource::HasAssertion(nsIRDFResource* source,
|
||||||
NS_IMETHODIMP nsABCardDataSource::AddObserver(nsIRDFObserver* n)
|
NS_IMETHODIMP nsABCardDataSource::AddObserver(nsIRDFObserver* n)
|
||||||
{
|
{
|
||||||
if (! mObservers) {
|
if (! mObservers) {
|
||||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
mObservers->AppendElement(n);
|
mObservers->AppendElement(n);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -387,7 +395,7 @@ NS_IMETHODIMP nsABCardDataSource::RemoveObserver(nsIRDFObserver* n)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsABCardDataSource::assertEnumFunc(void *aElement, void *aData)
|
nsABCardDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
|
||||||
{
|
{
|
||||||
nsAbRDFNotification *note = (nsAbRDFNotification *)aData;
|
nsAbRDFNotification *note = (nsAbRDFNotification *)aData;
|
||||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||||
|
@ -399,7 +407,7 @@ nsABCardDataSource::assertEnumFunc(void *aElement, void *aData)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsABCardDataSource::unassertEnumFunc(void *aElement, void *aData)
|
nsABCardDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
|
||||||
{
|
{
|
||||||
nsAbRDFNotification* note = (nsAbRDFNotification *)aData;
|
nsAbRDFNotification* note = (nsAbRDFNotification *)aData;
|
||||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||||
|
@ -486,12 +494,6 @@ nsABCardDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsABCardDataSource::Flush()
|
|
||||||
{
|
|
||||||
PR_ASSERT(0);
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsABCardDataSource::GetAllCommands(nsIRDFResource* source,
|
nsABCardDataSource::GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||||
|
|
|
@ -16,10 +16,12 @@
|
||||||
* Reserved.
|
* Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFService.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIAbListener.h"
|
#include "nsIAbListener.h"
|
||||||
#include "nsIAbCard.h"
|
#include "nsIAbCard.h"
|
||||||
|
#include "nsISupportsArray.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,8 +31,7 @@ class nsABCardDataSource : public nsIRDFDataSource,
|
||||||
public nsIAbListener
|
public nsIAbListener
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
char* mURI;
|
nsCOMPtr<nsISupportsArray> mObservers;
|
||||||
nsVoidArray* mObservers;
|
|
||||||
PRBool mInitialized;
|
PRBool mInitialized;
|
||||||
|
|
||||||
// The cached service managers
|
// The cached service managers
|
||||||
|
@ -43,10 +44,9 @@ public:
|
||||||
|
|
||||||
nsABCardDataSource(void);
|
nsABCardDataSource(void);
|
||||||
virtual ~nsABCardDataSource (void);
|
virtual ~nsABCardDataSource (void);
|
||||||
|
nsresult Init();
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHOD Init(const char* uri);
|
|
||||||
|
|
||||||
NS_IMETHOD GetURI(char* *uri);
|
NS_IMETHOD GetURI(char* *uri);
|
||||||
|
|
||||||
|
@ -79,6 +79,16 @@ public:
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target);
|
nsIRDFNode* target);
|
||||||
|
|
||||||
|
NS_IMETHOD Change(nsIRDFResource *aSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aOldTarget,
|
||||||
|
nsIRDFNode *aNewTarget);
|
||||||
|
|
||||||
|
NS_IMETHOD Move(nsIRDFResource *aOldSource,
|
||||||
|
nsIRDFResource *aNewSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aTarget);
|
||||||
|
|
||||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target,
|
nsIRDFNode* target,
|
||||||
|
@ -97,8 +107,6 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
||||||
|
|
||||||
NS_IMETHOD Flush();
|
|
||||||
|
|
||||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||||
|
|
||||||
|
@ -139,8 +147,8 @@ protected:
|
||||||
nsresult DoNewCard(nsIAbCard *directory,
|
nsresult DoNewCard(nsIAbCard *directory,
|
||||||
nsISupportsArray *arguments);
|
nsISupportsArray *arguments);
|
||||||
|
|
||||||
static PRBool assertEnumFunc(void *aElement, void *aData);
|
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||||
static PRBool unassertEnumFunc(void *aElement, void *aData);
|
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||||
|
|
||||||
static nsIRDFResource* kNC_PersonName;
|
static nsIRDFResource* kNC_PersonName;
|
||||||
static nsIRDFResource* kNC_ListName;
|
static nsIRDFResource* kNC_ListName;
|
||||||
|
|
|
@ -149,17 +149,17 @@ void nsABDirectoryDataSource::createNode(PRUint32 value, nsIRDFNode **node)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsABDirectoryDataSource::nsABDirectoryDataSource():
|
nsABDirectoryDataSource::nsABDirectoryDataSource():
|
||||||
mURI(nsnull),
|
|
||||||
mObservers(nsnull),
|
mObservers(nsnull),
|
||||||
mInitialized(PR_FALSE),
|
mInitialized(PR_FALSE),
|
||||||
mRDFService(nsnull)
|
mRDFService(nsnull)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
|
|
||||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||||
nsIRDFService::GetIID(),
|
// method that the factory calls, so that failure to construct
|
||||||
(nsISupports**) &mRDFService);
|
// will return an error code instead of returning a partially
|
||||||
|
// initialized object.
|
||||||
|
nsresult rv = Init();
|
||||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,17 +167,6 @@ nsABDirectoryDataSource::~nsABDirectoryDataSource (void)
|
||||||
{
|
{
|
||||||
mRDFService->UnregisterDataSource(this);
|
mRDFService->UnregisterDataSource(this);
|
||||||
|
|
||||||
PL_strfree(mURI);
|
|
||||||
if (mObservers)
|
|
||||||
{
|
|
||||||
PRInt32 i;
|
|
||||||
for (i = mObservers->Count() - 1; i >= 0; --i)
|
|
||||||
{
|
|
||||||
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
|
||||||
NS_RELEASE(obs);
|
|
||||||
}
|
|
||||||
delete mObservers;
|
|
||||||
}
|
|
||||||
nsrefcnt refcnt;
|
nsrefcnt refcnt;
|
||||||
NS_RELEASE2(kNC_Child, refcnt);
|
NS_RELEASE2(kNC_Child, refcnt);
|
||||||
NS_RELEASE2(kNC_DirName, refcnt);
|
NS_RELEASE2(kNC_DirName, refcnt);
|
||||||
|
@ -196,6 +185,39 @@ nsABDirectoryDataSource::~nsABDirectoryDataSource (void)
|
||||||
DIR_ShutDown();
|
DIR_ShutDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsABDirectoryDataSource::Init()
|
||||||
|
{
|
||||||
|
if (mInitialized)
|
||||||
|
return NS_ERROR_ALREADY_INITIALIZED;
|
||||||
|
|
||||||
|
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
|
nsIRDFService::GetIID(),
|
||||||
|
(nsISupports**) &mRDFService);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||||
|
|
||||||
|
if (!kNC_Child)
|
||||||
|
mRDFService->GetResource(kURINC_child, &kNC_Child);
|
||||||
|
if (!kNC_DirName)
|
||||||
|
mRDFService->GetResource(kURINC_DirName, &kNC_DirName);
|
||||||
|
if (!kNC_DirChild)
|
||||||
|
mRDFService->GetResource(kURINC_DirChild, &kNC_DirChild);
|
||||||
|
if (!kNC_CardChild)
|
||||||
|
mRDFService->GetResource(kURINC_CardChild, &kNC_CardChild);
|
||||||
|
|
||||||
|
if (!kNC_Delete)
|
||||||
|
mRDFService->GetResource(kURINC_Delete, &kNC_Delete);
|
||||||
|
if (!kNC_NewDirectory)
|
||||||
|
mRDFService->GetResource(kURINC_NewDirectory, &kNC_NewDirectory);
|
||||||
|
|
||||||
|
DIR_GetDirServers();
|
||||||
|
|
||||||
|
mInitialized = PR_TRUE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsABDirectoryDataSource)
|
NS_IMPL_ADDREF(nsABDirectoryDataSource)
|
||||||
NS_IMPL_RELEASE(nsABDirectoryDataSource)
|
NS_IMPL_RELEASE(nsABDirectoryDataSource)
|
||||||
|
@ -224,39 +246,9 @@ nsABDirectoryDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHODIMP nsABDirectoryDataSource::Init(const char* uri)
|
|
||||||
{
|
|
||||||
if (mInitialized)
|
|
||||||
return NS_ERROR_ALREADY_INITIALIZED;
|
|
||||||
|
|
||||||
if ((mURI = PL_strdup(uri)) == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
|
||||||
|
|
||||||
if (!kNC_Child)
|
|
||||||
mRDFService->GetResource(kURINC_child, &kNC_Child);
|
|
||||||
if (!kNC_DirName)
|
|
||||||
mRDFService->GetResource(kURINC_DirName, &kNC_DirName);
|
|
||||||
if (!kNC_DirChild)
|
|
||||||
mRDFService->GetResource(kURINC_DirChild, &kNC_DirChild);
|
|
||||||
if (!kNC_CardChild)
|
|
||||||
mRDFService->GetResource(kURINC_CardChild, &kNC_CardChild);
|
|
||||||
|
|
||||||
if (!kNC_Delete)
|
|
||||||
mRDFService->GetResource(kURINC_Delete, &kNC_Delete);
|
|
||||||
if (!kNC_NewDirectory)
|
|
||||||
mRDFService->GetResource(kURINC_NewDirectory, &kNC_NewDirectory);
|
|
||||||
|
|
||||||
DIR_GetDirServers();
|
|
||||||
|
|
||||||
mInitialized = PR_TRUE;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsABDirectoryDataSource::GetURI(char* *uri)
|
NS_IMETHODIMP nsABDirectoryDataSource::GetURI(char* *uri)
|
||||||
{
|
{
|
||||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
if ((*uri = nsXPIDLCString::Copy("rdf:addressdirectory")) == nsnull)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
else
|
else
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -385,6 +377,22 @@ NS_IMETHODIMP nsABDirectoryDataSource::Unassert(nsIRDFResource* source,
|
||||||
return NS_RDF_ASSERTION_REJECTED;//NS_ERROR_NOT_IMPLEMENTED;
|
return NS_RDF_ASSERTION_REJECTED;//NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsABDirectoryDataSource::Change(nsIRDFResource *aSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aOldTarget,
|
||||||
|
nsIRDFNode *aNewTarget)
|
||||||
|
{
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsABDirectoryDataSource::Move(nsIRDFResource *aOldSource,
|
||||||
|
nsIRDFResource *aNewSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aTarget)
|
||||||
|
{
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsABDirectoryDataSource::HasAssertion(nsIRDFResource* source,
|
NS_IMETHODIMP nsABDirectoryDataSource::HasAssertion(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
|
@ -399,8 +407,9 @@ NS_IMETHODIMP nsABDirectoryDataSource::HasAssertion(nsIRDFResource* source,
|
||||||
NS_IMETHODIMP nsABDirectoryDataSource::AddObserver(nsIRDFObserver* n)
|
NS_IMETHODIMP nsABDirectoryDataSource::AddObserver(nsIRDFObserver* n)
|
||||||
{
|
{
|
||||||
if (! mObservers) {
|
if (! mObservers) {
|
||||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
nsresult rv;
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
mObservers->AppendElement(n);
|
mObservers->AppendElement(n);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -415,7 +424,7 @@ NS_IMETHODIMP nsABDirectoryDataSource::RemoveObserver(nsIRDFObserver* n)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsABDirectoryDataSource::assertEnumFunc(void *aElement, void *aData)
|
nsABDirectoryDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
|
||||||
{
|
{
|
||||||
nsAbRDFNotification *note = (nsAbRDFNotification *)aData;
|
nsAbRDFNotification *note = (nsAbRDFNotification *)aData;
|
||||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||||
|
@ -427,7 +436,7 @@ nsABDirectoryDataSource::assertEnumFunc(void *aElement, void *aData)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsABDirectoryDataSource::unassertEnumFunc(void *aElement, void *aData)
|
nsABDirectoryDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
|
||||||
{
|
{
|
||||||
nsAbRDFNotification* note = (nsAbRDFNotification *)aData;
|
nsAbRDFNotification* note = (nsAbRDFNotification *)aData;
|
||||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||||
|
@ -511,12 +520,6 @@ nsABDirectoryDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsABDirectoryDataSource::Flush()
|
|
||||||
{
|
|
||||||
PR_ASSERT(0);
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsABDirectoryDataSource::GetAllCommands(nsIRDFResource* source,
|
nsABDirectoryDataSource::GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* Reserved.
|
* Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFService.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIAbListener.h"
|
#include "nsIAbListener.h"
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
#include "nsIAbCard.h"
|
#include "nsIAbCard.h"
|
||||||
#include "nsDirPrefs.h"
|
#include "nsDirPrefs.h"
|
||||||
#include "nsIAbListener.h"
|
#include "nsIAbListener.h"
|
||||||
|
#include "nsISupportsArray.h"
|
||||||
|
|
||||||
static const char kAddrBookRootURI[] = "abdirectory:/";
|
static const char kAddrBookRootURI[] = "abdirectory:/";
|
||||||
|
|
||||||
|
@ -35,8 +37,7 @@ class nsABDirectoryDataSource : public nsIRDFDataSource,
|
||||||
public nsIAbListener
|
public nsIAbListener
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
char* mURI;
|
nsCOMPtr<nsISupportsArray> mObservers;
|
||||||
nsVoidArray* mObservers;
|
|
||||||
PRBool mInitialized;
|
PRBool mInitialized;
|
||||||
|
|
||||||
// The cached service managers
|
// The cached service managers
|
||||||
|
@ -49,11 +50,9 @@ public:
|
||||||
|
|
||||||
nsABDirectoryDataSource(void);
|
nsABDirectoryDataSource(void);
|
||||||
virtual ~nsABDirectoryDataSource (void);
|
virtual ~nsABDirectoryDataSource (void);
|
||||||
|
nsresult Init();
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHOD Init(const char* uri);
|
|
||||||
|
|
||||||
NS_IMETHOD GetURI(char* *uri);
|
NS_IMETHOD GetURI(char* *uri);
|
||||||
|
|
||||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||||
|
@ -85,6 +84,16 @@ public:
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target);
|
nsIRDFNode* target);
|
||||||
|
|
||||||
|
NS_IMETHOD Change(nsIRDFResource *aSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aOldTarget,
|
||||||
|
nsIRDFNode *aNewTarget);
|
||||||
|
|
||||||
|
NS_IMETHOD Move(nsIRDFResource *aOldSource,
|
||||||
|
nsIRDFResource *aNewSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aTarget);
|
||||||
|
|
||||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target,
|
nsIRDFNode* target,
|
||||||
|
@ -103,8 +112,6 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
||||||
|
|
||||||
NS_IMETHOD Flush();
|
|
||||||
|
|
||||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||||
|
|
||||||
|
@ -151,8 +158,8 @@ protected:
|
||||||
nsresult DoNewDirectory(nsIAbDirectory *directory,
|
nsresult DoNewDirectory(nsIAbDirectory *directory,
|
||||||
nsISupportsArray *arguments);
|
nsISupportsArray *arguments);
|
||||||
|
|
||||||
static PRBool assertEnumFunc(void *aElement, void *aData);
|
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||||
static PRBool unassertEnumFunc(void *aElement, void *aData);
|
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||||
|
|
||||||
static nsIRDFResource* kNC_Child;
|
static nsIRDFResource* kNC_Child;
|
||||||
static nsIRDFResource* kNC_DirName;
|
static nsIRDFResource* kNC_DirName;
|
||||||
|
|
|
@ -44,7 +44,32 @@ nsIRDFResource* nsMessageViewDataSource::kNC_Date;
|
||||||
nsIRDFResource* nsMessageViewDataSource::kNC_Status;
|
nsIRDFResource* nsMessageViewDataSource::kNC_Status;
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsMessageViewDataSource)
|
NS_IMPL_ADDREF(nsMessageViewDataSource)
|
||||||
NS_IMPL_RELEASE(nsMessageViewDataSource)
|
|
||||||
|
NS_IMETHODIMP_(nsrefcnt)
|
||||||
|
nsMessageViewDataSource::Release()
|
||||||
|
{
|
||||||
|
// We need a special implementation of Release(). The composite
|
||||||
|
// datasource holds a reference to mDataSource, and mDataSource
|
||||||
|
// holds a reference _back_ to the composite datasource by way of
|
||||||
|
// the "observer".
|
||||||
|
NS_PRECONDITION(PRInt32(mRefCnt) > 0, "duplicate release");
|
||||||
|
--mRefCnt;
|
||||||
|
|
||||||
|
// When the number of references is one, we know that all that
|
||||||
|
// remains is the circular references from mDataSource back to
|
||||||
|
// us. Release it.
|
||||||
|
if (mRefCnt == 1 && mDataSource) {
|
||||||
|
mDataSource->RemoveObserver(this);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (mRefCnt == 0) {
|
||||||
|
delete this;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return mRefCnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMessageViewDataSource::QueryInterface(REFNSIID iid, void** result)
|
nsMessageViewDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||||
|
@ -73,16 +98,20 @@ nsMessageViewDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||||
nsMessageViewDataSource::nsMessageViewDataSource(void)
|
nsMessageViewDataSource::nsMessageViewDataSource(void)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
mURI = nsnull;
|
|
||||||
mObservers = nsnull;
|
mObservers = nsnull;
|
||||||
mShowStatus = VIEW_SHOW_ALL;
|
mShowStatus = VIEW_SHOW_ALL;
|
||||||
mInitialized = PR_FALSE;
|
mInitialized = PR_FALSE;
|
||||||
mShowThreads = PR_TRUE;
|
mShowThreads = PR_TRUE;
|
||||||
|
|
||||||
nsServiceManager::GetService(kRDFServiceCID,
|
// XXX This call should be moved to a NS_NewMessageViewDataSource()
|
||||||
nsIRDFService::GetIID(),
|
// method that the factory calls, so that failure to construct will
|
||||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
// return an error code instead of returning a partially initialized
|
||||||
|
// object.
|
||||||
|
nsresult rv = Init();
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh. couldn't initialize.");
|
||||||
|
if (NS_FAILED(rv)) return /* rv */;
|
||||||
|
|
||||||
|
return /* NS_OK */;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsMessageViewDataSource::~nsMessageViewDataSource (void)
|
nsMessageViewDataSource::~nsMessageViewDataSource (void)
|
||||||
|
@ -90,10 +119,6 @@ nsMessageViewDataSource::~nsMessageViewDataSource (void)
|
||||||
mRDFService->UnregisterDataSource(this);
|
mRDFService->UnregisterDataSource(this);
|
||||||
|
|
||||||
RemoveDataSource(mDataSource);
|
RemoveDataSource(mDataSource);
|
||||||
if(mURI)
|
|
||||||
PL_strfree(mURI);
|
|
||||||
|
|
||||||
delete mObservers; // we only hold a weak ref to each observer
|
|
||||||
|
|
||||||
nsrefcnt refcnt;
|
nsrefcnt refcnt;
|
||||||
NS_RELEASE2(kNC_MessageChild, refcnt);
|
NS_RELEASE2(kNC_MessageChild, refcnt);
|
||||||
|
@ -107,14 +132,18 @@ nsMessageViewDataSource::~nsMessageViewDataSource (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsMessageViewDataSource::Init(const char* uri)
|
nsresult
|
||||||
|
nsMessageViewDataSource::Init()
|
||||||
{
|
{
|
||||||
if (mInitialized)
|
if (mInitialized)
|
||||||
return NS_ERROR_ALREADY_INITIALIZED;
|
return NS_ERROR_ALREADY_INITIALIZED;
|
||||||
|
|
||||||
if ((mURI = PL_strdup(uri)) == nsnull)
|
nsresult rv;
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
|
nsIRDFService::GetIID(),
|
||||||
|
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||||
|
|
||||||
if (! kNC_MessageChild) {
|
if (! kNC_MessageChild) {
|
||||||
|
@ -131,7 +160,7 @@ NS_IMETHODIMP nsMessageViewDataSource::Init(const char* uri)
|
||||||
|
|
||||||
NS_IMETHODIMP nsMessageViewDataSource::GetURI(char* *uri)
|
NS_IMETHODIMP nsMessageViewDataSource::GetURI(char* *uri)
|
||||||
{
|
{
|
||||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
if ((*uri = nsXPIDLCString::Copy("rdf:mail-messageview")) == nsnull)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
else
|
else
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -290,6 +319,29 @@ NS_IMETHODIMP nsMessageViewDataSource::Unassert(nsIRDFResource* source,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMessageViewDataSource::Change(nsIRDFResource* aSource,
|
||||||
|
nsIRDFResource* aProperty,
|
||||||
|
nsIRDFNode* aOldTarget,
|
||||||
|
nsIRDFNode* aNewTarget)
|
||||||
|
{
|
||||||
|
if (mDataSource)
|
||||||
|
return mDataSource->Change(aSource, aProperty, aOldTarget, aNewTarget);
|
||||||
|
else
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMessageViewDataSource::Move(nsIRDFResource* aOldSource,
|
||||||
|
nsIRDFResource* aNewSource,
|
||||||
|
nsIRDFResource* aProperty,
|
||||||
|
nsIRDFNode* aTarget)
|
||||||
|
{
|
||||||
|
if (mDataSource)
|
||||||
|
return mDataSource->Move(aOldSource, aNewSource, aProperty, aTarget);
|
||||||
|
else
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsMessageViewDataSource::HasAssertion(nsIRDFResource* source,
|
NS_IMETHODIMP nsMessageViewDataSource::HasAssertion(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target,
|
nsIRDFNode* target,
|
||||||
|
@ -305,8 +357,8 @@ NS_IMETHODIMP nsMessageViewDataSource::HasAssertion(nsIRDFResource* source,
|
||||||
NS_IMETHODIMP nsMessageViewDataSource::AddObserver(nsIRDFObserver* n)
|
NS_IMETHODIMP nsMessageViewDataSource::AddObserver(nsIRDFObserver* n)
|
||||||
{
|
{
|
||||||
if (! mObservers) {
|
if (! mObservers) {
|
||||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
mObservers->AppendElement(n);
|
mObservers->AppendElement(n);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -393,14 +445,6 @@ NS_IMETHODIMP nsMessageViewDataSource::GetAllResources(nsISimpleEnumerator** aCu
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsMessageViewDataSource::Flush()
|
|
||||||
{
|
|
||||||
if(mDataSource)
|
|
||||||
return mDataSource->Flush();
|
|
||||||
else
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsMessageViewDataSource::GetAllCommands(nsIRDFResource* source,
|
NS_IMETHODIMP nsMessageViewDataSource::GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||||
{
|
{
|
||||||
|
@ -456,9 +500,14 @@ NS_IMETHODIMP nsMessageViewDataSource::OnAssert(nsIRDFResource* subject,
|
||||||
nsIRDFNode* object)
|
nsIRDFNode* object)
|
||||||
{
|
{
|
||||||
if (mObservers) {
|
if (mObservers) {
|
||||||
for (PRInt32 i = mObservers->Count() - 1; i >= 0; --i) {
|
PRUint32 count;
|
||||||
|
nsresult rv = mObservers->Count(&count);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
for (PRInt32 i = count - 1; i >= 0; --i) {
|
||||||
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
||||||
obs->OnAssert(subject, predicate, object);
|
obs->OnAssert(subject, predicate, object);
|
||||||
|
NS_RELEASE(obs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -470,15 +519,60 @@ NS_IMETHODIMP nsMessageViewDataSource::OnUnassert(nsIRDFResource* subject,
|
||||||
nsIRDFNode* object)
|
nsIRDFNode* object)
|
||||||
{
|
{
|
||||||
if (mObservers) {
|
if (mObservers) {
|
||||||
for (PRInt32 i = mObservers->Count() - 1; i >= 0; --i) {
|
PRUint32 count;
|
||||||
|
nsresult rv = mObservers->Count(&count);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
for (PRInt32 i = PRInt32(count) - 1; i >= 0; --i) {
|
||||||
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
||||||
obs->OnUnassert(subject, predicate, object);
|
obs->OnUnassert(subject, predicate, object);
|
||||||
|
NS_RELEASE(obs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMessageViewDataSource::OnChange(nsIRDFResource* aSource,
|
||||||
|
nsIRDFResource* aProperty,
|
||||||
|
nsIRDFNode* aOldTarget,
|
||||||
|
nsIRDFNode* aNewTarget)
|
||||||
|
{
|
||||||
|
if (mObservers) {
|
||||||
|
PRUint32 count;
|
||||||
|
nsresult rv = mObservers->Count(&count);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
for (PRInt32 i = PRInt32(count) - 1; i >= 0; --i) {
|
||||||
|
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
||||||
|
obs->OnChange(aSource, aProperty, aOldTarget, aNewTarget);
|
||||||
|
NS_RELEASE(obs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMessageViewDataSource::OnMove(nsIRDFResource* aOldSource,
|
||||||
|
nsIRDFResource* aNewSource,
|
||||||
|
nsIRDFResource* aProperty,
|
||||||
|
nsIRDFNode* aTarget)
|
||||||
|
{
|
||||||
|
if (mObservers) {
|
||||||
|
PRUint32 count;
|
||||||
|
nsresult rv = mObservers->Count(&count);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
for (PRInt32 i = PRInt32(count) - 1; i >= 0; --i) {
|
||||||
|
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
||||||
|
obs->OnMove(aOldSource, aNewSource, aProperty, aTarget);
|
||||||
|
NS_RELEASE(obs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsMessageViewDataSource::SetShowAll()
|
NS_IMETHODIMP nsMessageViewDataSource::SetShowAll()
|
||||||
{
|
{
|
||||||
mShowStatus = VIEW_SHOW_ALL;
|
mShowStatus = VIEW_SHOW_ALL;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "nsIMsgFolder.h"
|
#include "nsIMsgFolder.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFService.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsVoidArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsIEnumerator.h"
|
#include "nsIEnumerator.h"
|
||||||
#include "nsIMessage.h"
|
#include "nsIMessage.h"
|
||||||
#include "nsIMsgThread.h"
|
#include "nsIMsgThread.h"
|
||||||
|
@ -37,8 +37,7 @@ class nsMessageViewDataSource : public nsIRDFCompositeDataSource, public nsIMess
|
||||||
public nsIRDFObserver
|
public nsIRDFObserver
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
char* mURI;
|
nsCOMPtr<nsISupportsArray> mObservers;
|
||||||
nsVoidArray* mObservers;
|
|
||||||
PRBool mInitialized;
|
PRBool mInitialized;
|
||||||
nsIRDFService * mRDFService;
|
nsIRDFService * mRDFService;
|
||||||
|
|
||||||
|
@ -48,11 +47,10 @@ public:
|
||||||
|
|
||||||
nsMessageViewDataSource(void);
|
nsMessageViewDataSource(void);
|
||||||
virtual ~nsMessageViewDataSource (void);
|
virtual ~nsMessageViewDataSource (void);
|
||||||
|
virtual nsresult Init();
|
||||||
|
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHOD Init(const char* uri);
|
|
||||||
|
|
||||||
NS_IMETHOD GetURI(char* *uri);
|
NS_IMETHOD GetURI(char* *uri);
|
||||||
|
|
||||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||||
|
@ -84,6 +82,16 @@ public:
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target);
|
nsIRDFNode* target);
|
||||||
|
|
||||||
|
NS_IMETHOD Change(nsIRDFResource* aSource,
|
||||||
|
nsIRDFResource* aProperty,
|
||||||
|
nsIRDFNode* aOldTarget,
|
||||||
|
nsIRDFNode* aNewTarget);
|
||||||
|
|
||||||
|
NS_IMETHOD Move(nsIRDFResource* aOldSource,
|
||||||
|
nsIRDFResource* aNewSource,
|
||||||
|
nsIRDFResource* aProperty,
|
||||||
|
nsIRDFNode* aTarget);
|
||||||
|
|
||||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target,
|
nsIRDFNode* target,
|
||||||
|
@ -102,8 +110,6 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult);
|
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult);
|
||||||
|
|
||||||
NS_IMETHOD Flush();
|
|
||||||
|
|
||||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||||
|
|
||||||
|
@ -131,6 +137,15 @@ public:
|
||||||
nsIRDFResource* predicate,
|
nsIRDFResource* predicate,
|
||||||
nsIRDFNode* object);
|
nsIRDFNode* object);
|
||||||
|
|
||||||
|
NS_IMETHOD OnChange(nsIRDFResource* aSource,
|
||||||
|
nsIRDFResource* aProperty,
|
||||||
|
nsIRDFNode* aOldTarget,
|
||||||
|
nsIRDFNode* aNewTarget);
|
||||||
|
|
||||||
|
NS_IMETHOD OnMove(nsIRDFResource* aOldSource,
|
||||||
|
nsIRDFResource* aNewSource,
|
||||||
|
nsIRDFResource* aProperty,
|
||||||
|
nsIRDFNode* aTarget);
|
||||||
//nsIMessageView
|
//nsIMessageView
|
||||||
NS_IMETHOD SetShowAll();
|
NS_IMETHOD SetShowAll();
|
||||||
NS_IMETHOD SetShowUnread();
|
NS_IMETHOD SetShowUnread();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFResource.h"
|
#include "nsIRDFResource.h"
|
||||||
|
|
||||||
|
#include "nsXPIDLString.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
#include "nsMsgBaseCID.h"
|
#include "nsMsgBaseCID.h"
|
||||||
|
|
||||||
|
@ -41,12 +42,12 @@ class nsMsgAccountDataSource : public nsMsgRDFDataSource
|
||||||
public:
|
public:
|
||||||
nsMsgAccountDataSource();
|
nsMsgAccountDataSource();
|
||||||
virtual ~nsMsgAccountDataSource();
|
virtual ~nsMsgAccountDataSource();
|
||||||
|
virtual nsresult Init();
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
// RDF datasource methods
|
// RDF datasource methods
|
||||||
/* void Init (in string uri); */
|
NS_IMETHOD GetURI(char* *aURI);
|
||||||
NS_IMETHOD Init(const char *uri);
|
|
||||||
|
|
||||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||||
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
||||||
|
@ -115,30 +116,28 @@ DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Identity);
|
||||||
nsMsgAccountDataSource::nsMsgAccountDataSource():
|
nsMsgAccountDataSource::nsMsgAccountDataSource():
|
||||||
mInitialized(PR_FALSE)
|
mInitialized(PR_FALSE)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
nsresult rv;
|
||||||
|
rv = Init();
|
||||||
|
|
||||||
|
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||||
|
// method that the factory calls, so that failure to construct
|
||||||
|
// will return an error code instead of returning a partially
|
||||||
|
// initialized object.
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh, initialization failed");
|
||||||
|
if (NS_FAILED(rv)) return /* rv */;
|
||||||
|
|
||||||
|
return /* NS_OK */;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsMsgAccountDataSource::~nsMsgAccountDataSource()
|
nsMsgAccountDataSource::~nsMsgAccountDataSource()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsMsgAccountDataSource)
|
|
||||||
NS_IMPL_RELEASE(nsMsgAccountDataSource)
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsMsgAccountDataSource::QueryInterface(const nsIID& iid, void **result)
|
nsMsgAccountDataSource::Init()
|
||||||
{
|
{
|
||||||
|
nsMsgRDFDataSource::Init();
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* void Init (in string uri); */
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMsgAccountDataSource::Init(const char *uri)
|
|
||||||
{
|
|
||||||
nsMsgRDFDataSource::Init(uri);
|
|
||||||
|
|
||||||
if (! kNC_Child) {
|
if (! kNC_Child) {
|
||||||
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
||||||
|
@ -149,6 +148,28 @@ nsMsgAccountDataSource::Init(const char *uri)
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMPL_ADDREF_INHERITED(nsMsgAccountDataSource, nsMsgRDFDataSource)
|
||||||
|
NS_IMPL_RELEASE_INHERITED(nsMsgAccountDataSource, nsMsgRDFDataSource)
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsMsgAccountDataSource::QueryInterface(const nsIID& iid, void **result)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMsgAccountDataSource::GetURI(char* *aURI)
|
||||||
|
{
|
||||||
|
*aURI = nsXPIDLCString::Copy("rdf:msgaccounts");
|
||||||
|
if (! *aURI)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgAccountDataSource::GetTarget(nsIRDFResource *source,
|
nsMsgAccountDataSource::GetTarget(nsIRDFResource *source,
|
||||||
|
|
|
@ -61,14 +61,12 @@ public:
|
||||||
|
|
||||||
nsMsgAccountManagerDataSource();
|
nsMsgAccountManagerDataSource();
|
||||||
virtual ~nsMsgAccountManagerDataSource();
|
virtual ~nsMsgAccountManagerDataSource();
|
||||||
|
virtual nsresult Init();
|
||||||
|
|
||||||
// service manager shutdown method
|
// service manager shutdown method
|
||||||
|
|
||||||
// RDF datasource methods
|
// RDF datasource methods
|
||||||
|
|
||||||
/* void Init (in string uri); */
|
|
||||||
NS_IMETHOD Init(const char *uri);
|
|
||||||
|
|
||||||
|
|
||||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource property, in boolean aTruthValue); */
|
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource property, in boolean aTruthValue); */
|
||||||
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
||||||
nsIRDFResource *property,
|
nsIRDFResource *property,
|
||||||
|
@ -130,6 +128,16 @@ nsMsgAccountManagerDataSource::nsMsgAccountManagerDataSource():
|
||||||
#ifdef DEBUG_amds
|
#ifdef DEBUG_amds
|
||||||
printf("nsMsgAccountManagerDataSource() being created\n");
|
printf("nsMsgAccountManagerDataSource() being created\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||||
|
// method that the factory calls, so that failure to construct
|
||||||
|
// will return an error code instead of returning a partially
|
||||||
|
// initialized object.
|
||||||
|
nsresult rv = Init();
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh, initialization failed");
|
||||||
|
if (NS_FAILED(rv)) return /* rv */;
|
||||||
|
|
||||||
|
return /* NS_OK */;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsMsgAccountManagerDataSource::~nsMsgAccountManagerDataSource()
|
nsMsgAccountManagerDataSource::~nsMsgAccountManagerDataSource()
|
||||||
|
@ -139,11 +147,10 @@ nsMsgAccountManagerDataSource::~nsMsgAccountManagerDataSource()
|
||||||
this);
|
this);
|
||||||
|
|
||||||
}
|
}
|
||||||
/* void Init (in string uri); */
|
|
||||||
NS_IMETHODIMP
|
nsresult
|
||||||
nsMsgAccountManagerDataSource::Init(const char *uri)
|
nsMsgAccountManagerDataSource::Init()
|
||||||
{
|
{
|
||||||
nsMsgRDFDataSource::Init(uri);
|
|
||||||
nsresult rv=NS_OK;
|
nsresult rv=NS_OK;
|
||||||
#ifdef DEBUG_amds
|
#ifdef DEBUG_amds
|
||||||
printf("nsMsgAccountManagerDataSource::Init(%s)\n", uri ? uri : "(null)");
|
printf("nsMsgAccountManagerDataSource::Init(%s)\n", uri ? uri : "(null)");
|
||||||
|
|
|
@ -65,18 +65,17 @@ nsMsgFolderDataSource::nsMsgFolderDataSource():
|
||||||
mInitialized(PR_FALSE),
|
mInitialized(PR_FALSE),
|
||||||
mRDFService(nsnull)
|
mRDFService(nsnull)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
nsresult rv;
|
||||||
|
rv = Init();
|
||||||
|
|
||||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||||
nsIRDFService::GetIID(),
|
// method that the factory calls, so that failure to construct
|
||||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
// will return an error code instead of returning a partially
|
||||||
|
// initialized object.
|
||||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh, initialization failed");
|
||||||
|
if (NS_FAILED(rv)) return /* rv */;
|
||||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
|
||||||
if(NS_SUCCEEDED(rv))
|
|
||||||
mailSession->AddFolderListener(this);
|
|
||||||
|
|
||||||
|
return /* NS_OK */;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
||||||
|
@ -88,9 +87,6 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
||||||
if(NS_SUCCEEDED(rv))
|
if(NS_SUCCEEDED(rv))
|
||||||
mailSession->RemoveFolderListener(this);
|
mailSession->RemoveFolderListener(this);
|
||||||
|
|
||||||
PL_strfree(mURI);
|
|
||||||
|
|
||||||
|
|
||||||
nsrefcnt refcnt;
|
nsrefcnt refcnt;
|
||||||
NS_RELEASE2(kNC_Child, refcnt);
|
NS_RELEASE2(kNC_Child, refcnt);
|
||||||
NS_RELEASE2(kNC_MessageChild, refcnt);
|
NS_RELEASE2(kNC_MessageChild, refcnt);
|
||||||
|
@ -110,35 +106,21 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
||||||
mRDFService = nsnull;
|
mRDFService = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgFolderDataSource::Init()
|
||||||
NS_IMPL_ADDREF(nsMsgFolderDataSource)
|
|
||||||
NS_IMPL_RELEASE(nsMsgFolderDataSource)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMsgFolderDataSource::QueryInterface(REFNSIID iid, void** result)
|
|
||||||
{
|
|
||||||
if (! result)
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
|
|
||||||
*result = nsnull;
|
|
||||||
if(iid.Equals(nsIFolderListener::GetIID()))
|
|
||||||
{
|
|
||||||
*result = NS_STATIC_CAST(nsIFolderListener*, this);
|
|
||||||
NS_ADDREF(this);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return nsMsgRDFDataSource::QueryInterface(iid, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
|
||||||
NS_IMETHODIMP nsMsgFolderDataSource::Init(const char* uri)
|
|
||||||
{
|
{
|
||||||
if (mInitialized)
|
if (mInitialized)
|
||||||
return NS_ERROR_ALREADY_INITIALIZED;
|
return NS_ERROR_ALREADY_INITIALIZED;
|
||||||
|
|
||||||
if ((mURI = PL_strdup(uri)) == nsnull)
|
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
nsIRDFService::GetIID(),
|
||||||
|
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||||
|
|
||||||
|
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
||||||
|
if(NS_SUCCEEDED(rv))
|
||||||
|
mailSession->AddFolderListener(this);
|
||||||
|
|
||||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||||
|
|
||||||
|
@ -161,9 +143,32 @@ NS_IMETHODIMP nsMsgFolderDataSource::Init(const char* uri)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMPL_ADDREF_INHERITED(nsMsgFolderDataSource, nsMsgRDFDataSource)
|
||||||
|
NS_IMPL_RELEASE_INHERITED(nsMsgFolderDataSource, nsMsgRDFDataSource)
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMsgFolderDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||||
|
{
|
||||||
|
if (! result)
|
||||||
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
|
*result = nsnull;
|
||||||
|
if(iid.Equals(nsIFolderListener::GetIID()))
|
||||||
|
{
|
||||||
|
*result = NS_STATIC_CAST(nsIFolderListener*, this);
|
||||||
|
NS_ADDREF(this);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return nsMsgRDFDataSource::QueryInterface(iid, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHODIMP nsMsgFolderDataSource::GetURI(char* *uri)
|
NS_IMETHODIMP nsMsgFolderDataSource::GetURI(char* *uri)
|
||||||
{
|
{
|
||||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
if ((*uri = nsXPIDLCString::Copy("rdf:mailnewsfolders")) == nsnull)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
else
|
else
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -415,12 +420,6 @@ nsMsgFolderDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsMsgFolderDataSource::Flush()
|
|
||||||
{
|
|
||||||
PR_ASSERT(0);
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgFolderDataSource::GetAllCommands(nsIRDFResource* source,
|
nsMsgFolderDataSource::GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||||
|
|
|
@ -39,15 +39,13 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
nsMsgFolderDataSource(void);
|
nsMsgFolderDataSource(void);
|
||||||
virtual ~nsMsgFolderDataSource (void);
|
virtual ~nsMsgFolderDataSource (void);
|
||||||
|
virtual nsresult Init();
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHOD Init(const char* uri);
|
|
||||||
|
|
||||||
NS_IMETHOD GetURI(char* *uri);
|
NS_IMETHOD GetURI(char* *uri);
|
||||||
|
|
||||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||||
|
@ -93,8 +91,6 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult);
|
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult);
|
||||||
|
|
||||||
NS_IMETHOD Flush();
|
|
||||||
|
|
||||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "nsIMsgMailSession.h"
|
#include "nsIMsgMailSession.h"
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsXPIDLString.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
#include "nsMsgBaseCID.h"
|
#include "nsMsgBaseCID.h"
|
||||||
|
|
||||||
|
@ -41,11 +42,13 @@ class nsMsgIdentityDataSource : public nsMsgRDFDataSource
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
nsMsgIdentityDataSource();
|
||||||
|
virtual ~nsMsgIdentityDataSource();
|
||||||
|
virtual nsresult Init();
|
||||||
|
|
||||||
// RDF datasource methods
|
// RDF datasource methods
|
||||||
|
|
||||||
/* void Init (in string uri); */
|
NS_IMETHOD GetURI(char* *aURI);
|
||||||
NS_IMETHOD Init(const char *uri);
|
|
||||||
|
|
||||||
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
||||||
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
||||||
|
@ -93,11 +96,31 @@ DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child);
|
||||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Server);
|
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Server);
|
||||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Identity);
|
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Identity);
|
||||||
|
|
||||||
/* void Init (in string uri); */
|
nsMsgIdentityDataSource::nsMsgIdentityDataSource()
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMsgIdentityDataSource::Init(const char *uri)
|
|
||||||
{
|
{
|
||||||
nsMsgRDFDataSource::Init(uri);
|
nsresult rv;
|
||||||
|
rv = Init();
|
||||||
|
|
||||||
|
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||||
|
// method that the factory calls, so that failure to construct
|
||||||
|
// will return an error code instead of returning a partially
|
||||||
|
// initialized object.
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh, initialization failed");
|
||||||
|
if (NS_FAILED(rv)) return /* rv */;
|
||||||
|
|
||||||
|
return /* NS_OK */;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nsMsgIdentityDataSource::~nsMsgIdentityDataSource()
|
||||||
|
{
|
||||||
|
// XXX Release all the resources we acquired in Init()
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsMsgIdentityDataSource::Init()
|
||||||
|
{
|
||||||
|
nsMsgRDFDataSource::Init();
|
||||||
|
|
||||||
if (! kNC_Child) {
|
if (! kNC_Child) {
|
||||||
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
||||||
|
@ -106,6 +129,17 @@ nsMsgIdentityDataSource::Init(const char *uri)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMsgIdentityDataSource::GetURI(char* *aURI)
|
||||||
|
{
|
||||||
|
*aURI = nsXPIDLCString::Copy("rdf:msgidentities");
|
||||||
|
if (! *aURI)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgIdentityDataSource::GetTarget(nsIRDFResource *source,
|
nsMsgIdentityDataSource::GetTarget(nsIRDFResource *source,
|
||||||
|
|
|
@ -63,8 +63,6 @@ nsMsgMessageDataSource::nsMsgMessageDataSource():
|
||||||
mRDFService(nsnull),
|
mRDFService(nsnull),
|
||||||
mHeaderParser(nsnull)
|
mHeaderParser(nsnull)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
|
||||||
|
|
||||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
nsIRDFService::GetIID(),
|
nsIRDFService::GetIID(),
|
||||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||||
|
@ -90,6 +88,16 @@ nsMsgMessageDataSource::nsMsgMessageDataSource():
|
||||||
if(NS_SUCCEEDED(rv))
|
if(NS_SUCCEEDED(rv))
|
||||||
mailSession->AddFolderListener(this);
|
mailSession->AddFolderListener(this);
|
||||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||||
|
|
||||||
|
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||||
|
// method that the factory calls, so that failure to construct
|
||||||
|
// will return an error code instead of returning a partially
|
||||||
|
// initialized object.
|
||||||
|
rv = Init();
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh, initialization failed");
|
||||||
|
if (NS_FAILED(rv)) return /* rv */;
|
||||||
|
|
||||||
|
return /* NS_OK */;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
||||||
|
@ -102,8 +110,6 @@ nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
||||||
if(NS_SUCCEEDED(rv))
|
if(NS_SUCCEEDED(rv))
|
||||||
mailSession->RemoveFolderListener(this);
|
mailSession->RemoveFolderListener(this);
|
||||||
|
|
||||||
PL_strfree(mURI);
|
|
||||||
|
|
||||||
nsrefcnt refcnt;
|
nsrefcnt refcnt;
|
||||||
|
|
||||||
NS_RELEASE2(kNC_Subject, refcnt);
|
NS_RELEASE2(kNC_Subject, refcnt);
|
||||||
|
@ -120,36 +126,11 @@ nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
||||||
mRDFService = nsnull;
|
mRDFService = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgMessageDataSource::Init()
|
||||||
NS_IMPL_ADDREF(nsMsgMessageDataSource)
|
|
||||||
NS_IMPL_RELEASE(nsMsgMessageDataSource)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMsgMessageDataSource::QueryInterface(REFNSIID iid, void** result)
|
|
||||||
{
|
|
||||||
if (! result)
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
|
|
||||||
*result = nsnull;
|
|
||||||
if(iid.Equals(nsIFolderListener::GetIID()))
|
|
||||||
{
|
|
||||||
*result = NS_STATIC_CAST(nsIFolderListener*, this);
|
|
||||||
NS_ADDREF(this);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return nsMsgRDFDataSource::QueryInterface(iid, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
|
||||||
NS_IMETHODIMP nsMsgMessageDataSource::Init(const char* uri)
|
|
||||||
{
|
{
|
||||||
if (mInitialized)
|
if (mInitialized)
|
||||||
return NS_ERROR_ALREADY_INITIALIZED;
|
return NS_ERROR_ALREADY_INITIALIZED;
|
||||||
|
|
||||||
if ((mURI = PL_strdup(uri)) == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||||
|
|
||||||
if (! kNC_Subject) {
|
if (! kNC_Subject) {
|
||||||
|
@ -168,9 +149,30 @@ NS_IMETHODIMP nsMsgMessageDataSource::Init(const char* uri)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMPL_ADDREF_INHERITED(nsMsgMessageDataSource, nsMsgRDFDataSource)
|
||||||
|
NS_IMPL_RELEASE_INHERITED(nsMsgMessageDataSource, nsMsgRDFDataSource)
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMsgMessageDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||||
|
{
|
||||||
|
if (! result)
|
||||||
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
|
*result = nsnull;
|
||||||
|
if(iid.Equals(nsIFolderListener::GetIID()))
|
||||||
|
{
|
||||||
|
*result = NS_STATIC_CAST(nsIFolderListener*, this);
|
||||||
|
NS_ADDREF(this);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return nsMsgRDFDataSource::QueryInterface(iid, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHODIMP nsMsgMessageDataSource::GetURI(char* *uri)
|
NS_IMETHODIMP nsMsgMessageDataSource::GetURI(char* *uri)
|
||||||
{
|
{
|
||||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
if ((*uri = nsXPIDLCString::Copy("rdf:mailnewsmessages")) == nsnull)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
else
|
else
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -364,12 +366,6 @@ nsMsgMessageDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsMsgMessageDataSource::Flush()
|
|
||||||
{
|
|
||||||
PR_ASSERT(0);
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgMessageDataSource::GetAllCommands(nsIRDFResource* source,
|
nsMsgMessageDataSource::GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||||
|
|
|
@ -42,15 +42,13 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
nsMsgMessageDataSource(void);
|
nsMsgMessageDataSource(void);
|
||||||
virtual ~nsMsgMessageDataSource (void);
|
virtual ~nsMsgMessageDataSource (void);
|
||||||
|
virtual nsresult Init();
|
||||||
|
|
||||||
// nsIRDFDataSource methods
|
// nsIRDFDataSource methods
|
||||||
NS_IMETHOD Init(const char* uri);
|
|
||||||
|
|
||||||
NS_IMETHOD GetURI(char* *uri);
|
NS_IMETHOD GetURI(char* *uri);
|
||||||
|
|
||||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||||
|
@ -96,8 +94,6 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
||||||
|
|
||||||
NS_IMETHOD Flush();
|
|
||||||
|
|
||||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||||
|
|
||||||
|
|
|
@ -27,21 +27,33 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
static NS_DEFINE_CID(kISupportsIID, NS_ISUPPORTS_IID);
|
static NS_DEFINE_CID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
|
|
||||||
nsMsgRDFDataSource::nsMsgRDFDataSource():
|
nsMsgRDFDataSource::nsMsgRDFDataSource():
|
||||||
mURI(nsnull),
|
mRDFService(nsnull)
|
||||||
mRDFService(nsnull),
|
|
||||||
mObservers(nsnull)
|
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsMsgRDFDataSource::~nsMsgRDFDataSource()
|
nsMsgRDFDataSource::~nsMsgRDFDataSource()
|
||||||
{
|
{
|
||||||
if (mURI) PL_strfree(mURI);
|
|
||||||
if (mRDFService) nsServiceManager::ReleaseService(kRDFServiceCID,
|
if (mRDFService) nsServiceManager::ReleaseService(kRDFServiceCID,
|
||||||
mRDFService,
|
mRDFService,
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* void Init (); */
|
||||||
|
nsresult
|
||||||
|
nsMsgRDFDataSource::Init()
|
||||||
|
{
|
||||||
|
nsresult rv=NS_OK;
|
||||||
|
|
||||||
|
getRDFService();
|
||||||
|
|
||||||
|
rv = mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||||
|
if (!rv) return rv;
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsMsgRDFDataSource)
|
NS_IMPL_ADDREF(nsMsgRDFDataSource)
|
||||||
NS_IMPL_RELEASE(nsMsgRDFDataSource)
|
NS_IMPL_RELEASE(nsMsgRDFDataSource)
|
||||||
|
|
||||||
|
@ -72,37 +84,12 @@ nsMsgRDFDataSource::QueryInterface(const nsIID& iid, void **result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* void Init (in string uri); */
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMsgRDFDataSource::Init(const char *uri)
|
|
||||||
{
|
|
||||||
nsresult rv=NS_OK;
|
|
||||||
|
|
||||||
|
|
||||||
if (!mURI || PL_strcmp(uri, mURI) != 0)
|
|
||||||
mURI = PL_strdup(uri);
|
|
||||||
|
|
||||||
getRDFService();
|
|
||||||
|
|
||||||
rv = mRDFService->RegisterDataSource(this, PR_FALSE);
|
|
||||||
if (!rv) return rv;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* readonly attribute string URI; */
|
/* readonly attribute string URI; */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgRDFDataSource::GetURI(char * *aURI)
|
nsMsgRDFDataSource::GetURI(char * *aURI)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aURI != nsnull, "null ptr");
|
NS_NOTREACHED("should be implemented by a subclass");
|
||||||
if (! aURI)
|
return NS_ERROR_UNEXPECTED;
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
|
|
||||||
if ((*aURI = nsXPIDLCString::Copy(mURI)) == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
else
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,6 +141,25 @@ nsMsgRDFDataSource::Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMsgRDFDataSource::Change(nsIRDFResource *aSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aOldTarget,
|
||||||
|
nsIRDFNode *aNewTarget)
|
||||||
|
{
|
||||||
|
return NS_RDF_NO_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMsgRDFDataSource::Move(nsIRDFResource *aOldSource,
|
||||||
|
nsIRDFResource *aNewSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aTarget)
|
||||||
|
{
|
||||||
|
return NS_RDF_NO_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
/* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgRDFDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval)
|
nsMsgRDFDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval)
|
||||||
|
@ -168,8 +174,9 @@ NS_IMETHODIMP
|
||||||
nsMsgRDFDataSource::AddObserver(nsIRDFObserver *aObserver)
|
nsMsgRDFDataSource::AddObserver(nsIRDFObserver *aObserver)
|
||||||
{
|
{
|
||||||
if (! mObservers) {
|
if (! mObservers) {
|
||||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
nsresult rv;
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
mObservers->AppendElement(aObserver);
|
mObservers->AppendElement(aObserver);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -211,14 +218,6 @@ nsMsgRDFDataSource::GetAllResources(nsISimpleEnumerator **_retval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* void Flush (); */
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMsgRDFDataSource::Flush()
|
|
||||||
{
|
|
||||||
return NS_RDF_NO_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgRDFDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval)
|
nsMsgRDFDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval)
|
||||||
|
@ -288,7 +287,7 @@ nsresult nsMsgRDFDataSource::NotifyObservers(nsIRDFResource *subject,
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsMsgRDFDataSource::assertEnumFunc(void *aElement, void *aData)
|
nsMsgRDFDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
|
||||||
{
|
{
|
||||||
nsMsgRDFNotification *note = (nsMsgRDFNotification *)aData;
|
nsMsgRDFNotification *note = (nsMsgRDFNotification *)aData;
|
||||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||||
|
@ -300,7 +299,7 @@ nsMsgRDFDataSource::assertEnumFunc(void *aElement, void *aData)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsMsgRDFDataSource::unassertEnumFunc(void *aElement, void *aData)
|
nsMsgRDFDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
|
||||||
{
|
{
|
||||||
nsMsgRDFNotification* note = (nsMsgRDFNotification *)aData;
|
nsMsgRDFNotification* note = (nsMsgRDFNotification *)aData;
|
||||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||||
|
|
|
@ -20,10 +20,11 @@
|
||||||
#ifndef __nsMsgRDFDataSource_h
|
#ifndef __nsMsgRDFDataSource_h
|
||||||
#define __nsMsgRDFDataSource_h
|
#define __nsMsgRDFDataSource_h
|
||||||
|
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFService.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsVoidArray.h"
|
#include "nsISupportsArray.h"
|
||||||
|
|
||||||
class nsMsgRDFDataSource : public nsIRDFDataSource,
|
class nsMsgRDFDataSource : public nsIRDFDataSource,
|
||||||
public nsIShutdownListener
|
public nsIShutdownListener
|
||||||
|
@ -31,14 +32,12 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
||||||
public:
|
public:
|
||||||
nsMsgRDFDataSource();
|
nsMsgRDFDataSource();
|
||||||
virtual ~nsMsgRDFDataSource();
|
virtual ~nsMsgRDFDataSource();
|
||||||
|
virtual nsresult Init();
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
NS_IMETHOD OnShutdown(const nsCID& aClass, nsISupports* service);
|
NS_IMETHOD OnShutdown(const nsCID& aClass, nsISupports* service);
|
||||||
|
|
||||||
/* void Init (in string uri); */
|
|
||||||
NS_IMETHOD Init(const char *uri);
|
|
||||||
|
|
||||||
/* readonly attribute string URI; */
|
/* readonly attribute string URI; */
|
||||||
NS_IMETHOD GetURI(char * *aURI);
|
NS_IMETHOD GetURI(char * *aURI);
|
||||||
|
|
||||||
|
@ -90,6 +89,25 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
||||||
nsIRDFResource *aProperty,
|
nsIRDFResource *aProperty,
|
||||||
nsIRDFNode *aTarget);
|
nsIRDFNode *aTarget);
|
||||||
|
|
||||||
|
/* void Change (in nsIRDFResource aSource,
|
||||||
|
in nsIRDFResource aProperty,
|
||||||
|
in nsIRDFNode aOldTarget,
|
||||||
|
in nsIRDFNode aNewTarget);
|
||||||
|
*/
|
||||||
|
NS_IMETHOD Change(nsIRDFResource *aSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aOldTarget,
|
||||||
|
nsIRDFNode *aNewTarget);
|
||||||
|
|
||||||
|
/* void Move (in nsIRDFResource aOldSource,
|
||||||
|
in nsIRDFResource aNewSource,
|
||||||
|
in nsIRDFResource aProperty,
|
||||||
|
in nsIRDFNode aTarget); */
|
||||||
|
NS_IMETHOD Move(nsIRDFResource *aOldSource,
|
||||||
|
nsIRDFResource *aNewSource,
|
||||||
|
nsIRDFResource *aProperty,
|
||||||
|
nsIRDFNode *aTarget);
|
||||||
|
|
||||||
/* boolean HasAssertion (in nsIRDFResource aSource,
|
/* boolean HasAssertion (in nsIRDFResource aSource,
|
||||||
in nsIRDFResource aProperty,
|
in nsIRDFResource aProperty,
|
||||||
in nsIRDFNode aTarget,
|
in nsIRDFNode aTarget,
|
||||||
|
@ -117,9 +135,6 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
||||||
/* nsISimpleEnumerator GetAllResources (); */
|
/* nsISimpleEnumerator GetAllResources (); */
|
||||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator **_retval);
|
NS_IMETHOD GetAllResources(nsISimpleEnumerator **_retval);
|
||||||
|
|
||||||
/* void Flush (); */
|
|
||||||
NS_IMETHOD Flush();
|
|
||||||
|
|
||||||
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
||||||
NS_IMETHOD GetAllCommands(nsIRDFResource *aSource,
|
NS_IMETHOD GetAllCommands(nsIRDFResource *aSource,
|
||||||
nsIEnumerator **_retval);
|
nsIEnumerator **_retval);
|
||||||
|
@ -141,17 +156,15 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
char *mURI;
|
|
||||||
|
|
||||||
nsIRDFService *getRDFService();
|
nsIRDFService *getRDFService();
|
||||||
static PRBool assertEnumFunc(void *aElement, void *aData);
|
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||||
static PRBool unassertEnumFunc(void *aElement, void *aData);
|
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||||
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property,
|
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property,
|
||||||
nsIRDFNode *object, PRBool assert);
|
nsIRDFNode *object, PRBool assert);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsIRDFService *mRDFService;
|
nsIRDFService *mRDFService;
|
||||||
nsVoidArray *mObservers;
|
nsCOMPtr<nsISupportsArray> mObservers;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,19 @@
|
||||||
#include "rdf.h"
|
#include "rdf.h"
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsXPIDLString.h"
|
||||||
|
|
||||||
class nsMsgServerDataSource : public nsMsgRDFDataSource
|
class nsMsgServerDataSource : public nsMsgRDFDataSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// RDF datasource methods
|
nsMsgServerDataSource();
|
||||||
|
virtual ~nsMsgServerDataSource();
|
||||||
/* void Init (in string uri); */
|
virtual nsresult Init();
|
||||||
NS_IMETHOD Init(const char *uri);
|
|
||||||
|
|
||||||
|
// RDF datasource methods
|
||||||
|
|
||||||
|
NS_IMETHOD GetURI(char* *aURI);
|
||||||
|
|
||||||
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
||||||
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
||||||
nsIRDFResource *property,
|
nsIRDFResource *property,
|
||||||
|
@ -78,11 +82,30 @@ nsIRDFResource* nsMsgServerDataSource::kNC_Server;
|
||||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child);
|
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child);
|
||||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Server);
|
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Server);
|
||||||
|
|
||||||
/* void Init (in string uri); */
|
nsMsgServerDataSource::nsMsgServerDataSource()
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMsgServerDataSource::Init(const char *uri)
|
|
||||||
{
|
{
|
||||||
nsMsgRDFDataSource::Init(uri);
|
nsresult rv;
|
||||||
|
rv = Init();
|
||||||
|
|
||||||
|
// XXX This call should be moved to a NS_NewMsgFooDataSource()
|
||||||
|
// method that the factory calls, so that failure to construct
|
||||||
|
// will return an error code instead of returning a partially
|
||||||
|
// initialized object.
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "uh oh, initialization failed");
|
||||||
|
if (NS_FAILED(rv)) return /* rv */;
|
||||||
|
|
||||||
|
return /* NS_OK */;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nsMsgServerDataSource::~nsMsgServerDataSource()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsMsgServerDataSource::Init()
|
||||||
|
{
|
||||||
|
nsMsgRDFDataSource::Init();
|
||||||
|
|
||||||
if (! kNC_Child) {
|
if (! kNC_Child) {
|
||||||
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
||||||
|
@ -91,6 +114,16 @@ nsMsgServerDataSource::Init(const char *uri)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMsgServerDataSource::GetURI(char* *aURI)
|
||||||
|
{
|
||||||
|
*aURI = nsXPIDLCString::Copy("rdf:msgservers");
|
||||||
|
if (! *aURI)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMsgServerDataSource::GetTarget(nsIRDFResource *source,
|
nsMsgServerDataSource::GetTarget(nsIRDFResource *source,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче