Bug 99387 - turbo gain minimized due to profile support. Now observing a notifier which is sent to forget passwords without a profile shutdown. r=bhuvan/sr=mscott

This commit is contained in:
ccarlen%netscape.com 2001-09-21 05:04:25 +00:00
parent bbbcd2ca54
commit 8ab23df067
6 changed files with 53 additions and 8 deletions

View File

@ -96,6 +96,9 @@ interface nsIMsgIncomingServer : nsISupports {
/* forget the password in memory and in single signon database */
void forgetPassword();
/* forget the password in memory which is cached for the session */
void forgetSessionPassword();
/* should we download whole messages when biff goes off? */
/* in 4.x, this was "mail.pop3_gets_new_mail" for pop */
/* "mail.imap.new_mail_get_headers" for imap, and it was global. in 5.x, it is per server */

View File

@ -173,6 +173,7 @@ nsresult nsMsgAccountManager::Init()
observerService->AddObserver(this, topic.get());
observerService->AddObserver(this, NS_LITERAL_STRING("quit-application").get());
observerService->AddObserver(this, NS_LITERAL_STRING("network:offline-status-changed").get());
observerService->AddObserver(this, NS_LITERAL_STRING("session-logout").get());
observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get());
}
@ -213,6 +214,7 @@ NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const PRUnicha
nsAutoString quitApplicationString;
quitApplicationString.AssignWithConversion("quit-application");
nsAutoString offlineStatusChangedString(NS_LITERAL_STRING("network:offline-status-changed"));
NS_NAMED_LITERAL_STRING(sessionLogoutString, "session-logout");
NS_NAMED_LITERAL_STRING(beforeProfileChangeString, "profile-before-change");
if(topicString == shutdownString)
{
@ -232,7 +234,12 @@ NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const PRUnicha
CloseCachedConnections();
}
}
else if (beforeProfileChangeString.Equals(topicString)) {
else if (sessionLogoutString.Equals(topicString))
{
m_incomingServers.Enumerate(hashLogoutOfServer, nsnull);
}
else if (beforeProfileChangeString.Equals(topicString))
{
Shutdown();
}
@ -852,6 +859,22 @@ nsMsgAccountManager::hashUnloadServer(nsHashKey *aKey, void *aData,
}
PRBool
nsMsgAccountManager::hashLogoutOfServer(nsHashKey *aKey, void *aData,
void *closure)
{
nsresult rv;
nsCOMPtr<nsIMsgIncomingServer> server =
do_QueryInterface((nsISupports*)aData, &rv);
if (NS_FAILED(rv)) return PR_TRUE;
rv = server->CloseCachedConnections();
NS_ASSERTION(NS_SUCCEEDED(rv), "CloseCachedConnections failed");
server->ForgetSessionPassword();
return PR_TRUE;
}
nsresult nsMsgAccountManager::GetFolderCache(nsIMsgFolderCache* *aFolderCache)
{
if (!aFolderCache) return NS_ERROR_NULL_POINTER;

View File

@ -126,6 +126,10 @@ private:
static PRBool PR_CALLBACK hashUnloadServer(nsHashKey *aKey, void *aData,
void *closure);
// close connection and forget cached password
static PRBool PR_CALLBACK hashLogoutOfServer(nsHashKey *aKey, void *aData,
void *closure);
// clean up on exit
static PRBool PR_CALLBACK cleanupOnExit(nsHashKey *aKey, void *aData,
void *closure);

View File

@ -774,6 +774,13 @@ nsMsgIncomingServer::ForgetPassword()
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::ForgetSessionPassword()
{
m_password.Truncate(0);
return NS_OK;
}
NS_IMETHODIMP
nsMsgIncomingServer::SetDefaultLocalPath(nsIFileSpec *aDefaultLocalPath)
{

View File

@ -244,9 +244,10 @@ nsHttpHandler::Init()
nsCOMPtr<nsIObserverService> observerSvc =
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
if (observerSvc)
if (observerSvc) {
observerSvc->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get());
observerSvc->AddObserver(this, NS_LITERAL_STRING("session-logout").get());
}
return NS_OK;
}
@ -1780,7 +1781,8 @@ nsHttpHandler::Observe(nsISupports *subject,
const PRUnichar *topic,
const PRUnichar *data)
{
if (!nsCRT::strcmp(topic, NS_LITERAL_STRING("profile-before-change").get())) {
if (!nsCRT::strcmp(topic, NS_LITERAL_STRING("profile-before-change").get()) ||
!nsCRT::strcmp(topic, NS_LITERAL_STRING("session-logout").get())) {
// clear cache of all authentication credentials.
if (mAuthCache)
mAuthCache->ClearAll();

View File

@ -51,6 +51,7 @@
#include "nsIWindowsHooks.h"
#include "nsIPromptService.h"
#include "nsNetCID.h"
#include "nsIObserverService.h"
// These are needed to load a URL in a browser window.
#include "nsIDOMLocation.h"
@ -397,6 +398,7 @@ private:
static DWORD mInstance;
static char *mAppName;
static nsIDOMWindow *mInitialWindow;
static PRBool mDidProfileStartup;
friend struct MessageWindow;
}; // nsNativeAppSupportWin
@ -720,6 +722,7 @@ HSZ nsNativeAppSupportWin::mApplication = 0;
HSZ nsNativeAppSupportWin::mTopics[nsNativeAppSupportWin::topicCount] = { 0 };
DWORD nsNativeAppSupportWin::mInstance = 0;
nsIDOMWindow* nsNativeAppSupportWin::mInitialWindow = nsnull;
PRBool nsNativeAppSupportWin::mDidProfileStartup = PR_FALSE;
NOTIFYICONDATA nsNativeAppSupportWin::mIconData = { sizeof(NOTIFYICONDATA),
0,
@ -1593,7 +1596,7 @@ nsNativeAppSupportWin::EnsureProfile(nsICmdLineService* args)
// If we have a profile, everything is fine.
PRBool haveProfile;
rv = profileMgr->IsCurrentProfileAvailable(&haveProfile);
if (NS_SUCCEEDED(rv) && haveProfile)
if (mDidProfileStartup && NS_SUCCEEDED(rv) && haveProfile)
return NS_OK;
// If the profile selection is happening, fail.
@ -1603,6 +1606,8 @@ nsNativeAppSupportWin::EnsureProfile(nsICmdLineService* args)
rv = appShell->DoProfileStartup(args, PR_TRUE);
mDidProfileStartup = PR_TRUE;
return rv;
}
@ -2051,10 +2056,11 @@ nsNativeAppSupportWin::OnLastWindowClosing( nsIXULWindow *aWindow ) {
}
}
nsCOMPtr<nsIProfileInternal> profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
rv = profileMgr->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
nsCOMPtr<nsIObserverService> observerService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
observerService->Notify(nsnull, NS_LITERAL_STRING("session-logout").get(), nsnull);
mDidProfileStartup = PR_FALSE;
return NS_OK;
}