nsCAutoString msgURI(originalMsgURI); PRInt32 i = msgURI.FindChar('?'); if (i != kNotFound) msgURI.Truncate(i); NS_UnescapeURL(msgURI); pMsgComposeParams->SetOriginalMsgURI(msgURI.get());
if (originalMsgURI) pMsgComposeParams->SetOriginalMsgURI(originalMsgURI);
CreateTheComposeWindow(nsIMsgCompFields *   compFields,                       nsMsgAttachmentData *attachmentList,                       MSG_ComposeType      composeType,                       MSG_ComposeFormat    composeFormat,                       nsIMsgIdentity *     identity,                       char *               originalMsgURI                       ){nsresult            rv;MSG_ComposeFormat   format = nsIMsgCompFormat::Default;#ifdef NS_DEBUGmime_dump_attachments ( attachmentList );#endif  nsMsgAttachmentData *curAttachment = attachmentList;  if (curAttachment)  {    nsCAutoString spec;    while (curAttachment && curAttachment->real_name) //JFD: Why do we check for real_name?    {      rv = curAttachment->url->GetSpec(spec);      if (NS_SUCCEEDED(rv))      {        nsCOMPtr<nsIMsgAttachment> attachment = do_CreateInstance(NS_MSGATTACHMENT_CONTRACTID, &rv);        if (NS_SUCCEEDED(rv) && attachment)        {          nsAutoString nameStr;          rv = ConvertToUnicode(msgCompHeaderInternalCharset(), curAttachment->real_name, nameStr);          if (NS_FAILED(rv))            nameStr.AssignWithConversion(curAttachment->real_name);          attachment->SetName(nameStr.get());          attachment->SetUrl(spec.get());          attachment->SetTemporary(PR_TRUE);          attachment->SetContentType(curAttachment->real_type);          attachment->SetMacType(curAttachment->x_mac_type);          attachment->SetMacCreator(curAttachment->x_mac_creator);          compFields->AddAttachment(attachment);        }      }      curAttachment++;    }  }  nsCOMPtr<nsIMsgComposeService> msgComposeService =            do_GetService(kCMsgComposeServiceCID, &rv);  if ((NS_FAILED(rv)) || (!msgComposeService))    return rv;     if (identity && composeType == nsIMsgCompType::ForwardInline)  {    PRBool composeHtml = PR_FALSE;    identity->GetComposeHtml(&composeHtml);    if (composeHtml)      format = nsIMsgCompFormat::HTML;    else    {      format = nsIMsgCompFormat::PlainText;      /* do we we need to convert the HTML body to plain text? */      if (composeFormat == nsIMsgCompFormat::HTML)        compFields->ConvertBodyToPlainText();    }  }  else    format = composeFormat;    nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams (do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv));  if (NS_SUCCEEDED(rv) && pMsgComposeParams)  {    pMsgComposeParams->SetType(composeType);    pMsgComposeParams->SetFormat(format);    pMsgComposeParams->SetIdentity(identity);    pMsgComposeParams->SetComposeFields(compFields);        //Lets cleanup the URI    nsCAutoString msgURI(originalMsgURI);    PRInt32 i = msgURI.FindChar('?');    if (i != kNotFound)      msgURI.Truncate(i);    NS_UnescapeURL(msgURI);    pMsgComposeParams->SetOriginalMsgURI(msgURI.get());        rv = msgComposeService->OpenComposeWindowWithParams(nsnull /* default chrome */, pMsgComposeParams);  }  return rv;}