Added IStreamListener::OnStatus(...)...

git-svn-id: svn://10.0.0.236/trunk@6389 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rpotts%netscape.com
1998-07-24 10:02:50 +00:00
parent 6d7c9aeb3e
commit b174cb490f
17 changed files with 182 additions and 72 deletions

View File

@@ -80,7 +80,8 @@ public:
ImageConsumer(ilIURL *aURL, ImageNetContextImpl *aContext);
NS_IMETHOD GetBindInfo(nsIURL* aURL);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg);
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);
@@ -126,7 +127,13 @@ ImageConsumer::GetBindInfo(nsIURL* aURL)
}
NS_IMETHODIMP
ImageConsumer::OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg)
ImageConsumer::OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax)
{
return 0;
}
NS_IMETHODIMP
ImageConsumer::OnStatus(nsIURL* aURL, const nsString& aMsg)
{
return 0;
}

View File

@@ -124,7 +124,8 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg) { return NS_OK; }
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax) { return NS_OK; }
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg) { return NS_OK; }
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType) { return NS_OK; }
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);
};

View File

@@ -676,12 +676,28 @@ nsresult nsParser::GetBindInfo(nsIURL* aURL){
* @return error code -- 0 if ok, non-zero if error.
*/
nsresult
nsParser::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg)
nsParser::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
{
nsresult result=0;
if (nsnull != mObserver) {
mObserver->OnProgress(aURL, aProgress, aProgressMax, aMsg);
mObserver->OnProgress(aURL, aProgress, aProgressMax);
}
return result;
}
/**
*
*
* @update gess 5/12/98
* @param
* @return error code -- 0 if ok, non-zero if error.
*/
nsresult
nsParser::OnStatus(nsIURL* aURL, const nsString &aMsg)
{
nsresult result=0;
if (nsnull != mObserver) {
mObserver->OnStatus(aURL, aMsg);
}
return result;
}

View File

@@ -187,7 +187,8 @@ friend class CTokenHandler;
// net lib to let us know about our inputstream.
//*********************************************
NS_IMETHOD GetBindInfo(nsIURL* aURL);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMmsg);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMmsg);
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);

View File

@@ -64,9 +64,9 @@ public:
NS_DECL_ISUPPORTS
// nsIStreamObserver
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg);
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 status, const nsString& aMsg);
protected:
@@ -767,13 +767,23 @@ TempObserver::QueryInterface(const nsIID& aIID,
NS_IMETHODIMP
TempObserver::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg)
TempObserver::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
{
#if 0
fputs("[progress ", stdout);
fputs(mURL, stdout);
printf(" %d %d ", aProgress, aProgressMax);
fputs("]\n", stdout);
#endif
return NS_OK;
}
NS_IMETHODIMP
TempObserver::OnStatus(nsIURL* aURL, const nsString& aMsg)
{
#if 0
fputs("[status ", stdout);
fputs(mURL, stdout);
fputs(aMsg, stdout);
fputs("]\n", stdout);
#endif

View File

@@ -37,7 +37,7 @@ class nsIURL;
class nsIStreamObserver : public nsISupports {
public:
/**
* Notify the client that the URL has started to load. This method is
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
@@ -46,13 +46,17 @@ public:
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType) = 0;
/**
* Notify the client that progress as occurred for the URL load.<BR>
* Notify the observer that progress as occurred for the URL load.<BR>
*/
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString &aMsg) = 0;
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) = 0;
/**
* Notify the client that the URL has finished loading. This method is
* Notify the observer with a status message for the URL load.<BR>
*/
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg) = 0;
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
*

View File

@@ -218,8 +218,7 @@ PRIVATE void stub_GraphProgressInit(MWContext *context,
if (pListener = getStreamListener(URL_s)) {
nsConnectionInfo *pConn = (nsConnectionInfo *) URL_s->fe_data;
nsAutoString status;
pListener->OnProgress(pConn->pURL, 0, content_length, status);
pListener->OnProgress(pConn->pURL, 0, content_length);
pListener->Release();
}
}
@@ -238,9 +237,8 @@ PRIVATE void stub_GraphProgress(MWContext *context,
if (pListener = getStreamListener(URL_s)) {
nsConnectionInfo *pConn = (nsConnectionInfo *) URL_s->fe_data;
nsAutoString status;
pListener->OnProgress(pConn->pURL, bytes_received,
content_length, status);
content_length);
pListener->Release();
}
}
@@ -263,9 +261,8 @@ PRIVATE void stub_GraphProgressDestroy(MWContext *context,
if (pListener = getStreamListener(URL_s)) {
nsConnectionInfo *pConn = (nsConnectionInfo *) URL_s->fe_data;
nsAutoString status;
pListener->OnProgress(pConn->pURL, total_bytes_read,
content_length, status);
content_length);
}
}
@@ -277,7 +274,7 @@ PRIVATE void stub_Progress(MWContext *context, const char *msg)
nsConnectionInfo *pConn =
(nsConnectionInfo *) context->modular_data->fe_data;
nsAutoString status(msg);
pListener->OnProgress(pConn->pURL, -1, -1, status);
pListener->OnStatus(pConn->pURL, status);
pListener->Release();
} else {
printf("%s\n", msg);

View File

@@ -55,7 +55,8 @@ public:
TestConsumer();
NS_IMETHOD GetBindInfo(nsIURL* aURL);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg);
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);
@@ -93,16 +94,21 @@ NS_IMETHODIMP TestConsumer::GetBindInfo(nsIURL* aURL)
}
NS_IMETHODIMP TestConsumer::OnProgress(nsIURL* aURL, PRInt32 Progress,
PRInt32 ProgressMax, const nsString& aMsg)
PRInt32 ProgressMax)
{
if (bTraceEnabled) {
if (aMsg.Length()) {
printf("\n+++ TestConsumer::OnProgress: status ");
fputs(aMsg, stdout);
fputs("\n", stdout);
} else {
printf("\n+++ TestConsumer::OnProgress: URL: %p - %d of total %d\n", aURL, Progress, ProgressMax);
}
printf("\n+++ TestConsumer::OnProgress: URL: %p - %d of total %d\n", aURL, Progress, ProgressMax);
}
return 0;
}
NS_IMETHODIMP TestConsumer::OnStatus(nsIURL* aURL, const nsString& aMsg)
{
if (bTraceEnabled) {
printf("\n+++ TestConsumer::OnStatus: ");
fputs(aMsg, stdout);
fputs("\n", stdout);
}
return 0;

View File

@@ -124,7 +124,8 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg) { return NS_OK; }
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax) { return NS_OK; }
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg) { return NS_OK; }
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType) { return NS_OK; }
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);
};

View File

@@ -676,12 +676,28 @@ nsresult nsParser::GetBindInfo(nsIURL* aURL){
* @return error code -- 0 if ok, non-zero if error.
*/
nsresult
nsParser::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg)
nsParser::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
{
nsresult result=0;
if (nsnull != mObserver) {
mObserver->OnProgress(aURL, aProgress, aProgressMax, aMsg);
mObserver->OnProgress(aURL, aProgress, aProgressMax);
}
return result;
}
/**
*
*
* @update gess 5/12/98
* @param
* @return error code -- 0 if ok, non-zero if error.
*/
nsresult
nsParser::OnStatus(nsIURL* aURL, const nsString &aMsg)
{
nsresult result=0;
if (nsnull != mObserver) {
mObserver->OnStatus(aURL, aMsg);
}
return result;
}

View File

@@ -187,7 +187,8 @@ friend class CTokenHandler;
// net lib to let us know about our inputstream.
//*********************************************
NS_IMETHOD GetBindInfo(nsIURL* aURL);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMmsg);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMmsg);
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);

View File

@@ -83,8 +83,8 @@ public:
/* nsIStreamListener interface methods... */
NS_IMETHOD GetBindInfo(nsIURL* aURL);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg);
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aStream, PRInt32 aLength);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString& aMsg);
@@ -704,20 +704,38 @@ NS_METHOD nsDocumentBindInfo::GetBindInfo(nsIURL* aURL)
NS_METHOD nsDocumentBindInfo::OnProgress(nsIURL* aURL, PRInt32 aProgress,
PRInt32 aProgressMax,
const nsString& aMsg)
PRInt32 aProgressMax)
{
nsresult rv = NS_OK;
/* Pass the notification out to the next stream listener... */
if (nsnull != m_NextStream) {
rv = m_NextStream->OnProgress(aURL, aProgress, aProgressMax, aMsg);
rv = m_NextStream->OnProgress(aURL, aProgress, aProgressMax);
}
/* Pass the notification out to the Observer... */
if (nsnull != m_Observer) {
/* XXX: Should we ignore the return value? */
(void) m_Observer->OnProgress(aURL, aProgress, aProgressMax, aMsg);
(void) m_Observer->OnProgress(aURL, aProgress, aProgressMax);
}
return rv;
}
NS_METHOD nsDocumentBindInfo::OnStatus(nsIURL* aURL, const nsString& aMsg)
{
nsresult rv = NS_OK;
/* Pass the notification out to the next stream listener... */
if (nsnull != m_NextStream) {
rv = m_NextStream->OnStatus(aURL, aMsg);
}
/* Pass the notification out to the Observer... */
if (nsnull != m_Observer) {
/* XXX: Should we ignore the return value? */
(void) m_Observer->OnStatus(aURL, aMsg);
}
return rv;

View File

@@ -83,8 +83,8 @@ public:
/* nsIStreamListener interface methods... */
NS_IMETHOD GetBindInfo(nsIURL* aURL);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg);
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aStream, PRInt32 aLength);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString& aMsg);
@@ -704,20 +704,38 @@ NS_METHOD nsDocumentBindInfo::GetBindInfo(nsIURL* aURL)
NS_METHOD nsDocumentBindInfo::OnProgress(nsIURL* aURL, PRInt32 aProgress,
PRInt32 aProgressMax,
const nsString& aMsg)
PRInt32 aProgressMax)
{
nsresult rv = NS_OK;
/* Pass the notification out to the next stream listener... */
if (nsnull != m_NextStream) {
rv = m_NextStream->OnProgress(aURL, aProgress, aProgressMax, aMsg);
rv = m_NextStream->OnProgress(aURL, aProgress, aProgressMax);
}
/* Pass the notification out to the Observer... */
if (nsnull != m_Observer) {
/* XXX: Should we ignore the return value? */
(void) m_Observer->OnProgress(aURL, aProgress, aProgressMax, aMsg);
(void) m_Observer->OnProgress(aURL, aProgress, aProgressMax);
}
return rv;
}
NS_METHOD nsDocumentBindInfo::OnStatus(nsIURL* aURL, const nsString& aMsg)
{
nsresult rv = NS_OK;
/* Pass the notification out to the next stream listener... */
if (nsnull != m_NextStream) {
rv = m_NextStream->OnStatus(aURL, aMsg);
}
/* Pass the notification out to the Observer... */
if (nsnull != m_Observer) {
/* XXX: Should we ignore the return value? */
(void) m_Observer->OnStatus(aURL, aMsg);
}
return rv;

View File

@@ -705,26 +705,30 @@ nsBrowserWindow::EndLoadURL(nsIWebShell* aShell, const nsString& aURL)
NS_IMETHODIMP
nsBrowserWindow::OnProgress(nsIURL* aURL,
PRInt32 aProgress,
PRInt32 aProgressMax,
const nsString& aMsg)
PRInt32 aProgressMax)
{
if (mStatus) {
if (aMsg.Length() < 1) {
nsAutoString url;
if (nsnull != aURL) {
aURL->ToString(url);
}
url.Append(": progress ");
url.Append(aProgress, 10);
if (0 != aProgressMax) {
url.Append(" (out of ");
url.Append(aProgressMax, 10);
url.Append(")");
}
mStatus->SetText(url);
} else {
mStatus->SetText(aMsg);
nsAutoString url;
if (nsnull != aURL) {
aURL->ToString(url);
}
url.Append(": progress ");
url.Append(aProgress, 10);
if (0 != aProgressMax) {
url.Append(" (out of ");
url.Append(aProgressMax, 10);
url.Append(")");
}
mStatus->SetText(url);
}
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::OnStatus(nsIURL* aURL, const nsString& aMsg)
{
if (mStatus) {
mStatus->SetText(aMsg);
}
return NS_OK;
}

View File

@@ -75,8 +75,8 @@ public:
// nsIStreamObserver
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);
// nsIWebShellContainer

View File

@@ -316,8 +316,7 @@ nsDocLoader::OnStartBinding(nsIURL* aURL, const char *aContentType)
}
NS_IMETHODIMP
nsDocLoader::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg)
nsDocLoader::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
{
nsString* url = (nsString*)mURLList->ElementAt(mDocNum);
fputs(*url, stdout);
@@ -329,6 +328,17 @@ nsDocLoader::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
return NS_OK;
}
NS_IMETHODIMP
nsDocLoader::OnStatus(nsIURL* aURL, const nsString& aMsg)
{
nsString* url = (nsString*)mURLList->ElementAt(mDocNum);
fputs(*url, stdout);
printf(": status ");
fputs(aMsg, stdout);
fputs("\n", stdout);
return NS_OK;
}
NS_IMETHODIMP
nsDocLoader::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg)
{

View File

@@ -45,8 +45,8 @@ public:
// nsIStreamObserver
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax,
const nsString& aMsg);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);
// Add a URL to the doc loader