*default_charset = charset.ToNewCString();
*default_charset = ToNewCString(charset);
bridge_new_new_uri(void *bridgeStream, nsIURI *aURI, PRInt32 aOutputType){  nsMIMESession *session = (nsMIMESession *)bridgeStream;  const char    **fixup_pointer = nsnull;  if (session)  {    if (session->data_object)    {      PRBool   *override_charset = nsnull;      char    **default_charset = nsnull;      char    **url_name = nsnull;      if  ( (aOutputType == nsMimeOutput::nsMimeMessageDraftOrTemplate) ||            (aOutputType == nsMimeOutput::nsMimeMessageEditorTemplate) )      {        struct mime_draft_data *mdd = (struct mime_draft_data *)session->data_object;        if (mdd->options)        {          default_charset = &(mdd->options->default_charset);          override_charset = &(mdd->options->override_charset);          url_name = &(mdd->url_name);        }      }      else      {        struct mime_stream_data *msd = (struct mime_stream_data *)session->data_object;        if (msd->options)        {          default_charset = &(msd->options->default_charset);          override_charset = &(msd->options->override_charset);          url_name = &(msd->url_name);          fixup_pointer = &(msd->options->url);        }      }      if ( (default_charset) && (override_charset) && (url_name) )      {        //         // set the default charset to be the folder charset if we have one associated with        // this url...        nsCOMPtr<nsIMsgI18NUrl> i18nUrl (do_QueryInterface(aURI));        if (i18nUrl)        {          nsXPIDLString uniCharset;          nsAutoString charset;          // check to see if we have a charset override...and if we do, set that field appropriately too...          nsresult rv = i18nUrl->GetCharsetOverRide(getter_Copies(uniCharset));          charset = uniCharset;          if (NS_SUCCEEDED(rv) && !charset.IsEmpty() ) {            *override_charset = PR_TRUE;            *default_charset = charset.ToNewCString();          }          else          {            i18nUrl->GetFolderCharset(getter_Copies(uniCharset));            charset = uniCharset;            if (!charset.IsEmpty())              *default_charset = charset.ToNewCString();          }          // if there is no manual override and a folder charset exists          // then check if we have a folder level override          if (!(*override_charset) && *default_charset && **default_charset)          {            PRBool folderCharsetOverride;            rv = i18nUrl->GetFolderCharsetOverride(&folderCharsetOverride);            if (NS_SUCCEEDED(rv) && folderCharsetOverride)              *override_charset = PR_TRUE;            // notify the default to msgWindow (for the menu check mark)            nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(aURI));            if (msgurl)            {              nsCOMPtr<nsIMsgWindow> msgWindow;              msgurl->GetMsgWindow(getter_AddRefs(msgWindow));              if (msgWindow)                msgWindow->SetMailCharacterSet(NS_ConvertASCIItoUCS2(*default_charset).get());            }            // if the pref says always override and no manual override then set the folder charset to override            if (!*override_charset) {              nsCOMPtr <nsIPref> prefs = do_GetService(kPrefCID, &rv);              if (NS_SUCCEEDED(rv) && prefs)               {                PRBool  force_override;                rv = prefs->GetBoolPref("mailnews.force_charset_override", &force_override);                if (NS_SUCCEEDED(rv) && force_override)                 {                  *override_charset = PR_TRUE;                }              }            }          }        }        char *urlString;        if (NS_SUCCEEDED(aURI->GetSpec(&urlString)))        {          if ((urlString) && (*urlString))          {            CRTFREEIF(*url_name);            *url_name = nsCRT::strdup(urlString);            if (!(*url_name))              return NS_ERROR_OUT_OF_MEMORY;            // rhp: Ugh, this is ugly...but it works.            if (fixup_pointer)              *fixup_pointer = (const char *)*url_name;            CRTFREEIF(urlString);          }        }      }    }  }  return NS_OK;}