diff --git a/mailnews/base/public/msgCore.h b/mailnews/base/public/msgCore.h index afb9d03d5d18..69fb8efe95de 100644 --- a/mailnews/base/public/msgCore.h +++ b/mailnews/base/public/msgCore.h @@ -152,6 +152,8 @@ NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MAILNEWS, value) #define NS_MSG_CUSTOM_HEADERS_OVERFLOW NS_MSG_GENERATE_FAILURE(28) //when num of custom headers exceeds 50 #define NS_MSG_INVALID_CUSTOM_HEADER NS_MSG_GENERATE_FAILURE(29) //when custom header has invalid characters (as per rfc 2822) +#define NS_MSG_USER_NOT_AUTHENTICATED NS_MSG_GENERATE_FAILURE(30) // when local caches are password protect and user isn't auth + #define NS_MSGCOMP_ERROR_BEGIN 12500 /* NS_ERROR_NNTP_NO_CROSS_POSTING lives here, and not in nsMsgComposeStringBundle.h, because it is used in news and compose. */ #define NS_ERROR_NNTP_NO_CROSS_POSTING NS_MSG_GENERATE_FAILURE(12554) diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index b01c6cad7ab4..1d24cc72aed5 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -64,6 +64,7 @@ #include "nsIMsgCopyService.h" #include "nsMsgBaseCID.h" #include "nsISpamSettings.h" +#include "nsIMsgAccountManager.h" static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID); @@ -1722,10 +1723,21 @@ NS_IMETHODIMP nsMsgDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeValue sor m_sortOrder = sortOrder; m_sortType = sortType; + nsresult rv; + nsCOMPtr accountManager = + do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + PRBool userNeedsToAuthenticate = PR_FALSE; + // if we're PasswordProtectLocalCache, then we need to find out if the server is authenticated. + (void) accountManager->GetUserNeedsToAuthenticate(&userNeedsToAuthenticate); + if (userNeedsToAuthenticate) + return NS_MSG_USER_NOT_AUTHENTICATED; + if (folder) // search view will have a null folder { + nsCOMPtr folderInfo; - nsresult rv = folder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(m_db)); + rv = folder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(m_db)); NS_ENSURE_SUCCESS(rv,rv); m_db->AddListener(this); m_folder = folder;