From 8463f73305b10464990e1386d3137cd920203335 Mon Sep 17 00:00:00 2001 From: "putterman%netscape.com" Date: Fri, 1 Sep 2000 03:26:52 +0000 Subject: [PATCH] Work on 49212 and 17470. Add start/stop notifications for perf improvement for Mark All Read and Delete large number of messages. r=bienvenu. --- mailnews/base/public/nsIMsgFolder.idl | 9 +++++++++ mailnews/base/util/nsMsgFolder.cpp | 22 +++++++++++++++++++++- mailnews/base/util/nsMsgFolder.h | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/mailnews/base/public/nsIMsgFolder.idl b/mailnews/base/public/nsIMsgFolder.idl index 3366bbdd6db1..adbcfff1b66d 100644 --- a/mailnews/base/public/nsIMsgFolder.idl +++ b/mailnews/base/public/nsIMsgFolder.idl @@ -330,4 +330,13 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne nsIMsgDatabase getDBFolderInfoAndDB(out nsIDBFolderInfo folderInfo); nsIMsgFolder getChildWithURI(in string uri, in boolean deep); + + /** + * Turn notifications on/off for various notification types. Currently only supporting + * allMessageCountNotifications which refers to both total and unread message counts. + */ + const unsigned long allMessageCountNotifications = 0; + + void enableNotifications(in long notificationType, in boolean enable); + }; diff --git a/mailnews/base/util/nsMsgFolder.cpp b/mailnews/base/util/nsMsgFolder.cpp index 4ec0b69cbda9..8b3f0e1a22f7 100644 --- a/mailnews/base/util/nsMsgFolder.cpp +++ b/mailnews/base/util/nsMsgFolder.cpp @@ -94,7 +94,8 @@ nsMsgFolder::nsMsgFolder(void) mIsServerIsValid(PR_FALSE), mIsServer(PR_FALSE), mDeleteIsMoveToTrash(PR_TRUE), - mBaseMessageURI(nsnull) + mBaseMessageURI(nsnull), + mNotifyCountChanges(PR_TRUE) { // NS_INIT_REFCNT(); done by superclass @@ -2213,6 +2214,10 @@ nsMsgFolder::NotifyUnicharPropertyChanged(nsIAtom *property, nsresult nsMsgFolder::NotifyIntPropertyChanged(nsIAtom *property, PRInt32 oldValue, PRInt32 newValue) { + //Don't send off count notifications if they are turned off. + if(!mNotifyCountChanges && ((property == kTotalMessagesAtom) ||( property == kTotalUnreadMessagesAtom))) + return NS_OK; + nsCOMPtr supports; if(NS_SUCCEEDED(QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(supports)))) { @@ -2400,3 +2405,18 @@ nsMsgFolder::GetFilterList(nsIMsgFilterList **aResult) return server->GetFilterList(aResult); } + +/* void enableNotifications (in long notificationType, in boolean enable); */ +NS_IMETHODIMP nsMsgFolder::EnableNotifications(PRInt32 notificationType, PRBool enable) +{ + if(notificationType == nsIMsgFolder::allMessageCountNotifications) + { + mNotifyCountChanges = enable; + if(enable) + UpdateSummaryTotals(PR_TRUE); + return NS_OK; + } + return NS_ERROR_NOT_IMPLEMENTED; +} + + diff --git a/mailnews/base/util/nsMsgFolder.h b/mailnews/base/util/nsMsgFolder.h index 194c912f0547..4e290190b5f3 100644 --- a/mailnews/base/util/nsMsgFolder.h +++ b/mailnews/base/util/nsMsgFolder.h @@ -167,6 +167,7 @@ public: NS_IMETHOD MarkThreadRead(nsIMsgThread *thread); NS_IMETHOD GetChildWithURI(const char *uri, PRBool deep, nsIMsgFolder **_retval); + NS_IMETHOD EnableNotifications(PRInt32 notificationType, PRBool enable); // end NS_DECL_NSIMSGFOLDER @@ -237,6 +238,7 @@ protected: unknown; -2 means unknown but we already tried to find out.) */ PRInt32 mNumTotalMessages; /* count of existing messages. */ + PRBool mNotifyCountChanges; PRUint32 mExpungedBytes; nsCOMPtr mSubFolders; nsVoidArray *mListeners; //This can't be an nsISupportsArray because due to