114345 r=bienvenu sr=mscott Remove m_parsingInbox boolean, ask the db if the summary is valid, if not, it is being built and wait for it to be over, before downloading msgs.

This commit is contained in:
naving%netscape.com 2001-12-14 23:12:35 +00:00
parent 169c79e50d
commit c1ec7ce344
4 changed files with 55 additions and 69 deletions

View File

@ -56,6 +56,5 @@ interface nsIMsgLocalMailFolder : nsISupports {
void parseFolder(in nsIMsgWindow aMsgWindow, in nsIUrlListener listener);
void copyFolderLocal(in nsIMsgFolder srcFolder, in boolean isMove, in nsIMsgWindow msgWindow, in nsIMsgCopyServiceListener listener );
void doNextSubFolder(in nsIMsgFolder srcFolder, in nsIMsgWindow msgWindow, in nsIMsgCopyServiceListener listener );
readonly attribute boolean parsingInbox;
attribute boolean checkForNewMessagesAfterParsing;
};

View File

@ -98,7 +98,6 @@
#include "nsEscape.h"
#include "nsLocalStringBundle.h"
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kMailboxServiceCID, NS_MAILBOXSERVICE_CID);
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
@ -149,7 +148,7 @@ nsLocalMailCopyState::~nsLocalMailCopyState()
nsMsgLocalMailFolder::nsMsgLocalMailFolder(void)
: mHaveReadNameFromDB(PR_FALSE), mGettingMail(PR_FALSE),
mInitialized(PR_FALSE), mCopyState(nsnull), mType(nsnull),
mCheckForNewMessagesAfterParsing(PR_FALSE), mParsingInbox(PR_FALSE)
mCheckForNewMessagesAfterParsing(PR_FALSE)
{
// NS_INIT_REFCNT(); done by superclass
@ -572,8 +571,6 @@ nsresult nsMsgLocalMailFolder::GetDatabase(nsIMsgWindow *aMsgWindow)
if(folderOpen == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING ||
folderOpen == NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE)
{
if(mFlags & MSG_FOLDER_FLAG_INBOX)
mParsingInbox = PR_TRUE;
if(NS_FAILED(rv = ParseFolder(aMsgWindow, this)))
return rv;
else
@ -611,7 +608,6 @@ nsMsgLocalMailFolder::UpdateFolder(nsIMsgWindow *aWindow)
NS_ENSURE_SUCCESS(rv,rv);
}
}
return rv;
}
@ -1455,7 +1451,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetDeletable(PRBool *deletable)
return NS_OK;
}
NS_IMETHODIMP nsMsgLocalMailFolder::GetRequiresCleanup(PRBool *requiresCleanup)
{
#ifdef HAVE_PORT
@ -1470,6 +1466,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetRequiresCleanup(PRBool *requiresCleanup)
return NS_OK;
}
NS_IMETHODIMP nsMsgLocalMailFolder::GetSizeOnDisk(PRUint32* size)
{
#ifdef HAVE_PORT
@ -2191,13 +2188,15 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetNewMessages(nsIMsgWindow *aWindow, nsIUrl
PRUint32 numFolders;
rv = rootFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inbox));
}
PRBool parsingInbox;
nsCOMPtr<nsIMsgLocalMailFolder> localInbox = do_QueryInterface(inbox, &rv);
if (NS_SUCCEEDED(rv) && localInbox)
{
rv = localInbox->GetParsingInbox(&parsingInbox);
NS_ENSURE_SUCCESS(rv,rv);
if (!parsingInbox)
PRBool valid = PR_FALSE;
nsCOMPtr <nsIMsgDatabase> db;
rv = inbox->GetMsgDatabase(aWindow, getter_AddRefs(db));
if (NS_SUCCEEDED(rv) && db)
rv = db->GetSummaryValid(&valid);
if (valid)
rv = localMailServer->GetNewMail(aWindow, aListener, inbox, nsnull);
else
rv = localInbox->SetCheckForNewMessagesAfterParsing(PR_TRUE);
@ -3130,10 +3129,11 @@ nsMsgLocalMailFolder::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
}
}
}
if (mParsingInbox)
if (mDatabase && (mFlags & MSG_FOLDER_FLAG_INBOX))
{
mParsingInbox = PR_FALSE;
if (mCheckForNewMessagesAfterParsing)
PRBool valid;
mDatabase->GetSummaryValid(&valid);
if (valid && mCheckForNewMessagesAfterParsing)
{
if (msgWindow)
rv = GetNewMessages(msgWindow, nsnull);
@ -3141,7 +3141,6 @@ nsMsgLocalMailFolder::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
}
}
}
mParsingInbox = PR_FALSE; //make sure we turn off this flag even if parsing fails or else it will be a deadlock
return nsMsgDBFolder::OnStopRunningUrl(aUrl, aExitCode);
}
@ -3274,14 +3273,6 @@ nsMsgLocalMailFolder::SetCheckForNewMessagesAfterParsing(PRBool aCheckForNewMess
return NS_OK;
}
NS_IMETHODIMP
nsMsgLocalMailFolder::GetParsingInbox(PRBool *aParsingInbox)
{
NS_ENSURE_ARG(aParsingInbox);
*aParsingInbox = mParsingInbox;
return NS_OK;
}
NS_IMETHODIMP
nsMsgLocalMailFolder::NotifyCompactCompleted()
{

View File

@ -142,8 +142,7 @@ public:
NS_IMETHOD UpdateSummaryTotals(PRBool force) ;
NS_IMETHOD GetDeletable (PRBool *deletable);
NS_IMETHOD GetRequiresCleanup(PRBool *requiresCleanup);
NS_IMETHOD GetRequiresCleanup(PRBool *requiresCleanup);
NS_IMETHOD GetSizeOnDisk(PRUint32* size);
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *authenticate);
@ -215,7 +214,6 @@ protected:
//time
const char *mType;
PRBool mCheckForNewMessagesAfterParsing;
PRBool mParsingInbox;
nsCOMPtr<nsIMsgStringService> mMsgStringService;
nsresult setSubfolderFlag(PRUnichar *aFolderName, PRUint32 flags);

View File

@ -177,59 +177,57 @@ nsPop3IncomingServer::GetLocalStoreType(char **type)
NS_IMETHODIMP nsPop3IncomingServer::PerformBiff()
{
nsresult rv;
nsCOMPtr<nsIPop3Service> pop3Service(do_GetService(kCPop3ServiceCID, &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> inbox;
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
if(NS_SUCCEEDED(rv))
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> inbox;
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgFolder> rootMsgFolder = do_QueryInterface(rootFolder);
if(rootMsgFolder)
nsCOMPtr<nsIMsgFolder> rootMsgFolder = do_QueryInterface(rootFolder);
if(rootMsgFolder)
{
PRUint32 numFolders;
rv = rootMsgFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1,
&numFolders,
getter_AddRefs(inbox));
if (NS_FAILED(rv) || numFolders != 1) return rv;
}
}
PRUint32 numFolders;
rv = rootMsgFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1,
&numFolders,
getter_AddRefs(inbox));
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<nsIMsgMailSession> mailSession =
do_GetService(kCMsgMailSessionCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgWindow> msgWindow;
nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(kCMsgMailSessionCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgWindow> msgWindow;
rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow));
if(NS_SUCCEEDED(rv))
if(NS_SUCCEEDED(rv))
{
PRBool downloadOnBiff = PR_FALSE;
rv = GetDownloadOnBiff(&downloadOnBiff);
if (downloadOnBiff)
{
PRBool downloadOnBiff = PR_FALSE;
rv = GetDownloadOnBiff(&downloadOnBiff);
if (downloadOnBiff)
{
nsCOMPtr <nsIMsgLocalMailFolder> localInbox = do_QueryInterface(inbox, &rv);
PRBool parsingInbox;
if (localInbox && NS_SUCCEEDED(rv))
{
rv = localInbox->GetParsingInbox(&parsingInbox);
NS_ENSURE_SUCCESS(rv,rv);
if (!parsingInbox)
rv = pop3Service->GetNewMail(msgWindow, nsnull, inbox, this, nsnull);
else
rv = localInbox->SetCheckForNewMessagesAfterParsing(PR_TRUE);
}
}
nsCOMPtr <nsIMsgLocalMailFolder> localInbox = do_QueryInterface(inbox, &rv);
if (localInbox && NS_SUCCEEDED(rv))
{
PRBool valid =PR_FALSE;
nsCOMPtr <nsIMsgDatabase> 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, nsnull, inbox, this, nsnull);
else
rv = pop3Service->CheckForNewMail(msgWindow, nsnull, inbox, this,
nsnull);
rv = localInbox->SetCheckForNewMessagesAfterParsing(PR_TRUE);
}
}
return NS_OK;
else
rv = pop3Service->CheckForNewMail(msgWindow, nsnull, inbox, this,
nsnull);
}
return NS_OK;
}
NS_IMETHODIMP