Landed RDF_122898_BRANCH onto the trunk.

This commit is contained in:
waterson%netscape.com 1999-01-05 03:53:15 +00:00
Родитель cf7a9076f6
Коммит 314b664b4c
55 изменённых файлов: 4617 добавлений и 1280 удалений

Просмотреть файл

@ -59,7 +59,7 @@
#include "nsIRDFDataBase.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsRDFCID.h"
@ -78,12 +78,12 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIRDFContentIID, NS_IRDFCONTENT_IID);
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -924,9 +924,9 @@ nsRDFElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResu
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
// XXX I'm not sure if we should support properties as attributes
// or not...
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
nsIRDFService* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mgr)))
return rv;
@ -952,7 +952,7 @@ done:
NS_IF_RELEASE(property);
NS_IF_RELEASE(value);
NS_IF_RELEASE(db);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
return rv;
@ -1007,9 +1007,9 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
// XXX I'm not sure if we should support attributes or not...
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
nsIRDFService* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mgr)))
return rv;
@ -1050,7 +1050,7 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
done:
NS_IF_RELEASE(properties);
NS_IF_RELEASE(db);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
return rv;
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
@ -1293,14 +1293,14 @@ nsRDFElement::SetResource(const nsString& aURI)
nsresult rv;
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mgr)))
nsIRDFService* service = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &service)))
return rv;
rv = mgr->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
rv = service->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
nsServiceManager::ReleaseService(kRDFServiceCID, service);
return rv;
}
@ -1370,22 +1370,22 @@ nsRDFElement::SetProperty(const nsString& aPropertyURI, const nsString& aValue)
#endif
nsresult rv;
nsIRDFResourceManager* mgr = nsnull;
nsIRDFService* service = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mgr)))
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &service)))
return rv;
nsIRDFResource* property = nsnull;
nsIRDFLiteral* value = nsnull;
nsIRDFDataBase* db = nsnull;
if (NS_FAILED(rv = mgr->GetUnicodeResource(aPropertyURI, &property)))
if (NS_FAILED(rv = service->GetUnicodeResource(aPropertyURI, &property)))
goto done;
// XXX assume it's a literal?
if (NS_FAILED(rv = mgr->GetLiteral(aValue, &value)))
if (NS_FAILED(rv = service->GetLiteral(aValue, &value)))
goto done;
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
@ -1397,7 +1397,7 @@ done:
NS_IF_RELEASE(db);
NS_IF_RELEASE(value);
NS_IF_RELEASE(property);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, service);
return rv;
}

Просмотреть файл

@ -4,5 +4,6 @@ nsIRDFDataBase.h
nsIRDFDataSource.h
nsIRDFNode.h
nsIRDFObserver.h
nsIRDFResourceManager.h
nsIRDFResourceFactory.h
nsIRDFService.h
nsIRDFXMLSource.h

Просмотреть файл

@ -31,7 +31,8 @@ EXPORTS = \
nsIRDFDataSource.h \
nsIRDFNode.h \
nsIRDFObserver.h \
nsIRDFResourceManager.h \
nsIRDFResourceFactory.h \
nsIRDFService.h \
nsIRDFXMLSource.h \
$(NULL)

Просмотреть файл

@ -28,7 +28,8 @@ EXPORTS=\
nsIRDFDataSource.h \
nsIRDFNode.h \
nsIRDFObserver.h \
nsIRDFResourceManager.h \
nsIRDFResourceFactory.h \
nsIRDFService.h \
nsIRDFXMLSource.h \
$(NULL)

Просмотреть файл

@ -42,6 +42,16 @@ public:
* unless a catastrophic error occurs.
*/
NS_IMETHOD Advance(void) = 0;
/* Retrieve the data source from which the current item was obtained.
* @return NS_OK, unless a catastrophic error occurs.
*/
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) = 0;
/**
* Irrespective of the query, a cursor is an interator over a set.
* This allows you to obtain the current value.
*/
NS_IMETHOD GetValue(nsIRDFNode** aValue) = 0;
};
@ -55,13 +65,6 @@ public:
*/
class nsIRDFAssertionCursor : public nsIRDFCursor {
public:
/**
* Retrieve the data source in which the assertion actually
* lives.
* XXX Is it dangerous to be exposing naked data sources like this?
* @return NS_OK, unless a catastrophic error occurs.
*/
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) = 0;
/**
* Retrieve the assertion's subject resource.
@ -99,12 +102,7 @@ public:
*/
class nsIRDFArcsOutCursor : public nsIRDFCursor {
public:
/**
* Retrieve the data source in which the arc is stored.
* XXX Is it dangerous to be exposing naked data sources like this?
* @return NS_OK, unless a catastrophic error occurs.
*/
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) = 0;
/**
* Retrieve the "subject" node from which the arcs originate.
@ -117,12 +115,13 @@ public:
* @return NS_OK, unless a catastrophic error occurs.
*/
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
/**
* Retrieve the truth value of the arc.
* @return NS_OK, unless a catastrophic error occurs.
*/
* xxx rvg --- truth value doesn't make sense here.
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
*/
};
@ -136,12 +135,6 @@ public:
*/
class nsIRDFArcsInCursor : public nsIRDFCursor {
public:
/**
* Retrieve the data source in which the arc is stored.
* XXX Is it dangerous to be exposing naked data sources like this?
* @return NS_OK, unless a catastrophic error occurs.
*/
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) = 0;
/**
* Retrieve the "object" node in which the arc terminates.
@ -154,12 +147,13 @@ public:
* @return NS_OK, unless a catastrophic error occurs.
*/
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
/**
* Retrieve the truth value of the arc.
* @return NS_OK, unless a catastrophic error occurs.
*/
* xxx rvg --- truth value doesn't make sense here.
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
*/
};

Просмотреть файл

@ -39,7 +39,7 @@ class nsIRDFResource;
class nsIRDFDataSource : public nsISupports {
public:
// XXX I didn't make any of these methods "const" because it's
// XXX I didn't make some of these methods "const" because it's
// probably pretty likely that many data sources will just make
// stuff up at runtime to answer queries.
@ -50,6 +50,11 @@ public:
*/
NS_IMETHOD Init(const char* uri) = 0;
/**
* Retrieve the URI of the data source.
*/
NS_IMETHOD GetURI(const char* *uri) const = 0;
/**
* Find an RDF resource that points to a given node over the
* specified arc & truth value

Просмотреть файл

@ -28,19 +28,19 @@
/**
*
* Nodes are created using an instance of nsIRDFResourceManager, which
* Nodes are created using an instance of nsIRDFService, which
* should be obtained from the service manager:
*
* nsIRDFResourceManager* mgr;
* if (NS_SUCCEEDED(nsServiceManager::GetService(kCRDFResourceManagerCID,
* kIRDFResourceManagerIID,
* &mgr))) {
* nsIRDFService* service;
* if (NS_SUCCEEDED(nsServiceManager::GetService(kCRDFServiceCID,
* kIRDFServiceIID,
* (nsISupports**) &service))) {
* nsIRDFNode* node;
* if (NS_SUCCEEDED(mgr->GetResource("http://foo.bar/", node))) {
* if (NS_SUCCEEDED(service->GetResource("http://foo.bar/", node))) {
* // do something useful here...
* NS_IF_RELEASE(node);
* }
* nsServiceManager::ReleaseService(kCRDFManagerCID, mgr);
* nsServiceManager::ReleaseService(kCRDFServiceCID, mgr);
* }
*
*/

Просмотреть файл

@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
#ifndef nsIRDFResourceFactory_h__
#define nsIRDFResourceFactory_h__
#include "nsISupports.h"
class nsIRDFResource;
// {8CE57A20-A02C-11d2-8EBF-00805F29F370}
#define NS_IRDFRESOURCEFACTORY_IID \
{ 0x8ce57a20, 0xa02c, 0x11d2, { 0x8e, 0xbf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
/**
* A resource factory can be registered with <tt>nsIRDFService</tt> to produce
* resources with a certain <i>URI prefix</i>. The resource factory will be called
* upon to create a new resource, which the resource manager will cache.
*
* @see nsIRDFService::RegisterResourceFactory
* @see nsIRDFService::UnRegisterResourceFactory
*/
class nsIRDFResourceFactory : public nsISupports
{
public:
/**
* This method is called by the RDF service to create a new
* resource.
*
* NOTE. After constructing a new resource via a call to
* nsIRDFResourceFactory::CreateResource(), the implementation of
* the RDF service calls nsIRDFResource::GetValue() on the
* resulting resource. The resulting <tt>const char*</tt> is used
* as a key for the resource cache. (The assumption is that the
* custom resource implementation needs to store this information,
* anyway.)
*
* This has important implications for a custom resource's
* destructor; namely, that you must call
* nsIRDFService::UnCacheResource() <b>before</b> releasing the
* storage for the resource's URI. See
* nsIRDFService::UnCacheResource() for more information.
*/
NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult) = 0;
};
#endif // nsIRDFResourceFactory_h__

Просмотреть файл

@ -0,0 +1,141 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
#ifndef nsIRDFService_h__
#define nsIRDFService_h__
#include "nscore.h"
#include "nsISupports.h"
class nsIRDFDataBase;
class nsIRDFDataSource;
class nsIRDFLiteral;
class nsIRDFResource;
class nsIRDFResourceFactory;
/**
The RDF service interface. This is a singleton object, and should be
obtained from the <tt>nsServiceManager</tt>.
XXX I'm not particularly happy with the current APIs for named data
sources. The idea is that you want "rdf:bookmarks" to always map to
the "bookmarks" data store. The thing that bothers me now is that
the implementation has to pre-load all of the data sources: that
means you need to parse the bookmarks file, read the history, etc.,
rather than doing this on-demand. With a little thought, it may be
able to enormously improve these APIs so that pre-loading data
sources is unnecessary.
*/
class nsIRDFService : public nsISupports {
public:
// Resource management routines
/**
* Construct an RDF resource from a single-byte URI. <tt>nsIRDFSerivce</tt>
* caches resources that are in-use, so multiple calls to <tt>GetResource()</tt>
* for the same <tt>uri</tt> will return identical pointers.
*/
NS_IMETHOD GetResource(const char* uri, nsIRDFResource** resource) = 0;
/**
* Construct an RDF resource from a Unicode URI. This is provided
* as a convenience method, allowing automatic, in-line C++
* conversion from <tt>nsString</tt> objects. The <tt>uri</tt> will
* be converted to a single-byte representation internally.
*/
NS_IMETHOD GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource) = 0;
/**
* Construct an RDF literal from a Unicode string.
*/
NS_IMETHOD GetLiteral(const PRUnichar* value, nsIRDFLiteral** literal) = 0;
/**
* Called to notify the resource manager that a resource is no
* longer in use. This method should only be called from the
* destructor of a "custom" resource implementation to notify the
* RDF service that the last reference to the resource has been
* released, so the resource is no longer valid.
*
* NOTE. As mentioned in nsIRDFResourceFactory::CreateResource(),
* the RDF service will use the result of
* nsIRDFResource::GetValue() as a key into its cache. For this
* reason, you must always un-cache the resource <b>before</b>
* releasing the storage for the <tt>const char*</tt> URI.
*/
NS_IMETHOD UnCacheResource(nsIRDFResource* resource) = 0;
/**
* Registers the specified resource factory as the producer for resources that
* have the specified <i>URI prefix</i>.
*/
NS_IMETHOD RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory) = 0;
/**
* Unregsters the specified resource factory from producing resources that have
* the specified <i>URI prefix</i>.
*/
NS_IMETHOD UnRegisterResourceFactory(const char* aURIPrefix) = 0;
// Data source management routines
/**
* Register a <i>named data source</i> with the specified URI.
*/
NS_IMETHOD RegisterNamedDataSource(const char* uri, nsIRDFDataSource* dataSource) = 0;
/**
* Unregister a <i>named data source</i>.
*/
NS_IMETHOD UnRegisterNamedDataSource(const char* uri) = 0;
/**
* Get the <i>named data source</i> corresponding to the URI.
*/
NS_IMETHOD GetNamedDataSource(const char* uri, nsIRDFDataSource** dataSource) = 0;
/**
* Create a database that contains the specified named data
* sources. This is a convenience method whose functionality is
* equivalent to (1) constructing a new nsIRDFDataBase object from
* the repository, and (2) iteratively adding the named data sources
* to it, in order.
*/
NS_IMETHOD CreateDatabase(const char** uris, nsIRDFDataBase** dataBase) = 0;
/**
* Get the database aggregating all the stuff that Navigator sees as a default,
* including a "local" store.
*/
NS_IMETHOD CreateBrowserDatabase(nsIRDFDataBase** dataBase) = 0;
};
// {BFD05261-834C-11d2-8EAC-00805F29F370}
#define NS_IRDFSERVICE_IID \
{ 0xbfd05261, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
extern nsresult
NS_NewRDFService(nsIRDFService** result);
#endif // nsIRDFService_h__

Просмотреть файл

@ -29,7 +29,7 @@ class nsIOutputStream;
class nsIRDFXMLSource : public nsISupports
{
public:
NS_IMETHOD Serialize(nsIOutputStream* stream) = 0;
NS_IMETHOD Serialize(nsIOutputStream* aStream) = 0;
};
#endif // nsIRDFXMLSource_h__

Просмотреть файл

@ -51,6 +51,7 @@ static const char* kTag##prefix##_##name = kURI##prefix##_##name## + sizeof(##na
/* Returned from nsIRDFCursor::Advance() if the cursor has no more
elements to enuemrate */
#define NS_ERROR_RDF_CURSOR_EMPTY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 1)
#define NS_ERROR_RDF_NO_VALUE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 2)
/*@}*/

Просмотреть файл

@ -28,10 +28,11 @@ LIBRARY_NAME = rdfbase_s
CPPSRCS = \
nsContainerCursor.cpp \
nsDataBase.cpp \
nsDefaultResourceFactory.cpp \
nsEmptyCursor.cpp \
nsMemoryDataSource.cpp \
nsRDFResourceManager.cpp \
nsSimpleDataBase.cpp \
nsInMemoryDataSource.cpp \
nsRDFService.cpp \
rdfutil.cpp \
$(NULL)

Просмотреть файл

@ -21,10 +21,11 @@ LIBRARY_NAME=rdfbase_s
CPP_OBJS=\
.\$(OBJDIR)\nsContainerCursor.obj \
.\$(OBJDIR)\nsDataBase.obj \
.\$(OBJDIR)\nsDefaultResourceFactory.obj \
.\$(OBJDIR)\nsEmptyCursor.obj \
.\$(OBJDIR)\nsInMemoryDataSource.obj \
.\$(OBJDIR)\nsRDFResourceManager.obj \
.\$(OBJDIR)\nsSimpleDataBase.obj \
.\$(OBJDIR)\nsInMemoryDataSource.obj \
.\$(OBJDIR)\nsRDFService.obj \
.\$(OBJDIR)\rdfutil.obj \
$(NULL)

Просмотреть файл

@ -20,7 +20,7 @@
#include "nsIRDFCursor.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsRDFCID.h"
#include "nsString.h"
@ -55,10 +55,10 @@
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
////////////////////////////////////////////////////////////////////////
@ -71,7 +71,7 @@ DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, nextVal); // ad hoc way to make contain
class ContainerCursorImpl : public nsIRDFAssertionCursor {
private:
nsIRDFResourceManager* mResourceMgr;
nsIRDFService* mRDFService;
nsIRDFDataSource* mDataSource;
nsIRDFResource* mContainer;
nsIRDFNode* mNext;
@ -90,6 +90,7 @@ public:
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
NS_IMETHOD GetObject(nsIRDFNode** aObject);
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
NS_IMETHOD GetValue(nsIRDFNode** aValue);
};
ContainerCursorImpl::ContainerCursorImpl(nsIRDFDataSource* ds,
@ -101,13 +102,13 @@ ContainerCursorImpl::ContainerCursorImpl(nsIRDFDataSource* ds,
NS_IF_ADDREF(mContainer);
nsresult rv;
rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mResourceMgr);
rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to acquire resource manager");
NS_ASSERTION(rdf_IsContainer(mResourceMgr, mDataSource, container), "not a container");
NS_ASSERTION(rdf_IsContainer(mRDFService, mDataSource, container), "not a container");
}
@ -115,8 +116,8 @@ ContainerCursorImpl::~ContainerCursorImpl(void)
{
NS_IF_RELEASE(mNext);
if (mResourceMgr)
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mResourceMgr);
if (mRDFService)
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
NS_IF_RELEASE(mContainer);
NS_IF_RELEASE(mDataSource);
@ -158,7 +159,7 @@ ContainerCursorImpl::Advance(void)
PRInt32 err;
// XXX we could cache all this crap when the cursor gets created.
if (NS_FAILED(rv = mResourceMgr->GetResource(kURIRDF_nextVal, &RDF_nextVal)))
if (NS_FAILED(rv = mRDFService->GetResource(kURIRDF_nextVal, &RDF_nextVal)))
goto done;
if (NS_FAILED(rv = mDataSource->GetTarget(mContainer, RDF_nextVal, PR_TRUE, &nextNode)))
@ -242,7 +243,7 @@ ContainerCursorImpl::GetPredicate(nsIRDFResource** aPredicate)
s.Append(mCounter, 10);
// this'll AddRef(), null check, etc.
return mResourceMgr->GetUnicodeResource(s, aPredicate);
return mRDFService->GetUnicodeResource(s, aPredicate);
}
@ -262,6 +263,22 @@ ContainerCursorImpl::GetObject(nsIRDFNode** aObject)
}
NS_IMETHODIMP
ContainerCursorImpl::GetValue(nsIRDFNode** aObject)
{
NS_PRECONDITION(aObject != nsnull, "null ptr");
if (! aObject)
return NS_ERROR_NULL_POINTER;
if (! mNext)
return NS_ERROR_UNEXPECTED;
NS_ADDREF(mNext);
*aObject = mNext;
return NS_OK;
}
NS_IMETHODIMP
ContainerCursorImpl::GetTruthValue(PRBool* aTruthValue)
{

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,221 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 "nsIRDFNode.h"
#include "nsIRDFResourceFactory.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsRDFCID.h"
#include "plstr.h"
////////////////////////////////////////////////////////////////////////
static NS_DEFINE_IID(kIRDFNodeIID, NS_IRDFNODE_IID);
static NS_DEFINE_IID(kIRDFResourceFactoryIID, NS_IRDFRESOURCEFACTORY_IID);
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
////////////////////////////////////////////////////////////////////////
class DefaultResourceImpl : public nsIRDFResource
{
public:
DefaultResourceImpl(const char* uri);
virtual ~DefaultResourceImpl(void);
// nsISupports
NS_DECL_ISUPPORTS
// nsIRDFNode
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const;
// nsIRDFResource
NS_IMETHOD GetValue(const char* *uri) const;
NS_IMETHOD EqualsResource(const nsIRDFResource* resource, PRBool* result) const;
NS_IMETHOD EqualsString(const char* uri, PRBool* result) const;
// Implementation methods
const char* GetURI(void) const {
return mURI;
}
private:
char* mURI;
};
DefaultResourceImpl::DefaultResourceImpl(const char* uri)
{
NS_INIT_REFCNT();
mURI = PL_strdup(uri);
}
DefaultResourceImpl::~DefaultResourceImpl(void)
{
nsresult rv;
nsIRDFService* mgr;
rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mgr);
PR_ASSERT(NS_SUCCEEDED(rv));
if (NS_SUCCEEDED(rv)) {
mgr->UnCacheResource(this);
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
}
// N.B. that we need to free the URI *after* we un-cache the resource,
// due to the way that the resource manager is implemented.
PL_strfree(mURI);
}
NS_IMPL_ADDREF(DefaultResourceImpl);
NS_IMPL_RELEASE(DefaultResourceImpl);
nsresult
DefaultResourceImpl::QueryInterface(REFNSIID iid, void** result)
{
if (! result)
return NS_ERROR_NULL_POINTER;
*result = nsnull;
if (iid.Equals(kIRDFResourceIID) ||
iid.Equals(kIRDFNodeIID) ||
iid.Equals(kISupportsIID)) {
*result = NS_STATIC_CAST(nsIRDFResource*, this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP
DefaultResourceImpl::EqualsNode(nsIRDFNode* node, PRBool* result) const
{
nsresult rv;
nsIRDFResource* resource;
if (NS_SUCCEEDED(node->QueryInterface(kIRDFResourceIID, (void**) &resource))) {
rv = EqualsResource(resource, result);
NS_RELEASE(resource);
}
else {
*result = PR_FALSE;
rv = NS_OK;
}
return rv;
}
NS_IMETHODIMP
DefaultResourceImpl::GetValue(const char* *uri) const
{
if (!uri)
return NS_ERROR_NULL_POINTER;
*uri = mURI;
return NS_OK;
}
NS_IMETHODIMP
DefaultResourceImpl::EqualsResource(const nsIRDFResource* resource, PRBool* result) const
{
if (!resource || !result)
return NS_ERROR_NULL_POINTER;
*result = (resource == this);
return NS_OK;
}
NS_IMETHODIMP
DefaultResourceImpl::EqualsString(const char* uri, PRBool* result) const
{
if (!uri || !result)
return NS_ERROR_NULL_POINTER;
*result = (PL_strcmp(uri, mURI) == 0);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
class DefaultResourceFactoryImpl : public nsIRDFResourceFactory
{
public:
DefaultResourceFactoryImpl(void);
virtual ~DefaultResourceFactoryImpl(void);
NS_DECL_ISUPPORTS
NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult);
};
DefaultResourceFactoryImpl::DefaultResourceFactoryImpl(void)
{
NS_INIT_REFCNT();
}
DefaultResourceFactoryImpl::~DefaultResourceFactoryImpl(void)
{
}
NS_IMPL_ISUPPORTS(DefaultResourceFactoryImpl, kIRDFResourceFactoryIID);
NS_IMETHODIMP
DefaultResourceFactoryImpl::CreateResource(const char* aURI, nsIRDFResource** aResult)
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
DefaultResourceImpl* resource = new DefaultResourceImpl(aURI);
if (! resource)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(resource);
*aResult = resource;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsresult
NS_NewRDFDefaultResourceFactory(nsIRDFResourceFactory** result)
{
NS_PRECONDITION(result != nsnull, "null ptr");
if (! result)
return NS_ERROR_NULL_POINTER;
DefaultResourceFactoryImpl* factory = new DefaultResourceFactoryImpl();
if (! factory)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(factory);
*result = factory;
return NS_OK;
}

Просмотреть файл

@ -81,6 +81,11 @@ public:
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
return NS_ERROR_UNEXPECTED;
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return NS_ERROR_UNEXPECTED;
}
};
nsresult
@ -143,6 +148,11 @@ public:
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
return NS_ERROR_UNEXPECTED;
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return NS_ERROR_UNEXPECTED;
}
};
nsresult
@ -205,6 +215,11 @@ public:
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
return NS_ERROR_UNEXPECTED;
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return NS_ERROR_UNEXPECTED;
}
};
nsresult

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

Просмотреть файл

@ -29,16 +29,20 @@
class nsIRDFDataSource;
class nsIRDFDataBase;
#ifdef _WIN32
// in nsMemoryDataSource.cpp
nsresult NS_NewRDFInMemoryDataSource(nsIRDFDataSource** result);
#else
// in nsMemoryDataSource.cpp
nsresult NS_NewRDFMemoryDataSource(nsIRDFDataSource** result);
#endif
// in nsInMemoryDataSource.cpp
nsresult NS_NewRDFInMemoryDataSource(nsIRDFDataSource** result);
// in nsSimpleDataBase.cpp
nsresult NS_NewRDFSimpleDataBase(nsIRDFDataBase** result);
// in nsDataBase.cpp
nsresult NS_NewRDFDataBase(nsIRDFDataBase** result);
#endif // nsBaseDataSources_h__

Просмотреть файл

Просмотреть файл

@ -0,0 +1,679 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
/*
This file provides the implementation for the RDF service manager.
TO DO
-----
1) Figure out a better way to do "pluggable resources." Currently,
we have two _major_ hacks:
RegisterBuiltInNamedDataSources()
RegisterBuiltInResourceFactories()
These introduce dependencies on the datasource directory. You'd
like to have this stuff discovered dynamically at startup or
something. Maybe from the registry.
2) Implement the CreateDataBase() methods.
*/
#include "nsIAtom.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIRDFResourceFactory.h"
#include "nsString.h"
#include "plhash.h"
#include "plstr.h"
#include "prlog.h"
////////////////////////////////////////////////////////////////////////
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIRDFNodeIID, NS_IRDFNODE_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
////////////////////////////////////////////////////////////////////////
// PrefixMap
//
// A simple map from a string prefix to a value. It maintains an
// ordered list of prefixes that map to a <tt>void*</tt>. The list
// is sorted in ASCII order such that if one prefix <b>p</b> is
// itself a prefix of another prefix <b>q</b>, the longest prefix
// (<b>q</b>) will appear first in the list. The idea is that you
// want to find the "best" match first. (Will this actually be
// useful? Probabably not...)
//
class PrefixMap
{
private:
struct PrefixMapEntry
{
const char* mPrefix;
PRInt32 mPrefixLen;
const void* mValue;
PrefixMapEntry* mNext;
};
PrefixMapEntry* mHead;
public:
PrefixMap();
~PrefixMap();
PRBool Add(const char* aPrefix, const void* aValue);
const void* Remove(const char* aPrefix);
/**
* Find the most specific value matching the specified string.
*/
const void* Find(const char* aString);
};
PrefixMap::PrefixMap()
: mHead(nsnull)
{
}
PrefixMap::~PrefixMap()
{
while (mHead) {
PrefixMapEntry* doomed = mHead;
mHead = mHead->mNext;
PL_strfree(NS_CONST_CAST(char*, doomed->mPrefix));
delete doomed;
}
}
PRBool
PrefixMap::Add(const char* aPrefix, const void* aValue)
{
PRInt32 newPrefixLen = PL_strlen(aPrefix);
PrefixMapEntry* entry = mHead;
PrefixMapEntry* last = nsnull;
while (entry != nsnull) {
// check to see if the new prefix is longer than the current
// entry. If so, we'll want to insert the new prefix *before*
// this one.
if (newPrefixLen > entry->mPrefixLen)
break;
// check for exact equality: if so, the prefix is already
// registered, so fail (?)
if (PL_strcmp(entry->mPrefix, aPrefix) == 0)
return PR_FALSE;
// otherwise, the new prefix is the same length or shorter
// than the current entry: continue on to the next one.
last = entry;
entry = entry->mNext;
}
PrefixMapEntry* newEntry = new PrefixMapEntry;
if (! newEntry)
return PR_FALSE;
newEntry->mPrefix = PL_strdup(aPrefix);
newEntry->mPrefixLen = newPrefixLen;
newEntry->mValue = aValue;
if (last) {
// we found an entry that we need to insert the current
// entry *before*
newEntry->mNext = last->mNext;
last->mNext = newEntry;
}
else {
// Otherwise, insert at the start
newEntry->mNext = mHead;
mHead = newEntry;
}
return PR_TRUE;
}
const void*
PrefixMap::Remove(const char* aPrefix)
{
PrefixMapEntry* entry = mHead;
PrefixMapEntry* last = nsnull;
PRInt32 doomedPrefixLen = PL_strlen(aPrefix);
while (entry != nsnull) {
if ((doomedPrefixLen == entry->mPrefixLen) &&
(PL_strcmp(entry->mPrefix, aPrefix) == 0)) {
if (last) {
last->mNext = entry->mNext;
}
else {
mHead = entry->mNext;
}
const void* value = entry->mValue;
PL_strfree(NS_CONST_CAST(char*, entry->mPrefix));
delete entry;
return value;
}
last = entry;
entry = entry->mNext;
}
return nsnull;
}
const void*
PrefixMap::Find(const char* aString)
{
for (PrefixMapEntry* entry = mHead; entry != nsnull; entry = entry->mNext) {
PRInt32 cmp = PL_strncmp(entry->mPrefix, aString, entry->mPrefixLen);
if (cmp == 0)
return entry->mValue;
}
return nsnull;
}
////////////////////////////////////////////////////////////////////////
// LiteralImpl
//
// Currently, all literals are implemented exactly the same way;
// i.e., there is are no resource factories to allow you to generate
// customer resources. I doubt that makes sense, anyway.
//
// What _may_ make sense is to atomize literals (well, at least
// short ones), to reduce in memory overhead at the expense of some
// processing time.
//
class LiteralImpl : public nsIRDFLiteral {
public:
LiteralImpl(const PRUnichar* s);
virtual ~LiteralImpl(void);
// nsISupports
NS_DECL_ISUPPORTS
// nsIRDFNode
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const;
// nsIRDFLiteral
NS_IMETHOD GetValue(const PRUnichar* *value) const;
NS_IMETHOD EqualsLiteral(const nsIRDFLiteral* literal, PRBool* result) const;
private:
nsAutoString mValue;
};
LiteralImpl::LiteralImpl(const PRUnichar* s)
: mValue(s)
{
NS_INIT_REFCNT();
}
LiteralImpl::~LiteralImpl(void)
{
}
NS_IMPL_ADDREF(LiteralImpl);
NS_IMPL_RELEASE(LiteralImpl);
nsresult
LiteralImpl::QueryInterface(REFNSIID iid, void** result)
{
if (! result)
return NS_ERROR_NULL_POINTER;
*result = nsnull;
if (iid.Equals(kIRDFLiteralIID) ||
iid.Equals(kIRDFNodeIID) ||
iid.Equals(kISupportsIID)) {
*result = NS_STATIC_CAST(nsIRDFLiteral*, this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP
LiteralImpl::EqualsNode(nsIRDFNode* node, PRBool* result) const
{
nsresult rv;
nsIRDFLiteral* literal;
if (NS_SUCCEEDED(node->QueryInterface(kIRDFLiteralIID, (void**) &literal))) {
rv = EqualsLiteral(literal, result);
NS_RELEASE(literal);
}
else {
*result = PR_FALSE;
rv = NS_OK;
}
return rv;
}
NS_IMETHODIMP
LiteralImpl::GetValue(const PRUnichar* *value) const
{
NS_ASSERTION(value, "null ptr");
if (! value)
return NS_ERROR_NULL_POINTER;
*value = mValue.GetUnicode();
return NS_OK;
}
NS_IMETHODIMP
LiteralImpl::EqualsLiteral(const nsIRDFLiteral* literal, PRBool* result) const
{
NS_ASSERTION(literal && result, "null ptr");
if (!literal || !result)
return NS_ERROR_NULL_POINTER;
nsresult rv;
const PRUnichar* p;
if (NS_FAILED(rv = literal->GetValue(&p)))
return rv;
nsAutoString s(p);
*result = s.Equals(mValue);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// ServiceImpl
//
// This is the RDF service.
//
class ServiceImpl : public nsIRDFService
{
protected:
PrefixMap mResourceFactories;
PLHashTable* mNamedDataSources;
PLHashTable* mResources;
ServiceImpl(void);
virtual ~ServiceImpl(void);
static nsIRDFService* gRDFService; // The one-and-only RDF service
static void RegisterBuiltInResourceFactories();
static void RegisterBuiltInNamedDataSources();
public:
static nsresult GetRDFService(nsIRDFService** result);
// nsISupports
NS_DECL_ISUPPORTS
// nsIRDFService
NS_IMETHOD GetResource(const char* uri, nsIRDFResource** resource);
NS_IMETHOD GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource);
NS_IMETHOD GetLiteral(const PRUnichar* value, nsIRDFLiteral** literal);
NS_IMETHOD UnCacheResource(nsIRDFResource* resource);
NS_IMETHOD RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory);
NS_IMETHOD UnRegisterResourceFactory(const char* aURIPrefix);
NS_IMETHOD RegisterNamedDataSource(const char* uri, nsIRDFDataSource* dataSource);
NS_IMETHOD UnRegisterNamedDataSource(const char* uri);
NS_IMETHOD GetNamedDataSource(const char* uri, nsIRDFDataSource** dataSource);
NS_IMETHOD CreateDatabase(const char** uris, nsIRDFDataBase** dataBase);
NS_IMETHOD CreateBrowserDatabase(nsIRDFDataBase** dataBase);
};
nsIRDFService* ServiceImpl::gRDFService = nsnull;
////////////////////////////////////////////////////////////////////////
ServiceImpl::ServiceImpl(void)
: mResources(nsnull), mNamedDataSources(nsnull)
{
NS_INIT_REFCNT();
mResources = PL_NewHashTable(1023, // nbuckets
PL_HashString, // hash fn
PL_CompareStrings, // key compare fn
PL_CompareValues, // value compare fn
nsnull, nsnull); // alloc ops & priv
mNamedDataSources = PL_NewHashTable(23,
PL_HashString,
PL_CompareStrings,
PL_CompareValues,
nsnull, nsnull);
}
ServiceImpl::~ServiceImpl(void)
{
if (mResources) {
PL_HashTableDestroy(mResources);
mResources = nsnull;
}
if (mNamedDataSources) {
PL_HashTableDestroy(mNamedDataSources);
mNamedDataSources = nsnull;
}
gRDFService = nsnull;
}
nsresult
ServiceImpl::GetRDFService(nsIRDFService** mgr)
{
if (! gRDFService) {
gRDFService = new ServiceImpl();
if (! gRDFService)
return NS_ERROR_OUT_OF_MEMORY;
RegisterBuiltInResourceFactories();
RegisterBuiltInNamedDataSources();
}
NS_ADDREF(gRDFService);
*mgr = gRDFService;
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
ServiceImpl::AddRef(void)
{
return 2;
}
NS_IMETHODIMP_(nsrefcnt)
ServiceImpl::Release(void)
{
return 1;
}
NS_IMPL_QUERY_INTERFACE(ServiceImpl, kIRDFServiceIID);
NS_IMETHODIMP
ServiceImpl::GetResource(const char* uri, nsIRDFResource** resource)
{
nsIRDFResource* result =
NS_STATIC_CAST(nsIRDFResource*, PL_HashTableLookup(mResources, uri));
if (! result) {
nsIRDFResourceFactory* factory =
NS_STATIC_CAST(nsIRDFResourceFactory*,
NS_CONST_CAST(void*, mResourceFactories.Find(uri)));
PR_ASSERT(factory != nsnull);
if (! factory)
return NS_ERROR_FAILURE; // XXX
nsresult rv;
if (NS_FAILED(factory->CreateResource(uri, &result)))
return rv;
const char* uri;
result->GetValue(&uri);
// This is a little trick to make storage more efficient. For
// the "key" in the table, we'll use the string value that's
// stored as a member variable of the nsIRDFResource object.
PL_HashTableAdd(mResources, uri, result);
// *We* don't AddRef() the resource: that way, the resource
// can be garbage collected when the last refcount goes away.
}
result->AddRef();
*resource = result;
return NS_OK;
}
NS_IMETHODIMP
ServiceImpl::GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource)
{
nsString s(uri);
char* cstr = s.ToNewCString();
nsresult rv = GetResource(cstr, resource);
delete[] cstr;
return rv;
}
NS_IMETHODIMP
ServiceImpl::GetLiteral(const PRUnichar* uri, nsIRDFLiteral** literal)
{
LiteralImpl* result = new LiteralImpl(uri);
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
*literal = result;
NS_ADDREF(result);
return NS_OK;
}
NS_IMETHODIMP
ServiceImpl::UnCacheResource(nsIRDFResource* resource)
{
nsresult rv;
const char* uri;
if (NS_FAILED(rv = resource->GetValue(&uri)))
return rv;
PL_HashTableRemove(mResources, uri);
return NS_OK;
}
NS_IMETHODIMP
ServiceImpl::RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory)
{
if (! mResourceFactories.Add(aURIPrefix, aFactory))
return NS_ERROR_ILLEGAL_VALUE;
NS_ADDREF(aFactory); // XXX should we addref?
return NS_OK;
}
NS_IMETHODIMP
ServiceImpl::UnRegisterResourceFactory(const char* aURIPrefix)
{
nsIRDFResourceFactory* factory =
NS_STATIC_CAST(nsIRDFResourceFactory*,
NS_CONST_CAST(void*, mResourceFactories.Remove(aURIPrefix)));
if (! factory)
return NS_ERROR_ILLEGAL_VALUE;
NS_RELEASE(factory); // XXX should we addref?
return NS_OK;
}
NS_IMETHODIMP
ServiceImpl::RegisterNamedDataSource(const char* uri, nsIRDFDataSource* dataSource)
{
// XXX check for dups, etc.
NS_ADDREF(dataSource); // XXX is this the right thing to do?
PL_HashTableAdd(mNamedDataSources, uri, dataSource);
return NS_OK;
}
NS_IMETHODIMP
ServiceImpl::UnRegisterNamedDataSource(const char* uri)
{
nsIRDFDataSource* ds =
NS_STATIC_CAST(nsIRDFDataSource*, PL_HashTableLookup(mNamedDataSources, uri));
if (! ds)
return NS_ERROR_ILLEGAL_VALUE;
PL_HashTableRemove(mNamedDataSources, uri);
NS_RELEASE(ds);
return NS_OK;
}
NS_IMETHODIMP
ServiceImpl::GetNamedDataSource(const char* uri, nsIRDFDataSource** dataSource)
{
nsIRDFDataSource* ds =
NS_STATIC_CAST(nsIRDFDataSource*, PL_HashTableLookup(mNamedDataSources, uri));
if (! ds)
return NS_ERROR_ILLEGAL_VALUE;
NS_ADDREF(ds);
*dataSource = ds;
return NS_OK;
}
NS_IMETHODIMP
ServiceImpl::CreateDatabase(const char** uri, nsIRDFDataBase** dataBase)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
ServiceImpl::CreateBrowserDatabase(nsIRDFDataBase** dataBase)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
////////////////////////////////////////////////////////////////////////
//
// This is Big Hack #1. Depedencies on all builtin resource
// factories are *here*, in the ResourceFactoryTable.
//
struct ResourceFactoryTable {
const char* mPrefix;
nsresult (*mFactoryConstructor)(nsIRDFResourceFactory** result);
};
void
ServiceImpl::RegisterBuiltInResourceFactories(void)
{
extern nsresult NS_NewRDFDefaultResourceFactory(nsIRDFResourceFactory** result);
extern nsresult NS_NewRDFMailResourceFactory(nsIRDFResourceFactory** result);
extern nsresult NS_NewRDFMailAccountResourceFactory(nsIRDFResourceFactory** result);
extern nsresult NS_NewRDFFileResourceFactory(nsIRDFResourceFactory** result);
static ResourceFactoryTable gTable[] = {
"", NS_NewRDFDefaultResourceFactory,
"mailaccount:", NS_NewRDFMailAccountResourceFactory,
"mailbox:", NS_NewRDFMailResourceFactory,
#if 0
"file:", NS_NewRDFFileResourceFactory,
#endif
nsnull, nsnull
};
nsresult rv;
for (ResourceFactoryTable* entry = gTable; entry->mPrefix != nsnull; ++entry) {
nsIRDFResourceFactory* factory;
if (NS_FAILED(rv = (entry->mFactoryConstructor)(&factory)))
continue;
rv = gRDFService->RegisterResourceFactory(entry->mPrefix, factory);
PR_ASSERT(NS_SUCCEEDED(rv));
NS_RELEASE(factory);
}
}
////////////////////////////////////////////////////////////////////////
//
// This is Big Hack #2. Dependencies on all builtin datasources are
// *here*, in the DataSourceTable.
//
// FWIW, I don't particularly like this interface *anyway*, because
// it requires each built-in data source to be constructed "up
// front". Not only does it cause the service manager to be
// re-entered (which may be a problem), but it's wasteful: I think
// these data sources should be created on demand, and released when
// you're done with them.
//
struct DataSourceTable {
const char* mURI;
nsresult (*mDataSourceConstructor)(nsIRDFDataSource** result);
};
void
ServiceImpl::RegisterBuiltInNamedDataSources(void)
{
extern nsresult NS_NewRDFBookmarkDataSource(nsIRDFDataSource** result);
extern nsresult NS_NewRDFHistoryDataSource(nsIRDFDataSource** result);
extern nsresult NS_NewRDFLocalFileSystemDataSource(nsIRDFDataSource** result);
extern nsresult NS_NewRDFMailDataSource(nsIRDFDataSource** result);
static DataSourceTable gTable[] = {
"rdf:bookmarks", NS_NewRDFBookmarkDataSource,
"rdf:mail", NS_NewRDFMailDataSource,
#if 0
"rdf:history", NS_NewRDFHistoryDataSource,
"rdf:lfs", NS_NewRDFLocalFileSystemDataSource,
#endif
nsnull, nsnull
};
nsresult rv;
for (DataSourceTable* entry = gTable; entry->mURI != nsnull; ++entry) {
nsIRDFDataSource* ds;
if (NS_FAILED(rv = (entry->mDataSourceConstructor)(&ds)))
continue;
if (NS_SUCCEEDED(rv = ds->Init(entry->mURI))) {
rv = gRDFService->RegisterNamedDataSource(entry->mURI, ds);
PR_ASSERT(NS_SUCCEEDED(rv));
}
NS_RELEASE(ds);
}
}
////////////////////////////////////////////////////////////////////////
nsresult
NS_NewRDFService(nsIRDFService** mgr)
{
return ServiceImpl::GetRDFService(mgr);
}

Просмотреть файл

Просмотреть файл

@ -20,7 +20,7 @@
#include "nsIRDFCursor.h"
#include "nsIRDFDataBase.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsString.h"
#include "rdfutil.h"
@ -80,7 +80,7 @@ rdf_IsOrdinalProperty(const nsIRDFResource* property)
PRBool
rdf_IsContainer(nsIRDFResourceManager* mgr,
rdf_IsContainer(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* resource)
{
@ -91,10 +91,10 @@ rdf_IsContainer(nsIRDFResourceManager* mgr,
nsIRDFResource* RDF_Seq = nsnull;
nsresult rv;
if (NS_FAILED(rv = mgr->GetResource(kURIRDF_instanceOf, &RDF_instanceOf)))
if (NS_FAILED(rv = service->GetResource(kURIRDF_instanceOf, &RDF_instanceOf)))
goto done;
if (NS_FAILED(rv = mgr->GetResource(kURIRDF_Bag, &RDF_Bag)))
if (NS_FAILED(rv = service->GetResource(kURIRDF_Bag, &RDF_Bag)))
goto done;
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Bag, PR_TRUE, &result)))
@ -103,7 +103,7 @@ rdf_IsContainer(nsIRDFResourceManager* mgr,
if (result)
goto done;
if (NS_FAILED(rv = mgr->GetResource(kURIRDF_Seq, &RDF_Seq)))
if (NS_FAILED(rv = service->GetResource(kURIRDF_Seq, &RDF_Seq)))
goto done;
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Seq, PR_TRUE, &result)))
@ -143,7 +143,7 @@ rdf_IsResource(const nsString& s)
// 0. node, node, node
nsresult
rdf_Assert(nsIRDFResourceManager* mgr, // unused
rdf_Assert(nsIRDFService* service, // unused
nsIRDFDataSource* ds,
nsIRDFResource* subject,
nsIRDFResource* predicate,
@ -156,11 +156,11 @@ rdf_Assert(nsIRDFResourceManager* mgr, // unused
#ifdef DEBUG
const char* s;
subject->GetValue(&s);
printf("(%s\n", s);
predicate->GetValue(&s);
printf(" %s\n", s);
printf(" %s", (strchr(s, '#') ? strchr(s, '#')+1 : s));
subject->GetValue(&s);
printf("(%s, ", s);
nsIRDFResource* objectResource;
nsIRDFLiteral* objectLiteral;
@ -185,21 +185,21 @@ rdf_Assert(nsIRDFResourceManager* mgr, // unused
// 1. string, string, string
nsresult
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
const nsString& subjectURI,
const nsString& predicateURI,
const nsString& objectURI)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
nsresult rv;
nsIRDFResource* subject;
if (NS_FAILED(rv = mgr->GetUnicodeResource(subjectURI, &subject)))
if (NS_FAILED(rv = service->GetUnicodeResource(subjectURI, &subject)))
return rv;
rv = rdf_Assert(mgr, ds, subject, predicateURI, objectURI);
rv = rdf_Assert(service, ds, subject, predicateURI, objectURI);
NS_RELEASE(subject);
return rv;
@ -207,13 +207,13 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// 2. node, node, string
nsresult
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* subject,
nsIRDFResource* predicate,
const nsString& objectURI)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(subject, "null ptr");
@ -224,20 +224,20 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// literal. If you don't like it, then call ds->Assert() yerself.
if (rdf_IsResource(objectURI)) {
nsIRDFResource* resource;
if (NS_FAILED(rv = mgr->GetUnicodeResource(objectURI, &resource)))
if (NS_FAILED(rv = service->GetUnicodeResource(objectURI, &resource)))
return rv;
object = resource;
}
else {
nsIRDFLiteral* literal;
if (NS_FAILED(rv = mgr->GetLiteral(objectURI, &literal)))
if (NS_FAILED(rv = service->GetLiteral(objectURI, &literal)))
return rv;
object = literal;
}
rv = rdf_Assert(mgr, ds, subject, predicate, object);
rv = rdf_Assert(service, ds, subject, predicate, object);
NS_RELEASE(object);
return rv;
@ -246,22 +246,22 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// 3. node, string, string
nsresult
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* subject,
const nsString& predicateURI,
const nsString& objectURI)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(subject, "null ptr");
nsresult rv;
nsIRDFResource* predicate;
if (NS_FAILED(rv = mgr->GetUnicodeResource(predicateURI, &predicate)))
if (NS_FAILED(rv = service->GetUnicodeResource(predicateURI, &predicate)))
return rv;
rv = rdf_Assert(mgr, ds, subject, predicate, objectURI);
rv = rdf_Assert(service, ds, subject, predicate, objectURI);
NS_RELEASE(predicate);
return rv;
@ -269,23 +269,23 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// 4. node, string, node
nsresult
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* subject,
const nsString& predicateURI,
nsIRDFNode* object)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(subject, "null ptr");
NS_ASSERTION(object, "null ptr");
nsresult rv;
nsIRDFResource* predicate;
if (NS_FAILED(rv = mgr->GetUnicodeResource(predicateURI, &predicate)))
if (NS_FAILED(rv = service->GetUnicodeResource(predicateURI, &predicate)))
return rv;
rv = rdf_Assert(mgr, ds, subject, predicate, object);
rv = rdf_Assert(service, ds, subject, predicate, object);
NS_RELEASE(predicate);
return rv;
@ -293,21 +293,21 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// 5. string, string, node
nsresult
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
const nsString& subjectURI,
const nsString& predicateURI,
nsIRDFNode* object)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
nsresult rv;
nsIRDFResource* subject;
if (NS_FAILED(rv = mgr->GetUnicodeResource(subjectURI, &subject)))
if (NS_FAILED(rv = service->GetUnicodeResource(subjectURI, &subject)))
return rv;
rv = rdf_Assert(mgr, ds, subject, predicateURI, object);
rv = rdf_Assert(service, ds, subject, predicateURI, object);
NS_RELEASE(subject);
return rv;
@ -316,7 +316,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
nsresult
rdf_CreateAnonymousResource(nsIRDFResourceManager* mgr,
rdf_CreateAnonymousResource(nsIRDFService* service,
nsIRDFResource** result)
{
static PRUint32 gCounter = 0;
@ -324,15 +324,15 @@ rdf_CreateAnonymousResource(nsIRDFResourceManager* mgr,
nsAutoString s = "$";
s.Append(++gCounter, 10);
return mgr->GetUnicodeResource(s, result);
return service->GetUnicodeResource(s, result);
}
nsresult
rdf_MakeBag(nsIRDFResourceManager* mgr,
rdf_MakeBag(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* bag)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(bag, "null ptr");
@ -340,10 +340,10 @@ rdf_MakeBag(nsIRDFResourceManager* mgr,
// XXX check to see if someone else has already made this into a container.
if (NS_FAILED(rv = rdf_Assert(mgr, ds, bag, kURIRDF_instanceOf, kURIRDF_Bag)))
if (NS_FAILED(rv = rdf_Assert(service, ds, bag, kURIRDF_instanceOf, kURIRDF_Bag)))
return rv;
if (NS_FAILED(rv = rdf_Assert(mgr, ds, bag, kURIRDF_nextVal, "1")))
if (NS_FAILED(rv = rdf_Assert(service, ds, bag, kURIRDF_nextVal, "1")))
return rv;
return NS_OK;
@ -351,11 +351,11 @@ rdf_MakeBag(nsIRDFResourceManager* mgr,
nsresult
rdf_MakeSeq(nsIRDFResourceManager* mgr,
rdf_MakeSeq(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* seq)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(seq, "null ptr");
@ -363,10 +363,10 @@ rdf_MakeSeq(nsIRDFResourceManager* mgr,
// XXX check to see if someone else has already made this into a container.
if (NS_FAILED(rv = rdf_Assert(mgr, ds, seq, kURIRDF_instanceOf, kURIRDF_Seq)))
if (NS_FAILED(rv = rdf_Assert(service, ds, seq, kURIRDF_instanceOf, kURIRDF_Seq)))
return rv;
if (NS_FAILED(rv = rdf_Assert(mgr, ds, seq, kURIRDF_nextVal, "1")))
if (NS_FAILED(rv = rdf_Assert(service, ds, seq, kURIRDF_nextVal, "1")))
return rv;
return NS_OK;
@ -374,11 +374,11 @@ rdf_MakeSeq(nsIRDFResourceManager* mgr,
nsresult
rdf_MakeAlt(nsIRDFResourceManager* mgr,
rdf_MakeAlt(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* alt)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(alt, "null ptr");
@ -386,10 +386,10 @@ rdf_MakeAlt(nsIRDFResourceManager* mgr,
// XXX check to see if someone else has already made this into a container.
if (NS_FAILED(rv = rdf_Assert(mgr, ds, alt, kURIRDF_instanceOf, kURIRDF_Alt)))
if (NS_FAILED(rv = rdf_Assert(service, ds, alt, kURIRDF_instanceOf, kURIRDF_Alt)))
return rv;
if (NS_FAILED(rv = rdf_Assert(mgr, ds, alt, kURIRDF_nextVal, "1")))
if (NS_FAILED(rv = rdf_Assert(service, ds, alt, kURIRDF_nextVal, "1")))
return rv;
return NS_OK;
@ -397,12 +397,12 @@ rdf_MakeAlt(nsIRDFResourceManager* mgr,
static nsresult
rdf_ContainerGetNextValue(nsIRDFResourceManager* mgr,
rdf_ContainerGetNextValue(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* container,
nsIRDFResource** result)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(container, "null ptr");
@ -417,7 +417,7 @@ rdf_ContainerGetNextValue(nsIRDFResourceManager* mgr,
// Get the next value, which hangs off of the bag via the
// RDF:nextVal property.
if (NS_FAILED(rv = mgr->GetResource(kURIRDF_nextVal, &RDF_nextVal)))
if (NS_FAILED(rv = service->GetResource(kURIRDF_nextVal, &RDF_nextVal)))
goto done;
if (NS_FAILED(rv = ds->GetTarget(container, RDF_nextVal, PR_TRUE, &nextValNode)))
@ -439,7 +439,7 @@ rdf_ContainerGetNextValue(nsIRDFResourceManager* mgr,
nextValStr.Append("_");
nextValStr.Append(nextVal, 10);
if (NS_FAILED(rv = mgr->GetUnicodeResource(nextValStr, result)))
if (NS_FAILED(rv = service->GetUnicodeResource(nextValStr, result)))
goto done;
// Now increment the RDF:nextVal property.
@ -452,10 +452,10 @@ rdf_ContainerGetNextValue(nsIRDFResourceManager* mgr,
nextValStr.Truncate();
nextValStr.Append(nextVal, 10);
if (NS_FAILED(rv = mgr->GetLiteral(nextValStr, &nextValLiteral)))
if (NS_FAILED(rv = service->GetLiteral(nextValStr, &nextValLiteral)))
goto done;
if (NS_FAILED(rv = rdf_Assert(mgr, ds, container, RDF_nextVal, nextValLiteral)))
if (NS_FAILED(rv = rdf_Assert(service, ds, container, RDF_nextVal, nextValLiteral)))
goto done;
done:
@ -468,12 +468,12 @@ done:
nsresult
rdf_ContainerAddElement(nsIRDFResourceManager* mgr,
rdf_ContainerAddElement(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* container,
nsIRDFNode* element)
{
NS_ASSERTION(mgr, "null ptr");
NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(container, "null ptr");
NS_ASSERTION(element, "null ptr");
@ -482,10 +482,10 @@ rdf_ContainerAddElement(nsIRDFResourceManager* mgr,
nsIRDFResource* nextVal;
if (NS_FAILED(rv = rdf_ContainerGetNextValue(mgr, ds, container, &nextVal)))
if (NS_FAILED(rv = rdf_ContainerGetNextValue(service, ds, container, &nextVal)))
goto done;
if (rv = rdf_Assert(mgr, ds, container, nextVal, element))
if (rv = rdf_Assert(service, ds, container, nextVal, element))
goto done;
done:

Просмотреть файл

@ -31,7 +31,7 @@ class nsIRDFCursor;
class nsIRDFDataBase;
class nsIRDFDataSource;
class nsIRDFNode;
class nsIRDFResourceManager;
class nsIRDFService;
class nsString;
/**
@ -47,7 +47,7 @@ rdf_IsOrdinalProperty(const nsIRDFResource* property);
* rdf:Bag.
*/
PR_EXTERN(PRBool)
rdf_IsContainer(nsIRDFResourceManager* mgr,
rdf_IsContainer(nsIRDFService* service,
nsIRDFDataSource* db,
nsIRDFResource* resource);
@ -58,7 +58,7 @@ rdf_IsContainer(nsIRDFResourceManager* mgr,
// 0. node, node, node
PR_EXTERN(nsresult)
rdf_Assert(nsIRDFResourceManager* mgr, // unused
rdf_Assert(nsIRDFService* service, // unused
nsIRDFDataSource* ds,
nsIRDFResource* subject,
nsIRDFResource* predicate,
@ -66,7 +66,7 @@ rdf_Assert(nsIRDFResourceManager* mgr, // unused
// 1. string, string, string
PR_EXTERN(nsresult)
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
const nsString& subjectURI,
const nsString& predicateURI,
@ -74,7 +74,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// 2. node, node, string
PR_EXTERN(nsresult)
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* subject,
nsIRDFResource* predicate,
@ -82,7 +82,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// 3. node, string, string
PR_EXTERN(nsresult)
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* subject,
const nsString& predicateURI,
@ -90,7 +90,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// 4. node, string, node
PR_EXTERN(nsresult)
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* subject,
const nsString& predicateURI,
@ -98,7 +98,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
// 5. string, string, node
PR_EXTERN(nsresult)
rdf_Assert(nsIRDFResourceManager* mgr,
rdf_Assert(nsIRDFService* service,
nsIRDFDataSource* ds,
const nsString& subjectURI,
const nsString& predicateURI,
@ -109,7 +109,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
* resource URI.
*/
PR_EXTERN(nsresult)
rdf_CreateAnonymousResource(nsIRDFResourceManager* mgr,
rdf_CreateAnonymousResource(nsIRDFService* service,
nsIRDFResource** result);
@ -117,7 +117,7 @@ rdf_CreateAnonymousResource(nsIRDFResourceManager* mgr,
* Create a bag resource.
*/
PR_EXTERN(nsresult)
rdf_MakeBag(nsIRDFResourceManager* mgr,
rdf_MakeBag(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* resource);
@ -125,7 +125,7 @@ rdf_MakeBag(nsIRDFResourceManager* mgr,
* Create a sequence resource.
*/
PR_EXTERN(nsresult)
rdf_MakeSeq(nsIRDFResourceManager* mgr,
rdf_MakeSeq(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* resource);
@ -133,7 +133,7 @@ rdf_MakeSeq(nsIRDFResourceManager* mgr,
* Create an alternation resource.
*/
PR_EXTERN(nsresult)
rdf_MakeAlt(nsIRDFResourceManager* mgr,
rdf_MakeAlt(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* resource);
@ -142,7 +142,7 @@ rdf_MakeAlt(nsIRDFResourceManager* mgr,
* Add an element to the container.
*/
PR_EXTERN(nsresult)
rdf_ContainerAddElement(nsIRDFResourceManager* mgr,
rdf_ContainerAddElement(nsIRDFService* service,
nsIRDFDataSource* ds,
nsIRDFResource* container,
nsIRDFNode* element);

Просмотреть файл

@ -41,6 +41,8 @@ LLIBS=\
$(DIST)\lib\libplc21.lib \
$(LIBNSPR)
MISCDEP=$(LLIBS)
# XXX Note dependencies on implementation dirs for factory methods.
LINCS= -I$(PUBLIC)\rdf \

Просмотреть файл

@ -24,11 +24,11 @@
{ 0xf78da56, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {BFD05264-834C-11d2-8EAC-00805F29F370}
#define NS_RDFRESOURCEMANAGER_CID \
#define NS_RDFSERVICE_CID \
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {BFD0526D-834C-11d2-8EAC-00805F29F370}
#define NS_RDFMEMORYDATASOURCE_CID \
#define NS_RDFINMEMORYDATASOURCE_CID \
{ 0xbfd0526d, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {E638D760-8687-11d2-B530-000000000000}
@ -36,7 +36,7 @@
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
// {E638D761-8687-11d2-B530-000000000000}
#define NS_RDFSIMPLEDATABASE_CID \
#define NS_RDFDATABASE_CID \
{ 0xe638d761, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
// {954F0813-81DC-11d2-B52A-000000000000}

Просмотреть файл

@ -18,7 +18,8 @@
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFContentSink.h"
#include "nsIRDFService.h"
#include "nsRDFBaseDataSources.h"
#include "nsRDFBuiltInDataSources.h"
#include "nsRDFDocument.h"
@ -28,10 +29,11 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFSimpleContentSinkCID, NS_RDFSIMPLECONTENTSINK_CID);
static NS_DEFINE_CID(kRDFStreamDataSourceCID, NS_RDFSTREAMDATASOURCE_CID);
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
@ -112,28 +114,25 @@ RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
nsresult rv;
PRBool wasRefCounted = PR_TRUE;
nsISupports *inst = nsnull;
if (mClassID.Equals(kRDFResourceManagerCID)) {
if (NS_FAILED(rv = NS_NewRDFResourceManager((nsIRDFResourceManager**) &inst)))
if (mClassID.Equals(kRDFServiceCID)) {
if (NS_FAILED(rv = NS_NewRDFService((nsIRDFService**) &inst)))
return rv;
}
else if (mClassID.Equals(kRDFMemoryDataSourceCID)) {
#ifdef _WIN32
else if (mClassID.Equals(kRDFInMemoryDataSourceCID)) {
if (NS_FAILED(rv = NS_NewRDFInMemoryDataSource((nsIRDFDataSource**) &inst)))
#else
if (NS_FAILED(rv = NS_NewRDFMemoryDataSource((nsIRDFDataSource**) &inst)))
#endif
return rv;
}
else if (mClassID.Equals(kRDFStreamDataSourceCID)) {
if (NS_FAILED(rv = NS_NewRDFStreamDataSource((nsIRDFDataSource**) &inst)))
return rv;
// if (NS_FAILED(rv = NS_NewRDFStreamDataSource((nsIRDFDataSource**) &inst)))
return rv;
}
else if (mClassID.Equals(kRDFBookmarkDataSourceCID)) {
if (NS_FAILED(rv = NS_NewRDFBookmarkDataSource((nsIRDFDataSource**) &inst)))
return rv;
}
else if (mClassID.Equals(kRDFSimpleDataBaseCID)) {
if (NS_FAILED(rv = NS_NewRDFSimpleDataBase((nsIRDFDataBase**) &inst)))
else if (mClassID.Equals(kRDFDataBaseCID)) {
if (NS_FAILED(rv = NS_NewRDFDataBase((nsIRDFDataBase**) &inst)))
return rv;
}
else if (mClassID.Equals(kRDFHTMLDocumentCID)) {
@ -144,6 +143,10 @@ RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
if (NS_FAILED(rv = NS_NewRDFTreeDocument((nsIRDFDocument**) &inst)))
return rv;
}
else if (mClassID.Equals(kRDFSimpleContentSinkCID)) {
if (NS_FAILED(rv = NS_NewRDFSimpleContentSink((nsIRDFContentSink**) &inst)))
return rv;
}
else {
return NS_ERROR_NO_INTERFACE;
}

Просмотреть файл

@ -20,9 +20,11 @@
#define nsIRDFContentSink_h___
#include "nsIXMLContentSink.h"
class nsIDocument;
class nsIRDFDataSource;
class nsINameSpaceManager;
class nsIURL;
class nsIWebShell;
// {751843E2-8309-11d2-8EAC-00805F29F370}
#define NS_IRDFCONTENTSINK_IID \
@ -67,9 +69,7 @@ NS_NewRDFDocumentContentSink(nsIRDFContentSink** aResult,
* document, say, to create a stand-alone in-memory graph.
*/
nsresult
NS_NewRDFSimpleContentSink(nsIRDFContentSink** aResult,
nsIURL* aURL,
nsINameSpaceManager* aNameSpaceManager);
NS_NewRDFSimpleContentSink(nsIRDFContentSink** aResult);
#endif // nsIRDFContentSink_h___

Просмотреть файл

@ -49,7 +49,7 @@
#include "nsCRT.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "nsIServiceManager.h"
#include "nsIURL.h"
@ -90,13 +90,13 @@ static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID); // XXX grr...
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID);
static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
////////////////////////////////////////////////////////////////////////
// Utility routines
@ -243,7 +243,7 @@ rdf_FullyQualifyURI(const nsIURL* base, nsString& spec)
nsRDFContentSink::nsRDFContentSink()
: mDocumentURL(nsnull),
mResourceMgr(nsnull),
mRDFService(nsnull),
mDataSource(nsnull),
mGenSym(0),
mNameSpaceManager(nsnull),
@ -263,8 +263,8 @@ nsRDFContentSink::~nsRDFContentSink()
{
NS_IF_RELEASE(mDocumentURL);
if (mResourceMgr)
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mResourceMgr);
if (mRDFService)
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
NS_IF_RELEASE(mDataSource);
@ -275,8 +275,8 @@ nsRDFContentSink::~nsRDFContentSink()
PRInt32 index = mNameSpaceStack->Count();
while (0 < index--) {
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
NS_RELEASE(nameSpace);
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
NS_RELEASE(nameSpace);
}
delete mNameSpaceStack;
}
@ -579,9 +579,9 @@ nsRDFContentSink::Init(nsIURL* aURL, nsINameSpaceManager* aNameSpaceManager)
NS_ADDREF(mNameSpaceManager);
nsresult rv;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mResourceMgr)))
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mRDFService)))
return rv;
mState = eRDFContentSinkState_InProlog;
@ -641,8 +641,8 @@ nsRDFContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
value.Append(mText, mTextLength);
nsIRDFLiteral* literal;
if (NS_SUCCEEDED(rv = mResourceMgr->GetLiteral(value, &literal))) {
rv = rdf_ContainerAddElement(mResourceMgr,
if (NS_SUCCEEDED(rv = mRDFService->GetLiteral(value, &literal))) {
rv = rdf_ContainerAddElement(mRDFService,
mDataSource,
GetContextElement(0),
literal);
@ -654,7 +654,7 @@ nsRDFContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
nsAutoString value;
value.Append(mText, mTextLength);
rv = rdf_Assert(mResourceMgr,
rv = rdf_Assert(mRDFService,
mDataSource,
GetContextElement(1),
GetContextElement(0),
@ -811,7 +811,7 @@ nsRDFContentSink::AddProperties(const nsIParserNode& aNode,
k.Append(attr);
// Add the attribute to RDF
rdf_Assert(mResourceMgr, mDataSource, aSubject, k, v);
rdf_Assert(mRDFService, mDataSource, aSubject, k, v);
}
return NS_OK;
}
@ -850,7 +850,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
// node", or a "container", so this change the content sink's
// state appropriately.
if (! mResourceMgr)
if (! mRDFService)
return NS_ERROR_NOT_INITIALIZED;
nsAutoString tag;
@ -865,7 +865,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
return rv;
nsIRDFResource* rdfResource;
if (NS_FAILED(rv = mResourceMgr->GetUnicodeResource(uri, &rdfResource)))
if (NS_FAILED(rv = mRDFService->GetUnicodeResource(uri, &rdfResource)))
return rv;
// If we're in a member or property element, then this is the cue
@ -873,7 +873,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
// member/property.
switch (mState) {
case eRDFContentSinkState_InMemberElement: {
rdf_ContainerAddElement(mResourceMgr, mDataSource, GetContextElement(0), rdfResource);
rdf_ContainerAddElement(mRDFService, mDataSource, GetContextElement(0), rdfResource);
} break;
case eRDFContentSinkState_InPropertyElement: {
@ -901,17 +901,17 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
}
else if (tag.Equals(kTagRDF_Bag)) {
// it's a bag container
rdf_MakeBag(mResourceMgr, mDataSource, rdfResource);
rdf_MakeBag(mRDFService, mDataSource, rdfResource);
mState = eRDFContentSinkState_InContainerElement;
}
else if (tag.Equals(kTagRDF_Seq)) {
// it's a seq container
rdf_MakeSeq(mResourceMgr, mDataSource, rdfResource);
rdf_MakeSeq(mRDFService, mDataSource, rdfResource);
mState = eRDFContentSinkState_InContainerElement;
}
else if (tag.Equals(kTagRDF_Alt)) {
// it's an alt container
rdf_MakeAlt(mResourceMgr, mDataSource, rdfResource);
rdf_MakeAlt(mRDFService, mDataSource, rdfResource);
mState = eRDFContentSinkState_InContainerElement;
}
else {
@ -926,7 +926,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
nsAutoString nameSpace;
GetNameSpaceURI(nameSpaceID, nameSpace); // XXX append ':' too?
nameSpace.Append(tag);
rdf_Assert(mResourceMgr, mDataSource, rdfResource, kURIRDF_type, nameSpace);
rdf_Assert(mRDFService, mDataSource, rdfResource, kURIRDF_type, nameSpace);
mState = eRDFContentSinkState_InDescriptionElement;
}
@ -941,7 +941,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
nsresult
nsRDFContentSink::OpenProperty(const nsIParserNode& aNode)
{
if (! mResourceMgr)
if (! mRDFService)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
@ -961,7 +961,7 @@ nsRDFContentSink::OpenProperty(const nsIParserNode& aNode)
// name. We can do this 'cause we don't need it anymore...
ns.Append(tag);
nsIRDFResource* rdfProperty;
if (NS_FAILED(rv = mResourceMgr->GetUnicodeResource(ns, &rdfProperty)))
if (NS_FAILED(rv = mRDFService->GetUnicodeResource(ns, &rdfProperty)))
return rv;
nsAutoString resourceURI;
@ -971,9 +971,9 @@ nsRDFContentSink::OpenProperty(const nsIParserNode& aNode)
// URI, add the properties to it, and attach the inline
// resource to its parent.
nsIRDFResource* rdfResource;
if (NS_SUCCEEDED(rv = mResourceMgr->GetUnicodeResource(resourceURI, &rdfResource))) {
if (NS_SUCCEEDED(rv = mRDFService->GetUnicodeResource(resourceURI, &rdfResource))) {
if (NS_SUCCEEDED(rv = AddProperties(aNode, rdfResource))) {
rv = rdf_Assert(mResourceMgr,
rv = rdf_Assert(mRDFService,
mDataSource,
GetContextElement(0),
rdfProperty,
@ -1028,8 +1028,8 @@ nsRDFContentSink::OpenMember(const nsIParserNode& aNode)
// means that it's a "referenced item," as covered in [6.29].
nsIRDFResource* resource;
if (NS_SUCCEEDED(rv = mResourceMgr->GetUnicodeResource(resourceURI, &resource))) {
rv = rdf_ContainerAddElement(mResourceMgr, mDataSource, container, resource);
if (NS_SUCCEEDED(rv = mRDFService->GetUnicodeResource(resourceURI, &resource))) {
rv = rdf_ContainerAddElement(mRDFService, mDataSource, container, resource);
}
// XXX Technically, we should _not_ fall through here and push
@ -1131,12 +1131,12 @@ nsRDFContentSink::PushNameSpacesFrom(const nsIParserNode& aNode)
nsINameSpace* nameSpace = nsnull;
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(mNameSpaceStack->Count() - 1);
NS_ADDREF(nameSpace);
nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(mNameSpaceStack->Count() - 1);
NS_ADDREF(nameSpace);
}
else {
mNameSpaceManager->RegisterNameSpace(kRDFNameSpaceURI, mRDFNameSpaceID);
mNameSpaceManager->CreateRootNameSpace(nameSpace);
mNameSpaceManager->RegisterNameSpace(kRDFNameSpaceURI, mRDFNameSpaceID);
mNameSpaceManager->CreateRootNameSpace(nameSpace);
}
if (nsnull != nameSpace) {
@ -1171,6 +1171,8 @@ nsRDFContentSink::PushNameSpacesFrom(const nsIParserNode& aNode)
NS_IF_RELEASE(prefixAtom);
}
}
// Now push the *last* namespace that we discovered on to the stack.
if (nsnull == mNameSpaceStack) {
mNameSpaceStack = new nsVoidArray();
}
@ -1181,31 +1183,31 @@ nsRDFContentSink::PushNameSpacesFrom(const nsIParserNode& aNode)
nsIAtom*
nsRDFContentSink::CutNameSpacePrefix(nsString& aString)
{
nsAutoString prefix;
PRInt32 nsoffset = aString.Find(kNameSpaceSeparator);
if (-1 != nsoffset) {
aString.Left(prefix, nsoffset);
aString.Cut(0, nsoffset+1);
}
if (0 < prefix.Length()) {
return NS_NewAtom(prefix);
}
return nsnull;
nsAutoString prefix;
PRInt32 nsoffset = aString.Find(kNameSpaceSeparator);
if (-1 != nsoffset) {
aString.Left(prefix, nsoffset);
aString.Cut(0, nsoffset+1);
}
if (0 < prefix.Length()) {
return NS_NewAtom(prefix);
}
return nsnull;
}
PRInt32
nsRDFContentSink::GetNameSpaceID(nsIAtom* aPrefix)
{
PRInt32 id = kNameSpaceID_Unknown;
PRInt32 id = kNameSpaceID_Unknown;
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
PRInt32 index = mNameSpaceStack->Count() - 1;
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
nameSpace->FindNameSpaceID(aPrefix, id);
}
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
PRInt32 index = mNameSpaceStack->Count() - 1;
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
nameSpace->FindNameSpaceID(aPrefix, id);
}
NS_ASSERTION(kNameSpaceID_Unknown != mRDFNameSpaceID, "failed to register RDF nameSpace");
return id;
NS_ASSERTION(kNameSpaceID_Unknown != mRDFNameSpaceID, "failed to register RDF nameSpace");
return id;
}
void
@ -1217,11 +1219,15 @@ nsRDFContentSink::GetNameSpaceURI(PRInt32 aID, nsString& aURI)
void
nsRDFContentSink::PopNameSpaces()
{
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
PRInt32 index = mNameSpaceStack->Count() - 1;
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
mNameSpaceStack->RemoveElementAt(index);
NS_RELEASE(nameSpace);
}
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
PRInt32 index = mNameSpaceStack->Count() - 1;
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
mNameSpaceStack->RemoveElementAt(index);
// Releasing the most deeply nested namespace will recursively
// release intermediate parent namespaces until the next
// reference is held on the namespace stack.
NS_RELEASE(nameSpace);
}
}

Просмотреть файл

@ -26,7 +26,7 @@ class nsIURL;
class nsVoidArray;
class nsIRDFResource;
class nsIRDFDataSource;
class nsIRDFResourceManager;
class nsIRDFService;
class nsINameSpaceManager;
typedef enum {
@ -112,7 +112,7 @@ protected:
virtual nsresult OpenValue(const nsIParserNode& aNode);
// Miscellaneous RDF junk
nsIRDFResourceManager* mResourceMgr;
nsIRDFService* mRDFService;
nsIRDFDataSource* mDataSource;
RDFContentSinkState mState;

Просмотреть файл

@ -28,7 +28,7 @@
#include "nsIRDFDataBase.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIPresShell.h"
#include "nsIScriptContextOwner.h"
#include "nsIServiceManager.h"
@ -66,23 +66,23 @@ static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); // XXX grr...
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
static NS_DEFINE_CID(kHTMLStyleSheetCID, NS_HTMLSTYLESHEET_CID);
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_CID);
static NS_DEFINE_CID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
static NS_DEFINE_CID(kHTMLStyleSheetCID, NS_HTMLSTYLESHEET_CID);
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
static NS_DEFINE_CID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
////////////////////////////////////////////////////////////////////////
@ -99,7 +99,7 @@ nsRDFDocument::nsRDFDocument()
mAttrStyleSheet(nsnull),
mParser(nsnull),
mDB(nsnull),
mResourceMgr(nsnull),
mRDFService(nsnull),
mTreeProperties(nsnull)
{
NS_INIT_REFCNT();
@ -120,9 +120,9 @@ nsRDFDocument::~nsRDFDocument()
{
NS_IF_RELEASE(mParser);
if (mResourceMgr) {
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mResourceMgr);
mResourceMgr = nsnull;
if (mRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
mRDFService = nsnull;
}
// mParentDocument is never refcounted
@ -230,7 +230,7 @@ nsRDFDocument::StartDocumentLoad(nsIURL *aURL,
NS_RELEASE(webShell);
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFMemoryDataSourceCID,
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID,
nsnull,
kIRDFDataSourceIID,
(void**) &ds))) {
@ -1033,15 +1033,15 @@ nsRDFDocument::Init(void)
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFSimpleDataBaseCID,
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFDataBaseCID,
nsnull,
kIRDFDataBaseIID,
(void**) &mDB)))
return rv;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mResourceMgr)))
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mRDFService)))
return rv;
return NS_OK;
@ -1087,8 +1087,8 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
if (! mDB)
return NS_ERROR_NOT_INITIALIZED;
NS_ASSERTION(mResourceMgr, "not initialized");
if (! mResourceMgr)
NS_ASSERTION(mRDFService, "not initialized");
if (! mRDFService)
return NS_ERROR_NOT_INITIALIZED;
@ -1105,7 +1105,7 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
while (NS_SUCCEEDED(rv = properties->Advance())) {
nsIRDFResource* property = nsnull;
if (NS_FAILED(rv = properties->GetPredicate(&property)))
if (NS_FAILED(rv = properties->GetValue((nsIRDFNode**)&property)))
break;
const char* s;
@ -1126,7 +1126,7 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
while (NS_SUCCEEDED(rv = assertions->Advance())) {
nsIRDFNode* value;
if (NS_SUCCEEDED(rv = assertions->GetObject(&value))) {
if (NS_SUCCEEDED(rv = assertions->GetValue((nsIRDFNode**)&value))) {
// At this point, the specific nsRDFDocument
// implementations will create an appropriate child
// element (or elements).
@ -1230,7 +1230,7 @@ nsRDFDocument::IsTreeProperty(const nsIRDFResource* property) const
const char* p;
property->GetValue(&p);
nsAutoString s(p);
if (s.Equals("http://home.netscape.com/NC-rdf#Bookmark") ||
if (s.Equals("http://home.netscape.com/NC-rdf#child") ||
s.Equals("http://home.netscape.com/NC-rdf#Folder")) {
return PR_TRUE;
}

Просмотреть файл

@ -29,6 +29,7 @@ class nsIParser;
class nsISupportsArray;
class nsINameSpaceManager;
class nsIRDFNode;
class nsIRDFService;
/**
* An NGLayout document context for displaying an RDF graph.
@ -234,7 +235,7 @@ protected:
nsIStyleSheet* mAttrStyleSheet;
nsIParser* mParser;
nsIRDFDataBase* mDB;
nsIRDFResourceManager* mResourceMgr;
nsIRDFService* mRDFService;
nsISupportsArray* mTreeProperties;
};

Просмотреть файл

@ -27,7 +27,7 @@
#include "nsIRDFContent.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIURL.h"
#include "nsIWebShell.h"
#include "nsLayoutCID.h"
@ -399,7 +399,7 @@ nsRDFDocumentContentSink::OpenObject(const nsIParserNode& aNode)
return rv;
nsIRDFResource* resource;
if (NS_FAILED(rv = mResourceMgr->GetUnicodeResource(uri, &resource)))
if (NS_FAILED(rv = mRDFService->GetUnicodeResource(uri, &resource)))
return rv;
nsIRDFDocument* rdfDoc;

Просмотреть файл

@ -59,7 +59,7 @@
#include "nsIRDFDataBase.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsRDFCID.h"
@ -78,12 +78,12 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIRDFContentIID, NS_IRDFCONTENT_IID);
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -924,9 +924,9 @@ nsRDFElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResu
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
// XXX I'm not sure if we should support properties as attributes
// or not...
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
nsIRDFService* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mgr)))
return rv;
@ -952,7 +952,7 @@ done:
NS_IF_RELEASE(property);
NS_IF_RELEASE(value);
NS_IF_RELEASE(db);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
return rv;
@ -1007,9 +1007,9 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
// XXX I'm not sure if we should support attributes or not...
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
nsIRDFService* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mgr)))
return rv;
@ -1050,7 +1050,7 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
done:
NS_IF_RELEASE(properties);
NS_IF_RELEASE(db);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
return rv;
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
@ -1293,14 +1293,14 @@ nsRDFElement::SetResource(const nsString& aURI)
nsresult rv;
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mgr)))
nsIRDFService* service = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &service)))
return rv;
rv = mgr->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
rv = service->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
nsServiceManager::ReleaseService(kRDFServiceCID, service);
return rv;
}
@ -1370,22 +1370,22 @@ nsRDFElement::SetProperty(const nsString& aPropertyURI, const nsString& aValue)
#endif
nsresult rv;
nsIRDFResourceManager* mgr = nsnull;
nsIRDFService* service = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mgr)))
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &service)))
return rv;
nsIRDFResource* property = nsnull;
nsIRDFLiteral* value = nsnull;
nsIRDFDataBase* db = nsnull;
if (NS_FAILED(rv = mgr->GetUnicodeResource(aPropertyURI, &property)))
if (NS_FAILED(rv = service->GetUnicodeResource(aPropertyURI, &property)))
goto done;
// XXX assume it's a literal?
if (NS_FAILED(rv = mgr->GetLiteral(aValue, &value)))
if (NS_FAILED(rv = service->GetLiteral(aValue, &value)))
goto done;
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
@ -1397,7 +1397,7 @@ done:
NS_IF_RELEASE(db);
NS_IF_RELEASE(value);
NS_IF_RELEASE(property);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, service);
return rv;
}

Просмотреть файл

@ -29,7 +29,7 @@
#include "nsIRDFCursor.h"
#include "nsIRDFDataBase.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsINameSpaceManager.h"
#include "nsISupportsArray.h"
@ -175,7 +175,7 @@ RDFHTMLDocumentImpl::AddChild(nsIRDFContent* parent,
nsIRDFResource* valueResource;
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &valueResource))) {
if (IsTreeProperty(property) || rdf_IsContainer(mResourceMgr, mDB, valueResource)) {
if (IsTreeProperty(property) || rdf_IsContainer(mRDFService, mDB, valueResource)) {
rv = AddTreeChild(parent, tag, property, valueResource);
NS_RELEASE(valueResource);
return rv;

Просмотреть файл

@ -32,25 +32,19 @@ public:
////////////////////////////////////////////////////////////////////////
nsresult
NS_NewRDFSimpleContentSink(nsIRDFContentSink** aResult,
nsIURL* aURL,
nsINameSpaceManager* aNameSpaceManager)
NS_NewRDFSimpleContentSink(nsIRDFContentSink** aResult)
{
NS_PRECONDITION(aResult, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsRDFSimpleContentSink* it;
NS_NEWXPCOM(it, nsRDFSimpleContentSink);
if (! it)
nsRDFSimpleContentSink* sink = new nsRDFSimpleContentSink();
if (! sink)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = it->Init(aURL, aNameSpaceManager);
if (NS_FAILED(rv)) {
delete it;
return rv;
}
return it->QueryInterface(kIRDFContentSinkIID, (void **)aResult);
*aResult = sink;
NS_ADDREF(sink);
return NS_OK;
}

Просмотреть файл

@ -21,7 +21,7 @@
#include "nsIRDFCursor.h"
#include "nsIRDFDataBase.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsINameSpaceManager.h"
#include "nsISupportsArray.h"
@ -354,10 +354,10 @@ RDFTreeDocumentImpl::AddColumnsFromContainer(nsIContent* parent,
nsIRDFResource* NC_Title = nsnull;
nsIRDFAssertionCursor* cursor = nsnull;
if (NS_FAILED(rv = mResourceMgr->GetResource(kURINC_Column, &NC_Column)))
if (NS_FAILED(rv = mRDFService->GetResource(kURINC_Column, &NC_Column)))
goto done;
if (NS_FAILED(rv = mResourceMgr->GetResource(kURINC_Title, &NC_Title)))
if (NS_FAILED(rv = mRDFService->GetResource(kURINC_Title, &NC_Title)))
goto done;
if (NS_FAILED(rv = NS_NewContainerCursor(mDB, columns, &cursor)))
@ -495,7 +495,7 @@ RDFTreeDocumentImpl::AddColumns(nsIContent* parent,
{
nsresult rv;
if (rdf_IsContainer(mResourceMgr, mDB, columns)) {
if (rdf_IsContainer(mRDFService, mDB, columns)) {
rv = AddColumnsFromContainer(parent, columns);
}
else {
@ -568,7 +568,7 @@ RDFTreeDocumentImpl::AddChild(nsIRDFContent* parent,
NS_RELEASE(resource);
return rv;
}
else if (IsTreeProperty(property) || rdf_IsContainer(mResourceMgr, mDB, resource)) {
else if (IsTreeProperty(property) || rdf_IsContainer(mRDFService, mDB, resource)) {
rv = AddTreeChild(parent, property, resource);
NS_RELEASE(resource);

Просмотреть файл

@ -59,7 +59,7 @@
#include "nsIRDFDataBase.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsRDFCID.h"
@ -78,12 +78,12 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIRDFContentIID, NS_IRDFCONTENT_IID);
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_IID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -924,9 +924,9 @@ nsRDFElement::GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResu
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
// XXX I'm not sure if we should support properties as attributes
// or not...
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
nsIRDFService* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mgr)))
return rv;
@ -952,7 +952,7 @@ done:
NS_IF_RELEASE(property);
NS_IF_RELEASE(value);
NS_IF_RELEASE(db);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
return rv;
@ -1007,9 +1007,9 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
// XXX I'm not sure if we should support attributes or not...
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
nsIRDFService* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mgr)))
return rv;
@ -1050,7 +1050,7 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
done:
NS_IF_RELEASE(properties);
NS_IF_RELEASE(db);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
return rv;
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
@ -1293,14 +1293,14 @@ nsRDFElement::SetResource(const nsString& aURI)
nsresult rv;
nsIRDFResourceManager* mgr = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mgr)))
nsIRDFService* service = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &service)))
return rv;
rv = mgr->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
rv = service->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
nsServiceManager::ReleaseService(kRDFServiceCID, service);
return rv;
}
@ -1370,22 +1370,22 @@ nsRDFElement::SetProperty(const nsString& aPropertyURI, const nsString& aValue)
#endif
nsresult rv;
nsIRDFResourceManager* mgr = nsnull;
nsIRDFService* service = nsnull;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mgr)))
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &service)))
return rv;
nsIRDFResource* property = nsnull;
nsIRDFLiteral* value = nsnull;
nsIRDFDataBase* db = nsnull;
if (NS_FAILED(rv = mgr->GetUnicodeResource(aPropertyURI, &property)))
if (NS_FAILED(rv = service->GetUnicodeResource(aPropertyURI, &property)))
goto done;
// XXX assume it's a literal?
if (NS_FAILED(rv = mgr->GetLiteral(aValue, &value)))
if (NS_FAILED(rv = service->GetLiteral(aValue, &value)))
goto done;
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
@ -1397,7 +1397,7 @@ done:
NS_IF_RELEASE(db);
NS_IF_RELEASE(value);
NS_IF_RELEASE(property);
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
nsServiceManager::ReleaseService(kRDFServiceCID, service);
return rv;
}

Просмотреть файл

@ -0,0 +1,2 @@
nsIRDFMail.h

Просмотреть файл

@ -25,6 +25,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = rdf
EXPORTS = \
nsIRDFMail.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

Просмотреть файл

@ -21,6 +21,7 @@ MODULE=rdf
DEPTH=..\..\..
EXPORTS = \
nsIRDFMail.h \
$(NULL)
include <$(DEPTH)/config/rules.mak>

Просмотреть файл

@ -28,6 +28,7 @@ LIBRARY_NAME = rdfdatasource_s
CPPSRCS = \
nsBookmarkDataSource.cpp \
nsMailDataSource.cpp \
nsStreamDataSource.cpp \
$(NULL)

Просмотреть файл

@ -21,6 +21,7 @@ LIBRARY_NAME=rdfdatasource_s
CPP_OBJS=\
.\$(OBJDIR)\nsBookmarkDataSource.obj \
.\$(OBJDIR)\nsMailDataSource.obj \
.\$(OBJDIR)\nsStreamDataSource.obj \
$(NULL)

Просмотреть файл

@ -18,7 +18,7 @@
#include "nsIRDFDataSource.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsRDFCID.h"
#include "nsString.h"
@ -29,15 +29,15 @@
////////////////////////////////////////////////////////////////////////
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static const char kURI_bookmarks[] = "rdf:bookmarks"; // XXX?
#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Bookmark);
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child);
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, BookmarkAddDate);
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Description);
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder);
@ -88,7 +88,7 @@ protected:
eBookmarkParserState_InItemDescription
};
nsIRDFResourceManager* mResourceMgr;
nsIRDFService* mRDFService;
nsIRDFDataSource* mDataSource;
nsVoidArray mStack;
nsIRDFResource* mLastItem;
@ -127,34 +127,34 @@ const char* BookmarkParser::kSeparatorString = "<HR>";
BookmarkParser::BookmarkParser(void)
: mResourceMgr(nsnull), mDataSource(nsnull)
: mRDFService(nsnull), mDataSource(nsnull)
{
nsresult rv;
rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mResourceMgr);
rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mRDFService);
PR_ASSERT(NS_SUCCEEDED(rv));
}
BookmarkParser::~BookmarkParser(void)
{
if (mResourceMgr)
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mResourceMgr);
if (mRDFService)
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
}
nsresult
BookmarkParser::Parse(PRFileDesc* file, nsIRDFDataSource* dataSource)
{
NS_PRECONDITION(file && dataSource && mResourceMgr, "null ptr");
NS_PRECONDITION(file && dataSource && mRDFService, "null ptr");
if (! file)
return NS_ERROR_NULL_POINTER;
if (! dataSource)
return NS_ERROR_NULL_POINTER;
if (! mResourceMgr)
if (! mRDFService)
return NS_ERROR_NOT_INITIALIZED;
// Initialize the parser for a run...
@ -208,20 +208,20 @@ BookmarkParser::AddColumns(void)
const char* const* columnTitle = gColumnTitles;
const char* const* columnURI = gColumnURIs;
if (NS_FAILED(rv = rdf_CreateAnonymousResource(mResourceMgr, &columns)))
if (NS_FAILED(rv = rdf_CreateAnonymousResource(mRDFService, &columns)))
goto done;
if (NS_FAILED(rv = rdf_MakeSeq(mResourceMgr, mDataSource, columns)))
if (NS_FAILED(rv = rdf_MakeSeq(mRDFService, mDataSource, columns)))
goto done;
while (*columnTitle && *columnURI) {
nsIRDFResource* column = nsnull;
if (NS_SUCCEEDED(rv = rdf_CreateAnonymousResource(mResourceMgr, &column))) {
rdf_Assert(mResourceMgr, mDataSource, column, kURINC_Title, *columnTitle);
rdf_Assert(mResourceMgr, mDataSource, column, kURINC_Column, *columnURI);
if (NS_SUCCEEDED(rv = rdf_CreateAnonymousResource(mRDFService, &column))) {
rdf_Assert(mRDFService, mDataSource, column, kURINC_Title, *columnTitle);
rdf_Assert(mRDFService, mDataSource, column, kURINC_Column, *columnURI);
rdf_ContainerAddElement(mResourceMgr, mDataSource, columns, column);
rdf_ContainerAddElement(mRDFService, mDataSource, columns, column);
NS_IF_RELEASE(column);
}
@ -232,7 +232,7 @@ BookmarkParser::AddColumns(void)
break;
}
rdf_Assert(mResourceMgr, mDataSource, kURI_bookmarks, kURINC_Columns, columns);
rdf_Assert(mRDFService, mDataSource, kURI_bookmarks, kURINC_Columns, columns);
done:
NS_IF_RELEASE(columns);
@ -284,15 +284,15 @@ BookmarkParser::NextToken(void)
folderURI.Append('#');
folderURI.Append(++mCounter, 10);
if (NS_FAILED(mResourceMgr->GetUnicodeResource(folderURI, &folder)))
if (NS_FAILED(mRDFService->GetUnicodeResource(folderURI, &folder)))
return;
nsIRDFResource* parent = (nsIRDFResource*) mStack[mStack.Count() - 1];
rdf_Assert(mResourceMgr, mDataSource, parent, kURINC_Folder, folder);
rdf_Assert(mRDFService, mDataSource, parent, kURINC_Folder, folder);
}
else {
// it's the root
if (NS_FAILED(mResourceMgr->GetResource(kURI_bookmarks, &folder)))
if (NS_FAILED(mRDFService->GetResource(kURI_bookmarks, &folder)))
return;
}
@ -308,21 +308,21 @@ BookmarkParser::NextToken(void)
//NS_RELEASE(folder);
if (mState != eBookmarkParserState_InTitle)
rdf_Assert(mResourceMgr, mDataSource, mLastItem, kURINC_Name, mLine);
rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Name, mLine);
if (mLine.Find(kPersonalToolbar) == 0)
rdf_Assert(mResourceMgr, mDataSource, mLastItem, kURIRDF_instanceOf, kURINC_PersonalToolbarFolderCategory);
rdf_Assert(mRDFService, mDataSource, mLastItem, kURIRDF_instanceOf, kURINC_PersonalToolbarFolderCategory);
}
else if (mState == eBookmarkParserState_InItemTitle) {
PR_ASSERT(mLastItem);
if (! mLastItem)
return;
rdf_Assert(mResourceMgr, mDataSource, mLastItem, kURINC_Name, mLine);
rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Name, mLine);
NS_IF_RELEASE(mLastItem);
}
else if (mState == eBookmarkParserState_InItemDescription) {
rdf_Assert(mResourceMgr, mDataSource, mLastItem, kURINC_Description, mLine);
rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Description, mLine);
}
}
@ -376,7 +376,7 @@ BookmarkParser::DoStateTransition(void)
(mLine.Find(kBRString) == 0)) {
// XXX in the original bmk2rdf.c, we only added the
// description in the case that it wasn't set already...why?
rdf_Assert(mResourceMgr, mDataSource, mLastItem, kURINC_Description, mLine);
rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Description, mLine);
}
else {
mState = eBookmarkParserState_Initial;
@ -418,7 +418,7 @@ BookmarkParser::CreateBookmark(void)
return;
nsIRDFResource* bookmark;
if (NS_FAILED(mResourceMgr->GetUnicodeResource(values[eBmkAttribute_URL], &bookmark)))
if (NS_FAILED(mRDFService->GetUnicodeResource(values[eBmkAttribute_URL], &bookmark)))
return;
if (! mStack.Count())
@ -428,7 +428,7 @@ BookmarkParser::CreateBookmark(void)
if (! parent)
return;
rdf_Assert(mResourceMgr, mDataSource, parent, kURINC_Bookmark, bookmark);
rdf_Assert(mRDFService, mDataSource, parent, kURINC_child, bookmark);
if (values[eBmkAttribute_AddDate].Length() > 0)
AssertTime(bookmark, kURINC_BookmarkAddDate, values[eBmkAttribute_AddDate]);
@ -453,7 +453,7 @@ BookmarkParser::AssertTime(nsIRDFResource* object,
const nsString& time)
{
// XXX
return rdf_Assert(mResourceMgr, mDataSource, object, predicateURI, time);
return rdf_Assert(mRDFService, mDataSource, object, predicateURI, time);
}
////////////////////////////////////////////////////////////////////////
@ -482,8 +482,10 @@ public:
NS_DECL_ISUPPORTS
// nsIRDFDataSource
NS_IMETHOD Init(const char* uri) {
return mInner->Init(uri);
NS_IMETHOD Init(const char* uri);
NS_IMETHOD GetURI(const char* *uri) const {
return mInner->GetURI(uri);
}
NS_IMETHOD GetSource(nsIRDFResource* property,
@ -566,17 +568,6 @@ BookmarkDataSourceImpl::BookmarkDataSourceImpl(void)
// XXX rvg there should be only one instance of this class.
// this is actually true of all datasources.
NS_INIT_REFCNT();
nsresult rv;
// XXX do or die, my friend...
rv = nsRepository::CreateInstance(kRDFMemoryDataSourceCID,
nsnull,
kIRDFDataSourceIID,
(void**) &mInner);
PR_ASSERT(NS_SUCCEEDED(rv));
ReadBookmarks();
Init(kURI_bookmarks);
}
BookmarkDataSourceImpl::~BookmarkDataSourceImpl(void)
@ -587,6 +578,25 @@ BookmarkDataSourceImpl::~BookmarkDataSourceImpl(void)
NS_IMPL_ISUPPORTS(BookmarkDataSourceImpl, kIRDFDataSourceIID);
NS_IMETHODIMP
BookmarkDataSourceImpl::Init(const char* uri)
{
nsresult rv;
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID,
nsnull,
kIRDFDataSourceIID,
(void**) &mInner)))
return rv;
if (NS_FAILED(rv = mInner->Init(uri)))
return rv;
if (NS_FAILED(rv = ReadBookmarks()))
return rv;
return NS_OK;
}
NS_IMETHODIMP
BookmarkDataSourceImpl::Flush(void)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,354 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
/*
Class declarations for mail data source resource types.
XXX Should these be factored out into their own implementation files, etc.?
*/
#ifndef nsMailDataSource_h__
#define nsMailDataSource_h__
////////////////////////////////////////////////////////////////////////
// NS_DECL_IRDFRESOURCE, NS_IMPL_IRDFRESOURCE
//
// Convenience macros for implementing the RDF resource interface.
//
// XXX It might make sense to move these macros to nsIRDFResource.h?
#define NS_DECL_IRDFRESOURCE \
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const;\
NS_IMETHOD GetValue(const char* *uri) const;\
NS_IMETHOD EqualsResource(const nsIRDFResource* resource, PRBool* result) const;\
NS_IMETHOD EqualsString(const char* uri, PRBool* result) const;
#define NS_IMPL_IRDFRESOURCE(__class) \
NS_IMETHODIMP \
__class::EqualsNode(nsIRDFNode* node, PRBool* result) const {\
nsresult rv;\
nsIRDFResource* resource;\
if (NS_SUCCEEDED(node->QueryInterface(kIRDFResourceIID, (void**) &resource))) {\
rv = EqualsResource(resource, result);\
NS_RELEASE(resource);\
}\
else {\
*result = PR_FALSE;\
rv = NS_OK;\
}\
return rv;\
}\
NS_IMETHODIMP \
__class::GetValue(const char* *uri) const{\
if (!uri)\
return NS_ERROR_NULL_POINTER;\
*uri = mURI;\
return NS_OK;\
}\
NS_IMETHODIMP \
__class::EqualsResource(const nsIRDFResource* resource, PRBool* result) const {\
if (!resource || !result) return NS_ERROR_NULL_POINTER;\
*result = (resource == (nsIRDFResource*) this);\
return NS_OK;\
}\
NS_IMETHODIMP \
__class::EqualsString(const char* uri, PRBool* result) const {\
if (!uri || !result) return NS_ERROR_NULL_POINTER;\
*result = (PL_strcmp(uri, mURI) == 0);\
return NS_OK;\
}
////////////////////////////////////////////////////////////////////////
/**
* The mail data source.
*/
class MailDataSource : public nsIRDFMailDataSource
{
private:
char* mURI;
nsVoidArray* mObservers;
// internal methods
nsresult InitAccountList (void);
nsresult AddColumns (void);
public:
NS_DECL_ISUPPORTS
MailDataSource(void);
virtual ~MailDataSource (void);
// nsIRDFMailDataSource methods
NS_IMETHOD AddAccount (nsIRDFMailAccount* folder);
NS_IMETHOD RemoveAccount (nsIRDFMailAccount* folder);
// nsIRDFDataSource methods
NS_IMETHOD Init(const char* uri);
NS_IMETHOD GetURI(const char* *uri) const;
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,
nsIRDFAssertionCursor** sources);
NS_IMETHOD GetTargets(nsIRDFResource* source,
nsIRDFResource* property,
PRBool tv,
nsIRDFAssertionCursor** targets);
NS_IMETHOD Assert(nsIRDFResource* source,
nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv);
NS_IMETHOD Unassert(nsIRDFResource* source,
nsIRDFResource* property,
nsIRDFNode* target);
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,
nsIRDFArcsInCursor** labels);
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
nsIRDFArcsOutCursor** labels);
NS_IMETHOD Flush();
// caching frequently used resources
nsIRDFResource* mResourceChild;
nsIRDFResource* mResourceFolder;
nsIRDFResource* mResourceFrom;
nsIRDFResource* mResourceSubject;
nsIRDFResource* mResourceDate;
nsIRDFResource* mResourceUser;
nsIRDFResource* mResourceHost;
nsIRDFResource* mResourceAccount;
nsIRDFResource* mResourceName;
nsIRDFResource* mMailRoot;
nsIRDFResource* mResourceColumns;
nsIRDFDataSource* mMiscMailData;
};
////////////////////////////////////////////////////////////////////////
class MailAccount : public nsIRDFMailAccount
{
private:
char* mURI;
nsresult InitMailAccount (const char* uri);
public:
MailAccount (const char* uri);
MailAccount (char* uri, nsIRDFLiteral* user, nsIRDFLiteral* host);
virtual ~MailAccount (void);
NS_DECL_ISUPPORTS
NS_DECL_IRDFRESOURCE
NS_IMETHOD GetUser(nsIRDFLiteral** result) const;
NS_IMETHOD GetName(nsIRDFLiteral** result) const;
NS_IMETHOD GetHost(nsIRDFLiteral** result) const;
NS_IMETHOD AddFolder (nsIRDFMailFolder* folder);
NS_IMETHOD RemoveFolder (nsIRDFMailFolder* folder);
};
////////////////////////////////////////////////////////////////////////
class MailFolder : public nsIRDFMailFolder
{
private:
enum MailFolderStatus {
eMailFolder_Uninitialized,
eMailFolder_InitInProgress,
eMailFolder_WriteInProgress,
eMailFolder_OK
};
nsVoidArray mMessages;
FILE* mSummaryFile;
MailFolderStatus mStatus;
char* mURI;
public:
MailFolder (const char* uri);
virtual ~MailFolder (void);
NS_DECL_ISUPPORTS
NS_DECL_IRDFRESOURCE
NS_IMETHOD GetAccount(nsIRDFMailAccount** account);
NS_IMETHOD GetName(nsIRDFLiteral** result) const;
NS_IMETHOD GetMessageList (nsVoidArray** result);
NS_IMETHOD AddMessage (nsIRDFMailMessage* msg);
NS_IMETHOD RemoveMessage (nsIRDFMailMessage* msg);
nsresult AddMessage(PRUnichar* uri,
MailFolder* folder,
nsIRDFResource* from,
nsIRDFLiteral* subject,
nsIRDFLiteral* date,
int summaryFileOffset,
int mailFileOffset,
char* flags,
nsIRDFLiteral* messageID);
nsresult AddMessage(PRUnichar* uri,
MailFolder* folder,
nsIRDFResource* from,
nsIRDFLiteral* subject,
nsIRDFLiteral* date,
int mailFileOffset,
char* flags,
nsIRDFLiteral* messageID);
nsresult ReadSummaryFile(char* uri);
};
////////////////////////////////////////////////////////////////////////
class MailMessage : public nsIRDFMailMessage
{
private:
MailFolder* mFolder;
nsIRDFResource* mFrom;
nsIRDFLiteral* mSubject;
int mSummaryFileOffset;
int mMailFileOffset;
nsIRDFLiteral* mDate;
nsIRDFLiteral* mMessageID;
char mFlags[4];
char* mURI;
public:
MailMessage (const char* uri);
virtual ~MailMessage (void);
NS_DECL_ISUPPORTS
NS_DECL_IRDFRESOURCE
NS_IMETHOD GetFolder(nsIRDFMailFolder** result);
NS_IMETHOD GetSubject(nsIRDFLiteral** result);
NS_IMETHOD GetSender(nsIRDFResource** result);
NS_IMETHOD GetDate(nsIRDFLiteral** result);
NS_IMETHOD GetContent(const char* result);
NS_IMETHOD GetMessageID(nsIRDFLiteral** id);
NS_IMETHOD GetFlags(char** result);
NS_IMETHOD SetFlags(const char* result);
nsresult SetupMessage (MailFolder* folder,
nsIRDFResource* from,
nsIRDFLiteral* subject,
nsIRDFLiteral* date,
int summaryFileOffset,
int mailFileOffset,
char* flags,
nsIRDFLiteral* messageID);
};
////////////////////////////////////////////////////////////////////////
class SingletonMailCursor : public nsIRDFAssertionCursor
{
private:
nsIRDFNode* mValue;
nsIRDFResource* mSource;
nsIRDFResource* mProperty;
nsIRDFNode* mTarget;
PRBool mValueReturnedp;
PRBool mInversep;
public:
SingletonMailCursor(nsIRDFNode* u,
nsIRDFResource* s,
PRBool inversep);
virtual ~SingletonMailCursor(void);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIRDFCursor interface
NS_IMETHOD Advance(void);
NS_IMETHOD GetValue(nsIRDFNode** aValue);
// nsIRDFAssertionCursor interface
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
NS_IMETHOD GetSubject(nsIRDFResource** aResource);
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
NS_IMETHOD GetObject(nsIRDFNode** aObject);
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
};
////////////////////////////////////////////////////////////////////////
class ArrayMailCursor : public nsIRDFAssertionCursor ,
public nsIRDFArcsOutCursor
{
private:
nsIRDFNode* mValue;
nsIRDFResource* mSource;
nsIRDFResource* mProperty;
nsIRDFNode* mTarget;
int mCount;
nsVoidArray* mArray;
public:
ArrayMailCursor(nsIRDFResource* u, nsIRDFResource* s, nsVoidArray* array);
virtual ~ArrayMailCursor(void);
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIRDFCursor interface
NS_IMETHOD Advance(void);
NS_IMETHOD GetValue(nsIRDFNode** aValue);
// nsIRDFAssertionCursor interface
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
NS_IMETHOD GetSubject(nsIRDFResource** aResource);
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
NS_IMETHOD GetObject(nsIRDFNode** aObject);
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
};
#endif // nsMailDataSource_h__

Просмотреть файл

@ -18,41 +18,113 @@
/*
A data source that can read itself from and write itself to a stream.
A data source that can read itself from and write itself to an
RDF/XML stream.
TO DO
-----
1) Right now, the only kind of stream data sources that are writable
are "file:" URIs. (In fact, <em>all</em> "file:" URIs are
writable, modulo flie system permissions; this may lead to some
surprising behavior.) Eventually, it'd be great if we could open
an arbitrary nsIOutputStream on *any* URL, and Netlib could just
do the magic.
*/
#include "nsFileSpec.h"
#include "nsFileStream.h"
#include "nsIDTD.h"
#include "nsINameSpaceManager.h"
#include "nsIOutputStream.h"
#include "nsIParser.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFContentSink.h"
#include "nsIRDFCursor.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFXMLSource.h"
#include "nsIStreamListener.h"
#include "nsIURL.h"
#include "nsLayoutCID.h" // for NS_NAMESPACEMANAGER_CID.
#include "nsParserCIID.h"
#include "nsRDFCID.h"
#include "plstr.h"
#include "prio.h"
////////////////////////////////////////////////////////////////////////
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
static NS_DEFINE_IID(kIRDFXMLSourceIID, NS_IRDFXMLSOURCE_IID);
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFSimpleContentSinkCID, NS_RDFSIMPLECONTENTSINK_CID);
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
////////////////////////////////////////////////////////////////////////
// FileOutputStreamImpl
class FileOutputStreamImpl : public nsIOutputStream
{
private:
nsOutputFileStream mStream;
public:
FileOutputStreamImpl(const nsFilePath& path)
: mStream(path) {}
virtual ~FileOutputStreamImpl(void) {
Close();
}
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIBaseStream interface
NS_IMETHOD Close(void) {
mStream.close();
return NS_OK;
}
// nsIOutputStream interface
NS_IMETHOD Write(const char* aBuf,
PRUint32 aOffset,
PRUint32 aCount,
PRUint32 *aWriteCount)
{
PRInt32 written = mStream.write(aBuf + aOffset, aCount);
if (written == -1) {
*aWriteCount = 0;
return NS_ERROR_FAILURE; // XXX right error code?
}
else {
*aWriteCount = written;
return NS_OK;
}
}
};
NS_IMPL_ISUPPORTS(FileOutputStreamImpl, kIOutputStreamIID);
////////////////////////////////////////////////////////////////////////
// StreamDataSourceImpl
class StreamDataSourceImpl : public nsIRDFDataSource
class StreamDataSourceImpl : public nsIRDFDataSource,
public nsIRDFXMLSource
{
protected:
nsIURL* mURL;
nsIRDFDataSource* mInner;
PRBool mIsWritable;
PRBool mIsDirty;
public:
StreamDataSourceImpl(void);
@ -64,6 +136,10 @@ public:
// nsIRDFDataSource
NS_IMETHOD Init(const char* uri);
NS_IMETHOD GetURI(const char* *uri) const {
return mInner->GetURI(uri);
}
NS_IMETHOD GetSource(nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv,
@ -95,15 +171,11 @@ public:
NS_IMETHOD Assert(nsIRDFResource* source,
nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv) {
return mInner->Assert(source, property, target, tv);
}
PRBool tv);
NS_IMETHOD Unassert(nsIRDFResource* source,
nsIRDFResource* property,
nsIRDFNode* target) {
return mInner->Unassert(source, property, target);
}
nsIRDFNode* target);
NS_IMETHOD HasAssertion(nsIRDFResource* source,
nsIRDFResource* property,
@ -132,6 +204,9 @@ public:
}
NS_IMETHOD Flush(void);
// nsIRDFXMLSource interface
NS_IMETHOD Serialize(nsIOutputStream* aStream);
};
@ -139,35 +214,80 @@ public:
StreamDataSourceImpl::StreamDataSourceImpl(void)
: mURL(nsnull)
: mIsWritable(PR_FALSE)
{
}
StreamDataSourceImpl::~StreamDataSourceImpl(void)
{
NS_IF_RELEASE(mURL);
Flush();
}
NS_IMPL_ISUPPORTS(StreamDataSourceImpl, kIRDFDataSourceIID);
NS_IMPL_ADDREF(StreamDataSourceImpl);
NS_IMPL_RELEASE(StreamDataSourceImpl);
NS_IMETHODIMP
StreamDataSourceImpl::QueryInterface(REFNSIID iid, void** result)
{
if (! result)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(kISupportsIID) ||
iid.Equals(kIRDFDataSourceIID)) {
*result = NS_STATIC_CAST(nsIRDFDataSource*, this);
NS_ADDREF(this);
return NS_OK;
}
else if (iid.Equals(kIRDFXMLSourceIID)) {
*result = NS_STATIC_CAST(nsIRDFXMLSource*, this);
NS_ADDREF(this);
return NS_OK;
}
else {
*result = nsnull;
return NS_NOINTERFACE;
}
}
const char* kFileURIPrefix = "file:";
const PRInt32 kFileURIPrefixLen = 5;
NS_IMETHODIMP
StreamDataSourceImpl::Init(const char* uri)
{
nsresult rv;
if (NS_FAILED(rv = NS_NewURL(&mURL, uri)))
return rv;
// XXX this is a hack: any "file:" URI is considered writable. All
// others are considered read-only.
if (PL_strncmp(uri, kFileURIPrefix, kFileURIPrefixLen) == 0)
mIsWritable = PR_TRUE;
nsINameSpaceManager* ns = nsnull;
nsIRDFContentSink* sink = nsnull;
nsIParser* parser = nsnull;
nsIDTD* dtd = nsnull;
nsIStreamListener* lsnr = nsnull;
nsIURL* url = nsnull;
// XXX Get a namespace manager *here*
PR_ASSERT(0);
if (NS_FAILED(rv = NS_NewURL(&url, uri)))
goto done;
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID,
nsnull,
kIRDFDataSourceIID,
(void**) &mInner)))
goto done;
if (NS_FAILED(rv = mInner->Init(uri)))
goto done;
if (NS_FAILED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID,
nsnull,
kINameSpaceManagerIID,
(void**) &ns)))
goto done;
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFSimpleContentSinkCID,
nsnull,
@ -175,10 +295,12 @@ StreamDataSourceImpl::Init(const char* uri)
(void**) &sink)))
goto done;
if (NS_FAILED(rv = sink->Init(mURL, ns)))
if (NS_FAILED(sink->Init(url, ns)))
goto done;
if (NS_FAILED(rv = sink->SetDataSource(this)))
// We set the content sink's data source directly to our in-memory
// store. We _always_ fail asserts because they're not allowed.
if (NS_FAILED(rv = sink->SetDataSource(mInner)))
goto done;
if (NS_FAILED(rv = nsRepository::CreateInstance(kParserCID,
@ -200,11 +322,10 @@ StreamDataSourceImpl::Init(const char* uri)
if (NS_FAILED(rv = parser->QueryInterface(kIStreamListenerIID, (void**) &lsnr)))
goto done;
// XXX This _can't_ be all I need to do -- how do I start the parser?
if (NS_FAILED(parser->Parse(mURL)))
if (NS_FAILED(parser->Parse(url)))
goto done;
if (NS_FAILED(NS_OpenURL(mURL, lsnr)))
if (NS_FAILED(NS_OpenURL(url, lsnr)))
goto done;
done:
@ -212,6 +333,40 @@ done:
NS_IF_RELEASE(dtd);
NS_IF_RELEASE(parser);
NS_IF_RELEASE(sink);
NS_IF_RELEASE(url);
return rv;
}
NS_IMETHODIMP
StreamDataSourceImpl::Assert(nsIRDFResource* source,
nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv)
{
if (! mIsWritable)
return NS_ERROR_FAILURE; // XXX right error code?
nsresult rv;
if (NS_SUCCEEDED(rv = mInner->Assert(source, property, target, tv)))
mIsDirty = PR_TRUE;
return rv;
}
NS_IMETHODIMP
StreamDataSourceImpl::Unassert(nsIRDFResource* source,
nsIRDFResource* property,
nsIRDFNode* target)
{
if (! mIsWritable)
return NS_ERROR_FAILURE; // XXX right error code?
nsresult rv;
if (NS_SUCCEEDED(rv = mInner->Unassert(source, property, target)))
mIsDirty = PR_TRUE;
return rv;
}
@ -219,11 +374,38 @@ done:
NS_IMETHODIMP
StreamDataSourceImpl::Flush(void)
{
// XXX walk through all the resources, writing <RDF:Description>
// elements with properties for each.
if (!mIsWritable || !mIsDirty)
return NS_OK;
nsresult rv;
const char* uri;
if (NS_FAILED(rv = mInner->GetURI(&uri)))
return rv;
nsFileURL url(uri);
nsFilePath path(url);
FileOutputStreamImpl out(path);
if (NS_FAILED(rv = Serialize(&out)))
return rv;
mIsDirty = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
StreamDataSourceImpl::Serialize(nsIOutputStream* stream)
{
nsresult rv;
nsIRDFXMLSource* source;
if (NS_SUCCEEDED(rv = mInner->QueryInterface(kIRDFXMLSourceIID, (void**) &source))) {
rv = source->Serialize(stream);
NS_RELEASE(source);
}
return rv;
}
////////////////////////////////////////////////////////////////////////
nsresult
@ -237,3 +419,6 @@ NS_NewRDFStreamDataSource(nsIRDFDataSource** result)
NS_ADDREF(*result);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////

Двоичные данные
rdf/macbuild/rdf.mcp

Двоичный файл не отображается.

Просмотреть файл

@ -1,9 +1,9 @@
# target: rdf.shlb
mozilla/rdf/base/src/nsContainerCursor.cpp
mozilla/rdf/base/src/nsDataBase.cpp
mozilla/rdf/base/src/nsEmptyCursor.cpp
mozilla/rdf/base/src/nsMemoryDataSource.cpp
mozilla/rdf/base/src/nsRDFResourceManager.cpp
mozilla/rdf/base/src/nsSimpleDataBase.cpp
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
mozilla/rdf/base/src/nsRDFService.cpp
mozilla/rdf/base/src/rdfutil.cpp
mozilla/rdf/build/nsRDFFactory.cpp
mozilla/rdf/content/src/nsRDFContentSink.cpp
@ -14,4 +14,5 @@ mozilla/rdf/content/src/nsRDFHTMLDocument.cpp
mozilla/rdf/content/src/nsRDFSimpleContentSink.cpp
mozilla/rdf/content/src/nsRDFTreeDocument.cpp
mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
mozilla/rdf/datasource/src/nsMailDataSource.cpp
mozilla/rdf/datasource/src/nsStreamDataSource.cpp

Просмотреть файл

@ -16,16 +16,19 @@
* Reserved.
*/
#include <io.h>
#include "nsIContent.h"
#include "nsIInputStream.h"
#include "nsINetService.h"
#include "nsINetService.h"
#include "nsIOutputStream.h"
#include "nsIPostToServer.h"
#include "nsIRDFDataBase.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIRDFXMLSource.h"
#include "nsIServiceManager.h"
#include "nsIStreamListener.h"
#include "nsIURL.h"
@ -58,9 +61,10 @@ static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
// rdf
static NS_DEFINE_CID(kRDFBookMarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
static NS_DEFINE_CID(kRDFSimpleContentSinkCID, NS_RDFSIMPLECONTENTSINK_CID);
static NS_DEFINE_CID(kRDFStreamDataSourceCID, NS_RDFSTREAMDATASOURCE_CID);
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
@ -76,8 +80,10 @@ static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
// IIDs
//NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID);
NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
NS_DEFINE_IID(kIRDFXMLSourceIID, NS_IRDFXMLSOURCE_IID);
static nsresult
SetupRegistry(void)
@ -86,9 +92,10 @@ SetupRegistry(void)
nsRepository::RegisterFactory(kRDFBookMarkDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFHTMLDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFResourceManagerCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFSimpleDataBaseCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFInMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFServiceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFSimpleContentSinkCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFDataBaseCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFStreamDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFTreeDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
@ -101,6 +108,34 @@ SetupRegistry(void)
}
////////////////////////////////////////////////////////////////////////
class ConsoleOutputStreamImpl : public nsIOutputStream
{
public:
ConsoleOutputStreamImpl(void) {}
virtual ~ConsoleOutputStreamImpl(void) {}
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIBaseStream interface
NS_IMETHOD Close(void) {
return NS_OK;
}
// nsIOutputStream interface
NS_IMETHOD Write(const char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aWriteCount) {
write(1, aBuf + aOffset, aCount);
*aWriteCount = aCount;
return NS_OK;
}
};
NS_IMPL_ISUPPORTS(ConsoleOutputStreamImpl, kIOutputStreamIID);
////////////////////////////////////////////////////////////////////////
int
main(int argc, char** argv)
@ -118,6 +153,8 @@ main(int argc, char** argv)
SetupRegistry();
nsIRDFDataSource* ds = nsnull;
nsIRDFXMLSource* xmlSource = nsnull;
PRInt32 i;
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFStreamDataSourceCID,
nsnull,
@ -128,9 +165,16 @@ main(int argc, char** argv)
if (NS_FAILED(rv = ds->Init(argv[1])))
goto done;
while (1) {
// XXX This is really gross. I need to figure out the right way to do it...
for (i = 0; i < 1000000; ++i) {
PLEvent* event = PL_GetEvent(mainQueue);
PL_HandleEvent(event);
PL_HandleEvent(event);
}
if (NS_SUCCEEDED(ds->QueryInterface(kIRDFXMLSourceIID, (void**) &xmlSource))) {
ConsoleOutputStreamImpl* out = new ConsoleOutputStreamImpl();
xmlSource->Serialize(out);
NS_RELEASE(xmlSource);
}
done:

Просмотреть файл

@ -790,7 +790,7 @@ HandleTreeWindowEvent(nsGUIEvent *aEvent)
#include "nsIRDFDataSource.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFResourceManager.h"
#include "nsIRDFService.h"
#include "nsIContent.h"
#include "nsIServiceManager.h"
@ -798,28 +798,27 @@ static nsresult
rdf_CreateBookmarkDocument(nsIDocument*& result)
{
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
nsresult rv;
nsIRDFDataSource* ds = nsnull;
nsIRDFDataBase* db = nsnull;
nsIRDFDocument* doc = nsnull;
nsIRDFResourceManager* mgr = nsnull;
nsIRDFService* service = nsnull;
nsIRDFResource* root = nsnull;
result = nsnull; // reasonable default
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFBookmarkDataSourceCID,
nsnull,
kIRDFDataSourceIID,
(void**) &ds)))
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &service)))
goto done;
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFTreeDocumentCID,
@ -834,15 +833,13 @@ static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
if (NS_FAILED(rv = doc->GetDataBase(db)))
goto done;
if (NS_FAILED(rv = service->GetNamedDataSource("rdf:mail", &ds)))
goto done;
if (NS_FAILED(rv = db->AddDataSource(ds)))
goto done;
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
kIRDFResourceManagerIID,
(nsISupports**) &mgr)))
goto done;
if (NS_FAILED(rv = mgr->GetResource("rdf:bookmarks", &root)))
if (NS_FAILED(rv = service->GetResource("MailRoot", &root)))
goto done;
if (NS_FAILED(rv = doc->SetRootResource(root)))
@ -855,9 +852,9 @@ static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
done:
NS_IF_RELEASE(root);
if (mgr) {
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
mgr = nsnull;
if (service) {
nsServiceManager::ReleaseService(kRDFServiceCID, service);
service = nsnull;
}
NS_IF_RELEASE(doc);
NS_IF_RELEASE(db);

Просмотреть файл

@ -132,11 +132,11 @@ static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID);
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_CID);
static NS_DEFINE_CID(kRDFBookMarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
@ -199,12 +199,12 @@ NS_SetupRegistry()
nsRepository::RegisterFactory(kIEditFactoryIID, EDITOR_DLL, PR_FALSE, PR_FALSE);
#endif //XP_MAC
nsRepository::RegisterFactory(kRDFHTMLDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFTreeDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFResourceManagerCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFBookMarkDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFSimpleDataBaseCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFDataBaseCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFHTMLDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFInMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFServiceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFTreeDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCSSParserCID, LAYOUT_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kPresShellCID, LAYOUT_DLL, PR_FALSE, PR_FALSE);

Просмотреть файл

@ -150,11 +150,11 @@ static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID);
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_CID);
static NS_DEFINE_CID(kRDFBookMarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
@ -222,10 +222,10 @@ NS_SetupRegistry()
nsRepository::RegisterFactory(kRDFHTMLDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFTreeDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFResourceManagerCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFInMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFServiceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFBookMarkDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFSimpleDataBaseCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFDataBaseCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCSSParserCID, LAYOUT_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kPresShellCID, LAYOUT_DLL, PR_FALSE, PR_FALSE);