MimeCMS_init(MimeObject *obj, int (*output_fn) (const char *buf, PRInt32 buf_size, void *output_closure), void *output_closure)
static void *MimeCMS_init(MimeObject *obj, int (*output_fn) (const char *buf, PRInt32 buf_size, void *output_closure), void *output_closure)
MimeCMS_init(MimeObject *obj,			   int (*output_fn) (const char *buf, PRInt32 buf_size,								 void *output_closure),			   void *output_closure){  MimeCMSdata *data;  MimeDisplayOptions *opts;  nsresult rv;  if (!(obj && obj->options && output_fn)) return 0;  opts = obj->options;  data = new MimeCMSdata;  if (!data) return 0;  data->self = obj;  data->output_fn = output_fn;  data->output_closure = output_closure;  PR_SetError(0, 0);  data->decoder_context = do_CreateInstance(NS_CMSDECODER_CONTRACTID, &rv);  if (NS_FAILED(rv)) return 0;  rv = data->decoder_context->Start(MimeCMS_content_callback, data);  if (NS_FAILED(rv)) return 0;  // XXX Fix later XXX //  data->parent_holds_stamp_p =	(obj->parent &&	 (mime_crypto_stamped_p(obj->parent) ||	  mime_typep(obj->parent, (MimeObjectClass *) &mimeEncryptedClass)));  data->parent_is_encrypted_p =	(obj->parent && MimeEncryptedCMS_encrypted_p (obj->parent));  /* If the parent of this object is a crypto-blob, then it's the grandparent	 who would have written out the headers and prepared for a stamp...	 (This shit sucks.)   */  if (data->parent_is_encrypted_p &&	  !data->parent_holds_stamp_p &&	  obj->parent && obj->parent->parent)	data->parent_holds_stamp_p =	  mime_crypto_stamped_p (obj->parent->parent);  mime_stream_data *msd = (mime_stream_data *) (data->self->options->stream_closure);  if (msd)  {    nsIChannel *channel = msd->channel;  // note the lack of ref counting...    if (channel)    {      nsCOMPtr<nsIURI> uri;      nsCOMPtr<nsIMsgWindow> msgWindow;      nsCOMPtr<nsIMsgHeaderSink> headerSink;      nsCOMPtr<nsIMsgMailNewsUrl> msgurl;      nsCOMPtr<nsISupports> securityInfo;      channel->GetURI(getter_AddRefs(uri));      if (uri)      {        nsCAutoString urlSpec;        rv = uri->GetSpec(urlSpec);        // We only want to update the UI if the current mime transaction        // is intended for display.        // If the current transaction is intended for background processing,        // we can learn that by looking at the additional header=filter        // string contained in the URI.        //        // If we find something, we do not set smimeHeaderSink,        // which will prevent us from giving UI feedback.        //        // If we do not find header=filter, we assume the result of the        // processing will be shown in the UI.        if (!strstr(urlSpec.get(), "?header=filter") &&            !strstr(urlSpec.get(), "&header=filter"))        {          msgurl = do_QueryInterface(uri);          if (msgurl)            msgurl->GetMsgWindow(getter_AddRefs(msgWindow));          if (msgWindow)            msgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink));          if (headerSink)            headerSink->GetSecurityInfo(getter_AddRefs(securityInfo));          if (securityInfo)            data->smimeHeaderSink = do_QueryInterface(securityInfo);        }      }    } // if channel  } // if msd  return data;}