зеркало из https://github.com/mozilla/gecko-dev.git
add datasource datasource for the first time
(not complete, not yet part of the build)
This commit is contained in:
Родитель
d7387bc5c0
Коммит
49993ef1f0
|
@ -0,0 +1 @@
|
|||
Makefile
|
|
@ -0,0 +1,34 @@
|
|||
tree {
|
||||
display: table;
|
||||
background-color: white;
|
||||
border: none;
|
||||
border-spacing: 0px;
|
||||
//border-collapse: collapse;
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
treeitem {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
treehead {
|
||||
display: table-header-group;
|
||||
}
|
||||
|
||||
treebody {
|
||||
display: table-row-group;
|
||||
}
|
||||
|
||||
treecell {
|
||||
display: table-cell;
|
||||
color: black;
|
||||
font-family: Verdana;
|
||||
font-size: 10pt;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
treecell[selectedcell] {
|
||||
background-color: #666699;
|
||||
color: white;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="DataSourceViewer.css" type="text/css"?>
|
||||
|
||||
<window
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
style="width: 100%; height: 100%">
|
||||
|
||||
|
||||
<tree datasources="rdf:datasource"
|
||||
id="dataSourceTree"
|
||||
containment="http://home.netscape.com/NC-rdf#child">
|
||||
<treecol id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
|
||||
<treecol id="ValueColumn" rdf:resource="http://home.netscape.com/NC-rdf#Value"/>
|
||||
<treehead>
|
||||
<treeitem>
|
||||
<treecell>Name</treecell>
|
||||
<treecell>Value</treecell>
|
||||
</treeitem>
|
||||
</treehead>
|
||||
|
||||
|
||||
<treebody id="rdf:mailnewsfolders" name="dataSourceTreeBody">
|
||||
<treeitem id="msgaccounts:/" open="true">
|
||||
<treecell>
|
||||
<treeindentation/>
|
||||
<html:img hspace="2" style="vertical-align: bottom" src="chrome://messenger/skin/localMailHost.gif"/>Accounts
|
||||
</treecell>
|
||||
<treecell/>
|
||||
<treecell/>
|
||||
</treeitem>
|
||||
</treebody>
|
||||
</tree>
|
||||
</window>
|
|
@ -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 = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME=rdfdsds
|
||||
IS_COMPONENT=1
|
||||
|
||||
CPPSRCS = \
|
||||
nsRDFDataSourceDS.cpp \
|
||||
nsRDFDataSourceFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(NSPR_LIBS) \
|
||||
-L$(DIST)/bin \
|
||||
-lxpcom \
|
||||
$(NULL)
|
||||
|
||||
SAMPLES_DIR = $(DIST)/bin/res/samples/rdf
|
||||
|
||||
RESOURCE_SAMPLES = \
|
||||
DataSourceViewer.xul \
|
||||
DataSourceViewer.css \
|
||||
$(NULL)
|
||||
|
||||
EXPORT_RESOURCE_SAMPLES := $(addprefix $(srcdir)/,$(RESOURCE_SAMPLES))
|
||||
CLOBBER_RESOURCE_SAMPLES := $(addprefix $(SAMPLES_DIR)/, $(RESOURCE_SAMPLES))
|
||||
|
||||
install::
|
||||
$(INSTALL) $(EXPORT_RESOURCE_SAMPLES) $(SAMPLES_DIR)
|
||||
|
||||
clobber::
|
||||
$(RM) $(CLOBBER_RESOURCE_SAMPLES)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,91 @@
|
|||
/* -*- 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 __gen_nsRDFDOMDataSource_h__
|
||||
#define __gen_nsRDFDOMDataSource_h__
|
||||
|
||||
#include "nsRDFDOMDataSource.h"
|
||||
|
||||
/* starting interface: nsRDFDOMDataSource */
|
||||
|
||||
/* {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 nsRDFDOMDataSource : 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;
|
||||
};
|
||||
|
||||
#endif /* __gen_nsRDFDOMDataSource_h__ */
|
|
@ -0,0 +1,450 @@
|
|||
/* -*- 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 "nscore.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "rdf.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsEnumeratorUtils.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
#include "stdio.h"
|
||||
#endif
|
||||
|
||||
#define NC_RDF_Name NC_NAMESPACE_URI "Name"
|
||||
#define NC_RDF_Value NC_NAMESPACE_URI "Value"
|
||||
#define NC_RDF_Child NC_NAMESPACE_URI "child"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
class nsRDFDataSourceDataSource : public nsIRDFDataSource {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsRDFDataSourceDataSource();
|
||||
virtual ~nsRDFDataSourceDataSource();
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(const char *uri);
|
||||
|
||||
/* readonly attribute string URI; */
|
||||
NS_IMETHOD GetURI(char * *aURI);
|
||||
|
||||
/* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetSource(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsIRDFResource **_retval);
|
||||
|
||||
/* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsISimpleEnumerator **_retval);
|
||||
|
||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsIRDFNode **_retval);
|
||||
|
||||
/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsISimpleEnumerator **_retval);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */
|
||||
NS_IMETHOD Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* void AddObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver *aObserver);
|
||||
|
||||
/* void RemoveObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver *aObserver);
|
||||
|
||||
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval);
|
||||
|
||||
/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval);
|
||||
|
||||
/* nsISimpleEnumerator GetAllResources (); */
|
||||
NS_IMETHOD GetAllResources(nsISimpleEnumerator **_retval);
|
||||
|
||||
/* void Flush (); */
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
||||
NS_IMETHOD GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval);
|
||||
|
||||
/* boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */
|
||||
NS_IMETHOD IsCommandEnabled(nsISupportsArray * aSources, nsIRDFResource *aCommand, nsISupportsArray * aArguments, PRBool *_retval);
|
||||
|
||||
/* void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */
|
||||
NS_IMETHOD DoCommand(nsISupportsArray * aSources, nsIRDFResource *aCommand, nsISupportsArray * aArguments);
|
||||
|
||||
private:
|
||||
char *mURI;
|
||||
nsIRDFDataSource* mDataSource;
|
||||
|
||||
static nsIRDFResource* kNC_Name;
|
||||
static nsIRDFResource* kNC_Value;
|
||||
static nsIRDFResource* kNC_Child;
|
||||
|
||||
};
|
||||
|
||||
nsIRDFResource* nsRDFDataSourceDataSource::kNC_Name=nsnull;
|
||||
nsIRDFResource* nsRDFDataSourceDataSource::kNC_Value=nsnull;
|
||||
nsIRDFResource* nsRDFDataSourceDataSource::kNC_Child=nsnull;
|
||||
|
||||
|
||||
nsRDFDataSourceDataSource::nsRDFDataSourceDataSource():
|
||||
mURI(nsnull),
|
||||
mDataSource(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
nsRDFDataSourceDataSource::~nsRDFDataSourceDataSource()
|
||||
{
|
||||
nsCRT::free(mURI);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsRDFDataSourceDataSource, nsIRDFDataSource::GetIID());
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::Init(const char *uri)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (mURI) nsCRT::free(mURI);
|
||||
mURI = nsCRT::strdup(uri);
|
||||
|
||||
// get RDF resources
|
||||
|
||||
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
||||
if (!kNC_Name) {
|
||||
rdf->GetResource(NC_RDF_Name, &kNC_Name);
|
||||
rdf->GetResource(NC_RDF_Child, &kNC_Child);
|
||||
rdf->GetResource(NC_RDF_Value, &kNC_Value);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_alecf
|
||||
printf("nsRDFDataSourceDataSource::Init(%s)\n", uri);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string URI; */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::GetURI(char * *aURI)
|
||||
{
|
||||
#ifdef DEBUG_alecf
|
||||
printf("nsRDFDataSourceDataSource::GetURI()\n");
|
||||
#endif
|
||||
*aURI = nsCRT::strdup(mURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::GetSource(nsIRDFResource *aProperty,
|
||||
nsIRDFNode *aTarget,
|
||||
PRBool aTruthValue,
|
||||
nsIRDFResource **_retval)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::GetSources(nsIRDFResource *aProperty,
|
||||
nsIRDFNode *aTarget,
|
||||
PRBool aTruthValue,
|
||||
nsISimpleEnumerator **_retval)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::GetTarget(nsIRDFResource *aSource,
|
||||
nsIRDFResource *aProperty,
|
||||
PRBool aTruthValue,
|
||||
nsIRDFNode **_retval)
|
||||
{
|
||||
#ifdef DEBUG_alecf
|
||||
nsXPIDLCString sourceval;
|
||||
nsXPIDLCString propval;
|
||||
aSource->GetValue(getter_Copies(sourceval));
|
||||
aProperty->GetValue(getter_Copies(propval));
|
||||
printf("GetTarget(%s, %s,..)\n", (const char*)sourceval,
|
||||
(const char*)propval);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::GetTargets(nsIRDFResource *aSource,
|
||||
nsIRDFResource *aProperty,
|
||||
PRBool aTruthValue,
|
||||
nsISimpleEnumerator **_retval)
|
||||
{
|
||||
#ifdef DEBUG_alecf
|
||||
nsXPIDLCString sourceval;
|
||||
nsXPIDLCString propval;
|
||||
aSource->GetValue(getter_Copies(sourceval));
|
||||
aProperty->GetValue(getter_Copies(propval));
|
||||
printf("GetTargets(%s, %s,..)\n", (const char*)sourceval,
|
||||
(const char*)propval);
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
PRBool isProp;
|
||||
nsCOMPtr<nsISupportsArray> arcs;
|
||||
nsISimpleEnumerator *enumerator;
|
||||
|
||||
if (NS_SUCCEEDED(aProperty.EqualsResource(kNC_Child, &isProp)) &&
|
||||
isProp) {
|
||||
|
||||
// here we need to determine if we need to extract out the source
|
||||
// or use aSource?
|
||||
if (!PL_strcmp(sourceval, "dsresource:", 11)) {
|
||||
// somehow get the source
|
||||
rv = mDataSource->ArcLabelsOut(realsource, &enumerator);
|
||||
} else {
|
||||
rv = mDataSource->ArcLabelsOut(aSource, &enumerator);
|
||||
}
|
||||
// enumerate all the children and create the composite resources
|
||||
PRBool hasMoreArcs=PR_FALSE;
|
||||
|
||||
rv = enumerator->hasMoreElements(&hasMoreArcs);
|
||||
while (NS_SUCCEEDED(rv) && hasMoreArcs) {
|
||||
|
||||
// get the next arc
|
||||
nsCOMPtr<nsISupports> arcSupports;
|
||||
rv = enumerator->GetNext(getter_AddRefs(arcSupports));
|
||||
nsCOMPtr<nsIRDFResource> arc = do_QueryInterface(arcSupports, &rv);
|
||||
|
||||
// get all the resources on the ends of the arc arcs
|
||||
nsCOMPtr<nsISimpleEnumerator> targetEnumerator;
|
||||
rv = mDataSource->GetTargets(aSource, element, PR_TRUE,
|
||||
getter_AddRefs(targetEnumerator));
|
||||
|
||||
PRBool hasMoreTargets;
|
||||
rv = targetEnumerator->hasMoreElements(&hasMoreTargets);
|
||||
while (NS_SUCCEEDED(rv) && hasMoreTargets) {
|
||||
// get the next target
|
||||
nsCOMPtr<nsISupports> targetSupports;
|
||||
rv = enumerator->GetNext(getter_AddRefs(targetSupports));
|
||||
nsCOMPtr<nsIRDFResource> target=do_QueryInterface(targetSupports, &rv);
|
||||
|
||||
// now we have an (arc, target) tuple that will be our node
|
||||
// arc will become #Name
|
||||
// target will become #Value
|
||||
#ifdef DEBUG_alecf
|
||||
nsXPIDLString arcValue;
|
||||
nsXPIDLString targetValue;
|
||||
|
||||
arc->GetValue(getter_Copies(arcValue));
|
||||
target->GetValue(getter_Copies(targetValue));
|
||||
printf("#child of %s:\n\t%s = %s\n",
|
||||
(const char*)sourceval
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
rv = enumerator->hasMoreElements(&hasMoreArcs);
|
||||
}
|
||||
|
||||
nsIRDFResource *res = CreateCompositeResource(aSource, aProperty);
|
||||
|
||||
} else if (NS_SUCCEEDED(aProperty.EqualsResource(kNC_Name, &isProp)) &&
|
||||
isProp) {
|
||||
if (!PL_strncmp(sourceval, "dsresource:", 11) {
|
||||
// extract out the name
|
||||
|
||||
}
|
||||
|
||||
} else if (NS_SUCCEEDED(aProperty.EqualsResource(kNC_Value, &isProp)) &&
|
||||
isProp) {
|
||||
|
||||
|
||||
} else {
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(arcs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsArrayEnumerator* cursor =
|
||||
new nsArrayEnumerator(arcs);
|
||||
|
||||
if (!cursor) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*_retval = cursor;
|
||||
NS_ADDREF(*_retval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* void AddObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::AddObserver(nsIRDFObserver *aObserver)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* void RemoveObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::RemoveObserver(nsIRDFObserver *aObserver)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::ArcLabelsOut(nsIRDFResource *aSource,
|
||||
nsISimpleEnumerator **_retval)
|
||||
{
|
||||
nsresult rv=NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> arcs;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(arcs));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString sourceval;
|
||||
aSource->GetValue(getter_Copies(sourceval));
|
||||
|
||||
#ifdef DEBUG_alecf
|
||||
printf("ArcLabelsOut(%s)\n", (const char*)sourceval);
|
||||
#endif
|
||||
|
||||
// this is a terrible ugly hack, but it works.
|
||||
// set the datasource if the URI begins with rdf:
|
||||
if (!PL_strncmp((const char*)sourceval, "rdf:", 4)) {
|
||||
#ifdef DEBUG_alecf
|
||||
printf("Ahah! This is a datasource node. Setting the datasource..");
|
||||
#endif
|
||||
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
||||
rv = rdf->GetDataSource((const char*)sourceval, &mDataSource);
|
||||
|
||||
#ifdef DEBUG_alecf
|
||||
printf("done.\n");
|
||||
#endif
|
||||
|
||||
} else {
|
||||
arcs->AppendElement(kNC_Name);
|
||||
arcs->AppendElement(kNC_Value);
|
||||
arcs->AppendElement(kNC_Child);
|
||||
}
|
||||
|
||||
nsArrayEnumerator* cursor =
|
||||
new nsArrayEnumerator(arcs);
|
||||
|
||||
if (!cursor) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(cursor);
|
||||
*_retval = cursor;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator GetAllResources (); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::GetAllResources(nsISimpleEnumerator **_retval)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* void Flush (); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::Flush()
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::GetAllCommands(nsIRDFResource *aSource, nsIEnumerator **_retval)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::IsCommandEnabled(nsISupportsArray * aSources, nsIRDFResource *aCommand, nsISupportsArray * aArguments, PRBool *_retval)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
/* void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */
|
||||
NS_IMETHODIMP
|
||||
nsRDFDataSourceDataSource::DoCommand(nsISupportsArray * aSources, nsIRDFResource *aCommand, nsISupportsArray * aArguments)
|
||||
{
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewRDFDataSourceDataSource(nsISupports *, const nsIID& iid,
|
||||
void ** result)
|
||||
|
||||
{
|
||||
nsRDFDataSourceDataSource * dsds = new nsRDFDataSourceDataSource();
|
||||
|
||||
return dsds->QueryInterface(iid, result);
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- 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 __nsRDFDataSourceDS_h
|
||||
#define __nsRDFDataSourceDS_h
|
||||
|
||||
|
||||
/* {aa1b3f18-1aad-11d3-84bf-006008948010} */
|
||||
#define NS_RDFDATASOURCEDATASOURCE_CID \
|
||||
{0xaa1b3f18, 0x1aad, 0x11d3, \
|
||||
{0x84, 0xbf, 0x00, 0x60, 0x08, 0x94, 0x80, 0x10}}
|
||||
|
||||
nsresult
|
||||
NS_NewRDFDataSourceDataSource(nsISupports* aOuter,
|
||||
const nsIID& iid, void **result);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,87 @@
|
|||
/* -*- 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 "nsIGenericFactory.h"
|
||||
#include "nsRDFDataSourceDS.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "rdf.h"
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kRDFDataSourceCID, NS_RDFDATASOURCEDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
nsresult
|
||||
NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char* aClassName,
|
||||
const char* aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
nsresult rv=NS_OK;
|
||||
nsIGenericFactory* fact;
|
||||
if (aClass.Equals(kRDFDataSourceCID))
|
||||
rv = NS_NewGenericFactory(&fact, NS_NewRDFDataSourceDataSource);
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*aFactory = fact;
|
||||
|
||||
#ifdef DEBUG_alecf
|
||||
printf("nsRDFDataSource's NSGetFactory!\n");
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
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(kRDFDataSourceCID,
|
||||
"Generic DataSource DataSource",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
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(kRDFDataSourceCID, aPath);
|
||||
|
||||
return rv;
|
||||
}
|
Загрузка…
Ссылка в новой задаче