Bug 1071754 - Filter to move messages to IMAP folder on getting new mail doesn't work unless Filter after Junk Classification is selected. r=rkent, a=mkmelin
authoralta88
Sun, 28 Sep 2014 07:58:33 -0600
changeset 17045 359f6c0c65d1b39469c6c23efd485d67a7550d57
parent 17044 e147bfa72d662ecb9e8cf003cac4e46c140acc2b
child 17046 39eef55f4d647b751b156306f3f983a9ef1ba349
push id10569
push usermkmelin@iki.fi
push dateSat, 08 Nov 2014 19:18:42 +0000
treeherdercomm-central@39eef55f4d64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, mkmelin
bugs1071754
Bug 1071754 - Filter to move messages to IMAP folder on getting new mail doesn't work unless Filter after Junk Classification is selected. r=rkent, a=mkmelin
mailnews/local/src/nsLocalMailFolder.cpp
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -3574,28 +3574,36 @@ nsMsgLocalMailFolder::AddMessageBatch(ui
       NS_ENSURE_TRUE(newMailParser, NS_ERROR_OUT_OF_MEMORY);
       if (!mGettingNewMessages)
         newMailParser->DisableFilters();
       bool reusable;
       rv = msgStore->GetNewMsgOutputStream(this, getter_AddRefs(newHdr),
                                       &reusable,
                                       getter_AddRefs(outFileStream));
       NS_ENSURE_SUCCESS(rv, rv);
+
+      // Get a msgWindow. Proceed without one, but filter actions to imap folders
+      // will silently fail if not signed in and no window for a prompt.
+      nsCOMPtr<nsIMsgWindow> msgWindow;
+      nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
+      if (NS_SUCCEEDED(rv))
+        mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow));
+
       rv = newMailParser->Init(rootFolder, this,
-                               nullptr, newHdr, outFileStream);
+                               msgWindow, newHdr, outFileStream);
 
       uint32_t bytesWritten, messageLen = strlen(aMessages[i]);
       outFileStream->Write(aMessages[i], messageLen, &bytesWritten);
       newMailParser->BufferInput(aMessages[i], messageLen);
 
       msgStore->FinishNewMessage(outFileStream, newHdr);
       outFileStream->Close();
       outFileStream = nullptr;
+      newMailParser->OnStopRequest(nullptr, nullptr, NS_OK);
       newMailParser->EndMsgDownload();
-      newMailParser->OnStopRequest(nullptr, nullptr, NS_OK);
       hdrArray->AppendElement(newHdr, false);
     }
     NS_ADDREF(*aHdrArray = hdrArray);
   }
   ReleaseSemaphore(static_cast<nsIMsgLocalMailFolder*>(this));
   return rv;
 }