Compare commits
17 Commits
Bugzilla_P
...
RDF_199901
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6f01c6a79 | ||
|
|
2edfa7f1c8 | ||
|
|
43f2fa6af3 | ||
|
|
91581ad4a3 | ||
|
|
9ce2b0b847 | ||
|
|
16ad4428c0 | ||
|
|
e7debe4694 | ||
|
|
a181cfd20d | ||
|
|
3a8f74ebfb | ||
|
|
3c18ccb3a9 | ||
|
|
a03d6c80a8 | ||
|
|
ca0f8b379f | ||
|
|
75739aaf36 | ||
|
|
72dd387d87 | ||
|
|
38486bf78d | ||
|
|
0a68b3c848 | ||
|
|
6b1c3e384c |
107
mozilla/content/xul/content/src/nsRDFDOMNodeList.cpp
Normal file
107
mozilla/content/xul/content/src/nsRDFDOMNodeList.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 "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 "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
|
||||
class RDFDOMNodeListImpl : public nsIDOMNodeList {
|
||||
private:
|
||||
nsIContent* mElement;
|
||||
|
||||
public:
|
||||
RDFDOMNodeListImpl(nsIContent* element) : mElement(element) {
|
||||
NS_IF_ADDREF(mElement);
|
||||
}
|
||||
|
||||
virtual ~RDFDOMNodeListImpl(void) {
|
||||
NS_IF_RELEASE(mElement);
|
||||
}
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_IDOMNODELIST
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(RDFDOMNodeListImpl, kIDOMNodeListIID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFDOMNodeListImpl::GetLength(PRUint32* aLength)
|
||||
{
|
||||
PRInt32 count;
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = mElement->ChildCount(count)))
|
||||
return rv;
|
||||
*aLength = count;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFDOMNodeListImpl::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX naive. probably breaks when there are pseudo elements or something.
|
||||
nsresult rv;
|
||||
nsIContent* contentChild;
|
||||
if (NS_FAILED(rv = mElement->ChildAt(aIndex, contentChild)))
|
||||
return rv;
|
||||
|
||||
rv = contentChild->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
NS_RELEASE(contentChild);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFDOMNodeList(nsIDOMNodeList** aResult, nsIContent* aElement)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aElement != nsnull, "null ptr");
|
||||
if (! aElement)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFDOMNodeListImpl* list = new RDFDOMNodeListImpl(aElement);
|
||||
if (! list)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(list);
|
||||
*aResult = list;
|
||||
return NS_OK;
|
||||
}
|
||||
29
mozilla/rdf/Makefile.in
Normal file
29
mozilla/rdf/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 = base content datasource build
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
29
mozilla/rdf/base/Makefile.in
Normal file
29
mozilla/rdf/base/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
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
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>
|
||||
11
mozilla/rdf/base/public/MANIFEST
Normal file
11
mozilla/rdf/base/public/MANIFEST
Normal file
@@ -0,0 +1,11 @@
|
||||
rdf.h
|
||||
nsIRDFContentSink.h
|
||||
nsIRDFCursor.h
|
||||
nsIRDFDataBase.h
|
||||
nsIRDFDataSource.h
|
||||
nsIRDFNode.h
|
||||
nsIRDFObserver.h
|
||||
nsIRDFResourceFactory.h
|
||||
nsIRDFService.h
|
||||
nsIRDFXMLDocument.h
|
||||
nsIRDFXMLSource.h
|
||||
45
mozilla/rdf/base/public/Makefile.in
Normal file
45
mozilla/rdf/base/public/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
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
EXPORTS = \
|
||||
rdf.h \
|
||||
nsIRDFContentSink.h \
|
||||
nsIRDFCursor.h \
|
||||
nsIRDFDataBase.h \
|
||||
nsIRDFDataSource.h \
|
||||
nsIRDFNode.h \
|
||||
nsIRDFObserver.h \
|
||||
nsIRDFResourceFactory.h \
|
||||
nsIRDFService.h \
|
||||
nsIRDFXMLDocument.h \
|
||||
nsIRDFXMLSource.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
39
mozilla/rdf/base/public/makefile.win
Normal file
39
mozilla/rdf/base/public/makefile.win
Normal file
@@ -0,0 +1,39 @@
|
||||
#!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 \
|
||||
nsIRDFContentSink.h \
|
||||
nsIRDFCursor.h \
|
||||
nsIRDFDataBase.h \
|
||||
nsIRDFDataSource.h \
|
||||
nsIRDFNode.h \
|
||||
nsIRDFObserver.h \
|
||||
nsIRDFResourceFactory.h \
|
||||
nsIRDFService.h \
|
||||
nsIRDFXMLDocument.h \
|
||||
nsIRDFXMLSource.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
74
mozilla/rdf/base/public/nsIRDFContentSink.h
Normal file
74
mozilla/rdf/base/public/nsIRDFContentSink.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* -*- 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 nsIRDFDataSource;
|
||||
class nsIRDFXMLDocument;
|
||||
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:
|
||||
/**
|
||||
* Initialize the content sink.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIURL* aURL, nsINameSpaceManager* aNameSpaceManager) = 0;
|
||||
|
||||
/**
|
||||
* Set the content sink's RDF Data source
|
||||
*/
|
||||
NS_IMETHOD SetDataSource(nsIRDFDataSource* aDataSource) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the content sink's RDF data source.
|
||||
*/
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource*& rDataSource) = 0;
|
||||
|
||||
NS_IMETHOD SetRDFXMLDocument(nsIRDFXMLDocument* aDocument) = 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___
|
||||
167
mozilla/rdf/base/public/nsIRDFCursor.h
Normal file
167
mozilla/rdf/base/public/nsIRDFCursor.h
Normal file
@@ -0,0 +1,167 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Interfaces for RDF cursors, including nsIRDFCursor,
|
||||
nsIRDFAssertionCursor, nsIRDFArcsInCursor, and nsIRDFArcsOutCursor.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFCursor_h__
|
||||
#define nsIRDFCursor_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "prtypes.h"
|
||||
#include "rdf.h" // for error codes
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFNode;
|
||||
class nsIRDFResource;
|
||||
|
||||
// 1c2abdb0-4cef-11d2-bc16-00805f912fe7
|
||||
#define NS_IRDFCURSOR_IID \
|
||||
{ 0x1c2abdb0, 0x4cef, 0x11d2, { 0xbc, 0x16, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } }
|
||||
|
||||
/**
|
||||
* An abstract base interface that is the basis for all RDF cursors.
|
||||
*/
|
||||
class nsIRDFCursor : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Advance the cursor to the next element.
|
||||
* @return NS_ERROR_RDF_CURSOR_EMPTY if the cursor has reached the end
|
||||
* and there are no more elements to enumerate; otherwise, NS_OK
|
||||
* unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD Advance(void) = 0;
|
||||
/* Retrieve the data source from which the current item was obtained.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) = 0;
|
||||
/**
|
||||
* Irrespective of the query, a cursor is an interator over a set.
|
||||
* This allows you to obtain the current value.
|
||||
*/
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// {1ED57100-9904-11d2-8EBA-00805F29F370}
|
||||
#define NS_IRDFASSERTIONCURSOR_IID \
|
||||
{ 0x1ed57100, 0x9904, 0x11d2, { 0x8e, 0xba, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
* A cursor that enumerates assertions
|
||||
* @seealso nsIRDFDataSource::GetTargetS(), nsIRDFDataSource::GetSources()
|
||||
*/
|
||||
class nsIRDFAssertionCursor : public nsIRDFCursor {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Retrieve the assertion's subject resource.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aSubject) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the assertion's predicate resource.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the assertion's object node.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the assertion's truth value.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
|
||||
};
|
||||
|
||||
|
||||
// {1ED57101-9904-11d2-8EBA-00805F29F370}
|
||||
#define NS_IRDFARCSOUTCURSOR_IID \
|
||||
{ 0x1ed57101, 0x9904, 0x11d2, { 0x8e, 0xba, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
* A cursor that enumerates the outbound arcs from a resource node.
|
||||
* @seealso nsIRDFDataSource::ArcsOut()
|
||||
*/
|
||||
class nsIRDFArcsOutCursor : public nsIRDFCursor {
|
||||
public:
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the "subject" node from which the arcs originate.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aSubject) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the predicate label of the arc.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
||||
/**
|
||||
* Retrieve the truth value of the arc.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
* xxx rvg --- truth value doesn't make sense here.
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
// {1ED57102-9904-11d2-8EBA-00805F29F370}
|
||||
#define NS_IRDFARCSINCURSOR_IID \
|
||||
{ 0x1ed57102, 0x9904, 0x11d2, { 0x8e, 0xba, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
* A cursor that enumerates the inbound arcs to a node.
|
||||
* @seealso nsIRDFDataSource::ArcsIn()
|
||||
*/
|
||||
class nsIRDFArcsInCursor : public nsIRDFCursor {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Retrieve the "object" node in which the arc terminates.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the predicate label of the arc
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
||||
/**
|
||||
* Retrieve the truth value of the arc.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
* xxx rvg --- truth value doesn't make sense here.
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFCursor_h__ */
|
||||
56
mozilla/rdf/base/public/nsIRDFDataBase.h
Normal file
56
mozilla/rdf/base/public/nsIRDFDataBase.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 "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 data base interface. An RDF database aggregates individual RDF
|
||||
data sources.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDataBase_h__
|
||||
#define nsIRDFDataBase_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
|
||||
// 96343820-307c-11d2-bc15-00805f912fe7
|
||||
#define NS_IRDFDATABASE_IID \
|
||||
{ 0x96343820, 0x307c, 0x11d2, { 0xb, 0x15, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } }
|
||||
|
||||
/**
|
||||
* An <tt>nsIRDFDataBase</tt> composes individual data sources, providing
|
||||
* the illusion of a single, coherent RDF graph.
|
||||
*/
|
||||
class nsIRDFDataBase : public nsIRDFDataSource {
|
||||
public:
|
||||
/**
|
||||
* 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 /* nsIRDFDataBase_h__ */
|
||||
201
mozilla/rdf/base/public/nsIRDFDataSource.h
Normal file
201
mozilla/rdf/base/public/nsIRDFDataSource.h
Normal file
@@ -0,0 +1,201 @@
|
||||
/* -*- 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 "nsISupports.h"
|
||||
|
||||
// {0F78DA58-8321-11d2-8EAC-00805F29F370}
|
||||
#define NS_IRDFDATASOURCE_IID \
|
||||
{ 0xf78da58, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFAssertionCursor;
|
||||
class nsIRDFArcsInCursor;
|
||||
class nsIRDFArcsOutCursor;
|
||||
class nsIRDFDataBase;
|
||||
class nsIRDFNode;
|
||||
class nsIRDFObserver;
|
||||
class nsIRDFResource;
|
||||
|
||||
/**
|
||||
* An RDF data source.
|
||||
*/
|
||||
|
||||
class nsIRDFDataSource : public nsISupports {
|
||||
public:
|
||||
// XXX I didn't make some of these methods "const" because it's
|
||||
// probably pretty likely that many data sources will just make
|
||||
// stuff up at runtime to answer queries.
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
NS_IMETHOD Init(const char* uri) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the URI of the data source.
|
||||
*/
|
||||
NS_IMETHOD GetURI(const char* *uri) const = 0;
|
||||
|
||||
/**
|
||||
* Find an RDF resource that points to a given node over the
|
||||
* specified arc & truth value
|
||||
*
|
||||
* @return NS_ERROR_FAILURE if there is no source that leads
|
||||
* to the target with the specified property.
|
||||
*/
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source /* out */) = 0;
|
||||
|
||||
/**
|
||||
* 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 nsIRDFCursor points
|
||||
* to a valid (but possibly empty) cursor.
|
||||
*/
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** sources /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find a child of that is related to the source by the given arc
|
||||
* arc and truth value
|
||||
*
|
||||
* @return NS_ERROR_FAILURE if there is no target accessable from the
|
||||
* source via the specified property.
|
||||
*/
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target /* out */) = 0;
|
||||
|
||||
/**
|
||||
* 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 nsIRDFCursor points
|
||||
* to a valid (but possibly empty) cursor.
|
||||
*/
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Add an assertion to the graph.
|
||||
*/
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv) = 0;
|
||||
|
||||
/**
|
||||
* Remove an assertion from the graph.
|
||||
*/
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target) = 0;
|
||||
|
||||
/**
|
||||
* Query whether an assertion exists in this graph.
|
||||
*
|
||||
* @return NS_OK unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Add an observer to this data source.
|
||||
*/
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer from this data source
|
||||
*/
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n) = 0;
|
||||
|
||||
// XXX individual resource observers?
|
||||
|
||||
/**
|
||||
* 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) nsIRDFCursor object.
|
||||
*/
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels /* out */) = 0;
|
||||
|
||||
/**
|
||||
* 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) nsIRDFCursor object.
|
||||
*/
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Request that a data source write it's contents out to
|
||||
* permanent storage if applicable.
|
||||
*/
|
||||
NS_IMETHOD Flush() = 0;
|
||||
|
||||
/**
|
||||
* Determine whether the specified command is enabled for the
|
||||
* resource.
|
||||
*
|
||||
* XXX We will probably need to make this interface much more intricate
|
||||
* to handle arbitrary arguments and selection sets.
|
||||
*/
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult) = 0;
|
||||
|
||||
/**
|
||||
* Perform the specified command on the resource.
|
||||
*
|
||||
* XXX We will probably need to make this interface much more intricate
|
||||
* to handle arbitrary arguments and selection sets.
|
||||
*/
|
||||
NS_IMETHOD DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIRDFDataSource_h__ */
|
||||
104
mozilla/rdf/base/public/nsIRDFNode.h
Normal file
104
mozilla/rdf/base/public/nsIRDFNode.h
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
RDF node interfaces, including nsIRDFNode, nsIRDFResource, and
|
||||
nsIRDFLiteral. Nodes are the elements that appear in RDF graphs.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFNode_h__
|
||||
#define nsIRDFNode_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {0F78DA50-8321-11d2-8EAC-00805F29F370}
|
||||
#define NS_IRDFNODE_IID \
|
||||
{ 0xf78da50, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
*
|
||||
* Nodes are created using an instance of nsIRDFService, which
|
||||
* should be obtained from the service manager:
|
||||
*
|
||||
* nsIRDFService* service;
|
||||
* if (NS_SUCCEEDED(nsServiceManager::GetService(kCRDFServiceCID,
|
||||
* kIRDFServiceIID,
|
||||
* (nsISupports**) &service))) {
|
||||
* nsIRDFNode* node;
|
||||
* if (NS_SUCCEEDED(service->GetResource("http://foo.bar/", node))) {
|
||||
* // do something useful here...
|
||||
* NS_IF_RELEASE(node);
|
||||
* }
|
||||
* nsServiceManager::ReleaseService(kCRDFServiceCID, mgr);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
class nsIRDFNode : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Determine if two nodes are identical
|
||||
*/
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode* that, PRBool* result) const = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A resource node, which has unique object identity.
|
||||
*/
|
||||
class nsIRDFResource : public nsIRDFNode {
|
||||
public:
|
||||
/**
|
||||
* Get the 8-bit string value of the node.
|
||||
*/
|
||||
NS_IMETHOD GetValue(const char* *uri) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if two resources are identical.
|
||||
*/
|
||||
NS_IMETHOD EqualsResource(const nsIRDFResource* resource, PRBool* result) const = 0;
|
||||
NS_IMETHOD EqualsString(const char* uri, PRBool* result) const = 0;
|
||||
};
|
||||
|
||||
// {E0C493D1-9542-11d2-8EB8-00805F29F370}
|
||||
#define NS_IRDFRESOURCE_IID \
|
||||
{ 0xe0c493d1, 0x9542, 0x11d2, { 0x8e, 0xb8, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
class nsIRDFLiteral : public nsIRDFNode {
|
||||
public:
|
||||
/**
|
||||
* Get the Unicode string value of the node.
|
||||
*/
|
||||
NS_IMETHOD GetValue(const PRUnichar* *value) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if two resources are identical.
|
||||
*/
|
||||
NS_IMETHOD EqualsLiteral(const nsIRDFLiteral* literal, PRBool* result) const = 0;
|
||||
};
|
||||
|
||||
// {E0C493D2-9542-11d2-8EB8-00805F29F370}
|
||||
#define NS_IRDFLITERAL_IID \
|
||||
{ 0xe0c493d2, 0x9542, 0x11d2, { 0x8e, 0xb8, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
#endif // nsIRDFNode_h__
|
||||
61
mozilla/rdf/base/public/nsIRDFObserver.h
Normal file
61
mozilla/rdf/base/public/nsIRDFObserver.h
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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 "nsISupports.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFNode;
|
||||
|
||||
/**
|
||||
* An observer on an nsIRDFDataSource.
|
||||
*/
|
||||
class nsIRDFObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Called whenever a new assertion is made in the data source.
|
||||
*/
|
||||
NS_IMETHOD OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object) = 0;
|
||||
|
||||
/**
|
||||
* Called whenever an assertion is removed from the data source.
|
||||
*/
|
||||
NS_IMETHOD OnUnassert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object) = 0;
|
||||
};
|
||||
|
||||
|
||||
// 3cc75360-484a-11d2-bc16-00805f912fe7
|
||||
#define NS_IRDFOBSERVER_IID \
|
||||
{ 0x3cc75360, 0x484a, 0x11d2, { 0xbc, 0x16, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } }
|
||||
|
||||
#endif /* nsIRDFObserver_h__ */
|
||||
72
mozilla/rdf/base/public/nsIRDFResourceFactory.h
Normal file
72
mozilla/rdf/base/public/nsIRDFResourceFactory.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 "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__
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIRDFResource;
|
||||
|
||||
// {8CE57A20-A02C-11d2-8EBF-00805F29F370}
|
||||
#define NS_IRDFRESOURCEFACTORY_IID \
|
||||
{ 0x8ce57a20, 0xa02c, 0x11d2, { 0x8e, 0xbf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
/**
|
||||
* A resource factory can be registered with <tt>nsIRDFService</tt> to produce
|
||||
* resources with a certain <i>URI prefix</i>. The resource factory will be called
|
||||
* upon to create a new resource, which the resource manager will cache.
|
||||
*
|
||||
* @see nsIRDFService::RegisterResourceFactory
|
||||
* @see nsIRDFService::UnRegisterResourceFactory
|
||||
*/
|
||||
class nsIRDFResourceFactory : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This method is called by the RDF service to create a new
|
||||
* resource.
|
||||
*
|
||||
* NOTE. After constructing a new resource via a call to
|
||||
* nsIRDFResourceFactory::CreateResource(), the implementation of
|
||||
* the RDF service calls nsIRDFResource::GetValue() on the
|
||||
* resulting resource. The resulting <tt>const char*</tt> is used
|
||||
* as a key for the resource cache. (The assumption is that the
|
||||
* custom resource implementation needs to store this information,
|
||||
* anyway.)
|
||||
*
|
||||
* This has important implications for a custom resource's
|
||||
* destructor; namely, that you must call
|
||||
* nsIRDFService::UnCacheResource() <b>before</b> releasing the
|
||||
* storage for the resource's URI. See
|
||||
* nsIRDFService::UnCacheResource() for more information.
|
||||
*/
|
||||
NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsIRDFResourceFactory_h__
|
||||
|
||||
174
mozilla/rdf/base/public/nsIRDFService.h
Normal file
174
mozilla/rdf/base/public/nsIRDFService.h
Normal file
@@ -0,0 +1,174 @@
|
||||
/* -*- 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>.
|
||||
|
||||
XXX I'm not particularly happy with the current APIs for named data
|
||||
sources. The idea is that you want "rdf:bookmarks" to always map to
|
||||
the "bookmarks" data store. The thing that bothers me now is that
|
||||
the implementation has to pre-load all of the data sources: that
|
||||
means you need to parse the bookmarks file, read the history, etc.,
|
||||
rather than doing this on-demand. With a little thought, it may be
|
||||
able to enormously improve these APIs so that pre-loading data
|
||||
sources is unnecessary.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFService_h__
|
||||
#define nsIRDFService_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
class nsIRDFDataBase;
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFLiteral;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFResourceFactory;
|
||||
|
||||
typedef nsresult (*NSDataSourceConstructorCallback)(nsIRDFDataSource** aResult);
|
||||
|
||||
class nsIRDFService : public nsISupports {
|
||||
public:
|
||||
|
||||
// Resource management routines
|
||||
|
||||
/**
|
||||
* Construct an RDF resource from a single-byte URI. <tt>nsIRDFSerivce</tt>
|
||||
* caches resources that are in-use, so multiple calls to <tt>GetResource()</tt>
|
||||
* for the same <tt>uri</tt> will return identical pointers.
|
||||
*/
|
||||
NS_IMETHOD GetResource(const char* uri, nsIRDFResource** resource) = 0;
|
||||
|
||||
/**
|
||||
* Construct an RDF resource from a Unicode URI. This is provided
|
||||
* as a convenience method, allowing automatic, in-line C++
|
||||
* conversion from <tt>nsString</tt> objects. The <tt>uri</tt> will
|
||||
* be converted to a single-byte representation internally.
|
||||
*/
|
||||
NS_IMETHOD GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource) = 0;
|
||||
|
||||
/**
|
||||
* Construct an RDF literal from a Unicode string.
|
||||
*/
|
||||
NS_IMETHOD GetLiteral(const PRUnichar* value, nsIRDFLiteral** literal) = 0;
|
||||
|
||||
/**
|
||||
* Called to notify the resource manager that a resource is no
|
||||
* longer in use. This method should only be called from the
|
||||
* destructor of a "custom" resource implementation to notify the
|
||||
* RDF service that the last reference to the resource has been
|
||||
* released, so the resource is no longer valid.
|
||||
*
|
||||
* NOTE. As mentioned in nsIRDFResourceFactory::CreateResource(),
|
||||
* the RDF service will use the result of
|
||||
* nsIRDFResource::GetValue() as a key into its cache. For this
|
||||
* reason, you must always un-cache the resource <b>before</b>
|
||||
* releasing the storage for the <tt>const char*</tt> URI.
|
||||
*/
|
||||
NS_IMETHOD UnCacheResource(nsIRDFResource* resource) = 0;
|
||||
|
||||
/**
|
||||
* Registers the specified resource factory as the producer for resources that
|
||||
* have the specified <i>URI prefix</i>.
|
||||
*/
|
||||
NS_IMETHOD RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory) = 0;
|
||||
|
||||
/**
|
||||
* Unregsters the specified resource factory from producing resources that have
|
||||
* the specified <i>URI prefix</i>.
|
||||
*/
|
||||
NS_IMETHOD UnRegisterResourceFactory(const char* aURIPrefix) = 0;
|
||||
|
||||
|
||||
// Data source management routines
|
||||
|
||||
/**
|
||||
* Register a <i>named data source</i>. 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.
|
||||
*/
|
||||
NS_IMETHOD RegisterDataSource(nsIRDFDataSource* dataSource) = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
NS_IMETHOD UnregisterDataSource(nsIRDFDataSource* dataSource) = 0;
|
||||
|
||||
/**
|
||||
* Register a constructor function that will create a named data source.
|
||||
* The RDF service will call this function to attempt to create a
|
||||
* named data source.
|
||||
*/
|
||||
NS_IMETHOD RegisterDataSourceConstructor(const char* aURI, NSDataSourceConstructorCallback aFn) = 0;
|
||||
|
||||
/**
|
||||
* Unregister the constructor function for a named data source.
|
||||
*/
|
||||
NS_IMETHOD UnregisterDataSourceConstructor(const char* aURI) = 0;
|
||||
|
||||
/**
|
||||
* 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>.
|
||||
*/
|
||||
NS_IMETHOD GetDataSource(const char* uri, nsIRDFDataSource** dataSource) = 0;
|
||||
|
||||
/**
|
||||
* Create a database that contains the specified named data
|
||||
* sources. This is a convenience method whose functionality is
|
||||
* equivalent to (1) constructing a new nsIRDFDataBase object from
|
||||
* the repository, and (2) iteratively adding the named data sources
|
||||
* to it, in order.
|
||||
*/
|
||||
NS_IMETHOD CreateDatabase(const char** uris, nsIRDFDataBase** dataBase) = 0;
|
||||
|
||||
/**
|
||||
* Get the database aggregating all the stuff that Navigator sees as a default,
|
||||
* including a "local" store.
|
||||
*/
|
||||
NS_IMETHOD CreateBrowserDatabase(nsIRDFDataBase** dataBase) = 0;
|
||||
|
||||
};
|
||||
|
||||
// {BFD05261-834C-11d2-8EAC-00805F29F370}
|
||||
#define NS_IRDFSERVICE_IID \
|
||||
{ 0xbfd05261, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
extern nsresult
|
||||
NS_NewRDFService(nsIRDFService** result);
|
||||
|
||||
#endif // nsIRDFService_h__
|
||||
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
|
||||
73
mozilla/rdf/base/public/nsIRDFXMLDocument.h
Normal file
73
mozilla/rdf/base/public/nsIRDFXMLDocument.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- 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 stream data source interface.
|
||||
|
||||
*/
|
||||
|
||||
#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:
|
||||
NS_IMETHOD OnBeginLoad(void) = 0;
|
||||
NS_IMETHOD OnInterrupt(void) = 0;
|
||||
NS_IMETHOD OnResume(void) = 0;
|
||||
NS_IMETHOD OnEndLoad(void) = 0;
|
||||
|
||||
NS_IMETHOD OnRootResourceFound(nsIRDFResource* aResource) = 0;
|
||||
NS_IMETHOD OnCSSStyleSheetAdded(nsIURL* aCSSStyleSheetURL) = 0;
|
||||
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:
|
||||
NS_IMETHOD BeginLoad(void) = 0;
|
||||
NS_IMETHOD Interrupt(void) = 0;
|
||||
NS_IMETHOD Resume(void) = 0;
|
||||
NS_IMETHOD EndLoad(void) = 0;
|
||||
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* aResource) = 0;
|
||||
NS_IMETHOD GetRootResource(nsIRDFResource** aResource) = 0;
|
||||
NS_IMETHOD AddCSSStyleSheetURL(nsIURL* aStyleSheetURL) = 0;
|
||||
NS_IMETHOD GetCSSStyleSheetURLs(nsIURL*** aStyleSheetURLs, PRInt32* aCount) = 0;
|
||||
NS_IMETHOD AddNamedDataSourceURI(const char* aNamedDataSourceURI) = 0;
|
||||
NS_IMETHOD GetNamedDataSourceURIs(const char* const** aNamedDataSourceURIs, PRInt32* aCount) = 0;
|
||||
NS_IMETHOD AddDocumentObserver(nsIRDFXMLDocumentObserver* aObserver) = 0;
|
||||
NS_IMETHOD RemoveDocumentObserver(nsIRDFXMLDocumentObserver* aObserver) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsIRDFXMLDocument_h__
|
||||
|
||||
42
mozilla/rdf/base/public/nsIRDFXMLSource.h
Normal file
42
mozilla/rdf/base/public/nsIRDFXMLSource.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* -*- 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:
|
||||
NS_IMETHOD Serialize(nsIOutputStream* aStream) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIRDFXMLSource_h__
|
||||
64
mozilla/rdf/base/public/rdf.h
Normal file
64
mozilla/rdf/base/public/rdf.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* -*- 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]" and
|
||||
* "kTag[prefix]_[name]", with 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", and
|
||||
* kTagRDF_ID to be "ID"
|
||||
*/
|
||||
|
||||
#define DEFINE_RDF_VOCAB(namespace, prefix, name) \
|
||||
static const char* kURI##prefix##_##name = ##namespace #name ;\
|
||||
static const char* kTag##prefix##_##name = kURI##prefix##_##name## + sizeof(##namespace) - 1
|
||||
|
||||
|
||||
/**
|
||||
* @name Standard RDF error codes
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/* Returned from nsIRDFCursor::Advance() if the cursor has no more
|
||||
elements to enuemrate */
|
||||
#define NS_ERROR_RDF_CURSOR_EMPTY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 1)
|
||||
#define NS_ERROR_RDF_NO_VALUE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 2)
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* rdf_h___ */
|
||||
55
mozilla/rdf/base/src/Makefile.in
Normal file
55
mozilla/rdf/base/src/Makefile.in
Normal file
@@ -0,0 +1,55 @@
|
||||
#!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 = \
|
||||
nsContainerCursor.cpp \
|
||||
nsDataBase.cpp \
|
||||
nsDefaultResourceFactory.cpp \
|
||||
nsEmptyCursor.cpp \
|
||||
nsInMemoryDataSource.cpp \
|
||||
nsRDFContentSink.cpp \
|
||||
nsRDFService.cpp \
|
||||
nsStreamDataSource.cpp \
|
||||
rdfutil.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdfbase
|
||||
|
||||
REQUIRES = netlib rdf raptor xpcom
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
# we don't want the shared lib
|
||||
NO_SHARED_LIB=1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
46
mozilla/rdf/base/src/makefile.win
Normal file
46
mozilla/rdf/base/src/makefile.win
Normal file
@@ -0,0 +1,46 @@
|
||||
#!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
|
||||
LIBRARY_NAME=rdfbase_s
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsContainerCursor.obj \
|
||||
.\$(OBJDIR)\nsDataBase.obj \
|
||||
.\$(OBJDIR)\nsDefaultResourceFactory.obj \
|
||||
.\$(OBJDIR)\nsEmptyCursor.obj \
|
||||
.\$(OBJDIR)\nsInMemoryDataSource.obj \
|
||||
.\$(OBJDIR)\nsRDFContentSink.obj \
|
||||
.\$(OBJDIR)\nsRDFService.obj \
|
||||
.\$(OBJDIR)\nsStreamDataSource.obj \
|
||||
.\$(OBJDIR)\rdfutil.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\netlib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
316
mozilla/rdf/base/src/nsContainerCursor.cpp
Normal file
316
mozilla/rdf/base/src/nsContainerCursor.cpp
Normal file
@@ -0,0 +1,316 @@
|
||||
/* -*- 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.
|
||||
|
||||
2. This is sort of a continuation of (1), but -- it's not smart
|
||||
enough to notice duplicates.
|
||||
|
||||
TODO. This is way too brain dead to handle aggregated RDF
|
||||
databases. It needs to be upgraded in a big way.
|
||||
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "prlog.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define RDF_NAMESPACE_URI "http://www.w3.org/TR/WD-rdf-syntax#"
|
||||
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, nextVal); // ad hoc way to make containers fast
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ContainerCursorImpl : public nsIRDFAssertionCursor {
|
||||
private:
|
||||
nsIRDFService* mRDFService;
|
||||
nsIRDFDataSource* mDataSource;
|
||||
nsIRDFResource* mContainer;
|
||||
nsIRDFNode* mNext;
|
||||
PRInt32 mCounter;
|
||||
|
||||
public:
|
||||
ContainerCursorImpl(nsIRDFDataSource* ds, nsIRDFResource* container);
|
||||
virtual ~ContainerCursorImpl(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Advance(void);
|
||||
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource);
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject);
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue);
|
||||
};
|
||||
|
||||
ContainerCursorImpl::ContainerCursorImpl(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container)
|
||||
: mDataSource(ds), mContainer(container), mNext(nsnull), mCounter(1)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_IF_ADDREF(mDataSource);
|
||||
NS_IF_ADDREF(mContainer);
|
||||
|
||||
nsresult rv;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &mRDFService);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to acquire resource manager");
|
||||
|
||||
NS_ASSERTION(rdf_IsContainer(mDataSource, container), "not a container");
|
||||
}
|
||||
|
||||
|
||||
ContainerCursorImpl::~ContainerCursorImpl(void)
|
||||
{
|
||||
NS_IF_RELEASE(mNext);
|
||||
|
||||
if (mRDFService)
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||
|
||||
NS_IF_RELEASE(mContainer);
|
||||
NS_IF_RELEASE(mDataSource);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(ContainerCursorImpl);
|
||||
NS_IMPL_RELEASE(ContainerCursorImpl);
|
||||
|
||||
NS_IMETHODIMP_(nsresult)
|
||||
ContainerCursorImpl::QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFAssertionCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::Advance(void)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// release the last value that we were holding
|
||||
NS_IF_RELEASE(mNext);
|
||||
|
||||
nsIRDFResource* RDF_nextVal = nsnull;
|
||||
nsIRDFNode* nextNode = nsnull;
|
||||
nsIRDFLiteral* nextVal = nsnull;
|
||||
const PRUnichar* p;
|
||||
nsAutoString s;
|
||||
PRInt32 last;
|
||||
PRInt32 err;
|
||||
|
||||
// XXX we could cache all this crap when the cursor gets created.
|
||||
if (NS_FAILED(rv = mRDFService->GetResource(kURIRDF_nextVal, &RDF_nextVal)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = mDataSource->GetTarget(mContainer, RDF_nextVal, PR_TRUE, &nextNode)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nextNode->QueryInterface(kIRDFLiteralIID, (void**) &nextVal)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nextVal->GetValue(&p)))
|
||||
goto done;
|
||||
|
||||
s = p;
|
||||
last = s.ToInteger(&err);
|
||||
if (NS_FAILED(err))
|
||||
goto done;
|
||||
|
||||
// initialize rv to the case where mCounter has advanced past the
|
||||
// last element
|
||||
rv = NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
|
||||
while (mCounter < last) {
|
||||
nsIRDFResource* ordinalProperty = nsnull;
|
||||
if (NS_FAILED(rv = GetPredicate(&ordinalProperty)))
|
||||
break;
|
||||
|
||||
rv = mDataSource->GetTarget(mContainer, ordinalProperty, PR_TRUE, &mNext);
|
||||
NS_IF_RELEASE(ordinalProperty);
|
||||
|
||||
++mCounter;
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Don't bother releasing mNext; we'll let the AddRef
|
||||
// serve as the implicit addref that GetNext() should
|
||||
// perform.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(nextNode);
|
||||
NS_IF_RELEASE(nextVal);
|
||||
NS_IF_RELEASE(RDF_nextVal);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetDataSource(nsIRDFDataSource** aDataSource)
|
||||
{
|
||||
NS_PRECONDITION(aDataSource != nsnull, "null ptr");
|
||||
if (! aDataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ADDREF(mDataSource);
|
||||
*aDataSource = mDataSource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetSubject(nsIRDFResource** aSubject)
|
||||
{
|
||||
NS_PRECONDITION(aSubject != nsnull, "null ptr");
|
||||
if (! aSubject)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ADDREF(mContainer);
|
||||
*aSubject = mContainer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetPredicate(nsIRDFResource** aPredicate)
|
||||
{
|
||||
NS_PRECONDITION(aPredicate != nsnull, "null ptr");
|
||||
|
||||
nsAutoString s(kRDFNameSpaceURI);
|
||||
s.Append("_");
|
||||
s.Append(mCounter, 10);
|
||||
|
||||
// this'll AddRef(), null check, etc.
|
||||
return mRDFService->GetUnicodeResource(s, aPredicate);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetObject(nsIRDFNode** aObject)
|
||||
{
|
||||
NS_PRECONDITION(aObject != nsnull, "null ptr");
|
||||
if (! aObject)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! mNext)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
NS_ADDREF(mNext);
|
||||
*aObject = mNext;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetValue(nsIRDFNode** aObject)
|
||||
{
|
||||
NS_PRECONDITION(aObject != nsnull, "null ptr");
|
||||
if (! aObject)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! mNext)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
NS_ADDREF(mNext);
|
||||
*aObject = mNext;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetTruthValue(PRBool* aTruthValue)
|
||||
{
|
||||
NS_PRECONDITION(aTruthValue != nsnull, "null ptr");
|
||||
if (! aTruthValue)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aTruthValue = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewContainerCursor(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container,
|
||||
nsIRDFAssertionCursor** cursor)
|
||||
{
|
||||
NS_PRECONDITION(ds != nsnull, "null ptr");
|
||||
NS_PRECONDITION(container != nsnull, "null ptr");
|
||||
NS_PRECONDITION(cursor != nsnull, "null ptr");
|
||||
|
||||
if (!ds || !container || !cursor)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
ContainerCursorImpl* result = new ContainerCursorImpl(ds, container);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*cursor = result;
|
||||
NS_ADDREF(result);
|
||||
return NS_OK;
|
||||
}
|
||||
853
mozilla/rdf/base/src/nsDataBase.cpp
Normal file
853
mozilla/rdf/base/src/nsDataBase.cpp
Normal file
@@ -0,0 +1,853 @@
|
||||
/* -*- 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 "database" implementation. An RDF database is just a
|
||||
strategy for combining individual data sources into a collective
|
||||
graph.
|
||||
|
||||
|
||||
1) A database is a sequence of data sources. The set of data sources
|
||||
can be specified during creation of the database. Data sources
|
||||
can also be added/deleted from a database later.
|
||||
|
||||
2) The aggregation mechanism is based on simple super-positioning of
|
||||
the graphs from the datasources. If there is a conflict (i.e.,
|
||||
data source A has a true arc from foo to bar while data source B
|
||||
has a false arc from foo to bar), the data source that it earlier
|
||||
in the sequence wins.
|
||||
|
||||
The implementation below doesn't really do this and needs to be
|
||||
fixed.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFDataBase.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "prlog.h"
|
||||
|
||||
static NS_DEFINE_IID(kIRDFArcsInCursorIID, NS_IRDFARCSINCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFArcsOutCursorIID, NS_IRDFARCSOUTCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
|
||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// DataBase
|
||||
|
||||
class DataBase : public nsIRDFDataBase,
|
||||
public nsIRDFObserver
|
||||
{
|
||||
protected:
|
||||
nsVoidArray* mObservers;
|
||||
|
||||
virtual ~DataBase(void);
|
||||
|
||||
public:
|
||||
DataBase(void);
|
||||
DataBase(char** dataSources);
|
||||
|
||||
nsVoidArray mDataSources;
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFDataSource interface
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(const char* *uri) const;
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source);
|
||||
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** sources);
|
||||
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target);
|
||||
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets);
|
||||
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv);
|
||||
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target);
|
||||
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion);
|
||||
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n);
|
||||
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n);
|
||||
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels);
|
||||
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels);
|
||||
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult);
|
||||
|
||||
NS_IMETHOD DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget);
|
||||
|
||||
|
||||
// nsIRDFDataBase interface
|
||||
NS_IMETHOD AddDataSource(nsIRDFDataSource* source);
|
||||
NS_IMETHOD RemoveDataSource(nsIRDFDataSource* source);
|
||||
|
||||
// nsIRDFObserver interface
|
||||
NS_IMETHOD OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object);
|
||||
|
||||
NS_IMETHOD OnUnassert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object);
|
||||
|
||||
// Implementation methods
|
||||
PRBool HasAssertionN(int n, nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DBArcsInOutCursor : public nsIRDFArcsOutCursor,
|
||||
public nsIRDFArcsInCursor
|
||||
{
|
||||
DataBase* mDataBase;
|
||||
nsIRDFResource* mSource;
|
||||
nsIRDFNode* mTarget;
|
||||
PRInt32 mCount;
|
||||
nsIRDFArcsOutCursor* mOutCursor;
|
||||
nsIRDFArcsInCursor* mInCursor;
|
||||
nsVoidArray mResults;
|
||||
|
||||
public:
|
||||
DBArcsInOutCursor(DataBase* db, nsIRDFNode* node, PRBool arcsOutp);
|
||||
|
||||
virtual ~DBArcsInOutCursor();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Advance();
|
||||
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return (mInCursor ? mInCursor->GetDataSource(aDataSource) :
|
||||
mOutCursor->GetDataSource(aDataSource));
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource) {
|
||||
return mOutCursor->GetSubject(aResource);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aNode) {
|
||||
return mInCursor->GetObject(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return (mInCursor ? mInCursor->GetPredicate(aPredicate) :
|
||||
mOutCursor->GetPredicate(aPredicate));
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return (mInCursor ? mInCursor->GetValue(aValue) :
|
||||
mOutCursor->GetValue(aValue));
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
DBArcsInOutCursor::DBArcsInOutCursor (DataBase* db, nsIRDFNode* node, PRBool arcsOutp)
|
||||
: mDataBase(db),
|
||||
mTarget(0),
|
||||
mSource(0),
|
||||
mCount(0),
|
||||
mInCursor(0),
|
||||
mOutCursor(0)
|
||||
{
|
||||
if (arcsOutp) {
|
||||
mSource = (nsIRDFResource*) node;
|
||||
} else {
|
||||
mTarget = node;
|
||||
}
|
||||
NS_IF_ADDREF(node);
|
||||
|
||||
// XXX there better be at least _one_ datasource in this here
|
||||
// database, else this'll be a real short ride...
|
||||
PR_ASSERT(db->mDataSources.Count() > 0);
|
||||
nsIRDFDataSource* ds = (nsIRDFDataSource*) db->mDataSources[mCount++];
|
||||
|
||||
if (mTarget) {
|
||||
ds->ArcLabelsIn(mTarget, &mInCursor);
|
||||
} else {
|
||||
ds->ArcLabelsOut(mSource, &mOutCursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DBArcsInOutCursor::~DBArcsInOutCursor(void)
|
||||
{
|
||||
for (PRInt32 i = mResults.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFNode* node = (nsIRDFNode*) mResults[i];
|
||||
NS_RELEASE(node);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mSource);
|
||||
NS_IF_RELEASE(mTarget);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(DBArcsInOutCursor);
|
||||
NS_IMPL_RELEASE(DBArcsInOutCursor);
|
||||
|
||||
NS_IMETHODIMP_(nsresult)
|
||||
DBArcsInOutCursor::QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFArcsOutCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFArcsOutCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DBArcsInOutCursor::Advance(void)
|
||||
{
|
||||
nsIRDFDataSource* ds;
|
||||
while (mInCursor || mOutCursor) {
|
||||
nsresult result = (mInCursor ? mInCursor->Advance() : mOutCursor->Advance());
|
||||
|
||||
while (NS_SUCCEEDED(result)) {
|
||||
nsIRDFNode* obj ;
|
||||
GetValue(&obj);
|
||||
if (mResults.IndexOf(obj) < 0) {
|
||||
mResults.AppendElement(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
result = (mInCursor ? mInCursor->Advance() : mOutCursor->Advance());
|
||||
}
|
||||
|
||||
if (result != NS_ERROR_RDF_CURSOR_EMPTY)
|
||||
return result;
|
||||
|
||||
NS_IF_RELEASE(mInCursor);
|
||||
NS_IF_RELEASE(mOutCursor);
|
||||
|
||||
if (mCount >= mDataBase->mDataSources.Count())
|
||||
break;
|
||||
|
||||
ds = (nsIRDFDataSource*) mDataBase->mDataSources[mCount];
|
||||
++mCount;
|
||||
|
||||
if (mTarget) {
|
||||
ds->ArcLabelsIn(mTarget, &mInCursor);
|
||||
} else {
|
||||
ds->ArcLabelsOut(mSource, &mOutCursor);
|
||||
}
|
||||
}
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// DBAssertionCursor
|
||||
//
|
||||
// An assertion cursor implementation for the db.
|
||||
//
|
||||
class DBGetSTCursor : public nsIRDFAssertionCursor
|
||||
{
|
||||
private:
|
||||
DataBase* mDataBase;
|
||||
nsIRDFResource* mSource;
|
||||
nsIRDFResource* mLabel;
|
||||
nsIRDFNode* mTarget;
|
||||
PRInt32 mCount;
|
||||
PRBool mTruthValue;
|
||||
nsIRDFAssertionCursor* mCurrentCursor;
|
||||
|
||||
public:
|
||||
DBGetSTCursor(DataBase* db, nsIRDFNode* u,
|
||||
nsIRDFResource* property, PRBool inversep, PRBool tv);
|
||||
|
||||
virtual ~DBGetSTCursor();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFAssertionCursor interface
|
||||
NS_IMETHOD Advance();
|
||||
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return mCurrentCursor->GetDataSource(aDataSource);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource) {
|
||||
return mCurrentCursor->GetSubject(aResource);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return mCurrentCursor->GetPredicate(aPredicate);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject) {
|
||||
return mCurrentCursor->GetObject(aObject);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||
return mCurrentCursor->GetTruthValue(aTruthValue);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return mCurrentCursor->GetValue(aValue);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//NS_IMPL_ISUPPORTS(DBGetSTCursor, kIRDFAssertionCursorIID);
|
||||
|
||||
DBGetSTCursor::DBGetSTCursor (DataBase* db, nsIRDFNode* u,
|
||||
nsIRDFResource* property, PRBool inversep,
|
||||
PRBool tv)
|
||||
: mDataBase(db),
|
||||
mSource(nsnull),
|
||||
mLabel(property),
|
||||
mTarget(nsnull),
|
||||
mCount(0),
|
||||
mTruthValue(tv)
|
||||
{
|
||||
if (!inversep) {
|
||||
mSource = (nsIRDFResource*) u;
|
||||
} else {
|
||||
mTarget = u;
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(mSource);
|
||||
NS_IF_ADDREF(mTarget);
|
||||
NS_IF_ADDREF(mLabel);
|
||||
|
||||
// XXX assume that at least one data source exists in the database.
|
||||
nsIRDFDataSource* ds = (nsIRDFDataSource*) db->mDataSources[mCount++];
|
||||
if (mSource)
|
||||
ds->GetTargets(mSource, mLabel, mTruthValue, &mCurrentCursor);
|
||||
else
|
||||
ds->GetSources(mLabel, mTarget, mTruthValue, &mCurrentCursor);
|
||||
}
|
||||
|
||||
|
||||
DBGetSTCursor::~DBGetSTCursor(void)
|
||||
{
|
||||
NS_IF_RELEASE(mLabel);
|
||||
NS_IF_RELEASE(mSource);
|
||||
NS_IF_ADDREF(mTarget);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(DBGetSTCursor);
|
||||
NS_IMPL_RELEASE(DBGetSTCursor);
|
||||
|
||||
NS_IMETHODIMP_(nsresult)
|
||||
DBGetSTCursor::QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFAssertionCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DBGetSTCursor::Advance(void)
|
||||
{
|
||||
nsIRDFDataSource* ds;
|
||||
while (mCurrentCursor) {
|
||||
nsresult result = mCurrentCursor->Advance();
|
||||
while (NS_ERROR_RDF_CURSOR_EMPTY != result) {
|
||||
nsIRDFResource* src;
|
||||
nsIRDFNode* trg;
|
||||
mCurrentCursor->GetSubject(&src);
|
||||
mCurrentCursor->GetObject(&trg);
|
||||
if (!mDataBase->HasAssertionN(mCount-1, src, mLabel, trg, !mTruthValue)) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
result = mCurrentCursor->Advance();
|
||||
}
|
||||
}
|
||||
|
||||
if (mCount >= mDataBase->mDataSources.Count())
|
||||
break;
|
||||
|
||||
ds = (nsIRDFDataSource*) mDataBase->mDataSources[mCount];
|
||||
++mCount;
|
||||
|
||||
if (mSource)
|
||||
ds->GetTargets(mSource, mLabel, mTruthValue, &mCurrentCursor);
|
||||
else
|
||||
ds->GetSources(mLabel, mTarget, mTruthValue, &mCurrentCursor);
|
||||
}
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
DataBase::DataBase(void)
|
||||
: mObservers(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
DataBase::~DataBase(void)
|
||||
{
|
||||
for (PRInt32 i = mDataSources.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
ds->RemoveObserver(this);
|
||||
NS_IF_RELEASE(ds);
|
||||
}
|
||||
delete mObservers;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(DataBase);
|
||||
NS_IMPL_RELEASE(DataBase);
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFDataBaseIID) ||
|
||||
iid.Equals(kIRDFDataSourceIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFDataBase*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(kIRDFObserverIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
*result = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFDataSource interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::Init(const char* uri)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_UNEXPECTED; // XXX database doesn't have a URI?
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::GetURI(const char* *uri) const
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_UNEXPECTED; // XXX database doesn't have a URI?
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source)
|
||||
{
|
||||
PRInt32 count = mDataSources.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
|
||||
if (NS_FAILED(ds->GetSource(property, target, tv, source)))
|
||||
continue;
|
||||
|
||||
// okay, found it. make sure we don't have the opposite
|
||||
// asserted in a more local data source
|
||||
if (!HasAssertionN(count-1, *source, property, target, !tv))
|
||||
return NS_OK;
|
||||
|
||||
NS_RELEASE(*source);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = new DBGetSTCursor(this, target, property, 1, tv);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target)
|
||||
{
|
||||
PRInt32 count = mDataSources.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
|
||||
if (NS_FAILED(ds->GetTarget(source, property, tv, target)))
|
||||
continue;
|
||||
|
||||
// okay, found it. make sure we don't have the opposite
|
||||
// asserted in the "local" data source
|
||||
if (!HasAssertionN(count-1, source, property, *target, !tv))
|
||||
return NS_OK;
|
||||
|
||||
|
||||
NS_RELEASE(*target);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
DataBase::HasAssertionN (int n, nsIRDFResource* source,
|
||||
nsIRDFResource* property, nsIRDFNode* target, PRBool tv) {
|
||||
int m = 0;
|
||||
PRBool result = 0;
|
||||
while (m < n) {
|
||||
nsIRDFDataSource* ds = (nsIRDFDataSource*) mDataSources[m];
|
||||
ds->HasAssertion(source, property, target, tv, &result);
|
||||
if (result) return 1;
|
||||
m++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets)
|
||||
{
|
||||
if (! targets)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIRDFAssertionCursor* result;
|
||||
result = new DBGetSTCursor(this, source, property, 0, tv);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*targets = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv)
|
||||
{
|
||||
// Need to add back the stuff for unblocking ...
|
||||
for (PRInt32 i = mDataSources.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
if (NS_SUCCEEDED(ds->Assert(source, property, target, tv)))
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 count = mDataSources.Count();
|
||||
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
if (NS_FAILED(rv = ds->Unassert(source, property, target)))
|
||||
break;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsIRDFDataSource* ds0 = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[0]);
|
||||
rv = ds0->Assert(source, property, target, PR_FALSE);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
||||
// Otherwise, look through all the data sources to see if anyone
|
||||
// has the positive...
|
||||
PRInt32 count = mDataSources.Count();
|
||||
PRBool hasNegation = 0;
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
if (NS_FAILED(rv = ds->HasAssertion(source, property, target, tv, hasAssertion)))
|
||||
return rv;
|
||||
|
||||
if (*hasAssertion)
|
||||
return NS_OK;
|
||||
|
||||
if (NS_FAILED(rv = ds->HasAssertion(source, property, target, !tv, &hasNegation)))
|
||||
return rv;
|
||||
|
||||
if (hasNegation) {
|
||||
*hasAssertion = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, nobody had the assertion at all
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::AddObserver(nsIRDFObserver* obs)
|
||||
{
|
||||
if (!mObservers) {
|
||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// XXX ensure uniqueness
|
||||
|
||||
mObservers->AppendElement(obs);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::RemoveObserver(nsIRDFObserver* obs)
|
||||
{
|
||||
if (!mObservers)
|
||||
return NS_OK;
|
||||
|
||||
mObservers->RemoveElement(obs);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels)
|
||||
{
|
||||
if (! labels)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIRDFArcsInCursor* result = new DBArcsInOutCursor(this, node, 0);
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*labels = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels)
|
||||
{
|
||||
if (! labels)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIRDFArcsOutCursor* result = new DBArcsInOutCursor(this, source, 1);
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*labels = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::Flush()
|
||||
{
|
||||
for (PRInt32 i = mDataSources.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
ds->Flush();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFDataBase methods
|
||||
// XXX rvg We should make this take an additional argument specifying where
|
||||
// in the sequence of data sources (of the db), the new data source should
|
||||
// fit in. Right now, the new datasource gets stuck at the end.
|
||||
// need to add the observers of the database to the new data source.
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::AddDataSource(nsIRDFDataSource* source)
|
||||
{
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mDataSources.InsertElementAt(source, 0);
|
||||
source->AddObserver(this);
|
||||
NS_ADDREF(source);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::RemoveDataSource(nsIRDFDataSource* source)
|
||||
{
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
||||
if (mDataSources.IndexOf(source) >= 0) {
|
||||
mDataSources.RemoveElement(source);
|
||||
source->RemoveObserver(this);
|
||||
NS_RELEASE(source);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
if (mObservers) {
|
||||
for (PRInt32 i = mObservers->Count() - 1; i >= 0; --i) {
|
||||
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
||||
obs->OnAssert(subject, predicate, object);
|
||||
// XXX ignore return value?
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataBase::OnUnassert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
if (mObservers) {
|
||||
for (PRInt32 i = mObservers->Count() - 1; i >= 0; --i) {
|
||||
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
||||
obs->OnUnassert(subject, predicate, object);
|
||||
// XXX ignore return value?
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFDataBase(nsIRDFDataBase** result)
|
||||
{
|
||||
DataBase* db = new DataBase();
|
||||
if (! db)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*result = db;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
229
mozilla/rdf/base/src/nsDefaultResourceFactory.cpp
Normal file
229
mozilla/rdf/base/src/nsDefaultResourceFactory.cpp
Normal file
@@ -0,0 +1,229 @@
|
||||
/* -*- 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 "nsIRDFNode.h"
|
||||
#include "nsIRDFResourceFactory.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "plstr.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIRDFNodeIID, NS_IRDFNODE_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceFactoryIID, NS_IRDFRESOURCEFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class DefaultResourceImpl : public nsIRDFResource
|
||||
{
|
||||
public:
|
||||
DefaultResourceImpl(const char* uri);
|
||||
virtual ~DefaultResourceImpl(void);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFNode
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const;
|
||||
|
||||
// nsIRDFResource
|
||||
NS_IMETHOD GetValue(const char* *uri) const;
|
||||
NS_IMETHOD EqualsResource(const nsIRDFResource* resource, PRBool* result) const;
|
||||
NS_IMETHOD EqualsString(const char* uri, PRBool* result) const;
|
||||
|
||||
// Implementation methods
|
||||
const char* GetURI(void) const {
|
||||
return mURI;
|
||||
}
|
||||
|
||||
private:
|
||||
char* mURI;
|
||||
};
|
||||
|
||||
|
||||
DefaultResourceImpl::DefaultResourceImpl(const char* uri)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mURI = PL_strdup(uri);
|
||||
}
|
||||
|
||||
|
||||
DefaultResourceImpl::~DefaultResourceImpl(void)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsIRDFService* mgr;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &mgr);
|
||||
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mgr->UnCacheResource(this);
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
|
||||
}
|
||||
|
||||
// N.B. that we need to free the URI *after* we un-cache the resource,
|
||||
// due to the way that the resource manager is implemented.
|
||||
PL_strfree(mURI);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(DefaultResourceImpl);
|
||||
NS_IMPL_RELEASE(DefaultResourceImpl);
|
||||
|
||||
nsresult
|
||||
DefaultResourceImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(kIRDFResourceIID) ||
|
||||
iid.Equals(kIRDFNodeIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFResource*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DefaultResourceImpl::EqualsNode(nsIRDFNode* node, PRBool* result) const
|
||||
{
|
||||
nsresult rv;
|
||||
nsIRDFResource* resource;
|
||||
if (NS_SUCCEEDED(node->QueryInterface(kIRDFResourceIID, (void**) &resource))) {
|
||||
rv = EqualsResource(resource, result);
|
||||
NS_RELEASE(resource);
|
||||
}
|
||||
else {
|
||||
*result = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DefaultResourceImpl::GetValue(const char* *uri) const
|
||||
{
|
||||
if (!uri)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*uri = mURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DefaultResourceImpl::EqualsResource(const nsIRDFResource* resource, PRBool* result) const
|
||||
{
|
||||
if (!resource || !result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = (resource == this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
DefaultResourceImpl::EqualsString(const char* uri, PRBool* result) const
|
||||
{
|
||||
if (!uri || !result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = (PL_strcmp(uri, mURI) == 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class DefaultResourceFactoryImpl : public nsIRDFResourceFactory
|
||||
{
|
||||
public:
|
||||
DefaultResourceFactoryImpl(void);
|
||||
virtual ~DefaultResourceFactoryImpl(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult);
|
||||
};
|
||||
|
||||
|
||||
DefaultResourceFactoryImpl::DefaultResourceFactoryImpl(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
DefaultResourceFactoryImpl::~DefaultResourceFactoryImpl(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(DefaultResourceFactoryImpl, kIRDFResourceFactoryIID);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
DefaultResourceFactoryImpl::CreateResource(const char* aURI, nsIRDFResource** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
DefaultResourceImpl* resource = new DefaultResourceImpl(aURI);
|
||||
if (! resource)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(resource);
|
||||
*aResult = resource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFDefaultResourceFactory(nsIRDFResourceFactory** result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
DefaultResourceFactoryImpl* factory = new DefaultResourceFactoryImpl();
|
||||
if (! factory)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(factory);
|
||||
*result = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
240
mozilla/rdf/base/src/nsEmptyCursor.cpp
Normal file
240
mozilla/rdf/base/src/nsEmptyCursor.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
/* -*- 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 set of "empty cursors" (nsIRDFAssertionCursor,
|
||||
nsIRDFArcsOutCursor, nsIRDFArcsInCursor) that can be used to ensure
|
||||
that the data source methods which return a cursor always return
|
||||
*something*.
|
||||
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
|
||||
static NS_DEFINE_IID(kIRDFArcsInCursorIID, NS_IRDFARCSINCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFArcsOutCursorIID, NS_IRDFARCSOUTCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EmptyAssertionCursorImpl : public nsIRDFAssertionCursor
|
||||
{
|
||||
public:
|
||||
EmptyAssertionCursorImpl(void) {};
|
||||
virtual ~EmptyAssertionCursorImpl(void) {};
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFAssertionCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// nsIRDFCursor
|
||||
NS_IMETHOD Advance(void) {
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
// nsIRDFAssertionCursor
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewEmptyRDFAssertionCursor(nsIRDFAssertionCursor** result)
|
||||
{
|
||||
static EmptyAssertionCursorImpl gEmptyAssertionCursor;
|
||||
*result = &gEmptyAssertionCursor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EmptyArcsOutCursorImpl : public nsIRDFArcsOutCursor
|
||||
{
|
||||
public:
|
||||
EmptyArcsOutCursorImpl(void) {};
|
||||
virtual ~EmptyArcsOutCursorImpl(void) {};
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFArcsOutCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFArcsOutCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// nsIRDFCursor
|
||||
NS_IMETHOD Advance(void) {
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
// nsIRDFArcsOutCursor
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewEmptyRDFArcsOutCursor(nsIRDFArcsOutCursor** result)
|
||||
{
|
||||
static EmptyArcsOutCursorImpl gEmptyArcsOutCursor;
|
||||
*result = &gEmptyArcsOutCursor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EmptyArcsInCursorImpl : public nsIRDFArcsInCursor
|
||||
{
|
||||
public:
|
||||
EmptyArcsInCursorImpl(void) {};
|
||||
virtual ~EmptyArcsInCursorImpl(void) {};
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFArcsInCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFArcsInCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// nsIRDFCursor
|
||||
NS_IMETHOD Advance(void) {
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
// nsIRDFArcsInCursor
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aNode) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewEmptyRDFArcsInCursor(nsIRDFArcsInCursor** result)
|
||||
{
|
||||
static EmptyArcsInCursorImpl gEmptyArcsInCursor;
|
||||
*result = &gEmptyArcsInCursor;
|
||||
return NS_OK;
|
||||
}
|
||||
1404
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
Normal file
1404
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
Normal file
File diff suppressed because it is too large
Load Diff
44
mozilla/rdf/base/src/nsRDFBaseDataSources.h
Normal file
44
mozilla/rdf/base/src/nsRDFBaseDataSources.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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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;
|
||||
class nsIRDFDataBase;
|
||||
|
||||
// in nsInMemoryDataSource.cpp
|
||||
nsresult NS_NewRDFInMemoryDataSource(nsIRDFDataSource** result);
|
||||
|
||||
// in nsDataBase.cpp
|
||||
nsresult NS_NewRDFDataBase(nsIRDFDataBase** result);
|
||||
|
||||
#endif // nsBaseDataSources_h__
|
||||
|
||||
|
||||
1522
mozilla/rdf/base/src/nsRDFContentSink.cpp
Normal file
1522
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__
|
||||
755
mozilla/rdf/base/src/nsRDFService.cpp
Normal file
755
mozilla/rdf/base/src/nsRDFService.cpp
Normal file
@@ -0,0 +1,755 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file provides the implementation for the RDF service manager.
|
||||
|
||||
TO DO
|
||||
-----
|
||||
|
||||
1) Figure out a better way to do "pluggable resources." Currently,
|
||||
we have two _major_ hacks:
|
||||
|
||||
RegisterBuiltInNamedDataSources()
|
||||
RegisterBuiltInResourceFactories()
|
||||
|
||||
These introduce dependencies on the datasource directory. You'd
|
||||
like to have this stuff discovered dynamically at startup or
|
||||
something. Maybe from the registry.
|
||||
|
||||
2) Implement the CreateDataBase() methods.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFResourceFactory.h"
|
||||
#include "nsString.h"
|
||||
#include "plhash.h"
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFNodeIID, NS_IRDFNODE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// PrefixMap
|
||||
//
|
||||
// A simple map from a string prefix to a value. It maintains an
|
||||
// ordered list of prefixes that map to a <tt>void*</tt>. The list
|
||||
// is sorted in ASCII order such that if one prefix <b>p</b> is
|
||||
// itself a prefix of another prefix <b>q</b>, the longest prefix
|
||||
// (<b>q</b>) will appear first in the list. The idea is that you
|
||||
// want to find the "best" match first. (Will this actually be
|
||||
// useful? Probabably not...)
|
||||
//
|
||||
class PrefixMap
|
||||
{
|
||||
private:
|
||||
struct PrefixMapEntry
|
||||
{
|
||||
const char* mPrefix;
|
||||
PRInt32 mPrefixLen;
|
||||
const void* mValue;
|
||||
PrefixMapEntry* mNext;
|
||||
};
|
||||
|
||||
PrefixMapEntry* mHead;
|
||||
|
||||
public:
|
||||
PrefixMap();
|
||||
~PrefixMap();
|
||||
|
||||
PRBool Add(const char* aPrefix, const void* aValue);
|
||||
const void* Remove(const char* aPrefix);
|
||||
|
||||
/**
|
||||
* Find the most specific value matching the specified string.
|
||||
*/
|
||||
const void* Find(const char* aString);
|
||||
};
|
||||
|
||||
|
||||
PrefixMap::PrefixMap()
|
||||
: mHead(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
PrefixMap::~PrefixMap()
|
||||
{
|
||||
while (mHead) {
|
||||
PrefixMapEntry* doomed = mHead;
|
||||
mHead = mHead->mNext;
|
||||
PL_strfree(NS_CONST_CAST(char*, doomed->mPrefix));
|
||||
delete doomed;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
PrefixMap::Add(const char* aPrefix, const void* aValue)
|
||||
{
|
||||
PRInt32 newPrefixLen = PL_strlen(aPrefix);
|
||||
PrefixMapEntry* entry = mHead;
|
||||
PrefixMapEntry* last = nsnull;
|
||||
|
||||
while (entry != nsnull) {
|
||||
// check to see if the new prefix is longer than the current
|
||||
// entry. If so, we'll want to insert the new prefix *before*
|
||||
// this one.
|
||||
if (newPrefixLen > entry->mPrefixLen)
|
||||
break;
|
||||
|
||||
// check for exact equality: if so, the prefix is already
|
||||
// registered, so fail (?)
|
||||
if (PL_strcmp(entry->mPrefix, aPrefix) == 0)
|
||||
return PR_FALSE;
|
||||
|
||||
// otherwise, the new prefix is the same length or shorter
|
||||
// than the current entry: continue on to the next one.
|
||||
|
||||
last = entry;
|
||||
entry = entry->mNext;
|
||||
}
|
||||
|
||||
PrefixMapEntry* newEntry = new PrefixMapEntry;
|
||||
if (! newEntry)
|
||||
return PR_FALSE;
|
||||
|
||||
|
||||
newEntry->mPrefix = PL_strdup(aPrefix);
|
||||
newEntry->mPrefixLen = newPrefixLen;
|
||||
newEntry->mValue = aValue;
|
||||
|
||||
if (last) {
|
||||
// we found an entry that we need to insert the current
|
||||
// entry *before*
|
||||
newEntry->mNext = last->mNext;
|
||||
last->mNext = newEntry;
|
||||
}
|
||||
else {
|
||||
// Otherwise, insert at the start
|
||||
newEntry->mNext = mHead;
|
||||
mHead = newEntry;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
const void*
|
||||
PrefixMap::Remove(const char* aPrefix)
|
||||
{
|
||||
PrefixMapEntry* entry = mHead;
|
||||
PrefixMapEntry* last = nsnull;
|
||||
|
||||
PRInt32 doomedPrefixLen = PL_strlen(aPrefix);
|
||||
|
||||
while (entry != nsnull) {
|
||||
if ((doomedPrefixLen == entry->mPrefixLen) &&
|
||||
(PL_strcmp(entry->mPrefix, aPrefix) == 0)) {
|
||||
if (last) {
|
||||
last->mNext = entry->mNext;
|
||||
}
|
||||
else {
|
||||
mHead = entry->mNext;
|
||||
}
|
||||
|
||||
const void* value = entry->mValue;
|
||||
|
||||
PL_strfree(NS_CONST_CAST(char*, entry->mPrefix));
|
||||
delete entry;
|
||||
|
||||
return value;
|
||||
}
|
||||
last = entry;
|
||||
entry = entry->mNext;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
const void*
|
||||
PrefixMap::Find(const char* aString)
|
||||
{
|
||||
for (PrefixMapEntry* entry = mHead; entry != nsnull; entry = entry->mNext) {
|
||||
PRInt32 cmp = PL_strncmp(entry->mPrefix, aString, entry->mPrefixLen);
|
||||
if (cmp == 0)
|
||||
return entry->mValue;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// LiteralImpl
|
||||
//
|
||||
// Currently, all literals are implemented exactly the same way;
|
||||
// i.e., there is are no resource factories to allow you to generate
|
||||
// customer resources. I doubt that makes sense, anyway.
|
||||
//
|
||||
// What _may_ make sense is to atomize literals (well, at least
|
||||
// short ones), to reduce in memory overhead at the expense of some
|
||||
// processing time.
|
||||
//
|
||||
class LiteralImpl : public nsIRDFLiteral {
|
||||
public:
|
||||
LiteralImpl(const PRUnichar* s);
|
||||
virtual ~LiteralImpl(void);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFNode
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const;
|
||||
|
||||
// nsIRDFLiteral
|
||||
NS_IMETHOD GetValue(const PRUnichar* *value) const;
|
||||
NS_IMETHOD EqualsLiteral(const nsIRDFLiteral* literal, PRBool* result) const;
|
||||
|
||||
private:
|
||||
nsAutoString mValue;
|
||||
};
|
||||
|
||||
|
||||
LiteralImpl::LiteralImpl(const PRUnichar* s)
|
||||
: mValue(s)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
LiteralImpl::~LiteralImpl(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(LiteralImpl);
|
||||
NS_IMPL_RELEASE(LiteralImpl);
|
||||
|
||||
nsresult
|
||||
LiteralImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(kIRDFLiteralIID) ||
|
||||
iid.Equals(kIRDFNodeIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFLiteral*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LiteralImpl::EqualsNode(nsIRDFNode* node, PRBool* result) const
|
||||
{
|
||||
nsresult rv;
|
||||
nsIRDFLiteral* literal;
|
||||
if (NS_SUCCEEDED(node->QueryInterface(kIRDFLiteralIID, (void**) &literal))) {
|
||||
rv = EqualsLiteral(literal, result);
|
||||
NS_RELEASE(literal);
|
||||
}
|
||||
else {
|
||||
*result = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LiteralImpl::GetValue(const PRUnichar* *value) const
|
||||
{
|
||||
NS_ASSERTION(value, "null ptr");
|
||||
if (! value)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*value = mValue.GetUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
LiteralImpl::EqualsLiteral(const nsIRDFLiteral* literal, PRBool* result) const
|
||||
{
|
||||
NS_ASSERTION(literal && result, "null ptr");
|
||||
if (!literal || !result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
const PRUnichar* p;
|
||||
if (NS_FAILED(rv = literal->GetValue(&p)))
|
||||
return rv;
|
||||
|
||||
nsAutoString s(p);
|
||||
|
||||
*result = s.Equals(mValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ServiceImpl
|
||||
//
|
||||
// This is the RDF service.
|
||||
//
|
||||
class ServiceImpl : public nsIRDFService
|
||||
{
|
||||
protected:
|
||||
PrefixMap mResourceFactories;
|
||||
PLHashTable* mNamedDataSources;
|
||||
PLHashTable* mDataSourceConstructors;
|
||||
PLHashTable* mResources;
|
||||
|
||||
ServiceImpl(void);
|
||||
virtual ~ServiceImpl(void);
|
||||
|
||||
static nsIRDFService* gRDFService; // The one-and-only RDF service
|
||||
|
||||
static void RegisterBuiltInResourceFactories();
|
||||
static void RegisterBuiltInNamedDataSources();
|
||||
|
||||
public:
|
||||
|
||||
static nsresult GetRDFService(nsIRDFService** result);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFService
|
||||
NS_IMETHOD GetResource(const char* uri, nsIRDFResource** resource);
|
||||
NS_IMETHOD GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource);
|
||||
NS_IMETHOD GetLiteral(const PRUnichar* value, nsIRDFLiteral** literal);
|
||||
NS_IMETHOD UnCacheResource(nsIRDFResource* resource);
|
||||
|
||||
NS_IMETHOD RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory);
|
||||
NS_IMETHOD UnRegisterResourceFactory(const char* aURIPrefix);
|
||||
|
||||
NS_IMETHOD RegisterDataSource(nsIRDFDataSource* dataSource);
|
||||
NS_IMETHOD UnregisterDataSource(nsIRDFDataSource* dataSource);
|
||||
NS_IMETHOD RegisterDataSourceConstructor(const char* uri, NSDataSourceConstructorCallback fn);
|
||||
NS_IMETHOD UnregisterDataSourceConstructor(const char* uri);
|
||||
NS_IMETHOD GetDataSource(const char* uri, nsIRDFDataSource** dataSource);
|
||||
NS_IMETHOD CreateDatabase(const char** uris, nsIRDFDataBase** dataBase);
|
||||
NS_IMETHOD CreateBrowserDatabase(nsIRDFDataBase** dataBase);
|
||||
};
|
||||
|
||||
nsIRDFService* ServiceImpl::gRDFService = nsnull;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ServiceImpl::ServiceImpl(void)
|
||||
: mResources(nsnull), mNamedDataSources(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mResources = PL_NewHashTable(1023, // nbuckets
|
||||
PL_HashString, // hash fn
|
||||
PL_CompareStrings, // key compare fn
|
||||
PL_CompareValues, // value compare fn
|
||||
nsnull, nsnull); // alloc ops & priv
|
||||
|
||||
mNamedDataSources = PL_NewHashTable(23,
|
||||
PL_HashString,
|
||||
PL_CompareStrings,
|
||||
PL_CompareValues,
|
||||
nsnull, nsnull);
|
||||
|
||||
mDataSourceConstructors = PL_NewHashTable(23,
|
||||
PL_HashString,
|
||||
PL_CompareStrings,
|
||||
PL_CompareValues,
|
||||
nsnull, nsnull);
|
||||
}
|
||||
|
||||
|
||||
ServiceImpl::~ServiceImpl(void)
|
||||
{
|
||||
if (mDataSourceConstructors) {
|
||||
PL_HashTableDestroy(mDataSourceConstructors);
|
||||
mDataSourceConstructors = nsnull;
|
||||
}
|
||||
if (mNamedDataSources) {
|
||||
PL_HashTableDestroy(mNamedDataSources);
|
||||
mNamedDataSources = nsnull;
|
||||
}
|
||||
if (mResources) {
|
||||
PL_HashTableDestroy(mResources);
|
||||
mResources = nsnull;
|
||||
}
|
||||
gRDFService = nsnull;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
ServiceImpl::GetRDFService(nsIRDFService** mgr)
|
||||
{
|
||||
if (! gRDFService) {
|
||||
gRDFService = new ServiceImpl();
|
||||
if (! gRDFService)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
RegisterBuiltInResourceFactories();
|
||||
RegisterBuiltInNamedDataSources();
|
||||
}
|
||||
|
||||
NS_ADDREF(gRDFService);
|
||||
*mgr = gRDFService;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
ServiceImpl::AddRef(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
ServiceImpl::Release(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(ServiceImpl, kIRDFServiceIID);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetResource(const char* uri, nsIRDFResource** resource)
|
||||
{
|
||||
nsIRDFResource* result =
|
||||
NS_STATIC_CAST(nsIRDFResource*, PL_HashTableLookup(mResources, uri));
|
||||
|
||||
if (! result) {
|
||||
nsIRDFResourceFactory* factory =
|
||||
NS_STATIC_CAST(nsIRDFResourceFactory*,
|
||||
NS_CONST_CAST(void*, mResourceFactories.Find(uri)));
|
||||
|
||||
PR_ASSERT(factory != nsnull);
|
||||
if (! factory)
|
||||
return NS_ERROR_FAILURE; // XXX
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = factory->CreateResource(uri, &result)))
|
||||
return rv;
|
||||
|
||||
const char* uri;
|
||||
result->GetValue(&uri);
|
||||
|
||||
// This is a little trick to make storage more efficient. For
|
||||
// the "key" in the table, we'll use the string value that's
|
||||
// stored as a member variable of the nsIRDFResource object.
|
||||
PL_HashTableAdd(mResources, uri, result);
|
||||
|
||||
// *We* don't AddRef() the resource: that way, the resource
|
||||
// can be garbage collected when the last refcount goes away.
|
||||
}
|
||||
|
||||
result->AddRef();
|
||||
*resource = result;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource)
|
||||
{
|
||||
nsString s(uri);
|
||||
char* cstr = s.ToNewCString();
|
||||
nsresult rv = GetResource(cstr, resource);
|
||||
delete[] cstr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetLiteral(const PRUnichar* uri, nsIRDFLiteral** literal)
|
||||
{
|
||||
LiteralImpl* result = new LiteralImpl(uri);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*literal = result;
|
||||
NS_ADDREF(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::UnCacheResource(nsIRDFResource* resource)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
const char* uri;
|
||||
if (NS_FAILED(rv = resource->GetValue(&uri)))
|
||||
return rv;
|
||||
|
||||
PL_HashTableRemove(mResources, uri);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory)
|
||||
{
|
||||
if (! mResourceFactories.Add(aURIPrefix, aFactory))
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
NS_ADDREF(aFactory); // XXX should we addref?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::UnRegisterResourceFactory(const char* aURIPrefix)
|
||||
{
|
||||
nsIRDFResourceFactory* factory =
|
||||
NS_STATIC_CAST(nsIRDFResourceFactory*,
|
||||
NS_CONST_CAST(void*, mResourceFactories.Remove(aURIPrefix)));
|
||||
|
||||
if (! factory)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
NS_RELEASE(factory); // XXX should we addref?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource)
|
||||
{
|
||||
NS_PRECONDITION(aDataSource != nsnull, "null ptr");
|
||||
if (! aDataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
const char* uri;
|
||||
if (NS_FAILED(rv = aDataSource->GetURI(&uri)))
|
||||
return rv;
|
||||
|
||||
// XXX check for dups, etc.
|
||||
|
||||
PL_HashTableAdd(mNamedDataSources, uri, aDataSource);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::UnregisterDataSource(nsIRDFDataSource* aDataSource)
|
||||
{
|
||||
NS_PRECONDITION(aDataSource != nsnull, "null ptr");
|
||||
if (! aDataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
const char* uri;
|
||||
if (NS_FAILED(rv = aDataSource->GetURI(&uri)))
|
||||
return rv;
|
||||
|
||||
nsIRDFDataSource* ds =
|
||||
NS_STATIC_CAST(nsIRDFDataSource*, PL_HashTableLookup(mNamedDataSources, uri));
|
||||
|
||||
if (! ds)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
PL_HashTableRemove(mNamedDataSources, uri);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::RegisterDataSourceConstructor(const char* uri, NSDataSourceConstructorCallback fn)
|
||||
{
|
||||
// XXX check for dups, etc.
|
||||
PL_HashTableAdd(mDataSourceConstructors, uri, fn);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::UnregisterDataSourceConstructor(const char* uri)
|
||||
{
|
||||
PL_HashTableRemove(mDataSourceConstructors, uri);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::GetDataSource(const char* uri, nsIRDFDataSource** aDataSource)
|
||||
{
|
||||
nsIRDFDataSource* ds =
|
||||
NS_STATIC_CAST(nsIRDFDataSource*, PL_HashTableLookup(mNamedDataSources, uri));
|
||||
|
||||
if (ds) {
|
||||
NS_ADDREF(ds);
|
||||
*aDataSource = ds;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Otherwise, see if we have a lazy constructor
|
||||
NSDataSourceConstructorCallback constructor =
|
||||
(NSDataSourceConstructorCallback)
|
||||
PL_HashTableLookup(mDataSourceConstructors, uri);
|
||||
|
||||
if (constructor) {
|
||||
// Yep, so try to construct it on the fly...
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = constructor(&ds))) {
|
||||
#ifdef DEBUG
|
||||
printf("error constructing built-in datasource %s\n", uri);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
// If it wants to register itself, it should do so in the Init() method.
|
||||
if (NS_FAILED(rv = ds->Init(uri))) {
|
||||
#ifdef DEBUG
|
||||
printf("error initializing named datasource %s\n", uri);
|
||||
#endif
|
||||
NS_RELEASE(ds);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// constructor did an implicit addref
|
||||
*aDataSource = ds;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX at this point, we might want to try to construct a
|
||||
// stream URI and load it that way...
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::CreateDatabase(const char** uri, nsIRDFDataBase** dataBase)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceImpl::CreateBrowserDatabase(nsIRDFDataBase** dataBase)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is Big Hack #1. Depedencies on all builtin resource
|
||||
// factories are *here*, in the ResourceFactoryTable.
|
||||
//
|
||||
|
||||
struct ResourceFactoryTable {
|
||||
const char* mPrefix;
|
||||
nsresult (*mFactoryConstructor)(nsIRDFResourceFactory** result);
|
||||
};
|
||||
|
||||
void
|
||||
ServiceImpl::RegisterBuiltInResourceFactories(void)
|
||||
{
|
||||
extern nsresult NS_NewRDFDefaultResourceFactory(nsIRDFResourceFactory** result);
|
||||
extern nsresult NS_NewRDFMailResourceFactory(nsIRDFResourceFactory** result);
|
||||
extern nsresult NS_NewRDFMailAccountResourceFactory(nsIRDFResourceFactory** result);
|
||||
extern nsresult NS_NewRDFFileResourceFactory(nsIRDFResourceFactory** result);
|
||||
|
||||
static ResourceFactoryTable gTable[] = {
|
||||
"", NS_NewRDFDefaultResourceFactory,
|
||||
"mailaccount:", NS_NewRDFMailAccountResourceFactory,
|
||||
"mailbox:", NS_NewRDFMailResourceFactory,
|
||||
#if 0
|
||||
"file:", NS_NewRDFFileResourceFactory,
|
||||
#endif
|
||||
nsnull, nsnull
|
||||
};
|
||||
|
||||
nsresult rv;
|
||||
for (ResourceFactoryTable* entry = gTable; entry->mPrefix != nsnull; ++entry) {
|
||||
nsIRDFResourceFactory* factory;
|
||||
|
||||
if (NS_FAILED(rv = (entry->mFactoryConstructor)(&factory)))
|
||||
continue;
|
||||
|
||||
rv = gRDFService->RegisterResourceFactory(entry->mPrefix, factory);
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is Big Hack #2. Dependencies on all builtin datasources are
|
||||
// *here*, in the DataSourceTable.
|
||||
//
|
||||
// FWIW, I don't particularly like this interface *anyway*, because
|
||||
// it requires each built-in data source to be constructed "up
|
||||
// front". Not only does it cause the service manager to be
|
||||
// re-entered (which may be a problem), but it's wasteful: I think
|
||||
// these data sources should be created on demand, and released when
|
||||
// you're done with them.
|
||||
//
|
||||
|
||||
struct DataSourceTable {
|
||||
const char* mURI;
|
||||
nsresult (*mDataSourceConstructor)(nsIRDFDataSource** result);
|
||||
};
|
||||
|
||||
void
|
||||
ServiceImpl::RegisterBuiltInNamedDataSources(void)
|
||||
{
|
||||
extern nsresult NS_NewRDFBookmarkDataSource(nsIRDFDataSource** result);
|
||||
extern nsresult NS_NewRDFHistoryDataSource(nsIRDFDataSource** result);
|
||||
extern nsresult NS_NewRDFLocalFileSystemDataSource(nsIRDFDataSource** result);
|
||||
extern nsresult NS_NewRDFMailDataSource(nsIRDFDataSource** result);
|
||||
|
||||
static DataSourceTable gTable[] = {
|
||||
"rdf:bookmarks", NS_NewRDFBookmarkDataSource,
|
||||
"rdf:mail", NS_NewRDFMailDataSource,
|
||||
#if 0
|
||||
"rdf:history", NS_NewRDFHistoryDataSource,
|
||||
"rdf:lfs", NS_NewRDFLocalFileSystemDataSource,
|
||||
#endif
|
||||
nsnull, nsnull
|
||||
};
|
||||
|
||||
nsresult rv;
|
||||
for (DataSourceTable* entry = gTable; entry->mURI != nsnull; ++entry) {
|
||||
if (NS_FAILED(rv = gRDFService->RegisterDataSourceConstructor(entry->mURI, entry->mDataSourceConstructor))) {
|
||||
#ifdef DEBUG
|
||||
printf("error registering built-in datasource constructor for %s\n", entry->mURI);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFService(nsIRDFService** mgr)
|
||||
{
|
||||
return ServiceImpl::GetRDFService(mgr);
|
||||
}
|
||||
687
mozilla/rdf/base/src/nsStreamDataSource.cpp
Normal file
687
mozilla/rdf/base/src/nsStreamDataSource.cpp
Normal file
@@ -0,0 +1,687 @@
|
||||
/* -*- 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 data source that can read itself from and write itself to an
|
||||
RDF/XML stream.
|
||||
|
||||
TO DO
|
||||
-----
|
||||
|
||||
1) Right now, the only kind of stream data sources that are writable
|
||||
are "file:" URIs. (In fact, <em>all</em> "file:" URIs are
|
||||
writable, modulo flie system permissions; this may lead to some
|
||||
surprising behavior.) Eventually, it'd be great if we could open
|
||||
an arbitrary nsIOutputStream on *any* URL, and Netlib could just
|
||||
do the magic.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsIDTD.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIRDFContentSink.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFXMLDocument.h"
|
||||
#include "nsIRDFXMLSource.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsLayoutCID.h" // for NS_NAMESPACEMANAGER_CID.
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "plstr.h"
|
||||
#include "prio.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIRDFXMLDocumentIID, NS_IRDFXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIRDFXMLSourceIID, NS_IRDFXMLSOURCE_IID);
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFContentSinkCID, NS_RDFCONTENTSINK_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// FileOutputStreamImpl
|
||||
|
||||
class FileOutputStreamImpl : public nsIOutputStream
|
||||
{
|
||||
private:
|
||||
nsOutputFileStream mStream;
|
||||
|
||||
public:
|
||||
FileOutputStreamImpl(const nsFilePath& path)
|
||||
: mStream(path) {}
|
||||
|
||||
virtual ~FileOutputStreamImpl(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIBaseStream interface
|
||||
NS_IMETHOD Close(void) {
|
||||
mStream.close();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIOutputStream interface
|
||||
NS_IMETHOD Write(const char* aBuf,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aWriteCount)
|
||||
{
|
||||
PRInt32 written = mStream.write(aBuf + aOffset, aCount);
|
||||
if (written == -1) {
|
||||
*aWriteCount = 0;
|
||||
return NS_ERROR_FAILURE; // XXX right error code?
|
||||
}
|
||||
else {
|
||||
*aWriteCount = written;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(FileOutputStreamImpl, kIOutputStreamIID);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// StreamDataSourceImpl
|
||||
|
||||
class StreamDataSourceImpl : public nsIRDFDataSource,
|
||||
public nsIRDFXMLDocument,
|
||||
public nsIRDFXMLSource
|
||||
{
|
||||
protected:
|
||||
nsIRDFDataSource* mInner;
|
||||
PRBool mIsWritable;
|
||||
PRBool mIsDirty;
|
||||
nsVoidArray mObservers;
|
||||
char** mNamedDataSourceURIs;
|
||||
PRInt32 mNumNamedDataSourceURIs;
|
||||
nsIURL** mCSSStyleSheetURLs;
|
||||
PRInt32 mNumCSSStyleSheetURLs;
|
||||
nsIRDFResource* mRootResource;
|
||||
|
||||
public:
|
||||
StreamDataSourceImpl(void);
|
||||
virtual ~StreamDataSourceImpl(void);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFDataSource
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(const char* *uri) const {
|
||||
return mInner->GetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source) {
|
||||
return mInner->GetSource(property, target, tv, source);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** sources) {
|
||||
return mInner->GetSources(property, target, tv, sources);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target) {
|
||||
return mInner->GetTarget(source, property, tv, target);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets) {
|
||||
return mInner->GetTargets(source, property, tv, targets);
|
||||
}
|
||||
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv);
|
||||
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target);
|
||||
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion) {
|
||||
return mInner->HasAssertion(source, property, target, tv, hasAssertion);
|
||||
}
|
||||
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n) {
|
||||
return mInner->AddObserver(n);
|
||||
}
|
||||
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n) {
|
||||
return mInner->RemoveObserver(n);
|
||||
}
|
||||
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels) {
|
||||
return mInner->ArcLabelsIn(node, labels);
|
||||
}
|
||||
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels) {
|
||||
return mInner->ArcLabelsOut(source, labels);
|
||||
}
|
||||
|
||||
NS_IMETHOD Flush(void);
|
||||
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult) {
|
||||
return mInner->IsCommandEnabled(aCommand, aCommandTarget, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHOD DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget) {
|
||||
// XXX Uh oh, this could cause problems wrt. the "dirty" flag
|
||||
// if it changes the in-memory store's internal state.
|
||||
return mInner->DoCommand(aCommand, aCommandTarget);
|
||||
}
|
||||
|
||||
// nsIRDFXMLDocument interface
|
||||
NS_IMETHOD BeginLoad(void);
|
||||
NS_IMETHOD Interrupt(void);
|
||||
NS_IMETHOD Resume(void);
|
||||
NS_IMETHOD EndLoad(void);
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* aResource);
|
||||
NS_IMETHOD GetRootResource(nsIRDFResource** aResource);
|
||||
NS_IMETHOD AddCSSStyleSheetURL(nsIURL* aStyleSheetURL);
|
||||
NS_IMETHOD GetCSSStyleSheetURLs(nsIURL*** aStyleSheetURLs, PRInt32* aCount);
|
||||
NS_IMETHOD AddNamedDataSourceURI(const char* aNamedDataSourceURI);
|
||||
NS_IMETHOD GetNamedDataSourceURIs(const char* const** aNamedDataSourceURIs, PRInt32* aCount);
|
||||
NS_IMETHOD AddDocumentObserver(nsIRDFXMLDocumentObserver* aObserver);
|
||||
NS_IMETHOD RemoveDocumentObserver(nsIRDFXMLDocumentObserver* aObserver);
|
||||
|
||||
// nsIRDFXMLSource interface
|
||||
NS_IMETHOD Serialize(nsIOutputStream* aStream);
|
||||
|
||||
// Implementation methods
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
StreamDataSourceImpl::StreamDataSourceImpl(void)
|
||||
: mIsWritable(PR_FALSE),
|
||||
mNamedDataSourceURIs(nsnull),
|
||||
mNumNamedDataSourceURIs(0),
|
||||
mCSSStyleSheetURLs(nsnull),
|
||||
mNumCSSStyleSheetURLs(0)
|
||||
{
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID,
|
||||
nsnull,
|
||||
kIRDFDataSourceIID,
|
||||
(void**) &mInner)))
|
||||
PR_ASSERT(0);
|
||||
}
|
||||
|
||||
|
||||
StreamDataSourceImpl::~StreamDataSourceImpl(void)
|
||||
{
|
||||
nsIRDFService* rdfService;
|
||||
if (NS_SUCCEEDED(nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &rdfService))) {
|
||||
rdfService->UnregisterDataSource(this);
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, rdfService);
|
||||
}
|
||||
|
||||
Flush();
|
||||
|
||||
while (--mNumNamedDataSourceURIs >= 0)
|
||||
delete mNamedDataSourceURIs[mNumNamedDataSourceURIs];
|
||||
|
||||
delete mNamedDataSourceURIs;
|
||||
|
||||
while (--mNumCSSStyleSheetURLs >= 0)
|
||||
NS_RELEASE(mCSSStyleSheetURLs[mNumCSSStyleSheetURLs]);
|
||||
|
||||
delete mCSSStyleSheetURLs;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(StreamDataSourceImpl);
|
||||
NS_IMPL_RELEASE(StreamDataSourceImpl);
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kISupportsIID) ||
|
||||
iid.Equals(kIRDFDataSourceIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFDataSource*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(kIRDFXMLSourceIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFXMLSource*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(kIRDFXMLDocumentIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFXMLDocument*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
*result = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
const char* kFileURIPrefix = "file:";
|
||||
const PRInt32 kFileURIPrefixLen = 5;
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::Init(const char* uri)
|
||||
{
|
||||
NS_PRECONDITION(mInner != nsnull, "not initialized");
|
||||
if (! mInner)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// XXX this is a hack: any "file:" URI is considered writable. All
|
||||
// others are considered read-only.
|
||||
if (PL_strncmp(uri, kFileURIPrefix, kFileURIPrefixLen) == 0)
|
||||
mIsWritable = PR_TRUE;
|
||||
|
||||
nsIRDFService* rdfService = nsnull;
|
||||
nsINameSpaceManager* ns = nsnull;
|
||||
nsIRDFContentSink* sink = nsnull;
|
||||
nsIParser* parser = nsnull;
|
||||
nsIDTD* dtd = nsnull;
|
||||
nsIStreamListener* lsnr = nsnull;
|
||||
nsIURL* url = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewURL(&url, uri)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = mInner->Init(uri)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &rdfService)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = rdfService->RegisterDataSource(this)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID,
|
||||
nsnull,
|
||||
kINameSpaceManagerIID,
|
||||
(void**) &ns)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFContentSinkCID,
|
||||
nsnull,
|
||||
kIRDFContentSinkIID,
|
||||
(void**) &sink)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(sink->Init(url, ns)))
|
||||
goto done;
|
||||
|
||||
// We set the content sink's data source directly to our in-memory
|
||||
// store. This allows the initial content to be generated "directly".
|
||||
if (NS_FAILED(rv = sink->SetDataSource(mInner)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = sink->SetRDFXMLDocument(this)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kParserCID,
|
||||
nsnull,
|
||||
kIParserIID,
|
||||
(void**) &parser)))
|
||||
goto done;
|
||||
|
||||
parser->SetContentSink(sink);
|
||||
|
||||
// XXX this should eventually be kRDFDTDCID (oh boy, that's a
|
||||
// pretty identifier). The RDF DTD will be a much more
|
||||
// RDF-resilient parser.
|
||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kWellFormedDTDCID,
|
||||
nsnull,
|
||||
kIDTDIID,
|
||||
(void**) &dtd)))
|
||||
goto done;
|
||||
|
||||
parser->RegisterDTD(dtd);
|
||||
|
||||
if (NS_FAILED(rv = parser->QueryInterface(kIStreamListenerIID, (void**) &lsnr)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(parser->Parse(url)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(NS_OpenURL(url, lsnr)))
|
||||
goto done;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(lsnr);
|
||||
NS_IF_RELEASE(dtd);
|
||||
NS_IF_RELEASE(parser);
|
||||
NS_IF_RELEASE(sink);
|
||||
if (rdfService) {
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, rdfService);
|
||||
rdfService = nsnull;
|
||||
}
|
||||
NS_IF_RELEASE(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv)
|
||||
{
|
||||
if (! mIsWritable)
|
||||
return NS_ERROR_FAILURE; // XXX right error code?
|
||||
|
||||
nsresult rv;
|
||||
if (NS_SUCCEEDED(rv = mInner->Assert(source, property, target, tv)))
|
||||
mIsDirty = PR_TRUE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target)
|
||||
{
|
||||
if (! mIsWritable)
|
||||
return NS_ERROR_FAILURE; // XXX right error code?
|
||||
|
||||
nsresult rv;
|
||||
if (NS_SUCCEEDED(rv = mInner->Unassert(source, property, target)))
|
||||
mIsDirty = PR_TRUE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::Flush(void)
|
||||
{
|
||||
if (!mIsWritable || !mIsDirty)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
const char* uri;
|
||||
if (NS_FAILED(rv = mInner->GetURI(&uri)))
|
||||
return rv;
|
||||
|
||||
nsFileURL url(uri);
|
||||
nsFilePath path(url);
|
||||
|
||||
FileOutputStreamImpl out(path);
|
||||
if (NS_FAILED(rv = Serialize(&out)))
|
||||
return rv;
|
||||
|
||||
mIsDirty = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFXMLDocument methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::BeginLoad(void)
|
||||
{
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLDocumentObserver* obs = (nsIRDFXMLDocumentObserver*) mObservers[i];
|
||||
obs->OnBeginLoad();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::Interrupt(void)
|
||||
{
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLDocumentObserver* obs = (nsIRDFXMLDocumentObserver*) mObservers[i];
|
||||
obs->OnInterrupt();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::Resume(void)
|
||||
{
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLDocumentObserver* obs = (nsIRDFXMLDocumentObserver*) mObservers[i];
|
||||
obs->OnResume();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::EndLoad(void)
|
||||
{
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLDocumentObserver* obs = (nsIRDFXMLDocumentObserver*) mObservers[i];
|
||||
obs->OnEndLoad();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::SetRootResource(nsIRDFResource* aResource)
|
||||
{
|
||||
NS_PRECONDITION(aResource != nsnull, "null ptr");
|
||||
if (! aResource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ADDREF(aResource);
|
||||
mRootResource = aResource;
|
||||
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLDocumentObserver* obs = (nsIRDFXMLDocumentObserver*) mObservers[i];
|
||||
obs->OnRootResourceFound(mRootResource);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::GetRootResource(nsIRDFResource** aResource)
|
||||
{
|
||||
NS_ADDREF(mRootResource);
|
||||
*aResource = mRootResource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::AddCSSStyleSheetURL(nsIURL* aCSSStyleSheetURL)
|
||||
{
|
||||
NS_PRECONDITION(aCSSStyleSheetURL != nsnull, "null ptr");
|
||||
if (! aCSSStyleSheetURL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIURL** p = new nsIURL*[mNumCSSStyleSheetURLs + 1];
|
||||
if (! p)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PRInt32 i;
|
||||
for (i = mNumCSSStyleSheetURLs - 1; i >= 0; --i)
|
||||
p[i] = mCSSStyleSheetURLs[i];
|
||||
|
||||
NS_ADDREF(aCSSStyleSheetURL);
|
||||
p[mNumCSSStyleSheetURLs] = aCSSStyleSheetURL;
|
||||
|
||||
++mNumCSSStyleSheetURLs;
|
||||
mCSSStyleSheetURLs = p;
|
||||
|
||||
for (i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLDocumentObserver* obs = (nsIRDFXMLDocumentObserver*) mObservers[i];
|
||||
obs->OnCSSStyleSheetAdded(aCSSStyleSheetURL);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::GetCSSStyleSheetURLs(nsIURL*** aCSSStyleSheetURLs, PRInt32* aCount)
|
||||
{
|
||||
*aCSSStyleSheetURLs = mCSSStyleSheetURLs;
|
||||
*aCount = mNumCSSStyleSheetURLs;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::AddNamedDataSourceURI(const char* aNamedDataSourceURI)
|
||||
{
|
||||
NS_PRECONDITION(aNamedDataSourceURI != nsnull, "null ptr");
|
||||
if (! aNamedDataSourceURI)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
char** p = new char*[mNumNamedDataSourceURIs + 1];
|
||||
if (! p)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PRInt32 i;
|
||||
for (i = mNumNamedDataSourceURIs - 1; i >= 0; --i)
|
||||
p[i] = mNamedDataSourceURIs[i];
|
||||
|
||||
PRInt32 len = PL_strlen(aNamedDataSourceURI);
|
||||
char* buf = new char[len + 1];
|
||||
if (! buf) {
|
||||
delete p;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PL_strcpy(buf, aNamedDataSourceURI);
|
||||
p[mNumNamedDataSourceURIs] = buf;
|
||||
|
||||
++mNumNamedDataSourceURIs;
|
||||
mNamedDataSourceURIs = p;
|
||||
|
||||
for (i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLDocumentObserver* obs = (nsIRDFXMLDocumentObserver*) mObservers[i];
|
||||
obs->OnNamedDataSourceAdded(aNamedDataSourceURI);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::GetNamedDataSourceURIs(const char* const** aNamedDataSourceURIs, PRInt32* aCount)
|
||||
{
|
||||
*aNamedDataSourceURIs = mNamedDataSourceURIs;
|
||||
*aCount = mNumNamedDataSourceURIs;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::AddDocumentObserver(nsIRDFXMLDocumentObserver* aObserver)
|
||||
{
|
||||
mObservers.AppendElement(aObserver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::RemoveDocumentObserver(nsIRDFXMLDocumentObserver* aObserver)
|
||||
{
|
||||
mObservers.RemoveElement(aObserver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFXMLSource methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamDataSourceImpl::Serialize(nsIOutputStream* stream)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIRDFXMLSource* source;
|
||||
if (NS_SUCCEEDED(rv = mInner->QueryInterface(kIRDFXMLSourceIID, (void**) &source))) {
|
||||
rv = source->Serialize(stream);
|
||||
NS_RELEASE(source);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFStreamDataSource(nsIRDFDataSource** result)
|
||||
{
|
||||
StreamDataSourceImpl* ds = new StreamDataSourceImpl();
|
||||
if (! ds)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = ds;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
527
mozilla/rdf/base/src/rdfutil.cpp
Normal file
527
mozilla/rdf/base/src/rdfutil.cpp
Normal file
@@ -0,0 +1,527 @@
|
||||
/* -*- 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.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFDataBase.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// RDF core vocabulary
|
||||
|
||||
#include "rdf.h"
|
||||
#define RDF_NAMESPACE_URI "http://www.w3.org/TR/WD-rdf-syntax#"
|
||||
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, Alt);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, Bag);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, Description);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, ID);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, RDF);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, Seq);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, about);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, aboutEach);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, bagID);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, instanceOf);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, li);
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, resource);
|
||||
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, nextVal); // ad hoc way to make containers fast
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static nsIRDFService* gRDFService = nsnull;
|
||||
|
||||
static nsresult
|
||||
rdf_EnsureRDFService(void)
|
||||
{
|
||||
if (gRDFService)
|
||||
return NS_OK;
|
||||
|
||||
return nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &gRDFService);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PRBool
|
||||
rdf_IsOrdinalProperty(const nsIRDFResource* property)
|
||||
{
|
||||
const char* s;
|
||||
if (NS_FAILED(property->GetValue(&s)))
|
||||
return PR_FALSE;
|
||||
|
||||
nsAutoString uri = s;
|
||||
|
||||
if (uri.Find(kRDFNameSpaceURI) != 0)
|
||||
return PR_FALSE;
|
||||
|
||||
nsAutoString tag(uri);
|
||||
tag.Cut(0, sizeof(kRDFNameSpaceURI) - 1);
|
||||
|
||||
if (tag[0] != '_')
|
||||
return PR_FALSE;
|
||||
|
||||
for (PRInt32 i = tag.Length() - 1; i >= 1; --i) {
|
||||
if (tag[i] < '0' || tag[i] > '9')
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
rdf_IsContainer(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* resource)
|
||||
{
|
||||
PRBool result = PR_FALSE;
|
||||
|
||||
nsIRDFResource* RDF_instanceOf = nsnull;
|
||||
nsIRDFResource* RDF_Bag = nsnull;
|
||||
nsIRDFResource* RDF_Seq = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = rdf_EnsureRDFService()))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = gRDFService->GetResource(kURIRDF_instanceOf, &RDF_instanceOf)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = gRDFService->GetResource(kURIRDF_Bag, &RDF_Bag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Bag, PR_TRUE, &result)))
|
||||
goto done;
|
||||
|
||||
if (result)
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = gRDFService->GetResource(kURIRDF_Seq, &RDF_Seq)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Seq, PR_TRUE, &result)))
|
||||
goto done;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(RDF_Seq);
|
||||
NS_IF_RELEASE(RDF_Bag);
|
||||
NS_IF_RELEASE(RDF_instanceOf);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// A complete hack that looks at the string value of a node and
|
||||
// guesses if it's a resource
|
||||
static PRBool
|
||||
rdf_IsResource(const nsString& s)
|
||||
{
|
||||
PRInt32 index;
|
||||
|
||||
// A URI needs a colon.
|
||||
index = s.Find(':');
|
||||
if (index < 0)
|
||||
return PR_FALSE;
|
||||
|
||||
// Assume some sane maximum for protocol specs
|
||||
#define MAX_PROTOCOL_SPEC 10
|
||||
if (index > MAX_PROTOCOL_SPEC)
|
||||
return PR_FALSE;
|
||||
|
||||
// It can't have spaces or newlines or tabs
|
||||
if (s.Find(' ') > 0 || s.Find('\n') > 0 || s.Find('\t') > 0)
|
||||
return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// 0. node, node, node
|
||||
nsresult
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(subject, "null ptr");
|
||||
NS_ASSERTION(predicate, "null ptr");
|
||||
NS_ASSERTION(object, "null ptr");
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* s;
|
||||
predicate->GetValue(&s);
|
||||
printf(" %s", (strchr(s, '#') ? strchr(s, '#')+1 : s));
|
||||
subject->GetValue(&s);
|
||||
printf("(%s, ", s);
|
||||
|
||||
|
||||
nsIRDFResource* objectResource;
|
||||
nsIRDFLiteral* objectLiteral;
|
||||
|
||||
if (NS_SUCCEEDED(object->QueryInterface(kIRDFResourceIID, (void**) &objectResource))) {
|
||||
objectResource->GetValue(&s);
|
||||
printf(" %s)\n", s);
|
||||
NS_RELEASE(objectResource);
|
||||
}
|
||||
else if (NS_SUCCEEDED(object->QueryInterface(kIRDFLiteralIID, (void**) &objectLiteral))) {
|
||||
const PRUnichar* p;
|
||||
objectLiteral->GetValue(&p);
|
||||
nsAutoString s2(p);
|
||||
char buf[1024];
|
||||
printf(" %s)\n", s2.ToCString(buf, sizeof buf));
|
||||
NS_RELEASE(objectLiteral);
|
||||
}
|
||||
#endif
|
||||
return ds->Assert(subject, predicate, object, PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
// 1. string, string, string
|
||||
nsresult
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
const nsString& subjectURI,
|
||||
const nsString& predicateURI,
|
||||
const nsString& objectURI)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
nsIRDFResource* subject;
|
||||
if (NS_FAILED(rv = rdf_EnsureRDFService()))
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(subjectURI, &subject)))
|
||||
return rv;
|
||||
|
||||
rv = rdf_Assert(ds, subject, predicateURI, objectURI);
|
||||
NS_RELEASE(subject);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// 2. node, node, string
|
||||
nsresult
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
const nsString& objectURI)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(subject, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
nsIRDFNode* object;
|
||||
|
||||
if (NS_FAILED(rv = rdf_EnsureRDFService()))
|
||||
return rv;
|
||||
|
||||
// XXX Make a guess *here* if the object should be a resource or a
|
||||
// literal. If you don't like it, then call ds->Assert() yerself.
|
||||
if (rdf_IsResource(objectURI)) {
|
||||
nsIRDFResource* resource;
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(objectURI, &resource)))
|
||||
return rv;
|
||||
|
||||
object = resource;
|
||||
}
|
||||
else {
|
||||
nsIRDFLiteral* literal;
|
||||
if (NS_FAILED(rv = gRDFService->GetLiteral(objectURI, &literal)))
|
||||
return rv;
|
||||
|
||||
object = literal;
|
||||
}
|
||||
|
||||
rv = rdf_Assert(ds, subject, predicate, object);
|
||||
NS_RELEASE(object);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// 3. node, string, string
|
||||
nsresult
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
const nsString& predicateURI,
|
||||
const nsString& objectURI)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(subject, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = rdf_EnsureRDFService()))
|
||||
return rv;
|
||||
|
||||
nsIRDFResource* predicate;
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(predicateURI, &predicate)))
|
||||
return rv;
|
||||
|
||||
rv = rdf_Assert(ds, subject, predicate, objectURI);
|
||||
NS_RELEASE(predicate);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// 4. node, string, node
|
||||
nsresult
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
const nsString& predicateURI,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(subject, "null ptr");
|
||||
NS_ASSERTION(object, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = rdf_EnsureRDFService()))
|
||||
return rv;
|
||||
|
||||
nsIRDFResource* predicate;
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(predicateURI, &predicate)))
|
||||
return rv;
|
||||
|
||||
rv = rdf_Assert(ds, subject, predicate, object);
|
||||
NS_RELEASE(predicate);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// 5. string, string, node
|
||||
nsresult
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
const nsString& subjectURI,
|
||||
const nsString& predicateURI,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = rdf_EnsureRDFService()))
|
||||
return rv;
|
||||
|
||||
nsIRDFResource* subject;
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(subjectURI, &subject)))
|
||||
return rv;
|
||||
|
||||
rv = rdf_Assert(ds, subject, predicateURI, object);
|
||||
NS_RELEASE(subject);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
rdf_CreateAnonymousResource(nsIRDFResource** result)
|
||||
{
|
||||
static PRUint32 gCounter = 0;
|
||||
|
||||
nsAutoString s = "$";
|
||||
s.Append(++gCounter, 10);
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = rdf_EnsureRDFService()))
|
||||
return rv;
|
||||
|
||||
return gRDFService->GetUnicodeResource(s, result);
|
||||
}
|
||||
|
||||
nsresult
|
||||
rdf_MakeBag(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* bag)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(bag, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// XXX check to see if someone else has already made this into a container.
|
||||
|
||||
if (NS_FAILED(rv = rdf_Assert(ds, bag, kURIRDF_instanceOf, kURIRDF_Bag)))
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = rdf_Assert(ds, bag, kURIRDF_nextVal, "1")))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
rdf_MakeSeq(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* seq)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(seq, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// XXX check to see if someone else has already made this into a container.
|
||||
|
||||
if (NS_FAILED(rv = rdf_Assert(ds, seq, kURIRDF_instanceOf, kURIRDF_Seq)))
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = rdf_Assert(ds, seq, kURIRDF_nextVal, "1")))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
rdf_MakeAlt(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* alt)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(alt, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// XXX check to see if someone else has already made this into a container.
|
||||
|
||||
if (NS_FAILED(rv = rdf_Assert(ds, alt, kURIRDF_instanceOf, kURIRDF_Alt)))
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = rdf_Assert(ds, alt, kURIRDF_nextVal, "1")))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
static nsresult
|
||||
rdf_ContainerGetNextValue(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container,
|
||||
nsIRDFResource** result)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(container, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = rdf_EnsureRDFService()))
|
||||
return rv;
|
||||
|
||||
nsIRDFResource* RDF_nextVal = nsnull;
|
||||
nsIRDFNode* nextValNode = nsnull;
|
||||
nsIRDFLiteral* nextValLiteral = nsnull;
|
||||
const PRUnichar* s;
|
||||
nsAutoString nextValStr;
|
||||
PRInt32 nextVal;
|
||||
PRInt32 err;
|
||||
|
||||
// Get the next value, which hangs off of the bag via the
|
||||
// RDF:nextVal property.
|
||||
if (NS_FAILED(rv = gRDFService->GetResource(kURIRDF_nextVal, &RDF_nextVal)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = ds->GetTarget(container, RDF_nextVal, PR_TRUE, &nextValNode)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nextValNode->QueryInterface(kIRDFLiteralIID, (void**) &nextValLiteral)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nextValLiteral->GetValue(&s)))
|
||||
goto done;
|
||||
|
||||
nextValStr = s;
|
||||
nextVal = nextValStr.ToInteger(&err);
|
||||
if (NS_FAILED(err))
|
||||
goto done;
|
||||
|
||||
// Generate a URI that we can return.
|
||||
nextValStr = kRDFNameSpaceURI;
|
||||
nextValStr.Append("_");
|
||||
nextValStr.Append(nextVal, 10);
|
||||
|
||||
if (NS_FAILED(rv = gRDFService->GetUnicodeResource(nextValStr, result)))
|
||||
goto done;
|
||||
|
||||
// Now increment the RDF:nextVal property.
|
||||
if (NS_FAILED(rv = ds->Unassert(container, RDF_nextVal, nextValLiteral)))
|
||||
goto done;
|
||||
|
||||
NS_RELEASE(nextValLiteral);
|
||||
|
||||
++nextVal;
|
||||
nextValStr.Truncate();
|
||||
nextValStr.Append(nextVal, 10);
|
||||
|
||||
if (NS_FAILED(rv = gRDFService->GetLiteral(nextValStr, &nextValLiteral)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = rdf_Assert(ds, container, RDF_nextVal, nextValLiteral)))
|
||||
goto done;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(nextValLiteral);
|
||||
NS_IF_RELEASE(nextValNode);
|
||||
NS_IF_RELEASE(RDF_nextVal);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
rdf_ContainerAddElement(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container,
|
||||
nsIRDFNode* element)
|
||||
{
|
||||
NS_ASSERTION(ds, "null ptr");
|
||||
NS_ASSERTION(container, "null ptr");
|
||||
NS_ASSERTION(element, "null ptr");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsIRDFResource* nextVal;
|
||||
|
||||
if (NS_FAILED(rv = rdf_ContainerGetNextValue(ds, container, &nextVal)))
|
||||
goto done;
|
||||
|
||||
if (rv = rdf_Assert(ds, container, nextVal, element))
|
||||
goto done;
|
||||
|
||||
done:
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
169
mozilla/rdf/base/src/rdfutil.h
Normal file
169
mozilla/rdf/base/src/rdfutil.h
Normal file
@@ -0,0 +1,169 @@
|
||||
/* -*- 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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef rdfutil_h__
|
||||
#define rdfutil_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsIRDFCursor;
|
||||
class nsIRDFDataBase;
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFNode;
|
||||
class nsString;
|
||||
|
||||
/**
|
||||
* Returns PR_TRUE if the URI is an RDF ordinal property; e.g., rdf:_1,
|
||||
* rdf:_2, etc.
|
||||
*/
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsOrdinalProperty(const nsIRDFResource* property);
|
||||
|
||||
|
||||
/**
|
||||
* Returns PR_TRUE if the resource is a container resource; e.g., an
|
||||
* rdf:Bag.
|
||||
*/
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsContainer(nsIRDFDataSource* db,
|
||||
nsIRDFResource* resource);
|
||||
|
||||
|
||||
/**
|
||||
* Various utilities routines for making assertions in a data source
|
||||
*/
|
||||
|
||||
// 0. node, node, node
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object);
|
||||
|
||||
// 1. string, string, string
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
const nsString& subjectURI,
|
||||
const nsString& predicateURI,
|
||||
const nsString& objectURI);
|
||||
|
||||
// 2. node, node, string
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
const nsString& objectURI);
|
||||
|
||||
// 3. node, string, string
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
const nsString& predicateURI,
|
||||
const nsString& objectURI);
|
||||
|
||||
// 4. node, string, node
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
const nsString& predicateURI,
|
||||
nsIRDFNode* object);
|
||||
|
||||
// 5. string, string, node
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
const nsString& subjectURI,
|
||||
const nsString& predicateURI,
|
||||
nsIRDFNode* object);
|
||||
|
||||
/**
|
||||
* Construct a new, "anonymous" node; that is, a node with an internal
|
||||
* resource URI.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_CreateAnonymousResource(nsIRDFResource** result);
|
||||
|
||||
|
||||
/**
|
||||
* Create a bag resource.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_MakeBag(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* resource);
|
||||
|
||||
/**
|
||||
* Create a sequence resource.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_MakeSeq(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* resource);
|
||||
|
||||
/**
|
||||
* Create an alternation resource.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_MakeAlt(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* resource);
|
||||
|
||||
|
||||
/**
|
||||
* Add an element to the container.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_ContainerAddElement(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container,
|
||||
nsIRDFNode* element);
|
||||
|
||||
/**
|
||||
* Create a cursor on a container that enumerates its contents in
|
||||
* order
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewContainerCursor(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container,
|
||||
nsIRDFAssertionCursor** cursor);
|
||||
|
||||
|
||||
/**
|
||||
* Create an empty nsIRDFCursor. This will *never* fail, and will *always*
|
||||
* return the same object.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewEmptyRDFAssertionCursor(nsIRDFAssertionCursor** result);
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewEmptyRDFArcsInCursor(nsIRDFArcsInCursor** result);
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewEmptyRDFArcsOutCursor(nsIRDFArcsOutCursor** result);
|
||||
|
||||
|
||||
// XXX need to move nsEmptyCursor stuff here.
|
||||
|
||||
#endif // rdfutil_h__
|
||||
|
||||
|
||||
1
mozilla/rdf/build/MANIFEST
Normal file
1
mozilla/rdf/build/MANIFEST
Normal file
@@ -0,0 +1 @@
|
||||
nsRDFCID.h
|
||||
68
mozilla/rdf/build/Makefile.in
Normal file
68
mozilla/rdf/build/Makefile.in
Normal file
@@ -0,0 +1,68 @@
|
||||
#!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
|
||||
|
||||
CPPSRCS = \
|
||||
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)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
-L$(DIST)/bin \
|
||||
-L$(DIST)/lib \
|
||||
-lrdfbase_s \
|
||||
-lrdfcontent_s \
|
||||
-lrdfdatasource_s \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(srcdir)/../resources/Mail/joe@meer.net/inbox $(DIST)/bin/res/rdf/Mail/joe@meer.net
|
||||
$(INSTALL) $(srcdir)/../resources/LocalStore.rdf $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/LocalStore.css $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/Mail/joe@meer.net/work $(DIST)/bin/res/rdf/Mail/joe@meer.net
|
||||
$(INSTALL) $(srcdir)/../resources/Mail/joe@meer.net/other $(DIST)/bin/res/rdf/Mail/joe@meer.net
|
||||
$(INSTALL) $(srcdir)/../resources/Mail/jane@aol.com/inbox $(DIST)/bin/res/rdf/Mail/jane@aol.com
|
||||
$(INSTALL) $(srcdir)/../resources/Mail/jane@aol.com/hiking $(DIST)/bin/res/rdf/Mail/jane@aol.com
|
||||
$(INSTALL) $(srcdir)/../resources/Mail/jane@aol.com/trash $(DIST)/bin/res/rdf/Mail/jane@aol.com
|
||||
75
mozilla/rdf/build/makefile.win
Normal file
75
mozilla/rdf/build/makefile.win
Normal file
@@ -0,0 +1,75 @@
|
||||
#!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)
|
||||
|
||||
LLIBS=\
|
||||
$(DIST)\lib\rdfbase_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\libplc21.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
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
$(MAKE_INSTALL) ..\resources\Mail\joe@meer.net\inbox $(DIST)\bin\res\rdf\Mail\joe@meer.net
|
||||
$(MAKE_INSTALL) ..\resources\LocalStore.rdf $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\LocalStore.css $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\Mail\joe@meer.net\work $(DIST)\bin\res\rdf\Mail\joe@meer.net
|
||||
$(MAKE_INSTALL) ..\resources\Mail\joe@meer.net\other $(DIST)\bin\res\rdf\Mail\joe@meer.net
|
||||
$(MAKE_INSTALL) ..\resources\Mail\jane@aol.com\inbox $(DIST)\bin\res\rdf\Mail\jane@aol.com
|
||||
$(MAKE_INSTALL) ..\resources\Mail\jane@aol.com\hiking $(DIST)\bin\res\rdf\Mail\jane@aol.com
|
||||
$(MAKE_INSTALL) ..\resources\Mail\jane@aol.com\trash $(DIST)\bin\res\rdf\Mail\jane@aol.com
|
||||
|
||||
|
||||
|
||||
|
||||
71
mozilla/rdf/build/nsRDFCID.h
Normal file
71
mozilla/rdf/build/nsRDFCID.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 "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_RDFNODE_CID \
|
||||
{ 0xf78da56, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {BFD05264-834C-11d2-8EAC-00805F29F370}
|
||||
#define NS_RDFSERVICE_CID \
|
||||
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {BFD0526D-834C-11d2-8EAC-00805F29F370}
|
||||
#define NS_RDFINMEMORYDATASOURCE_CID \
|
||||
{ 0xbfd0526d, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {E638D760-8687-11d2-B530-000000000000}
|
||||
#define NS_RDFBOOKMARKDATASOURCE_CID \
|
||||
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {E638D761-8687-11d2-B530-000000000000}
|
||||
#define NS_RDFDATABASE_CID \
|
||||
{ 0xe638d761, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {541AFCB2-A9A3-11d2-8EC5-00805F29F370}
|
||||
#define NS_RDFDOCUMENT_CID \
|
||||
{ 0x541afcb2, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {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 } }
|
||||
|
||||
// {7BAF62E0-8E61-11d2-8EB1-00805F29F370}
|
||||
#define NS_RDFSTREAMDATASOURCE_CID \
|
||||
{ 0x7baf62e0, 0x8e61, 0x11d2, { 0x8e, 0xb1, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {0958B101-9ADA-11d2-8EBC-00805F29F370}
|
||||
#define NS_RDFCONTENTSINK_CID \
|
||||
{ 0x958b101, 0x9ada, 0x11d2, { 0x8e, 0xbc, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
|
||||
#endif // nsRDFCID_h__
|
||||
202
mozilla/rdf/build/nsRDFFactory.cpp
Normal file
202
mozilla/rdf/build/nsRDFFactory.cpp
Normal file
@@ -0,0 +1,202 @@
|
||||
/* -*- 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 "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFContentSink.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsRDFBaseDataSources.h"
|
||||
#include "nsRDFBuiltInDataSources.h"
|
||||
#include "nsRDFCID.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
|
||||
static NS_DEFINE_CID(kRDFDocumentCID, NS_RDFDOCUMENT_CID);
|
||||
static NS_DEFINE_CID(kRDFHTMLBuilderCID, NS_RDFHTMLBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContentSinkCID, NS_RDFCONTENTSINK_CID);
|
||||
static NS_DEFINE_CID(kRDFStreamDataSourceCID, NS_RDFSTREAMDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFTreeBuilderCID, NS_RDFTREEBUILDER_CID);
|
||||
|
||||
class RDFFactoryImpl : public nsIFactory
|
||||
{
|
||||
public:
|
||||
RDFFactoryImpl(const nsCID &aClass);
|
||||
|
||||
// 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();
|
||||
|
||||
private:
|
||||
nsCID mClassID;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RDFFactoryImpl::RDFFactoryImpl(const nsCID &aClass)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mClassID = aClass;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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;
|
||||
PRBool wasRefCounted = PR_TRUE;
|
||||
nsISupports *inst = nsnull;
|
||||
if (mClassID.Equals(kRDFServiceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFService((nsIRDFService**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFInMemoryDataSourceCID)) {
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFInMemoryDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFStreamDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFStreamDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFBookmarkDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFBookmarkDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFDataBaseCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFDataBase((nsIRDFDataBase**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFDocumentCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFDocument((nsIRDFDocument**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFHTMLBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFHTMLBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFTreeBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFTreeBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFContentSinkCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFContentSink((nsIRDFContentSink**) &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, so clean up
|
||||
delete inst;
|
||||
|
||||
if (wasRefCounted)
|
||||
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(const nsCID &aClass, nsIFactory **aFactory)
|
||||
{
|
||||
if (! aFactory)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aFactory = new RDFFactoryImpl(aClass);
|
||||
if (aFactory == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
|
||||
}
|
||||
|
||||
29
mozilla/rdf/content/Makefile.in
Normal file
29
mozilla/rdf/content/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
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
27
mozilla/rdf/content/makefile.win
Normal file
27
mozilla/rdf/content/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>
|
||||
3
mozilla/rdf/content/public/MANIFEST
Normal file
3
mozilla/rdf/content/public/MANIFEST
Normal file
@@ -0,0 +1,3 @@
|
||||
nsIRDFContent.h
|
||||
nsIRDFContentModelBuilder.h
|
||||
nsIRDFDocument.h
|
||||
37
mozilla/rdf/content/public/Makefile.in
Normal file
37
mozilla/rdf/content/public/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
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
EXPORTS = \
|
||||
nsIRDFContent.h \
|
||||
nsIRDFContentModelBuilder.h \
|
||||
nsIRDFDocument.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
30
mozilla/rdf/content/public/makefile.win
Normal file
30
mozilla/rdf/content/public/makefile.win
Normal file
@@ -0,0 +1,30 @@
|
||||
#!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 = \
|
||||
nsIRDFContent.h \
|
||||
nsIRDFContentModelBuilder.h \
|
||||
nsIRDFDocument.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
60
mozilla/rdf/content/public/nsIRDFContent.h
Normal file
60
mozilla/rdf/content/public/nsIRDFContent.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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
An interface for RDF content model elements.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFContent_h___
|
||||
#define nsIRDFContent_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIXMLContent.h"
|
||||
|
||||
class nsIRDFResource;
|
||||
|
||||
// {954F0810-81DC-11d2-B52A-000000000000}
|
||||
#define NS_IRDFCONTENT_IID \
|
||||
{ 0x954f0810, 0x81dc, 0x11d2, { 0xb5, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
/**
|
||||
* RDF content extensions to nsIContent
|
||||
*/
|
||||
class nsIRDFContent : public nsIContent {
|
||||
public:
|
||||
NS_IMETHOD GetResource(nsIRDFResource*& aResource) const = 0;
|
||||
NS_IMETHOD ChildrenHaveBeenGenerated(PRBool& aResult) const = 0;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewRDFResourceElement(nsIRDFContent** aResult,
|
||||
nsIRDFResource* aResource,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
PRBool aChildrenMustBeGenerated);
|
||||
|
||||
nsresult
|
||||
NS_NewRDFGenericElement(nsIContent** aResult,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aTag);
|
||||
|
||||
|
||||
#endif // nsIRDFContent_h___
|
||||
79
mozilla/rdf/content/public/nsIRDFContentModelBuilder.h
Normal file
79
mozilla/rdf/content/public/nsIRDFContentModelBuilder.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* -*- 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 content model builder interface. An object that implements this
|
||||
interface is associated with an nsIRDFDocument object to construct
|
||||
an NGLayout content model.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFContentModelBuilder_h__
|
||||
#define nsIRDFContentModelBuilder_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIRDFContent;
|
||||
class nsIRDFDocument;
|
||||
class nsIRDFNode;
|
||||
class nsIRDFResource;
|
||||
|
||||
// {541AFCB0-A9A3-11d2-8EC5-00805F29F370}
|
||||
#define NS_IRDFCONTENTMODELBUILDER_IID \
|
||||
{ 0x541afcb0, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFContentModelBuilder : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Point the content model builder to the document. The content model
|
||||
* builder must not reference count the document.
|
||||
*/
|
||||
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Called to instruct the content model builder to construct the root
|
||||
* document element. The content model builder should construct an
|
||||
* nsIContent object and set the document's content root to that object
|
||||
* via the nsIDocument::SetDocumentRoot() method.
|
||||
*/
|
||||
NS_IMETHOD CreateRoot(nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Called when a new assertion is made to the RDF graph that affects an
|
||||
* element in the content model. The content model builder should update
|
||||
* the document's content model as appropriate.
|
||||
*/
|
||||
NS_IMETHOD OnAssert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue) = 0;
|
||||
|
||||
/**
|
||||
* Called when an assertion is removed from the RDF graph that affects
|
||||
* an element in the content model. The content model builder should
|
||||
* update the document's content model as appropriate.
|
||||
*/
|
||||
NS_IMETHOD OnUnassert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue) = 0;
|
||||
};
|
||||
|
||||
|
||||
extern nsresult NS_NewRDFTreeBuilder(nsIRDFContentModelBuilder** aResult);
|
||||
extern nsresult NS_NewRDFHTMLBuilder(nsIRDFContentModelBuilder** aResult);
|
||||
|
||||
|
||||
#endif // nsIRDFContentModelBuilder_h__
|
||||
108
mozilla/rdf/content/public/nsIRDFDocument.h
Normal file
108
mozilla/rdf/content/public/nsIRDFDocument.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* -*- 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 "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 extension to nsIXMLDocument. Includes methods for
|
||||
setting the root resource of the document content model, a factory
|
||||
method for constructing the children of a node, etc.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDocument_h___
|
||||
#define nsIRDFDocument_h___
|
||||
|
||||
class nsIContent; // XXX nsIXMLDocument.h is bad and doesn't declare this class...
|
||||
|
||||
#include "nsIXMLDocument.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIRDFContent;
|
||||
class nsIRDFContentModelBuilder;
|
||||
class nsIRDFDataBase;
|
||||
class nsISupportsArray;
|
||||
class nsIRDFResource;
|
||||
|
||||
// {954F0811-81DC-11d2-B52A-000000000000}
|
||||
#define NS_IRDFDOCUMENT_IID \
|
||||
{ 0x954f0811, 0x81dc, 0x11d2, { 0xb5, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
/**
|
||||
* RDF document extensions to nsIDocument
|
||||
*/
|
||||
class nsIRDFDocument : public nsIXMLDocument
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Initialize the document object. This will force the document to create
|
||||
* its internal RDF database.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIRDFContentModelBuilder* aBuilder) = 0;
|
||||
|
||||
/**
|
||||
* Set the document's "root" resource.
|
||||
*/
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the document's RDF data base.
|
||||
*/
|
||||
NS_IMETHOD GetDataBase(nsIRDFDataBase*& rDataBase) = 0;
|
||||
|
||||
/**
|
||||
* Given an nsIRDFContent element in the document, create its
|
||||
* "content children," that is, a set of nsIRDFContent elements that
|
||||
* should appear as the node's children in the content model.
|
||||
*/
|
||||
NS_IMETHOD CreateChildren(nsIRDFContent* element) = 0;
|
||||
|
||||
// XXX the following two methods should probably accept strings as
|
||||
// parameters so you can mess with them via JS. Also, should they
|
||||
// take a "notify" parameter that would control whether any viewers
|
||||
// of the content model should be informed that the content model is
|
||||
// invalid?
|
||||
|
||||
/**
|
||||
* Add a property to the set of "tree properties" that the document
|
||||
* should use when constructing the content model from the RDF
|
||||
* graph.
|
||||
*/
|
||||
NS_IMETHOD AddTreeProperty(nsIRDFResource* resource) = 0;
|
||||
|
||||
/**
|
||||
* Remove a property from the set of "tree properties" that the
|
||||
* document should use when constructing the content model from the
|
||||
* RDF graph.
|
||||
*/
|
||||
NS_IMETHOD RemoveTreeProperty(nsIRDFResource* resource) = 0;
|
||||
|
||||
/**
|
||||
* Determine whether the specified property is a "tree" property.
|
||||
*/
|
||||
NS_IMETHOD IsTreeProperty(nsIRDFResource* aProperty, PRBool* aResult) const = 0;
|
||||
|
||||
NS_IMETHOD MapResource(nsIRDFResource* aResource, nsIRDFContent* aContent) = 0;
|
||||
NS_IMETHOD UnMapResource(nsIRDFResource* aResource, nsIRDFContent* aContent) = 0;
|
||||
NS_IMETHOD SplitProperty(nsIRDFResource* aResource, PRInt32* aNameSpaceID, nsIAtom** aTag) = 0;
|
||||
};
|
||||
|
||||
// factory functions
|
||||
nsresult NS_NewRDFDocument(nsIRDFDocument** result);
|
||||
|
||||
#endif // nsIRDFDocument_h___
|
||||
58
mozilla/rdf/content/src/Makefile.in
Normal file
58
mozilla/rdf/content/src/Makefile.in
Normal file
@@ -0,0 +1,58 @@
|
||||
#!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 = rdfcontent_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsRDFContentUtils.cpp \
|
||||
nsRDFDOMNodeList.cpp \
|
||||
nsRDFDocument.cpp \
|
||||
nsRDFGenericElement.cpp \
|
||||
nsRDFHTMLBuilder.cpp \
|
||||
nsRDFResourceElement.cpp \
|
||||
nsRDFTreeBuilder.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
REQUIRES = dom js netlib rdf raptor xpcom
|
||||
|
||||
# XXX This is a dependency on rdfutil.h: it'll go away once that becomes
|
||||
# a first-class XPCOM interface.
|
||||
INCLUDES += -I$(srcdir)/../../base/src
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
# we don't want the shared lib
|
||||
NO_SHARED_LIB=1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
49
mozilla/rdf/content/src/makefile.win
Normal file
49
mozilla/rdf/content/src/makefile.win
Normal file
@@ -0,0 +1,49 @@
|
||||
#!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
|
||||
LIBRARY_NAME=rdfcontent_s
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsRDFContentUtils.obj \
|
||||
.\$(OBJDIR)\nsRDFDOMNodeList.obj \
|
||||
.\$(OBJDIR)\nsRDFDocument.obj \
|
||||
.\$(OBJDIR)\nsRDFGenericElement.obj \
|
||||
.\$(OBJDIR)\nsRDFHTMLBuilder.obj \
|
||||
.\$(OBJDIR)\nsRDFResourceElement.obj \
|
||||
.\$(OBJDIR)\nsRDFTreeBuilder.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(DEPTH)\rdf\base\src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
|
||||
|
||||
53
mozilla/rdf/content/src/nsGenericAttribute.h
Normal file
53
mozilla/rdf/content/src/nsGenericAttribute.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* -*- 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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsGenericAttribute_h__
|
||||
#define nsGenericAttribute_h__
|
||||
|
||||
class nsGenericAttribute
|
||||
{
|
||||
public:
|
||||
nsGenericAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue)
|
||||
: mNameSpaceID(aNameSpaceID),
|
||||
mName(aName),
|
||||
mValue(aValue)
|
||||
{
|
||||
NS_IF_ADDREF(mName);
|
||||
}
|
||||
|
||||
~nsGenericAttribute(void)
|
||||
{
|
||||
NS_IF_RELEASE(mName);
|
||||
}
|
||||
|
||||
PRInt32 mNameSpaceID;
|
||||
nsIAtom* mName;
|
||||
nsString mValue;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsGenericAttribute_h__
|
||||
|
||||
87
mozilla/rdf/content/src/nsRDFContentUtils.cpp
Normal file
87
mozilla/rdf/content/src/nsRDFContentUtils.cpp
Normal file
@@ -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 "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 "nsIContent.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); // XXX grr...
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
rdf_AttachTextNode(nsIContent* parent, nsIRDFNode* value)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString s;
|
||||
nsIContent* node = nsnull;
|
||||
nsITextContent* text = nsnull;
|
||||
nsIRDFResource* resource = nsnull;
|
||||
nsIRDFLiteral* literal = nsnull;
|
||||
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &resource))) {
|
||||
const char* p;
|
||||
if (NS_FAILED(rv = resource->GetValue(&p)))
|
||||
goto error;
|
||||
|
||||
s = p;
|
||||
}
|
||||
else if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, (void**) &literal))) {
|
||||
const PRUnichar* p;
|
||||
if (NS_FAILED(rv = literal->GetValue(&p)))
|
||||
goto error;
|
||||
|
||||
s = p;
|
||||
}
|
||||
else {
|
||||
PR_ASSERT(0);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kTextNodeCID,
|
||||
nsnull,
|
||||
kIContentIID,
|
||||
(void**) &node)))
|
||||
goto error;
|
||||
|
||||
if (NS_FAILED(rv = node->QueryInterface(kITextContentIID, (void**) &text)))
|
||||
goto error;
|
||||
|
||||
if (NS_FAILED(rv = text->SetText(s.GetUnicode(), s.Length(), PR_FALSE)))
|
||||
goto error;
|
||||
|
||||
// hook it up to the child
|
||||
if (NS_FAILED(rv = parent->AppendChildTo(NS_STATIC_CAST(nsIContent*, node), PR_TRUE)))
|
||||
goto error;
|
||||
|
||||
error:
|
||||
NS_IF_RELEASE(node);
|
||||
NS_IF_RELEASE(text);
|
||||
return rv;
|
||||
}
|
||||
|
||||
49
mozilla/rdf/content/src/nsRDFContentUtils.h
Normal file
49
mozilla/rdf/content/src/nsRDFContentUtils.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Utility routines used throughout the content model library.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsRDFContentUtils_h__
|
||||
#define nsRDFContentUtils_h__
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMNodeList;
|
||||
class nsIRDFNode;
|
||||
class nsString;
|
||||
|
||||
nsresult
|
||||
rdf_GetQuotedAttributeValue(const nsString& aSource,
|
||||
const nsString& aAttribute,
|
||||
nsString& aValue);
|
||||
|
||||
nsresult
|
||||
rdf_AttachTextNode(nsIContent* parent, nsIRDFNode* value);
|
||||
|
||||
// In nsRDFDOMNodeList.cpp
|
||||
extern nsresult
|
||||
NS_NewRDFDOMNodeList(nsIDOMNodeList** aChildNodes, nsIContent* aElement);
|
||||
|
||||
#endif // nsRDFContentUtils_h__
|
||||
|
||||
107
mozilla/rdf/content/src/nsRDFDOMNodeList.cpp
Normal file
107
mozilla/rdf/content/src/nsRDFDOMNodeList.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 "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 "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
|
||||
class RDFDOMNodeListImpl : public nsIDOMNodeList {
|
||||
private:
|
||||
nsIContent* mElement;
|
||||
|
||||
public:
|
||||
RDFDOMNodeListImpl(nsIContent* element) : mElement(element) {
|
||||
NS_IF_ADDREF(mElement);
|
||||
}
|
||||
|
||||
virtual ~RDFDOMNodeListImpl(void) {
|
||||
NS_IF_RELEASE(mElement);
|
||||
}
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_IDOMNODELIST
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(RDFDOMNodeListImpl, kIDOMNodeListIID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFDOMNodeListImpl::GetLength(PRUint32* aLength)
|
||||
{
|
||||
PRInt32 count;
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = mElement->ChildCount(count)))
|
||||
return rv;
|
||||
*aLength = count;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFDOMNodeListImpl::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
// XXX naive. probably breaks when there are pseudo elements or something.
|
||||
nsresult rv;
|
||||
nsIContent* contentChild;
|
||||
if (NS_FAILED(rv = mElement->ChildAt(aIndex, contentChild)))
|
||||
return rv;
|
||||
|
||||
rv = contentChild->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
NS_RELEASE(contentChild);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFDOMNodeList(nsIDOMNodeList** aResult, nsIContent* aElement)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aElement != nsnull, "null ptr");
|
||||
if (! aElement)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFDOMNodeListImpl* list = new RDFDOMNodeListImpl(aElement);
|
||||
if (! list)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(list);
|
||||
*aResult = list;
|
||||
return NS_OK;
|
||||
}
|
||||
1992
mozilla/rdf/content/src/nsRDFDocument.cpp
Normal file
1992
mozilla/rdf/content/src/nsRDFDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1130
mozilla/rdf/content/src/nsRDFGenericElement.cpp
Normal file
1130
mozilla/rdf/content/src/nsRDFGenericElement.cpp
Normal file
File diff suppressed because it is too large
Load Diff
320
mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
Normal file
320
mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
Normal file
@@ -0,0 +1,320 @@
|
||||
/* -*- 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 nsIRDFDocument implementation that builds an HTML-like model,
|
||||
complete with text nodes. The model can be displayed in a vanilla
|
||||
HTML content viewer by applying CSS2 styles to the text.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIRDFContent.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFDataBase.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RDFHTMLBuilderImpl : public nsIRDFContentModelBuilder
|
||||
{
|
||||
private:
|
||||
nsIRDFDocument* mDocument;
|
||||
nsIRDFDataBase* mDB;
|
||||
|
||||
public:
|
||||
RDFHTMLBuilderImpl();
|
||||
virtual ~RDFHTMLBuilderImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFContentModelBuilder interface
|
||||
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
|
||||
NS_IMETHOD CreateRoot(nsIRDFResource* aResource);
|
||||
NS_IMETHOD OnAssert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
|
||||
NS_IMETHOD OnUnassert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
|
||||
|
||||
// Implementation methods
|
||||
nsresult AddTreeChild(nsIRDFContent* aParent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFResource* value);
|
||||
|
||||
nsresult AddLeafChild(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFLiteral* value);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static nsIAtom* kIdAtom;
|
||||
|
||||
RDFHTMLBuilderImpl::RDFHTMLBuilderImpl(void)
|
||||
: mDocument(nsnull),
|
||||
mDB(nsnull)
|
||||
{
|
||||
if (nsnull == kIdAtom) {
|
||||
kIdAtom = NS_NewAtom("ID");
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(kIdAtom);
|
||||
}
|
||||
}
|
||||
|
||||
RDFHTMLBuilderImpl::~RDFHTMLBuilderImpl(void)
|
||||
{
|
||||
nsrefcnt refcnt;
|
||||
NS_RELEASE2(kIdAtom, refcnt);
|
||||
|
||||
NS_IF_RELEASE(mDB);
|
||||
// mDocument is _not_ refcounted
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ISUPPORTS(RDFHTMLBuilderImpl, kIRDFContentModelBuilderIID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
RDFHTMLBuilderImpl::AddTreeChild(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFResource* value)
|
||||
{
|
||||
// If it's a tree property, then create a child element whose
|
||||
// value is the value of the property. We'll also attach an "ID="
|
||||
// attribute to the new child; e.g.,
|
||||
//
|
||||
// <parent>
|
||||
// <property id="value">
|
||||
// <!-- recursively generated -->
|
||||
// </property>
|
||||
// ...
|
||||
// </parent>
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 nameSpaceID;
|
||||
nsIAtom* tag = nsnull;
|
||||
nsIRDFContent* child = nsnull;
|
||||
const char* p;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, &tag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFResourceElement(&child, value, nameSpaceID, tag, PR_TRUE)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = value->GetValue(&p)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = child->SetAttribute(kNameSpaceID_HTML, kIdAtom, p, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
rv = parent->AppendChildTo(child, PR_TRUE);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(child);
|
||||
NS_IF_RELEASE(tag);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFHTMLBuilderImpl::AddLeafChild(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFLiteral* value)
|
||||
{
|
||||
// Otherwise, it's not a tree property. So we'll just create a
|
||||
// new element for the property, and a simple text node for
|
||||
// its value; e.g.,
|
||||
//
|
||||
// <parent>
|
||||
// <property>value</property>
|
||||
// ...
|
||||
// </parent>
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 nameSpaceID;
|
||||
nsIAtom* tag = nsnull;
|
||||
nsIRDFContent* child = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, &tag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFResourceElement(&child, property, nameSpaceID, tag, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = parent->AppendChildTo(child, PR_TRUE)))
|
||||
goto done;
|
||||
|
||||
rv = rdf_AttachTextNode(child, value);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(tag);
|
||||
NS_IF_RELEASE(child);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::SetDocument(nsIRDFDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION(aDocument != nsnull, "null ptr");
|
||||
if (! aDocument)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mDocument = aDocument; // not refcounted
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = mDocument->GetDataBase(mDB)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::CreateRoot(nsIRDFResource* aResource)
|
||||
{
|
||||
NS_PRECONDITION(mDocument != nsnull, "not initialized");
|
||||
if (! mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv;
|
||||
nsIAtom* tag = nsnull;
|
||||
nsIDocument* doc = nsnull;
|
||||
nsIContent* root = nsnull;
|
||||
nsIRDFContent* body = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->QueryInterface(kIDocumentIID, (void**) &doc)))
|
||||
goto done;
|
||||
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
if ((tag = NS_NewAtom("DOCUMENT")) == nsnull)
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFGenericElement(&root, kNameSpaceID_None, tag)))
|
||||
goto done;
|
||||
|
||||
doc->SetRootContent(NS_STATIC_CAST(nsIContent*, root));
|
||||
|
||||
NS_RELEASE(tag);
|
||||
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
if ((tag = NS_NewAtom("BODY")) == nsnull)
|
||||
goto done;
|
||||
|
||||
// PR_TRUE indicates that children should be recursively generated on demand
|
||||
if (NS_FAILED(rv = NS_NewRDFResourceElement(&body, aResource, kNameSpaceID_None, tag, PR_TRUE)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = root->AppendChildTo(body, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(body);
|
||||
NS_IF_RELEASE(root);
|
||||
NS_IF_RELEASE(tag);
|
||||
NS_IF_RELEASE(doc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::OnAssert(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* value)
|
||||
{
|
||||
NS_PRECONDITION(mDocument != nsnull, "not initialized");
|
||||
if (! mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsIRDFResource* valueResource;
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &valueResource))) {
|
||||
// If it's a tree property or an RDF container, then add it as
|
||||
// a tree child and return.
|
||||
PRBool isTreeProperty;
|
||||
if ((NS_SUCCEEDED(rv = mDocument->IsTreeProperty(property, &isTreeProperty)) && isTreeProperty) ||
|
||||
(rdf_IsContainer(mDB, valueResource))) {
|
||||
rv = AddTreeChild(parent, property, valueResource);
|
||||
NS_RELEASE(valueResource);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Otherwise, fall through and add try to add it as a property
|
||||
NS_RELEASE(valueResource);
|
||||
}
|
||||
|
||||
nsIRDFLiteral* valueLiteral;
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, (void**) &valueLiteral))) {
|
||||
rv = AddLeafChild(parent, property, valueLiteral);
|
||||
NS_RELEASE(valueLiteral);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::OnUnassert(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* value)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFHTMLBuilder(nsIRDFContentModelBuilder** result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFHTMLBuilderImpl* builder = new RDFHTMLBuilderImpl();
|
||||
if (! builder)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(builder);
|
||||
*result = builder;
|
||||
return NS_OK;
|
||||
}
|
||||
1416
mozilla/rdf/content/src/nsRDFResourceElement.cpp
Normal file
1416
mozilla/rdf/content/src/nsRDFResourceElement.cpp
Normal file
File diff suppressed because it is too large
Load Diff
757
mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
Normal file
757
mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
Normal file
@@ -0,0 +1,757 @@
|
||||
/* -*- 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 nsIRDFDocument implementation that builds a tree widget XUL
|
||||
content model that is to be used with a tree control.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIRDFContent.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFDataBase.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Columns);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Column);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Title);
|
||||
|
||||
static const char* kColumnsTag = "COLUMNS";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RDFTreeBuilderImpl : public nsIRDFContentModelBuilder
|
||||
{
|
||||
private:
|
||||
nsIRDFDocument* mDocument;
|
||||
nsIRDFService* mRDFService;
|
||||
nsIRDFDataBase* mDB;
|
||||
|
||||
public:
|
||||
RDFTreeBuilderImpl();
|
||||
virtual ~RDFTreeBuilderImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFContentModelBuilder interface
|
||||
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
|
||||
NS_IMETHOD CreateRoot(nsIRDFResource* aResource);
|
||||
NS_IMETHOD OnAssert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
|
||||
NS_IMETHOD OnUnassert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
|
||||
|
||||
|
||||
// Implementation methods
|
||||
|
||||
/**
|
||||
* Ensure that the specified tag exists as a child of the
|
||||
* parent element.
|
||||
*/
|
||||
nsresult
|
||||
EnsureChildElement(nsIContent* parent,
|
||||
nsIAtom* tag,
|
||||
nsIContent*& result);
|
||||
|
||||
/**
|
||||
* Add a new child to the content model from a tree property. This creates
|
||||
* the necessary cruft in the content model to ensure that content will
|
||||
* recursively be generated as the content model is descended.
|
||||
*/
|
||||
nsresult
|
||||
AddTreeChild(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFResource* value);
|
||||
|
||||
/**
|
||||
* Add a single column to the content model.
|
||||
*/
|
||||
nsresult
|
||||
AddColumn(nsIContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFLiteral* title);
|
||||
|
||||
|
||||
/**
|
||||
* Add columns to the content model from an RDF container (sequence or bag)
|
||||
*/
|
||||
nsresult
|
||||
AddColumnsFromContainer(nsIContent* parent,
|
||||
nsIRDFResource* columns);
|
||||
|
||||
|
||||
/**
|
||||
* Add columns to the content model from a set of multi-attributes
|
||||
*/
|
||||
nsresult
|
||||
AddColumnsFromMultiAttributes(nsIContent* parent,
|
||||
nsIRDFResource* columns);
|
||||
|
||||
/**
|
||||
* Add columns to the content model.
|
||||
*/
|
||||
nsresult
|
||||
AddColumns(nsIContent* parent,
|
||||
nsIRDFResource* columns);
|
||||
|
||||
/**
|
||||
* Add a new property element to the content model
|
||||
*/
|
||||
nsresult
|
||||
AddPropertyChild(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* value);
|
||||
|
||||
/**
|
||||
* Determine if the specified property on the content element is
|
||||
* a tree property.
|
||||
*/
|
||||
PRBool
|
||||
IsTreeProperty(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFResource* value);
|
||||
|
||||
/**
|
||||
* Determine if the specified property on the content element is
|
||||
* the root columns property.
|
||||
*/
|
||||
PRBool
|
||||
IsRootColumnsProperty(nsIRDFContent* parent,
|
||||
nsIRDFResource* property);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static nsIAtom* kIdAtom;
|
||||
static nsIAtom* kOpenAtom;
|
||||
static nsIAtom* kFolderAtom;
|
||||
static nsIAtom* kChildrenAtom;
|
||||
static nsIAtom* kColumnsAtom;
|
||||
|
||||
nsresult
|
||||
NS_NewRDFTreeBuilder(nsIRDFContentModelBuilder** result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFTreeBuilderImpl* builder = new RDFTreeBuilderImpl();
|
||||
if (! builder)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(builder);
|
||||
*result = builder;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFTreeBuilderImpl::RDFTreeBuilderImpl(void)
|
||||
{
|
||||
if (nsnull == kIdAtom) {
|
||||
kIdAtom = NS_NewAtom("ID");
|
||||
kOpenAtom = NS_NewAtom("OPEN");
|
||||
kFolderAtom = NS_NewAtom("FOLDER");
|
||||
kChildrenAtom = NS_NewAtom("CHILDREN");
|
||||
kColumnsAtom = NS_NewAtom("COLUMNS");
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(kIdAtom);
|
||||
NS_ADDREF(kOpenAtom);
|
||||
NS_ADDREF(kFolderAtom);
|
||||
NS_ADDREF(kChildrenAtom);
|
||||
NS_ADDREF(kColumnsAtom);
|
||||
}
|
||||
}
|
||||
|
||||
RDFTreeBuilderImpl::~RDFTreeBuilderImpl(void)
|
||||
{
|
||||
NS_IF_RELEASE(mDB);
|
||||
|
||||
if (mRDFService)
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||
|
||||
nsrefcnt refcnt;
|
||||
NS_RELEASE2(kIdAtom, refcnt);
|
||||
NS_RELEASE2(kOpenAtom, refcnt);
|
||||
NS_RELEASE2(kFolderAtom, refcnt);
|
||||
NS_RELEASE2(kChildrenAtom, refcnt);
|
||||
NS_RELEASE2(kColumnsAtom, refcnt);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ISUPPORTS(RDFTreeBuilderImpl, kIRDFContentModelBuilderIID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFContentModelBuilder methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFTreeBuilderImpl::SetDocument(nsIRDFDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION(aDocument != nsnull, "null ptr");
|
||||
if (! aDocument)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mDocument = aDocument; // not refcounted
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = mDocument->GetDataBase(mDB)))
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &mRDFService)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFTreeBuilderImpl::CreateRoot(nsIRDFResource* aResource)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIAtom* tag = nsnull;
|
||||
nsIRDFContent* root = nsnull;
|
||||
nsIDocument* doc = nsnull;
|
||||
|
||||
if ((tag = NS_NewAtom("ROOT")) == nsnull)
|
||||
goto done;
|
||||
|
||||
// PR_TRUE indicates that children should be recursively generated on demand
|
||||
if (NS_FAILED(rv = NS_NewRDFResourceElement(&root, aResource, kNameSpaceID_None, tag, PR_TRUE)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->QueryInterface(kIDocumentIID, (void**) &doc)))
|
||||
goto done;
|
||||
|
||||
doc->SetRootContent(root);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(doc);
|
||||
NS_IF_RELEASE(root);
|
||||
NS_IF_RELEASE(tag);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFTreeBuilderImpl::OnAssert(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* value)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIRDFResource* resource;
|
||||
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &resource))) {
|
||||
if (IsRootColumnsProperty(parent, property)) {
|
||||
rv = AddColumns(parent, resource);
|
||||
NS_RELEASE(resource);
|
||||
return rv;
|
||||
}
|
||||
else if (IsTreeProperty(parent, property, resource)) {
|
||||
rv = AddTreeChild(parent, property, resource);
|
||||
NS_RELEASE(resource);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// fall through and add as a property
|
||||
NS_RELEASE(resource);
|
||||
}
|
||||
|
||||
rv = AddPropertyChild(parent, property, value);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFTreeBuilderImpl::OnUnassert(nsIRDFContent* aElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aValue)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation methods
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::EnsureChildElement(nsIContent* parent,
|
||||
nsIAtom* tag,
|
||||
nsIContent*& result)
|
||||
{
|
||||
nsresult rv;
|
||||
result = nsnull; // reasonable default
|
||||
|
||||
PRInt32 count;
|
||||
if (NS_FAILED(rv = parent->ChildCount(count)))
|
||||
return rv;
|
||||
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIContent* kid;
|
||||
if (NS_FAILED(rv = parent->ChildAt(i, kid)))
|
||||
break;
|
||||
|
||||
nsIAtom* kidTag;
|
||||
if (NS_FAILED(rv = kid->GetTag(kidTag))) {
|
||||
NS_RELEASE(kid);
|
||||
break;
|
||||
}
|
||||
|
||||
if (kidTag == tag) {
|
||||
NS_RELEASE(kidTag);
|
||||
result = kid; // no need to addref, got it from ChildAt().
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_RELEASE(kidTag);
|
||||
NS_RELEASE(kid);
|
||||
}
|
||||
|
||||
nsIContent* element = nsnull;
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
goto done;
|
||||
|
||||
// if we get here, we need to construct a new <children> element.
|
||||
|
||||
// XXX no namespace?
|
||||
if (NS_FAILED(rv = NS_NewRDFGenericElement(&element, kNameSpaceID_None, tag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = parent->AppendChildTo(element, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
result = element;
|
||||
NS_ADDREF(result);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(element);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::AddTreeChild(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFResource* value)
|
||||
{
|
||||
// If it's a tree property, then we need to add the new child
|
||||
// element to a special "children" element in the parent. The
|
||||
// child element's value will be the value of the
|
||||
// property. We'll also attach an "ID=" attribute to the new
|
||||
// child; e.g.,
|
||||
//
|
||||
// <parent>
|
||||
// ...
|
||||
// <children>
|
||||
// <item id="value">
|
||||
// <!-- recursively generated -->
|
||||
// </item>
|
||||
// </children>
|
||||
// ...
|
||||
// </parent>
|
||||
|
||||
nsresult rv;
|
||||
nsIRDFContent* child = nsnull;
|
||||
nsIContent* children = nsnull;
|
||||
const char* p;
|
||||
|
||||
// Ensure that the <children> element exists on the parent.
|
||||
if (NS_FAILED(rv = EnsureChildElement(parent, kChildrenAtom, children)))
|
||||
goto done;
|
||||
|
||||
// Create a new child that represents the "value"
|
||||
// resource. PR_TRUE indicates that we want the child to
|
||||
// dynamically generate its own kids.
|
||||
if (NS_FAILED(rv = NS_NewRDFResourceElement(&child, value, kNameSpaceID_None, kFolderAtom, PR_TRUE)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = value->GetValue(&p)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = child->SetAttribute(kNameSpaceID_HTML, kIdAtom, p, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
#define ALL_NODES_OPEN_HACK
|
||||
#ifdef ALL_NODES_OPEN_HACK
|
||||
if (NS_FAILED(rv = child->SetAttribute(kNameSpaceID_None, kOpenAtom, "TRUE", PR_FALSE)))
|
||||
goto done;
|
||||
#endif
|
||||
|
||||
// Finally, add the thing to the <children> element.
|
||||
children->AppendChildTo(child, PR_TRUE);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(child);
|
||||
NS_IF_RELEASE(children);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::AddColumn(nsIContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFLiteral* title)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsIAtom* tag = nsnull;
|
||||
nsIContent* column = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, &tag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFGenericElement(&column, nameSpaceID, tag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = parent->AppendChildTo(column, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
rv = rdf_AttachTextNode(column, title);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(tag);
|
||||
NS_IF_RELEASE(column);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
When columns are specified using a container, the data model is
|
||||
assumed to look something like the following example:
|
||||
|
||||
<RDF:RDF>
|
||||
<RDF:Description RDF:about="nc:history">
|
||||
<NC:Columns>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<NC:Description
|
||||
NC:Column="http://home.netscape.com/NC-rdf#LastVisitDate"
|
||||
NC:Title="Date Last Visited"/>
|
||||
</RDF:li>
|
||||
|
||||
<RDF:li>
|
||||
<NC:Description
|
||||
NC:Column="http://home.netscape.com/NC-rdf#URL"
|
||||
NC:Title="URL"/>
|
||||
</RDF:li>
|
||||
|
||||
<RDF:li>
|
||||
<NC:Description
|
||||
NC:Column="http://home.netscape.com/NC-rdf#Title"
|
||||
NC:Title="Title"/>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</NC:Columns>
|
||||
|
||||
<!-- ...whatever... -->
|
||||
|
||||
</RDF:Description>
|
||||
</RDF:RDF>
|
||||
|
||||
*/
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::AddColumnsFromContainer(nsIContent* parent,
|
||||
nsIRDFResource* columns)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsIContent* columnsElement;
|
||||
if (NS_FAILED(rv = EnsureChildElement(parent, kColumnsAtom, columnsElement)))
|
||||
return rv;
|
||||
|
||||
nsIRDFResource* NC_Column = nsnull;
|
||||
nsIRDFResource* NC_Title = nsnull;
|
||||
nsIRDFAssertionCursor* cursor = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = mRDFService->GetResource(kURINC_Column, &NC_Column)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = mRDFService->GetResource(kURINC_Title, &NC_Title)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewContainerCursor(mDB, columns, &cursor)))
|
||||
goto done;
|
||||
|
||||
while (NS_SUCCEEDED(rv = cursor->Advance())) {
|
||||
nsIRDFNode* columnNode;
|
||||
if (NS_SUCCEEDED(rv = cursor->GetObject(&columnNode))) {
|
||||
nsIRDFResource* column;
|
||||
if (NS_SUCCEEDED(rv = columnNode->QueryInterface(kIRDFResourceIID, (void**) &column))) {
|
||||
// XXX okay, error recovery leaves a bit to be desired here...
|
||||
nsIRDFNode* propertyNode = nsnull;
|
||||
nsIRDFResource* property = nsnull;
|
||||
nsIRDFNode* titleNode = nsnull;
|
||||
nsIRDFLiteral* title = nsnull;
|
||||
|
||||
rv = mDB->GetTarget(column, NC_Column, PR_TRUE, &propertyNode);
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
rv = propertyNode->QueryInterface(kIRDFResourceIID, (void**) &property);
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
rv = mDB->GetTarget(column, NC_Title, PR_TRUE, &titleNode);
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
rv = titleNode->QueryInterface(kIRDFLiteralIID, (void**) &title);
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
AddColumn(columnsElement, property, title);
|
||||
|
||||
NS_IF_RELEASE(title);
|
||||
NS_IF_RELEASE(titleNode);
|
||||
NS_IF_RELEASE(property);
|
||||
NS_IF_RELEASE(propertyNode);
|
||||
|
||||
NS_RELEASE(column);
|
||||
}
|
||||
NS_RELEASE(columnNode);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
}
|
||||
|
||||
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
|
||||
// This is a "normal" return code from nsIRDFCursor::Advance().
|
||||
rv = NS_OK;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(cursor);
|
||||
NS_IF_RELEASE(NC_Title);
|
||||
NS_IF_RELEASE(NC_Column);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
When the columns are specified using multi-attributes, the data
|
||||
model assumed to look something like the following example:
|
||||
|
||||
<RDF:RDF>
|
||||
<RDF:Description RDF:about="nc:history">
|
||||
<NC:Columns>
|
||||
<NC:LastVisitDate RDF:ID="#001">Date Last Visited</NC:LastVisitDate>
|
||||
<NC:URL RDF:ID="#002">URL</NC:URL>
|
||||
<NC:Title RDF:ID="#003">Title</NC:URL>
|
||||
<NC:Order>
|
||||
<RDF:Seq>
|
||||
<RDF:li RDF:resource="#003"/>
|
||||
<RDF:li RDF:resource="#002"/>
|
||||
<RDF:li RDF:resource="#001"/>
|
||||
</RDF:Seq>
|
||||
</NC:Order>
|
||||
</NC:Columns>
|
||||
|
||||
<!-- ...whatever... -->
|
||||
|
||||
</RDF:Description>
|
||||
</RDF:RDF>
|
||||
|
||||
TODO: implement the NC:Order property on the column set. This is not
|
||||
exactly a slam dunk; it requires getting reification working
|
||||
properly in the RDF content sink.
|
||||
|
||||
*/
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::AddColumnsFromMultiAttributes(nsIContent* parent,
|
||||
nsIRDFResource* columns)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsIContent* columnsElement;
|
||||
if (NS_FAILED(rv = EnsureChildElement(parent, kColumnsAtom, columnsElement)))
|
||||
return rv;
|
||||
|
||||
nsIRDFArcsOutCursor* cursor = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = mDB->ArcLabelsOut(columns, &cursor)))
|
||||
goto done;
|
||||
|
||||
while (NS_SUCCEEDED(rv = cursor->Advance())) {
|
||||
nsIRDFResource* property;
|
||||
if (NS_SUCCEEDED(rv = cursor->GetPredicate(&property))) {
|
||||
nsIRDFNode* titleNode;
|
||||
if (NS_SUCCEEDED(rv = mDB->GetTarget(columns, property, PR_TRUE, &titleNode))) {
|
||||
nsIRDFLiteral* title;
|
||||
if (NS_SUCCEEDED(rv = titleNode->QueryInterface(kIRDFLiteralIID,
|
||||
(void**) &title))) {
|
||||
rv = AddColumn(columnsElement, property, title);
|
||||
NS_RELEASE(title);
|
||||
}
|
||||
NS_RELEASE(titleNode);
|
||||
}
|
||||
NS_RELEASE(property);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
}
|
||||
|
||||
NS_ASSERTION(rv == NS_ERROR_RDF_CURSOR_EMPTY, "error reading from cursor");
|
||||
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
|
||||
// This is a reasonable return code from nsIRDFCursor::Advance()
|
||||
rv = NS_OK;
|
||||
|
||||
// XXX Now search for an "order" property and apply it to the
|
||||
// above to sort them...
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(cursor);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::AddColumns(nsIContent* parent,
|
||||
nsIRDFResource* columns)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (rdf_IsContainer(mDB, columns)) {
|
||||
rv = AddColumnsFromContainer(parent, columns);
|
||||
}
|
||||
else {
|
||||
rv = AddColumnsFromMultiAttributes(parent, columns);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::AddPropertyChild(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* value)
|
||||
{
|
||||
// Otherwise, it's not a tree property. So we'll just create a
|
||||
// new element for the property, and a simple text node for
|
||||
// its value; e.g.,
|
||||
//
|
||||
// <parent>
|
||||
// <columns>
|
||||
// <folder>value</folder>
|
||||
// </columns>
|
||||
// ...
|
||||
// </parent>
|
||||
nsresult rv;
|
||||
nsIContent* columnsElement = nsnull;
|
||||
nsIRDFContent* child = nsnull;
|
||||
PRInt32 nameSpaceID;
|
||||
nsIAtom* tag = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = EnsureChildElement(parent, kColumnsAtom, columnsElement)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, &tag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFResourceElement(&child, property, nameSpaceID, tag, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = columnsElement->AppendChildTo(child, PR_TRUE)))
|
||||
goto done;
|
||||
|
||||
rv = rdf_AttachTextNode(child, value);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(tag);
|
||||
NS_IF_RELEASE(columnsElement);
|
||||
NS_IF_RELEASE(child);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
RDFTreeBuilderImpl::IsTreeProperty(nsIRDFContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFResource* value)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRBool isTreeProperty = PR_FALSE;
|
||||
if (NS_FAILED(rv = mDocument->IsTreeProperty(property, &isTreeProperty)))
|
||||
goto done;
|
||||
|
||||
if (isTreeProperty)
|
||||
goto done;
|
||||
|
||||
isTreeProperty = rdf_IsContainer(mDB, value);
|
||||
|
||||
done:
|
||||
return isTreeProperty;
|
||||
}
|
||||
|
||||
PRBool
|
||||
RDFTreeBuilderImpl::IsRootColumnsProperty(nsIRDFContent* parent,
|
||||
nsIRDFResource* property)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsIDocument* doc = nsnull;
|
||||
nsIContent* rootContent = nsnull;
|
||||
|
||||
PRBool isColumnsProperty = PR_FALSE;;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->QueryInterface(kIDocumentIID, (void**) &doc)))
|
||||
goto done;
|
||||
|
||||
if ((rootContent = doc->GetRootContent()) == nsnull)
|
||||
goto done;
|
||||
|
||||
if (parent != rootContent)
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(property->EqualsString(kURINC_Columns, &isColumnsProperty)))
|
||||
goto done;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(rootContent);
|
||||
NS_IF_RELEASE(doc);
|
||||
return isColumnsProperty;
|
||||
}
|
||||
29
mozilla/rdf/datasource/Makefile.in
Normal file
29
mozilla/rdf/datasource/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
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
27
mozilla/rdf/datasource/makefile.win
Normal file
27
mozilla/rdf/datasource/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>
|
||||
2
mozilla/rdf/datasource/public/MANIFEST
Normal file
2
mozilla/rdf/datasource/public/MANIFEST
Normal file
@@ -0,0 +1,2 @@
|
||||
nsIRDFMail.h
|
||||
|
||||
35
mozilla/rdf/datasource/public/Makefile.in
Normal file
35
mozilla/rdf/datasource/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 = rdf
|
||||
|
||||
EXPORTS = \
|
||||
nsIRDFMail.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
28
mozilla/rdf/datasource/public/makefile.win
Normal file
28
mozilla/rdf/datasource/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.
|
||||
|
||||
|
||||
MODULE=rdf
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsIRDFMail.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
56
mozilla/rdf/datasource/public/nsIRDFHistory.h
Normal file
56
mozilla/rdf/datasource/public/nsIRDFHistory.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 "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 nsIRDFHistory_h__
|
||||
#define nsIRDFHistory_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {115CE051-A59D-11d2-80B6-006097B76B8E}
|
||||
#define NS_IRDFWEBPAGE_IID \
|
||||
{ 0x115ce051, 0xa59d, 0x11d2, { 0x80, 0xb6, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } };
|
||||
|
||||
// {1A880051-A59D-11d2-80B6-006097B76B8E}
|
||||
#define NS_IRDFHISTORYDATASOURCE_IID \
|
||||
{ 0x1a880051, 0xa59d, 0x11d2, { 0x80, 0xb6, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } };
|
||||
|
||||
|
||||
class nsIRDFHistoryDataSource : public nsIRDFDataSource {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Add the specified item to history
|
||||
*/
|
||||
NS_IMETHOD AddPage (const char* uri) = 0;
|
||||
|
||||
/**
|
||||
* Set the title of the page
|
||||
*/
|
||||
NS_IMETHOD SetPageTitle (const char* uri, PRUnichar* title) = 0;
|
||||
|
||||
/**
|
||||
* Remove the page from history
|
||||
*/
|
||||
NS_IMETHOD RemovePage (nsIRDFResource* page) = 0;
|
||||
|
||||
/**
|
||||
* Get the uri's last visit date
|
||||
*/
|
||||
NS_IMETHOD LastVisitDate (const char* uri, unit32 *date) = 0;
|
||||
};
|
||||
128
mozilla/rdf/datasource/public/nsIRDFMail.h
Normal file
128
mozilla/rdf/datasource/public/nsIRDFMail.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* -*- 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 nsIRDFMail_h__
|
||||
#define nsIRDFMail_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
/*
|
||||
Interfaces for the mail data source.
|
||||
|
||||
The UI will interact with the mail data source via the
|
||||
nsIRDFDataSource interface. The following methods are mostly for
|
||||
netlib to talk to the database. It needs to be able to add/delete an
|
||||
account, folder or message.
|
||||
*/
|
||||
|
||||
// {669F3361-9EAF-11d2-80B4-006097B76B8E}
|
||||
#define NS_IRDFMAILDATAOURCE_IID \
|
||||
{ 0x669f3361, 0x9eaf, 0x11d2, { 0x80, 0xb4, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } }
|
||||
|
||||
class nsIRDFMailAccount;
|
||||
class nsIRDFMailFolder;
|
||||
class nsIRDFMailMessage;
|
||||
|
||||
class nsIRDFMailDataSource : public nsIRDFDataSource {
|
||||
public:
|
||||
/**
|
||||
* Add the specified mail account to the data source.
|
||||
*/
|
||||
NS_IMETHOD AddAccount (nsIRDFMailAccount* folder) = 0;
|
||||
|
||||
/**
|
||||
* Remove the specified mail account from the data source.
|
||||
*/
|
||||
NS_IMETHOD RemoveAccount (nsIRDFMailAccount* folder) = 0;
|
||||
};
|
||||
|
||||
// {9D2792E0-9EAE-11d2-80B4-006097B76B8E}
|
||||
#define NS_IMAILACCOUNT_IID \
|
||||
{ 0x9d2792e0, 0x9eae, 0x11d2, { 0x80, 0xb4, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } }
|
||||
|
||||
/**
|
||||
* A resource specialization for mail accounts.
|
||||
*/
|
||||
class nsIRDFMailAccount : public nsIRDFResource {
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetUser(nsIRDFLiteral** result) const = 0;
|
||||
|
||||
NS_IMETHOD GetHost(nsIRDFLiteral** result) const = 0;
|
||||
|
||||
NS_IMETHOD GetName(nsIRDFLiteral** result) const = 0;
|
||||
|
||||
NS_IMETHOD AddFolder (nsIRDFMailFolder* folder) = 0;
|
||||
|
||||
NS_IMETHOD RemoveFolder (nsIRDFMailFolder* folder) = 0;
|
||||
};
|
||||
|
||||
// {9D2792E1-9EAE-11d2-80B4-006097B76B8E}
|
||||
#define NS_IMAILFOLDER_IID \
|
||||
{ 0x9d2792e1, 0x9eae, 0x11d2, { 0x80, 0xb4, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } }
|
||||
|
||||
/**
|
||||
* A resource specialization for mail folders.
|
||||
*/
|
||||
class nsIRDFMailFolder : public nsIRDFResource {
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetAccount(nsIRDFMailAccount** account) = 0;
|
||||
|
||||
NS_IMETHOD GetName(nsIRDFLiteral** result) const = 0;
|
||||
|
||||
NS_IMETHOD GetMessageList (nsVoidArray** result) = 0;
|
||||
|
||||
NS_IMETHOD AddMessage (nsIRDFMailMessage* msg) = 0;
|
||||
|
||||
NS_IMETHOD RemoveMessage (nsIRDFMailMessage* msg) = 0;
|
||||
};
|
||||
|
||||
// {9D2792E2-9EAE-11d2-80B4-006097B76B8E}
|
||||
#define NS_IMAILMESSAGE_IID \
|
||||
{ 0x9d2792e2, 0x9eae, 0x11d2, { 0x80, 0xb4, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } }
|
||||
|
||||
/**
|
||||
* A resource specialization for mail messages.
|
||||
*/
|
||||
class nsIRDFMailMessage : public nsIRDFResource {
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetFolder(nsIRDFMailFolder** account) = 0;
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFLiteral** result) = 0;
|
||||
|
||||
NS_IMETHOD GetSender(nsIRDFResource** result) = 0;
|
||||
|
||||
NS_IMETHOD GetDate(nsIRDFLiteral** result) = 0;
|
||||
|
||||
NS_IMETHOD GetContent(const char* result) = 0;
|
||||
|
||||
NS_IMETHOD GetMessageID(nsIRDFLiteral** id) = 0;
|
||||
|
||||
// XXX this really sucks --- the flags, such as replied, forwarded, read, etc.
|
||||
// should have separate methods
|
||||
NS_IMETHOD GetFlags(char** result) = 0;
|
||||
|
||||
NS_IMETHOD SetFlags(const char* result) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif nsIRDFMail_h
|
||||
54
mozilla/rdf/datasource/src/Makefile.in
Normal file
54
mozilla/rdf/datasource/src/Makefile.in
Normal file
@@ -0,0 +1,54 @@
|
||||
#!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 = rdfdatasource_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsBookmarkDataSource.cpp \
|
||||
nsMailDataSource.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
REQUIRES = dom js netlib rdf raptor xpcom
|
||||
|
||||
# XXX This is a dependency on rdfutil.h: it'll go away once that becomes
|
||||
# a first-class XPCOM interface.
|
||||
INCLUDES += -I$(srcdir)/../../base/src
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
# we don't want the shared lib
|
||||
NO_SHARED_LIB=1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
50
mozilla/rdf/datasource/src/makefile.win
Normal file
50
mozilla/rdf/datasource/src/makefile.win
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=..\..\..
|
||||
MODULE=rdf
|
||||
LIBRARY_NAME=rdfdatasource_s
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsBookmarkDataSource.obj \
|
||||
.\$(OBJDIR)\nsMailDataSource.obj \
|
||||
$(NULL)
|
||||
|
||||
# XXX Note the dependency on $(DEPTH)\rdf\base\src: we use rdfutil.h over
|
||||
# in this library: this'll go away once we formalize utilities into an
|
||||
# "real live" XPCOM interface.
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(DEPTH)\rdf\base\src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
|
||||
|
||||
|
||||
|
||||
719
mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
Normal file
719
mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
Normal file
@@ -0,0 +1,719 @@
|
||||
/* -*- 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 data source that reads the 4.x "bookmarks.html" file and
|
||||
constructs an in-memory data source.
|
||||
|
||||
TO DO
|
||||
|
||||
1) Write the modified bookmarks file back to disk.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "prio.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
static const char kURINC_BookmarksRoot[] = "NC:BookmarksRoot"; // XXX?
|
||||
|
||||
#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, BookmarkAddDate);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Description);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Name);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, PersonalToolbarFolderCategory);
|
||||
|
||||
|
||||
#define WEB_NAMESPACE_URI "http://home.netscape.com/WEB-rdf#"
|
||||
DEFINE_RDF_VOCAB(WEB_NAMESPACE_URI, WEB, LastVisitDate);
|
||||
DEFINE_RDF_VOCAB(WEB_NAMESPACE_URI, WEB, LastModifiedDate);
|
||||
|
||||
|
||||
#define RDF_NAMESPACE_URI "http://www.w3.org/TR/WD-rdf-syntax#"
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, instanceOf);
|
||||
|
||||
static const char kPersonalToolbar[] = "Personal Toolbar";
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The bookmark parser knows how to read <tt>bookmarks.html</tt> and convert it
|
||||
* into an RDF graph.
|
||||
*/
|
||||
class BookmarkParser {
|
||||
protected:
|
||||
static const char* kBRString;
|
||||
static const char* kCloseDLString;
|
||||
static const char* kDDString;
|
||||
static const char* kOpenAnchorString;
|
||||
static const char* kOpenDLString;
|
||||
static const char* kOpenH3String;
|
||||
static const char* kOpenTitleString;
|
||||
static const char* kSeparatorString;
|
||||
|
||||
enum BookmarkParserState {
|
||||
eBookmarkParserState_Initial,
|
||||
eBookmarkParserState_InTitle,
|
||||
eBookmarkParserState_InH3,
|
||||
eBookmarkParserState_InItemTitle,
|
||||
eBookmarkParserState_InItemDescription
|
||||
};
|
||||
|
||||
nsIRDFService* mRDFService;
|
||||
nsIRDFDataSource* mDataSource;
|
||||
nsVoidArray mStack;
|
||||
nsIRDFResource* mLastItem;
|
||||
nsAutoString mLine;
|
||||
PRInt32 mCounter;
|
||||
nsAutoString mFolderDate;
|
||||
BookmarkParserState mState;
|
||||
|
||||
void Tokenize(const char* buf, PRInt32 size);
|
||||
void NextToken(void);
|
||||
void DoStateTransition(void);
|
||||
void CreateBookmark(void);
|
||||
|
||||
nsresult AssertTime(nsIRDFResource* subject,
|
||||
const nsString& predicateURI,
|
||||
const nsString& time);
|
||||
|
||||
public:
|
||||
BookmarkParser(void);
|
||||
~BookmarkParser();
|
||||
|
||||
nsresult Parse(PRFileDesc* file, nsIRDFDataSource* dataSource);
|
||||
};
|
||||
|
||||
|
||||
const char* BookmarkParser::kBRString = "<BR>";
|
||||
const char* BookmarkParser::kCloseDLString = "</DL>";
|
||||
const char* BookmarkParser::kDDString = "<DD>";
|
||||
const char* BookmarkParser::kOpenAnchorString = "<A";
|
||||
const char* BookmarkParser::kOpenDLString = "<DL>";
|
||||
const char* BookmarkParser::kOpenH3String = "<H3";
|
||||
const char* BookmarkParser::kOpenTitleString = "<TITLE>";
|
||||
const char* BookmarkParser::kSeparatorString = "<HR>";
|
||||
|
||||
|
||||
BookmarkParser::BookmarkParser(void)
|
||||
: mRDFService(nsnull), mDataSource(nsnull)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &mRDFService);
|
||||
|
||||
PR_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
BookmarkParser::~BookmarkParser(void)
|
||||
{
|
||||
if (mRDFService)
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
BookmarkParser::Parse(PRFileDesc* file, nsIRDFDataSource* dataSource)
|
||||
{
|
||||
NS_PRECONDITION(file && dataSource && mRDFService, "null ptr");
|
||||
if (! file)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! dataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! mRDFService)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Initialize the parser for a run...
|
||||
mDataSource = dataSource;
|
||||
mState = eBookmarkParserState_Initial;
|
||||
mCounter = 0;
|
||||
mLastItem = nsnull;
|
||||
mLine.Truncate();
|
||||
|
||||
char buf[1024];
|
||||
PRInt32 len;
|
||||
|
||||
while ((len = PR_Read(file, buf, sizeof(buf))) > 0)
|
||||
Tokenize(buf, len);
|
||||
|
||||
NS_IF_RELEASE(mLastItem);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BookmarkParser::Tokenize(const char* buf, PRInt32 size)
|
||||
{
|
||||
for (PRInt32 i = 0; i < size; ++i) {
|
||||
char c = buf[i];
|
||||
if (c == '<') {
|
||||
if (mLine.Length() > 0) {
|
||||
NextToken();
|
||||
mLine.Truncate();
|
||||
}
|
||||
}
|
||||
mLine.Append(c);
|
||||
if (c == '>') {
|
||||
if (mLine.Length() > 0) {
|
||||
NextToken();
|
||||
mLine.Truncate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BookmarkParser::NextToken(void)
|
||||
{
|
||||
if (mLine[0] == '<') {
|
||||
DoStateTransition();
|
||||
return;
|
||||
}
|
||||
|
||||
// ok, we have a piece of content. can be the title, or a
|
||||
// description
|
||||
if ((mState == eBookmarkParserState_InTitle) ||
|
||||
(mState == eBookmarkParserState_InH3)) {
|
||||
nsIRDFResource* folder;
|
||||
|
||||
if (mStack.Count() > 0) {
|
||||
// a regular old folder
|
||||
|
||||
nsAutoString folderURI(kURINC_BookmarksRoot);
|
||||
folderURI.Append('#');
|
||||
folderURI.Append(++mCounter, 10);
|
||||
|
||||
if (NS_FAILED(mRDFService->GetUnicodeResource(folderURI, &folder)))
|
||||
return;
|
||||
|
||||
nsIRDFResource* parent = (nsIRDFResource*) mStack[mStack.Count() - 1];
|
||||
rdf_Assert(mDataSource, parent, kURINC_Folder, folder);
|
||||
}
|
||||
else {
|
||||
// it's the root
|
||||
if (NS_FAILED(mRDFService->GetResource(kURINC_BookmarksRoot, &folder)))
|
||||
return;
|
||||
}
|
||||
|
||||
if (mFolderDate.Length()) {
|
||||
AssertTime(folder, kURINC_BookmarkAddDate, mFolderDate);
|
||||
mFolderDate.Truncate();
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mLastItem);
|
||||
mLastItem = folder;
|
||||
// XXX Implied
|
||||
//NS_ADDREF(mLastItem);
|
||||
//NS_RELEASE(folder);
|
||||
|
||||
if (mState != eBookmarkParserState_InTitle)
|
||||
rdf_Assert(mDataSource, mLastItem, kURINC_Name, mLine);
|
||||
|
||||
if (mLine.Find(kPersonalToolbar) == 0)
|
||||
rdf_Assert(mDataSource, mLastItem, kURIRDF_instanceOf, kURINC_PersonalToolbarFolderCategory);
|
||||
}
|
||||
else if (mState == eBookmarkParserState_InItemTitle) {
|
||||
PR_ASSERT(mLastItem);
|
||||
if (! mLastItem)
|
||||
return;
|
||||
|
||||
rdf_Assert(mDataSource, mLastItem, kURINC_Name, mLine);
|
||||
NS_IF_RELEASE(mLastItem);
|
||||
}
|
||||
else if (mState == eBookmarkParserState_InItemDescription) {
|
||||
rdf_Assert(mDataSource, mLastItem, kURINC_Description, mLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
BookmarkParser::DoStateTransition(void)
|
||||
{
|
||||
if (mLine.Find(kOpenAnchorString) == 0) {
|
||||
CreateBookmark();
|
||||
mState = eBookmarkParserState_InItemTitle;
|
||||
}
|
||||
else if (mLine.Find(kOpenH3String) == 0) {
|
||||
PRInt32 start = mLine.Find('"');
|
||||
PRInt32 end = mLine.RFind('"');
|
||||
if (start >= 0 && end >= 0)
|
||||
mLine.Mid(mFolderDate, start + 1, end - start - 1);
|
||||
mState = eBookmarkParserState_InH3;
|
||||
}
|
||||
else if (mLine.Find(kOpenTitleString) == 0) {
|
||||
mState = eBookmarkParserState_InTitle;
|
||||
}
|
||||
else if (mLine.Find(kDDString) == 0) {
|
||||
#if 0 // XXX if it doesn't already have a description? Huh?
|
||||
if (remoteStoreGetSlotValue(gLocalStore, mLastItem, gWebData->RDF_description,
|
||||
RDF_STRING_TYPE, false, true)
|
||||
== nsnull)
|
||||
#endif
|
||||
mState = eBookmarkParserState_InItemDescription;
|
||||
}
|
||||
else if (mLine.Find(kOpenDLString) == 0) {
|
||||
mStack.AppendElement(mLastItem);
|
||||
NS_ADDREF(mLastItem);
|
||||
}
|
||||
else if (mLine.Find(kCloseDLString) == 0) {
|
||||
PRInt32 count = mStack.Count();
|
||||
if (count) {
|
||||
nsIRDFNode* top = NS_STATIC_CAST(nsIRDFNode*, mStack[--count]);
|
||||
mStack.RemoveElementAt(count);
|
||||
NS_IF_RELEASE(top);
|
||||
}
|
||||
}
|
||||
else if (mLine.Find(kSeparatorString) == 0) {
|
||||
#if FIXME // separators
|
||||
addSlotValue(f, createSeparator(), gCoreVocab->RDF_parent, mStack[mStack.Count() - 1],
|
||||
RDF_RESOURCE_TYPE, nsnull);
|
||||
#endif
|
||||
mState = eBookmarkParserState_Initial;
|
||||
}
|
||||
else if ((mState == eBookmarkParserState_InItemDescription) &&
|
||||
(mLine.Find(kBRString) == 0)) {
|
||||
// XXX in the original bmk2rdf.c, we only added the
|
||||
// description in the case that it wasn't set already...why?
|
||||
rdf_Assert(mDataSource, mLastItem, kURINC_Description, mLine);
|
||||
}
|
||||
else {
|
||||
mState = eBookmarkParserState_Initial;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
BookmarkParser::CreateBookmark(void)
|
||||
{
|
||||
enum {
|
||||
eBmkAttribute_URL = 0,
|
||||
eBmkAttribute_AddDate = 1,
|
||||
eBmkAttribute_LastVisit = 2,
|
||||
eBmkAttribute_LastModified = 3
|
||||
};
|
||||
|
||||
nsAutoString values[4];
|
||||
PRInt32 index = 0;
|
||||
for (PRInt32 i = 0; i < 4; ++i) {
|
||||
PRInt32 start = mLine.Find('"', index);
|
||||
if (start == -1)
|
||||
break;
|
||||
|
||||
++start; // past the first quote
|
||||
|
||||
PRInt32 end = mLine.Find('"', start);
|
||||
PR_ASSERT(end > 0); // unterminated
|
||||
if (end == -1)
|
||||
end = mLine.Length();
|
||||
|
||||
mLine.Mid(values[i], start, end - start);
|
||||
index = end + 1;
|
||||
}
|
||||
|
||||
if (values[eBmkAttribute_URL].Length() == 0)
|
||||
return;
|
||||
|
||||
nsIRDFResource* bookmark;
|
||||
if (NS_FAILED(mRDFService->GetUnicodeResource(values[eBmkAttribute_URL], &bookmark)))
|
||||
return;
|
||||
|
||||
if (! mStack.Count())
|
||||
return;
|
||||
|
||||
nsIRDFResource* parent = (nsIRDFResource*) mStack[mStack.Count() - 1];
|
||||
if (! parent)
|
||||
return;
|
||||
|
||||
rdf_Assert(mDataSource, parent, kURINC_child, bookmark);
|
||||
|
||||
if (values[eBmkAttribute_AddDate].Length() > 0)
|
||||
AssertTime(bookmark, kURINC_BookmarkAddDate, values[eBmkAttribute_AddDate]);
|
||||
|
||||
if (values[eBmkAttribute_LastVisit].Length() > 0)
|
||||
AssertTime(bookmark, kURIWEB_LastVisitDate, values[eBmkAttribute_LastVisit]);
|
||||
|
||||
if (values[eBmkAttribute_LastModified].Length() > 0)
|
||||
AssertTime(bookmark, kURIWEB_LastModifiedDate, values[eBmkAttribute_LastModified]);
|
||||
|
||||
NS_IF_RELEASE(mLastItem);
|
||||
mLastItem = bookmark;
|
||||
// XXX Implied
|
||||
//NS_ADDREF(mLastItem);
|
||||
//NS_RELEASE(bookmark);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
BookmarkParser::AssertTime(nsIRDFResource* object,
|
||||
const nsString& predicateURI,
|
||||
const nsString& time)
|
||||
{
|
||||
// XXX
|
||||
return rdf_Assert(mDataSource, object, predicateURI, time);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// BookmarkDataSourceImpl
|
||||
|
||||
/**
|
||||
* The bookmark data source uses a <tt>BookmarkParser</tt> to read the
|
||||
* <tt>bookmarks.html</tt> file from the local disk and present an
|
||||
* in-memory RDF graph based on it.
|
||||
*/
|
||||
class BookmarkDataSourceImpl : public nsIRDFDataSource {
|
||||
protected:
|
||||
static const char* kBookmarksFilename;
|
||||
|
||||
nsIRDFDataSource* mInner;
|
||||
|
||||
nsresult ReadBookmarks(void);
|
||||
nsresult WriteBookmarks(void);
|
||||
nsresult AddColumns(void);
|
||||
|
||||
public:
|
||||
BookmarkDataSourceImpl(void);
|
||||
virtual ~BookmarkDataSourceImpl(void);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFDataSource
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(const char* *uri) const {
|
||||
return mInner->GetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source) {
|
||||
return mInner->GetSource(property, target, tv, source);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** sources) {
|
||||
return mInner->GetSources(property, target, tv, sources);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target) {
|
||||
return mInner->GetTarget(source, property, tv, target);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets) {
|
||||
return mInner->GetTargets(source, property, tv, targets);
|
||||
}
|
||||
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv) {
|
||||
return mInner->Assert(source, property, target, tv);
|
||||
}
|
||||
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target) {
|
||||
return mInner->Unassert(source, property, target);
|
||||
}
|
||||
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion) {
|
||||
return mInner->HasAssertion(source, property, target, tv, hasAssertion);
|
||||
}
|
||||
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n) {
|
||||
return mInner->AddObserver(n);
|
||||
}
|
||||
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n) {
|
||||
return mInner->RemoveObserver(n);
|
||||
}
|
||||
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels) {
|
||||
return mInner->ArcLabelsIn(node, labels);
|
||||
}
|
||||
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels) {
|
||||
return mInner->ArcLabelsOut(source, labels);
|
||||
}
|
||||
|
||||
NS_IMETHOD Flush(void);
|
||||
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult);
|
||||
|
||||
NS_IMETHOD DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// XXX we should get this from prefs.
|
||||
const char* BookmarkDataSourceImpl::kBookmarksFilename = "bookmarks.html";
|
||||
|
||||
BookmarkDataSourceImpl::BookmarkDataSourceImpl(void)
|
||||
{
|
||||
// XXX rvg there should be only one instance of this class.
|
||||
// this is actually true of all datasources.
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
BookmarkDataSourceImpl::~BookmarkDataSourceImpl(void)
|
||||
{
|
||||
// unregister this from the RDF service
|
||||
nsresult rv;
|
||||
nsIRDFService* rdfService;
|
||||
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &rdfService))) {
|
||||
rdfService->UnregisterDataSource(this);
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, rdfService);
|
||||
}
|
||||
Flush();
|
||||
NS_RELEASE(mInner);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(BookmarkDataSourceImpl, kIRDFDataSourceIID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
BookmarkDataSourceImpl::Init(const char* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID,
|
||||
nsnull,
|
||||
kIRDFDataSourceIID,
|
||||
(void**) &mInner)))
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = mInner->Init(uri)))
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = ReadBookmarks()))
|
||||
return rv;
|
||||
|
||||
// register this as a named data source with the RDF service
|
||||
nsIRDFService* rdfService;
|
||||
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &rdfService))) {
|
||||
rdfService->RegisterDataSource(this);
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, rdfService);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BookmarkDataSourceImpl::Flush(void)
|
||||
{
|
||||
return WriteBookmarks();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
BookmarkDataSourceImpl::IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BookmarkDataSourceImpl::DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
BookmarkDataSourceImpl::ReadBookmarks(void)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
PRFileDesc* f;
|
||||
if ((f = PR_Open(kBookmarksFilename, PR_RDONLY, 0644))) {
|
||||
BookmarkParser parser;
|
||||
rv = parser.Parse(f, this);
|
||||
PR_Close(f);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
BookmarkDataSourceImpl::WriteBookmarks(void)
|
||||
{
|
||||
//PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#if FIXME
|
||||
|
||||
static const nsString&
|
||||
rdf_NumericDate(const nsString& url)
|
||||
{
|
||||
nsAutoString result;
|
||||
PRInt32 len = url.Length();
|
||||
PRInt32 index = 0;
|
||||
|
||||
while (index < len && url[index] < '0' && url[index] > '9')
|
||||
++index;
|
||||
|
||||
if (index >= len)
|
||||
return result;
|
||||
|
||||
while (index < len && url[index] >= '0' && url[index] <= '9')
|
||||
result.Append(url[index++]);
|
||||
|
||||
result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent)
|
||||
{
|
||||
RDF_Cursor c = RDF_GetSources(rdf, u, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
||||
RDF_Resource next;
|
||||
char *date, *name, *url;
|
||||
int loop;
|
||||
|
||||
if (c == nsnull) return;
|
||||
if (u == top) {
|
||||
name = RDF_GetResourceName(rdf, u);
|
||||
ht_rjcprintf(fp, "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n", nsnull);
|
||||
ht_rjcprintf(fp, "<!-- This is an automatically generated file.\n", nsnull);
|
||||
ht_rjcprintf(fp, "It will be read and overwritten.\n", nsnull);
|
||||
ht_rjcprintf(fp, "Do Not Edit! -->\n", nsnull);
|
||||
|
||||
ht_rjcprintf(fp, "<TITLE>%s</TITLE>\n", (name) ? name:"");
|
||||
ht_rjcprintf(fp, "<H1>%s</H1>\n<DL><p>\n", (name) ? name:"");
|
||||
}
|
||||
while ((next = RDF_NextValue(c)) != nsnull) {
|
||||
|
||||
url = resourceID(next);
|
||||
if (containerp(next) && (!startsWith("ftp:",url)) && (!startsWith("file:",url))
|
||||
&& (!startsWith("IMAP:", url)) && (!startsWith("nes:", url))
|
||||
&& (!startsWith("mail:", url)) && (!startsWith("cache:", url))
|
||||
&& (!startsWith("ldap:", url))) {
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", nsnull);
|
||||
|
||||
date = numericDate(resourceID(next));
|
||||
ht_rjcprintf(fp, "<DT><H3 ADD_DATE=\"%s\">", (date) ? date:"");
|
||||
if (date) freeMem(date);
|
||||
name = RDF_GetResourceName(rdf, next);
|
||||
ht_rjcprintf(fp, "%s</H3>\n", name);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", nsnull);
|
||||
ht_rjcprintf(fp, "<DL><p>\n", nsnull);
|
||||
HT_WriteOutAsBookmarks1(rdf, fp, next, top, indent+1);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", nsnull);
|
||||
|
||||
ht_rjcprintf(fp, "</DL><p>\n", nsnull);
|
||||
}
|
||||
else if (isSeparator(next)) {
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", nsnull);
|
||||
ht_rjcprintf(fp, "<HR>\n", nsnull);
|
||||
}
|
||||
else {
|
||||
char* bkAddDate = (char*)RDF_GetSlotValue(rdf, next,
|
||||
gNavCenter->RDF_bookmarkAddDate,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", nsnull);
|
||||
|
||||
ht_rjcprintf(fp, "<DT><A HREF=\"%s\" ", resourceID(next));
|
||||
date = numericDate(bkAddDate);
|
||||
ht_rjcprintf(fp, "ADD_DATE=\"%s\" ", (date) ? date: "");
|
||||
if (date) freeMem(date);
|
||||
ht_rjcprintf(fp, "LAST_VISIT=\"%s\" ", resourceLastVisitDate(rdf, next));
|
||||
ht_rjcprintf(fp, "LAST_MODIFIED=\"%s\">", resourceLastModifiedDate(rdf, next));
|
||||
ht_rjcprintf(fp, "%s</A>\n", RDF_GetResourceName(rdf, next));
|
||||
|
||||
if (resourceDescription(rdf, next) != nsnull) {
|
||||
ht_rjcprintf(fp, "<DD>%s\n", resourceDescription(rdf, next));
|
||||
}
|
||||
}
|
||||
}
|
||||
RDF_DisposeCursor(c);
|
||||
if (u == top) {
|
||||
ht_rjcprintf(fp, "</DL>\n", nsnull);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFBookmarkDataSource(nsIRDFDataSource** result)
|
||||
{
|
||||
BookmarkDataSourceImpl* ds = new BookmarkDataSourceImpl();
|
||||
if (! ds)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = ds;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
1510
mozilla/rdf/datasource/src/nsMailDataSource.cpp
Normal file
1510
mozilla/rdf/datasource/src/nsMailDataSource.cpp
Normal file
File diff suppressed because it is too large
Load Diff
361
mozilla/rdf/datasource/src/nsMailDataSource.h
Normal file
361
mozilla/rdf/datasource/src/nsMailDataSource.h
Normal file
@@ -0,0 +1,361 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Class declarations for mail data source resource types.
|
||||
|
||||
XXX Should these be factored out into their own implementation files, etc.?
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsMailDataSource_h__
|
||||
#define nsMailDataSource_h__
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// NS_DECL_IRDFRESOURCE, NS_IMPL_IRDFRESOURCE
|
||||
//
|
||||
// Convenience macros for implementing the RDF resource interface.
|
||||
//
|
||||
// XXX It might make sense to move these macros to nsIRDFResource.h?
|
||||
|
||||
#define NS_DECL_IRDFRESOURCE \
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const;\
|
||||
NS_IMETHOD GetValue(const char* *uri) const;\
|
||||
NS_IMETHOD EqualsResource(const nsIRDFResource* resource, PRBool* result) const;\
|
||||
NS_IMETHOD EqualsString(const char* uri, PRBool* result) const;
|
||||
|
||||
|
||||
#define NS_IMPL_IRDFRESOURCE(__class) \
|
||||
NS_IMETHODIMP \
|
||||
__class::EqualsNode(nsIRDFNode* node, PRBool* result) const {\
|
||||
nsresult rv;\
|
||||
nsIRDFResource* resource;\
|
||||
if (NS_SUCCEEDED(node->QueryInterface(kIRDFResourceIID, (void**) &resource))) {\
|
||||
rv = EqualsResource(resource, result);\
|
||||
NS_RELEASE(resource);\
|
||||
}\
|
||||
else {\
|
||||
*result = PR_FALSE;\
|
||||
rv = NS_OK;\
|
||||
}\
|
||||
return rv;\
|
||||
}\
|
||||
NS_IMETHODIMP \
|
||||
__class::GetValue(const char* *uri) const{\
|
||||
if (!uri)\
|
||||
return NS_ERROR_NULL_POINTER;\
|
||||
*uri = mURI;\
|
||||
return NS_OK;\
|
||||
}\
|
||||
NS_IMETHODIMP \
|
||||
__class::EqualsResource(const nsIRDFResource* resource, PRBool* result) const {\
|
||||
if (!resource || !result) return NS_ERROR_NULL_POINTER;\
|
||||
*result = (resource == (nsIRDFResource*) this);\
|
||||
return NS_OK;\
|
||||
}\
|
||||
NS_IMETHODIMP \
|
||||
__class::EqualsString(const char* uri, PRBool* result) const {\
|
||||
if (!uri || !result) return NS_ERROR_NULL_POINTER;\
|
||||
*result = (PL_strcmp(uri, mURI) == 0);\
|
||||
return NS_OK;\
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The mail data source.
|
||||
*/
|
||||
class MailDataSource : public nsIRDFMailDataSource
|
||||
{
|
||||
private:
|
||||
char* mURI;
|
||||
nsVoidArray* mObservers;
|
||||
|
||||
// internal methods
|
||||
nsresult InitAccountList (void);
|
||||
nsresult AddColumns (void);
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
MailDataSource(void);
|
||||
virtual ~MailDataSource (void);
|
||||
|
||||
// nsIRDFMailDataSource methods
|
||||
NS_IMETHOD AddAccount (nsIRDFMailAccount* folder);
|
||||
NS_IMETHOD RemoveAccount (nsIRDFMailAccount* folder);
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(const char* *uri) const;
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source /* out */);
|
||||
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target);
|
||||
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** sources);
|
||||
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets);
|
||||
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv);
|
||||
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target);
|
||||
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion);
|
||||
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n);
|
||||
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n);
|
||||
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels);
|
||||
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels);
|
||||
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult);
|
||||
|
||||
NS_IMETHOD DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget);
|
||||
|
||||
// caching frequently used resources
|
||||
static nsIRDFResource* kNC_Child;
|
||||
static nsIRDFResource* kNC_Folder;
|
||||
static nsIRDFResource* kNC_From;
|
||||
static nsIRDFResource* kNC_subject;
|
||||
static nsIRDFResource* kNC_date;
|
||||
static nsIRDFResource* kNC_user;
|
||||
static nsIRDFResource* kNC_host;
|
||||
static nsIRDFResource* kNC_account;
|
||||
static nsIRDFResource* kNC_Name;
|
||||
static nsIRDFResource* kNC_Columns;
|
||||
static nsIRDFResource* kNC_MailRoot;
|
||||
|
||||
nsIRDFDataSource* mMiscMailData;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MailAccount : public nsIRDFMailAccount
|
||||
{
|
||||
private:
|
||||
char* mURI;
|
||||
nsresult InitMailAccount (const char* uri);
|
||||
|
||||
public:
|
||||
MailAccount (const char* uri);
|
||||
MailAccount (char* uri, nsIRDFLiteral* user, nsIRDFLiteral* host);
|
||||
virtual ~MailAccount (void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IRDFRESOURCE
|
||||
|
||||
NS_IMETHOD GetUser(nsIRDFLiteral** result) const;
|
||||
NS_IMETHOD GetName(nsIRDFLiteral** result) const;
|
||||
NS_IMETHOD GetHost(nsIRDFLiteral** result) const;
|
||||
NS_IMETHOD AddFolder (nsIRDFMailFolder* folder);
|
||||
NS_IMETHOD RemoveFolder (nsIRDFMailFolder* folder);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MailFolder : public nsIRDFMailFolder
|
||||
{
|
||||
private:
|
||||
enum MailFolderStatus {
|
||||
eMailFolder_Uninitialized,
|
||||
eMailFolder_InitInProgress,
|
||||
eMailFolder_WriteInProgress,
|
||||
eMailFolder_OK
|
||||
};
|
||||
|
||||
nsVoidArray mMessages;
|
||||
FILE* mSummaryFile;
|
||||
MailFolderStatus mStatus;
|
||||
char* mURI;
|
||||
|
||||
public:
|
||||
MailFolder (const char* uri);
|
||||
virtual ~MailFolder (void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IRDFRESOURCE
|
||||
|
||||
NS_IMETHOD GetAccount(nsIRDFMailAccount** account);
|
||||
NS_IMETHOD GetName(nsIRDFLiteral** result) const;
|
||||
NS_IMETHOD GetMessageList (nsVoidArray** result);
|
||||
NS_IMETHOD AddMessage (nsIRDFMailMessage* msg);
|
||||
NS_IMETHOD RemoveMessage (nsIRDFMailMessage* msg);
|
||||
|
||||
nsresult AddMessage(PRUnichar* uri,
|
||||
MailFolder* folder,
|
||||
nsIRDFResource* from,
|
||||
nsIRDFLiteral* subject,
|
||||
nsIRDFLiteral* date,
|
||||
int summaryFileOffset,
|
||||
int mailFileOffset,
|
||||
char* flags,
|
||||
nsIRDFLiteral* messageID);
|
||||
|
||||
nsresult AddMessage(PRUnichar* uri,
|
||||
MailFolder* folder,
|
||||
nsIRDFResource* from,
|
||||
nsIRDFLiteral* subject,
|
||||
nsIRDFLiteral* date,
|
||||
int mailFileOffset,
|
||||
char* flags,
|
||||
nsIRDFLiteral* messageID);
|
||||
|
||||
nsresult ReadSummaryFile(char* uri);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MailMessage : public nsIRDFMailMessage
|
||||
{
|
||||
private:
|
||||
MailFolder* mFolder;
|
||||
nsIRDFResource* mFrom;
|
||||
nsIRDFLiteral* mSubject;
|
||||
int mSummaryFileOffset;
|
||||
int mMailFileOffset;
|
||||
nsIRDFLiteral* mDate;
|
||||
nsIRDFLiteral* mMessageID;
|
||||
char mFlags[4];
|
||||
char* mURI;
|
||||
|
||||
public:
|
||||
MailMessage (const char* uri);
|
||||
virtual ~MailMessage (void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IRDFRESOURCE
|
||||
|
||||
NS_IMETHOD GetFolder(nsIRDFMailFolder** result);
|
||||
NS_IMETHOD GetSubject(nsIRDFLiteral** result);
|
||||
NS_IMETHOD GetSender(nsIRDFResource** result);
|
||||
NS_IMETHOD GetDate(nsIRDFLiteral** result);
|
||||
NS_IMETHOD GetContent(const char* result);
|
||||
NS_IMETHOD GetMessageID(nsIRDFLiteral** id);
|
||||
NS_IMETHOD GetFlags(char** result);
|
||||
NS_IMETHOD SetFlags(const char* result);
|
||||
|
||||
nsresult SetupMessage (MailFolder* folder,
|
||||
nsIRDFResource* from,
|
||||
nsIRDFLiteral* subject,
|
||||
nsIRDFLiteral* date,
|
||||
int summaryFileOffset,
|
||||
int mailFileOffset,
|
||||
char* flags,
|
||||
nsIRDFLiteral* messageID);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class SingletonMailCursor : public nsIRDFAssertionCursor
|
||||
{
|
||||
private:
|
||||
nsIRDFNode* mValue;
|
||||
nsIRDFResource* mSource;
|
||||
nsIRDFResource* mProperty;
|
||||
nsIRDFNode* mTarget;
|
||||
PRBool mValueReturnedp;
|
||||
PRBool mInversep;
|
||||
|
||||
public:
|
||||
SingletonMailCursor(nsIRDFNode* u,
|
||||
nsIRDFResource* s,
|
||||
PRBool inversep);
|
||||
virtual ~SingletonMailCursor(void);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFCursor interface
|
||||
NS_IMETHOD Advance(void);
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue);
|
||||
|
||||
// nsIRDFAssertionCursor interface
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource);
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject);
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ArrayMailCursor : public nsIRDFAssertionCursor ,
|
||||
public nsIRDFArcsOutCursor
|
||||
{
|
||||
private:
|
||||
nsIRDFNode* mValue;
|
||||
nsIRDFResource* mSource;
|
||||
nsIRDFResource* mProperty;
|
||||
nsIRDFNode* mTarget;
|
||||
int mCount;
|
||||
nsVoidArray* mArray;
|
||||
|
||||
public:
|
||||
ArrayMailCursor(nsIRDFResource* u, nsIRDFResource* s, nsVoidArray* array);
|
||||
virtual ~ArrayMailCursor(void);
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFCursor interface
|
||||
NS_IMETHOD Advance(void);
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue);
|
||||
// nsIRDFAssertionCursor interface
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource);
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject);
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
|
||||
};
|
||||
|
||||
|
||||
#endif // nsMailDataSource_h__
|
||||
48
mozilla/rdf/datasource/src/nsRDFBuiltInDataSources.h
Normal file
48
mozilla/rdf/datasource/src/nsRDFBuiltInDataSources.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* -*- 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 nsBuiltinDataSources_h__
|
||||
#define nsBuiltinDataSources_h__
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFDataBase;
|
||||
|
||||
// in nsBookmarkDataSource.cpp
|
||||
nsresult NS_NewRDFBookmarkDataSource(nsIRDFDataSource** result);
|
||||
|
||||
// in nsMemoryDataSource.cpp
|
||||
nsresult NS_NewRDFInMemoryDataSource(nsIRDFDataSource** result);
|
||||
|
||||
// in nsStreamDataSource.cpp
|
||||
nsresult NS_NewRDFStreamDataSource(nsIRDFDataSource** result);
|
||||
|
||||
#endif // nsBuiltinDataSources_h__
|
||||
|
||||
|
||||
BIN
mozilla/rdf/macbuild/rdf.mcp
Normal file
BIN
mozilla/rdf/macbuild/rdf.mcp
Normal file
Binary file not shown.
4
mozilla/rdf/macbuild/rdf.prefix
Normal file
4
mozilla/rdf/macbuild/rdf.prefix
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "DefinesMac.h"
|
||||
#include "DefinesMozilla.h"
|
||||
#include "IDE_Options.h"
|
||||
#include "ansi_prefix.mac.h"
|
||||
18
mozilla/rdf/macbuild/rdf.toc
Normal file
18
mozilla/rdf/macbuild/rdf.toc
Normal file
@@ -0,0 +1,18 @@
|
||||
# target: rdf.shlb
|
||||
mozilla/rdf/base/src/nsContainerCursor.cpp
|
||||
mozilla/rdf/base/src/nsDataBase.cpp
|
||||
mozilla/rdf/base/src/nsEmptyCursor.cpp
|
||||
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
|
||||
mozilla/rdf/base/src/nsRDFContentSink.cpp
|
||||
mozilla/rdf/base/src/nsRDFService.cpp
|
||||
mozilla/rdf/base/src/nsStreamDataSource.cpp
|
||||
mozilla/rdf/base/src/rdfutil.cpp
|
||||
mozilla/rdf/build/nsRDFFactory.cpp
|
||||
mozilla/rdf/content/src/nsRDFContentUtils.cpp
|
||||
mozilla/rdf/content/src/nsRDFDocument.cpp
|
||||
mozilla/rdf/content/src/nsRDFGenericElement.cpp
|
||||
mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
|
||||
mozilla/rdf/content/src/nsRDFResourceElement.cpp
|
||||
mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
|
||||
mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
|
||||
mozilla/rdf/datasource/src/nsMailDataSource.cpp
|
||||
6
mozilla/rdf/macbuild/rdfDebug.prefix
Normal file
6
mozilla/rdf/macbuild/rdfDebug.prefix
Normal file
@@ -0,0 +1,6 @@
|
||||
#define DEBUG
|
||||
|
||||
#include "DefinesMac.h"
|
||||
#include "DefinesMozilla.h"
|
||||
#include "IDE_Options.h"
|
||||
#include "ansi_prefix.mac.h"
|
||||
29
mozilla/rdf/makefile.win
Normal file
29
mozilla/rdf/makefile.win
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=..
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
DIRS=\
|
||||
base \
|
||||
content \
|
||||
datasource \
|
||||
build \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
281
mozilla/rdf/opendir/genopendir.c
Normal file
281
mozilla/rdf/opendir/genopendir.c
Normal file
@@ -0,0 +1,281 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "rdf.h"
|
||||
#include "gs.h"
|
||||
|
||||
void describeItem (WriteClientProc callBack, void* obj, RDF_Resource u) ;
|
||||
void describeItemSimple (WriteClientProc callBack, void* obj, RDF_Resource u) ;
|
||||
|
||||
RDF_Resource
|
||||
getNodeFromQuery (char* query) {
|
||||
RDF_Resource ans;
|
||||
if (!(ans = RDF_GetResource(query, 0))) {
|
||||
return RDF_GetResource("Top", 1);
|
||||
} else return ans;
|
||||
}
|
||||
|
||||
#define ROW_WIDTH 3
|
||||
|
||||
#define PREFIX "<form method=get action=\"OpenDir?\"><B>Search:</B> <input size=25 name=search> <input type=submit value=search><br><BR><BR></form><div align=right><a href=\"/odoptions.html\">Personalize</a></div>"
|
||||
|
||||
void
|
||||
SortResourceList (RDF_Resource* list, size_t n, char sortType) {
|
||||
if (sortType == 'd') {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
listParents(WriteClientProc callBack, void* obj, RDF_Resource node, int depth) {
|
||||
RDF_Resource narrow = RDF_GetResource("narrow", 1);
|
||||
RDF_Resource parent = RDF_OnePropSource(0, node, narrow);
|
||||
RDF_Resource name = RDF_GetResource("name", 1);
|
||||
char* id = RDF_ResourceID(node);
|
||||
char* nm = (char*) RDF_OnePropValue(0, node, name, RDF_STRING_TYPE);
|
||||
char* cnm = strrchr(id, '/');
|
||||
char buff[500];
|
||||
if (!nm || strchr(nm, '/')) nm = (cnm ? cnm + 1 : id);
|
||||
if ((depth < 10) && parent) listParents(callBack, obj, parent, depth+1);
|
||||
sprintf(buff, "<B><a href=\"OpenDir?browse=%s\">%s</a> > </B> ", id, nm);
|
||||
|
||||
(*callBack)(obj, buff);
|
||||
}
|
||||
|
||||
char
|
||||
cookiePropValue (char* cookie, char* prop) {
|
||||
size_t len = strlen(prop);
|
||||
char* str = strstr(cookie, prop);
|
||||
if (!str) {
|
||||
return 0;
|
||||
} else {
|
||||
return *(str + len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AnswerOpenDirQuery (WriteClientProc callBack, void* obj, char *query, char* cookie) {
|
||||
char buff[1000];
|
||||
RDF_Resource narrow = RDF_GetResource("narrow", 1);
|
||||
RDF_Resource link = RDF_GetResource("link", 1);
|
||||
RDF_Resource name = RDF_GetResource("name", 1);
|
||||
RDF_Resource topic = RDF_GetResource("Topic", 1);
|
||||
RDF_Resource desc = RDF_GetResource("description", 1);
|
||||
RDF_Resource editor = RDF_GetResource("editor", 1);
|
||||
RDF_Resource newsGroup = RDF_GetResource("newsGroup", 1);
|
||||
RDF_Resource node = getNodeFromQuery(query);
|
||||
char widthc = cookiePropValue(cookie, "cols");
|
||||
char sort = cookiePropValue(cookie, "sort");
|
||||
size_t rw = (widthc ? ((int)widthc - 48) : 3);
|
||||
|
||||
if (!sort) sort = 'D';
|
||||
|
||||
if (node) {
|
||||
RDF_Cursor c = RDF_GetTargets(0, node, narrow, RDF_RESOURCE_TYPE);
|
||||
RDF_Resource u = (RDF_Resource) RDF_NextValue(c);
|
||||
(*callBack)(obj, PREFIX);
|
||||
listParents(callBack, obj, node, 0);
|
||||
if (u) {
|
||||
(*callBack)(obj, "<BR><hr><table cellspacing=\"6\" cellpadding=\"6\" width=\"80%\">");
|
||||
while (u) {
|
||||
int w = 0;
|
||||
(*callBack)(obj, "<tr>");
|
||||
while ((w < rw) && u) {
|
||||
char* nm = (char*) RDF_OnePropValue(0, u, name, RDF_STRING_TYPE);
|
||||
char* id = RDF_ResourceID(u);
|
||||
if (!nm || strchr(nm, '/')) nm = strrchr(id, '/') +1;
|
||||
sprintf(buff, "<td width=\"%i%\"><li><a href=\"OpenDir?browse=%s\">%s</a></td>",
|
||||
(100 / rw), id, (nm ? nm : id));
|
||||
(*callBack)(obj, buff);
|
||||
w++;
|
||||
u = (RDF_Resource) RDF_NextValue(c);
|
||||
}
|
||||
(*callBack)(obj, "</tr>");
|
||||
}
|
||||
(*callBack)(obj, "</table>");
|
||||
}
|
||||
|
||||
RDF_DisposeCursor(c);
|
||||
(*callBack)(obj, "<hr><UL>");
|
||||
c = RDF_GetTargets(0, node, link, RDF_RESOURCE_TYPE);
|
||||
u = (RDF_Resource) RDF_NextValue(c);
|
||||
while (u) {
|
||||
describeItem(callBack, obj, u);
|
||||
u = (RDF_Resource) RDF_NextValue(c);
|
||||
}
|
||||
(*callBack)(obj, "</UL>");
|
||||
RDF_DisposeCursor(c);
|
||||
|
||||
c = RDF_GetTargets(0, node, newsGroup, RDF_RESOURCE_TYPE);
|
||||
u = (RDF_Resource) RDF_NextValue(c);
|
||||
if (u) {
|
||||
(*callBack)(obj, "<hr><b>NewsGroups:</B>");
|
||||
while (u) {
|
||||
char* id = RDF_ResourceID(u);
|
||||
sprintf(buff, "<li><a href=\"%s\">%s</a>", id, id);
|
||||
(*callBack)(obj, buff);
|
||||
u = (RDF_Resource) RDF_NextValue(c);
|
||||
}
|
||||
(*callBack)(obj, "</UL>");
|
||||
}
|
||||
RDF_DisposeCursor(c);
|
||||
|
||||
|
||||
c = RDF_GetTargets(0, node, editor, RDF_RESOURCE_TYPE);
|
||||
u = (RDF_Resource) RDF_NextValue(c);
|
||||
if (u) {
|
||||
(*callBack)(obj, "<hr><b>Editors:</b>");
|
||||
while (u) {
|
||||
char* id = RDF_ResourceID(u);
|
||||
sprintf(buff, " %s", id);
|
||||
(*callBack)(obj, buff);
|
||||
u = (RDF_Resource) RDF_NextValue(c);
|
||||
}
|
||||
|
||||
RDF_DisposeCursor(c);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void describeCategory (WriteClientProc callBack, void* obj, RDF_Resource u) {
|
||||
char buff[1000];
|
||||
sprintf(buff, "<li><B><a href=\"OpenDir?browse=%s\">%s</a></B>", RDF_ResourceID(u),
|
||||
RDF_ResourceID(u));
|
||||
(*callBack)(obj, buff);
|
||||
}
|
||||
|
||||
#define MRN 1000
|
||||
|
||||
char*
|
||||
xGetMem (size_t n) {
|
||||
char* ans = (char*) malloc(n);
|
||||
if (ans) memset(ans, '\0', n);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xFreeMem(void* item) {
|
||||
free(item);
|
||||
}
|
||||
|
||||
RDF_Resource
|
||||
stToProp (char c) {
|
||||
if (!c || (c == 'a')) {
|
||||
return 0;
|
||||
} else if (c == 'n') {
|
||||
return RDF_GetResource("name", 1);
|
||||
} else if (c == 'd') {
|
||||
return RDF_GetResource("description", 1);
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
void
|
||||
AnswerSearchQuery (WriteClientProc callBack, void* obj, char *query, char* cookie) {
|
||||
char st = cookiePropValue(cookie, "searchTarget");
|
||||
RDF_Cursor c = RDFGS_Search(0, query, stToProp(st));
|
||||
RDF_Resource name = RDF_GetResource("name", 1);
|
||||
RDF_Resource topic = RDF_GetResource("Topic", 1);
|
||||
RDF_Resource type = RDF_GetResource("type", 1);
|
||||
RDF_Resource u ;
|
||||
RDF_Resource* cats = (RDF_Resource*)xGetMem(sizeof(RDF_Resource) * (MRN + 1));
|
||||
RDF_Resource* items = (RDF_Resource*)xGetMem(sizeof(RDF_Resource) * (MRN + 1));;
|
||||
size_t catn = 0;
|
||||
size_t itemn = 0;
|
||||
size_t index;
|
||||
char showDesc = cookiePropValue(cookie, "searchDesc");
|
||||
|
||||
(*callBack)(obj, PREFIX);
|
||||
(*callBack)(obj, "<B>Search : ");
|
||||
(*callBack)(obj, query);
|
||||
(*callBack)(obj, "</B>");
|
||||
|
||||
while ((u = (RDF_Resource) RDFGS_NextValue(c)) &&
|
||||
(itemn < MRN-1) && (catn < MRN-1)) {
|
||||
if (RDF_HasAssertion(0, u, type, topic, RDF_RESOURCE_TYPE)) {
|
||||
cats[catn++] = u;
|
||||
} else {
|
||||
items[itemn++] = u;
|
||||
}
|
||||
}
|
||||
|
||||
RDFGS_DisposeCursor(c);
|
||||
if (catn > 0) {
|
||||
(*callBack)(obj, "<HR><B>Matching Categories :</B><BR>");
|
||||
(*callBack)(obj, "<UL>");
|
||||
for (index = 0; index < catn ; index++) {
|
||||
if (cats[index]) describeCategory(callBack, obj, cats[index]);
|
||||
}
|
||||
(*callBack)(obj, "</UL>");
|
||||
}
|
||||
|
||||
if (itemn > 0) {
|
||||
(*callBack)(obj, "<HR><B>Matching Links :</B><BR><UL>");
|
||||
for (index = 0; index < itemn ; index++) {
|
||||
if (items[index]) {
|
||||
if (showDesc == 'n') {
|
||||
describeItemSimple(callBack, obj, items[index]);
|
||||
} else {
|
||||
describeItem(callBack, obj, items[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
(*callBack)(obj, "</UL>");
|
||||
}
|
||||
|
||||
xFreeMem(items);
|
||||
xFreeMem(cats);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
describeItemSimple (WriteClientProc callBack, void* obj, RDF_Resource u) {
|
||||
char buff[5000];
|
||||
RDF_Resource name = RDF_GetResource("name", 1);
|
||||
char* nm = (char*) RDF_OnePropValue(0, u, name, RDF_STRING_TYPE);
|
||||
char* id = RDF_ResourceID(u);
|
||||
sprintf(buff, "<li><a href=\"%s\">%s</a>", id, (nm ? nm : id));
|
||||
(*callBack)(obj, buff);
|
||||
}
|
||||
|
||||
void
|
||||
describeItem (WriteClientProc callBack, void* obj, RDF_Resource u) {
|
||||
char buff[5000];
|
||||
RDF_Resource name = RDF_GetResource("name", 1);
|
||||
RDF_Resource desc = RDF_GetResource("description", 1);
|
||||
char* nm = (char*) RDF_OnePropValue(0, u, name, RDF_STRING_TYPE);
|
||||
char* id = RDF_ResourceID(u);
|
||||
char* des = (char*) RDF_OnePropValue(0, u, desc, RDF_STRING_TYPE);
|
||||
sprintf(buff, "<li><a href=\"%s\">%s</a> %s %s", id, (nm ? nm : id),
|
||||
(des ? " : " : ""), (des ? des : ""));
|
||||
(*callBack)(obj, buff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
227
mozilla/rdf/opendir/gs.c
Normal file
227
mozilla/rdf/opendir/gs.c
Normal file
@@ -0,0 +1,227 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
|
||||
|
||||
// 39204897
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "rdf-int.h"
|
||||
#include "gs.h"
|
||||
|
||||
|
||||
|
||||
typedef struct _TrieNodeStruct {
|
||||
char c;
|
||||
struct _TrieNodeStruct* child;
|
||||
struct _TrieNodeStruct* next;
|
||||
struct _TrieTargetStruct* targets;
|
||||
} TrieNodeStruct;
|
||||
|
||||
typedef TrieNodeStruct* TNS;
|
||||
|
||||
typedef struct _TrieTargetStruct {
|
||||
RDF_Resource label;
|
||||
RDF_Resource target;
|
||||
struct _TrieTargetStruct* next;
|
||||
RDFT db;
|
||||
} TrieTargetStruct;
|
||||
|
||||
typedef TrieTargetStruct* TTS;
|
||||
|
||||
static TNS gRootNode = 0;
|
||||
|
||||
int
|
||||
addTarget (RDFT db, TNS node, RDF_Resource label, RDF_Resource targetNode) {
|
||||
TTS target ;
|
||||
int n = 0;
|
||||
/* for (target = node->targets; target != null; target = target->next) {
|
||||
if (target->target == targetNode) return 0;
|
||||
n++;
|
||||
} */
|
||||
target = (TTS) fgetMem(sizeof(TrieTargetStruct));
|
||||
target->next = node->targets;
|
||||
node->targets = target;
|
||||
target->label = label;
|
||||
target->target = targetNode;
|
||||
target->db = db;
|
||||
return n;
|
||||
}
|
||||
|
||||
TNS
|
||||
findChildOfChar (TNS node, char c) {
|
||||
TNS ch = node->child;
|
||||
char c1 = tolower(c);
|
||||
while (ch) {
|
||||
if (c1 == ch->c) return ch;
|
||||
ch = ch->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
TNS
|
||||
findChildOfString (TNS node, char* str) {
|
||||
size_t size = strlen(str);
|
||||
size_t n = 0;
|
||||
while (n < size) {
|
||||
char c = str[n++];
|
||||
node = findChildOfChar(node, c);
|
||||
if (!node) return 0;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
void RDFGS_AddSearchIndex (RDFT db, char* string, RDF_Resource label, RDF_Resource target) {
|
||||
size_t size = strlen(string);
|
||||
size_t n = 0;
|
||||
char* stk = 0;
|
||||
TNS prev, next;
|
||||
if (!gRootNode) gRootNode = (TNS) getMem(sizeof(TrieNodeStruct));
|
||||
prev = gRootNode;
|
||||
next = 0;
|
||||
while (n < size) {
|
||||
char c = string[n++];
|
||||
if (!wsCharp(c) && (c != '/')) {
|
||||
if (!stk) stk = &string[n-1];
|
||||
next = (TNS) findChildOfChar(prev, c);
|
||||
if (!next) {
|
||||
next = (TNS)fgetMem(sizeof(TrieNodeStruct));
|
||||
next->next = prev->child;
|
||||
prev->child = next;
|
||||
next->c = tolower(c);
|
||||
}
|
||||
prev = next;
|
||||
} else if (next) {
|
||||
int n = addTarget(db, next, label, target);
|
||||
stk = 0;
|
||||
prev = gRootNode;
|
||||
next = 0;
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
addTarget(db, next, label, target);
|
||||
prev = gRootNode;
|
||||
next = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
countChildren (TNS node, size_t *n, size_t *m) {
|
||||
TNS ch;
|
||||
TTS tg ;
|
||||
if (node->targets) (*n)++;
|
||||
for (tg = node->targets; tg; tg = tg->next) (*m)++;
|
||||
ch = node->child;
|
||||
while (ch) {
|
||||
countChildren(ch, n, m);
|
||||
ch = ch->next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fillUpChildren (RDF_Cursor c, TNS node) {
|
||||
TNS ch;
|
||||
if (node->targets) *((TTS*)c->pdata1 + c->count++) = node->targets;
|
||||
ch = node->child;
|
||||
while (ch) {
|
||||
fillUpChildren(c, ch);
|
||||
ch = ch->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RDF_Cursor RDFGS_Search (RDFT db, char* searchString, RDF_Resource label) {
|
||||
RDF_Cursor c = (RDF_Cursor) getMem(sizeof(RDF_CursorStruct));
|
||||
size_t n = 0;
|
||||
size_t m = 0;
|
||||
c->searchString = searchString;
|
||||
c->s = label;
|
||||
c->db = db;
|
||||
c->pdata = findChildOfString(gRootNode, searchString);
|
||||
if (!c->pdata) return c;
|
||||
countChildren((TNS)c->pdata, &n, &m);
|
||||
c->pdata2 = (RDF_Resource*) getMem(sizeof(RDF_Resource) * (m+1));
|
||||
c->off1 = m;
|
||||
if (n > 0) {
|
||||
c->count = 0;
|
||||
c->pdata1 = getMem(sizeof(TTS) * (n+1));
|
||||
fillUpChildren(c, (TNS)c->pdata);
|
||||
c->count = 1;
|
||||
}
|
||||
if (c->pdata) c->pdata = ((TNS)c->pdata)->targets;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void RDFGS_DisposeCursor (RDF_Cursor c) {
|
||||
if (c->pdata1) freeMem(c->pdata1);
|
||||
if (c->pdata2) freeMem(c->pdata2);
|
||||
freeMem(c);
|
||||
}
|
||||
|
||||
int
|
||||
alreadyAdded(RDF_Resource node, RDF_Cursor c) {
|
||||
int n =0;
|
||||
while (c->pdata2[n] && (n < c->off)) {
|
||||
if (c->pdata2[n] == node) return 1;
|
||||
n++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
RDF_Resource RDFGS_NextValue (RDF_Cursor c) {
|
||||
if (!c->pdata) {
|
||||
return 0;
|
||||
} else {
|
||||
TTS currentTTS = (TTS) c->pdata;
|
||||
while (currentTTS) {
|
||||
if (((!c->s) || (c->s == currentTTS->label)) &&
|
||||
(!alreadyAdded(currentTTS->target, c))) {
|
||||
RDF_Resource ans = currentTTS->target;
|
||||
c->pdata = currentTTS = currentTTS->next;
|
||||
if (!currentTTS && (c->pdata1)) {
|
||||
c->pdata = ((TTS*)c->pdata1)[c->count++];
|
||||
}
|
||||
if (c->off < c->off1) c->pdata2[c->off++] = ans;
|
||||
return ans;
|
||||
}
|
||||
c->pdata = currentTTS = currentTTS->next;
|
||||
if (!currentTTS && (c->pdata1)) {
|
||||
c->pdata = currentTTS = ((TTS*)c->pdata1)[c->count++];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
26
mozilla/rdf/opendir/gs.h
Normal file
26
mozilla/rdf/opendir/gs.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/* This is the header file for the RDF related search functions */
|
||||
|
||||
void RDFGS_AddSearchIndex (RDFT db, char* string, RDF_Resource label, RDF_Resource target) ;
|
||||
RDF_Cursor RDFGS_Search (RDFT db, char* searchString, RDF_Resource label);
|
||||
RDF_Resource RDFGS_NextValue (RDF_Cursor c) ;
|
||||
void RDFGS_DisposeCursor (RDF_Cursor c);
|
||||
|
||||
|
||||
107
mozilla/rdf/opendir/hash.c
Normal file
107
mozilla/rdf/opendir/hash.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/* This file holds a temporary implementation of hash tables. It will
|
||||
be replaced with STL or NSPR
|
||||
*/
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
typedef struct _HashEntryStruct {
|
||||
struct _HashEntryStruct* next; /* hash chain linkage */
|
||||
char* key;
|
||||
void* value;
|
||||
} HashEntryStruct;
|
||||
|
||||
typedef HashEntryStruct* HashEntry;
|
||||
|
||||
typedef struct _HashTableStruct {
|
||||
int size;
|
||||
HashEntry* buckets; /* vector of hash buckets */
|
||||
} HashTableStruct;
|
||||
|
||||
|
||||
|
||||
int
|
||||
hashKey (HashTable ht, char* key) {
|
||||
size_t len = strlen(key);
|
||||
int sum = 0;
|
||||
size_t n = 0;
|
||||
int ans;
|
||||
for (n = 0; n < len; n++) sum = sum + (int)key[n];
|
||||
ans = sum & ht->size;
|
||||
if (ans == ht->size) ans = ans-1;
|
||||
return ans;
|
||||
}
|
||||
|
||||
HashTable
|
||||
NewHashTable(int size) {
|
||||
HashTable ht = (HashTable)getMem(sizeof(HashTableStruct));
|
||||
ht->size = size;
|
||||
ht->buckets = (HashEntry*)getMem(sizeof(HashEntry) * size);
|
||||
return ht;
|
||||
}
|
||||
|
||||
void*
|
||||
HashLookup(HashTable ht, char* key) {
|
||||
int offset = hashKey(ht, key);
|
||||
HashEntry he = ht->buckets[offset];
|
||||
while (he) {
|
||||
if (strcmp(he->key, key) == 0) return he->value;
|
||||
he = he->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int catCount = 0;
|
||||
int itemCount = 0;
|
||||
|
||||
void
|
||||
HashAdd (HashTable ht, char* key, void* value) {
|
||||
int offset = hashKey(ht, key);
|
||||
HashEntry he = ht->buckets[offset];
|
||||
HashEntry prev = he;
|
||||
while (he) {
|
||||
if (strcmp(he->key, key) == 0) {
|
||||
if (value == he->value) {
|
||||
return;
|
||||
} else {
|
||||
he->value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
prev = he;
|
||||
he = he->next;
|
||||
}
|
||||
if (startsWith("http://", key)) {
|
||||
itemCount++;
|
||||
} else {
|
||||
catCount++;
|
||||
}
|
||||
he = (HashEntry) fgetMem(sizeof(HashEntryStruct));
|
||||
he->value = value;
|
||||
he->key = key;
|
||||
if (prev) {
|
||||
prev->next = he;
|
||||
} else {
|
||||
ht->buckets[offset] = he;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
29
mozilla/rdf/opendir/makefile.win
Normal file
29
mozilla/rdf/opendir/makefile.win
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Microsoft Visual C makefile for WAI sample
|
||||
|
||||
|
||||
INCLUDES = -I..\..\..\include -I..\..\include -IC:\Netscape\Suitespot\include -IC:\Netscape\Suitespot\wai\include
|
||||
NSLIB = ..\..\..\lib
|
||||
WAILIB= c:\netscape\suitespot\wai\lib
|
||||
LIBS = $(WAILIB)\ONEiiop10.lib WSOCK32.lib
|
||||
OPTIMIZER=-Zi -Od -DDEBUG
|
||||
CPPFLAGS=$(INCLUDES) $(OPTIMIZER) -DXP_WIN32 -DWIN32 /MD
|
||||
|
||||
|
||||
OBJS = opendir.o \
|
||||
rdf.o \
|
||||
rdfparse.o \
|
||||
remstore.o \
|
||||
hash.o \
|
||||
genopendir.o \
|
||||
gs.o \
|
||||
$(NULL)
|
||||
|
||||
|
||||
all: opendir
|
||||
|
||||
opendir: opendir.c rdf.c rdfparse.c remstore.c hash.c genopendir.c gs.c
|
||||
$(CC) $(CPPFLAGS) $(LIBS) $? -o $@
|
||||
|
||||
clean:
|
||||
del *.obj
|
||||
141
mozilla/rdf/opendir/opendir.c
Normal file
141
mozilla/rdf/opendir/opendir.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include "ONEiiop.h"
|
||||
#include "rdf.h"
|
||||
|
||||
#if !defined(WIN32)
|
||||
extern "C" int gethostname(char *name, int namelen);
|
||||
#endif
|
||||
|
||||
void
|
||||
WriteClient (void* obj, char* buffer) {
|
||||
size_t len = strlen(buffer);
|
||||
WAIWriteClient((ServerSession_t)obj, (const unsigned char *) buffer, len);
|
||||
}
|
||||
|
||||
void AnswerOpenDirQuery(WriteClientProc callBack, void* obj, char* query, char* cookie);
|
||||
void AnswerSearchQuery (WriteClientProc callBack, void* obj, char *query, char* cookie) ;
|
||||
|
||||
#define PREFIX "<html><body><a href=\"/\"><center><img src=\"http://directory.mozilla.org/img/opendir.gif\" width=396 height=79 border=\"0\"></center></a>"
|
||||
|
||||
#define POSTFIX "</body><html>"
|
||||
|
||||
long
|
||||
Run(ServerSession_t obj)
|
||||
{
|
||||
char* query = (char*) malloc(300);
|
||||
char* val;
|
||||
char* cookie;
|
||||
WAIgetRequestInfo(obj, "QUERY", &query);
|
||||
WAIgetCookie(obj, &cookie);
|
||||
|
||||
if (!query) return 0;
|
||||
printf("Query = %s. Cookie = %s\n", query, cookie);
|
||||
val = strchr(query, '=');
|
||||
if (!val) return 0;
|
||||
val++;
|
||||
*(val -1) = '\0';
|
||||
WAIStartResponse(obj);
|
||||
WriteClient(obj, PREFIX);
|
||||
|
||||
if (strcmp(query, "browse") == 0) {
|
||||
AnswerOpenDirQuery(WriteClient, obj, val, cookie);
|
||||
} else if (strcmp(query, "search") == 0) {
|
||||
AnswerSearchQuery(WriteClient, obj, val, cookie);
|
||||
}
|
||||
WriteClient(obj, POSTFIX);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if defined(WIN32)
|
||||
int WINAPI WinMain(
|
||||
HINSTANCE hInstance, // handle to current instance
|
||||
HINSTANCE hPrevInstance, // handle to previous instance
|
||||
LPSTR lpCmdLine, // pointer to command line
|
||||
int nCmdShow // show state of window
|
||||
)
|
||||
{
|
||||
int argc = 0;
|
||||
char **argv = NULL;
|
||||
#else
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#endif
|
||||
char localhost[256];
|
||||
char *host;
|
||||
RDF_Resource u;
|
||||
IIOPWebAppService_t obj;
|
||||
|
||||
//
|
||||
// Normally we expect to see a hostname:port as
|
||||
// our one and only argument. If we are started by
|
||||
// the OAD we will see an extra argument which should
|
||||
// be ignored.
|
||||
// The recommended registration with the OAD should
|
||||
// specify the hostname:port as an argument to the
|
||||
// object provider.
|
||||
//
|
||||
// So try to ferrit out the hostname:port
|
||||
#ifndef WIN32
|
||||
// Easier if we just have a normal main.
|
||||
if (argc > 1){
|
||||
if (argc == 1)
|
||||
host = argv[1];
|
||||
else if (*argv[1] != '-')
|
||||
host = argv[1];
|
||||
|
||||
#else
|
||||
// Windows command line drops the program name
|
||||
// that appears as argv[0].
|
||||
// GetCommandLine can be used to retrieve the
|
||||
// whole thing.
|
||||
if (lpCmdLine && *lpCmdLine){
|
||||
if (*lpCmdLine != '-'){
|
||||
char *sep = strchr(lpCmdLine, ' ');
|
||||
if (sep)
|
||||
*sep = '\0';
|
||||
host = lpCmdLine;
|
||||
}
|
||||
#endif
|
||||
}else{
|
||||
gethostname(localhost, sizeof(localhost));
|
||||
host = localhost;
|
||||
}
|
||||
|
||||
//
|
||||
// Pass in argc/argv if we have 'em.
|
||||
#ifndef WIN32
|
||||
obj = WAIcreateWebAppService("OpenDir", Run, argc, argv);
|
||||
#else
|
||||
obj = WAIcreateWebAppService("OpenDir", Run, 0, 0);
|
||||
#endif
|
||||
WAIregisterService(obj, host);
|
||||
RDF_Initialize();
|
||||
printf("RDF Initialized!\n");
|
||||
RDF_ReadFile(argv[2]);
|
||||
|
||||
printf("done");
|
||||
|
||||
WAIimplIsReady();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
126
mozilla/rdf/opendir/query.c
Normal file
126
mozilla/rdf/opendir/query.c
Normal file
@@ -0,0 +1,126 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
#define SEP '|'
|
||||
|
||||
typedef struct _QuerySegmentStruct {
|
||||
RDF_Resource s;
|
||||
int num;
|
||||
int inversep;
|
||||
} QuerySegmentStruct;
|
||||
|
||||
typedef QuerySegmentStruct* QuerySegment;
|
||||
|
||||
QuerySegment*
|
||||
parseQuery (char* query, RDF_Resource *root, int *numSegments) {
|
||||
int len = strlen(query);
|
||||
int count ;
|
||||
char* rootURL = getMem(100);
|
||||
QuerySegment* ans;
|
||||
*numSegments = 0;
|
||||
for (count = 0; count < len; count++) {
|
||||
if (query[count] != SEP) {
|
||||
if (!*numSegments) rootURL[count] = query[count];
|
||||
} else
|
||||
(*numSegments)++;
|
||||
}
|
||||
*root = getResource(rootURL, 1);
|
||||
freeMem(rootURL);
|
||||
ans = (QuerySegment*)getMem(*numSegments * (sizeof(QuerySegment)));
|
||||
query = strchr(query, SEP)+1;
|
||||
for (count = 0; count < *numSegments; count++) {
|
||||
char *surl = getMem(100);
|
||||
int num = -1;
|
||||
char* nquery = strchr(query, SEP) ;
|
||||
QuerySegment nq = (QuerySegment)getMem(sizeof(QuerySegmentStruct));
|
||||
if (query[0] == '!') {
|
||||
memcpy(surl, query+1, (nquery ? nquery-query-1 : strlen(query)-1));
|
||||
nq->inversep = 1;
|
||||
} else {
|
||||
memcpy(surl, query, (nquery ? nquery-query : strlen(query)));
|
||||
}
|
||||
if (strchr(surl, '[') && strchr(surl, ']')) {
|
||||
int n = strchr(surl, '[') - surl;
|
||||
surl[n] = '\0';
|
||||
sscanf(&surl[n+1], "%i]", &num);
|
||||
if (num == -1) num = 4096;
|
||||
nq->s = getResource(surl, 1);
|
||||
nq->num = num;
|
||||
} else {
|
||||
nq->s = getResource(surl, 1);
|
||||
nq->num = 4096;
|
||||
}
|
||||
freeMem(surl);
|
||||
ans[count] = nq;
|
||||
if (nquery) {
|
||||
query = nquery+1;
|
||||
} else break;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char**
|
||||
processRDFQuery (char* query) {
|
||||
RDF_Resource root;
|
||||
int numSegments;
|
||||
int count = 0;
|
||||
char** ans = NULL;
|
||||
QuerySegment* querySegments = parseQuery(query, &root, &numSegments);
|
||||
int n = 0;
|
||||
QuerySegment current = NULL;
|
||||
QuerySegment prev = NULL;
|
||||
char** currentValArray = (char**)getMem(sizeof(RDF_Resource)*2);
|
||||
char** newValArray = (char**)getMem(4096 * sizeof(RDF_Resource));
|
||||
currentValArray[0] = (char*) root;
|
||||
for (n = 0; n < numSegments; n++) {
|
||||
QuerySegment q = querySegments[n];
|
||||
int nc = 0;
|
||||
int ansType = ((n == numSegments-1) ? RDF_STRING_TYPE : RDF_RESOURCE_TYPE);
|
||||
count = 0;
|
||||
for (nc = 0; currentValArray[nc] != NULL; nc++) {
|
||||
RDF_Cursor c = getSlotValues(NULL, (RDF_Resource)currentValArray[nc], q->s,
|
||||
ansType, q->inversep, 1);
|
||||
RDF_Resource ans;
|
||||
int lc = 0;
|
||||
while (c && (lc++ < q->num) && (ans = nextValue(c))) {
|
||||
newValArray[count++] = (char*) ans;
|
||||
}
|
||||
if (c) disposeCursor(c);
|
||||
}
|
||||
freeMem(currentValArray);
|
||||
currentValArray = newValArray;
|
||||
newValArray = (char**) getMem(4096 * sizeof(RDF_Resource));
|
||||
}
|
||||
freeMem(newValArray);
|
||||
if (count > 0) {
|
||||
ans = (char**)getMem((count+1) * sizeof(char*));
|
||||
memcpy(ans, currentValArray, (count * sizeof(char*)));
|
||||
}
|
||||
freeMem(currentValArray);
|
||||
for (n = 0; n < numSegments; n++) freeMem(querySegments[n]);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
161
mozilla/rdf/opendir/rdf-int.h
Normal file
161
mozilla/rdf/opendir/rdf-int.h
Normal file
@@ -0,0 +1,161 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "rdf.h"
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#define null NULL
|
||||
#define nullp(x) (((void*)x) == ((void*)0))
|
||||
#define noRDFErr 0
|
||||
#define noMoreValuesErr 1
|
||||
|
||||
#define LookupResource(x) ((RDF_Resource)PL_HashTableLookup(resourceHash, x));
|
||||
#define stringEquals(x, y) (strcmp(x, y) ==0)
|
||||
|
||||
#define wsCharp(c) ((c == '\r') || (c == '\t') || (c == ' ') || (c == '\n'))
|
||||
#define RDF_BUF_SIZE (4096 * 16)
|
||||
#define MAX_ATTRIBUTES 256
|
||||
#define EXPECTING_OBJECT 1
|
||||
#define EXPECTING_PROPERTY 2
|
||||
#define GROW_LIST_INCR 1000
|
||||
|
||||
typedef struct _RDF_ResourceStruct {
|
||||
char* url;
|
||||
struct _RDF_AssertionStruct* rarg1;
|
||||
struct _RDF_AssertionStruct* rarg2;
|
||||
} RDF_ResourceStruct ;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
GET_SLOT_VALUES,
|
||||
ARC_LABELS_IN,
|
||||
ARC_LABELS_OUT,
|
||||
SEARCH
|
||||
} QueryType;
|
||||
|
||||
|
||||
typedef struct _RDF_FileStruct {
|
||||
char* url;
|
||||
int status;
|
||||
char* storeAway;
|
||||
char* line;
|
||||
char* holdOver;
|
||||
RDF_Resource stack[256];
|
||||
RDF_Resource lastItem;
|
||||
int depth ;
|
||||
int tagDepth;
|
||||
int assertionListCount;
|
||||
int assertionListSize;
|
||||
struct _RDF_AssertionStruct** assertionList;
|
||||
} RDF_FileStruct;
|
||||
|
||||
|
||||
|
||||
typedef struct _RDF_CursorStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
void *value;
|
||||
void* pdata;
|
||||
void* pdata1;
|
||||
RDF_Resource* pdata2;
|
||||
int inversep;
|
||||
RDF_ValueType type;
|
||||
size_t count;
|
||||
size_t off;
|
||||
size_t off1;
|
||||
RDFT db;
|
||||
QueryType queryType;
|
||||
char* searchString;
|
||||
} RDF_CursorStruct;
|
||||
|
||||
|
||||
|
||||
typedef struct _RDF_AssertionStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
void* value;
|
||||
RDF_ValueType type;
|
||||
struct _RDF_AssertionStruct* next;
|
||||
struct _RDF_AssertionStruct* invNext;
|
||||
RDFT db;
|
||||
} RDF_AssertionStruct;
|
||||
|
||||
|
||||
typedef RDF_AssertionStruct* Assertion;
|
||||
typedef struct _HashTableStruct* HashTable;
|
||||
|
||||
HashTable NewHashTable(int size) ;
|
||||
void* HashLookup(HashTable ht, char* key) ;
|
||||
void HashAdd (HashTable ht, char* key, void* value) ;
|
||||
|
||||
void readRDFFile (char* file) ;
|
||||
RDF_Resource getResource(char* url, int createp);
|
||||
char* getMem(size_t n);
|
||||
char* fgetMem (size_t size) ;
|
||||
void freeMem(void* item);
|
||||
RDFT initFileStruct (char* url) ;
|
||||
void rdf_init();
|
||||
int startsWith (const char* pattern, const char* uuid);
|
||||
char decodeEntityRef (char* string, int* stringIndexPtr, int len);
|
||||
char * copyStringIgnoreWhiteSpace(char* string);
|
||||
char * getHref(char** attlist);
|
||||
int parseNextRDFXMLBlobInt(RDFT f, char* blob, int size) ;
|
||||
char * getAttributeValue (char** attlist, char* elName);
|
||||
int tagEquals (RDFT f, char* tag1, char* tag2);
|
||||
void addElementProps (char** attlist, char* elementName, RDFT f, RDF_Resource obj);
|
||||
int knownObjectElement (char* eln);
|
||||
char *possiblyMakeAbsolute (RDFT f, char* url);
|
||||
int containerTagp (RDFT f, char* elementName);
|
||||
RDF_Resource ResourceFromElementName (RDFT f, char* elementName);
|
||||
int parseNextRDFToken (RDFT f, char* token);
|
||||
int tokenizeElement (char* attr, char** attlist, char** elementName);
|
||||
void addSlotValue (RDFT f, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, char* op);
|
||||
char* copyString(char* str) ;
|
||||
char* fcopyString (char* str) ;
|
||||
|
||||
|
||||
|
||||
|
||||
int asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type);
|
||||
Assertion makeNewAssertion (RDFT r, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, int tv);
|
||||
void freeAssertion (Assertion as);
|
||||
Assertion remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, int tv);
|
||||
Assertion remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type);
|
||||
int remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, int tv);
|
||||
void * getSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
int inversep, int tv);
|
||||
RDF_Cursor getSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
int inversep, int tv);
|
||||
void* nextValue (RDF_Cursor c) ;
|
||||
void disposeCursor (RDF_Cursor c);
|
||||
void unloadRDFT (RDFT f);
|
||||
int rdf_DigestNewStuff (char* fileName, char* data, int len) ;
|
||||
RDFT getRDFT(char* url, int createp);
|
||||
char** processRDFQuery (char* query);
|
||||
90
mozilla/rdf/opendir/rdf.c
Normal file
90
mozilla/rdf/opendir/rdf.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/* This file contains the RDF APIs for Brooklyn. These are just
|
||||
wrappers around functions implemented in other files */
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
void RDF_Initialize () {
|
||||
rdf_init();
|
||||
}
|
||||
|
||||
void RDF_ReadFile (char* fileName) {
|
||||
readRDFFile(fileName);
|
||||
}
|
||||
|
||||
int RDF_Consume (char* fileName, char* data, int len) {
|
||||
return rdf_DigestNewStuff (fileName, data, len) ;
|
||||
}
|
||||
|
||||
void RDF_Unload (RDFT f) {
|
||||
unloadRDFT (f);
|
||||
}
|
||||
|
||||
RDFT RDF_GetRDFT (char* url, int createp) {
|
||||
return getRDFT (url, createp) ;
|
||||
}
|
||||
|
||||
RDF_Resource RDF_GetResource (char* url, int createp) {
|
||||
return getResource (url, createp) ;
|
||||
}
|
||||
|
||||
int RDF_Assert(RDFT db, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) {
|
||||
return (NULL != remoteStoreAdd (db, u, s, v, type, 1));
|
||||
}
|
||||
|
||||
int RDF_Unassert (RDFT db, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) {
|
||||
return (NULL != remoteStoreRemove (db, u, s, v, type));
|
||||
}
|
||||
|
||||
int RDF_HasAssertion (RDFT db, RDF_Resource u, RDF_Resource s,
|
||||
void* v, RDF_ValueType type) {
|
||||
return remoteStoreHasAssertion (db, u, s, v, type, 1);
|
||||
}
|
||||
|
||||
RDF_Resource RDF_OnePropSource (RDFT db, RDF_Resource u, RDF_Resource s) {
|
||||
return (RDF_Resource) getSlotValue(db, u, s, RDF_RESOURCE_TYPE, 1, 1);
|
||||
}
|
||||
|
||||
void* RDF_OnePropValue (RDFT db, RDF_Resource u, RDF_Resource s, RDF_ValueType type) {
|
||||
return getSlotValue (db, u, s, type, 0, 1);
|
||||
}
|
||||
|
||||
RDF_Cursor RDF_GetTargets (RDFT db, RDF_Resource u, RDF_Resource s, RDF_ValueType type) {
|
||||
return getSlotValues (db, u, s, type, 0, 1);
|
||||
}
|
||||
|
||||
RDF_Cursor RDF_GetSourcess (RDFT db, RDF_Resource u, RDF_Resource s) {
|
||||
return getSlotValues (db, u, s, RDF_RESOURCE_TYPE, 1, 1);
|
||||
}
|
||||
|
||||
void* RDF_NextValue (RDF_Cursor c) {
|
||||
return nextValue (c) ;
|
||||
}
|
||||
|
||||
void RDF_DisposeCursor (RDF_Cursor c) {
|
||||
disposeCursor(c);
|
||||
}
|
||||
|
||||
char** RDF_processPathQuery(char* query) {
|
||||
// return processRDFQuery (query) ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
55
mozilla/rdf/opendir/rdf.h
Normal file
55
mozilla/rdf/opendir/rdf.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/* This is the header file for the functions exported from RDF */
|
||||
|
||||
|
||||
|
||||
typedef struct _RDF_ResourceStruct* RDF_Resource;
|
||||
typedef struct _RDF_FileStruct* RDFT;
|
||||
typedef struct _RDF_CursorStruct* RDF_Cursor;
|
||||
typedef void (*WriteClientProc)(void* obj, char* buffer);
|
||||
|
||||
typedef enum {
|
||||
RDF_RESOURCE_TYPE,
|
||||
RDF_INT_TYPE,
|
||||
RDF_STRING_TYPE
|
||||
} RDF_ValueType;
|
||||
|
||||
|
||||
void RDF_Initialize () ;
|
||||
int RDF_Consume (char* fileName, char* data, int len) ;
|
||||
void RDF_ReadFile (char* fileName) ;
|
||||
void RDF_Unload (RDFT f);
|
||||
RDFT RDF_GetRDFT (char* url, int createp);
|
||||
|
||||
RDF_Resource RDF_GetResource (char* url, int createp);
|
||||
char* RDF_ResourceID(RDF_Resource u);
|
||||
int RDF_Assert(RDFT db, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
int RDF_Unassert (RDFT db, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
|
||||
int RDF_HasAssertion (RDFT db, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type);
|
||||
void* RDF_OnePropValue (RDFT db, RDF_Resource u, RDF_Resource s, RDF_ValueType type);
|
||||
RDF_Resource RDF_OnePropSource (RDFT db, RDF_Resource u, RDF_Resource s);
|
||||
RDF_Cursor RDF_GetTargets (RDFT db, RDF_Resource u, RDF_Resource s, RDF_ValueType type);
|
||||
RDF_Cursor RDF_GetSourcess (RDFT db, RDF_Resource u, RDF_Resource s);
|
||||
void* RDF_NextValue (RDF_Cursor c) ;
|
||||
void RDF_DisposeCursor (RDF_Cursor c);
|
||||
|
||||
char** RDF_processPathQuery(char* query);
|
||||
470
mozilla/rdf/opendir/rdfparse.c
Normal file
470
mozilla/rdf/opendir/rdfparse.c
Normal file
@@ -0,0 +1,470 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
char* error_string = NULL;
|
||||
int lineNumber = 0;
|
||||
|
||||
static HashTable resourceHash = NULL;
|
||||
|
||||
RDF_Resource
|
||||
getResource (char* key, int createp) {
|
||||
RDF_Resource existing = (RDF_Resource) HashLookup(resourceHash, key);
|
||||
if (existing) {
|
||||
return existing;
|
||||
} else if (createp){
|
||||
existing = (RDF_Resource)fgetMem(sizeof(RDF_ResourceStruct));
|
||||
existing->url = fcopyString(key);
|
||||
HashAdd(resourceHash, existing->url, existing);
|
||||
return existing;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
char*
|
||||
RDF_ResourceID (RDF_Resource u) {
|
||||
return u->url;
|
||||
}
|
||||
|
||||
static char* MemBlock = 0;
|
||||
size_t allocated = 0;
|
||||
#define MEM_BLOCK_SIZE 10000
|
||||
|
||||
char*
|
||||
fgetMem (size_t rsize) {
|
||||
char* ans = 0;
|
||||
size_t size = rsize + (4 - ldiv(rsize, 4).rem);
|
||||
if (!MemBlock || (size >= (MEM_BLOCK_SIZE - allocated))) {
|
||||
MemBlock = getMem(MEM_BLOCK_SIZE);
|
||||
allocated = 0;
|
||||
}
|
||||
ans = MemBlock;
|
||||
MemBlock = MemBlock + size;
|
||||
allocated = allocated + size;
|
||||
return ans;
|
||||
}
|
||||
|
||||
void readRDFFile (char* file) {
|
||||
FILE* f = fopen(file, "r");
|
||||
if (f) {
|
||||
RDFT rf = (RDFT)getRDFT(file, 1) ;
|
||||
int ok = 1;
|
||||
char* buff = (char*) malloc(100 * 1024);
|
||||
int len ;
|
||||
int i = 0;
|
||||
memset(buff, '\0', (100 * 1024));
|
||||
memset(rf, '\0', sizeof(RDF_FileStruct));
|
||||
|
||||
rf->line = (char*)getMem(RDF_BUF_SIZE);
|
||||
rf->holdOver = (char*)getMem(RDF_BUF_SIZE);
|
||||
rf->depth = 1;
|
||||
rf->lastItem = rf->stack[0] ;
|
||||
while ((len = fread(buff, 1, (100 * 1024) -1, f)) > 0) {
|
||||
buff[len] = '\0';
|
||||
printf("[%i] ", i++);
|
||||
fflush(0);
|
||||
if (!(ok = parseNextRDFXMLBlobInt(rf, buff, len))) {
|
||||
printf("Error in RDF File\n");
|
||||
}
|
||||
}
|
||||
printf("Finished reading %s\n", file);
|
||||
freeMem(rf->line);
|
||||
rf->line = NULL;
|
||||
freeMem(rf->holdOver);
|
||||
rf->holdOver = NULL;
|
||||
free(buff);
|
||||
} else printf("Could not find %s\n", file);
|
||||
}
|
||||
|
||||
static HashTable rdftHash = NULL;
|
||||
|
||||
RDFT
|
||||
getRDFT (char* key, int createp) {
|
||||
RDFT existing = (RDFT) HashLookup(rdftHash, key);
|
||||
if (existing) {
|
||||
return existing;
|
||||
} else if (createp){
|
||||
existing = (RDFT)getMem(sizeof(RDF_FileStruct));
|
||||
existing->url = fcopyString(key);
|
||||
HashAdd(rdftHash, existing->url, existing);
|
||||
return existing;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
rdf_init () {
|
||||
error_string = getMem(1000);
|
||||
resourceHash = NewHashTable((int)0x00000FFF);
|
||||
rdftHash = NewHashTable((int)0x00000FFF);
|
||||
}
|
||||
|
||||
int
|
||||
rdf_DigestNewStuff (char* url, char* data, int len) {
|
||||
RDFT rf = (RDFT)getRDFT(url, 1) ;
|
||||
int ok = 1;
|
||||
RDF_Resource u;
|
||||
unloadRDFT(rf);
|
||||
memset(rf, '\0', sizeof(RDF_FileStruct));
|
||||
rf->line = (char*)getMem(RDF_BUF_SIZE);
|
||||
rf->holdOver = (char*)getMem(RDF_BUF_SIZE);
|
||||
rf->depth = 1;
|
||||
rf->lastItem = rf->stack[0] ;
|
||||
ok = parseNextRDFXMLBlobInt(rf, data, len);
|
||||
/* if (!ok) unloadRDFT(rf); */
|
||||
freeMem(rf->line);
|
||||
rf->line = NULL;
|
||||
freeMem(rf->holdOver);
|
||||
rf->holdOver = NULL;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
startsWith (const char* pattern, const char* uuid) {
|
||||
int l1 = strlen(pattern);
|
||||
int l2 = strlen(uuid);
|
||||
int n;
|
||||
if (l2 < l1) return 0;
|
||||
for (n = 0; n < l1; n++) {
|
||||
if (pattern[n] != uuid[n]) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
char*
|
||||
getMem (size_t n) {
|
||||
char* ans = (char*) malloc(n);
|
||||
if (ans) memset(ans, '\0', n);
|
||||
return ans;
|
||||
}
|
||||
|
||||
void
|
||||
freeMem(void* item) {
|
||||
free(item);
|
||||
}
|
||||
|
||||
char
|
||||
decodeEntityRef (char* string, int* stringIndexPtr, int len) {
|
||||
if (startsWith("lt;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 3;
|
||||
return '<';
|
||||
} else if (startsWith("gt;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 3;
|
||||
return '>';
|
||||
} else if (startsWith("amp;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 4;
|
||||
return '&';
|
||||
} else return '&';
|
||||
}
|
||||
|
||||
char *
|
||||
copyStringIgnoreWhiteSpace(char* string)
|
||||
{
|
||||
int len = strlen(string);
|
||||
char* buf = (char*)fgetMem(len + 1);
|
||||
int inWhiteSpace = 1;
|
||||
int buffIndex = 0;
|
||||
int stringIndex = 0;
|
||||
|
||||
while (stringIndex < len) {
|
||||
char nextChar = *(string + stringIndex);
|
||||
int wsp = wsCharp(nextChar);
|
||||
if (!wsp) {
|
||||
if (nextChar == '&') {
|
||||
*(buf + buffIndex++) = decodeEntityRef(&string[stringIndex+1],
|
||||
&stringIndex, len-stringIndex);
|
||||
} else {
|
||||
*(buf + buffIndex++) = nextChar;
|
||||
}
|
||||
inWhiteSpace = 0;
|
||||
} else if (!inWhiteSpace) {
|
||||
*(buf + buffIndex++) = ' ';
|
||||
inWhiteSpace = 1;
|
||||
} else {
|
||||
inWhiteSpace = 1;
|
||||
}
|
||||
stringIndex++;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *
|
||||
getHref(char** attlist)
|
||||
{
|
||||
char* ans = getAttributeValue(attlist, "resource");
|
||||
if (!ans) ans = getAttributeValue(attlist, "rdf:resource");
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
getID(char** attlist)
|
||||
{
|
||||
char* ans = getAttributeValue(attlist, "id");
|
||||
if (!ans) ans = getAttributeValue(attlist, "about");
|
||||
if (!ans) ans = getAttributeValue(attlist, "rdf:about");
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
parseNextRDFXMLBlobInt(RDFT f, char* blob, int size) {
|
||||
int n, last, m;
|
||||
int somethingseenp = 0;
|
||||
n = last = 0;
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
if ((c == '\n') || (c == '\r')) lineNumber++;
|
||||
m = 0;
|
||||
somethingseenp = 0;
|
||||
memset(f->line, '\0', RDF_BUF_SIZE-1);
|
||||
if (f->holdOver[0] != '\0') {
|
||||
memcpy(f->line, f->holdOver, strlen(f->holdOver));
|
||||
m = strlen(f->holdOver);
|
||||
somethingseenp = 1;
|
||||
memset(f->holdOver, '\0', RDF_BUF_SIZE-1);
|
||||
}
|
||||
while ((n < size) && (wsCharp(c)) && (!somethingseenp)) {
|
||||
c = blob[++n];
|
||||
if ((c == '\n') || (c == '\r')) lineNumber++;
|
||||
}
|
||||
while ((m < RDF_BUF_SIZE) && (c != '<') && (c != '>')) {
|
||||
f->line[m] = c;
|
||||
m++;
|
||||
somethingseenp = (somethingseenp || (!(wsCharp(c))));
|
||||
n++;
|
||||
if (n < size) c = blob[n];
|
||||
else break;
|
||||
if ((c == '\n') || (c == '\r')) lineNumber++;
|
||||
}
|
||||
if (c == '>') f->line[m] = c;
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '<') || (c == '>')) {
|
||||
last = n;
|
||||
if (c == '<') f->holdOver[0] = '<';
|
||||
if (somethingseenp == 1) {
|
||||
int ok = parseNextRDFToken(f, f->line);
|
||||
if (!ok)
|
||||
return 0;
|
||||
}
|
||||
} else if (size > last) {
|
||||
memcpy(f->holdOver, f->line, m);
|
||||
}
|
||||
} else if (c == '<') f->holdOver[0] = '<';
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
char *
|
||||
getAttributeValue (char** attlist, char* elName)
|
||||
{
|
||||
size_t n = 0;
|
||||
if (!attlist) return NULL;
|
||||
while ((n < 2*MAX_ATTRIBUTES) && (*(attlist + n) != NULL)) {
|
||||
if (strcmp(*(attlist + n), elName) == 0) return *(attlist + n + 1);
|
||||
n = n + 2;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char*
|
||||
copyString (char* str) {
|
||||
char* ans = getMem(strlen(str)+1);
|
||||
if (ans) {
|
||||
memcpy(ans, str, strlen(str));
|
||||
return ans;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
char*
|
||||
fcopyString (char* str) {
|
||||
char* ans = fgetMem(strlen(str)+1);
|
||||
if (ans) {
|
||||
memcpy(ans, str, strlen(str));
|
||||
return ans;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
addElementProps (char** attlist, char* elementName, RDFT f, RDF_Resource obj)
|
||||
{
|
||||
int count = 0;
|
||||
while (count < 2*MAX_ATTRIBUTES) {
|
||||
char* attName = attlist[count++];
|
||||
char* attValue = attlist[count++];
|
||||
if ((attName == NULL) || (attValue == NULL)) break;
|
||||
if (!stringEquals(attName, "resource") &&
|
||||
!stringEquals(attName, "rdf:resource") &&
|
||||
!stringEquals(attName, "about") &&
|
||||
!stringEquals(attName, "rdf:about") &&
|
||||
!stringEquals(attName, "tv") &&
|
||||
!stringEquals(attName, "id")) {
|
||||
remoteStoreAdd(f, obj, getResource(attName, 1),
|
||||
copyStringIgnoreWhiteSpace(attValue),
|
||||
RDF_STRING_TYPE, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
parseNextRDFToken (RDFT f, char* token)
|
||||
{
|
||||
char* attlist[2*MAX_ATTRIBUTES+1];
|
||||
char* elementName;
|
||||
|
||||
if (token[0] != '<') {
|
||||
if ((f->status == EXPECTING_OBJECT) && (f->depth > 1)) {
|
||||
RDF_Resource u = f->stack[f->depth-2];
|
||||
RDF_Resource s = f->stack[f->depth-1];
|
||||
char* val = copyStringIgnoreWhiteSpace(token);
|
||||
remoteStoreAdd(f, u, s, val , RDF_STRING_TYPE, 1);
|
||||
return 1;
|
||||
} else {
|
||||
printf(error_string, "Did not expect \n\"%s\".\n Was expecting a tag.", token);
|
||||
return 0;
|
||||
}
|
||||
} else if (startsWith("<!--", token)) {
|
||||
return 1;
|
||||
} else if (token[1] == '?') {
|
||||
return 1;
|
||||
} else if (token[1] == '/') {
|
||||
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) {
|
||||
printf(error_string, "Did not expect %s. Something pretty screwed up", token);
|
||||
return 0;
|
||||
}
|
||||
if (f->depth > 0) f->depth--;
|
||||
f->status = (f->status == EXPECTING_OBJECT ? EXPECTING_PROPERTY : EXPECTING_OBJECT);
|
||||
return 1;
|
||||
} else if ((f->status == 0) && (startsWith("<RDF:RDF", token) ||
|
||||
startsWith("<RDF>", token))) {
|
||||
f->status = EXPECTING_OBJECT;
|
||||
return 1;
|
||||
} else {
|
||||
int emptyElementp = (token[strlen(token)-2] == '/');
|
||||
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) return 1;
|
||||
if (!tokenizeElement(token, attlist, &elementName)) return 0;
|
||||
if (f->status == EXPECTING_OBJECT) {
|
||||
char* url = NULL;
|
||||
RDF_Resource obj;
|
||||
int count = 0;
|
||||
url = getID(attlist);
|
||||
if (!url) {
|
||||
if (f->tagDepth > 2) {
|
||||
printf(error_string, "Unbalanced tags ");
|
||||
} else {
|
||||
printf(error_string, "Require a \"about\" attribute on %s", token);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
obj = getResource(url, 1);
|
||||
addElementProps (attlist, elementName, f, obj) ;
|
||||
if (!stringEquals(elementName, "RDF:Description")) {
|
||||
RDF_Resource eln = getResource(elementName, 1);
|
||||
remoteStoreAdd(f, obj, getResource("type", 1),
|
||||
eln, RDF_RESOURCE_TYPE,
|
||||
1);
|
||||
}
|
||||
if (f->depth > 1) {
|
||||
remoteStoreAdd(f, f->stack[f->depth-2], f->stack[f->depth-1], obj,
|
||||
RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
if (!emptyElementp) {
|
||||
f->stack[f->depth++] = obj;
|
||||
f->status = EXPECTING_PROPERTY;
|
||||
}
|
||||
} else if (f->status == EXPECTING_PROPERTY) {
|
||||
char* url;
|
||||
RDF_Resource obj;
|
||||
int count = 0;
|
||||
url = getHref(attlist) ;
|
||||
if (url) {
|
||||
RDF_Resource eln = getResource(elementName, 1);
|
||||
obj = getResource(url, 1);
|
||||
addElementProps (attlist, elementName, f, obj) ;
|
||||
remoteStoreAdd(f, f->stack[f->depth-1], eln, obj, RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
if (!emptyElementp) {
|
||||
f->stack[f->depth++] = getResource(elementName, 1);
|
||||
f->status = EXPECTING_OBJECT;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
tokenizeElement (char* attr, char** attlist, char** elementName)
|
||||
{
|
||||
size_t n = 1;
|
||||
size_t s = strlen(attr);
|
||||
char c ;
|
||||
size_t m = 0;
|
||||
size_t atc = 0;
|
||||
int emptyTagp = (attr[s-2] == '/');
|
||||
int inAttrNamep = 1;
|
||||
c = attr[n++];
|
||||
while (wsCharp(c)) {
|
||||
c = attr[n++];
|
||||
}
|
||||
*elementName = &attr[n-1];
|
||||
while (n < s) {
|
||||
if (wsCharp(c)) break;
|
||||
c = attr[n++];
|
||||
}
|
||||
attr[n-1] = '\0';
|
||||
while (atc < 2*MAX_ATTRIBUTES+1) {*(attlist + atc++) = NULL;}
|
||||
atc = 0;
|
||||
s = (emptyTagp ? s-2 : s-1);
|
||||
while (n < s) {
|
||||
int attributeOpenStringSeenp = 0;
|
||||
m = 0;
|
||||
c = attr[n++];
|
||||
while ((n <= s) && (atc < 2*MAX_ATTRIBUTES)) {
|
||||
if (inAttrNamep && (m > 0) && (wsCharp(c) || (c == '='))) {
|
||||
attr[n-1] = '\0';
|
||||
*(attlist + atc++) = &attr[n-m-1];
|
||||
break;
|
||||
}
|
||||
if (!inAttrNamep && attributeOpenStringSeenp && (c == '"')) {
|
||||
attr[n-1] = '\0';
|
||||
*(attlist + atc++) = &attr[n-m-1];
|
||||
break;
|
||||
}
|
||||
if (inAttrNamep) {
|
||||
if ((m > 0) || (!wsCharp(c))) m++;
|
||||
} else {
|
||||
if (c == '"') {
|
||||
attributeOpenStringSeenp = 1;
|
||||
} else {
|
||||
if ((m > 0) || (!(wsCharp(c)))) m++;
|
||||
}
|
||||
}
|
||||
c = attr[n++];
|
||||
}
|
||||
inAttrNamep = (inAttrNamep ? 0 : 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
216
mozilla/rdf/opendir/remstore.c
Normal file
216
mozilla/rdf/opendir/remstore.c
Normal file
@@ -0,0 +1,216 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
#include "rdf-int.h"
|
||||
#include "gs.h"
|
||||
|
||||
int
|
||||
asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
return (((r == NULL) || (as->db == r)) &&
|
||||
(as->u == u) &&
|
||||
(as->s == s) &&
|
||||
(as->type == type) &&
|
||||
((as->value == v) ||
|
||||
((type == RDF_STRING_TYPE) && (strcmp((char*)v, (char*)as->value) == 0))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
makeNewAssertion (RDFT r, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, int tv)
|
||||
{
|
||||
Assertion newAs = (Assertion) fgetMem(sizeof(RDF_AssertionStruct));
|
||||
newAs->u = u;
|
||||
newAs->s = s;
|
||||
newAs->value = v;
|
||||
newAs->type = type;
|
||||
newAs->db = r;
|
||||
return newAs;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
addToAssertionList (RDFT f, Assertion as)
|
||||
{
|
||||
if (f->assertionListCount >= f->assertionListSize) {
|
||||
f->assertionList = (Assertion*) realloc(f->assertionList,
|
||||
(sizeof(Assertion*) *
|
||||
(f->assertionListSize =
|
||||
f->assertionListSize + GROW_LIST_INCR)));
|
||||
}
|
||||
*(f->assertionList + f->assertionListCount++) = as;
|
||||
}
|
||||
|
||||
void
|
||||
freeAssertion (Assertion as)
|
||||
{
|
||||
if (as->type == RDF_STRING_TYPE) {
|
||||
freeMem(as->value);
|
||||
}
|
||||
freeMem(as);
|
||||
}
|
||||
|
||||
|
||||
Assertion
|
||||
remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, int tv)
|
||||
{
|
||||
Assertion newAs = makeNewAssertion(mcf, u, s, v, type, tv);
|
||||
newAs->next = u->rarg1;
|
||||
u->rarg1 = newAs;
|
||||
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
RDF_Resource iu = (RDF_Resource)v;
|
||||
newAs->invNext = iu->rarg2;
|
||||
iu->rarg2 = newAs;
|
||||
}
|
||||
if (type == RDF_STRING_TYPE) RDFGS_AddSearchIndex(mcf, (char*) v, s, u);
|
||||
|
||||
return newAs;
|
||||
}
|
||||
|
||||
|
||||
Assertion
|
||||
remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
||||
void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, ans;
|
||||
int found = false;
|
||||
nextAs = prevAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) {
|
||||
if (prevAs == nextAs) {
|
||||
u->rarg1 = nextAs->next;
|
||||
} else {
|
||||
prevAs->next = nextAs->next;
|
||||
}
|
||||
found = true;
|
||||
ans = nextAs;
|
||||
break;
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
if (found == false) return null;
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ((RDF_Resource)v)->rarg2;
|
||||
while (nextAs != null) {
|
||||
if (nextAs == ans) {
|
||||
if (prevAs == nextAs) {
|
||||
((RDF_Resource)v)->rarg2 = nextAs->invNext;
|
||||
} else {
|
||||
prevAs->invNext = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
int
|
||||
remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, int tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
|
||||
nextAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
getSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, int inversep, int tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
|
||||
nextAs = (inversep ? u->rarg2 : u->rarg1);
|
||||
while (nextAs != null) {
|
||||
if (((nextAs->db == mcf) || (!mcf)) && (nextAs->s == s)
|
||||
&& (nextAs->type == type)) {
|
||||
return (inversep ? nextAs->u : nextAs->value);
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
RDF_Cursor
|
||||
getSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, int inversep, int tv)
|
||||
{
|
||||
Assertion as = (inversep ? u->rarg2 : u->rarg1);
|
||||
RDF_Cursor c;
|
||||
if (!as) return NULL;
|
||||
c = (RDF_Cursor)getMem(sizeof(RDF_CursorStruct));
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->type = type;
|
||||
c->inversep = inversep;
|
||||
c->count = 0;
|
||||
c->db = mcf;
|
||||
c->pdata = as;
|
||||
c->queryType = GET_SLOT_VALUES;
|
||||
return c;
|
||||
}
|
||||
|
||||
void *
|
||||
nextValue (RDF_Cursor c) {
|
||||
if (!c) return null;
|
||||
while (c->pdata != null) {
|
||||
Assertion as = (Assertion) c->pdata;
|
||||
if (((as->db == c->db) || (!c->db)) && (as->s == c->s) && (c->type == as->type)) {
|
||||
c->value = (c->inversep ? as->u : as->value);
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
return c->value;
|
||||
}
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void
|
||||
disposeCursor (RDF_Cursor c)
|
||||
{
|
||||
if (c) freeMem(c);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
unloadRDFT (RDFT f)
|
||||
{
|
||||
int n = 0;
|
||||
while (n < f->assertionListCount) {
|
||||
Assertion as = *(f->assertionList + n);
|
||||
remoteStoreRemove(f, as->u, as->s, as->value, as->type);
|
||||
freeAssertion(as);
|
||||
*(f->assertionList + n) = NULL;
|
||||
n++;
|
||||
}
|
||||
f->assertionListCount = 0;
|
||||
f->assertionListSize = 0;
|
||||
freeMem(f->assertionList);
|
||||
f->assertionList = NULL;
|
||||
}
|
||||
|
||||
39
mozilla/rdf/opendir/rl.c
Normal file
39
mozilla/rdf/opendir/rl.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
|
||||
#include "rl.h"
|
||||
#include "plstr.h"
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
RLInit(void)
|
||||
{
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
RLTrace(const char* fmtstr, ...)
|
||||
{
|
||||
char* str;
|
||||
va_list ap;
|
||||
va_start(ap, fmtstr);
|
||||
|
||||
str = PR_vsmprintf(fmtstr, ap);
|
||||
if (str) {
|
||||
PR_Write(PR_STDERR, str, PL_strlen(str));
|
||||
PR_smprintf_free(str);
|
||||
}
|
||||
}
|
||||
431
mozilla/rdf/opendir/spf2ldiff.c
Normal file
431
mozilla/rdf/opendir/spf2ldiff.c
Normal file
@@ -0,0 +1,431 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
char* error_string = NULL;
|
||||
int lineNumber = 0;
|
||||
void
|
||||
main (int argc, char* argv[]) {
|
||||
RDFFile rf = initFileStruct();
|
||||
int ok = 1;
|
||||
error_string = getMem(1000);
|
||||
if (argc == 2) {
|
||||
FILE* f = fopen(argv[1], "r");
|
||||
if (f != NULL) {
|
||||
char* buff = getMem(RDF_BUF_SIZE);
|
||||
int len;
|
||||
while (ok && ((len = fread(buff, 1, RDF_BUF_SIZE-1, f)) > 0)) {
|
||||
buff[len] = '\0';
|
||||
ok = parseNextRDFXMLBlobInt(rf, buff, strlen(buff));
|
||||
memset(buff, '\0', RDF_BUF_SIZE);
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
while (1) {
|
||||
char* nextQuery = getMem(200);
|
||||
int n;
|
||||
nextQuery = gets(nextQuery);
|
||||
if (nextQuery) {
|
||||
char** ans = processRDFQuery(nextQuery);
|
||||
if (ans) {
|
||||
for (n = 0; ans[n] != NULL; n++) {
|
||||
printf("%s\n", ans[n]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RDF_Init () {
|
||||
error_string = getMem(1000);
|
||||
}
|
||||
|
||||
int
|
||||
RDF_DigestNewStuff (char* fileName, char* data, int len) {
|
||||
RDFFile rf = initFileStruct();
|
||||
int ok = 1;
|
||||
ok = parseNextRDFXMLBlobInt(rf, data, len);
|
||||
freeMem(rf->line);
|
||||
freeMem(rf->holdOver);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
RDFFile
|
||||
initFileStruct (void) {
|
||||
RDFFile ans = (RDFFile)getMem(sizeof(RDF_FileStruct));
|
||||
ans->line = (char*)getMem(RDF_BUF_SIZE);
|
||||
ans->holdOver = (char*)getMem(RDF_BUF_SIZE);
|
||||
ans->depth = 1;
|
||||
ans->lastItem = ans->stack[0] ;
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
startsWith (const char* pattern, const char* uuid)
|
||||
{
|
||||
int l1 = strlen(pattern);
|
||||
int l2 = strlen(uuid);
|
||||
int n;
|
||||
if (l2 < l1) return 0;
|
||||
for (n = 0; n < l1; n++) {
|
||||
if (pattern[n] != uuid[n]) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
char*
|
||||
getMem (size_t n) {
|
||||
char* ans = (char*) malloc(n);
|
||||
if (ans) memset(ans, '\0', n);
|
||||
return ans;
|
||||
}
|
||||
|
||||
void
|
||||
freeMem(void* item) {
|
||||
free(item);
|
||||
}
|
||||
|
||||
char
|
||||
decodeEntityRef (char* string, int* stringIndexPtr, int len) {
|
||||
if (startsWith("lt;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 3;
|
||||
return '<';
|
||||
} else if (startsWith("gt;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 3;
|
||||
return '>';
|
||||
} else if (startsWith("amp;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 4;
|
||||
return '&';
|
||||
} else return '&';
|
||||
}
|
||||
|
||||
char *
|
||||
copyStringIgnoreWhiteSpace(char* string)
|
||||
{
|
||||
int len = strlen(string);
|
||||
char* buf = (char*)getMem(len + 1);
|
||||
PRBool inWhiteSpace = 1;
|
||||
int buffIndex = 0;
|
||||
int stringIndex = 0;
|
||||
|
||||
while (stringIndex < len) {
|
||||
char nextChar = *(string + stringIndex);
|
||||
PRBool wsp = wsCharp(nextChar);
|
||||
if (!wsp) {
|
||||
if (nextChar == '&') {
|
||||
*(buf + buffIndex++) = decodeEntityRef(&string[stringIndex+1],
|
||||
&stringIndex, len-stringIndex);
|
||||
} else {
|
||||
*(buf + buffIndex++) = nextChar;
|
||||
}
|
||||
inWhiteSpace = 0;
|
||||
} else if (!inWhiteSpace) {
|
||||
*(buf + buffIndex++) = ' ';
|
||||
inWhiteSpace = 1;
|
||||
} else {
|
||||
inWhiteSpace = 1;
|
||||
}
|
||||
stringIndex++;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *
|
||||
getHref(char** attlist)
|
||||
{
|
||||
char* ans = getAttributeValue(attlist, "resource");
|
||||
if (!ans) ans = getAttributeValue(attlist, "rdf:resource");
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
getID(char** attlist)
|
||||
{
|
||||
char* ans = getAttributeValue(attlist, "id");
|
||||
if (!ans) ans = getAttributeValue(attlist, "about");
|
||||
if (!ans) ans = getAttributeValue(attlist, "rdf:about");
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
parseNextRDFXMLBlobInt(RDFFile f, char* blob, int size) {
|
||||
int n, last, m;
|
||||
PRBool somethingseenp = 0;
|
||||
n = last = 0;
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
if ((c == '\n') || (c == '\r')) lineNumber++;
|
||||
m = 0;
|
||||
somethingseenp = 0;
|
||||
memset(f->line, '\0', RDF_BUF_SIZE-1);
|
||||
if (f->holdOver[0] != '\0') {
|
||||
memcpy(f->line, f->holdOver, strlen(f->holdOver));
|
||||
m = strlen(f->holdOver);
|
||||
somethingseenp = 1;
|
||||
memset(f->holdOver, '\0', RDF_BUF_SIZE-1);
|
||||
}
|
||||
while ((n < size) && (wsCharp(c))) {
|
||||
c = blob[++n];
|
||||
if ((c == '\n') || (c == '\r')) lineNumber++;
|
||||
}
|
||||
while ((m < RDF_BUF_SIZE) && (c != '<') && (c != '>')) {
|
||||
f->line[m] = c;
|
||||
m++;
|
||||
somethingseenp = (somethingseenp || (!(wsCharp(c))));
|
||||
n++;
|
||||
if (n < size) c = blob[n];
|
||||
else break;
|
||||
if ((c == '\n') || (c == '\r')) lineNumber++;
|
||||
}
|
||||
if (c == '>') f->line[m] = c;
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '<') || (c == '>')) {
|
||||
last = n;
|
||||
if (c == '<') f->holdOver[0] = '<';
|
||||
if (somethingseenp == 1) {
|
||||
int ok = parseNextRDFToken(f, f->line);
|
||||
if (!ok)
|
||||
return 0;
|
||||
}
|
||||
} else if (size > last) {
|
||||
memcpy(f->holdOver, f->line, m);
|
||||
}
|
||||
} else if (c == '<') f->holdOver[0] = '<';
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
char *
|
||||
getAttributeValue (char** attlist, char* elName)
|
||||
{
|
||||
size_t n = 0;
|
||||
if (!attlist) return NULL;
|
||||
while ((n < 2*MAX_ATTRIBUTES) && (*(attlist + n) != NULL)) {
|
||||
if (strcmp(*(attlist + n), elName) == 0) return *(attlist + n + 1);
|
||||
n = n + 2;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char*
|
||||
copyString (char* str) {
|
||||
char* ans = getMem(strlen(str)+1);
|
||||
if (ans) {
|
||||
memcpy(ans, str, strlen(str));
|
||||
return ans;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
addElementProps (char** attlist, char* elementName, RDFFile f, RDF_Resource obj)
|
||||
{
|
||||
int count = 0;
|
||||
while (count < 2*MAX_ATTRIBUTES) {
|
||||
char* attName = attlist[count++];
|
||||
char* attValue = attlist[count++];
|
||||
if ((attName == NULL) || (attValue == NULL)) break;
|
||||
if (!stringEquals(attName, "resource") &&
|
||||
!stringEquals(attName, "rdf:resource") &&
|
||||
!stringEquals(attName, "about") &&
|
||||
!stringEquals(attName, "rdf:about") &&
|
||||
!stringEquals(attName, "tv") &&
|
||||
!stringEquals(attName, "id")) {
|
||||
remoteStoreAdd(f, obj, getResource(f, attName),
|
||||
copyStringIgnoreWhiteSpace(attValue),
|
||||
RDF_STRING_TYPE, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
parseNextRDFToken (RDFFile f, char* token)
|
||||
{
|
||||
char* attlist[2*MAX_ATTRIBUTES+1];
|
||||
char* elementName;
|
||||
if (token[0] == '<') {
|
||||
size_t len = strlen(token);
|
||||
if (token[len-2] != '/') {
|
||||
if (token[1] == '/') {
|
||||
char* tok = getMem(len);
|
||||
memcpy(tok, &token[2], len-3);
|
||||
if (!stringEquals(tok, f->tagStack[f->tagDepth-1])) {
|
||||
sprintf(error_string, "Unbalanced tags : Expecting </%s>, found %s",
|
||||
f->tagStack[f->tagDepth-1], token);
|
||||
return 0;
|
||||
} else {
|
||||
f->tagDepth--;
|
||||
freeMem(tok);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (token[0] != '<') {
|
||||
if ((f->status == EXPECTING_OBJECT) && (f->depth > 1)) {
|
||||
RDF_Resource u = f->stack[f->depth-2];
|
||||
RDF_Resource s = f->stack[f->depth-1];
|
||||
char* val = copyStringIgnoreWhiteSpace(token);
|
||||
remoteStoreAdd(f, u, s, val , RDF_STRING_TYPE, 1);
|
||||
} else {
|
||||
sprintf(error_string, "Did not expect \n\"%s\".\n Was expecting a tag.", token);
|
||||
return 0;
|
||||
}
|
||||
} else if (startsWith("<!--", token)) {
|
||||
return 1;
|
||||
} else if (token[1] == '?') {
|
||||
return 1;
|
||||
} else if (token[1] == '/') {
|
||||
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) {
|
||||
sprintf(error_string, "Did not expect %s. Something pretty screwed up", token);
|
||||
return 0;
|
||||
}
|
||||
if (f->depth > 0) f->depth--;
|
||||
f->status = (f->status == EXPECTING_OBJECT ? EXPECTING_PROPERTY : EXPECTING_OBJECT);
|
||||
return 1;
|
||||
} else if ((f->status == 0) && (startsWith("<RDF:RDF", token) ||
|
||||
startsWith("<RDF>", token))) {
|
||||
f->tagStack[f->tagDepth++] = copyString("RDF");
|
||||
f->status = EXPECTING_OBJECT;
|
||||
return 1;
|
||||
} else {
|
||||
PRBool emptyElementp = (token[strlen(token)-2] == '/');
|
||||
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) return 1;
|
||||
if (!tokenizeElement(token, attlist, &elementName)) return 0;
|
||||
if (!emptyElementp)
|
||||
f->tagStack[f->tagDepth++] = copyString(elementName);
|
||||
if (f->status == EXPECTING_OBJECT) {
|
||||
char* url = NULL;
|
||||
RDF_Resource obj;
|
||||
int count = 0;
|
||||
url = getID(attlist);
|
||||
if (!url) {
|
||||
if (f->tagDepth > 2) {
|
||||
sprintf(error_string, "Unbalanced tags : Expecting </%s>, found %s",
|
||||
f->tagStack[f->tagDepth-2], token);
|
||||
} else {
|
||||
sprintf(error_string, "Require a \"about\" attribute on %s", token);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
obj = getResource(f, url);
|
||||
addElementProps (attlist, elementName, f, obj) ;
|
||||
if (!stringEquals(elementName, "RDF:Description")) {
|
||||
RDF_Resource eln = getResource(f, elementName);
|
||||
remoteStoreAdd(f, obj, getResource(NULL, "instanceOf"),
|
||||
eln, RDF_RESOURCE_TYPE,
|
||||
1);
|
||||
}
|
||||
if (f->depth > 1) {
|
||||
remoteStoreAdd(f, f->stack[f->depth-2], f->stack[f->depth-1], obj,
|
||||
RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
if (!emptyElementp) {
|
||||
f->stack[f->depth++] = obj;
|
||||
f->status = EXPECTING_PROPERTY;
|
||||
}
|
||||
} else if (f->status == EXPECTING_PROPERTY) {
|
||||
char* url;
|
||||
RDF_Resource obj;
|
||||
int count = 0;
|
||||
url = getHref(attlist) ;
|
||||
if (url) {
|
||||
RDF_Resource eln = getResource(f, elementName);
|
||||
char* tvAtt = getAttributeValue(attlist, "tv");
|
||||
obj = getResource(f, url);
|
||||
freeMem(url);
|
||||
addElementProps (attlist, elementName, f, obj) ;
|
||||
remoteStoreAdd(f, f->stack[f->depth-1], eln, obj, RDF_RESOURCE_TYPE, 1);
|
||||
|
||||
}
|
||||
if (!emptyElementp) {
|
||||
f->stack[f->depth++] = getResource(f, elementName);
|
||||
f->status = EXPECTING_OBJECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
tokenizeElement (char* attr, char** attlist, char** elementName)
|
||||
{
|
||||
size_t n = 1;
|
||||
size_t s = strlen(attr);
|
||||
char c ;
|
||||
size_t m = 0;
|
||||
size_t atc = 0;
|
||||
PRBool emptyTagp = (attr[s-2] == '/');
|
||||
PRBool inAttrNamep = 1;
|
||||
c = attr[n++];
|
||||
while (wsCharp(c)) {
|
||||
c = attr[n++];
|
||||
}
|
||||
*elementName = &attr[n-1];
|
||||
while (n < s) {
|
||||
if (wsCharp(c)) break;
|
||||
c = attr[n++];
|
||||
}
|
||||
attr[n-1] = '\0';
|
||||
while (atc < 2*MAX_ATTRIBUTES+1) {*(attlist + atc++) = NULL;}
|
||||
atc = 0;
|
||||
s = (emptyTagp ? s-2 : s-1);
|
||||
while (n < s) {
|
||||
PRBool attributeOpenStringSeenp = 0;
|
||||
m = 0;
|
||||
c = attr[n++];
|
||||
while ((n <= s) && (atc < 2*MAX_ATTRIBUTES)) {
|
||||
if (inAttrNamep && (m > 0) && (wsCharp(c) || (c == '='))) {
|
||||
attr[n-1] = '\0';
|
||||
*(attlist + atc++) = &attr[n-m-1];
|
||||
break;
|
||||
}
|
||||
if (!inAttrNamep && attributeOpenStringSeenp && (c == '"')) {
|
||||
attr[n-1] = '\0';
|
||||
*(attlist + atc++) = &attr[n-m-1];
|
||||
break;
|
||||
}
|
||||
if (inAttrNamep) {
|
||||
if ((m > 0) || (!wsCharp(c))) m++;
|
||||
} else {
|
||||
if (c == '"') {
|
||||
attributeOpenStringSeenp = 1;
|
||||
} else {
|
||||
if ((m > 0) || (!(wsCharp(c)))) m++;
|
||||
}
|
||||
}
|
||||
c = attr[n++];
|
||||
}
|
||||
inAttrNamep = (inAttrNamep ? 0 : 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
66
mozilla/rdf/opendir/test.c
Normal file
66
mozilla/rdf/opendir/test.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C; tab-width: 8; 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "rdf.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void main () {
|
||||
char* nextQuery = malloc(200);
|
||||
memset(nextQuery, '\0', 200);
|
||||
RDF_Initialize();
|
||||
while (1) {
|
||||
int n;
|
||||
int startsWith(const char* pattern, const char* item);
|
||||
nextQuery = gets(nextQuery);
|
||||
if (nextQuery) {
|
||||
if (startsWith("read", nextQuery)) {
|
||||
FILE* f = fopen(&nextQuery[5], "r");
|
||||
if (f) {
|
||||
char* buff = malloc(100 * 1024);
|
||||
int len ;
|
||||
memset(buff, '\0', (100 * 1024));
|
||||
len = fread(buff, 1, (100 * 1024) -1, f);
|
||||
buff[len] = '\0';
|
||||
if (!RDF_Consume(&nextQuery[5], buff, len)) {
|
||||
printf("Error in RDF File\n");
|
||||
} else {
|
||||
printf("Finished reading %s\n", &nextQuery[5]);
|
||||
}
|
||||
free(buff);
|
||||
} else {
|
||||
printf("could not open %s\n", &nextQuery[5]);
|
||||
}
|
||||
} else if (startsWith("rdf", nextQuery)) {
|
||||
char** ans = RDF_processPathQuery(&nextQuery[4]);
|
||||
printf("\n");
|
||||
if (ans) {
|
||||
for (n = 0; ans[n] != 0; n++) {
|
||||
printf("(%i) %s\n",n, ans[n]);
|
||||
}
|
||||
} else {
|
||||
printf("No answers\n");
|
||||
}
|
||||
free(ans);
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
}
|
||||
52
mozilla/rdf/resources/LocalStore.css
Normal file
52
mozilla/rdf/resources/LocalStore.css
Normal file
@@ -0,0 +1,52 @@
|
||||
DOCUMENT, BODY {
|
||||
display: block;
|
||||
}
|
||||
|
||||
FOLDER, CHILD {
|
||||
display: block;
|
||||
color: #FFFFFF;
|
||||
background-color: #AAAAEE;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
NAME {
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
SUBJECT {
|
||||
display: none;
|
||||
}
|
||||
|
||||
FOLDER FOLDER CHILD SUBJECT {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 300px;
|
||||
font-family: Verdana, Sans-Serif;
|
||||
font-size: 10pt;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
FOLDER CHILD NAME {
|
||||
text-decoration: none;
|
||||
font-family: Verdana, Sans-Serif;
|
||||
font-size: 10pt;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
DATE {
|
||||
margin-left: 12px;
|
||||
font-family: Verdana, Sans-Serif;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
LASTVISITDATE, BOOKMARKADDDATE, LASTMODIFIEDDATE {
|
||||
font-family: monospace;
|
||||
display: block;
|
||||
float: right;
|
||||
width: 100px;
|
||||
}
|
||||
58
mozilla/rdf/resources/LocalStore.rdf
Normal file
58
mozilla/rdf/resources/LocalStore.rdf
Normal file
@@ -0,0 +1,58 @@
|
||||
<!--
|
||||
|
||||
This file contains the description for the "local store". Using the
|
||||
"#root" resource as the root of an RDF document will produce a content
|
||||
model that can be displayed in the tree widget, HTML viewer, etc.
|
||||
|
||||
-->
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="LocalStore.css" type="text/css"?>
|
||||
<?rdf-datasource href="rdf:mail"?>
|
||||
<?rdf-datasource href="rdf:bookmarks"?>
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/TR/WD-rdf-syntax#"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:web="http://home.netscape.com/WEB-rdf#">
|
||||
|
||||
<RDF:Description RDF:ID="#root">
|
||||
<!-- List out all the columns that we want to appear in the tree control -->
|
||||
<nc:Columns>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description nc:Title="Subject" nc:Column="http://home.netscape.com/NC-rdf#subject"/>
|
||||
</RDF:li>
|
||||
|
||||
<RDF:li>
|
||||
<RDF:Description nc:Title="From" nc:Column="http://home.netscape.com/NC-rdf#from"/>
|
||||
</RDF:li>
|
||||
|
||||
<RDF:li>
|
||||
<RDF:Description nc:Title="Date" nc:Column="http://home.netscape.com/NC-rdf#date"/>
|
||||
</RDF:li>
|
||||
|
||||
<RDF:li>
|
||||
<RDF:Description nc:Title="Name" nc:Column="http://home.netscape.com/NC-rdf#Name"/>
|
||||
</rdf:li>
|
||||
|
||||
<RDF:li>
|
||||
<RDF:Description nc:Title="Added" nc:Column="http://home.netscape.com/NC-rdf#BookmarkAddDate"/>
|
||||
</RDF:li>
|
||||
|
||||
<RDF:li>
|
||||
<RDF:Description nc:Title="Last Visited" nc:Column="http://home.netscape.com/WEB-rdf#LastVisitDate"/>
|
||||
</RDF:li>
|
||||
|
||||
<RDF:li>
|
||||
<RDF:Description nc:Title="Last Modified" nc:Column="http://home.netscape.com/WEB-rdf#LastModifiedDate"/>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</nc:Columns>
|
||||
|
||||
<!-- Top-level folders and items -->
|
||||
<nc:child RDF:resource="http://www.netscape.com" nc:subject="Netscape Home Page!"/>
|
||||
<nc:child RDF:resource="NC:MailRoot" nc:subject="Mail"/>
|
||||
<nc:child RDF:resource="NC:BookmarksRoot" nc:subject="Bookmarks"/>
|
||||
</RDF:Description>
|
||||
|
||||
</RDF:RDF>
|
||||
102
mozilla/rdf/resources/Mail/jane@aol.com/hiking
Normal file
102
mozilla/rdf/resources/Mail/jane@aol.com/hiking
Normal file
@@ -0,0 +1,102 @@
|
||||
From - Tue Mar 03 14:14:13 1998
|
||||
Return-Path: <neumann@netscape.com>
|
||||
Received: from netscape.com ([207.1.142.184]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA28E8;
|
||||
Tue, 3 Mar 1998 13:33:54 -0800
|
||||
Message-ID: <34FC773F.62AEA20D@netscape.com>
|
||||
Date: Tue, 03 Mar 1998 13:33:51 -0800
|
||||
From: neumann@netscape.com (Lori Neumann)
|
||||
Organization: Netscape Communications
|
||||
X-Mailer: Mozilla 4.04 [en] (Win95; I)
|
||||
MIME-Version: 1.0
|
||||
To: jane@aol.com
|
||||
CC: Irene Au <irene@netscape.com>, german@netscape.com,
|
||||
Valerie Hunter <valh@netscape.com>, kenh@netscape.com,
|
||||
pinkerton@netscape.com, blythe@netscape.com,
|
||||
hyatt@netscape.com, slamm@netscape.com, ramiro@netscape.com,
|
||||
Don Melton <don@netscape.com>, jg@netscape.com,
|
||||
"guha@netscape.com" <guha@netscape.com>, tgoldman@netscape.com
|
||||
Subject: Re: Toward resolution of UI for hiking
|
||||
References: <34FC40A9.A1F22D04@netscape.com> <34FC6EE8.6FA41408@netscape.com>
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 7613
|
||||
|
||||
<HTML>
|
||||
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#534A86" VLINK="#8080C0" ALINK="#FF0000">
|
||||
John, Thanks for the summary.
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
From - Tue Mar 03 14:14:13 1998
|
||||
Return-Path: <neumann@netscape.com>
|
||||
Received: from netscape.com ([207.1.142.184]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA54DC;
|
||||
Tue, 3 Mar 1998 14:11:00 -0800
|
||||
Message-ID: <34FC7FF1.88AAD459@netscape.com>
|
||||
Date: Tue, 03 Mar 1998 14:10:57 -0800
|
||||
From: neumann@netscape.com (Lori Neumann)
|
||||
Organization: Netscape Communications
|
||||
X-Mailer: Mozilla 4.04 [en] (Win95; I)
|
||||
MIME-Version: 1.0
|
||||
To: David Hyatt <hyatt@netscape.com>
|
||||
CC: John Gable <johng@netscape.com>, Irene Au <irene@netscape.com>
|
||||
, german@netscape.com, Valerie Hunter <valh@netscape.com>
|
||||
, kenh@netscape.com, pinkerton@netscape.com,
|
||||
blythe@netscape.com, slamm@netscape.com, ramiro@netscape.com,
|
||||
Don Melton <don@netscape.com>, jg@netscape.com,
|
||||
"guha@netscape.com" <guha@netscape.com>, tgoldman@netscape.com
|
||||
Subject: Re: Toward resolution of hiking UI
|
||||
References: <34FC40A9.A1F22D04@netscape.com> <34FC6EE8.6FA41408@netscape.com> <34FC773F.62AEA20D@netscape.com> <34FC7A47.4AEC3D6F@netscape.com>
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 284
|
||||
|
||||
<HTML>
|
||||
David, I completely agree. But unless we have a clear design model for
|
||||
how hiking works, we're going to get asked to put random buttons on Yosemite.
|
||||
We've been there. I just want to make sure we get the requirements met
|
||||
while designing a predictable UI.
|
||||
|
||||
<P>--Lori</HTML>
|
||||
|
||||
From - Tue Mar 03 16:12:53 1998
|
||||
Return-Path: <neumann@netscape.com>
|
||||
Received: from netscape.com ([207.1.142.184]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA6102;
|
||||
Tue, 3 Mar 1998 14:20:50 -0800
|
||||
Message-ID: <34FC823F.F214C16B@netscape.com>
|
||||
Date: Tue, 03 Mar 1998 14:20:47 -0800
|
||||
From: neumann@netscape.com (Lori Neumann)
|
||||
Organization: Netscape Communications
|
||||
X-Mailer: Mozilla 4.04 [en] (Win95; I)
|
||||
MIME-Version: 1.0
|
||||
To: pinkerton@netscape.com
|
||||
CC: John Gable <johng@netscape.com>, Irene Au <irene@netscape.com>
|
||||
, german@netscape.com, Valerie Hunter <valh@netscape.com>
|
||||
, kenh@netscape.com, blythe@netscape.com, hyatt@netscape.com,
|
||||
slamm@netscape.com, ramiro@netscape.com,
|
||||
Don Melton <don@netscape.com>, jg@netscape.com,
|
||||
"guha@netscape.com" <guha@netscape.com>, tgoldman@netscape.com
|
||||
Subject: Wither hiking?
|
||||
References: <34FC40A9.A1F22D04@netscape.com> <34FC6EE8.6FA41408@netscape.com> <34FC773F.62AEA20D@netscape.com> <34FC7E10.A47976A8@netscape.com>
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 584
|
||||
|
||||
<HTML>
|
||||
Mike, I agree that the features shouldn't interfere with the UI. And the
|
||||
last thing I want the UI to have to do is be contorted to accommodate Yellowstone!
|
||||
|
||||
<P>However, we do need a design that is more scalable than what we currently
|
||||
have and helps drives traffic and membership to Yellowstone without impacting
|
||||
the user experience.
|
||||
|
||||
<P>This is why it is important to get a requirements document distributed
|
||||
and approved.
|
||||
|
||||
<P>--Lori</HTML>
|
||||
|
||||
372
mozilla/rdf/resources/Mail/jane@aol.com/inbox
Normal file
372
mozilla/rdf/resources/Mail/jane@aol.com/inbox
Normal file
@@ -0,0 +1,372 @@
|
||||
From - Fri Feb 13 14:23:39 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA20967;
|
||||
Wed, 11 Feb 1998 09:43:51 -0800
|
||||
Received: from netscape.com ([208.12.41.138]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA11421;
|
||||
Wed, 11 Feb 1998 09:43:51 -0800
|
||||
Message-ID: <34E1E2AB.7993EC37@netscape.com>
|
||||
Date: Wed, 11 Feb 1998 09:40:59 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: Chris Hofmann <chofmann@netscape.com>, tomt@netscape.com,
|
||||
John Gable <johng@netscape.com>, guha@netscape.com,
|
||||
Don Melton <don@netscape.com>
|
||||
, Jean-Charles Mourey <mourey@netscape.com>
|
||||
Subject: 5.01
|
||||
Content-Type: multipart/mixed; boundary="------------6D489A9D88CBB8298AFCCF06"
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 1268
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------6D489A9D88CBB8298AFCCF06
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
something here
|
||||
<P>Thanks,
|
||||
<BR>Dave</HTML>
|
||||
|
||||
--------------6D489A9D88CBB8298AFCCF06
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------6D489A9D88CBB8298AFCCF06--
|
||||
|
||||
From - Fri Feb 13 14:23:55 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA3B91;
|
||||
Thu, 12 Feb 1998 13:33:59 -0800
|
||||
Received: from netscape.com ([208.12.41.137]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA27509;
|
||||
Thu, 12 Feb 1998 13:33:59 -0800
|
||||
Message-ID: <34E36AC7.3EB06EAE@netscape.com>
|
||||
Date: Thu, 12 Feb 1998 13:33:59 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: erik@netscape.com
|
||||
CC: Ramanathan Guha <guha@netscape.com>
|
||||
, Bob Jung <bobj@netscape.com>
|
||||
, Chris Hofmann <chofmann@netscape.com>, tomt@netscape.com
|
||||
Subject: Re: related links feature
|
||||
References: <34E34D27.48D37F0B@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------B4222A6E5B925588AECF254E"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 2273
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------B4222A6E5B925588AECF254E
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
Have you had a chance to talk to Chris Hofmann about this?
|
||||
|
||||
<P>Dave
|
||||
<P>Global Applications, Client Internationalization Engineering</BLOCKQUOTE>
|
||||
</HTML>
|
||||
|
||||
--------------B4222A6E5B925588AECF254E
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------B4222A6E5B925588AECF254E--
|
||||
|
||||
From - Fri Feb 13 14:24:01 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA6238;
|
||||
Fri, 13 Feb 1998 00:02:09 -0800
|
||||
Received: from netscape.com ([198.93.95.113]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA6890;
|
||||
Fri, 13 Feb 1998 00:02:10 -0800
|
||||
Message-ID: <34E3FDFF.B33E6DA8@netscape.com>
|
||||
Date: Fri, 13 Feb 1998 00:02:07 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: John Gable <johng@netscape.com>
|
||||
CC: Julie Herendeen <julieh@netscape.com>
|
||||
, Ramanathan Guha <guha@netscape.com>, don@netscape.com,
|
||||
mourey@netscape.com, paquin@netscape.com
|
||||
Subject: Aurora in 5.0
|
||||
References: <34E331E6.EA313DB1@netscape.com> <34E34A50.56018A5F@netscape.com> <34E3AB4D.D2A09F7B@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------6E2A1770C2D6129D39EC9809"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 3100
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------6E2A1770C2D6129D39EC9809
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
|
||||
<P>Thanks,
|
||||
|
||||
<P>Guha</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</HTML>
|
||||
|
||||
--------------6E2A1770C2D6129D39EC9809
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------6E2A1770C2D6129D39EC9809--
|
||||
|
||||
From - Tue Feb 17 13:06:05 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA5951;
|
||||
Tue, 17 Feb 1998 12:54:49 -0800
|
||||
Received: from netscape.com ([208.12.41.138]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA29510;
|
||||
Tue, 17 Feb 1998 12:54:50 -0800
|
||||
Message-ID: <34E9F918.BBC56F81@netscape.com>
|
||||
Date: Tue, 17 Feb 1998 12:54:48 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: John Gable <johng@netscape.com>
|
||||
CC: Julie Herendeen <julieh@netscape.com>
|
||||
, Ramanathan Guha <guha@netscape.com>, don@netscape.com,
|
||||
mourey@netscape.com, paquin@netscape.com, jcorr@netscape.com,
|
||||
bob@netscape.com, Jim Hamerly <hamerly@netscape.com>
|
||||
, Mark Tompkins <tompkins@netscape.com>
|
||||
Subject: Re: Aurora in 4.5/ 5.0 Lite
|
||||
References: <34E331E6.EA313DB1@netscape.com> <34E34A50.56018A5F@netscape.com> <34E9DFBF.74B946BB@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------4C4F789D2C6BE10AD06B738F"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 3644
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------4C4F789D2C6BE10AD06B738F
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
John,
|
||||
|
||||
<P>Thanks,
|
||||
|
||||
<P>Guha</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</HTML>
|
||||
|
||||
--------------4C4F789D2C6BE10AD06B738F
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------4C4F789D2C6BE10AD06B738F--
|
||||
|
||||
From - Thu Feb 19 22:04:06 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA59DF;
|
||||
Thu, 19 Feb 1998 21:42:38 -0800
|
||||
Received: from netscape.com ([198.93.95.139]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA871;
|
||||
Thu, 19 Feb 1998 21:42:36 -0800
|
||||
Message-ID: <34ED17C8.637FEE0C@netscape.com>
|
||||
Date: Thu, 19 Feb 1998 21:42:32 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: guha@netscape.com
|
||||
CC: julieh@netscape.com, hamerly@netscape.com, bob@netscape.com,
|
||||
paquin@netscape.com, jg@netscape.com, mikem@netscape.com,
|
||||
pmarca@netscape.com, mtoy@netscape.com,
|
||||
John Friend <jfriend@netscape.com>, benh@netscape.com
|
||||
Subject: Re: An idea
|
||||
References: <34EB266D.3936@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------88B897522D00B6EFEB1EE999"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 6031
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------88B897522D00B6EFEB1EE999
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
Guha,
|
||||
|
||||
<P>I very much like this idea. I can see lots of benefits.
|
||||
--------------88B897522D00B6EFEB1EE999
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------88B897522D00B6EFEB1EE999--
|
||||
|
||||
From - Thu Feb 19 22:04:06 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA5CA2;
|
||||
Thu, 19 Feb 1998 21:47:27 -0800
|
||||
Received: from netscape.com ([198.93.95.139]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAAA43;
|
||||
Thu, 19 Feb 1998 21:47:25 -0800
|
||||
Message-ID: <34ED18EB.8A6354AA@netscape.com>
|
||||
Date: Thu, 19 Feb 1998 21:47:23 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: Jean-Charles Mourey <mourey@netscape.com>
|
||||
CC: Bob Lisbonne <bob@netscape.com>, blstaff@netscape.com,
|
||||
guha@netscape.com, Brendan Eich <brendan@netscape.com>
|
||||
, Kipp Hickman <kipp@netscape.com>, jg@netscape.com,
|
||||
homer@netscape.com, marca@netscape.com,
|
||||
moureystaff@netscape.com, johng@netscape.com,
|
||||
jcorr@netscape.com, davestaff@netscape.com,
|
||||
rickg@netscape.com, byunn@netscape.com, wade@netscape.com
|
||||
Subject: something more
|
||||
References: <34E4FA23.C95C21B1@netscape.com> <34EB38B1.6786335E@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------9FFA63E7222E7615F265EEE3"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 5663
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------9FFA63E7222E7615F265EEE3
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
Jean-Charles,
|
||||
|
||||
<P>I would have the following two questions with this.
|
||||
|
||||
<P>Thanks,
|
||||
<BR>Jean-Charles
|
||||
<BR>
|
||||
<BR>
|
||||
<BR> </BLOCKQUOTE>
|
||||
</HTML>
|
||||
|
||||
--------------9FFA63E7222E7615F265EEE3
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------9FFA63E7222E7615F265EEE3--
|
||||
|
||||
|
||||
288
mozilla/rdf/resources/Mail/jane@aol.com/trash
Normal file
288
mozilla/rdf/resources/Mail/jane@aol.com/trash
Normal file
@@ -0,0 +1,288 @@
|
||||
From -
|
||||
From -
|
||||
From -
|
||||
Return-Path: <johng@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA3BF5
|
||||
for <guha@dredd.mcom.com>; Tue, 3 Mar 1998 22:15:57 -0800
|
||||
Received: from netscape.com ([208.12.38.138]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA1668
|
||||
for <guha@netscape.com>; Tue, 3 Mar 1998 22:15:54 -0800
|
||||
Message-ID: <34FCF19A.6DD68867@netscape.com>
|
||||
Date: Tue, 03 Mar 1998 22:15:54 -0800
|
||||
From: johng@netscape.com (John Gable)
|
||||
Organization: Netscape Communication
|
||||
X-Mailer: Mozilla 4.04b9 [en] (Win95; I)
|
||||
X-Accept-Language: en
|
||||
MIME-Version: 1.0
|
||||
To: "guha@netscape.com" <guha@netscape.com>
|
||||
Subject: Better then flaky?
|
||||
Content-Type: multipart/mixed; boundary="------------42F73A432115F5CA91E4965C"
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 1109
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------42F73A432115F5CA91E4965C
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
Guha,
|
||||
<P>Do you have a Aurora build better then Flaky? I'm showing some
|
||||
of this stuff to Clinton tomorrow at 11am, and it would be nice to
|
||||
have a build that works better by 10:30a (when I have a different meeting).
|
||||
<P>I'll be OK with Flaky if you don't have time, or if you can't just point
|
||||
me to it and let me take care of setting it up.
|
||||
<P>Thanks,
|
||||
<P>John</HTML>
|
||||
|
||||
--------------42F73A432115F5CA91E4965C
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for John Gable
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: John Gable
|
||||
n: Gable;John
|
||||
org: Netscape
|
||||
email;internet: Johng@netscape.com
|
||||
title: Communicator Team/ Aurora
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------42F73A432115F5CA91E4965C--
|
||||
|
||||
From -
|
||||
Return-Path: <list@glacier.mcom.com>
|
||||
Received: from glacier.mcom.com ([205.217.233.39]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA9AB;
|
||||
Wed, 18 Mar 1998 13:46:13 -0800
|
||||
Received: (from list@localhost) by glacier.mcom.com (8.7.3/8.7.3) id NAA04464; Wed, 18 Mar 1998 13:46:10 -0800 (PST)
|
||||
Resent-Date: Wed, 18 Mar 1998 13:46:10 -0800 (PST)
|
||||
Message-ID: <3510409D.33ADB2F@netscape.com>
|
||||
Date: Wed, 18 Mar 1998 13:46:06 -0800
|
||||
From: johng@netscape.com (John Gable)
|
||||
Organization: Netscape Communication
|
||||
X-Mailer: Mozilla 4.04 [en]C-NSCP (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: relatedlinks@netscape.com
|
||||
Subject: Cancel meeting today
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Resent-Message-ID: <"acOC-2.0.i51.X244r"@glacier>
|
||||
Resent-From: relatedlinks@netscape.com
|
||||
X-Mailing-List: <relatedlinks@netscape.com> archive/latest/84
|
||||
X-Loop: relatedlinks@netscape.com
|
||||
Precedence: list
|
||||
Resent-Sender: relatedlinks-request@netscape.com
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 333
|
||||
|
||||
<HTML>
|
||||
Gang,
|
||||
|
||||
|
||||
<P>John</HTML>
|
||||
|
||||
From -
|
||||
X-Mozilla-Status: 0000
|
||||
Return-Path: <FareTracker@expedia.com>
|
||||
Received: from hemail.mcom.com ([198.93.92.25]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.52) with ESMTP id AAA2024
|
||||
for <guha@dredd.mcom.com>; Sat, 25 Jul 1998 03:16:19 -0700
|
||||
Received: from xwing.netscape.com (xwing.netscape.com [207.200.76.40])
|
||||
by hemail.mcom.com (8.8.8/8.8.5) with ESMTP id DAA02578
|
||||
for <guha@netscape.com>; Sat, 25 Jul 1998 03:16:17 -0700 (PDT)
|
||||
From: FareTracker@expedia.com
|
||||
Received: from UPIMSSMTPSYS09 (upimssmtpsys09.email.msn.com [207.68.152.46])
|
||||
by xwing.netscape.com (8.8.5/8.8.5) with ESMTP id DAA28286
|
||||
for <guha@netscape.com>; Sat, 25 Jul 1998 03:16:16 -0700 (PDT)
|
||||
Received: from [10.204.149.250] - 10.204.149.250 by email.msn.com with Microsoft SMTPSVC;
|
||||
Sat, 25 Jul 1998 02:13:35 -0700
|
||||
To: guha@netscape.com
|
||||
Subject: Expedia Fare Tracker Update
|
||||
Message-ID: <033bb3413091978UPIMSSMTPSYS09@email.msn.com>
|
||||
Date: 25 Jul 1998 02:13:35 -0700
|
||||
|
||||
Dear Bonzle Boogledog,
|
||||
|
||||
Here is your customized report listing the lowest roundtrip published
|
||||
airfares on the trips you requested.
|
||||
|
||||
The fares listed in your personal Fare Tracker report do not reflect
|
||||
actual availability of seats on any specific flights, but rather the
|
||||
lowest fares the airlines have filed for the city pairs you have
|
||||
requested. This service is intended to assist you in locating these
|
||||
low fares by providing you with the fare rules and parameters necessary
|
||||
to secure seats at these fares if available.
|
||||
|
||||
Since airline restrictions apply to these fares, please be sure to
|
||||
read the footnotes below.
|
||||
|
||||
***************************
|
||||
FARE TRACKER LOW FARES
|
||||
|
||||
|
||||
1. 32.00 US Dollars
|
||||
From: San Francisco, CA, United States (SFO)
|
||||
To: San Jose, CA, United States (SJC)
|
||||
On: United Airlines
|
||||
Rules: Trip must occur on or after 27 Apr 98.
|
||||
Other restrictions may apply.
|
||||
|
||||
752.00 US Dollars
|
||||
From: San Francisco, CA, United States (SFO)
|
||||
To: San Jose, CA, United States (SJC)
|
||||
On: United Airlines
|
||||
Rules: Trip must occur on or after 26 Sep 97.
|
||||
Other restrictions may apply.
|
||||
|
||||
The information above shows the best airfares currently offered
|
||||
on this route at the time of this mailing. To find out more, and to view
|
||||
up-to-date fares, please visit our site at:
|
||||
http://expedia.msn.com/pub/ft.dll?qscr=airp&afr1=SFO&ato1=SJC
|
||||
After you sign in, Expedia will show you complete details about
|
||||
this fare, including rules and regulations.
|
||||
|
||||
|
||||
|
||||
*******************
|
||||
IMPORTANT: Fares are typically for one adult, flying roundtrip
|
||||
between the selected airports. Prices DO NOT INCLUDE taxes
|
||||
or fees (taxes and fees to international destinations may
|
||||
be higher). Seats are subject to availability and other
|
||||
restrictions may apply.
|
||||
*******************
|
||||
|
||||
To reserve or purchase a ticket, visit the Expedia
|
||||
Travel Agent at: http://expedia.com/
|
||||
|
||||
You may cancel or change your Fare Tracker subscription at:
|
||||
http://expedia.msn.com/pub/ft.dll?qscr=subs&xerr=
|
||||
|
||||
*******************
|
||||
ADVERTISER MESSAGE
|
||||
|
||||
Spectacular dining, exciting nightlife, impeccable service, and visits
|
||||
to the most remarkable ports of call. These are just a few of the
|
||||
things you'll find on a fabulous cruise adventure. If you'd rather stay
|
||||
in one place, try a great package vacation to any of hundreds of
|
||||
fascinating places, including the Caribbean, Europe, Mexico, Hawaii,
|
||||
Orlando, Las Vegas, and many more. You decide where to go and we'll
|
||||
take care of all the details.
|
||||
|
||||
For the world's best vacation packages and cruises at great prices
|
||||
visit the Cruise Outlet at http://www.expcruiseoutlet.com or the Vacation
|
||||
Outlet at http://www.expvacationoutlet.com.
|
||||
|
||||
*******************
|
||||
EXPEDIA PROMOTION
|
||||
|
||||
France has never been more fun, and you can be part of it if you win
|
||||
the City of Light, Speed of Sound sweepstakes cosponsored by Air France
|
||||
and Expedia.com. Winners will fly the supersonic Air France Concorde to
|
||||
Paris and stay seven nights at a luxurious Le Meridien hotel. Enter
|
||||
between 14 July and 15 August by visiting Expedia.com at http://expedia.msn.com/promos/concorFrom -
|
||||
X-Mozilla-Status: 0000
|
||||
Return-Path: <scopus@netscape.com>
|
||||
Received: from netscape.com ([205.217.237.46]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.52) with ESMTP id AAA13C8
|
||||
for <guha@dredd.mcom.com>; Mon, 10 Aug 1998 12:25:47 -0700
|
||||
Received: from admitone.mcom.com (admitone.mcom.com [205.217.237.154])
|
||||
by netscape.com (8.8.5/8.8.5) with ESMTP id MAA25187
|
||||
for <guha@netscape.com>; Mon, 10 Aug 1998 12:25:47 -0700 (PDT)
|
||||
Received: (from scopus@localhost)
|
||||
by admitone.mcom.com (8.8.5/8.8.5) id MAA10647
|
||||
for guha@netscape.com; Mon, 10 Aug 1998 12:25:35 -0700 (PDT)
|
||||
Date: Mon, 10 Aug 1998 12:25:35 -0700 (PDT)
|
||||
From: Scopus Account <scopus@netscape.com>
|
||||
Message-Id: <199808101925.MAA10647@admitone.mcom.com>
|
||||
To: guha@netscape.com
|
||||
Subject: 312965 Defect ID(s) modified
|
||||
|
||||
312965 Defect ID(s) modified
|
||||
=====================================
|
||||
|
||||
|
||||
======================================================================
|
||||
Defect ID: 312965 has been modified on 10-AUG-98 12:19:24
|
||||
http://scopus/bugsplat/show_bug.cgi?id=312965
|
||||
Reported by: glynn
|
||||
Old Assigned To: >> New Assigned to: guha
|
||||
Old Status: >> New Status: REOPENED
|
||||
Old Priority: >> New Priority: P0
|
||||
Old Severity: >> New Severity: critical
|
||||
Resolution: FIXED
|
||||
|
||||
Summary: lower case "netscape" fails DNS on Internet Keyword lookup
|
||||
Description: Could be server, could be app..not sure yet
|
||||
Aug 6 4.06 builds
|
||||
PPC, NT 4.0, UNIX IRIX 6.3
|
||||
|
||||
1. Launch Communicator with direct connection set in proxies:prefs (default)
|
||||
into a browser window.
|
||||
2. Enter precisely "netscape" into the location field and hit return.
|
||||
|
||||
• DNS failure to find server alert will present itself.
|
||||
|
||||
If keywords are off std DNS works fine on "netscape"....if on the problem
|
||||
continues...only lower case "netscape" fails
|
||||
|
||||
Wiping out pref files does not help/new profile does not help
|
||||
|
||||
*******One clue...when I was routed through "ducky" at 8288 last night my NT 4.0
|
||||
would work where ernie's NT 4.0 with direct connect failed...when I turned my
|
||||
machine back to direct connect it failed...cannot check ducky right now because
|
||||
it is out due to power outage.
|
||||
|
||||
Summary: Direct connect set in proxy prefs
|
||||
|
||||
"netscape" - FAILS
|
||||
|
||||
"Netscape" works
|
||||
"Netscape Communications" works
|
||||
"netscape communications" works
|
||||
|
||||
|
||||
------- Additional Comments From glynn 08/07/98 17:51 -------
|
||||
|
||||
Steve Dagley investigating....has clue as to where in code problem
|
||||
lies...talking to valeski....assign to sdagley...reassign as needed
|
||||
|
||||
|
||||
------- Additional Comments From sdagley 08/07/98 18:17 -------
|
||||
|
||||
After looking at the code and discussing things with valeski and guha the problem
|
||||
is understood and the fix simple. Reassigning to guha since he'll be making the
|
||||
fix on valeski's machine.
|
||||
|
||||
|
||||
------- Additional Comments From valeski 08/07/98 19:34 -------
|
||||
|
||||
checked in fix 8/7/98 7:35pm into 4.06 tree
|
||||
|
||||
------- Additional Comments From varada 08/09/98 15:16 -------
|
||||
|
||||
I tried the builds on the 9th - on the win nt and win 98 ( there were no other
|
||||
new builds on the unix platform ) and while netscape works - netscape.com and
|
||||
http://netscape.com fails and Netscape.com and http://Netscape.com throws up
|
||||
server not found - dns entry not there
|
||||
|
||||
------- Additional Comments From kenh 08/10/98 09:51 -------
|
||||
|
||||
The failure to resolve netscape.com and http://netscape.com is independent of
|
||||
the Keyword system. Both are fully qualified URLs (the first because Nav adds
|
||||
the protocol), so they are resolved directly, but are not found because they are
|
||||
not registered domains or aliases to www.netscape.com or home.netscape.com.
|
||||
|
||||
------- Additional Comments From varada 08/10/98 12:08 -------
|
||||
|
||||
This is more of a comment for future improvements rather than reopening the bug
|
||||
- I tried the pages of microsoft,oracle,sun,intel,yahoo etc., etc.. and all of
|
||||
them seem to have registered or made an alias of their "[company].com" - I think
|
||||
it would make sense for us to also do so and not blame it on the existence or
|
||||
non existence of the IK preferences - cuz the end
|
||||
102
mozilla/rdf/resources/Mail/jane_aol/hiking
Normal file
102
mozilla/rdf/resources/Mail/jane_aol/hiking
Normal file
@@ -0,0 +1,102 @@
|
||||
From - Tue Mar 03 14:14:13 1998
|
||||
Return-Path: <neumann@netscape.com>
|
||||
Received: from netscape.com ([207.1.142.184]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA28E8;
|
||||
Tue, 3 Mar 1998 13:33:54 -0800
|
||||
Message-ID: <34FC773F.62AEA20D@netscape.com>
|
||||
Date: Tue, 03 Mar 1998 13:33:51 -0800
|
||||
From: neumann@netscape.com (Lori Neumann)
|
||||
Organization: Netscape Communications
|
||||
X-Mailer: Mozilla 4.04 [en] (Win95; I)
|
||||
MIME-Version: 1.0
|
||||
To: jane@aol.com
|
||||
CC: Irene Au <irene@netscape.com>, german@netscape.com,
|
||||
Valerie Hunter <valh@netscape.com>, kenh@netscape.com,
|
||||
pinkerton@netscape.com, blythe@netscape.com,
|
||||
hyatt@netscape.com, slamm@netscape.com, ramiro@netscape.com,
|
||||
Don Melton <don@netscape.com>, jg@netscape.com,
|
||||
"guha@netscape.com" <guha@netscape.com>, tgoldman@netscape.com
|
||||
Subject: Re: Toward resolution of UI for hiking
|
||||
References: <34FC40A9.A1F22D04@netscape.com> <34FC6EE8.6FA41408@netscape.com>
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 7613
|
||||
|
||||
<HTML>
|
||||
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#534A86" VLINK="#8080C0" ALINK="#FF0000">
|
||||
John, Thanks for the summary.
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
From - Tue Mar 03 14:14:13 1998
|
||||
Return-Path: <neumann@netscape.com>
|
||||
Received: from netscape.com ([207.1.142.184]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA54DC;
|
||||
Tue, 3 Mar 1998 14:11:00 -0800
|
||||
Message-ID: <34FC7FF1.88AAD459@netscape.com>
|
||||
Date: Tue, 03 Mar 1998 14:10:57 -0800
|
||||
From: neumann@netscape.com (Lori Neumann)
|
||||
Organization: Netscape Communications
|
||||
X-Mailer: Mozilla 4.04 [en] (Win95; I)
|
||||
MIME-Version: 1.0
|
||||
To: David Hyatt <hyatt@netscape.com>
|
||||
CC: John Gable <johng@netscape.com>, Irene Au <irene@netscape.com>
|
||||
, german@netscape.com, Valerie Hunter <valh@netscape.com>
|
||||
, kenh@netscape.com, pinkerton@netscape.com,
|
||||
blythe@netscape.com, slamm@netscape.com, ramiro@netscape.com,
|
||||
Don Melton <don@netscape.com>, jg@netscape.com,
|
||||
"guha@netscape.com" <guha@netscape.com>, tgoldman@netscape.com
|
||||
Subject: Re: Toward resolution of hiking UI
|
||||
References: <34FC40A9.A1F22D04@netscape.com> <34FC6EE8.6FA41408@netscape.com> <34FC773F.62AEA20D@netscape.com> <34FC7A47.4AEC3D6F@netscape.com>
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 284
|
||||
|
||||
<HTML>
|
||||
David, I completely agree. But unless we have a clear design model for
|
||||
how hiking works, we're going to get asked to put random buttons on Yosemite.
|
||||
We've been there. I just want to make sure we get the requirements met
|
||||
while designing a predictable UI.
|
||||
|
||||
<P>--Lori</HTML>
|
||||
|
||||
From - Tue Mar 03 16:12:53 1998
|
||||
Return-Path: <neumann@netscape.com>
|
||||
Received: from netscape.com ([207.1.142.184]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA6102;
|
||||
Tue, 3 Mar 1998 14:20:50 -0800
|
||||
Message-ID: <34FC823F.F214C16B@netscape.com>
|
||||
Date: Tue, 03 Mar 1998 14:20:47 -0800
|
||||
From: neumann@netscape.com (Lori Neumann)
|
||||
Organization: Netscape Communications
|
||||
X-Mailer: Mozilla 4.04 [en] (Win95; I)
|
||||
MIME-Version: 1.0
|
||||
To: pinkerton@netscape.com
|
||||
CC: John Gable <johng@netscape.com>, Irene Au <irene@netscape.com>
|
||||
, german@netscape.com, Valerie Hunter <valh@netscape.com>
|
||||
, kenh@netscape.com, blythe@netscape.com, hyatt@netscape.com,
|
||||
slamm@netscape.com, ramiro@netscape.com,
|
||||
Don Melton <don@netscape.com>, jg@netscape.com,
|
||||
"guha@netscape.com" <guha@netscape.com>, tgoldman@netscape.com
|
||||
Subject: Wither hiking?
|
||||
References: <34FC40A9.A1F22D04@netscape.com> <34FC6EE8.6FA41408@netscape.com> <34FC773F.62AEA20D@netscape.com> <34FC7E10.A47976A8@netscape.com>
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 584
|
||||
|
||||
<HTML>
|
||||
Mike, I agree that the features shouldn't interfere with the UI. And the
|
||||
last thing I want the UI to have to do is be contorted to accommodate Yellowstone!
|
||||
|
||||
<P>However, we do need a design that is more scalable than what we currently
|
||||
have and helps drives traffic and membership to Yellowstone without impacting
|
||||
the user experience.
|
||||
|
||||
<P>This is why it is important to get a requirements document distributed
|
||||
and approved.
|
||||
|
||||
<P>--Lori</HTML>
|
||||
|
||||
372
mozilla/rdf/resources/Mail/jane_aol/inbox
Normal file
372
mozilla/rdf/resources/Mail/jane_aol/inbox
Normal file
@@ -0,0 +1,372 @@
|
||||
From - Fri Feb 13 14:23:39 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA20967;
|
||||
Wed, 11 Feb 1998 09:43:51 -0800
|
||||
Received: from netscape.com ([208.12.41.138]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA11421;
|
||||
Wed, 11 Feb 1998 09:43:51 -0800
|
||||
Message-ID: <34E1E2AB.7993EC37@netscape.com>
|
||||
Date: Wed, 11 Feb 1998 09:40:59 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: Chris Hofmann <chofmann@netscape.com>, tomt@netscape.com,
|
||||
John Gable <johng@netscape.com>, guha@netscape.com,
|
||||
Don Melton <don@netscape.com>
|
||||
, Jean-Charles Mourey <mourey@netscape.com>
|
||||
Subject: 5.01
|
||||
Content-Type: multipart/mixed; boundary="------------6D489A9D88CBB8298AFCCF06"
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 1268
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------6D489A9D88CBB8298AFCCF06
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
something here
|
||||
<P>Thanks,
|
||||
<BR>Dave</HTML>
|
||||
|
||||
--------------6D489A9D88CBB8298AFCCF06
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------6D489A9D88CBB8298AFCCF06--
|
||||
|
||||
From - Fri Feb 13 14:23:55 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA3B91;
|
||||
Thu, 12 Feb 1998 13:33:59 -0800
|
||||
Received: from netscape.com ([208.12.41.137]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA27509;
|
||||
Thu, 12 Feb 1998 13:33:59 -0800
|
||||
Message-ID: <34E36AC7.3EB06EAE@netscape.com>
|
||||
Date: Thu, 12 Feb 1998 13:33:59 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: erik@netscape.com
|
||||
CC: Ramanathan Guha <guha@netscape.com>
|
||||
, Bob Jung <bobj@netscape.com>
|
||||
, Chris Hofmann <chofmann@netscape.com>, tomt@netscape.com
|
||||
Subject: Re: related links feature
|
||||
References: <34E34D27.48D37F0B@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------B4222A6E5B925588AECF254E"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 2273
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------B4222A6E5B925588AECF254E
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
Have you had a chance to talk to Chris Hofmann about this?
|
||||
|
||||
<P>Dave
|
||||
<P>Global Applications, Client Internationalization Engineering</BLOCKQUOTE>
|
||||
</HTML>
|
||||
|
||||
--------------B4222A6E5B925588AECF254E
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------B4222A6E5B925588AECF254E--
|
||||
|
||||
From - Fri Feb 13 14:24:01 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA6238;
|
||||
Fri, 13 Feb 1998 00:02:09 -0800
|
||||
Received: from netscape.com ([198.93.95.113]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA6890;
|
||||
Fri, 13 Feb 1998 00:02:10 -0800
|
||||
Message-ID: <34E3FDFF.B33E6DA8@netscape.com>
|
||||
Date: Fri, 13 Feb 1998 00:02:07 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: John Gable <johng@netscape.com>
|
||||
CC: Julie Herendeen <julieh@netscape.com>
|
||||
, Ramanathan Guha <guha@netscape.com>, don@netscape.com,
|
||||
mourey@netscape.com, paquin@netscape.com
|
||||
Subject: Aurora in 5.0
|
||||
References: <34E331E6.EA313DB1@netscape.com> <34E34A50.56018A5F@netscape.com> <34E3AB4D.D2A09F7B@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------6E2A1770C2D6129D39EC9809"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 3100
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------6E2A1770C2D6129D39EC9809
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
|
||||
<P>Thanks,
|
||||
|
||||
<P>Guha</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</HTML>
|
||||
|
||||
--------------6E2A1770C2D6129D39EC9809
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------6E2A1770C2D6129D39EC9809--
|
||||
|
||||
From - Tue Feb 17 13:06:05 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA5951;
|
||||
Tue, 17 Feb 1998 12:54:49 -0800
|
||||
Received: from netscape.com ([208.12.41.138]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.0) with ESMTP id AAA29510;
|
||||
Tue, 17 Feb 1998 12:54:50 -0800
|
||||
Message-ID: <34E9F918.BBC56F81@netscape.com>
|
||||
Date: Tue, 17 Feb 1998 12:54:48 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: John Gable <johng@netscape.com>
|
||||
CC: Julie Herendeen <julieh@netscape.com>
|
||||
, Ramanathan Guha <guha@netscape.com>, don@netscape.com,
|
||||
mourey@netscape.com, paquin@netscape.com, jcorr@netscape.com,
|
||||
bob@netscape.com, Jim Hamerly <hamerly@netscape.com>
|
||||
, Mark Tompkins <tompkins@netscape.com>
|
||||
Subject: Re: Aurora in 4.5/ 5.0 Lite
|
||||
References: <34E331E6.EA313DB1@netscape.com> <34E34A50.56018A5F@netscape.com> <34E9DFBF.74B946BB@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------4C4F789D2C6BE10AD06B738F"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 3644
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------4C4F789D2C6BE10AD06B738F
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
John,
|
||||
|
||||
<P>Thanks,
|
||||
|
||||
<P>Guha</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
</HTML>
|
||||
|
||||
--------------4C4F789D2C6BE10AD06B738F
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------4C4F789D2C6BE10AD06B738F--
|
||||
|
||||
From - Thu Feb 19 22:04:06 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA59DF;
|
||||
Thu, 19 Feb 1998 21:42:38 -0800
|
||||
Received: from netscape.com ([198.93.95.139]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA871;
|
||||
Thu, 19 Feb 1998 21:42:36 -0800
|
||||
Message-ID: <34ED17C8.637FEE0C@netscape.com>
|
||||
Date: Thu, 19 Feb 1998 21:42:32 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: guha@netscape.com
|
||||
CC: julieh@netscape.com, hamerly@netscape.com, bob@netscape.com,
|
||||
paquin@netscape.com, jg@netscape.com, mikem@netscape.com,
|
||||
pmarca@netscape.com, mtoy@netscape.com,
|
||||
John Friend <jfriend@netscape.com>, benh@netscape.com
|
||||
Subject: Re: An idea
|
||||
References: <34EB266D.3936@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------88B897522D00B6EFEB1EE999"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 6031
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------88B897522D00B6EFEB1EE999
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
Guha,
|
||||
|
||||
<P>I very much like this idea. I can see lots of benefits.
|
||||
--------------88B897522D00B6EFEB1EE999
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------88B897522D00B6EFEB1EE999--
|
||||
|
||||
From - Thu Feb 19 22:04:06 1998
|
||||
Return-Path: <daver@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA5CA2;
|
||||
Thu, 19 Feb 1998 21:47:27 -0800
|
||||
Received: from netscape.com ([198.93.95.139]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAAA43;
|
||||
Thu, 19 Feb 1998 21:47:25 -0800
|
||||
Message-ID: <34ED18EB.8A6354AA@netscape.com>
|
||||
Date: Thu, 19 Feb 1998 21:47:23 -0800
|
||||
From: daver@netscape.com (Dave Rothschild)
|
||||
Reply-To: daver@netscape.com
|
||||
Organization: Netscape Communications Corp; Client Product Division
|
||||
X-Mailer: Mozilla 4.05 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: Jean-Charles Mourey <mourey@netscape.com>
|
||||
CC: Bob Lisbonne <bob@netscape.com>, blstaff@netscape.com,
|
||||
guha@netscape.com, Brendan Eich <brendan@netscape.com>
|
||||
, Kipp Hickman <kipp@netscape.com>, jg@netscape.com,
|
||||
homer@netscape.com, marca@netscape.com,
|
||||
moureystaff@netscape.com, johng@netscape.com,
|
||||
jcorr@netscape.com, davestaff@netscape.com,
|
||||
rickg@netscape.com, byunn@netscape.com, wade@netscape.com
|
||||
Subject: something more
|
||||
References: <34E4FA23.C95C21B1@netscape.com> <34EB38B1.6786335E@netscape.com>
|
||||
Content-Type: multipart/mixed; boundary="------------9FFA63E7222E7615F265EEE3"
|
||||
X-Mozilla-Status: 0011
|
||||
Content-Length: 5663
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------9FFA63E7222E7615F265EEE3
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
Jean-Charles,
|
||||
|
||||
<P>I would have the following two questions with this.
|
||||
|
||||
<P>Thanks,
|
||||
<BR>Jean-Charles
|
||||
<BR>
|
||||
<BR>
|
||||
<BR> </BLOCKQUOTE>
|
||||
</HTML>
|
||||
|
||||
--------------9FFA63E7222E7615F265EEE3
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for Dave Rothschild
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: Dave Rothschild
|
||||
n: Rothschild;Dave
|
||||
org: Netscape Communications Corp.
|
||||
adr: 501 E. Middlefield Road;;;Mt. View;CA;94043;USA
|
||||
email;internet: daver@netscape.com
|
||||
title: VP Client Products
|
||||
tel;work: 650-937-2835
|
||||
tel;fax: 650-428-4080
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------9FFA63E7222E7615F265EEE3--
|
||||
|
||||
|
||||
288
mozilla/rdf/resources/Mail/jane_aol/trash
Normal file
288
mozilla/rdf/resources/Mail/jane_aol/trash
Normal file
@@ -0,0 +1,288 @@
|
||||
From -
|
||||
From -
|
||||
From -
|
||||
Return-Path: <johng@netscape.com>
|
||||
Received: from judge.mcom.com ([205.217.237.53]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA3BF5
|
||||
for <guha@dredd.mcom.com>; Tue, 3 Mar 1998 22:15:57 -0800
|
||||
Received: from netscape.com ([208.12.38.138]) by judge.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA1668
|
||||
for <guha@netscape.com>; Tue, 3 Mar 1998 22:15:54 -0800
|
||||
Message-ID: <34FCF19A.6DD68867@netscape.com>
|
||||
Date: Tue, 03 Mar 1998 22:15:54 -0800
|
||||
From: johng@netscape.com (John Gable)
|
||||
Organization: Netscape Communication
|
||||
X-Mailer: Mozilla 4.04b9 [en] (Win95; I)
|
||||
X-Accept-Language: en
|
||||
MIME-Version: 1.0
|
||||
To: "guha@netscape.com" <guha@netscape.com>
|
||||
Subject: Better then flaky?
|
||||
Content-Type: multipart/mixed; boundary="------------42F73A432115F5CA91E4965C"
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 1109
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------42F73A432115F5CA91E4965C
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<HTML>
|
||||
Guha,
|
||||
<P>Do you have a Aurora build better then Flaky? I'm showing some
|
||||
of this stuff to Clinton tomorrow at 11am, and it would be nice to
|
||||
have a build that works better by 10:30a (when I have a different meeting).
|
||||
<P>I'll be OK with Flaky if you don't have time, or if you can't just point
|
||||
me to it and let me take care of setting it up.
|
||||
<P>Thanks,
|
||||
<P>John</HTML>
|
||||
|
||||
--------------42F73A432115F5CA91E4965C
|
||||
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Content-Description: Card for John Gable
|
||||
Content-Disposition: attachment; filename="vcard.vcf"
|
||||
|
||||
begin: vcard
|
||||
fn: John Gable
|
||||
n: Gable;John
|
||||
org: Netscape
|
||||
email;internet: Johng@netscape.com
|
||||
title: Communicator Team/ Aurora
|
||||
x-mozilla-cpt: ;0
|
||||
x-mozilla-html: TRUE
|
||||
version: 2.1
|
||||
end: vcard
|
||||
|
||||
|
||||
--------------42F73A432115F5CA91E4965C--
|
||||
|
||||
From -
|
||||
Return-Path: <list@glacier.mcom.com>
|
||||
Received: from glacier.mcom.com ([205.217.233.39]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.5) with ESMTP id AAA9AB;
|
||||
Wed, 18 Mar 1998 13:46:13 -0800
|
||||
Received: (from list@localhost) by glacier.mcom.com (8.7.3/8.7.3) id NAA04464; Wed, 18 Mar 1998 13:46:10 -0800 (PST)
|
||||
Resent-Date: Wed, 18 Mar 1998 13:46:10 -0800 (PST)
|
||||
Message-ID: <3510409D.33ADB2F@netscape.com>
|
||||
Date: Wed, 18 Mar 1998 13:46:06 -0800
|
||||
From: johng@netscape.com (John Gable)
|
||||
Organization: Netscape Communication
|
||||
X-Mailer: Mozilla 4.04 [en]C-NSCP (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: relatedlinks@netscape.com
|
||||
Subject: Cancel meeting today
|
||||
Content-Type: text/html; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
Resent-Message-ID: <"acOC-2.0.i51.X244r"@glacier>
|
||||
Resent-From: relatedlinks@netscape.com
|
||||
X-Mailing-List: <relatedlinks@netscape.com> archive/latest/84
|
||||
X-Loop: relatedlinks@netscape.com
|
||||
Precedence: list
|
||||
Resent-Sender: relatedlinks-request@netscape.com
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 333
|
||||
|
||||
<HTML>
|
||||
Gang,
|
||||
|
||||
|
||||
<P>John</HTML>
|
||||
|
||||
From -
|
||||
X-Mozilla-Status: 0000
|
||||
Return-Path: <FareTracker@expedia.com>
|
||||
Received: from hemail.mcom.com ([198.93.92.25]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.52) with ESMTP id AAA2024
|
||||
for <guha@dredd.mcom.com>; Sat, 25 Jul 1998 03:16:19 -0700
|
||||
Received: from xwing.netscape.com (xwing.netscape.com [207.200.76.40])
|
||||
by hemail.mcom.com (8.8.8/8.8.5) with ESMTP id DAA02578
|
||||
for <guha@netscape.com>; Sat, 25 Jul 1998 03:16:17 -0700 (PDT)
|
||||
From: FareTracker@expedia.com
|
||||
Received: from UPIMSSMTPSYS09 (upimssmtpsys09.email.msn.com [207.68.152.46])
|
||||
by xwing.netscape.com (8.8.5/8.8.5) with ESMTP id DAA28286
|
||||
for <guha@netscape.com>; Sat, 25 Jul 1998 03:16:16 -0700 (PDT)
|
||||
Received: from [10.204.149.250] - 10.204.149.250 by email.msn.com with Microsoft SMTPSVC;
|
||||
Sat, 25 Jul 1998 02:13:35 -0700
|
||||
To: guha@netscape.com
|
||||
Subject: Expedia Fare Tracker Update
|
||||
Message-ID: <033bb3413091978UPIMSSMTPSYS09@email.msn.com>
|
||||
Date: 25 Jul 1998 02:13:35 -0700
|
||||
|
||||
Dear Bonzle Boogledog,
|
||||
|
||||
Here is your customized report listing the lowest roundtrip published
|
||||
airfares on the trips you requested.
|
||||
|
||||
The fares listed in your personal Fare Tracker report do not reflect
|
||||
actual availability of seats on any specific flights, but rather the
|
||||
lowest fares the airlines have filed for the city pairs you have
|
||||
requested. This service is intended to assist you in locating these
|
||||
low fares by providing you with the fare rules and parameters necessary
|
||||
to secure seats at these fares if available.
|
||||
|
||||
Since airline restrictions apply to these fares, please be sure to
|
||||
read the footnotes below.
|
||||
|
||||
***************************
|
||||
FARE TRACKER LOW FARES
|
||||
|
||||
|
||||
1. 32.00 US Dollars
|
||||
From: San Francisco, CA, United States (SFO)
|
||||
To: San Jose, CA, United States (SJC)
|
||||
On: United Airlines
|
||||
Rules: Trip must occur on or after 27 Apr 98.
|
||||
Other restrictions may apply.
|
||||
|
||||
752.00 US Dollars
|
||||
From: San Francisco, CA, United States (SFO)
|
||||
To: San Jose, CA, United States (SJC)
|
||||
On: United Airlines
|
||||
Rules: Trip must occur on or after 26 Sep 97.
|
||||
Other restrictions may apply.
|
||||
|
||||
The information above shows the best airfares currently offered
|
||||
on this route at the time of this mailing. To find out more, and to view
|
||||
up-to-date fares, please visit our site at:
|
||||
http://expedia.msn.com/pub/ft.dll?qscr=airp&afr1=SFO&ato1=SJC
|
||||
After you sign in, Expedia will show you complete details about
|
||||
this fare, including rules and regulations.
|
||||
|
||||
|
||||
|
||||
*******************
|
||||
IMPORTANT: Fares are typically for one adult, flying roundtrip
|
||||
between the selected airports. Prices DO NOT INCLUDE taxes
|
||||
or fees (taxes and fees to international destinations may
|
||||
be higher). Seats are subject to availability and other
|
||||
restrictions may apply.
|
||||
*******************
|
||||
|
||||
To reserve or purchase a ticket, visit the Expedia
|
||||
Travel Agent at: http://expedia.com/
|
||||
|
||||
You may cancel or change your Fare Tracker subscription at:
|
||||
http://expedia.msn.com/pub/ft.dll?qscr=subs&xerr=
|
||||
|
||||
*******************
|
||||
ADVERTISER MESSAGE
|
||||
|
||||
Spectacular dining, exciting nightlife, impeccable service, and visits
|
||||
to the most remarkable ports of call. These are just a few of the
|
||||
things you'll find on a fabulous cruise adventure. If you'd rather stay
|
||||
in one place, try a great package vacation to any of hundreds of
|
||||
fascinating places, including the Caribbean, Europe, Mexico, Hawaii,
|
||||
Orlando, Las Vegas, and many more. You decide where to go and we'll
|
||||
take care of all the details.
|
||||
|
||||
For the world's best vacation packages and cruises at great prices
|
||||
visit the Cruise Outlet at http://www.expcruiseoutlet.com or the Vacation
|
||||
Outlet at http://www.expvacationoutlet.com.
|
||||
|
||||
*******************
|
||||
EXPEDIA PROMOTION
|
||||
|
||||
France has never been more fun, and you can be part of it if you win
|
||||
the City of Light, Speed of Sound sweepstakes cosponsored by Air France
|
||||
and Expedia.com. Winners will fly the supersonic Air France Concorde to
|
||||
Paris and stay seven nights at a luxurious Le Meridien hotel. Enter
|
||||
between 14 July and 15 August by visiting Expedia.com at http://expedia.msn.com/promos/concorFrom -
|
||||
X-Mozilla-Status: 0000
|
||||
Return-Path: <scopus@netscape.com>
|
||||
Received: from netscape.com ([205.217.237.46]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.52) with ESMTP id AAA13C8
|
||||
for <guha@dredd.mcom.com>; Mon, 10 Aug 1998 12:25:47 -0700
|
||||
Received: from admitone.mcom.com (admitone.mcom.com [205.217.237.154])
|
||||
by netscape.com (8.8.5/8.8.5) with ESMTP id MAA25187
|
||||
for <guha@netscape.com>; Mon, 10 Aug 1998 12:25:47 -0700 (PDT)
|
||||
Received: (from scopus@localhost)
|
||||
by admitone.mcom.com (8.8.5/8.8.5) id MAA10647
|
||||
for guha@netscape.com; Mon, 10 Aug 1998 12:25:35 -0700 (PDT)
|
||||
Date: Mon, 10 Aug 1998 12:25:35 -0700 (PDT)
|
||||
From: Scopus Account <scopus@netscape.com>
|
||||
Message-Id: <199808101925.MAA10647@admitone.mcom.com>
|
||||
To: guha@netscape.com
|
||||
Subject: 312965 Defect ID(s) modified
|
||||
|
||||
312965 Defect ID(s) modified
|
||||
=====================================
|
||||
|
||||
|
||||
======================================================================
|
||||
Defect ID: 312965 has been modified on 10-AUG-98 12:19:24
|
||||
http://scopus/bugsplat/show_bug.cgi?id=312965
|
||||
Reported by: glynn
|
||||
Old Assigned To: >> New Assigned to: guha
|
||||
Old Status: >> New Status: REOPENED
|
||||
Old Priority: >> New Priority: P0
|
||||
Old Severity: >> New Severity: critical
|
||||
Resolution: FIXED
|
||||
|
||||
Summary: lower case "netscape" fails DNS on Internet Keyword lookup
|
||||
Description: Could be server, could be app..not sure yet
|
||||
Aug 6 4.06 builds
|
||||
PPC, NT 4.0, UNIX IRIX 6.3
|
||||
|
||||
1. Launch Communicator with direct connection set in proxies:prefs (default)
|
||||
into a browser window.
|
||||
2. Enter precisely "netscape" into the location field and hit return.
|
||||
|
||||
• DNS failure to find server alert will present itself.
|
||||
|
||||
If keywords are off std DNS works fine on "netscape"....if on the problem
|
||||
continues...only lower case "netscape" fails
|
||||
|
||||
Wiping out pref files does not help/new profile does not help
|
||||
|
||||
*******One clue...when I was routed through "ducky" at 8288 last night my NT 4.0
|
||||
would work where ernie's NT 4.0 with direct connect failed...when I turned my
|
||||
machine back to direct connect it failed...cannot check ducky right now because
|
||||
it is out due to power outage.
|
||||
|
||||
Summary: Direct connect set in proxy prefs
|
||||
|
||||
"netscape" - FAILS
|
||||
|
||||
"Netscape" works
|
||||
"Netscape Communications" works
|
||||
"netscape communications" works
|
||||
|
||||
|
||||
------- Additional Comments From glynn 08/07/98 17:51 -------
|
||||
|
||||
Steve Dagley investigating....has clue as to where in code problem
|
||||
lies...talking to valeski....assign to sdagley...reassign as needed
|
||||
|
||||
|
||||
------- Additional Comments From sdagley 08/07/98 18:17 -------
|
||||
|
||||
After looking at the code and discussing things with valeski and guha the problem
|
||||
is understood and the fix simple. Reassigning to guha since he'll be making the
|
||||
fix on valeski's machine.
|
||||
|
||||
|
||||
------- Additional Comments From valeski 08/07/98 19:34 -------
|
||||
|
||||
checked in fix 8/7/98 7:35pm into 4.06 tree
|
||||
|
||||
------- Additional Comments From varada 08/09/98 15:16 -------
|
||||
|
||||
I tried the builds on the 9th - on the win nt and win 98 ( there were no other
|
||||
new builds on the unix platform ) and while netscape works - netscape.com and
|
||||
http://netscape.com fails and Netscape.com and http://Netscape.com throws up
|
||||
server not found - dns entry not there
|
||||
|
||||
------- Additional Comments From kenh 08/10/98 09:51 -------
|
||||
|
||||
The failure to resolve netscape.com and http://netscape.com is independent of
|
||||
the Keyword system. Both are fully qualified URLs (the first because Nav adds
|
||||
the protocol), so they are resolved directly, but are not found because they are
|
||||
not registered domains or aliases to www.netscape.com or home.netscape.com.
|
||||
|
||||
------- Additional Comments From varada 08/10/98 12:08 -------
|
||||
|
||||
This is more of a comment for future improvements rather than reopening the bug
|
||||
- I tried the pages of microsoft,oracle,sun,intel,yahoo etc., etc.. and all of
|
||||
them seem to have registered or made an alias of their "[company].com" - I think
|
||||
it would make sense for us to also do so and not blame it on the existence or
|
||||
non existence of the IK preferences - cuz the end
|
||||
30
mozilla/rdf/resources/Mail/joe@meer.net/inbox
Normal file
30
mozilla/rdf/resources/Mail/joe@meer.net/inbox
Normal file
@@ -0,0 +1,30 @@
|
||||
From - Fri Jul 10 15:31:27 1998
|
||||
Received: from shemail.mcom.com ([198.93.92.28]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.52) with ESMTP id AAA2B05
|
||||
for <guha@dredd.mcom.com>; Fri, 10 Jul 1998 15:30:38 -0700
|
||||
Received: from interceptor.netscape.com (interceptor.netscape.com [207.200.76.41])
|
||||
by shemail.mcom.com (8.8.8/8.8.5) with ESMTP id PAA17518
|
||||
for <guha@netscape.com>; Fri, 10 Jul 1998 15:30:36 -0700 (PDT)
|
||||
Received: from [207.82.50.70] by exosecure-faud.fraud.com
|
||||
via smtpd (for interceptor.netscape.com [207.200.76.41]) with SMTP; 10 Jul 1998 21:47:03 UT
|
||||
Date: Fri, 10 Jul 1998 15:29:21 -0700
|
||||
Message-Id: <199807102229.PAA05989@www.fraud.com.>
|
||||
To: guha@netscape.com
|
||||
From: Jaccuzzi Johnson <jaccij@fraud.com>
|
||||
Subject: We have received your online application
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 1407
|
||||
|
||||
Dear Ramanathan:
|
||||
|
||||
Thank you for choosing Fraud-r-us. We look forward to helping you with your
|
||||
life. We have received your online application and have started
|
||||
working toward getting your request approved. If you have any questions
|
||||
along the way, please feel free to call us at 1-666-666-6666 and we will
|
||||
be happy to assist you.
|
||||
|
||||
Sincerely,
|
||||
|
||||
Jacuzzi Johnson
|
||||
Customer Service Manager
|
||||
|
||||
188
mozilla/rdf/resources/Mail/joe@meer.net/other
Normal file
188
mozilla/rdf/resources/Mail/joe@meer.net/other
Normal file
@@ -0,0 +1,188 @@
|
||||
From - Mon Apr 27 17:18:20 1998
|
||||
Return-Path: <melledge@printing.org>
|
||||
Received: from hemail.mcom.com ([198.93.92.25]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.52) with ESMTP id AAA2DAA
|
||||
for <guha@dredd.mcom.com>; Mon, 27 Apr 1998 17:14:29 -0700
|
||||
Received: from interceptor.netscape.com (interceptor.netscape.com [207.200.76.41])
|
||||
by hemail.mcom.com (8.8.8/8.8.5) with ESMTP id RAA19790
|
||||
for <guha@netscape.com>; Mon, 27 Apr 1998 17:14:24 -0700 (PDT)
|
||||
Received: from pia_exch01.printing.org ([12.4.59.5])
|
||||
by interceptor.netscape.com (Netscape Messaging Server 3.52)
|
||||
with ESMTP id AAA5C7A for <guha@netscape.com>;
|
||||
Mon, 27 Apr 1998 17:14:11 -0700
|
||||
Received: by PIA_EXCH01 with Internet Mail Service (5.5.1960.3)
|
||||
id <JK34CBS6>; Mon, 27 Apr 1998 14:23:12 -0400
|
||||
Message-ID: <41592D13CBB9D1119B480060977151EE094D21@PIA_EXCH01>
|
||||
From: "Elledge, Marion" <melledge@printing.org>
|
||||
To: guha@netscape.com
|
||||
Cc: "'ratomlin@aol.com'" <ratomlin@aol.com>
|
||||
Subject: SGML/XML Tokyo, Asia/Pacific, XML'98
|
||||
Date: Mon, 27 Apr 1998 14:23:03 -0400
|
||||
MIME-Version: 1.0
|
||||
X-Mailer: Internet Mail Service (5.5.1960.3)
|
||||
Content-Type: text/plain
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 775
|
||||
|
||||
something here.
|
||||
|
||||
From - Sat May 16 19:45:45 1998
|
||||
Return-Path: <list@glacier.mcom.com>
|
||||
Received: from glacier.mcom.com ([205.217.233.39]) by dredd.mcom.com
|
||||
(Netscape Messaging Server 3.52) with ESMTP id AAA168D;
|
||||
Wed, 6 May 1998 21:50:47 -0700
|
||||
Received: (from list@localhost) by glacier.mcom.com (8.7.3/8.7.3) id VAA01084; Wed, 6 May 1998 21:50:42 -0700 (PDT)
|
||||
Resent-Date: Wed, 6 May 1998 21:50:42 -0700 (PDT)
|
||||
Message-ID: <35513DB6.A8716BC0@netscape.com>
|
||||
Date: Wed, 06 May 1998 21:51:02 -0700
|
||||
From: chofmann@netscape.com (Chris Hofmann)
|
||||
X-Mailer: Mozilla 4.1 [en] (Win95; U)
|
||||
MIME-Version: 1.0
|
||||
To: relatedlinks@netscape.com, jg@netscape.com, johng@netscape.com
|
||||
Subject: Bug List
|
||||
Content-Type: multipart/mixed; boundary="------------6BEC6C99BAA019BD72B287D1"
|
||||
Resent-Message-ID: <"jIuOt.0.vG.YsJKr"@glacier>
|
||||
Resent-From: relatedlinks@netscape.com
|
||||
X-Mailing-List: <relatedlinks@netscape.com>
|
||||
X-Loop: relatedlinks@netscape.com
|
||||
Precedence: list
|
||||
Resent-Sender: relatedlinks-request@netscape.com
|
||||
X-Mozilla-Status: 0001
|
||||
Content-Length: 8369
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
--------------6BEC6C99BAA019BD72B287D1
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
Does anyone know additional status on this list of
|
||||
bugs assigned to guha. johng/jg, figure out if these
|
||||
bugs should be marked fixed or if we need to get the
|
||||
bugs reassigned to get someone working on them?
|
||||
|
||||
thanks
|
||||
chris h.
|
||||
|
||||
http://scopus.mcom.com/bugsplat/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&assigned_to=guha&reporter=&product=Communicator&product=Communicator+Pro&target_fix_version=4.06+In&target_fix_version=4.06&changedin=&newqueryname=&order=bugs.bug_id
|
||||
--------------6BEC6C99BAA019BD72B287D1
|
||||
Content-Type: text/html; charset=iso-8859-1; name="buglist.cgi"
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Disposition: inline; filename="buglist.cgi"
|
||||
Content-Base: "http://scopus.mcom.com/bugsplat/buglis
|
||||
t.cgi?bug_status=NEW&bug_status=ASS
|
||||
IGNED&bug_status=REOPENED&assigned_
|
||||
to=guha&reporter=&product=Communica
|
||||
tor&product=Communicator+Pro&target
|
||||
_fix_version=4.06+In&target_fix_ver
|
||||
sion=4.06&changedin=&newqueryname=&
|
||||
order=bugs.bug_id"
|
||||
|
||||
<HTML> <TITLE>Bug List</TITLE>
|
||||
<CENTER><H1>N<font -=3D 2>ETSCAPE</font> B<font -=3D 2>UGS</font></H1>
|
||||
<B>Wed May 06 21:47:44 PDT 1998</B><HR><I><A HREF=3D"newquip.html">
|
||||
Mmm...Netscape: Where everything is irrelevant the next day.</I></A></CE=
|
||||
NTER>
|
||||
<HR SIZE=3D10><TABLE CELLSPACING=3D0 CELLPADDING=3D2>
|
||||
<TR ALIGN=3DLEFT><TH>
|
||||
<A HREF=3D"buglist.cgi?bug_status=3DNEW&bug_status=3DASSIGNED&bug_status=3D=
|
||||
REOPENED&assigned_to=3Dguha&reporter=3D&product=3DCommunicator&product=3D=
|
||||
Communicator+Pro&target_fix_version=3D4.06+In&target_fix_version=3D4.06&c=
|
||||
hangedin=3D&newqueryname=3D&order=3Dbugs.bug_id">ID</A><TH valign=3Dleft>=
|
||||
<A HREF=3D"buglist.cgi?bug_status=3DNEW&bug_status=3DASSIGNED&bug_status=3D=
|
||||
REOPENED&assigned_to=3Dguha&reporter=3D&product=3DCommunicator&product=3D=
|
||||
Communicator+Pro&target_fix_version=3D4.06+In&target_fix_version=3D4.06&c=
|
||||
hangedin=3D&newqueryname=3D&order=3Dbugs.rep_platform,%20bugs.bug_id">Plt=
|
||||
</A><TH valign=3Dleft><A HREF=3D"buglist.cgi?bug_status=3DNEW&bug_status=3D=
|
||||
ASSIGNED&bug_status=3DREOPENED&assigned_to=3Dguha&reporter=3D&product=3DC=
|
||||
ommunicator&product=3DCommunicator+Pro&target_fix_version=3D4.06+In&targe=
|
||||
t_fix_version=3D4.06&changedin=3D&newqueryname=3D&order=3Dassign.login_na=
|
||||
me,%20bugs.bug_id">Owner</A><TH valign=3Dleft><A HREF=3D"buglist.cgi?bug_=
|
||||
status=3DNEW&bug_status=3DASSIGNED&bug_status=3DREOPENED&assigned_to=3Dgu=
|
||||
ha&reporter=3D&product=3DCommunicator&product=3DCommunicator+Pro&target_f=
|
||||
ix_version=3D4.06+In&target_fix_version=3D4.06&changedin=3D&newqueryname=3D=
|
||||
&order=3Dbugs.bug_status,%20bugs.bug_id">State</A><TH valign=3Dleft><A HR=
|
||||
EF=3D"buglist.cgi?bug_status=3DNEW&bug_status=3DASSIGNED&bug_status=3DREO=
|
||||
PENED&assigned_to=3Dguha&reporter=3D&product=3DCommunicator&product=3DCom=
|
||||
municator+Pro&target_fix_version=3D4.06+In&target_fix_version=3D4.06&chan=
|
||||
gedin=3D&newqueryname=3D&order=3Dbugs.resolution,%20bugs.bug_id">Res</A><=
|
||||
TH valign=3Dleft><A HREF=3D"buglist.cgi?bug_status=3DNEW&bug_status=3DASS=
|
||||
IGNED&bug_status=3DREOPENED&assigned_to=3Dguha&reporter=3D&product=3DComm=
|
||||
unicator&product=3DCommunicator+Pro&target_fix_version=3D4.06+In&target_f=
|
||||
ix_version=3D4.06&changedin=3D&newqueryname=3D&order=3Dbugs.component,%20=
|
||||
bugs.bug_id">Comp</A><TH valign=3Dleft><A HREF=3D"buglist.cgi?bug_status=3D=
|
||||
NEW&bug_status=3DASSIGNED&bug_status=3DREOPENED&assigned_to=3Dguha&report=
|
||||
er=3D&product=3DCommunicator&product=3DCommunicator+Pro&target_fix_versio=
|
||||
n=3D4.06+In&target_fix_version=3D4.06&changedin=3D&newqueryname=3D&order=3D=
|
||||
bugs.product,%20bugs.bug_id">Product</A><TH valign=3Dleft><A HREF=3D"bugl=
|
||||
ist.cgi?bug_status=3DNEW&bug_status=3DASSIGNED&bug_status=3DREOPENED&assi=
|
||||
gned_to=3Dguha&reporter=3D&product=3DCommunicator&product=3DCommunicator+=
|
||||
Pro&target_fix_version=3D4.06+In&target_fix_version=3D4.06&changedin=3D&n=
|
||||
ewqueryname=3D&order=3Dbugs.target_fix_version,%20bugs.bug_id">FixVers</A=
|
||||
><TH valign=3Dleft><A HREF=3D"buglist.cgi?bug_status=3DNEW&bug_status=3DA=
|
||||
SSIGNED&bug_status=3DREOPENED&assigned_to=3Dguha&reporter=3D&product=3DCo=
|
||||
mmunicator&product=3DCommunicator+Pro&target_fix_version=3D4.06+In&target=
|
||||
_fix_version=3D4.06&changedin=3D&newqueryname=3D&order=3Dbugs.area,%20bug=
|
||||
s.bug_id">Area</A><TH valign=3Dleft><A HREF=3D"buglist.cgi?bug_status=3DN=
|
||||
EW&bug_status=3DASSIGNED&bug_status=3DREOPENED&assigned_to=3Dguha&reporte=
|
||||
r=3D&product=3DCommunicator&product=3DCommunicator+Pro&target_fix_version=
|
||||
=3D4.06+In&target_fix_version=3D4.06&changedin=3D&newqueryname=3D&order=3D=
|
||||
bugs.op_sys,%20bugs.bug_id">OS</A><TH valign=3Dleft><A HREF=3D"buglist.cg=
|
||||
i?bug_status=3DNEW&bug_status=3DASSIGNED&bug_status=3DREOPENED&assigned_t=
|
||||
o=3Dguha&reporter=3D&product=3DCommunicator&product=3DCommunicator+Pro&ta=
|
||||
rget_fix_version=3D4.06+In&target_fix_version=3D4.06&changedin=3D&newquer=
|
||||
yname=3D&order=3Dbugs.escalation_level,%20bugs.bug_id">Escal</A><TH WIDTH=
|
||||
=3D100% valigh=3Dleft>Summary<TH WIDTH=3D100% valigh=3Dleft>Status_Summar=
|
||||
y
|
||||
|
||||
<TR VALIGN=3DTOP ALIGN=3DLEFT><TD><A HREF=3D"show_bug.cgi?id=3D106005">10=
|
||||
6005</A> <td ><nobr>PC</nobr><td ><nobr>guha</nobr><td ><nobr>NEW</nobr><=
|
||||
td ><nobr></nobr><td ><nobr>other</nobr><td ><nobr>Communic</nobr><td ><n=
|
||||
obr>4.06</nobr><td ><nobr>CODE</nobr><td ><nobr>Wind</nobr><td ><nobr></n=
|
||||
obr><td >Related Links menu is out of order<td >
|
||||
<TR VALIGN=3DTOP ALIGN=3DLEFT><TD><A HREF=3D"show_bug.cgi?id=3D106009">10=
|
||||
6009</A> <td ><nobr>PC</nobr><td ><nobr>guha</nobr><td ><nobr>NEW</nobr><=
|
||||
td ><nobr></nobr><td ><nobr>other</nobr><td ><nobr>Communic</nobr><td ><n=
|
||||
obr>4.06</nobr><td ><nobr>CODE</nobr><td ><nobr>Wind</nobr><td ><nobr></n=
|
||||
obr><td >Related Links menu when no rl available is inconsistent<td >
|
||||
<TR VALIGN=3DTOP ALIGN=3DLEFT><TD><A HREF=3D"show_bug.cgi?id=3D114398">11=
|
||||
4398</A> <td ><nobr>PC</nobr><td ><nobr>guha</nobr><td ><nobr>NEW</nobr><=
|
||||
td ><nobr></nobr><td ><nobr>other</nobr><td ><nobr>Communic</nobr><td ><n=
|
||||
obr>4.06</nobr><td ><nobr>CODE</nobr><td ><nobr>Wind</nobr><td ><nobr></n=
|
||||
obr><td >related sites, NOT?<td >
|
||||
<TR VALIGN=3DTOP ALIGN=3DLEFT><TD><A HREF=3D"show_bug.cgi?id=3D115497">11=
|
||||
5497</A> <td ><nobr>PC</nobr><td ><nobr>guha</nobr><td ><nobr>NEW</nobr><=
|
||||
td ><nobr></nobr><td ><nobr>mail/new</nobr><td ><nobr>Communic</nobr><td =
|
||||
><nobr>4.06</nobr><td ><nobr>CODE</nobr><td ><nobr>Wind</nobr><td ><nobr>=
|
||||
</nobr><td >blank alert box grabs focus, renders browser inoperable<td >
|
||||
<TR VALIGN=3DTOP ALIGN=3DLEFT><TD><A HREF=3D"show_bug.cgi?id=3D116350">11=
|
||||
6350</A> <td ><nobr>All</nobr><td ><nobr>guha</nobr><td ><nobr>NEW</nobr>=
|
||||
<td ><nobr></nobr><td ><nobr>netlib</nobr><td ><nobr>Communic</nobr><td >=
|
||||
<nobr>4.06</nobr><td ><nobr>CODE</nobr><td ><nobr>othe</nobr><td ><nobr><=
|
||||
/nobr><td >goBrowsingEnabled pref ignored in some cases<td >
|
||||
<TR VALIGN=3DTOP ALIGN=3DLEFT><TD><A HREF=3D"show_bug.cgi?id=3D116367">11=
|
||||
6367</A> <td ><nobr>PC</nobr><td ><nobr>guha</nobr><td ><nobr>NEW</nobr><=
|
||||
td ><nobr></nobr><td ><nobr>Browser</nobr><td ><nobr>Communic</nobr><td >=
|
||||
<nobr>4.06</nobr><td ><nobr>CODE</nobr><td ><nobr>Wind</nobr><td ><nobr><=
|
||||
/nobr><td >Window resize causes loss of Related Itemslist data<td >
|
||||
|
||||
</TABLE>
|
||||
6 bugs found.
|
||||
<FORM METHOD=3DPOST ACTION=3D"long_list.cgi">
|
||||
<INPUT TYPE=3DHIDDEN NAME=3Dbuglist VALUE=3D106005:106009:114398:115497:1=
|
||||
16350:116367>
|
||||
<INPUT TYPE=3DSUBMIT VALUE=3D"Long Format">
|
||||
<A HREF=3D"query.cgi">Query Page</A>
|
||||
<A HREF=3D"colchange.cgi?bug_status=3DNEW&bug_status=3DASSIGNED&bug_statu=
|
||||
s=3DREOPENED&assigned_to=3Dguha&reporter=3D&product=3DCommunicator&produc=
|
||||
t=3DCommunicator+Pro&target_fix_version=3D4.06+In&target_fix_version=3D4.=
|
||||
06&changedin=3D&newqueryname=3D&order=3Dbugs.bug_id">Change columns</A>
|
||||
</FORM>
|
||||
<A HREF=3D"buglist.cgi?bug_status=3DNEW&bug_status=3DASSIGNED&bug_status=3D=
|
||||
REOPENED&assigned_to=3Dguha&reporter=3D&product=3DCommunicator&product=3D=
|
||||
Communicator+Pro&target_fix_version=3D4.06+In&target_fix_version=3D4.06&c=
|
||||
hangedin=3D&newqueryname=3D&tweak=3D1">Make changes to several of these b=
|
||||
ugs at once.</A>
|
||||
<h6>Mozilla Communications Corporation, Company Confidential, read and ea=
|
||||
t.</h6>
|
||||
--------------6BEC6C99BAA019BD72B287D1--
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user