mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Implemented asynchronous stream manager for loading multiple
XML UI definitions simultaneously
This commit is contained in:
parent
4701208437
commit
a018a39601
@ -10,7 +10,7 @@
|
||||
GDEPTH = ../../..
|
||||
DEPTH = ../../..
|
||||
|
||||
DIRS = stream capi
|
||||
DIRS = capi
|
||||
|
||||
LIBRARY_NAME = calnetwork
|
||||
|
||||
|
@ -74,8 +74,6 @@ public:
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent);
|
||||
|
||||
NS_IMETHOD_(nsIStreamListener *) GetParserStreamInterface();
|
||||
|
||||
NS_IMETHOD GetRootCanvas(nsIXPFCCanvas ** aCanvas) ;
|
||||
|
||||
private:
|
||||
|
@ -60,8 +60,6 @@ public:
|
||||
|
||||
NS_IMETHOD BindToDocument(nsISupports *aDoc, const char *aCommand) = 0;
|
||||
|
||||
NS_IMETHOD_(nsIStreamListener *) GetParserStreamInterface() = 0;
|
||||
|
||||
NS_IMETHOD LoadURL(const nsString& aURLSpec,
|
||||
nsIStreamObserver* aListener,
|
||||
nsIPostData* aPostData = 0) = 0;
|
||||
|
@ -540,6 +540,7 @@ typedef struct
|
||||
static JULIAN_KEY_VAL KVPairs[] =
|
||||
{
|
||||
CAL_STRING_PREF_JULIAN_UI_XML_MENUBAR, CAL_STRING_RESOURCE_UI_MENUBAR,
|
||||
CAL_STRING_PREF_JULIAN_UI_XML_TOOLBAR, CAL_STRING_RESOURCE_UI_TOOLBAR,
|
||||
CAL_STRING_PREF_JULIAN_UI_XML_CALENDAR, CAL_STRING_RESOURCE_UI_CALENDAR,
|
||||
CAL_STRING_PREF_LOCAL_ADDRESS, CAL_STRING_PREF_LOCAL_ADDRESS_DEFAULT,
|
||||
CAL_STRING_PREF_PREFERRED_ADDR, CAL_STRING_PREF_PREFERRED_ADDR_DEFAULT,
|
||||
@ -790,11 +791,15 @@ nsresult nsCalendarShell::LoadUI()
|
||||
*/
|
||||
#ifdef XP_UNIX
|
||||
mShellInstance->GetPreferences()->GetCharPref(CAL_STRING_PREF_JULIAN_UI_XML_CALENDAR,pUI,&i);
|
||||
res = mDocumentContainer->LoadURL(pUI,nsnull);
|
||||
#else
|
||||
mShellInstance->GetPreferences()->GetCharPref(CAL_STRING_PREF_JULIAN_UI_XML_MENUBAR,pUI,&i);
|
||||
#endif
|
||||
|
||||
res = mDocumentContainer->LoadURL(pUI,nsnull);
|
||||
mShellInstance->GetPreferences()->GetCharPref(CAL_STRING_PREF_JULIAN_UI_XML_CALENDAR,pUI,&i);
|
||||
res = mDocumentContainer->LoadURL(pUI,nsnull);
|
||||
mShellInstance->GetPreferences()->GetCharPref(CAL_STRING_PREF_JULIAN_UI_XML_TOOLBAR,pUI,&i);
|
||||
res = mDocumentContainer->LoadURL(pUI,nsnull);
|
||||
#endif
|
||||
|
||||
mShellInstance->ShowApplicationWindow(PR_TRUE) ;
|
||||
|
||||
|
@ -55,7 +55,6 @@ class nsICalendarShell;
|
||||
#include "nsCalXMLDTD.h"
|
||||
#include "nsXPFCXMLContentSink.h"
|
||||
#include "nsXPFCXMLDTD.h"
|
||||
#include "nsCalStreamListener.h"
|
||||
#include "nsCurlParser.h"
|
||||
#include "nsCalToolkit.h"
|
||||
#include "nsBoxLayout.h"
|
||||
@ -213,14 +212,6 @@ nsresult nsCalendarWidget::LoadURL(const nsString& aURLSpec, nsIStreamObserver*
|
||||
if (stream_manager == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
|
||||
nsIStreamListener * stream_listener;
|
||||
|
||||
NS_NewCalStreamListener(&stream_listener);
|
||||
|
||||
((nsCalStreamListener *)stream_listener)->SetWidget(this);
|
||||
|
||||
nsIID * iid_dtd = nsnull;
|
||||
nsIID * iid_sink = nsnull ;
|
||||
|
||||
@ -236,7 +227,6 @@ nsresult nsCalendarWidget::LoadURL(const nsString& aURLSpec, nsIStreamObserver*
|
||||
|
||||
res = stream_manager->LoadURL(((nsCalendarShell*)mCalendarShell)->mDocumentContainer,
|
||||
aURLSpec,
|
||||
stream_listener,
|
||||
aPostData,iid_dtd,iid_sink);
|
||||
|
||||
return res;
|
||||
@ -270,25 +260,6 @@ nsEventStatus nsCalendarWidget::HandleEvent(nsGUIEvent *aEvent)
|
||||
return (mRootCanvas->HandleEvent(aEvent));
|
||||
}
|
||||
|
||||
nsIStreamListener * nsCalendarWidget::GetParserStreamInterface()
|
||||
{
|
||||
NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
|
||||
nsIStreamManager * stream_manager = ((nsCalendarShell *)mCalendarShell)->mShellInstance->GetStreamManager();
|
||||
|
||||
if (stream_manager == nsnull)
|
||||
return nsnull;
|
||||
|
||||
nsIStreamListener * aStreamListener ;
|
||||
|
||||
nsresult res = ((nsStreamManager *)stream_manager)->mParser->QueryInterface(kIStreamListenerIID, (void **)&aStreamListener);
|
||||
|
||||
if (NS_OK != res)
|
||||
return (nsnull);
|
||||
|
||||
return (aStreamListener);
|
||||
}
|
||||
|
||||
nsresult nsCalendarWidget::GetRootCanvas(nsIXPFCCanvas ** aCanvas)
|
||||
{
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#define CAL_STRING_HEIGHT "height"
|
||||
#define CAL_STRING_HOUR "hour"
|
||||
#define CAL_STRING_PREF_JULIAN_UI_XML_MENUBAR "julian.ui.xml.menubar"
|
||||
#define CAL_STRING_PREF_JULIAN_UI_XML_TOOLBAR "julian.ui.xml.toolbar"
|
||||
#define CAL_STRING_PREF_JULIAN_UI_XML_CALENDAR "julian.ui.xml.calendar"
|
||||
#define CAL_STRING_ID "id"
|
||||
#define CAL_STRING_LABEL "label"
|
||||
@ -48,6 +49,7 @@
|
||||
#define CAL_STRING_ORIENTATION "orientation"
|
||||
#define CAL_STRING_PANEL "panel"
|
||||
#define CAL_STRING_RESOURCE_UI_MENUBAR "resource://res/ui/menubar.ui"
|
||||
#define CAL_STRING_RESOURCE_UI_TOOLBAR "resource://res/ui/toolbar.ui"
|
||||
#define CAL_STRING_RESOURCE_UI_CALENDAR "resource://res/ui/julian.cal"
|
||||
#define CAL_STRING_RULE "rule"
|
||||
#define CAL_STRING_SECOND "second"
|
||||
|
@ -37,6 +37,11 @@
|
||||
{ 0x03dd8f40, 0x3610, 0x11d2, \
|
||||
{0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} }
|
||||
|
||||
// f7c349a0-4915-11d2-924a-00805f8a7ab6
|
||||
#define NS_STREAM_OBJECT_CID \
|
||||
{ 0xf7c349a0, 0x4915, 0x11d2, \
|
||||
{0x92, 0x4a, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} }
|
||||
|
||||
// cd5cd8b0-3b80-11d2-bee0-00805f8a8dbd
|
||||
#define NS_XPFC_DIALOG_CID \
|
||||
{ 0xcd5cd8b0, 0x3b80, 0x11d2, \
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "nsMenuManager.h"
|
||||
#include "nsToolbarManager.h"
|
||||
#include "nsStreamManager.h"
|
||||
#include "nsStreamObject.h"
|
||||
#include "nsVector.h"
|
||||
#include "nsVectorIterator.h"
|
||||
#include "nsStack.h"
|
||||
@ -63,6 +64,8 @@ static NS_DEFINE_IID(kCMenuContainer, NS_MENUCONTAINER_CID);
|
||||
static NS_DEFINE_IID(kCMenuManager, NS_MENU_MANAGER_CID);
|
||||
static NS_DEFINE_IID(kCStreamManager, NS_STREAM_MANAGER_CID);
|
||||
static NS_DEFINE_IID(kIStreamManager, NS_ISTREAM_MANAGER_IID);
|
||||
static NS_DEFINE_IID(kCStreamObject, NS_STREAM_OBJECT_CID);
|
||||
static NS_DEFINE_IID(kIStreamObject, NS_ISTREAM_OBJECT_IID);
|
||||
static NS_DEFINE_IID(kCXPFCDTD, NS_IXPFCXML_DTD_IID);
|
||||
static NS_DEFINE_IID(kCXPFCContentSink, NS_XPFCXMLCONTENTSINK_IID);
|
||||
static NS_DEFINE_IID(kCXPFCToolbar, NS_XPFC_TOOLBAR_CID);
|
||||
|
@ -110,6 +110,8 @@ nsresult nsxpfcFactory::CreateInstance(nsISupports *aOuter,
|
||||
inst = (nsISupports *)(nsIToolbarManager *)new nsToolbarManager();
|
||||
} else if (mClassID.Equals(kCStreamManager)) {
|
||||
inst = (nsISupports *)(nsIStreamManager *)new nsStreamManager();
|
||||
} else if (mClassID.Equals(kCStreamObject)) {
|
||||
inst = (nsISupports *)(nsIStreamObject *)new nsStreamObject();
|
||||
} else if (mClassID.Equals(kCMenuItem)) {
|
||||
inst = (nsISupports *)(nsIMenuItem *)new nsMenuItem();
|
||||
} else if (mClassID.Equals(kCXPFCDTD)) {
|
||||
|
@ -13,6 +13,7 @@ EXPORTS = \
|
||||
nsShellInstance.h \
|
||||
nsApplicationManager.h \
|
||||
nsStreamManager.h \
|
||||
nsStreamObject.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = xpfc
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIVector.h"
|
||||
#include "nsIIterator.h"
|
||||
#include "nsIStreamManager.h"
|
||||
|
||||
class nsStreamManager : public nsIStreamManager
|
||||
@ -44,7 +46,6 @@ public:
|
||||
|
||||
NS_IMETHOD LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
const nsString& aURLSpec,
|
||||
nsIStreamListener* aListener,
|
||||
nsIPostData * aPostData,
|
||||
nsIID *aDTDIID = nsnull,
|
||||
nsIID *aSinkIID = nsnull);
|
||||
@ -53,6 +54,7 @@ private:
|
||||
nsIURL * mUrl;
|
||||
nsIDTD * mDTD;
|
||||
nsIContentSink * mSink;
|
||||
nsIVector * mStreamObjects;
|
||||
|
||||
public:
|
||||
nsIParser * mParser;
|
||||
|
67
xpfc/shell/inc/nsStreamObject.h
Normal file
67
xpfc/shell/inc/nsStreamObject.h
Normal file
@ -0,0 +1,67 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIStreamObject.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
class nsStreamObject : public nsIStreamObject,
|
||||
public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor and Destructor
|
||||
*/
|
||||
|
||||
nsStreamObject();
|
||||
~nsStreamObject();
|
||||
|
||||
/**
|
||||
* ISupports Interface
|
||||
*/
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
* Initialize Method
|
||||
* @result The result of the initialization, NS_OK if no errors
|
||||
*/
|
||||
NS_IMETHOD Init();
|
||||
|
||||
NS_IMETHOD OnStartBinding(nsIURL * aURL, const char *aContentType);
|
||||
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg) ;
|
||||
NS_IMETHOD OnStopBinding(nsIURL * aURL,
|
||||
PRInt32 aStatus,
|
||||
const nsString &aMsg);
|
||||
|
||||
NS_IMETHOD GetBindInfo(nsIURL * aURL);
|
||||
NS_IMETHOD OnDataAvailable(nsIURL * aURL,
|
||||
nsIInputStream *aIStream,
|
||||
PRInt32 aLength);
|
||||
|
||||
public:
|
||||
nsIParser * mParser;
|
||||
nsIURL * mUrl;
|
||||
nsIDTD * mDTD;
|
||||
nsIContentSink * mSink;
|
||||
nsIStreamListener * mStreamListener;
|
||||
};
|
||||
|
||||
|
@ -15,6 +15,7 @@ EXPORTS = \
|
||||
nsIShellInstance.h \
|
||||
nsIWebViewerContainer.h\
|
||||
nsIStreamManager.h \
|
||||
nsIStreamObject.h \
|
||||
$(NULL)
|
||||
|
||||
PRIVATE_EXPORTS = \
|
||||
|
@ -44,7 +44,6 @@ public:
|
||||
|
||||
NS_IMETHOD LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
const nsString& aURLSpec,
|
||||
nsIStreamListener* aListener,
|
||||
nsIPostData * aPostData,
|
||||
nsIID *aDTDIID = nsnull,
|
||||
nsIID *aSinkIID = nsnull) = 0;
|
||||
|
47
xpfc/shell/public/nsIStreamObject.h
Normal file
47
xpfc/shell/public/nsIStreamObject.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIStreamObject_h___
|
||||
#define nsIStreamObject_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsxpfc.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIWebViewerContainer.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
// 38acdab0-4914-11d2-924a-00805f8a7ab6
|
||||
#define NS_ISTREAM_OBJECT_IID \
|
||||
{ 0x38acdab0, 0x4914, 0x11d2, \
|
||||
{0x92, 0x4a, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} }
|
||||
|
||||
// Application Shell Interface
|
||||
class nsIStreamObject : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Initialize the StreamObject
|
||||
* @result The result of the initialization, NS_OK if no errors
|
||||
*/
|
||||
NS_IMETHOD Init() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIStreamObject_h___ */
|
@ -23,6 +23,7 @@ CPPSRCS = \
|
||||
nsApplicationManager.cpp \
|
||||
nsShellInstance.cpp \
|
||||
nsStreamManager.cpp \
|
||||
nsStreamObject.cpp \
|
||||
$(NULL)
|
||||
|
||||
REQUIRES = xpcom raptor pref js netlib
|
||||
|
@ -27,11 +27,20 @@
|
||||
#include "nspr.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsXPFCXMLContentSink.h"
|
||||
#include "nsStreamObject.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kCStreamManager, NS_STREAM_MANAGER_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
|
||||
static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID);
|
||||
static NS_DEFINE_IID(kCCalXPFCXMLDTD, NS_IXPFCXML_DTD_IID);
|
||||
static NS_DEFINE_IID(kCCalXPFCXMLContentSinkCID, NS_XPFCXMLCONTENTSINK_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIStreamObjectIID, NS_ISTREAM_OBJECT_IID);
|
||||
static NS_DEFINE_IID(kCStreamObjectCID, NS_STREAM_OBJECT_CID);
|
||||
|
||||
nsStreamManager::nsStreamManager()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
@ -46,6 +55,12 @@ nsStreamManager::~nsStreamManager()
|
||||
NS_IF_RELEASE(mUrl);
|
||||
NS_IF_RELEASE(mParser);
|
||||
NS_IF_RELEASE(mSink);
|
||||
|
||||
if (mStreamObjects != nsnull) {
|
||||
mStreamObjects->RemoveAll();
|
||||
NS_RELEASE(mStreamObjects);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_DEFINE_IID(kIStreamManagerIID, NS_ISTREAM_MANAGER_IID);
|
||||
@ -53,28 +68,27 @@ NS_IMPL_ISUPPORTS(nsStreamManager,kIStreamManagerIID);
|
||||
|
||||
nsresult nsStreamManager::Init()
|
||||
{
|
||||
static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID);
|
||||
|
||||
nsresult res = nsRepository::CreateInstance(kCVectorCID,
|
||||
nsnull,
|
||||
kCVectorCID,
|
||||
(void **)&mStreamObjects);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
mStreamObjects->Init();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsStreamManager::LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
const nsString& aURLSpec,
|
||||
nsIStreamListener* aListener,
|
||||
nsIPostData * aPostData,
|
||||
nsIID *aDTDIID,
|
||||
nsIID *aSinkIID)
|
||||
{
|
||||
/*
|
||||
* If we can find the file, then use it, else use the HARDCODE.
|
||||
* We'll need to change the way we deal with this since the file
|
||||
* could be gotten over the network.
|
||||
*/
|
||||
|
||||
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
|
||||
static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID);
|
||||
|
||||
static NS_DEFINE_IID(kCCalXPFCXMLDTD, NS_IXPFCXML_DTD_IID);
|
||||
static NS_DEFINE_IID(kCCalXPFCXMLContentSinkCID, NS_XPFCXMLCONTENTSINK_IID);
|
||||
|
||||
nsIID * iid_dtd = aDTDIID;
|
||||
nsIID * iid_sink = aSinkIID;
|
||||
|
||||
@ -83,22 +97,40 @@ nsresult nsStreamManager::LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
if (iid_sink == nsnull)
|
||||
iid_sink = (nsIID*)&kCCalXPFCXMLContentSinkCID;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
char * pUI = aURLSpec.ToNewCString();
|
||||
|
||||
nsStreamObject * stream_object = nsnull;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
res = nsRepository::CreateInstance(kCStreamObjectCID,
|
||||
nsnull,
|
||||
kIStreamObjectIID,
|
||||
(void**) &stream_object);
|
||||
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
stream_object->Init();
|
||||
|
||||
mStreamObjects->Append(stream_object);
|
||||
|
||||
/*
|
||||
* Create a nsIURL representing the interface ...
|
||||
*/
|
||||
|
||||
nsresult res = NS_OK;
|
||||
nsUrlParser urlParser(pUI);
|
||||
|
||||
|
||||
/*
|
||||
* Create a StreamObject
|
||||
*/
|
||||
|
||||
if (urlParser.IsLocalFile() == PR_TRUE) {
|
||||
char * pURL = urlParser.LocalFileToURL();
|
||||
res = NS_NewURL(&mUrl, pURL);
|
||||
res = NS_NewURL(&(stream_object->mUrl), pURL);
|
||||
} else {
|
||||
res = NS_NewURL(&mUrl, pUI);
|
||||
res = NS_NewURL(&(stream_object->mUrl), pUI);
|
||||
}
|
||||
|
||||
|
||||
@ -122,16 +154,18 @@ nsresult nsStreamManager::LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
rv = nsRepository::CreateInstance(kCParserCID,
|
||||
res = nsRepository::CreateInstance(kCParserCID,
|
||||
nsnull,
|
||||
kCParserIID,
|
||||
(void **)&mParser);
|
||||
(void **)&(stream_object->mParser));
|
||||
|
||||
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = stream_object->mParser->QueryInterface(kIStreamListenerIID, (void **)&(stream_object->mStreamListener));
|
||||
|
||||
/*
|
||||
* Create the DTD and Sink
|
||||
*/
|
||||
@ -139,7 +173,7 @@ nsresult nsStreamManager::LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
res = nsRepository::CreateInstance(*iid_dtd,
|
||||
nsnull,
|
||||
kIDTDIID,
|
||||
(void**) &mDTD);
|
||||
(void**) &(stream_object->mDTD));
|
||||
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
@ -149,7 +183,7 @@ nsresult nsStreamManager::LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
res = nsRepository::CreateInstance(*iid_sink,
|
||||
nsnull,
|
||||
kIContentSinkIID,
|
||||
(void**) &mSink);
|
||||
(void**) &(stream_object->mSink));
|
||||
|
||||
if (NS_OK != res) {
|
||||
return res;
|
||||
@ -159,7 +193,7 @@ nsresult nsStreamManager::LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
|
||||
static NS_DEFINE_IID(kIXPFCXMLContentSinkIID, NS_IXPFC_XML_CONTENT_SINK_IID);
|
||||
|
||||
res = mSink->QueryInterface(kIXPFCXMLContentSinkIID,(void**)&sink);
|
||||
res = stream_object->mSink->QueryInterface(kIXPFCXMLContentSinkIID,(void**)&sink);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
@ -171,35 +205,35 @@ nsresult nsStreamManager::LoadURL(nsIWebViewerContainer * aWebViewerContainer,
|
||||
* Register the DTD
|
||||
*/
|
||||
|
||||
mParser->RegisterDTD(mDTD);
|
||||
stream_object->mParser->RegisterDTD(stream_object->mDTD);
|
||||
|
||||
|
||||
/*
|
||||
* Register the Context Sink, Parser, etc...
|
||||
*/
|
||||
|
||||
mParser->SetContentSink(mSink);
|
||||
stream_object->mParser->SetContentSink(stream_object->mSink);
|
||||
|
||||
|
||||
mDTD->SetContentSink(mSink);
|
||||
mDTD->SetParser(mParser);
|
||||
stream_object->mDTD->SetContentSink(stream_object->mSink);
|
||||
stream_object->mDTD->SetParser(stream_object->mParser);
|
||||
|
||||
|
||||
/*
|
||||
* Open the URL
|
||||
*/
|
||||
|
||||
res = mUrl->Open(aListener);
|
||||
res = stream_object->mUrl->Open(stream_object->mStreamListener);
|
||||
|
||||
|
||||
/*
|
||||
* We want to parse when the Stream has data?
|
||||
*/
|
||||
|
||||
mParser->Parse(mUrl);
|
||||
stream_object->mParser->Parse(stream_object->mUrl);
|
||||
|
||||
delete pUI;
|
||||
|
||||
return rv;
|
||||
return res;
|
||||
|
||||
}
|
128
xpfc/shell/src/nsStreamObject.cpp
Normal file
128
xpfc/shell/src/nsStreamObject.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nscore.h"
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsStreamObject.h"
|
||||
#include "nsxpfcCIID.h"
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsUrlParser.h"
|
||||
#include "nspr.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsXPFCXMLContentSink.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kCStreamObject, NS_STREAM_OBJECT_CID);
|
||||
|
||||
nsStreamObject::nsStreamObject()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mUrl = nsnull;
|
||||
mParser = nsnull;
|
||||
mDTD = nsnull;
|
||||
mSink = nsnull;
|
||||
mStreamListener = nsnull;
|
||||
}
|
||||
|
||||
nsStreamObject::~nsStreamObject()
|
||||
{
|
||||
NS_IF_RELEASE(mUrl);
|
||||
NS_IF_RELEASE(mParser);
|
||||
NS_IF_RELEASE(mSink);
|
||||
NS_IF_RELEASE(mDTD);
|
||||
NS_IF_RELEASE(mStreamListener);
|
||||
}
|
||||
|
||||
NS_DEFINE_IID(kIStreamObjectIID, NS_ISTREAM_OBJECT_IID);
|
||||
|
||||
NS_IMPL_ADDREF(nsStreamObject)
|
||||
NS_IMPL_RELEASE(nsStreamObject)
|
||||
|
||||
nsresult nsStreamObject::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if(aIID.Equals(kISupportsIID)) { //do IUnknown...
|
||||
*aInstancePtr = (nsISupports*)(nsIStreamObject*)(this);
|
||||
}
|
||||
else if(aIID.Equals(kIStreamObjectIID)) { //do this class...
|
||||
*aInstancePtr = (nsStreamObject*)(this);
|
||||
}
|
||||
else if(aIID.Equals(kIStreamListenerIID)) { //do this class...
|
||||
*aInstancePtr = (nsIStreamListener*)(this);
|
||||
}
|
||||
else {
|
||||
*aInstancePtr=0;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
((nsISupports*) *aInstancePtr)->AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsStreamObject::Init()
|
||||
{
|
||||
if (mParser != nsnull)
|
||||
{
|
||||
nsresult res = mParser->QueryInterface(kIStreamListenerIID, (void **)&mStreamListener);
|
||||
|
||||
if (NS_OK != res)
|
||||
mStreamListener = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsStreamObject::GetBindInfo(nsIURL * aURL)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsStreamObject::OnDataAvailable(nsIURL * aURL,
|
||||
nsIInputStream *aIStream,
|
||||
PRInt32 aLength)
|
||||
{
|
||||
return (mStreamListener->OnDataAvailable(aURL, aIStream, aLength));
|
||||
}
|
||||
|
||||
nsresult nsStreamObject::OnStartBinding(nsIURL * aURL,
|
||||
const char *aContentType)
|
||||
{
|
||||
return (mStreamListener->OnStartBinding(aURL,aContentType));
|
||||
}
|
||||
|
||||
nsresult nsStreamObject::OnStopBinding(nsIURL * aURL, PRInt32 aStatus, const nsString &aMsg)
|
||||
{
|
||||
return (mStreamListener->OnStopBinding(aURL, aStatus, aMsg));
|
||||
}
|
||||
|
||||
nsresult nsStreamObject::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsStreamObject::OnStatus(nsIURL* aURL, const nsString &aMsg)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID);
|
||||
static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID);
|
||||
static NS_DEFINE_IID(kCstackCID, NS_STACK_CID);
|
||||
static NS_DEFINE_IID(kCStreamManagerCID, NS_STREAM_MANAGER_CID);
|
||||
static NS_DEFINE_IID(kCStreamObjectCID, NS_STREAM_OBJECT_CID);
|
||||
|
||||
XtAppContext app_context ;
|
||||
Widget topLevel;
|
||||
@ -88,6 +89,7 @@ void main(int argc, char **argv)
|
||||
nsRepository::RegisterFactory(kCXPFCTabWidgetCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCToolbarManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCStreamManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCStreamObjectCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCVectorCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCVectorIteratorCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCstackCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
|
@ -52,6 +52,7 @@ static NS_DEFINE_IID(kCXPFCTabWidgetCID, NS_XPFC_TABWIDGET_CID);
|
||||
|
||||
static NS_DEFINE_IID(kCToolbarManagerCID, NS_TOOLBAR_MANAGER_CID);
|
||||
static NS_DEFINE_IID(kCStreamManagerCID, NS_STREAM_MANAGER_CID);
|
||||
static NS_DEFINE_IID(kCStreamObjectCID, NS_STREAM_OBJECT_CID);
|
||||
static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID);
|
||||
static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID);
|
||||
static NS_DEFINE_IID(kCstackCID, NS_STACK_CID);
|
||||
@ -79,6 +80,7 @@ int PASCAL WinMain(HANDLE instance, HANDLE prevInstance, LPSTR cmdParam, int nCm
|
||||
nsRepository::RegisterFactory(kCXPFCTabWidgetCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCToolbarManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCStreamManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCStreamObjectCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCVectorCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCVectorIteratorCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterFactory(kCstackCID, XPFC_DLL, PR_FALSE, PR_FALSE);
|
||||
|
Loading…
Reference in New Issue
Block a user