reflect the ServerType into RDF

This commit is contained in:
alecf%netscape.com 1999-08-18 02:37:16 +00:00
Родитель 3f1a005088
Коммит f29f7f0656
4 изменённых файлов: 95 добавлений и 32 удалений

Просмотреть файл

@ -48,6 +48,7 @@ nsIRDFResource* nsMsgFolderDataSource::kNC_MessageChild = nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_Folder= nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_Name= nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_SpecialFolder= nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_ServerType = nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalMessages= nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalUnreadMessages= nsnull;
nsIRDFResource* nsMsgFolderDataSource::kNC_Charset = nsnull;
@ -87,6 +88,7 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
NS_RELEASE2(kNC_Folder, refcnt);
NS_RELEASE2(kNC_Name, refcnt);
NS_RELEASE2(kNC_SpecialFolder, refcnt);
NS_RELEASE2(kNC_ServerType, refcnt);
NS_RELEASE2(kNC_TotalMessages, refcnt);
NS_RELEASE2(kNC_TotalUnreadMessages, refcnt);
NS_RELEASE2(kNC_Charset, refcnt);
@ -130,6 +132,7 @@ nsresult nsMsgFolderDataSource::Init()
mRDFService->GetResource(NC_RDF_FOLDER, &kNC_Folder);
mRDFService->GetResource(NC_RDF_NAME, &kNC_Name);
mRDFService->GetResource(NC_RDF_SPECIALFOLDER, &kNC_SpecialFolder);
mRDFService->GetResource(NC_RDF_SERVERTYPE, &kNC_ServerType);
mRDFService->GetResource(NC_RDF_TOTALMESSAGES, &kNC_TotalMessages);
mRDFService->GetResource(NC_RDF_TOTALUNREADMESSAGES, &kNC_TotalUnreadMessages);
mRDFService->GetResource(NC_RDF_CHARSET, &kNC_Charset);
@ -293,7 +296,9 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
rv = NS_OK;
}
}
else if((kNC_Name == property) || (kNC_SpecialFolder == property))
else if ((kNC_Name == property) ||
(kNC_SpecialFolder == property) ||
(kNC_ServerType == property))
{
nsSingletonEnumerator* cursor =
new nsSingletonEnumerator(property);
@ -350,6 +355,16 @@ NS_IMETHODIMP nsMsgFolderDataSource::HasAssertion(nsIRDFResource* source,
PRBool* hasAssertion)
{
nsresult rv;
#if 0
nsXPIDLCString sourceval;
nsXPIDLCString propval;
nsXPIDLCString targetval;
source->GetValue(getter_Copies(sourceval));
property->GetValue(getter_Copies(propval));
/* target->GetValue(getter_Copies(targetval)); */
printf("HasAssertion(%s, %s, ??...)\n", (const char*)sourceval, (const char*)propval);
#endif
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(source, &rv));
if(NS_SUCCEEDED(rv))
return DoFolderHasAssertion(folder, property, target, tv, hasAssertion);
@ -373,7 +388,6 @@ NS_IMETHODIMP nsMsgFolderDataSource::ArcLabelsOut(nsIRDFResource* source,
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv)) {
fflush(stdout);
rv = getFolderArcLabelsOut(folder, getter_AddRefs(arcs));
#if 0
nsXPIDLCString srcval;
@ -409,6 +423,7 @@ nsMsgFolderDataSource::getFolderArcLabelsOut(nsIMsgFolder *folder,
(*arcs)->AppendElement(kNC_Name);
(*arcs)->AppendElement(kNC_SpecialFolder);
(*arcs)->AppendElement(kNC_ServerType);
(*arcs)->AppendElement(kNC_TotalMessages);
(*arcs)->AppendElement(kNC_TotalUnreadMessages);
(*arcs)->AppendElement(kNC_Charset);
@ -725,6 +740,8 @@ nsresult nsMsgFolderDataSource::createFolderNode(nsIMsgFolder* folder,
rv = createFolderNameNode(folder, target);
else if ((kNC_SpecialFolder == property))
rv = createFolderSpecialNode(folder,target);
else if ((kNC_ServerType == property))
rv = createFolderServerTypeNode(folder, target);
else if ((kNC_TotalMessages == property))
rv = createTotalMessagesNode(folder, target);
else if ((kNC_TotalUnreadMessages == property))
@ -783,6 +800,22 @@ nsMsgFolderDataSource::createFolderSpecialNode(nsIMsgFolder *folder,
return NS_OK;
}
nsresult
nsMsgFolderDataSource::createFolderServerTypeNode(nsIMsgFolder* folder,
nsIRDFNode **target)
{
nsresult rv;
nsCOMPtr<nsIMsgIncomingServer> server;
rv = folder->GetServer(getter_AddRefs(server));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString serverType;
rv = server->GetType(getter_Copies(serverType));
createNode(serverType, target);
return NS_OK;
}
nsresult
nsMsgFolderDataSource::createTotalMessagesNode(nsIMsgFolder *folder,
nsIRDFNode **target)
@ -1050,8 +1083,11 @@ nsresult nsMsgFolderDataSource::DoFolderAssert(nsIMsgFolder *folder, nsIRDFResou
}
nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target,
PRBool tv, PRBool *hasAssertion)
nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder,
nsIRDFResource *property,
nsIRDFNode *target,
PRBool tv,
PRBool *hasAssertion)
{
nsresult rv = NS_OK;
if(!hasAssertion)
@ -1082,8 +1118,13 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder, nsIRD
if(NS_SUCCEEDED(rv))
rv = folder->HasMessage(message, hasAssertion);
}
else if ((kNC_Name == property) || (kNC_SpecialFolder == property) || (kNC_TotalMessages == property)
|| (kNC_TotalUnreadMessages == property) || (kNC_Charset == property) || (kNC_BiffState == property))
else if ((kNC_Name == property) ||
(kNC_SpecialFolder == property) ||
(kNC_ServerType == property) ||
(kNC_TotalMessages == property) ||
(kNC_TotalUnreadMessages == property) ||
(kNC_Charset == property) ||
(kNC_BiffState == property))
{
nsCOMPtr<nsIRDFResource> folderResource(do_QueryInterface(folder, &rv));

Просмотреть файл

@ -127,6 +127,8 @@ protected:
nsIRDFNode **target);
nsresult createFolderNameNode(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createFolderSpecialNode(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createFolderServerTypeNode(nsIMsgFolder *folder,
nsIRDFNode **target);
nsresult createTotalMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createUnreadMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target);
nsresult createCharsetNode(nsIMsgFolder *folder, nsIRDFNode **target);
@ -164,6 +166,7 @@ protected:
static nsIRDFResource* kNC_Columns;
static nsIRDFResource* kNC_MSGFolderRoot;
static nsIRDFResource* kNC_SpecialFolder;
static nsIRDFResource* kNC_ServerType;
static nsIRDFResource* kNC_TotalMessages;
static nsIRDFResource* kNC_TotalUnreadMessages;
static nsIRDFResource* kNC_Charset;

Просмотреть файл

@ -114,6 +114,23 @@ nsresult createNode(PRUint32 value, nsIRDFNode **node)
return rv;
}
nsresult createNode(const char* charstr, nsIRDFNode **node)
{
nsresult rv;
// use nsString to convert to unicode
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFLiteral> value;
nsString str(charstr);
PRUnichar *ucharstr = str.ToNewUnicode();
rv = rdf->GetLiteral(ucharstr, getter_AddRefs(value));
if(NS_SUCCEEDED(rv)) {
*node = value;
NS_IF_ADDREF(*node);
}
return rv;
}
nsresult createDateNode(PRTime time, nsIRDFNode **node)
{
*node = nsnull;

Просмотреть файл

@ -33,36 +33,37 @@ typedef struct _nsMsgRDFNotification {
//Some property declarations
#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 NC_RDF_SUBJECT NC_NAMESPACE_URI "Subject"
#define NC_RDF_SENDER NC_NAMESPACE_URI "Sender"
#define NC_RDF_DATE NC_NAMESPACE_URI "Date"
#define NC_RDF_STATUS NC_NAMESPACE_URI "Status"
#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 NC_RDF_CHARSET "http://home.netscape.com/NC-rdf#Charset"
#define NC_RDF_BIFFSTATE "http://home.netscape.com/NC-rdf#BiffState"
#define NC_RDF_CHILD NC_NAMESPACE_URI "child"
#define NC_RDF_MESSAGECHILD NC_NAMESPACE_URI "MessageChild"
#define NC_RDF_NAME NC_NAMESPACE_URI "Name"
#define NC_RDF_FOLDER NC_NAMESPACE_URI "Folder"
#define NC_RDF_SPECIALFOLDER NC_NAMESPACE_URI "SpecialFolder"
#define NC_RDF_SERVERTYPE NC_NAMESPACE_URI "ServerType"
#define NC_RDF_TOTALMESSAGES NC_NAMESPACE_URI "TotalMessages"
#define NC_RDF_TOTALUNREADMESSAGES NC_NAMESPACE_URI "TotalUnreadMessages"
#define NC_RDF_CHARSET NC_NAMESPACE_URI "Charset"
#define NC_RDF_BIFFSTATE NC_NAMESPACE_URI "BiffState"
//Folder Commands
#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"
#define NC_RDF_COPY "http://home.netscape.com/NC-rdf#Copy"
#define NC_RDF_MOVE "http://home.netscape.com/NC-rdf#Move"
#define NC_RDF_MARKALLMESSAGESREAD "http://home.netscape.com/NC-rdf#MarkAllMessagesRead"
#define NC_RDF_COMPACT "http://home.netscape.com/NC-rdf#Compact"
#define NC_RDF_RENAME "http://home.netscape.com/NC_rdf#Rename"
#define NC_RDF_EMPTYTRASH "http://home.netscape.com/NC_rdf#EmptyTrash"
#define NC_RDF_DELETE NC_NAMESPACE_URI "Delete"
#define NC_RDF_NEWFOLDER NC_NAMESPACE_URI "NewFolder"
#define NC_RDF_GETNEWMESSAGES NC_NAMESPACE_URI "GetNewMessages"
#define NC_RDF_COPY NC_NAMESPACE_URI "Copy"
#define NC_RDF_MOVE NC_NAMESPACE_URI "Move"
#define NC_RDF_MARKALLMESSAGESREAD NC_NAMESPACE_URI "MarkAllMessagesRead"
#define NC_RDF_COMPACT NC_NAMESPACE_URI "Compact"
#define NC_RDF_RENAME NC_NAMESPACE_URI "Rename"
#define NC_RDF_EMPTYTRASH NC_NAMESPACE_URI "EmptyTrash"
//Message Commands
#define NC_RDF_MARKREAD "http://home.netscape.com/NC-rdf#MarkRead"
#define NC_RDF_MARKUNREAD "http://home.netscape.com/NC-rdf#MarkUnread"
#define NC_RDF_TOGGLEREAD "http://home.netscape.com/NC-rdf#ToggleRead"
#define NC_RDF_MARKREAD NC_NAMESPACE_URI "MarkRead"
#define NC_RDF_MARKUNREAD NC_NAMESPACE_URI "MarkUnread"
#define NC_RDF_TOGGLEREAD NC_NAMESPACE_URI "ToggleRead"
//Returns PR_TRUE if r1 is equal to r2 and r2 is the sort property.
@ -75,6 +76,7 @@ peqCollationSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isCollation);
//Given an nsString, create an nsIRDFNode
nsresult createNode(nsString& str, nsIRDFNode **node);
nsresult createNode(const char*, nsIRDFNode **);
//Given a PRUint32, create an nsiIRDFNode.
nsresult createNode(PRUint32 value, nsIRDFNode **node);