From 08da26b629fcf2541333dfe8b4c7a17dd0f16386 Mon Sep 17 00:00:00 2001 From: "naving%netscape.com" Date: Thu, 7 Jun 2001 05:09:48 +0000 Subject: [PATCH] 82764 r=bienvenu sr=sspitzer a=blizzard; make undo for multiple messages work across servers and also make it so that we do a copy when we do move/copy across message. 75936 r=bienvenu sr=mscott a=chofmann; clearing the copystate and calling onStopCopy() at the right place to make filing messages across server from search window work. --- .../resources/content/mailWindowOverlay.js | 4 +-- .../base/resources/content/messengerdnd.js | 5 ++-- mailnews/imap/src/nsImapMailFolder.cpp | 3 +-- mailnews/imap/src/nsImapProtocol.cpp | 10 ++++--- mailnews/local/src/nsLocalMailFolder.cpp | 26 ++++++++++++++----- mailnews/local/src/nsLocalUndoTxn.cpp | 7 ++++- mailnews/local/src/nsLocalUndoTxn.h | 1 + 7 files changed, 40 insertions(+), 16 deletions(-) diff --git a/mailnews/base/resources/content/mailWindowOverlay.js b/mailnews/base/resources/content/mailWindowOverlay.js index 738d8f7acea..d39397366e0 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.js +++ b/mailnews/base/resources/content/mailWindowOverlay.js @@ -484,9 +484,9 @@ function MsgMoveMessage(destFolder) var destUri = destFolder.getAttribute('id'); var destResource = RDF.GetResource(destUri); var destMsgFolder = destResource.QueryInterface(Components.interfaces.nsIMsgFolder); - + var sameServer = destMsgFolder.server == gDBView.msgFolder.server; // we don't move news messages, we copy them - if (isNewsURI(gDBView.msgFolder.URI)) { + if (isNewsURI(gDBView.msgFolder.URI) || !sameServer) { gDBView.doCommandWithFolder(nsMsgViewCommandType.copyMessages, destMsgFolder); } else { diff --git a/mailnews/base/resources/content/messengerdnd.js b/mailnews/base/resources/content/messengerdnd.js index 211d770b9a0..88a42b1b48e 100644 --- a/mailnews/base/resources/content/messengerdnd.js +++ b/mailnews/base/resources/content/messengerdnd.js @@ -399,10 +399,11 @@ function DropOnFolderTree(event) } else { // fix this, will not work for multiple 3 panes - if (!ctrlKeydown) { + var sameServer = (sourceServer == targetServer); + if (!ctrlKeydown && sameServer) { SetNextMessageAfterDelete(); } - messenger.CopyMessages(sourceFolder, targetFolder, list, !ctrlKeydown); + messenger.CopyMessages(sourceFolder, targetFolder, list, (!ctrlKeydown && sameServer)); } } catch (ex) { diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 88f6ca971b6..72381cc21b0 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -3866,6 +3866,7 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode) if (m_transactionManager && m_copyState->m_undoMsgTxn) m_transactionManager->DoTransaction(m_copyState->m_undoMsgTxn); ClearCopyState(aExitCode); + sendEndCopyNotification = PR_TRUE; } else NS_ASSERTION(PR_FALSE, "not clearing copy state"); @@ -4453,8 +4454,6 @@ nsImapMailFolder::CopyNextStreamMessage(nsIImapProtocol* aProtocol, PR_TRUE, PR_TRUE, nsnull, PR_FALSE); // we want to send this notification after the source messages have // been deleted. - if (mCopyListener) - mCopyListener->OnStopCopy(NS_OK); nsCOMPtr popFolder = do_QueryInterface(srcFolder); if (popFolder) //needed if move pop->imap to notify FE srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom); diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index 962dbb2e5fb..daf0f07fb6a 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -4770,7 +4770,7 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec, m_runningUrl->GetImapAction(&imapAction); if (GetServerStateParser().LastCommandSuccessful() && ( - imapAction == nsIImapUrl::nsImapAppendDraftFromFile )) + imapAction == nsIImapUrl::nsImapAppendDraftFromFile || imapAction == nsIImapUrl::nsImapAppendMsgFromFile )) { if (GetServerStateParser().GetCapabilityFlag() & kUidplusCapability) @@ -4794,7 +4794,11 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec, } } else if (m_imapExtensionSink) - { // *** code me to search for the newly appended message + { // *** code me to search for the newly appended message + // go to selected state + AutoSubscribeToMailboxIfNecessary(mailboxName); + SelectMailbox(mailboxName); + nsCString messageId; rv = m_imapExtensionSink->GetMessageId(this, &messageId, m_runningUrl); @@ -4804,7 +4808,7 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec, { command = "SEARCH SEEN HEADER Message-ID "; command.Append(messageId); - + // Clean up result sequence before issuing the cmd. GetServerStateParser().ResetSearchResultSequence(); diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index 9e2676867f3..9a6bf25eb91 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -2277,8 +2277,10 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded) newHdr->AndFlags(~MSG_FLAG_OFFLINE, &newHdrFlags); } } - - if (NS_SUCCEEDED(rv) && localUndoTxn && mCopyState->m_message) + PRBool isImap; + if (NS_SUCCEEDED(rv) && localUndoTxn) + localUndoTxn->GetSrcIsImap(&isImap); + if (NS_SUCCEEDED(rv) && localUndoTxn && (!isImap || !mCopyState->m_copyingMultipleMessages)) { nsMsgKey aKey; mCopyState->m_message->GetMessageKey(&aKey); @@ -2359,9 +2361,14 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded) srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom); nsCOMPtr srcSupport = do_QueryInterface(mCopyState->m_srcSupport); + nsCOMPtr listener =do_QueryInterface(mCopyState->m_listener); if (!mCopyState->m_copyingMultipleMessages || multipleCopiesFinished) ClearCopyState(PR_TRUE); + + if (listener) //notify after clearing the copy state; + listener->OnStopCopy(NS_OK); + if (NS_SUCCEEDED(result)) copyService->NotifyCompletion(srcSupport, this, rv); @@ -2403,10 +2410,11 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndMove() mTxnMgr->DoTransaction(mCopyState->m_undoMsgTxn); nsCOMPtr srcSupport = do_QueryInterface(mCopyState->m_srcSupport); - - if (mCopyState->m_listener) - mCopyState->m_listener->OnStopCopy(NS_OK); - ClearCopyState(PR_TRUE); // ### we don't know if it succeeded + nsCOMPtr listener =do_QueryInterface(mCopyState->m_listener); + ClearCopyState(PR_TRUE); //clear the copy state so that the next message from a different folder can be moved + if (listener) //notify after clearing the copy state; + listener->OnStopCopy(NS_OK); + // ### we don't know if it succeeded //passing in NS_OK because we only get in here if copy portion succeeded copyService->NotifyCompletion(srcSupport, this, NS_OK); @@ -2437,6 +2445,12 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndMessage(nsMsgKey key) if (NS_SUCCEEDED(rv)) localUndoTxn->GetMsgWindow(getter_AddRefs(msgWindow)); } + + if (localUndoTxn) + { + localUndoTxn->AddSrcKey(key); + localUndoTxn->AddDstKey(mCopyState->m_curDstKey); + } // I think this is always true for online to offline copy mCopyState->m_dummyEnvelopeNeeded = PR_TRUE; diff --git a/mailnews/local/src/nsLocalUndoTxn.cpp b/mailnews/local/src/nsLocalUndoTxn.cpp index 6d0f8d48e03..95316976c7f 100644 --- a/mailnews/local/src/nsLocalUndoTxn.cpp +++ b/mailnews/local/src/nsLocalUndoTxn.cpp @@ -97,7 +97,12 @@ nsLocalMoveCopyMsgTxn::Init(nsIMsgFolder* srcFolder, nsIMsgFolder* dstFolder, } return NS_OK; } - +nsresult +nsLocalMoveCopyMsgTxn::GetSrcIsImap(PRBool *isImap) +{ + *isImap = m_srcIsImap4; + return NS_OK; +} nsresult nsLocalMoveCopyMsgTxn::SetSrcFolder(nsIMsgFolder* srcFolder) { diff --git a/mailnews/local/src/nsLocalUndoTxn.h b/mailnews/local/src/nsLocalUndoTxn.h index f00722a7858..2583eea07b1 100644 --- a/mailnews/local/src/nsLocalUndoTxn.h +++ b/mailnews/local/src/nsLocalUndoTxn.h @@ -58,6 +58,7 @@ public: nsresult AddDstKey(nsMsgKey aKey); nsresult AddDstMsgSize(PRUint32 msgSize); nsresult SetSrcFolder(nsIMsgFolder* srcFolder); + nsresult GetSrcIsImap(PRBool *isImap); nsresult SetDstFolder(nsIMsgFolder* dstFolder); nsresult Init(nsIMsgFolder* srcFolder, nsIMsgFolder* dstFolder,