PL_strlen(body), &newBody, &newBodyLen, NULL);
nsCRT::strlen(body), &newBody, &newBodyLen, NULL);
mime_parse_stream_complete (nsMIMESession *stream){  struct mime_draft_data *mdd = (struct mime_draft_data *) stream->data_object;  nsIMsgCompFields *fields = NULL;  int htmlAction = 0;  int lineWidth = 0;    char *host = 0;  char *news_host = 0;  char *to_and_cc = 0;  char *re_subject = 0;  char *new_refs = 0;  char *from = 0;  char *repl = 0;  char *subj = 0;  char *id = 0;  char *refs = 0;  char *to = 0;  char *cc = 0;  char *bcc = 0;   char *fcc = 0;   char *org = 0;   char *grps = 0;  char *foll = 0;  char *priority = 0;  char *draftInfo = 0;    PRBool xlate_p = PR_FALSE;	/* #### how do we determine this? */  PRBool sign_p = PR_FALSE;		/* #### how do we determine this? */  PRBool forward_inline = PR_FALSE;    PR_ASSERT (mdd);    if (!mdd) return;    if (mdd->obj)   {    int status;        status = mdd->obj->clazz->parse_eof ( mdd->obj, PR_FALSE );    mdd->obj->clazz->parse_end( mdd->obj, status < 0 ? PR_TRUE : PR_FALSE );        xlate_p = mdd->options->dexlate_p;    sign_p = mdd->options->signed_p;        // RICHIE    // We need to figure out how to pass the forwarded flag along with this    // operation.        //forward_inline = (mdd->format_out != FO_CMDLINE_ATTACHMENTS);    	forward_inline = mdd->forwardInline;    if (forward_inline)    {#ifdef MOZ_SECURITY      HG88890#endif    }        PR_ASSERT ( mdd->options == mdd->obj->options );    mime_free (mdd->obj);    mdd->obj = 0;    if (mdd->options)     {      PR_FREEIF (mdd->options->part_to_load);      PR_Free(mdd->options);      mdd->options = 0;    }    if (mdd->stream)     {      mdd->stream->complete ((nsMIMESession *)mdd->stream->data_object);      PR_Free( mdd->stream );      mdd->stream = 0;    }  }  //  // Now, process the attachments that we have gathered from the message  // on disk  //  nsMsgAttachmentData     *newAttachData = nsnull;  if (mdd && (mdd->attachments_count > 0))    newAttachData = mime_draft_process_attachments(mdd);    //  // time to bring up the compose windows with all the info gathered   //  if ( mdd->headers )  {    subj = MimeHeaders_get(mdd->headers, HEADER_SUBJECT,  PR_FALSE, PR_FALSE);    if (forward_inline)    {      if (subj)      {        char *newSubj = PR_smprintf("[Fwd: %s]", subj);        if (newSubj)        {          PR_Free(subj);          subj = newSubj;        }      }    }	    else    {      repl = MimeHeaders_get(mdd->headers, HEADER_REPLY_TO, PR_FALSE, PR_FALSE);      to   = MimeHeaders_get(mdd->headers, HEADER_TO,       PR_FALSE, PR_TRUE);      cc   = MimeHeaders_get(mdd->headers, HEADER_CC,       PR_FALSE, PR_TRUE);      bcc   = MimeHeaders_get(mdd->headers, HEADER_BCC,       PR_FALSE, PR_TRUE);            /* These headers should not be RFC-1522-decoded. */      grps = MimeHeaders_get(mdd->headers, HEADER_NEWSGROUPS,  PR_FALSE, PR_TRUE);      foll = MimeHeaders_get(mdd->headers, HEADER_FOLLOWUP_TO, PR_FALSE, PR_TRUE);            host = MimeHeaders_get(mdd->headers, HEADER_X_MOZILLA_NEWSHOST, PR_FALSE, PR_FALSE);      if (!host)        host = MimeHeaders_get(mdd->headers, HEADER_NNTP_POSTING_HOST, PR_FALSE, PR_FALSE);            id   = MimeHeaders_get(mdd->headers, HEADER_MESSAGE_ID,  PR_FALSE, PR_FALSE);      refs = MimeHeaders_get(mdd->headers, HEADER_REFERENCES,  PR_FALSE, PR_TRUE);      priority = MimeHeaders_get(mdd->headers, HEADER_X_PRIORITY, PR_FALSE, PR_FALSE);            mime_intl_mimepart_2_str(&repl, mdd->mailcharset);      mime_intl_mimepart_2_str(&to, mdd->mailcharset);      mime_intl_mimepart_2_str(&cc, mdd->mailcharset);      mime_intl_mimepart_2_str(&bcc, mdd->mailcharset);      mime_intl_mimepart_2_str(&grps, mdd->mailcharset);      mime_intl_mimepart_2_str(&foll, mdd->mailcharset);      mime_intl_mimepart_2_str(&host, mdd->mailcharset);            if (host)       {        char *secure = NULL;                secure = PL_strcasestr(host, "secure");        if (secure)         {          *secure = 0;          news_host = PR_smprintf ("snews://%s", host);        }        else         {          news_host = PR_smprintf ("news://%s", host);        }      }    }        mime_intl_mimepart_2_str(&subj, mdd->mailcharset);        fields = CreateCompositionFields( from, repl, to, cc, bcc, fcc, grps, foll,      org, subj, refs, 0, priority, 0, news_host,      xlate_p, sign_p);        draftInfo = MimeHeaders_get(mdd->headers, HEADER_X_MOZILLA_DRAFT_INFO, PR_FALSE, PR_FALSE);    if (draftInfo && fields && !forward_inline)     {      char *parm = 0;      parm = MimeHeaders_get_parameter(draftInfo, "vcard", NULL, NULL);      if (parm && !PL_strcmp(parm, "1"))        fields->SetBoolHeader(nsMsg_ATTACH_VCARD_BOOL_HEADER_MASK, PR_TRUE);      else        fields->SetBoolHeader(nsMsg_ATTACH_VCARD_BOOL_HEADER_MASK, PR_FALSE);            PR_FREEIF(parm);      parm = MimeHeaders_get_parameter(draftInfo, "receipt", NULL, NULL);      if (parm && !PL_strcmp(parm, "0"))        fields->SetBoolHeader(nsMsg_RETURN_RECEIPT_BOOL_HEADER_MASK, PR_FALSE);       else      {        int receiptType = 0;        fields->SetBoolHeader(nsMsg_RETURN_RECEIPT_BOOL_HEADER_MASK, PR_TRUE);         sscanf(parm, "%d", &receiptType);        fields->SetReturnReceipt((PRInt32) receiptType);      }      PR_FREEIF(parm);      parm = MimeHeaders_get_parameter(draftInfo, "uuencode", NULL, NULL);      if (parm && !PL_strcmp(parm, "1"))        fields->SetBoolHeader(nsMsg_UUENCODE_BINARY_BOOL_HEADER_MASK, PR_TRUE);      else        fields->SetBoolHeader(nsMsg_UUENCODE_BINARY_BOOL_HEADER_MASK, PR_FALSE);      PR_FREEIF(parm);      parm = MimeHeaders_get_parameter(draftInfo, "html", NULL, NULL);      if (parm)        sscanf(parm, "%d", &htmlAction);      PR_FREEIF(parm);      parm = MimeHeaders_get_parameter(draftInfo, "linewidth", NULL, NULL);      if (parm)        sscanf(parm, "%d", &lineWidth);      PR_FREEIF(parm);          }        if (mdd->messageBody)     {      char *body;      PRUint32 bodyLen = 0;      nsMsgEditorType editorType = nsMsgDefault;            bodyLen = mdd->messageBody->file_spec->GetFileSize();      body = (char *)PR_MALLOC (bodyLen + 1);      if (body)      {        nsCRT::memset (body, 0, bodyLen+1);                nsInputFileStream inputFile(*(mdd->messageBody->file_spec));        if (inputFile.is_open())          inputFile.read(body, bodyLen);                inputFile.close();                if (mdd->messageBody->type && *mdd->messageBody->type)        {          if( PL_strcasestr(mdd->messageBody->type, "text/html") != NULL )            editorType = nsMsgHTMLEditor;          else if ( PL_strcasestr(mdd->messageBody->type, "text/plain") != NULL )            editorType = nsMsgPlainTextEditor;        }        else        {          editorType = nsMsgPlainTextEditor;        }          // Since we have body text, then we should set the compose fields with        // this data.              if (editorType == nsMsgPlainTextEditor)          fields->SetTheForcePlainText(PR_TRUE);                if (forward_inline)        {          mime_insert_forwarded_message_headers(&body, mdd->headers, editorType,                                                mdd->mailcharset);          bodyLen = PL_strlen(body);        }        //        // RICHIE - once again, we need to know what we should be converting        // to in order to do the right thing here!!!        //        // Now do conversion to UTF-8???        char      *newBody = NULL;        PRInt32   newBodyLen;        PRInt32 res = MIME_ConvertCharset(PR_TRUE, mdd->mailcharset, "UTF-8", body,                                           PL_strlen(body), &newBody, &newBodyLen, NULL);		    if ( (NS_SUCCEEDED(res)) && (newBody && newBody != body))		    {			    PR_FREEIF(body);          // RICHIE SHERRY          //          // Insert the META tag to tell Gecko it's UTF-8...          //          nsString      aNewBody("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">");          aNewBody.Append(newBody);          PR_FREEIF(newBody);          fields->SetCharacterSet(nsString("UTF-8").GetUnicode());          fields->SetBody(aNewBody.GetUnicode());          // RICHIE SHERRY          // RICHIE SHERRY OLD STUFF body = newBody;          // RICHIE SHERRY OLD STUFF bodyLen = newBodyLen;		    }        else        {          fields->SetCharacterSet(nsString(mdd->mailcharset).GetUnicode());          fields->SetBody(nsString(body).GetUnicode());        }        PR_FREEIF(body);      } // end if (messageBody)        //      // At this point, we need to create a message compose window or editor      // window via XP-COM with the information that we have retrieved from       // the message store.      //      if (mdd->format_out == nsMimeOutput::nsMimeMessageEditorTemplate)      {        printf("RICHIE: Time to create the EDITOR with this template - HAS a body!!!!\n");      }      else      {#ifdef NS_DEBUG        printf("Time to create the composition window WITH a body!!!!\n");#endif        CreateTheComposeWindow(fields, newAttachData, editorType);      }            PR_FREEIF(body);      mime_free_attachments (mdd->messageBody, 1);    }    else    {      //      // At this point, we need to create a message compose window via      // XP-COM with the information that we have retrieved from the message store.      //      if (mdd->format_out == nsMimeOutput::nsMimeMessageEditorTemplate)      {        printf("RICHIE: Time to create the EDITOR with this template - NO body!!!!\n");        CreateTheComposeWindow(fields, newAttachData, nsMsgDefault);      }      else      {#ifdef NS_DEBUG        printf("Time to create the composition window WITHOUT a body!!!!\n");#endif        CreateTheComposeWindow(fields, newAttachData, nsMsgDefault);      }    }      }  else  {    fields = CreateCompositionFields( from, repl, to, cc, bcc, fcc, grps, foll,                                      org, subj, refs, 0, priority, 0, news_host,                                      GetMailXlateionPreference(),                                       GetMailSigningPreference());    if (fields)      CreateTheComposeWindow(fields, newAttachData, nsMsgDefault);  }    if ( mdd->headers )    MimeHeaders_free ( mdd->headers );  //   // Free the original attachment structure...  // Make sure we only cleanup the local copy of the memory and not kill   // files we need on disk  //  if (mdd->attachments)  {    int               i;    nsMsgAttachedFile *cur = mdd->attachments;    for ( i = 0; i < mdd->attachments_count; i++, cur++ )     {	    if ( cur->file_spec )       {	      delete ( cur->file_spec );        cur->file_spec = nsnull;      }    }    mime_free_attachments( mdd->attachments, mdd->attachments_count );  }  PR_FREEIF(mdd);  if (fields)    NS_RELEASE(fields);    // Release the prefs service  MimeObject *obj = (mdd ? mdd->obj : 0);    if ( (obj) && (obj->options) && (obj->options->prefs) )    nsServiceManager::ReleaseService(kPrefCID, obj->options->prefs);  PR_Free (mdd);    PR_FREEIF(host);  PR_FREEIF(to_and_cc);  PR_FREEIF(re_subject);  PR_FREEIF(new_refs);  PR_FREEIF(from);  PR_FREEIF(repl);  PR_FREEIF(subj);  PR_FREEIF(id);  PR_FREEIF(refs);  PR_FREEIF(to);  PR_FREEIF(cc);  PR_FREEIF(grps);  PR_FREEIF(foll);  PR_FREEIF(priority);  PR_FREEIF(draftInfo);  }