Bug 1493143 - Allow copy service to find request by dstFolder for folder copy/move; change IMAP notify accordingly. r+a=jorgk
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Fri, 21 Sep 2018 05:50:00 +0200
changeset 33050 788a85e7fd34
parent 33049 90c267d6d48f
child 33051 04ee89d424ba
push id386
push userclokep@gmail.com
push dateTue, 23 Oct 2018 00:48:12 +0000
bugs1493143
Bug 1493143 - Allow copy service to find request by dstFolder for folder copy/move; change IMAP notify accordingly. r+a=jorgk
mailnews/base/src/nsMsgCopyService.cpp
mailnews/imap/src/nsImapMailFolder.cpp
--- a/mailnews/base/src/nsMsgCopyService.cpp
+++ b/mailnews/base/src/nsMsgCopyService.cpp
@@ -375,16 +375,22 @@ nsCopyRequest*
 nsMsgCopyService::FindRequest(nsISupports* aSupport,
                               nsIMsgFolder* dstFolder)
 {
   nsCopyRequest* copyRequest = nullptr;
   uint32_t cnt = m_copyRequests.Length();
   for (uint32_t i = 0; i < cnt; i++)
   {
     copyRequest = m_copyRequests.ElementAt(i);
+    if (copyRequest->m_srcSupport.get() == aSupport &&
+        copyRequest->m_dstFolder.get() == dstFolder)
+      break;
+
+    // When copying folders the notification of the message copy serves as a
+    // proxy for the folder copy. Check for that here.
     if (copyRequest->m_requestType == nsCopyFoldersType)
     {
         // If the src is different then check next request.
         if (copyRequest->m_srcSupport.get() != aSupport)
         {
           copyRequest = nullptr;
           continue;
         }
@@ -410,19 +416,16 @@ nsMsgCopyService::FindRequest(nsISupport
         {
           copyRequest = nullptr;
           continue;
         }
 
         if (copyRequest->m_dstFolderName == folderName)
           break;
     }
-    else if (copyRequest->m_srcSupport.get() == aSupport &&
-        copyRequest->m_dstFolder.get() == dstFolder)
-        break;
     else
         copyRequest = nullptr;
   }
 
   return copyRequest;
 }
 
 NS_IMPL_ISUPPORTS(nsMsgCopyService, nsIMsgCopyService)
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -5454,22 +5454,17 @@ nsImapMailFolder::OnStopRunningUrl(nsIUR
       case nsIImapUrl::nsImapMoveFolderHierarchy:
         if (m_copyState) // delete folder gets here, but w/o an m_copyState
         {
           nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
           NS_ENSURE_SUCCESS(rv, rv);
           nsCOMPtr<nsIMsgFolder> srcFolder = do_QueryInterface(m_copyState->m_srcSupport);
           if (srcFolder)
           {
-            nsCOMPtr<nsIMsgFolder> destFolder;
-            nsString srcName;
-            srcFolder->GetName(srcName);
-            GetChildNamed(srcName, getter_AddRefs(destFolder));
-            if (destFolder)
-              copyService->NotifyCompletion(m_copyState->m_srcSupport, destFolder, aExitCode);
+            copyService->NotifyCompletion(m_copyState->m_srcSupport, this, aExitCode);
           }
           m_copyState = nullptr;
         }
         break;
       case nsIImapUrl::nsImapRenameFolder:
         if (NS_FAILED(aExitCode))
         {
           NotifyFolderEvent(kRenameCompleted);