diff --git a/mozilla/modules/progress/public/nsITransferListener.h b/mozilla/modules/progress/public/nsITransferListener.h new file mode 100644 index 00000000000..e47d5b12734 --- /dev/null +++ b/mozilla/modules/progress/public/nsITransferListener.h @@ -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 almost identical to the nsIStreamListener + * 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 nsIURL and + * nsString, which in turn bring in a bunch of stuff that just isn't + * really running in Mozilla yet. + * + *
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.
+ */
+ NS_IMETHOD
+ OnProgress(const URL_Struct* url, PRUint32 bytesReceived, PRUint32 contentLength) = 0;
+
+ /**
+ * Notify the observer with a status message for the URL load.
+ */
+ 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.
+ *
+ * This method is called regardless of whether the URL loaded successfully.
+ *
+ * @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__ */
diff --git a/mozilla/modules/progress/public/nsProgressManager.h b/mozilla/modules/progress/public/nsProgressManager.h
new file mode 100644
index 00000000000..cc883093ae1
--- /dev/null
+++ b/mozilla/modules/progress/public/nsProgressManager.h
@@ -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 nsProgressManager 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
+ * progressManager field is maintained by the progress manager
+ * object, and will be set to NULL 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__
+
diff --git a/mozilla/modules/progress/public/progress.h b/mozilla/modules/progress/public/progress.h
new file mode 100644
index 00000000000..dcc18ce4621
--- /dev/null
+++ b/mozilla/modules/progress/public/progress.h
@@ -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.
+ *
+ *
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__ */