зеркало из 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():
|
||||
mURI(nsnull),
|
||||
mObservers(nsnull),
|
||||
mInitialized(PR_FALSE),
|
||||
mRDFService(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||
|
||||
// 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();
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
|
@ -173,16 +173,6 @@ nsABCardDataSource::~nsABCardDataSource (void)
|
|||
{
|
||||
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;
|
||||
|
||||
NS_RELEASE2(kNC_PersonName, refcnt);
|
||||
|
@ -200,6 +190,36 @@ nsABCardDataSource::~nsABCardDataSource (void)
|
|||
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_RELEASE(nsABCardDataSource)
|
||||
|
@ -228,36 +248,9 @@ nsABCardDataSource::QueryInterface(REFNSIID iid, void** result)
|
|||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
||||
if ((*uri = nsXPIDLCString::Copy("rdf:addresscard")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
|
@ -357,6 +350,21 @@ NS_IMETHODIMP nsABCardDataSource::Unassert(nsIRDFResource* source,
|
|||
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,
|
||||
nsIRDFResource* property,
|
||||
|
@ -371,8 +379,8 @@ NS_IMETHODIMP nsABCardDataSource::HasAssertion(nsIRDFResource* source,
|
|||
NS_IMETHODIMP nsABCardDataSource::AddObserver(nsIRDFObserver* n)
|
||||
{
|
||||
if (! mObservers) {
|
||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
mObservers->AppendElement(n);
|
||||
return NS_OK;
|
||||
|
@ -387,7 +395,7 @@ NS_IMETHODIMP nsABCardDataSource::RemoveObserver(nsIRDFObserver* n)
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsABCardDataSource::assertEnumFunc(void *aElement, void *aData)
|
||||
nsABCardDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsAbRDFNotification *note = (nsAbRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
@ -399,7 +407,7 @@ nsABCardDataSource::assertEnumFunc(void *aElement, void *aData)
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsABCardDataSource::unassertEnumFunc(void *aElement, void *aData)
|
||||
nsABCardDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsAbRDFNotification* note = (nsAbRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
@ -486,12 +494,6 @@ nsABCardDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCardDataSource::Flush()
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsABCardDataSource::GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||
|
|
|
@ -16,10 +16,12 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIAbListener.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -29,8 +31,7 @@ class nsABCardDataSource : public nsIRDFDataSource,
|
|||
public nsIAbListener
|
||||
{
|
||||
private:
|
||||
char* mURI;
|
||||
nsVoidArray* mObservers;
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
PRBool mInitialized;
|
||||
|
||||
// The cached service managers
|
||||
|
@ -43,10 +44,9 @@ public:
|
|||
|
||||
nsABCardDataSource(void);
|
||||
virtual ~nsABCardDataSource (void);
|
||||
|
||||
nsresult Init();
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(char* *uri);
|
||||
|
||||
|
@ -79,6 +79,16 @@ public:
|
|||
nsIRDFResource* property,
|
||||
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,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
|
@ -97,8 +107,6 @@ public:
|
|||
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
||||
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||
|
||||
|
@ -139,8 +147,8 @@ protected:
|
|||
nsresult DoNewCard(nsIAbCard *directory,
|
||||
nsISupportsArray *arguments);
|
||||
|
||||
static PRBool assertEnumFunc(void *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(void *aElement, void *aData);
|
||||
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||
|
||||
static nsIRDFResource* kNC_PersonName;
|
||||
static nsIRDFResource* kNC_ListName;
|
||||
|
|
|
@ -149,17 +149,17 @@ void nsABDirectoryDataSource::createNode(PRUint32 value, nsIRDFNode **node)
|
|||
}
|
||||
|
||||
nsABDirectoryDataSource::nsABDirectoryDataSource():
|
||||
mURI(nsnull),
|
||||
mObservers(nsnull),
|
||||
mInitialized(PR_FALSE),
|
||||
mRDFService(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &mRDFService);
|
||||
|
||||
// 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();
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
|
@ -167,17 +167,6 @@ nsABDirectoryDataSource::~nsABDirectoryDataSource (void)
|
|||
{
|
||||
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;
|
||||
NS_RELEASE2(kNC_Child, refcnt);
|
||||
NS_RELEASE2(kNC_DirName, refcnt);
|
||||
|
@ -196,6 +185,39 @@ nsABDirectoryDataSource::~nsABDirectoryDataSource (void)
|
|||
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_RELEASE(nsABDirectoryDataSource)
|
||||
|
@ -224,39 +246,9 @@ nsABDirectoryDataSource::QueryInterface(REFNSIID iid, void** result)
|
|||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
||||
if ((*uri = nsXPIDLCString::Copy("rdf:addressdirectory")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
|
@ -385,6 +377,22 @@ NS_IMETHODIMP nsABDirectoryDataSource::Unassert(nsIRDFResource* source,
|
|||
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,
|
||||
nsIRDFResource* property,
|
||||
|
@ -399,8 +407,9 @@ NS_IMETHODIMP nsABDirectoryDataSource::HasAssertion(nsIRDFResource* source,
|
|||
NS_IMETHODIMP nsABDirectoryDataSource::AddObserver(nsIRDFObserver* n)
|
||||
{
|
||||
if (! mObservers) {
|
||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
mObservers->AppendElement(n);
|
||||
return NS_OK;
|
||||
|
@ -415,7 +424,7 @@ NS_IMETHODIMP nsABDirectoryDataSource::RemoveObserver(nsIRDFObserver* n)
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsABDirectoryDataSource::assertEnumFunc(void *aElement, void *aData)
|
||||
nsABDirectoryDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsAbRDFNotification *note = (nsAbRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
@ -427,7 +436,7 @@ nsABDirectoryDataSource::assertEnumFunc(void *aElement, void *aData)
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsABDirectoryDataSource::unassertEnumFunc(void *aElement, void *aData)
|
||||
nsABDirectoryDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsAbRDFNotification* note = (nsAbRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
@ -511,12 +520,6 @@ nsABDirectoryDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABDirectoryDataSource::Flush()
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsABDirectoryDataSource::GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIAbListener.h"
|
||||
|
@ -23,6 +24,7 @@
|
|||
#include "nsIAbCard.h"
|
||||
#include "nsDirPrefs.h"
|
||||
#include "nsIAbListener.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
static const char kAddrBookRootURI[] = "abdirectory:/";
|
||||
|
||||
|
@ -35,8 +37,7 @@ class nsABDirectoryDataSource : public nsIRDFDataSource,
|
|||
public nsIAbListener
|
||||
{
|
||||
private:
|
||||
char* mURI;
|
||||
nsVoidArray* mObservers;
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
PRBool mInitialized;
|
||||
|
||||
// The cached service managers
|
||||
|
@ -49,11 +50,9 @@ public:
|
|||
|
||||
nsABDirectoryDataSource(void);
|
||||
virtual ~nsABDirectoryDataSource (void);
|
||||
|
||||
nsresult Init();
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(char* *uri);
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
|
@ -85,6 +84,16 @@ public:
|
|||
nsIRDFResource* property,
|
||||
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,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
|
@ -103,8 +112,6 @@ public:
|
|||
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
||||
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||
|
||||
|
@ -151,8 +158,8 @@ protected:
|
|||
nsresult DoNewDirectory(nsIAbDirectory *directory,
|
||||
nsISupportsArray *arguments);
|
||||
|
||||
static PRBool assertEnumFunc(void *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(void *aElement, void *aData);
|
||||
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||
|
||||
static nsIRDFResource* kNC_Child;
|
||||
static nsIRDFResource* kNC_DirName;
|
||||
|
|
|
@ -44,7 +44,32 @@ nsIRDFResource* nsMessageViewDataSource::kNC_Date;
|
|||
nsIRDFResource* nsMessageViewDataSource::kNC_Status;
|
||||
|
||||
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
|
||||
nsMessageViewDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||
|
@ -73,16 +98,20 @@ nsMessageViewDataSource::QueryInterface(REFNSIID iid, void** result)
|
|||
nsMessageViewDataSource::nsMessageViewDataSource(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mURI = nsnull;
|
||||
mObservers = nsnull;
|
||||
mShowStatus = VIEW_SHOW_ALL;
|
||||
mInitialized = PR_FALSE;
|
||||
mShowThreads = PR_TRUE;
|
||||
|
||||
nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||
|
||||
// XXX This call should be moved to a NS_NewMessageViewDataSource()
|
||||
// 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. couldn't initialize.");
|
||||
if (NS_FAILED(rv)) return /* rv */;
|
||||
|
||||
return /* NS_OK */;
|
||||
}
|
||||
|
||||
nsMessageViewDataSource::~nsMessageViewDataSource (void)
|
||||
|
@ -90,10 +119,6 @@ nsMessageViewDataSource::~nsMessageViewDataSource (void)
|
|||
mRDFService->UnregisterDataSource(this);
|
||||
|
||||
RemoveDataSource(mDataSource);
|
||||
if(mURI)
|
||||
PL_strfree(mURI);
|
||||
|
||||
delete mObservers; // we only hold a weak ref to each observer
|
||||
|
||||
nsrefcnt 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)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
if ((mURI = PL_strdup(uri)) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
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_MessageChild) {
|
||||
|
@ -131,7 +160,7 @@ NS_IMETHODIMP nsMessageViewDataSource::Init(const 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;
|
||||
else
|
||||
return NS_OK;
|
||||
|
@ -290,6 +319,29 @@ NS_IMETHODIMP nsMessageViewDataSource::Unassert(nsIRDFResource* source,
|
|||
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,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
|
@ -305,8 +357,8 @@ NS_IMETHODIMP nsMessageViewDataSource::HasAssertion(nsIRDFResource* source,
|
|||
NS_IMETHODIMP nsMessageViewDataSource::AddObserver(nsIRDFObserver* n)
|
||||
{
|
||||
if (! mObservers) {
|
||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
mObservers->AppendElement(n);
|
||||
return NS_OK;
|
||||
|
@ -393,14 +445,6 @@ NS_IMETHODIMP nsMessageViewDataSource::GetAllResources(nsISimpleEnumerator** aCu
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::Flush()
|
||||
{
|
||||
if(mDataSource)
|
||||
return mDataSource->Flush();
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessageViewDataSource::GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||
{
|
||||
|
@ -456,9 +500,14 @@ NS_IMETHODIMP nsMessageViewDataSource::OnAssert(nsIRDFResource* subject,
|
|||
nsIRDFNode* object)
|
||||
{
|
||||
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);
|
||||
obs->OnAssert(subject, predicate, object);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -470,15 +519,60 @@ NS_IMETHODIMP nsMessageViewDataSource::OnUnassert(nsIRDFResource* subject,
|
|||
nsIRDFNode* object)
|
||||
{
|
||||
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);
|
||||
obs->OnUnassert(subject, predicate, object);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
}
|
||||
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()
|
||||
{
|
||||
mShowStatus = VIEW_SHOW_ALL;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "nsIMsgFolder.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIMessage.h"
|
||||
#include "nsIMsgThread.h"
|
||||
|
@ -37,8 +37,7 @@ class nsMessageViewDataSource : public nsIRDFCompositeDataSource, public nsIMess
|
|||
public nsIRDFObserver
|
||||
{
|
||||
private:
|
||||
char* mURI;
|
||||
nsVoidArray* mObservers;
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
PRBool mInitialized;
|
||||
nsIRDFService * mRDFService;
|
||||
|
||||
|
@ -48,11 +47,10 @@ public:
|
|||
|
||||
nsMessageViewDataSource(void);
|
||||
virtual ~nsMessageViewDataSource (void);
|
||||
virtual nsresult Init();
|
||||
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(char* *uri);
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
|
@ -84,6 +82,16 @@ public:
|
|||
nsIRDFResource* property,
|
||||
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,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
|
@ -102,8 +110,6 @@ public:
|
|||
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult);
|
||||
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||
|
||||
|
@ -131,6 +137,15 @@ public:
|
|||
nsIRDFResource* predicate,
|
||||
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
|
||||
NS_IMETHOD SetShowAll();
|
||||
NS_IMETHOD SetShowUnread();
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFResource.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plstr.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
|
||||
|
@ -41,12 +42,12 @@ class nsMsgAccountDataSource : public nsMsgRDFDataSource
|
|||
public:
|
||||
nsMsgAccountDataSource();
|
||||
virtual ~nsMsgAccountDataSource();
|
||||
virtual nsresult Init();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// RDF datasource methods
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(const char *uri);
|
||||
NS_IMETHOD GetURI(char* *aURI);
|
||||
|
||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
||||
|
@ -115,30 +116,28 @@ DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Identity);
|
|||
nsMsgAccountDataSource::nsMsgAccountDataSource():
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsMsgAccountDataSource)
|
||||
NS_IMPL_RELEASE(nsMsgAccountDataSource)
|
||||
|
||||
nsresult
|
||||
nsMsgAccountDataSource::QueryInterface(const nsIID& iid, void **result)
|
||||
nsMsgAccountDataSource::Init()
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgAccountDataSource::Init(const char *uri)
|
||||
{
|
||||
nsMsgRDFDataSource::Init(uri);
|
||||
nsMsgRDFDataSource::Init();
|
||||
|
||||
if (! kNC_Child) {
|
||||
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
||||
|
@ -149,6 +148,28 @@ nsMsgAccountDataSource::Init(const char *uri)
|
|||
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); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgAccountDataSource::GetTarget(nsIRDFResource *source,
|
||||
|
|
|
@ -61,14 +61,12 @@ public:
|
|||
|
||||
nsMsgAccountManagerDataSource();
|
||||
virtual ~nsMsgAccountManagerDataSource();
|
||||
virtual nsresult Init();
|
||||
|
||||
// service manager shutdown method
|
||||
|
||||
// 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); */
|
||||
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
||||
nsIRDFResource *property,
|
||||
|
@ -130,6 +128,16 @@ nsMsgAccountManagerDataSource::nsMsgAccountManagerDataSource():
|
|||
#ifdef DEBUG_amds
|
||||
printf("nsMsgAccountManagerDataSource() being created\n");
|
||||
#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()
|
||||
|
@ -139,11 +147,10 @@ nsMsgAccountManagerDataSource::~nsMsgAccountManagerDataSource()
|
|||
this);
|
||||
|
||||
}
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgAccountManagerDataSource::Init(const char *uri)
|
||||
|
||||
nsresult
|
||||
nsMsgAccountManagerDataSource::Init()
|
||||
{
|
||||
nsMsgRDFDataSource::Init(uri);
|
||||
nsresult rv=NS_OK;
|
||||
#ifdef DEBUG_amds
|
||||
printf("nsMsgAccountManagerDataSource::Init(%s)\n", uri ? uri : "(null)");
|
||||
|
|
|
@ -65,18 +65,17 @@ nsMsgFolderDataSource::nsMsgFolderDataSource():
|
|||
mInitialized(PR_FALSE),
|
||||
mRDFService(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
nsresult rv;
|
||||
rv = Init();
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
mailSession->AddFolderListener(this);
|
||||
// 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 */;
|
||||
}
|
||||
|
||||
nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
||||
|
@ -88,9 +87,6 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
|||
if(NS_SUCCEEDED(rv))
|
||||
mailSession->RemoveFolderListener(this);
|
||||
|
||||
PL_strfree(mURI);
|
||||
|
||||
|
||||
nsrefcnt refcnt;
|
||||
NS_RELEASE2(kNC_Child, refcnt);
|
||||
NS_RELEASE2(kNC_MessageChild, refcnt);
|
||||
|
@ -110,35 +106,21 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
|||
mRDFService = nsnull;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
nsresult nsMsgFolderDataSource::Init()
|
||||
{
|
||||
if (mInitialized)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
if ((mURI = PL_strdup(uri)) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
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);
|
||||
|
||||
|
@ -161,9 +143,32 @@ NS_IMETHODIMP nsMsgFolderDataSource::Init(const char* uri)
|
|||
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)
|
||||
{
|
||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
||||
if ((*uri = nsXPIDLCString::Copy("rdf:mailnewsfolders")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
|
@ -415,12 +420,6 @@ nsMsgFolderDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolderDataSource::Flush()
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolderDataSource::GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||
|
|
|
@ -39,15 +39,13 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsMsgFolderDataSource(void);
|
||||
virtual ~nsMsgFolderDataSource (void);
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(char* *uri);
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
|
@ -93,8 +91,6 @@ public:
|
|||
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult);
|
||||
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "nsIMsgMailSession.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plstr.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
|
||||
|
@ -41,11 +42,13 @@ class nsMsgIdentityDataSource : public nsMsgRDFDataSource
|
|||
{
|
||||
|
||||
public:
|
||||
nsMsgIdentityDataSource();
|
||||
virtual ~nsMsgIdentityDataSource();
|
||||
virtual nsresult Init();
|
||||
|
||||
// RDF datasource methods
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(const char *uri);
|
||||
NS_IMETHOD GetURI(char* *aURI);
|
||||
|
||||
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
||||
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, Identity);
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgIdentityDataSource::Init(const char *uri)
|
||||
nsMsgIdentityDataSource::nsMsgIdentityDataSource()
|
||||
{
|
||||
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) {
|
||||
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
||||
|
@ -106,6 +129,17 @@ nsMsgIdentityDataSource::Init(const char *uri)
|
|||
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); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgIdentityDataSource::GetTarget(nsIRDFResource *source,
|
||||
|
|
|
@ -63,8 +63,6 @@ nsMsgMessageDataSource::nsMsgMessageDataSource():
|
|||
mRDFService(nsnull),
|
||||
mHeaderParser(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &mRDFService); // XXX probably need shutdown listener here
|
||||
|
@ -90,6 +88,16 @@ nsMsgMessageDataSource::nsMsgMessageDataSource():
|
|||
if(NS_SUCCEEDED(rv))
|
||||
mailSession->AddFolderListener(this);
|
||||
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)
|
||||
|
@ -102,8 +110,6 @@ nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
|||
if(NS_SUCCEEDED(rv))
|
||||
mailSession->RemoveFolderListener(this);
|
||||
|
||||
PL_strfree(mURI);
|
||||
|
||||
nsrefcnt refcnt;
|
||||
|
||||
NS_RELEASE2(kNC_Subject, refcnt);
|
||||
|
@ -120,36 +126,11 @@ nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
|||
mRDFService = nsnull;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
nsresult nsMsgMessageDataSource::Init()
|
||||
{
|
||||
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_Subject) {
|
||||
|
@ -168,9 +149,30 @@ NS_IMETHODIMP nsMsgMessageDataSource::Init(const char* uri)
|
|||
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)
|
||||
{
|
||||
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull)
|
||||
if ((*uri = nsXPIDLCString::Copy("rdf:mailnewsmessages")) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
|
@ -364,12 +366,6 @@ nsMsgMessageDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMessageDataSource::Flush()
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgMessageDataSource::GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||
|
|
|
@ -42,15 +42,13 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsMsgMessageDataSource(void);
|
||||
virtual ~nsMsgMessageDataSource (void);
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(char* *uri);
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
|
@ -96,8 +94,6 @@ public:
|
|||
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
||||
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||
|
||||
|
|
|
@ -27,21 +27,33 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
|||
static NS_DEFINE_CID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
nsMsgRDFDataSource::nsMsgRDFDataSource():
|
||||
mURI(nsnull),
|
||||
mRDFService(nsnull),
|
||||
mObservers(nsnull)
|
||||
mRDFService(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsMsgRDFDataSource::~nsMsgRDFDataSource()
|
||||
{
|
||||
if (mURI) PL_strfree(mURI);
|
||||
if (mRDFService) nsServiceManager::ReleaseService(kRDFServiceCID,
|
||||
mRDFService,
|
||||
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_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; */
|
||||
NS_IMETHODIMP
|
||||
nsMsgRDFDataSource::GetURI(char * *aURI)
|
||||
{
|
||||
NS_PRECONDITION(aURI != nsnull, "null ptr");
|
||||
if (! aURI)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if ((*aURI = nsXPIDLCString::Copy(mURI)) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return NS_OK;
|
||||
NS_NOTREACHED("should be implemented by a subclass");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgRDFDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval)
|
||||
|
@ -168,8 +174,9 @@ NS_IMETHODIMP
|
|||
nsMsgRDFDataSource::AddObserver(nsIRDFObserver *aObserver)
|
||||
{
|
||||
if (! mObservers) {
|
||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
mObservers->AppendElement(aObserver);
|
||||
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); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgRDFDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval)
|
||||
|
@ -288,7 +287,7 @@ nsresult nsMsgRDFDataSource::NotifyObservers(nsIRDFResource *subject,
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsMsgRDFDataSource::assertEnumFunc(void *aElement, void *aData)
|
||||
nsMsgRDFDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsMsgRDFNotification *note = (nsMsgRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
@ -300,7 +299,7 @@ nsMsgRDFDataSource::assertEnumFunc(void *aElement, void *aData)
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsMsgRDFDataSource::unassertEnumFunc(void *aElement, void *aData)
|
||||
nsMsgRDFDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsMsgRDFNotification* note = (nsMsgRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
#ifndef __nsMsgRDFDataSource_h
|
||||
#define __nsMsgRDFDataSource_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
class nsMsgRDFDataSource : public nsIRDFDataSource,
|
||||
public nsIShutdownListener
|
||||
|
@ -31,14 +32,12 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
|||
public:
|
||||
nsMsgRDFDataSource();
|
||||
virtual ~nsMsgRDFDataSource();
|
||||
virtual nsresult Init();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD OnShutdown(const nsCID& aClass, nsISupports* service);
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(const char *uri);
|
||||
|
||||
/* readonly attribute string URI; */
|
||||
NS_IMETHOD GetURI(char * *aURI);
|
||||
|
||||
|
@ -90,6 +89,25 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
|||
nsIRDFResource *aProperty,
|
||||
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,
|
||||
in nsIRDFResource aProperty,
|
||||
in nsIRDFNode aTarget,
|
||||
|
@ -117,9 +135,6 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
|||
/* nsISimpleEnumerator GetAllResources (); */
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator **_retval);
|
||||
|
||||
/* void Flush (); */
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource *aSource,
|
||||
nsIEnumerator **_retval);
|
||||
|
@ -141,17 +156,15 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
|
|||
|
||||
|
||||
protected:
|
||||
char *mURI;
|
||||
|
||||
nsIRDFService *getRDFService();
|
||||
static PRBool assertEnumFunc(void *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(void *aElement, void *aData);
|
||||
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property,
|
||||
nsIRDFNode *object, PRBool assert);
|
||||
|
||||
private:
|
||||
nsIRDFService *mRDFService;
|
||||
nsVoidArray *mObservers;
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -24,15 +24,19 @@
|
|||
#include "rdf.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
class nsMsgServerDataSource : public nsMsgRDFDataSource
|
||||
{
|
||||
public:
|
||||
// RDF datasource methods
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(const char *uri);
|
||||
nsMsgServerDataSource();
|
||||
virtual ~nsMsgServerDataSource();
|
||||
virtual nsresult Init();
|
||||
|
||||
// RDF datasource methods
|
||||
|
||||
NS_IMETHOD GetURI(char* *aURI);
|
||||
|
||||
/* nsIRDFNode GetTarget (in nsIRDFResource source, in nsIRDFResource property, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetTarget(nsIRDFResource *source,
|
||||
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, Server);
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgServerDataSource::Init(const char *uri)
|
||||
nsMsgServerDataSource::nsMsgServerDataSource()
|
||||
{
|
||||
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) {
|
||||
getRDFService()->GetResource(kURINC_child, &kNC_Child);
|
||||
|
@ -91,6 +114,16 @@ nsMsgServerDataSource::Init(const char *uri)
|
|||
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); */
|
||||
NS_IMETHODIMP
|
||||
nsMsgServerDataSource::GetTarget(nsIRDFResource *source,
|
||||
|
|
Загрузка…
Ссылка в новой задаче