зеркало из https://github.com/mozilla/pjs.git
New files, not in build
This commit is contained in:
Родитель
22cea43adc
Коммит
135f3c5044
|
@ -0,0 +1,221 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsAbDirProperty.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "nsAbCard.h"
|
||||
#include "nsAddrDatabase.h"
|
||||
#include "nsIAbListener.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIFileLocator.h"
|
||||
#include "nsFileLocations.h"
|
||||
#include "mdb.h"
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
#include "prmem.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kAbCardCID, NS_ABCARDRESOURCE_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDB, NS_ADDRESSBOOKDB_CID);
|
||||
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
||||
|
||||
nsAbDirProperty::nsAbDirProperty(void)
|
||||
: m_DirName(nsnull), m_LastModifiedDate(nsnull),
|
||||
m_DbPath(nsnull), m_Server(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsAbDirProperty::~nsAbDirProperty(void)
|
||||
{
|
||||
PR_FREEIF(m_DirName);
|
||||
PR_FREEIF(m_LastModifiedDate);
|
||||
PR_FREEIF(m_DbPath);
|
||||
// m_Server will free with the list
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAbDirProperty)
|
||||
NS_IMPL_RELEASE(nsAbDirProperty)
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIAbDirectory>::GetIID()) ||
|
||||
aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIAbDirectory*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetChildNodes(nsIEnumerator* *result)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetChildCards(nsIEnumerator* *result)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetMailingList(nsIEnumerator **mailingList)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::CreateNewDirectory(const char *dirName)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::AddChildCards(const char *uriName, nsIAbCard **childCard)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::AddDirectory(const char *uriName, nsIAbDirectory **childDir)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::DeleteDirectories(nsISupportsArray *directories)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::DeleteCards(nsISupportsArray *cards)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::HasCard(nsIAbCard *cards, PRBool *hasCard)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::HasDirectory(nsIAbDirectory *dir, PRBool *hasDir)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetDirFilePath(char **dbPath)
|
||||
{
|
||||
char* path = nsnull;
|
||||
if (m_Server && m_Server->fileName)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIFileSpec* userdir;
|
||||
rv = locator->GetFileLocation(nsSpecialFileSpec::App_UserProfileDirectory50, &userdir);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsFileSpec dbFile;
|
||||
userdir->GetFileSpec(&dbFile);
|
||||
dbFile += m_Server->fileName;
|
||||
char* file = PL_strdup(dbFile.GetCString());
|
||||
*dbPath = file;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetDirName(char **name)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
if (m_DirName)
|
||||
*name = PL_strdup(m_DirName);
|
||||
else
|
||||
*name = PL_strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetDirName(char * name)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
PR_FREEIF(m_DirName);
|
||||
m_DirName = PL_strdup(name);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetLastModifiedDate(char * *aLastModifiedDate)
|
||||
{
|
||||
if (aLastModifiedDate)
|
||||
{
|
||||
if (m_DirName)
|
||||
*aLastModifiedDate = PL_strdup(m_LastModifiedDate);
|
||||
else
|
||||
*aLastModifiedDate = PL_strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetLastModifiedDate(char * aLastModifiedDate)
|
||||
{
|
||||
if (aLastModifiedDate)
|
||||
{
|
||||
PR_FREEIF(m_LastModifiedDate);
|
||||
m_LastModifiedDate = PL_strdup(aLastModifiedDate);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetServer(DIR_Server * *aServer)
|
||||
{
|
||||
if (aServer)
|
||||
{
|
||||
*aServer = m_Server;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetServer(DIR_Server * aServer)
|
||||
{
|
||||
m_Server = aServer;
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/********************************************************************************************************
|
||||
|
||||
Interface for representing Address Book Directory
|
||||
|
||||
*********************************************************************************************************/
|
||||
|
||||
#ifndef nsAbDirProperty_h__
|
||||
#define nsAbDirProperty_h__
|
||||
|
||||
#include "nsIAbDirectory.h" /* include the interface we are going to support */
|
||||
#include "nsAbRDFResource.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDirPrefs.h"
|
||||
|
||||
/*
|
||||
* Address Book Directory
|
||||
*/
|
||||
|
||||
class nsAbDirProperty: public nsIAbDirectory
|
||||
{
|
||||
public:
|
||||
nsAbDirProperty(void);
|
||||
virtual ~nsAbDirProperty(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIAbDirectory methods:
|
||||
NS_IMETHOD GetDirName(char **name);
|
||||
NS_IMETHOD SetDirName(char * name);
|
||||
NS_IMETHOD GetLastModifiedDate(char * *aLastModifiedDate);
|
||||
NS_IMETHOD SetLastModifiedDate(char * aLastModifiedDate);
|
||||
NS_IMETHOD GetServer(DIR_Server * *aServer);
|
||||
NS_IMETHOD SetServer(DIR_Server * aServer);
|
||||
NS_IMETHOD GetDirFilePath(char **dbPath);
|
||||
|
||||
NS_IMETHOD GetChildNodes(nsIEnumerator* *result);
|
||||
NS_IMETHOD GetChildCards(nsIEnumerator* *result);
|
||||
NS_IMETHOD AddChildCards(const char *uriName, nsIAbCard **childCard);
|
||||
NS_IMETHOD AddDirectory(const char *uriName, nsIAbDirectory **childDir);
|
||||
NS_IMETHOD DeleteDirectories(nsISupportsArray *directories);
|
||||
NS_IMETHOD DeleteCards(nsISupportsArray *cards);
|
||||
NS_IMETHOD HasCard(nsIAbCard *cards, PRBool *hasCard);
|
||||
NS_IMETHOD HasDirectory(nsIAbDirectory *dir, PRBool *hasDir);
|
||||
NS_IMETHOD GetMailingList(nsIEnumerator **mailingList);
|
||||
NS_IMETHOD CreateNewDirectory(const char *dirName);
|
||||
|
||||
protected:
|
||||
|
||||
char* m_DirName;
|
||||
char* m_LastModifiedDate;
|
||||
nsFileSpec* m_DbPath;
|
||||
DIR_Server* m_Server;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,314 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsAbRDFDataSource.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "nsAbDirectory.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsIAbCard.h"
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "prprf.h"
|
||||
#include "prlog.h"
|
||||
|
||||
// this is used for notification of observers using nsVoidArray
|
||||
typedef struct _nsAbRDFNotification {
|
||||
nsIRDFResource *subject;
|
||||
nsIRDFResource *property;
|
||||
nsIRDFNode *object;
|
||||
} nsAbRDFNotification;
|
||||
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Utilities
|
||||
|
||||
|
||||
void nsAbRDFDataSource::createNode(nsString& str, nsIRDFNode **node)
|
||||
{
|
||||
*node = nsnull;
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return; // always check this before proceeding
|
||||
nsIRDFLiteral * value;
|
||||
if (NS_SUCCEEDED(rdf->GetLiteral(str.GetUnicode(), &value)))
|
||||
{
|
||||
*node = value;
|
||||
}
|
||||
}
|
||||
|
||||
void nsAbRDFDataSource::createNode(PRUint32 value, nsIRDFNode **node)
|
||||
{
|
||||
char *valueStr = PR_smprintf("%d", value);
|
||||
nsString str(valueStr);
|
||||
createNode(str, node);
|
||||
PR_smprintf_free(valueStr);
|
||||
}
|
||||
|
||||
PRBool nsAbRDFDataSource::assertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsAbRDFNotification *note = (nsAbRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
||||
observer->OnAssert(note->subject,
|
||||
note->property,
|
||||
note->object);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool nsAbRDFDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
|
||||
{
|
||||
nsAbRDFNotification* note = (nsAbRDFNotification *)aData;
|
||||
nsIRDFObserver* observer = (nsIRDFObserver *)aElement;
|
||||
|
||||
observer->OnUnassert(note->subject,
|
||||
note->property,
|
||||
note->object);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsresult nsAbRDFDataSource::NotifyObservers(nsIRDFResource *subject,
|
||||
nsIRDFResource *property,
|
||||
nsIRDFNode *object,
|
||||
PRBool assert)
|
||||
{
|
||||
if(mObservers)
|
||||
{
|
||||
nsAbRDFNotification note = { subject, property, object };
|
||||
if (assert)
|
||||
mObservers->EnumerateForwards(assertEnumFunc, ¬e);
|
||||
else
|
||||
mObservers->EnumerateForwards(unassertEnumFunc, ¬e);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbRDFDataSource::NotifyPropertyChanged(nsIRDFResource *resource,
|
||||
nsIRDFResource *propertyResource,
|
||||
const char *oldValue, const char *newValue)
|
||||
{
|
||||
nsCOMPtr<nsIRDFNode> newValueNode;
|
||||
nsString newValueStr = newValue;
|
||||
createNode(newValueStr, getter_AddRefs(newValueNode));
|
||||
NotifyObservers(resource, propertyResource, newValueNode, PR_TRUE);
|
||||
|
||||
if (oldValue)
|
||||
{
|
||||
nsCOMPtr<nsIRDFNode> oldValueNode;
|
||||
nsString oldValueStr = oldValue;
|
||||
createNode(oldValueStr, getter_AddRefs(oldValueNode));
|
||||
NotifyObservers(resource, propertyResource, oldValueNode, PR_FALSE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsAbRDFDataSource::nsAbRDFDataSource():
|
||||
mObservers(nsnull),
|
||||
mInitialized(PR_FALSE),
|
||||
mRDFService(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsAbRDFDataSource::~nsAbRDFDataSource (void)
|
||||
{
|
||||
mRDFService->UnregisterDataSource(this);
|
||||
|
||||
if (mRDFService)
|
||||
{
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||
mRDFService = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsAbRDFDataSource::Init()
|
||||
{
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsCOMTypeInfo<nsIRDFService>::GetIID(),
|
||||
(nsISupports**) &mRDFService);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsAbRDFDataSource, nsCOMTypeInfo<nsIRDFDataSource>::GetIID());
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHODIMP nsAbRDFDataSource::GetURI(char* *uri)
|
||||
{
|
||||
NS_NOTREACHED("should be implemented by a subclass");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source /* out */)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** sources)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** targets)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::Change(nsIRDFResource *aSource,
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFNode *aOldTarget,
|
||||
nsIRDFNode *aNewTarget)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::Move(nsIRDFResource *aOldSource,
|
||||
nsIRDFResource *aNewSource,
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFNode *aTarget)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion)
|
||||
{
|
||||
*hasAssertion = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::AddObserver(nsIRDFObserver* n)
|
||||
{
|
||||
if (! mObservers) {
|
||||
nsresult rv;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mObservers));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
mObservers->AppendElement(n);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::RemoveObserver(nsIRDFObserver* n)
|
||||
{
|
||||
if (! mObservers)
|
||||
return NS_OK;
|
||||
mObservers->RemoveElement(n);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::ArcLabelsIn(nsIRDFNode* node,
|
||||
nsISimpleEnumerator** labels)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::ArcLabelsOut(nsIRDFResource* source,
|
||||
nsISimpleEnumerator** labels)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::GetAllResources(nsISimpleEnumerator** aCursor)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbRDFDataSource::GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbRDFDataSource::GetAllCmds(nsIRDFResource* source,
|
||||
nsISimpleEnumerator/*<nsIRDFResource>*/** commands)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbRDFDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
|
||||
PRBool* aResult)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbRDFDataSource::DoCommand
|
||||
(nsISupportsArray * aSources, nsIRDFResource* aCommand, nsISupportsArray * aArguments)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsAbRDFDataSource_h__
|
||||
#define nsAbRDFDataSource_h__
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsString.h"
|
||||
|
||||
/**
|
||||
* The addressbook data source.
|
||||
*/
|
||||
class nsAbRDFDataSource : public nsIRDFDataSource
|
||||
{
|
||||
private:
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
PRBool mInitialized;
|
||||
|
||||
// The cached service managers
|
||||
|
||||
nsIRDFService* mRDFService;
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsAbRDFDataSource(void);
|
||||
virtual ~nsAbRDFDataSource(void);
|
||||
virtual nsresult Init();
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHOD GetURI(char* *uri);
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source /* out */);
|
||||
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target);
|
||||
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** sources);
|
||||
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** targets);
|
||||
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv);
|
||||
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
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,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion);
|
||||
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n);
|
||||
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n);
|
||||
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsISimpleEnumerator** labels);
|
||||
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsISimpleEnumerator** labels);
|
||||
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor);
|
||||
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands);
|
||||
NS_IMETHOD GetAllCmds(nsIRDFResource* source,
|
||||
nsISimpleEnumerator/*<nsIRDFResource>*/** commands);
|
||||
|
||||
NS_IMETHOD IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
|
||||
PRBool* aResult);
|
||||
|
||||
NS_IMETHOD DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void createNode(nsString& str, nsIRDFNode **node);
|
||||
void createNode(PRUint32 value, nsIRDFNode **node);
|
||||
|
||||
nsresult NotifyPropertyChanged(nsIRDFResource *resource, nsIRDFResource *propertyResource,
|
||||
const char *oldValue, const char *newValue);
|
||||
|
||||
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property,
|
||||
nsIRDFNode *object, PRBool assert);
|
||||
|
||||
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче