set forwarded flag on messages forwarded inline by message filters, r=standard8, bug 624337
authorDavid Bienvenu <bienvenu@nventure.com>
Wed, 19 Jan 2011 07:54:31 -0800
changeset 6981 73c0c88c59135386828001951495893c8424bfa3
parent 6980 e9f62190bdf069a792b236d8e31bc2670fcfd918
child 6982 44bfbaecd26681033f4b803c6408b47b18eabeff
push idunknown
push userunknown
push dateunknown
reviewersstandard8, bug
bugs624337
set forwarded flag on messages forwarded inline by message filters, r=standard8, bug 624337
mailnews/mime/src/mimedrft.cpp
--- a/mailnews/mime/src/mimedrft.cpp
+++ b/mailnews/mime/src/mimedrft.cpp
@@ -277,46 +277,54 @@ CreateTheComposeWindow(nsIMsgCompFields 
   nsCOMPtr<nsIMsgComposeService> msgComposeService =
            do_GetService(kCMsgComposeServiceCID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return msgComposeService->OpenComposeWindowWithParams(nsnull /* default chrome */, pMsgComposeParams);
 }
 
 nsresult
-SendTheMessage(nsIMsgCompFields *   compFields,
-               nsMsgAttachmentData *attachmentList,
-               MSG_ComposeType      composeType,
-               MSG_ComposeFormat    composeFormat,
-               nsIMsgIdentity *     identity,
-               const char *         originalMsgURI,
-               nsIMsgDBHdr *        origMsgHdr)
+ForwardMsgInline(nsIMsgCompFields *compFields,
+                 nsMsgAttachmentData *attachmentList,
+                 MSG_ComposeFormat composeFormat,
+                 nsIMsgIdentity *identity,
+                 const char *originalMsgURI,
+                 nsIMsgDBHdr *origMsgHdr)
 {
   nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams;
   nsresult rv = CreateComposeParams(pMsgComposeParams, compFields,
-                       attachmentList,
-                       composeType,
-                       composeFormat,
-                       identity,
-                       originalMsgURI,
-                       origMsgHdr);
+                                    attachmentList,
+                                    nsIMsgCompType::ForwardInline,
+                                    composeFormat,
+                                    identity,
+                                    originalMsgURI,
+                                    origMsgHdr);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgComposeService> msgComposeService =
            do_GetService(kCMsgComposeServiceCID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   // create the nsIMsgCompose object to send the object
   nsCOMPtr<nsIMsgCompose> pMsgCompose (do_CreateInstance(NS_MSGCOMPOSE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   /** initialize nsIMsgCompose, Send the message, wait for send completion response **/
   rv = pMsgCompose->Initialize(pMsgComposeParams, nsnull, nsnull);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  return pMsgCompose->SendMsg(nsIMsgSend::nsMsgDeliverNow, identity, nsnull, nsnull, nsnull) ;
+  rv = pMsgCompose->SendMsg(nsIMsgSend::nsMsgDeliverNow, identity, nsnull, nsnull, nsnull);
+  if (NS_SUCCEEDED(rv))
+  {
+    nsCOMPtr<nsIMsgFolder> origFolder;
+    origMsgHdr->GetFolder(getter_AddRefs(origFolder));
+    if (origFolder)
+      origFolder->AddMessageDispositionState(
+                  origMsgHdr, nsIMsgFolder::nsMsgDispositionState_Forwarded);
+  }
+  return rv;
 }
 
 nsresult
 CreateCompositionFields(const char        *from,
                         const char        *reply_to,
                         const char        *to,
                         const char        *cc,
                         const char        *bcc,
@@ -1582,22 +1590,25 @@ mime_parse_stream_complete (nsMIMESessio
         {
           if (convertToPlainText)
             fields->ConvertBodyToPlainText();
           if (mdd->overrideComposeFormat)
             composeFormat = nsIMsgCompFormat::OppositeOfDefault;
           if (mdd->forwardInlineFilter)
           {
             fields->SetTo(mdd->forwardToAddress);
-            SendTheMessage(fields, newAttachData, nsIMsgCompType::ForwardInline,
-                           composeFormat, mdd->identity, mdd->originalMsgURI,
-                           mdd->origMsgHdr);
+            ForwardMsgInline(fields, newAttachData, composeFormat,
+                             mdd->identity, mdd->originalMsgURI,
+                             mdd->origMsgHdr);
           }
           else
-            CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::ForwardInline, composeFormat, mdd->identity, mdd->originalMsgURI, mdd->origMsgHdr);
+            CreateTheComposeWindow(fields, newAttachData,
+                                   nsIMsgCompType::ForwardInline, composeFormat,
+                                   mdd->identity, mdd->originalMsgURI,
+                                   mdd->origMsgHdr);
         }
         else
         {
           fields->SetDraftId(mdd->url_name);
           CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::Draft, composeFormat, mdd->identity, mdd->originalMsgURI, mdd->origMsgHdr);
         }
       }
     }