From 3456144dd5020145b550d3893b76ae4dc2b2d281 Mon Sep 17 00:00:00 2001 From: "bienvenu%netscape.com" Date: Tue, 14 Sep 1999 04:02:34 +0000 Subject: [PATCH] break out UpdateFolder method from GetMessages --- mailnews/base/public/nsIMsgFolder.idl | 2 ++ mailnews/base/util/nsMsgFolder.cpp | 6 ++++ mailnews/base/util/nsMsgFolder.h | 2 ++ .../compose/src/nsMsgComposeStringBundle.cpp | 2 ++ mailnews/db/msgdb/src/nsMsgDatabase.cpp | 3 ++ mailnews/imap/src/nsImapMailFolder.cpp | 14 ++++++--- mailnews/imap/src/nsImapMailFolder.h | 1 + mailnews/local/src/nsLocalMailFolder.cpp | 6 ++++ mailnews/local/src/nsLocalMailFolder.h | 2 +- mailnews/news/src/nsNewsFolder.cpp | 31 +++++-------------- mailnews/news/src/nsNewsFolder.h | 1 + 11 files changed, 41 insertions(+), 29 deletions(-) diff --git a/mailnews/base/public/nsIMsgFolder.idl b/mailnews/base/public/nsIMsgFolder.idl index f57a51b7c74c..5782e9f790b8 100644 --- a/mailnews/base/public/nsIMsgFolder.idl +++ b/mailnews/base/public/nsIMsgFolder.idl @@ -51,6 +51,8 @@ interface nsIMsgFolder : nsIFolder { nsISimpleEnumerator GetMessages(); nsISimpleEnumerator GetThreads(); + /* get new headers for db */ + void UpdateFolder(); nsIMsgThread GetThreadForMessage(in nsIMessage message); boolean HasMessage(in nsIMessage message); nsIEnumerator GetVisibleSubFolders(); diff --git a/mailnews/base/util/nsMsgFolder.cpp b/mailnews/base/util/nsMsgFolder.cpp index 4cab3709977a..14b7b9d5265a 100644 --- a/mailnews/base/util/nsMsgFolder.cpp +++ b/mailnews/base/util/nsMsgFolder.cpp @@ -276,6 +276,12 @@ nsMsgFolder::GetMessages(nsISimpleEnumerator* *result) return NS_ERROR_FAILURE; } +NS_IMETHODIMP +nsMsgFolder::UpdateFolder() +{ + return NS_OK; +} + NS_IMETHODIMP nsMsgFolder::GetThreads(nsISimpleEnumerator ** threadEnumerator) { diff --git a/mailnews/base/util/nsMsgFolder.h b/mailnews/base/util/nsMsgFolder.h index 72d5fa04ee92..4299d96d3703 100644 --- a/mailnews/base/util/nsMsgFolder.h +++ b/mailnews/base/util/nsMsgFolder.h @@ -92,6 +92,8 @@ public: NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement); NS_IMETHOD GetVisibleSubFolders(nsIEnumerator* *result); NS_IMETHOD GetMessages(nsISimpleEnumerator* *result); + NS_IMETHOD UpdateFolder(); + NS_IMETHOD GetThreads(nsISimpleEnumerator ** threadEnumerator); NS_IMETHOD GetThreadForMessage(nsIMessage *message, nsIMsgThread **thread); NS_IMETHOD HasMessage(nsIMessage *message, PRBool *hasMessage); diff --git a/mailnews/compose/src/nsMsgComposeStringBundle.cpp b/mailnews/compose/src/nsMsgComposeStringBundle.cpp index 800d8078c62a..feb852c5a2b8 100644 --- a/mailnews/compose/src/nsMsgComposeStringBundle.cpp +++ b/mailnews/compose/src/nsMsgComposeStringBundle.cpp @@ -79,6 +79,7 @@ ComposeBEGetStringByIDREAL(PRInt32 stringID) nsIStringBundle* sBundle = nsnull; res = sBundleService->CreateBundle(url, locale, &sBundle); #endif + NS_RELEASE(sBundle); if (NS_FAILED(res)) { return PL_strdup("???"); // Don't I18N this string...failsafe return value @@ -92,6 +93,7 @@ ComposeBEGetStringByIDREAL(PRInt32 stringID) #else res = sBundle->GetStringFromID(stringID, v); #endif + NS_RELEASE(sBundle); if (NS_FAILED(res)) { char buf[128]; diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index 496db8080d4c..3b211a24669b 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -143,6 +143,9 @@ NS_IMETHODIMP nsMsgDatabase::NotifyKeyDeletedAll(nsMsgKey keyDeleted, nsMsgKey p NS_IMETHODIMP nsMsgDatabase::NotifyKeyAddedAll(nsMsgKey keyAdded, nsMsgKey parentKey, PRInt32 flags, nsIDBChangeListener *instigator) { +#ifdef DEBUG_bienvenu1 + printf("notifying add of %ld parent %ld\n", keyAdded, parentKey); +#endif if (m_ChangeListeners == nsnull) return NS_OK; for (PRInt32 i = 0; i < m_ChangeListeners->Count(); i++) diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 7368b3c1f329..37bad0d0383a 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -411,12 +411,11 @@ nsresult nsImapMailFolder::GetDatabase() return folderOpen; } -NS_IMETHODIMP nsImapMailFolder::GetMessages(nsISimpleEnumerator* *result) +NS_IMETHODIMP +nsImapMailFolder::UpdateFolder() { nsresult rv = NS_ERROR_NULL_POINTER; PRBool selectFolder = PR_FALSE; - if (result) - *result = nsnull; NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv); @@ -455,7 +454,15 @@ NS_IMETHODIMP nsImapMailFolder::GetMessages(nsISimpleEnumerator* *result) rv = imapService->SelectFolder(eventQ, this, this, nsnull, nsnull); m_urlRunning = PR_TRUE; } + return rv; +} + +NS_IMETHODIMP nsImapMailFolder::GetMessages(nsISimpleEnumerator* *result) +{ + if (result) + *result = nsnull; + nsresult rv = UpdateFolder(); if(NS_SUCCEEDED(rv)) { nsCOMPtr msgHdrEnumerator; @@ -2904,7 +2911,6 @@ nsImapMailFolder::CreateDirectoryForFolder(nsFileSpec &path) //** dup return rv; nsFileSpec tempPath(path.GetNativePathCString(), PR_TRUE); // create incoming directories. -// need bienvenu to fix this for real - the intent of this line is a mystery to sfraser and I //If that doesn't exist, then we have to create this directory if(!path.IsDirectory()) diff --git a/mailnews/imap/src/nsImapMailFolder.h b/mailnews/imap/src/nsImapMailFolder.h index 4205652b5975..17e1c4d43f72 100644 --- a/mailnews/imap/src/nsImapMailFolder.h +++ b/mailnews/imap/src/nsImapMailFolder.h @@ -106,6 +106,7 @@ public: NS_IMETHOD AddUnique(nsISupports* element); NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement); NS_IMETHOD GetMessages(nsISimpleEnumerator* *result); + NS_IMETHOD UpdateFolder(); NS_IMETHOD CreateSubfolder(const char *folderName); diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index 430512bc14f2..941cd416fde1 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -500,6 +500,12 @@ nsresult nsMsgLocalMailFolder::GetDatabase() return rv; } +NS_IMETHODIMP +nsMsgLocalMailFolder::UpdateFolder() +{ + return GetDatabase(); // this will cause a reparse, if needed. +} + NS_IMETHODIMP nsMsgLocalMailFolder::GetMessages(nsISimpleEnumerator* *result) { diff --git a/mailnews/local/src/nsLocalMailFolder.h b/mailnews/local/src/nsLocalMailFolder.h index 1486c2af563d..67f90b660ffd 100644 --- a/mailnews/local/src/nsLocalMailFolder.h +++ b/mailnews/local/src/nsLocalMailFolder.h @@ -85,7 +85,7 @@ public: NS_IMETHOD AddUnique(nsISupports* element); NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement); NS_IMETHOD GetMessages(nsISimpleEnumerator* *result); - + NS_IMETHOD UpdateFolder(); NS_IMETHOD CreateSubfolder(const char *folderName); diff --git a/mailnews/news/src/nsNewsFolder.cpp b/mailnews/news/src/nsNewsFolder.cpp index 5157b2fa1da9..39e3d3bd4ca9 100644 --- a/mailnews/news/src/nsNewsFolder.cpp +++ b/mailnews/news/src/nsNewsFolder.cpp @@ -369,39 +369,22 @@ nsresult nsMsgNewsFolder::GetDatabase() return NS_OK; } + +NS_IMETHODIMP +nsMsgNewsFolder::UpdateFolder() +{ + return GetNewMessages(); +} + NS_IMETHODIMP nsMsgNewsFolder::GetMessages(nsISimpleEnumerator* *result) { #ifdef DEBUG_NEWS printf("nsMsgNewsFolder::GetMessages(%s)\n",mURI); #endif - // number_to_show is a tempory hack to allow newsgroups - // with thousands of message to work. the way it works is - // we return a cropped enumerator back to to the caller - // instead of the full one. This gets around the problem - // where tree layout (and probably other things) don't scale - PRInt32 number_to_show; nsresult rv = NS_OK; - NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv); - if (NS_SUCCEEDED(rv) && prefs) { - rv = prefs->GetIntPref(PREF_NEWS_MAX_HEADERS_TO_SHOW, &number_to_show); - if (NS_FAILED(rv)) { - // failed to get the pref...show them all the headers - number_to_show = 0; - } - } - else { - // failed to get pref service...show them all headers - number_to_show = 0; - } - - // if the user asks for a negative value, I'll just ignore them - if (number_to_show < 0) { - number_to_show = 0; - } - rv = GetDatabase(); *result = nsnull; diff --git a/mailnews/news/src/nsNewsFolder.h b/mailnews/news/src/nsNewsFolder.h index 1ba295a4e402..55faceb69b3e 100644 --- a/mailnews/news/src/nsNewsFolder.h +++ b/mailnews/news/src/nsNewsFolder.h @@ -54,6 +54,7 @@ public: NS_IMETHOD AddUnique(nsISupports* element); NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement); NS_IMETHOD GetMessages(nsISimpleEnumerator* *result); + NS_IMETHOD UpdateFolder(); NS_IMETHOD CreateSubfolder(const char *folderName);