Bug 833098: Part 2 - Remove RDF service. r=hsivonen,Mossop,pike

MozReview-Commit-ID: 32Nl5McAFGJ

--HG--
extra : source : c00426f6bc7d1a10e5609ac9530eb315d64d9d85
extra : histedit_source : 4ab49fa208d0fc0ccd8e0b623644cc91d705d462
This commit is contained in:
Kris Maglione 2018-04-28 20:06:40 -07:00
Родитель 53c3d346c3
Коммит 3d65fdbc34
68 изменённых файлов: 0 добавлений и 13522 удалений

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

@ -20,7 +20,6 @@
#include "nsIEHistoryEnumerator.h"
#endif
#include "rdf.h"
#include "nsFeedSniffer.h"
#include "AboutRedirector.h"
#include "nsIAboutModule.h"

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

@ -1707,9 +1707,6 @@ addExternalIface('LoadInfo', nativeType='nsILoadInfo',
addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
addExternalIface('XULControllers', nativeType='nsIControllers', notflattened=True)
addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True)
addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
notflattened=True)
addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
addExternalIface('MozTreeView', nativeType='nsITreeView',
headerFile='nsITreeView.h', notflattened=True)
addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')

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

@ -29,8 +29,6 @@
#include "js/TracingAPI.h"
#include "js/TypeDecls.h"
class nsIRDFResource;
class nsIRDFService;
class nsPIWindowRoot;
class nsXULPrototypeElement;
#if 0 // XXXbe save me, scc (need NSCAP_FORWARD_DECL(nsXULPrototypeScript))
@ -254,11 +252,6 @@ protected:
// pseudo constants
static int32_t gRefCnt;
static nsIRDFService* gRDFService;
static nsIRDFResource* kNC_persist;
static nsIRDFResource* kNC_attribute;
static nsIRDFResource* kNC_value;
static LazyLogModule gXULLog;
nsresult

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

@ -21,7 +21,6 @@
#include "nsIScriptGlobalObject.h"
#include "nsPIDOMWindow.h"
#include "nsPIWindowRoot.h"
#include "nsRDFCID.h"
#include "nsXULCommandDispatcher.h"
#include "mozilla/Logging.h"
#include "nsContentUtils.h"

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

@ -34,7 +34,6 @@
#include "nsIScriptSecurityManager.h"
#include "nsLayoutCID.h"
#include "nsNetUtil.h"
#include "nsRDFCID.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsXULElement.h"

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

@ -19,11 +19,9 @@
#include "nsICollation.h"
#include "nsIDocument.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsXULContentUtils.h"
#include "nsLayoutCID.h"
#include "nsRDFCID.h"
#include "nsString.h"
#include "nsGkAtoms.h"
#include "XULDocument.h"
@ -33,30 +31,15 @@ using dom::XULDocument;
//------------------------------------------------------------------------
nsIRDFService* nsXULContentUtils::gRDF;
nsICollation *nsXULContentUtils::gCollation;
//------------------------------------------------------------------------
// Constructors n' stuff
//
nsresult
nsXULContentUtils::Init()
{
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
nsresult rv = CallGetService(kRDFServiceCID, &gRDF);
if (NS_FAILED(rv)) {
return rv;
}
return NS_OK;
}
nsresult
nsXULContentUtils::Finish()
{
NS_IF_RELEASE(gRDF);
NS_IF_RELEASE(gCollation);
return NS_OK;

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

@ -18,7 +18,6 @@ class nsAtom;
class nsICollation;
class nsIContent;
class nsIDocument;
class nsIRDFService;
namespace mozilla {
namespace dom {
@ -29,7 +28,6 @@ class Element;
class nsXULContentUtils
{
protected:
static nsIRDFService* gRDF;
static nsICollation *gCollation;
static bool gDisableXULCache;
@ -38,9 +36,6 @@ protected:
DisableXULCacheChangedCallback(const char* aPrefName, void* aClosure);
public:
static nsresult
Init();
static nsresult
Finish();
@ -53,12 +48,6 @@ public:
static nsresult
SetCommandUpdater(nsIDocument* aDocument, mozilla::dom::Element* aElement);
static nsIRDFService*
RDFService()
{
return gRDF;
}
static nsICollation*
GetCollation();
};

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

@ -49,7 +49,6 @@
#include "nsHTMLDNSPrefetch.h"
#include "nsHtml5Module.h"
#include "nsHTMLTags.h"
#include "nsIRDFContentSink.h" // for RDF atom initialization
#include "mozilla/dom/FallbackEncoding.h"
#include "nsFocusManager.h"
#include "nsListControlFrame.h"
@ -181,15 +180,6 @@ nsLayoutStatics::Initialize()
return rv;
}
#ifdef MOZ_XUL
rv = nsXULContentUtils::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsXULContentUtils");
return rv;
}
#endif
nsMathMLOperators::AddRefTable();
#ifdef DEBUG

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

@ -1,59 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPIDL_SOURCES += [
'nsIRDFCompositeDataSource.idl',
'nsIRDFContainer.idl',
'nsIRDFContainerUtils.idl',
'nsIRDFDataSource.idl',
'nsIRDFDelegateFactory.idl',
'nsIRDFInferDataSource.idl',
'nsIRDFInMemoryDataSource.idl',
'nsIRDFLiteral.idl',
'nsIRDFNode.idl',
'nsIRDFObserver.idl',
'nsIRDFPropagatableDataSource.idl',
'nsIRDFPurgeableDataSource.idl',
'nsIRDFRemoteDataSource.idl',
'nsIRDFResource.idl',
'nsIRDFService.idl',
'nsIRDFXMLParser.idl',
'nsIRDFXMLSerializer.idl',
'nsIRDFXMLSink.idl',
'nsIRDFXMLSource.idl',
'rdfIDataSource.idl',
'rdfITripleVisitor.idl',
]
XPIDL_MODULE = 'rdf'
EXPORTS += [
'nsIRDFContentSink.h',
'nsRDFResource.h',
'rdf.h',
]
UNIFIED_SOURCES += [
'nsCompositeDataSource.cpp',
'nsContainerEnumerator.cpp',
'nsDefaultResourceFactory.cpp',
'nsInMemoryDataSource.cpp',
'nsNameSpaceMap.cpp',
'nsRDFContainer.cpp',
'nsRDFContainerUtils.cpp',
'nsRDFContentSink.cpp',
'nsRDFResource.cpp',
'nsRDFService.cpp',
'nsRDFXMLDataSource.cpp',
'nsRDFXMLParser.cpp',
'nsRDFXMLSerializer.cpp',
'rdfutil.cpp',
]
FINAL_LIBRARY = 'xul'
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']

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

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

@ -1,262 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
A simple cursor that enumerates the elements of an RDF container
(RDF:Bag, RDF:Seq, or RDF:Alt).
Caveats
-------
1. This uses an implementation-specific detail to determine the
index of the last element in the container; specifically, the RDF
utilities maintain a counter attribute on the container that
holds the numeric value of the next value that is to be
assigned. So, this cursor will bust if you use it with a bag that
hasn't been created using the RDF utility routines.
*/
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsRDFCID.h"
#include "nsString.h"
#include "mozilla/Logging.h"
#include "rdf.h"
#include "rdfutil.h"
////////////////////////////////////////////////////////////////////////
class ContainerEnumeratorImpl : public nsISimpleEnumerator {
private:
// pseudo-constants
static nsrefcnt gRefCnt;
static nsIRDFResource* kRDF_nextVal;
static nsIRDFContainerUtils* gRDFC;
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsCOMPtr<nsIRDFResource> mContainer;
nsCOMPtr<nsIRDFResource> mOrdinalProperty;
nsCOMPtr<nsISimpleEnumerator> mCurrent;
nsCOMPtr<nsIRDFNode> mResult;
int32_t mNextIndex;
virtual ~ContainerEnumeratorImpl();
public:
ContainerEnumeratorImpl(nsIRDFDataSource* ds, nsIRDFResource* container);
nsresult Init();
NS_DECL_ISUPPORTS
NS_DECL_NSISIMPLEENUMERATOR
};
nsrefcnt ContainerEnumeratorImpl::gRefCnt;
nsIRDFResource* ContainerEnumeratorImpl::kRDF_nextVal;
nsIRDFContainerUtils* ContainerEnumeratorImpl::gRDFC;
ContainerEnumeratorImpl::ContainerEnumeratorImpl(nsIRDFDataSource* aDataSource,
nsIRDFResource* aContainer)
: mDataSource(aDataSource),
mContainer(aContainer),
mNextIndex(1)
{
}
nsresult
ContainerEnumeratorImpl::Init()
{
if (gRefCnt++ == 0) {
nsresult rv;
NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
nsCOMPtr<nsIRDFService> rdf = do_GetService(kRDFServiceCID);
NS_ASSERTION(rdf != nullptr, "unable to acquire resource manager");
if (! rdf)
return NS_ERROR_FAILURE;
rv = rdf->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"), &kRDF_nextVal);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
if (NS_FAILED(rv)) return rv;
NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
rv = CallGetService(kRDFContainerUtilsCID, &gRDFC);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
ContainerEnumeratorImpl::~ContainerEnumeratorImpl()
{
if (--gRefCnt == 0) {
NS_IF_RELEASE(kRDF_nextVal);
NS_IF_RELEASE(gRDFC);
}
}
NS_IMPL_ISUPPORTS(ContainerEnumeratorImpl, nsISimpleEnumerator)
NS_IMETHODIMP
ContainerEnumeratorImpl::HasMoreElements(bool* aResult)
{
NS_PRECONDITION(aResult != nullptr, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsresult rv;
// If we've already queued up a next value, then we know there are more elements.
if (mResult) {
*aResult = true;
return NS_OK;
}
// Otherwise, we need to grovel
// Figure out the upper bound so we'll know when we're done. Since it's
// possible that we're targeting a composite datasource, we'll need to
// "GetTargets()" and take the maximum value of "nextVal" to know the
// upper bound.
//
// Remember that since nextVal is the next index that we'd assign
// to an element in a container, it's *one more* than count of
// elements in the container.
int32_t max = 0;
nsCOMPtr<nsISimpleEnumerator> targets;
rv = mDataSource->GetTargets(mContainer, kRDF_nextVal, true, getter_AddRefs(targets));
if (NS_FAILED(rv)) return rv;
while (1) {
bool hasmore;
targets->HasMoreElements(&hasmore);
if (! hasmore)
break;
nsCOMPtr<nsISupports> isupports;
targets->GetNext(getter_AddRefs(isupports));
nsCOMPtr<nsIRDFLiteral> nextValLiteral = do_QueryInterface(isupports);
if (! nextValLiteral)
continue;
const char16_t *nextValStr;
nextValLiteral->GetValueConst(&nextValStr);
nsresult err;
int32_t nextVal = nsAutoString(nextValStr).ToInteger(&err);
if (nextVal > max)
max = nextVal;
}
// Now pre-fetch our next value into mResult.
while (mCurrent || mNextIndex < max) {
// If mCurrent has been depleted, then conjure up a new one
if (! mCurrent) {
rv = gRDFC->IndexToOrdinalResource(mNextIndex, getter_AddRefs(mOrdinalProperty));
if (NS_FAILED(rv)) return rv;
rv = mDataSource->GetTargets(mContainer, mOrdinalProperty, true, getter_AddRefs(mCurrent));
if (NS_FAILED(rv)) return rv;
++mNextIndex;
}
if (mCurrent) {
bool hasMore;
rv = mCurrent->HasMoreElements(&hasMore);
if (NS_FAILED(rv)) return rv;
// Is the current enumerator depleted? If so, iterate to
// the next index.
if (! hasMore) {
mCurrent = nullptr;
continue;
}
// "Peek" ahead and pull out the next target.
nsCOMPtr<nsISupports> result;
rv = mCurrent->GetNext(getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
mResult = do_QueryInterface(result, &rv);
if (NS_FAILED(rv)) return rv;
*aResult = true;
return NS_OK;
}
}
// If we get here, we ran out of elements. The cursor is empty.
*aResult = false;
return NS_OK;
}
NS_IMETHODIMP
ContainerEnumeratorImpl::GetNext(nsISupports** aResult)
{
nsresult rv;
bool hasMore;
rv = HasMoreElements(&hasMore);
if (NS_FAILED(rv)) return rv;
if (! hasMore)
return NS_ERROR_UNEXPECTED;
NS_ADDREF(*aResult = mResult);
mResult = nullptr;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsresult
NS_NewContainerEnumerator(nsIRDFDataSource* aDataSource,
nsIRDFResource* aContainer,
nsISimpleEnumerator** aResult)
{
NS_PRECONDITION(aDataSource != nullptr, "null ptr");
if (! aDataSource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aContainer != nullptr, "null ptr");
if (! aContainer)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResult != nullptr, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
ContainerEnumeratorImpl* result = new ContainerEnumeratorImpl(aDataSource, aContainer);
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);
nsresult rv = result->Init();
if (NS_FAILED(rv))
NS_RELEASE(result);
*aResult = result;
return rv;
}

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

@ -1,30 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
The default resource factory implementation. This resource factory
produces nsIRDFResource objects for any URI prefix that is not
covered by some other factory.
*/
#include "nsRDFResource.h"
nsresult
NS_NewDefaultResource(nsIRDFResource** aResult)
{
NS_PRECONDITION(aResult != nullptr, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsRDFResource* resource = new nsRDFResource();
if (! resource)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(resource);
*aResult = resource;
return NS_OK;
}

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

@ -1,68 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIRDFDataSource.idl"
interface nsISimpleEnumerator;
/**
* An nsIRDFCompositeDataSource composes individual data sources, providing
* the illusion of a single, coherent RDF graph.
*/
[scriptable, uuid(96343820-307C-11D2-BC15-00805F912FE7)]
interface nsIRDFCompositeDataSource : nsIRDFDataSource {
/**
*
* Set this value to <code>true</code> if the composite datasource
* may contains at least one datasource that has <em>negative</em>
* assertions. (This is the default.)
*
* Set this value to <code>false</code> if none of the datasources
* being composed contains a negative assertion. This allows the
* composite datasource to perform some query optimizations.
*
* By default, this value is <code>true</true>.
*/
attribute boolean allowNegativeAssertions;
/**
* Set to <code>true</code> if the composite datasource should
* take care to coalesce duplicate arcs when returning values from
* queries. (This is the default.)
*
* Set to <code>false</code> if the composite datasource shouldn't
* bother to check for duplicates. This allows the composite
* datasource to more efficiently answer queries.
*
* By default, this value is <code>true</code>.
*/
attribute boolean coalesceDuplicateArcs;
/**
* Add a datasource the the composite data source.
* @param aDataSource the datasource to add to composite
*/
void AddDataSource(in nsIRDFDataSource aDataSource);
/**
* Remove a datasource from the composite data source.
* @param aDataSource the datasource to remove from the composite
*/
void RemoveDataSource(in nsIRDFDataSource aDataSource);
/**
* Retrieve the datasources in the composite data source.
* @return an nsISimpleEnumerator that will enumerate each
* of the datasources in the composite
*/
nsISimpleEnumerator GetDataSources();
};
%{C++
extern nsresult
NS_NewRDFCompositeDataSource(nsIRDFCompositeDataSource** result);
%}

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

@ -1,94 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFDataSource.idl"
#include "nsIRDFResource.idl"
#include "nsIRDFNode.idl"
#include "nsISimpleEnumerator.idl"
// A wrapper for manipulating RDF containers
[scriptable, uuid(D4214E90-FB94-11D2-BDD8-00104BDE6048)]
interface nsIRDFContainer : nsISupports {
readonly attribute nsIRDFDataSource DataSource;
readonly attribute nsIRDFResource Resource;
/**
* Initialize the container wrapper to the specified resource
* using the specified datasource for context.
*/
void Init(in nsIRDFDataSource aDataSource, in nsIRDFResource aContainer);
/**
* Return the number of elements in the container. Note that this
* may not always be accurate due to aggregation.
*/
long GetCount();
/**
* Return an enumerator that can be used to enumerate the contents
* of the container in ascending order.
*/
nsISimpleEnumerator GetElements();
/**
* Append an element to the container, assigning it the next
* available ordinal.
*/
void AppendElement(in nsIRDFNode aElement);
/**
* Remove the first occurence of the specified element from the
* container. If aRenumber is 'true', then the underlying RDF graph
* will be 're-numbered' to account for the removal.
*/
void RemoveElement(in nsIRDFNode aElement, in boolean aRenumber);
/**
* Insert aElement at the specified index. If aRenumber is 'true', then
* the underlying RDF graph will be 're-numbered' to accomodate the new
* element.
*/
void InsertElementAt(in nsIRDFNode aElement, in long aIndex, in boolean aRenumber);
/**
* Remove the element at the specified index. If aRenumber is 'true', then
* the underlying RDF graph will be 're-numbered' to account for the
* removal.
*
* @return the element that was removed.
*/
nsIRDFNode RemoveElementAt(in long aIndex, in boolean aRenumber);
/**
* Determine the index of an element in the container.
*
* @return The index of the specified element in the container. If
* the element is not contained in the container, this function
* returns '-1'.
*/
long IndexOf(in nsIRDFNode aElement);
};
%{C++
nsresult
NS_NewRDFContainer(nsIRDFContainer** aResult);
nsresult
NS_NewRDFContainer(nsIRDFDataSource* aDataSource,
nsIRDFResource* aResource,
nsIRDFContainer** aResult);
/**
* Create a cursor on a container that enumerates its contents in
* order
*/
nsresult
NS_NewContainerEnumerator(nsIRDFDataSource* aDataSource,
nsIRDFResource* aContainer,
nsISimpleEnumerator** aResult);
%}

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

@ -1,82 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFContainer.idl"
#include "nsIRDFResource.idl"
// Container utilities
[scriptable, uuid(D4214E91-FB94-11D2-BDD8-00104BDE6048)]
interface nsIRDFContainerUtils : nsISupports {
/**
* Returns 'true' if the property is an RDF ordinal property.
*/
boolean IsOrdinalProperty(in nsIRDFResource aProperty);
/**
* Convert the specified index to an ordinal property.
*/
nsIRDFResource IndexToOrdinalResource(in long aIndex);
/**
* Convert the specified ordinal property into an index
*/
long OrdinalResourceToIndex(in nsIRDFResource aOrdinal);
/**
* Return 'true' if the specified resource is a container
*/
boolean IsContainer(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
/**
* Return 'true' if the specified resource is a container and it is empty
*/
boolean IsEmpty(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
/**
* Return 'true' if the specified resource is a bag
*/
boolean IsBag(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
/**
* Return 'true' if the specified resource is a sequence
*/
boolean IsSeq(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
/**
* Return 'true' if the specified resource is an alternation
*/
boolean IsAlt(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
/**
* Decorates the specified resource appropriately to make it
* usable as an empty bag in the specified data source.
*/
nsIRDFContainer MakeBag(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
/**
* Decorates the specified resource appropriately to make it
* usable as an empty sequence in the specified data source.
*/
nsIRDFContainer MakeSeq(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
/**
* Decorates the specified resource appropriately to make it
* usable as an empty alternation in the specified data source.
*/
nsIRDFContainer MakeAlt(in nsIRDFDataSource aDataSource, in nsIRDFResource aResource);
/**
* Retrieve the index of element in the container. Returns -1 if
* the element is not in the container.
*/
long indexOf(in nsIRDFDataSource aDataSource, in nsIRDFResource aContainer, in nsIRDFNode aElement);
};
%{C++
extern nsresult
NS_NewRDFContainerUtils(nsIRDFContainerUtils** aResult);
%}

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

@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
An RDF-specific content sink. The content sink is targeted by the
parser for building the RDF content model.
*/
#ifndef nsIRDFContentSink_h___
#define nsIRDFContentSink_h___
#include "nsIXMLContentSink.h"
class nsIRDFDataSource;
class nsIURI;
// {3a7459d7-d723-483c-aef0-404fc48e09b8}
#define NS_IRDFCONTENTSINK_IID \
{ 0x3a7459d7, 0xd723, 0x483c, { 0xae, 0xf0, 0x40, 0x4f, 0xc4, 0x8e, 0x09, 0xb8 } }
/**
* This interface represents a content sink for RDF files.
*/
class nsIRDFContentSink : public nsIXMLContentSink {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRDFCONTENTSINK_IID)
/**
* Initialize the content sink.
*/
NS_IMETHOD Init(nsIURI* aURL) = 0;
/**
* Set the content sink's RDF Data source
*/
NS_IMETHOD SetDataSource(nsIRDFDataSource* aDataSource) = 0;
/**
* Retrieve the content sink's RDF data source.
*/
NS_IMETHOD GetDataSource(nsIRDFDataSource*& rDataSource) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIRDFContentSink, NS_IRDFCONTENTSINK_IID)
/**
* This constructs a content sink that can be used without a
* document, say, to create a stand-alone in-memory graph.
*/
nsresult
NS_NewRDFContentSink(nsIRDFContentSink** aResult);
#endif // nsIRDFContentSink_h___

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

@ -1,181 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFResource.idl"
#include "nsIRDFNode.idl"
#include "nsISimpleEnumerator.idl"
#include "nsIRDFObserver.idl"
[scriptable, uuid(0F78DA58-8321-11d2-8EAC-00805F29F370)]
interface nsIRDFDataSource : nsISupports
{
/** The "URI" of the data source. This used by the RDF service's
* |GetDataSource()| method to cache datasources.
*/
readonly attribute ACString URI;
/** Find an RDF resource that points to a given node over the
* specified arc & truth value
*
* @throws NS_RDF_NO_VALUE if there is no source that leads
* to the target with the specified property.
*/
nsIRDFResource GetSource(in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue);
/**
* Find all RDF resources that point to a given node over the
* specified arc & truth value
*/
nsISimpleEnumerator GetSources(in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue);
/**
* Find a child of that is related to the source by the given arc
* arc and truth value
*
* @throws NS_RDF_NO_VALUE if there is no target accessible from the
* source via the specified property.
*/
nsIRDFNode GetTarget(in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in boolean aTruthValue);
/**
* Find all children of that are related to the source by the given arc
* arc and truth value.
*/
nsISimpleEnumerator GetTargets(in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in boolean aTruthValue);
/**
* Add an assertion to the graph.
*/
void Assert(in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue);
/**
* Remove an assertion from the graph.
*/
void Unassert(in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget);
/**
* Change an assertion from
*
* [aSource]--[aProperty]-->[aOldTarget]
*
* to
*
* [aSource]--[aProperty]-->[aNewTarget]
*/
void Change(in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aOldTarget,
in nsIRDFNode aNewTarget);
/**
* 'Move' an assertion from
*
* [aOldSource]--[aProperty]-->[aTarget]
*
* to
*
* [aNewSource]--[aProperty]-->[aTarget]
*/
void Move(in nsIRDFResource aOldSource,
in nsIRDFResource aNewSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget);
/**
* Query whether an assertion exists in this graph.
*/
boolean HasAssertion(in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue);
/**
* Add an observer to this data source. If the datasource
* supports observers, the datasource source should hold a strong
* reference to the observer.
*/
void AddObserver(in nsIRDFObserver aObserver);
/**
* Remove an observer from this data source.
*/
void RemoveObserver(in nsIRDFObserver aObserver);
/**
* Get a cursor to iterate over all the arcs that point into a node.
*/
nsISimpleEnumerator ArcLabelsIn(in nsIRDFNode aNode);
/**
* Get a cursor to iterate over all the arcs that originate in
* a resource.
*/
nsISimpleEnumerator ArcLabelsOut(in nsIRDFResource aSource);
/**
* Retrieve all of the resources that the data source currently
* refers to.
*/
nsISimpleEnumerator GetAllResources();
/**
* Returns whether a given command is enabled for a set of sources.
*/
boolean IsCommandEnabled(in nsISupports aSources,
in nsIRDFResource aCommand,
in nsISupports aArguments);
/**
* Perform the specified command on set of sources.
*/
void DoCommand(in nsISupports aSources,
in nsIRDFResource aCommand,
in nsISupports aArguments);
/**
* Returns the set of all commands defined for a given source.
*/
nsISimpleEnumerator GetAllCmds(in nsIRDFResource aSource);
/**
* Returns true if the specified node is pointed to by the specified arc.
* Equivalent to enumerating ArcLabelsIn and comparing for the specified arc.
*/
boolean hasArcIn(in nsIRDFNode aNode, in nsIRDFResource aArc);
/**
* Returns true if the specified node has the specified outward arc.
* Equivalent to enumerating ArcLabelsOut and comparing for the specified arc.
*/
boolean hasArcOut(in nsIRDFResource aSource, in nsIRDFResource aArc);
/**
* Notify observers that the datasource is about to send several
* notifications at once.
* This must be followed by calling endUpdateBatch(), otherwise
* viewers will get out of sync.
*/
void beginUpdateBatch();
/**
* Notify observers that the datasource has completed issuing
* a notification group.
*/
void endUpdateBatch();
};

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

@ -1,40 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
An interface used for runtime pseudo-aggregation of RDF delegate
objects.
*/
#include "nsrootidl.idl"
#include "nsISupports.idl"
interface nsIRDFResource;
/**
* This interface should be implemented by an XPCOM factory that
* is registered to handle "@mozilla.org/rdf/delegate-factory/[key]/[scheme];1"
* ContractIDs.
*
* The factory will be invoked to create delegate objects from
* nsIRDFResource::GetDelegate().
*/
[scriptable, uuid(A1B89470-A124-11d3-BE59-0020A6361667)]
interface nsIRDFDelegateFactory : nsISupports
{
/**
* Create a delegate for the specified RDF resource.
*
* The created delegate should forward AddRef() and Release()
* calls to the aOuter object.
*/
void CreateDelegate(in nsIRDFResource aOuter,
in string aKey,
in nsIIDRef aIID,
[retval, iid_is(aIID)] out nsQIResult aResult);
};

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

@ -1,14 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFResource.idl"
#include "nsIRDFNode.idl"
[scriptable, uuid(17C4E0AA-1DD2-11B2-8029-BF6F668DE500)]
interface nsIRDFInMemoryDataSource : nsISupports
{
void EnsureFastContainment(in nsIRDFResource aSource);
};

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

@ -1,28 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIRDFDataSource.idl"
/**
* An nsIRDFInferDataSource is implemented by a infer engine. This
* engine mimics assertions in addition to those in the baseDataSource
* according to a particular vocabulary.
* Infer engines have contract IDs in the form of
* "@mozilla.org/rdf/infer-datasource;1?engine="
*/
[scriptable, uuid(2b04860f-4017-40f6-8a57-784a1e35077a)]
interface nsIRDFInferDataSource : nsIRDFDataSource {
/**
*
* The wrapped datasource.
*
* The InferDataSource contains all arcs from the wrapped
* datasource plus those infered by the vocabulary implemented
* by the InferDataSource.
*/
attribute nsIRDFDataSource baseDataSource;
};

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

@ -1,68 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIRDFNode.idl"
%{C++
#include "nscore.h" // for char16_t
%}
[ptr] native const_octet_ptr(const uint8_t);
/**
* A literal node in the graph, whose value is a string.
*/
[scriptable, uuid(E0C493D2-9542-11d2-8EB8-00805F29F370)]
interface nsIRDFLiteral : nsIRDFNode {
/**
* The Unicode string value of the literal.
*/
readonly attribute wstring Value;
/**
* An unscriptable version used to avoid a string copy. Meant
* for use as a performance optimization.
*/
[noscript] void GetValueConst([shared] out wstring aConstValue);
};
/**
* A literal node in the graph, whose value is a date
*/
[scriptable, uuid(E13A24E1-C77A-11d2-80BE-006097B76B8E)]
interface nsIRDFDate : nsIRDFNode {
/**
* The date value of the literal
*/
readonly attribute PRTime Value;
};
/**
* A literal node in the graph, whose value is an integer
*/
[scriptable, uuid(E13A24E3-C77A-11d2-80BE-006097B76B8E)]
interface nsIRDFInt : nsIRDFNode {
/**
* The integer value of the literal
*/
readonly attribute long Value;
};
/**
* A literal node in the graph, whose value is arbitrary
* binary data.
*/
[scriptable, uuid(237f85a2-1dd2-11b2-94af-8122582fc45e)]
interface nsIRDFBlob : nsIRDFNode {
/**
* The binary data.
*/
[noscript] readonly attribute const_octet_ptr value;
/**
* The data's length.
*/
readonly attribute long length;
};

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

@ -1,15 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
// An nsIRDFNode object is an abstract placeholder for a node in the
// RDF data model. Its concreted implementations (e.g., nsIRDFResource
// or nsIRDFLiteral) are the actual objects that populate the graph.
[scriptable, uuid(0F78DA50-8321-11d2-8EAC-00805F29F370)]
interface nsIRDFNode : nsISupports {
// Determine if two nodes are identical
boolean EqualsNode(in nsIRDFNode aNode);
};

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

@ -1,94 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFResource.idl"
#include "nsIRDFNode.idl"
interface nsIRDFDataSource;
// An nsIRDFObserver object is an observer that will be notified
// when assertions are made or removed from a datasource
[scriptable, uuid(3CC75360-484A-11D2-BC16-00805F912FE7)]
interface nsIRDFObserver : nsISupports {
/**
* This method is called whenever a new assertion is made
* in the data source
* @param aDataSource the datasource that is issuing
* the notification.
* @param aSource the subject of the assertion
* @param aProperty the predicate of the assertion
* @param aTarget the object of the assertion
*/
void onAssert(in nsIRDFDataSource aDataSource,
in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget);
/**
* This method is called whenever an assertion is removed
* from the data source
* @param aDataSource the datasource that is issuing
* the notification.
* @param aSource the subject of the assertion
* @param aProperty the predicate of the assertion
* @param aTarget the object of the assertion
*/
void onUnassert(in nsIRDFDataSource aDataSource,
in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget);
/**
* This method is called when the object of an assertion
* changes from one value to another.
* @param aDataSource the datasource that is issuing
* the notification.
* @param aSource the subject of the assertion
* @param aProperty the predicate of the assertion
* @param aOldTarget the old object of the assertion
* @param aNewTarget the new object of the assertion
*/
void onChange(in nsIRDFDataSource aDataSource,
in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aOldTarget,
in nsIRDFNode aNewTarget);
/**
* This method is called when the subject of an assertion
* changes from one value to another.
* @param aDataSource the datasource that is issuing
* the notification.
* @param aOldSource the old subject of the assertion
* @param aNewSource the new subject of the assertion
* @param aProperty the predicate of the assertion
* @param aTarget the object of the assertion
*/
void onMove(in nsIRDFDataSource aDataSource,
in nsIRDFResource aOldSource,
in nsIRDFResource aNewSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget);
/**
* This method is called when a datasource is about to
* send several notifications at once. The observer can
* use this as a cue to optimize its behavior. The observer
* can expect the datasource to call endUpdateBatch() when
* the group of notifications has completed.
* @param aDataSource the datasource that is going to
* be issuing the notifications.
*/
void onBeginUpdateBatch(in nsIRDFDataSource aDataSource);
/**
* This method is called when a datasource has completed
* issuing a notification group.
* @param aDataSource the datasource that has finished
* issuing a group of notifications
*/
void onEndUpdateBatch(in nsIRDFDataSource aDataSource);
};

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

@ -1,27 +0,0 @@
/* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
/**
* An nsIRDFPropagatableDataSource provides an ability to suppress
* synchronization notifications.
*/
[scriptable, uuid(5a9b4770-9fcb-4307-a12e-4b6708e78b97)]
interface nsIRDFPropagatableDataSource: nsISupports {
/**
* Set this value to <code>true</code> to enable synchronization
* notifications.
*
* Set this value to <code>false</code> to disable synchronization
* notifications.
*
* By default, this value is <code>true</code>.
*/
attribute boolean propagateChanges;
};

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

@ -1,19 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFResource.idl"
#include "nsIRDFNode.idl"
[scriptable, uuid(951700F0-FED0-11D2-BDD9-00104BDE6048)]
interface nsIRDFPurgeableDataSource : nsISupports
{
boolean Mark(in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue);
void Sweep();
};

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

@ -1,44 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
/**
* A datasource that may load asynchronously
*/
[scriptable, uuid(1D297320-27F7-11d3-BE01-000064657374)]
interface nsIRDFRemoteDataSource : nsISupports
{
/**
* This value is <code>true</code> when the datasource has
* fully loaded itself.
*/
readonly attribute boolean loaded;
/**
* Specify the URI for the data source: this is the prefix
* that will be used to register the data source in the
* data source registry.
* @param aURI the URI to load
*/
void Init(in string aURI);
/**
* Refresh the remote datasource, re-loading its contents
* from the URI.
*
* @param aBlocking If <code>true</code>, the call will block
* until the datasource has completely reloaded.
*/
void Refresh(in boolean aBlocking);
/**
* Request that a data source write its contents out to
* permanent storage, if applicable.
*/
void Flush();
void FlushTo(in string aURI);
};

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

@ -1,81 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsrootidl.idl"
#include "nsIRDFNode.idl"
/**
* An nsIRDFResource is an object that has unique identity in the
* RDF data model. The object's identity is determined by its URI.
*/
[scriptable, uuid(fb9686a7-719a-49dc-9107-10dea5739341)]
interface nsIRDFResource : nsIRDFNode {
/**
* The single-byte string value of the resource.
* @note THIS IS OBSOLETE. C++ should use GetValueConst and script
* should use .valueUTF8
*/
readonly attribute string Value;
/**
* The UTF-8 URI of the resource.
*/
readonly attribute AUTF8String ValueUTF8;
/**
* An unscriptable version used to avoid a string copy. Meant
* for use as a performance optimization. The string is encoded
* in UTF-8.
*/
[noscript] void GetValueConst([shared] out string aConstValue);
/**
* This method is called by the nsIRDFService after constructing
* a resource object to initialize its URI. You would not normally
* call this method directly
*/
void Init(in string uri);
/**
* Determine if the resource has the given URI.
*/
boolean EqualsString(in string aURI);
/**
* Retrieve the "delegate" object for this resource. A resource
* may have several delegate objects, each of whose lifetimes is
* bound to the life of the resource object.
*
* This method will return the delegate for the given key after
* QueryInterface()-ing it to the requested IID.
*
* If no delegate exists for the specified key, this method will
* attempt to create one using the component manager. Specifically,
* it will combine aKey with the resource's URI scheme to produce
* a ContractID as follows:
*
* component:/rdf/delegate-factory/[key]/[scheme]
*
* This ContractID will be used to locate a factory using the
* FindFactory() method of nsIComponentManager. If the nsIFactory
* exists, it will be used to create a "delegate factory"; that
* is, an object that supports nsIRDFDelegateFactory. The delegate
* factory will be used to construct the delegate object.
*/
void GetDelegate(in string aKey, in nsIIDRef aIID,
[iid_is(aIID),retval] out nsQIResult aResult);
/**
* Force a delegate to be "unbound" from the resource.
*
* Normally, a delegate object's lifetime will be identical to
* that of the resource to which it is bound; this method allows a
* delegate to unlink itself from an RDF resource prematurely.
*/
void ReleaseDelegate(in string aKey);
};

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

@ -1,146 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFResource.idl"
#include "nsIRDFLiteral.idl"
#include "nsIRDFDataSource.idl"
/**
* The RDF service interface. This is a singleton object which should be
* obtained from the <code>nsServiceManager</code>.
*/
[scriptable, uuid(BFD05261-834C-11d2-8EAC-00805F29F370)]
interface nsIRDFService : nsISupports {
/**
* Construct an RDF resource from a single-byte URI. <code>nsIRDFService</code>
* caches resources that are in-use, so multiple calls to <code>GetResource()</code>
* for the same <code>uri</code> will return identical pointers. FindResource
* is used to find out whether there already exists a resource corresponding to that url.
*/
nsIRDFResource GetResource(in AUTF8String aURI);
/**
* Construct an RDF resource from a Unicode URI. This is provided
* as a convenience method, allowing automatic, in-line C++
* conversion from <code>nsString</code> objects. The <code>uri</code> will
* be converted to a single-byte representation internally.
*/
nsIRDFResource GetUnicodeResource(in AString aURI);
nsIRDFResource GetAnonymousResource();
/**
* Construct an RDF literal from a Unicode string.
*/
nsIRDFLiteral GetLiteral(in wstring aValue);
/**
* Construct an RDF literal from a PRTime.
*/
nsIRDFDate GetDateLiteral(in PRTime aValue);
/**
* Construct an RDF literal from an int.
*/
nsIRDFInt GetIntLiteral(in long aValue);
/**
* Construct an RDF literal from a data blob
*/
[noscript] nsIRDFBlob getBlobLiteral(in const_octet_ptr aValue, in long aLength);
boolean IsAnonymousResource(in nsIRDFResource aResource);
/**
* Registers a resource with the RDF system, making it unique w.r.t.
* GetResource.
*
* An implementation of nsIRDFResource should call this in its
* Init() method if it wishes the resource to be globally unique
* (which is usually the case).
*
* @note that the resource will <i>not</i> be ref-counted by the
* RDF service: the assumption is that the resource implementation
* will call nsIRDFService::UnregisterResource() when the last
* reference to the resource is released.
*
* @note that the nsIRDFService implementation may choose to
* maintain a reference to the resource's URI; therefore, the
* resource implementation should ensure that the resource's URI
* (accessible via nsIRDFResource::GetValue(const char* *aURI)) is
* valid before calling RegisterResource(). Furthermore, the
* resource implementation should ensure that this pointer
* <i>remains</i> valid for the lifetime of the resource. (The
* implementation of the resource cache in nsIRDFService uses the
* URI maintained "internally" in the resource as a key into the
* cache rather than copying the resource URI itself.)
*/
void RegisterResource(in nsIRDFResource aResource, in boolean aReplace);
/**
* 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 <code>const char*</code> URI.
*/
void UnregisterResource(in nsIRDFResource aResource);
/**
* Register a <i>named data source</i>. The RDF service will call
* <code>nsIRDFDataSource::GetURI()</code> to determine the URI under
* which to register the data source.
*
* @note that the data source will <i>not</i> be refcounted by the
* RDF service! The assumption is that an RDF data source
* registers with the service once it is initialized (via
* <code>nsIRDFDataSource::Init()</code>), and unregisters when the
* last reference to the data source is released.
*/
void RegisterDataSource(in nsIRDFDataSource aDataSource,
in boolean aReplace);
/**
* Unregister a <i>named data source</i>. The RDF service will call
* <code>nsIRDFDataSource::GetURI()</code> to determine the URI under which the
* data source was registered.
*/
void UnregisterDataSource(in nsIRDFDataSource aDataSource);
/**
* Get the <i>named data source</i> corresponding to the URI. If a data
* source has been registered via <code>RegisterDataSource()</code>, that
* data source will be returned.
*
* If no data source is currently
* registered for the specified URI, and a data source <i>constructor</i>
* function has been registered via <code>RegisterDatasourceConstructor()</code>,
* the RDF service will call the constructor to attempt to construct a
* new data source. If construction is successful, the data source will
* be initialized via <code>nsIRDFDataSource::Init()</code>.
*/
nsIRDFDataSource GetDataSource(in string aURI);
/**
* Same as GetDataSource, but if a remote/XML data source needs to be
* constructed, then this method will issue a <b>blocking</b> Refresh
* call on that data source.
*/
nsIRDFDataSource GetDataSourceBlocking(in string aURI);
};
%{C++
extern nsresult
NS_NewRDFService(nsIRDFService** result);
%}

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

@ -1,33 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFDataSource.idl"
#include "nsIStreamListener.idl"
#include "nsIURI.idl"
[scriptable, uuid(1831dd2e-1dd2-11b2-bdb3-86b7b50b70b5)]
interface nsIRDFXMLParser : nsISupports
{
/**
* Create a stream listener that can be used to asynchronously
* parse RDF/XML.
* @param aSink the RDF datasource the will receive the data
* @param aBaseURI the base URI used to resolve relative
* references in the RDF/XML
* @return an nsIStreamListener object to handle the data
*/
nsIStreamListener parseAsync(in nsIRDFDataSource aSink, in nsIURI aBaseURI);
/**
* Parse a string of RDF/XML
* @param aSink the RDF datasource that will receive the data
* @param aBaseURI the base URI used to resolve relative
* references in the RDF/XML
* @param aSource a UTF8 string containing RDF/XML data.
*/
void parseString(in nsIRDFDataSource aSink, in nsIURI aBaseURI, in AUTF8String aSource);
};

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

@ -1,31 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIRDFDataSource.idl"
%{C++
class nsAtom;
%}
[ptr] native nsAtomPtr(nsAtom);
[scriptable, uuid(8ae1fbf8-1dd2-11b2-bd21-d728069cca92)]
interface nsIRDFXMLSerializer : nsISupports
{
/**
* Initialize the serializer with the specified datasource.
* @param aDataSource the datasource from which data will be
* serialized
*/
void init(in nsIRDFDataSource aDataSource);
/**
* Add the specified namespace to the serializer.
* @param aPrefix the attribute namespace prefix
* @param aURI the namespace URI
*/
[noscript] void addNameSpace(in nsAtomPtr aPrefix, in DOMString aURI);
};

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

@ -1,133 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
Interfaces for the RDF/XML sink, which parses RDF/XML into
a graph representation.
*/
#include "nsISupports.idl"
%{C++
class nsAtom;
%}
[ptr] native nsAtomPtr(nsAtom);
// XXX Until these get scriptable. See nsIRDFXMLSink::AddNameSpace()
[ref] native nsStringRef(nsString);
%{C++
#include "nsStringFwd.h"
%}
interface nsIRDFXMLSink;
/**
* An observer that is notified as progress is made on the load
* of an RDF/XML document in an <code>nsIRDFXMLSink</code>.
*/
[scriptable, uuid(EB1A5D30-AB33-11D2-8EC6-00805F29F370)]
interface nsIRDFXMLSinkObserver : nsISupports
{
/**
* Called when the load begins.
* @param aSink the RDF/XML sink on which the load is beginning.
*/
void onBeginLoad(in nsIRDFXMLSink aSink);
/**
* Called when the load is suspended (e.g., for network quantization).
* @param aSink the RDF/XML sink that is being interrupted.
*/
void onInterrupt(in nsIRDFXMLSink aSink);
/**
* Called when a suspended load is resuming.
* @param aSink the RDF/XML sink that is resuming.
*/
void onResume(in nsIRDFXMLSink aSink);
/**
* Called when an RDF/XML load completes successfully.
* @param aSink the RDF/XML sink that has finished loading.
*/
void onEndLoad(in nsIRDFXMLSink aSink);
/**
* Called when an error occurs during the load
* @param aSink the RDF/XML sink in which the error occurred
* @param aStatus the networking result code
* @param aErrorMsg an error message, if applicable
*/
void onError(in nsIRDFXMLSink aSink, in nsresult aStatus, in wstring aErrorMsg);
};
/**
* A "sink" that receives and processes RDF/XML. This interface is used
* by the RDF/XML parser.
*/
[scriptable, uuid(EB1A5D31-AB33-11D2-8EC6-00805F29F370)]
interface nsIRDFXMLSink : nsISupports
{
/**
* Set to <code>true</code> if the sink is read-only and cannot
* be modified
*/
attribute boolean readOnly;
/**
* Initiate the RDF/XML load.
*/
void beginLoad();
/**
* Suspend the RDF/XML load.
*/
void interrupt();
/**
* Resume the RDF/XML load.
*/
void resume();
/**
* Complete the RDF/XML load.
*/
void endLoad();
/**
* Add namespace information to the RDF/XML sink.
* @param aPrefix the namespace prefix
* @param aURI the namespace URI
*/
[noscript] void addNameSpace(in nsAtomPtr aPrefix,
[const] in nsStringRef aURI);
/**
* Add an observer that will be notified as the RDF/XML load
* progresses.
* <p>
*
* Note that the sink will acquire a strong reference to the
* observer, so care should be taken to avoid cyclical references
* that cannot be released (i.e., if the observer holds a
* reference to the sink, it should be sure that it eventually
* clears the reference).
*
* @param aObserver the observer to add to the sink's set of
* load observers.
*/
void addXMLSinkObserver(in nsIRDFXMLSinkObserver aObserver);
/**
* Remove an observer from the sink's set of observers.
* @param aObserver the observer to remove.
*/
void removeXMLSinkObserver(in nsIRDFXMLSinkObserver aObserver);
};

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

@ -1,20 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsIOutputStream.idl"
[scriptable, uuid(4DA56F10-99FE-11d2-8EBB-00805F29F370)]
interface nsIRDFXMLSource : nsISupports
{
/**
* Serialize the contents of the datasource to aStream.
* @param aStream the output stream the will receive the
* RDF/XML. Currently, the output stream need only
* implement the |write()| method.
*/
void Serialize(in nsIOutputStream aStream);
};

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

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

@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsNameSpaceMap.h"
#include "nsReadableUtils.h"
nsNameSpaceMap::nsNameSpaceMap()
: mEntries(nullptr)
{
MOZ_COUNT_CTOR(nsNameSpaceMap);
}
nsNameSpaceMap::~nsNameSpaceMap()
{
MOZ_COUNT_DTOR(nsNameSpaceMap);
while (mEntries) {
Entry* doomed = mEntries;
mEntries = mEntries->mNext;
delete doomed;
}
}
nsresult
nsNameSpaceMap::Put(const nsAString& aURI, nsAtom* aPrefix)
{
nsCString uriUTF8;
AppendUTF16toUTF8(aURI, uriUTF8);
return Put(uriUTF8, aPrefix);
}
nsresult
nsNameSpaceMap::Put(const nsACString& aURI, nsAtom* aPrefix)
{
Entry* entry;
// Make sure we're not adding a duplicate
for (entry = mEntries; entry != nullptr; entry = entry->mNext) {
if (entry->mURI == aURI || entry->mPrefix == aPrefix)
return NS_ERROR_FAILURE;
}
entry = new Entry(aURI, aPrefix);
if (! entry)
return NS_ERROR_OUT_OF_MEMORY;
entry->mNext = mEntries;
mEntries = entry;
return NS_OK;
}
nsNameSpaceMap::const_iterator
nsNameSpaceMap::GetNameSpaceOf(const nsACString& aURI) const
{
for (Entry* entry = mEntries; entry != nullptr; entry = entry->mNext) {
if (StringBeginsWith(aURI, entry->mURI))
return const_iterator(entry);
}
return last();
}

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

@ -1,98 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsNameSpaceMap_h__
#define nsNameSpaceMap_h__
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsAtom.h"
class nsNameSpaceMap
{
public:
class Entry {
public:
Entry(const nsACString& aURI, nsAtom* aPrefix)
: mURI(aURI), mPrefix(aPrefix), mNext(nullptr) {
MOZ_COUNT_CTOR(nsNameSpaceMap::Entry); }
~Entry() { MOZ_COUNT_DTOR(nsNameSpaceMap::Entry); }
nsCString mURI;
RefPtr<nsAtom> mPrefix;
Entry* mNext;
};
nsNameSpaceMap();
~nsNameSpaceMap();
nsresult
Put(const nsAString& aURI, nsAtom* aPrefix);
nsresult
Put(const nsACString& aURI, nsAtom* aPrefix);
class const_iterator {
protected:
friend class nsNameSpaceMap;
explicit const_iterator(const Entry* aCurrent)
: mCurrent(aCurrent) {}
const Entry* mCurrent;
public:
const_iterator()
: mCurrent(nullptr) {}
const_iterator(const const_iterator& iter)
: mCurrent(iter.mCurrent) {}
const_iterator&
operator=(const const_iterator& iter) {
mCurrent = iter.mCurrent;
return *this; }
const_iterator&
operator++() {
mCurrent = mCurrent->mNext;
return *this; }
const_iterator
operator++(int) {
const_iterator tmp(*this);
mCurrent = mCurrent->mNext;
return tmp; }
const Entry* operator->() const { return mCurrent; }
const Entry& operator*() const { return *mCurrent; }
bool
operator==(const const_iterator& iter) const {
return mCurrent == iter.mCurrent; }
bool
operator!=(const const_iterator& iter) const {
return ! iter.operator==(*this); }
};
const_iterator first() const {
return const_iterator(mEntries); }
const_iterator last() const {
return const_iterator(nullptr); }
const_iterator GetNameSpaceOf(const nsACString& aURI) const;
protected:
Entry* mEntries;
};
#endif // nsNameSpaceMap_h__

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

@ -1,32 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
This header file just contains prototypes for the factory methods
for "builtin" data sources that are included in rdf.dll.
Each of these data sources is exposed to the external world via its
CID in ../include/nsRDFCID.h.
*/
#ifndef nsBaseDataSources_h__
#define nsBaseDataSources_h__
#include "nsError.h"
class nsIRDFDataSource;
// in nsInMemoryDataSource.cpp
nsresult
NS_NewRDFInMemoryDataSource(nsISupports* aOuter, const nsIID& aIID, void** aResult);
// in nsRDFXMLDataSource.cpp
extern nsresult
NS_NewRDFXMLDataSource(nsIRDFDataSource** aResult);
#endif // nsBaseDataSources_h__

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

@ -1,724 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
Implementation for the RDF container.
Notes
-----
1. RDF containers are one-indexed. This means that a lot of the loops
that you'd normally think you'd write like this:
for (i = 0; i < count; ++i) {}
You've gotta write like this:
for (i = 1; i <= count; ++i) {}
"Sure, right, yeah, of course.", you say. Well maybe I'm just
thick, but it's easy to slip up.
2. The RDF:nextVal property on the container is an
implementation-level hack that is used to quickly compute the
next value for appending to the container. It will no doubt
become royally screwed up in the case of aggregation.
3. The RDF:nextVal property is also used to retrieve the count of
elements in the container.
*/
#include "nsCOMPtr.h"
#include "nsIRDFContainer.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFInMemoryDataSource.h"
#include "nsIRDFPropagatableDataSource.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsRDFCID.h"
#include "nsString.h"
#include "rdf.h"
#define RDF_SEQ_LIST_LIMIT 8
class RDFContainerImpl : public nsIRDFContainer
{
public:
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIRDFContainer interface
NS_DECL_NSIRDFCONTAINER
private:
friend nsresult NS_NewRDFContainer(nsIRDFContainer** aResult);
RDFContainerImpl();
virtual ~RDFContainerImpl();
nsresult Init();
nsresult Renumber(int32_t aStartIndex, int32_t aIncrement);
nsresult SetNextValue(int32_t aIndex);
nsresult GetNextValue(nsIRDFResource** aResult);
nsIRDFDataSource* mDataSource;
nsIRDFResource* mContainer;
// pseudo constants
static int32_t gRefCnt;
static nsIRDFService* gRDFService;
static nsIRDFContainerUtils* gRDFContainerUtils;
static nsIRDFResource* kRDF_nextVal;
};
int32_t RDFContainerImpl::gRefCnt = 0;
nsIRDFService* RDFContainerImpl::gRDFService;
nsIRDFContainerUtils* RDFContainerImpl::gRDFContainerUtils;
nsIRDFResource* RDFContainerImpl::kRDF_nextVal;
////////////////////////////////////////////////////////////////////////
// nsISupports interface
NS_IMPL_ISUPPORTS(RDFContainerImpl, nsIRDFContainer)
////////////////////////////////////////////////////////////////////////
// nsIRDFContainer interface
NS_IMETHODIMP
RDFContainerImpl::GetDataSource(nsIRDFDataSource** _retval)
{
*_retval = mDataSource;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
RDFContainerImpl::GetResource(nsIRDFResource** _retval)
{
*_retval = mContainer;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
RDFContainerImpl::Init(nsIRDFDataSource *aDataSource, nsIRDFResource *aContainer)
{
NS_PRECONDITION(aDataSource != nullptr, "null ptr");
if (! aDataSource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aContainer != nullptr, "null ptr");
if (! aContainer)
return NS_ERROR_NULL_POINTER;
nsresult rv;
bool isContainer;
rv = gRDFContainerUtils->IsContainer(aDataSource, aContainer, &isContainer);
if (NS_FAILED(rv)) return rv;
// ``throw'' if we can't create a container on the specified
// datasource/resource combination.
if (! isContainer)
return NS_ERROR_FAILURE;
NS_IF_RELEASE(mDataSource);
mDataSource = aDataSource;
NS_ADDREF(mDataSource);
NS_IF_RELEASE(mContainer);
mContainer = aContainer;
NS_ADDREF(mContainer);
return NS_OK;
}
NS_IMETHODIMP
RDFContainerImpl::GetCount(int32_t *aCount)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
// Get the next value, which hangs off of the bag via the
// RDF:nextVal property. This is the _next value_ that will get
// assigned in a one-indexed array. So, it's actually _one more_
// than the actual count of elements in the container.
//
// XXX To handle aggregation, this should probably be a
// GetTargets() that enumerates all of the values and picks the
// largest one.
nsCOMPtr<nsIRDFNode> nextValNode;
rv = mDataSource->GetTarget(mContainer, kRDF_nextVal, true, getter_AddRefs(nextValNode));
if (NS_FAILED(rv)) return rv;
if (rv == NS_RDF_NO_VALUE)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIRDFLiteral> nextValLiteral;
rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral), getter_AddRefs(nextValLiteral));
if (NS_FAILED(rv)) return rv;
const char16_t *s;
rv = nextValLiteral->GetValueConst( &s );
if (NS_FAILED(rv)) return rv;
nsAutoString nextValStr(s);
int32_t nextVal;
nsresult err;
nextVal = nextValStr.ToInteger(&err);
if (NS_FAILED(err))
return NS_ERROR_UNEXPECTED;
*aCount = nextVal - 1;
return NS_OK;
}
NS_IMETHODIMP
RDFContainerImpl::GetElements(nsISimpleEnumerator **_retval)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
return NS_NewContainerEnumerator(mDataSource, mContainer, _retval);
}
NS_IMETHODIMP
RDFContainerImpl::AppendElement(nsIRDFNode *aElement)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
NS_PRECONDITION(aElement != nullptr, "null ptr");
if (! aElement)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsCOMPtr<nsIRDFResource> nextVal;
rv = GetNextValue(getter_AddRefs(nextVal));
if (NS_FAILED(rv)) return rv;
rv = mDataSource->Assert(mContainer, nextVal, aElement, true);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
NS_IMETHODIMP
RDFContainerImpl::RemoveElement(nsIRDFNode *aElement, bool aRenumber)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
NS_PRECONDITION(aElement != nullptr, "null ptr");
if (! aElement)
return NS_ERROR_NULL_POINTER;
nsresult rv;
int32_t idx;
rv = IndexOf(aElement, &idx);
if (NS_FAILED(rv)) return rv;
if (idx < 0)
return NS_OK;
// Remove the element.
nsCOMPtr<nsIRDFResource> ordinal;
rv = gRDFContainerUtils->IndexToOrdinalResource(idx,
getter_AddRefs(ordinal));
if (NS_FAILED(rv)) return rv;
rv = mDataSource->Unassert(mContainer, ordinal, aElement);
if (NS_FAILED(rv)) return rv;
if (aRenumber) {
// Now slide the rest of the collection backwards to fill in
// the gap. This will have the side effect of completely
// renumber the container from index to the end.
rv = Renumber(idx + 1, -1);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
NS_IMETHODIMP
RDFContainerImpl::InsertElementAt(nsIRDFNode *aElement, int32_t aIndex, bool aRenumber)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
NS_PRECONDITION(aElement != nullptr, "null ptr");
if (! aElement)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aIndex >= 1, "illegal value");
if (aIndex < 1)
return NS_ERROR_ILLEGAL_VALUE;
nsresult rv;
int32_t count;
rv = GetCount(&count);
if (NS_FAILED(rv)) return rv;
NS_ASSERTION(aIndex <= count + 1, "illegal value");
if (aIndex > count + 1)
return NS_ERROR_ILLEGAL_VALUE;
if (aRenumber) {
// Make a hole for the element. This will have the side effect of
// completely renumbering the container from 'aIndex' to 'count',
// and will spew assertions.
rv = Renumber(aIndex, +1);
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIRDFResource> ordinal;
rv = gRDFContainerUtils->IndexToOrdinalResource(aIndex, getter_AddRefs(ordinal));
if (NS_FAILED(rv)) return rv;
rv = mDataSource->Assert(mContainer, ordinal, aElement, true);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
NS_IMETHODIMP
RDFContainerImpl::RemoveElementAt(int32_t aIndex, bool aRenumber, nsIRDFNode** _retval)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
*_retval = nullptr;
if (aIndex< 1)
return NS_ERROR_ILLEGAL_VALUE;
nsresult rv;
int32_t count;
rv = GetCount(&count);
if (NS_FAILED(rv)) return rv;
if (aIndex > count)
return NS_ERROR_ILLEGAL_VALUE;
nsCOMPtr<nsIRDFResource> ordinal;
rv = gRDFContainerUtils->IndexToOrdinalResource(aIndex, getter_AddRefs(ordinal));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFNode> old;
rv = mDataSource->GetTarget(mContainer, ordinal, true, getter_AddRefs(old));
if (NS_FAILED(rv)) return rv;
if (rv == NS_OK) {
rv = mDataSource->Unassert(mContainer, ordinal, old);
if (NS_FAILED(rv)) return rv;
if (aRenumber) {
// Now slide the rest of the collection backwards to fill in
// the gap. This will have the side effect of completely
// renumber the container from index to the end.
rv = Renumber(aIndex + 1, -1);
if (NS_FAILED(rv)) return rv;
}
}
old.swap(*_retval);
return NS_OK;
}
NS_IMETHODIMP
RDFContainerImpl::IndexOf(nsIRDFNode *aElement, int32_t *aIndex)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
return gRDFContainerUtils->IndexOf(mDataSource, mContainer,
aElement, aIndex);
}
////////////////////////////////////////////////////////////////////////
RDFContainerImpl::RDFContainerImpl()
: mDataSource(nullptr), mContainer(nullptr)
{
}
nsresult
RDFContainerImpl::Init()
{
if (gRefCnt++ == 0) {
nsresult rv;
NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
rv = CallGetService(kRDFServiceCID, &gRDFService);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get RDF service");
return rv;
}
rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"),
&kRDF_nextVal);
if (NS_FAILED(rv)) return rv;
NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
if (NS_FAILED(rv)) {
NS_ERROR("unable to get RDF container utils service");
return rv;
}
}
return NS_OK;
}
RDFContainerImpl::~RDFContainerImpl()
{
#ifdef DEBUG_REFS
--gInstanceCount;
fprintf(stdout, "%d - RDF: RDFContainerImpl\n", gInstanceCount);
#endif
NS_IF_RELEASE(mContainer);
NS_IF_RELEASE(mDataSource);
if (--gRefCnt == 0) {
NS_IF_RELEASE(gRDFContainerUtils);
NS_IF_RELEASE(gRDFService);
NS_IF_RELEASE(kRDF_nextVal);
}
}
nsresult
NS_NewRDFContainer(nsIRDFContainer** aResult)
{
RDFContainerImpl* result = new RDFContainerImpl();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
rv = result->Init();
if (NS_FAILED(rv)) {
delete result;
return rv;
}
NS_ADDREF(result);
*aResult = result;
return NS_OK;
}
nsresult
NS_NewRDFContainer(nsIRDFDataSource* aDataSource,
nsIRDFResource* aResource,
nsIRDFContainer** aResult)
{
nsresult rv;
rv = NS_NewRDFContainer(aResult);
if (NS_FAILED(rv)) return rv;
rv = (*aResult)->Init(aDataSource, aResource);
if (NS_FAILED(rv)) {
NS_RELEASE(*aResult);
}
return rv;
}
nsresult
RDFContainerImpl::Renumber(int32_t aStartIndex, int32_t aIncrement)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
// Renumber the elements in the container starting with
// aStartIndex, updating each element's index by aIncrement. For
// example,
//
// (1:a 2:b 3:c)
// Renumber(2, +1);
// (1:a 3:b 4:c)
// Renumber(3, -1);
// (1:a 2:b 3:c)
//
nsresult rv;
if (! aIncrement)
return NS_OK;
int32_t count;
rv = GetCount(&count);
if (NS_FAILED(rv)) return rv;
if (aIncrement > 0) {
// Update the container's nextVal to reflect the
// renumbering. We do this now if aIncrement > 0 because we'll
// want to be able to acknowledge that new elements are in the
// container.
rv = SetNextValue(count + aIncrement + 1);
if (NS_FAILED(rv)) return rv;
}
int32_t i;
if (aIncrement < 0) {
i = aStartIndex;
}
else {
i = count; // we're one-indexed.
}
// Note: once we disable notifications, don't exit this method until
// enabling notifications
nsCOMPtr<nsIRDFPropagatableDataSource> propagatable =
do_QueryInterface(mDataSource);
if (propagatable) {
propagatable->SetPropagateChanges(false);
}
bool err = false;
while (!err && ((aIncrement < 0) ? (i <= count) : (i >= aStartIndex)))
{
nsCOMPtr<nsIRDFResource> oldOrdinal;
rv = gRDFContainerUtils->IndexToOrdinalResource(i, getter_AddRefs(oldOrdinal));
if (NS_FAILED(rv))
{
err = true;
continue;
}
nsCOMPtr<nsIRDFResource> newOrdinal;
rv = gRDFContainerUtils->IndexToOrdinalResource(i + aIncrement, getter_AddRefs(newOrdinal));
if (NS_FAILED(rv))
{
err = true;
continue;
}
// Because of aggregation, we need to be paranoid about the
// possibility that >1 element may be present per ordinal. If
// there _is_ in fact more than one element, they'll all get
// assigned to the same new ordinal; i.e., we don't make any
// attempt to "clean up" the duplicate numbering. (Doing so
// would require two passes.)
nsCOMPtr<nsISimpleEnumerator> targets;
rv = mDataSource->GetTargets(mContainer, oldOrdinal, true, getter_AddRefs(targets));
if (NS_FAILED(rv))
{
err = true;
continue;
}
while (1) {
bool hasMore;
rv = targets->HasMoreElements(&hasMore);
if (NS_FAILED(rv))
{
err = true;
break;
}
if (! hasMore)
break;
nsCOMPtr<nsISupports> isupports;
rv = targets->GetNext(getter_AddRefs(isupports));
if (NS_FAILED(rv))
{
err = true;
break;
}
nsCOMPtr<nsIRDFNode> element( do_QueryInterface(isupports) );
NS_ASSERTION(element != nullptr, "something funky in the enumerator");
if (! element)
{
err = true;
rv = NS_ERROR_UNEXPECTED;
break;
}
rv = mDataSource->Unassert(mContainer, oldOrdinal, element);
if (NS_FAILED(rv))
{
err = true;
break;
}
rv = mDataSource->Assert(mContainer, newOrdinal, element, true);
if (NS_FAILED(rv))
{
err = true;
break;
}
}
i -= aIncrement;
}
if (!err && (aIncrement < 0))
{
// Update the container's nextVal to reflect the
// renumbering. We do this now if aIncrement < 0 because, up
// until this point, we'll want people to be able to find
// things that are still "at the end".
rv = SetNextValue(count + aIncrement + 1);
if (NS_FAILED(rv))
{
err = true;
}
}
// Note: MUST enable notifications before exiting this method
if (propagatable) {
propagatable->SetPropagateChanges(true);
}
if (err) return(rv);
return NS_OK;
}
nsresult
RDFContainerImpl::SetNextValue(int32_t aIndex)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
// Remove the current value of nextVal, if there is one.
nsCOMPtr<nsIRDFNode> nextValNode;
if (NS_SUCCEEDED(rv = mDataSource->GetTarget(mContainer,
kRDF_nextVal,
true,
getter_AddRefs(nextValNode)))) {
if (NS_FAILED(rv = mDataSource->Unassert(mContainer, kRDF_nextVal, nextValNode))) {
NS_ERROR("unable to update nextVal");
return rv;
}
}
nsAutoString s;
s.AppendInt(aIndex, 10);
nsCOMPtr<nsIRDFLiteral> nextVal;
if (NS_FAILED(rv = gRDFService->GetLiteral(s.get(), getter_AddRefs(nextVal)))) {
NS_ERROR("unable to get nextVal literal");
return rv;
}
rv = mDataSource->Assert(mContainer, kRDF_nextVal, nextVal, true);
if (rv != NS_RDF_ASSERTION_ACCEPTED) {
NS_ERROR("unable to update nextVal");
return NS_ERROR_FAILURE;
}
return NS_OK;
}
nsresult
RDFContainerImpl::GetNextValue(nsIRDFResource** aResult)
{
if (!mDataSource || !mContainer)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
// Get the next value, which hangs off of the bag via the
// RDF:nextVal property.
nsCOMPtr<nsIRDFNode> nextValNode;
rv = mDataSource->GetTarget(mContainer, kRDF_nextVal, true, getter_AddRefs(nextValNode));
if (NS_FAILED(rv)) return rv;
if (rv == NS_RDF_NO_VALUE)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIRDFLiteral> nextValLiteral;
rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral), getter_AddRefs(nextValLiteral));
if (NS_FAILED(rv)) return rv;
const char16_t* s;
rv = nextValLiteral->GetValueConst(&s);
if (NS_FAILED(rv)) return rv;
int32_t nextVal = 0;
{
for (const char16_t* p = s; *p != 0; ++p) {
NS_ASSERTION(*p >= '0' && *p <= '9', "not a digit");
if (*p < '0' || *p > '9')
break;
nextVal *= 10;
nextVal += *p - '0';
}
}
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
nsAutoCStringN<sizeof(kRDFNameSpaceURI) + 16> nextValStr;
nextValStr = kRDFNameSpaceURI;
nextValStr.Append('_');
nextValStr.AppendInt(nextVal, 10);
rv = gRDFService->GetResource(nextValStr, aResult);
if (NS_FAILED(rv)) return rv;
// Now increment the RDF:nextVal property.
rv = mDataSource->Unassert(mContainer, kRDF_nextVal, nextValLiteral);
if (NS_FAILED(rv)) return rv;
++nextVal;
nextValStr.Truncate();
nextValStr.AppendInt(nextVal, 10);
rv = gRDFService->GetLiteral(NS_ConvertASCIItoUTF16(nextValStr).get(), getter_AddRefs(nextValLiteral));
if (NS_FAILED(rv)) return rv;
rv = mDataSource->Assert(mContainer, kRDF_nextVal, nextValLiteral, true);
if (NS_FAILED(rv)) return rv;
if (RDF_SEQ_LIST_LIMIT == nextVal)
{
// focal point for RDF container mutation;
// basically, provide a hint to allow for fast access
nsCOMPtr<nsIRDFInMemoryDataSource> inMem = do_QueryInterface(mDataSource);
if (inMem)
{
// ignore error; failure just means slower access
(void)inMem->EnsureFastContainment(mContainer);
}
}
return NS_OK;
}

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

@ -1,513 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
Implementation for the RDF container utils.
*/
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIRDFContainer.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "nsString.h"
#include "plstr.h"
#include "rdf.h"
#include "rdfutil.h"
class RDFContainerUtilsImpl : public nsIRDFContainerUtils
{
public:
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIRDFContainerUtils interface
NS_DECL_NSIRDFCONTAINERUTILS
private:
friend nsresult NS_NewRDFContainerUtils(nsIRDFContainerUtils** aResult);
RDFContainerUtilsImpl();
virtual ~RDFContainerUtilsImpl();
nsresult MakeContainer(nsIRDFDataSource* aDataSource,
nsIRDFResource* aResource,
nsIRDFResource* aType,
nsIRDFContainer** aResult);
bool IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType);
// pseudo constants
static int32_t gRefCnt;
static nsIRDFService* gRDFService;
static nsIRDFResource* kRDF_instanceOf;
static nsIRDFResource* kRDF_nextVal;
static nsIRDFResource* kRDF_Bag;
static nsIRDFResource* kRDF_Seq;
static nsIRDFResource* kRDF_Alt;
static nsIRDFLiteral* kOne;
static const char kRDFNameSpaceURI[];
};
int32_t RDFContainerUtilsImpl::gRefCnt = 0;
nsIRDFService* RDFContainerUtilsImpl::gRDFService;
nsIRDFResource* RDFContainerUtilsImpl::kRDF_instanceOf;
nsIRDFResource* RDFContainerUtilsImpl::kRDF_nextVal;
nsIRDFResource* RDFContainerUtilsImpl::kRDF_Bag;
nsIRDFResource* RDFContainerUtilsImpl::kRDF_Seq;
nsIRDFResource* RDFContainerUtilsImpl::kRDF_Alt;
nsIRDFLiteral* RDFContainerUtilsImpl::kOne;
const char RDFContainerUtilsImpl::kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
////////////////////////////////////////////////////////////////////////
// nsISupports interface
NS_IMPL_ISUPPORTS(RDFContainerUtilsImpl, nsIRDFContainerUtils)
////////////////////////////////////////////////////////////////////////
// nsIRDFContainerUtils interface
NS_IMETHODIMP
RDFContainerUtilsImpl::IsOrdinalProperty(nsIRDFResource *aProperty, bool *_retval)
{
NS_PRECONDITION(aProperty != nullptr, "null ptr");
if (! aProperty)
return NS_ERROR_NULL_POINTER;
nsresult rv;
const char *propertyStr;
rv = aProperty->GetValueConst( &propertyStr );
if (NS_FAILED(rv)) return rv;
if (PL_strncmp(propertyStr, kRDFNameSpaceURI, sizeof(kRDFNameSpaceURI) - 1) != 0) {
*_retval = false;
return NS_OK;
}
const char* s = propertyStr;
s += sizeof(kRDFNameSpaceURI) - 1;
if (*s != '_') {
*_retval = false;
return NS_OK;
}
++s;
while (*s) {
if (*s < '0' || *s > '9') {
*_retval = false;
return NS_OK;
}
++s;
}
*_retval = true;
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IndexToOrdinalResource(int32_t aIndex, nsIRDFResource **aOrdinal)
{
NS_PRECONDITION(aIndex > 0, "illegal value");
if (aIndex <= 0)
return NS_ERROR_ILLEGAL_VALUE;
nsAutoCString uri(kRDFNameSpaceURI);
uri.Append('_');
uri.AppendInt(aIndex);
nsresult rv = gRDFService->GetResource(uri, aOrdinal);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get ordinal resource");
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::OrdinalResourceToIndex(nsIRDFResource *aOrdinal, int32_t *aIndex)
{
NS_PRECONDITION(aOrdinal != nullptr, "null ptr");
if (! aOrdinal)
return NS_ERROR_NULL_POINTER;
const char *ordinalStr;
if (NS_FAILED(aOrdinal->GetValueConst( &ordinalStr )))
return NS_ERROR_FAILURE;
const char* s = ordinalStr;
if (PL_strncmp(s, kRDFNameSpaceURI, sizeof(kRDFNameSpaceURI) - 1) != 0) {
NS_ERROR("not an ordinal");
return NS_ERROR_UNEXPECTED;
}
s += sizeof(kRDFNameSpaceURI) - 1;
if (*s != '_') {
NS_ERROR("not an ordinal");
return NS_ERROR_UNEXPECTED;
}
int32_t idx = 0;
++s;
while (*s) {
if (*s < '0' || *s > '9') {
NS_ERROR("not an ordinal");
return NS_ERROR_UNEXPECTED;
}
idx *= 10;
idx += (*s - '0');
++s;
}
*aIndex = idx;
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IsContainer(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, bool *_retval)
{
NS_PRECONDITION(aDataSource != nullptr, "null ptr");
if (! aDataSource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResource != nullptr, "null ptr");
if (! aResource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(_retval != nullptr, "null ptr");
if (! _retval)
return NS_ERROR_NULL_POINTER;
if (IsA(aDataSource, aResource, kRDF_Seq) ||
IsA(aDataSource, aResource, kRDF_Bag) ||
IsA(aDataSource, aResource, kRDF_Alt)) {
*_retval = true;
}
else {
*_retval = false;
}
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IsEmpty(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, bool* _retval)
{
if (! aDataSource)
return NS_ERROR_NULL_POINTER;
nsresult rv;
// By default, say that we're an empty container. Even if we're not
// really even a container.
*_retval = true;
nsCOMPtr<nsIRDFNode> nextValNode;
rv = aDataSource->GetTarget(aResource, kRDF_nextVal, true, getter_AddRefs(nextValNode));
if (NS_FAILED(rv)) return rv;
if (rv == NS_RDF_NO_VALUE)
return NS_OK;
nsCOMPtr<nsIRDFLiteral> nextValLiteral;
rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral), getter_AddRefs(nextValLiteral));
if (NS_FAILED(rv)) return rv;
if (nextValLiteral.get() != kOne)
*_retval = false;
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IsBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, bool *_retval)
{
NS_PRECONDITION(aDataSource != nullptr, "null ptr");
if (! aDataSource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResource != nullptr, "null ptr");
if (! aResource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(_retval != nullptr, "null ptr");
if (! _retval)
return NS_ERROR_NULL_POINTER;
*_retval = IsA(aDataSource, aResource, kRDF_Bag);
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IsSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, bool *_retval)
{
NS_PRECONDITION(aDataSource != nullptr, "null ptr");
if (! aDataSource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResource != nullptr, "null ptr");
if (! aResource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(_retval != nullptr, "null ptr");
if (! _retval)
return NS_ERROR_NULL_POINTER;
*_retval = IsA(aDataSource, aResource, kRDF_Seq);
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IsAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, bool *_retval)
{
NS_PRECONDITION(aDataSource != nullptr, "null ptr");
if (! aDataSource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResource != nullptr, "null ptr");
if (! aResource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(_retval != nullptr, "null ptr");
if (! _retval)
return NS_ERROR_NULL_POINTER;
*_retval = IsA(aDataSource, aResource, kRDF_Alt);
return NS_OK;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::MakeBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval)
{
return MakeContainer(aDataSource, aResource, kRDF_Bag, _retval);
}
NS_IMETHODIMP
RDFContainerUtilsImpl::MakeSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval)
{
return MakeContainer(aDataSource, aResource, kRDF_Seq, _retval);
}
NS_IMETHODIMP
RDFContainerUtilsImpl::MakeAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval)
{
return MakeContainer(aDataSource, aResource, kRDF_Alt, _retval);
}
////////////////////////////////////////////////////////////////////////
RDFContainerUtilsImpl::RDFContainerUtilsImpl()
{
if (gRefCnt++ == 0) {
nsresult rv;
NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
rv = CallGetService(kRDFServiceCID, &gRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
if (NS_SUCCEEDED(rv)) {
gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"),
&kRDF_instanceOf);
gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"),
&kRDF_nextVal);
gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Bag"),
&kRDF_Bag);
gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Seq"),
&kRDF_Seq);
gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Alt"),
&kRDF_Alt);
gRDFService->GetLiteral(u"1", &kOne);
}
}
}
RDFContainerUtilsImpl::~RDFContainerUtilsImpl()
{
#ifdef DEBUG_REFS
--gInstanceCount;
fprintf(stdout, "%d - RDF: RDFContainerUtilsImpl\n", gInstanceCount);
#endif
if (--gRefCnt == 0) {
NS_IF_RELEASE(gRDFService);
NS_IF_RELEASE(kRDF_instanceOf);
NS_IF_RELEASE(kRDF_nextVal);
NS_IF_RELEASE(kRDF_Bag);
NS_IF_RELEASE(kRDF_Seq);
NS_IF_RELEASE(kRDF_Alt);
NS_IF_RELEASE(kOne);
}
}
nsresult
NS_NewRDFContainerUtils(nsIRDFContainerUtils** aResult)
{
NS_PRECONDITION(aResult != nullptr, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
RDFContainerUtilsImpl* result =
new RDFContainerUtilsImpl();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);
*aResult = result;
return NS_OK;
}
nsresult
RDFContainerUtilsImpl::MakeContainer(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType, nsIRDFContainer** aResult)
{
NS_PRECONDITION(aDataSource != nullptr, "null ptr");
if (! aDataSource) return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResource != nullptr, "null ptr");
if (! aResource) return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aType != nullptr, "null ptr");
if (! aType) return NS_ERROR_NULL_POINTER;
if (aResult) *aResult = nullptr;
nsresult rv;
// Check to see if somebody has already turned it into a container; if so
// don't try to do it again.
bool isContainer;
rv = IsContainer(aDataSource, aResource, &isContainer);
if (NS_FAILED(rv)) return rv;
if (!isContainer)
{
rv = aDataSource->Assert(aResource, kRDF_instanceOf, aType, true);
if (NS_FAILED(rv)) return rv;
rv = aDataSource->Assert(aResource, kRDF_nextVal, kOne, true);
if (NS_FAILED(rv)) return rv;
}
if (aResult) {
rv = NS_NewRDFContainer(aResult);
if (NS_FAILED(rv)) return rv;
rv = (*aResult)->Init(aDataSource, aResource);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
bool
RDFContainerUtilsImpl::IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType)
{
if (!aDataSource || !aResource || !aType) {
NS_WARNING("Unexpected null argument");
return false;
}
nsresult rv;
bool result;
rv = aDataSource->HasAssertion(aResource, kRDF_instanceOf, aType, true, &result);
if (NS_FAILED(rv))
return false;
return result;
}
NS_IMETHODIMP
RDFContainerUtilsImpl::IndexOf(nsIRDFDataSource* aDataSource, nsIRDFResource* aContainer, nsIRDFNode* aElement, int32_t* aIndex)
{
if (!aDataSource || !aContainer)
return NS_ERROR_NULL_POINTER;
// Assume we can't find it.
*aIndex = -1;
// If the resource is null, bail quietly
if (! aElement)
return NS_OK;
// We'll assume that fan-out is much higher than fan-in, so grovel
// through the inbound arcs, look for an ordinal resource, and
// decode it.
nsCOMPtr<nsISimpleEnumerator> arcsIn;
aDataSource->ArcLabelsIn(aElement, getter_AddRefs(arcsIn));
if (! arcsIn)
return NS_OK;
while (1) {
bool hasMoreArcs = false;
arcsIn->HasMoreElements(&hasMoreArcs);
if (! hasMoreArcs)
break;
nsCOMPtr<nsISupports> isupports;
arcsIn->GetNext(getter_AddRefs(isupports));
if (! isupports)
break;
nsCOMPtr<nsIRDFResource> property =
do_QueryInterface(isupports);
if (! property)
continue;
bool isOrdinal;
IsOrdinalProperty(property, &isOrdinal);
if (! isOrdinal)
continue;
nsCOMPtr<nsISimpleEnumerator> sources;
aDataSource->GetSources(property, aElement, true, getter_AddRefs(sources));
if (! sources)
continue;
while (1) {
bool hasMoreSources = false;
sources->HasMoreElements(&hasMoreSources);
if (! hasMoreSources)
break;
nsCOMPtr<nsISupports> isupports2;
sources->GetNext(getter_AddRefs(isupports2));
if (! isupports2)
break;
nsCOMPtr<nsIRDFResource> source =
do_QueryInterface(isupports2);
if (source == aContainer)
// Found it.
return OrdinalResourceToIndex(property, aIndex);
}
}
return NS_OK;
}

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

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

@ -1,220 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsRDFResource.h"
#include "nsIServiceManager.h"
#include "nsIRDFDelegateFactory.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "mozilla/Logging.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
nsIRDFService* nsRDFResource::gRDFService = nullptr;
nsrefcnt nsRDFResource::gRDFServiceRefCnt = 0;
////////////////////////////////////////////////////////////////////////////////
nsRDFResource::nsRDFResource(void)
: mDelegates(nullptr)
{
}
nsRDFResource::~nsRDFResource(void)
{
// Release all of the delegate objects
while (mDelegates) {
DelegateEntry* doomed = mDelegates;
mDelegates = mDelegates->mNext;
delete doomed;
}
if (!gRDFService)
return;
gRDFService->UnregisterResource(this);
if (--gRDFServiceRefCnt == 0)
NS_RELEASE(gRDFService);
}
NS_IMPL_ISUPPORTS(nsRDFResource, nsIRDFResource, nsIRDFNode)
////////////////////////////////////////////////////////////////////////////////
// nsIRDFNode methods:
NS_IMETHODIMP
nsRDFResource::EqualsNode(nsIRDFNode* aNode, bool* aResult)
{
NS_PRECONDITION(aNode != nullptr, "null ptr");
if (! aNode)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsIRDFResource* resource;
rv = aNode->QueryInterface(NS_GET_IID(nsIRDFResource), (void**)&resource);
if (NS_SUCCEEDED(rv)) {
*aResult = (static_cast<nsIRDFResource*>(this) == resource);
NS_RELEASE(resource);
return NS_OK;
}
if (rv == NS_NOINTERFACE) {
*aResult = false;
return NS_OK;
}
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIRDFResource methods:
NS_IMETHODIMP
nsRDFResource::Init(const char* aURI)
{
NS_PRECONDITION(aURI != nullptr, "null ptr");
if (! aURI)
return NS_ERROR_NULL_POINTER;
mURI = aURI;
if (gRDFServiceRefCnt++ == 0) {
nsresult rv = CallGetService(kRDFServiceCID, &gRDFService);
if (NS_FAILED(rv)) return rv;
}
// don't replace an existing resource with the same URI automatically
return gRDFService->RegisterResource(this, true);
}
NS_IMETHODIMP
nsRDFResource::GetValue(char* *aURI)
{
NS_ASSERTION(aURI, "Null out param.");
*aURI = ToNewCString(mURI);
if (!*aURI)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsRDFResource::GetValueUTF8(nsACString& aResult)
{
aResult = mURI;
return NS_OK;
}
NS_IMETHODIMP
nsRDFResource::GetValueConst(const char** aURI)
{
*aURI = mURI.get();
return NS_OK;
}
NS_IMETHODIMP
nsRDFResource::EqualsString(const char* aURI, bool* aResult)
{
NS_PRECONDITION(aURI != nullptr, "null ptr");
if (! aURI)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResult, "null ptr");
*aResult = mURI.Equals(aURI);
return NS_OK;
}
NS_IMETHODIMP
nsRDFResource::GetDelegate(const char* aKey, REFNSIID aIID, void** aResult)
{
NS_PRECONDITION(aKey != nullptr, "null ptr");
if (! aKey)
return NS_ERROR_NULL_POINTER;
nsresult rv;
*aResult = nullptr;
DelegateEntry* entry = mDelegates;
while (entry) {
if (entry->mKey.Equals(aKey)) {
rv = entry->mDelegate->QueryInterface(aIID, aResult);
return rv;
}
entry = entry->mNext;
}
// Construct a ContractID of the form "@mozilla.org/rdf/delegate/[key]/[scheme];1
nsAutoCString contractID(NS_RDF_DELEGATEFACTORY_CONTRACTID_PREFIX);
contractID.Append(aKey);
contractID.AppendLiteral("&scheme=");
int32_t i = mURI.FindChar(':');
contractID += StringHead(mURI, i);
nsCOMPtr<nsIRDFDelegateFactory> delegateFactory =
do_CreateInstance(contractID.get(), &rv);
if (NS_FAILED(rv)) return rv;
rv = delegateFactory->CreateDelegate(this, aKey, aIID, aResult);
if (NS_FAILED(rv)) return rv;
// Okay, we've successfully created a delegate. Let's remember it.
entry = new DelegateEntry;
if (! entry) {
NS_RELEASE(*reinterpret_cast<nsISupports**>(aResult));
return NS_ERROR_OUT_OF_MEMORY;
}
entry->mKey = aKey;
entry->mDelegate = do_QueryInterface(*reinterpret_cast<nsISupports**>(aResult), &rv);
if (NS_FAILED(rv)) {
NS_ERROR("nsRDFResource::GetDelegate(): can't QI to nsISupports!");
delete entry;
NS_RELEASE(*reinterpret_cast<nsISupports**>(aResult));
return NS_ERROR_FAILURE;
}
entry->mNext = mDelegates;
mDelegates = entry;
return NS_OK;
}
NS_IMETHODIMP
nsRDFResource::ReleaseDelegate(const char* aKey)
{
NS_PRECONDITION(aKey != nullptr, "null ptr");
if (! aKey)
return NS_ERROR_NULL_POINTER;
DelegateEntry* entry = mDelegates;
DelegateEntry** link = &mDelegates;
while (entry) {
if (entry->mKey.Equals(aKey)) {
*link = entry->mNext;
delete entry;
return NS_OK;
}
link = &(entry->mNext);
entry = entry->mNext;
}
NS_WARNING("nsRDFResource::ReleaseDelegate() no delegate found");
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

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

@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsRDFResource_h__
#define nsRDFResource_h__
#include "nsCOMPtr.h"
#include "nsIRDFNode.h"
#include "nsIRDFResource.h"
#include "nscore.h"
#include "nsString.h"
#include "rdf.h"
class nsIRDFService;
/**
* This simple base class implements nsIRDFResource, and can be used as a
* superclass for more sophisticated resource implementations.
*/
class nsRDFResource : public nsIRDFResource {
public:
NS_DECL_THREADSAFE_ISUPPORTS
// nsIRDFNode methods:
NS_IMETHOD EqualsNode(nsIRDFNode* aNode, bool* aResult) override;
// nsIRDFResource methods:
NS_IMETHOD Init(const char* aURI) override;
NS_IMETHOD GetValue(char* *aURI) override;
NS_IMETHOD GetValueUTF8(nsACString& aResult) override;
NS_IMETHOD GetValueConst(const char** aURI) override;
NS_IMETHOD EqualsString(const char* aURI, bool* aResult) override;
NS_IMETHOD GetDelegate(const char* aKey, REFNSIID aIID, void** aResult) override;
NS_IMETHOD ReleaseDelegate(const char* aKey) override;
// nsRDFResource methods:
nsRDFResource(void);
protected:
virtual ~nsRDFResource(void);
static nsIRDFService* gRDFService;
static nsrefcnt gRDFServiceRefCnt;
protected:
nsCString mURI;
struct DelegateEntry {
nsCString mKey;
nsCOMPtr<nsISupports> mDelegate;
DelegateEntry* mNext;
};
DelegateEntry* mDelegates;
};
#endif // nsRDFResource_h__

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

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

@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsRDFService_h__
#define nsRDFService_h__
#include "nsIRDFService.h"
#include "nsWeakReference.h"
#include "nsIFactory.h"
#include "nsCOMPtr.h"
#include "PLDHashTable.h"
#include "nsString.h"
struct PLHashTable;
class nsIRDFLiteral;
class nsIRDFInt;
class nsIRDFDate;
class BlobImpl;
class RDFServiceImpl final : public nsIRDFService,
public nsSupportsWeakReference
{
protected:
PLHashTable* mNamedDataSources;
PLDHashTable mResources;
PLDHashTable mLiterals;
PLDHashTable mInts;
PLDHashTable mDates;
PLDHashTable mBlobs;
nsCString mLastURIPrefix;
nsCOMPtr<nsIFactory> mLastFactory;
nsCOMPtr<nsIFactory> mDefaultResourceFactory;
RDFServiceImpl();
nsresult Init();
virtual ~RDFServiceImpl();
public:
static RDFServiceImpl *gRDFService NS_VISIBILITY_HIDDEN;
static nsresult CreateSingleton(nsISupports* aOuter,
const nsIID& aIID, void **aResult);
// nsISupports
NS_DECL_ISUPPORTS
// nsIRDFService
NS_DECL_NSIRDFSERVICE
// Implementation methods
nsresult RegisterLiteral(nsIRDFLiteral* aLiteral);
nsresult UnregisterLiteral(nsIRDFLiteral* aLiteral);
nsresult RegisterInt(nsIRDFInt* aInt);
nsresult UnregisterInt(nsIRDFInt* aInt);
nsresult RegisterDate(nsIRDFDate* aDate);
nsresult UnregisterDate(nsIRDFDate* aDate);
nsresult RegisterBlob(BlobImpl* aBlob);
nsresult UnregisterBlob(BlobImpl* aBlob);
nsresult GetDataSource(const char *aURI, bool aBlock, nsIRDFDataSource **aDataSource );
};
#endif // nsRDFService_h__

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

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

@ -1,137 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsRDFXMLParser.h"
#include "mozilla/Encoding.h"
#include "nsIComponentManager.h"
#include "nsIParser.h"
#include "nsCharsetSource.h"
#include "nsIRDFContentSink.h"
#include "nsParserCIID.h"
#include "nsStringStream.h"
#include "nsNetUtil.h"
#include "NullPrincipal.h"
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
NS_IMPL_ISUPPORTS(nsRDFXMLParser, nsIRDFXMLParser)
nsresult
nsRDFXMLParser::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsRDFXMLParser* result = new nsRDFXMLParser();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
NS_ADDREF(result);
rv = result->QueryInterface(aIID, aResult);
NS_RELEASE(result);
return rv;
}
nsRDFXMLParser::nsRDFXMLParser()
{
}
nsRDFXMLParser::~nsRDFXMLParser()
{
}
NS_IMETHODIMP
nsRDFXMLParser::ParseAsync(nsIRDFDataSource* aSink, nsIURI* aBaseURI, nsIStreamListener** aResult)
{
nsresult rv;
nsCOMPtr<nsIRDFContentSink> sink =
do_CreateInstance("@mozilla.org/rdf/content-sink;1", &rv);
if (NS_FAILED(rv)) return rv;
rv = sink->Init(aBaseURI);
if (NS_FAILED(rv)) return rv;
// We set the content sink's data source directly to our in-memory
// store. This allows the initial content to be generated "directly".
rv = sink->SetDataSource(aSink);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIParser> parser = do_CreateInstance(kParserCID, &rv);
if (NS_FAILED(rv)) return rv;
parser->SetDocumentCharset(UTF_8_ENCODING,
kCharsetFromDocTypeDefault);
parser->SetContentSink(sink);
rv = parser->Parse(aBaseURI);
if (NS_FAILED(rv)) return rv;
return CallQueryInterface(parser, aResult);
}
NS_IMETHODIMP
nsRDFXMLParser::ParseString(nsIRDFDataSource* aSink, nsIURI* aBaseURI, const nsACString& aString)
{
nsresult rv;
nsCOMPtr<nsIRDFContentSink> sink =
do_CreateInstance("@mozilla.org/rdf/content-sink;1", &rv);
if (NS_FAILED(rv)) return rv;
rv = sink->Init(aBaseURI);
if (NS_FAILED(rv)) return rv;
// We set the content sink's data source directly to our in-memory
// store. This allows the initial content to be generated "directly".
rv = sink->SetDataSource(aSink);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIParser> parser = do_CreateInstance(kParserCID, &rv);
if (NS_FAILED(rv)) return rv;
parser->SetDocumentCharset(UTF_8_ENCODING,
kCharsetFromOtherComponent);
parser->SetContentSink(sink);
rv = parser->Parse(aBaseURI);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStreamListener> listener =
do_QueryInterface(parser);
if (! listener)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIInputStream> stream;
rv = NS_NewCStringInputStream(getter_AddRefs(stream), aString);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrincipal> nullPrincipal = NullPrincipal::CreateWithoutOriginAttributes();
// The following channel is never openend, so it does not matter what
// securityFlags we pass; let's follow the principle of least privilege.
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsIInputStream> tmpStream = stream;
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aBaseURI,
tmpStream.forget(),
nullPrincipal,
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/xml"));
if (NS_FAILED(rv)) return rv;
listener->OnStartRequest(channel, nullptr);
listener->OnDataAvailable(channel, nullptr, stream, 0, aString.Length());
listener->OnStopRequest(channel, nullptr, NS_OK);
return NS_OK;
}

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

@ -1,31 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsRDFParser_h__
#define nsRDFParser_h__
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIRDFXMLParser.h"
#include "nsIRDFDataSource.h"
/**
* A helper class that is used to parse RDF/XML.
*/
class nsRDFXMLParser : public nsIRDFXMLParser {
public:
static nsresult
Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
NS_DECL_ISUPPORTS
NS_DECL_NSIRDFXMLPARSER
protected:
nsRDFXMLParser();
virtual ~nsRDFXMLParser();
};
#endif // nsRDFParser_h__

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

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

@ -1,117 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsRDFXMLSerializer_h__
#define nsRDFXMLSerializer_h__
#include "nsIRDFLiteral.h"
#include "nsIRDFXMLSerializer.h"
#include "nsIRDFXMLSource.h"
#include "nsNameSpaceMap.h"
#include "nsString.h"
#include "nsDataHashtable.h"
#include "rdfITripleVisitor.h"
class nsIOutputStream;
class nsIRDFContainerUtils;
/**
* A helper class that can serialize RDF/XML from a
* datasource. Implements both nsIRDFXMLSerializer and
* nsIRDFXMLSource.
*/
class nsRDFXMLSerializer : public nsIRDFXMLSerializer,
public nsIRDFXMLSource
{
public:
static nsresult
Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
NS_DECL_ISUPPORTS
NS_DECL_NSIRDFXMLSERIALIZER
NS_DECL_NSIRDFXMLSOURCE
protected:
nsRDFXMLSerializer();
virtual ~nsRDFXMLSerializer();
// Implementation methods
nsresult
RegisterQName(nsIRDFResource* aResource);
nsresult
GetQName(nsIRDFResource* aResource, nsCString& aQName);
already_AddRefed<nsAtom>
EnsureNewPrefix();
nsresult
SerializeInlineAssertion(nsIOutputStream* aStream,
nsIRDFResource* aResource,
nsIRDFResource* aProperty,
nsIRDFLiteral* aValue);
nsresult
SerializeChildAssertion(nsIOutputStream* aStream,
nsIRDFResource* aResource,
nsIRDFResource* aProperty,
nsIRDFNode* aValue);
nsresult
SerializeProperty(nsIOutputStream* aStream,
nsIRDFResource* aResource,
nsIRDFResource* aProperty,
bool aInline,
int32_t* aSkipped);
bool
IsContainerProperty(nsIRDFResource* aProperty);
nsresult
SerializeDescription(nsIOutputStream* aStream,
nsIRDFResource* aResource);
nsresult
SerializeMember(nsIOutputStream* aStream,
nsIRDFResource* aContainer,
nsIRDFNode* aMember);
nsresult
SerializeContainer(nsIOutputStream* aStream,
nsIRDFResource* aContainer);
nsresult
SerializePrologue(nsIOutputStream* aStream);
nsresult
SerializeEpilogue(nsIOutputStream* aStream);
nsresult
CollectNamespaces();
bool
IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType);
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsNameSpaceMap mNameSpaces;
nsCString mBaseURLSpec;
// hash mapping resources to utf8-encoded QNames
nsDataHashtable<nsISupportsHashKey, nsCString> mQNames;
friend class QNameCollector;
uint32_t mPrefixID;
static int32_t gRefCnt;
static nsIRDFResource* kRDF_instanceOf;
static nsIRDFResource* kRDF_type;
static nsIRDFResource* kRDF_nextVal;
static nsIRDFResource* kRDF_Bag;
static nsIRDFResource* kRDF_Seq;
static nsIRDFResource* kRDF_Alt;
static nsIRDFContainerUtils* gRDFC;
};
#endif // nsRDFXMLSerializer_h__

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

@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
A catch-all header file for miscellaneous RDF stuff. Currently
contains error codes and vocabulary macros.
*/
#ifndef rdf_h___
#define rdf_h___
#include "nsError.h"
/**
* The following macros are to aid in vocabulary definition. They
* creates const char*'s for "kURI[prefix]_[name]", appropriate
* complete namespace qualification on the URI, e.g.,
*
* #define RDF_NAMESPACE_URI "http://www.w3.org/TR/WD-rdf-syntax#"
* DEFINE_RDF_ELEMENT(RDF_NAMESPACE_URI, RDF, ID);
*
* will define:
*
* kURIRDF_ID to be "http://www.w3.org/TR/WD-rdf-syntax#ID"
*/
#define DEFINE_RDF_VOCAB(ns, prefix, name) \
static const char kURI##prefix##_##name[] = ns #name
/**
* Core RDF vocabularies that we use to define semantics
*/
#define RDF_NAMESPACE_URI "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
#define WEB_NAMESPACE_URI "http://home.netscape.com/WEB-rdf#"
#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
/* ContractID prefixes for RDF DLL registration. */
#define NS_RDF_CONTRACTID "@mozilla.org/rdf"
#define NS_RDF_DATASOURCE_CONTRACTID NS_RDF_CONTRACTID "/datasource;1"
#define NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_RDF_DATASOURCE_CONTRACTID "?name="
#define NS_RDF_RESOURCE_FACTORY_CONTRACTID "@mozilla.org/rdf/resource-factory;1"
#define NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX NS_RDF_RESOURCE_FACTORY_CONTRACTID "?name="
#define NS_RDF_INFER_DATASOURCE_CONTRACTID_PREFIX NS_RDF_CONTRACTID "/infer-datasource;1?engine="
// contract ID is in the form
// @mozilla.org/rdf/delegate-factory;1?key=<key>&scheme=<scheme>
#define NS_RDF_DELEGATEFACTORY_CONTRACTID "@mozilla.org/rdf/delegate-factory;1"
#define NS_RDF_DELEGATEFACTORY_CONTRACTID_PREFIX NS_RDF_DELEGATEFACTORY_CONTRACTID "?key="
/*@}*/
#endif /* rdf_h___ */

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

@ -1,38 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface rdfITripleVisitor;
/**
* Interface used in RDF to describe data sources.
*
* @status PLASMA
*/
[scriptable, uuid(ebce86bd-1568-4a34-a808-9ccf9cde8087)]
interface rdfIDataSource : nsISupports
{
/**
* Visit all the subject resources in the datasource. The order is
* intederminate and may change from one invocation to the next.
* The subjects will be in the aSubject argument in calls into
* aVisitor, aPredicate and aObject will be null.
* @note Implementations may throw NS_ERROR_NOT_IMPLEMENTED for
* this method, but in this case RDF serializations of this
* datasource will not be possible.
*/
void visitAllSubjects(in rdfITripleVisitor aVisitor);
/**
* Visit all the triples in the datasource. The order is
* intederminate and may change from one invocation to the next.
* @note Implementations may throw NS_ERROR_NOT_IMPLEMENTED for
* this method, but in this case RDF serializations of this
* datasource will not be possible.
*/
void visitAllTriples(in rdfITripleVisitor aVisitor);
};

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

@ -1,31 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIRDFResource;
interface nsIRDFNode;
/**
* Interface used in RDF to enumerate triples.
* Also used by rdfIDataSource::getAllSubjects, then aPredicate,
* aObject and aTruthValue are ignored.
*
* @status PLASMA
*/
[scriptable, function, uuid(aafea151-c271-4505-9978-a100d292800c)]
interface rdfITripleVisitor : nsISupports
{
/**
* Callback function for returning query results.
*
* @param aSubject, aPredicate, aObject describe the (sub-)arc
* @returnCode NS_RDF_STOP_VISIT to stop iterating over the query result.
* Any error code will stop the iteration as well.
*/
void visit(in nsIRDFNode aSubject, in nsIRDFResource aPredicate,
in nsIRDFNode aObject, in boolean aTruthValue);
};

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

@ -1,110 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
Implementations for a bunch of useful RDF utility routines. Many of
these will eventually be exported outside of RDF.DLL via the
nsIRDFService interface.
TO DO
1) Make this so that it doesn't permanently leak the RDF service
object.
2) Make container functions thread-safe. They currently don't ensure
that the RDF:nextVal property is maintained safely.
*/
#include "nsCOMPtr.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsIURL.h"
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsRDFCID.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "rdfutil.h"
#include "prtime.h"
////////////////////////////////////////////////////////////////////////
nsresult
rdf_MakeRelativeRef(const nsACString& aBaseURI, nsCString& aURI)
{
// This implementation is extremely simple: e.g., it can't compute
// relative paths, or anything fancy like that. If the context URI
// is not a prefix of the URI in question, we'll just bail.
uint32_t prefixLen = aBaseURI.Length();
if (prefixLen != 0 && StringBeginsWith(aURI, aBaseURI)) {
if (prefixLen < aURI.Length() && aURI.CharAt(prefixLen) == '/')
++prefixLen; // chop the leading slash so it's not `absolute'
aURI.Cut(0, prefixLen);
}
return NS_OK;
}
void
rdf_FormatDate(PRTime aTime, nsACString &aResult)
{
// Outputs Unixish date in GMT plus usecs; e.g.,
// Wed Jan 9 19:15:13 2002 +002441
//
PRExplodedTime t;
PR_ExplodeTime(aTime, PR_GMTParameters, &t);
char buf[256];
PR_FormatTimeUSEnglish(buf, sizeof buf, "%a %b %d %H:%M:%S %Y", &t);
aResult.Append(buf);
// usecs
aResult.AppendLiteral(" +");
int32_t usec = t.tm_usec;
for (int32_t digit = 100000; digit > 1; digit /= 10) {
aResult.Append(char('0' + (usec / digit)));
usec %= digit;
}
aResult.Append(char('0' + usec));
}
PRTime
rdf_ParseDate(const nsACString &aTime)
{
PRTime t;
PR_ParseTimeString(PromiseFlatCString(aTime).get(), true, &t);
int32_t usec = 0;
nsACString::const_iterator begin, digit, end;
aTime.BeginReading(begin);
aTime.EndReading(end);
// Walk backwards until we find a `+', run out of string, or a
// non-numeric character.
digit = end;
while (--digit != begin && *digit != '+') {
if (*digit < '0' || *digit > '9')
break;
}
if (digit != begin && *digit == '+') {
// There's a usec field specified (or, at least, something
// that looks close enough. Parse it, and add it to the time.
while (++digit != end) {
usec *= 10;
usec += *digit - '0';
}
t += usec;
}
return t;
}

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

@ -1,38 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
A bunch of useful RDF utility routines. Many of these will
eventually be exported outside of RDF.DLL via the nsIRDFService
interface.
TO DO
1) Move the anonymous resource stuff to nsIRDFService?
2) All that's left is rdf_PossiblyMakeRelative() and
-Absolute(). Maybe those go on nsIRDFService, too.
*/
#ifndef rdfutil_h__
#define rdfutil_h__
#include "nsStringFwd.h"
nsresult
rdf_MakeRelativeRef(const nsACString& aBaseURI, nsCString& aURI);
void
rdf_FormatDate(PRTime aTime, nsACString &aResult);
PRTime
rdf_ParseDate(const nsACString &aTime);
#endif // rdfutil_h__

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

@ -1,20 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS += [
'nsRDFCID.h',
]
SOURCES += [
'nsRDFModule.cpp',
]
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/rdf/base',
'/rdf/datasource',
]

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

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
XPCOM Class IDs for RDF objects that can be constructed via the RDF
factory.
*/
#ifndef nsRDFCID_h__
#define nsRDFCID_h__
// {0F78DA56-8321-11d2-8EAC-00805F29F370}
#define NS_RDFDEFAULTRESOURCE_CID \
{ 0xf78da56, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {BFD05264-834C-11d2-8EAC-00805F29F370}
#define NS_RDFSERVICE_CID \
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {BFD0526D-834C-11d2-8EAC-00805F29F370}
#define NS_RDFINMEMORYDATASOURCE_CID \
{ 0xbfd0526d, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {E638D760-8687-11d2-B530-000000000001}
#define NS_RDFFILESYSTEMDATASOURCE_CID \
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x01 } }
// {6bd1d807-1c67-11d3-9820-ed1b357eb3c4}
#define NS_RDFSEARCHDATASOURCE_CID \
{ 0x6bd1d807, 0x1c67, 0x11d3, { 0x98, 0x20, 0xed, 0x1b, 0x35, 0x7e, 0xb3, 0xc4 } }
// {E638D760-8687-11d2-B530-000000000002}
#define NS_RDFFINDDATASOURCE_CID \
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x02 } }
// {E638D761-8687-11d2-B530-000000000000}
#define NS_RDFCOMPOSITEDATASOURCE_CID \
{ 0xe638d761, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
// {7BAF62E0-8E61-11d2-8EB1-00805F29F370}
#define NS_RDFXMLDATASOURCE_CID \
{ 0x7baf62e0, 0x8e61, 0x11d2, { 0x8e, 0xb1, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {0958B101-9ADA-11d2-8EBC-00805F29F370}
#define NS_RDFCONTENTSINK_CID \
{ 0x958b101, 0x9ada, 0x11d2, { 0x8e, 0xbc, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {1EAAFD60-D596-11d2-80BE-006097B76B8E}
#define NS_RDFHISTORYDATASOURCE_CID \
{ 0x1eaafd60, 0xd596, 0x11d2, { 0x80, 0xbe, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } }
// {D4214E92-FB94-11d2-BDD8-00104BDE6048}
#define NS_RDFCONTAINERUTILS_CID \
{ 0xd4214e92, 0xfb94, 0x11d2, { 0xbd, 0xd8, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
// {D4214E93-FB94-11d2-BDD8-00104BDE6048}
#define NS_RDFCONTAINER_CID \
{ 0xd4214e93, 0xfb94, 0x11d2, { 0xbd, 0xd8, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
// {0032d852-1dd2-11b2-95f7-e0a1910ed2da}
#define NS_RDFXMLSERIALIZER_CID \
{ 0x0032d852, 0x1dd2, 0x11b2, { 0x95, 0xf7, 0xe0, 0xa1, 0x91, 0x0e, 0xd2, 0xda } }
// {a4048e94-1dd1-11b2-a676-8a06c086cc7d}
#define NS_RDFXMLPARSER_CID \
{ 0xa4048e94, 0x1dd1, 0x11b2, { 0xa6, 0x76, 0x8a, 0x06, 0xc0, 0x86, 0xcc, 0x7d } }
// {0a5cd734-eb65-4d14-88a0-9f0bb2aba206}
#define NS_RDFNTRIPLES_SERIALIZER_CID \
{ 0x0a5cd734, 0xeb65, 0x4d14, { 0x88, 0xa0, 0x9f, 0x0b, 0xb2, 0xab, 0xa2, 0x06 } }
#endif // nsRDFCID_h__

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

@ -1,120 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCOMPtr.h"
#include "mozilla/ModuleUtils.h"
#include "nsIFactory.h"
#include "nsRDFService.h"
#include "nsIRDFContainer.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFContentSink.h"
#include "nsISupports.h"
#include "nsRDFBaseDataSources.h"
#include "nsRDFBuiltInDataSources.h"
#include "nsRDFCID.h"
#include "nsIComponentManager.h"
#include "rdf.h"
#include "nsIServiceManager.h"
#include "nsILocalStore.h"
#include "nsRDFXMLParser.h"
#include "nsRDFXMLSerializer.h"
//----------------------------------------------------------------------
// Functions used to create new instances of a given object by the
// generic factory.
#define MAKE_CTOR(_func,_new,_ifname) \
static nsresult \
CreateNew##_func(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
{ \
if (!aResult) { \
return NS_ERROR_INVALID_POINTER; \
} \
if (aOuter) { \
*aResult = nullptr; \
return NS_ERROR_NO_AGGREGATION; \
} \
nsI##_ifname* inst; \
nsresult rv = NS_New##_new(&inst); \
if (NS_FAILED(rv)) { \
*aResult = nullptr; \
return rv; \
} \
rv = inst->QueryInterface(aIID, aResult); \
if (NS_FAILED(rv)) { \
*aResult = nullptr; \
} \
NS_RELEASE(inst); /* get rid of extra refcnt */ \
return rv; \
}
extern nsresult
NS_NewDefaultResource(nsIRDFResource** aResult);
MAKE_CTOR(RDFXMLDataSource,RDFXMLDataSource,RDFDataSource)
MAKE_CTOR(RDFCompositeDataSource,RDFCompositeDataSource,RDFCompositeDataSource)
MAKE_CTOR(RDFContainer,RDFContainer,RDFContainer)
MAKE_CTOR(RDFContainerUtils,RDFContainerUtils,RDFContainerUtils)
MAKE_CTOR(RDFContentSink,RDFContentSink,RDFContentSink)
MAKE_CTOR(RDFDefaultResource,DefaultResource,RDFResource)
NS_DEFINE_NAMED_CID(NS_RDFCOMPOSITEDATASOURCE_CID);
NS_DEFINE_NAMED_CID(NS_RDFINMEMORYDATASOURCE_CID);
NS_DEFINE_NAMED_CID(NS_RDFXMLDATASOURCE_CID);
NS_DEFINE_NAMED_CID(NS_RDFDEFAULTRESOURCE_CID);
NS_DEFINE_NAMED_CID(NS_RDFCONTENTSINK_CID);
NS_DEFINE_NAMED_CID(NS_RDFCONTAINER_CID);
NS_DEFINE_NAMED_CID(NS_RDFCONTAINERUTILS_CID);
NS_DEFINE_NAMED_CID(NS_RDFSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_RDFXMLPARSER_CID);
NS_DEFINE_NAMED_CID(NS_RDFXMLSERIALIZER_CID);
NS_DEFINE_NAMED_CID(NS_LOCALSTORE_CID);
static const mozilla::Module::CIDEntry kRDFCIDs[] = {
{ &kNS_RDFCOMPOSITEDATASOURCE_CID, false, nullptr, CreateNewRDFCompositeDataSource },
{ &kNS_RDFINMEMORYDATASOURCE_CID, false, nullptr, NS_NewRDFInMemoryDataSource },
{ &kNS_RDFXMLDATASOURCE_CID, false, nullptr, CreateNewRDFXMLDataSource },
{ &kNS_RDFDEFAULTRESOURCE_CID, false, nullptr, CreateNewRDFDefaultResource },
{ &kNS_RDFCONTENTSINK_CID, false, nullptr, CreateNewRDFContentSink },
{ &kNS_RDFCONTAINER_CID, false, nullptr, CreateNewRDFContainer },
{ &kNS_RDFCONTAINERUTILS_CID, false, nullptr, CreateNewRDFContainerUtils },
{ &kNS_RDFSERVICE_CID, false, nullptr, RDFServiceImpl::CreateSingleton },
{ &kNS_RDFXMLPARSER_CID, false, nullptr, nsRDFXMLParser::Create },
{ &kNS_RDFXMLSERIALIZER_CID, false, nullptr, nsRDFXMLSerializer::Create },
{ &kNS_LOCALSTORE_CID, false, nullptr, NS_NewLocalStore },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kRDFContracts[] = {
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "composite-datasource", &kNS_RDFCOMPOSITEDATASOURCE_CID },
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "in-memory-datasource", &kNS_RDFINMEMORYDATASOURCE_CID },
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "xml-datasource", &kNS_RDFXMLDATASOURCE_CID },
{ NS_RDF_RESOURCE_FACTORY_CONTRACTID, &kNS_RDFDEFAULTRESOURCE_CID },
{ NS_RDF_CONTRACTID "/content-sink;1", &kNS_RDFCONTENTSINK_CID },
{ NS_RDF_CONTRACTID "/container;1", &kNS_RDFCONTAINER_CID },
{ NS_RDF_CONTRACTID "/container-utils;1", &kNS_RDFCONTAINERUTILS_CID },
{ NS_RDF_CONTRACTID "/rdf-service;1", &kNS_RDFSERVICE_CID },
{ NS_RDF_CONTRACTID "/xml-parser;1", &kNS_RDFXMLPARSER_CID },
{ NS_RDF_CONTRACTID "/xml-serializer;1", &kNS_RDFXMLSERIALIZER_CID },
{ NS_LOCALSTORE_CONTRACTID, &kNS_LOCALSTORE_CID },
{ nullptr }
};
static const mozilla::Module kRDFModule = {
mozilla::Module::kVersion,
kRDFCIDs,
kRDFContracts,
nullptr,
nullptr,
nullptr,
nullptr
};
NSMODULE_DEFN(nsRDFModule) = &kRDFModule;

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

@ -1,21 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS += [
'nsILocalStore.h',
]
UNIFIED_SOURCES += [
'nsLocalStore.cpp',
]
FINAL_LIBRARY = 'xul'
# "This is a dependency on rdfutil.h: it'll go away once that becomes
# a first-class XPCOM interface."
LOCAL_INCLUDES += [
'/rdf/base',
]

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

@ -1,34 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsILocalStore_h__
#define nsILocalStore_h__
#include "rdf.h"
#include "nsISupports.h"
// {DF71C6F1-EC53-11d2-BDCA-000064657374}
#define NS_ILOCALSTORE_IID \
{ 0xdf71c6f1, 0xec53, 0x11d2, { 0xbd, 0xca, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
// {DF71C6F0-EC53-11d2-BDCA-000064657374}
#define NS_LOCALSTORE_CID \
{ 0xdf71c6f0, 0xec53, 0x11d2, { 0xbd, 0xca, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
#define NS_LOCALSTORE_CONTRACTID NS_RDF_DATASOURCE_CONTRACTID_PREFIX "local-store"
class nsILocalStore : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILOCALSTORE_IID)
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsILocalStore, NS_ILOCALSTORE_IID)
extern nsresult
NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult);
#endif // nsILocalStore_h__

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

@ -1,33 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsIRDFFTP_h__
#define nsIRDFFTP_h__
#include "nscore.h"
#include "nsISupports.h"
#include "nsIRDFNode.h"
#define NS_IRDFFTPDATAOURCE_IID \
{ 0x1222e6f0, 0xa5e3, 0x11d2, { 0x8b, 0x7c, 0x00, 0x80, 0x5f, 0x8a, 0x7d, 0xb7 } }
class nsIRDFFTPDataSource : public nsIRDFDataSource
{
public:
};
#define NS_IRDFFTPDATASOURCECALLBACK_IID \
{ 0x204a1a00, 0xa5e4, 0x11d2, { 0x8b, 0x7c, 0x00, 0x80, 0x5f, 0x8a, 0x7d, 0xb8 } }
class nsIRDFFTPDataSourceCallback : public nsIStreamListener
{
public:
};
#endif // nsIRDFFTP_h__

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

@ -1,474 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set cindent tabstop=4 expandtab shiftwidth=4: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
Implementation for the local store
*/
#include "nsNetUtil.h"
#include "nsIFile.h"
#include "nsIURI.h"
#include "nsIIOService.h"
#include "nsIOutputStream.h"
#include "nsIComponentManager.h"
#include "nsILocalStore.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFRemoteDataSource.h"
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsRDFCID.h"
#include "nsString.h"
#include "plstr.h"
#include "rdf.h"
#include "nsCOMPtr.h"
#include "nsWeakPtr.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsWeakReference.h"
#include "nsCRTGlue.h"
#include "nsCRT.h"
#include "nsEnumeratorUtils.h"
#include "nsCycleCollectionParticipant.h"
////////////////////////////////////////////////////////////////////////
class LocalStoreImpl : public nsILocalStore,
public nsIRDFDataSource,
public nsIRDFRemoteDataSource,
public nsIObserver,
public nsSupportsWeakReference
{
protected:
nsCOMPtr<nsIRDFDataSource> mInner;
LocalStoreImpl();
virtual ~LocalStoreImpl();
nsresult Init();
nsresult CreateLocalStore(nsIFile* aFile);
nsresult LoadData();
friend nsresult
NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult);
nsCOMPtr<nsIRDFService> mRDFService;
public:
// nsISupports interface
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(LocalStoreImpl, nsILocalStore)
// nsILocalStore interface
// nsIRDFDataSource interface. Most of these are just delegated to
// the inner, in-memory datasource.
NS_IMETHOD GetURI(nsACString& aURI) override;
NS_IMETHOD GetSource(nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
bool aTruthValue,
nsIRDFResource** aSource) override {
return mInner->GetSource(aProperty, aTarget, aTruthValue, aSource);
}
NS_IMETHOD GetSources(nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
bool aTruthValue,
nsISimpleEnumerator** aSources) override {
return mInner->GetSources(aProperty, aTarget, aTruthValue, aSources);
}
NS_IMETHOD GetTarget(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
bool aTruthValue,
nsIRDFNode** aTarget) override {
return mInner->GetTarget(aSource, aProperty, aTruthValue, aTarget);
}
NS_IMETHOD GetTargets(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
bool aTruthValue,
nsISimpleEnumerator** aTargets) override {
return mInner->GetTargets(aSource, aProperty, aTruthValue, aTargets);
}
NS_IMETHOD Assert(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
bool aTruthValue) override {
return mInner->Assert(aSource, aProperty, aTarget, aTruthValue);
}
NS_IMETHOD Unassert(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget) override {
return mInner->Unassert(aSource, aProperty, aTarget);
}
NS_IMETHOD Change(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget,
nsIRDFNode* aNewTarget) override {
return mInner->Change(aSource, aProperty, aOldTarget, aNewTarget);
}
NS_IMETHOD Move(nsIRDFResource* aOldSource,
nsIRDFResource* aNewSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget) override {
return mInner->Move(aOldSource, aNewSource, aProperty, aTarget);
}
NS_IMETHOD HasAssertion(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
bool aTruthValue,
bool* hasAssertion) override {
return mInner->HasAssertion(aSource, aProperty, aTarget, aTruthValue, hasAssertion);
}
NS_IMETHOD AddObserver(nsIRDFObserver* aObserver) override {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHOD RemoveObserver(nsIRDFObserver* aObserver) override {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, bool *_retval) override {
return mInner->HasArcIn(aNode, aArc, _retval);
}
NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *_retval) override {
return mInner->HasArcOut(aSource, aArc, _retval);
}
NS_IMETHOD ArcLabelsIn(nsIRDFNode* aNode,
nsISimpleEnumerator** aLabels) override {
return mInner->ArcLabelsIn(aNode, aLabels);
}
NS_IMETHOD ArcLabelsOut(nsIRDFResource* aSource,
nsISimpleEnumerator** aLabels) override {
return mInner->ArcLabelsOut(aSource, aLabels);
}
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult) override {
return mInner->GetAllResources(aResult);
}
NS_IMETHOD GetAllCmds(nsIRDFResource* aSource,
nsISimpleEnumerator/*<nsIRDFResource>*/** aCommands) override;
NS_IMETHOD IsCommandEnabled(nsISupports* aSources,
nsIRDFResource* aCommand,
nsISupports* aArguments,
bool* aResult) override;
NS_IMETHOD DoCommand(nsISupports* aSources,
nsIRDFResource* aCommand,
nsISupports* aArguments) override;
NS_IMETHOD BeginUpdateBatch() override {
return mInner->BeginUpdateBatch();
}
NS_IMETHOD EndUpdateBatch() override {
return mInner->EndUpdateBatch();
}
NS_IMETHOD GetLoaded(bool* _result) override;
NS_IMETHOD Init(const char *uri) override;
NS_IMETHOD Flush() override;
NS_IMETHOD FlushTo(const char *aURI) override;
NS_IMETHOD Refresh(bool sync) override;
// nsIObserver
NS_DECL_NSIOBSERVER
};
////////////////////////////////////////////////////////////////////////
LocalStoreImpl::LocalStoreImpl(void)
{
}
LocalStoreImpl::~LocalStoreImpl(void)
{
if (mRDFService)
mRDFService->UnregisterDataSource(this);
}
nsresult
NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
NS_PRECONDITION(aOuter == nullptr, "no aggregation");
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
NS_PRECONDITION(aResult != nullptr, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
LocalStoreImpl* impl = new LocalStoreImpl();
if (! impl)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(impl);
nsresult rv;
rv = impl->Init();
if (NS_SUCCEEDED(rv)) {
// Set up the result pointer
rv = impl->QueryInterface(aIID, aResult);
}
NS_RELEASE(impl);
return rv;
}
NS_IMPL_CYCLE_COLLECTION(LocalStoreImpl, mInner)
NS_IMPL_CYCLE_COLLECTING_ADDREF(LocalStoreImpl)
NS_IMPL_CYCLE_COLLECTING_RELEASE(LocalStoreImpl)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(LocalStoreImpl)
NS_INTERFACE_MAP_ENTRY(nsILocalStore)
NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
NS_INTERFACE_MAP_ENTRY(nsIRDFRemoteDataSource)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsILocalStore)
NS_INTERFACE_MAP_END
// nsILocalStore interface
// nsIRDFDataSource interface
NS_IMETHODIMP
LocalStoreImpl::GetLoaded(bool* _result)
{
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
NS_ASSERTION(remote != nullptr, "not an nsIRDFRemoteDataSource");
if (! remote)
return NS_ERROR_UNEXPECTED;
return remote->GetLoaded(_result);
}
NS_IMETHODIMP
LocalStoreImpl::Init(const char *uri)
{
return(NS_OK);
}
NS_IMETHODIMP
LocalStoreImpl::Flush()
{
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
// FIXME Bug 340242: Temporarily make this a warning rather than an
// assertion until we sort out the ordering of how we write
// everything to the localstore, flush it, and disconnect it when
// we're getting profile-change notifications.
NS_WARNING_ASSERTION(remote != nullptr, "not an nsIRDFRemoteDataSource");
if (! remote)
return NS_ERROR_UNEXPECTED;
return remote->Flush();
}
NS_IMETHODIMP
LocalStoreImpl::FlushTo(const char *aURI)
{
// Do not ever implement this (security)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
LocalStoreImpl::Refresh(bool sync)
{
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
NS_ASSERTION(remote != nullptr, "not an nsIRDFRemoteDataSource");
if (! remote)
return NS_ERROR_UNEXPECTED;
return remote->Refresh(sync);
}
nsresult
LocalStoreImpl::Init()
{
nsresult rv;
rv = LoadData();
if (NS_FAILED(rv)) return rv;
// register this as a named data source with the RDF service
mRDFService = do_GetService(NS_RDF_CONTRACTID "/rdf-service;1", &rv);
if (NS_FAILED(rv)) return rv;
mRDFService->RegisterDataSource(this, false);
// Register as an observer of profile changes
nsCOMPtr<nsIObserverService> obs =
do_GetService("@mozilla.org/observer-service;1");
if (obs) {
obs->AddObserver(this, "profile-before-change", true);
obs->AddObserver(this, "profile-do-change", true);
}
return NS_OK;
}
nsresult
LocalStoreImpl::CreateLocalStore(nsIFile* aFile)
{
nsresult rv;
rv = aFile->Create(nsIFile::NORMAL_FILE_TYPE, 0666);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIOutputStream> outStream;
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outStream), aFile);
if (NS_FAILED(rv)) return rv;
const char defaultRDF[] =
"<?xml version=\"1.0\"?>\n" \
"<RDF:RDF xmlns:RDF=\"" RDF_NAMESPACE_URI "\"\n" \
" xmlns:NC=\"" NC_NAMESPACE_URI "\">\n" \
" <!-- Empty -->\n" \
"</RDF:RDF>\n";
uint32_t count;
rv = outStream->Write(defaultRDF, sizeof(defaultRDF)-1, &count);
if (NS_FAILED(rv)) return rv;
if (count != sizeof(defaultRDF)-1)
return NS_ERROR_UNEXPECTED;
// Okay, now see if the file exists _for real_. If it's still
// not there, it could be that the profile service gave us
// back a read-only directory. Whatever.
bool fileExistsFlag = false;
aFile->Exists(&fileExistsFlag);
if (!fileExistsFlag)
return NS_ERROR_UNEXPECTED;
return NS_OK;
}
nsresult
LocalStoreImpl::LoadData()
{
nsresult rv;
// Look for localstore.rdf in the current profile
// directory. Bomb if we can't find it.
nsCOMPtr<nsIFile> aFile;
rv = NS_GetSpecialDirectory(NS_APP_LOCALSTORE_50_FILE, getter_AddRefs(aFile));
if (NS_FAILED(rv)) return rv;
bool fileExistsFlag = false;
(void)aFile->Exists(&fileExistsFlag);
if (!fileExistsFlag) {
// if file doesn't exist, create it
rv = CreateLocalStore(aFile);
if (NS_FAILED(rv)) return rv;
}
mInner = do_CreateInstance(NS_RDF_DATASOURCE_CONTRACTID_PREFIX "xml-datasource", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> aURI;
rv = NS_NewFileURI(getter_AddRefs(aURI), aFile);
if (NS_FAILED(rv)) return rv;
nsAutoCString spec;
rv = aURI->GetSpec(spec);
if (NS_FAILED(rv)) return rv;
rv = remote->Init(spec.get());
if (NS_FAILED(rv)) return rv;
// Read the datasource synchronously.
rv = remote->Refresh(true);
if (NS_FAILED(rv)) {
// Load failed, delete and recreate a fresh localstore
aFile->Remove(true);
rv = CreateLocalStore(aFile);
if (NS_FAILED(rv)) return rv;
rv = remote->Refresh(true);
}
return rv;
}
NS_IMETHODIMP
LocalStoreImpl::GetURI(nsACString& aURI)
{
aURI.AssignLiteral("rdf:local-store");
return NS_OK;
}
NS_IMETHODIMP
LocalStoreImpl::GetAllCmds(nsIRDFResource* aSource,
nsISimpleEnumerator/*<nsIRDFResource>*/** aCommands)
{
return(NS_NewEmptyEnumerator(aCommands));
}
NS_IMETHODIMP
LocalStoreImpl::IsCommandEnabled(nsISupports* aSources,
nsIRDFResource* aCommand,
nsISupports* aArguments,
bool* aResult)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
LocalStoreImpl::DoCommand(nsISupports* aSources,
nsIRDFResource* aCommand,
nsISupports* aArguments)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
LocalStoreImpl::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData)
{
nsresult rv = NS_OK;
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
// Write out the old datasource's contents.
if (mInner) {
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
if (remote)
remote->Flush();
}
// Create an in-memory datasource for use while we're
// profile-less.
mInner = do_CreateInstance(NS_RDF_DATASOURCE_CONTRACTID_PREFIX "in-memory-datasource");
}
else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
rv = LoadData();
}
return rv;
}

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

@ -1,27 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
This header file just contains prototypes for the factory methods
for "builtin" data sources that are included in rdf.dll.
Each of these data sources is exposed to the external world via its
CID in ../include/nsRDFCID.h.
*/
#ifndef nsBuiltinDataSources_h__
#define nsBuiltinDataSources_h__
#include "nsError.h"
class nsIRDFDataSource;
// in nsFileSystemDataSource.cpp
nsresult NS_NewRDFFileSystemDataSource(nsIRDFDataSource** result);
#endif // nsBuiltinDataSources_h__

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

@ -1,12 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('**'):
BUG_COMPONENT = ('Core', 'RDF')
DIRS += ['base', 'datasource', 'build']
TEST_DIRS += ['tests']

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

@ -1,7 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']

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

@ -1,9 +0,0 @@
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description about="urn:mozilla:sample-data"
dc:title="Sample" />
</rdf:RDF>

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

@ -1,92 +0,0 @@
ChromeUtils.import("resource://testing-common/httpd.js");
function getRDFService()
{
return Cc["@mozilla.org/rdf/rdf-service;1"].
getService(Ci.nsIRDFService);
}
var server1, server2;
function run_test()
{
var samplefile = do_get_file('sample.rdf');
server1 = new HttpServer();
server1.registerPathHandler("/sample-xs.rdf", xsRedirect);
server1.registerPathHandler("/sample-local.rdf", localRedirect);
server1.registerFile('/sample.rdf', samplefile);
server1.start(4444);
server2 = new HttpServer();
server2.registerFile('/sample.rdf', samplefile);
server2.start(4445);
do_test_pending();
new rdfLoadObserver('http://localhost:4444/sample.rdf', true);
new rdfLoadObserver('http://localhost:4445/sample.rdf', true);
new rdfLoadObserver('http://localhost:4444/sample-xs.rdf', false);
new rdfLoadObserver('http://localhost:4444/sample-local.rdf', true);
}
var gPending = 0;
function rdfLoadObserver(uri, shouldPass)
{
this.shouldPass = shouldPass;
this.uri = uri;
++gPending;
var rdfService = getRDFService();
this.ds = rdfService.GetDataSource(uri).
QueryInterface(Ci.nsIRDFXMLSink);
this.ds.addXMLSinkObserver(this);
}
rdfLoadObserver.prototype =
{
onBeginLoad : function() { },
onInterrupt : function() { },
onResume : function() { },
onEndLoad : function() {
print("Testing results of loading " + this.uri);
var rdfs = getRDFService();
var res = rdfs.GetResource("urn:mozilla:sample-data");
var arc = rdfs.GetResource("http://purl.org/dc/elements/1.1/title");
var answer = this.ds.GetTarget(res, arc, true);
if (answer !== null) {
Assert.ok(this.shouldPass);
Assert.ok(answer instanceof Ci.nsIRDFLiteral);
Assert.equal(answer.Value, "Sample");
}
else {
Assert.ok(!this.shouldPass);
}
gPending -= 1;
this.ds.removeXMLSinkObserver(this);
if (gPending == 0) {
do_test_pending();
server1.stop(do_test_finished);
server2.stop(do_test_finished);
}
},
onError : function() { }
}
function xsRedirect(metadata, response)
{
response.setStatusLine(metadata.httpVersion, 301, "Moved Permanently");
response.setHeader("Location", "http://localhost:4445/sample.rdf", false);
}
function localRedirect(metadata, response)
{
response.setStatusLine(metadata.httpVersion, 301, "Moved Permanently");
response.setHeader("Location", "http://localhost:4444/sample.rdf", false);
}

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

@ -1,5 +0,0 @@
[DEFAULT]
head =
support-files = sample.rdf
[test_rdfredirect.js]

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

@ -20,7 +20,6 @@
#include "nsAlertsService.h"
#include "DownloadPlatform.h"
#include "rdf.h"
#include "nsTypeAheadFind.h"

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

@ -88,10 +88,6 @@ DIRS += [
'/extensions/permissions',
]
DIRS += [
'/rdf',
]
if CONFIG['MOZ_WEBRTC'] and CONFIG['COMPILE_ENVIRONMENT']:
DIRS += [
'/media/webrtc',