// nsEnigMimeDecrypt implementation nsEnigMimeDecrypt::nsEnigMimeDecrypt() : mInitialized(PR_FALSE), mVerifyOnly(PR_FALSE), mRfc2015(PR_FALSE), mDone(PR_FALSE), mInputLen(0), mOutputLen(0), mIterations(0), mCtFound(-1), mBuffer(nsnull), mListener(nsnull), mPipeTrans(nsnull), mSecurityInfo(nsnull), mUri(nsnull) { nsresult rv; NS_INIT_ISUPPORTS(); #ifdef PR_LOGGING if (gEnigMimeDecryptLog == nsnull) { gEnigMimeDecryptLog = PR_NewLogModule("nsEnigMimeDecrypt"); } #endif #ifdef FORCE_PR_LOG nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsEnigMimeDecrypt:: <<<<<<<<< CTOR(%p): myThread=%p\n", this, myThread.get())); #endif }
// nsEnigMsgCompose implementation nsEnigMsgCompose::nsEnigMsgCompose() : mInitialized(PR_FALSE), mUseSMIME(PR_FALSE), mEnigMsgComposeJS(NULL), mMsgComposeSecure(NULL) { nsresult rv; NS_INIT_ISUPPORTS(); #ifdef PR_LOGGING if (gEnigMsgComposeLog == NULL) { gEnigMsgComposeLog = PR_NewLogModule("nsEnigMsgCompose"); } #endif // Remember to use original CID, not CONTRACTID, to avoid infinite looping! mMsgComposeSecure = do_CreateInstance(kMsgComposeSecureCID, &rv); #ifdef FORCE_PR_LOG nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsEnigMsgCompose:: <<<<<<<<< CTOR(%p): myThread=%p\n", this, myThread.get())); #endif }
// nsEnigMsgCompose implementation nsEnigMsgCompose::nsEnigMsgCompose() : mInitialized(PR_FALSE), mUseSMIME(PR_FALSE), mIsDraft(PR_FALSE), mRequestStopped(PR_FALSE), mLinebreak(PR_TRUE), mSpace(0), mMatchFrom(0), mInputLen(0), mOutputLen(0), mSendFlags(0), mUIFlags(0), mMultipartSigned(PR_FALSE), mStripWhitespace(PR_FALSE), mSenderEmailAddr(""), mRecipients(""), mBccAddr(""), mHashAlgorithm("sha1"), mBoundary(""), mStream(0), mEncoderData(nsnull), mMsgComposeSecure(nsnull), mMimeListener(nsnull), mWriter(nsnull), mPipeTrans(nsnull) { nsresult rv; NS_INIT_ISUPPORTS(); #ifdef PR_LOGGING if (gEnigMsgComposeLog == nsnull) { gEnigMsgComposeLog = PR_NewLogModule("nsEnigMsgCompose"); } #endif // Remember to use original CID, not CONTRACTID, to avoid infinite looping! mMsgComposeSecure = do_CreateInstance(kMsgComposeSecureCID, &rv); #ifdef FORCE_PR_LOG nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsEnigMsgCompose:: <<<<<<<<< CTOR(%p): myThread=%p\n", this, myThread.get())); #endif }
nsEnigMimeService::~nsEnigMimeService() { nsresult rv; #ifdef FORCE_PR_LOG nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsEnigMimeService:: >>>>>>>>> DTOR(%p): myThread=%p\n", this, myThread.get())); #endif }
// nsEnigMimeListener implementation nsEnigMimeListener::nsEnigMimeListener() : mInitialized(PR_FALSE), mRequestStarted(PR_FALSE), mSkipHeaders(PR_FALSE), mSkipBody(PR_FALSE), mContentType(""), mContentCharset(""), mContentBoundary(""), mContentProtocol(""), mContentMicalg(""), mContentEncoding(""), mContentDisposition(""), mContentLength(-1), mDecodeContent(PR_FALSE), mDecoderData(nsnull), mLinebreak(""), mHeaders(""), mDataStr(""), mHeaderSearchCounter(0), mHeadersFinalCR(PR_FALSE), mHeadersLinebreak(2), mMaxHeaderBytes(0), mDataOffset(0), mStreamBuf(nsnull), mStreamOffset(0), mStreamLength(0), mSubPartTreatment(PR_FALSE), mListener(nsnull), mContext(nsnull) { NS_INIT_ISUPPORTS(); #ifdef PR_LOGGING if (gEnigMimeListenerLog == nsnull) { gEnigMimeListenerLog = PR_NewLogModule("nsEnigMimeListener"); } #endif #ifdef FORCE_PR_LOG nsresult rv; nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsEnigMimeListener:: <<<<<<<<< CTOR(%p): myThread=%p\n", this, myThread.get())); #endif }
nsPipeFilterListener::~nsPipeFilterListener() { nsresult rv; #ifdef FORCE_PR_LOG nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsPipeFilterListener:: >>>>>>>>> DTOR(%p): myThread=%p\n", this, myThread.get())); #endif // Release owning refs mListener = nsnull; mTailListener = nsnull; mContext = nsnull; }
// nsPipeFilterListener implementation nsPipeFilterListener::nsPipeFilterListener() : mInitialized(PR_FALSE), mRequestStarted(PR_FALSE), mRequestEnded(PR_FALSE), mTailRequestStarted(PR_FALSE), mStartDelimiter(""), mEndDelimiter(""), mStartLine(""), mEndLine(""), mKeepDelimiters(PR_FALSE), mMimeMultipart(PR_FALSE), mAutoMimeBoundary(PR_FALSE), mFirstMatch(PR_TRUE), mLastMatch(PR_FALSE), mSavePartMatch(PR_FALSE), mOldPartMatch(""), mPartMatch(""), mLinebreak(0), mStreamBuf(nsnull), mStreamOffset(0), mStreamLength(0), mListener(nsnull), mTailListener(nsnull), mContext(nsnull) { NS_INIT_ISUPPORTS(); #ifdef PR_LOGGING if (gPipeFilterListenerLog == nsnull) { gPipeFilterListenerLog = PR_NewLogModule("nsPipeFilterListener"); } #endif #ifdef FORCE_PR_LOG nsresult rv; nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsPipeFilterListener:: <<<<<<<<< CTOR(%p): myThread=%p\n", this, myThread.get())); #endif }
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; }
// nsEnigMimeVerify implementation nsEnigMimeVerify::nsEnigMimeVerify() : mInitialized(PR_FALSE), mPgpMime(PR_FALSE), mRequestStopped(PR_FALSE), mLastLinebreak(PR_TRUE), mStartCount(0), mContentBoundary(""), mLinebreak(""), mURISpec(""), mMsgWindow(nsnull), mOutBuffer(nsnull), mPipeTrans(nsnull), mArmorListener(nsnull), mSecondPartListener(nsnull), mFirstPartListener(nsnull), mOuterMimeListener(nsnull), mInnerMimeListener(nsnull) { nsresult rv; NS_INIT_ISUPPORTS(); #ifdef PR_LOGGING if (gEnigMimeVerifyLog == nsnull) { gEnigMimeVerifyLog = PR_NewLogModule("nsEnigMimeVerify"); } #endif #ifdef FORCE_PR_LOG nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsEnigMimeVerify:: <<<<<<<<< CTOR(%p): myThread=%p\n", this, myThread.get())); #endif }
// nsEnigMimeService implementation nsEnigMimeService::nsEnigMimeService() : mDummyHandler(PR_FALSE), mInitialized(PR_FALSE) { nsresult rv; NS_INIT_ISUPPORTS(); #ifdef PR_LOGGING if (gEnigMimeServiceLog == nsnull) { gEnigMimeServiceLog = PR_NewLogModule("nsEnigMimeService"); } #endif #ifdef FORCE_PR_LOG nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); DEBUG_LOG(("nsEnigMimeService:: <<<<<<<<< CTOR(%p): myThread=%p\n", this, myThread.get())); #endif mDummyHandler = PR_TRUE; }
nsresult nsEnigMimeDecrypt::FinishAux(nsIMsgWindow* msgWindow, nsIURI* uri) { // Enigmail stuff nsresult rv; nsCOMPtr<nsIThread> myThread; rv = ENIG_GET_THREAD(myThread); mUri = uri; nsCAutoString uriSpec(""); if (mListener) { rv = mListener->OnStopRequest(nsnull, nsnull, 0); if (NS_FAILED(rv)) return rv; nsCAutoString endLine; rv = mListener->GetEndLine(endLine); if (NS_FAILED(rv)) return rv; if (endLine.IsEmpty()) { ERROR_LOG(("nsEnigMimeDecrypt::FinishAux: ERROR MIME part not terminated\n")); return NS_ERROR_FAILURE; } mListener = nsnull; } rv = mBuffer->OnStopRequest(nsnull, nsnull, 0); if (NS_FAILED(rv)) return rv; if (msgWindow) { nsCOMPtr<nsIMsgHeaderSink> headerSink; msgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink)); if (headerSink) headerSink->GetSecurityInfo(getter_AddRefs(mSecurityInfo)); } DEBUG_LOG(("nsEnigMimeDecrypt::FinishAux: securityInfo=%p\n", mSecurityInfo.get())); nsCOMPtr<nsIPrompt> prompter; if (msgWindow) { msgWindow->GetPromptDialog(getter_AddRefs(prompter)); } if (!prompter) { nsCOMPtr <nsIMsgMailSession> mailSession (do_GetService(NS_MSGMAILSESSION_CONTRACTID)); if (mailSession) { nsCOMPtr<nsIMsgWindow> msgwin; mailSession->GetTopmostMsgWindow(getter_AddRefs(msgwin)); if (msgwin) msgwin->GetPromptDialog(getter_AddRefs(prompter)); } } DEBUG_LOG(("nsEnigMimeDecrypt::FinishAux: prompter=%p\n", prompter.get())); nsCOMPtr<nsIEnigmail> enigmailSvc = do_GetService(NS_ENIGMAIL_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; nsString errorMsg; EMBool noOutput = PR_FALSE; PRUint32 statusFlags; rv = enigmailSvc->DecryptMessageStart(nsnull, prompter, mVerifyOnly, noOutput, nsnull, &statusFlags, getter_Copies(errorMsg), getter_AddRefs(mPipeTrans) ); if (NS_FAILED(rv)) return rv; if (!mPipeTrans) { if (mSecurityInfo) { nsCOMPtr<nsIEnigMimeHeaderSink> enigHeaderSink = do_QueryInterface(mSecurityInfo); if (enigHeaderSink) { NS_NAMED_LITERAL_STRING(nullString, ""); rv = enigHeaderSink->UpdateSecurityStatus(uriSpec, -1, statusFlags, nullString.get(), nullString.get(), nullString.get(), errorMsg.get(), nullString.get(), mUri); } } return NS_ERROR_FAILURE; } mIterations = 0; mCtFound = -1; nsCOMPtr<nsIInputStream> plainStream = nsnull; // read via pipeTransport.jsm nsCOMPtr<nsIRequest> request; rv = mPipeTrans->ReadInputStream(this, getter_AddRefs(request)); NS_ENSURE_SUCCESS(rv, rv); // Write buffered data asyncronously to process nsCOMPtr<nsIInputStream> bufStream; rv = mBuffer->OpenInputStream(getter_AddRefs(bufStream)); if (NS_FAILED(rv)) return rv; PRUint32 available; rv = bufStream->Available(&available); if (NS_FAILED(rv)) return rv; DEBUG_LOG(("nsEnigMimeDecrypt::FinishAux: available=%d\n", available)); rv = mPipeTrans->WriteAsync(bufStream, available, PR_TRUE); if (NS_FAILED(rv)) return rv; // read via pipeTransport.jsm nsCOMPtr<nsIThread> currentThread; rv = ENIG_GET_THREAD(currentThread); NS_ENSURE_SUCCESS(rv, rv); mDone = PR_FALSE; // wait with returning until message is completely processed // (simulate synchronous function) while (! mDone) { EMBool pendingEvents; rv = currentThread->ProcessNextEvent(PR_TRUE, &pendingEvents); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; }