зеркало из https://github.com/mozilla/gecko-dev.git
Added Biff Manager and CharSet functions.
This commit is contained in:
Родитель
f5f66a5a61
Коммит
16132db4b1
|
@ -27,4 +27,5 @@ nsMessageViewDataSource.h
|
|||
nsMsgAccount.h
|
||||
nsMsgAccountManager.h
|
||||
nsMsgRDFDataSource.h
|
||||
nsMsgBiffManager.h
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ EXPORTS = \
|
|||
nsMsgIdentityDataSource.h \
|
||||
nsMsgServerDataSource.h \
|
||||
nsMsgRDFDataSource.h \
|
||||
nsMsgBiffManager.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -64,6 +65,7 @@ CPPSRCS = \
|
|||
nsMsgIdentityDataSource.cpp \
|
||||
nsMsgServerDataSource.cpp \
|
||||
nsMsgRDFUtils.cpp \
|
||||
nsMsgBiffManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -46,6 +46,7 @@ CPPSRCS= \
|
|||
nsMsgAccountManagerDS.cpp \
|
||||
nsMsgIdentityDataSource.cpp \
|
||||
nsMsgServerDataSource.cpp \
|
||||
nsMsgBiffManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
@ -70,6 +71,7 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsMsgAccountManagerDS.obj \
|
||||
.\$(OBJDIR)\nsMsgIdentityDataSource.obj \
|
||||
.\$(OBJDIR)\nsMsgServerDataSource.obj \
|
||||
.\$(OBJDIR)\nsMsgBiffManager.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
@ -89,6 +91,7 @@ EXPORTS= \
|
|||
nsMsgAccountManagerDS.h \
|
||||
nsMsgIdentityDataSource.h \
|
||||
nsMsgServerDataSource.h \
|
||||
nsMsgBiffManager.h \
|
||||
$(NULL)
|
||||
|
||||
LINCS= \
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "plstr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIMsgBiffManager.h"
|
||||
|
||||
#include "nsCRT.h" // for nsCRT::strtok
|
||||
|
||||
|
@ -38,6 +39,8 @@
|
|||
static NS_DEFINE_CID(kMsgAccountCID, NS_MSGACCOUNT_CID);
|
||||
static NS_DEFINE_CID(kMsgIdentityCID, NS_MSGIDENTITY_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kMsgBiffManagerCID, NS_MSGBIFFMANAGER_CID);
|
||||
|
||||
|
||||
// use this to search all accounts for the given account and store the
|
||||
// resulting key in hashKey
|
||||
|
@ -113,11 +116,16 @@ public:
|
|||
NS_IMETHOD FindServersByHostname(const char* hostname,
|
||||
const nsIID& iid,
|
||||
nsISupportsArray* *serverArray);
|
||||
|
||||
NS_IMETHOD GetIdentitiesForServer(nsIMsgIncomingServer *server,
|
||||
nsISupportsArray **_retval);
|
||||
|
||||
NS_IMETHOD GetServersForIdentity(nsIMsgIdentity *identity,
|
||||
nsISupportsArray **_retval);
|
||||
|
||||
//Add/remove an account to/from the Biff Manager if it has Biff turned on.
|
||||
nsresult addAccountToBiff(nsIMsgAccount *account);
|
||||
nsresult removeAccountFromBiff(nsIMsgAccount *account);
|
||||
|
||||
private:
|
||||
nsHashtable *m_accounts;
|
||||
|
@ -136,10 +144,15 @@ private:
|
|||
void *closure);
|
||||
static PRBool hashTableFindFirst(nsHashKey *aKey, void *aData,
|
||||
void *closure);
|
||||
|
||||
static PRBool findIdentitiesForServer(nsHashKey *aKey,
|
||||
void *aData, void *closure);
|
||||
static PRBool findServersForIdentity (nsHashKey *aKey,
|
||||
void *aData, void *closure);
|
||||
|
||||
// remove all of the servers from the Biff Manager
|
||||
static PRBool hashTableRemoveAccountFromBiff(nsHashKey *aKey, void *aData, void *closure);
|
||||
|
||||
// nsISupportsArray enumerators
|
||||
static PRBool findServerByName(nsISupports *aElement, void *data);
|
||||
|
||||
|
@ -163,6 +176,7 @@ nsMsgAccountManager::nsMsgAccountManager() :
|
|||
nsMsgAccountManager::~nsMsgAccountManager()
|
||||
{
|
||||
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID, m_prefs);
|
||||
m_accounts->Enumerate(hashTableRemoveAccountFromBiff, this);
|
||||
delete m_accounts;
|
||||
}
|
||||
|
||||
|
@ -236,9 +250,62 @@ nsMsgAccountManager::addAccount(nsIMsgAccount *account)
|
|||
if (m_accounts->Count() == 1)
|
||||
m_defaultAccount = dont_QueryInterface(account);
|
||||
|
||||
addAccountToBiff(account);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgAccountManager::addAccountToBiff(nsIMsgAccount *account)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
PRBool doBiff = PR_FALSE;
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgBiffManager, biffManager, kMsgBiffManagerCID, &rv);
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = account->GetIncomingServer(getter_AddRefs(server));
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = server->GetDoBiff(&doBiff);
|
||||
}
|
||||
|
||||
if(NS_SUCCEEDED(rv) && doBiff)
|
||||
{
|
||||
rv = biffManager->AddServerBiff(server);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgAccountManager::removeAccountFromBiff(nsIMsgAccount *account)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
PRBool doBiff = PR_FALSE;
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgBiffManager, biffManager, kMsgBiffManagerCID, &rv);
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = account->GetIncomingServer(getter_AddRefs(server));
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = server->GetDoBiff(&doBiff);
|
||||
}
|
||||
|
||||
if(NS_SUCCEEDED(rv) && doBiff)
|
||||
{
|
||||
rv = biffManager->RemoveServerBiff(server);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* get the default account. If no default account, pick the first account */
|
||||
NS_IMETHODIMP
|
||||
|
@ -338,6 +405,17 @@ nsMsgAccountManager::hashTableFindFirst(nsHashKey *aKey,
|
|||
return PR_FALSE; // stop enumerating immediately
|
||||
}
|
||||
|
||||
// enumaration for removing accounts from the BiffManager
|
||||
PRBool nsMsgAccountManager::hashTableRemoveAccountFromBiff(nsHashKey *aKey, void *aData, void *closure)
|
||||
{
|
||||
nsIMsgAccount* account = (nsIMsgAccount *)aData;
|
||||
nsMsgAccountManager *accountManager = (nsMsgAccountManager*)closure;
|
||||
|
||||
accountManager->removeAccountFromBiff(account);
|
||||
|
||||
return PR_TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* nsISupportsArray getAccounts (); */
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsMsgBiffManager.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
//There's no GetIID for this.
|
||||
static NS_DEFINE_IID(kITimerCallbackIID, NS_ITIMERCALLBACK_IID);
|
||||
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
nsresult
|
||||
NS_NewMsgBiffManager(const nsIID& iid, void **result)
|
||||
{
|
||||
nsMsgBiffManager *biffManager = new nsMsgBiffManager();
|
||||
return biffManager->QueryInterface(iid, result);
|
||||
}
|
||||
|
||||
NS_END_EXTERN_C
|
||||
|
||||
NS_IMPL_ADDREF(nsMsgBiffManager)
|
||||
NS_IMPL_RELEASE(nsMsgBiffManager)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgBiffManager::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(nsIMsgBiffManager::GetIID()) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIMsgBiffManager*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if(iid.Equals(kITimerCallbackIID))
|
||||
{
|
||||
*result = NS_STATIC_CAST(nsITimerCallback*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsMsgBiffManager::nsMsgBiffManager()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
NS_NewTimer(&mBiffTimer);
|
||||
|
||||
mBiffArray = new nsVoidArray();
|
||||
}
|
||||
|
||||
nsMsgBiffManager::~nsMsgBiffManager()
|
||||
{
|
||||
mBiffTimer->Cancel();
|
||||
NS_IF_RELEASE(mBiffTimer);
|
||||
|
||||
PRInt32 count = mBiffArray->Count();
|
||||
for(PRInt32 i; i < count; i++)
|
||||
{
|
||||
nsBiffEntry *biffEntry = (nsBiffEntry*)mBiffArray->ElementAt(i);
|
||||
delete biffEntry;
|
||||
}
|
||||
delete mBiffArray;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgBiffManager::AddServerBiff(nsIMsgIncomingServer *server)
|
||||
{
|
||||
PRInt32 serverIndex = FindServer(server);
|
||||
nsresult rv;
|
||||
//Only add it if it hasn't been added already.
|
||||
if(serverIndex == -1)
|
||||
{
|
||||
PRInt32 biffInterval;
|
||||
nsBiffEntry *biffEntry = new nsBiffEntry;
|
||||
if(!biffEntry)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
biffEntry->server = server;
|
||||
rv = server->GetBiffMinutes(&biffInterval);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
//Add 60 secs/minute in microseconds to current time. biffEntry->nextBiffTime's
|
||||
//constructor makes it the current time.
|
||||
biffEntry->nextBiffTime += (60000000 * biffInterval);
|
||||
AddBiffEntry(biffEntry);
|
||||
SetupNextBiff();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgBiffManager::RemoveServerBiff(nsIMsgIncomingServer *server)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMsgBiffManager::ForceBiff(nsIMsgIncomingServer *server)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgBiffManager::ForceBiffAll()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsMsgBiffManager::Notify(nsITimer *timer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PRInt32 nsMsgBiffManager::FindServer(nsIMsgIncomingServer *server)
|
||||
{
|
||||
PRInt32 count = mBiffArray->Count();
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsBiffEntry *biffEntry = (nsBiffEntry*)mBiffArray->ElementAt(i);
|
||||
if(server == biffEntry->server)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
nsresult nsMsgBiffManager::AddBiffEntry(nsBiffEntry *biffEntry)
|
||||
{
|
||||
PRInt32 count = mBiffArray->Count();
|
||||
PRInt32 i;
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
nsBiffEntry *current = (nsBiffEntry*)mBiffArray->ElementAt(i);
|
||||
if(biffEntry->nextBiffTime < current->nextBiffTime)
|
||||
mBiffArray->InsertElementAt(biffEntry, i);
|
||||
|
||||
}
|
||||
mBiffArray->InsertElementAt(biffEntry, i);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgBiffManager::SetupNextBiff()
|
||||
{
|
||||
if(mBiffArray->Count() > 0)
|
||||
{
|
||||
//Get the next biff entry
|
||||
nsBiffEntry *biffEntry = (nsBiffEntry*)mBiffArray->ElementAt(0);
|
||||
nsTime currentTime;
|
||||
nsTime biffDelay;
|
||||
|
||||
if(currentTime > biffEntry->nextBiffTime)
|
||||
biffDelay = 0;
|
||||
else
|
||||
biffDelay = biffEntry->nextBiffTime - currentTime;
|
||||
mBiffTimer->Cancel();
|
||||
//Convert biffDelay into milliseconds
|
||||
PRInt64 timeInMS;
|
||||
PRUint32 timeInMSUint32;
|
||||
|
||||
LL_DIV(timeInMS, biffDelay, 1000);
|
||||
LL_L2UI(timeInMSUint32, timeInMS);
|
||||
mBiffTimer->Init(this, timeInMSUint32);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef NSMSGBIFFMANAGER_H
|
||||
#define NSMSGBIFFMANAGER_H
|
||||
|
||||
#include "msgCore.h"
|
||||
#include "nsIMsgBiffManager.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsITimerCallback.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsTime.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef struct {
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
nsTime nextBiffTime;
|
||||
} nsBiffEntry;
|
||||
|
||||
|
||||
class nsMsgBiffManager: public nsIMsgBiffManager, nsITimerCallback
|
||||
{
|
||||
public:
|
||||
nsMsgBiffManager();
|
||||
virtual ~nsMsgBiffManager();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
//nsIBiffManager implementation
|
||||
NS_IMETHOD AddServerBiff(nsIMsgIncomingServer *server);
|
||||
NS_IMETHOD RemoveServerBiff(nsIMsgIncomingServer *server);
|
||||
NS_IMETHOD ForceBiff(nsIMsgIncomingServer *server);
|
||||
NS_IMETHOD ForceBiffAll();
|
||||
|
||||
//nsITimerCallback implementation
|
||||
virtual void Notify(nsITimer *timer);
|
||||
|
||||
protected:
|
||||
PRInt32 FindServer(nsIMsgIncomingServer *server);
|
||||
nsresult SetupNextBiff();
|
||||
nsresult AddBiffEntry(nsBiffEntry *biffEntry);
|
||||
|
||||
protected:
|
||||
nsITimer *mBiffTimer;
|
||||
nsVoidArray *mBiffArray;
|
||||
};
|
||||
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
nsresult
|
||||
NS_NewMsgBiffManager(const nsIID& iid, void **result);
|
||||
|
||||
NS_END_EXTERN_C
|
||||
|
||||
#endif
|
|
@ -44,18 +44,19 @@ static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
|||
// that multiply inherits from nsISupports
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Child;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_MessageChild;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Folder;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Name;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_SpecialFolder;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalMessages;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalUnreadMessages;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Child = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_MessageChild = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Folder= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Name= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_SpecialFolder= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalMessages= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalUnreadMessages= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Charset = nsnull;
|
||||
|
||||
// commands
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Delete;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_NewFolder;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_GetNewMessages;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Delete= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_NewFolder= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_GetNewMessages= nsnull;
|
||||
|
||||
|
||||
|
||||
|
@ -97,6 +98,7 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
|||
NS_RELEASE2(kNC_SpecialFolder, refcnt);
|
||||
NS_RELEASE2(kNC_TotalMessages, refcnt);
|
||||
NS_RELEASE2(kNC_TotalUnreadMessages, refcnt);
|
||||
NS_RELEASE2(kNC_Charset, refcnt);
|
||||
|
||||
NS_RELEASE2(kNC_Delete, refcnt);
|
||||
NS_RELEASE2(kNC_NewFolder, refcnt);
|
||||
|
@ -146,6 +148,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::Init(const char* uri)
|
|||
mRDFService->GetResource(NC_RDF_SPECIALFOLDER, &kNC_SpecialFolder);
|
||||
mRDFService->GetResource(NC_RDF_TOTALMESSAGES, &kNC_TotalMessages);
|
||||
mRDFService->GetResource(NC_RDF_TOTALUNREADMESSAGES, &kNC_TotalUnreadMessages);
|
||||
mRDFService->GetResource(NC_RDF_CHARSET, &kNC_Charset);
|
||||
|
||||
mRDFService->GetResource(NC_RDF_DELETE, &kNC_Delete);
|
||||
mRDFService->GetResource(NC_RDF_NEWFOLDER, &kNC_NewFolder);
|
||||
|
@ -281,7 +284,13 @@ NS_IMETHODIMP nsMsgFolderDataSource::Assert(nsIRDFResource* source,
|
|||
nsIRDFNode* target,
|
||||
PRBool tv)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(source, &rv));
|
||||
//We don't handle tv = PR_FALSE at the moment.
|
||||
if(NS_SUCCEEDED(rv) && tv)
|
||||
return DoFolderAssert(folder, property, target);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolderDataSource::Unassert(nsIRDFResource* source,
|
||||
|
@ -356,6 +365,7 @@ nsMsgFolderDataSource::getFolderArcLabelsOut(nsIMsgFolder *folder,
|
|||
(*arcs)->AppendElement(kNC_SpecialFolder);
|
||||
(*arcs)->AppendElement(kNC_TotalMessages);
|
||||
(*arcs)->AppendElement(kNC_TotalUnreadMessages);
|
||||
(*arcs)->AppendElement(kNC_Charset);
|
||||
(*arcs)->AppendElement(kNC_Child);
|
||||
(*arcs)->AppendElement(kNC_MessageChild);
|
||||
|
||||
|
@ -583,6 +593,8 @@ nsresult nsMsgFolderDataSource::createFolderNode(nsIMsgFolder* folder,
|
|||
rv = createTotalMessagesNode(folder, target);
|
||||
else if (peq(kNC_TotalUnreadMessages, property))
|
||||
rv = createUnreadMessagesNode(folder, target);
|
||||
else if (peq(kNC_Charset, property))
|
||||
rv = createCharsetNode(folder, target);
|
||||
else if (peq(kNC_Child, property))
|
||||
rv = createFolderChildNode(folder, target);
|
||||
else if (peq(kNC_MessageChild, property))
|
||||
|
@ -652,6 +664,22 @@ nsMsgFolderDataSource::createTotalMessagesNode(nsIMsgFolder *folder,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgFolderDataSource::createCharsetNode(nsIMsgFolder *folder, nsIRDFNode **target)
|
||||
{
|
||||
PRUnichar *charset;
|
||||
nsString charsetStr;
|
||||
nsresult rv = folder->GetCharset(&charset);
|
||||
//We always need to return a value
|
||||
if(NS_SUCCEEDED(rv))
|
||||
charsetStr = charset;
|
||||
else
|
||||
charsetStr ="";
|
||||
createNode(charsetStr, target);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgFolderDataSource::createUnreadMessagesNode(nsIMsgFolder *folder,
|
||||
nsIRDFNode **target)
|
||||
|
@ -775,6 +803,32 @@ nsresult nsMsgFolderDataSource::DoNewFolder(nsIMsgFolder *folder, nsISupportsArr
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgFolderDataSource::DoFolderAssert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if(peq(kNC_Charset, property))
|
||||
{
|
||||
nsCOMPtr<nsIRDFLiteral> literal(do_QueryInterface(target));
|
||||
if(literal)
|
||||
{
|
||||
PRUnichar *value;
|
||||
rv = literal->GetValue(&value);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = folder->SetCharset(value);
|
||||
delete[] value;
|
||||
}
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target,
|
||||
PRBool tv, PRBool *hasAssertion)
|
||||
{
|
||||
|
@ -790,7 +844,7 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder, nsIRD
|
|||
}
|
||||
|
||||
if (peq(kNC_Name, property) || peq(kNC_SpecialFolder, property) || peq(kNC_TotalMessages, property)
|
||||
|| peq(kNC_TotalUnreadMessages, property))
|
||||
|| peq(kNC_TotalUnreadMessages, property) || peq(kNC_Charset, property))
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> folderResource(do_QueryInterface(folder, &rv));
|
||||
|
||||
|
|
|
@ -131,6 +131,8 @@ protected:
|
|||
nsresult createFolderSpecialNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
nsresult createTotalMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
nsresult createUnreadMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
nsresult createCharsetNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
|
||||
nsresult createFolderChildNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
nsresult createFolderMessageNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
|
||||
|
@ -146,6 +148,8 @@ protected:
|
|||
nsresult DoNewFolder(nsIMsgFolder *folder,
|
||||
nsISupportsArray *arguments);
|
||||
|
||||
nsresult DoFolderAssert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target);
|
||||
|
||||
nsresult DoFolderHasAssertion(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target,
|
||||
PRBool tv, PRBool *hasAssertion);
|
||||
|
||||
|
@ -159,6 +163,7 @@ protected:
|
|||
static nsIRDFResource* kNC_SpecialFolder;
|
||||
static nsIRDFResource* kNC_TotalMessages;
|
||||
static nsIRDFResource* kNC_TotalUnreadMessages;
|
||||
static nsIRDFResource* kNC_Charset;
|
||||
|
||||
// commands
|
||||
static nsIRDFResource* kNC_Delete;
|
||||
|
|
|
@ -45,6 +45,7 @@ typedef struct _nsMsgRDFNotification {
|
|||
#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"
|
||||
|
||||
//Folder Commands
|
||||
#define NC_RDF_DELETE "http://home.netscape.com/NC-rdf#Delete"
|
||||
|
|
Загрузка…
Ссылка в новой задаче