> In abDirTreeOverlay.xul, the tree has the following attribute:
> datasources="rdf:addressdirectory"
> Where is this datasource and how can I see the RDF definition file?
>I'd like to know what all is stored in it.
See:
http://lxr.mozilla.org/seamonkey/source/mailnews/addrbook/src/nsDirectoryDataSou
rce.cpp
for the address book directory RDF data source
implementation.
I don't know if there is a tool to generate
RDF XML files from a data source.
See:
http://www.mozilla.org/rdf/doc/datasource-howto.html
to how to get a data source.
Attached is an example of how to get the address book
data sources and resources in C++, note that this
was created off the top of my head so may not
compile :-), but it gets the point accross.
Paul.
| ? + ? = To question
----------------\
Paul Sandoz
x19219
+353-1-8199219
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
/*
Get the RDF service
*/
nsresult rv;
NS_WITH_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, &rv);
/*
Get the address book directory RDF data source
*/
nsCOMPtr<nsIRDFDataSource> directoryDataSource;
rv = rdf->GetDataSource("rdf:addressdirectory",
getter_AddRefs (directoryDataSource));
/*
Get the top level address book RDF resource
*/
nsCOMPtr<nsIRDFResource> topDirectory;
rv = rdf->GetResource ("abdirectory://",
getter_AddRefs (topDirectory);
//
// JS friendly way
//
/*
Get the child card property resource
*/
nsCOMPtr<nsIRDFResource> childCardProperty;
rv = rdf->GetResource ("http://home.netscape.com/NC-rdf#CardChild",
getter_AddRefs (childCardProperty));
/*
Get the enumeration of children
*/
nsCOMPtr<nsISimpleEnumerator> childrenEnumerator;
rv = directoryDataSource->GetTargets (topDirectory,
childCardProperty,
PR_FALSE,
getter_AddRefs (childrenEnumerator));
PRBool hasMore = PR_FALSE;
rv = childrenEnumerator->HasMoreElements (&hasMore);
while (hasMore)
{
nsCOMPtr<nsISupports> item;
rv = childrenEnumerator->GetNext (getter_AddRefs (item));
nsCOMPtr<nsIAbCard> card (do_QueryInterface (item, &rv));
rv = childrenEnumerator->HasMoreElements (&hasMore);
}
//
// JS UN-friendly way
//
nsCOMPtr<nsIAbDirectory> dir (do_QueryInterface (topDirectory, &rv));
nsCOMPtr<nsIEnumeratory> children;
rv = dir->GetChildCards (getter_AddRefs (children)));
.
.
.