diff --git a/mailnews/base/macbuild/msgCore.mcp b/mailnews/base/macbuild/msgCore.mcp index 659f2b47995..2584986883b 100644 Binary files a/mailnews/base/macbuild/msgCore.mcp and b/mailnews/base/macbuild/msgCore.mcp differ diff --git a/mailnews/base/macbuild/msgCoreIDL.mcp b/mailnews/base/macbuild/msgCoreIDL.mcp index c09cd9356ba..0d3526a03e7 100644 Binary files a/mailnews/base/macbuild/msgCoreIDL.mcp and b/mailnews/base/macbuild/msgCoreIDL.mcp differ diff --git a/mailnews/base/public/Makefile.in b/mailnews/base/public/Makefile.in index 1d5b6cf96c9..77c4e55b9f1 100644 --- a/mailnews/base/public/Makefile.in +++ b/mailnews/base/public/Makefile.in @@ -78,7 +78,6 @@ XPIDLSRCS = \ nsIMsgViewNavigationService.idl \ nsIMsgPrintEngine.idl \ nsISubscribableServer.idl \ - nsISaveMsgListener.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mailnews/base/public/makefile.win b/mailnews/base/public/makefile.win index cb0e2a4df14..3788c488b56 100644 --- a/mailnews/base/public/makefile.win +++ b/mailnews/base/public/makefile.win @@ -63,7 +63,6 @@ XPIDLSRCS = \ .\nsIMsgViewNavigationService.idl \ .\nsIMsgPrintEngine.idl \ .\nsISubscribableServer.idl \ - .\nsISaveMsgListener.idl \ $(NULL) ################################################################################ diff --git a/mailnews/base/src/nsMessenger.cpp b/mailnews/base/src/nsMessenger.cpp index 72a75d190df..c47c67577a2 100644 --- a/mailnews/base/src/nsMessenger.cpp +++ b/mailnews/base/src/nsMessenger.cpp @@ -76,11 +76,6 @@ #include "nsIMsgStatusFeedback.h" #include "nsMsgRDFUtils.h" -#include "nsISaveMsgListener.h" -#ifdef XP_MAC - #include "nsDecodeAppleFile.h" -#endif - // compose #include "nsMsgCompCID.h" #include "nsMsgI18N.h" @@ -189,8 +184,7 @@ ConvertBufToPlainText(nsString &aConBuf) // class nsSaveAllAttachmentsState; -class nsSaveMsgListener : public nsISaveMsgListener, - public nsIUrlListener, +class nsSaveMsgListener : public nsIUrlListener, public nsIMsgCopyServiceListener, public nsIStreamListener { @@ -200,7 +194,6 @@ public: NS_DECL_ISUPPORTS - NS_DECL_NSISAVEMSGLISTENER NS_DECL_NSIURLLISTENER NS_DECL_NSIMSGCOPYSERVICELISTENER NS_DECL_NSISTREAMLISTENER @@ -219,12 +212,6 @@ public: nsString m_charset; nsString m_outputFormat; nsString m_msgBuffer; - -private: -#ifdef XP_MAC - //For Mac attachment handling - ProcessAppleDoubleResourceFork *m_processADRsrcFk; -#endif }; class nsSaveAllAttachmentsState @@ -1502,10 +1489,6 @@ nsSaveMsgListener::nsSaveMsgListener(nsIFileSpec* aSpec, nsMessenger *aMessenger // rhp: for charset handling m_doCharsetConversion = PR_FALSE; m_saveAllAttachmentsState = nsnull; - -#ifdef XP_MAC - m_processADRsrcFk = nsnull; -#endif } nsSaveMsgListener::~nsSaveMsgListener() @@ -1515,8 +1498,7 @@ nsSaveMsgListener::~nsSaveMsgListener() // // nsISupports // -NS_IMPL_ISUPPORTS4(nsSaveMsgListener, nsISaveMsgListener, nsIUrlListener, - nsIMsgCopyServiceListener, nsIStreamListener) +NS_IMPL_ISUPPORTS3(nsSaveMsgListener, nsIUrlListener, nsIMsgCopyServiceListener, nsIStreamListener) // // nsIUrlListener @@ -1658,16 +1640,6 @@ nsSaveMsgListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport, if ( (NS_SUCCEEDED(rv)) && (conBuf) ) { PRUint32 writeCount; -#ifdef XP_MAC - if (m_processADRsrcFk) - { - if (noErr == m_processADRsrcFk->Write((unsigned char *)conBuf, conLength, &writeCount)) - rv = NS_OK; - else - rv = NS_ERROR_FAILURE; - } - else -#endif rv = m_outputStream->Write(conBuf, conLength, &writeCount); if (conLength != writeCount) rv = NS_ERROR_FAILURE; @@ -1677,13 +1649,6 @@ nsSaveMsgListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport, } // close down the file stream and release ourself -#ifdef XP_MAC - if (m_processADRsrcFk) - { - delete m_processADRsrcFk; - m_processADRsrcFk = nsnull; - } -#endif if (m_fileSpec) { m_fileSpec->Flush(); @@ -1789,19 +1754,7 @@ nsSaveMsgListener::OnDataAvailable(nsIChannel* aChannel, m_msgBuffer.AppendWithConversion(m_dataBuffer, readCount); } else - { -#ifdef XP_MAC - if (m_processADRsrcFk) - { - if (noErr == m_processADRsrcFk->Write((unsigned char *)m_dataBuffer, readCount, &writeCount)) - rv = NS_OK; - else - rv = NS_ERROR_FAILURE; - } - else -#endif rv = m_outputStream->Write(m_dataBuffer, readCount, &writeCount); - } available -= readCount; } @@ -1810,61 +1763,6 @@ nsSaveMsgListener::OnDataAvailable(nsIChannel* aChannel, return rv; } -NS_IMETHODIMP -nsSaveMsgListener::SetMacTypeAndCreator(PRUint32 type, PRUint32 creator) -{ -#ifdef XP_MAC - if (m_fileSpec) - { - nsFileSpec realSpec; - m_fileSpec->GetFileSpec(&realSpec); - realSpec.SetFileTypeAndCreator((OSType)type, (OSType)creator); - } -#endif - - return NS_OK; -} - -NS_IMETHODIMP -nsSaveMsgListener::OnStartAppleDoubleDataFork() -{ -#ifdef XP_MAC - if (m_processADRsrcFk) - { - delete m_processADRsrcFk; - m_processADRsrcFk = nsnull; - } -#endif - - return NS_OK; -} - -NS_IMETHODIMP -nsSaveMsgListener::OnStartAppleDoubleResourceFork() -{ -#ifdef XP_MAC - if (m_fileSpec) - { - nsFileSpec realSpec; - m_fileSpec->GetFileSpec(&realSpec); - - if (m_processADRsrcFk) - return NS_ERROR_FAILURE; - - OSErr anErr = -1; - m_processADRsrcFk = new ProcessAppleDoubleResourceFork; - if (m_processADRsrcFk) - anErr = m_processADRsrcFk->Initialize(realSpec); - - if (anErr != noErr) - return NS_ERROR_FAILURE; - } -#endif - - return NS_OK; -} - - #define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties" nsresult diff --git a/mailnews/compose/src/nsMsgAppleDoubleEncode.cpp b/mailnews/compose/src/nsMsgAppleDoubleEncode.cpp index d68c95b987f..ae7df31c084 100644 --- a/mailnews/compose/src/nsMsgAppleDoubleEncode.cpp +++ b/mailnews/compose/src/nsMsgAppleDoubleEncode.cpp @@ -57,8 +57,6 @@ PRBool nsMsgIsMacFile(char *aUrlString) { - Boolean returnValue = PR_FALSE; - nsAutoString urlStr; urlStr.AssignWithConversion(aUrlString); char *ext = nsMsgGetExtensionFromFileURL(urlStr); if ( (!ext) || (!*ext) ) diff --git a/mailnews/compose/src/nsMsgAttachmentHandler.cpp b/mailnews/compose/src/nsMsgAttachmentHandler.cpp index 49e40f5df45..cce3c948d0d 100644 --- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp +++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp @@ -403,7 +403,7 @@ FetcherURLDoneCallback(nsIURI* aURL, nsresult aStatus, if (aContentType) { //Do not change the type if we are dealing with an apple double file - if (!ma->mAppleFileSpec || PL_strcasecmp(aContentType, APPLICATION_BINHEX)) + if (!ma->mAppleFileSpec) { PR_FREEIF(ma->m_type); ma->m_type = PL_strdup(aContentType); diff --git a/mailnews/mime/src/mimemoz2.cpp b/mailnews/mime/src/mimemoz2.cpp index 87abbc793c4..06a18961277 100644 --- a/mailnews/mime/src/mimemoz2.cpp +++ b/mailnews/mime/src/mimemoz2.cpp @@ -66,8 +66,6 @@ #include "mimeebod.h" -#include "nsISaveMsgListener.h" - static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -776,6 +774,10 @@ mime_output_fn(char *buf, PRInt32 size, void *stream_closure) if ( (!msd->pluginObj2) && (!msd->output_emitter) ) return -1; + // Fire pending start request + ((nsStreamConverter*)msd->pluginObj2)->FirePendingStartRequest(); + + // Now, write to the WriteBody method if this is a message body and not // a part retrevial if (!msd->options->part_to_load) @@ -1016,20 +1018,6 @@ mime_output_init_fn (const char *type, { struct mime_stream_data *msd = (struct mime_stream_data *) stream_closure; -#ifdef XP_MAC - if (msd && msd->output_emitter) - { - nsCOMPtr outputListener; - msd->output_emitter->GetOutputListener(getter_AddRefs(outputListener)); - nsCOMPtr saveListener(do_QueryInterface(outputListener)); - if (saveListener) - { - saveListener->SetMacTypeAndCreator(mime_convert_chars_to_ostype(x_mac_type), - mime_convert_chars_to_ostype(x_mac_creator)); - } - } -#endif - // Now, all of this stream creation is done outside of libmime, so this // is just a check of the pluginObj member and returning accordingly. if (!msd->pluginObj2) diff --git a/mailnews/mime/src/mimemult.cpp b/mailnews/mime/src/mimemult.cpp index b2e64e44c62..7764657f997 100644 --- a/mailnews/mime/src/mimemult.cpp +++ b/mailnews/mime/src/mimemult.cpp @@ -29,7 +29,6 @@ #include "prio.h" #include "nsMimeStringResources.h" #include "nsMimeTypes.h" -#include "nsISaveMsgListener.h" #ifdef XP_MAC extern MimeObjectClass mimeMultipartAppleDoubleClass; @@ -385,30 +384,12 @@ MimeMultipart_create_child(MimeObject *obj) status = body->clazz->parse_begin(body); #ifdef XP_MAC - /* if we are saving an apple double attachment, we need to inform the output stream listener - which fork we are currently processing - */ + /* if we are saving an apple double attachment, we need to set correctly the conten type of the channel */ if (mime_typep(obj, (MimeObjectClass *) &mimeMultipartAppleDoubleClass)) { struct mime_stream_data *msd = (struct mime_stream_data *)body->options->stream_closure; - - if (msd && msd->output_emitter) - { - nsCOMPtr outputListener; - msd->output_emitter->GetOutputListener(getter_AddRefs(outputListener)); - nsCOMPtr saveListener(do_QueryInterface(outputListener)); - if (saveListener) - { - if (body->content_type && !nsCRT::strcasecmp(body->content_type, APPLICATION_APPLEFILE)) - saveListener->OnStartAppleDoubleResourceFork(); - else - { - /* before start writting the data fork, we mush flush the emitter buffer */ - msd->output_emitter->Complete(); - saveListener->OnStartAppleDoubleDataFork(); - } - } - } + if (!body->options->write_html_p && body->content_type && !nsCRT::strcasecmp(body->content_type, APPLICATION_APPLEFILE)) + msd->channel->SetContentType(APPLICATION_APPLEFILE); } #endif diff --git a/mailnews/mime/src/nsStreamConverter.cpp b/mailnews/mime/src/nsStreamConverter.cpp index fb5cd4d59d5..e3c1e10873a 100644 --- a/mailnews/mime/src/nsStreamConverter.cpp +++ b/mailnews/mime/src/nsStreamConverter.cpp @@ -512,6 +512,9 @@ nsStreamConverter::nsStreamConverter() mMimeStreamConverterListener = nsnull; mForwardInline = PR_FALSE; mDesiredOutputType = nsnull; + + mPendingChannel = nsnull; + mPendingContext = nsnull; } nsStreamConverter::~nsStreamConverter() @@ -841,6 +844,7 @@ char *output = "\ PR_snprintf(outBuf, sizeof(outBuf), output, url, url); PR_FREEIF(url); + if (mEmitter) mEmitter->Write(outBuf, nsCRT::strlen(outBuf), &written); mTotalRead += written; @@ -904,9 +908,17 @@ nsStreamConverter::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) aChannel->SetContentType(contentType); } - // forward the start rquest to any listeners + // forward the start request to any listeners if (mOutListener) - mOutListener->OnStartRequest(aChannel, ctxt); + if (mOutputType == nsMimeOutput::nsMimeMessageRaw) + { + //we need to delay the on start request until we have figure out the real content type + mPendingChannel = aChannel; + mPendingContext = ctxt; + } + else + mOutListener->OnStartRequest(aChannel, ctxt); + return NS_OK; } @@ -1062,3 +1074,12 @@ NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const PRUnichar *aFromType, co return Init(aUri, aListener, aChannel); } +NS_IMETHODIMP nsStreamConverter::FirePendingStartRequest() +{ + if (mPendingChannel && mOutListener) + { + mOutListener->OnStartRequest(mPendingChannel, mPendingContext); + mPendingChannel = nsnull; + mPendingContext = nsnull; + } +} diff --git a/mailnews/mime/src/nsStreamConverter.h b/mailnews/mime/src/nsStreamConverter.h index 49ccb9f56a7..d35423492ab 100644 --- a/mailnews/mime/src/nsStreamConverter.h +++ b/mailnews/mime/src/nsStreamConverter.h @@ -60,6 +60,7 @@ public: NS_IMETHOD GetContentType(char **aOutputContentType); NS_IMETHOD InternalCleanup(void); NS_IMETHOD DetermineOutputFormat(const char *url, nsMimeOutputType *newType); + NS_IMETHOD FirePendingStartRequest(void); private: nsresult Close(); @@ -69,7 +70,7 @@ private: nsCOMPtr mInputStream; nsCOMPtr mOutListener; // output stream listener - nsCOMPtr mOutgoingChannel; + nsCOMPtr mOutgoingChannel; nsCOMPtr mEmitter; // emitter being used... nsCOMPtr mURI; // URI being processed @@ -89,11 +90,13 @@ private: PRBool mDoneParsing; // If this is true, we've already been told by libmime to stop sending // data so don't feed the parser any more! nsIMimeStreamConverterListener* mMimeStreamConverterListener; - PRBool mForwardInline; - nsCOMPtr mIdentity; + PRBool mForwardInline; + nsCOMPtr mIdentity; #ifdef DEBUG_mscott PRTime mConvertContentTime; #endif + nsIChannel * mPendingChannel; //Will be use whenn we need to delay to fire onStartRequest + nsISupports * mPendingContext; //Will be use whenn we need to delay to fire onStartRequest }; #endif /* nsStreamConverter_h_ */