mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
fix 130986 when imap logon redirector fails, shouldn't log out of connection (for mscott) r=me, sr=sspitzer a=asa, part of 114211 close imap folder db after move/copy into folder r=cavin, sr=sspitzer 129928 multiple drag/drop of local messages to imap folder failing r=sspitzer, sr=mscott, a=asa 130989 shouldn't display logon errors from biff with imap logon redirection r=cavin, sr=sspitzer, a=asa
This commit is contained in:
parent
4298b8f639
commit
5beb90a147
@ -67,7 +67,7 @@ interface nsIImapMailFolderSink : nsISupports {
|
||||
attribute boolean folderNeedsACLListed;
|
||||
attribute boolean folderNeedsSubscribing;
|
||||
attribute boolean folderNeedsAdded;
|
||||
attribute boolean folderVerifiedOnline;
|
||||
attribute boolean folderVerifiedOnline;
|
||||
string GetOnlineDelimiter();
|
||||
// Tell mail master about the newly selected mailbox
|
||||
void UpdateImapMailboxInfo(in nsIImapProtocol aProtocol,
|
||||
@ -86,16 +86,17 @@ interface nsIImapMailFolderSink : nsISupports {
|
||||
void AbortHeaderParseStream(in nsIImapProtocol aProtocol) ;
|
||||
|
||||
void OnlineCopyCompleted(in nsIImapProtocol aProtocol, in ImapOnlineCopyState aCopyState);
|
||||
void StartMessage(in nsIMsgMailNewsUrl aUrl);
|
||||
void EndMessage(in nsIMsgMailNewsUrl aUrl, in nsMsgKey uidOfMessage);
|
||||
void StartMessage(in nsIMsgMailNewsUrl aUrl);
|
||||
void EndMessage(in nsIMsgMailNewsUrl aUrl, in nsMsgKey uidOfMessage);
|
||||
|
||||
void NotifySearchHit(in nsIMsgMailNewsUrl aUrl, in string hitLine);
|
||||
void NotifySearchHit(in nsIMsgMailNewsUrl aUrl, in string hitLine);
|
||||
|
||||
// these two hokey methods are needed so we can try to make sure the imap url is released
|
||||
// on the UI thread. This in turn ensures that the objects the imap url holds on to
|
||||
// are only released / destroyed from the UI thread.
|
||||
void prepareToReleaseUrl(in nsIMsgMailNewsUrl aUrl);
|
||||
void releaseUrl();
|
||||
void copyNextStreamMessage(in boolean copySucceeded);
|
||||
// these two hokey methods are needed so we can try to make sure the imap url is released
|
||||
// on the UI thread. This in turn ensures that the objects the imap url holds on to
|
||||
// are only released / destroyed from the UI thread.
|
||||
void prepareToReleaseUrl(in nsIMsgMailNewsUrl aUrl);
|
||||
void releaseUrl();
|
||||
void closeMockChannel(in nsIImapMockChannel aChannel);
|
||||
void setUrlState(in nsIImapProtocol aProtocol, in nsIMsgMailNewsUrl aUrl, in boolean isRunning, in nsresult status);
|
||||
void releaseUrlCacheEntry(in nsIMsgMailNewsUrl aUrl);
|
||||
|
@ -80,9 +80,6 @@ public:
|
||||
msg_line_info* aInfo) = 0;
|
||||
NS_IMETHOD ProcessTunnel(nsIImapProtocol* aProtocol,
|
||||
TunnelInfo *aInfo) = 0;
|
||||
NS_IMETHOD CopyNextStreamMessage(nsIImapProtocol* aProtocol,
|
||||
nsIImapUrl * aUrl,
|
||||
PRBool copySucceeded) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -388,3 +388,6 @@
|
||||
## @name IMAP_REDIRECT_LOGIN_FAILED
|
||||
## @loc None
|
||||
5091=Login failed.
|
||||
|
||||
# LOCALIZATION NOTE (autoSubscribeText): %1$S is the imap folder.
|
||||
5092=Would you like to subscribe to %1$S?
|
||||
|
@ -674,7 +674,7 @@ char *nsIMAPNamespaceList::GenerateFullFolderNameWithDefaultNamespace(const char
|
||||
}
|
||||
else
|
||||
{
|
||||
// Could not find a namespace on the given host
|
||||
// Could not find other users namespace on the given host
|
||||
NS_ASSERTION(PR_FALSE, "couldn't find namespace for given host");
|
||||
}
|
||||
return (fullFolderName);
|
||||
|
@ -672,19 +672,19 @@ nsImapIncomingServer::CreateImapConnection(nsIEventQueue *aEventQueue,
|
||||
nsIImapUrl * aImapUrl,
|
||||
nsIImapProtocol ** aImapConnection)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool canRunUrlImmediately = PR_FALSE;
|
||||
nsresult rv = NS_OK;
|
||||
PRBool canRunUrlImmediately = PR_FALSE;
|
||||
PRBool canRunButBusy = PR_FALSE;
|
||||
nsCOMPtr<nsIImapProtocol> connection;
|
||||
nsCOMPtr<nsIImapProtocol> connection;
|
||||
nsCOMPtr<nsIImapProtocol> freeConnection;
|
||||
PRBool isBusy = PR_FALSE;
|
||||
PRBool isInboxConnection = PR_FALSE;
|
||||
nsXPIDLCString redirectorType;
|
||||
nsXPIDLCString redirectorType;
|
||||
|
||||
PR_CEnterMonitor(this);
|
||||
|
||||
GetRedirectorType(getter_Copies(redirectorType));
|
||||
PRBool redirectLogon = ((const char *) redirectorType && strlen((const char *) redirectorType) > 0);
|
||||
GetRedirectorType(getter_Copies(redirectorType));
|
||||
PRBool redirectLogon = ((const char *) redirectorType && strlen((const char *) redirectorType) > 0);
|
||||
|
||||
PRInt32 maxConnections = 5; // default to be five
|
||||
rv = GetMaximumConnectionsNumber(&maxConnections);
|
||||
@ -726,6 +726,7 @@ nsImapIncomingServer::CreateImapConnection(nsIEventQueue *aEventQueue,
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
connection = nsnull;
|
||||
rv = NS_OK; // don't want to return this error, just don't use the connection
|
||||
continue;
|
||||
}
|
||||
// if we haven't found a free connection, and this connection
|
||||
@ -769,6 +770,8 @@ nsImapIncomingServer::CreateImapConnection(nsIEventQueue *aEventQueue,
|
||||
userCancelled = PR_TRUE;
|
||||
}
|
||||
}
|
||||
nsImapState requiredState;
|
||||
aImapUrl->GetRequiredImapState(&requiredState);
|
||||
// if we got here and we have a connection, then we should return it!
|
||||
if (canRunUrlImmediately && connection)
|
||||
{
|
||||
@ -783,7 +786,12 @@ nsImapIncomingServer::CreateImapConnection(nsIEventQueue *aEventQueue,
|
||||
{
|
||||
rv = NS_BINDING_ABORTED; // user cancelled
|
||||
}
|
||||
else if (cnt < ((PRUint32)maxConnections) && aEventQueue)
|
||||
// CanHandleUrl will pretend that some types of urls require a selected state url
|
||||
// (e.g., a folder delete or msg append) but we shouldn't create new connections
|
||||
// for these types of urls if we have a free connection. So we check the actual
|
||||
// required state here.
|
||||
else if (cnt < ((PRUint32)maxConnections) && aEventQueue
|
||||
&& (!freeConnection || requiredState == nsIImapUrl::nsImapSelectedState))
|
||||
{
|
||||
rv = CreateProtocolInstance(aEventQueue, aImapConnection);
|
||||
}
|
||||
@ -2486,41 +2494,41 @@ NS_IMETHODIMP nsImapIncomingServer::RemoveChannelFromUrl(nsIMsgMailNewsUrl *aUrl
|
||||
|
||||
NS_IMETHODIMP nsImapIncomingServer::CreatePRUnicharStringFromUTF7(const char * aSourceString, PRUnichar **aUnicodeStr)
|
||||
{
|
||||
return CreateUnicodeStringFromUtf7(aSourceString, aUnicodeStr);
|
||||
return CreateUnicodeStringFromUtf7(aSourceString, aUnicodeStr);
|
||||
}
|
||||
|
||||
nsresult nsImapIncomingServer::RequestOverrideInfo(nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
nsCAutoString contractID(NS_MSGLOGONREDIRECTORSERVICE_CONTRACTID);
|
||||
nsXPIDLCString redirectorType;
|
||||
|
||||
GetRedirectorType(getter_Copies(redirectorType));
|
||||
contractID.Append('/');
|
||||
contractID.Append(redirectorType);
|
||||
|
||||
m_logonRedirector = do_GetService(contractID.get(), &rv);
|
||||
if (m_logonRedirector && NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr <nsIMsgLogonRedirectionRequester> logonRedirectorRequester;
|
||||
rv = QueryInterface(NS_GET_IID(nsIMsgLogonRedirectionRequester), getter_AddRefs(logonRedirectorRequester));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsXPIDLCString password;
|
||||
nsXPIDLCString userName;
|
||||
|
||||
nsresult rv;
|
||||
nsCAutoString contractID(NS_MSGLOGONREDIRECTORSERVICE_CONTRACTID);
|
||||
nsXPIDLCString redirectorType;
|
||||
|
||||
GetRedirectorType(getter_Copies(redirectorType));
|
||||
contractID.Append('/');
|
||||
contractID.Append(redirectorType);
|
||||
|
||||
m_logonRedirector = do_GetService(contractID.get(), &rv);
|
||||
if (m_logonRedirector && NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr <nsIMsgLogonRedirectionRequester> logonRedirectorRequester;
|
||||
rv = QueryInterface(NS_GET_IID(nsIMsgLogonRedirectionRequester), getter_AddRefs(logonRedirectorRequester));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsXPIDLCString password;
|
||||
nsXPIDLCString userName;
|
||||
PRBool requiresPassword = PR_TRUE;
|
||||
|
||||
|
||||
GetRealUsername(getter_Copies(userName));
|
||||
m_logonRedirector->RequiresPassword(userName, &requiresPassword);
|
||||
|
||||
if (requiresPassword)
|
||||
{
|
||||
GetPassword(getter_Copies(password));
|
||||
|
||||
if (password.IsEmpty())
|
||||
PromptForPassword(getter_Copies(password), aMsgWindow);
|
||||
|
||||
|
||||
if (password.IsEmpty())
|
||||
PromptForPassword(getter_Copies(password), aMsgWindow);
|
||||
|
||||
if (password.IsEmpty()) // if still empty then the user canceld out of the password dialog
|
||||
{
|
||||
// be sure to clear the waiting for connection info flag because we aren't waiting
|
||||
@ -2533,90 +2541,85 @@ nsresult nsImapIncomingServer::RequestOverrideInfo(nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
SetUserAuthenticated(PR_TRUE); // we are already authenicated
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIPrompt> dialogPrompter;
|
||||
if (aMsgWindow)
|
||||
aMsgWindow->GetPromptDialog(getter_AddRefs(dialogPrompter));
|
||||
rv = m_logonRedirector->Logon(userName, password, redirectorType, dialogPrompter, logonRedirectorRequester, nsMsgLogonRedirectionServiceIDs::Imap);
|
||||
rv = m_logonRedirector->Logon(userName, password, redirectorType, dialogPrompter, logonRedirectorRequester, nsMsgLogonRedirectionServiceIDs::Imap);
|
||||
if (NS_FAILED(rv)) return OnLogonRedirectionError(nsnull, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionError(const PRUnichar *pErrMsg, PRBool badPassword)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsXPIDLString progressString;
|
||||
GetImapStringByID(IMAP_REDIRECT_LOGIN_FAILED, getter_Copies(progressString));
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsXPIDLString progressString;
|
||||
GetImapStringByID(IMAP_REDIRECT_LOGIN_FAILED, getter_Copies(progressString));
|
||||
|
||||
nsCOMPtr<nsIMsgWindow> msgWindow;
|
||||
PRUint32 urlQueueCnt = 0;
|
||||
// pull the url out of the queue so we can get the msg window, and try to rerun it.
|
||||
m_urlQueue->Count(&urlQueueCnt);
|
||||
|
||||
if (urlQueueCnt > 0)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supportCtxt(getter_AddRefs(m_urlQueue->ElementAt(0)));
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl(do_QueryInterface(supportCtxt, &rv));
|
||||
// pull the url out of the queue so we can get the msg window, and try to rerun it.
|
||||
m_urlQueue->Count(&urlQueueCnt);
|
||||
|
||||
if (urlQueueCnt > 0)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supportCtxt(getter_AddRefs(m_urlQueue->ElementAt(0)));
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl(do_QueryInterface(supportCtxt, &rv));
|
||||
if (mailnewsUrl)
|
||||
mailnewsUrl->GetMsgWindow(getter_AddRefs(msgWindow));
|
||||
}
|
||||
|
||||
FEAlert(progressString, msgWindow);
|
||||
|
||||
|
||||
if (m_logonRedirector)
|
||||
{
|
||||
nsXPIDLCString userName;
|
||||
|
||||
GetRealUsername(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?
|
||||
if (urlQueueCnt > 0)
|
||||
{
|
||||
nsCOMPtr<nsISupports>
|
||||
aSupport(getter_AddRefs(m_urlQueue->ElementAt(0)));
|
||||
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryInterface(aSupport, &rv));
|
||||
|
||||
nsCOMPtr <nsIImapProtocol> imapProtocol;
|
||||
nsCOMPtr <nsIEventQueue> aEventQueue;
|
||||
// Get current thread envent queue
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(aEventQueue));
|
||||
|
||||
if (aImapUrl)
|
||||
{
|
||||
nsCOMPtr <nsIImapProtocol> protocolInstance ;
|
||||
m_waitingForConnectionInfo = PR_FALSE;
|
||||
rv = CreateImapConnection(aEventQueue, aImapUrl,
|
||||
getter_AddRefs(protocolInstance));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_redirectedLogonRetries = 0; // reset so next attempt will start at 0.
|
||||
if (urlQueueCnt > 0)
|
||||
{
|
||||
m_urlQueue->RemoveElementAt(0);
|
||||
m_urlConsumers.RemoveElementAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
// don't put up alert if no msg window - it means we're biffing.
|
||||
if (msgWindow)
|
||||
FEAlert(progressString, msgWindow);
|
||||
|
||||
|
||||
|
||||
if (badPassword)
|
||||
SetPassword(nsnull);
|
||||
|
||||
|
||||
if (badPassword && ++m_redirectedLogonRetries <= 3)
|
||||
{
|
||||
// this will force a reprompt for the password.
|
||||
// ### DMB TODO display error message?
|
||||
if (urlQueueCnt > 0)
|
||||
{
|
||||
nsCOMPtr<nsISupports>
|
||||
aSupport(getter_AddRefs(m_urlQueue->ElementAt(0)));
|
||||
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryInterface(aSupport, &rv));
|
||||
|
||||
nsCOMPtr <nsIImapProtocol> imapProtocol;
|
||||
nsCOMPtr <nsIEventQueue> aEventQueue;
|
||||
// Get current thread envent queue
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(aEventQueue));
|
||||
|
||||
if (aImapUrl)
|
||||
{
|
||||
nsCOMPtr <nsIImapProtocol> protocolInstance ;
|
||||
m_waitingForConnectionInfo = PR_FALSE;
|
||||
rv = CreateImapConnection(aEventQueue, aImapUrl,
|
||||
getter_AddRefs(protocolInstance));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_redirectedLogonRetries = 0; // reset so next attempt will start at 0.
|
||||
if (urlQueueCnt > 0)
|
||||
{
|
||||
m_urlQueue->RemoveElementAt(0);
|
||||
m_urlConsumers.RemoveElementAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -2630,56 +2633,56 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionProgress(nsMsgLogonRedirec
|
||||
/* reply with logon redirection data. */
|
||||
NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionReply(const PRUnichar *pHost, unsigned short pPort, const char *pCookieData, unsigned short pCookieSize)
|
||||
{
|
||||
PRBool urlRun = PR_FALSE;
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIImapProtocol> imapProtocol;
|
||||
nsCOMPtr <nsIEventQueue> aEventQueue;
|
||||
nsCAutoString cookie(pCookieData, pCookieSize);
|
||||
// Get current thread envent queue
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
PRBool urlRun = PR_FALSE;
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIImapProtocol> imapProtocol;
|
||||
nsCOMPtr <nsIEventQueue> aEventQueue;
|
||||
nsCAutoString cookie(pCookieData, pCookieSize);
|
||||
// Get current thread envent queue
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(aEventQueue));
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(aEventQueue));
|
||||
// we used to logoff the external requestor...we no longer need to do
|
||||
// that.
|
||||
|
||||
m_redirectedLogonRetries = 0; // we got through, so reset this counter.
|
||||
|
||||
|
||||
m_redirectedLogonRetries = 0; // we got through, so reset this counter.
|
||||
|
||||
PRUint32 cnt = 0;
|
||||
|
||||
|
||||
m_urlQueue->Count(&cnt);
|
||||
if (cnt > 0)
|
||||
{
|
||||
nsCOMPtr<nsISupports> aSupport(getter_AddRefs(m_urlQueue->ElementAt(0)));
|
||||
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryInterface(aSupport, &rv));
|
||||
|
||||
|
||||
if (aImapUrl)
|
||||
{
|
||||
nsISupports *aConsumer = (nsISupports*)m_urlConsumers.ElementAt(0);
|
||||
NS_IF_ADDREF(aConsumer);
|
||||
|
||||
nsCOMPtr <nsIImapProtocol> protocolInstance ;
|
||||
rv = CreateImapConnection(aEventQueue, aImapUrl, getter_AddRefs(protocolInstance));
|
||||
m_waitingForConnectionInfo = PR_FALSE;
|
||||
if (NS_SUCCEEDED(rv) && protocolInstance)
|
||||
nsCOMPtr <nsIImapProtocol> protocolInstance ;
|
||||
rv = CreateImapConnection(aEventQueue, aImapUrl, getter_AddRefs(protocolInstance));
|
||||
m_waitingForConnectionInfo = PR_FALSE;
|
||||
if (NS_SUCCEEDED(rv) && protocolInstance)
|
||||
{
|
||||
protocolInstance->OverrideConnectionInfo(pHost, pPort, cookie.get());
|
||||
nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
|
||||
if (NS_SUCCEEDED(rv) && url)
|
||||
{
|
||||
rv = protocolInstance->LoadUrl(url, aConsumer);
|
||||
urlRun = PR_TRUE;
|
||||
}
|
||||
protocolInstance->OverrideConnectionInfo(pHost, pPort, cookie.get());
|
||||
nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
|
||||
if (NS_SUCCEEDED(rv) && url)
|
||||
{
|
||||
rv = protocolInstance->LoadUrl(url, aConsumer);
|
||||
urlRun = PR_TRUE;
|
||||
}
|
||||
|
||||
m_urlQueue->RemoveElementAt(0);
|
||||
m_urlConsumers.RemoveElementAt(0);
|
||||
}
|
||||
|
||||
|
||||
NS_IF_RELEASE(aConsumer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -4116,7 +4116,7 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||
m_downloadingFolderForOfflineUse = PR_FALSE;
|
||||
SetNotifyDownloadedLines(PR_FALSE);
|
||||
nsCOMPtr<nsIMsgMailSession> session =
|
||||
do_GetService(kMsgMailSessionCID, &rv);
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
nsCOMPtr <nsIMsgCopyServiceListener> listener;
|
||||
if (aUrl)
|
||||
{
|
||||
@ -4207,6 +4207,12 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||
ClearCopyState(aExitCode);
|
||||
sendEndCopyNotification = PR_TRUE;
|
||||
}
|
||||
// we're the dest folder of a move/copy - if we're not open in the ui,
|
||||
// then we should clear our nsMsgDatabase pointer. Otherwise, the db would
|
||||
// be open until the user selected it and then selected another folder.
|
||||
// but don't do this for the trash or inbox - we'll leave them open
|
||||
if (!folderOpen && ! (mFlags & (MSG_FOLDER_FLAG_TRASH | MSG_FOLDER_FLAG_INBOX)))
|
||||
SetMsgDatabase(nsnull);
|
||||
break;
|
||||
case nsIImapUrl::nsImapSubtractMsgFlags:
|
||||
{
|
||||
@ -5376,52 +5382,38 @@ nsImapMailFolder::ProcessTunnel(nsIImapProtocol* aProtocol,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::CopyNextStreamMessage(nsIImapProtocol* aProtocol,
|
||||
nsIImapUrl * aUrl,
|
||||
PRBool copySucceeded)
|
||||
nsImapMailFolder::CopyNextStreamMessage(PRBool copySucceeded)
|
||||
{
|
||||
//if copy has failed it could be either user interrupted it or for some other reason
|
||||
//don't do any subsequent copies or delete src messages if it is move
|
||||
|
||||
if (!copySucceeded)
|
||||
if (!copySucceeded || !m_copyState)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
if (!aUrl)
|
||||
return rv;
|
||||
nsCOMPtr<nsISupports> copyState;
|
||||
aUrl->GetCopyState(getter_AddRefs(copyState));
|
||||
if (!copyState)
|
||||
return rv;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsImapMailCopyState> mailCopyState = do_QueryInterface(copyState,
|
||||
&rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!mailCopyState->m_streamCopy)
|
||||
if (!m_copyState->m_streamCopy)
|
||||
return NS_OK;
|
||||
|
||||
if (mailCopyState->m_curIndex < mailCopyState->m_totalCount)
|
||||
if (m_copyState->m_curIndex < m_copyState->m_totalCount)
|
||||
{
|
||||
nsCOMPtr<nsISupports> aSupport =
|
||||
getter_AddRefs(mailCopyState->m_messages->ElementAt
|
||||
(mailCopyState->m_curIndex));
|
||||
mailCopyState->m_message = do_QueryInterface(aSupport,
|
||||
getter_AddRefs(m_copyState->m_messages->ElementAt
|
||||
(m_copyState->m_curIndex));
|
||||
m_copyState->m_message = do_QueryInterface(aSupport,
|
||||
&rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = CopyStreamMessage(mailCopyState->m_message,
|
||||
this, mailCopyState->m_msgWindow, mailCopyState->m_isMove);
|
||||
rv = CopyStreamMessage(m_copyState->m_message,
|
||||
this, m_copyState->m_msgWindow, m_copyState->m_isMove);
|
||||
}
|
||||
}
|
||||
else if (mailCopyState->m_isMove)
|
||||
else if (m_copyState->m_isMove)
|
||||
{
|
||||
nsCOMPtr<nsIMsgFolder> srcFolder =
|
||||
do_QueryInterface(mailCopyState->m_srcSupport, &rv);
|
||||
do_QueryInterface(m_copyState->m_srcSupport, &rv);
|
||||
if (NS_SUCCEEDED(rv) && srcFolder)
|
||||
{
|
||||
srcFolder->DeleteMessages(mailCopyState->m_messages, nsnull,
|
||||
srcFolder->DeleteMessages(m_copyState->m_messages, nsnull,
|
||||
PR_TRUE, PR_TRUE, nsnull, PR_FALSE);
|
||||
// we want to send this notification after the source messages have
|
||||
// been deleted.
|
||||
|
@ -340,9 +340,6 @@ public:
|
||||
NS_IMETHOD ProcessTunnel(nsIImapProtocol* aProtocol,
|
||||
TunnelInfo *aInfo);
|
||||
|
||||
NS_IMETHOD CopyNextStreamMessage(nsIImapProtocol* aProtocol,
|
||||
nsIImapUrl * aUrl,
|
||||
PRBool copySucceeded);
|
||||
NS_IMETHOD MatchName(nsString *name, PRBool *matches);
|
||||
// nsIMsgFilterHitNotification method(s)
|
||||
NS_IMETHOD ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindow *msgWindow, PRBool *applyMore);
|
||||
|
@ -999,7 +999,6 @@ nsImapProtocol::ImapThreadMainLoop()
|
||||
// in the case of the server dropping the connection, this call is reputed
|
||||
// to make it so that we process the :OnStop notification.
|
||||
m_eventQueue->ProcessPendingEvents();
|
||||
// m_sinkEventQueue->ProcessPendingEvents();
|
||||
|
||||
if (m_nextUrlReadyToRun && m_runningUrl)
|
||||
{
|
||||
@ -1211,11 +1210,6 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
||||
}
|
||||
m_lastActiveTime = PR_Now(); // ** jt -- is this the best place for time stamp
|
||||
SetFlag(IMAP_CLEAN_UP_URL_STATE);
|
||||
if (GetConnectionStatus() >= 0 && m_imapMiscellaneousSink && m_runningUrl)
|
||||
{
|
||||
m_imapMiscellaneousSink->CopyNextStreamMessage(this, m_runningUrl, GetServerStateParser().LastCommandSuccessful());
|
||||
WaitForFEEventCompletion();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_bienvenu1
|
||||
mailnewsurl->GetSpec(getter_Copies(urlSpec));
|
||||
@ -1225,12 +1219,20 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
||||
// BEFORE calling ReleaseUrlState
|
||||
mailnewsurl = nsnull;
|
||||
|
||||
// save the imap folder sink since we need it to do the CopyNextStreamMessage
|
||||
nsCOMPtr<nsIImapMailFolderSink> imapMailFolderSink = m_imapMailFolderSink;
|
||||
// release the url as we are done with it...
|
||||
ReleaseUrlState();
|
||||
ResetProgressInfo();
|
||||
m_urlInProgress = PR_FALSE;
|
||||
ClearFlag(IMAP_CLEAN_UP_URL_STATE);
|
||||
|
||||
if (GetConnectionStatus() >= 0 && imapMailFolderSink)
|
||||
{
|
||||
imapMailFolderSink->CopyNextStreamMessage(GetServerStateParser().LastCommandSuccessful());
|
||||
imapMailFolderSink = nsnull;
|
||||
}
|
||||
|
||||
// now try queued urls, now that we've released this connection.
|
||||
if (m_imapServerSink)
|
||||
{
|
||||
@ -1321,7 +1323,7 @@ NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIRequest *request, nsISupports *c
|
||||
NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus)
|
||||
{
|
||||
|
||||
PRBool killThread = PR_FALSE;
|
||||
PRBool killThread = PR_TRUE; // we always want to kill the thread, I believe.
|
||||
|
||||
if (NS_FAILED(aStatus))
|
||||
{
|
||||
@ -7203,6 +7205,11 @@ nsImapMockChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor *entry, nsCache
|
||||
|
||||
NS_ENSURE_ARG(m_url); // kick out if m_url is null for some reason.
|
||||
|
||||
#ifdef DEBUG_bienvenu
|
||||
nsXPIDLCString entryKey;
|
||||
entry->GetKey(getter_Copies(entryKey));
|
||||
printf("%s with access %ld status %ld\n", entryKey.get(), access, status);
|
||||
#endif
|
||||
if (NS_SUCCEEDED(status))
|
||||
{
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_url, &rv);
|
||||
@ -7210,11 +7217,6 @@ nsImapMockChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor *entry, nsCache
|
||||
|
||||
if (mTryingToReadPart && access & nsICache::ACCESS_WRITE && !(access & nsICache::ACCESS_READ))
|
||||
{
|
||||
#ifdef DEBUG_bienvenu
|
||||
nsXPIDLCString entryKey;
|
||||
entry->GetKey(getter_Copies(entryKey));
|
||||
printf("dooming %s with access %ld\n", entryKey.get(), access);
|
||||
#endif
|
||||
entry->Doom();
|
||||
// whoops, we're looking for a part, but didn't find it. Fall back to fetching the whole msg.
|
||||
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(m_url);
|
||||
@ -7231,19 +7233,18 @@ nsImapMockChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor *entry, nsCache
|
||||
nsCOMPtr<nsIStreamListenerTee> tee = do_CreateInstance(kStreamListenerTeeCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
||||
nsCOMPtr<nsITransport> transport;
|
||||
rv = entry->GetTransport(getter_AddRefs(transport));
|
||||
nsCOMPtr<nsITransport> transport;
|
||||
rv = entry->GetTransport(getter_AddRefs(transport));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIOutputStream> out;
|
||||
nsCOMPtr<nsIOutputStream> out;
|
||||
// this will fail with the mem cache turned off, so we need to fall through
|
||||
// to ReadFromImapConnection instead of aborting with NS_ENSURE_SUCCESS(rv,rv)
|
||||
rv = transport->OpenOutputStream(0, PRUint32(-1), 0, getter_AddRefs(out));
|
||||
rv = transport->OpenOutputStream(0, PRUint32(-1), 0, getter_AddRefs(out));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = tee->Init(m_channelListener, out);
|
||||
m_channelListener = do_QueryInterface(tee);
|
||||
rv = tee->Init(m_channelListener, out);
|
||||
m_channelListener = do_QueryInterface(tee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,37 +516,6 @@ nsImapMiscellaneousSinkProxy::ProcessTunnel(nsIImapProtocol* aProtocol,
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMiscellaneousSinkProxy::CopyNextStreamMessage(nsIImapProtocol* aProtocol,
|
||||
nsIImapUrl * aUrl,
|
||||
PRBool copySucceeded )
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
NS_PRECONDITION (aUrl, "Oops... null aUrl");
|
||||
NS_ASSERTION (m_protocol == aProtocol, "Ooh ooh, wrong protocol");
|
||||
|
||||
if (PR_GetCurrentThread() == m_thread)
|
||||
{
|
||||
CopyNextStreamMessageProxyEvent *ev =
|
||||
new CopyNextStreamMessageProxyEvent(this, aUrl, copySucceeded);
|
||||
if(nsnull == ev)
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
{
|
||||
ev->SetNotifyCompletion(PR_TRUE);
|
||||
ev->PostEvent(m_eventQueue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res = m_realImapMiscellaneousSink->CopyNextStreamMessage(aProtocol,
|
||||
aUrl,
|
||||
copySucceeded);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
|
||||
@ -932,28 +901,3 @@ ProcessTunnelProxyEvent::HandleEvent()
|
||||
return res;
|
||||
}
|
||||
|
||||
CopyNextStreamMessageProxyEvent::CopyNextStreamMessageProxyEvent(
|
||||
nsImapMiscellaneousSinkProxy* aProxy, nsIImapUrl * aUrl, PRBool copySucceeded ) :
|
||||
nsImapMiscellaneousSinkProxyEvent(aProxy)
|
||||
{
|
||||
NS_ASSERTION (aUrl, "Oops... a null url");
|
||||
// potential ownership/lifetime problem here, but incoming server
|
||||
// shouldn't be deleted while urls are running.
|
||||
m_Url = aUrl;
|
||||
m_copySucceeded = copySucceeded;
|
||||
}
|
||||
|
||||
CopyNextStreamMessageProxyEvent::~CopyNextStreamMessageProxyEvent()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CopyNextStreamMessageProxyEvent::HandleEvent()
|
||||
{
|
||||
nsresult res = m_proxy->m_realImapMiscellaneousSink->CopyNextStreamMessage(
|
||||
m_proxy->m_protocol, m_Url, m_copySucceeded);
|
||||
if (m_notifyCompletion)
|
||||
m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -124,10 +124,6 @@ public:
|
||||
msg_line_info* aInfo);
|
||||
NS_IMETHOD ProcessTunnel(nsIImapProtocol* aProtocol,
|
||||
TunnelInfo *aInfo);
|
||||
NS_IMETHOD CopyNextStreamMessage(nsIImapProtocol* aProtocl,
|
||||
nsIImapUrl * aUrl,
|
||||
PRBool copySucceeded);
|
||||
|
||||
nsIImapMiscellaneousSink* m_realImapMiscellaneousSink;
|
||||
};
|
||||
|
||||
@ -282,15 +278,4 @@ struct ProcessTunnelProxyEvent : public nsImapMiscellaneousSinkProxyEvent
|
||||
TunnelInfo m_tunnelInfo;
|
||||
};
|
||||
|
||||
struct CopyNextStreamMessageProxyEvent : public nsImapMiscellaneousSinkProxyEvent
|
||||
{
|
||||
CopyNextStreamMessageProxyEvent(nsImapMiscellaneousSinkProxy* aProxy,
|
||||
nsIImapUrl * aUrl,
|
||||
PRBool copySucceeded);
|
||||
virtual ~CopyNextStreamMessageProxyEvent();
|
||||
NS_IMETHOD HandleEvent();
|
||||
nsCOMPtr<nsIImapUrl> m_Url;
|
||||
PRBool m_copySucceeded;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user