added stream converter functionality to the doc loader. also initialize/register the multipartmixedreplace stream converter in the webshell
git-svn-id: svn://10.0.0.236/trunk@45046 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
6ebdbfafb5
commit
09be5128d6
@ -68,6 +68,13 @@
|
||||
#include "prmem.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "nsMultiMixedConv.h" // for
|
||||
#include "nsIRegistry.h"
|
||||
static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID);
|
||||
#endif // XP_MAC
|
||||
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@ -1172,6 +1179,39 @@ nsWebShell::Init(nsNativeWidget aNativeParent,
|
||||
widgetInit.mWindowType = eWindowType_child;
|
||||
}
|
||||
|
||||
// STREAM CONVERTER REGISTRATION
|
||||
// multipart mixed converter registration
|
||||
#ifndef XP_MAC
|
||||
nsIFactory *multiMixedFactSup;
|
||||
rv = nsComponentManager::FindFactory(kMultiMixedConverterCID, &multiMixedFactSup);
|
||||
if (SUCCEEDED(rv)) {
|
||||
rv = nsComponentManager::RegisterFactory(kMultiMixedConverterCID,
|
||||
"MultiMixedConverter",
|
||||
NS_ISTREAMCONVERTER_KEY "?from=multipart/x-mixed-replace?to=text/html",
|
||||
multiMixedFactSup,
|
||||
PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
nsIRegistry *registry;
|
||||
rv = nsServiceManager::GetService(kRegistryCID, NS_GET_IID(nsIRegistry), (nsISupports**) ®istry);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
// open the registry
|
||||
rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
// set the key
|
||||
nsIRegistry::Key key, key1;
|
||||
|
||||
rv = registry->AddSubtree(nsIRegistry::Common, NS_ISTREAMCONVERTER_KEY, &key);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = registry->AddSubtreeRaw(key, "?from=multipart/x-mixed-replace?to=text/html", &key1);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
}
|
||||
#endif // XP_MAC
|
||||
// END STREAM CONVERTER REGISTRATION
|
||||
|
||||
done:
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -57,6 +57,12 @@
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIStreamConverter.h"
|
||||
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
#endif // XP_MAC
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
// XXX ick ick ick
|
||||
@ -2055,6 +2061,7 @@ nsDocumentBindInfo::OnStartRequest(nsIURI* aURL, const char *aContentType)
|
||||
* (and viewer) of the appropriate type...
|
||||
*/
|
||||
if (m_DocLoader) {
|
||||
|
||||
rv = m_DocLoader->CreateContentViewer(m_Command,
|
||||
#ifdef NECKO
|
||||
channel,
|
||||
@ -2382,9 +2389,47 @@ nsChannelListener::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext)
|
||||
nsCOMPtr<nsIContentViewerContainer> container;
|
||||
nsCOMPtr<nsIContentViewer> viewer;
|
||||
|
||||
///////////////////////////////
|
||||
// STREAM CONVERTERS
|
||||
///////////////////////////////
|
||||
#ifndef XP_MAC
|
||||
char *contentType = nsnull;
|
||||
rv = aChannel->GetContentType(&contentType);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Let's shanghai this channelListener's mNextListener if we want to convert the stream.
|
||||
if (!PL_strcmp(contentType, "multipart/x-mixed-replace")) {
|
||||
// we want to pass off multipart/x-mixed-replace to the a stream converter
|
||||
// that knows what to do with it.
|
||||
NS_WITH_SERVICE(nsIStreamConverterService, StreamConvService, kStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
nsAllocator::Free(contentType);
|
||||
return rv;
|
||||
}
|
||||
nsString2 from("multipart/x-mixed-replace"), to("text/html");
|
||||
|
||||
// The following call binds this channelListener's mNextListener (typically
|
||||
// the nsDocumentBindInfo) to the underlying stream converter, and returns
|
||||
// the underlying stream converter which we then set to be this channelListener's
|
||||
// mNextListener. This effectively nestles the stream converter down right
|
||||
// in between the raw stream and the final listener.
|
||||
nsIStreamListener *converterListener = nsnull;
|
||||
rv = StreamConvService->AsyncConvertData(from.GetUnicode(),
|
||||
to.GetUnicode(), mNextListener,
|
||||
&converterListener);
|
||||
mNextListener = converterListener;
|
||||
}
|
||||
nsAllocator::Free(contentType);
|
||||
#endif // XP_MAC
|
||||
|
||||
//////////////////////////////
|
||||
// END STREAM CONVERTERS
|
||||
//////////////////////////////
|
||||
|
||||
// Pass the notification to the next listener...
|
||||
rv = mNextListener->OnStartRequest(aChannel, aContext);
|
||||
|
||||
|
||||
//
|
||||
// Notify the document loader...
|
||||
mDocLoader->GetContainer(getter_AddRefs(container));
|
||||
|
||||
@ -57,6 +57,12 @@
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIStreamConverter.h"
|
||||
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
#endif // XP_MAC
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
// XXX ick ick ick
|
||||
@ -2055,6 +2061,7 @@ nsDocumentBindInfo::OnStartRequest(nsIURI* aURL, const char *aContentType)
|
||||
* (and viewer) of the appropriate type...
|
||||
*/
|
||||
if (m_DocLoader) {
|
||||
|
||||
rv = m_DocLoader->CreateContentViewer(m_Command,
|
||||
#ifdef NECKO
|
||||
channel,
|
||||
@ -2382,9 +2389,47 @@ nsChannelListener::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext)
|
||||
nsCOMPtr<nsIContentViewerContainer> container;
|
||||
nsCOMPtr<nsIContentViewer> viewer;
|
||||
|
||||
///////////////////////////////
|
||||
// STREAM CONVERTERS
|
||||
///////////////////////////////
|
||||
#ifndef XP_MAC
|
||||
char *contentType = nsnull;
|
||||
rv = aChannel->GetContentType(&contentType);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Let's shanghai this channelListener's mNextListener if we want to convert the stream.
|
||||
if (!PL_strcmp(contentType, "multipart/x-mixed-replace")) {
|
||||
// we want to pass off multipart/x-mixed-replace to the a stream converter
|
||||
// that knows what to do with it.
|
||||
NS_WITH_SERVICE(nsIStreamConverterService, StreamConvService, kStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
nsAllocator::Free(contentType);
|
||||
return rv;
|
||||
}
|
||||
nsString2 from("multipart/x-mixed-replace"), to("text/html");
|
||||
|
||||
// The following call binds this channelListener's mNextListener (typically
|
||||
// the nsDocumentBindInfo) to the underlying stream converter, and returns
|
||||
// the underlying stream converter which we then set to be this channelListener's
|
||||
// mNextListener. This effectively nestles the stream converter down right
|
||||
// in between the raw stream and the final listener.
|
||||
nsIStreamListener *converterListener = nsnull;
|
||||
rv = StreamConvService->AsyncConvertData(from.GetUnicode(),
|
||||
to.GetUnicode(), mNextListener,
|
||||
&converterListener);
|
||||
mNextListener = converterListener;
|
||||
}
|
||||
nsAllocator::Free(contentType);
|
||||
#endif // XP_MAC
|
||||
|
||||
//////////////////////////////
|
||||
// END STREAM CONVERTERS
|
||||
//////////////////////////////
|
||||
|
||||
// Pass the notification to the next listener...
|
||||
rv = mNextListener->OnStartRequest(aChannel, aContext);
|
||||
|
||||
|
||||
//
|
||||
// Notify the document loader...
|
||||
mDocLoader->GetContainer(getter_AddRefs(container));
|
||||
|
||||
@ -68,6 +68,13 @@
|
||||
#include "prmem.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "nsMultiMixedConv.h" // for
|
||||
#include "nsIRegistry.h"
|
||||
static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID);
|
||||
#endif // XP_MAC
|
||||
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@ -1172,6 +1179,39 @@ nsWebShell::Init(nsNativeWidget aNativeParent,
|
||||
widgetInit.mWindowType = eWindowType_child;
|
||||
}
|
||||
|
||||
// STREAM CONVERTER REGISTRATION
|
||||
// multipart mixed converter registration
|
||||
#ifndef XP_MAC
|
||||
nsIFactory *multiMixedFactSup;
|
||||
rv = nsComponentManager::FindFactory(kMultiMixedConverterCID, &multiMixedFactSup);
|
||||
if (SUCCEEDED(rv)) {
|
||||
rv = nsComponentManager::RegisterFactory(kMultiMixedConverterCID,
|
||||
"MultiMixedConverter",
|
||||
NS_ISTREAMCONVERTER_KEY "?from=multipart/x-mixed-replace?to=text/html",
|
||||
multiMixedFactSup,
|
||||
PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
nsIRegistry *registry;
|
||||
rv = nsServiceManager::GetService(kRegistryCID, NS_GET_IID(nsIRegistry), (nsISupports**) ®istry);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
// open the registry
|
||||
rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
// set the key
|
||||
nsIRegistry::Key key, key1;
|
||||
|
||||
rv = registry->AddSubtree(nsIRegistry::Common, NS_ISTREAMCONVERTER_KEY, &key);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = registry->AddSubtreeRaw(key, "?from=multipart/x-mixed-replace?to=text/html", &key1);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
}
|
||||
#endif // XP_MAC
|
||||
// END STREAM CONVERTER REGISTRATION
|
||||
|
||||
done:
|
||||
return rv;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user