Minor changes to nsIStreamListener interface... OnStartBinding(...) now passes out the stream content-type. User visible strings are now nsString arguments (for subsequent i18n)

This commit is contained in:
rpotts 1998-06-04 05:09:32 +00:00
Родитель b40933b15c
Коммит 53ca67cf12
12 изменённых файлов: 79 добавлений и 55 удалений

Просмотреть файл

@ -130,15 +130,17 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD GetBindInfo(void) { return NS_OK; } NS_IMETHOD GetBindInfo(void) { return NS_OK; }
NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) { return NS_OK; } NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg) { return NS_OK; }
NS_IMETHOD OnStartBinding(void) { return NS_OK; } NS_IMETHOD OnStartBinding(const char *aContentType) { return NS_OK; }
NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) { return NS_OK; } NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) { return NS_OK; }
NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg);
}; };
NS_IMETHODIMP CStreamListener::OnStopBinding(PRInt32 status, const char *msg) NS_IMETHODIMP CStreamListener::OnStopBinding(PRInt32 status, const nsString& aMsg)
{ {
printf("CStreamListener: stream complete: %s\n", msg); fputs("CStreamListener: stream complete: ", stdout);
fputs(aMsg, stdout);
fputs("\n", stdout);
g_bReadyForNextUrl = PR_TRUE; g_bReadyForNextUrl = PR_TRUE;
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -1629,7 +1629,7 @@ nsresult nsHTMLParser::GetBindInfo(void){
*/ */
nsresult nsresult
nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax,
const char *aMsg) const nsString& aMsg)
{ {
nsresult result=0; nsresult result=0;
if (nsnull != mListener) { if (nsnull != mListener) {
@ -1645,9 +1645,9 @@ nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax,
* @param * @param
* @return * @return
*/ */
nsresult nsHTMLParser::OnStartBinding(void){ nsresult nsHTMLParser::OnStartBinding(const char *aContentType){
if (nsnull != mListener) { if (nsnull != mListener) {
mListener->OnStartBinding(); mListener->OnStartBinding(aContentType);
} }
nsresult result=WillBuildModel(); nsresult result=WillBuildModel();
if(!mTransferBuffer) { if(!mTransferBuffer) {
@ -1710,10 +1710,10 @@ nsresult nsHTMLParser::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length)
* @param * @param
* @return * @return
*/ */
nsresult nsHTMLParser::OnStopBinding(PRInt32 status, const char *msg){ nsresult nsHTMLParser::OnStopBinding(PRInt32 status, const nsString& aMsg){
nsresult result=DidBuildModel(status); nsresult result=DidBuildModel(status);
if (nsnull != mListener) { if (nsnull != mListener) {
mListener->OnStopBinding(status, msg); mListener->OnStopBinding(status, aMsg);
} }
return result; return result;
} }

Просмотреть файл

@ -249,10 +249,10 @@ friend class CTokenHandler;
// net lib to let us know about our inputstream. // net lib to let us know about our inputstream.
//********************************************* //*********************************************
NS_IMETHOD GetBindInfo(void); NS_IMETHOD GetBindInfo(void);
NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg); NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMmsg);
NS_IMETHOD OnStartBinding(void); NS_IMETHOD OnStartBinding(const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length); NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length);
NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg);
protected: protected:

Просмотреть файл

@ -24,7 +24,7 @@
/* forward declaration */ /* forward declaration */
class nsIInputStream; class nsIInputStream;
class nsString;
/* 45d234d0-c6c9-11d1-bea2-00805f8a66dc */ /* 45d234d0-c6c9-11d1-bea2-00805f8a66dc */
#define NS_ISTREAMNOTIFICATION_IID \ #define NS_ISTREAMNOTIFICATION_IID \
@ -54,7 +54,8 @@ public:
/** /**
* Notify the client that progress as occurred for the URL load.<BR> * Notify the client that progress as occurred for the URL load.<BR>
*/ */
NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) = 0; NS_IMETHOD OnProgress(PRInt32 aProgress, PRInt32 aProgressMax,
const nsString &aMsg) = 0;
/** /**
* Notify the client that the URL has started to load. This method is * Notify the client that the URL has started to load. This method is
@ -63,7 +64,7 @@ public:
* @return The return value is currently ignored. In the future it may be * @return The return value is currently ignored. In the future it may be
* used to cancel the URL load.. * used to cancel the URL load..
*/ */
NS_IMETHOD OnStartBinding(void) = 0; NS_IMETHOD OnStartBinding(const char *aContentType) = 0;
/** /**
* Notify the client that data is available in the input stream. This * Notify the client that data is available in the input stream. This
@ -75,7 +76,8 @@ public:
* @param length The amount of data that was just pushed into the stream. * @param length The amount of data that was just pushed into the stream.
* @return The return value is currently ignored. * @return The return value is currently ignored.
*/ */
NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) = 0; NS_IMETHOD OnDataAvailable(nsIInputStream *aIStream,
PRInt32 aLength) = 0;
/** /**
* Notify the client that the URL has finished loading. This method is * Notify the client that the URL has finished loading. This method is
@ -88,7 +90,7 @@ public:
* @param msg A text string describing the error. * @param msg A text string describing the error.
* @return The return value is currently ignored. * @return The return value is currently ignored.
*/ */
NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg) = 0; NS_IMETHOD OnStopBinding(PRInt32 aStatus, const nsString &aMsg) = 0;
}; };
/* Generic status codes for OnStopBinding */ /* Generic status codes for OnStopBinding */

Просмотреть файл

@ -21,6 +21,7 @@
#include "net.h" #include "net.h"
#include "mktrace.h" #include "mktrace.h"
#include "nsString.h"
#include "nsIProtocolConnection.h" #include "nsIProtocolConnection.h"
/* XXX: Legacy definitions... */ /* XXX: Legacy definitions... */
@ -318,7 +319,9 @@ static void bam_exit_routine(URL_Struct *URL_s, int status, MWContext *window_id
* closed (or possibly created). So, the binding has failed... * closed (or possibly created). So, the binding has failed...
*/ */
if (pConn->pConsumer) { if (pConn->pConsumer) {
pConn->pConsumer->OnStopBinding(NS_BINDING_FAILED, nsnull); nsAutoString status;
pConn->pConsumer->OnStopBinding(NS_BINDING_FAILED, status);
pConn->pConsumer->Release(); pConn->pConsumer->Release();
pConn->pConsumer = NULL; pConn->pConsumer = NULL;
} }

Просмотреть файл

@ -23,6 +23,7 @@
#include "ctxtfunc.h" #include "ctxtfunc.h"
#include "xp_list.h" #include "xp_list.h"
#include "nsString.h"
#include "nsIStreamListener.h" #include "nsIStreamListener.h"
#include "nsNetStream.h" #include "nsNetStream.h"
@ -57,7 +58,9 @@ PRIVATE void stub_GraphProgressInit(MWContext *context,
*/ */
pConn = (nsConnectionInfo *)URL_s->fe_data; pConn = (nsConnectionInfo *)URL_s->fe_data;
if ((NULL != pConn) && (NULL != pConn->pConsumer)) { if ((NULL != pConn) && (NULL != pConn->pConsumer)) {
pConn->pConsumer->OnProgress(0, content_length, NULL); nsAutoString status;
pConn->pConsumer->OnProgress(0, content_length, status);
} }
} }
} }
@ -78,7 +81,9 @@ PRIVATE void stub_GraphProgress(MWContext *context,
*/ */
pConn = (nsConnectionInfo *)URL_s->fe_data; pConn = (nsConnectionInfo *)URL_s->fe_data;
if ((NULL != pConn) && (NULL != pConn->pConsumer)) { if ((NULL != pConn) && (NULL != pConn->pConsumer)) {
pConn->pConsumer->OnProgress(bytes_received, content_length, NULL); nsAutoString status;
pConn->pConsumer->OnProgress(bytes_received, content_length, status);
} }
} }
} }
@ -103,7 +108,9 @@ PRIVATE void stub_GraphProgressDestroy(MWContext *context,
*/ */
pConn = (nsConnectionInfo *)URL_s->fe_data; pConn = (nsConnectionInfo *)URL_s->fe_data;
if ((NULL != pConn) && (NULL != pConn->pConsumer)) { if ((NULL != pConn) && (NULL != pConn->pConsumer)) {
pConn->pConsumer->OnProgress(total_bytes_read, content_length, NULL); nsAutoString status;
pConn->pConsumer->OnProgress(total_bytes_read, content_length, status);
} }
} }
} }
@ -312,7 +319,9 @@ void stub_complete(NET_StreamClass *stream)
/* Notify the Data Consumer that the Binding has completed... */ /* Notify the Data Consumer that the Binding has completed... */
if (pConn->pConsumer) { if (pConn->pConsumer) {
pConn->pConsumer->OnStopBinding(NS_BINDING_SUCCEEDED, nsnull); nsAutoString status;
pConn->pConsumer->OnStopBinding(NS_BINDING_SUCCEEDED, status);
pConn->pConsumer->Release(); pConn->pConsumer->Release();
pConn->pConsumer = NULL; pConn->pConsumer = NULL;
} }
@ -340,7 +349,9 @@ void stub_abort(NET_StreamClass *stream, int status)
* abort... * abort...
*/ */
if (pConn->pConsumer) { if (pConn->pConsumer) {
pConn->pConsumer->OnStopBinding(NS_BINDING_ABORTED, nsnull); nsAutoString status;
pConn->pConsumer->OnStopBinding(NS_BINDING_ABORTED, status);
pConn->pConsumer->Release(); pConn->pConsumer->Release();
pConn->pConsumer = NULL; pConn->pConsumer = NULL;
} }
@ -471,7 +482,7 @@ NET_StreamBuilder (FO_Present_Types format_out,
printf("+++ Created a stream for %s\n", URL_s->address); printf("+++ Created a stream for %s\n", URL_s->address);
#endif #endif
if (pConn->pConsumer) { if (pConn->pConsumer) {
pConn->pConsumer->OnStartBinding(); pConn->pConsumer->OnStartBinding(URL_s->content_type);
} }
} }
} }

Просмотреть файл

@ -55,10 +55,10 @@ public:
TestConsumer(); TestConsumer();
NS_IMETHOD GetBindInfo(void); NS_IMETHOD GetBindInfo(void);
NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg); NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg);
NS_IMETHOD OnStartBinding(void); NS_IMETHOD OnStartBinding(const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length); NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length);
NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg);
protected: protected:
~TestConsumer(); ~TestConsumer();
@ -92,11 +92,14 @@ NS_IMETHODIMP TestConsumer::GetBindInfo(void)
return 0; return 0;
} }
NS_IMETHODIMP TestConsumer::OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) NS_IMETHODIMP TestConsumer::OnProgress(PRInt32 Progress, PRInt32 ProgressMax,
const nsString& aMsg)
{ {
if (bTraceEnabled) { if (bTraceEnabled) {
if (msg) { if (aMsg.Length()) {
printf("\n+++ TestConsumer::OnProgress: status %s\n", msg); printf("\n+++ TestConsumer::OnProgress: status ");
fputs(aMsg, stdout);
fputs("\n", stdout);
} else { } else {
printf("\n+++ TestConsumer::OnProgress: %d of total %d\n", Progress, ProgressMax); printf("\n+++ TestConsumer::OnProgress: %d of total %d\n", Progress, ProgressMax);
} }
@ -105,10 +108,10 @@ NS_IMETHODIMP TestConsumer::OnProgress(PRInt32 Progress, PRInt32 ProgressMax, co
return 0; return 0;
} }
NS_IMETHODIMP TestConsumer::OnStartBinding(void) NS_IMETHODIMP TestConsumer::OnStartBinding(const char *aContentType)
{ {
if (bTraceEnabled) { if (bTraceEnabled) {
printf("\n+++ TestConsumer::OnStartBinding\n"); printf("\n+++ TestConsumer::OnStartBinding: Content type: %s\n", aContentType);
} }
return 0; return 0;
@ -138,7 +141,7 @@ NS_IMETHODIMP TestConsumer::OnDataAvailable(nsIInputStream *pIStream, PRInt32 le
} }
NS_IMETHODIMP TestConsumer::OnStopBinding(PRInt32 status, const char *msg) NS_IMETHODIMP TestConsumer::OnStopBinding(PRInt32 status, const nsString& aMsg)
{ {
if (bTraceEnabled) { if (bTraceEnabled) {
printf("\n+++ TestConsumer::OnStopBinding... status: %d\n", status); printf("\n+++ TestConsumer::OnStopBinding... status: %d\n", status);

Просмотреть файл

@ -130,15 +130,17 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_IMETHOD GetBindInfo(void) { return NS_OK; } NS_IMETHOD GetBindInfo(void) { return NS_OK; }
NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) { return NS_OK; } NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg) { return NS_OK; }
NS_IMETHOD OnStartBinding(void) { return NS_OK; } NS_IMETHOD OnStartBinding(const char *aContentType) { return NS_OK; }
NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) { return NS_OK; } NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) { return NS_OK; }
NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg);
}; };
NS_IMETHODIMP CStreamListener::OnStopBinding(PRInt32 status, const char *msg) NS_IMETHODIMP CStreamListener::OnStopBinding(PRInt32 status, const nsString& aMsg)
{ {
printf("CStreamListener: stream complete: %s\n", msg); fputs("CStreamListener: stream complete: ", stdout);
fputs(aMsg, stdout);
fputs("\n", stdout);
g_bReadyForNextUrl = PR_TRUE; g_bReadyForNextUrl = PR_TRUE;
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -1629,7 +1629,7 @@ nsresult nsHTMLParser::GetBindInfo(void){
*/ */
nsresult nsresult
nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax,
const char *aMsg) const nsString& aMsg)
{ {
nsresult result=0; nsresult result=0;
if (nsnull != mListener) { if (nsnull != mListener) {
@ -1645,9 +1645,9 @@ nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax,
* @param * @param
* @return * @return
*/ */
nsresult nsHTMLParser::OnStartBinding(void){ nsresult nsHTMLParser::OnStartBinding(const char *aContentType){
if (nsnull != mListener) { if (nsnull != mListener) {
mListener->OnStartBinding(); mListener->OnStartBinding(aContentType);
} }
nsresult result=WillBuildModel(); nsresult result=WillBuildModel();
if(!mTransferBuffer) { if(!mTransferBuffer) {
@ -1710,10 +1710,10 @@ nsresult nsHTMLParser::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length)
* @param * @param
* @return * @return
*/ */
nsresult nsHTMLParser::OnStopBinding(PRInt32 status, const char *msg){ nsresult nsHTMLParser::OnStopBinding(PRInt32 status, const nsString& aMsg){
nsresult result=DidBuildModel(status); nsresult result=DidBuildModel(status);
if (nsnull != mListener) { if (nsnull != mListener) {
mListener->OnStopBinding(status, msg); mListener->OnStopBinding(status, aMsg);
} }
return result; return result;
} }

Просмотреть файл

@ -249,10 +249,10 @@ friend class CTokenHandler;
// net lib to let us know about our inputstream. // net lib to let us know about our inputstream.
//********************************************* //*********************************************
NS_IMETHOD GetBindInfo(void); NS_IMETHOD GetBindInfo(void);
NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg); NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMmsg);
NS_IMETHOD OnStartBinding(void); NS_IMETHOD OnStartBinding(const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length); NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length);
NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg);
protected: protected:

Просмотреть файл

@ -307,17 +307,18 @@ DocObserver::GetBindInfo(void)
NS_IMETHODIMP NS_IMETHODIMP
DocObserver::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, DocObserver::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax,
const char *aMsg) const nsString& aMsg)
{ {
fputs("[progress ", stdout); fputs("[progress ", stdout);
fputs(mURL, stdout); fputs(mURL, stdout);
printf(" %d %d %s]\n", aProgress, aProgressMax, printf(" %d %d ", aProgress, aProgressMax);
aMsg ? aMsg : ""); fputs(aMsg, stdout);
fputs("]\n", stdout);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
DocObserver::OnStartBinding(void) DocObserver::OnStartBinding(const char *aContentType)
{ {
fputs("Loading ", stdout); fputs("Loading ", stdout);
fputs(mURL, stdout); fputs(mURL, stdout);
@ -332,7 +333,7 @@ DocObserver::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length)
} }
NS_IMETHODIMP NS_IMETHODIMP
DocObserver::OnStopBinding(PRInt32 status, const char *msg) DocObserver::OnStopBinding(PRInt32 status, const nsString& aMsg)
{ {
fputs("Done loading ", stdout); fputs("Done loading ", stdout);
fputs(mURL, stdout); fputs(mURL, stdout);

Просмотреть файл

@ -75,10 +75,10 @@ public:
// nsIStreamListener // nsIStreamListener
NS_IMETHOD GetBindInfo(void); NS_IMETHOD GetBindInfo(void);
NS_IMETHOD OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, NS_IMETHOD OnProgress(PRInt32 aProgress, PRInt32 aProgressMax,
const char *aMsg); const nsString& aMsg);
NS_IMETHOD OnStartBinding(void); NS_IMETHOD OnStartBinding(const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length); NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length);
NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg);
// nsILinkHandler // nsILinkHandler
NS_IMETHOD Init(nsIWebWidget* aWidget); NS_IMETHOD Init(nsIWebWidget* aWidget);