fix 370786, detaching attachment from imap message doesn't reselect the message after the operation is done, sr=mscott

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@220797 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bienvenu%nventure.com
2007-02-23 03:53:06 +00:00
parent c224554c1c
commit 20e1329f8d
2 changed files with 30 additions and 6 deletions

View File

@@ -2762,7 +2762,16 @@ public:
nsCOMPtr<nsIMsgWindow> mMsgWindow; // our UI window
PRUint32 mNewMessageKey; // new message key
PRUint32 mOrigMsgFlags;
// temp
enum {
eStarting,
eCopyingNewMsg,
eUpdatingFolder, // for IMAP
eDeletingOldMessage,
eSelectingNewMessage
} m_state;
// temp
PRBool mWrittenExtra;
PRBool mDetaching;
nsCStringArray mDetachedFileUris;
@@ -2811,6 +2820,7 @@ nsDelAttachListener::OnStopRequest(nsIRequest * aRequest, nsISupports * aContext
mMsgFileSpec->CloseStream();
mNewMessageKey = PR_UINT32_MAX;
nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID);
m_state = eCopyingNewMsg;
if (copyService)
rv = copyService->CopyFileMessage(mMsgFileSpec, mMessageFolder, nsnull, PR_FALSE,
mOrigMsgFlags, listenerCopyService, mMsgWindow);
@@ -2855,6 +2865,7 @@ nsresult nsDelAttachListener::DeleteOriginalMessage()
QueryInterface( NS_GET_IID(nsIMsgCopyServiceListener), getter_AddRefs(listenerCopyService) );
mOriginalMessage = nsnull;
m_state = eDeletingOldMessage;
return mMessageFolder->DeleteMessages(
messageArray, // messages
mMsgWindow, // msgWindow
@@ -2885,13 +2896,14 @@ NS_IMETHODIMP
nsDelAttachListener::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
{
nsresult rv = NS_OK;
// the imap code gets here, since the delete triggers an OnStopRunningUrl.
// the local msg code doesn't get here.
const char * messageUri = mAttach->mAttachmentArray[0].mMessageUri;
if (mOriginalMessage && !strncmp(messageUri, "imap-message:", 13))
rv = DeleteOriginalMessage();
{
if (m_state == eUpdatingFolder)
rv = DeleteOriginalMessage();
}
// check if we've deleted the original message, and we know the new msg id.
else if (!mOriginalMessage && mNewMessageKey != PR_UINT32_MAX && mMsgWindow)
else if (m_state == eDeletingOldMessage && mMsgWindow)
SelectNewMessage();
return rv;
@@ -2942,7 +2954,7 @@ nsDelAttachListener::OnStopCopy(nsresult aStatus)
return aStatus;
// check if we've deleted the original message, and we know the new msg id.
if (!mOriginalMessage && mNewMessageKey != PR_UINT32_MAX && mMsgWindow)
if (m_state == eDeletingOldMessage && mMsgWindow)
SelectNewMessage();
// do this for non-imap messages - for imap, we'll do the delete in
// OnStopRunningUrl. For local messages, we won't get an OnStopRunningUrl
@@ -2955,6 +2967,8 @@ nsDelAttachListener::OnStopCopy(nsresult aStatus)
const char * messageUri = mAttach->mAttachmentArray[0].mMessageUri;
if (mOriginalMessage && strncmp(messageUri, "imap-message:", 13))
return DeleteOriginalMessage();
else
m_state = eUpdatingFolder;
return NS_OK;
}
@@ -2968,6 +2982,7 @@ nsDelAttachListener::nsDelAttachListener()
mSaveFirst = PR_FALSE;
mWrittenExtra = PR_FALSE;
mNewMessageKey = PR_UINT32_MAX;
m_state = eStarting;
}
nsDelAttachListener::~nsDelAttachListener()

View File

@@ -4990,7 +4990,16 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
if (m_copyState->m_curIndex >= m_copyState->m_totalCount)
{
if (folderOpen)
{
// This gives a way for the caller to get notified
// when the UpdateFolder url is done.
nsCOMPtr <nsIUrlListener> saveUrlListener = m_urlListener;
if (m_copyState->m_listener)
m_urlListener = do_QueryInterface(m_copyState->m_listener);
UpdateFolder(msgWindow);
m_urlListener = saveUrlListener;
}
if (m_copyState->m_msgWindow && m_copyState->m_undoMsgTxn)
{
nsCOMPtr<nsITransactionManager> txnMgr;