зеркало из https://github.com/mozilla/pjs.git
Landed RDF_122898_BRANCH onto the trunk.
This commit is contained in:
Родитель
cf7a9076f6
Коммит
314b664b4c
|
@ -59,7 +59,7 @@
|
||||||
#include "nsIRDFDataBase.h"
|
#include "nsIRDFDataBase.h"
|
||||||
#include "nsIRDFDocument.h"
|
#include "nsIRDFDocument.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsRDFCID.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(kIRDFContentIID, NS_IRDFCONTENT_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_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(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_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)
|
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
// XXX I'm not sure if we should support properties as attributes
|
// XXX I'm not sure if we should support properties as attributes
|
||||||
// or not...
|
// or not...
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* mgr = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &mgr)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ done:
|
||||||
NS_IF_RELEASE(property);
|
NS_IF_RELEASE(property);
|
||||||
NS_IF_RELEASE(value);
|
NS_IF_RELEASE(value);
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
|
||||||
|
|
||||||
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -1007,9 +1007,9 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
|
||||||
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
// XXX I'm not sure if we should support attributes or not...
|
// XXX I'm not sure if we should support attributes or not...
|
||||||
|
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* mgr = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &mgr)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
@ -1050,7 +1050,7 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
|
||||||
done:
|
done:
|
||||||
NS_IF_RELEASE(properties);
|
NS_IF_RELEASE(properties);
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
|
@ -1293,14 +1293,14 @@ nsRDFElement::SetResource(const nsString& aURI)
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* service = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &service)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
rv = mgr->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
|
rv = service->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, service);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1370,22 +1370,22 @@ nsRDFElement::SetProperty(const nsString& aPropertyURI, const nsString& aValue)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* service = nsnull;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &service)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsIRDFResource* property = nsnull;
|
nsIRDFResource* property = nsnull;
|
||||||
nsIRDFLiteral* value = nsnull;
|
nsIRDFLiteral* value = nsnull;
|
||||||
nsIRDFDataBase* db = nsnull;
|
nsIRDFDataBase* db = nsnull;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(aPropertyURI, &property)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(aPropertyURI, &property)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
// XXX assume it's a literal?
|
// XXX assume it's a literal?
|
||||||
if (NS_FAILED(rv = mgr->GetLiteral(aValue, &value)))
|
if (NS_FAILED(rv = service->GetLiteral(aValue, &value)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
|
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
|
||||||
|
@ -1397,7 +1397,7 @@ done:
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
NS_IF_RELEASE(value);
|
NS_IF_RELEASE(value);
|
||||||
NS_IF_RELEASE(property);
|
NS_IF_RELEASE(property);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, service);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,6 @@ nsIRDFDataBase.h
|
||||||
nsIRDFDataSource.h
|
nsIRDFDataSource.h
|
||||||
nsIRDFNode.h
|
nsIRDFNode.h
|
||||||
nsIRDFObserver.h
|
nsIRDFObserver.h
|
||||||
nsIRDFResourceManager.h
|
nsIRDFResourceFactory.h
|
||||||
|
nsIRDFService.h
|
||||||
nsIRDFXMLSource.h
|
nsIRDFXMLSource.h
|
||||||
|
|
|
@ -31,7 +31,8 @@ EXPORTS = \
|
||||||
nsIRDFDataSource.h \
|
nsIRDFDataSource.h \
|
||||||
nsIRDFNode.h \
|
nsIRDFNode.h \
|
||||||
nsIRDFObserver.h \
|
nsIRDFObserver.h \
|
||||||
nsIRDFResourceManager.h \
|
nsIRDFResourceFactory.h \
|
||||||
|
nsIRDFService.h \
|
||||||
nsIRDFXMLSource.h \
|
nsIRDFXMLSource.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ EXPORTS=\
|
||||||
nsIRDFDataSource.h \
|
nsIRDFDataSource.h \
|
||||||
nsIRDFNode.h \
|
nsIRDFNode.h \
|
||||||
nsIRDFObserver.h \
|
nsIRDFObserver.h \
|
||||||
nsIRDFResourceManager.h \
|
nsIRDFResourceFactory.h \
|
||||||
|
nsIRDFService.h \
|
||||||
nsIRDFXMLSource.h \
|
nsIRDFXMLSource.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,16 @@ public:
|
||||||
* unless a catastrophic error occurs.
|
* unless a catastrophic error occurs.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD Advance(void) = 0;
|
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 {
|
class nsIRDFAssertionCursor : public nsIRDFCursor {
|
||||||
public:
|
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.
|
* Retrieve the assertion's subject resource.
|
||||||
|
@ -99,12 +102,7 @@ public:
|
||||||
*/
|
*/
|
||||||
class nsIRDFArcsOutCursor : public nsIRDFCursor {
|
class nsIRDFArcsOutCursor : public nsIRDFCursor {
|
||||||
public:
|
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.
|
* Retrieve the "subject" node from which the arcs originate.
|
||||||
|
@ -117,12 +115,13 @@ public:
|
||||||
* @return NS_OK, unless a catastrophic error occurs.
|
* @return NS_OK, unless a catastrophic error occurs.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the truth value of the arc.
|
* Retrieve the truth value of the arc.
|
||||||
* @return NS_OK, unless a catastrophic error occurs.
|
* @return NS_OK, unless a catastrophic error occurs.
|
||||||
*/
|
* xxx rvg --- truth value doesn't make sense here.
|
||||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
|
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,12 +135,6 @@ public:
|
||||||
*/
|
*/
|
||||||
class nsIRDFArcsInCursor : public nsIRDFCursor {
|
class nsIRDFArcsInCursor : public nsIRDFCursor {
|
||||||
public:
|
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.
|
* Retrieve the "object" node in which the arc terminates.
|
||||||
|
@ -154,12 +147,13 @@ public:
|
||||||
* @return NS_OK, unless a catastrophic error occurs.
|
* @return NS_OK, unless a catastrophic error occurs.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the truth value of the arc.
|
* Retrieve the truth value of the arc.
|
||||||
* @return NS_OK, unless a catastrophic error occurs.
|
* @return NS_OK, unless a catastrophic error occurs.
|
||||||
*/
|
* xxx rvg --- truth value doesn't make sense here.
|
||||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
|
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class nsIRDFResource;
|
||||||
|
|
||||||
class nsIRDFDataSource : public nsISupports {
|
class nsIRDFDataSource : public nsISupports {
|
||||||
public:
|
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
|
// probably pretty likely that many data sources will just make
|
||||||
// stuff up at runtime to answer queries.
|
// stuff up at runtime to answer queries.
|
||||||
|
|
||||||
|
@ -50,6 +50,11 @@ public:
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD Init(const char* uri) = 0;
|
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
|
* Find an RDF resource that points to a given node over the
|
||||||
* specified arc & truth value
|
* 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:
|
* should be obtained from the service manager:
|
||||||
*
|
*
|
||||||
* nsIRDFResourceManager* mgr;
|
* nsIRDFService* service;
|
||||||
* if (NS_SUCCEEDED(nsServiceManager::GetService(kCRDFResourceManagerCID,
|
* if (NS_SUCCEEDED(nsServiceManager::GetService(kCRDFServiceCID,
|
||||||
* kIRDFResourceManagerIID,
|
* kIRDFServiceIID,
|
||||||
* &mgr))) {
|
* (nsISupports**) &service))) {
|
||||||
* nsIRDFNode* node;
|
* nsIRDFNode* node;
|
||||||
* if (NS_SUCCEEDED(mgr->GetResource("http://foo.bar/", node))) {
|
* if (NS_SUCCEEDED(service->GetResource("http://foo.bar/", node))) {
|
||||||
* // do something useful here...
|
* // do something useful here...
|
||||||
* NS_IF_RELEASE(node);
|
* 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
|
class nsIRDFXMLSource : public nsISupports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_IMETHOD Serialize(nsIOutputStream* stream) = 0;
|
NS_IMETHOD Serialize(nsIOutputStream* aStream) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsIRDFXMLSource_h__
|
#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
|
/* Returned from nsIRDFCursor::Advance() if the cursor has no more
|
||||||
elements to enuemrate */
|
elements to enuemrate */
|
||||||
#define NS_ERROR_RDF_CURSOR_EMPTY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 1)
|
#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 = \
|
CPPSRCS = \
|
||||||
nsContainerCursor.cpp \
|
nsContainerCursor.cpp \
|
||||||
|
nsDataBase.cpp \
|
||||||
|
nsDefaultResourceFactory.cpp \
|
||||||
nsEmptyCursor.cpp \
|
nsEmptyCursor.cpp \
|
||||||
nsMemoryDataSource.cpp \
|
nsInMemoryDataSource.cpp \
|
||||||
nsRDFResourceManager.cpp \
|
nsRDFService.cpp \
|
||||||
nsSimpleDataBase.cpp \
|
|
||||||
rdfutil.cpp \
|
rdfutil.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,11 @@ LIBRARY_NAME=rdfbase_s
|
||||||
|
|
||||||
CPP_OBJS=\
|
CPP_OBJS=\
|
||||||
.\$(OBJDIR)\nsContainerCursor.obj \
|
.\$(OBJDIR)\nsContainerCursor.obj \
|
||||||
|
.\$(OBJDIR)\nsDataBase.obj \
|
||||||
|
.\$(OBJDIR)\nsDefaultResourceFactory.obj \
|
||||||
.\$(OBJDIR)\nsEmptyCursor.obj \
|
.\$(OBJDIR)\nsEmptyCursor.obj \
|
||||||
.\$(OBJDIR)\nsInMemoryDataSource.obj \
|
.\$(OBJDIR)\nsInMemoryDataSource.obj \
|
||||||
.\$(OBJDIR)\nsRDFResourceManager.obj \
|
.\$(OBJDIR)\nsRDFService.obj \
|
||||||
.\$(OBJDIR)\nsSimpleDataBase.obj \
|
|
||||||
.\$(OBJDIR)\rdfutil.obj \
|
.\$(OBJDIR)\rdfutil.obj \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "nsIRDFCursor.h"
|
#include "nsIRDFCursor.h"
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsRDFCID.h"
|
#include "nsRDFCID.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
@ -55,10 +55,10 @@
|
||||||
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
|
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
|
||||||
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
|
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
|
||||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_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_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 {
|
class ContainerCursorImpl : public nsIRDFAssertionCursor {
|
||||||
private:
|
private:
|
||||||
nsIRDFResourceManager* mResourceMgr;
|
nsIRDFService* mRDFService;
|
||||||
nsIRDFDataSource* mDataSource;
|
nsIRDFDataSource* mDataSource;
|
||||||
nsIRDFResource* mContainer;
|
nsIRDFResource* mContainer;
|
||||||
nsIRDFNode* mNext;
|
nsIRDFNode* mNext;
|
||||||
|
@ -90,6 +90,7 @@ public:
|
||||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
|
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
|
||||||
NS_IMETHOD GetObject(nsIRDFNode** aObject);
|
NS_IMETHOD GetObject(nsIRDFNode** aObject);
|
||||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
|
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
|
||||||
|
NS_IMETHOD GetValue(nsIRDFNode** aValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
ContainerCursorImpl::ContainerCursorImpl(nsIRDFDataSource* ds,
|
ContainerCursorImpl::ContainerCursorImpl(nsIRDFDataSource* ds,
|
||||||
|
@ -101,13 +102,13 @@ ContainerCursorImpl::ContainerCursorImpl(nsIRDFDataSource* ds,
|
||||||
NS_IF_ADDREF(mContainer);
|
NS_IF_ADDREF(mContainer);
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mResourceMgr);
|
(nsISupports**) &mRDFService);
|
||||||
|
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to acquire resource manager");
|
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);
|
NS_IF_RELEASE(mNext);
|
||||||
|
|
||||||
if (mResourceMgr)
|
if (mRDFService)
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mResourceMgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||||
|
|
||||||
NS_IF_RELEASE(mContainer);
|
NS_IF_RELEASE(mContainer);
|
||||||
NS_IF_RELEASE(mDataSource);
|
NS_IF_RELEASE(mDataSource);
|
||||||
|
@ -158,7 +159,7 @@ ContainerCursorImpl::Advance(void)
|
||||||
PRInt32 err;
|
PRInt32 err;
|
||||||
|
|
||||||
// XXX we could cache all this crap when the cursor gets created.
|
// 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;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mDataSource->GetTarget(mContainer, RDF_nextVal, PR_TRUE, &nextNode)))
|
if (NS_FAILED(rv = mDataSource->GetTarget(mContainer, RDF_nextVal, PR_TRUE, &nextNode)))
|
||||||
|
@ -242,7 +243,7 @@ ContainerCursorImpl::GetPredicate(nsIRDFResource** aPredicate)
|
||||||
s.Append(mCounter, 10);
|
s.Append(mCounter, 10);
|
||||||
|
|
||||||
// this'll AddRef(), null check, etc.
|
// 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
|
NS_IMETHODIMP
|
||||||
ContainerCursorImpl::GetTruthValue(PRBool* aTruthValue)
|
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) {
|
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -143,6 +148,11 @@ public:
|
||||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -205,6 +215,11 @@ public:
|
||||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -29,16 +29,20 @@
|
||||||
class nsIRDFDataSource;
|
class nsIRDFDataSource;
|
||||||
class nsIRDFDataBase;
|
class nsIRDFDataBase;
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
// in nsMemoryDataSource.cpp
|
|
||||||
nsresult NS_NewRDFInMemoryDataSource(nsIRDFDataSource** result);
|
|
||||||
#else
|
|
||||||
// in nsMemoryDataSource.cpp
|
// in nsMemoryDataSource.cpp
|
||||||
|
|
||||||
nsresult NS_NewRDFMemoryDataSource(nsIRDFDataSource** result);
|
nsresult NS_NewRDFMemoryDataSource(nsIRDFDataSource** result);
|
||||||
#endif
|
|
||||||
|
// in nsInMemoryDataSource.cpp
|
||||||
|
|
||||||
|
nsresult NS_NewRDFInMemoryDataSource(nsIRDFDataSource** result);
|
||||||
|
|
||||||
// in nsSimpleDataBase.cpp
|
// in nsSimpleDataBase.cpp
|
||||||
nsresult NS_NewRDFSimpleDataBase(nsIRDFDataBase** result);
|
nsresult NS_NewRDFSimpleDataBase(nsIRDFDataBase** result);
|
||||||
|
|
||||||
|
// in nsDataBase.cpp
|
||||||
|
nsresult NS_NewRDFDataBase(nsIRDFDataBase** result);
|
||||||
#endif // nsBaseDataSources_h__
|
#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 "nsIRDFCursor.h"
|
||||||
#include "nsIRDFDataBase.h"
|
#include "nsIRDFDataBase.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "rdfutil.h"
|
#include "rdfutil.h"
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ rdf_IsOrdinalProperty(const nsIRDFResource* property)
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
rdf_IsContainer(nsIRDFResourceManager* mgr,
|
rdf_IsContainer(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* resource)
|
nsIRDFResource* resource)
|
||||||
{
|
{
|
||||||
|
@ -91,10 +91,10 @@ rdf_IsContainer(nsIRDFResourceManager* mgr,
|
||||||
nsIRDFResource* RDF_Seq = nsnull;
|
nsIRDFResource* RDF_Seq = nsnull;
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (NS_FAILED(rv = mgr->GetResource(kURIRDF_instanceOf, &RDF_instanceOf)))
|
if (NS_FAILED(rv = service->GetResource(kURIRDF_instanceOf, &RDF_instanceOf)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mgr->GetResource(kURIRDF_Bag, &RDF_Bag)))
|
if (NS_FAILED(rv = service->GetResource(kURIRDF_Bag, &RDF_Bag)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Bag, PR_TRUE, &result)))
|
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Bag, PR_TRUE, &result)))
|
||||||
|
@ -103,7 +103,7 @@ rdf_IsContainer(nsIRDFResourceManager* mgr,
|
||||||
if (result)
|
if (result)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mgr->GetResource(kURIRDF_Seq, &RDF_Seq)))
|
if (NS_FAILED(rv = service->GetResource(kURIRDF_Seq, &RDF_Seq)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Seq, PR_TRUE, &result)))
|
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
|
// 0. node, node, node
|
||||||
nsresult
|
nsresult
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr, // unused
|
rdf_Assert(nsIRDFService* service, // unused
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* subject,
|
nsIRDFResource* subject,
|
||||||
nsIRDFResource* predicate,
|
nsIRDFResource* predicate,
|
||||||
|
@ -156,11 +156,11 @@ rdf_Assert(nsIRDFResourceManager* mgr, // unused
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const char* s;
|
const char* s;
|
||||||
|
|
||||||
subject->GetValue(&s);
|
|
||||||
printf("(%s\n", s);
|
|
||||||
predicate->GetValue(&s);
|
predicate->GetValue(&s);
|
||||||
printf(" %s\n", s);
|
printf(" %s", (strchr(s, '#') ? strchr(s, '#')+1 : s));
|
||||||
|
subject->GetValue(&s);
|
||||||
|
printf("(%s, ", s);
|
||||||
|
|
||||||
|
|
||||||
nsIRDFResource* objectResource;
|
nsIRDFResource* objectResource;
|
||||||
nsIRDFLiteral* objectLiteral;
|
nsIRDFLiteral* objectLiteral;
|
||||||
|
@ -185,21 +185,21 @@ rdf_Assert(nsIRDFResourceManager* mgr, // unused
|
||||||
|
|
||||||
// 1. string, string, string
|
// 1. string, string, string
|
||||||
nsresult
|
nsresult
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
const nsString& subjectURI,
|
const nsString& subjectURI,
|
||||||
const nsString& predicateURI,
|
const nsString& predicateURI,
|
||||||
const nsString& objectURI)
|
const nsString& objectURI)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIRDFResource* subject;
|
nsIRDFResource* subject;
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(subjectURI, &subject)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(subjectURI, &subject)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
rv = rdf_Assert(mgr, ds, subject, predicateURI, objectURI);
|
rv = rdf_Assert(service, ds, subject, predicateURI, objectURI);
|
||||||
NS_RELEASE(subject);
|
NS_RELEASE(subject);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -207,13 +207,13 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 2. node, node, string
|
// 2. node, node, string
|
||||||
nsresult
|
nsresult
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* subject,
|
nsIRDFResource* subject,
|
||||||
nsIRDFResource* predicate,
|
nsIRDFResource* predicate,
|
||||||
const nsString& objectURI)
|
const nsString& objectURI)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
NS_ASSERTION(subject, "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.
|
// literal. If you don't like it, then call ds->Assert() yerself.
|
||||||
if (rdf_IsResource(objectURI)) {
|
if (rdf_IsResource(objectURI)) {
|
||||||
nsIRDFResource* resource;
|
nsIRDFResource* resource;
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(objectURI, &resource)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(objectURI, &resource)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
object = resource;
|
object = resource;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nsIRDFLiteral* literal;
|
nsIRDFLiteral* literal;
|
||||||
if (NS_FAILED(rv = mgr->GetLiteral(objectURI, &literal)))
|
if (NS_FAILED(rv = service->GetLiteral(objectURI, &literal)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
object = literal;
|
object = literal;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = rdf_Assert(mgr, ds, subject, predicate, object);
|
rv = rdf_Assert(service, ds, subject, predicate, object);
|
||||||
NS_RELEASE(object);
|
NS_RELEASE(object);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -246,22 +246,22 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 3. node, string, string
|
// 3. node, string, string
|
||||||
nsresult
|
nsresult
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* subject,
|
nsIRDFResource* subject,
|
||||||
const nsString& predicateURI,
|
const nsString& predicateURI,
|
||||||
const nsString& objectURI)
|
const nsString& objectURI)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
NS_ASSERTION(subject, "null ptr");
|
NS_ASSERTION(subject, "null ptr");
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIRDFResource* predicate;
|
nsIRDFResource* predicate;
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(predicateURI, &predicate)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(predicateURI, &predicate)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
rv = rdf_Assert(mgr, ds, subject, predicate, objectURI);
|
rv = rdf_Assert(service, ds, subject, predicate, objectURI);
|
||||||
NS_RELEASE(predicate);
|
NS_RELEASE(predicate);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -269,23 +269,23 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 4. node, string, node
|
// 4. node, string, node
|
||||||
nsresult
|
nsresult
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* subject,
|
nsIRDFResource* subject,
|
||||||
const nsString& predicateURI,
|
const nsString& predicateURI,
|
||||||
nsIRDFNode* object)
|
nsIRDFNode* object)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
NS_ASSERTION(subject, "null ptr");
|
NS_ASSERTION(subject, "null ptr");
|
||||||
NS_ASSERTION(object, "null ptr");
|
NS_ASSERTION(object, "null ptr");
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIRDFResource* predicate;
|
nsIRDFResource* predicate;
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(predicateURI, &predicate)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(predicateURI, &predicate)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
rv = rdf_Assert(mgr, ds, subject, predicate, object);
|
rv = rdf_Assert(service, ds, subject, predicate, object);
|
||||||
NS_RELEASE(predicate);
|
NS_RELEASE(predicate);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -293,21 +293,21 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 5. string, string, node
|
// 5. string, string, node
|
||||||
nsresult
|
nsresult
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
const nsString& subjectURI,
|
const nsString& subjectURI,
|
||||||
const nsString& predicateURI,
|
const nsString& predicateURI,
|
||||||
nsIRDFNode* object)
|
nsIRDFNode* object)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIRDFResource* subject;
|
nsIRDFResource* subject;
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(subjectURI, &subject)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(subjectURI, &subject)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
rv = rdf_Assert(mgr, ds, subject, predicateURI, object);
|
rv = rdf_Assert(service, ds, subject, predicateURI, object);
|
||||||
NS_RELEASE(subject);
|
NS_RELEASE(subject);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -316,7 +316,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
rdf_CreateAnonymousResource(nsIRDFResourceManager* mgr,
|
rdf_CreateAnonymousResource(nsIRDFService* service,
|
||||||
nsIRDFResource** result)
|
nsIRDFResource** result)
|
||||||
{
|
{
|
||||||
static PRUint32 gCounter = 0;
|
static PRUint32 gCounter = 0;
|
||||||
|
@ -324,15 +324,15 @@ rdf_CreateAnonymousResource(nsIRDFResourceManager* mgr,
|
||||||
nsAutoString s = "$";
|
nsAutoString s = "$";
|
||||||
s.Append(++gCounter, 10);
|
s.Append(++gCounter, 10);
|
||||||
|
|
||||||
return mgr->GetUnicodeResource(s, result);
|
return service->GetUnicodeResource(s, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
rdf_MakeBag(nsIRDFResourceManager* mgr,
|
rdf_MakeBag(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* bag)
|
nsIRDFResource* bag)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
NS_ASSERTION(bag, "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.
|
// 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;
|
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 rv;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -351,11 +351,11 @@ rdf_MakeBag(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
rdf_MakeSeq(nsIRDFResourceManager* mgr,
|
rdf_MakeSeq(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* seq)
|
nsIRDFResource* seq)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
NS_ASSERTION(seq, "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.
|
// 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;
|
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 rv;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -374,11 +374,11 @@ rdf_MakeSeq(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
rdf_MakeAlt(nsIRDFResourceManager* mgr,
|
rdf_MakeAlt(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* alt)
|
nsIRDFResource* alt)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
NS_ASSERTION(alt, "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.
|
// 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;
|
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 rv;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -397,12 +397,12 @@ rdf_MakeAlt(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
rdf_ContainerGetNextValue(nsIRDFResourceManager* mgr,
|
rdf_ContainerGetNextValue(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* container,
|
nsIRDFResource* container,
|
||||||
nsIRDFResource** result)
|
nsIRDFResource** result)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
NS_ASSERTION(container, "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
|
// Get the next value, which hangs off of the bag via the
|
||||||
// RDF:nextVal property.
|
// 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;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = ds->GetTarget(container, RDF_nextVal, PR_TRUE, &nextValNode)))
|
if (NS_FAILED(rv = ds->GetTarget(container, RDF_nextVal, PR_TRUE, &nextValNode)))
|
||||||
|
@ -439,7 +439,7 @@ rdf_ContainerGetNextValue(nsIRDFResourceManager* mgr,
|
||||||
nextValStr.Append("_");
|
nextValStr.Append("_");
|
||||||
nextValStr.Append(nextVal, 10);
|
nextValStr.Append(nextVal, 10);
|
||||||
|
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(nextValStr, result)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(nextValStr, result)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
// Now increment the RDF:nextVal property.
|
// Now increment the RDF:nextVal property.
|
||||||
|
@ -452,10 +452,10 @@ rdf_ContainerGetNextValue(nsIRDFResourceManager* mgr,
|
||||||
nextValStr.Truncate();
|
nextValStr.Truncate();
|
||||||
nextValStr.Append(nextVal, 10);
|
nextValStr.Append(nextVal, 10);
|
||||||
|
|
||||||
if (NS_FAILED(rv = mgr->GetLiteral(nextValStr, &nextValLiteral)))
|
if (NS_FAILED(rv = service->GetLiteral(nextValStr, &nextValLiteral)))
|
||||||
goto done;
|
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;
|
goto done;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -468,12 +468,12 @@ done:
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
rdf_ContainerAddElement(nsIRDFResourceManager* mgr,
|
rdf_ContainerAddElement(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* container,
|
nsIRDFResource* container,
|
||||||
nsIRDFNode* element)
|
nsIRDFNode* element)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mgr, "null ptr");
|
NS_ASSERTION(service, "null ptr");
|
||||||
NS_ASSERTION(ds, "null ptr");
|
NS_ASSERTION(ds, "null ptr");
|
||||||
NS_ASSERTION(container, "null ptr");
|
NS_ASSERTION(container, "null ptr");
|
||||||
NS_ASSERTION(element, "null ptr");
|
NS_ASSERTION(element, "null ptr");
|
||||||
|
@ -482,10 +482,10 @@ rdf_ContainerAddElement(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
nsIRDFResource* nextVal;
|
nsIRDFResource* nextVal;
|
||||||
|
|
||||||
if (NS_FAILED(rv = rdf_ContainerGetNextValue(mgr, ds, container, &nextVal)))
|
if (NS_FAILED(rv = rdf_ContainerGetNextValue(service, ds, container, &nextVal)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (rv = rdf_Assert(mgr, ds, container, nextVal, element))
|
if (rv = rdf_Assert(service, ds, container, nextVal, element))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -31,7 +31,7 @@ class nsIRDFCursor;
|
||||||
class nsIRDFDataBase;
|
class nsIRDFDataBase;
|
||||||
class nsIRDFDataSource;
|
class nsIRDFDataSource;
|
||||||
class nsIRDFNode;
|
class nsIRDFNode;
|
||||||
class nsIRDFResourceManager;
|
class nsIRDFService;
|
||||||
class nsString;
|
class nsString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ rdf_IsOrdinalProperty(const nsIRDFResource* property);
|
||||||
* rdf:Bag.
|
* rdf:Bag.
|
||||||
*/
|
*/
|
||||||
PR_EXTERN(PRBool)
|
PR_EXTERN(PRBool)
|
||||||
rdf_IsContainer(nsIRDFResourceManager* mgr,
|
rdf_IsContainer(nsIRDFService* service,
|
||||||
nsIRDFDataSource* db,
|
nsIRDFDataSource* db,
|
||||||
nsIRDFResource* resource);
|
nsIRDFResource* resource);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ rdf_IsContainer(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 0. node, node, node
|
// 0. node, node, node
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr, // unused
|
rdf_Assert(nsIRDFService* service, // unused
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* subject,
|
nsIRDFResource* subject,
|
||||||
nsIRDFResource* predicate,
|
nsIRDFResource* predicate,
|
||||||
|
@ -66,7 +66,7 @@ rdf_Assert(nsIRDFResourceManager* mgr, // unused
|
||||||
|
|
||||||
// 1. string, string, string
|
// 1. string, string, string
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
const nsString& subjectURI,
|
const nsString& subjectURI,
|
||||||
const nsString& predicateURI,
|
const nsString& predicateURI,
|
||||||
|
@ -74,7 +74,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 2. node, node, string
|
// 2. node, node, string
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* subject,
|
nsIRDFResource* subject,
|
||||||
nsIRDFResource* predicate,
|
nsIRDFResource* predicate,
|
||||||
|
@ -82,7 +82,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 3. node, string, string
|
// 3. node, string, string
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* subject,
|
nsIRDFResource* subject,
|
||||||
const nsString& predicateURI,
|
const nsString& predicateURI,
|
||||||
|
@ -90,7 +90,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 4. node, string, node
|
// 4. node, string, node
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* subject,
|
nsIRDFResource* subject,
|
||||||
const nsString& predicateURI,
|
const nsString& predicateURI,
|
||||||
|
@ -98,7 +98,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
|
|
||||||
// 5. string, string, node
|
// 5. string, string, node
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_Assert(nsIRDFResourceManager* mgr,
|
rdf_Assert(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
const nsString& subjectURI,
|
const nsString& subjectURI,
|
||||||
const nsString& predicateURI,
|
const nsString& predicateURI,
|
||||||
|
@ -109,7 +109,7 @@ rdf_Assert(nsIRDFResourceManager* mgr,
|
||||||
* resource URI.
|
* resource URI.
|
||||||
*/
|
*/
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_CreateAnonymousResource(nsIRDFResourceManager* mgr,
|
rdf_CreateAnonymousResource(nsIRDFService* service,
|
||||||
nsIRDFResource** result);
|
nsIRDFResource** result);
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ rdf_CreateAnonymousResource(nsIRDFResourceManager* mgr,
|
||||||
* Create a bag resource.
|
* Create a bag resource.
|
||||||
*/
|
*/
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_MakeBag(nsIRDFResourceManager* mgr,
|
rdf_MakeBag(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* resource);
|
nsIRDFResource* resource);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ rdf_MakeBag(nsIRDFResourceManager* mgr,
|
||||||
* Create a sequence resource.
|
* Create a sequence resource.
|
||||||
*/
|
*/
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_MakeSeq(nsIRDFResourceManager* mgr,
|
rdf_MakeSeq(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* resource);
|
nsIRDFResource* resource);
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ rdf_MakeSeq(nsIRDFResourceManager* mgr,
|
||||||
* Create an alternation resource.
|
* Create an alternation resource.
|
||||||
*/
|
*/
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_MakeAlt(nsIRDFResourceManager* mgr,
|
rdf_MakeAlt(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* resource);
|
nsIRDFResource* resource);
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ rdf_MakeAlt(nsIRDFResourceManager* mgr,
|
||||||
* Add an element to the container.
|
* Add an element to the container.
|
||||||
*/
|
*/
|
||||||
PR_EXTERN(nsresult)
|
PR_EXTERN(nsresult)
|
||||||
rdf_ContainerAddElement(nsIRDFResourceManager* mgr,
|
rdf_ContainerAddElement(nsIRDFService* service,
|
||||||
nsIRDFDataSource* ds,
|
nsIRDFDataSource* ds,
|
||||||
nsIRDFResource* container,
|
nsIRDFResource* container,
|
||||||
nsIRDFNode* element);
|
nsIRDFNode* element);
|
||||||
|
|
|
@ -41,6 +41,8 @@ LLIBS=\
|
||||||
$(DIST)\lib\libplc21.lib \
|
$(DIST)\lib\libplc21.lib \
|
||||||
$(LIBNSPR)
|
$(LIBNSPR)
|
||||||
|
|
||||||
|
MISCDEP=$(LLIBS)
|
||||||
|
|
||||||
# XXX Note dependencies on implementation dirs for factory methods.
|
# XXX Note dependencies on implementation dirs for factory methods.
|
||||||
|
|
||||||
LINCS= -I$(PUBLIC)\rdf \
|
LINCS= -I$(PUBLIC)\rdf \
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
{ 0xf78da56, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
{ 0xf78da56, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||||
|
|
||||||
// {BFD05264-834C-11d2-8EAC-00805F29F370}
|
// {BFD05264-834C-11d2-8EAC-00805F29F370}
|
||||||
#define NS_RDFRESOURCEMANAGER_CID \
|
#define NS_RDFSERVICE_CID \
|
||||||
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||||
|
|
||||||
// {BFD0526D-834C-11d2-8EAC-00805F29F370}
|
// {BFD0526D-834C-11d2-8EAC-00805F29F370}
|
||||||
#define NS_RDFMEMORYDATASOURCE_CID \
|
#define NS_RDFINMEMORYDATASOURCE_CID \
|
||||||
{ 0xbfd0526d, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
{ 0xbfd0526d, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||||
|
|
||||||
// {E638D760-8687-11d2-B530-000000000000}
|
// {E638D760-8687-11d2-B530-000000000000}
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||||
|
|
||||||
// {E638D761-8687-11d2-B530-000000000000}
|
// {E638D761-8687-11d2-B530-000000000000}
|
||||||
#define NS_RDFSIMPLEDATABASE_CID \
|
#define NS_RDFDATABASE_CID \
|
||||||
{ 0xe638d761, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
{ 0xe638d761, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||||
|
|
||||||
// {954F0813-81DC-11d2-B52A-000000000000}
|
// {954F0813-81DC-11d2-B52A-000000000000}
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
|
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsIFactory.h"
|
#include "nsIFactory.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFContentSink.h"
|
||||||
|
#include "nsIRDFService.h"
|
||||||
#include "nsRDFBaseDataSources.h"
|
#include "nsRDFBaseDataSources.h"
|
||||||
#include "nsRDFBuiltInDataSources.h"
|
#include "nsRDFBuiltInDataSources.h"
|
||||||
#include "nsRDFDocument.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_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||||
|
|
||||||
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_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(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
|
||||||
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
|
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||||
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_CID);
|
static NS_DEFINE_CID(kRDFSimpleContentSinkCID, NS_RDFSIMPLECONTENTSINK_CID);
|
||||||
static NS_DEFINE_CID(kRDFStreamDataSourceCID, NS_RDFSTREAMDATASOURCE_CID);
|
static NS_DEFINE_CID(kRDFStreamDataSourceCID, NS_RDFSTREAMDATASOURCE_CID);
|
||||||
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
|
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
|
||||||
|
|
||||||
|
@ -112,28 +114,25 @@ RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
PRBool wasRefCounted = PR_TRUE;
|
PRBool wasRefCounted = PR_TRUE;
|
||||||
nsISupports *inst = nsnull;
|
nsISupports *inst = nsnull;
|
||||||
if (mClassID.Equals(kRDFResourceManagerCID)) {
|
if (mClassID.Equals(kRDFServiceCID)) {
|
||||||
if (NS_FAILED(rv = NS_NewRDFResourceManager((nsIRDFResourceManager**) &inst)))
|
if (NS_FAILED(rv = NS_NewRDFService((nsIRDFService**) &inst)))
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kRDFMemoryDataSourceCID)) {
|
else if (mClassID.Equals(kRDFInMemoryDataSourceCID)) {
|
||||||
#ifdef _WIN32
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFInMemoryDataSource((nsIRDFDataSource**) &inst)))
|
if (NS_FAILED(rv = NS_NewRDFInMemoryDataSource((nsIRDFDataSource**) &inst)))
|
||||||
#else
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFMemoryDataSource((nsIRDFDataSource**) &inst)))
|
|
||||||
#endif
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kRDFStreamDataSourceCID)) {
|
else if (mClassID.Equals(kRDFStreamDataSourceCID)) {
|
||||||
if (NS_FAILED(rv = NS_NewRDFStreamDataSource((nsIRDFDataSource**) &inst)))
|
// if (NS_FAILED(rv = NS_NewRDFStreamDataSource((nsIRDFDataSource**) &inst)))
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kRDFBookmarkDataSourceCID)) {
|
else if (mClassID.Equals(kRDFBookmarkDataSourceCID)) {
|
||||||
if (NS_FAILED(rv = NS_NewRDFBookmarkDataSource((nsIRDFDataSource**) &inst)))
|
if (NS_FAILED(rv = NS_NewRDFBookmarkDataSource((nsIRDFDataSource**) &inst)))
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kRDFSimpleDataBaseCID)) {
|
else if (mClassID.Equals(kRDFDataBaseCID)) {
|
||||||
if (NS_FAILED(rv = NS_NewRDFSimpleDataBase((nsIRDFDataBase**) &inst)))
|
if (NS_FAILED(rv = NS_NewRDFDataBase((nsIRDFDataBase**) &inst)))
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kRDFHTMLDocumentCID)) {
|
else if (mClassID.Equals(kRDFHTMLDocumentCID)) {
|
||||||
|
@ -144,6 +143,10 @@ RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
|
||||||
if (NS_FAILED(rv = NS_NewRDFTreeDocument((nsIRDFDocument**) &inst)))
|
if (NS_FAILED(rv = NS_NewRDFTreeDocument((nsIRDFDocument**) &inst)))
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
else if (mClassID.Equals(kRDFSimpleContentSinkCID)) {
|
||||||
|
if (NS_FAILED(rv = NS_NewRDFSimpleContentSink((nsIRDFContentSink**) &inst)))
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return NS_ERROR_NO_INTERFACE;
|
return NS_ERROR_NO_INTERFACE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,11 @@
|
||||||
#define nsIRDFContentSink_h___
|
#define nsIRDFContentSink_h___
|
||||||
|
|
||||||
#include "nsIXMLContentSink.h"
|
#include "nsIXMLContentSink.h"
|
||||||
|
class nsIDocument;
|
||||||
class nsIRDFDataSource;
|
class nsIRDFDataSource;
|
||||||
class nsINameSpaceManager;
|
class nsINameSpaceManager;
|
||||||
class nsIURL;
|
class nsIURL;
|
||||||
|
class nsIWebShell;
|
||||||
|
|
||||||
// {751843E2-8309-11d2-8EAC-00805F29F370}
|
// {751843E2-8309-11d2-8EAC-00805F29F370}
|
||||||
#define NS_IRDFCONTENTSINK_IID \
|
#define NS_IRDFCONTENTSINK_IID \
|
||||||
|
@ -67,9 +69,7 @@ NS_NewRDFDocumentContentSink(nsIRDFContentSink** aResult,
|
||||||
* document, say, to create a stand-alone in-memory graph.
|
* document, say, to create a stand-alone in-memory graph.
|
||||||
*/
|
*/
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewRDFSimpleContentSink(nsIRDFContentSink** aResult,
|
NS_NewRDFSimpleContentSink(nsIRDFContentSink** aResult);
|
||||||
nsIURL* aURL,
|
|
||||||
nsINameSpaceManager* aNameSpaceManager);
|
|
||||||
|
|
||||||
|
|
||||||
#endif // nsIRDFContentSink_h___
|
#endif // nsIRDFContentSink_h___
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsRDFCID.h"
|
#include "nsRDFCID.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIURL.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(kIContentSinkIID, NS_ICONTENT_SINK_IID); // XXX grr...
|
||||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
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(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
static NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID);
|
static NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID);
|
||||||
static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
|
static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
|
||||||
|
|
||||||
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
|
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Utility routines
|
// Utility routines
|
||||||
|
@ -243,7 +243,7 @@ rdf_FullyQualifyURI(const nsIURL* base, nsString& spec)
|
||||||
|
|
||||||
nsRDFContentSink::nsRDFContentSink()
|
nsRDFContentSink::nsRDFContentSink()
|
||||||
: mDocumentURL(nsnull),
|
: mDocumentURL(nsnull),
|
||||||
mResourceMgr(nsnull),
|
mRDFService(nsnull),
|
||||||
mDataSource(nsnull),
|
mDataSource(nsnull),
|
||||||
mGenSym(0),
|
mGenSym(0),
|
||||||
mNameSpaceManager(nsnull),
|
mNameSpaceManager(nsnull),
|
||||||
|
@ -263,8 +263,8 @@ nsRDFContentSink::~nsRDFContentSink()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(mDocumentURL);
|
NS_IF_RELEASE(mDocumentURL);
|
||||||
|
|
||||||
if (mResourceMgr)
|
if (mRDFService)
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mResourceMgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||||
|
|
||||||
NS_IF_RELEASE(mDataSource);
|
NS_IF_RELEASE(mDataSource);
|
||||||
|
|
||||||
|
@ -275,8 +275,8 @@ nsRDFContentSink::~nsRDFContentSink()
|
||||||
PRInt32 index = mNameSpaceStack->Count();
|
PRInt32 index = mNameSpaceStack->Count();
|
||||||
|
|
||||||
while (0 < index--) {
|
while (0 < index--) {
|
||||||
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
||||||
NS_RELEASE(nameSpace);
|
NS_RELEASE(nameSpace);
|
||||||
}
|
}
|
||||||
delete mNameSpaceStack;
|
delete mNameSpaceStack;
|
||||||
}
|
}
|
||||||
|
@ -579,9 +579,9 @@ nsRDFContentSink::Init(nsIURL* aURL, nsINameSpaceManager* aNameSpaceManager)
|
||||||
NS_ADDREF(mNameSpaceManager);
|
NS_ADDREF(mNameSpaceManager);
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mResourceMgr)))
|
(nsISupports**) &mRDFService)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
mState = eRDFContentSinkState_InProlog;
|
mState = eRDFContentSinkState_InProlog;
|
||||||
|
@ -641,8 +641,8 @@ nsRDFContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
|
||||||
value.Append(mText, mTextLength);
|
value.Append(mText, mTextLength);
|
||||||
|
|
||||||
nsIRDFLiteral* literal;
|
nsIRDFLiteral* literal;
|
||||||
if (NS_SUCCEEDED(rv = mResourceMgr->GetLiteral(value, &literal))) {
|
if (NS_SUCCEEDED(rv = mRDFService->GetLiteral(value, &literal))) {
|
||||||
rv = rdf_ContainerAddElement(mResourceMgr,
|
rv = rdf_ContainerAddElement(mRDFService,
|
||||||
mDataSource,
|
mDataSource,
|
||||||
GetContextElement(0),
|
GetContextElement(0),
|
||||||
literal);
|
literal);
|
||||||
|
@ -654,7 +654,7 @@ nsRDFContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
value.Append(mText, mTextLength);
|
value.Append(mText, mTextLength);
|
||||||
|
|
||||||
rv = rdf_Assert(mResourceMgr,
|
rv = rdf_Assert(mRDFService,
|
||||||
mDataSource,
|
mDataSource,
|
||||||
GetContextElement(1),
|
GetContextElement(1),
|
||||||
GetContextElement(0),
|
GetContextElement(0),
|
||||||
|
@ -811,7 +811,7 @@ nsRDFContentSink::AddProperties(const nsIParserNode& aNode,
|
||||||
k.Append(attr);
|
k.Append(attr);
|
||||||
|
|
||||||
// Add the attribute to RDF
|
// Add the attribute to RDF
|
||||||
rdf_Assert(mResourceMgr, mDataSource, aSubject, k, v);
|
rdf_Assert(mRDFService, mDataSource, aSubject, k, v);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -850,7 +850,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
|
||||||
// node", or a "container", so this change the content sink's
|
// node", or a "container", so this change the content sink's
|
||||||
// state appropriately.
|
// state appropriately.
|
||||||
|
|
||||||
if (! mResourceMgr)
|
if (! mRDFService)
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
nsAutoString tag;
|
nsAutoString tag;
|
||||||
|
@ -865,7 +865,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsIRDFResource* rdfResource;
|
nsIRDFResource* rdfResource;
|
||||||
if (NS_FAILED(rv = mResourceMgr->GetUnicodeResource(uri, &rdfResource)))
|
if (NS_FAILED(rv = mRDFService->GetUnicodeResource(uri, &rdfResource)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
// If we're in a member or property element, then this is the cue
|
// 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.
|
// member/property.
|
||||||
switch (mState) {
|
switch (mState) {
|
||||||
case eRDFContentSinkState_InMemberElement: {
|
case eRDFContentSinkState_InMemberElement: {
|
||||||
rdf_ContainerAddElement(mResourceMgr, mDataSource, GetContextElement(0), rdfResource);
|
rdf_ContainerAddElement(mRDFService, mDataSource, GetContextElement(0), rdfResource);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case eRDFContentSinkState_InPropertyElement: {
|
case eRDFContentSinkState_InPropertyElement: {
|
||||||
|
@ -901,17 +901,17 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
|
||||||
}
|
}
|
||||||
else if (tag.Equals(kTagRDF_Bag)) {
|
else if (tag.Equals(kTagRDF_Bag)) {
|
||||||
// it's a bag container
|
// it's a bag container
|
||||||
rdf_MakeBag(mResourceMgr, mDataSource, rdfResource);
|
rdf_MakeBag(mRDFService, mDataSource, rdfResource);
|
||||||
mState = eRDFContentSinkState_InContainerElement;
|
mState = eRDFContentSinkState_InContainerElement;
|
||||||
}
|
}
|
||||||
else if (tag.Equals(kTagRDF_Seq)) {
|
else if (tag.Equals(kTagRDF_Seq)) {
|
||||||
// it's a seq container
|
// it's a seq container
|
||||||
rdf_MakeSeq(mResourceMgr, mDataSource, rdfResource);
|
rdf_MakeSeq(mRDFService, mDataSource, rdfResource);
|
||||||
mState = eRDFContentSinkState_InContainerElement;
|
mState = eRDFContentSinkState_InContainerElement;
|
||||||
}
|
}
|
||||||
else if (tag.Equals(kTagRDF_Alt)) {
|
else if (tag.Equals(kTagRDF_Alt)) {
|
||||||
// it's an alt container
|
// it's an alt container
|
||||||
rdf_MakeAlt(mResourceMgr, mDataSource, rdfResource);
|
rdf_MakeAlt(mRDFService, mDataSource, rdfResource);
|
||||||
mState = eRDFContentSinkState_InContainerElement;
|
mState = eRDFContentSinkState_InContainerElement;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -926,7 +926,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
|
||||||
nsAutoString nameSpace;
|
nsAutoString nameSpace;
|
||||||
GetNameSpaceURI(nameSpaceID, nameSpace); // XXX append ':' too?
|
GetNameSpaceURI(nameSpaceID, nameSpace); // XXX append ':' too?
|
||||||
nameSpace.Append(tag);
|
nameSpace.Append(tag);
|
||||||
rdf_Assert(mResourceMgr, mDataSource, rdfResource, kURIRDF_type, nameSpace);
|
rdf_Assert(mRDFService, mDataSource, rdfResource, kURIRDF_type, nameSpace);
|
||||||
|
|
||||||
mState = eRDFContentSinkState_InDescriptionElement;
|
mState = eRDFContentSinkState_InDescriptionElement;
|
||||||
}
|
}
|
||||||
|
@ -941,7 +941,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
|
||||||
nsresult
|
nsresult
|
||||||
nsRDFContentSink::OpenProperty(const nsIParserNode& aNode)
|
nsRDFContentSink::OpenProperty(const nsIParserNode& aNode)
|
||||||
{
|
{
|
||||||
if (! mResourceMgr)
|
if (! mRDFService)
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
@ -961,7 +961,7 @@ nsRDFContentSink::OpenProperty(const nsIParserNode& aNode)
|
||||||
// name. We can do this 'cause we don't need it anymore...
|
// name. We can do this 'cause we don't need it anymore...
|
||||||
ns.Append(tag);
|
ns.Append(tag);
|
||||||
nsIRDFResource* rdfProperty;
|
nsIRDFResource* rdfProperty;
|
||||||
if (NS_FAILED(rv = mResourceMgr->GetUnicodeResource(ns, &rdfProperty)))
|
if (NS_FAILED(rv = mRDFService->GetUnicodeResource(ns, &rdfProperty)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsAutoString resourceURI;
|
nsAutoString resourceURI;
|
||||||
|
@ -971,9 +971,9 @@ nsRDFContentSink::OpenProperty(const nsIParserNode& aNode)
|
||||||
// URI, add the properties to it, and attach the inline
|
// URI, add the properties to it, and attach the inline
|
||||||
// resource to its parent.
|
// resource to its parent.
|
||||||
nsIRDFResource* rdfResource;
|
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))) {
|
if (NS_SUCCEEDED(rv = AddProperties(aNode, rdfResource))) {
|
||||||
rv = rdf_Assert(mResourceMgr,
|
rv = rdf_Assert(mRDFService,
|
||||||
mDataSource,
|
mDataSource,
|
||||||
GetContextElement(0),
|
GetContextElement(0),
|
||||||
rdfProperty,
|
rdfProperty,
|
||||||
|
@ -1028,8 +1028,8 @@ nsRDFContentSink::OpenMember(const nsIParserNode& aNode)
|
||||||
// means that it's a "referenced item," as covered in [6.29].
|
// means that it's a "referenced item," as covered in [6.29].
|
||||||
|
|
||||||
nsIRDFResource* resource;
|
nsIRDFResource* resource;
|
||||||
if (NS_SUCCEEDED(rv = mResourceMgr->GetUnicodeResource(resourceURI, &resource))) {
|
if (NS_SUCCEEDED(rv = mRDFService->GetUnicodeResource(resourceURI, &resource))) {
|
||||||
rv = rdf_ContainerAddElement(mResourceMgr, mDataSource, container, resource);
|
rv = rdf_ContainerAddElement(mRDFService, mDataSource, container, resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Technically, we should _not_ fall through here and push
|
// XXX Technically, we should _not_ fall through here and push
|
||||||
|
@ -1131,12 +1131,12 @@ nsRDFContentSink::PushNameSpacesFrom(const nsIParserNode& aNode)
|
||||||
nsINameSpace* nameSpace = nsnull;
|
nsINameSpace* nameSpace = nsnull;
|
||||||
|
|
||||||
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
||||||
nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(mNameSpaceStack->Count() - 1);
|
nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(mNameSpaceStack->Count() - 1);
|
||||||
NS_ADDREF(nameSpace);
|
NS_ADDREF(nameSpace);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mNameSpaceManager->RegisterNameSpace(kRDFNameSpaceURI, mRDFNameSpaceID);
|
mNameSpaceManager->RegisterNameSpace(kRDFNameSpaceURI, mRDFNameSpaceID);
|
||||||
mNameSpaceManager->CreateRootNameSpace(nameSpace);
|
mNameSpaceManager->CreateRootNameSpace(nameSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsnull != nameSpace) {
|
if (nsnull != nameSpace) {
|
||||||
|
@ -1171,6 +1171,8 @@ nsRDFContentSink::PushNameSpacesFrom(const nsIParserNode& aNode)
|
||||||
NS_IF_RELEASE(prefixAtom);
|
NS_IF_RELEASE(prefixAtom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now push the *last* namespace that we discovered on to the stack.
|
||||||
if (nsnull == mNameSpaceStack) {
|
if (nsnull == mNameSpaceStack) {
|
||||||
mNameSpaceStack = new nsVoidArray();
|
mNameSpaceStack = new nsVoidArray();
|
||||||
}
|
}
|
||||||
|
@ -1181,31 +1183,31 @@ nsRDFContentSink::PushNameSpacesFrom(const nsIParserNode& aNode)
|
||||||
nsIAtom*
|
nsIAtom*
|
||||||
nsRDFContentSink::CutNameSpacePrefix(nsString& aString)
|
nsRDFContentSink::CutNameSpacePrefix(nsString& aString)
|
||||||
{
|
{
|
||||||
nsAutoString prefix;
|
nsAutoString prefix;
|
||||||
PRInt32 nsoffset = aString.Find(kNameSpaceSeparator);
|
PRInt32 nsoffset = aString.Find(kNameSpaceSeparator);
|
||||||
if (-1 != nsoffset) {
|
if (-1 != nsoffset) {
|
||||||
aString.Left(prefix, nsoffset);
|
aString.Left(prefix, nsoffset);
|
||||||
aString.Cut(0, nsoffset+1);
|
aString.Cut(0, nsoffset+1);
|
||||||
}
|
}
|
||||||
if (0 < prefix.Length()) {
|
if (0 < prefix.Length()) {
|
||||||
return NS_NewAtom(prefix);
|
return NS_NewAtom(prefix);
|
||||||
}
|
}
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt32
|
PRInt32
|
||||||
nsRDFContentSink::GetNameSpaceID(nsIAtom* aPrefix)
|
nsRDFContentSink::GetNameSpaceID(nsIAtom* aPrefix)
|
||||||
{
|
{
|
||||||
PRInt32 id = kNameSpaceID_Unknown;
|
PRInt32 id = kNameSpaceID_Unknown;
|
||||||
|
|
||||||
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
||||||
PRInt32 index = mNameSpaceStack->Count() - 1;
|
PRInt32 index = mNameSpaceStack->Count() - 1;
|
||||||
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
||||||
nameSpace->FindNameSpaceID(aPrefix, id);
|
nameSpace->FindNameSpaceID(aPrefix, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION(kNameSpaceID_Unknown != mRDFNameSpaceID, "failed to register RDF nameSpace");
|
NS_ASSERTION(kNameSpaceID_Unknown != mRDFNameSpaceID, "failed to register RDF nameSpace");
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1217,11 +1219,15 @@ nsRDFContentSink::GetNameSpaceURI(PRInt32 aID, nsString& aURI)
|
||||||
void
|
void
|
||||||
nsRDFContentSink::PopNameSpaces()
|
nsRDFContentSink::PopNameSpaces()
|
||||||
{
|
{
|
||||||
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
if ((nsnull != mNameSpaceStack) && (0 < mNameSpaceStack->Count())) {
|
||||||
PRInt32 index = mNameSpaceStack->Count() - 1;
|
PRInt32 index = mNameSpaceStack->Count() - 1;
|
||||||
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack->ElementAt(index);
|
||||||
mNameSpaceStack->RemoveElementAt(index);
|
mNameSpaceStack->RemoveElementAt(index);
|
||||||
NS_RELEASE(nameSpace);
|
|
||||||
}
|
// 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 nsVoidArray;
|
||||||
class nsIRDFResource;
|
class nsIRDFResource;
|
||||||
class nsIRDFDataSource;
|
class nsIRDFDataSource;
|
||||||
class nsIRDFResourceManager;
|
class nsIRDFService;
|
||||||
class nsINameSpaceManager;
|
class nsINameSpaceManager;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -112,7 +112,7 @@ protected:
|
||||||
virtual nsresult OpenValue(const nsIParserNode& aNode);
|
virtual nsresult OpenValue(const nsIParserNode& aNode);
|
||||||
|
|
||||||
// Miscellaneous RDF junk
|
// Miscellaneous RDF junk
|
||||||
nsIRDFResourceManager* mResourceMgr;
|
nsIRDFService* mRDFService;
|
||||||
nsIRDFDataSource* mDataSource;
|
nsIRDFDataSource* mDataSource;
|
||||||
RDFContentSinkState mState;
|
RDFContentSinkState mState;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "nsIRDFDataBase.h"
|
#include "nsIRDFDataBase.h"
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
#include "nsIScriptContextOwner.h"
|
#include "nsIScriptContextOwner.h"
|
||||||
#include "nsIServiceManager.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(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
|
||||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_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(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); // XXX grr...
|
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); // XXX grr...
|
||||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||||
|
|
||||||
static NS_DEFINE_CID(kHTMLStyleSheetCID, NS_HTMLSTYLESHEET_CID);
|
static NS_DEFINE_CID(kHTMLStyleSheetCID, NS_HTMLSTYLESHEET_CID);
|
||||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||||
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX
|
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX
|
||||||
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
|
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
|
||||||
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
|
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||||
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_CID);
|
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
|
||||||
static NS_DEFINE_CID(kRangeListCID, NS_RANGELIST_CID);
|
static NS_DEFINE_CID(kRangeListCID, NS_RANGELIST_CID);
|
||||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ nsRDFDocument::nsRDFDocument()
|
||||||
mAttrStyleSheet(nsnull),
|
mAttrStyleSheet(nsnull),
|
||||||
mParser(nsnull),
|
mParser(nsnull),
|
||||||
mDB(nsnull),
|
mDB(nsnull),
|
||||||
mResourceMgr(nsnull),
|
mRDFService(nsnull),
|
||||||
mTreeProperties(nsnull)
|
mTreeProperties(nsnull)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
|
@ -120,9 +120,9 @@ nsRDFDocument::~nsRDFDocument()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(mParser);
|
NS_IF_RELEASE(mParser);
|
||||||
|
|
||||||
if (mResourceMgr) {
|
if (mRDFService) {
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mResourceMgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||||
mResourceMgr = nsnull;
|
mRDFService = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mParentDocument is never refcounted
|
// mParentDocument is never refcounted
|
||||||
|
@ -230,7 +230,7 @@ nsRDFDocument::StartDocumentLoad(nsIURL *aURL,
|
||||||
|
|
||||||
NS_RELEASE(webShell);
|
NS_RELEASE(webShell);
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFMemoryDataSourceCID,
|
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID,
|
||||||
nsnull,
|
nsnull,
|
||||||
kIRDFDataSourceIID,
|
kIRDFDataSourceIID,
|
||||||
(void**) &ds))) {
|
(void**) &ds))) {
|
||||||
|
@ -1033,15 +1033,15 @@ nsRDFDocument::Init(void)
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFSimpleDataBaseCID,
|
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFDataBaseCID,
|
||||||
nsnull,
|
nsnull,
|
||||||
kIRDFDataBaseIID,
|
kIRDFDataBaseIID,
|
||||||
(void**) &mDB)))
|
(void**) &mDB)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mResourceMgr)))
|
(nsISupports**) &mRDFService)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1087,8 +1087,8 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
|
||||||
if (! mDB)
|
if (! mDB)
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
NS_ASSERTION(mResourceMgr, "not initialized");
|
NS_ASSERTION(mRDFService, "not initialized");
|
||||||
if (! mResourceMgr)
|
if (! mRDFService)
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1105,7 +1105,7 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
|
||||||
while (NS_SUCCEEDED(rv = properties->Advance())) {
|
while (NS_SUCCEEDED(rv = properties->Advance())) {
|
||||||
nsIRDFResource* property = nsnull;
|
nsIRDFResource* property = nsnull;
|
||||||
|
|
||||||
if (NS_FAILED(rv = properties->GetPredicate(&property)))
|
if (NS_FAILED(rv = properties->GetValue((nsIRDFNode**)&property)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const char* s;
|
const char* s;
|
||||||
|
@ -1126,7 +1126,7 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
|
||||||
|
|
||||||
while (NS_SUCCEEDED(rv = assertions->Advance())) {
|
while (NS_SUCCEEDED(rv = assertions->Advance())) {
|
||||||
nsIRDFNode* value;
|
nsIRDFNode* value;
|
||||||
if (NS_SUCCEEDED(rv = assertions->GetObject(&value))) {
|
if (NS_SUCCEEDED(rv = assertions->GetValue((nsIRDFNode**)&value))) {
|
||||||
// At this point, the specific nsRDFDocument
|
// At this point, the specific nsRDFDocument
|
||||||
// implementations will create an appropriate child
|
// implementations will create an appropriate child
|
||||||
// element (or elements).
|
// element (or elements).
|
||||||
|
@ -1230,7 +1230,7 @@ nsRDFDocument::IsTreeProperty(const nsIRDFResource* property) const
|
||||||
const char* p;
|
const char* p;
|
||||||
property->GetValue(&p);
|
property->GetValue(&p);
|
||||||
nsAutoString s(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")) {
|
s.Equals("http://home.netscape.com/NC-rdf#Folder")) {
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class nsIParser;
|
||||||
class nsISupportsArray;
|
class nsISupportsArray;
|
||||||
class nsINameSpaceManager;
|
class nsINameSpaceManager;
|
||||||
class nsIRDFNode;
|
class nsIRDFNode;
|
||||||
|
class nsIRDFService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An NGLayout document context for displaying an RDF graph.
|
* An NGLayout document context for displaying an RDF graph.
|
||||||
|
@ -234,7 +235,7 @@ protected:
|
||||||
nsIStyleSheet* mAttrStyleSheet;
|
nsIStyleSheet* mAttrStyleSheet;
|
||||||
nsIParser* mParser;
|
nsIParser* mParser;
|
||||||
nsIRDFDataBase* mDB;
|
nsIRDFDataBase* mDB;
|
||||||
nsIRDFResourceManager* mResourceMgr;
|
nsIRDFService* mRDFService;
|
||||||
nsISupportsArray* mTreeProperties;
|
nsISupportsArray* mTreeProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "nsIRDFContent.h"
|
#include "nsIRDFContent.h"
|
||||||
#include "nsIRDFDocument.h"
|
#include "nsIRDFDocument.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsIWebShell.h"
|
#include "nsIWebShell.h"
|
||||||
#include "nsLayoutCID.h"
|
#include "nsLayoutCID.h"
|
||||||
|
@ -399,7 +399,7 @@ nsRDFDocumentContentSink::OpenObject(const nsIParserNode& aNode)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsIRDFResource* resource;
|
nsIRDFResource* resource;
|
||||||
if (NS_FAILED(rv = mResourceMgr->GetUnicodeResource(uri, &resource)))
|
if (NS_FAILED(rv = mRDFService->GetUnicodeResource(uri, &resource)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsIRDFDocument* rdfDoc;
|
nsIRDFDocument* rdfDoc;
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
#include "nsIRDFDataBase.h"
|
#include "nsIRDFDataBase.h"
|
||||||
#include "nsIRDFDocument.h"
|
#include "nsIRDFDocument.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsRDFCID.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(kIRDFContentIID, NS_IRDFCONTENT_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_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(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_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)
|
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
// XXX I'm not sure if we should support properties as attributes
|
// XXX I'm not sure if we should support properties as attributes
|
||||||
// or not...
|
// or not...
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* mgr = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &mgr)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ done:
|
||||||
NS_IF_RELEASE(property);
|
NS_IF_RELEASE(property);
|
||||||
NS_IF_RELEASE(value);
|
NS_IF_RELEASE(value);
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
|
||||||
|
|
||||||
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -1007,9 +1007,9 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
|
||||||
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
// XXX I'm not sure if we should support attributes or not...
|
// XXX I'm not sure if we should support attributes or not...
|
||||||
|
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* mgr = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &mgr)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
@ -1050,7 +1050,7 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
|
||||||
done:
|
done:
|
||||||
NS_IF_RELEASE(properties);
|
NS_IF_RELEASE(properties);
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
|
@ -1293,14 +1293,14 @@ nsRDFElement::SetResource(const nsString& aURI)
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* service = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &service)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
rv = mgr->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
|
rv = service->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, service);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1370,22 +1370,22 @@ nsRDFElement::SetProperty(const nsString& aPropertyURI, const nsString& aValue)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* service = nsnull;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &service)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsIRDFResource* property = nsnull;
|
nsIRDFResource* property = nsnull;
|
||||||
nsIRDFLiteral* value = nsnull;
|
nsIRDFLiteral* value = nsnull;
|
||||||
nsIRDFDataBase* db = nsnull;
|
nsIRDFDataBase* db = nsnull;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(aPropertyURI, &property)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(aPropertyURI, &property)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
// XXX assume it's a literal?
|
// XXX assume it's a literal?
|
||||||
if (NS_FAILED(rv = mgr->GetLiteral(aValue, &value)))
|
if (NS_FAILED(rv = service->GetLiteral(aValue, &value)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
|
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
|
||||||
|
@ -1397,7 +1397,7 @@ done:
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
NS_IF_RELEASE(value);
|
NS_IF_RELEASE(value);
|
||||||
NS_IF_RELEASE(property);
|
NS_IF_RELEASE(property);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, service);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "nsIRDFCursor.h"
|
#include "nsIRDFCursor.h"
|
||||||
#include "nsIRDFDataBase.h"
|
#include "nsIRDFDataBase.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
|
@ -175,7 +175,7 @@ RDFHTMLDocumentImpl::AddChild(nsIRDFContent* parent,
|
||||||
|
|
||||||
nsIRDFResource* valueResource;
|
nsIRDFResource* valueResource;
|
||||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &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);
|
rv = AddTreeChild(parent, tag, property, valueResource);
|
||||||
NS_RELEASE(valueResource);
|
NS_RELEASE(valueResource);
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -32,25 +32,19 @@ public:
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewRDFSimpleContentSink(nsIRDFContentSink** aResult,
|
NS_NewRDFSimpleContentSink(nsIRDFContentSink** aResult)
|
||||||
nsIURL* aURL,
|
|
||||||
nsINameSpaceManager* aNameSpaceManager)
|
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aResult, "null ptr");
|
NS_PRECONDITION(aResult, "null ptr");
|
||||||
if (! aResult)
|
if (! aResult)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsRDFSimpleContentSink* it;
|
nsRDFSimpleContentSink* sink = new nsRDFSimpleContentSink();
|
||||||
NS_NEWXPCOM(it, nsRDFSimpleContentSink);
|
if (! sink)
|
||||||
if (! it)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
nsresult rv = it->Init(aURL, aNameSpaceManager);
|
*aResult = sink;
|
||||||
if (NS_FAILED(rv)) {
|
NS_ADDREF(sink);
|
||||||
delete it;
|
return NS_OK;
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
return it->QueryInterface(kIRDFContentSinkIID, (void **)aResult);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "nsIRDFCursor.h"
|
#include "nsIRDFCursor.h"
|
||||||
#include "nsIRDFDataBase.h"
|
#include "nsIRDFDataBase.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
|
@ -354,10 +354,10 @@ RDFTreeDocumentImpl::AddColumnsFromContainer(nsIContent* parent,
|
||||||
nsIRDFResource* NC_Title = nsnull;
|
nsIRDFResource* NC_Title = nsnull;
|
||||||
nsIRDFAssertionCursor* cursor = 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;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mResourceMgr->GetResource(kURINC_Title, &NC_Title)))
|
if (NS_FAILED(rv = mRDFService->GetResource(kURINC_Title, &NC_Title)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = NS_NewContainerCursor(mDB, columns, &cursor)))
|
if (NS_FAILED(rv = NS_NewContainerCursor(mDB, columns, &cursor)))
|
||||||
|
@ -495,7 +495,7 @@ RDFTreeDocumentImpl::AddColumns(nsIContent* parent,
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
if (rdf_IsContainer(mResourceMgr, mDB, columns)) {
|
if (rdf_IsContainer(mRDFService, mDB, columns)) {
|
||||||
rv = AddColumnsFromContainer(parent, columns);
|
rv = AddColumnsFromContainer(parent, columns);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -568,7 +568,7 @@ RDFTreeDocumentImpl::AddChild(nsIRDFContent* parent,
|
||||||
NS_RELEASE(resource);
|
NS_RELEASE(resource);
|
||||||
return rv;
|
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);
|
rv = AddTreeChild(parent, property, resource);
|
||||||
|
|
||||||
NS_RELEASE(resource);
|
NS_RELEASE(resource);
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
#include "nsIRDFDataBase.h"
|
#include "nsIRDFDataBase.h"
|
||||||
#include "nsIRDFDocument.h"
|
#include "nsIRDFDocument.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsRDFCID.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(kIRDFContentIID, NS_IRDFCONTENT_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_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(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
static NS_DEFINE_IID(kIXMLContentIID, NS_IXMLCONTENT_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)
|
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
// XXX I'm not sure if we should support properties as attributes
|
// XXX I'm not sure if we should support properties as attributes
|
||||||
// or not...
|
// or not...
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* mgr = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &mgr)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ done:
|
||||||
NS_IF_RELEASE(property);
|
NS_IF_RELEASE(property);
|
||||||
NS_IF_RELEASE(value);
|
NS_IF_RELEASE(value);
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
|
||||||
|
|
||||||
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -1007,9 +1007,9 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
|
||||||
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#if defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
// XXX I'm not sure if we should support attributes or not...
|
// XXX I'm not sure if we should support attributes or not...
|
||||||
|
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* mgr = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &mgr)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
@ -1050,7 +1050,7 @@ nsRDFElement::GetAttributeNameAt(PRInt32 aIndex,
|
||||||
done:
|
done:
|
||||||
NS_IF_RELEASE(properties);
|
NS_IF_RELEASE(properties);
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
#endif // defined(CREATE_PROPERTIES_AS_ATTRIBUTES)
|
||||||
|
@ -1293,14 +1293,14 @@ nsRDFElement::SetResource(const nsString& aURI)
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* service = nsnull;
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &service)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
rv = mgr->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
|
rv = service->GetUnicodeResource(aURI, &mResource); // implicit AddRef()
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, service);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1370,22 +1370,22 @@ nsRDFElement::SetProperty(const nsString& aPropertyURI, const nsString& aValue)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* service = nsnull;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mgr)))
|
(nsISupports**) &service)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsIRDFResource* property = nsnull;
|
nsIRDFResource* property = nsnull;
|
||||||
nsIRDFLiteral* value = nsnull;
|
nsIRDFLiteral* value = nsnull;
|
||||||
nsIRDFDataBase* db = nsnull;
|
nsIRDFDataBase* db = nsnull;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mgr->GetUnicodeResource(aPropertyURI, &property)))
|
if (NS_FAILED(rv = service->GetUnicodeResource(aPropertyURI, &property)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
// XXX assume it's a literal?
|
// XXX assume it's a literal?
|
||||||
if (NS_FAILED(rv = mgr->GetLiteral(aValue, &value)))
|
if (NS_FAILED(rv = service->GetLiteral(aValue, &value)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
|
if (NS_FAILED(rv = mDocument->GetDataBase(db)))
|
||||||
|
@ -1397,7 +1397,7 @@ done:
|
||||||
NS_IF_RELEASE(db);
|
NS_IF_RELEASE(db);
|
||||||
NS_IF_RELEASE(value);
|
NS_IF_RELEASE(value);
|
||||||
NS_IF_RELEASE(property);
|
NS_IF_RELEASE(property);
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, service);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
nsIRDFMail.h
|
||||||
|
|
|
@ -25,6 +25,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||||
MODULE = rdf
|
MODULE = rdf
|
||||||
|
|
||||||
EXPORTS = \
|
EXPORTS = \
|
||||||
|
nsIRDFMail.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||||
|
|
|
@ -21,6 +21,7 @@ MODULE=rdf
|
||||||
DEPTH=..\..\..
|
DEPTH=..\..\..
|
||||||
|
|
||||||
EXPORTS = \
|
EXPORTS = \
|
||||||
|
nsIRDFMail.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
include <$(DEPTH)/config/rules.mak>
|
include <$(DEPTH)/config/rules.mak>
|
||||||
|
|
|
@ -28,6 +28,7 @@ LIBRARY_NAME = rdfdatasource_s
|
||||||
|
|
||||||
CPPSRCS = \
|
CPPSRCS = \
|
||||||
nsBookmarkDataSource.cpp \
|
nsBookmarkDataSource.cpp \
|
||||||
|
nsMailDataSource.cpp \
|
||||||
nsStreamDataSource.cpp \
|
nsStreamDataSource.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ LIBRARY_NAME=rdfdatasource_s
|
||||||
|
|
||||||
CPP_OBJS=\
|
CPP_OBJS=\
|
||||||
.\$(OBJDIR)\nsBookmarkDataSource.obj \
|
.\$(OBJDIR)\nsBookmarkDataSource.obj \
|
||||||
|
.\$(OBJDIR)\nsMailDataSource.obj \
|
||||||
.\$(OBJDIR)\nsStreamDataSource.obj \
|
.\$(OBJDIR)\nsStreamDataSource.obj \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsRDFCID.h"
|
#include "nsRDFCID.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
@ -29,15 +29,15 @@
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
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_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
|
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||||
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
|
|
||||||
static const char kURI_bookmarks[] = "rdf:bookmarks"; // XXX?
|
static const char kURI_bookmarks[] = "rdf:bookmarks"; // XXX?
|
||||||
|
|
||||||
#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
|
#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, BookmarkAddDate);
|
||||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Description);
|
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Description);
|
||||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder);
|
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder);
|
||||||
|
@ -88,7 +88,7 @@ protected:
|
||||||
eBookmarkParserState_InItemDescription
|
eBookmarkParserState_InItemDescription
|
||||||
};
|
};
|
||||||
|
|
||||||
nsIRDFResourceManager* mResourceMgr;
|
nsIRDFService* mRDFService;
|
||||||
nsIRDFDataSource* mDataSource;
|
nsIRDFDataSource* mDataSource;
|
||||||
nsVoidArray mStack;
|
nsVoidArray mStack;
|
||||||
nsIRDFResource* mLastItem;
|
nsIRDFResource* mLastItem;
|
||||||
|
@ -127,34 +127,34 @@ const char* BookmarkParser::kSeparatorString = "<HR>";
|
||||||
|
|
||||||
|
|
||||||
BookmarkParser::BookmarkParser(void)
|
BookmarkParser::BookmarkParser(void)
|
||||||
: mResourceMgr(nsnull), mDataSource(nsnull)
|
: mRDFService(nsnull), mDataSource(nsnull)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
kIRDFResourceManagerIID,
|
kIRDFServiceIID,
|
||||||
(nsISupports**) &mResourceMgr);
|
(nsISupports**) &mRDFService);
|
||||||
|
|
||||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarkParser::~BookmarkParser(void)
|
BookmarkParser::~BookmarkParser(void)
|
||||||
{
|
{
|
||||||
if (mResourceMgr)
|
if (mRDFService)
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mResourceMgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
BookmarkParser::Parse(PRFileDesc* file, nsIRDFDataSource* dataSource)
|
BookmarkParser::Parse(PRFileDesc* file, nsIRDFDataSource* dataSource)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(file && dataSource && mResourceMgr, "null ptr");
|
NS_PRECONDITION(file && dataSource && mRDFService, "null ptr");
|
||||||
if (! file)
|
if (! file)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
if (! dataSource)
|
if (! dataSource)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
if (! mResourceMgr)
|
if (! mRDFService)
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
// Initialize the parser for a run...
|
// Initialize the parser for a run...
|
||||||
|
@ -208,20 +208,20 @@ BookmarkParser::AddColumns(void)
|
||||||
const char* const* columnTitle = gColumnTitles;
|
const char* const* columnTitle = gColumnTitles;
|
||||||
const char* const* columnURI = gColumnURIs;
|
const char* const* columnURI = gColumnURIs;
|
||||||
|
|
||||||
if (NS_FAILED(rv = rdf_CreateAnonymousResource(mResourceMgr, &columns)))
|
if (NS_FAILED(rv = rdf_CreateAnonymousResource(mRDFService, &columns)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = rdf_MakeSeq(mResourceMgr, mDataSource, columns)))
|
if (NS_FAILED(rv = rdf_MakeSeq(mRDFService, mDataSource, columns)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
while (*columnTitle && *columnURI) {
|
while (*columnTitle && *columnURI) {
|
||||||
nsIRDFResource* column = nsnull;
|
nsIRDFResource* column = nsnull;
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv = rdf_CreateAnonymousResource(mResourceMgr, &column))) {
|
if (NS_SUCCEEDED(rv = rdf_CreateAnonymousResource(mRDFService, &column))) {
|
||||||
rdf_Assert(mResourceMgr, mDataSource, column, kURINC_Title, *columnTitle);
|
rdf_Assert(mRDFService, mDataSource, column, kURINC_Title, *columnTitle);
|
||||||
rdf_Assert(mResourceMgr, mDataSource, column, kURINC_Column, *columnURI);
|
rdf_Assert(mRDFService, mDataSource, column, kURINC_Column, *columnURI);
|
||||||
|
|
||||||
rdf_ContainerAddElement(mResourceMgr, mDataSource, columns, column);
|
rdf_ContainerAddElement(mRDFService, mDataSource, columns, column);
|
||||||
NS_IF_RELEASE(column);
|
NS_IF_RELEASE(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ BookmarkParser::AddColumns(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rdf_Assert(mResourceMgr, mDataSource, kURI_bookmarks, kURINC_Columns, columns);
|
rdf_Assert(mRDFService, mDataSource, kURI_bookmarks, kURINC_Columns, columns);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
NS_IF_RELEASE(columns);
|
NS_IF_RELEASE(columns);
|
||||||
|
@ -284,15 +284,15 @@ BookmarkParser::NextToken(void)
|
||||||
folderURI.Append('#');
|
folderURI.Append('#');
|
||||||
folderURI.Append(++mCounter, 10);
|
folderURI.Append(++mCounter, 10);
|
||||||
|
|
||||||
if (NS_FAILED(mResourceMgr->GetUnicodeResource(folderURI, &folder)))
|
if (NS_FAILED(mRDFService->GetUnicodeResource(folderURI, &folder)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsIRDFResource* parent = (nsIRDFResource*) mStack[mStack.Count() - 1];
|
nsIRDFResource* parent = (nsIRDFResource*) mStack[mStack.Count() - 1];
|
||||||
rdf_Assert(mResourceMgr, mDataSource, parent, kURINC_Folder, folder);
|
rdf_Assert(mRDFService, mDataSource, parent, kURINC_Folder, folder);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// it's the root
|
// it's the root
|
||||||
if (NS_FAILED(mResourceMgr->GetResource(kURI_bookmarks, &folder)))
|
if (NS_FAILED(mRDFService->GetResource(kURI_bookmarks, &folder)))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,21 +308,21 @@ BookmarkParser::NextToken(void)
|
||||||
//NS_RELEASE(folder);
|
//NS_RELEASE(folder);
|
||||||
|
|
||||||
if (mState != eBookmarkParserState_InTitle)
|
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)
|
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) {
|
else if (mState == eBookmarkParserState_InItemTitle) {
|
||||||
PR_ASSERT(mLastItem);
|
PR_ASSERT(mLastItem);
|
||||||
if (! mLastItem)
|
if (! mLastItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rdf_Assert(mResourceMgr, mDataSource, mLastItem, kURINC_Name, mLine);
|
rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Name, mLine);
|
||||||
NS_IF_RELEASE(mLastItem);
|
NS_IF_RELEASE(mLastItem);
|
||||||
}
|
}
|
||||||
else if (mState == eBookmarkParserState_InItemDescription) {
|
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)) {
|
(mLine.Find(kBRString) == 0)) {
|
||||||
// XXX in the original bmk2rdf.c, we only added the
|
// XXX in the original bmk2rdf.c, we only added the
|
||||||
// description in the case that it wasn't set already...why?
|
// 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 {
|
else {
|
||||||
mState = eBookmarkParserState_Initial;
|
mState = eBookmarkParserState_Initial;
|
||||||
|
@ -418,7 +418,7 @@ BookmarkParser::CreateBookmark(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsIRDFResource* bookmark;
|
nsIRDFResource* bookmark;
|
||||||
if (NS_FAILED(mResourceMgr->GetUnicodeResource(values[eBmkAttribute_URL], &bookmark)))
|
if (NS_FAILED(mRDFService->GetUnicodeResource(values[eBmkAttribute_URL], &bookmark)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (! mStack.Count())
|
if (! mStack.Count())
|
||||||
|
@ -428,7 +428,7 @@ BookmarkParser::CreateBookmark(void)
|
||||||
if (! parent)
|
if (! parent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rdf_Assert(mResourceMgr, mDataSource, parent, kURINC_Bookmark, bookmark);
|
rdf_Assert(mRDFService, mDataSource, parent, kURINC_child, bookmark);
|
||||||
|
|
||||||
if (values[eBmkAttribute_AddDate].Length() > 0)
|
if (values[eBmkAttribute_AddDate].Length() > 0)
|
||||||
AssertTime(bookmark, kURINC_BookmarkAddDate, values[eBmkAttribute_AddDate]);
|
AssertTime(bookmark, kURINC_BookmarkAddDate, values[eBmkAttribute_AddDate]);
|
||||||
|
@ -453,7 +453,7 @@ BookmarkParser::AssertTime(nsIRDFResource* object,
|
||||||
const nsString& time)
|
const nsString& time)
|
||||||
{
|
{
|
||||||
// XXX
|
// 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
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
// nsIRDFDataSource
|
// nsIRDFDataSource
|
||||||
NS_IMETHOD Init(const char* uri) {
|
NS_IMETHOD Init(const char* uri);
|
||||||
return mInner->Init(uri);
|
|
||||||
|
NS_IMETHOD GetURI(const char* *uri) const {
|
||||||
|
return mInner->GetURI(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||||
|
@ -566,17 +568,6 @@ BookmarkDataSourceImpl::BookmarkDataSourceImpl(void)
|
||||||
// XXX rvg there should be only one instance of this class.
|
// XXX rvg there should be only one instance of this class.
|
||||||
// this is actually true of all datasources.
|
// this is actually true of all datasources.
|
||||||
NS_INIT_REFCNT();
|
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)
|
BookmarkDataSourceImpl::~BookmarkDataSourceImpl(void)
|
||||||
|
@ -587,6 +578,25 @@ BookmarkDataSourceImpl::~BookmarkDataSourceImpl(void)
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(BookmarkDataSourceImpl, kIRDFDataSourceIID);
|
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
|
NS_IMETHODIMP
|
||||||
BookmarkDataSourceImpl::Flush(void)
|
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 "nsIDTD.h"
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
|
#include "nsIOutputStream.h"
|
||||||
#include "nsIParser.h"
|
#include "nsIParser.h"
|
||||||
#include "nsIRDFDataSource.h"
|
|
||||||
#include "nsIRDFContentSink.h"
|
#include "nsIRDFContentSink.h"
|
||||||
#include "nsIRDFCursor.h"
|
#include "nsIRDFCursor.h"
|
||||||
|
#include "nsIRDFDataSource.h"
|
||||||
|
#include "nsIRDFXMLSource.h"
|
||||||
#include "nsIStreamListener.h"
|
#include "nsIStreamListener.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
|
#include "nsLayoutCID.h" // for NS_NAMESPACEMANAGER_CID.
|
||||||
#include "nsParserCIID.h"
|
#include "nsParserCIID.h"
|
||||||
#include "nsRDFCID.h"
|
#include "nsRDFCID.h"
|
||||||
|
#include "plstr.h"
|
||||||
|
#include "prio.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
|
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
|
||||||
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||||
static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
|
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
||||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_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(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(kRDFSimpleContentSinkCID, NS_RDFSIMPLECONTENTSINK_CID);
|
||||||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_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:
|
protected:
|
||||||
nsIURL* mURL;
|
|
||||||
nsIRDFDataSource* mInner;
|
nsIRDFDataSource* mInner;
|
||||||
|
PRBool mIsWritable;
|
||||||
|
PRBool mIsDirty;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StreamDataSourceImpl(void);
|
StreamDataSourceImpl(void);
|
||||||
|
@ -64,6 +136,10 @@ public:
|
||||||
// nsIRDFDataSource
|
// nsIRDFDataSource
|
||||||
NS_IMETHOD Init(const char* uri);
|
NS_IMETHOD Init(const char* uri);
|
||||||
|
|
||||||
|
NS_IMETHOD GetURI(const char* *uri) const {
|
||||||
|
return mInner->GetURI(uri);
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||||
nsIRDFNode* target,
|
nsIRDFNode* target,
|
||||||
PRBool tv,
|
PRBool tv,
|
||||||
|
@ -95,15 +171,11 @@ public:
|
||||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target,
|
nsIRDFNode* target,
|
||||||
PRBool tv) {
|
PRBool tv);
|
||||||
return mInner->Assert(source, property, target, tv);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
nsIRDFNode* target) {
|
nsIRDFNode* target);
|
||||||
return mInner->Unassert(source, property, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||||
nsIRDFResource* property,
|
nsIRDFResource* property,
|
||||||
|
@ -132,6 +204,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHOD Flush(void);
|
NS_IMETHOD Flush(void);
|
||||||
|
|
||||||
|
// nsIRDFXMLSource interface
|
||||||
|
NS_IMETHOD Serialize(nsIOutputStream* aStream);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,35 +214,80 @@ public:
|
||||||
|
|
||||||
|
|
||||||
StreamDataSourceImpl::StreamDataSourceImpl(void)
|
StreamDataSourceImpl::StreamDataSourceImpl(void)
|
||||||
: mURL(nsnull)
|
: mIsWritable(PR_FALSE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StreamDataSourceImpl::~StreamDataSourceImpl(void)
|
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
|
NS_IMETHODIMP
|
||||||
StreamDataSourceImpl::Init(const char* uri)
|
StreamDataSourceImpl::Init(const char* uri)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
if (NS_FAILED(rv = NS_NewURL(&mURL, uri)))
|
// XXX this is a hack: any "file:" URI is considered writable. All
|
||||||
return rv;
|
// others are considered read-only.
|
||||||
|
if (PL_strncmp(uri, kFileURIPrefix, kFileURIPrefixLen) == 0)
|
||||||
|
mIsWritable = PR_TRUE;
|
||||||
|
|
||||||
nsINameSpaceManager* ns = nsnull;
|
nsINameSpaceManager* ns = nsnull;
|
||||||
nsIRDFContentSink* sink = nsnull;
|
nsIRDFContentSink* sink = nsnull;
|
||||||
nsIParser* parser = nsnull;
|
nsIParser* parser = nsnull;
|
||||||
nsIDTD* dtd = nsnull;
|
nsIDTD* dtd = nsnull;
|
||||||
nsIStreamListener* lsnr = nsnull;
|
nsIStreamListener* lsnr = nsnull;
|
||||||
|
nsIURL* url = nsnull;
|
||||||
|
|
||||||
// XXX Get a namespace manager *here*
|
if (NS_FAILED(rv = NS_NewURL(&url, uri)))
|
||||||
PR_ASSERT(0);
|
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,
|
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFSimpleContentSinkCID,
|
||||||
nsnull,
|
nsnull,
|
||||||
|
@ -175,10 +295,12 @@ StreamDataSourceImpl::Init(const char* uri)
|
||||||
(void**) &sink)))
|
(void**) &sink)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = sink->Init(mURL, ns)))
|
if (NS_FAILED(sink->Init(url, ns)))
|
||||||
goto done;
|
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;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kParserCID,
|
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)))
|
if (NS_FAILED(rv = parser->QueryInterface(kIStreamListenerIID, (void**) &lsnr)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
// XXX This _can't_ be all I need to do -- how do I start the parser?
|
if (NS_FAILED(parser->Parse(url)))
|
||||||
if (NS_FAILED(parser->Parse(mURL)))
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(NS_OpenURL(mURL, lsnr)))
|
if (NS_FAILED(NS_OpenURL(url, lsnr)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -212,6 +333,40 @@ done:
|
||||||
NS_IF_RELEASE(dtd);
|
NS_IF_RELEASE(dtd);
|
||||||
NS_IF_RELEASE(parser);
|
NS_IF_RELEASE(parser);
|
||||||
NS_IF_RELEASE(sink);
|
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;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,11 +374,38 @@ done:
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
StreamDataSourceImpl::Flush(void)
|
StreamDataSourceImpl::Flush(void)
|
||||||
{
|
{
|
||||||
// XXX walk through all the resources, writing <RDF:Description>
|
if (!mIsWritable || !mIsDirty)
|
||||||
// elements with properties for each.
|
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;
|
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
|
nsresult
|
||||||
|
@ -237,3 +419,6 @@ NS_NewRDFStreamDataSource(nsIRDFDataSource** result)
|
||||||
NS_ADDREF(*result);
|
NS_ADDREF(*result);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
Двоичные данные
rdf/macbuild/rdf.mcp
Двоичные данные
rdf/macbuild/rdf.mcp
Двоичный файл не отображается.
|
@ -1,9 +1,9 @@
|
||||||
# target: rdf.shlb
|
# target: rdf.shlb
|
||||||
mozilla/rdf/base/src/nsContainerCursor.cpp
|
mozilla/rdf/base/src/nsContainerCursor.cpp
|
||||||
|
mozilla/rdf/base/src/nsDataBase.cpp
|
||||||
mozilla/rdf/base/src/nsEmptyCursor.cpp
|
mozilla/rdf/base/src/nsEmptyCursor.cpp
|
||||||
mozilla/rdf/base/src/nsMemoryDataSource.cpp
|
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
|
||||||
mozilla/rdf/base/src/nsRDFResourceManager.cpp
|
mozilla/rdf/base/src/nsRDFService.cpp
|
||||||
mozilla/rdf/base/src/nsSimpleDataBase.cpp
|
|
||||||
mozilla/rdf/base/src/rdfutil.cpp
|
mozilla/rdf/base/src/rdfutil.cpp
|
||||||
mozilla/rdf/build/nsRDFFactory.cpp
|
mozilla/rdf/build/nsRDFFactory.cpp
|
||||||
mozilla/rdf/content/src/nsRDFContentSink.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/nsRDFSimpleContentSink.cpp
|
||||||
mozilla/rdf/content/src/nsRDFTreeDocument.cpp
|
mozilla/rdf/content/src/nsRDFTreeDocument.cpp
|
||||||
mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
|
mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
|
||||||
|
mozilla/rdf/datasource/src/nsMailDataSource.cpp
|
||||||
mozilla/rdf/datasource/src/nsStreamDataSource.cpp
|
mozilla/rdf/datasource/src/nsStreamDataSource.cpp
|
||||||
|
|
|
@ -16,16 +16,19 @@
|
||||||
* Reserved.
|
* Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <io.h>
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsIInputStream.h"
|
#include "nsIInputStream.h"
|
||||||
#include "nsINetService.h"
|
#include "nsINetService.h"
|
||||||
#include "nsINetService.h"
|
#include "nsINetService.h"
|
||||||
|
#include "nsIOutputStream.h"
|
||||||
#include "nsIPostToServer.h"
|
#include "nsIPostToServer.h"
|
||||||
#include "nsIRDFDataBase.h"
|
#include "nsIRDFDataBase.h"
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFDocument.h"
|
#include "nsIRDFDocument.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
|
#include "nsIRDFXMLSource.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIStreamListener.h"
|
#include "nsIStreamListener.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
|
@ -58,9 +61,10 @@ static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||||
// rdf
|
// rdf
|
||||||
static NS_DEFINE_CID(kRDFBookMarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
static NS_DEFINE_CID(kRDFBookMarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
||||||
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
|
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
|
||||||
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
|
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||||
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_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(kRDFStreamDataSourceCID, NS_RDFSTREAMDATASOURCE_CID);
|
||||||
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
|
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
|
||||||
|
|
||||||
|
@ -76,8 +80,10 @@ static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||||
// IIDs
|
// IIDs
|
||||||
|
|
||||||
//NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID);
|
//NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID);
|
||||||
|
NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||||
NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_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
|
static nsresult
|
||||||
SetupRegistry(void)
|
SetupRegistry(void)
|
||||||
|
@ -86,9 +92,10 @@ SetupRegistry(void)
|
||||||
|
|
||||||
nsRepository::RegisterFactory(kRDFBookMarkDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
|
nsRepository::RegisterFactory(kRDFBookMarkDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
|
||||||
nsRepository::RegisterFactory(kRDFHTMLDocumentCID, 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(kRDFInMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
|
||||||
nsRepository::RegisterFactory(kRDFResourceManagerCID, RDF_DLL, PR_FALSE, PR_FALSE);
|
nsRepository::RegisterFactory(kRDFServiceCID, RDF_DLL, PR_FALSE, PR_FALSE);
|
||||||
nsRepository::RegisterFactory(kRDFSimpleDataBaseCID, 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(kRDFStreamDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
|
||||||
nsRepository::RegisterFactory(kRDFTreeDocumentCID, 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
|
int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
|
@ -118,6 +153,8 @@ main(int argc, char** argv)
|
||||||
SetupRegistry();
|
SetupRegistry();
|
||||||
|
|
||||||
nsIRDFDataSource* ds = nsnull;
|
nsIRDFDataSource* ds = nsnull;
|
||||||
|
nsIRDFXMLSource* xmlSource = nsnull;
|
||||||
|
PRInt32 i;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFStreamDataSourceCID,
|
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFStreamDataSourceCID,
|
||||||
nsnull,
|
nsnull,
|
||||||
|
@ -128,9 +165,16 @@ main(int argc, char** argv)
|
||||||
if (NS_FAILED(rv = ds->Init(argv[1])))
|
if (NS_FAILED(rv = ds->Init(argv[1])))
|
||||||
goto done;
|
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);
|
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:
|
done:
|
||||||
|
|
|
@ -790,7 +790,7 @@ HandleTreeWindowEvent(nsGUIEvent *aEvent)
|
||||||
#include "nsIRDFDataSource.h"
|
#include "nsIRDFDataSource.h"
|
||||||
#include "nsIRDFDocument.h"
|
#include "nsIRDFDocument.h"
|
||||||
#include "nsIRDFNode.h"
|
#include "nsIRDFNode.h"
|
||||||
#include "nsIRDFResourceManager.h"
|
#include "nsIRDFService.h"
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
|
|
||||||
|
@ -798,28 +798,27 @@ static nsresult
|
||||||
rdf_CreateBookmarkDocument(nsIDocument*& result)
|
rdf_CreateBookmarkDocument(nsIDocument*& result)
|
||||||
{
|
{
|
||||||
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
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_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
|
||||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
||||||
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_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;
|
nsresult rv;
|
||||||
|
|
||||||
nsIRDFDataSource* ds = nsnull;
|
nsIRDFDataSource* ds = nsnull;
|
||||||
nsIRDFDataBase* db = nsnull;
|
nsIRDFDataBase* db = nsnull;
|
||||||
nsIRDFDocument* doc = nsnull;
|
nsIRDFDocument* doc = nsnull;
|
||||||
nsIRDFResourceManager* mgr = nsnull;
|
nsIRDFService* service = nsnull;
|
||||||
nsIRDFResource* root = nsnull;
|
nsIRDFResource* root = nsnull;
|
||||||
|
|
||||||
result = nsnull; // reasonable default
|
result = nsnull; // reasonable default
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFBookmarkDataSourceCID,
|
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||||
nsnull,
|
kIRDFServiceIID,
|
||||||
kIRDFDataSourceIID,
|
(nsISupports**) &service)))
|
||||||
(void**) &ds)))
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFTreeDocumentCID,
|
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)))
|
if (NS_FAILED(rv = doc->GetDataBase(db)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
if (NS_FAILED(rv = service->GetNamedDataSource("rdf:mail", &ds)))
|
||||||
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = db->AddDataSource(ds)))
|
if (NS_FAILED(rv = db->AddDataSource(ds)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFResourceManagerCID,
|
if (NS_FAILED(rv = service->GetResource("MailRoot", &root)))
|
||||||
kIRDFResourceManagerIID,
|
|
||||||
(nsISupports**) &mgr)))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
if (NS_FAILED(rv = mgr->GetResource("rdf:bookmarks", &root)))
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (NS_FAILED(rv = doc->SetRootResource(root)))
|
if (NS_FAILED(rv = doc->SetRootResource(root)))
|
||||||
|
@ -855,9 +852,9 @@ static NS_DEFINE_IID(kIRDFResourceManagerIID, NS_IRDFRESOURCEMANAGER_IID);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
NS_IF_RELEASE(root);
|
NS_IF_RELEASE(root);
|
||||||
if (mgr) {
|
if (service) {
|
||||||
nsServiceManager::ReleaseService(kRDFResourceManagerCID, mgr);
|
nsServiceManager::ReleaseService(kRDFServiceCID, service);
|
||||||
mgr = nsnull;
|
service = nsnull;
|
||||||
}
|
}
|
||||||
NS_IF_RELEASE(doc);
|
NS_IF_RELEASE(doc);
|
||||||
NS_IF_RELEASE(db);
|
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(kNetServiceCID, NS_NETSERVICE_CID);
|
||||||
static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID);
|
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(kRDFBookMarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
||||||
|
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
|
||||||
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_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(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
|
||||||
|
|
||||||
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
|
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
|
||||||
|
@ -199,12 +199,12 @@ NS_SetupRegistry()
|
||||||
nsRepository::RegisterFactory(kIEditFactoryIID, EDITOR_DLL, PR_FALSE, PR_FALSE);
|
nsRepository::RegisterFactory(kIEditFactoryIID, EDITOR_DLL, PR_FALSE, PR_FALSE);
|
||||||
#endif //XP_MAC
|
#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(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(kCSSParserCID, LAYOUT_DLL, PR_FALSE, PR_FALSE);
|
||||||
nsRepository::RegisterFactory(kPresShellCID, 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(kNetServiceCID, NS_NETSERVICE_CID);
|
||||||
static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID);
|
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(kRDFBookMarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
||||||
|
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
|
||||||
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_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(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
|
||||||
|
|
||||||
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_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(kRDFHTMLDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
|
||||||
nsRepository::RegisterFactory(kRDFTreeDocumentCID, 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(kRDFInMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
|
||||||
nsRepository::RegisterFactory(kRDFResourceManagerCID, 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(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(kCSSParserCID, LAYOUT_DLL, PR_FALSE, PR_FALSE);
|
||||||
nsRepository::RegisterFactory(kPresShellCID, LAYOUT_DLL, PR_FALSE, PR_FALSE);
|
nsRepository::RegisterFactory(kPresShellCID, LAYOUT_DLL, PR_FALSE, PR_FALSE);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче