static void MimeEncrypted_cleanup (MimeObject *obj, PRBool finalizing_p) { MimeEncrypted *enc = (MimeEncrypted *) obj; if (enc->part_buffer) { MimePartBufferDestroy(enc->part_buffer); enc->part_buffer = 0; } if (finalizing_p && enc->crypto_closure) { /* Don't free these until this object is really going away -- keep them around for the lifetime of the MIME object, so that we can get at the security info of sub-parts of the currently-displayed message. */ ((MimeEncryptedClass *) obj->clazz)->crypto_free (enc->crypto_closure); enc->crypto_closure = 0; } /* (Duplicated from MimeLeaf, see comments in mimecryp.h.) Free the decoder data, if it's still around. */ if (enc->decoder_data) { MimeDecoderDestroy(enc->decoder_data, PR_TRUE); enc->decoder_data = 0; } if (enc->hdrs) { MimeHeaders_free(enc->hdrs); enc->hdrs = 0; } }
NS_IMETHODIMP nsEnigMimeListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, nsresult aStatus) { nsresult rv = NS_OK; DEBUG_LOG(("nsEnigMimeListener::OnStopRequest: (%p)\n", this)); // Ensure that OnStopRequest call chain does not break by failing softly if (!mRequestStarted) { if (mHeadersFinalCR) { // Handle special case of terminating CR with no content mHeadersFinalCR = PR_FALSE; mLinebreak = "\r"; mHeaders = mDataStr; if (mSkipHeaders) { // Skip headers mDataStr = ""; } } rv = StartRequest(aRequest, aContext); if (NS_FAILED(rv)) aStatus = NS_BINDING_ABORTED; } if (mDecoderData) { // Clear decoder buffer MimeDecoderDestroy(mDecoderData, PR_FALSE); mDecoderData = nsnull; } if (mListener) { rv = mListener->OnStopRequest(aRequest, mContext ? mContext.get() : aContext, aStatus); if (NS_FAILED(rv)) aStatus = NS_BINDING_ABORTED; } // Release owning refs mListener = nsnull; mContext = nsnull; return (aStatus == NS_BINDING_ABORTED) ? NS_ERROR_FAILURE : NS_OK; }
static int MimeLeaf_close_decoder (MimeObject *obj) { MimeLeaf *leaf = (MimeLeaf *) obj; if (leaf->decoder_data) { int status = MimeDecoderDestroy(leaf->decoder_data, PR_FALSE); leaf->decoder_data = 0; return status; } return 0; }
static void MimeLeaf_finalize (MimeObject *object) { MimeLeaf *leaf = (MimeLeaf *)object; object->clazz->parse_eof (object, PR_FALSE); /* Free the decoder data, if it's still around. It was probably freed in MimeLeaf_parse_eof(), but just in case... */ if (leaf->decoder_data) { MimeDecoderDestroy(leaf->decoder_data, PR_TRUE); leaf->decoder_data = 0; } ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize (object); }
nsEnigMimeListener::~nsEnigMimeListener() { nsresult rv; #ifdef FORCE_PR_LOG nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsEnigMimeListener:: >>>>>>>>> DTOR(%p): myThread=%p\n", this, myThread.get())); #endif if (mDecoderData) { // Clear decoder buffer MimeDecoderDestroy(mDecoderData, PR_FALSE); mDecoderData = nsnull; } // Release owning refs mListener = nsnull; mContext = nsnull; }
static void MimeMultipartSigned_cleanup (MimeObject *obj, bool finalizing_p) { MimeMultipart *mult = (MimeMultipart *) obj; /* #58075. Fix suggested by jwz */ MimeMultipartSigned *sig = (MimeMultipartSigned *) obj; if (sig->part_buffer) { MimePartBufferDestroy(sig->part_buffer); sig->part_buffer = 0; } if (sig->body_hdrs) { MimeHeaders_free (sig->body_hdrs); sig->body_hdrs = 0; } if (sig->sig_hdrs) { MimeHeaders_free (sig->sig_hdrs); sig->sig_hdrs = 0; } mult->state = MimeMultipartEpilogue; /* #58075. Fix suggested by jwz */ sig->state = MimeMultipartSignedEpilogue; if (finalizing_p && sig->crypto_closure) { /* Don't free these until this object is really going away -- keep them around for the lifetime of the MIME object, so that we can get at the security info of sub-parts of the currently-displayed message. */ ((MimeMultipartSignedClass *) obj->clazz)->crypto_free (sig->crypto_closure); sig->crypto_closure = 0; } if (sig->sig_decoder_data) { MimeDecoderDestroy(sig->sig_decoder_data, true); sig->sig_decoder_data = 0; } }
static int MimeEncrypted_parse_eof (MimeObject *obj, PRBool abort_p) { int status = 0; MimeEncrypted *enc = (MimeEncrypted *) obj; if (obj->closed_p) return 0; NS_ASSERTION(!obj->parsed_p, "1.2 <*****@*****.**> 01 Nov 2001 17:59"); /* (Duplicated from MimeLeaf, see comments in mimecryp.h.) Close off the decoder, to cause it to give up any buffered data that it is still holding. */ if (enc->decoder_data) { int status = MimeDecoderDestroy(enc->decoder_data, PR_FALSE); enc->decoder_data = 0; if (status < 0) return status; } /* If there is still data in the ibuffer, that means that the last *decrypted* line of this part didn't end in a newline; so push it out anyway (this means that the parse_line method will be called with a string with no trailing newline, which isn't the usual case.) */ if (!abort_p && obj->ibuffer_fp > 0) { int status = MimeHandleDecryptedOutputLine (obj->ibuffer, obj->ibuffer_fp, obj); obj->ibuffer_fp = 0; if (status < 0) { obj->closed_p = PR_TRUE; return status; } } /* Now run the superclass's parse_eof, which (because we've already taken care of ibuffer in a way appropriate for this class, immediately above) will ony set closed_p to true. */ status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof (obj, abort_p); if (status < 0) return status; /* Now close off the underlying crypto module. At this point, the crypto module has all of the input. (DecoderDestroy called parse_decoded_buffer which called crypto_write, with the last of the data.) */ if (enc->crypto_closure) { status = ((MimeEncryptedClass *) obj->clazz)->crypto_eof (enc->crypto_closure, abort_p); if (status < 0 && !abort_p) return status; } /* Now we have the entire child part in the part buffer. We are now able to verify its signature, emit a blurb, and then emit the part. */ if (abort_p) return 0; else return MimeEncrypted_emit_buffered_child (obj); }