From a7bd2338ab64e3b484153856bb7de9afff86af18 Mon Sep 17 00:00:00 2001 From: "bienvenu%netscape.com" Date: Wed, 18 Jul 2001 13:51:27 +0000 Subject: [PATCH] fix problems with biff and cleanup inbox on exit with SSL, r=naving, sr=mscott 90767 58964 --- mailnews/base/src/nsMsgAccountManager.cpp | 12 +++++--- mailnews/imap/public/nsIImapServerSink.idl | 2 +- mailnews/imap/src/nsImapIncomingServer.cpp | 35 +++++++++++++--------- mailnews/imap/src/nsImapIncomingServer.h | 26 ++++++++-------- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp index e265cd02e3e..e4bef79aff9 100644 --- a/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mailnews/base/src/nsMsgAccountManager.cpp @@ -918,12 +918,16 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa if (folder) { nsXPIDLCString passwd; + PRBool serverRequiresPasswordForAuthentication = PR_TRUE; PRBool isImap = (type ? PL_strcmp(type, "imap") == 0 : PR_FALSE); if (isImap) + { + server->GetServerRequiresPasswordForBiff(&serverRequiresPasswordForAuthentication); server->GetPassword(getter_Copies(passwd)); - if (!isImap || (isImap && passwd && - nsCRT::strlen((const char*) passwd))) + } + if (!isImap || (isImap && (!serverRequiresPasswordForAuthentication || (passwd && + nsCRT::strlen((const char*) passwd))))) { nsCOMPtr urlListener; NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, @@ -979,7 +983,7 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa { accountManager->GetCleanupInboxInProgress(&inProgress); PR_CEnterMonitor(folder); - PR_CWait(folder, 1000UL); + PR_CWait(folder, PR_MicrosecondsToInterval(1000UL)); PR_CExitMonitor(folder); if (eventQueue) eventQueue->ProcessPendingEvents(); @@ -992,7 +996,7 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa { accountManager->GetEmptyTrashInProgress(&inProgress); PR_CEnterMonitor(folder); - PR_CWait(folder, 1000UL); + PR_CWait(folder, PR_MicrosecondsToInterval(1000UL)); PR_CExitMonitor(folder); if (eventQueue) eventQueue->ProcessPendingEvents(); diff --git a/mailnews/imap/public/nsIImapServerSink.idl b/mailnews/imap/public/nsIImapServerSink.idl index 4c5f4ceb7d4..4e390455911 100644 --- a/mailnews/imap/public/nsIImapServerSink.idl +++ b/mailnews/imap/public/nsIImapServerSink.idl @@ -46,7 +46,7 @@ interface nsIImapServerSink : nsISupports { void fEAlertFromServer(in string aString, in nsIMsgWindow aMsgWindow); void commitNamespaces(); void promptForPassword(out string aString, in nsIMsgWindow aMsgWindow); - void setUserAuthenticated(in boolean authenticated); + attribute boolean userAuthenticated; void setMailServerUrls(in string manageMailAccount, in string manageLists, in string manageFilters); /* this is a bogus method on this interface but i need it until misc. sink is scriptable.. */ diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index 38700af7418..01f0a945468 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -96,16 +96,17 @@ NS_INTERFACE_MAP_END_INHERITING(nsMsgIncomingServer) nsImapIncomingServer::nsImapIncomingServer() { - NS_INIT_REFCNT(); - nsresult rv; - rv = NS_NewISupportsArray(getter_AddRefs(m_connectionCache)); - rv = NS_NewISupportsArray(getter_AddRefs(m_urlQueue)); - m_capability = kCapabilityUndefined; - m_waitingForConnectionInfo = PR_FALSE; - m_redirectedLogonRetries = 0; - mDoingSubscribeDialog = PR_FALSE; - mDoingLsub = PR_FALSE; - m_canHaveFilters = PR_TRUE; + NS_INIT_REFCNT(); + nsresult rv; + rv = NS_NewISupportsArray(getter_AddRefs(m_connectionCache)); + rv = NS_NewISupportsArray(getter_AddRefs(m_urlQueue)); + m_capability = kCapabilityUndefined; + m_waitingForConnectionInfo = PR_FALSE; + m_redirectedLogonRetries = 0; + mDoingSubscribeDialog = PR_FALSE; + mDoingLsub = PR_FALSE; + m_canHaveFilters = PR_TRUE; + m_userAuthenticated = PR_FALSE; m_readPFCName = PR_FALSE; } @@ -2143,6 +2144,15 @@ nsresult nsImapIncomingServer::GetUnverifiedSubFolders(nsIFolder *parentFolder, return rv; } +NS_IMETHODIMP nsImapIncomingServer::GetServerRequiresPasswordForBiff(PRBool *_retval) +{ + NS_ENSURE_ARG_POINTER(_retval); + // if the user has already been authenticated, we've got the password + *_retval = !m_userAuthenticated; + return NS_OK; +} + + NS_IMETHODIMP nsImapIncomingServer::PromptForPassword(char ** aPassword, nsIMsgWindow * aMsgWindow) { @@ -2283,10 +2293,7 @@ void MSG_IMAPFolderInfoMail::ResetNamespaceReferences() #endif //FINISHED_PORTED_NAMESPACE_STUFF -NS_IMETHODIMP nsImapIncomingServer::SetUserAuthenticated(PRBool authenticated) -{ - return NS_OK; -} +NS_IMPL_GETSET(nsImapIncomingServer, UserAuthenticated, PRBool, m_userAuthenticated); /* void SetMailServerUrls (in string manageMailAccount, in string manageLists, in string manageFilters); */ NS_IMETHODIMP nsImapIncomingServer::SetMailServerUrls(const char *manageMailAccount, const char *manageLists, const char *manageFilters) diff --git a/mailnews/imap/src/nsImapIncomingServer.h b/mailnews/imap/src/nsImapIncomingServer.h index 62904e3786d..31d0571a3bc 100644 --- a/mailnews/imap/src/nsImapIncomingServer.h +++ b/mailnews/imap/src/nsImapIncomingServer.h @@ -71,6 +71,7 @@ public: NS_IMETHOD GetCanFileMessagesOnServer(PRBool *aCanFileMessagesOnServer); NS_IMETHOD GetFilterScope(nsMsgSearchScopeValue *filterScope); NS_IMETHOD GetSearchScope(nsMsgSearchScopeValue *searchScope); + NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *_retval); protected: nsresult GetFolder(const char* name, nsIMsgFolder** pFolder); nsresult ResetFoldersToUnverified(nsIFolder *parentFolder); @@ -101,21 +102,22 @@ private: nsCOMPtr m_connectionCache; nsCOMPtr m_urlQueue; nsCOMPtr m_stringBundle; - nsVoidArray m_urlConsumers; - PRUint32 m_capability; - nsCString m_manageMailAccountUrl; + nsVoidArray m_urlConsumers; + PRUint32 m_capability; + nsCString m_manageMailAccountUrl; PRBool m_readPFCName; + PRBool m_userAuthenticated; nsCString m_pfcName; - PRBool m_waitingForConnectionInfo; - PRInt32 m_redirectedLogonRetries; - nsCOMPtr m_logonRedirector; - - // subscribe dialog stuff - PRBool mDoingSubscribeDialog; - PRBool mDoingLsub; - nsresult AddFolderToSubscribeDialog(const char *parentUri, const char *uri,const char *folderName); + PRBool m_waitingForConnectionInfo; + PRInt32 m_redirectedLogonRetries; + nsCOMPtr m_logonRedirector; + + // subscribe dialog stuff + PRBool mDoingSubscribeDialog; + PRBool mDoingLsub; + nsresult AddFolderToSubscribeDialog(const char *parentUri, const char *uri,const char *folderName); - nsCOMPtr mInner; + nsCOMPtr mInner; nsresult EnsureInner(); nsresult ClearInner(); };