From 6d0429b17c091dfca2bb3869cbfab219b76f8a7b Mon Sep 17 00:00:00 2001 From: "bienvenu%netscape.com" Date: Thu, 13 May 1999 23:16:39 +0000 Subject: [PATCH] add old flags to key change notification, use PRUint32 exclusively --- mailnews/db/msgdb/public/nsIDBChangeListener.h | 2 +- mailnews/db/msgdb/public/nsIMsgDatabase.h | 2 +- mailnews/db/msgdb/public/nsMsgDatabase.h | 4 ++-- mailnews/db/msgdb/src/nsMsgDatabase.cpp | 17 +++++++++++------ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mailnews/db/msgdb/public/nsIDBChangeListener.h b/mailnews/db/msgdb/public/nsIDBChangeListener.h index 77979721e049..c96175ad8724 100644 --- a/mailnews/db/msgdb/public/nsIDBChangeListener.h +++ b/mailnews/db/msgdb/public/nsIDBChangeListener.h @@ -12,7 +12,7 @@ class nsIDBChangeListener : public nsISupports public: static const nsIID& IID(void) { static nsIID iid = NS_IDBCHANGELISTENER_IID; return iid; } - NS_IMETHOD OnKeyChange(nsMsgKey aKeyChanged, PRInt32 aFlags, + NS_IMETHOD OnKeyChange(nsMsgKey aKeyChanged, PRUint32 aOldFlags, PRUint32 aNewFlags, nsIDBChangeListener * aInstigator) = 0; NS_IMETHOD OnKeyDeleted(nsMsgKey aKeyChanged, PRInt32 aFlags, nsIDBChangeListener * aInstigator) = 0; diff --git a/mailnews/db/msgdb/public/nsIMsgDatabase.h b/mailnews/db/msgdb/public/nsIMsgDatabase.h index 30af2ff90e20..b0d34751921f 100644 --- a/mailnews/db/msgdb/public/nsIMsgDatabase.h +++ b/mailnews/db/msgdb/public/nsIMsgDatabase.h @@ -60,7 +60,7 @@ public: NS_IMETHOD AddListener(nsIDBChangeListener *listener) = 0; NS_IMETHOD RemoveListener(nsIDBChangeListener *listener) = 0; - NS_IMETHOD NotifyKeyChangeAll(nsMsgKey keyChanged, PRInt32 flags, + NS_IMETHOD NotifyKeyChangeAll(nsMsgKey keyChanged, PRUint32 aOldFlags, PRUint32 aNewFlags, nsIDBChangeListener *instigator) = 0; NS_IMETHOD NotifyKeyAddedAll(nsMsgKey keyAdded, PRInt32 flags, nsIDBChangeListener *instigator) = 0; diff --git a/mailnews/db/msgdb/public/nsMsgDatabase.h b/mailnews/db/msgdb/public/nsMsgDatabase.h index 012bc1f82a69..d24caffcdf59 100644 --- a/mailnews/db/msgdb/public/nsMsgDatabase.h +++ b/mailnews/db/msgdb/public/nsMsgDatabase.h @@ -47,7 +47,7 @@ public: NS_IMETHOD AddListener(nsIDBChangeListener *listener); NS_IMETHOD RemoveListener(nsIDBChangeListener *listener); - NS_IMETHOD NotifyKeyChangeAll(nsMsgKey keyChanged, PRInt32 flags, + NS_IMETHOD NotifyKeyChangeAll(nsMsgKey keyChanged, PRUint32 aOldFlags, PRUint32 aNewFlags, nsIDBChangeListener *instigator); NS_IMETHOD NotifyKeyAddedAll(nsMsgKey keyAdded, PRInt32 flags, nsIDBChangeListener *instigator); @@ -263,7 +263,7 @@ protected: #endif // Flag handling routines - virtual nsresult SetKeyFlag(nsMsgKey key, PRBool set, PRInt32 flag, + virtual nsresult SetKeyFlag(nsMsgKey key, PRBool set, PRUint32 flag, nsIDBChangeListener *instigator = NULL); virtual PRBool SetHdrFlag(nsIMsgDBHdr *, PRBool bSet, MsgFlags flag); virtual PRUint32 GetStatusFlags(nsIMsgDBHdr *msgHdr); diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index e8f792f1e0ef..eb161217c2e1 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -115,7 +115,7 @@ NS_IMETHODIMP nsMsgDatabase::RemoveListener(nsIDBChangeListener *listener) } // change announcer methods - just broadcast to all listeners. -NS_IMETHODIMP nsMsgDatabase::NotifyKeyChangeAll(nsMsgKey keyChanged, PRInt32 flags, +NS_IMETHODIMP nsMsgDatabase::NotifyKeyChangeAll(nsMsgKey keyChanged, PRUint32 oldFlags, PRUint32 newFlags, nsIDBChangeListener *instigator) { if (m_ChangeListeners == nsnull) @@ -125,7 +125,7 @@ NS_IMETHODIMP nsMsgDatabase::NotifyKeyChangeAll(nsMsgKey keyChanged, PRInt32 fla nsIDBChangeListener *changeListener = (nsIDBChangeListener *) m_ChangeListeners->ElementAt(i); - nsresult rv = changeListener->OnKeyChange(keyChanged, flags, instigator); + nsresult rv = changeListener->OnKeyChange(keyChanged, oldFlags, newFlags, instigator); if (NS_FAILED(rv)) return rv; } @@ -1077,7 +1077,9 @@ NS_IMETHODIMP nsMsgDatabase::MarkHdrReadInDB(nsIMsgDBHdr *msgHdr, PRBool bRead, nsIDBChangeListener *instigator) { nsMsgKey key; + PRUint32 oldFlags; (void)msgHdr->GetMessageKey(&key); + msgHdr->GetFlags(&oldFlags); SetHdrFlag(msgHdr, bRead, MSG_FLAG_READ); if (m_newSet) m_newSet->Remove(key); @@ -1091,7 +1093,7 @@ NS_IMETHODIMP nsMsgDatabase::MarkHdrReadInDB(nsIMsgDBHdr *msgHdr, PRBool bRead, PRUint32 flags; (void)msgHdr->GetFlags(&flags); - return NotifyKeyChangeAll(key, flags, instigator); + return NotifyKeyChangeAll(key, oldFlags, flags, instigator); } NS_IMETHODIMP nsMsgDatabase::MarkRead(nsMsgKey key, PRBool bRead, @@ -1212,7 +1214,7 @@ nsresult nsMsgDatabase::IsMDNSent(nsMsgKey key, PRBool *pSent) } -nsresult nsMsgDatabase::SetKeyFlag(nsMsgKey key, PRBool set, PRInt32 flag, +nsresult nsMsgDatabase::SetKeyFlag(nsMsgKey key, PRBool set, PRUint32 flag, nsIDBChangeListener *instigator) { nsresult rv; @@ -1222,11 +1224,14 @@ nsresult nsMsgDatabase::SetKeyFlag(nsMsgKey key, PRBool set, PRInt32 flag, if (NS_FAILED(rv) || !msgHdr) return NS_MSG_MESSAGE_NOT_FOUND; // XXX return rv? + PRUint32 oldFlags; + msgHdr->GetFlags(&oldFlags); + SetHdrFlag(msgHdr, set, flag); PRUint32 flags; (void)msgHdr->GetFlags(&flags); - NotifyKeyChangeAll(key, flags, instigator); + NotifyKeyChangeAll(key, oldFlags, flags, instigator); NS_RELEASE(msgHdr); return rv; @@ -1398,7 +1403,7 @@ NS_IMETHODIMP nsMsgDatabase::ClearNewList(PRBool notify /* = FALSE */) (void)msgHdr->GetMessageKey(&key); PRUint32 flags; (void)msgHdr->GetFlags(&flags); - NotifyKeyChangeAll(key, flags, NULL); + NotifyKeyChangeAll(key, flags | MSG_FLAG_NEW, flags, NULL); NS_RELEASE(msgHdr); } }