From 0c6c872206accf7680dd52292ab5e416b7d74c15 Mon Sep 17 00:00:00 2001 From: "putterman%netscape.com" Date: Fri, 7 May 1999 00:32:10 +0000 Subject: [PATCH] Added GetTargetHasAssertion, GetNewMessages and use string instead of ints for property names. --- mailnews/base/src/nsMessageViewDataSource.cpp | 10 +++--- mailnews/base/src/nsMsgAccountManagerDS.cpp | 4 +-- mailnews/base/src/nsMsgMessageDataSource.cpp | 8 ++--- mailnews/base/src/nsMsgRDFUtils.cpp | 25 +++++++++++++ mailnews/base/src/nsMsgRDFUtils.h | 36 +++++++++++-------- 5 files changed, 58 insertions(+), 25 deletions(-) diff --git a/mailnews/base/src/nsMessageViewDataSource.cpp b/mailnews/base/src/nsMessageViewDataSource.cpp index 8932bab7c1a..7342f8f2bdc 100644 --- a/mailnews/base/src/nsMessageViewDataSource.cpp +++ b/mailnews/base/src/nsMessageViewDataSource.cpp @@ -118,11 +118,11 @@ NS_IMETHODIMP nsMessageViewDataSource::Init(const char* uri) mRDFService->RegisterDataSource(this, PR_FALSE); if (! kNC_MessageChild) { - mRDFService->GetResource(kURINC_MessageChild, &kNC_MessageChild); - mRDFService->GetResource(kURINC_Subject, &kNC_Subject); - mRDFService->GetResource(kURINC_Date, &kNC_Date); - mRDFService->GetResource(kURINC_Sender, &kNC_Sender); - mRDFService->GetResource(kURINC_Status , &kNC_Status); + mRDFService->GetResource(NC_RDF_MESSAGECHILD, &kNC_MessageChild); + mRDFService->GetResource(NC_RDF_SUBJECT, &kNC_Subject); + mRDFService->GetResource(NC_RDF_DATE, &kNC_Date); + mRDFService->GetResource(NC_RDF_SENDER, &kNC_Sender); + mRDFService->GetResource(NC_RDF_STATUS , &kNC_Status); } mInitialized = PR_TRUE; diff --git a/mailnews/base/src/nsMsgAccountManagerDS.cpp b/mailnews/base/src/nsMsgAccountManagerDS.cpp index 659bde6064c..9f7d9841a09 100644 --- a/mailnews/base/src/nsMsgAccountManagerDS.cpp +++ b/mailnews/base/src/nsMsgAccountManagerDS.cpp @@ -143,8 +143,8 @@ nsMsgAccountManagerDataSource::Init(const char *uri) } if (! kNC_Child) { - getRDFService()->GetResource(kURINC_child, &kNC_Child); - getRDFService()->GetResource(kURINC_Name, &kNC_Name); + getRDFService()->GetResource(NC_RDF_CHILD, &kNC_Child); + getRDFService()->GetResource(NC_RDF_NAME, &kNC_Name); getRDFService()->GetResource(kURINC_Account, &kNC_Account); getRDFService()->GetResource(kURINC_Server, &kNC_Server); getRDFService()->GetResource(kURINC_Identity, &kNC_Identity); diff --git a/mailnews/base/src/nsMsgMessageDataSource.cpp b/mailnews/base/src/nsMsgMessageDataSource.cpp index 79644c81d21..66c65d11865 100644 --- a/mailnews/base/src/nsMsgMessageDataSource.cpp +++ b/mailnews/base/src/nsMsgMessageDataSource.cpp @@ -122,10 +122,10 @@ NS_IMETHODIMP nsMsgMessageDataSource::Init(const char* uri) if (! kNC_Subject) { - mRDFService->GetResource(kURINC_Subject, &kNC_Subject); - mRDFService->GetResource(kURINC_Sender, &kNC_Sender); - mRDFService->GetResource(kURINC_Date, &kNC_Date); - mRDFService->GetResource(kURINC_Status, &kNC_Status); + mRDFService->GetResource(NC_RDF_SUBJECT, &kNC_Subject); + mRDFService->GetResource(NC_RDF_SENDER, &kNC_Sender); + mRDFService->GetResource(NC_RDF_DATE, &kNC_Date); + mRDFService->GetResource(NC_RDF_STATUS, &kNC_Status); } mInitialized = PR_TRUE; diff --git a/mailnews/base/src/nsMsgRDFUtils.cpp b/mailnews/base/src/nsMsgRDFUtils.cpp index 50d80cef9e1..2c7ac25138f 100644 --- a/mailnews/base/src/nsMsgRDFUtils.cpp +++ b/mailnews/base/src/nsMsgRDFUtils.cpp @@ -101,3 +101,28 @@ nsresult createNode(PRUint32 value, nsIRDFNode **node) rv = createNode(str, node); return rv; } + +nsresult GetTargetHasAssertion(nsIRDFDataSource *dataSource, nsIRDFResource* folderResource, + nsIRDFResource *property,PRBool tv, nsIRDFNode *target,PRBool* hasAssertion) +{ + nsresult rv; + if(!hasAssertion) + return NS_ERROR_NULL_POINTER; + + nsCOMPtr currentTarget; + + rv = dataSource->GetTarget(folderResource, property,tv, getter_AddRefs(currentTarget)); + if(NS_SUCCEEDED(rv)) + { + nsCOMPtr value1(do_QueryInterface(target)); + nsCOMPtr value2(do_QueryInterface(currentTarget)); + if(value1 && value2) + //If the two values are equal then it has this assertion + rv = value1->EqualsLiteral(value2, hasAssertion); + } + else + rv = NS_NOINTERFACE; + + return rv; + +} \ No newline at end of file diff --git a/mailnews/base/src/nsMsgRDFUtils.h b/mailnews/base/src/nsMsgRDFUtils.h index 1e6fd47811c..0950bb5682d 100644 --- a/mailnews/base/src/nsMsgRDFUtils.h +++ b/mailnews/base/src/nsMsgRDFUtils.h @@ -21,6 +21,7 @@ #include "rdf.h" #include "nsIRDFResource.h" #include "nsIRDFNode.h" +#include "nsIRDFDataSource.h" #include "nsString.h" // this is used for notification of observers using nsVoidArray @@ -31,23 +32,23 @@ typedef struct _nsMsgRDFNotification { } nsMsgRDFNotification; //Some property declarations -#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#" -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Subject); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Sender); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Date); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Status); +#define NC_RDF_SUBJECT "http://home.netscape.com/NC-rdf#Subject" +#define NC_RDF_SENDER "http://home.netscape.com/NC-rdf#Sender" +#define NC_RDF_DATE "http://home.netscape.com/NC-rdf#Date" +#define NC_RDF_STATUS "http://home.netscape.com/NC-rdf#Status" -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, MessageChild); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Name); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, SpecialFolder); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, TotalMessages); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, TotalUnreadMessages); +#define NC_RDF_CHILD "http://home.netscape.com/NC-rdf#child" +#define NC_RDF_MESSAGECHILD "http://home.netscape.com/NC-rdf#MessageChild" +#define NC_RDF_NAME "http://home.netscape.com/NC-rdf#Name" +#define NC_RDF_FOLDER "http://home.netscape.com/NC-rdf#Folder" +#define NC_RDF_SPECIALFOLDER "http://home.netscape.com/NC-rdf#SpecialFolder" +#define NC_RDF_TOTALMESSAGES "http://home.netscape.com/NC-rdf#TotalMessages" +#define NC_RDF_TOTALUNREADMESSAGES "http://home.netscape.com/NC-rdf#TotalUnreadMessages" -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Delete); -DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, NewFolder); +#define NC_RDF_DELETE "http://home.netscape.com/NC-rdf#Delete" +#define NC_RDF_NEWFOLDER "http://home.netscape.com/NC-rdf#NewFolder" +#define NC_RDF_GETNEWMESSAGES "http://home.netscape.com/NC-rdf#GetNewMessages" //Returns PR_TRUE if r1 is equal to r2 @@ -64,3 +65,10 @@ nsresult createNode(nsString& str, nsIRDFNode **node); //Given a PRUint32, create an nsiIRDFNode. nsresult createNode(PRUint32 value, nsIRDFNode **node); +//Has Assertion for a datasource that will just call GetTarget on property. When all of our +//datasource derive from our datasource baseclass, this should be moved there and the first +//parameter will no longer be needed. +nsresult GetTargetHasAssertion(nsIRDFDataSource *dataSource, nsIRDFResource* folderResource, + nsIRDFResource *property,PRBool tv, nsIRDFNode *target,PRBool* hasAssertion); + +