Initial revision on the trunk, merged from PROGRESS_19980920_BRANCH.

git-svn-id: svn://10.0.0.236/trunk@12051 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
waterson%netscape.com
1998-10-06 20:09:50 +00:00
parent 3f9e984507
commit 9a8f60cf9e
3 changed files with 281 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 nsITransferListener_h__
#define nsITransferListener_h__
#include "nsISupports.h"
#include "net.h" // for URL_Struct
// {663f0fa1-edfe-11d9-8031-006008159b5a}
#define NS_ITRANSFERLISTENER_IID \
{0x663f0fa1, 0xedfe, 0x11d9, \
{0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
/**
* This interface is <i>almost</i> identical to the <tt>nsIStreamListener</tt>
* interface. The reason that I don't just use that interface is that it's
* a little bit too heavy-weight right now: it brings in <tt>nsIURL</tt> and
* <tt>nsString</tt>, which in turn bring in a bunch of stuff that just isn't
* really running in Mozilla yet.
*
* <p>The interface defines an object to which a stream or "transfer"
* can report its status.
*/
class nsITransferListener : public nsISupports
{
public:
/**
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.
*/
NS_IMETHOD
OnStartBinding(const URL_Struct* url) = 0;
/**
* Notify the observer that progress as occurred for the URL load.<BR>
*/
NS_IMETHOD
OnProgress(const URL_Struct* url, PRUint32 bytesReceived, PRUint32 contentLength) = 0;
/**
* Notify the observer with a status message for the URL load.<BR>
*/
NS_IMETHOD
OnStatus(const URL_Struct* url, const char* message) = 0;
/**
* Notify the observer that the transfer has been suspended.
*/
NS_IMETHOD
OnSuspend(const URL_Struct* url) = 0;
/**
* Notify the observer that the transfer has been resumed.
*/
NS_IMETHOD
OnResume(const URL_Struct* url) = 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.<BR><BR>
*
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
*
* @param status Status code for the URL load.
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
NS_IMETHOD
OnStopBinding(const URL_Struct* url, PRInt32 status, const char* message) = 0;
};
#endif /* nsITransferListener_h__ */

View File

@@ -0,0 +1,95 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 nsProgressManager_h__
#define nsProgressManager_h__
#include "nsITransferListener.h"
#include "nsTime.h"
#include "prtypes.h"
#include "plhash.h"
#include "structs.h" // for MWContext
/**
* An <tt>nsProgressManager</tt> object is used to manage the progress
* bar and status bar for a context.
*/
class nsProgressManager : public nsITransferListener
{
protected:
/**
* The context to which the progress manager is bound.
*/
MWContext* fContext;
nsProgressManager(MWContext* context);
virtual ~nsProgressManager(void);
public:
/**
* Ensure that a progress manager exists in the specified context,
* creating a new one if necessary. If the context is a nested grid
* context, this may recursively create progress managers in
* parent contexts as well.
*/
static void Ensure(MWContext* context);
/**
* Release the progress manager from the current context. This may
* or may not destroy the progress manager, depending on the progress
* manager's reference count. Note that the context's
* <b>progressManager</b> field is maintained by the progress manager
* object, and will be set to <b>NULL</b> only when the progress
* manager's reference count goes to zero and the progress manager
* is destroyed.
*/
static void Release(MWContext* context);
NS_DECL_ISUPPORTS
// The nsITransferListener interface.
NS_IMETHOD
OnStartBinding(const URL_Struct* url) = 0;
NS_IMETHOD
OnProgress(const URL_Struct* url, PRUint32 bytesReceived, PRUint32 contentLength) = 0;
NS_IMETHOD
OnStatus(const URL_Struct* url, const char* message) = 0;
NS_IMETHOD
OnSuspend(const URL_Struct* url) = 0;
NS_IMETHOD
OnResume(const URL_Struct* url) = 0;
NS_IMETHOD
OnStopBinding(const URL_Struct* url, PRInt32 status, const char* message) = 0;
};
#endif // nsProgressManager_h__

View File

@@ -0,0 +1,95 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
/*
* A C-interface to the progress manager.
*/
#ifndef progress_h__
#define progress_h__
#include "prtypes.h"
#include "structs.h"
#include "net.h"
PR_BEGIN_EXTERN_C
/**
* Create a progress manager in the specified context if one does
* not already exist.
*/
extern void
PM_EnsureProgressManager(MWContext* context);
/**
* Release the progress manager from the specified context.
*
* <p> Note that this will not necessarily destroy the progress
* manager and unbind it from the context: it simply decrements the
* reference count onthe progress manager.
*/
extern void
PM_ReleaseProgressManager(MWContext* context);
/**
* Notify the progress manager for the specified context that the
* specified URL has begun to connect.
*/
extern void
PM_StartBinding(MWContext* context, const URL_Struct* url);
/**
* Notify the progress manager for the specified context that some
* progress has been made for the specified URL.
*/
extern void
PM_Progress(MWContext* context, const URL_Struct* url, PRUint32 bytesReceived, PRUint32 contentLength);
/**
* Notify the progress manager for the specified context of status
* for the specified URL. The progress manager will make a copy of the
* message.
*/
extern void
PM_Status(MWContext* context, const URL_Struct* url, const char* message);
/**
* Notify the progress manager that the specified URL transfer has
* beein suspended.
*/
extern void
PM_Suspend(MWContext* context, const URL_Struct* url);
/**
* Notify the progress manager that the specified URL transfer has
* been resumed.
*/
extern void
PM_Resume(MWContext* context, const URL_Struct* url);
/**
* Notify the progress manager for the specified context that the
* URL has completed.
*/
extern void
PM_StopBinding(MWContext* context, const URL_Struct* url, PRInt32 status, const char* message);
PR_END_EXTERN_C
#endif /* progress_h__ */