2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 22:33:16 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-09-28 04:44:47 +04:00
|
|
|
*
|
2004-04-17 22:33:16 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-09-28 04:44:47 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-09-28 04:44:47 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 22:33:16 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2005-12-13 17:27:13 +03:00
|
|
|
* Benjamin Smedberg <benjamin@smedbergs.us>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 22:33:16 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-17 22:33:16 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-17 22:33:16 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-09-28 04:44:47 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2000-01-04 02:37:30 +03:00
|
|
|
#include "nsIGenericFactory.h"
|
|
|
|
#include "nsIModule.h"
|
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
#include "nsRDFModule.h"
|
|
|
|
#include "nsIFactory.h"
|
2005-12-01 18:03:48 +03:00
|
|
|
#include "nsRDFService.h"
|
1999-09-28 04:44:47 +04:00
|
|
|
#include "nsIRDFContainer.h"
|
|
|
|
#include "nsIRDFContainerUtils.h"
|
|
|
|
#include "nsIRDFCompositeDataSource.h"
|
|
|
|
#include "nsIRDFContentSink.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsRDFBaseDataSources.h"
|
|
|
|
#include "nsRDFBuiltInDataSources.h"
|
2005-12-01 18:03:48 +03:00
|
|
|
#include "nsFileSystemDataSource.h"
|
1999-09-28 04:44:47 +04:00
|
|
|
#include "nsRDFCID.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "rdf.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2001-02-22 06:01:34 +03:00
|
|
|
#include "nsILocalStore.h"
|
2001-05-15 23:56:28 +04:00
|
|
|
#include "nsRDFXMLParser.h"
|
|
|
|
#include "nsRDFXMLSerializer.h"
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2005-06-24 11:49:44 +04:00
|
|
|
#include "rdfISerializer.h"
|
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Functions used to create new instances of a given object by the
|
|
|
|
// generic factory.
|
|
|
|
|
|
|
|
#define MAKE_CTOR(_func,_new,_ifname) \
|
1999-09-28 06:38:46 +04:00
|
|
|
static NS_IMETHODIMP \
|
1999-09-28 04:44:47 +04:00
|
|
|
CreateNew##_func(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
|
|
|
|
{ \
|
|
|
|
if (!aResult) { \
|
|
|
|
return NS_ERROR_INVALID_POINTER; \
|
|
|
|
} \
|
|
|
|
if (aOuter) { \
|
|
|
|
*aResult = nsnull; \
|
|
|
|
return NS_ERROR_NO_AGGREGATION; \
|
|
|
|
} \
|
|
|
|
nsI##_ifname* inst; \
|
|
|
|
nsresult rv = NS_New##_new(&inst); \
|
|
|
|
if (NS_FAILED(rv)) { \
|
|
|
|
*aResult = nsnull; \
|
1999-10-01 01:36:35 +04:00
|
|
|
return rv; \
|
1999-09-28 04:44:47 +04:00
|
|
|
} \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
if (NS_FAILED(rv)) { \
|
|
|
|
*aResult = nsnull; \
|
|
|
|
} \
|
|
|
|
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)
|
|
|
|
|
2005-06-24 11:49:44 +04:00
|
|
|
#define MAKE_RDF_CTOR(_func,_new,_ifname) \
|
|
|
|
static NS_IMETHODIMP \
|
|
|
|
CreateNew##_func(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
|
|
|
|
{ \
|
|
|
|
if (!aResult) { \
|
|
|
|
return NS_ERROR_INVALID_POINTER; \
|
|
|
|
} \
|
|
|
|
if (aOuter) { \
|
|
|
|
*aResult = nsnull; \
|
|
|
|
return NS_ERROR_NO_AGGREGATION; \
|
|
|
|
} \
|
|
|
|
rdfI##_ifname* inst; \
|
|
|
|
nsresult rv = NS_New##_new(&inst); \
|
|
|
|
if (NS_FAILED(rv)) { \
|
|
|
|
*aResult = nsnull; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
if (NS_FAILED(rv)) { \
|
|
|
|
*aResult = nsnull; \
|
|
|
|
} \
|
|
|
|
NS_RELEASE(inst); /* get rid of extra refcnt */ \
|
|
|
|
return rv; \
|
|
|
|
}
|
|
|
|
|
|
|
|
extern nsresult
|
|
|
|
NS_NewTriplesSerializer(rdfISerializer** aResult);
|
|
|
|
|
|
|
|
MAKE_RDF_CTOR(TriplesSerializer, TriplesSerializer, Serializer)
|
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
// The list of components we register
|
2002-01-31 00:14:20 +03:00
|
|
|
static const nsModuleComponentInfo components[] =
|
2000-01-04 02:37:30 +03:00
|
|
|
{ // register our build-in datasources:
|
|
|
|
{
|
|
|
|
"RDF Composite Data Source",
|
|
|
|
NS_RDFCOMPOSITEDATASOURCE_CID,
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_DATASOURCE_CONTRACTID_PREFIX "composite-datasource",
|
2000-01-04 02:37:30 +03:00
|
|
|
CreateNewRDFCompositeDataSource
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
"RDF File System Data Source",
|
|
|
|
NS_RDFFILESYSTEMDATASOURCE_CID,
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_DATASOURCE_CONTRACTID_PREFIX "files",
|
2005-12-01 18:03:48 +03:00
|
|
|
FileSystemDataSource::Create
|
2000-01-04 02:37:30 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
{ "RDF In-Memory Data Source",
|
|
|
|
NS_RDFINMEMORYDATASOURCE_CID,
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_DATASOURCE_CONTRACTID_PREFIX "in-memory-datasource",
|
2000-01-04 02:37:30 +03:00
|
|
|
NS_NewRDFInMemoryDataSource
|
|
|
|
},
|
|
|
|
|
|
|
|
{ "RDF XML Data Source",
|
|
|
|
NS_RDFXMLDATASOURCE_CID,
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_DATASOURCE_CONTRACTID_PREFIX "xml-datasource",
|
2000-01-04 02:37:30 +03:00
|
|
|
CreateNewRDFXMLDataSource
|
|
|
|
},
|
1999-09-28 04:44:47 +04:00
|
|
|
|
|
|
|
// register our built-in resource factories:
|
2000-01-04 02:37:30 +03:00
|
|
|
{ "RDF Default Resource Factory",
|
|
|
|
NS_RDFDEFAULTRESOURCE_CID,
|
1999-09-28 04:44:47 +04:00
|
|
|
// Note: default resource factory has no name= part
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_RESOURCE_FACTORY_CONTRACTID,
|
2000-01-04 02:37:30 +03:00
|
|
|
CreateNewRDFDefaultResource
|
|
|
|
},
|
1999-09-28 04:44:47 +04:00
|
|
|
|
|
|
|
// register all the other rdf components:
|
2000-01-04 02:37:30 +03:00
|
|
|
{ "RDF Content Sink",
|
|
|
|
NS_RDFCONTENTSINK_CID,
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_CONTRACTID "/content-sink;1",
|
2000-01-04 02:37:30 +03:00
|
|
|
CreateNewRDFContentSink
|
|
|
|
},
|
|
|
|
|
|
|
|
{ "RDF Container",
|
|
|
|
NS_RDFCONTAINER_CID,
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_CONTRACTID "/container;1",
|
2000-01-04 02:37:30 +03:00
|
|
|
CreateNewRDFContainer
|
|
|
|
},
|
|
|
|
|
|
|
|
{ "RDF Container Utilities",
|
|
|
|
NS_RDFCONTAINERUTILS_CID,
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_CONTRACTID "/container-utils;1",
|
2000-01-04 02:37:30 +03:00
|
|
|
CreateNewRDFContainerUtils
|
|
|
|
},
|
|
|
|
|
|
|
|
{ "RDF Service",
|
|
|
|
NS_RDFSERVICE_CID,
|
2000-09-14 03:57:52 +04:00
|
|
|
NS_RDF_CONTRACTID "/rdf-service;1",
|
2005-12-01 18:03:48 +03:00
|
|
|
RDFServiceImpl::CreateSingleton
|
2000-01-04 02:37:30 +03:00
|
|
|
},
|
|
|
|
|
2001-05-15 23:56:28 +04:00
|
|
|
{ "RDF/XML Parser",
|
|
|
|
NS_RDFXMLPARSER_CID,
|
|
|
|
NS_RDF_CONTRACTID "/xml-parser;1",
|
|
|
|
nsRDFXMLParser::Create
|
|
|
|
},
|
|
|
|
|
|
|
|
{ "RDF/XML Serializer",
|
|
|
|
NS_RDFXMLSERIALIZER_CID,
|
|
|
|
NS_RDF_CONTRACTID "/xml-serializer;1",
|
|
|
|
nsRDFXMLSerializer::Create
|
|
|
|
},
|
|
|
|
|
2005-06-24 11:49:44 +04:00
|
|
|
{ "RDF/NTriples Serializer",
|
|
|
|
NS_RDFNTRIPLES_SERIALIZER_CID,
|
|
|
|
NS_RDF_SERIALIZER "ntriples",
|
|
|
|
CreateNewTriplesSerializer
|
|
|
|
},
|
|
|
|
|
2001-02-22 06:01:34 +03:00
|
|
|
// XXX move this to XPFE at some point.
|
|
|
|
{ "Local Store", NS_LOCALSTORE_CID,
|
|
|
|
NS_LOCALSTORE_CONTRACTID, NS_NewLocalStore },
|
1999-09-28 04:44:47 +04:00
|
|
|
};
|
|
|
|
|
2005-12-01 18:03:48 +03:00
|
|
|
static nsresult
|
|
|
|
StartupRDFModule(nsIModule* unused)
|
|
|
|
{
|
|
|
|
if (RDFServiceImpl::gRDFService) {
|
|
|
|
NS_ERROR("Leaked the RDF service from a previous startup.");
|
|
|
|
RDFServiceImpl::gRDFService = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ShutdownRDFModule(nsIModule* unused)
|
|
|
|
{
|
|
|
|
if (RDFServiceImpl::gRDFService) {
|
|
|
|
// XXX make this an assertion!
|
|
|
|
NS_WARNING("Leaking the RDF Service.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsRDFModule, components,
|
|
|
|
StartupRDFModule, ShutdownRDFModule)
|