mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
make the mail notification systems use nsIAtoms instead of char*s, and add capability to notify on PRUnichar* data that changes
(in preparationfor #19079) r=scottip
This commit is contained in:
parent
ea798addcb
commit
151c9ac450
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAtom.idl"
|
||||
|
||||
interface nsIFolder;
|
||||
|
||||
@ -29,10 +30,12 @@ interface nsIFolderListener : nsISupports {
|
||||
|
||||
void OnItemAdded(in nsISupports parentItem, in nsISupports item, in string viewString);
|
||||
void OnItemRemoved(in nsISupports parentItem, in nsISupports item, in string viewString);
|
||||
void OnItemPropertyChanged(in nsISupports item, in string property, in string oldValue, in string newValue);
|
||||
void OnItemIntPropertyChanged(in nsISupports item, in string property, in long oldValue, in long newValue);
|
||||
void OnItemBoolPropertyChanged(in nsISupports item, in string property, in boolean oldValue, in boolean newValue);
|
||||
void OnItemPropertyFlagChanged(in nsISupports item, in string property, in unsigned long oldFlag,
|
||||
|
||||
void OnItemPropertyChanged(in nsISupports item, in nsIAtom property, in string oldValue, in string newValue);
|
||||
void OnItemIntPropertyChanged(in nsISupports item, in nsIAtom property, in long oldValue, in long newValue);
|
||||
void OnItemBoolPropertyChanged(in nsISupports item, in nsIAtom property, in boolean oldValue, in boolean newValue);
|
||||
void OnItemUnicharPropertyChanged(in nsISupports item, in nsIAtom property, in wstring oldValue, in wstring newValue);
|
||||
void OnItemPropertyFlagChanged(in nsISupports item, in nsIAtom property, in unsigned long oldFlag,
|
||||
in unsigned long newFlag);
|
||||
void OnFolderLoaded(in nsIFolder aFolder);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
@ -35,6 +35,7 @@
|
||||
#include "nsIFolderListener.idl"
|
||||
#include "nsIMsgWindow.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
#include "nsIAtom.idl"
|
||||
|
||||
interface nsIMsgWindow;
|
||||
|
||||
@ -47,21 +48,25 @@ interface nsIMsgMailSession : nsISupports {
|
||||
void AddFolderListener(in nsIFolderListener listener);
|
||||
void RemoveFolderListener(in nsIFolderListener listener);
|
||||
void NotifyFolderItemPropertyChanged(in nsISupports item,
|
||||
in string property,
|
||||
in nsIAtom property,
|
||||
in string oldValue,
|
||||
in string newValue);
|
||||
void NotifyFolderItemIntPropertyChanged(in nsISupports item,
|
||||
in string property,
|
||||
in nsIAtom property,
|
||||
in long oldValue,
|
||||
in long newValue);
|
||||
void NotifyFolderItemBoolPropertyChanged(in nsISupports item,
|
||||
in string property,
|
||||
in nsIAtom property,
|
||||
in boolean oldValue,
|
||||
in boolean newValue);
|
||||
void NotifyFolderItemPropertyFlagChanged(in nsISupports item,
|
||||
in string property,
|
||||
in nsIAtom property,
|
||||
in unsigned long oldValue,
|
||||
in unsigned long newValue);
|
||||
void NotifyFolderItemUnicharPropertyChanged(in nsISupports item,
|
||||
in nsIAtom property,
|
||||
in wstring oldValue,
|
||||
in wstring newValue);
|
||||
|
||||
void NotifyFolderItemAdded(in nsISupports parentItem, in nsISupports item, in string viewString);
|
||||
void NotifyFolderItemDeleted(in nsISupports parentItem, in nsISupports item, in string viewString);
|
||||
|
@ -86,6 +86,9 @@ nsIRDFResource* nsMsgFolderDataSource::kNC_EmptyTrash= nsnull;
|
||||
|
||||
nsrefcnt nsMsgFolderDataSource::gFolderResourceRefCnt = 0;
|
||||
|
||||
nsIAtom * nsMsgFolderDataSource::kBiffStateAtom = nsnull;
|
||||
nsIAtom * nsMsgFolderDataSource::kTotalMessagesAtom = nsnull;
|
||||
nsIAtom * nsMsgFolderDataSource::kTotalUnreadMessagesAtom = nsnull;
|
||||
|
||||
nsMsgFolderDataSource::nsMsgFolderDataSource():
|
||||
mInitialized(PR_FALSE)
|
||||
@ -135,6 +138,10 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
||||
NS_RELEASE2(kNC_Compact, refcnt);
|
||||
NS_RELEASE2(kNC_Rename, refcnt);
|
||||
NS_RELEASE2(kNC_EmptyTrash, refcnt);
|
||||
|
||||
NS_RELEASE(kTotalMessagesAtom);
|
||||
NS_RELEASE(kTotalUnreadMessagesAtom);
|
||||
NS_RELEASE(kBiffStateAtom);
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,6 +192,10 @@ nsresult nsMsgFolderDataSource::Init()
|
||||
rdf->GetResource(NC_RDF_COMPACT, &kNC_Compact);
|
||||
rdf->GetResource(NC_RDF_RENAME, &kNC_Rename);
|
||||
rdf->GetResource(NC_RDF_EMPTYTRASH, &kNC_EmptyTrash);
|
||||
|
||||
kTotalMessagesAtom = NS_NewAtom("TotalMessages");
|
||||
kTotalUnreadMessagesAtom = NS_NewAtom("TotalUnreadMessages");
|
||||
kBiffStateAtom = NS_NewAtom("BiffState");
|
||||
}
|
||||
CreateLiterals(rdf);
|
||||
rv = CreateArcsOutEnumerator();
|
||||
@ -749,26 +760,32 @@ nsresult nsMsgFolderDataSource::OnItemAddedOrRemoved(nsISupports *parentItem, ns
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolderDataSource::OnItemPropertyChanged(nsISupports *item, const char *property,
|
||||
const char *oldValue, const char *newValue)
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolderDataSource::OnItemPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
const char *oldValue,
|
||||
const char *newValue)
|
||||
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolderDataSource::OnItemIntPropertyChanged(nsISupports *item, const char *property,
|
||||
PRInt32 oldValue, PRInt32 newValue)
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolderDataSource::OnItemIntPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRInt32 oldValue,
|
||||
PRInt32 newValue)
|
||||
{
|
||||
//We only care about folder changes
|
||||
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(item);
|
||||
if(folder)
|
||||
{
|
||||
|
||||
if(PL_strcmp("TotalMessages", property) == 0)
|
||||
if (kTotalMessagesAtom == property)
|
||||
{
|
||||
OnTotalMessagePropertyChanged(folder, oldValue, newValue);
|
||||
}
|
||||
else if(PL_strcmp("TotalUnreadMessages", property) == 0)
|
||||
else if (kTotalUnreadMessagesAtom == property)
|
||||
{
|
||||
OnUnreadMessagePropertyChanged(folder, oldValue, newValue);
|
||||
}
|
||||
@ -777,15 +794,31 @@ NS_IMETHODIMP nsMsgFolderDataSource::OnItemIntPropertyChanged(nsISupports *item,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolderDataSource::OnItemBoolPropertyChanged(nsISupports *item, const char *property,
|
||||
PRBool oldValue, PRBool newValue)
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolderDataSource::OnItemUnicharPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
const PRUnichar *oldValue,
|
||||
const PRUnichar *newValue)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolderDataSource::OnItemBoolPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRBool oldValue,
|
||||
PRBool newValue)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolderDataSource::OnItemPropertyFlagChanged(nsISupports *item, const char *property,
|
||||
PRUint32 oldFlag, PRUint32 newFlag)
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolderDataSource::OnItemPropertyFlagChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRUint32 oldFlag,
|
||||
PRUint32 newFlag)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(item));
|
||||
@ -794,7 +827,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::OnItemPropertyFlagChanged(nsISupports *item
|
||||
nsCOMPtr<nsIRDFResource> resource(do_QueryInterface(item));
|
||||
if(resource)
|
||||
{
|
||||
if(PL_strcmp("BiffState", property) == 0)
|
||||
if (kBiffStateAtom == property)
|
||||
{
|
||||
nsCAutoString newBiffStateStr;
|
||||
|
||||
@ -1226,23 +1259,31 @@ nsMsgFolderDataSource::OnUnreadMessagePropertyChanged(nsIMsgFolder *folder, PRIn
|
||||
}
|
||||
//We will have to change the folderTreeName also
|
||||
|
||||
NotifyFolderTreeNameChanged(folder, newValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgFolderDataSource::NotifyFolderTreeNameChanged(nsIMsgFolder* aFolder,
|
||||
PRInt32 aUnreadMessages)
|
||||
{
|
||||
nsXPIDLString name;
|
||||
nsresult rv = folder->GetAbbreviatedName(getter_Copies(name));
|
||||
nsresult rv = aFolder->GetAbbreviatedName(getter_Copies(name));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsAutoString newNameString(name);
|
||||
|
||||
CreateUnreadMessagesNameString(newValue, newNameString);
|
||||
CreateUnreadMessagesNameString(aUnreadMessages, newNameString);
|
||||
|
||||
nsCOMPtr<nsIRDFNode> newNameNode;
|
||||
createNode(newNameString, getter_AddRefs(newNameNode), getRDFService());
|
||||
|
||||
nsCOMPtr<nsIRDFResource> folderResource =
|
||||
do_QueryInterface(aFolder);
|
||||
NotifyPropertyChanged(folderResource, kNC_FolderTreeName, newNameNode);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,6 +170,8 @@ protected:
|
||||
|
||||
nsresult OnUnreadMessagePropertyChanged(nsIMsgFolder *folder, PRInt32 oldValue, PRInt32 newValue);
|
||||
nsresult OnTotalMessagePropertyChanged(nsIMsgFolder *folder, PRInt32 oldValue, PRInt32 newValue);
|
||||
nsresult NotifyFolderTreeNameChanged(nsIMsgFolder *folder, PRInt32 aUnreadMessages);
|
||||
|
||||
nsresult GetNumMessagesNode(PRInt32 numMessages, nsIRDFNode **node);
|
||||
|
||||
nsresult CreateLiterals(nsIRDFService *rdf);
|
||||
@ -212,6 +214,11 @@ protected:
|
||||
nsCOMPtr<nsIRDFNode> kTrueLiteral;
|
||||
nsCOMPtr<nsIRDFNode> kFalseLiteral;
|
||||
|
||||
// property atoms
|
||||
static nsIAtom* kTotalMessagesAtom;
|
||||
static nsIAtom* kTotalUnreadMessagesAtom;
|
||||
static nsIAtom* kBiffStateAtom;
|
||||
|
||||
static nsrefcnt gFolderResourceRefCnt;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> kFolderArcsOutArray;
|
||||
|
@ -98,7 +98,7 @@ NS_IMETHODIMP nsMsgMailSession::RemoveFolderListener(nsIFolderListener * listene
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgMailSession::NotifyFolderItemPropertyChanged(nsISupports *item,
|
||||
const char *property,
|
||||
nsIAtom *property,
|
||||
const char* oldValue,
|
||||
const char* newValue)
|
||||
{
|
||||
@ -118,11 +118,33 @@ nsMsgMailSession::NotifyFolderItemPropertyChanged(nsISupports *item,
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgMailSession::NotifyFolderItemUnicharPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
const PRUnichar* oldValue,
|
||||
const PRUnichar* newValue)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 count;
|
||||
rv = mListeners->Count(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
for(PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
|
||||
listener->OnItemUnicharPropertyChanged(item, property, oldValue, newValue);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgMailSession::NotifyFolderItemIntPropertyChanged(nsISupports *item,
|
||||
const char *property,
|
||||
PRInt32 oldValue,
|
||||
PRInt32 newValue)
|
||||
nsIAtom *property,
|
||||
PRInt32 oldValue,
|
||||
PRInt32 newValue)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 count;
|
||||
@ -142,9 +164,9 @@ nsMsgMailSession::NotifyFolderItemIntPropertyChanged(nsISupports *item,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgMailSession::NotifyFolderItemBoolPropertyChanged(nsISupports *item,
|
||||
const char *property,
|
||||
PRBool oldValue,
|
||||
PRBool newValue)
|
||||
nsIAtom *property,
|
||||
PRBool oldValue,
|
||||
PRBool newValue)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 count;
|
||||
@ -163,7 +185,7 @@ nsMsgMailSession::NotifyFolderItemBoolPropertyChanged(nsISupports *item,
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsMsgMailSession::NotifyFolderItemPropertyFlagChanged(nsISupports *item,
|
||||
const char *property,
|
||||
nsIAtom *property,
|
||||
PRUint32 oldValue,
|
||||
PRUint32 newValue)
|
||||
{
|
||||
|
@ -73,6 +73,10 @@ nsIRDFResource* nsMsgMessageDataSource::kNC_MarkUnflagged= nsnull;
|
||||
|
||||
nsrefcnt nsMsgMessageDataSource::gMessageResourceRefCnt = 0;
|
||||
|
||||
nsIAtom * nsMsgMessageDataSource::kFlaggedAtom = nsnull;
|
||||
nsIAtom * nsMsgMessageDataSource::kStatusAtom = nsnull;
|
||||
|
||||
|
||||
|
||||
nsMsgMessageDataSource::nsMsgMessageDataSource():
|
||||
mInitialized(PR_FALSE),
|
||||
@ -115,6 +119,9 @@ nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
||||
NS_RELEASE2(kNC_ToggleRead, refcnt);
|
||||
NS_RELEASE2(kNC_MarkFlagged, refcnt);
|
||||
NS_RELEASE2(kNC_MarkUnflagged, refcnt);
|
||||
|
||||
NS_RELEASE(kStatusAtom);
|
||||
NS_RELEASE(kFlaggedAtom);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mHeaderParser);
|
||||
@ -164,7 +171,9 @@ nsresult nsMsgMessageDataSource::Init()
|
||||
rdf->GetResource(NC_RDF_TOGGLEREAD, &kNC_ToggleRead);
|
||||
rdf->GetResource(NC_RDF_MARKFLAGGED, &kNC_MarkFlagged);
|
||||
rdf->GetResource(NC_RDF_MARKUNFLAGGED, &kNC_MarkUnflagged);
|
||||
|
||||
|
||||
kStatusAtom = NS_NewAtom("Status");
|
||||
kFlaggedAtom = NS_NewAtom("Flagged");
|
||||
}
|
||||
|
||||
CreateLiterals(rdf);
|
||||
@ -635,41 +644,62 @@ nsresult nsMsgMessageDataSource::OnItemAddedOrRemoved(nsISupports *parentItem, n
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMessageDataSource::OnItemPropertyChanged(nsISupports *item, const char *property,
|
||||
const char *oldValue, const char *newValue)
|
||||
NS_IMETHODIMP
|
||||
nsMsgMessageDataSource::OnItemPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
const char *oldValue,
|
||||
const char *newValue)
|
||||
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMessageDataSource::OnItemIntPropertyChanged(nsISupports *item, const char *property,
|
||||
PRInt32 oldValue, PRInt32 newValue)
|
||||
NS_IMETHODIMP
|
||||
nsMsgMessageDataSource::OnItemUnicharPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
const PRUnichar *oldValue,
|
||||
const PRUnichar *newValue)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMessageDataSource::OnItemBoolPropertyChanged(nsISupports *item, const char *property,
|
||||
PRBool oldValue, PRBool newValue)
|
||||
NS_IMETHODIMP
|
||||
nsMsgMessageDataSource::OnItemIntPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRInt32 oldValue,
|
||||
PRInt32 newValue)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgMessageDataSource::OnItemPropertyFlagChanged(nsISupports *item, const char *property,
|
||||
PRUint32 oldFlag, PRUint32 newFlag)
|
||||
NS_IMETHODIMP
|
||||
nsMsgMessageDataSource::OnItemBoolPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRBool oldValue,
|
||||
PRBool newValue)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgMessageDataSource::OnItemPropertyFlagChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRUint32 oldFlag,
|
||||
PRUint32 newFlag)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFResource> resource(do_QueryInterface(item, &rv));
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
if(PL_strcmp("Status", property) == 0)
|
||||
if (kStatusAtom == property)
|
||||
{
|
||||
OnChangeStatus(resource, oldFlag, newFlag);
|
||||
}
|
||||
else if(PL_strcmp("Flagged", property) == 0)
|
||||
else if(kFlaggedAtom == property)
|
||||
{
|
||||
nsCAutoString newFlaggedStr;
|
||||
rv = createFlaggedStringFromFlag(newFlag, newFlaggedStr);
|
||||
|
@ -215,6 +215,10 @@ protected:
|
||||
nsCOMPtr<nsIRDFNode> kTrueLiteral;
|
||||
nsCOMPtr<nsIRDFNode> kFalseLiteral;
|
||||
|
||||
// message properties
|
||||
static nsIAtom *kStatusAtom;
|
||||
static nsIAtom *kFlaggedAtom;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> kThreadsArcsOutArray;
|
||||
nsCOMPtr<nsISupportsArray> kNoThreadsArcsOutArray;
|
||||
|
||||
|
@ -46,6 +46,8 @@ nsIRDFResource* nsMsgNotificationManager::kNC_Child = nsnull;
|
||||
|
||||
nsIRDFResource* nsMsgNotificationManager::kNC_NewMessages = nsnull;
|
||||
|
||||
nsIAtom * nsMsgNotificationManager::kBiffStateAtom = nsnull;
|
||||
nsIAtom * nsMsgNotificationManager::kNumNewBiffMessagesAtom = nsnull;
|
||||
|
||||
#define NC_RDF_FLASHROOT "NC:FlashRoot"
|
||||
#define NC_RDF_TYPE "http://home.netscape.com/NC-rdf#type"
|
||||
@ -76,6 +78,9 @@ nsMsgNotificationManager::~nsMsgNotificationManager()
|
||||
NS_IF_RELEASE(kNC_Child);
|
||||
NS_IF_RELEASE(kNC_NewMessages);
|
||||
|
||||
NS_IF_RELEASE(kNumNewBiffMessagesAtom);
|
||||
NS_IF_RELEASE(kBiffStateAtom);
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsMsgNotificationManager)
|
||||
@ -143,6 +148,9 @@ nsresult nsMsgNotificationManager::Init()
|
||||
rdfService->GetResource(NC_RDF_URL, &kNC_URL);
|
||||
rdfService->GetResource(NC_RDF_CHILD, &kNC_Child);
|
||||
rdfService->GetResource(NC_RDF_NEWMESSAGES, &kNC_NewMessages);
|
||||
|
||||
kNumNewBiffMessagesAtom = NS_NewAtom("NumNewBiffMessages");
|
||||
kBiffStateAtom = NS_NewAtom("BiffState");
|
||||
}
|
||||
return rv;
|
||||
|
||||
@ -158,14 +166,18 @@ NS_IMETHODIMP nsMsgNotificationManager::OnItemRemoved(nsISupports *parentItem, n
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNotificationManager::OnItemPropertyChanged(nsISupports *item, const char *property, const char *oldValue, const char *newValue)
|
||||
NS_IMETHODIMP
|
||||
nsMsgNotificationManager::OnItemPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
const char *oldValue,
|
||||
const char *newValue)
|
||||
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(item));
|
||||
if(folder)
|
||||
{
|
||||
if(PL_strcmp("NumNewBiffMessages", property) == 0)
|
||||
if(kNumNewBiffMessagesAtom == property)
|
||||
{
|
||||
PRUint32 biffState;
|
||||
rv = folder->GetBiffState(&biffState);
|
||||
@ -178,28 +190,49 @@ NS_IMETHODIMP nsMsgNotificationManager::OnItemPropertyChanged(nsISupports *item,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNotificationManager::OnItemIntPropertyChanged(nsISupports *item, const char *property,
|
||||
PRInt32 oldValue, PRInt32 newValue)
|
||||
NS_IMETHODIMP
|
||||
nsMsgNotificationManager::OnItemUnicharPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
const PRUnichar* oldValue,
|
||||
const PRUnichar* newValue)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNotificationManager::OnItemBoolPropertyChanged(nsISupports *item, const char *property,
|
||||
PRBool oldValue, PRBool newValue)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgNotificationManager::OnItemIntPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRInt32 oldValue,
|
||||
PRInt32 newValue)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNotificationManager::OnItemPropertyFlagChanged(nsISupports *item, const char *property, PRUint32 oldFlag, PRUint32 newFlag)
|
||||
NS_IMETHODIMP
|
||||
nsMsgNotificationManager::OnItemBoolPropertyChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRBool oldValue,
|
||||
PRBool newValue)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgNotificationManager::OnItemPropertyFlagChanged(nsISupports *item,
|
||||
nsIAtom *property,
|
||||
PRUint32 oldFlag,
|
||||
PRUint32 newFlag)
|
||||
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(item));
|
||||
if(folder)
|
||||
{
|
||||
if(PL_strcmp("BiffState", property) == 0)
|
||||
if(kBiffStateAtom == property)
|
||||
{
|
||||
if(newFlag == nsMsgBiffState_NewMail)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
@ -59,6 +59,8 @@ protected:
|
||||
static nsIRDFResource* kNC_Child;
|
||||
static nsIRDFResource* kNC_NewMessages;
|
||||
|
||||
static nsIAtom* kNumNewBiffMessagesAtom;
|
||||
static nsIAtom* kBiffStateAtom;
|
||||
};
|
||||
|
||||
|
||||
|
@ -324,11 +324,11 @@ nsresult nsMsgDBFolder::SendFlagNotifications(nsISupports *item, PRUint32 oldFla
|
||||
if((changedFlags & MSG_FLAG_READ) || (changedFlags & MSG_FLAG_REPLIED)
|
||||
|| (changedFlags & MSG_FLAG_FORWARDED)|| (changedFlags & MSG_FLAG_NEW))
|
||||
{
|
||||
rv = NotifyPropertyFlagChanged(item, "Status", oldFlags, newFlags);
|
||||
rv = NotifyPropertyFlagChanged(item, kStatusAtom, oldFlags, newFlags);
|
||||
}
|
||||
else if((changedFlags & MSG_FLAG_MARKED))
|
||||
{
|
||||
rv = NotifyPropertyFlagChanged(item, "Flagged", oldFlags, newFlags);
|
||||
rv = NotifyPropertyFlagChanged(item, kFlaggedAtom, oldFlags, newFlags);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -47,6 +47,15 @@ static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
|
||||
PRInt32 nsMsgFolder::gInstanceCount = 0;
|
||||
|
||||
nsIAtom * nsMsgFolder::kTotalMessagesAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kPrettyNameAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kNumNewBiffMessagesAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kBiffStateAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kTotalUnreadMessagesAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kFlaggedAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kStatusAtom = nsnull;
|
||||
|
||||
|
||||
nsMsgFolder::nsMsgFolder(void)
|
||||
@ -78,6 +87,19 @@ nsMsgFolder::nsMsgFolder(void)
|
||||
|
||||
mPath = null_nsCOMPtr();
|
||||
m_server = nsnull;
|
||||
|
||||
if (gInstanceCount == 0) {
|
||||
kBiffStateAtom = NS_NewAtom("BiffState");
|
||||
kNumNewBiffMessagesAtom = NS_NewAtom("NumNewBiffMessages");
|
||||
kPrettyNameAtom = NS_NewAtom("PrettyName");
|
||||
kTotalUnreadMessagesAtom = NS_NewAtom("TotalUnreadMessages");
|
||||
kTotalMessagesAtom = NS_NewAtom("TotalMessages");
|
||||
kStatusAtom = NS_NewAtom("Status");
|
||||
kFlaggedAtom = NS_NewAtom("Flagged");
|
||||
|
||||
}
|
||||
|
||||
gInstanceCount++;
|
||||
}
|
||||
|
||||
nsMsgFolder::~nsMsgFolder(void)
|
||||
@ -94,6 +116,12 @@ nsMsgFolder::~nsMsgFolder(void)
|
||||
|
||||
delete mListeners;
|
||||
|
||||
gInstanceCount--;
|
||||
if (gInstanceCount <= 0) {
|
||||
NS_IF_RELEASE(kBiffStateAtom);
|
||||
NS_IF_RELEASE(kNumNewBiffMessagesAtom);
|
||||
NS_IF_RELEASE(kPrettyNameAtom);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsMsgFolder, nsRDFResource)
|
||||
@ -666,6 +694,8 @@ NS_IMETHODIMP nsMsgFolder::GetPrettyName(PRUnichar ** name)
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::SetPrettyName(const PRUnichar *name)
|
||||
{
|
||||
|
||||
NotifyUnicharPropertyChanged(kPrettyNameAtom, mName.GetUnicode(), name);
|
||||
mName = name;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1201,7 +1231,7 @@ void nsMsgFolder::ChangeNumPendingUnread(PRInt32 delta)
|
||||
mNumPendingUnreadMessages += delta;
|
||||
PRInt32 newUnreadMessages = mNumUnreadMessages + mNumPendingUnreadMessages;
|
||||
|
||||
NotifyIntPropertyChanged("TotalUnreadMessages", oldUnreadMessages, newUnreadMessages);
|
||||
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, newUnreadMessages);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1213,7 +1243,7 @@ void nsMsgFolder::ChangeNumPendingTotalMessages(PRInt32 delta)
|
||||
mNumPendingTotalMessages += delta;
|
||||
PRInt32 newTotalMessages = mNumTotalMessages + mNumPendingTotalMessages;
|
||||
|
||||
NotifyIntPropertyChanged("TotalMessages", oldTotalMessages, newTotalMessages);
|
||||
NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, newTotalMessages);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1668,7 +1698,7 @@ NS_IMETHODIMP nsMsgFolder::SetBiffState(PRUint32 aBiffState)
|
||||
mBiffState = aBiffState;
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
if(NS_SUCCEEDED(QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), getter_AddRefs(supports))))
|
||||
NotifyPropertyFlagChanged(supports, "BiffState", oldBiffState, mBiffState);
|
||||
NotifyPropertyFlagChanged(supports, kBiffStateAtom, oldBiffState, mBiffState);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1689,11 +1719,11 @@ NS_IMETHODIMP nsMsgFolder::SetNumNewMessages(PRInt32 aNumNewMessages)
|
||||
PRInt32 oldNumMessages = mNumNewBiffMessages;
|
||||
mNumNewBiffMessages = aNumNewMessages;
|
||||
|
||||
char *oldNumMessagesStr = PR_smprintf("%d", oldNumMessages);
|
||||
char *newNumMessagesStr = PR_smprintf("%d",aNumNewMessages);
|
||||
NotifyPropertyChanged("NumNewBiffMessages", oldNumMessagesStr, newNumMessagesStr);
|
||||
PR_smprintf_free(oldNumMessagesStr);
|
||||
PR_smprintf_free(newNumMessagesStr);
|
||||
nsCAutoString oldNumMessagesStr;
|
||||
oldNumMessagesStr.Append(oldNumMessages);
|
||||
nsCAutoString newNumMessagesStr;
|
||||
newNumMessagesStr.Append(aNumNewMessages);
|
||||
NotifyPropertyChanged(kNumNewBiffMessagesAtom, oldNumMessagesStr, newNumMessagesStr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -1866,7 +1896,9 @@ NS_IMETHODIMP nsMsgFolder::MatchName(nsString *name, PRBool *matches)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgFolder::NotifyPropertyChanged(char *property, char *oldValue, char* newValue)
|
||||
nsresult
|
||||
nsMsgFolder::NotifyPropertyChanged(nsIAtom *property,
|
||||
char *oldValue, char* newValue)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
if(NS_SUCCEEDED(QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), getter_AddRefs(supports))))
|
||||
@ -1891,7 +1923,35 @@ nsresult nsMsgFolder::NotifyPropertyChanged(char *property, char *oldValue, char
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMsgFolder::NotifyIntPropertyChanged(char *property, PRInt32 oldValue, PRInt32 newValue)
|
||||
nsresult
|
||||
nsMsgFolder::NotifyUnicharPropertyChanged(nsIAtom *property,
|
||||
const PRUnichar* oldValue,
|
||||
const PRUnichar *newValue)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = QueryInterface(NS_GET_IID(nsISupports),
|
||||
(void **)getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 i;
|
||||
for (i=0; i<mListeners->Count(); i++) {
|
||||
// folderlisteners arent refcounted in the array
|
||||
nsIFolderListener* listener=(nsIFolderListener*)mListeners->ElementAt(i);
|
||||
listener->OnItemUnicharPropertyChanged(supports, property, oldValue, newValue);
|
||||
}
|
||||
|
||||
// Notify listeners who listen to every folder
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = mailSession->NotifyFolderItemUnicharPropertyChanged(supports,
|
||||
property,
|
||||
oldValue,
|
||||
newValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgFolder::NotifyIntPropertyChanged(nsIAtom *property, PRInt32 oldValue, PRInt32 newValue)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
if(NS_SUCCEEDED(QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), getter_AddRefs(supports))))
|
||||
@ -1916,7 +1976,9 @@ nsresult nsMsgFolder::NotifyIntPropertyChanged(char *property, PRInt32 oldValue,
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMsgFolder::NotifyBoolPropertyChanged(char *property, PRBool oldValue, PRBool newValue)
|
||||
nsresult
|
||||
nsMsgFolder::NotifyBoolPropertyChanged(nsIAtom* property,
|
||||
PRBool oldValue, PRBool newValue)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
if(NS_SUCCEEDED(QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), getter_AddRefs(supports))))
|
||||
@ -1941,8 +2003,9 @@ nsresult nsMsgFolder::NotifyBoolPropertyChanged(char *property, PRBool oldValue,
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMsgFolder::NotifyPropertyFlagChanged(nsISupports *item, char *property, PRUint32 oldValue,
|
||||
PRUint32 newValue)
|
||||
nsresult
|
||||
nsMsgFolder::NotifyPropertyFlagChanged(nsISupports *item, nsIAtom *property,
|
||||
PRUint32 oldValue, PRUint32 newValue)
|
||||
{
|
||||
PRInt32 i;
|
||||
for(i = 0; i < mListeners->Count(); i++)
|
||||
@ -2027,14 +2090,7 @@ nsresult nsMsgFolder::NotifyFolderLoaded()
|
||||
nsresult
|
||||
nsGetMailFolderSeparator(nsString& result)
|
||||
{
|
||||
static char* gMailFolderSep = nsnull; // never freed
|
||||
|
||||
if (gMailFolderSep == nsnull) {
|
||||
gMailFolderSep = PR_smprintf(".sbd");
|
||||
if (gMailFolderSep == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
result = gMailFolderSep;
|
||||
result = ".sbd";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -155,9 +155,6 @@ public:
|
||||
// nsRDFResource overrides
|
||||
NS_IMETHOD Init(const char* aURI);
|
||||
|
||||
#if 0
|
||||
static nsresult GetRoot(nsIMsgFolder* *result);
|
||||
#endif
|
||||
// Gets the URL that represents the given message. Returns a newly
|
||||
// created string that must be free'd using XP_FREE().
|
||||
// If the db is NULL, then returns a URL that represents the entire
|
||||
@ -217,10 +214,13 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
nsresult NotifyPropertyChanged(char *property, char* oldValue, char* newValue);
|
||||
nsresult NotifyIntPropertyChanged(char *property, PRInt32 oldValue, PRInt32 newValue);
|
||||
nsresult NotifyBoolPropertyChanged(char *property, PRBool oldValue, PRBool newValue);
|
||||
nsresult NotifyPropertyFlagChanged(nsISupports *item, char *property, PRUint32 oldValue,
|
||||
nsresult NotifyPropertyChanged(nsIAtom *property, char* oldValue, char* newValue);
|
||||
nsresult NotifyIntPropertyChanged(nsIAtom *property, PRInt32 oldValue, PRInt32 newValue);
|
||||
nsresult NotifyBoolPropertyChanged(nsIAtom *property, PRBool oldValue, PRBool newValue);
|
||||
nsresult NotifyUnicharPropertyChanged(nsIAtom *property, const PRUnichar* oldValue, const PRUnichar* newValue);
|
||||
|
||||
|
||||
nsresult NotifyPropertyFlagChanged(nsISupports *item, nsIAtom *property, PRUint32 oldValue,
|
||||
PRUint32 newValue);
|
||||
nsresult NotifyItemAdded(nsISupports *parentItem, nsISupports *item, const char *viewString);
|
||||
nsresult NotifyItemDeleted(nsISupports *parentItem, nsISupports *item, const char* viewString);
|
||||
@ -274,6 +274,18 @@ protected:
|
||||
PRBool mIsServer;
|
||||
nsString mName;
|
||||
nsCOMPtr<nsIFileSpec> mPath;
|
||||
|
||||
// static stuff for cross-instance objects like atoms
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
static nsIAtom* kBiffStateAtom;
|
||||
static nsIAtom* kNumNewBiffMessagesAtom;
|
||||
static nsIAtom* kPrettyNameAtom;
|
||||
static nsIAtom* kTotalUnreadMessagesAtom;
|
||||
static nsIAtom* kTotalMessagesAtom;
|
||||
static nsIAtom* kStatusAtom;
|
||||
static nsIAtom* kFlaggedAtom;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -494,8 +494,17 @@ nsMsgIncomingServer::GetPrettyName(PRUnichar **retval) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgIncomingServer::SetPrettyName(const PRUnichar *value) {
|
||||
return SetUnicharValue("name", value);
|
||||
nsMsgIncomingServer::SetPrettyName(const PRUnichar *value)
|
||||
{
|
||||
SetUnicharValue("name", value);
|
||||
|
||||
nsCOMPtr<nsIFolder> rootFolder;
|
||||
GetRootFolder(getter_AddRefs(rootFolder));
|
||||
|
||||
if (rootFolder)
|
||||
rootFolder->SetPrettyName(value);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -860,12 +860,12 @@ NS_IMETHODIMP nsImapMailFolder::UpdateSummaryTotals(PRBool force)
|
||||
//Need to notify listeners that total count changed.
|
||||
if(oldTotalMessages != newTotalMessages)
|
||||
{
|
||||
NotifyIntPropertyChanged("TotalMessages", oldTotalMessages, newTotalMessages);
|
||||
NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, newTotalMessages);
|
||||
}
|
||||
|
||||
if(oldUnreadMessages != newUnreadMessages)
|
||||
{
|
||||
NotifyIntPropertyChanged("TotalUnreadMessages", oldUnreadMessages, newUnreadMessages);
|
||||
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, newUnreadMessages);
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -2448,7 +2448,7 @@ nsImapMailFolder::OnlineCopyCompleted(nsIImapProtocol *aProtocol, ImapOnlineCopy
|
||||
if (action == nsIImapUrl::nsImapOnlineToOfflineMove)
|
||||
{
|
||||
nsCString messageIds;
|
||||
nsresult rv = imapUrl->CreateListOfMessageIdsString(&messageIds);
|
||||
rv = imapUrl->CreateListOfMessageIdsString(&messageIds);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIEventQueue> queue;
|
||||
|
@ -903,12 +903,12 @@ NS_IMETHODIMP nsMsgLocalMailFolder::UpdateSummaryTotals(PRBool force)
|
||||
//Need to notify listeners that total count changed.
|
||||
if(oldTotalMessages != mNumTotalMessages)
|
||||
{
|
||||
NotifyIntPropertyChanged("TotalMessages", oldTotalMessages, mNumTotalMessages);
|
||||
NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, mNumTotalMessages);
|
||||
}
|
||||
|
||||
if(oldUnreadMessages != mNumUnreadMessages)
|
||||
{
|
||||
NotifyIntPropertyChanged("TotalUnreadMessages", oldUnreadMessages, mNumUnreadMessages);
|
||||
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, mNumUnreadMessages);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -721,12 +721,12 @@ NS_IMETHODIMP nsMsgNewsFolder::UpdateSummaryTotals(PRBool force)
|
||||
//Need to notify listeners that total count changed.
|
||||
if(oldTotalMessages != mNumTotalMessages)
|
||||
{
|
||||
NotifyIntPropertyChanged("TotalMessages", oldTotalMessages, mNumTotalMessages);
|
||||
NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, mNumTotalMessages);
|
||||
}
|
||||
|
||||
if(oldUnreadMessages != mNumUnreadMessages)
|
||||
{
|
||||
NotifyIntPropertyChanged("TotalUnreadMessages", oldUnreadMessages, mNumUnreadMessages);
|
||||
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, mNumUnreadMessages);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user