Compare commits
4 Commits
Bugzilla_P
...
RDF_199904
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7b9563ca4 | ||
|
|
ea0eaee19a | ||
|
|
adfaee71ff | ||
|
|
a47b470619 |
107
mozilla/chrome/src/nsChromeFactory.cpp
Normal file
107
mozilla/chrome/src/nsChromeFactory.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nscore.h"
|
||||
#include "rdf.h"
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
|
||||
static NS_IMETHODIMP
|
||||
NS_ConstructChromeRegistry(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aOuter == nsnull, "no aggregation");
|
||||
nsIChromeRegistry* chromeRegistry;
|
||||
rv = NS_NewChromeRegistry(&chromeRegistry);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Unable to construct chrome registry");
|
||||
return rv;
|
||||
}
|
||||
rv = chromeRegistry->QueryInterface(aIID, aResult);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
|
||||
NS_RELEASE(chromeRegistry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aFactory != nsnull, "bad factory pointer");
|
||||
NS_ASSERTION(aClass.Equals(kChromeRegistryCID), "incorrectly registered");
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIGenericFactory* factory;
|
||||
rv = compMgr->CreateInstance(kGenericFactoryCID, nsnull, nsIGenericFactory::GetIID(),
|
||||
(void**)&factory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = factory->SetConstructor(NS_ConstructChromeRegistry);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete factory;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kChromeRegistryCID,
|
||||
"Chrome Registry",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "chrome",
|
||||
aPath,
|
||||
PR_TRUE, PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kChromeRegistryCID, aPath);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
601
mozilla/chrome/src/nsChromeRegistry.cpp
Normal file
601
mozilla/chrome/src/nsChromeRegistry.cpp
Normal file
@@ -0,0 +1,601 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsCRT.h"
|
||||
#include "rdf.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
#define CHROME_NAMESPACE_URI "http://chrome.mozilla.org/rdf#"
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, chrome);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, skin);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, content);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, locale);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, platform);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, behavior);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, base);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, main);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, archive);
|
||||
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, Description);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsChromeRegistry : public nsIChromeRegistry, public nsIRDFDataSource {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIChromeRegistry methods:
|
||||
NS_IMETHOD InitRegistry();
|
||||
NS_IMETHOD ConvertChromeURL(nsIURL* aChromeURL);
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHOD Init(const char* uri) ; // Called to init the data source.
|
||||
NS_IMETHOD GetURI(char** uri);
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source /* out */) ;
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** sources /* out */) ;
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target /* out */) ;
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** targets /* out */) ;
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv) ;
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target) ;
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion /* out */) ;
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n) ;
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n) ;
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsISimpleEnumerator** labels /* out */) ;
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsISimpleEnumerator** labels /* out */) ;
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult) ;
|
||||
NS_IMETHOD Flush(void) ;
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands) ;
|
||||
NS_IMETHOD IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
|
||||
PRBool* retVal) ;
|
||||
NS_IMETHOD DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments) ;
|
||||
|
||||
// nsChromeRegistry methods:
|
||||
nsChromeRegistry();
|
||||
virtual ~nsChromeRegistry();
|
||||
|
||||
static PRUint32 gRefCnt;
|
||||
static nsIRDFService* gRDFService;
|
||||
static nsIRDFResource* kCHROME_chrome;
|
||||
static nsIRDFResource* kCHROME_skin;
|
||||
static nsIRDFResource* kCHROME_content;
|
||||
static nsIRDFResource* kCHROME_platform;
|
||||
static nsIRDFResource* kCHROME_locale;
|
||||
static nsIRDFResource* kCHROME_behavior;
|
||||
static nsIRDFResource* kCHROME_base;
|
||||
static nsIRDFResource* kCHROME_main;
|
||||
static nsIRDFResource* kCHROME_archive;
|
||||
static nsIRDFDataSource* mInner;
|
||||
|
||||
protected:
|
||||
nsresult GetProviderTypeResource(const nsString& aChromeType, nsIRDFResource** aResult);
|
||||
nsresult GetChromeResource(nsString& aResult, nsIRDFResource* aChromeResource,
|
||||
nsIRDFResource* aProperty);
|
||||
};
|
||||
|
||||
PRUint32 nsChromeRegistry::gRefCnt ;
|
||||
nsIRDFService* nsChromeRegistry::gRDFService = nsnull;
|
||||
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_chrome = nsnull;
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_skin = nsnull;
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_content = nsnull;
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_locale = nsnull;
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_behavior = nsnull;
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_platform = nsnull;
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_base = nsnull;
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_main = nsnull;
|
||||
nsIRDFResource* nsChromeRegistry::kCHROME_archive = nsnull;
|
||||
nsIRDFDataSource* nsChromeRegistry::mInner = nsnull;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsChromeRegistry::nsChromeRegistry()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
nsChromeRegistry::~nsChromeRegistry()
|
||||
{
|
||||
|
||||
--gRefCnt;
|
||||
if (gRefCnt == 0) {
|
||||
|
||||
// Release our inner data source
|
||||
NS_IF_RELEASE(mInner);
|
||||
|
||||
// release all the properties:
|
||||
NS_IF_RELEASE(kCHROME_chrome);
|
||||
NS_IF_RELEASE(kCHROME_skin);
|
||||
NS_IF_RELEASE(kCHROME_content);
|
||||
NS_IF_RELEASE(kCHROME_platform);
|
||||
NS_IF_RELEASE(kCHROME_locale);
|
||||
NS_IF_RELEASE(kCHROME_behavior);
|
||||
NS_IF_RELEASE(kCHROME_base);
|
||||
NS_IF_RELEASE(kCHROME_main);
|
||||
NS_IF_RELEASE(kCHROME_archive);
|
||||
|
||||
if (gRDFService) {
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
gRDFService = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsChromeRegistry)
|
||||
NS_IMPL_RELEASE(nsChromeRegistry)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIChromeRegistry::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIChromeRegistry*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIRDFDataSourceIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFDataSource*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChromeRegistry methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::ConvertChromeURL(nsIURL* aChromeURL)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Retrieve the resource for this chrome element.
|
||||
const char* host;
|
||||
if (NS_FAILED(rv = aChromeURL->GetHost(&host))) {
|
||||
NS_ERROR("Unable to retrieve the host for a chrome URL.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString hostStr(host);
|
||||
|
||||
// Construct a chrome URL and use it to look up a resource.
|
||||
nsAutoString windowType = nsAutoString("chrome://") + hostStr + "/";
|
||||
|
||||
// Find out the provider type of the URL
|
||||
const char* file;
|
||||
aChromeURL->GetFile(&file);
|
||||
nsAutoString restOfURL(file);
|
||||
|
||||
// Find the second slash.
|
||||
nsAutoString providerType("content");
|
||||
nsAutoString path("");
|
||||
PRInt32 slashIndex = -1;
|
||||
if (restOfURL.Length() > 1)
|
||||
{
|
||||
// There is something to the right of that slash. A provider type must have
|
||||
// been specified.
|
||||
slashIndex = restOfURL.Find('/', 1);
|
||||
if (slashIndex == -1)
|
||||
slashIndex = restOfURL.Length();
|
||||
|
||||
restOfURL.Mid(providerType, 1, slashIndex - 1);
|
||||
|
||||
if (slashIndex < restOfURL.Length()-1)
|
||||
{
|
||||
// There are some extra subdirectories to remember.
|
||||
restOfURL.Right(path, restOfURL.Length()-slashIndex-1);
|
||||
}
|
||||
}
|
||||
|
||||
windowType += providerType + "/";
|
||||
|
||||
// We have the resource URI that we wish to retrieve. Fetch it.
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
if (NS_FAILED(rv = GetProviderTypeResource(windowType, getter_AddRefs(chromeResource)))) {
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsString chromeBase;
|
||||
if (NS_FAILED(rv = GetChromeResource(chromeBase, chromeResource, kCHROME_base))) {
|
||||
NS_ERROR("Unable to retrieve codebase for chrome entry.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Make sure base ends in a slash
|
||||
PRInt32 length = chromeBase.Length();
|
||||
if (length > 0)
|
||||
{
|
||||
PRUnichar c = chromeBase.CharAt(length-1);
|
||||
if (c != '/')
|
||||
chromeBase += "/"; // Ensure that a slash is present.
|
||||
}
|
||||
|
||||
// Check to see if we should append the "main" entry in the registry.
|
||||
// Only do this when the user doesn't have anything following "skin"
|
||||
// or "content" in the specified URL.
|
||||
if (path == "")
|
||||
{
|
||||
PRInt32 length = restOfURL.Length();
|
||||
if (length > 0)
|
||||
{
|
||||
PRUnichar c = restOfURL.CharAt(length-1);
|
||||
if (c != '/')
|
||||
restOfURL += "/"; // Ensure that a slash is present.
|
||||
}
|
||||
|
||||
// Append the "main" entry.
|
||||
nsString mainFile;
|
||||
if (NS_FAILED(rv = GetChromeResource(mainFile, chromeResource, kCHROME_main))) {
|
||||
NS_ERROR("Unable to retrieve the main file registry entry for a chrome URL.");
|
||||
return rv;
|
||||
}
|
||||
chromeBase += mainFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXX Just append the rest of the URL to base to get the actual URL to look up.
|
||||
chromeBase += path;
|
||||
}
|
||||
|
||||
char* finalDecision = chromeBase.ToNewCString();
|
||||
aChromeURL->SetSpec(finalDecision);
|
||||
delete []finalDecision;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::InitRegistry()
|
||||
{
|
||||
if (mInner == nsnull)
|
||||
return Init("rdf:chrome");
|
||||
else return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFObserver methods:
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::GetProviderTypeResource(const nsString& aChromeType,
|
||||
nsIRDFResource** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
char* url = aChromeType.ToNewCString();
|
||||
if (NS_FAILED(rv = gRDFService->GetResource(url, aResult))) {
|
||||
NS_ERROR("Unable to retrieve a resource for this provider type.");
|
||||
*aResult = nsnull;
|
||||
delete []url;
|
||||
return rv;
|
||||
}
|
||||
delete []url;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::GetChromeResource(nsString& aResult,
|
||||
nsIRDFResource* aChromeResource,
|
||||
nsIRDFResource* aProperty)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mInner == nsnull)
|
||||
return NS_ERROR_FAILURE; // Must have a DB to attempt this operation.
|
||||
|
||||
nsCOMPtr<nsIRDFNode> chromeBase;
|
||||
if (NS_FAILED(rv = GetTarget(aChromeResource, aProperty, PR_TRUE, getter_AddRefs(chromeBase)))) {
|
||||
NS_ERROR("Unable to obtain a base resource.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (chromeBase == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
|
||||
if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(kIRDFResourceIID,
|
||||
(void**) getter_AddRefs(resource)))) {
|
||||
nsXPIDLCString uri;
|
||||
resource->GetValue( getter_Copies(uri) );
|
||||
aResult = uri;
|
||||
}
|
||||
else if (NS_SUCCEEDED(rv = chromeBase->QueryInterface(kIRDFLiteralIID,
|
||||
(void**) getter_AddRefs(literal)))) {
|
||||
nsXPIDLString s;
|
||||
literal->GetValue( getter_Copies(s) );
|
||||
aResult = s;
|
||||
}
|
||||
else {
|
||||
// This should _never_ happen.
|
||||
NS_ERROR("uh, this isn't a resource or a literal!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewChromeRegistry(nsIChromeRegistry** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsChromeRegistry* chromeRegistry = new nsChromeRegistry();
|
||||
if (chromeRegistry == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(chromeRegistry);
|
||||
*aResult = chromeRegistry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::Init(const char* uri)
|
||||
{
|
||||
// We're going to be init'ed with the "rdf:chrome" URI.
|
||||
// We want to use the location of the registry source instead.
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
gRefCnt++;
|
||||
if (gRefCnt == 1) {
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**)&gRDFService);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// get all the properties we'll need:
|
||||
rv = gRDFService->GetResource(kURICHROME_chrome, &kCHROME_chrome);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(kURICHROME_skin, &kCHROME_skin);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(kURICHROME_content, &kCHROME_content);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(kURICHROME_content, &kCHROME_platform);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(kURICHROME_content, &kCHROME_locale);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(kURICHROME_content, &kCHROME_behavior);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(kURICHROME_base, &kCHROME_base);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(kURICHROME_main, &kCHROME_main);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(kURICHROME_archive, &kCHROME_archive);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Retrieve the mInner data source.
|
||||
nsSpecialSystemDirectory chromeFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
chromeFile += "chrome";
|
||||
chromeFile += "registry.rdf";
|
||||
|
||||
nsFileURL chromeURL(chromeFile);
|
||||
const char* innerURI = chromeURL.GetAsString();
|
||||
|
||||
// Try to create the new data source.
|
||||
if (NS_FAILED(rv = gRDFService->GetDataSource(innerURI, &mInner)))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetURI(char** uri)
|
||||
{
|
||||
return mInner->GetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source /* out */)
|
||||
{
|
||||
return mInner->GetSource(property, target, tv, source);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** sources /* out */)
|
||||
{
|
||||
return mInner->GetSources(property, target, tv, sources);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target /* out */)
|
||||
{
|
||||
|
||||
return mInner->GetTarget(source, property, tv, target);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** targets /* out */)
|
||||
{
|
||||
return mInner->GetTargets(source, property, tv, targets);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv)
|
||||
{
|
||||
return mInner->Assert(source, property, target, tv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target)
|
||||
{
|
||||
return mInner->Unassert(source, property, target);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion /* out */)
|
||||
{
|
||||
return mInner->HasAssertion(source, property, target, tv, hasAssertion);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::AddObserver(nsIRDFObserver* n)
|
||||
{
|
||||
return mInner->AddObserver(n);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::RemoveObserver(nsIRDFObserver* n)
|
||||
{
|
||||
return mInner->RemoveObserver(n);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::ArcLabelsIn(nsIRDFNode* node,
|
||||
nsISimpleEnumerator** labels /* out */)
|
||||
{
|
||||
return mInner->ArcLabelsIn(node, labels);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::ArcLabelsOut(nsIRDFResource* source,
|
||||
nsISimpleEnumerator** labels /* out */)
|
||||
{
|
||||
return mInner->ArcLabelsOut(source, labels);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::GetAllResources(nsISimpleEnumerator** aCursor)
|
||||
{
|
||||
return mInner->GetAllResources(aCursor);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::Flush(void)
|
||||
{
|
||||
return mInner->Flush();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetAllCommands(nsIRDFResource* source,
|
||||
nsIEnumerator/*<nsIRDFResource>*/** commands)
|
||||
{
|
||||
return mInner->GetAllCommands(source, commands);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
|
||||
PRBool* retVal)
|
||||
{
|
||||
return mInner->IsCommandEnabled(aSources, aCommand, aArguments, retVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
||||
nsIRDFResource* aCommand,
|
||||
nsISupportsArray/*<nsIRDFResource>*/* aArguments)
|
||||
{
|
||||
return mInner->DoCommand(aSources, aCommand, aArguments);
|
||||
}
|
||||
305
mozilla/content/xul/content/src/nsRDFDOMNodeList.cpp
Normal file
305
mozilla/content/xul/content/src/nsRDFDOMNodeList.cpp
Normal file
@@ -0,0 +1,305 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Helper class to implement the nsIDOMNodeList interface.
|
||||
|
||||
XXX It's probably wrong in some sense, as it uses the "naked"
|
||||
content interface to look for kids. (I assume in general this is
|
||||
bad because there may be pseudo-elements created for presentation
|
||||
that aren't visible to the DOM.)
|
||||
|
||||
*/
|
||||
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsRDFDOMNodeList.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GUID definitions
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
static NS_DEFINE_IID(kIDOMScriptObjectFactoryIID, NS_IDOM_SCRIPT_OBJECT_FACTORY_IID);
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class RDFHTMLCollectionImpl : public nsIDOMHTMLCollection
|
||||
{
|
||||
private:
|
||||
nsRDFDOMNodeList* mOuter;
|
||||
|
||||
public:
|
||||
RDFHTMLCollectionImpl(nsRDFDOMNodeList* aOuter);
|
||||
virtual ~RDFHTMLCollectionImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult);
|
||||
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_DECL_IDOMHTMLCOLLECTION
|
||||
};
|
||||
|
||||
|
||||
RDFHTMLCollectionImpl::RDFHTMLCollectionImpl(nsRDFDOMNodeList* aOuter)
|
||||
: mOuter(aOuter)
|
||||
{
|
||||
}
|
||||
|
||||
RDFHTMLCollectionImpl::~RDFHTMLCollectionImpl(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
RDFHTMLCollectionImpl::AddRef(void)
|
||||
{
|
||||
return mOuter->AddRef();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
RDFHTMLCollectionImpl::Release(void)
|
||||
{
|
||||
return mOuter->Release();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMHTMLCollection::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMHTMLCollection*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
return mOuter->QueryInterface(aIID, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::GetLength(PRUint32* aLength)
|
||||
{
|
||||
return mOuter->GetLength(aLength);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
return mOuter->Item(aIndex, aReturn);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ctors & dtors
|
||||
|
||||
nsRDFDOMNodeList::nsRDFDOMNodeList(void)
|
||||
: mInner(nsnull),
|
||||
mElements(nsnull),
|
||||
mScriptObject(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsRDFDOMNodeList::~nsRDFDOMNodeList(void)
|
||||
{
|
||||
NS_IF_RELEASE(mElements);
|
||||
delete mInner;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::Create(nsRDFDOMNodeList** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsRDFDOMNodeList* list = new nsRDFDOMNodeList();
|
||||
if (! list)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = list->Init())) {
|
||||
delete list;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(list);
|
||||
*aResult = list;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(nsRDFDOMNodeList);
|
||||
NS_IMPL_RELEASE(nsRDFDOMNodeList);
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMNodeList::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNodeList*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIScriptObjectOwner*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(nsIDOMHTMLCollection::GetIID())) {
|
||||
// Aggregate this interface
|
||||
if (! mInner) {
|
||||
if (! (mInner = new RDFHTMLCollectionImpl(this)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return mInner->QueryInterface(aIID, aResult);
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMNodeList interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
NS_ASSERTION(aLength != nsnull, "null ptr");
|
||||
if (! aLength)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aLength = mElements->Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aIndex < (PRUint32) mElements->Count(), "invalid arg");
|
||||
if (aIndex >= (PRUint32) mElements->Count())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// Cast is okay because we're in a closed system.
|
||||
*aReturn = (nsIDOMNode*) mElements->ElementAt(aIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIScriptObjectOwner interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsIScriptGlobalObject* global = aContext->GetGlobalObject();
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kDOMScriptObjectFactoryCID,
|
||||
kIDOMScriptObjectFactoryIID,
|
||||
(nsISupports **)&factory))) {
|
||||
rv = factory->NewScriptHTMLCollection(aContext,
|
||||
(nsISupports*)(nsIDOMNodeList*)this,
|
||||
global,
|
||||
(void**)&mScriptObject);
|
||||
|
||||
nsServiceManager::ReleaseService(kDOMScriptObjectFactoryCID, factory);
|
||||
}
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
NS_RELEASE(global);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::SetScriptObject(void* aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation methods
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = NS_NewISupportsArray(&mElements))) {
|
||||
NS_ERROR("unable to create elements array");
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::AppendNode(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode != nsnull, "null ptr");
|
||||
if (! aNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return mElements->AppendElement(aNode);
|
||||
}
|
||||
58
mozilla/content/xul/content/src/nsRDFDOMNodeList.h
Normal file
58
mozilla/content/xul/content/src/nsRDFDOMNodeList.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsRDFDOMNodeList_h__
|
||||
#define nsRDFDOMNodeList_h__
|
||||
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
class nsIDOMNode;
|
||||
class nsISupportsArray;
|
||||
|
||||
class nsRDFDOMNodeList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
private:
|
||||
nsISupports* mInner;
|
||||
nsISupportsArray* mElements;
|
||||
void* mScriptObject;
|
||||
|
||||
nsRDFDOMNodeList(void);
|
||||
nsresult Init(void);
|
||||
|
||||
public:
|
||||
static nsresult Create(nsRDFDOMNodeList** aResult);
|
||||
virtual ~nsRDFDOMNodeList(void);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNodeList interface
|
||||
NS_DECL_IDOMNODELIST
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// Implementation methods
|
||||
nsresult AppendNode(nsIDOMNode* aNode);
|
||||
};
|
||||
|
||||
#endif // nsRDFDOMNodeList_h__
|
||||
|
||||
646
mozilla/content/xul/content/src/nsXULAttributes.cpp
Normal file
646
mozilla/content/xul/content/src/nsXULAttributes.cpp
Normal file
@@ -0,0 +1,646 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A helper class used to implement attributes.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Notes
|
||||
*
|
||||
* A lot of these methods delegate back to the original content node
|
||||
* that created them. This is so that we can lazily produce attribute
|
||||
* values from the RDF graph as they're asked for.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsXULAttributes.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXULAttribute
|
||||
|
||||
nsXULAttribute::nsXULAttribute(nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
const nsString& aValue)
|
||||
: mNameSpaceID(aNameSpaceID),
|
||||
mName(aName),
|
||||
mValue(aValue),
|
||||
mContent(aContent),
|
||||
mScriptObject(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_IF_ADDREF(aName);
|
||||
}
|
||||
|
||||
nsXULAttribute::~nsXULAttribute()
|
||||
{
|
||||
NS_IF_RELEASE(mName);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewXULAttribute(nsXULAttribute** aResult,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
const nsString& aValue)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! (*aResult = new nsXULAttribute(aContent, aNameSpaceID, aName, aValue)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsISupports interface
|
||||
NS_IMPL_ADDREF(nsXULAttribute);
|
||||
NS_IMPL_RELEASE(nsXULAttribute);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMAttr::GetIID()) ||
|
||||
aIID.Equals(nsIDOMNode::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMAttr*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(nsIScriptObjectOwner::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIScriptObjectOwner*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
// nsIDOMNode interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
aNodeName.SetString(mName->GetUnicode());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetNodeValue(nsString& aNodeValue)
|
||||
{
|
||||
aNodeValue=mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::SetNodeValue(const nsString& aNodeValue)
|
||||
{
|
||||
return SetValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::ATTRIBUTE_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
*aParentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
*aPreviousSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
*aNextSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::HasChildNodes(PRBool* aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// nsIDOMAttr interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetName(nsString& aName)
|
||||
{
|
||||
aName.SetString(mName->GetUnicode());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetSpecified(PRBool* aSpecified)
|
||||
{
|
||||
// XXX this'll break when we make Clone() work
|
||||
*aSpecified = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetValue(nsString& aValue)
|
||||
{
|
||||
aValue=mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::SetValue(const nsString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> element( do_QueryInterface(mContent) );
|
||||
if (element) {
|
||||
nsAutoString qualifiedName;
|
||||
GetQualifiedName(qualifiedName);
|
||||
return element->SetAttribute(qualifiedName, aValue);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (! mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
rv = nsServiceManager::GetService(kDOMScriptObjectFactoryCID,
|
||||
nsIDOMScriptObjectFactory::GetIID(),
|
||||
(nsISupports **)&factory);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = factory->NewScriptAttr(aContext,
|
||||
(nsISupports*)(nsIDOMAttr*) this,
|
||||
(nsISupports*) mContent,
|
||||
(void**) &mScriptObject);
|
||||
|
||||
nsServiceManager::ReleaseService(kDOMScriptObjectFactoryCID, factory);
|
||||
}
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Implementation methods
|
||||
|
||||
void
|
||||
nsXULAttribute::GetQualifiedName(nsString& aQualifiedName)
|
||||
{
|
||||
aQualifiedName.Truncate();
|
||||
if ((mNameSpaceID != kNameSpaceID_None) &&
|
||||
(mNameSpaceID != kNameSpaceID_Unknown)) {
|
||||
nsresult rv;
|
||||
|
||||
nsIAtom* prefix;
|
||||
rv = mContent->GetNameSpacePrefixFromId(mNameSpaceID, prefix);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (prefix != nsnull)) {
|
||||
aQualifiedName.Append(prefix->GetUnicode());
|
||||
aQualifiedName.Append(':');
|
||||
NS_RELEASE(prefix);
|
||||
}
|
||||
}
|
||||
aQualifiedName.Append(mName->GetUnicode());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXULAttributes
|
||||
|
||||
nsXULAttributes::nsXULAttributes(nsIContent* aContent)
|
||||
: mContent(aContent),
|
||||
mClassList(nsnull),
|
||||
mStyleRule(nsnull),
|
||||
mScriptObject(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
nsXULAttributes::~nsXULAttributes()
|
||||
{
|
||||
PRInt32 count = mAttributes.Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsXULAttribute* attr = (nsXULAttribute*)mAttributes.ElementAt(index);
|
||||
NS_RELEASE(attr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewXULAttributes(nsXULAttributes** aResult, nsIContent* aContent)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! (*aResult = new nsXULAttributes(aContent)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(nsXULAttributes);
|
||||
NS_IMPL_RELEASE(nsXULAttributes);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttributes::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMNamedNodeMap::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNamedNodeMap*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(nsIScriptObjectOwner::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIScriptObjectOwner*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// nsIDOMNamedNodeMap interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttributes::GetLength(PRUint32* aLength)
|
||||
{
|
||||
NS_PRECONDITION(aLength != nsnull, "null ptr");
|
||||
if (! aLength)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aLength = mAttributes.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttributes::GetNamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
*aReturn = nsnull;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsIAtom* name;
|
||||
|
||||
if (NS_FAILED(rv = mContent->ParseAttributeString(aName, name, nameSpaceID)))
|
||||
return rv;
|
||||
|
||||
// XXX doing this instead of calling mContent->GetAttribute() will
|
||||
// make it a lot harder to lazily instantiate properties from the
|
||||
// graph. The problem is, how else do we get the named item?
|
||||
for (PRInt32 i = mAttributes.Count() - 1; i >= 0; --i) {
|
||||
nsXULAttribute* attr = (nsXULAttribute*) mAttributes[i];
|
||||
if (((nameSpaceID == attr->mNameSpaceID) ||
|
||||
(nameSpaceID == kNameSpaceID_Unknown) ||
|
||||
(nameSpaceID == kNameSpaceID_None)) &&
|
||||
(name == attr->mName)) {
|
||||
NS_ADDREF(attr);
|
||||
*aReturn = attr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(name);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttributes::SetNamedItem(nsIDOMNode* aArg, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttributes::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> element( do_QueryInterface(mContent) );
|
||||
if (element) {
|
||||
return element->RemoveAttribute(aName);
|
||||
*aReturn = nsnull; // XXX should be the element we just removed
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttributes::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = (nsXULAttribute*) mAttributes[aIndex];
|
||||
NS_IF_ADDREF(*aReturn);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttributes::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (! mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
rv = nsServiceManager::GetService(kDOMScriptObjectFactoryCID,
|
||||
nsIDOMScriptObjectFactory::GetIID(),
|
||||
(nsISupports **)&factory);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = factory->NewScriptNamedNodeMap(aContext,
|
||||
(nsISupports*)(nsIDOMNamedNodeMap*) this,
|
||||
(nsISupports*) mContent,
|
||||
(void**) &mScriptObject);
|
||||
|
||||
nsServiceManager::ReleaseService(kDOMScriptObjectFactoryCID, factory);
|
||||
}
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAttributes::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Implementation methods
|
||||
|
||||
nsresult
|
||||
nsXULAttributes::GetClasses(nsVoidArray& aArray) const
|
||||
{
|
||||
aArray.Clear();
|
||||
const nsClassList* classList = mClassList;
|
||||
while (nsnull != classList) {
|
||||
aArray.AppendElement(classList->mAtom); // NOTE atom is not addrefed
|
||||
classList = classList->mNext;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULAttributes::HasClass(nsIAtom* aClass) const
|
||||
{
|
||||
const nsClassList* classList = mClassList;
|
||||
while (nsnull != classList) {
|
||||
if (classList->mAtom == aClass) {
|
||||
return NS_OK;
|
||||
}
|
||||
classList = classList->mNext;
|
||||
}
|
||||
return NS_COMFALSE;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::UpdateClassList(const nsString& aValue)
|
||||
{
|
||||
if (mClassList != nsnull)
|
||||
{
|
||||
delete mClassList;
|
||||
mClassList = nsnull;
|
||||
}
|
||||
|
||||
if (aValue != "")
|
||||
ParseClasses(aValue, &mClassList);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::UpdateStyleRule(nsIURL* aDocURL, const nsString& aValue)
|
||||
{
|
||||
if (aValue == "")
|
||||
{
|
||||
// XXX: Removing the rule. Is this sufficient?
|
||||
NS_IF_RELEASE(mStyleRule);
|
||||
mStyleRule = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsICSSParser* css;
|
||||
nsresult result = NS_NewCSSParser(&css);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
nsIStyleRule* rule;
|
||||
result = css->ParseDeclarations(aValue, aDocURL, rule);
|
||||
//NS_IF_RELEASE(docURL);
|
||||
|
||||
if ((NS_OK == result) && (nsnull != rule)) {
|
||||
mStyleRule = rule; //Addrefed already during parse, so don't need to addref again.
|
||||
//result = SetHTMLAttribute(aAttribute, nsHTMLValue(rule), aNotify);
|
||||
}
|
||||
//else {
|
||||
// result = SetHTMLAttribute(aAttribute, nsHTMLValue(aValue), aNotify);
|
||||
//}
|
||||
NS_RELEASE(css);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::GetInlineStyleRule(nsIStyleRule*& aRule)
|
||||
{
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
if (mStyleRule != nsnull)
|
||||
{
|
||||
aRule = mStyleRule;
|
||||
NS_ADDREF(aRule);
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsXULAttributes::ParseClasses(const nsString& aClassString, nsClassList** aClassList)
|
||||
{
|
||||
static const PRUnichar kNullCh = PRUnichar('\0');
|
||||
|
||||
NS_ASSERTION(nsnull == *aClassList, "non null start list");
|
||||
|
||||
nsAutoString classStr(aClassString); // copy to work buffer
|
||||
classStr.Append(kNullCh); // put an extra null at the end
|
||||
|
||||
PRUnichar* start = (PRUnichar*)(const PRUnichar*)classStr.GetUnicode();
|
||||
PRUnichar* end = start;
|
||||
|
||||
while (kNullCh != *start) {
|
||||
while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space
|
||||
start++;
|
||||
}
|
||||
end = start;
|
||||
|
||||
while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end
|
||||
end++;
|
||||
}
|
||||
*end = kNullCh; // end string here
|
||||
|
||||
if (start < end) {
|
||||
*aClassList = new nsClassList(NS_NewAtom(start));
|
||||
aClassList = &((*aClassList)->mNext);
|
||||
}
|
||||
|
||||
start = ++end;
|
||||
}
|
||||
}
|
||||
|
||||
180
mozilla/content/xul/content/src/nsXULAttributes.h
Normal file
180
mozilla/content/xul/content/src/nsXULAttributes.h
Normal file
@@ -0,0 +1,180 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A set of helper classes used to implement attributes.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsXULAttributes_h__
|
||||
#define nsXULAttributes_h__
|
||||
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIURL;
|
||||
|
||||
struct nsClassList {
|
||||
nsClassList(nsIAtom* aAtom)
|
||||
: mAtom(aAtom),
|
||||
mNext(nsnull)
|
||||
{
|
||||
}
|
||||
nsClassList(const nsClassList& aCopy)
|
||||
: mAtom(aCopy.mAtom),
|
||||
mNext(nsnull)
|
||||
{
|
||||
NS_ADDREF(mAtom);
|
||||
if (nsnull != aCopy.mNext) {
|
||||
mNext = new nsClassList(*(aCopy.mNext));
|
||||
}
|
||||
}
|
||||
~nsClassList(void)
|
||||
{
|
||||
NS_RELEASE(mAtom);
|
||||
if (nsnull != mNext) {
|
||||
delete mNext;
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom* mAtom;
|
||||
nsClassList* mNext;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsXULAttribute : public nsIDOMAttr,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
private:
|
||||
nsXULAttribute(nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
const nsString& aValue);
|
||||
|
||||
virtual ~nsXULAttribute();
|
||||
|
||||
friend nsresult
|
||||
NS_NewXULAttribute(nsXULAttribute** aResult,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
const nsString& aValue);
|
||||
|
||||
public:
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_DECL_IDOMNODE
|
||||
|
||||
// nsIDOMAttr interface
|
||||
NS_DECL_IDOMATTR
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// Implementation methods
|
||||
void GetQualifiedName(nsString& aAttributeName);
|
||||
|
||||
PRInt32 GetNameSpaceID();
|
||||
nsIAtom* GetName();
|
||||
const nsString& GetValue();
|
||||
|
||||
// Publicly exposed to make life easier. This is a private class
|
||||
// anyway.
|
||||
PRInt32 mNameSpaceID;
|
||||
nsIAtom* mName;
|
||||
nsString mValue;
|
||||
|
||||
private:
|
||||
nsIContent* mContent;
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewXULAttribute(nsXULAttribute** aResult,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
const nsString& aValue);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsXULAttributes : public nsIDOMNamedNodeMap,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
public:
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNamedNodeMap interface
|
||||
NS_DECL_IDOMNAMEDNODEMAP
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
||||
|
||||
// Implementation methods
|
||||
// VoidArray Helpers
|
||||
PRInt32 Count() { return mAttributes.Count(); };
|
||||
nsXULAttribute* ElementAt(PRInt32 i) { return (nsXULAttribute*)mAttributes.ElementAt(i); };
|
||||
void AppendElement(nsXULAttribute* aElement) { mAttributes.AppendElement((void*)aElement); };
|
||||
void RemoveElementAt(PRInt32 index) { mAttributes.RemoveElementAt(index); };
|
||||
|
||||
// Style Helpers
|
||||
nsresult GetClasses(nsVoidArray& aArray) const;
|
||||
nsresult HasClass(nsIAtom* aClass) const;
|
||||
|
||||
nsresult UpdateClassList(const nsString& aValue);
|
||||
nsresult UpdateStyleRule(nsIURL* aDocURL, const nsString& aValue);
|
||||
nsresult GetInlineStyleRule(nsIStyleRule*& aRule);
|
||||
|
||||
private:
|
||||
friend nsresult
|
||||
NS_NewXULAttributes(nsXULAttributes** aResult, nsIContent* aContent);
|
||||
|
||||
nsXULAttributes(nsIContent* aContent);
|
||||
virtual ~nsXULAttributes();
|
||||
|
||||
static void
|
||||
ParseClasses(const nsString& aClassString, nsClassList** aClassList);
|
||||
|
||||
nsIContent* mContent;
|
||||
nsClassList* mClassList;
|
||||
nsIStyleRule* mStyleRule;
|
||||
nsVoidArray mAttributes;
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewXULAttributes(nsXULAttributes** aResult, nsIContent* aContent);
|
||||
|
||||
#endif // nsXULAttributes_h__
|
||||
|
||||
2709
mozilla/content/xul/content/src/nsXULElement.cpp
Normal file
2709
mozilla/content/xul/content/src/nsXULElement.cpp
Normal file
File diff suppressed because it is too large
Load Diff
71
mozilla/content/xul/content/src/nsXULElement.h
Normal file
71
mozilla/content/xul/content/src/nsXULElement.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsXULElement_h__
|
||||
#define nsXULElement_h__
|
||||
|
||||
#include "nsIDOMXULElement.h"
|
||||
class nsXULElement : public nsISupports
|
||||
{
|
||||
protected:
|
||||
nsIDOMXULElement* mOuter;
|
||||
nsXULElement(nsIDOMXULElement* aOuter) : mOuter(aOuter) {}
|
||||
|
||||
public:
|
||||
virtual ~nsXULElement() {};
|
||||
|
||||
// nsISupports interface. Subclasses should use the
|
||||
// NS_DECL/IMPL_ISUPPORTS_INHERITED macros to implement the
|
||||
// nsISupports interface.
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() {
|
||||
return mOuter->AddRef();
|
||||
}
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) Release() {
|
||||
return mOuter->Release();
|
||||
}
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult) {
|
||||
return mOuter->QueryInterface(aIID, aResult);
|
||||
}
|
||||
};
|
||||
|
||||
#define NS_IMPL_XULELEMENT_ISUPPORTS \
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { \
|
||||
return mOuter->AddRef(); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHOD_(nsrefcnt) Release() { \
|
||||
return mOuter->Release(); \
|
||||
} \
|
||||
\
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult) { \
|
||||
if (aIID.Equals(GetDOMIID())) { \
|
||||
*aResult = this; \
|
||||
NS_ADDREF(this); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
else { \
|
||||
return mOuter->QueryInterface(aIID, aResult); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // nsXULElement_h__
|
||||
55
mozilla/content/xul/content/src/nsXULTreeElement.cpp
Normal file
55
mozilla/content/xul/content/src/nsXULTreeElement.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsXULTreeElement.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsXULTreeElement, nsXULElement, nsIDOMXULTreeElement);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::GetDatabase(nsIRDFCompositeDataSource** aDatabase)
|
||||
{
|
||||
NS_PRECONDITION(aDatabase != nsnull, "null ptr");
|
||||
if (! aDatabase)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_IF_ADDREF(mDatabase);
|
||||
*aDatabase = mDatabase;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::SetDatabase(nsIRDFCompositeDataSource* aDatabase)
|
||||
{
|
||||
// XXX maybe someday you'll be allowed to change it.
|
||||
NS_PRECONDITION(mDatabase == nsnull, "already initialized");
|
||||
if (mDatabase)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
mDatabase = aDatabase;
|
||||
NS_IF_ADDREF(aDatabase);
|
||||
|
||||
// XXX reconstruct the entire tree now!
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
60
mozilla/content/xul/content/src/nsXULTreeElement.h
Normal file
60
mozilla/content/xul/content/src/nsXULTreeElement.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsXULTreeElement_h__
|
||||
#define nsXULTreeElement_h__
|
||||
|
||||
#include "nsXULElement.h"
|
||||
#include "nsIDOMXULTreeElement.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
|
||||
class nsXULTreeElement : public nsXULElement,
|
||||
public nsIDOMXULTreeElement
|
||||
{
|
||||
private:
|
||||
nsIRDFCompositeDataSource* mDatabase;
|
||||
|
||||
public:
|
||||
nsXULTreeElement(nsIDOMXULElement* aOuter)
|
||||
: nsXULElement(aOuter),
|
||||
mDatabase(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_FORWARD_IDOMNODE(mOuter->);
|
||||
|
||||
// nsIDOMElement interface
|
||||
NS_FORWARD_IDOMELEMENT(mOuter->);
|
||||
|
||||
// nsIDOMXULElement interface
|
||||
NS_FORWARD_IDOMXULELEMENT(mOuter->);
|
||||
|
||||
// nsIDOMXULTreeElement interface
|
||||
NS_DECL_IDOMXULTREEELEMENT
|
||||
|
||||
virtual const nsIID& GetDOMIID() {
|
||||
return nsIDOMXULTreeElement::GetIID();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // nsXULTreeElement_h__
|
||||
3680
mozilla/content/xul/document/src/nsXULDocument.cpp
Normal file
3680
mozilla/content/xul/document/src/nsXULDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1209
mozilla/content/xul/templates/src/nsXULSortService.cpp
Normal file
1209
mozilla/content/xul/templates/src/nsXULSortService.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1570
mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp
Normal file
1570
mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp
Normal file
File diff suppressed because it is too large
Load Diff
9
mozilla/dom/public/idl/xul/XULDocument.idl
Normal file
9
mozilla/dom/public/idl/xul/XULDocument.idl
Normal file
@@ -0,0 +1,9 @@
|
||||
interface XULDocument : Document {
|
||||
|
||||
/* IID: { 0x17ddd8c0, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
Element getElementById(in DOMString id);
|
||||
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
};
|
||||
12
mozilla/dom/public/idl/xul/XULElement.idl
Normal file
12
mozilla/dom/public/idl/xul/XULElement.idl
Normal file
@@ -0,0 +1,12 @@
|
||||
interface XULElement : Element {
|
||||
|
||||
/* IID: { 0x574ed81, 0xc088, 0x11d2, \
|
||||
{ 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } } */
|
||||
readonly attribute xpidl nsIRDFResource resource;
|
||||
|
||||
void addBroadcastListener(in DOMString attr, in Element element);
|
||||
void removeBroadcastListener(in DOMString attr, in Element element);
|
||||
void doCommand();
|
||||
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
};
|
||||
5
mozilla/dom/public/idl/xul/XULTreeElement.idl
Normal file
5
mozilla/dom/public/idl/xul/XULTreeElement.idl
Normal file
@@ -0,0 +1,5 @@
|
||||
interface XULTreeElement : XULElement {
|
||||
/* IID: { 0xa6cf90ec, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */
|
||||
attribute xpidl nsIRDFCompositeDataSource database;
|
||||
};
|
||||
60
mozilla/dom/public/xul/nsIDOMXULDocument.h
Normal file
60
mozilla/dom/public/xul/nsIDOMXULDocument.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULDocument_h__
|
||||
#define nsIDOMXULDocument_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULDOCUMENT_IID \
|
||||
{ 0x17ddd8c0, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIDOMXULDocument : public nsIDOMDocument {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULDOCUMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULDOCUMENT \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULDOCUMENT(_to) \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn) { return _to GetElementById(aId, aReturn); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULDocumentClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULDocument(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULDocument_h__
|
||||
73
mozilla/dom/public/xul/nsIDOMXULElement.h
Normal file
73
mozilla/dom/public/xul/nsIDOMXULElement.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULElement_h__
|
||||
#define nsIDOMXULElement_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIRDFResource;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULELEMENT_IID \
|
||||
{ 0x574ed81, 0xc088, 0x11d2, \
|
||||
{ 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } }
|
||||
|
||||
class nsIDOMXULElement : public nsIDOMElement {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULELEMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetResource(nsIRDFResource** aResource)=0;
|
||||
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
|
||||
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
|
||||
|
||||
NS_IMETHOD DoCommand()=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULELEMENT \
|
||||
NS_IMETHOD GetResource(nsIRDFResource** aResource); \
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
|
||||
NS_IMETHOD DoCommand(); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULELEMENT(_to) \
|
||||
NS_IMETHOD GetResource(nsIRDFResource** aResource) { return _to GetResource(aResource); } \
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to AddBroadcastListener(aAttr, aElement); } \
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to RemoveBroadcastListener(aAttr, aElement); } \
|
||||
NS_IMETHOD DoCommand() { return _to DoCommand(); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULElementClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULElement_h__
|
||||
58
mozilla/dom/public/xul/nsIDOMXULTreeElement.h
Normal file
58
mozilla/dom/public/xul/nsIDOMXULTreeElement.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULTreeElement_h__
|
||||
#define nsIDOMXULTreeElement_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
|
||||
class nsIRDFCompositeDataSource;
|
||||
|
||||
#define NS_IDOMXULTREEELEMENT_IID \
|
||||
{ 0xa6cf90ec, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
class nsIDOMXULTreeElement : public nsIDOMXULElement {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULTREEELEMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetDatabase(nsIRDFCompositeDataSource** aDatabase)=0;
|
||||
NS_IMETHOD SetDatabase(nsIRDFCompositeDataSource* aDatabase)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULTREEELEMENT \
|
||||
NS_IMETHOD GetDatabase(nsIRDFCompositeDataSource** aDatabase); \
|
||||
NS_IMETHOD SetDatabase(nsIRDFCompositeDataSource* aDatabase); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULTREEELEMENT(_to) \
|
||||
NS_IMETHOD GetDatabase(nsIRDFCompositeDataSource** aDatabase) { return _to GetDatabase(aDatabase); } \
|
||||
NS_IMETHOD SetDatabase(nsIRDFCompositeDataSource* aDatabase) { return _to SetDatabase(aDatabase); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULTreeElementClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULTreeElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULTreeElement_h__
|
||||
356
mozilla/dom/src/xul/nsJSXULDocument.cpp
Normal file
356
mozilla/dom/src/xul/nsJSXULDocument.cpp
Normal file
@@ -0,0 +1,356 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULDocument);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULDocument Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULDocument *a = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULDocument Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULDocument *a = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULDocument(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULDocument(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULDocument(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementById
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULDocument *nativeThis = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElement* nativeRet;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 1) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementById(b0, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementById requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementsByAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULDocument *nativeThis = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodeList* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementsByAttribute(b0, b1, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementsByAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULDocument
|
||||
//
|
||||
JSClass XULDocumentClass = {
|
||||
"XULDocument",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULDocumentProperty,
|
||||
SetXULDocumentProperty,
|
||||
EnumerateXULDocument,
|
||||
ResolveXULDocument,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULDocument
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class properties
|
||||
//
|
||||
static JSPropertySpec XULDocumentProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class methods
|
||||
//
|
||||
static JSFunctionSpec XULDocumentMethods[] =
|
||||
{
|
||||
{"getElementById", XULDocumentGetElementById, 1},
|
||||
{"getElementsByAttribute", XULDocumentGetElementsByAttribute, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocument(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULDocumentClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULDocument", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
if (NS_OK != NS_InitDocumentClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULDocumentClass, // JSClass
|
||||
XULDocument, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULDocumentProperties, // proto props
|
||||
XULDocumentMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new XULDocument JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULDocument(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULDocument");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULDocument *aXULDocument;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULDocumentClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULDocumentIID, (void **)&aXULDocument);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULDocumentClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULDocument);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULDocument);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
469
mozilla/dom/src/xul/nsJSXULElement.cpp
Normal file
469
mozilla/dom/src/xul/nsJSXULElement.cpp
Normal file
@@ -0,0 +1,469 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULElementIID, NS_IDOMXULELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULElement);
|
||||
NS_DEF_PTR(nsIRDFResource);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
//
|
||||
// XULElement property ids
|
||||
//
|
||||
enum XULElement_slots {
|
||||
XULELEMENT_RESOURCE = -1
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULElement Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULElement *a = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULELEMENT_RESOURCE:
|
||||
{
|
||||
nsIRDFResource* prop;
|
||||
if (NS_OK == a->GetResource(&prop)) {
|
||||
// get the js object
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
*vp = OBJECT_TO_JSVAL(nsIRDFResource::GetJSObject(cx, prop));
|
||||
#else
|
||||
nsJSUtils::nsConvertXPCObjectToJSVal(prop, nsIRDFResource::GetIID(), cx, vp);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULElement Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULElement *a = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULElement(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method AddBroadcastListener
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
nsIDOMElementPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->AddBroadcastListener(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function addBroadcastListener requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method RemoveBroadcastListener
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
nsIDOMElementPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->RemoveBroadcastListener(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function removeBroadcastListener requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method DoCommand
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
|
||||
if (NS_OK != nativeThis->DoCommand()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function doCommand requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementsByAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodeList* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementsByAttribute(b0, b1, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementsByAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULElement
|
||||
//
|
||||
JSClass XULElementClass = {
|
||||
"XULElement",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULElementProperty,
|
||||
SetXULElementProperty,
|
||||
EnumerateXULElement,
|
||||
ResolveXULElement,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULElement
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement class properties
|
||||
//
|
||||
static JSPropertySpec XULElementProperties[] =
|
||||
{
|
||||
{"resource", XULELEMENT_RESOURCE, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement class methods
|
||||
//
|
||||
static JSFunctionSpec XULElementMethods[] =
|
||||
{
|
||||
{"addBroadcastListener", XULElementAddBroadcastListener, 2},
|
||||
{"removeBroadcastListener", XULElementRemoveBroadcastListener, 2},
|
||||
{"doCommand", XULElementDoCommand, 0},
|
||||
{"getElementsByAttribute", XULElementGetElementsByAttribute, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULElementClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULElement", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
if (NS_OK != NS_InitElementClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULElementClass, // JSClass
|
||||
XULElement, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULElementProperties, // proto props
|
||||
XULElementMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new XULElement JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULElement");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULElement *aXULElement;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULElementClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULElementIID, (void **)&aXULElement);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULElementClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULElement);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULElement);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
308
mozilla/dom/src/xul/nsJSXULTreeElement.cpp
Normal file
308
mozilla/dom/src/xul/nsJSXULTreeElement.cpp
Normal file
@@ -0,0 +1,308 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIDOMXULTreeElement.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIRDFCompositeDataSourceIID, NS_IRDFCOMPOSITEDATASOURCE_IID);
|
||||
static NS_DEFINE_IID(kIXULTreeElementIID, NS_IDOMXULTREEELEMENT_IID);
|
||||
|
||||
NS_DEF_PTR(nsIRDFCompositeDataSource);
|
||||
NS_DEF_PTR(nsIDOMXULTreeElement);
|
||||
|
||||
//
|
||||
// XULTreeElement property ids
|
||||
//
|
||||
enum XULTreeElement_slots {
|
||||
XULTREEELEMENT_DATABASE = -1
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULTreeElement Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULTreeElement *a = (nsIDOMXULTreeElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULTREEELEMENT_DATABASE:
|
||||
{
|
||||
nsIRDFCompositeDataSource* prop;
|
||||
if (NS_OK == a->GetDatabase(&prop)) {
|
||||
// get the js object
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
*vp = OBJECT_TO_JSVAL(nsIRDFCompositeDataSource::GetJSObject(cx, prop));
|
||||
#else
|
||||
nsJSUtils::nsConvertXPCObjectToJSVal(prop, nsIRDFCompositeDataSource::GetIID(), cx, vp);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULTreeElement Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULTreeElement *a = (nsIDOMXULTreeElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULTREEELEMENT_DATABASE:
|
||||
{
|
||||
nsIRDFCompositeDataSource* prop;
|
||||
if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop,
|
||||
kIRDFCompositeDataSourceIID, "RDFCompositeDataSource",
|
||||
cx, *vp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetDatabase(prop);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULTreeElement finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULTreeElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULTreeElement enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULTreeElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULTreeElement resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULTreeElement(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULTreeElement
|
||||
//
|
||||
JSClass XULTreeElementClass = {
|
||||
"XULTreeElement",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULTreeElementProperty,
|
||||
SetXULTreeElementProperty,
|
||||
EnumerateXULTreeElement,
|
||||
ResolveXULTreeElement,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULTreeElement
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULTreeElement class properties
|
||||
//
|
||||
static JSPropertySpec XULTreeElementProperties[] =
|
||||
{
|
||||
{"database", XULTREEELEMENT_DATABASE, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULTreeElement class methods
|
||||
//
|
||||
static JSFunctionSpec XULTreeElementMethods[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULTreeElement constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULTreeElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULTreeElement class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULTreeElementClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULTreeElement", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
if (NS_OK != NS_InitXULElementClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULTreeElementClass, // JSClass
|
||||
XULTreeElement, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULTreeElementProperties, // proto props
|
||||
XULTreeElementMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new XULTreeElement JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULTreeElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULTreeElement");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULTreeElement *aXULTreeElement;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULTreeElementClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULTreeElementIID, (void **)&aXULTreeElement);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULTreeElementClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULTreeElement);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULTreeElement);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
37
mozilla/rdf/Makefile.in
Normal file
37
mozilla/rdf/Makefile.in
Normal file
@@ -0,0 +1,37 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = base util content datasource chrome build
|
||||
|
||||
ifdef MOZ_BRPROF
|
||||
DIRS += brprof
|
||||
endif
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += tests
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
33
mozilla/rdf/base/Makefile.in
Normal file
33
mozilla/rdf/base/Makefile.in
Normal file
@@ -0,0 +1,33 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
ifdef USE_XPIDL
|
||||
DIRS += idl
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
45
mozilla/rdf/base/idl/Makefile.in
Normal file
45
mozilla/rdf/base/idl/Makefile.in
Normal file
@@ -0,0 +1,45 @@
|
||||
#!gmake
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
IDLSRCS = \
|
||||
nsRDFInterfaces.idl \
|
||||
# nsIRDFArcsInCursor.idl \
|
||||
# nsIRDFArcsOutCursor.idl \
|
||||
# nsIRDFAssertionCursor.idl \
|
||||
# nsIRDFCursor.idl \
|
||||
# nsIRDFDataSource.idl \
|
||||
# nsIRDFLiteral.idl \
|
||||
# nsIRDFNode.idl \
|
||||
# nsIRDFObserver.idl \
|
||||
# nsIRDFResoruce.idl \
|
||||
# nsIRDFResourceCursor.idl \
|
||||
$(NULL)
|
||||
|
||||
# for testing purposes
|
||||
#EXPORTS = $(IDLSRCS:.idl=.h)
|
||||
|
||||
# to build in the static methods
|
||||
#CPPSRCS = $(IDLSRCS:.idl=.cpp)
|
||||
#LIBRARY_NAME = rdfidl
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
43
mozilla/rdf/base/idl/makefile.win
Normal file
43
mozilla/rdf/base/idl/makefile.win
Normal file
@@ -0,0 +1,43 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=rdf
|
||||
|
||||
GARBAGE= nsRDFInterfaces.h \
|
||||
nsRDFInterfaces.cpp \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
XPIDL=$(DIST)\bin\xpidl.exe
|
||||
|
||||
XPIDL_INCLUDES= -I $(DEPTH)\xpcom\idl \
|
||||
$(NULL)
|
||||
|
||||
nsRDFInterfaces.h: nsRDFInterfaces.idl
|
||||
@echo +++ make: generating XPIDL headers
|
||||
$(XPIDL) -m header $(XPIDL_INCLUDES) $**
|
||||
|
||||
nsRDFInterfaces.xpt: nsRDFInterfaces.idl
|
||||
@echo +++ make: generating XPIDL typelib
|
||||
$(XPIDL) -m typelib $(XPIDL_INCLUDES) $**
|
||||
|
||||
export:: nsRDFInterfaces.h nsRDFInterfaces.xpt
|
||||
$(MAKE_INSTALL) nsRDFInterfaces.h $(DEPTH)\rdf\base\public
|
||||
$(MAKE_INSTALL) nsRDFInterfaces.xpt $(DEPTH)\rdf\build
|
||||
|
||||
393
mozilla/rdf/base/idl/nsRDFInterfaces.idl
Normal file
393
mozilla/rdf/base/idl/nsRDFInterfaces.idl
Normal file
@@ -0,0 +1,393 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file contains _all_ of the interface definitions, lumped into
|
||||
one big happy file. It's done this way to circumvent problems with
|
||||
forward declarations in the current version of `xpidl'.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIEnumerator.idl"
|
||||
#include "nsISimpleEnumerator.idl"
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
|
||||
%{C++
|
||||
#include "nscore.h" // for PRUnichar
|
||||
%}
|
||||
|
||||
// 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);
|
||||
};
|
||||
|
||||
// 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(E0C493D1-9542-11d2-8EB8-00805F29F370)]
|
||||
interface nsIRDFResource : nsIRDFNode {
|
||||
// The single-byte string value of the resource
|
||||
readonly attribute string Value;
|
||||
|
||||
// This method is called by the nsIRDFService after constructing
|
||||
// a resource object to initialize it's URI. You would not normally
|
||||
// call this method directly
|
||||
void Init(in string uri);
|
||||
|
||||
// Determine if two resources are identical.
|
||||
boolean EqualsResource(in nsIRDFResource aResource);
|
||||
|
||||
// Determine if the resource has the given URI.
|
||||
boolean EqualsString(in string aURI);
|
||||
};
|
||||
|
||||
// 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;
|
||||
|
||||
// Determine if two literals are identical.
|
||||
boolean EqualsLiteral(in nsIRDFLiteral aLiteral);
|
||||
};
|
||||
|
||||
// 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 long long Value;
|
||||
|
||||
// Determine if the date is equal to another
|
||||
//
|
||||
// XXX Is this really necessary?
|
||||
boolean EqualsDate(in nsIRDFDate aDate);
|
||||
};
|
||||
|
||||
// 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;
|
||||
|
||||
// Determine if the integer is equal to another
|
||||
//
|
||||
// XXX Is this really necessary?
|
||||
boolean EqualsInt(in nsIRDFInt aInt);
|
||||
};
|
||||
|
||||
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
|
||||
void OnAssert(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aLabel,
|
||||
in nsIRDFNode aTarget);
|
||||
|
||||
// This method is called whenever an assertion is removed
|
||||
// from the data source
|
||||
void OnUnassert(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aLabel,
|
||||
in nsIRDFNode aTarget);
|
||||
};
|
||||
|
||||
|
||||
[scriptable, uuid(0F78DA58-8321-11d2-8EAC-00805F29F370)]
|
||||
interface nsIRDFDataSource : nsISupports {
|
||||
// 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.
|
||||
void Init(in string uri);
|
||||
|
||||
// The URI of the data source.
|
||||
readonly attribute string URI;
|
||||
|
||||
// Find an RDF resource that points to a given node over the
|
||||
// specified arc & truth value
|
||||
//
|
||||
// @return 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
|
||||
//
|
||||
// @return NS_OK unless a catastrophic error occurs. If the
|
||||
// method returns NS_OK, you may assume that nsISimpleEnumerator points
|
||||
// to a valid (but possibly empty) cursor.
|
||||
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
|
||||
//
|
||||
// @return NS_RDF_NO_VALUE if there is no target accessable 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.
|
||||
//
|
||||
// @return NS_OK unless a catastrophic error occurs. If the
|
||||
// method returns NS_OK, you may assume that nsISimpleEnumerator points
|
||||
// to a valid (but possibly empty) cursor.
|
||||
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);
|
||||
|
||||
// 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.
|
||||
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.
|
||||
//
|
||||
// @return NS_OK unless a catastrophic error occurs. If the method
|
||||
// returns NS_OK, you may assume that labels points to a valid (but
|
||||
// possible empty) nsISimpleEnumerator object.
|
||||
nsISimpleEnumerator ArcLabelsIn(in nsIRDFNode aNode);
|
||||
|
||||
// Get a cursor to iterate over all the arcs that originate in
|
||||
// a resource.
|
||||
//
|
||||
// @return NS_OK unless a catastrophic error occurs. If the method
|
||||
// returns NS_OK, you may assume that labels points to a valid (but
|
||||
// possible empty) nsISimpleEnumerator object.
|
||||
nsISimpleEnumerator ArcLabelsOut(in nsIRDFResource aSource);
|
||||
|
||||
// Retrieve all of the resources that the data source currently
|
||||
// refers to.
|
||||
nsISimpleEnumerator GetAllResources();
|
||||
|
||||
// Request that a data source write it's contents out to
|
||||
// permanent storage if applicable.
|
||||
void Flush();
|
||||
|
||||
// Returns the set of all commands defined for a given source.
|
||||
nsIEnumerator GetAllCommands(in nsIRDFResource aSource);
|
||||
|
||||
// Returns whether a given command is enabled for a set of sources.
|
||||
boolean IsCommandEnabled(in nsISupportsArray aSources,
|
||||
in nsIRDFResource aCommand,
|
||||
in nsISupportsArray aArguments);
|
||||
|
||||
// Perform the specified command on set of sources.
|
||||
void DoCommand(in nsISupportsArray aSources,
|
||||
in nsIRDFResource aCommand,
|
||||
in nsISupportsArray aArguments);
|
||||
};
|
||||
|
||||
// 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 {
|
||||
// Add a datasource the the database.
|
||||
void AddDataSource(in nsIRDFDataSource aDataSource);
|
||||
|
||||
// Remove a datasource from the database
|
||||
void RemoveDataSource(in nsIRDFDataSource aDataSource);
|
||||
};
|
||||
|
||||
// The RDF service interface. This is a singleton object, and should be
|
||||
// obtained from the <tt>nsServiceManager</tt>.
|
||||
[scriptable, uuid(BFD05261-834C-11d2-8EAC-00805F29F370)]
|
||||
interface nsIRDFService : nsISupports {
|
||||
// Construct an RDF resource from a single-byte URI. <tt>nsIRDFSerivce</tt>
|
||||
// caches resources that are in-use, so multiple calls to <tt>GetResource()</tt>
|
||||
// for the same <tt>uri</tt> will return identical pointers. FindResource
|
||||
// is used to find out whether there already exists a resource corresponding to that url.
|
||||
nsIRDFResource GetResource(in string aURI);
|
||||
|
||||
// Construct an RDF resource from a Unicode URI. This is provided
|
||||
// as a convenience method, allowing automatic, in-line C++
|
||||
// conversion from <tt>nsString</tt> objects. The <tt>uri</tt> will
|
||||
// be converted to a single-byte representation internally.
|
||||
nsIRDFResource GetUnicodeResource(in wstring aURI);
|
||||
|
||||
// Construct an RDF literal from a Unicode string.
|
||||
nsIRDFLiteral GetLiteral(in wstring aValue);
|
||||
|
||||
// Construct an RDF literal from a PRTime.
|
||||
nsIRDFDate GetDateLiteral(in long long aValue);
|
||||
|
||||
// Construct an RDF literal from an int.
|
||||
nsIRDFInt GetIntLiteral(in long aValue);
|
||||
|
||||
// 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
|
||||
// (accessable 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 <tt>const char*</tt> URI.
|
||||
void UnregisterResource(in nsIRDFResource aResource);
|
||||
|
||||
// Register a <i>named data source</i>. The RDF service will call
|
||||
// <tt>nsIRDFDataSource::GetURI()</tt> 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
|
||||
// <tt>nsIRDFDataSource::Init()</tt>), 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
|
||||
// <tt>nsIRDFDataSource::GetURI()</tt> 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 <tt>RegisterDataSource()</tt>, 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 <tt>RegisterDatasourceConstructor()</tt>,
|
||||
// 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 <tt>nsIRDFDataSource::Init()</tt>.
|
||||
nsIRDFDataSource GetDataSource(in string aURI);
|
||||
};
|
||||
|
||||
|
||||
// A wrapper for manipulating RDF containers
|
||||
[scriptable, uuid(D4214E90-FB94-11D2-BDD8-00104BDE6048)]
|
||||
interface nsIRDFContainer : nsISupports {
|
||||
|
||||
// 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.
|
||||
void RemoveElement(in nsIRDFNode aElement, in boolean aRenumber);
|
||||
void InsertElementAt(in nsIRDFNode aElement, in long aIndex, in boolean aRenumber);
|
||||
long IndexOf(in nsIRDFNode aElement);
|
||||
};
|
||||
|
||||
|
||||
// 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 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);
|
||||
};
|
||||
27
mozilla/rdf/base/makefile.win
Normal file
27
mozilla/rdf/base/makefile.win
Normal file
@@ -0,0 +1,27 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
DIRS=\
|
||||
public \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
14
mozilla/rdf/base/public/MANIFEST
Normal file
14
mozilla/rdf/base/public/MANIFEST
Normal file
@@ -0,0 +1,14 @@
|
||||
rdf.h
|
||||
nsIRDFCompositeDataSource.h
|
||||
nsIRDFContainer.h
|
||||
nsIRDFContainerUtils.h
|
||||
nsIRDFContentSink.h
|
||||
nsIRDFDataSource.h
|
||||
nsIRDFNode.h
|
||||
nsIRDFObserver.h
|
||||
nsIRDFResource.h
|
||||
nsIRDFResourceFactory.h
|
||||
nsIRDFService.h
|
||||
nsIRDFXMLDataSource.h
|
||||
nsIRDFXMLSource.h
|
||||
nsRDFInterfaces.h
|
||||
48
mozilla/rdf/base/public/Makefile.in
Normal file
48
mozilla/rdf/base/public/Makefile.in
Normal file
@@ -0,0 +1,48 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
EXPORTS = \
|
||||
rdf.h \
|
||||
nsIRDFCompositeDataSource.h \
|
||||
nsIRDFContainer.h \
|
||||
nsIRDFContainerUtils.h \
|
||||
nsIRDFContentSink.h \
|
||||
nsIRDFDataSource.h \
|
||||
nsIRDFNode.h \
|
||||
nsIRDFObserver.h \
|
||||
nsIRDFResource.h \
|
||||
nsIRDFResourceFactory.h \
|
||||
nsIRDFService.h \
|
||||
nsIRDFXMLDataSource.h \
|
||||
nsIRDFXMLSource.h \
|
||||
nsRDFInterfaces.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
42
mozilla/rdf/base/public/makefile.win
Normal file
42
mozilla/rdf/base/public/makefile.win
Normal file
@@ -0,0 +1,42 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
MODULE=rdf
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
EXPORTS=\
|
||||
rdf.h \
|
||||
nsIRDFCompositeDataSource.h \
|
||||
nsIRDFContainer.h \
|
||||
nsIRDFContainerUtils.h \
|
||||
nsIRDFContentSink.h \
|
||||
nsIRDFDataSource.h \
|
||||
nsIRDFNode.h \
|
||||
nsIRDFObserver.h \
|
||||
nsIRDFResource.h \
|
||||
nsIRDFResourceFactory.h \
|
||||
nsIRDFService.h \
|
||||
nsIRDFXMLDataSource.h \
|
||||
nsIRDFXMLSource.h \
|
||||
nsRDFInterfaces.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
66
mozilla/rdf/base/public/nsIRDFCompositeDataSource.h
Normal file
66
mozilla/rdf/base/public/nsIRDFCompositeDataSource.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
RDF composite data source interface. A composite data source
|
||||
aggregates individual RDF data sources.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFCompositeDataSource_h__
|
||||
#define nsIRDFCompositeDataSource_h__
|
||||
|
||||
#if 1 //defined(USE_XPIDL_INTERFACES)
|
||||
#include "nsRDFInterfaces.h"
|
||||
#else
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
|
||||
// 96343820-307c-11d2-bc15-00805f912fe7
|
||||
#define NS_IRDFCOMPOSITEDATASOURCE_IID \
|
||||
{ 0x96343820, 0x307c, 0x11d2, { 0xb, 0x15, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } }
|
||||
|
||||
/**
|
||||
* An <tt>nsIRDFCompositeDataSource</tt> composes individual data sources, providing
|
||||
* the illusion of a single, coherent RDF graph.
|
||||
*/
|
||||
class nsIRDFCompositeDataSource : public nsIRDFDataSource {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFCOMPOSITEDATASOURCE_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Add a datasource the the database.
|
||||
*/
|
||||
NS_IMETHOD AddDataSource(nsIRDFDataSource* source) = 0;
|
||||
|
||||
/**
|
||||
* Remove a datasource from the database
|
||||
*/
|
||||
NS_IMETHOD RemoveDataSource(nsIRDFDataSource* source) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
extern nsresult
|
||||
NS_NewRDFCompositeDataSource(nsIRDFCompositeDataSource** result);
|
||||
|
||||
#endif /* nsIRDFCompositeDataSource_h__ */
|
||||
47
mozilla/rdf/base/public/nsIRDFContainer.h
Normal file
47
mozilla/rdf/base/public/nsIRDFContainer.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFContainer_h__
|
||||
#define nsIRDFContainer_h__
|
||||
|
||||
#include "nsRDFInterfaces.h"
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewRDFContainer(nsIRDFContainer** aResult);
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewRDFContainer(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aResource,
|
||||
nsIRDFContainer** aResult);
|
||||
|
||||
/**
|
||||
* Create a cursor on a container that enumerates its contents in
|
||||
* order
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewContainerEnumerator(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aContainer,
|
||||
nsISimpleEnumerator** aResult);
|
||||
|
||||
|
||||
#endif // nsIRDFContainer_h__
|
||||
|
||||
|
||||
|
||||
|
||||
29
mozilla/rdf/base/public/nsIRDFContainerUtils.h
Normal file
29
mozilla/rdf/base/public/nsIRDFContainerUtils.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFContainerUtils_h__
|
||||
#define nsIRDFContainerUtils_h__
|
||||
|
||||
#include "nsRDFInterfaces.h"
|
||||
|
||||
extern nsresult
|
||||
NS_NewRDFContainerUtils(nsIRDFContainerUtils** aResult);
|
||||
|
||||
#endif // nsIRDFContainerUtils_h__
|
||||
|
||||
72
mozilla/rdf/base/public/nsIRDFContentSink.h
Normal file
72
mozilla/rdf/base/public/nsIRDFContentSink.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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 nsIDocument;
|
||||
class nsIRDFXMLDataSource;
|
||||
class nsINameSpaceManager;
|
||||
class nsIURL;
|
||||
|
||||
// {751843E2-8309-11d2-8EAC-00805F29F370}
|
||||
#define NS_IRDFCONTENTSINK_IID \
|
||||
{ 0x751843e2, 0x8309, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
* This interface represents a content sink for RDF files.
|
||||
*/
|
||||
|
||||
class nsIRDFContentSink : public nsIXMLContentSink {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFCONTENTSINK_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Initialize the content sink.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIURL* aURL, nsINameSpaceManager* aNameSpaceManager) = 0;
|
||||
|
||||
/**
|
||||
* Set the content sink's RDF Data source
|
||||
*/
|
||||
NS_IMETHOD SetDataSource(nsIRDFXMLDataSource* aDataSource) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the content sink's RDF data source.
|
||||
*/
|
||||
NS_IMETHOD GetDataSource(nsIRDFXMLDataSource*& rDataSource) = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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___
|
||||
31
mozilla/rdf/base/public/nsIRDFDataSource.h
Normal file
31
mozilla/rdf/base/public/nsIRDFDataSource.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF data source interface. An RDF data source presents a
|
||||
graph-like interface to a back-end service.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDataSource_h__
|
||||
#define nsIRDFDataSource_h__
|
||||
|
||||
#include "nsRDFInterfaces.h"
|
||||
|
||||
#endif /* nsIRDFDataSource_h__ */
|
||||
31
mozilla/rdf/base/public/nsIRDFNode.h
Normal file
31
mozilla/rdf/base/public/nsIRDFNode.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
RDF node interfaces, including nsIRDFNode, nsIRDFResource, and
|
||||
nsIRDFLiteral. Nodes are the elements that appear in RDF graphs.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFNode_h__
|
||||
#define nsIRDFNode_h__
|
||||
|
||||
#include "nsRDFInterfaces.h"
|
||||
|
||||
#endif // nsIRDFNode_h__
|
||||
31
mozilla/rdf/base/public/nsIRDFObserver.h
Normal file
31
mozilla/rdf/base/public/nsIRDFObserver.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF data source observer interface. Data source observers are
|
||||
notified when the contents of the graph change.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFObserver_h__
|
||||
#define nsIRDFObserver_h__
|
||||
|
||||
#include "nsRDFInterfaces.h"
|
||||
|
||||
#endif /* nsIRDFObserver_h__ */
|
||||
26
mozilla/rdf/base/public/nsIRDFResource.h
Normal file
26
mozilla/rdf/base/public/nsIRDFResource.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsIRDFResource_h__
|
||||
#define nsIRDFResource_h__
|
||||
|
||||
#include "nsRDFInterfaces.h"
|
||||
|
||||
#endif // nsIRDFResource_h__
|
||||
|
||||
77
mozilla/rdf/base/public/nsIRDFResourceFactory.h
Normal file
77
mozilla/rdf/base/public/nsIRDFResourceFactory.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
The RDF resource factory interface. A resource factory produces
|
||||
nsIRDFResource objects for a specified URI prefix.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFResourceFactory_h__
|
||||
#define nsIRDFResourceFactory_h__
|
||||
|
||||
#if 0 // obsolete
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIRDFResource;
|
||||
|
||||
// {8CE57A20-A02C-11d2-8EBF-00805F29F370}
|
||||
#define NS_IRDFRESOURCEFACTORY_IID \
|
||||
{ 0x8ce57a20, 0xa02c, 0x11d2, { 0x8e, 0xbf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
/**
|
||||
* A resource factory can be registered with <tt>nsIRDFService</tt> to produce
|
||||
* resources with a certain <i>URI prefix</i>. The resource factory will be called
|
||||
* upon to create a new resource, which the resource manager will cache.
|
||||
*
|
||||
* @see nsIRDFService::RegisterResourceFactory
|
||||
* @see nsIRDFService::UnRegisterResourceFactory
|
||||
*/
|
||||
class nsIRDFResourceFactory : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFRESOURCEFACTORY_IID; return iid; }
|
||||
|
||||
/**
|
||||
* This method is called by the RDF service to create a new
|
||||
* resource.
|
||||
*
|
||||
* NOTE. After constructing a new resource via a call to
|
||||
* nsIRDFResourceFactory::CreateResource(), the implementation of
|
||||
* the RDF service calls nsIRDFResource::GetValue() on the
|
||||
* resulting resource. The resulting <tt>const char*</tt> is used
|
||||
* as a key for the resource cache. (The assumption is that the
|
||||
* custom resource implementation needs to store this information,
|
||||
* anyway.)
|
||||
*
|
||||
* This has important implications for a custom resource's
|
||||
* destructor; namely, that you must call
|
||||
* nsIRDFService::UnCacheResource() <b>before</b> releasing the
|
||||
* storage for the resource's URI. See
|
||||
* nsIRDFService::UnCacheResource() for more information.
|
||||
*/
|
||||
NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // nsIRDFResourceFactory_h__
|
||||
|
||||
34
mozilla/rdf/base/public/nsIRDFService.h
Normal file
34
mozilla/rdf/base/public/nsIRDFService.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF service interface. This is a singleton object, and should be
|
||||
obtained from the <tt>nsServiceManager</tt>.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFService_h__
|
||||
#define nsIRDFService_h__
|
||||
|
||||
#include "nsRDFInterfaces.h"
|
||||
|
||||
extern nsresult
|
||||
NS_NewRDFService(nsIRDFService** result);
|
||||
|
||||
#endif // nsIRDFService_h__
|
||||
60
mozilla/rdf/base/public/nsIRDFTree.h
Normal file
60
mozilla/rdf/base/public/nsIRDFTree.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFTree_h__
|
||||
#define nsIRDFTree_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "prtypes.h"
|
||||
#include "rdf.h" // for error codes
|
||||
|
||||
/*
|
||||
An interface for presenting a tree view of an rdf datasource (or
|
||||
database).
|
||||
|
||||
Any datasource can also support nsIRDFTree. The interface is purely
|
||||
syntactic sugar for traversing simple tree where the child relation
|
||||
corresponds to the property type nc:child (nc = http://home.netscape.com/NC-rdf#).
|
||||
Each leaf is assumed to have a certain predefined set of properties
|
||||
such as creationDate, size, lastModificationDate, lastVisitDate, etc.
|
||||
|
||||
This interface is substantially less general than nsIRDFDataSource,
|
||||
but is adequate for bookmarks, the file system, history and a few
|
||||
other very commonly used data sources.
|
||||
|
||||
*/
|
||||
|
||||
// {7D7EEBD1-AA41-11d2-80B7-006097B76B8E}
|
||||
#define NS_IRDFTREE_IID \
|
||||
{ 0x7d7eebd1, 0xaa41, 0x11d2, { 0x80, 0xb7, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } };
|
||||
|
||||
class nsIRDFTree : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD ListChildren (nsIRDFResource* folder, nsVoidArray** result);
|
||||
// XXX should define something called nsResourceArray and use that
|
||||
|
||||
NS_IMETHOD IsFolder (nsIRDFResource* node, PRBool* result);
|
||||
|
||||
NS_IMETHOD GetProperty (nsIRDFResource* node, nsIRDFResource* property,
|
||||
nsIRDFNode** result);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
200
mozilla/rdf/base/public/nsIRDFXMLDataSource.h
Normal file
200
mozilla/rdf/base/public/nsIRDFXMLDataSource.h
Normal file
@@ -0,0 +1,200 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This interface encapsulates information about an RDF/XML file,
|
||||
including the root resource, CSS style sheets, and named data
|
||||
sources.
|
||||
|
||||
This file also includes an observer interface for nsIRDFXMLDataSource
|
||||
objects.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFXMLDataSource_h__
|
||||
#define nsIRDFXMLDataSource_h__
|
||||
|
||||
#include "nsIRDFDataSource.h"
|
||||
class nsIAtom;
|
||||
class nsIOutputStream;
|
||||
class nsIURL;
|
||||
class nsString;
|
||||
|
||||
// {EB1A5D30-AB33-11d2-8EC6-00805F29F370}
|
||||
#define NS_IRDFXMLDOCUMENTOBSERVER_IID \
|
||||
{ 0xeb1a5d30, 0xab33, 0x11d2, { 0x8e, 0xc6, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFXMLDataSource;
|
||||
|
||||
class nsIRDFXMLDataSourceObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFXMLDOCUMENTOBSERVER_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Called when the RDF/XML document begins to load.
|
||||
*/
|
||||
NS_IMETHOD OnBeginLoad(nsIRDFXMLDataSource* aStream) = 0;
|
||||
|
||||
/**
|
||||
* Called when the RDF/XML document load is interrupted for some reason.
|
||||
*/
|
||||
NS_IMETHOD OnInterrupt(nsIRDFXMLDataSource* aStream) = 0;
|
||||
|
||||
/**
|
||||
* Called when an interrupted RDF/XML document load is resumed.
|
||||
*/
|
||||
NS_IMETHOD OnResume(nsIRDFXMLDataSource* aStream) = 0;
|
||||
|
||||
/**
|
||||
* Called whtn the RDF/XML document load is complete.
|
||||
*/
|
||||
NS_IMETHOD OnEndLoad(nsIRDFXMLDataSource* aStream) = 0;
|
||||
|
||||
/**
|
||||
* Called when the root resource of the RDF/XML document is found
|
||||
*/
|
||||
NS_IMETHOD OnRootResourceFound(nsIRDFXMLDataSource* aStream, nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Called when a CSS style sheet is included (via XML processing
|
||||
* instruction) to the document.
|
||||
*/
|
||||
NS_IMETHOD OnCSSStyleSheetAdded(nsIRDFXMLDataSource* aStream, nsIURL* aCSSStyleSheetURL) = 0;
|
||||
|
||||
/**
|
||||
* Called when a named data source is included (via XML processing
|
||||
* instruction) to the document.
|
||||
*/
|
||||
NS_IMETHOD OnNamedDataSourceAdded(nsIRDFXMLDataSource* aStream, const char* aNamedDataSourceURI) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// {EB1A5D31-AB33-11d2-8EC6-00805F29F370}
|
||||
#define NS_IRDFXMLDATASOURCE_IID \
|
||||
{ 0xeb1a5d31, 0xab33, 0x11d2, { 0x8e, 0xc6, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFXMLDataSource : public nsIRDFDataSource
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFXMLDATASOURCE_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Sets the RDF/XML stream to load either synchronously or
|
||||
* asynchronously when nsIRDFDataSource::Init() is called.
|
||||
* By default, the stream will load <em>asynchronously</em>.
|
||||
*/
|
||||
NS_IMETHOD SetSynchronous(PRBool aIsSynchronous) = 0;
|
||||
|
||||
/**
|
||||
* Sets the RDF/XML stream's read-only status. By default,
|
||||
* the stream will be read/write if the URL on which
|
||||
* nsIRDFDataSource::Init() is called is writable.
|
||||
*/
|
||||
NS_IMETHOD SetReadOnly(PRBool aIsReadOnly) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is beginning.
|
||||
*/
|
||||
NS_IMETHOD BeginLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is being interrupted.
|
||||
*/
|
||||
NS_IMETHOD Interrupt(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that an interrupted load is being resumed.
|
||||
*/
|
||||
NS_IMETHOD Resume(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is ending.
|
||||
*/
|
||||
NS_IMETHOD EndLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the root resource for the document.
|
||||
*/
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the root resource for the document.
|
||||
*/
|
||||
NS_IMETHOD GetRootResource(nsIRDFResource** aResource) = 0;
|
||||
|
||||
/**
|
||||
* Add a CSS style sheet to the document.
|
||||
* @param aStyleSheetURL An nsIURL object that is the URL of the style
|
||||
* sheet to add to the document.
|
||||
*/
|
||||
NS_IMETHOD AddCSSStyleSheetURL(nsIURL* aStyleSheetURL) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of style sheets that have been included in the
|
||||
* document.
|
||||
* @param aStyleSheetURLs (out) A pointer to an array of pointers to nsIURL objects.
|
||||
* @param aCount (out) The number of nsIURL objects returned.
|
||||
*/
|
||||
NS_IMETHOD GetCSSStyleSheetURLs(nsIURL*** aStyleSheetURLs, PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Add a named data source to the document.
|
||||
* @param aNamedDataSoruceURI A URI identifying the data source.
|
||||
*/
|
||||
NS_IMETHOD AddNamedDataSourceURI(const char* aNamedDataSourceURI) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of named data sources that have been included in
|
||||
* the document
|
||||
* @param aNamedDataSourceURIs (out) A pointer to an array of C-style character
|
||||
* strings.
|
||||
* @param aCount (out) The number of named data sources in the array.
|
||||
*/
|
||||
NS_IMETHOD GetNamedDataSourceURIs(const char* const** aNamedDataSourceURIs, PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Add a new namespace declaration to the RDF/XML document.
|
||||
*/
|
||||
NS_IMETHOD AddNameSpace(nsIAtom* aPrefix, const nsString& aURI) = 0;
|
||||
|
||||
/**
|
||||
* Add an observer to the document. The observer will be notified of
|
||||
* RDF/XML events via the nsIRDFXMLDataSourceObserver interface. Note that
|
||||
* the observer is <em>not</em> reference counted.
|
||||
*/
|
||||
NS_IMETHOD AddXMLStreamObserver(nsIRDFXMLDataSourceObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer from the document.
|
||||
*/
|
||||
NS_IMETHOD RemoveXMLStreamObserver(nsIRDFXMLDataSourceObserver* aObserver) = 0;
|
||||
};
|
||||
|
||||
// Two different kinds of XML data sources exist for RDF: serialized RDF and XUL.
|
||||
// These are the methods that make these data sources.
|
||||
extern nsresult
|
||||
NS_NewRDFXMLDataSource(nsIRDFXMLDataSource** result);
|
||||
|
||||
extern nsresult
|
||||
NS_NewXULDataSource(nsIRDFXMLDataSource** result);
|
||||
|
||||
#endif // nsIRDFXMLDataSource_h__
|
||||
|
||||
165
mozilla/rdf/base/public/nsIRDFXMLDocument.h
Normal file
165
mozilla/rdf/base/public/nsIRDFXMLDocument.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This interface encapsulates information about an RDF/XML file,
|
||||
including the root resource, CSS style sheets, and named data
|
||||
sources.
|
||||
|
||||
This file also includes an observer interface for nsIRDFXMLDocument
|
||||
objects.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFXMLDocument_h__
|
||||
#define nsIRDFXMLDocument_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIOutputStream;
|
||||
class nsIURL;
|
||||
|
||||
// {EB1A5D30-AB33-11d2-8EC6-00805F29F370}
|
||||
#define NS_IRDFXMLDOCUMENTOBSERVER_IID \
|
||||
{ 0xeb1a5d30, 0xab33, 0x11d2, { 0x8e, 0xc6, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFXMLDocumentObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Called when the RDF/XML document begins to load.
|
||||
*/
|
||||
NS_IMETHOD OnBeginLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Called when the RDF/XML document load is interrupted for some reason.
|
||||
*/
|
||||
NS_IMETHOD OnInterrupt(void) = 0;
|
||||
|
||||
/**
|
||||
* Called when an interrupted RDF/XML document load is resumed.
|
||||
*/
|
||||
NS_IMETHOD OnResume(void) = 0;
|
||||
|
||||
/**
|
||||
* Called whtn the RDF/XML document load is complete.
|
||||
*/
|
||||
NS_IMETHOD OnEndLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Called when the root resource of the RDF/XML document is found
|
||||
*/
|
||||
NS_IMETHOD OnRootResourceFound(nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Called when a CSS style sheet is included (via XML processing
|
||||
* instruction) to the document.
|
||||
*/
|
||||
NS_IMETHOD OnCSSStyleSheetAdded(nsIURL* aCSSStyleSheetURL) = 0;
|
||||
|
||||
/**
|
||||
* Called when a named data source is included (via XML processing
|
||||
* instruction) to the document.
|
||||
*/
|
||||
NS_IMETHOD OnNamedDataSourceAdded(const char* aNamedDataSourceURI) = 0;
|
||||
};
|
||||
|
||||
|
||||
// {EB1A5D31-AB33-11d2-8EC6-00805F29F370}
|
||||
#define NS_IRDFXMLDOCUMENT_IID \
|
||||
{ 0xeb1a5d31, 0xab33, 0x11d2, { 0x8e, 0xc6, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFXMLDocument : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Notify the document that the load is beginning.
|
||||
*/
|
||||
NS_IMETHOD BeginLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is being interrupted.
|
||||
*/
|
||||
NS_IMETHOD Interrupt(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that an interrupted load is being resumed.
|
||||
*/
|
||||
NS_IMETHOD Resume(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is ending.
|
||||
*/
|
||||
NS_IMETHOD EndLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the root resource for the document.
|
||||
*/
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the root resource for the document.
|
||||
*/
|
||||
NS_IMETHOD GetRootResource(nsIRDFResource** aResource) = 0;
|
||||
|
||||
/**
|
||||
* Add a CSS style sheet to the document.
|
||||
* @param aStyleSheetURL An nsIURL object that is the URL of the style
|
||||
* sheet to add to the document.
|
||||
*/
|
||||
NS_IMETHOD AddCSSStyleSheetURL(nsIURL* aStyleSheetURL) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of style sheets that have been included in the
|
||||
* document.
|
||||
* @param aStyleSheetURLs (out) A pointer to an array of pointers to nsIURL objects.
|
||||
* @param aCount (out) The number of nsIURL objects returned.
|
||||
*/
|
||||
NS_IMETHOD GetCSSStyleSheetURLs(nsIURL*** aStyleSheetURLs, PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Add a named data source to the document.
|
||||
* @param aNamedDataSoruceURI A URI identifying the data source.
|
||||
*/
|
||||
NS_IMETHOD AddNamedDataSourceURI(const char* aNamedDataSourceURI) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of named data sources that have been included in
|
||||
* the document
|
||||
* @param aNamedDataSourceURIs (out) A pointer to an array of C-style character
|
||||
* strings.
|
||||
* @param aCount (out) The number of named data sources in the array.
|
||||
*/
|
||||
NS_IMETHOD GetNamedDataSourceURIs(const char* const** aNamedDataSourceURIs, PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Add an observer to the document. The observer will be notified of
|
||||
* RDF/XML events via the nsIRDFXMLDocumentObserver interface. Note that
|
||||
* the observer is <em>not</em> reference counted.
|
||||
*/
|
||||
NS_IMETHOD AddDocumentObserver(nsIRDFXMLDocumentObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer from the document.
|
||||
*/
|
||||
NS_IMETHOD RemoveDocumentObserver(nsIRDFXMLDocumentObserver* aObserver) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsIRDFXMLDocument_h__
|
||||
|
||||
44
mozilla/rdf/base/public/nsIRDFXMLSource.h
Normal file
44
mozilla/rdf/base/public/nsIRDFXMLSource.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF/XML source interface. An RDF/XML source is capable of
|
||||
producing serialized RDF/XML to an output stream.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFXMLSource_h__
|
||||
#define nsIRDFXMLSource_h__
|
||||
|
||||
class nsIOutputStream;
|
||||
|
||||
// {4DA56F10-99FE-11d2-8EBB-00805F29F370}
|
||||
#define NS_IRDFXMLSOURCE_IID \
|
||||
{ 0x4da56f10, 0x99fe, 0x11d2, { 0x8e, 0xbb, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
class nsIRDFXMLSource : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFXMLSOURCE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD Serialize(nsIOutputStream* aStream) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIRDFXMLSource_h__
|
||||
400
mozilla/rdf/base/public/nsRDFInterfaces.h
Normal file
400
mozilla/rdf/base/public/nsRDFInterfaces.h
Normal file
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* DO NOT EDIT. THIS FILE IS GENERATED FROM nsRDFInterfaces.idl
|
||||
*/
|
||||
|
||||
#ifndef __gen_nsRDFInterfaces_h__
|
||||
#define __gen_nsRDFInterfaces_h__
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsISupportsArray.h" /* interface nsISupportsArray */
|
||||
#include "nsICollection.h" /* interface nsICollection */
|
||||
#include "nsIEnumerator.h" /* interface nsIEnumerator */
|
||||
#include "nsrootidl.h" /* interface nsrootidl */
|
||||
#include "nsISimpleEnumerator.h" /* interface nsISimpleEnumerator */
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
#include "nscore.h" // for PRUnichar
|
||||
|
||||
|
||||
/* starting interface: nsIRDFNode */
|
||||
|
||||
/* {0F78DA50-8321-11d2-8EAC-00805F29F370} */
|
||||
#define NS_IRDFNODE_IID_STR "0F78DA50-8321-11d2-8EAC-00805F29F370"
|
||||
#define NS_IRDFNODE_IID \
|
||||
{0x0F78DA50, 0x8321, 0x11d2, \
|
||||
{ 0x8E, 0xAC, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFNode : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFNODE_IID)
|
||||
|
||||
/* boolean EqualsNode (in nsIRDFNode aNode); */
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode *aNode, PRBool *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFNode *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFResource */
|
||||
|
||||
/* {E0C493D1-9542-11d2-8EB8-00805F29F370} */
|
||||
#define NS_IRDFRESOURCE_IID_STR "E0C493D1-9542-11d2-8EB8-00805F29F370"
|
||||
#define NS_IRDFRESOURCE_IID \
|
||||
{0xE0C493D1, 0x9542, 0x11d2, \
|
||||
{ 0x8E, 0xB8, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFResource : public nsIRDFNode {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFRESOURCE_IID)
|
||||
|
||||
/* readonly attribute string Value; */
|
||||
NS_IMETHOD GetValue(char * *aValue) = 0;
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(const char *uri) = 0;
|
||||
|
||||
/* boolean EqualsResource (in nsIRDFResource aResource); */
|
||||
NS_IMETHOD EqualsResource(nsIRDFResource *aResource, PRBool *_retval) = 0;
|
||||
|
||||
/* boolean EqualsString (in string aURI); */
|
||||
NS_IMETHOD EqualsString(const char *aURI, PRBool *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFResource *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFLiteral */
|
||||
|
||||
/* {E0C493D2-9542-11d2-8EB8-00805F29F370} */
|
||||
#define NS_IRDFLITERAL_IID_STR "E0C493D2-9542-11d2-8EB8-00805F29F370"
|
||||
#define NS_IRDFLITERAL_IID \
|
||||
{0xE0C493D2, 0x9542, 0x11d2, \
|
||||
{ 0x8E, 0xB8, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFLiteral : public nsIRDFNode {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFLITERAL_IID)
|
||||
|
||||
/* readonly attribute wstring Value; */
|
||||
NS_IMETHOD GetValue(PRUnichar * *aValue) = 0;
|
||||
|
||||
/* boolean EqualsLiteral (in nsIRDFLiteral aLiteral); */
|
||||
NS_IMETHOD EqualsLiteral(nsIRDFLiteral *aLiteral, PRBool *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFLiteral *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFDate */
|
||||
|
||||
/* {E13A24E1-C77A-11d2-80BE-006097B76B8E} */
|
||||
#define NS_IRDFDATE_IID_STR "E13A24E1-C77A-11d2-80BE-006097B76B8E"
|
||||
#define NS_IRDFDATE_IID \
|
||||
{0xE13A24E1, 0xC77A, 0x11d2, \
|
||||
{ 0x80, 0xBE, 0x00, 0x60, 0x97, 0xB7, 0x6B, 0x8E }}
|
||||
|
||||
class nsIRDFDate : public nsIRDFNode {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFDATE_IID)
|
||||
|
||||
/* readonly attribute long long Value; */
|
||||
NS_IMETHOD GetValue(PRInt64 *aValue) = 0;
|
||||
|
||||
/* boolean EqualsDate (in nsIRDFDate aDate); */
|
||||
NS_IMETHOD EqualsDate(nsIRDFDate *aDate, PRBool *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFDate *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFInt */
|
||||
|
||||
/* {E13A24E3-C77A-11d2-80BE-006097B76B8E} */
|
||||
#define NS_IRDFINT_IID_STR "E13A24E3-C77A-11d2-80BE-006097B76B8E"
|
||||
#define NS_IRDFINT_IID \
|
||||
{0xE13A24E3, 0xC77A, 0x11d2, \
|
||||
{ 0x80, 0xBE, 0x00, 0x60, 0x97, 0xB7, 0x6B, 0x8E }}
|
||||
|
||||
class nsIRDFInt : public nsIRDFNode {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFINT_IID)
|
||||
|
||||
/* readonly attribute long Value; */
|
||||
NS_IMETHOD GetValue(PRInt32 *aValue) = 0;
|
||||
|
||||
/* boolean EqualsInt (in nsIRDFInt aInt); */
|
||||
NS_IMETHOD EqualsInt(nsIRDFInt *aInt, PRBool *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFInt *priv);
|
||||
#endif
|
||||
};
|
||||
class nsIRDFDataSource; /* forward decl */
|
||||
|
||||
/* starting interface: nsIRDFObserver */
|
||||
|
||||
/* {3CC75360-484A-11D2-BC16-00805F912FE7} */
|
||||
#define NS_IRDFOBSERVER_IID_STR "3CC75360-484A-11D2-BC16-00805F912FE7"
|
||||
#define NS_IRDFOBSERVER_IID \
|
||||
{0x3CC75360, 0x484A, 0x11D2, \
|
||||
{ 0xBC, 0x16, 0x00, 0x80, 0x5F, 0x91, 0x2F, 0xE7 }}
|
||||
|
||||
class nsIRDFObserver : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFOBSERVER_IID)
|
||||
|
||||
/* void OnAssert (in nsIRDFResource aSource, in nsIRDFResource aLabel, in nsIRDFNode aTarget); */
|
||||
NS_IMETHOD OnAssert(nsIRDFResource *aSource, nsIRDFResource *aLabel, nsIRDFNode *aTarget) = 0;
|
||||
|
||||
/* void OnUnassert (in nsIRDFResource aSource, in nsIRDFResource aLabel, in nsIRDFNode aTarget); */
|
||||
NS_IMETHOD OnUnassert(nsIRDFResource *aSource, nsIRDFResource *aLabel, nsIRDFNode *aTarget) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFObserver *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFDataSource */
|
||||
|
||||
/* {0F78DA58-8321-11d2-8EAC-00805F29F370} */
|
||||
#define NS_IRDFDATASOURCE_IID_STR "0F78DA58-8321-11d2-8EAC-00805F29F370"
|
||||
#define NS_IRDFDATASOURCE_IID \
|
||||
{0x0F78DA58, 0x8321, 0x11d2, \
|
||||
{ 0x8E, 0xAC, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFDataSource : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFDATASOURCE_IID)
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(const char *uri) = 0;
|
||||
|
||||
/* readonly attribute string URI; */
|
||||
NS_IMETHOD GetURI(char * *aURI) = 0;
|
||||
|
||||
/* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetSource(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsIRDFResource **_retval) = 0;
|
||||
|
||||
/* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsISimpleEnumerator **_retval) = 0;
|
||||
|
||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsIRDFNode **_retval) = 0;
|
||||
|
||||
/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsISimpleEnumerator **_retval) = 0;
|
||||
|
||||
/* void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue) = 0;
|
||||
|
||||
/* void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */
|
||||
NS_IMETHOD Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget) = 0;
|
||||
|
||||
/* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval) = 0;
|
||||
|
||||
/* void AddObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver *aObserver) = 0;
|
||||
|
||||
/* void RemoveObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver *aObserver) = 0;
|
||||
|
||||
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval) = 0;
|
||||
|
||||
/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval) = 0;
|
||||
|
||||
/* nsISimpleEnumerator GetAllResources (); */
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator **_retval) = 0;
|
||||
|
||||
/* void Flush (); */
|
||||
NS_IMETHOD Flush() = 0;
|
||||
|
||||
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval) = 0;
|
||||
|
||||
/* boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */
|
||||
NS_IMETHOD IsCommandEnabled(nsISupportsArray *aSources, nsIRDFResource *aCommand, nsISupportsArray *aArguments, PRBool *_retval) = 0;
|
||||
|
||||
/* void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */
|
||||
NS_IMETHOD DoCommand(nsISupportsArray *aSources, nsIRDFResource *aCommand, nsISupportsArray *aArguments) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFDataSource *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFCompositeDataSource */
|
||||
|
||||
/* {96343820-307C-11D2-BC15-00805F912FE7} */
|
||||
#define NS_IRDFCOMPOSITEDATASOURCE_IID_STR "96343820-307C-11D2-BC15-00805F912FE7"
|
||||
#define NS_IRDFCOMPOSITEDATASOURCE_IID \
|
||||
{0x96343820, 0x307C, 0x11D2, \
|
||||
{ 0xBC, 0x15, 0x00, 0x80, 0x5F, 0x91, 0x2F, 0xE7 }}
|
||||
|
||||
class nsIRDFCompositeDataSource : public nsIRDFDataSource {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFCOMPOSITEDATASOURCE_IID)
|
||||
|
||||
/* void AddDataSource (in nsIRDFDataSource aDataSource); */
|
||||
NS_IMETHOD AddDataSource(nsIRDFDataSource *aDataSource) = 0;
|
||||
|
||||
/* void RemoveDataSource (in nsIRDFDataSource aDataSource); */
|
||||
NS_IMETHOD RemoveDataSource(nsIRDFDataSource *aDataSource) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFCompositeDataSource *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFService */
|
||||
|
||||
/* {BFD05261-834C-11d2-8EAC-00805F29F370} */
|
||||
#define NS_IRDFSERVICE_IID_STR "BFD05261-834C-11d2-8EAC-00805F29F370"
|
||||
#define NS_IRDFSERVICE_IID \
|
||||
{0xBFD05261, 0x834C, 0x11d2, \
|
||||
{ 0x8E, 0xAC, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFService : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFSERVICE_IID)
|
||||
|
||||
/* nsIRDFResource GetResource (in string aURI); */
|
||||
NS_IMETHOD GetResource(const char *aURI, nsIRDFResource **_retval) = 0;
|
||||
|
||||
/* nsIRDFResource GetUnicodeResource (in wstring aURI); */
|
||||
NS_IMETHOD GetUnicodeResource(const PRUnichar *aURI, nsIRDFResource **_retval) = 0;
|
||||
|
||||
/* nsIRDFLiteral GetLiteral (in wstring aValue); */
|
||||
NS_IMETHOD GetLiteral(const PRUnichar *aValue, nsIRDFLiteral **_retval) = 0;
|
||||
|
||||
/* nsIRDFDate GetDateLiteral (in long long aValue); */
|
||||
NS_IMETHOD GetDateLiteral(PRInt64 aValue, nsIRDFDate **_retval) = 0;
|
||||
|
||||
/* nsIRDFInt GetIntLiteral (in long aValue); */
|
||||
NS_IMETHOD GetIntLiteral(PRInt32 aValue, nsIRDFInt **_retval) = 0;
|
||||
|
||||
/* void RegisterResource (in nsIRDFResource aResource, in boolean aReplace); */
|
||||
NS_IMETHOD RegisterResource(nsIRDFResource *aResource, PRBool aReplace) = 0;
|
||||
|
||||
/* void UnregisterResource (in nsIRDFResource aResource); */
|
||||
NS_IMETHOD UnregisterResource(nsIRDFResource *aResource) = 0;
|
||||
|
||||
/* void RegisterDataSource (in nsIRDFDataSource aDataSource, in boolean aReplace); */
|
||||
NS_IMETHOD RegisterDataSource(nsIRDFDataSource *aDataSource, PRBool aReplace) = 0;
|
||||
|
||||
/* void UnregisterDataSource (in nsIRDFDataSource aDataSource); */
|
||||
NS_IMETHOD UnregisterDataSource(nsIRDFDataSource *aDataSource) = 0;
|
||||
|
||||
/* nsIRDFDataSource GetDataSource (in string aURI); */
|
||||
NS_IMETHOD GetDataSource(const char *aURI, nsIRDFDataSource **_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFService *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFContainer */
|
||||
|
||||
/* {D4214E90-FB94-11D2-BDD8-00104BDE6048} */
|
||||
#define NS_IRDFCONTAINER_IID_STR "D4214E90-FB94-11D2-BDD8-00104BDE6048"
|
||||
#define NS_IRDFCONTAINER_IID \
|
||||
{0xD4214E90, 0xFB94, 0x11D2, \
|
||||
{ 0xBD, 0xD8, 0x00, 0x10, 0x4B, 0xDE, 0x60, 0x48 }}
|
||||
|
||||
class nsIRDFContainer : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFCONTAINER_IID)
|
||||
|
||||
/* void Init (in nsIRDFDataSource aDataSource, in nsIRDFResource aContainer); */
|
||||
NS_IMETHOD Init(nsIRDFDataSource *aDataSource, nsIRDFResource *aContainer) = 0;
|
||||
|
||||
/* long GetCount (); */
|
||||
NS_IMETHOD GetCount(PRInt32 *_retval) = 0;
|
||||
|
||||
/* nsISimpleEnumerator GetElements (); */
|
||||
NS_IMETHOD GetElements(nsISimpleEnumerator **_retval) = 0;
|
||||
|
||||
/* void AppendElement (in nsIRDFNode aElement); */
|
||||
NS_IMETHOD AppendElement(nsIRDFNode *aElement) = 0;
|
||||
|
||||
/* void RemoveElement (in nsIRDFNode aElement, in boolean aRenumber); */
|
||||
NS_IMETHOD RemoveElement(nsIRDFNode *aElement, PRBool aRenumber) = 0;
|
||||
|
||||
/* void InsertElementAt (in nsIRDFNode aElement, in long aIndex, in boolean aRenumber); */
|
||||
NS_IMETHOD InsertElementAt(nsIRDFNode *aElement, PRInt32 aIndex, PRBool aRenumber) = 0;
|
||||
|
||||
/* long IndexOf (in nsIRDFNode aElement); */
|
||||
NS_IMETHOD IndexOf(nsIRDFNode *aElement, PRInt32 *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFContainer *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface: nsIRDFContainerUtils */
|
||||
|
||||
/* {D4214E91-FB94-11D2-BDD8-00104BDE6048} */
|
||||
#define NS_IRDFCONTAINERUTILS_IID_STR "D4214E91-FB94-11D2-BDD8-00104BDE6048"
|
||||
#define NS_IRDFCONTAINERUTILS_IID \
|
||||
{0xD4214E91, 0xFB94, 0x11D2, \
|
||||
{ 0xBD, 0xD8, 0x00, 0x10, 0x4B, 0xDE, 0x60, 0x48 }}
|
||||
|
||||
class nsIRDFContainerUtils : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRDFCONTAINERUTILS_IID)
|
||||
|
||||
/* boolean IsOrdinalProperty (in nsIRDFResource aProperty); */
|
||||
NS_IMETHOD IsOrdinalProperty(nsIRDFResource *aProperty, PRBool *_retval) = 0;
|
||||
|
||||
/* nsIRDFResource IndexToOrdinalResource (in long aIndex); */
|
||||
NS_IMETHOD IndexToOrdinalResource(PRInt32 aIndex, nsIRDFResource **_retval) = 0;
|
||||
|
||||
/* long OrdinalResourceToIndex (in nsIRDFResource aOrdinal); */
|
||||
NS_IMETHOD OrdinalResourceToIndex(nsIRDFResource *aOrdinal, PRInt32 *_retval) = 0;
|
||||
|
||||
/* boolean IsContainer (in nsIRDFDataSource aDataSource, in nsIRDFResource aResource); */
|
||||
NS_IMETHOD IsContainer(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval) = 0;
|
||||
|
||||
/* boolean IsBag (in nsIRDFDataSource aDataSource, in nsIRDFResource aResource); */
|
||||
NS_IMETHOD IsBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval) = 0;
|
||||
|
||||
/* boolean IsSeq (in nsIRDFDataSource aDataSource, in nsIRDFResource aResource); */
|
||||
NS_IMETHOD IsSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval) = 0;
|
||||
|
||||
/* boolean IsAlt (in nsIRDFDataSource aDataSource, in nsIRDFResource aResource); */
|
||||
NS_IMETHOD IsAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval) = 0;
|
||||
|
||||
/* nsIRDFContainer MakeBag (in nsIRDFDataSource aDataSource, in nsIRDFResource aResource); */
|
||||
NS_IMETHOD MakeBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval) = 0;
|
||||
|
||||
/* nsIRDFContainer MakeSeq (in nsIRDFDataSource aDataSource, in nsIRDFResource aResource); */
|
||||
NS_IMETHOD MakeSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval) = 0;
|
||||
|
||||
/* nsIRDFContainer MakeAlt (in nsIRDFDataSource aDataSource, in nsIRDFResource aResource); */
|
||||
NS_IMETHOD MakeAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFContainerUtils *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* __gen_nsRDFInterfaces_h__ */
|
||||
105
mozilla/rdf/base/public/rdf.h
Normal file
105
mozilla/rdf/base/public/rdf.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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#"
|
||||
|
||||
|
||||
/**
|
||||
* @name Standard RDF error codes
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/* Returned from nsIRDFCursor::Advance() if the cursor has no more
|
||||
elements to enuemrate */
|
||||
#define NS_RDF_CURSOR_EMPTY NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_RDF, 1)
|
||||
|
||||
/* Returned from nsIRDFDataSource::GetSource() and GetTarget() if the source/target
|
||||
has no value */
|
||||
#define NS_RDF_NO_VALUE NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_RDF, 2)
|
||||
|
||||
/* Returned from nsIRDFDataSource::Assert() and Unassert() if the assertion (or
|
||||
unassertion was accepted by the datasource*/
|
||||
#define NS_RDF_ASSERTION_ACCEPTED NS_OK
|
||||
|
||||
/* Returned from nsIRDFDataSource::Assert() and Unassert() if the assertion (or
|
||||
unassertion) was rejected by the datasource; i.e., the datasource was not
|
||||
willing to record the statement. */
|
||||
#define NS_RDF_ASSERTION_REJECTED NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_RDF, 3)
|
||||
|
||||
|
||||
|
||||
/* ProgID prefixes for RDF DLL registration. */
|
||||
#define NS_RDF_PROGID "component://netscape/rdf"
|
||||
#define NS_RDF_DATASOURCE_PROGID NS_RDF_PROGID "/datasource"
|
||||
#define NS_RDF_DATASOURCE_PROGID_PREFIX NS_RDF_DATASOURCE_PROGID "?name="
|
||||
#define NS_RDF_RESOURCE_FACTORY_PROGID "component://netscape/rdf/resource-factory"
|
||||
#define NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX NS_RDF_RESOURCE_FACTORY_PROGID "?name="
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
#ifdef _IMPL_NS_RDF
|
||||
#ifdef XP_PC
|
||||
#define NS_RDF _declspec(dllexport)
|
||||
#else /* !XP_PC */
|
||||
#define NS_RDF
|
||||
#endif /* !XP_PC */
|
||||
#else /* !_IMPL_NS_RDF */
|
||||
#ifdef XP_PC
|
||||
#define NS_RDF _declspec(dllimport)
|
||||
#else /* !XP_PC */
|
||||
#define NS_RDF
|
||||
#endif /* !XP_PC */
|
||||
#endif /* !_IMPL_NS_RDF */
|
||||
|
||||
#endif /* rdf_h___ */
|
||||
60
mozilla/rdf/base/src/Makefile.in
Normal file
60
mozilla/rdf/base/src/Makefile.in
Normal file
@@ -0,0 +1,60 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = rdfbase_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsCompositeDataSource.cpp \
|
||||
nsContainerEnumerator.cpp \
|
||||
nsDefaultResourceFactory.cpp \
|
||||
nsInMemoryDataSource.cpp \
|
||||
nsRDFContentSink.cpp \
|
||||
nsRDFContainer.cpp \
|
||||
nsRDFContainerUtils.cpp \
|
||||
nsRDFParserUtils.cpp \
|
||||
nsRDFService.cpp \
|
||||
nsRDFXMLDataSource.cpp \
|
||||
rdfutil.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdfbase
|
||||
|
||||
REQUIRES = netlib rdf rdfutil raptor xpcom
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
53
mozilla/rdf/base/src/makefile.win
Normal file
53
mozilla/rdf/base/src/makefile.win
Normal file
@@ -0,0 +1,53 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
LCFLAGS=
|
||||
|
||||
MODULE=rdf
|
||||
LIBRARY_NAME=rdfbase_s
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsCompositeDataSource.obj \
|
||||
.\$(OBJDIR)\nsContainerEnumerator.obj \
|
||||
.\$(OBJDIR)\nsDefaultResourceFactory.obj \
|
||||
.\$(OBJDIR)\nsInMemoryDataSource.obj \
|
||||
.\$(OBJDIR)\nsRDFContentSink.obj \
|
||||
.\$(OBJDIR)\nsRDFContainer.obj \
|
||||
.\$(OBJDIR)\nsRDFContainerUtils.obj \
|
||||
.\$(OBJDIR)\nsRDFParserUtils.obj \
|
||||
.\$(OBJDIR)\nsRDFService.obj \
|
||||
.\$(OBJDIR)\nsRDFXMLDataSource.obj \
|
||||
.\$(OBJDIR)\rdfutil.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\rdfutil \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\js \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
1165
mozilla/rdf/base/src/nsCompositeDataSource.cpp
Normal file
1165
mozilla/rdf/base/src/nsCompositeDataSource.cpp
Normal file
File diff suppressed because it is too large
Load Diff
256
mozilla/rdf/base/src/nsContainerEnumerator.cpp
Normal file
256
mozilla/rdf/base/src/nsContainerEnumerator.cpp
Normal file
@@ -0,0 +1,256 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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 "nsIRDFDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "prlog.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ContainerEnumeratorImpl : public nsISimpleEnumerator {
|
||||
private:
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
static nsIRDFResource* kRDF_nextVal;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> mDataSource;
|
||||
nsCOMPtr<nsIRDFResource> mContainer;
|
||||
nsCOMPtr<nsIRDFResource> mOrdinalProperty;
|
||||
|
||||
nsISimpleEnumerator* mCurrent;
|
||||
nsIRDFNode* mResult;
|
||||
PRInt32 mNextIndex;
|
||||
|
||||
public:
|
||||
ContainerEnumeratorImpl(nsIRDFDataSource* ds, nsIRDFResource* container);
|
||||
virtual ~ContainerEnumeratorImpl(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD HasMoreElements(PRBool* aResult);
|
||||
NS_IMETHOD GetNext(nsISupports** aResult);
|
||||
};
|
||||
|
||||
nsrefcnt ContainerEnumeratorImpl::gRefCnt;
|
||||
nsIRDFResource* ContainerEnumeratorImpl::kRDF_nextVal;
|
||||
|
||||
ContainerEnumeratorImpl::ContainerEnumeratorImpl(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aContainer)
|
||||
: mCurrent(nsnull),
|
||||
mResult(nsnull),
|
||||
mNextIndex(1)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mDataSource = dont_QueryInterface(aDataSource);
|
||||
mContainer = dont_QueryInterface(aContainer);
|
||||
|
||||
if (gRefCnt++ == 0) {
|
||||
nsresult rv;
|
||||
nsIRDFService* service;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &service);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to acquire resource manager");
|
||||
if (! service)
|
||||
return;
|
||||
|
||||
rv = service->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ContainerEnumeratorImpl::~ContainerEnumeratorImpl(void)
|
||||
{
|
||||
NS_IF_RELEASE(mResult);
|
||||
NS_IF_RELEASE(mCurrent);
|
||||
|
||||
if (--gRefCnt == 0) {
|
||||
NS_IF_RELEASE(kRDF_nextVal);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(ContainerEnumeratorImpl, nsISimpleEnumerator::GetIID());
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerEnumeratorImpl::HasMoreElements(PRBool* aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "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 = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Otherwise, we need to grovel
|
||||
|
||||
// Figure out the upper bound so we'll know when we're done.
|
||||
nsCOMPtr<nsIRDFNode> nextValNode;
|
||||
rv = mDataSource->GetTarget(mContainer, kRDF_nextVal, PR_TRUE, getter_AddRefs(nextValNode));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (rv != NS_OK)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> nextVal = do_QueryInterface(nextValNode);
|
||||
if (! nextVal)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsXPIDLString nextValStr;
|
||||
rv = nextVal->GetValue(getter_Copies(nextValStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 err;
|
||||
PRInt32 count = nsAutoString(nextValStr).ToInteger(&err);
|
||||
if (NS_FAILED(err))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// Now iterate through each index.
|
||||
while (mNextIndex < count) {
|
||||
if (! mCurrent) {
|
||||
NS_WITH_SERVICE(nsIRDFContainerUtils, rdfc, kRDFContainerUtilsCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = rdfc->IndexToOrdinalResource(mNextIndex, getter_AddRefs(mOrdinalProperty));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mDataSource->GetTargets(mContainer, mOrdinalProperty, PR_TRUE, &mCurrent);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
++mNextIndex;
|
||||
}
|
||||
|
||||
do {
|
||||
PRBool hasMore;
|
||||
rv = mCurrent->HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Is the current enumerator depleted?
|
||||
if (! hasMore) {
|
||||
NS_RELEASE(mCurrent);
|
||||
break;
|
||||
}
|
||||
|
||||
// "Peek" ahead and pull out the next target.
|
||||
nsCOMPtr<nsISupports> result;
|
||||
rv = mCurrent->GetNext(getter_AddRefs(result));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = result->QueryInterface(nsIRDFNode::GetIID(), (void**) &mResult);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
} while (1);
|
||||
}
|
||||
|
||||
// If we get here, we ran out of elements. The cursor is empty.
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerEnumeratorImpl::GetNext(nsISupports** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRBool hasMore;
|
||||
rv = HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (! hasMore)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// Don't AddRef: we "transfer" ownership to the caller
|
||||
*aResult = mResult;
|
||||
mResult = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewContainerEnumerator(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aContainer,
|
||||
nsISimpleEnumerator** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aDataSource != nsnull, "null ptr");
|
||||
if (! aDataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aContainer != nsnull, "null ptr");
|
||||
if (! aContainer)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aResult != nsnull, "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);
|
||||
*aResult = result;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
43
mozilla/rdf/base/src/nsDefaultResourceFactory.cpp
Normal file
43
mozilla/rdf/base/src/nsDefaultResourceFactory.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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 != nsnull, "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;
|
||||
}
|
||||
1319
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
Normal file
1319
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
Normal file
File diff suppressed because it is too large
Load Diff
40
mozilla/rdf/base/src/nsRDFBaseDataSources.h
Normal file
40
mozilla/rdf/base/src/nsRDFBaseDataSources.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This 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(nsIRDFDataSource** result);
|
||||
|
||||
#endif // nsBaseDataSources_h__
|
||||
|
||||
|
||||
556
mozilla/rdf/base/src/nsRDFContainer.cpp
Normal file
556
mozilla/rdf/base/src/nsRDFContainer.cpp
Normal file
@@ -0,0 +1,556 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Implementation for the RDF container.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "rdf.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
|
||||
|
||||
class RDFContainerImpl : public nsIRDFContainer
|
||||
{
|
||||
public:
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFContainer interface
|
||||
NS_IMETHOD Init(nsIRDFDataSource *aDataSource, nsIRDFResource *aContainer);
|
||||
NS_IMETHOD GetCount(PRInt32 *_retval);
|
||||
NS_IMETHOD GetElements(nsISimpleEnumerator **_retval);
|
||||
NS_IMETHOD AppendElement(nsIRDFNode *aElement);
|
||||
NS_IMETHOD RemoveElement(nsIRDFNode *aElement, PRBool aRenumber);
|
||||
NS_IMETHOD InsertElementAt(nsIRDFNode *aElement, PRInt32 aIndex, PRBool aRenumber);
|
||||
NS_IMETHOD IndexOf(nsIRDFNode *aElement, PRInt32 *_retval);
|
||||
|
||||
private:
|
||||
friend nsresult NS_NewRDFContainer(nsIRDFContainer** aResult);
|
||||
|
||||
RDFContainerImpl();
|
||||
virtual ~RDFContainerImpl();
|
||||
|
||||
nsresult Renumber(PRInt32 aStartIndex);
|
||||
nsresult SetNextValue(PRInt32 aIndex);
|
||||
nsresult GetNextValue(nsIRDFResource** aResult);
|
||||
|
||||
nsIRDFDataSource* mDataSource;
|
||||
nsIRDFResource* mContainer;
|
||||
|
||||
// pseudo constants
|
||||
static PRInt32 gRefCnt;
|
||||
static nsIRDFService* gRDFService;
|
||||
static nsIRDFContainerUtils* gRDFContainerUtils;
|
||||
static nsIRDFResource* kRDF_nextVal;
|
||||
};
|
||||
|
||||
|
||||
PRInt32 RDFContainerImpl::gRefCnt = 0;
|
||||
nsIRDFService* RDFContainerImpl::gRDFService;
|
||||
nsIRDFContainerUtils* RDFContainerImpl::gRDFContainerUtils;
|
||||
nsIRDFResource* RDFContainerImpl::kRDF_nextVal;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ISUPPORTS(RDFContainerImpl, nsIRDFContainer::GetIID());
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFContainer interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerImpl::Init(nsIRDFDataSource *aDataSource, nsIRDFResource *aContainer)
|
||||
{
|
||||
NS_PRECONDITION(aDataSource != nsnull, "null ptr");
|
||||
if (! aDataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aContainer != nsnull, "null ptr");
|
||||
if (! aContainer)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
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(PRInt32 *aCount)
|
||||
{
|
||||
NS_PRECONDITION(aCount != nsnull, "null ptr");
|
||||
if (! aCount)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
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, PR_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(nsIRDFLiteral::GetIID(), getter_AddRefs(nextValLiteral));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLString s;
|
||||
rv = nextValLiteral->GetValue( getter_Copies(s) );
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString nextValStr = (const PRUnichar*) s;
|
||||
|
||||
PRInt32 err;
|
||||
*aCount = nextValStr.ToInteger(&err);
|
||||
if (NS_FAILED(err))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerImpl::GetElements(nsISimpleEnumerator **_retval)
|
||||
{
|
||||
return NS_NewContainerEnumerator(mDataSource, mContainer, _retval);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerImpl::AppendElement(nsIRDFNode *aElement)
|
||||
{
|
||||
NS_PRECONDITION(aElement != nsnull, "null ptr");
|
||||
if (! aElement)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
PRBool isContainer;
|
||||
rv = gRDFContainerUtils->IsContainer(mDataSource, mContainer, &isContainer);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_PRECONDITION(isContainer, "not a container");
|
||||
if (! isContainer)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> nextVal;
|
||||
rv = GetNextValue(getter_AddRefs(nextVal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mDataSource->Assert(mContainer, nextVal, aElement, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerImpl::RemoveElement(nsIRDFNode *aElement, PRBool aRenumber)
|
||||
{
|
||||
NS_PRECONDITION(aElement != nsnull, "null ptr");
|
||||
if (! aElement)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 index;
|
||||
rv = IndexOf(aElement, &index);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (index < 0) {
|
||||
NS_WARNING("attempt to remove non-existant element");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Remove the element.
|
||||
nsCOMPtr<nsIRDFResource> ordinal;
|
||||
rv = gRDFContainerUtils->IndexToOrdinalResource(index, 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(index);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerImpl::InsertElementAt(nsIRDFNode *aElement, PRInt32 aIndex, PRBool aRenumber)
|
||||
{
|
||||
NS_PRECONDITION(aElement != nsnull, "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;
|
||||
|
||||
PRInt32 count;
|
||||
rv = GetCount(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(aIndex <= count, "illegal value");
|
||||
if (aIndex > count)
|
||||
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);
|
||||
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, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerImpl::IndexOf(nsIRDFNode *aElement, PRInt32 *aIndex)
|
||||
{
|
||||
NS_PRECONDITION(aElement != nsnull, "null ptr");
|
||||
if (! aElement)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aIndex != nsnull, "null ptr");
|
||||
if (! aIndex)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 count;
|
||||
rv = GetCount(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
for (PRInt32 index = 0; index < count; ++index) {
|
||||
nsCOMPtr<nsIRDFResource> ordinal;
|
||||
rv = gRDFContainerUtils->IndexToOrdinalResource(index, getter_AddRefs(ordinal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get all of the elements in the container with the specified
|
||||
// ordinal. This is an ultra-paranoid way to do it, but -- due
|
||||
// to aggregation, we may end up with a container that has >1
|
||||
// element for the same ordinal.
|
||||
nsCOMPtr<nsISimpleEnumerator> targets;
|
||||
rv = mDataSource->GetTargets(mContainer, ordinal, PR_TRUE, getter_AddRefs(targets));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (1) {
|
||||
PRBool hasMore;
|
||||
rv = targets->HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (! hasMore)
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsISupports> isupports;
|
||||
rv = targets->GetNext(getter_AddRefs(isupports));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to read cursor");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> element = do_QueryInterface(isupports);
|
||||
|
||||
if (element.get() != aElement)
|
||||
continue;
|
||||
|
||||
// Okay, we've found it!
|
||||
*aIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_WARNING("element not found");
|
||||
*aIndex = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RDFContainerImpl::RDFContainerImpl()
|
||||
: mDataSource(nsnull), mContainer(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
if (gRefCnt++ == 0) {
|
||||
nsresult rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &gRDFService);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gRDFService->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal);
|
||||
}
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFContainerUtilsCID,
|
||||
nsIRDFContainerUtils::GetIID(),
|
||||
(nsISupports**) &gRDFContainerUtils);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF container utils service");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RDFContainerImpl::~RDFContainerImpl()
|
||||
{
|
||||
NS_IF_RELEASE(mContainer);
|
||||
NS_IF_RELEASE(mDataSource);
|
||||
|
||||
if (--gRefCnt == 0) {
|
||||
nsServiceManager::ReleaseService(kRDFContainerUtilsCID, gRDFContainerUtils);
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewRDFContainer(nsIRDFContainer** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFContainerImpl* result =
|
||||
new RDFContainerImpl();
|
||||
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
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(PRInt32 aStartIndex)
|
||||
{
|
||||
// Renumber the elements in the container
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 count;
|
||||
rv = GetCount(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 oldIndex = aStartIndex;
|
||||
PRInt32 newIndex = aStartIndex;
|
||||
while (oldIndex < count) {
|
||||
nsCOMPtr<nsIRDFResource> oldOrdinal;
|
||||
rv = gRDFContainerUtils->IndexToOrdinalResource(oldIndex, getter_AddRefs(oldOrdinal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Because of aggregation, we need to be paranoid about
|
||||
// the possibility that >1 element may be present per
|
||||
// ordinal.
|
||||
nsCOMPtr<nsISimpleEnumerator> targets;
|
||||
rv = mDataSource->GetTargets(mContainer, oldOrdinal, PR_TRUE, getter_AddRefs(targets));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (1) {
|
||||
PRBool hasMore;
|
||||
rv = targets->HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (! hasMore)
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsISupports> isupports;
|
||||
rv = targets->GetNext(getter_AddRefs(isupports));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> element( do_QueryInterface(isupports) );
|
||||
NS_ASSERTION(element != nsnull, "something funky in the enumerator");
|
||||
if (! element)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = mDataSource->Unassert(mContainer, oldOrdinal, element);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> newOrdinal;
|
||||
rv = gRDFContainerUtils->IndexToOrdinalResource(++newIndex, getter_AddRefs(newOrdinal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mDataSource->Assert(mContainer, newOrdinal, element, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the container's nextVal to reflect the renumbering
|
||||
rv = SetNextValue(++newIndex);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
RDFContainerImpl::SetNextValue(PRInt32 aIndex)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Remove the current value of nextVal, if there is one.
|
||||
nsCOMPtr<nsIRDFNode> nextValNode;
|
||||
if (NS_SUCCEEDED(rv = mDataSource->GetTarget(mContainer,
|
||||
kRDF_nextVal,
|
||||
PR_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.Append(aIndex, 10);
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> nextVal;
|
||||
if (NS_FAILED(rv = gRDFService->GetLiteral(s.GetUnicode(), getter_AddRefs(nextVal)))) {
|
||||
NS_ERROR("unable to get nextVal literal");
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mDataSource->Assert(mContainer, kRDF_nextVal, nextVal, PR_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)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
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, PR_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(nsIRDFLiteral::GetIID(), getter_AddRefs(nextValLiteral));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLString s;
|
||||
rv = nextValLiteral->GetValue( getter_Copies(s) );
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString nextValStr = (const PRUnichar*) s;
|
||||
|
||||
PRInt32 err;
|
||||
PRInt32 nextVal = nextValStr.ToInteger(&err);
|
||||
if (NS_FAILED(err))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// Generate a URI that we can return.
|
||||
nextValStr = kRDFNameSpaceURI;
|
||||
nextValStr.Append("_");
|
||||
nextValStr.Append(nextVal, 10);
|
||||
|
||||
rv = gRDFService->GetUnicodeResource(nextValStr.GetUnicode(), 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.Append(nextVal, 10);
|
||||
|
||||
rv = gRDFService->GetLiteral(nextValStr.GetUnicode(), getter_AddRefs(nextValLiteral));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mDataSource->Assert(mContainer, kRDF_nextVal, nextValLiteral, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
362
mozilla/rdf/base/src/nsRDFContainerUtils.cpp
Normal file
362
mozilla/rdf/base/src/nsRDFContainerUtils.cpp
Normal file
@@ -0,0 +1,362 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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 "nsXPIDLString.h"
|
||||
#include "plstr.h"
|
||||
#include "prprf.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
|
||||
|
||||
class RDFContainerUtilsImpl : public nsIRDFContainerUtils
|
||||
{
|
||||
public:
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFContainerUtils interface
|
||||
NS_IMETHOD IsOrdinalProperty(nsIRDFResource *aProperty, PRBool *_retval);
|
||||
NS_IMETHOD IndexToOrdinalResource(PRInt32 aIndex, nsIRDFResource **_retval);
|
||||
NS_IMETHOD OrdinalResourceToIndex(nsIRDFResource *aOrdinal, PRInt32 *_retval);
|
||||
NS_IMETHOD IsContainer(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval);
|
||||
NS_IMETHOD IsBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval);
|
||||
NS_IMETHOD IsSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval);
|
||||
NS_IMETHOD IsAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval);
|
||||
NS_IMETHOD MakeBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval);
|
||||
NS_IMETHOD MakeSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval);
|
||||
NS_IMETHOD MakeAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, nsIRDFContainer **_retval);
|
||||
|
||||
private:
|
||||
friend nsresult NS_NewRDFContainerUtils(nsIRDFContainerUtils** aResult);
|
||||
|
||||
RDFContainerUtilsImpl();
|
||||
virtual ~RDFContainerUtilsImpl();
|
||||
|
||||
nsresult MakeContainer(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aResource,
|
||||
nsIRDFResource* aType,
|
||||
nsIRDFContainer** aResult);
|
||||
|
||||
// pseudo constants
|
||||
static PRInt32 gRefCnt;
|
||||
static nsIRDFService* gRDFService;
|
||||
static nsIRDFResource* kRDF_instanceOf;
|
||||
static nsIRDFResource* kRDF_nextVal;
|
||||
static nsIRDFResource* kRDF_Bag;
|
||||
static nsIRDFResource* kRDF_Seq;
|
||||
static nsIRDFResource* kRDF_Alt;
|
||||
};
|
||||
|
||||
|
||||
PRInt32 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;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ISUPPORTS(RDFContainerUtilsImpl, nsIRDFContainerUtils::GetIID());
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFContainerUtils interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerUtilsImpl::IsOrdinalProperty(nsIRDFResource *aProperty, PRBool *_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString propertyStr;
|
||||
rv = aProperty->GetValue( getter_Copies(propertyStr) );
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (PL_strncmp(propertyStr, kRDFNameSpaceURI, sizeof(kRDFNameSpaceURI) - 1) != 0) {
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char* s = propertyStr;
|
||||
s += sizeof(kRDFNameSpaceURI) - 1;
|
||||
if (*s != '_') {
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
++s;
|
||||
while (*s) {
|
||||
if (*s < '0' || *s > '9') {
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
++s;
|
||||
}
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerUtilsImpl::IndexToOrdinalResource(PRInt32 aIndex, nsIRDFResource **aOrdinal)
|
||||
{
|
||||
NS_PRECONDITION(aIndex > 0, "illegal value");
|
||||
if (aIndex <= 0)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
// 16 digits should be plenty to hold a decimal version of a
|
||||
// PRInt32.
|
||||
char buf[sizeof(kRDFNameSpaceURI) + 16 + 1];
|
||||
|
||||
PL_strcpy(buf, kRDFNameSpaceURI);
|
||||
buf[sizeof(kRDFNameSpaceURI) - 1] = '_';
|
||||
|
||||
PR_snprintf(buf + sizeof(kRDFNameSpaceURI), 16, "%ld", aIndex);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = gRDFService->GetResource(buf, 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, PRInt32 *aIndex)
|
||||
{
|
||||
nsXPIDLCString ordinalStr;
|
||||
if (NS_FAILED(aOrdinal->GetValue( getter_Copies(ordinalStr) )))
|
||||
return PR_FALSE;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
PRInt32 index = 0;
|
||||
|
||||
++s;
|
||||
while (*s) {
|
||||
if (*s < '0' || *s > '9') {
|
||||
NS_ERROR("not an ordinal");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
index *= 10;
|
||||
index += (*s - '0');
|
||||
|
||||
++s;
|
||||
}
|
||||
|
||||
*aIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerUtilsImpl::IsContainer(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval)
|
||||
{
|
||||
NS_PRECONDITION(_retval != nsnull, "null ptr");
|
||||
if (! _retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (rdf_IsA(aDataSource, aResource, kRDF_Bag) ||
|
||||
rdf_IsA(aDataSource, aResource, kRDF_Seq) ||
|
||||
rdf_IsA(aDataSource, aResource, kRDF_Alt)) {
|
||||
*_retval = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
*_retval = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerUtilsImpl::IsBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval)
|
||||
{
|
||||
NS_PRECONDITION(_retval != nsnull, "null ptr");
|
||||
if (! _retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*_retval = rdf_IsA(aDataSource, aResource, kRDF_Bag);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerUtilsImpl::IsSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval)
|
||||
{
|
||||
NS_PRECONDITION(_retval != nsnull, "null ptr");
|
||||
if (! _retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*_retval = rdf_IsA(aDataSource, aResource, kRDF_Seq);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContainerUtilsImpl::IsAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, PRBool *_retval)
|
||||
{
|
||||
NS_PRECONDITION(_retval != nsnull, "null ptr");
|
||||
if (! _retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*_retval = rdf_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()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
if (gRefCnt++ == 0) {
|
||||
nsresult rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &gRDFService);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_instanceOf);
|
||||
gRDFService->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal);
|
||||
gRDFService->GetResource(RDF_NAMESPACE_URI "Bag", &kRDF_Bag);
|
||||
gRDFService->GetResource(RDF_NAMESPACE_URI "Seq", &kRDF_Seq);
|
||||
gRDFService->GetResource(RDF_NAMESPACE_URI "Alt", &kRDF_Alt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RDFContainerUtilsImpl::~RDFContainerUtilsImpl()
|
||||
{
|
||||
if (--gRefCnt == 0) {
|
||||
if (gRDFService) {
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
gRDFService = nsnull;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewRDFContainerUtils(nsIRDFContainerUtils** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "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)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = aDataSource->Assert(aResource, kRDF_instanceOf, aType, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> nextVal;
|
||||
rv = gRDFService->GetLiteral(nsAutoString("1").GetUnicode(), getter_AddRefs(nextVal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = aDataSource->Assert(aResource, kRDF_nextVal, nextVal, PR_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;
|
||||
}
|
||||
|
||||
1546
mozilla/rdf/base/src/nsRDFContentSink.cpp
Normal file
1546
mozilla/rdf/base/src/nsRDFContentSink.cpp
Normal file
File diff suppressed because it is too large
Load Diff
137
mozilla/rdf/base/src/nsRDFContentSink.h
Normal file
137
mozilla/rdf/base/src/nsRDFContentSink.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsRDFContentSink_h__
|
||||
#define nsRDFContentSink_h__
|
||||
|
||||
#include "nsIRDFContentSink.h"
|
||||
|
||||
class nsIURL;
|
||||
class nsVoidArray;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFService;
|
||||
class nsINameSpaceManager;
|
||||
|
||||
typedef enum {
|
||||
eRDFContentSinkState_InProlog,
|
||||
eRDFContentSinkState_InDocumentElement,
|
||||
eRDFContentSinkState_InDescriptionElement,
|
||||
eRDFContentSinkState_InContainerElement,
|
||||
eRDFContentSinkState_InPropertyElement,
|
||||
eRDFContentSinkState_InMemberElement,
|
||||
eRDFContentSinkState_InEpilog
|
||||
} RDFContentSinkState;
|
||||
|
||||
|
||||
class RDFContentSinkImpl : public nsIRDFContentSink
|
||||
{
|
||||
public:
|
||||
RDFContentSinkImpl();
|
||||
virtual ~RDFContentSinkImpl();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void);
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
||||
NS_IMETHOD WillInterrupt(void);
|
||||
NS_IMETHOD WillResume(void);
|
||||
NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(nsresult aErrorResult);
|
||||
|
||||
// nsIXMLContentSink
|
||||
NS_IMETHOD AddXMLDecl(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddCharacterData(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddUnparsedEntity(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddNotation(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddEntityReference(const nsIParserNode& aNode);
|
||||
|
||||
// nsIRDFContentSink
|
||||
NS_IMETHOD SetDataSource(nsIRDFDataSource* ds);
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource*& ds);
|
||||
NS_IMETHOD Init(nsIURL* aURL, nsINameSpaceManager* aNameSpaceManager);
|
||||
|
||||
protected:
|
||||
// Text management
|
||||
nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,
|
||||
PRBool* aDidFlush=nsnull);
|
||||
|
||||
PRUnichar* mText;
|
||||
PRInt32 mTextLength;
|
||||
PRInt32 mTextSize;
|
||||
PRBool mConstrainSize;
|
||||
|
||||
// namespace management
|
||||
void PushNameSpacesFrom(const nsIParserNode& aNode);
|
||||
nsIAtom* CutNameSpacePrefix(nsString& aString);
|
||||
PRInt32 GetNameSpaceID(nsIAtom* aPrefix);
|
||||
void GetNameSpaceURI(PRInt32 aID, nsString& aURI);
|
||||
void PopNameSpaces();
|
||||
|
||||
nsINameSpaceManager* mNameSpaceManager;
|
||||
nsVoidArray* mNameSpaceStack;
|
||||
PRInt32 mRDFNameSpaceID;
|
||||
|
||||
void SplitQualifiedName(const nsString& aQualifiedName,
|
||||
PRInt32& rNameSpaceID,
|
||||
nsString& rProperty);
|
||||
|
||||
// RDF-specific parsing
|
||||
nsresult GetIdAboutAttribute(const nsIParserNode& aNode, nsString& rResource);
|
||||
nsresult GetResourceAttribute(const nsIParserNode& aNode, nsString& rResource);
|
||||
nsresult AddProperties(const nsIParserNode& aNode, nsIRDFResource* aSubject);
|
||||
|
||||
virtual nsresult OpenRDF(const nsIParserNode& aNode);
|
||||
virtual nsresult OpenObject(const nsIParserNode& aNode);
|
||||
virtual nsresult OpenProperty(const nsIParserNode& aNode);
|
||||
virtual nsresult OpenMember(const nsIParserNode& aNode);
|
||||
virtual nsresult OpenValue(const nsIParserNode& aNode);
|
||||
|
||||
// Miscellaneous RDF junk
|
||||
nsIRDFService* mRDFService;
|
||||
nsIRDFDataSource* mDataSource;
|
||||
RDFContentSinkState mState;
|
||||
|
||||
// content stack management
|
||||
PRInt32 PushContext(nsIRDFResource *aContext, RDFContentSinkState aState);
|
||||
nsresult PopContext(nsIRDFResource*& rContext, RDFContentSinkState& rState);
|
||||
nsIRDFResource* GetContextElement(PRInt32 ancestor = 0);
|
||||
|
||||
nsVoidArray* mContextStack;
|
||||
|
||||
nsIURL* mDocumentURL;
|
||||
PRUint32 mGenSym; // for generating anonymous resources
|
||||
};
|
||||
|
||||
|
||||
#endif // nsRDFContentSink_h__
|
||||
2291
mozilla/rdf/base/src/nsRDFInterfaces.cpp
Normal file
2291
mozilla/rdf/base/src/nsRDFInterfaces.cpp
Normal file
File diff suppressed because it is too large
Load Diff
245
mozilla/rdf/base/src/nsRDFParserUtils.cpp
Normal file
245
mozilla/rdf/base/src/nsRDFParserUtils.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Some useful parsing routines.
|
||||
|
||||
This isn't the best place for them: I wish that they'd go into some
|
||||
shared area (like mozilla/base).
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h> // XXX for atoi(), maybe this should go into nsCRT?
|
||||
#include "nsCRT.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsString.h"
|
||||
#include "nsRDFParserUtils.h"
|
||||
|
||||
// XXX This totally sucks. I wish that mozilla/base had this code.
|
||||
PRUnichar
|
||||
nsRDFParserUtils::EntityToUnicode(const char* buf)
|
||||
{
|
||||
if ((buf[0] == 'g' || buf[0] == 'G') &&
|
||||
(buf[1] == 't' || buf[1] == 'T'))
|
||||
return PRUnichar('>');
|
||||
|
||||
if ((buf[0] == 'l' || buf[0] == 'L') &&
|
||||
(buf[1] == 't' || buf[1] == 'T'))
|
||||
return PRUnichar('<');
|
||||
|
||||
if ((buf[0] == 'a' || buf[0] == 'A') &&
|
||||
(buf[1] == 'm' || buf[1] == 'M') &&
|
||||
(buf[2] == 'p' || buf[2] == 'P'))
|
||||
return PRUnichar('&');
|
||||
|
||||
NS_NOTYETIMPLEMENTED("this is a named entity that I can't handle...");
|
||||
return PRUnichar('?');
|
||||
}
|
||||
|
||||
// XXX Code copied from nsHTMLContentSink. It should be shared.
|
||||
void
|
||||
nsRDFParserUtils::StripAndConvert(nsString& aResult)
|
||||
{
|
||||
// Strip quotes if present
|
||||
PRUnichar first = aResult.First();
|
||||
if ((first == '"') || (first == '\'')) {
|
||||
if (aResult.Last() == first) {
|
||||
aResult.Cut(0, 1);
|
||||
PRInt32 pos = aResult.Length() - 1;
|
||||
if (pos >= 0) {
|
||||
aResult.Cut(pos, 1);
|
||||
}
|
||||
} else {
|
||||
// Mismatched quotes - leave them in
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce any entities
|
||||
// XXX Note: as coded today, this will only convert well formed
|
||||
// entities. This may not be compatible enough.
|
||||
// XXX there is a table in navigator that translates some numeric entities
|
||||
// should we be doing that? If so then it needs to live in two places (bad)
|
||||
// so we should add a translate numeric entity method from the parser...
|
||||
char cbuf[100];
|
||||
PRInt32 index = 0;
|
||||
while (index < aResult.Length()) {
|
||||
// If we have the start of an entity (and it's not at the end of
|
||||
// our string) then translate the entity into it's unicode value.
|
||||
if ((aResult.CharAt(index++) == '&') && (index < aResult.Length())) {
|
||||
PRInt32 start = index - 1;
|
||||
PRUnichar e = aResult.CharAt(index);
|
||||
if (e == '#') {
|
||||
// Convert a numeric character reference
|
||||
index++;
|
||||
char* cp = cbuf;
|
||||
char* limit = cp + sizeof(cbuf) - 1;
|
||||
PRBool ok = PR_FALSE;
|
||||
PRInt32 slen = aResult.Length();
|
||||
while ((index < slen) && (cp < limit)) {
|
||||
PRUnichar e = aResult.CharAt(index);
|
||||
if (e == ';') {
|
||||
index++;
|
||||
ok = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
if ((e >= '0') && (e <= '9')) {
|
||||
*cp++ = char(e);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!ok || (cp == cbuf)) {
|
||||
continue;
|
||||
}
|
||||
*cp = '\0';
|
||||
if (cp - cbuf > 5) {
|
||||
continue;
|
||||
}
|
||||
PRInt32 ch = PRInt32( ::atoi(cbuf) );
|
||||
if (ch > 65535) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove entity from string and replace it with the integer
|
||||
// value.
|
||||
aResult.Cut(start, index - start);
|
||||
aResult.Insert(PRUnichar(ch), start);
|
||||
index = start + 1;
|
||||
}
|
||||
else if (((e >= 'A') && (e <= 'Z')) ||
|
||||
((e >= 'a') && (e <= 'z'))) {
|
||||
// Convert a named entity
|
||||
index++;
|
||||
char* cp = cbuf;
|
||||
char* limit = cp + sizeof(cbuf) - 1;
|
||||
*cp++ = char(e);
|
||||
PRBool ok = PR_FALSE;
|
||||
PRInt32 slen = aResult.Length();
|
||||
while ((index < slen) && (cp < limit)) {
|
||||
PRUnichar e = aResult.CharAt(index);
|
||||
if (e == ';') {
|
||||
index++;
|
||||
ok = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
if (((e >= '0') && (e <= '9')) ||
|
||||
((e >= 'A') && (e <= 'Z')) ||
|
||||
((e >= 'a') && (e <= 'z'))) {
|
||||
*cp++ = char(e);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!ok || (cp == cbuf)) {
|
||||
continue;
|
||||
}
|
||||
*cp = '\0';
|
||||
PRInt32 ch;
|
||||
|
||||
// XXX Um, here's where we should be converting a
|
||||
// named entity. I removed this to avoid a link-time
|
||||
// dependency on core raptor.
|
||||
ch = EntityToUnicode(cbuf);
|
||||
|
||||
if (ch < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove entity from string and replace it with the integer
|
||||
// value.
|
||||
aResult.Cut(start, index - start);
|
||||
aResult.Insert(PRUnichar(ch), start);
|
||||
index = start + 1;
|
||||
}
|
||||
else if (e == '{') {
|
||||
// Convert a script entity
|
||||
// XXX write me!
|
||||
NS_NOTYETIMPLEMENTED("convert a script entity");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsRDFParserUtils::GetQuotedAttributeValue(const nsString& aSource,
|
||||
const nsString& aAttribute,
|
||||
nsString& aValue)
|
||||
{
|
||||
static const char kQuote = '\"';
|
||||
static const char kApostrophe = '\'';
|
||||
|
||||
PRInt32 offset;
|
||||
PRInt32 endOffset = -1;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
offset = aSource.Find(aAttribute);
|
||||
if (-1 != offset) {
|
||||
offset = aSource.Find('=', offset);
|
||||
|
||||
PRUnichar next = aSource.CharAt(++offset);
|
||||
if (kQuote == next) {
|
||||
endOffset = aSource.Find(kQuote, ++offset);
|
||||
}
|
||||
else if (kApostrophe == next) {
|
||||
endOffset = aSource.Find(kApostrophe, ++offset);
|
||||
}
|
||||
|
||||
if (-1 != endOffset) {
|
||||
aSource.Mid(aValue, offset, endOffset-offset);
|
||||
}
|
||||
else {
|
||||
// Mismatched quotes - return an error
|
||||
result = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aValue.Truncate();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsRDFParserUtils::IsJavaScriptLanguage(const nsString& aName)
|
||||
{
|
||||
if (aName.EqualsIgnoreCase("JavaScript") ||
|
||||
aName.EqualsIgnoreCase("LiveScript") ||
|
||||
aName.EqualsIgnoreCase("Mocha")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.1")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.2")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.3")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.4")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
56
mozilla/rdf/base/src/nsRDFParserUtils.h
Normal file
56
mozilla/rdf/base/src/nsRDFParserUtils.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Some useful parsing routines.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsRDFParserUtils_h__
|
||||
#define nsRDFParserUtils_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsError.h"
|
||||
class nsIURL;
|
||||
class nsString;
|
||||
|
||||
class nsRDFParserUtils {
|
||||
public:
|
||||
static PRUnichar
|
||||
EntityToUnicode(const char* buf);
|
||||
|
||||
static void
|
||||
StripAndConvert(nsString& aResult);
|
||||
|
||||
static nsresult
|
||||
GetQuotedAttributeValue(const nsString& aSource,
|
||||
const nsString& aAttribute,
|
||||
nsString& aValue);
|
||||
|
||||
|
||||
static PRBool
|
||||
IsJavaScriptLanguage(const nsString& aName);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // nsRDFPasrserUtils_h__
|
||||
|
||||
951
mozilla/rdf/base/src/nsRDFService.cpp
Normal file
951
mozilla/rdf/base/src/nsRDFService.cpp
Normal file
@@ -0,0 +1,951 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file provides the implementation for the RDF service manager.
|
||||
|
||||
TO DO
|
||||
-----
|
||||
|
||||
1) Implement the CreateDataBase() methods.
|
||||
|
||||
2) Cache date and int literals.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFResourceFactory.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFXMLDataSource.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plhash.h"
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
#include "rdf.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFDateIID, NS_IRDFDATE_IID);
|
||||
static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFNodeIID, NS_IRDFNODE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ServiceImpl
|
||||
//
|
||||
// This is the RDF service.
|
||||
//
|
||||
class ServiceImpl : public nsIRDFService
|
||||
{
|
||||
protected:
|
||||
PLHashTable* mNamedDataSources;
|
||||
PLHashTable* mResources;
|
||||
PLHashTable* mLiterals;
|
||||
|
||||
ServiceImpl(void);
|
||||
virtual ~ServiceImpl(void);
|
||||
|
||||
public:
|
||||
|
||||
static nsresult GetRDFService(nsIRDFService** result);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFService
|
||||
NS_IMETHOD GetResource(const char* uri, nsIRDFResource** resource);
|
||||
NS_IMETHOD GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource);
|
||||
NS_IMETHOD GetLiteral(const PRUnichar* value, nsIRDFLiteral** literal);
|
||||
NS_IMETHOD GetDateLiteral(PRTime value, nsIRDFDate** date) ;
|
||||
NS_IMETHOD GetIntLiteral(PRInt32 value, nsIRDFInt** intLiteral);
|
||||
NS_IMETHOD RegisterResource(nsIRDFResource* aResource, PRBool replace = PR_FALSE);
|
||||
NS_IMETHOD UnregisterResource(nsIRDFResource* aResource);
|
||||
NS_IMETHOD RegisterDataSource(nsIRDFDataSource* dataSource, PRBool replace = PR_FALSE);
|
||||
NS_IMETHOD UnregisterDataSource(nsIRDFDataSource* dataSource);
|
||||
NS_IMETHOD GetDataSource(const char* uri, nsIRDFDataSource** dataSource);
|
||||
|
||||
// Implementation methods
|
||||
nsresult RegisterLiteral(nsIRDFLiteral* aLiteral, PRBool aReplace = PR_FALSE);
|
||||
nsresult UnregisterLiteral(nsIRDFLiteral* aLiteral);
|
||||
};
|
||||
|
||||
static ServiceImpl* gRDFService; // The one-and-only RDF service
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// LiteralImpl
|
||||
//
|
||||
// Currently, all literals are implemented exactly the same way;
|
||||
// i.e., there is are no resource factories to allow you to generate
|
||||
// customer resources. I doubt that makes sense, anyway.
|
||||
//
|
||||
class LiteralImpl : public nsIRDFLiteral {
|
||||
public:
|
||||
LiteralImpl(const PRUnichar* s);
|
||||
virtual ~LiteralImpl(void);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFNode
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result);
|
||||
|
||||
// nsIRDFLiteral
|
||||
NS_IMETHOD GetValue(PRUnichar* *value);
|
||||
NS_IMETHOD EqualsLiteral(nsIRDFLiteral* literal, PRBool* result);
|
||||
|
||||
private:
|
||||
nsAutoString mValue;
|
||||
};
|
||||
|
||||
|
||||
LiteralImpl::LiteralImpl(const PRUnichar* s)
|
||||
: mValue(s)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gRDFService->RegisterLiteral(this);
|
||||
}
|
||||
|
||||
LiteralImpl::~LiteralImpl(void)
|
||||
{
|
||||
gRDFService->UnregisterLiteral(this);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(LiteralImpl);
|
||||
NS_IMPL_RELEASE(LiteralImpl);
|
||||
|
||||
nsresult
|
||||
LiteralImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(kIRDFLiteralIID) ||
|
||||
iid.Equals(kIRDFNodeIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFLiteral*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LiteralImpl::EqualsNode(nsIRDFNode* node, PRBool* result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIRDFLiteral* literal;
|
||||
if (NS_SUCCEEDED(node->QueryInterface(kIRDFLiteralIID, (void**) &literal))) {
|
||||
rv = EqualsLiteral(literal, result);
|
||||
NS_RELEASE(literal);
|
||||
}
|
||||
else {
|
||||
*result = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LiteralImpl::GetValue(PRUnichar* *value)
|
||||
{
|
||||
NS_ASSERTION(value, "null ptr");
|
||||
if (! value)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*value = nsXPIDLString::Copy(mValue.GetUnicode());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
LiteralImpl::EqualsLiteral(nsIRDFLiteral* literal, PRBool* result)
|
||||
{
|
||||
NS_ASSERTION(literal && result, "null ptr");
|
||||
if (!literal || !result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
nsXPIDLString p;
|
||||
if (NS_FAILED(rv = literal->GetValue(getter_Copies(p))))
|
||||
return rv;
|
||||
|
||||
nsAutoString s((const PRUnichar*) p);
|
||||
|
||||
*result = s.Equals(mValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// DateImpl
|
||||
//
|
||||
|
||||
class DateImpl : public nsIRDFDate {
|
||||
public:
|
||||
DateImpl(const PRTime s);
|
||||
virtual ~DateImpl(void);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFNode
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result);
|
||||
|
||||
// nsIRDFDate
|
||||
NS_IMETHOD GetValue(PRTime *value);
|
||||
NS_IMETHOD EqualsDate(nsIRDFDate* date, PRBool* result);
|
||||
|
||||
private:
|
||||
PRTime mValue;
|
||||
};
|
||||
|
||||
|
||||
DateImpl::DateImpl(const PRTime s)
|
||||
: mValue(s)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
DateImpl::~DateImpl(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(DateImpl);
|
||||
NS_IMPL_RELEASE(DateImpl);
|
||||
|
||||
nsresult
|
||||
DateImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(kIRDFDateIID) ||
|
||||
iid.Equals(kIRDFNodeIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFDate*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DateImpl::EqualsNode(nsIRDFNode* node, PRBool* result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIRDFDate* date;
|
||||
if (NS_SUCCEEDED(node->QueryInterface(kIRDFDateIID, (void**) &date))) {
|
||||
rv = EqualsDate(date, result);
|
||||
NS_RELEASE(date);
|
||||
}
|
||||
else {
|
||||
*result = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DateImpl::GetValue(PRTime *value)
|
||||
{
|
||||
NS_ASSERTION(value, "null ptr");
|
||||
if (! value)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*value = mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
DateImpl::EqualsDate(nsIRDFDate* date, PRBool* result)
|
||||
{
|
||||
NS_ASSERTION(date && result, "null ptr");
|
||||
if (!date || !result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
PRTime p;
|
||||
if (NS_FAILED(rv = date->GetValue(&p)))
|
||||
return rv;
|
||||
|
||||
*result = LL_EQ(p, mValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// IntImpl
|
||||
//
|
||||
|
||||
class IntImpl : public nsIRDFInt {
|
||||
public:
|
||||
IntImpl(PRInt32 s);
|
||||
virtual ~IntImpl(void);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFNode
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result);
|
||||
|
||||
// nsIRDFInt
|
||||
NS_IMETHOD GetValue(PRInt32 *value);
|
||||
NS_IMETHOD EqualsInt(nsIRDFInt* value, PRBool* result);
|
||||
|
||||
private:
|
||||
PRInt32 mValue;
|
||||
};
|
||||
|
||||
|
||||
IntImpl::IntImpl(PRInt32 s)
|
||||
: mValue(s)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
IntImpl::~IntImpl(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(IntImpl);
|
||||
NS_IMPL_RELEASE(IntImpl);
|
||||
|
||||
nsresult
|
||||
IntImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(kIRDFIntIID) ||
|
||||
iid.Equals(kIRDFNodeIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFInt*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IntImpl::EqualsNode(nsIRDFNode* node, PRBool* result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIRDFInt* intValue;
|
||||
if (NS_SUCCEEDED(node->QueryInterface(kIRDFIntIID, (void**) &intValue))) {
|
||||
rv = EqualsInt(intValue, result);
|
||||
NS_RELEASE(intValue);
|
||||
}
|
||||
else {
|
||||
*result = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IntImpl::GetValue(PRInt32 *value)
|
||||
{
|
||||
NS_ASSERTION(value, "null ptr");
|
||||
if (! value)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*value = mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
IntImpl::EqualsInt(nsIRDFInt* intValue, PRBool* result)
|
||||
{
|
||||
NS_ASSERTION(intValue && result, "null ptr");
|
||||
if (!intValue || !result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 p;
|
||||
if (NS_FAILED(rv = intValue->GetValue(&p)))
|
||||
return rv;
|
||||
|
||||
*result = (p == mValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ServiceImpl
|
||||
|
||||
static PLHashNumber
|
||||
rdf_HashWideString(const void* key)
|
||||
{
|
||||
PLHashNumber result = 0;
|
||||
for (PRUnichar* s = (PRUnichar*) key; *s != nsnull; ++s)
|
||||
result = (result >> 28) ^ (result << 4) ^ *s;
|
||||
return result;
|
||||
}
|
||||
|
||||
ServiceImpl::ServiceImpl(void)
|
||||
: mNamedDataSources(nsnull), mResources(nsnull), mLiterals(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mResources = PL_NewHashTable(1023, // nbuckets
|
||||
PL_HashString, // hash fn
|
||||
PL_CompareStrings, // key compare fn
|
||||
PL_CompareValues, // value compare fn
|
||||
nsnull, nsnull); // alloc ops & priv
|
||||
|
||||
mLiterals = PL_NewHashTable(1023,
|
||||
rdf_HashWideString,
|
||||
PL_CompareStrings,
|
||||
PL_CompareValues,
|
||||
nsnull, nsnull);
|
||||
|
||||
mNamedDataSources = PL_NewHashTable(23,
|
||||
PL_HashString,
|
||||
PL_CompareStrings,
|
||||
PL_CompareValues,
|
||||
nsnull, nsnull);
|
||||
}
|
||||
|
||||
|
||||
ServiceImpl::~ServiceImpl(void)
|
||||
{
|
||||
if (mNamedDataSources) {
|
||||
PL_HashTableDestroy(mNamedDataSources);
|
||||
mNamedDataSources = nsnull;
|
||||
}
|
||||
if (mResources) {
|
||||
PL_HashTableDestroy(mResources);
|
||||
mResources = nsnull;
|
||||
}
|
||||
if (mLiterals) {
|
||||
PL_HashTableDestroy(mLiterals);
|
||||
mLiterals = nsnull;
|
||||
}
|
||||
gRDFService = nsnull;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
ServiceImpl::GetRDFService(nsIRDFService** mgr)
|
||||
{
|
||||
if (! gRDFService) {
|
||||
ServiceImpl* serv = new ServiceImpl();
|
||||
if (! serv)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
gRDFService = serv;
|
||||
}
|
||||
|
||||
NS_ADDREF(gRDFService);
|
||||
*mgr = gRDFService;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
ServiceImpl::AddRef(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
ServiceImpl::Release(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(ServiceImpl, kIRDFServiceIID);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource)
|
||||
{
|
||||
// Sanity checks
|
||||
NS_PRECONDITION(aURI != nsnull, "null ptr");
|
||||
if (! aURI)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aResource != nsnull, "null ptr");
|
||||
if (! aResource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// First, check the cache to see if we've already created and
|
||||
// registered this thing.
|
||||
nsIRDFResource* result =
|
||||
NS_STATIC_CAST(nsIRDFResource*, PL_HashTableLookup(mResources, aURI));
|
||||
|
||||
if (result) {
|
||||
// Addref for the callee.
|
||||
NS_ADDREF(result);
|
||||
*aResource = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Nope. So go to the repository to create it.
|
||||
nsresult rv;
|
||||
char* p = PL_strchr(aURI, ':');
|
||||
if (!p) {
|
||||
// no colon, so try the default resource factory
|
||||
rv = nsComponentManager::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID,
|
||||
nsnull, nsIRDFResource::GetIID(),
|
||||
(void**)&result);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("unable to create resource");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// the resource is qualified, so construct a ProgID and
|
||||
// construct it from the repository.
|
||||
static const char kRDFResourceFactoryProgIDPrefix[]
|
||||
= NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX;
|
||||
|
||||
PRInt32 pos = (p) ? (p - aURI) : (-1);
|
||||
PRInt32 len = pos + sizeof(kRDFResourceFactoryProgIDPrefix) - 1;
|
||||
|
||||
// Safely convert to a C-string for the XPCOM APIs
|
||||
char buf[128];
|
||||
char* progID = buf;
|
||||
if (len >= sizeof(buf))
|
||||
progID = new char[len + 1];
|
||||
|
||||
if (progID == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PL_strcpy(progID, kRDFResourceFactoryProgIDPrefix);
|
||||
PL_strncpy(progID + sizeof(kRDFResourceFactoryProgIDPrefix) - 1, aURI, pos);
|
||||
progID[len] = '\0';
|
||||
|
||||
rv = nsComponentManager::CreateInstance(progID, nsnull,
|
||||
nsIRDFResource::GetIID(),
|
||||
(void**)&result);
|
||||
|
||||
if (progID != buf)
|
||||
delete[] progID;
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// if we failed, try the default resource factory
|
||||
rv = nsComponentManager::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID,
|
||||
nsnull, nsIRDFResource::GetIID(),
|
||||
(void**)&result);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("unable to create resource");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now initialize it with it's URI. At this point, the resource
|
||||
// implementation should register itself with the RDF service.
|
||||
rv = result->Init(aURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("unable to initialize resource");
|
||||
NS_RELEASE(result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aResource = result; // already refcounted from repository
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetUnicodeResource(const PRUnichar* aURI, nsIRDFResource** aResource)
|
||||
{
|
||||
nsAutoString uriStr(aURI);
|
||||
char buf[128];
|
||||
char* uri = buf;
|
||||
|
||||
if (uriStr.Length() >= sizeof(buf))
|
||||
uri = new char[uriStr.Length() + 1];
|
||||
|
||||
uriStr.ToCString(uri, uriStr.Length() + 1);
|
||||
|
||||
nsresult rv = GetResource(uri, aResource);
|
||||
|
||||
if (uri != buf)
|
||||
delete[] uri;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetLiteral(const PRUnichar* aValue, nsIRDFLiteral** aLiteral)
|
||||
{
|
||||
NS_PRECONDITION(aValue != nsnull, "null ptr");
|
||||
if (! aValue)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aLiteral != nsnull, "null ptr");
|
||||
if (! aLiteral)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// See if we have on already cached
|
||||
nsIRDFLiteral* literal =
|
||||
NS_STATIC_CAST(nsIRDFLiteral*, PL_HashTableLookup(mLiterals, aValue));
|
||||
|
||||
if (literal) {
|
||||
NS_ADDREF(literal);
|
||||
*aLiteral = literal;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Nope. Create a new one
|
||||
literal = new LiteralImpl(aValue);
|
||||
if (! literal)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aLiteral = literal;
|
||||
NS_ADDREF(literal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetDateLiteral(PRTime time, nsIRDFDate** literal)
|
||||
{
|
||||
// XXX how do we cache these? should they live in their own hashtable?
|
||||
DateImpl* result = new DateImpl(time);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*literal = result;
|
||||
NS_ADDREF(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetIntLiteral(PRInt32 value, nsIRDFInt** literal)
|
||||
{
|
||||
// XXX how do we cache these? should they live in their own hashtable?
|
||||
IntImpl* result = new IntImpl(value);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*literal = result;
|
||||
NS_ADDREF(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::RegisterResource(nsIRDFResource* aResource, PRBool replace)
|
||||
{
|
||||
NS_PRECONDITION(aResource != nsnull, "null ptr");
|
||||
if (! aResource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = aResource->GetValue(getter_Copies(uri));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("unable to get URI from resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ASSERTION(uri != nsnull, "resource has no URI");
|
||||
if (! uri)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PLHashEntry** hep = PL_HashTableRawLookup(mResources, (*mResources->keyHash)(uri), uri);
|
||||
|
||||
if (*hep) {
|
||||
if (!replace) {
|
||||
NS_WARNING("resource already registered, and replace not specified");
|
||||
return NS_ERROR_FAILURE; // already registered
|
||||
}
|
||||
|
||||
// N.B., we do _not_ release the original resource because we
|
||||
// only ever held a weak reference to it. We simply replace
|
||||
// it.
|
||||
|
||||
(*hep)->value = aResource;
|
||||
}
|
||||
else {
|
||||
const char* key = PL_strdup(uri);
|
||||
if (! key)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PL_HashTableAdd(mResources, key, aResource);
|
||||
|
||||
// N.B., we only hold a weak reference to the resource: that
|
||||
// way, the resource can be destroyed when the last refcount
|
||||
// goes away. The single addref that the CreateResource() call
|
||||
// made will be owned by the callee.
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::UnregisterResource(nsIRDFResource* resource)
|
||||
{
|
||||
NS_PRECONDITION(resource != nsnull, "null ptr");
|
||||
if (! resource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = resource->GetValue(getter_Copies(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PLHashEntry** hep = PL_HashTableRawLookup(mResources, (*mResources->keyHash)(uri), uri);
|
||||
NS_ASSERTION(*hep != nsnull, "resource wasn't registered");
|
||||
if (! *hep)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PL_strfree((char*) (*hep)->key);
|
||||
|
||||
// N.B. that we _don't_ release the resource: we only held a weak
|
||||
// reference to it in the hashtable.
|
||||
|
||||
PL_HashTableRawRemove(mResources, hep, *hep);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource, PRBool replace)
|
||||
{
|
||||
NS_PRECONDITION(aDataSource != nsnull, "null ptr");
|
||||
if (! aDataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = aDataSource->GetURI(getter_Copies(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PLHashEntry** hep =
|
||||
PL_HashTableRawLookup(mNamedDataSources, (*mNamedDataSources->keyHash)(uri), uri);
|
||||
|
||||
if (*hep) {
|
||||
if (! replace)
|
||||
return NS_ERROR_FAILURE; // already registered
|
||||
|
||||
// N.B., we only hold a weak reference to the datasource, so
|
||||
// just replace the old with the new and don't touch any
|
||||
// refcounts.
|
||||
(*hep)->value = aDataSource;
|
||||
}
|
||||
else {
|
||||
const char* key = PL_strdup(uri);
|
||||
if (! key)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PL_HashTableAdd(mNamedDataSources, key, aDataSource);
|
||||
|
||||
// N.B., we only hold a weak reference to the datasource, so don't
|
||||
// addref.
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::UnregisterDataSource(nsIRDFDataSource* aDataSource)
|
||||
{
|
||||
NS_PRECONDITION(aDataSource != nsnull, "null ptr");
|
||||
if (! aDataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = aDataSource->GetURI(getter_Copies(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
//NS_ASSERTION(uri != nsnull, "datasource has no URI");
|
||||
if (! uri)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PLHashEntry** hep =
|
||||
PL_HashTableRawLookup(mNamedDataSources, (*mNamedDataSources->keyHash)(uri), uri);
|
||||
|
||||
NS_ASSERTION(*hep != nsnull, "datasource was never registered");
|
||||
if (! *hep)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
PL_strfree((char*) (*hep)->key);
|
||||
|
||||
// N.B., we only held a weak reference to the datasource, so we
|
||||
// don't release here.
|
||||
PL_HashTableRawRemove(mNamedDataSources, hep, *hep);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetDataSource(const char* uri, nsIRDFDataSource** aDataSource)
|
||||
{
|
||||
// First, check the cache to see if we already have this
|
||||
// datasource loaded and initialized.
|
||||
nsIRDFDataSource* ds =
|
||||
NS_STATIC_CAST(nsIRDFDataSource*, PL_HashTableLookup(mNamedDataSources, uri));
|
||||
|
||||
if (ds) {
|
||||
NS_ADDREF(ds);
|
||||
*aDataSource = ds;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Nope. So go to the repository to try to create it.
|
||||
nsresult rv;
|
||||
nsAutoString rdfName(uri);
|
||||
static const char kRDFPrefix[] = "rdf:";
|
||||
PRInt32 pos = rdfName.Find(kRDFPrefix);
|
||||
if (pos == 0) {
|
||||
// It's a built-in data source
|
||||
nsAutoString dataSourceName;
|
||||
rdfName.Right(dataSourceName, rdfName.Length() - (pos + sizeof(kRDFPrefix) - 1));
|
||||
|
||||
nsAutoString progIDStr(NS_RDF_DATASOURCE_PROGID_PREFIX);
|
||||
progIDStr.Append(dataSourceName);
|
||||
|
||||
// Safely convert it to a C-string for the XPCOM APIs
|
||||
char buf[64];
|
||||
char* progID = buf;
|
||||
if (progIDStr.Length() >= sizeof(buf))
|
||||
progID = new char[progIDStr.Length() + 1];
|
||||
|
||||
if (progID == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
progIDStr.ToCString(progID, progIDStr.Length() + 1);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(progID, nsnull,
|
||||
nsIRDFDataSource::GetIID(),
|
||||
(void**)&ds);
|
||||
if (progID != buf)
|
||||
delete[] progID;
|
||||
}
|
||||
else {
|
||||
// Try to load this as an RDF/XML data source
|
||||
rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,
|
||||
nsnull,
|
||||
nsIRDFDataSource::GetIID(),
|
||||
(void**) &ds);
|
||||
|
||||
// XXX hack for now: make sure that the data source is
|
||||
// synchronously loaded. In the long run, we should factor out
|
||||
// the "loading" from the "creating". See nsRDFXMLDataSource::Init().
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIRDFXMLDataSource> rdfxmlDataSource(do_QueryInterface(ds));
|
||||
NS_ASSERTION(rdfxmlDataSource, "not an RDF/XML data source!");
|
||||
if (rdfxmlDataSource) {
|
||||
rv = rdfxmlDataSource->SetSynchronous(PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to make RDF/XML data source synchronous");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// XXX only a warning, because the URI may have been ill-formed.
|
||||
NS_WARNING("unable to create data source");
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = ds->Init(uri);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(ds);
|
||||
NS_ERROR("unable to initialize data source");
|
||||
return rv;
|
||||
}
|
||||
*aDataSource = ds;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
ServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral, PRBool aReplace)
|
||||
{
|
||||
NS_PRECONDITION(aLiteral != nsnull, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
nsXPIDLString value;
|
||||
rv = aLiteral->GetValue(getter_Copies(value));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get literal's value");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIRDFLiteral* prevLiteral =
|
||||
NS_STATIC_CAST(nsIRDFLiteral*, PL_HashTableLookup(mLiterals, value));
|
||||
|
||||
if (prevLiteral) {
|
||||
if (aReplace) {
|
||||
NS_RELEASE(prevLiteral);
|
||||
// XXXwaterson LEAK! free the previous key
|
||||
}
|
||||
else {
|
||||
NS_WARNING("literal already registered and replace not specified");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
const PRUnichar* key = nsXPIDLString::Copy(value);
|
||||
if (! key)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PL_HashTableAdd(mLiterals, key, aLiteral);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
ServiceImpl::UnregisterLiteral(nsIRDFLiteral* aLiteral)
|
||||
{
|
||||
NS_PRECONDITION(aLiteral != nsnull, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLString value;
|
||||
rv = aLiteral->GetValue(getter_Copies(value));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get literal's value");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PL_HashTableRemove(mLiterals, value);
|
||||
|
||||
// XXXwaterson LEAK! free the key
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFService(nsIRDFService** mgr)
|
||||
{
|
||||
return ServiceImpl::GetRDFService(mgr);
|
||||
}
|
||||
1512
mozilla/rdf/base/src/nsRDFXMLDataSource.cpp
Normal file
1512
mozilla/rdf/base/src/nsRDFXMLDataSource.cpp
Normal file
File diff suppressed because it is too large
Load Diff
186
mozilla/rdf/base/src/rdf_qsort.c
Normal file
186
mozilla/rdf/base/src/rdf_qsort.c
Normal file
@@ -0,0 +1,186 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* We need this because Solaris' version of qsort is broken and
|
||||
* causes array bounds reads.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "prtypes.h"
|
||||
|
||||
#if !defined(DEBUG) && (defined(__cplusplus) || defined(__gcc))
|
||||
# ifndef INLINE
|
||||
# define INLINE inline
|
||||
# endif
|
||||
#else
|
||||
# define INLINE
|
||||
#endif
|
||||
|
||||
typedef int cmp_t(const void *, const void *, void *);
|
||||
static INLINE char *med3(char *, char *, char *, cmp_t *, void *);
|
||||
static INLINE void swapfunc(char *, char *, int, int);
|
||||
|
||||
/*
|
||||
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
|
||||
*/
|
||||
#define swapcode(TYPE, parmi, parmj, n) { \
|
||||
long i = (n) / sizeof (TYPE); \
|
||||
register TYPE *pi = (TYPE *) (parmi); \
|
||||
register TYPE *pj = (TYPE *) (parmj); \
|
||||
do { \
|
||||
register TYPE t = *pi; \
|
||||
*pi++ = *pj; \
|
||||
*pj++ = t; \
|
||||
} while (--i > 0); \
|
||||
}
|
||||
|
||||
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
|
||||
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
|
||||
|
||||
static INLINE void
|
||||
swapfunc(a, b, n, swaptype)
|
||||
char *a, *b;
|
||||
int n, swaptype;
|
||||
{
|
||||
if(swaptype <= 1)
|
||||
swapcode(long, a, b, n)
|
||||
else
|
||||
swapcode(char, a, b, n)
|
||||
}
|
||||
|
||||
#define swap(a, b) \
|
||||
if (swaptype == 0) { \
|
||||
long t = *(long *)(a); \
|
||||
*(long *)(a) = *(long *)(b); \
|
||||
*(long *)(b) = t; \
|
||||
} else \
|
||||
swapfunc(a, b, es, swaptype)
|
||||
|
||||
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
|
||||
|
||||
static INLINE char *
|
||||
med3(a, b, c, cmp, data)
|
||||
char *a, *b, *c;
|
||||
cmp_t *cmp;
|
||||
void *data;
|
||||
{
|
||||
return cmp(a, b, data) < 0 ?
|
||||
(cmp(b, c, data) < 0 ? b : (cmp(a, c, data) < 0 ? c : a ))
|
||||
:(cmp(b, c, data) > 0 ? b : (cmp(a, c, data) < 0 ? a : c ));
|
||||
}
|
||||
|
||||
void rdf_qsort (
|
||||
void *a,
|
||||
unsigned n,
|
||||
unsigned es,
|
||||
cmp_t *cmp,
|
||||
void *data
|
||||
)
|
||||
{
|
||||
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
|
||||
int d, r, swaptype, swap_cnt;
|
||||
|
||||
loop: SWAPINIT(a, es);
|
||||
swap_cnt = 0;
|
||||
if (n < 7) {
|
||||
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
|
||||
for (pl = pm; pl > (char *)a && cmp(pl - es, pl, data) > 0;
|
||||
pl -= es)
|
||||
swap(pl, pl - es);
|
||||
return;
|
||||
}
|
||||
pm = (char *)a + (n / 2) * es;
|
||||
if (n > 7) {
|
||||
pl = a;
|
||||
pn = (char *)a + (n - 1) * es;
|
||||
if (n > 40) {
|
||||
d = (n / 8) * es;
|
||||
pl = med3(pl, pl + d, pl + 2 * d, cmp, data);
|
||||
pm = med3(pm - d, pm, pm + d, cmp, data);
|
||||
pn = med3(pn - 2 * d, pn - d, pn, cmp, data);
|
||||
}
|
||||
pm = med3(pl, pm, pn, cmp, data);
|
||||
}
|
||||
swap(a, pm);
|
||||
pa = pb = (char *)a + es;
|
||||
|
||||
pc = pd = (char *)a + (n - 1) * es;
|
||||
for (;;) {
|
||||
while (pb <= pc && (r = cmp(pb, a, data)) <= 0) {
|
||||
if (r == 0) {
|
||||
swap_cnt = 1;
|
||||
swap(pa, pb);
|
||||
pa += es;
|
||||
}
|
||||
pb += es;
|
||||
}
|
||||
while (pb <= pc && (r = cmp(pc, a, data)) >= 0) {
|
||||
if (r == 0) {
|
||||
swap_cnt = 1;
|
||||
swap(pc, pd);
|
||||
pd -= es;
|
||||
}
|
||||
pc -= es;
|
||||
}
|
||||
if (pb > pc)
|
||||
break;
|
||||
swap(pb, pc);
|
||||
swap_cnt = 1;
|
||||
pb += es;
|
||||
pc -= es;
|
||||
}
|
||||
if (swap_cnt == 0) { /* Switch to insertion sort */
|
||||
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
|
||||
for (pl = pm; pl > (char *)a && cmp(pl - es, pl, data) > 0;
|
||||
pl -= es)
|
||||
swap(pl, pl - es);
|
||||
return;
|
||||
}
|
||||
|
||||
pn = (char *)a + n * es;
|
||||
r = PR_MIN(pa - (char *)a, pb - pa);
|
||||
vecswap(a, pb - r, r);
|
||||
r = PR_MIN(pd - pc, pn - pd - es);
|
||||
vecswap(pb, pn - r, r);
|
||||
if ((r = pb - pa) > es)
|
||||
rdf_qsort(a, r / es, es, cmp, data);
|
||||
if ((r = pd - pc) > es) {
|
||||
/* Iterate rather than recurse to save stack space */
|
||||
a = pn - r;
|
||||
n = r / es;
|
||||
goto loop;
|
||||
}
|
||||
/* rdf_qsort(pn - r, r / es, es, cmp, data);*/
|
||||
}
|
||||
222
mozilla/rdf/base/src/rdfutil.cpp
Normal file
222
mozilla/rdf/base/src/rdfutil.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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 "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plstr.h"
|
||||
#include "prprf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
#include "rdf.h"
|
||||
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// XXX This'll permanently leak
|
||||
static nsIRDFService* gRDFService = nsnull;
|
||||
|
||||
static nsIRDFResource* kRDF_instanceOf = nsnull;
|
||||
static nsIRDFResource* kRDF_Bag = nsnull;
|
||||
static nsIRDFResource* kRDF_Seq = nsnull;
|
||||
static nsIRDFResource* kRDF_Alt = nsnull;
|
||||
static nsIRDFResource* kRDF_nextVal = nsnull;
|
||||
|
||||
static nsresult
|
||||
rdf_EnsureRDFService(void)
|
||||
{
|
||||
if (gRDFService)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &gRDFService);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_instanceOf);
|
||||
rv = gRDFService->GetResource(RDF_NAMESPACE_URI "Bag", &kRDF_Bag);
|
||||
rv = gRDFService->GetResource(RDF_NAMESPACE_URI "Seq", &kRDF_Seq);
|
||||
rv = gRDFService->GetResource(RDF_NAMESPACE_URI "Alt", &kRDF_Alt);
|
||||
rv = gRDFService->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PR_IMPLEMENT(PRBool)
|
||||
rdf_IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = rdf_EnsureRDFService();
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
PRBool result;
|
||||
rv = aDataSource->HasAssertion(aResource, kRDF_instanceOf, aType, PR_TRUE, &result);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
rdf_CreateAnonymousResource(const nsString& aContextURI, nsIRDFResource** aResult)
|
||||
{
|
||||
static PRUint32 gCounter = 0;
|
||||
|
||||
nsresult rv;
|
||||
rv = rdf_EnsureRDFService();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
do {
|
||||
nsAutoString s(aContextURI);
|
||||
s.Append("#$");
|
||||
s.Append(++gCounter, 10);
|
||||
|
||||
nsIRDFResource* resource;
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(s.GetUnicode(), &resource)))
|
||||
return rv;
|
||||
|
||||
// XXX an ugly but effective way to make sure that this
|
||||
// resource is really unique in the world.
|
||||
nsrefcnt refcnt = resource->AddRef();
|
||||
resource->Release();
|
||||
|
||||
if (refcnt == 2) {
|
||||
*aResult = resource;
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
rdf_IsAnonymousResource(const nsString& aContextURI, nsIRDFResource* aResource)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString s;
|
||||
if (NS_FAILED(rv = aResource->GetValue( getter_Copies(s) ))) {
|
||||
NS_ASSERTION(PR_FALSE, "unable to get resource URI");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString uri((const char*) s);
|
||||
|
||||
// Make sure that they have the same context (prefix)
|
||||
if (uri.Find(aContextURI) != 0)
|
||||
return PR_FALSE;
|
||||
|
||||
uri.Cut(0, aContextURI.Length());
|
||||
|
||||
// Anonymous resources look like the regexp "\$[0-9]+"
|
||||
if (uri.CharAt(0) != '#' || uri.CharAt(1) != '$')
|
||||
return PR_FALSE;
|
||||
|
||||
for (PRInt32 i = uri.Length() - 1; i >= 1; --i) {
|
||||
if (uri.CharAt(i) < '0' || uri.CharAt(i) > '9')
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_PossiblyMakeRelative(const nsString& aContextURI, nsString& aURI)
|
||||
{
|
||||
// This implementation is extremely simple: no ".." or anything
|
||||
// fancy like that. If the context URI is not a prefix of the URI
|
||||
// in question, we'll just bail.
|
||||
if (aURI.Find(aContextURI) != 0)
|
||||
return NS_OK;
|
||||
|
||||
// Otherwise, pare down the target URI, removing the context URI.
|
||||
aURI.Cut(0, aContextURI.Length());
|
||||
|
||||
if (aURI.First() == '#' || aURI.First() == '/')
|
||||
aURI.Cut(0, 1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_PossiblyMakeAbsolute(const nsString& aContextURI, nsString& aURI)
|
||||
{
|
||||
PRInt32 index = aURI.Find(':');
|
||||
if (index > 0 && index < 25 /* XXX */)
|
||||
return NS_OK;
|
||||
|
||||
PRUnichar last = aContextURI.Last();
|
||||
PRUnichar first = aURI.First();
|
||||
|
||||
nsAutoString result(aContextURI);
|
||||
if (last == '#' || last == '/') {
|
||||
if (first == '#') {
|
||||
result.Truncate(result.Length() - 2);
|
||||
}
|
||||
result.Append(aURI);
|
||||
}
|
||||
else if (first == '#') {
|
||||
result.Append(aURI);
|
||||
}
|
||||
else {
|
||||
result.Append('#');
|
||||
result.Append(aURI);
|
||||
}
|
||||
|
||||
aURI = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
89
mozilla/rdf/base/src/rdfutil.h
Normal file
89
mozilla/rdf/base/src/rdfutil.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
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) Create an nsIRDFContainerService and lump all the container
|
||||
utilities there.
|
||||
|
||||
2) Move the anonymous resource stuff to nsIRDFService
|
||||
|
||||
3) All that's left is rdf_PossiblyMakeRelative() and
|
||||
-Absolute(). Maybe those go on nsIRDFService, too.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef rdfutil_h__
|
||||
#define rdfutil_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
class nsISimpleEnumerator;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFNode;
|
||||
class nsIRDFResource;
|
||||
class nsString;
|
||||
|
||||
/**
|
||||
* The dreaded is-a function. Uses rdf:instanceOf to determine if aResource is aType.
|
||||
*/
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType);
|
||||
|
||||
/**
|
||||
* Construct a new, "anonymous" node; that is, a node with an internal
|
||||
* resource URI.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_CreateAnonymousResource(const nsString& aContextURI, nsIRDFResource** result);
|
||||
|
||||
/**
|
||||
* Determine if a resource is an "anonymous" resource that we've constructed
|
||||
* ourselves.
|
||||
*/
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsAnonymousResource(const nsString& aContextURI, nsIRDFResource* aResource);
|
||||
|
||||
/**
|
||||
* Try to convert the absolute URL into a relative URL.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_PossiblyMakeRelative(const nsString& aContextURI, nsString& aURI);
|
||||
|
||||
|
||||
/**
|
||||
* Try to convert the possibly-relative URL into an absolute URL.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_PossiblyMakeAbsolute(const nsString& aContextURI, nsString& aURI);
|
||||
|
||||
|
||||
PR_EXTERN(void) SHTtest ();
|
||||
|
||||
#endif // rdfutil_h__
|
||||
|
||||
|
||||
29
mozilla/rdf/brprof/Makefile.in
Normal file
29
mozilla/rdf/brprof/Makefile.in
Normal file
@@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src build
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
70
mozilla/rdf/brprof/build/Makefile.in
Normal file
70
mozilla/rdf/brprof/build/Makefile.in
Normal file
@@ -0,0 +1,70 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = brprof
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
nsBrowsingProfileFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = brprof
|
||||
|
||||
REQUIRES = xpcom
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/libbrprof_s.a \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
EXTRA_DSO_LDOPTS = -c objs/objslist
|
||||
else
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MKSHLIB_FORCE_ALL) \
|
||||
$(SHARED_LIBRARY_LIBS) \
|
||||
$(MKSHLIB_UNFORCE_ALL)
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += -L$(DIST)/bin $(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
shared_library_objs: $(SHARED_LIBRARY_LIBS)
|
||||
rm -rf objs
|
||||
mkdir objs
|
||||
(cd objs; for lib in $(SHARED_LIBRARY_LIBS); do ar xv ../$$lib; done) \
|
||||
| awk '{ print "objs/"$$3 }' > objs/objslist
|
||||
|
||||
$(LIBRARY) $(SHARED_LIBRARY): shared_library_objs Makefile
|
||||
else
|
||||
$(LIBRARY) $(SHARED_LIBRARY): $(SHARED_LIBRARY_LIBS) Makefile
|
||||
endif
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(srcdir)/directory.rdf $(DIST)/bin/res/samples
|
||||
BIN
mozilla/rdf/brprof/build/brprof.mcp
Normal file
BIN
mozilla/rdf/brprof/build/brprof.mcp
Normal file
Binary file not shown.
1
mozilla/rdf/brprof/build/brprof.prefix
Normal file
1
mozilla/rdf/brprof/build/brprof.prefix
Normal file
@@ -0,0 +1 @@
|
||||
#include "MacPrefix.h"
|
||||
2
mozilla/rdf/brprof/build/brprof.toc
Normal file
2
mozilla/rdf/brprof/build/brprof.toc
Normal file
@@ -0,0 +1,2 @@
|
||||
# target: brprof.shlb
|
||||
mozilla/rdf/brprof/src/nsBrowsingProfile.cpp
|
||||
2
mozilla/rdf/brprof/build/brprofDebug.prefix
Normal file
2
mozilla/rdf/brprof/build/brprofDebug.prefix
Normal file
@@ -0,0 +1,2 @@
|
||||
#define DEBUG 1
|
||||
#include "MacPrefix_debug.h"
|
||||
1797
mozilla/rdf/brprof/build/directory.rdf
Normal file
1797
mozilla/rdf/brprof/build/directory.rdf
Normal file
File diff suppressed because it is too large
Load Diff
56
mozilla/rdf/brprof/build/makefile.win
Normal file
56
mozilla/rdf/brprof/build/makefile.win
Normal file
@@ -0,0 +1,56 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=brprof
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=brprof
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsBrowsingProfileFactory.obj \
|
||||
$(NULL)
|
||||
|
||||
# XXX linking in raptor is a heinous crime that will go away once we
|
||||
# have a more DOM-based mechanism for constructing elements and
|
||||
# hooking in to their changes.
|
||||
|
||||
LLIBS=\
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\brprof_s.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
MISCDEP=$(LLIBS)
|
||||
|
||||
# XXX Note dependencies on implementation dirs for factory methods.
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\brprof \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
$(MAKE_INSTALL) directory.rdf $(DIST)\bin\res\samples
|
||||
|
||||
104
mozilla/rdf/brprof/build/nsBrowsingProfileFactory.cpp
Normal file
104
mozilla/rdf/brprof/build/nsBrowsingProfileFactory.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIBrowsingProfile.h"
|
||||
#include "nscore.h"
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
static NS_DEFINE_CID(kBrowsingProfileCID, NS_BROWSINGPROFILE_CID);
|
||||
|
||||
static NS_IMETHODIMP
|
||||
nsConstructBrowsingProfile(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aOuter == nsnull, "no aggregation");
|
||||
nsIBrowsingProfile* brprof;
|
||||
rv = NS_NewBrowsingProfile(&brprof);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Unable to construct browsing profile");
|
||||
return rv;
|
||||
}
|
||||
rv = brprof->QueryInterface(aIID, aResult);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
|
||||
NS_RELEASE(brprof);
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aFactory != nsnull, "bad factory pointer");
|
||||
NS_ASSERTION(aClass.Equals(kBrowsingProfileCID), "incorrectly registered");
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIGenericFactory* factory;
|
||||
rv = compMgr->CreateInstance(kGenericFactoryCID, nsnull, nsIGenericFactory::GetIID(),
|
||||
(void**)&factory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = factory->SetConstructor(nsConstructBrowsingProfile);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete factory;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kBrowsingProfileCID,
|
||||
"Browsing Profile", nsnull, aPath,
|
||||
PR_TRUE, PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kBrowsingProfileCID, aPath);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
24
mozilla/rdf/brprof/makefile.win
Normal file
24
mozilla/rdf/brprof/makefile.win
Normal file
@@ -0,0 +1,24 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
DIRS= public src build
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
1
mozilla/rdf/brprof/public/MANIFEST
Normal file
1
mozilla/rdf/brprof/public/MANIFEST
Normal file
@@ -0,0 +1 @@
|
||||
nsIBrowsingProfile.h
|
||||
35
mozilla/rdf/brprof/public/Makefile.in
Normal file
35
mozilla/rdf/brprof/public/Makefile.in
Normal file
@@ -0,0 +1,35 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = brprof
|
||||
|
||||
EXPORTS = \
|
||||
nsIBrowsingProfile.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
28
mozilla/rdf/brprof/public/makefile.win
Normal file
28
mozilla/rdf/brprof/public/makefile.win
Normal file
@@ -0,0 +1,28 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=brprof
|
||||
|
||||
EXPORTS = \
|
||||
nsIBrowsingProfile.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
|
||||
|
||||
102
mozilla/rdf/brprof/public/nsIBrowsingProfile.h
Normal file
102
mozilla/rdf/brprof/public/nsIBrowsingProfile.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIBrowsingProfile_h__
|
||||
#define nsIBrowsingProfile_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
struct nsBrowsingProfileCategoryDescriptor {
|
||||
PRUint16 mID;
|
||||
PRUint8 mVisitCount;
|
||||
PRUint8 mFlags;
|
||||
};
|
||||
|
||||
// setting this to 56 brings the size of an nsBrowsingProfileVector
|
||||
// struct up to 256 bytes
|
||||
#define nsBrowsingProfile_CategoryCount 56
|
||||
|
||||
struct nsBrowsingProfileVector {
|
||||
union {
|
||||
PRUint8 mPadding[32];
|
||||
struct {
|
||||
PRUint32 mCheck; // should always == nsBrowsingProfile_Check
|
||||
PRUint16 mMajorVersion; // denotes a non-backward compatible change (e.g. structural change to this vector)
|
||||
PRUint16 mMinorVersion; // denotes a backward compatible change to the meaning of this vector
|
||||
} mInfo;
|
||||
} mHeader;
|
||||
nsBrowsingProfileCategoryDescriptor
|
||||
mCategory[nsBrowsingProfile_CategoryCount];
|
||||
};
|
||||
|
||||
#define nsBrowsingProfile_Check 0xbaadf00d
|
||||
#define nsBrowsingProfile_CurrentMajorVersion 1
|
||||
#define nsBrowsingProfile_CurrentMinorVersion 0
|
||||
|
||||
enum nsBrowsingProfileFlag {
|
||||
nsBrowsingProfileFlag_ThisSession = (1 << 0),
|
||||
nsBrowsingProfileFlag_Recent = (1 << 1)
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// size of hex encoding (plus one for null-termination):
|
||||
const PRUint32 kBrowsingProfileCookieSize = sizeof(nsBrowsingProfileVector) * 2 + 1;
|
||||
|
||||
#define NS_IBROWSINGPROFILE_IID \
|
||||
{ /* 4aef9ba2-e0af-11d2-8cca-0060b0fc14a3 */ \
|
||||
0x4aef9ba2, \
|
||||
0xe0af, \
|
||||
0x11d2, \
|
||||
{0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
class nsIBrowsingProfile : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IBROWSINGPROFILE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD Init(const char* userProfileName) = 0;
|
||||
|
||||
NS_IMETHOD GetVector(nsBrowsingProfileVector& result) = 0;
|
||||
|
||||
NS_IMETHOD SetVector(nsBrowsingProfileVector& value) = 0;
|
||||
|
||||
NS_IMETHOD GetCookieString(char buf[kBrowsingProfileCookieSize]) = 0;
|
||||
|
||||
NS_IMETHOD SetCookieString(char buf[kBrowsingProfileCookieSize]) = 0;
|
||||
|
||||
NS_IMETHOD GetDescription(char* *htmlResult) = 0;
|
||||
|
||||
NS_IMETHOD CountPageVisit(const char* url) = 0;
|
||||
};
|
||||
|
||||
// for component registration
|
||||
#define NS_BROWSINGPROFILE_CID \
|
||||
{ /* 7ef80dd0-e0af-11d2-8cca-0060b0fc14a3 */ \
|
||||
0x7ef80dd0, \
|
||||
0xe0af, \
|
||||
0x11d2, \
|
||||
{0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern nsresult
|
||||
NS_NewBrowsingProfile(nsIBrowsingProfile* *aResult);
|
||||
|
||||
#endif // nsIBrowsingProfile_h__
|
||||
60
mozilla/rdf/brprof/server/makefile.win
Normal file
60
mozilla/rdf/brprof/server/makefile.win
Normal file
@@ -0,0 +1,60 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
# XXX You'll need to hack this to point to your installation of ES 3.61
|
||||
SUITESPOT=D:\SuiteSpot
|
||||
|
||||
DEPTH = ..\..\..
|
||||
MODULE=brprof
|
||||
|
||||
MAKE_OBJ_TYPE=EXE
|
||||
|
||||
EXENAME=brprof
|
||||
PDBFILE=brprof.pdb
|
||||
MAPFILE=brprof.map
|
||||
|
||||
PROGRAM= .\$(OBJDIR)\$(EXENAME).exe
|
||||
|
||||
OBJS= .\$(OBJDIR)\nsBrowsingProfileReader.obj
|
||||
|
||||
LCFLAGS= -DXP_WIN32 -DWIN32
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\brprof \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(LIBNSPR) \
|
||||
-I$(SUITESPOT)\include \
|
||||
-I$(SUITESPOT)\wai\include \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= $(DIST)\lib\rdf.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(LIBNSPR) \
|
||||
$(SUITESPOT)\wai\lib\ONEiiop10.lib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
|
||||
|
||||
508
mozilla/rdf/brprof/server/nsBrowsingProfileReader.cpp
Normal file
508
mozilla/rdf/brprof/server/nsBrowsingProfileReader.cpp
Normal file
@@ -0,0 +1,508 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#define FORCE_PR_LOG
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <strstrea.h>
|
||||
#else
|
||||
#include <strstream.h>
|
||||
#endif
|
||||
|
||||
#include "ONESrvPI.hpp"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIBrowsingProfile.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsXPComCIID.h"
|
||||
#include "plevent.h"
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
#include "rdf.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// brprof
|
||||
static NS_DEFINE_CID(kBrowsingProfileCID, NS_BROWSINGPROFILE_CID);
|
||||
|
||||
// rdf
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
// xpcom
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Page);
|
||||
|
||||
#define OPENDIR_NAMESPACE_URI "http://directory.mozilla.org/rdf#"
|
||||
DEFINE_RDF_VOCAB(OPENDIR_NAMESPACE_URI, OPENDIR, Topic);
|
||||
DEFINE_RDF_VOCAB(OPENDIR_NAMESPACE_URI, OPENDIR, narrow);
|
||||
DEFINE_RDF_VOCAB(OPENDIR_NAMESPACE_URI, OPENDIR, catid);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PRLogModuleInfo* gLog;
|
||||
#endif
|
||||
|
||||
const char kInstanceName[] = "BRPROF";
|
||||
|
||||
class nsBrowsingProfileReader : public WAIWebApplicationService
|
||||
{
|
||||
protected:
|
||||
nsIRDFService* mRDFService;
|
||||
nsIRDFDataSource* mDirectory;
|
||||
|
||||
// pseudo-constants
|
||||
static nsIRDFResource* kNC_Page;
|
||||
static nsIRDFResource* kOPENDIR_Topic;
|
||||
static nsIRDFResource* kOPENDIR_narrow;
|
||||
static nsIRDFResource* kOPENDIR_catid;
|
||||
|
||||
public:
|
||||
nsBrowsingProfileReader(const char *object_name = (const char *)NULL,
|
||||
int argc=0,
|
||||
char **argv=0);
|
||||
|
||||
virtual ~nsBrowsingProfileReader();
|
||||
|
||||
virtual long
|
||||
Run(WAIServerRequest_ptr session);
|
||||
|
||||
virtual char*
|
||||
getServiceInfo();
|
||||
|
||||
nsresult
|
||||
Init();
|
||||
|
||||
nsresult
|
||||
WriteVector(WAIServerRequest_ptr aSession,
|
||||
const nsBrowsingProfileVector& aVector);
|
||||
|
||||
nsresult
|
||||
WriteError(WAIServerRequest_ptr aSession,
|
||||
const char* aMessage);
|
||||
|
||||
nsresult
|
||||
GetCategory(PRInt32 aCategoryID, nsXPIDLCString& aCategory);
|
||||
};
|
||||
|
||||
nsIRDFResource* nsBrowsingProfileReader::kNC_Page = nsnull;
|
||||
nsIRDFResource* nsBrowsingProfileReader::kOPENDIR_Topic = nsnull;
|
||||
nsIRDFResource* nsBrowsingProfileReader::kOPENDIR_narrow = nsnull;
|
||||
nsIRDFResource* nsBrowsingProfileReader::kOPENDIR_catid = nsnull;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsBrowsingProfileReader::nsBrowsingProfileReader(const char *object_name, int argc, char **argv)
|
||||
: WAIWebApplicationService(object_name, argc, argv),
|
||||
mRDFService(nsnull),
|
||||
mDirectory(nsnull)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (! gLog)
|
||||
gLog = PR_NewLogModule("nsBrowsingProfileReader");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
nsBrowsingProfileReader::~nsBrowsingProfileReader()
|
||||
{
|
||||
NS_IF_RELEASE(mDirectory);
|
||||
if (mRDFService) {
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long
|
||||
nsBrowsingProfileReader::Run(WAIServerRequest_ptr aSession)
|
||||
{
|
||||
static const char kBrowsingProfileCookiePrefix[] = "BP=";
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("(%p) start processing request", aSession));
|
||||
|
||||
// Process an HTTP request
|
||||
char *cookie = nsnull;
|
||||
if ((WAISPISuccess == aSession->getCookie(cookie)) && (nsnull != cookie)) {
|
||||
char* browsingProfileCookie =
|
||||
PL_strstr(cookie, kBrowsingProfileCookiePrefix);
|
||||
|
||||
if (browsingProfileCookie) {
|
||||
// skip over the "BP=" so we can point directly to the hex
|
||||
// digits.
|
||||
browsingProfileCookie += sizeof(kBrowsingProfileCookiePrefix) - 1;
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("(%p) browsing profile cookie is set", aSession));
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("(%p) %s", aSession, browsingProfileCookie));
|
||||
|
||||
// create a cookie object into which we'll try to stuff the
|
||||
// hex digits (i.e., let the cookie object do the parsing).
|
||||
nsresult rv;
|
||||
nsIBrowsingProfile* profile;
|
||||
rv = nsComponentManager::CreateInstance(kBrowsingProfileCID,
|
||||
nsnull,
|
||||
nsIBrowsingProfile::GetIID(),
|
||||
(void**) &profile);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create profile");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("(%p) constructed profile", aSession));
|
||||
|
||||
rv = profile->SetCookieString(browsingProfileCookie);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set cookie");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("(%p) set cookie string", aSession));
|
||||
|
||||
// now pull out the browsing profile vector and write
|
||||
// it back as fancy HTML.
|
||||
nsBrowsingProfileVector vector;
|
||||
rv = profile->GetVector(vector);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get vector");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("(%p) got profile vector", aSession));
|
||||
|
||||
rv = WriteVector(aSession, vector);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
WriteError(aSession, "No profile cookie");
|
||||
}
|
||||
|
||||
StringDelete(cookie);
|
||||
}
|
||||
else {
|
||||
WriteError(aSession, "No profile cookie.");
|
||||
}
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("(%p) done processing request", aSession));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
nsBrowsingProfileReader::getServiceInfo()
|
||||
{
|
||||
return StringDup("test ver 1.0");
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsBrowsingProfileReader::Init()
|
||||
{
|
||||
// Bring up RDF, read in the directory data source
|
||||
nsresult rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &mRDFService);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mRDFService->GetDataSource("resource:/res/samples/directory.rdf", &mDirectory);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get directory data source");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mRDFService->GetResource(kURINC_Page, &kNC_Page);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mRDFService->GetResource(kURIOPENDIR_Topic, &kOPENDIR_Topic);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mRDFService->GetResource(kURIOPENDIR_narrow, &kOPENDIR_narrow);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mRDFService->GetResource(kURIOPENDIR_catid, &kOPENDIR_catid);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsBrowsingProfileReader::WriteVector(WAIServerRequest_ptr aSession,
|
||||
const nsBrowsingProfileVector& aVector)
|
||||
{
|
||||
ostrstream out;
|
||||
|
||||
// header
|
||||
#if 0
|
||||
out << "<html>" << endl;
|
||||
out << "<head>" << endl;
|
||||
out << "<title>Browsing Profile</title" << endl;
|
||||
out << "</head>" << endl;
|
||||
out << "<body>" << endl;
|
||||
#endif
|
||||
|
||||
out << "<h1>Browsing Profile</h1>" << endl;
|
||||
|
||||
// magic
|
||||
out << "<b>Magic:</b> ";
|
||||
out << aVector.mHeader.mInfo.mCheck << " ";
|
||||
if (aVector.mHeader.mInfo.mCheck == nsBrowsingProfile_Check)
|
||||
out << "(good)";
|
||||
else
|
||||
out << "<font color='red'>(bad)</font>";
|
||||
out << "<br></br>" << endl;
|
||||
|
||||
// version
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("(%p) cookie version %d.%d",
|
||||
aSession,
|
||||
aVector.mHeader.mInfo.mMajorVersion,
|
||||
aVector.mHeader.mInfo.mMinorVersion));
|
||||
|
||||
out << "<b>Version:</b> ";
|
||||
out << aVector.mHeader.mInfo.mMajorVersion << ".";
|
||||
out << aVector.mHeader.mInfo.mMinorVersion << "<br></br>" << endl;
|
||||
|
||||
// categories
|
||||
out << "<table border='1'>" << endl;
|
||||
out << "<tr>" << endl;
|
||||
out << "<td>Category</td>" << endl;
|
||||
out << "<td>Visits</td>" << endl;
|
||||
out << "<td>Flags</td>" << endl;
|
||||
out << "</tr>" << endl;
|
||||
|
||||
nsXPIDLCString category;
|
||||
for (PRInt32 i = 0; i < nsBrowsingProfile_CategoryCount; ++i) {
|
||||
// zero means no more categories -- profile is small
|
||||
if (aVector.mCategory[i].mID == 0)
|
||||
break;
|
||||
|
||||
nsresult rv = GetCategory(aVector.mCategory[i].mID, category);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
out << " <tr>" << endl;
|
||||
out << " <td>" << (const char*) category << "</td>" << endl;
|
||||
out << " <td>" << (PRInt32) aVector.mCategory[i].mVisitCount << "</td>" << endl;
|
||||
out << " <td>" << (PRInt32) aVector.mCategory[i].mFlags << "</td>" << endl;
|
||||
out << " </tr>" << endl;
|
||||
}
|
||||
}
|
||||
out << "</table>" << endl;
|
||||
|
||||
// footer
|
||||
#if 0
|
||||
out << "</body>" << endl;
|
||||
out << "</html>" << endl;
|
||||
#endif
|
||||
|
||||
aSession->setResponseContentLength(out.pcount());
|
||||
aSession->StartResponse();
|
||||
aSession->WriteClient((const unsigned char *)out.str(), out.pcount());
|
||||
out.rdbuf()->freeze(0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsBrowsingProfileReader::WriteError(WAIServerRequest_ptr aSession,
|
||||
const char* aMessage)
|
||||
{
|
||||
ostrstream out;
|
||||
|
||||
out << "<h1>Browsing Profile</h1>" << endl;
|
||||
out << "<b>" << aMessage << "</b>" << endl;
|
||||
|
||||
aSession->setResponseContentLength(out.pcount());
|
||||
aSession->StartResponse();
|
||||
aSession->WriteClient((const unsigned char *)out.str(), out.pcount());
|
||||
out.rdbuf()->freeze(0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsBrowsingProfileReader::GetCategory(PRInt32 aCategoryID, nsXPIDLCString& aCategory)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString categoryIDStr;
|
||||
categoryIDStr.Append(aCategoryID, 10);
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> categoryIDLiteral;
|
||||
rv = mRDFService->GetLiteral(categoryIDStr, getter_AddRefs(categoryIDLiteral));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get literal for category ID");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> topic;
|
||||
rv = mDirectory->GetSource(kOPENDIR_catid, categoryIDLiteral, PR_TRUE, getter_AddRefs(topic));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find topic for category");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// if we didn't actually find a value, then GetCategory() failed.
|
||||
if (rv != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = topic->GetValue(getter_Copies(aCategory));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get category URI");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
(" %d ==> %s", aCategoryID, (const char*) aCategory));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//#include "nsDOMCID.h" // for NS_SCRIPT_NAMESET_REGISTRY_CID
|
||||
#include "nsINetService.h"
|
||||
#include "nsLayoutCID.h" // for NS_NAMESPACEMANAGER_CID
|
||||
#include "nsParserCIID.h"
|
||||
|
||||
#if defined(XP_PC)
|
||||
#define DOM_DLL "jsdom.dll"
|
||||
#define LAYOUT_DLL "raptorhtml.dll"
|
||||
#define NETLIB_DLL "netlib.dll"
|
||||
#define PARSER_DLL "raptorhtmlpars.dll"
|
||||
#define RDF_DLL "rdf.dll"
|
||||
#define XPCOM_DLL "xpcom32.dll"
|
||||
#elif defined(XP_UNIX)
|
||||
#define DOM_DLL "libjsdom.so"
|
||||
#define LAYOUT_DLL "libraptorhtml.so"
|
||||
#define NETLIB_DLL "libnetlib.so"
|
||||
#define PARSER_DLL "libraptorhtmlpars.so"
|
||||
#define RDF_DLL "librdf.so"
|
||||
#define XPCOM_DLL "libxpcom.so"
|
||||
#elif defined(XP_MAC)
|
||||
#define DOM_DLL "DOM_DLL"
|
||||
#define LAYOUT_DLL "LAYOUT_DLL"
|
||||
#define NETLIB_DLL "NETLIB_DLL"
|
||||
#define PARSER_DLL "PARSER_DLL"
|
||||
#define RDF_DLL "RDF_DLL"
|
||||
#define XPCOM_DLL "XPCOM_DLL"
|
||||
#endif
|
||||
|
||||
static nsresult
|
||||
SetupRegistry()
|
||||
{
|
||||
// netlib
|
||||
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
|
||||
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
// parser
|
||||
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID);
|
||||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||
|
||||
nsComponentManager::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kWellFormedDTDCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
// layout
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
|
||||
nsComponentManager::RegisterComponent(kNameSpaceManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
// xpcom
|
||||
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kGenericFactoryCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Get the hostname we're supposed to talk to
|
||||
char localhost[256];
|
||||
char *host;
|
||||
|
||||
if (argc > 1) {
|
||||
if (argc == 1)
|
||||
host = argv[1];
|
||||
else if (*argv[1] != '-')
|
||||
host = argv[1];
|
||||
}
|
||||
else {
|
||||
gethostname(localhost, sizeof(localhost));
|
||||
host = localhost;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// Setup the registry
|
||||
SetupRegistry();
|
||||
|
||||
// Get netlib off the floor...
|
||||
nsIEventQueueService* theEventQueueService = nsnull;
|
||||
rv = nsServiceManager::GetService(kEventQueueServiceCID,
|
||||
nsIEventQueueService::GetIID(),
|
||||
(nsISupports**) &theEventQueueService);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get event queue service");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = theEventQueueService->CreateThreadEventQueue();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create thread event queue");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PLEventQueue* mainQueue;
|
||||
rv = theEventQueueService->GetThreadEventQueue(PR_GetCurrentThread(),
|
||||
&mainQueue);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get event queue for current thread");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Create a WAI instance, register, and run.
|
||||
nsBrowsingProfileReader service(kInstanceName, argc, argv);
|
||||
rv = service.Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (! service.RegisterService(host)) {
|
||||
printf("Failed to Register with %s\n", host);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Wait forever */
|
||||
while(1)
|
||||
Sleep(1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
50
mozilla/rdf/brprof/src/Makefile.in
Normal file
50
mozilla/rdf/brprof/src/Makefile.in
Normal file
@@ -0,0 +1,50 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = brprof_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsBrowsingProfile.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdfbase
|
||||
|
||||
REQUIRES = brprof netlib rdf rdfutil raptor xpcom
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
43
mozilla/rdf/brprof/src/makefile.win
Normal file
43
mozilla/rdf/brprof/src/makefile.win
Normal file
@@ -0,0 +1,43 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=brprof
|
||||
LIBRARY_NAME=brprof_s
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsBrowsingProfile.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS= -I$(PUBLIC)\nspr \
|
||||
-I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\brprof \
|
||||
-I$(PUBLIC)\raptor \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
|
||||
|
||||
|
||||
|
||||
691
mozilla/rdf/brprof/src/nsBrowsingProfile.cpp
Normal file
691
mozilla/rdf/brprof/src/nsBrowsingProfile.cpp
Normal file
@@ -0,0 +1,691 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIBrowsingProfile.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsCRT.h"
|
||||
#include "rdf.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "prclist.h"
|
||||
#include "prprf.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Page);
|
||||
|
||||
#define OPENDIR_NAMESPACE_URI "http://directory.mozilla.org/rdf#"
|
||||
DEFINE_RDF_VOCAB(OPENDIR_NAMESPACE_URI, OPENDIR, Topic);
|
||||
DEFINE_RDF_VOCAB(OPENDIR_NAMESPACE_URI, OPENDIR, narrow);
|
||||
DEFINE_RDF_VOCAB(OPENDIR_NAMESPACE_URI, OPENDIR, catid);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct nsCategory {
|
||||
PRCList mHeader; // for ordering
|
||||
const char* mURL;
|
||||
PRInt32 mVectorIndex;
|
||||
nsBrowsingProfileCategoryDescriptor mDescriptor;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsBrowsingProfile : public nsIBrowsingProfile, public nsIRDFObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIBrowsingProfile methods:
|
||||
NS_IMETHOD Init(const char* userProfileName);
|
||||
NS_IMETHOD GetVector(nsBrowsingProfileVector& result);
|
||||
NS_IMETHOD SetVector(nsBrowsingProfileVector& value);
|
||||
NS_IMETHOD GetCookieString(char buf[kBrowsingProfileCookieSize]);
|
||||
NS_IMETHOD SetCookieString(char buf[kBrowsingProfileCookieSize]);
|
||||
NS_IMETHOD GetDescription(char* *htmlResult);
|
||||
NS_IMETHOD CountPageVisit(const char* url);
|
||||
|
||||
// nsIRDFObserver methods:
|
||||
NS_IMETHOD OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object);
|
||||
NS_IMETHOD OnUnassert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object);
|
||||
|
||||
// nsBrowsingProfile methods:
|
||||
nsBrowsingProfile();
|
||||
virtual ~nsBrowsingProfile();
|
||||
|
||||
nsresult RecordHit(const char* categoryURL, PRUint16 id);
|
||||
nsresult GetCategoryID(nsIRDFResource* category, PRUint16 *result);
|
||||
void UpdateVector(nsCategory* cat) {
|
||||
if (cat->mVectorIndex < nsBrowsingProfile_CategoryCount) {
|
||||
mVector.mCategory[cat->mVectorIndex] = cat->mDescriptor;
|
||||
}
|
||||
}
|
||||
|
||||
static PRUint32 gRefCnt;
|
||||
static nsIRDFService* gRDFService;
|
||||
static nsIRDFDataSource* gCategoryDB;
|
||||
static nsIRDFDataSource* gHistory;
|
||||
static nsIRDFResource* kNC_Page;
|
||||
static nsIRDFResource* kOPENDIR_Topic;
|
||||
static nsIRDFResource* kOPENDIR_narrow;
|
||||
static nsIRDFResource* kOPENDIR_catid;
|
||||
|
||||
// To deal with endian-ness
|
||||
static void Uint8ToHex(PRUint8 aNum, char aBuf[2]);
|
||||
static void Uint16ToHex(PRUint16 aNum, char aBuf[4]);
|
||||
static void Uint32ToHex(PRUint32 aNum, char aBuf[8]);
|
||||
|
||||
static void HexToUint8(const char aBuf[2], PRUint8* aNum);
|
||||
static void HexToUint16(const char aBuf[4], PRUint16* aNum);
|
||||
static void HexToUint32(const char aBuf[8], PRUint32* aNum);
|
||||
|
||||
protected:
|
||||
const char* mUserProfileName;
|
||||
nsBrowsingProfileVector mVector;
|
||||
nsHashtable mCategories; // for fast indexing into mCategoryChain
|
||||
PRCList mCategoryChain;
|
||||
|
||||
static char kHexMap[];
|
||||
};
|
||||
|
||||
PRUint32 nsBrowsingProfile::gRefCnt = 0;
|
||||
nsIRDFService* nsBrowsingProfile::gRDFService = nsnull;
|
||||
nsIRDFDataSource* nsBrowsingProfile::gCategoryDB = nsnull;
|
||||
nsIRDFDataSource* nsBrowsingProfile::gHistory = nsnull;
|
||||
|
||||
nsIRDFResource* nsBrowsingProfile::kNC_Page = nsnull;
|
||||
nsIRDFResource* nsBrowsingProfile::kOPENDIR_Topic = nsnull;
|
||||
nsIRDFResource* nsBrowsingProfile::kOPENDIR_narrow = nsnull;
|
||||
nsIRDFResource* nsBrowsingProfile::kOPENDIR_catid = nsnull;
|
||||
|
||||
char nsBrowsingProfile::kHexMap[] = "0123456789ABCDEF";
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsBrowsingProfile::nsBrowsingProfile()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
nsCRT::zero(&mVector, sizeof(nsBrowsingProfileVector));
|
||||
mVector.mHeader.mInfo.mCheck = nsBrowsingProfile_Check;
|
||||
mVector.mHeader.mInfo.mMajorVersion = nsBrowsingProfile_CurrentMajorVersion;
|
||||
mVector.mHeader.mInfo.mMinorVersion = nsBrowsingProfile_CurrentMinorVersion;
|
||||
PR_INIT_CLIST(&mCategoryChain);
|
||||
gRefCnt++;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::Init(const char* userProfileName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
mUserProfileName = userProfileName;
|
||||
|
||||
if (gRefCnt == 1) {
|
||||
NS_ASSERTION(kNC_Page == nsnull, "out of sync");
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**)&gRDFService);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetDataSource("resource:/res/samples/directory.rdf", &gCategoryDB);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get directory data source");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = gRDFService->GetDataSource("rdf:history", &gHistory);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get history data source");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// get all the properties we'll need:
|
||||
rv = gRDFService->GetResource(kURINC_Page, &kNC_Page);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = gRDFService->GetResource(kURIOPENDIR_Topic, &kOPENDIR_Topic);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = gRDFService->GetResource(kURIOPENDIR_narrow, &kOPENDIR_narrow);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = gRDFService->GetResource(kURIOPENDIR_catid, &kOPENDIR_catid);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// XXX: TODO Grovel through the history data source to initialize
|
||||
// the profile. This gets done automagically so long as the
|
||||
// history data source creates the profile, which is kind of
|
||||
// wrong.
|
||||
|
||||
// add ourself as an observer so that we can keep the profile
|
||||
// in-sync as the user browses.
|
||||
rv = gHistory->AddObserver(this);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add self as history observer");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsBrowsingProfile::~nsBrowsingProfile()
|
||||
{
|
||||
// Stop observing the history data source
|
||||
if (gHistory)
|
||||
gHistory->RemoveObserver(this);
|
||||
|
||||
PRCList* chain = &mCategoryChain;
|
||||
while (!PR_CLIST_IS_EMPTY(chain)) {
|
||||
PRCList* element = chain;
|
||||
chain = PR_NEXT_LINK(chain);
|
||||
PR_REMOVE_LINK(element);
|
||||
delete element;
|
||||
}
|
||||
|
||||
--gRefCnt;
|
||||
if (gRefCnt == 0) {
|
||||
// release all the properties:
|
||||
NS_IF_RELEASE(kOPENDIR_Topic);
|
||||
NS_IF_RELEASE(kOPENDIR_catid);
|
||||
NS_IF_RELEASE(kOPENDIR_narrow);
|
||||
NS_IF_RELEASE(kNC_Page);
|
||||
|
||||
if (gCategoryDB) {
|
||||
NS_RELEASE(gCategoryDB);
|
||||
gCategoryDB = nsnull;
|
||||
}
|
||||
|
||||
if (gHistory) {
|
||||
NS_RELEASE(gHistory);
|
||||
gHistory = nsnull;
|
||||
}
|
||||
|
||||
if (gRDFService) {
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
gRDFService = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsBrowsingProfile)
|
||||
NS_IMPL_RELEASE(nsBrowsingProfile)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIBrowsingProfile::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIBrowsingProfile*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIRDFObserverIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIBrowsingProfile methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::GetVector(nsBrowsingProfileVector& result)
|
||||
{
|
||||
result = mVector; // copy
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::SetVector(nsBrowsingProfileVector& value)
|
||||
{
|
||||
mVector = value; // copy
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::GetCookieString(char buf[kBrowsingProfileCookieSize])
|
||||
{
|
||||
// translate mVector to hex
|
||||
|
||||
char* p = buf;
|
||||
|
||||
Uint32ToHex(mVector.mHeader.mInfo.mCheck, p);
|
||||
p += 8;
|
||||
|
||||
Uint16ToHex(mVector.mHeader.mInfo.mMajorVersion, p);
|
||||
p += 4;
|
||||
|
||||
Uint16ToHex(mVector.mHeader.mInfo.mMinorVersion, p);
|
||||
p += 4;
|
||||
|
||||
while (p < buf + sizeof(mVector.mHeader))
|
||||
*p++ = '0'; // pad with zeroes
|
||||
|
||||
for (PRInt32 i = 0; i < nsBrowsingProfile_CategoryCount; ++i) {
|
||||
Uint16ToHex(mVector.mCategory[i].mID, p);
|
||||
p += 4;
|
||||
|
||||
Uint8ToHex(mVector.mCategory[i].mVisitCount, p);
|
||||
p += 2;
|
||||
|
||||
Uint8ToHex(mVector.mCategory[i].mFlags, p);
|
||||
p += 2;
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::SetCookieString(char buf[kBrowsingProfileCookieSize])
|
||||
{
|
||||
// translate mVector from hex
|
||||
|
||||
char* p = buf;
|
||||
HexToUint32(p, &mVector.mHeader.mInfo.mCheck);
|
||||
p += 8;
|
||||
|
||||
HexToUint16(p, &mVector.mHeader.mInfo.mMajorVersion);
|
||||
p += 4;
|
||||
|
||||
HexToUint16(p, &mVector.mHeader.mInfo.mMinorVersion);
|
||||
//p += 4;
|
||||
|
||||
p = buf + sizeof(mVector.mHeader);
|
||||
for (PRInt32 i = 0; i < nsBrowsingProfile_CategoryCount; ++i) {
|
||||
HexToUint16(p, &mVector.mCategory[i].mID);
|
||||
p += 4;
|
||||
|
||||
HexToUint8(p, &mVector.mCategory[i].mVisitCount);
|
||||
p += 2;
|
||||
|
||||
HexToUint8(p, &mVector.mCategory[i].mFlags);
|
||||
p += 2;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::GetDescription(char* *htmlResult)
|
||||
{
|
||||
// generate some nice html
|
||||
// XXX really wish I had an nsStringStream here to use
|
||||
|
||||
nsresult rv;
|
||||
char* buf = PR_smprintf("<h1>Browsing Profile</h1>format version %d.%d",
|
||||
mVector.mHeader.mInfo.mMajorVersion,
|
||||
mVector.mHeader.mInfo.mMinorVersion);
|
||||
if (buf == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for (PRUint32 i = 0; i < nsBrowsingProfile_CategoryCount; i++) {
|
||||
nsBrowsingProfileCategoryDescriptor* desc = &mVector.mCategory[i];
|
||||
nsIRDFInt* intLit;
|
||||
rv = gRDFService->GetIntLiteral(desc->mID, &intLit);
|
||||
nsIRDFResource* category;
|
||||
rv = gCategoryDB->GetSource(kOPENDIR_catid, category, PR_TRUE, &category);
|
||||
nsXPIDLCString uri;
|
||||
rv = category->GetValue( getter_Copies(uri) );
|
||||
char* buf2 = PR_smprintf("%s%s: %d<b>", buf, (const char*) uri, desc->mVisitCount);
|
||||
PR_smprintf_free(buf);
|
||||
if (buf2 == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
buf = buf2;
|
||||
}
|
||||
*htmlResult = buf;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::CountPageVisit(const char* initialURL)
|
||||
{
|
||||
// Here's where the real work is:
|
||||
// Find the url in the directory, and get the category ID.
|
||||
// Then increment the count (and set the flags) for that category ID
|
||||
// in the vector.
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
PRInt32 pos;
|
||||
|
||||
nsAutoString urlStr(initialURL);
|
||||
// first chop off any query part of the initialURL
|
||||
pos = urlStr.RFind("?");
|
||||
if (pos >= 0) {
|
||||
urlStr.Cut(pos, urlStr.Length());
|
||||
}
|
||||
pos = urlStr.RFind("#");
|
||||
if (pos >= 0) {
|
||||
urlStr.Cut(pos, urlStr.Length());
|
||||
}
|
||||
|
||||
PRBool done = PR_FALSE;
|
||||
do {
|
||||
char* url = urlStr.ToNewCString();
|
||||
if (url == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsIRDFResource* urlRes;
|
||||
rv = gRDFService->GetResource(url, &urlRes);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsISimpleEnumerator* sources;
|
||||
rv = gCategoryDB->GetSources(kOPENDIR_narrow, urlRes, PR_TRUE, &sources);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
while (1) {
|
||||
PRBool hasMore;
|
||||
rv = sources->HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv)) {
|
||||
done = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (! hasMore)
|
||||
break;
|
||||
|
||||
nsISupports* isupports;
|
||||
rv = sources->GetNext(&isupports);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIRDFResource> category = do_QueryInterface(isupports);
|
||||
if (category) {
|
||||
// found this page in a category -- count it
|
||||
PRUint16 id;
|
||||
rv = GetCategoryID(category, &id);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsXPIDLCString catURI;
|
||||
rv = category->GetValue( getter_Copies(catURI) );
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = RecordHit(catURI, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(isupports);
|
||||
done = PR_TRUE;
|
||||
}
|
||||
}
|
||||
NS_RELEASE(sources);
|
||||
}
|
||||
NS_RELEASE(urlRes);
|
||||
}
|
||||
delete[] url;
|
||||
|
||||
// we didn't find this page exactly, but see if some parent directory
|
||||
// url is there
|
||||
if (!done) {
|
||||
// if it already ends with a one or more slashes, rip them off.
|
||||
while (urlStr.Length() > 0 && urlStr.Last() == PRUnichar('/')) {
|
||||
urlStr.Truncate(urlStr.Length() - 1);
|
||||
}
|
||||
|
||||
// _Now_ find the right most forward-slash
|
||||
pos = urlStr.RFind("/");
|
||||
|
||||
if (pos >= 0) {
|
||||
// leave the last '/', as this is the way most opendir
|
||||
// entries are specified; for example,
|
||||
// http://www.amazon.com/
|
||||
urlStr.Cut(pos + 1, urlStr.Length());
|
||||
}
|
||||
else {
|
||||
done = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsBrowsingProfile::GetCategoryID(nsIRDFResource* category, PRUint16 *result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFNode> catID;
|
||||
rv = gCategoryDB->GetTarget(category, kOPENDIR_catid, PR_TRUE, getter_AddRefs(catID));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get category ID");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> catIDLiteral(do_QueryInterface(catID));
|
||||
NS_ASSERTION(catID != nsnull, "not a literal");
|
||||
if (! catID) return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
nsXPIDLString idStr;
|
||||
rv = catIDLiteral->GetValue( getter_Copies(idStr) );
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get literal value");
|
||||
|
||||
PRInt32 err;
|
||||
*result = nsAutoString(idStr).ToInteger(&err);
|
||||
NS_ASSERTION(err == 0, "error converting to integer");
|
||||
|
||||
return (err == 0) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsBrowsingProfile::RecordHit(const char* categoryURL, PRUint16 id)
|
||||
{
|
||||
nsCStringKey key(categoryURL);
|
||||
nsCategory* cat = NS_STATIC_CAST(nsCategory*, mCategories.Get(&key));
|
||||
if (cat == nsnull) {
|
||||
nsCategory* cat = new nsCategory;
|
||||
if (cat == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
cat->mURL = categoryURL;
|
||||
cat->mVectorIndex = 0;
|
||||
cat->mDescriptor.mID = id;
|
||||
cat->mDescriptor.mVisitCount = 1;
|
||||
cat->mDescriptor.mFlags = 0;
|
||||
|
||||
// find the right place to insert this
|
||||
PRCList* end = &mCategoryChain;
|
||||
PRCList* chain = PR_NEXT_LINK(&mCategoryChain);
|
||||
nsCategory* other;
|
||||
PRInt32 count = 0;
|
||||
|
||||
while (chain != end) {
|
||||
other = (nsCategory*)chain;
|
||||
if (cat->mDescriptor.mVisitCount >= other->mDescriptor.mVisitCount)
|
||||
break;
|
||||
|
||||
chain = PR_NEXT_LINK(chain);
|
||||
++count;
|
||||
}
|
||||
|
||||
// do the deed
|
||||
PR_INSERT_BEFORE(&cat->mHeader, chain);
|
||||
cat->mVectorIndex = (chain != end) ? other->mVectorIndex : count;
|
||||
UpdateVector(cat);
|
||||
|
||||
// slide everybody else down
|
||||
for (; chain != end; chain = PR_NEXT_LINK(chain)) {
|
||||
other = (nsCategory*)chain;
|
||||
other->mVectorIndex++;
|
||||
UpdateVector(other);
|
||||
}
|
||||
|
||||
// and insert this in the lookup table
|
||||
mCategories.Put(&key, cat);
|
||||
}
|
||||
else {
|
||||
cat->mDescriptor.mVisitCount++;
|
||||
if (PR_PREV_LINK(&cat->mHeader) != &mCategoryChain) {
|
||||
// it's not the first element already
|
||||
nsCategory* prev = (nsCategory*)PR_PREV_LINK(&cat->mHeader);
|
||||
if (cat->mDescriptor.mVisitCount >= prev->mDescriptor.mVisitCount) {
|
||||
// if we got more hits on this category then it's predecessor
|
||||
// then reorder the chain
|
||||
PR_REMOVE_LINK(&cat->mHeader);
|
||||
PR_INSERT_BEFORE(&cat->mHeader, &prev->mHeader);
|
||||
cat->mVectorIndex = prev->mVectorIndex++;
|
||||
UpdateVector(prev);
|
||||
}
|
||||
}
|
||||
UpdateVector(cat);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (predicate == kNC_Page) {
|
||||
nsIRDFResource* objRes;
|
||||
rv = object->QueryInterface(kIRDFResourceIID, (void**)&objRes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString url;
|
||||
rv = objRes->GetValue( getter_Copies(url) );
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = CountPageVisit(url);
|
||||
}
|
||||
NS_RELEASE(objRes);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowsingProfile::OnUnassert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
// we don't care about history entries going away
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsBrowsingProfile::Uint8ToHex(PRUint8 aNum, char aBuf[2])
|
||||
{
|
||||
char* p = aBuf + 2;
|
||||
while (--p >= aBuf) {
|
||||
*p = kHexMap[aNum & 0x0f];
|
||||
aNum = aNum >> 4;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowsingProfile::Uint16ToHex(PRUint16 aNum, char aBuf[4])
|
||||
{
|
||||
char* p = aBuf + 4;
|
||||
while (--p >= aBuf) {
|
||||
*p = kHexMap[aNum & 0x0f];
|
||||
aNum = aNum >> 4;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowsingProfile::Uint32ToHex(PRUint32 aNum, char aBuf[8])
|
||||
{
|
||||
char* p = aBuf + 8;
|
||||
while (--p >= aBuf) {
|
||||
*p = kHexMap[aNum & 0x0f];
|
||||
aNum = aNum >> 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsBrowsingProfile::HexToUint8(const char aBuf[2], PRUint8* aNum)
|
||||
{
|
||||
PRUint32 num = 0;
|
||||
for (PRInt32 count = 2; count > 0; --count) {
|
||||
const char* hex = PL_strchr(kHexMap, *aBuf);
|
||||
NS_ASSERTION(hex != nsnull, "invalid character");
|
||||
if (! hex)
|
||||
break;
|
||||
|
||||
num = num << 4;
|
||||
num += (hex - kHexMap);
|
||||
++aBuf;
|
||||
}
|
||||
*aNum = num;
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowsingProfile::HexToUint16(const char aBuf[4], PRUint16* aNum)
|
||||
{
|
||||
PRUint32 num = 0;
|
||||
for (PRInt32 count = 4; count > 0; --count) {
|
||||
const char* hex = PL_strchr(kHexMap, *aBuf);
|
||||
NS_ASSERTION(hex != nsnull, "invalid character");
|
||||
if (! hex)
|
||||
break;
|
||||
|
||||
num = num << 4;
|
||||
num += (hex - kHexMap);
|
||||
++aBuf;
|
||||
}
|
||||
*aNum = num;
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowsingProfile::HexToUint32(const char aBuf[8], PRUint32* aNum)
|
||||
{
|
||||
PRUint32 num = 0;
|
||||
for (PRInt32 count = 8; count > 0; --count) {
|
||||
const char* hex = PL_strchr(kHexMap, *aBuf);
|
||||
NS_ASSERTION(hex != nsnull, "invalid character");
|
||||
if (! hex)
|
||||
break;
|
||||
|
||||
num = num << 4;
|
||||
num += (hex - kHexMap);
|
||||
++aBuf;
|
||||
}
|
||||
*aNum = num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewBrowsingProfile(nsIBrowsingProfile* *aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsBrowsingProfile* profile = new nsBrowsingProfile();
|
||||
if (profile == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(profile);
|
||||
*aResult = profile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
1
mozilla/rdf/build/MANIFEST
Normal file
1
mozilla/rdf/build/MANIFEST
Normal file
@@ -0,0 +1 @@
|
||||
nsRDFCID.h
|
||||
109
mozilla/rdf/build/Makefile.in
Normal file
109
mozilla/rdf/build/Makefile.in
Normal file
@@ -0,0 +1,109 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = rdf
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
dlldeps.cpp \
|
||||
nsRDFFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsRDFCID.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
REQUIRES = dom js netlib rdf raptor xpcom
|
||||
|
||||
# XXX Note dependencies on implementation headers for factory functions
|
||||
|
||||
INCLUDES += -I$(srcdir)/../base/src \
|
||||
-I$(srcdir)/../content/src \
|
||||
-I$(srcdir)/../datasource/src \
|
||||
$(NULL)
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/librdfbase_s.a \
|
||||
$(DIST)/lib/librdfcontent_s.a \
|
||||
$(DIST)/lib/librdfdatasource_s.a \
|
||||
$(DIST)/lib/librdfutil_s.a \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
EXTRA_DSO_LDOPTS = -c objs/objslist
|
||||
else
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MKSHLIB_FORCE_ALL) \
|
||||
$(SHARED_LIBRARY_LIBS) \
|
||||
$(MKSHLIB_UNFORCE_ALL)
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += -L$(DIST)/bin $(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
shared_library_objs: $(SHARED_LIBRARY_LIBS)
|
||||
rm -rf objs
|
||||
mkdir objs
|
||||
(cd objs; for lib in $(SHARED_LIBRARY_LIBS); do ar xv ../$$lib; done) \
|
||||
| awk '{ print "objs/"$$3 }' > objs/objslist
|
||||
|
||||
$(LIBRARY) $(SHARED_LIBRARY): shared_library_objs Makefile
|
||||
else
|
||||
$(LIBRARY) $(SHARED_LIBRARY): $(SHARED_LIBRARY_LIBS) Makefile
|
||||
endif
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(srcdir)/../resources/sidebar.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/sidebar.css $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bm-props.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmarks.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmarks.css $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/history.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/history.css $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmarks.html $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmark-item.gif $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmark-folder-closed.gif $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmark-folder-open.gif $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/personal-folder-closed.gif $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/personal-folder-open.gif $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/folder-open.gif $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/folder-closed.gif $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/document.gif $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/History/h1.hst $(DIST)/bin/res/rdf/History
|
||||
$(INSTALL) $(srcdir)/../resources/dom-test-1.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/dom-test-2.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/dom-test-3.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/dom-test-4.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/dom-test-5.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/dom-test-1.css $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/dom-test-4.css $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/xpidl-test-1.xul $(DIST)/bin/res/rdf
|
||||
61
mozilla/rdf/build/dlldeps.cpp
Normal file
61
mozilla/rdf/build/dlldeps.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsRDFParserUtils.h"
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsString.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
void XXXNeverCalled()
|
||||
{
|
||||
static nsAutoString s;
|
||||
|
||||
// nsRDFParserUtils
|
||||
nsRDFParserUtils::EntityToUnicode("");
|
||||
nsRDFParserUtils::StripAndConvert(s);
|
||||
nsRDFParserUtils::GetQuotedAttributeValue(s, s, s);
|
||||
nsRDFParserUtils::IsJavaScriptLanguage(s);
|
||||
|
||||
// rdfutils
|
||||
rdf_IsOrdinalProperty(nsnull);
|
||||
rdf_OrdinalResourceToIndex(nsnull, nsnull);
|
||||
rdf_IndexToOrdinalResource(0, nsnull);
|
||||
rdf_IsContainer(nsnull, nsnull);
|
||||
rdf_IsBag(nsnull, nsnull);
|
||||
rdf_IsSeq(nsnull, nsnull);
|
||||
rdf_IsAlt(nsnull, nsnull);
|
||||
rdf_CreateAnonymousResource(s, nsnull);
|
||||
rdf_IsAnonymousResource(s, nsnull);
|
||||
rdf_PossiblyMakeRelative(s, s);
|
||||
rdf_MakeBag(nsnull, nsnull);
|
||||
rdf_MakeSeq(nsnull, nsnull);
|
||||
rdf_MakeAlt(nsnull, nsnull);
|
||||
rdf_ContainerAppendElement(nsnull, nsnull, nsnull);
|
||||
rdf_ContainerRemoveElement(nsnull, nsnull, nsnull, PR_FALSE);
|
||||
rdf_ContainerInsertElementAt(nsnull, nsnull, nsnull, 0, PR_FALSE);
|
||||
rdf_ContainerIndexOf(nsnull, nsnull, nsnull, nsnull);
|
||||
NS_NewContainerEnumerator(nsnull, nsnull, nsnull);
|
||||
NS_NewEmptyEnumerator(nsnull);
|
||||
|
||||
// nsRDFResource
|
||||
nsRDFResource r();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
98
mozilla/rdf/build/makefile.win
Normal file
98
mozilla/rdf/build/makefile.win
Normal file
@@ -0,0 +1,98 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
MODULE=rdf
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=rdf
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
EXPORTS=\
|
||||
nsRDFCID.h \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsRDFFactory.obj \
|
||||
$(NULL)
|
||||
|
||||
# XXX linking in raptor is a heinous crime that will go away once we
|
||||
# have a more DOM-based mechanism for constructing elements and
|
||||
# hooking in to their changes.
|
||||
|
||||
LLIBS=\
|
||||
$(DIST)\lib\rdfbase_s.lib \
|
||||
$(DIST)\lib\rdfutil_s.lib \
|
||||
$(DIST)\lib\rdfcontent_s.lib \
|
||||
$(DIST)\lib\rdfdatasource_s.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\raptorgfxwin.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\raptorhtml.lib \
|
||||
$(DIST)\lib\jsdom.lib \
|
||||
$(DIST)\lib\js3250.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
MISCDEP=$(LLIBS)
|
||||
|
||||
# XXX Note dependencies on implementation dirs for factory methods.
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(DEPTH)\rdf\base\src \
|
||||
-I$(DEPTH)\rdf\content\src \
|
||||
-I$(DEPTH)\rdf\datasource\src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
$(MAKE_INSTALL) nsRDFInterfaces.xpt $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) ..\resources\sidebar.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\sidebar.css $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bm-props.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmarks.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmarks.css $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\history.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\history.css $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmarks.html $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmark-item.gif $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmark-folder-closed.gif $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmark-folder-open.gif $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\personal-folder-closed.gif $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\personal-folder-open.gif $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\folder-open.gif $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\folder-closed.gif $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\document.gif $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\History\h1.hst $(DIST)\bin\res\rdf\History
|
||||
$(MAKE_INSTALL) ..\resources\dom-test-1.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\dom-test-2.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\dom-test-3.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\dom-test-4.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\dom-test-5.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\dom-test-1.css $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\dom-test-4.css $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\xpidl-test-1.xul $(DIST)\bin\res\rdf
|
||||
|
||||
130
mozilla/rdf/build/nsRDFCID.h
Normal file
130
mozilla/rdf/build/nsRDFCID.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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 } }
|
||||
|
||||
// {BFD05264-834C-11d2-8EAC-00805F29F371}
|
||||
#define NS_XULSORTSERVICE_CID \
|
||||
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x71 } }
|
||||
|
||||
// {BFD0526D-834C-11d2-8EAC-00805F29F370}
|
||||
#define NS_RDFINMEMORYDATASOURCE_CID \
|
||||
{ 0xbfd0526d, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {E638D760-8687-11d2-B530-000000000000}
|
||||
#define NS_RDFBOOKMARKDATASOURCE_CID \
|
||||
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {E638D760-8687-11d2-B530-000000000001}
|
||||
#define NS_RDFFILESYSTEMDATASOURCE_CID \
|
||||
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x01 } }
|
||||
|
||||
// {E638D760-8687-11d2-B530-000000000002}
|
||||
#define NS_RDFFINDDATASOURCE_CID \
|
||||
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x02 } }
|
||||
|
||||
// {9ebd2e83-e2fc-11d2-9820-c7de17d21fbc}
|
||||
#define NS_RDFFTPDATASOURCE_CID \
|
||||
{ 0x9ebd2e83, 0xe2fc, 0x11d2, { 0x98, 0x20, 0xc7, 0xde, 0x17, 0xd2, 0x1f, 0xbc } }
|
||||
|
||||
// {dc2fb186-f7ff-11d2-9820-f65ea652ae3c}
|
||||
#define NS_RDFRELATEDLINKSDATASOURCE_CID \
|
||||
{ 0xdc2fb186, 0xf7ff, 0x11d2, { 0x98, 0x20, 0xf6, 0x5e, 0xa6, 0x52, 0xae, 0x3c } }
|
||||
|
||||
// {E638D761-8687-11d2-B530-000000000000}
|
||||
#define NS_RDFCOMPOSITEDATASOURCE_CID \
|
||||
{ 0xe638d761, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {954F0813-81DC-11d2-B52A-000000000000}
|
||||
#define NS_RDFHTMLBUILDER_CID \
|
||||
{ 0x954f0813, 0x81dc, 0x11d2, { 0xb5, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {3D262D00-8B5A-11d2-8EB0-00805F29F370}
|
||||
#define NS_RDFTREEBUILDER_CID \
|
||||
{ 0x3d262d00, 0x8b5a, 0x11d2, { 0x8e, 0xb0, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {CF6547E1-D427-11d2-96ED-00104B7B7DEB}
|
||||
#define NS_RDFMENUBUILDER_CID \
|
||||
{ 0xcf6547e1, 0xd427, 0x11d2, { 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } }
|
||||
|
||||
// {FEA36A61-D48F-11d2-96ED-00104B7B7DEB}
|
||||
#define NS_RDFTOOLBARBUILDER_CID \
|
||||
{ 0xfea36a61, 0xd48f, 0x11d2, { 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } }
|
||||
|
||||
// {7BAF62E0-8E61-11d2-8EB1-00805F29F370}
|
||||
#define NS_RDFXMLDATASOURCE_CID \
|
||||
{ 0x7baf62e0, 0x8e61, 0x11d2, { 0x8e, 0xb1, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {6791B601-B9FE-11d2-BF86-00105A1B0627}
|
||||
#define NS_XULDATASOURCE_CID \
|
||||
{ 0x6791b601, 0xb9fe, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {0958B101-9ADA-11d2-8EBC-00805F29F370}
|
||||
#define NS_RDFCONTENTSINK_CID \
|
||||
{ 0x958b101, 0x9ada, 0x11d2, { 0x8e, 0xbc, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {E45313F0-B59C-11d2-A68C-00104BDE6048}
|
||||
#define NS_RDFXULBUILDER_CID \
|
||||
{ 0xe45313f0, 0xb59c, 0x11d2, { 0xa6, 0x8c, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
// {CE058B21-BA9C-11d2-BF86-00105A1B0627}
|
||||
#define NS_XULCONTENTSINK_CID \
|
||||
{ 0xce058b21, 0xba9c, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {541AFCB2-A9A3-11d2-8EC5-00805F29F370}
|
||||
#define NS_XULDOCUMENT_CID \
|
||||
{ 0x541afcb2, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {F53279E1-D7A4-11d2-BF86-00105A1B0627}
|
||||
#define NS_XULDOCUMENTINFO_CID \
|
||||
{ 0xf53279e1, 0xd7a4, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {1EAAFD60-D596-11d2-80BE-006097B76B8E}
|
||||
#define NS_RDFHISTORYDATASOURCE_CID \
|
||||
{ 0x1eaafd60, 0xd596, 0x11d2, { 0x80, 0xbe, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } }
|
||||
|
||||
// {DF71C6F0-EC53-11d2-BDCA-000064657374}
|
||||
#define NS_LOCALSTORE_CID \
|
||||
{ 0xdf71c6f0, 0xec53, 0x11d2, { 0xbd, 0xca, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
|
||||
// {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 } }
|
||||
|
||||
|
||||
#endif // nsRDFCID_h__
|
||||
529
mozilla/rdf/build/nsRDFFactory.cpp
Normal file
529
mozilla/rdf/build/nsRDFFactory.cpp
Normal file
@@ -0,0 +1,529 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF factory implementation.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIHistoryDataSource.h"
|
||||
#include "nsILocalStore.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFContentSink.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFXMLDataSource.h"
|
||||
#include "nsIXULContentSink.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsRDFBaseDataSources.h"
|
||||
#include "nsRDFBuiltInDataSources.h"
|
||||
#include "nsIRDFFileSystem.h"
|
||||
#include "nsIRDFFind.h"
|
||||
#include "nsIRelatedLinksDataSource.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "rdf.h"
|
||||
#include "nsIXULSortService.h"
|
||||
#include "nsIXULDocumentInfo.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
static NS_DEFINE_CID(kLocalStoreCID, NS_LOCALSTORE_CID);
|
||||
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFCompositeDataSourceCID, NS_RDFCOMPOSITEDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kRDFContentSinkCID, NS_RDFCONTENTSINK_CID);
|
||||
static NS_DEFINE_CID(kRDFDefaultResourceCID, NS_RDFDEFAULTRESOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFFileSystemDataSourceCID, NS_RDFFILESYSTEMDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFFindDataSourceCID, NS_RDFFINDDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFFTPDataSourceCID, NS_RDFFTPDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFHTMLBuilderCID, NS_RDFHTMLBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFHistoryDataSourceCID, NS_RDFHISTORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFMenuBuilderCID, NS_RDFMENUBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFRelatedLinksDataSourceCID, NS_RDFRELATEDLINKSDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFToolbarBuilderCID, NS_RDFTOOLBARBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFTreeBuilderCID, NS_RDFTREEBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFXULBuilderCID, NS_RDFXULBUILDER_CID);
|
||||
static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID);
|
||||
static NS_DEFINE_CID(kXULDataSourceCID, NS_XULDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kXULDocumentCID, NS_XULDOCUMENT_CID);
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kXULDocumentInfoCID, NS_XULDOCUMENTINFO_CID);
|
||||
|
||||
class RDFFactoryImpl : public nsIFactory
|
||||
{
|
||||
public:
|
||||
RDFFactoryImpl(const nsCID &aClass, const char* className, const char* progID);
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
protected:
|
||||
virtual ~RDFFactoryImpl();
|
||||
|
||||
protected:
|
||||
nsCID mClassID;
|
||||
const char* mClassName;
|
||||
const char* mProgID;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RDFFactoryImpl::RDFFactoryImpl(const nsCID &aClass,
|
||||
const char* className,
|
||||
const char* progID)
|
||||
: mClassID(aClass), mClassName(className), mProgID(progID)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
RDFFactoryImpl::~RDFFactoryImpl()
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFFactoryImpl::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = nsnull;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIFactory*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(RDFFactoryImpl);
|
||||
NS_IMPL_RELEASE(RDFFactoryImpl);
|
||||
|
||||
extern nsresult
|
||||
NS_NewDefaultResource(nsIRDFResource** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
if (mClassID.Equals(kRDFServiceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFService((nsIRDFService**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULSortServiceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULSortService((nsIXULSortService**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFInMemoryDataSourceCID)) {
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFInMemoryDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFXMLDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFXMLDataSource((nsIRDFXMLDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFBookmarkDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFBookmarkDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFFileSystemDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFFileSystemDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFFindDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFFindDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFFTPDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFFTPDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFCompositeDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFCompositeDataSource((nsIRDFCompositeDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFContainerCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFContainer((nsIRDFContainer**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFContainerUtilsCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFContainerUtils((nsIRDFContainerUtils**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFHistoryDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewHistoryDataSource((nsIHistoryDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFRelatedLinksDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFRelatedLinksDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULDocumentCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULDocument((nsIRDFDocument**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULDocumentInfoCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULDocumentInfo((nsIXULDocumentInfo**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFHTMLBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFHTMLBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFMenuBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFMenuBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFToolbarBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFToolbarBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFTreeBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFTreeBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFXULBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFXULBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFContentSinkCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFContentSink((nsIRDFContentSink**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULDataSource((nsIRDFXMLDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULContentSinkCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULContentSink((nsIXULContentSink**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFDefaultResourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewDefaultResource((nsIRDFResource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kLocalStoreCID)) {
|
||||
if (NS_FAILED(rv = NS_NewLocalStore((nsILocalStore**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
if (! inst)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(rv = inst->QueryInterface(aIID, aResult))) {
|
||||
// We didn't get the right interface.
|
||||
NS_ERROR("didn't support the interface you wanted");
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(inst);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult RDFFactoryImpl::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// return the proper factory to the caller
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (! aFactory)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFFactoryImpl* factory = new RDFFactoryImpl(aClass, aClassName, aProgID);
|
||||
if (factory == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// register our build-in datasources:
|
||||
rv = compMgr->RegisterComponent(kRDFBookmarkDataSourceCID,
|
||||
"Bookmarks",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "bookmarks",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFCompositeDataSourceCID,
|
||||
"RDF Composite Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "composite-datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFFileSystemDataSourceCID,
|
||||
"RDF File System Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "files",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFFindDataSourceCID,
|
||||
"RDF Find Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "find",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFFTPDataSourceCID,
|
||||
"RDF FTP Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "ftp",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFHistoryDataSourceCID,
|
||||
"RDF History Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "history",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFRelatedLinksDataSourceCID,
|
||||
"RDF Related Links Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "relatedlinks",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFInMemoryDataSourceCID,
|
||||
"RDF In-Memory Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "in-memory-datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kLocalStoreCID,
|
||||
"Local Store",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "local-store",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFXMLDataSourceCID,
|
||||
"RDF XML Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "xml-datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kXULDataSourceCID,
|
||||
"XUL Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "xul-datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
// register our built-in resource factories:
|
||||
rv = compMgr->RegisterComponent(kRDFDefaultResourceCID,
|
||||
"RDF Default Resource Factory",
|
||||
NS_RDF_RESOURCE_FACTORY_PROGID, // default resource factory has no name= part
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
// register all the other rdf components:
|
||||
rv = compMgr->RegisterComponent(kRDFContentSinkCID,
|
||||
"RDF Content Sink",
|
||||
NS_RDF_PROGID "/content-sink",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFContainerCID,
|
||||
"RDF Container",
|
||||
NS_RDF_PROGID "/container",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFContainerUtilsCID,
|
||||
"RDF Container Utilities",
|
||||
NS_RDF_PROGID "/container-utils",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFHTMLBuilderCID,
|
||||
"RDF HTML Builder",
|
||||
NS_RDF_PROGID "/html-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFServiceCID,
|
||||
"RDF Service",
|
||||
NS_RDF_PROGID "/rdf-service",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kXULSortServiceCID,
|
||||
"XUL Sort Service",
|
||||
NS_RDF_PROGID "/xul-sort-service",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFTreeBuilderCID,
|
||||
"RDF Tree Builder",
|
||||
NS_RDF_PROGID "/tree-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFMenuBuilderCID,
|
||||
"RDF Menu Builder",
|
||||
NS_RDF_PROGID "/menu-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFToolbarBuilderCID,
|
||||
"RDF Toolbar Builder",
|
||||
NS_RDF_PROGID "/toolbar-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kRDFXULBuilderCID,
|
||||
"RDF XUL Builder",
|
||||
NS_RDF_PROGID "/xul-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kXULContentSinkCID,
|
||||
"XUL Content Sink",
|
||||
NS_RDF_PROGID "/xul-content-sink",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kXULDocumentCID,
|
||||
"XUL Document",
|
||||
NS_RDF_PROGID "/xul-document",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kXULDocumentInfoCID,
|
||||
"XUL Document Info",
|
||||
NS_RDF_PROGID "/xul-document-info",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kRDFBookmarkDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFFileSystemDataSourceCID,aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFFindDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFFTPDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFHistoryDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFRelatedLinksDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFCompositeDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFInMemoryDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kLocalStoreCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFXMLDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kXULDataSourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kRDFDefaultResourceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kRDFContentSinkCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFHTMLBuilderCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFServiceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kXULSortServiceCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFTreeBuilderCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFMenuBuilderCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFToolbarBuilderCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kRDFXULBuilderCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kXULContentSinkCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kXULDocumentCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kXULDocumentInfoCID, aPath);
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
BIN
mozilla/rdf/build/nsRDFInterfaces.xpt
Normal file
BIN
mozilla/rdf/build/nsRDFInterfaces.xpt
Normal file
Binary file not shown.
29
mozilla/rdf/chrome/Makefile.in
Normal file
29
mozilla/rdf/chrome/Makefile.in
Normal file
@@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src build
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
70
mozilla/rdf/chrome/build/Makefile.in
Normal file
70
mozilla/rdf/chrome/build/Makefile.in
Normal file
@@ -0,0 +1,70 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = chrome
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
nsChromeFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = chrome
|
||||
|
||||
REQUIRES = xpcom
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/libchrome_s.a \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
EXTRA_DSO_LDOPTS = -c objs/objslist
|
||||
else
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MKSHLIB_FORCE_ALL) \
|
||||
$(SHARED_LIBRARY_LIBS) \
|
||||
$(MKSHLIB_UNFORCE_ALL)
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += -L$(DIST)/bin $(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
shared_library_objs: $(SHARED_LIBRARY_LIBS)
|
||||
rm -rf objs
|
||||
mkdir objs
|
||||
(cd objs; for lib in $(SHARED_LIBRARY_LIBS); do ar xv ../$$lib; done) \
|
||||
| awk '{ print "objs/"$$3 }' > objs/objslist
|
||||
|
||||
$(LIBRARY) $(SHARED_LIBRARY): shared_library_objs Makefile
|
||||
else
|
||||
$(LIBRARY) $(SHARED_LIBRARY): $(SHARED_LIBRARY_LIBS) Makefile
|
||||
endif
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(srcdir)/registry.rdf $(DIST)/bin/chrome
|
||||
BIN
mozilla/rdf/chrome/build/chrome.mcp
Normal file
BIN
mozilla/rdf/chrome/build/chrome.mcp
Normal file
Binary file not shown.
3
mozilla/rdf/chrome/build/chrome.toc
Normal file
3
mozilla/rdf/chrome/build/chrome.toc
Normal file
@@ -0,0 +1,3 @@
|
||||
# target: chromeDebug.shlb
|
||||
mozilla/rdf/chrome/build/nsChromeFactory.cpp
|
||||
mozilla/rdf/chrome/build/nsChromeRegistry.cpp
|
||||
57
mozilla/rdf/chrome/build/makefile.win
Normal file
57
mozilla/rdf/chrome/build/makefile.win
Normal file
@@ -0,0 +1,57 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=chrome
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=chrome
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsChromeFactory.obj \
|
||||
$(NULL)
|
||||
|
||||
# XXX linking in raptor is a heinous crime that will go away once we
|
||||
# have a more DOM-based mechanism for constructing elements and
|
||||
# hooking in to their changes.
|
||||
|
||||
LLIBS=\
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\chrome_s.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
MISCDEP=$(LLIBS)
|
||||
|
||||
# XXX Note dependencies on implementation dirs for factory methods.
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\chrome \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
$(MAKE_INSTALL) registry.rdf $(DIST)\bin\chrome
|
||||
|
||||
107
mozilla/rdf/chrome/build/nsChromeFactory.cpp
Normal file
107
mozilla/rdf/chrome/build/nsChromeFactory.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nscore.h"
|
||||
#include "rdf.h"
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
|
||||
static NS_IMETHODIMP
|
||||
NS_ConstructChromeRegistry(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aOuter == nsnull, "no aggregation");
|
||||
nsIChromeRegistry* chromeRegistry;
|
||||
rv = NS_NewChromeRegistry(&chromeRegistry);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Unable to construct chrome registry");
|
||||
return rv;
|
||||
}
|
||||
rv = chromeRegistry->QueryInterface(aIID, aResult);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
|
||||
NS_RELEASE(chromeRegistry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aFactory != nsnull, "bad factory pointer");
|
||||
NS_ASSERTION(aClass.Equals(kChromeRegistryCID), "incorrectly registered");
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIGenericFactory* factory;
|
||||
rv = compMgr->CreateInstance(kGenericFactoryCID, nsnull, nsIGenericFactory::GetIID(),
|
||||
(void**)&factory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = factory->SetConstructor(NS_ConstructChromeRegistry);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete factory;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kChromeRegistryCID,
|
||||
"Chrome Registry",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "chrome",
|
||||
aPath,
|
||||
PR_TRUE, PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kChromeRegistryCID, aPath);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
125
mozilla/rdf/chrome/build/registry.rdf
Normal file
125
mozilla/rdf/chrome/build/registry.rdf
Normal file
@@ -0,0 +1,125 @@
|
||||
<!-- -*- Mode: SGML; tab-width: 4; indent-tabs-mode: nil -*- -->
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://chrome.mozilla.org/rdf#">
|
||||
|
||||
<chrome ID="chrome://global/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description ID="chrome://global/skin/">
|
||||
<base>resource:/res/samples/</base>
|
||||
<main>xul.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
</chrome>
|
||||
|
||||
|
||||
<chrome ID="chrome://navigator/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description ID="chrome://navigator/skin/">
|
||||
<base>resource:/res/samples/</base>
|
||||
<main>navigator.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description ID="chrome://navigator/content/">
|
||||
<base>resource:/res/samples/</base>
|
||||
<main>navigator.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome ID="chrome://messenger/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description ID="chrome://messenger/skin/">
|
||||
<base>resource:/res/mailnews/messenger/</base>
|
||||
<main>messenger.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description ID="chrome://messenger/content/">
|
||||
<base>resource:/res/mailnews/messenger/</base>
|
||||
<main>mailshell.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome ID="chrome://messengercompose/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description ID="chrome://messengercompose/skin/">
|
||||
<base>resource:/res/mailnews/compose/</base>
|
||||
<main>messengercompose.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description ID="chrome://messengercompose/content/">
|
||||
<base>resource:/res/mailnews/compose/</base>
|
||||
<main>msgcompose.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome ID="chrome://editor/">
|
||||
|
||||
<content>
|
||||
<RDF:Description ID="chrome://editor/content/">
|
||||
<base>resource:/chrome/editor/composer/content/default/</base>
|
||||
<main>EditorAppShell.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description ID="chrome://editor/skin/">
|
||||
<base>resource:/chrome/editor/composer/skin/default/</base>
|
||||
<main>Editor.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome ID="chrome://editordlgs/">
|
||||
<skin>
|
||||
<RDF:Description ID="chrome://editordlgs/skin/">
|
||||
<base>resource:/chrome/editor/dialogs/skin/default/</base>
|
||||
<main>EditorDialog.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description ID="chrome://editordlgs/content/">
|
||||
<base>resource:/chrome/editor/dialogs/content/default/</base>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
</chrome>
|
||||
|
||||
<chrome ID="chrome://addressbook/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description ID="chrome://addressbook/skin/">
|
||||
<base>resource:/res/mailnews/addrbook/</base>
|
||||
<main>addrshell.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description ID="chrome://addressbook/content/">
|
||||
<base>resource:/res/mailnews/addrbook/</base>
|
||||
<main>addrshell.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
</chrome>
|
||||
|
||||
</RDF:RDF>
|
||||
|
||||
|
||||
24
mozilla/rdf/chrome/makefile.win
Normal file
24
mozilla/rdf/chrome/makefile.win
Normal file
@@ -0,0 +1,24 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
DIRS= public src build
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user