fix logon referral stuff to put up error messages and reprompt a=phil,r=mscott 28201 28203

This commit is contained in:
bienvenu%netscape.com 2000-02-24 04:27:16 +00:00
Родитель 65dad6ba58
Коммит c8bac6b070
3 изменённых файлов: 77 добавлений и 15 удалений

Просмотреть файл

@ -16,7 +16,7 @@ interface nsMsgLogonRedirectionStates
interface nsIMsgLogonRedirectionRequester : nsISupports interface nsIMsgLogonRedirectionRequester : nsISupports
{ {
/* Erron on processing the logon redirection */ /* Erron on processing the logon redirection */
void OnLogonRedirectionError(in wstring pErrMsg); void OnLogonRedirectionError(in wstring pErrMsg, in boolean badPassword);
/* Logon Redirection Progress */ /* Logon Redirection Progress */
void OnLogonRedirectionProgress(in nsMsgLogonRedirectionState pState); void OnLogonRedirectionProgress(in nsMsgLogonRedirectionState pState);
@ -30,6 +30,6 @@ interface nsIMsgLogonRedirectionRequester : nsISupports
interface nsIMsgLogonRedirector : nsISupports interface nsIMsgLogonRedirector : nsISupports
{ {
void Logon(in string userName, in string password, in nsIMsgLogonRedirectionRequester listener); void Logon(in string userName, in string password, in nsIMsgLogonRedirectionRequester listener);
void Logoff(); /* might not need this one */ void Logoff(in string userName); /* might not need this one */
}; };

Просмотреть файл

@ -100,6 +100,7 @@ nsImapIncomingServer::nsImapIncomingServer()
rv = NS_NewISupportsArray(getter_AddRefs(m_urlQueue)); rv = NS_NewISupportsArray(getter_AddRefs(m_urlQueue));
m_capability = kCapabilityUndefined; m_capability = kCapabilityUndefined;
m_waitingForConnectionInfo = PR_FALSE; m_waitingForConnectionInfo = PR_FALSE;
m_redirectedLogonRetries = 0;
} }
nsImapIncomingServer::~nsImapIncomingServer() nsImapIncomingServer::~nsImapIncomingServer()
@ -1575,8 +1576,8 @@ nsresult nsImapIncomingServer::RequestOverrideInfo(nsIMsgWindow *aMsgWindow)
progID.Append('/'); progID.Append('/');
progID.Append(redirectorType); progID.Append(redirectorType);
nsCOMPtr <nsIMsgLogonRedirector> redirector = do_GetService(progID.GetBuffer(), &rv); m_logonRedirector = do_GetService(progID.GetBuffer(), &rv);
if (redirector && NS_SUCCEEDED(rv)) if (m_logonRedirector && NS_SUCCEEDED(rv))
{ {
nsCOMPtr <nsIMsgLogonRedirectionRequester> logonRedirectorRequester; nsCOMPtr <nsIMsgLogonRedirectionRequester> logonRedirectorRequester;
rv = QueryInterface(NS_GET_IID(nsIMsgLogonRedirectionRequester), getter_AddRefs(logonRedirectorRequester)); rv = QueryInterface(NS_GET_IID(nsIMsgLogonRedirectionRequester), getter_AddRefs(logonRedirectorRequester));
@ -1590,17 +1591,79 @@ nsresult nsImapIncomingServer::RequestOverrideInfo(nsIMsgWindow *aMsgWindow)
if (!((const char *) password) || nsCRT::strlen((const char *) password) == 0) if (!((const char *) password) || nsCRT::strlen((const char *) password) == 0)
PromptForPassword(getter_Copies(password), aMsgWindow); PromptForPassword(getter_Copies(password), aMsgWindow);
rv = redirector->Logon(userName, password, logonRedirectorRequester); rv = m_logonRedirector->Logon(userName, password, logonRedirectorRequester);
} }
} }
return rv; return rv;
} }
NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionError(const PRUnichar *pErrMsg) NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionError(const PRUnichar *pErrMsg, PRBool badPassword)
{ {
// ### DMB TODO display error message? nsresult rv = NS_OK;
return NS_OK;
nsXPIDLString progressString;
GetImapStringByID(IMAP_LOGIN_FAILED, getter_Copies(progressString));
FEAlert(progressString);
if (m_logonRedirector)
{
nsXPIDLCString userName;
GetUsername(getter_Copies(userName));
m_logonRedirector->Logoff(userName);
}
if (badPassword)
SetPassword(nsnull);
if (badPassword && ++m_redirectedLogonRetries <= 3)
{
// this will force a reprompt for the password.
// ### DMB TODO display error message?
PRUint32 cnt = 0;
// pull the url out of the queue so we can get the msg window, and try to rerun it.
m_urlQueue->Count(&cnt);
if (cnt > 0)
{
nsCOMPtr<nsISupports>
aSupport(getter_AddRefs(m_urlQueue->ElementAt(0)));
nsCOMPtr<nsIImapUrl>
aImapUrl(do_QueryInterface(aSupport, &rv));
PRBool urlRun = PR_FALSE;
nsresult rv;
nsCOMPtr <nsIImapProtocol> imapProtocol;
nsCOMPtr <nsIEventQueue> aEventQueue;
// Get current thread envent queue
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pEventQService)
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
getter_AddRefs(aEventQueue));
if (aImapUrl)
{
nsISupports *aConsumer =
(nsISupports*)m_urlConsumers.ElementAt(0);
NS_IF_ADDREF(aConsumer);
nsCOMPtr <nsIImapProtocol> protocolInstance ;
m_waitingForConnectionInfo = PR_FALSE;
rv = CreateImapConnection(aEventQueue, aImapUrl,
getter_AddRefs(protocolInstance));
m_urlQueue->RemoveElementAt(0);
m_urlConsumers.RemoveElementAt(0);
NS_IF_RELEASE(aConsumer);
}
}
}
else
m_redirectedLogonRetries = 0; // reset so next attempt will start at 0.
return rv;
} }
/* Logon Redirection Progress */ /* Logon Redirection Progress */
@ -1618,14 +1681,12 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionReply(const PRUnichar *pHo
nsCOMPtr <nsIEventQueue> aEventQueue; nsCOMPtr <nsIEventQueue> aEventQueue;
nsCAutoString cookie(pCookieData, pCookieSize); nsCAutoString cookie(pCookieData, pCookieSize);
// Get current thread envent queue // Get current thread envent queue
#ifdef DEBUG_bienvenu
pPort = 144; // while server guys debug their stuff, hard code port to 144 (not 143)
#endif
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv); NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
if (NS_SUCCEEDED(rv) && pEventQService) if (NS_SUCCEEDED(rv) && pEventQService)
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
getter_AddRefs(aEventQueue)); getter_AddRefs(aEventQueue));
m_redirectedLogonRetries = 0; // we got through, so reset this counter.
PRUint32 cnt = 0; PRUint32 cnt = 0;
@ -1644,11 +1705,10 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionReply(const PRUnichar *pHo
NS_IF_ADDREF(aConsumer); NS_IF_ADDREF(aConsumer);
nsCOMPtr <nsIImapProtocol> protocolInstance ; nsCOMPtr <nsIImapProtocol> protocolInstance ;
rv = CreateImapConnection(aEventQueue, aImapUrl, rv = CreateImapConnection(aEventQueue, aImapUrl, getter_AddRefs(protocolInstance));
getter_AddRefs(protocolInstance));
m_waitingForConnectionInfo = PR_FALSE; m_waitingForConnectionInfo = PR_FALSE;
if (NS_SUCCEEDED(rv) && protocolInstance) if (NS_SUCCEEDED(rv) && protocolInstance)
{ {
protocolInstance->OverrideConnectionInfo(pHost, pPort, cookie.GetBuffer()); protocolInstance->OverrideConnectionInfo(pHost, pPort, cookie.GetBuffer());
nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv); nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);

Просмотреть файл

@ -80,6 +80,8 @@ private:
PRUint32 m_capability; PRUint32 m_capability;
nsCString m_manageMailAccountUrl; nsCString m_manageMailAccountUrl;
PRBool m_waitingForConnectionInfo; PRBool m_waitingForConnectionInfo;
PRInt32 m_redirectedLogonRetries;
nsCOMPtr<nsIMsgLogonRedirector> m_logonRedirector;
}; };