mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 20:42:49 +00:00
Add Directory Uri to datasource
This commit is contained in:
parent
b56bc5ce30
commit
aadb72ddfd
@ -46,5 +46,6 @@ interface nsIAbDirectory : nsISupports {
|
||||
void HasDirectory(in nsIAbDirectory dir, out boolean hasDir);
|
||||
void GetMailingList(out nsIEnumerator mailingList);
|
||||
void CreateNewDirectory(in string dirName, in string fileName);
|
||||
void GetDirUri(out string uri);
|
||||
|
||||
};
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
NS_IMETHOD HasDirectory(nsIAbDirectory *dir, PRBool *hasDir) { return NS_OK; }
|
||||
NS_IMETHOD GetMailingList(nsIEnumerator **mailingList) { return NS_OK; }
|
||||
NS_IMETHOD CreateNewDirectory(const char *dirName, const char *fileName) { return NS_OK; }
|
||||
NS_IMETHOD GetDirUri(char **uri) { return NS_OK; }
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -471,3 +471,18 @@ nsresult nsAbDirectory::NotifyItemDeleted(nsISupports *item)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirectory::GetDirUri(char **uri)
|
||||
{
|
||||
if (uri)
|
||||
{
|
||||
if (mURI)
|
||||
*uri = PL_strdup(mURI);
|
||||
else
|
||||
*uri = PL_strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
NS_IMETHOD HasDirectory(nsIAbDirectory *dir, PRBool *hasDir);
|
||||
NS_IMETHOD GetMailingList(nsIEnumerator **mailingList);
|
||||
NS_IMETHOD CreateNewDirectory(const char *dirName, const char *fileName);
|
||||
NS_IMETHOD GetDirUri(char **uri);
|
||||
|
||||
// nsIAddrDBListener methods:
|
||||
NS_IMETHOD OnCardAttribChange(PRUint32 abCode, nsIAddrDBListener *instigator);
|
||||
|
@ -55,6 +55,8 @@ nsIRDFResource* nsAbDirectoryDataSource::kNC_DirName = nsnull;
|
||||
nsIRDFResource* nsAbDirectoryDataSource::kNC_MailingList = nsnull;
|
||||
nsIRDFResource* nsAbDirectoryDataSource::kNC_CardChild = nsnull;
|
||||
|
||||
nsIRDFResource* nsAbDirectoryDataSource::kNC_DirUri = nsnull;
|
||||
|
||||
// commands
|
||||
nsIRDFResource* nsAbDirectoryDataSource::kNC_Delete = nsnull;
|
||||
nsIRDFResource* nsAbDirectoryDataSource::kNC_NewDirectory = nsnull;
|
||||
@ -63,6 +65,7 @@ nsIRDFResource* nsAbDirectoryDataSource::kNC_NewDirectory = nsnull;
|
||||
#define NC_RDF_DIRNAME "http://home.netscape.com/NC-rdf#DirName"
|
||||
#define NC_RDF_MAILINGLIST "http://home.netscape.com/NC-rdf#MailingList"
|
||||
#define NC_RDF_CARDCHILD "http://home.netscape.com/NC-rdf#CardChild"
|
||||
#define NC_RDF_DIRURI "http://home.netscape.com/NC-rdf#DirUri"
|
||||
|
||||
//Directory Commands
|
||||
#define NC_RDF_DELETE "http://home.netscape.com/NC-rdf#Delete"
|
||||
@ -97,6 +100,7 @@ nsAbDirectoryDataSource::~nsAbDirectoryDataSource (void)
|
||||
NS_RELEASE2(kNC_DirName, refcnt);
|
||||
NS_RELEASE2(kNC_MailingList, refcnt);
|
||||
NS_RELEASE2(kNC_CardChild, refcnt);
|
||||
NS_RELEASE2(kNC_DirUri, refcnt);
|
||||
|
||||
NS_RELEASE2(kNC_Delete, refcnt);
|
||||
NS_RELEASE2(kNC_NewDirectory, refcnt);
|
||||
@ -128,6 +132,7 @@ nsAbDirectoryDataSource::Init()
|
||||
mRDFService->GetResource(NC_RDF_DIRNAME, &kNC_DirName);
|
||||
mRDFService->GetResource(NC_RDF_MAILINGLIST, &kNC_MailingList);
|
||||
mRDFService->GetResource(NC_RDF_CARDCHILD, &kNC_CardChild);
|
||||
mRDFService->GetResource(NC_RDF_DIRURI, &kNC_DirUri);
|
||||
|
||||
mRDFService->GetResource(NC_RDF_DELETE, &kNC_Delete);
|
||||
mRDFService->GetResource(NC_RDF_NEWDIRECTORY, &kNC_NewDirectory);
|
||||
@ -211,9 +216,9 @@ NS_IMETHODIMP nsAbDirectoryDataSource::GetTargets(nsIRDFResource* source,
|
||||
NS_ADDREF(cursor);
|
||||
*targets = cursor;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
else if((kNC_DirName == property))
|
||||
{
|
||||
{
|
||||
nsSingletonEnumerator* cursor =
|
||||
new nsSingletonEnumerator(property);
|
||||
if (cursor == nsnull)
|
||||
@ -252,6 +257,16 @@ NS_IMETHODIMP nsAbDirectoryDataSource::GetTargets(nsIRDFResource* source,
|
||||
*targets = cursor;
|
||||
rv = NS_OK;
|
||||
}
|
||||
else if((kNC_DirUri == property))
|
||||
{
|
||||
nsSingletonEnumerator* cursor =
|
||||
new nsSingletonEnumerator(property);
|
||||
if (cursor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(cursor);
|
||||
*targets = cursor;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//create empty cursor
|
||||
@ -338,6 +353,7 @@ nsAbDirectoryDataSource::getDirectoryArcLabelsOut(nsIAbDirectory *directory,
|
||||
(*arcs)->AppendElement(kNC_DirName);
|
||||
(*arcs)->AppendElement(kNC_Child);
|
||||
(*arcs)->AppendElement(kNC_CardChild);
|
||||
(*arcs)->AppendElement(kNC_DirUri);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -505,10 +521,8 @@ nsresult nsAbDirectoryDataSource::createDirectoryNode(nsIAbDirectory* directory,
|
||||
|
||||
if ((kNC_DirName == property))
|
||||
rv = createDirectoryNameNode(directory, target);
|
||||
// else if ((kNC_Child == property))
|
||||
// rv = createDirectoryChildNode(directory,target);
|
||||
// else if ((kNC_CardChild == property))
|
||||
// rv = createCardChildNode(directory,target);
|
||||
if ((kNC_DirUri == property))
|
||||
rv = createDirectoryUriNode(directory, target);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -526,6 +540,18 @@ nsresult nsAbDirectoryDataSource::createDirectoryNameNode(nsIAbDirectory *direct
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbDirectoryDataSource::createDirectoryUriNode(nsIAbDirectory *directory,
|
||||
nsIRDFNode **target)
|
||||
{
|
||||
char *uri;
|
||||
nsresult rv = directory->GetDirUri(&uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsString nameString(uri);
|
||||
createNode(nameString, target);
|
||||
delete[] uri;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAbDirectoryDataSource::createDirectoryChildNode(nsIAbDirectory *directory,
|
||||
nsIRDFNode **target)
|
||||
|
@ -97,6 +97,8 @@ protected:
|
||||
nsIRDFNode** target);
|
||||
nsresult createDirectoryNameNode(nsIAbDirectory *directory,
|
||||
nsIRDFNode **target);
|
||||
nsresult createDirectoryUriNode(nsIAbDirectory *directory,
|
||||
nsIRDFNode **target);
|
||||
nsresult createDirectoryChildNode(nsIAbDirectory *directory,
|
||||
nsIRDFNode **target);
|
||||
nsresult createCardChildNode(nsIAbDirectory *directory,
|
||||
@ -119,6 +121,7 @@ protected:
|
||||
static nsIRDFResource* kNC_DirName;
|
||||
static nsIRDFResource* kNC_MailingList;
|
||||
static nsIRDFResource* kNC_CardChild;
|
||||
static nsIRDFResource* kNC_DirUri;
|
||||
|
||||
// commands
|
||||
static nsIRDFResource* kNC_Delete;
|
||||
|
Loading…
x
Reference in New Issue
Block a user