From 72f75498c99c6d014ee0ff94c5060f80b6929efc Mon Sep 17 00:00:00 2001 From: "cavin%netscape.com" Date: Mon, 19 May 2003 23:59:06 +0000 Subject: [PATCH] Fix for 205729. Added 'aMsgWindow' input parameter to PerformBiff() which is set to null for regular biff (ie, check mail for every xx minutes) and is set to a valid window for check mail at startup. r=sspitzer, sr=bienvenu, a=sspitzer. --- mailnews/base/public/nsIMsgIncomingServer.idl | 2 +- .../resources/content/mailWindowOverlay.js | 2 +- .../resources/content/msgMail3PaneWindow.js | 2 +- mailnews/base/src/nsMsgBiffManager.cpp | 2 +- mailnews/base/util/nsMsgIncomingServer.cpp | 2 +- mailnews/imap/src/nsImapIncomingServer.cpp | 4 +- mailnews/imap/src/nsImapIncomingServer.h | 2 +- mailnews/local/src/nsPop3IncomingServer.cpp | 62 ++++++++----------- mailnews/local/src/nsPop3IncomingServer.h | 2 +- mailnews/news/src/nsNntpIncomingServer.cpp | 2 +- mailnews/news/src/nsNntpIncomingServer.h | 2 +- 11 files changed, 37 insertions(+), 47 deletions(-) diff --git a/mailnews/base/public/nsIMsgIncomingServer.idl b/mailnews/base/public/nsIMsgIncomingServer.idl index ed4559791dd8..eb102919a054 100644 --- a/mailnews/base/public/nsIMsgIncomingServer.idl +++ b/mailnews/base/public/nsIMsgIncomingServer.idl @@ -189,7 +189,7 @@ interface nsIMsgIncomingServer : nsISupports { void SetDefaultLocalPath(in nsIFileSpec aDefaultLocalPath); /* do a biff */ - void PerformBiff(); + void PerformBiff(in nsIMsgWindow aMsgWindow); /* this checks if a server needs a password to do biff */ readonly attribute boolean serverRequiresPasswordForBiff; diff --git a/mailnews/base/resources/content/mailWindowOverlay.js b/mailnews/base/resources/content/mailWindowOverlay.js index fe4c0b33aeef..d46547e8dc72 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.js +++ b/mailnews/base/resources/content/mailWindowOverlay.js @@ -749,7 +749,7 @@ function MsgGetMessagesForAllServers(defaultServer) else { // Check to see if there are new messages on the server - currentServer.PerformBiff(); + currentServer.PerformBiff(msgWindow); } } } diff --git a/mailnews/base/resources/content/msgMail3PaneWindow.js b/mailnews/base/resources/content/msgMail3PaneWindow.js index b93cb1c974be..06d0e7a55875 100644 --- a/mailnews/base/resources/content/msgMail3PaneWindow.js +++ b/mailnews/base/resources/content/msgMail3PaneWindow.js @@ -788,7 +788,7 @@ function loadStartFolder(initialUri) { // Perform biff on the server to check for new mail, except for imap if (defaultServer.type != "imap") - defaultServer.PerformBiff(); + defaultServer.PerformBiff(msgWindow); } diff --git a/mailnews/base/src/nsMsgBiffManager.cpp b/mailnews/base/src/nsMsgBiffManager.cpp index c15629794cf0..c63daf5f5843 100644 --- a/mailnews/base/src/nsMsgBiffManager.cpp +++ b/mailnews/base/src/nsMsgBiffManager.cpp @@ -335,7 +335,7 @@ nsresult nsMsgBiffManager::PerformBiff() // (since we don't want to prompt the user for password UI) // and make sure the server isn't already in the middle of downloading new messages if(!serverBusy && (!serverRequiresPassword || userAuthenticated)) - current->server->PerformBiff(); + current->server->PerformBiff(nsnull); mBiffArray->RemoveElementAt(i); i--; //Because we removed it we need to look at the one that just moved up. SetNextBiffTime(current, currentTime); diff --git a/mailnews/base/util/nsMsgIncomingServer.cpp b/mailnews/base/util/nsMsgIncomingServer.cpp index e2fe8c9b8ad0..c45e1383811b 100644 --- a/mailnews/base/util/nsMsgIncomingServer.cpp +++ b/mailnews/base/util/nsMsgIncomingServer.cpp @@ -173,7 +173,7 @@ nsMsgIncomingServer::PerformExpand(nsIMsgWindow *aMsgWindow) NS_IMETHODIMP -nsMsgIncomingServer::PerformBiff() +nsMsgIncomingServer::PerformBiff(nsIMsgWindow* aMsgWindow) { //This had to be implemented in the derived class, but in case someone doesn't implement it //just return not implemented. diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index 2db9a67fea5d..be840ad54f42 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -948,7 +948,7 @@ nsImapIncomingServer::PerformExpand(nsIMsgWindow *aMsgWindow) return rv; } -NS_IMETHODIMP nsImapIncomingServer::PerformBiff() +NS_IMETHODIMP nsImapIncomingServer::PerformBiff(nsIMsgWindow* aMsgWindow) { nsresult rv; @@ -957,7 +957,7 @@ NS_IMETHODIMP nsImapIncomingServer::PerformBiff() if(NS_SUCCEEDED(rv)) { SetPerformingBiff(PR_TRUE); - rv = rootMsgFolder->GetNewMessages(nsnull, nsnull); + rv = rootMsgFolder->GetNewMessages(aMsgWindow, nsnull); } return rv; } diff --git a/mailnews/imap/src/nsImapIncomingServer.h b/mailnews/imap/src/nsImapIncomingServer.h index 9187bc4a1005..53472b67856f 100644 --- a/mailnews/imap/src/nsImapIncomingServer.h +++ b/mailnews/imap/src/nsImapIncomingServer.h @@ -75,7 +75,7 @@ public: NS_DECL_NSISUBSCRIBABLESERVER NS_DECL_NSIURLLISTENER - NS_IMETHOD PerformBiff(); + NS_IMETHOD PerformBiff(nsIMsgWindow *aMsgWindow); NS_IMETHOD PerformExpand(nsIMsgWindow *aMsgWindow); NS_IMETHOD CloseCachedConnections(); NS_IMETHOD GetConstructedPrettyName(PRUnichar **retval); diff --git a/mailnews/local/src/nsPop3IncomingServer.cpp b/mailnews/local/src/nsPop3IncomingServer.cpp index 2a4f133705d9..db01a541cc40 100644 --- a/mailnews/local/src/nsPop3IncomingServer.cpp +++ b/mailnews/local/src/nsPop3IncomingServer.cpp @@ -53,7 +53,6 @@ #include "nsMsgFolderFlags.h" #include "nsIFileSpec.h" #include "nsPop3Protocol.h" -#include "nsIMsgMailSession.h" #include "nsIMsgLocalMailFolder.h" static NS_DEFINE_CID(kCPop3ServiceCID, NS_POP3SERVICE_CID); @@ -120,7 +119,7 @@ nsPop3IncomingServer::GetLocalStoreType(char **type) return NS_OK; } -NS_IMETHODIMP nsPop3IncomingServer::PerformBiff() +NS_IMETHODIMP nsPop3IncomingServer::PerformBiff(nsIMsgWindow *aMsgWindow) { nsresult rv; nsCOMPtr pop3Service(do_GetService(kCPop3ServiceCID, &rv)); @@ -139,50 +138,41 @@ NS_IMETHODIMP nsPop3IncomingServer::PerformBiff() if (NS_FAILED(rv) || numFolders != 1) return rv; } - //Biff just needs to give status in one of the windows. so do it in topmost window. - nsCOMPtr mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr msgWindow; + SetPerformingBiff(PR_TRUE); + urlListener = do_QueryInterface(inbox); - rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow)); - if(NS_SUCCEEDED(rv)) + PRBool downloadOnBiff = PR_FALSE; + rv = GetDownloadOnBiff(&downloadOnBiff); + if (downloadOnBiff) { - SetPerformingBiff(PR_TRUE); - urlListener = do_QueryInterface(inbox); - - PRBool downloadOnBiff = PR_FALSE; - rv = GetDownloadOnBiff(&downloadOnBiff); - if (downloadOnBiff) + nsCOMPtr localInbox = do_QueryInterface(inbox, &rv); + if (localInbox && NS_SUCCEEDED(rv)) { - nsCOMPtr localInbox = do_QueryInterface(inbox, &rv); - if (localInbox && NS_SUCCEEDED(rv)) + PRBool valid =PR_FALSE; + nsCOMPtr db; + rv = inbox->GetMsgDatabase(aMsgWindow, getter_AddRefs(db)); + if (NS_SUCCEEDED(rv) && db) + rv = db->GetSummaryValid(&valid); + if (NS_SUCCEEDED(rv) && valid) + rv = pop3Service->GetNewMail(aMsgWindow, urlListener, inbox, this, nsnull); + else { - PRBool valid =PR_FALSE; - nsCOMPtr db; - rv = inbox->GetMsgDatabase(msgWindow, getter_AddRefs(db)); - if (NS_SUCCEEDED(rv) && db) - rv = db->GetSummaryValid(&valid); - if (NS_SUCCEEDED(rv) && valid) - rv = pop3Service->GetNewMail(msgWindow, urlListener, inbox, this, nsnull); - else + PRBool isLocked; + inbox->GetLocked(&isLocked); + if (!isLocked) { - PRBool isLocked; - inbox->GetLocked(&isLocked); - if (!isLocked) - { - rv = localInbox->ParseFolder(msgWindow, urlListener); - } - if (NS_SUCCEEDED(rv)) - rv = localInbox->SetCheckForNewMessagesAfterParsing(PR_TRUE); + rv = localInbox->ParseFolder(aMsgWindow, urlListener); } + if (NS_SUCCEEDED(rv)) + rv = localInbox->SetCheckForNewMessagesAfterParsing(PR_TRUE); } } - else - rv = pop3Service->CheckForNewMail(nsnull, urlListener, inbox, this, nsnull); + } + else + rv = pop3Service->CheckForNewMail(nsnull, urlListener, inbox, this, nsnull); // it's important to pass in null for the msg window if we are performing biff // this makes sure that we don't show any kind of UI during biff. - } + return NS_OK; } diff --git a/mailnews/local/src/nsPop3IncomingServer.h b/mailnews/local/src/nsPop3IncomingServer.h index 62167ab316a5..e4982792331e 100644 --- a/mailnews/local/src/nsPop3IncomingServer.h +++ b/mailnews/local/src/nsPop3IncomingServer.h @@ -58,7 +58,7 @@ public: virtual ~nsPop3IncomingServer(); NS_IMETHOD GetLocalStoreType(char **); - NS_IMETHOD PerformBiff(); + NS_IMETHOD PerformBiff(nsIMsgWindow *aMsgWindow); NS_IMETHOD GetDownloadMessagesAtStartup(PRBool *getMessages); NS_IMETHOD GetCanBeDefaultServer(PRBool *canBeDefaultServer); NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages); diff --git a/mailnews/news/src/nsNntpIncomingServer.cpp b/mailnews/news/src/nsNntpIncomingServer.cpp index 71bc4fe48e1a..d71d23bf32d1 100644 --- a/mailnews/news/src/nsNntpIncomingServer.cpp +++ b/mailnews/news/src/nsNntpIncomingServer.cpp @@ -699,7 +699,7 @@ nsNntpIncomingServer::DisplaySubscribedGroup(nsIMsgNewsFolder *aMsgFolder, PRInt } NS_IMETHODIMP -nsNntpIncomingServer::PerformBiff() +nsNntpIncomingServer::PerformBiff(nsIMsgWindow *aMsgWindow) { #ifdef DEBUG_NEWS printf("PerformBiff for nntp\n"); diff --git a/mailnews/news/src/nsNntpIncomingServer.h b/mailnews/news/src/nsNntpIncomingServer.h index 516d71741cde..9f6a936e798c 100644 --- a/mailnews/news/src/nsNntpIncomingServer.h +++ b/mailnews/news/src/nsNntpIncomingServer.h @@ -84,7 +84,7 @@ public: NS_IMETHOD GetLocalStoreType(char * *type); NS_IMETHOD CloseCachedConnections(); - NS_IMETHOD PerformBiff(); + NS_IMETHOD PerformBiff(nsIMsgWindow *aMsgWindow); NS_IMETHOD PerformExpand(nsIMsgWindow *aMsgWindow); NS_IMETHOD GetFilterList(nsIMsgWindow *aMsgWindow, nsIMsgFilterList **aResult); NS_IMETHOD OnUserOrHostNameChanged(const char *oldName, const char *newName);