From ae6cca052daae7c2337fd2a3fb4e403e698c786a Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Fri, 3 Sep 1999 22:03:12 +0000 Subject: [PATCH] Bug #10845 --> mailnews mime stream converter now works with the stream converter service and uses nsIstreamConverter instead of nsIStreamConverter2. git-svn-id: svn://10.0.0.236/trunk@45919 18797224-902f-48f8-a5cc-f745e15eee43 --- .../protocol/file/src/nsFileChannel.cpp | 23 ++++++++++--------- .../netwerk/protocol/file/src/nsFileChannel.h | 6 ++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp index 567a8af67ea..14d1a4ef9c4 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp @@ -50,8 +50,8 @@ static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #ifdef STREAM_CONVERTER_HACK +#include "nsIStreamConverter.h" #include "nsIAllocator.h" -static NS_DEFINE_CID(kStreamConverterCID, NS_STREAM_CONVERTER_CID); #endif #if defined(PR_LOGGING) @@ -384,13 +384,11 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, // code which if we are rfc-822 will cause us to literally insert a converter between // the file channel stream of incoming data and the consumer at the other end of the // AsyncRead call... - + mRealListener = listener; #ifdef STREAM_CONVERTER_HACK nsXPIDLCString aContentType; - mRealListener = listener; - rv = GetContentType(getter_Copies(aContentType)); if (NS_SUCCEEDED(rv) && PL_strcasecmp("message/rfc822", aContentType) == 0) { @@ -404,13 +402,17 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, // (4) set mListener to be the stream converter's listener. // (0) create a stream converter - nsCOMPtr mimeParser; + nsCOMPtr mimeParser; // mscott - we could generalize this hack to work with other stream converters by simply // using the content type of the file to generate a progid for a stream converter and use // that instead of a class id... + + nsIComponentManager *comMgr; + rv = NS_GetGlobalComponentManager(&comMgr); + if (!mStreamConverter) - rv = nsComponentManager::CreateInstance(kStreamConverterCID, - NULL, nsCOMTypeInfo::GetIID(), + rv = comMgr->CreateInstance(NS_ISTREAMCONVERTER_KEY "?from=message/rfc822?to=text/xul", + NULL, nsCOMTypeInfo::GetIID(), (void **) getter_AddRefs(mStreamConverter)); if (NS_FAILED(rv)) return rv; @@ -423,9 +425,8 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, mListener = mStreamConverter; NS_IF_ADDREF(mListener); // mListener is NOT a com ptr... - // now set the output stream correctly - mStreamConverter->Init(mURI, proxiedConsumerListener, this); - mStreamConverter->GetContentType(getter_Copies(mStreamConverterOutType)); + mStreamConverter->AsyncConvertData(nsnull, nsnull, proxiedConsumerListener, (nsIChannel *) this); + mStreamConverterOutType = "text/xul"; } else rv = serv->NewAsyncStreamListener(this, mEventQueue, &mListener); @@ -528,7 +529,7 @@ nsFileChannel::GetContentType(char * *aContentType) // the stream converter out type... if (mStreamConverter) { - *aContentType = (char *) nsAllocator::Clone(mStreamConverterOutType, nsCRT::strlen(mStreamConverterOutType) + 1); + *aContentType = mStreamConverterOutType.ToNewCString(); return rv; } #endif diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.h b/mozilla/netwerk/protocol/file/src/nsFileChannel.h index 3c842f1bd71..09955055376 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.h +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.h @@ -39,7 +39,7 @@ #include "nsCOMPtr.h" #ifdef STREAM_CONVERTER_HACK -#include "nsIStreamConverter2.h" +#include "nsIStreamConverter.h" #include "nsXPIDLString.h" #endif @@ -128,8 +128,8 @@ protected: nsCOMPtr mRealListener; #ifdef STREAM_CONVERTER_HACK - nsCOMPtr mStreamConverter; - nsXPIDLCString mStreamConverterOutType; + nsCOMPtr mStreamConverter; + nsCString mStreamConverterOutType; #endif };