Networking changes: Reworked nsIURL, adding setters, factoring Open. Unsigned arguments for nsIStreamListener.

This commit is contained in:
warren%netscape.com 1998-12-16 05:46:06 +00:00
Родитель 5bdf19f9b4
Коммит 634f7bc90c
9 изменённых файлов: 527 добавлений и 0 удалений

12
network/public/MANIFEST Normal file
Просмотреть файл

@ -0,0 +1,12 @@
#
# This is a list of local files which get copied to the mozilla:dist:network:module directory
#
nsIHttpURL.h
nsILoadAttribs.h
nsIPostToServer.h
nsIStreamListener.h
nsIStreamObserver.h
nsIURL.h

0
network/public/Makefile Normal file
Просмотреть файл

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

@ -0,0 +1,54 @@
# 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.
NODEPEND=1
IGNORE_MANIFEST = 1
#//------------------------------------------------------------------------
#//
# New build system where zip dll is build indepenant of java stubs.
#//
#//------------------------------------------------------------------------
MODULE = netlib
EXPORTS = nsIStreamObserver.h \
nsIStreamListener.h \
nsIURL.h \
nsIPostToServer.h \
nsIHttpURL.h \
nsILoadAttribs.h \
$(NULL)
#//------------------------------------------------------------------------
#//
#// Specify the depth of the current directory relative to the
#// root of NS
#//
#//------------------------------------------------------------------------
DEPTH= ..\..\
#//------------------------------------------------------------------------
#//
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
#// (these must be defined before the common makefiles are included)
#//
#//------------------------------------------------------------------------
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>

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

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 4; 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 nsIHttpURL_h___
#define nsIHttpURL_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nspr.h"
/* 1A0B6FA1-EA25-11d1-BEAE-00805F8A66DC */
#define NS_IHTTPURL_IID \
{ 0x1a0b6fa1, 0xea25, 0x11d1, \
{ 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } }
struct nsIHttpURL : public nsISupports
{
/**
* Parse the mime header into the url struct.
* This method is intended to be used when an HTML META tag is encoutered
* with the type http-equiv. In this case, the http-equiv header should
* be added to the url in netlib, immediately after the http-equiv meta
* tag is encoutered.
*
* @param shell The shell loading this url.
* @param url The url to parse the mime header into.
* @param name The name of the mime header.
* @param value The value of the mime header.
*/
NS_IMETHOD AddMimeHeader(const char *name, const char *value) = 0;
};
/** Create a new HttpURL. */
extern "C" NS_NET nsresult NS_NewHttpURL(nsISupports** aInstancePtrResult,
nsISupports* aOuter);
#endif /* nsIHttpURL_h___ */

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

@ -0,0 +1,84 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsILoadAttribs_h___
#define nsILoadAttribs_h___
#include "nscore.h"
#include "prtypes.h"
#include "nsISupports.h"
// Class ID for an implementation of nsILoadAttribs
// {8942D321-48D3-11d2-9E7A-006008BF092E}
#define NS_ILOAD_ATTRIBS_IID \
{ 0x8942d321, 0x48d3, 0x11d2,{0x9e, 0x7a, 0x00, 0x60, 0x08, 0xbf, 0x09, 0x2e}}
/*
* The nsReloadType represents the following:
* nsURLReload - normal reload (uses cache)
* nsURLReloadBypassCache - bypass the cache
* nsURLReloadBypassCacheAndProxy - bypass the proxy (not yet implemented)
*/
typedef enum {
nsURLReload = 0,
nsURLReloadBypassCache,
nsURLReloadBypassProxy,
nsURLReloadBypassCacheAndProxy,
nsURLReloadMax
} nsURLReloadType;
/*
* The nsLoadType represents the following:
* nsURLLoadNormal - Load the URL normally.
* nsURLLoadBackground - Supress all notifications when loading the URL.
*/
typedef enum {
nsURLLoadNormal = 0,
nsURLLoadBackground,
nsURLLoadMax
} nsURLLoadType;
// Defining attributes of a url's load behavior.
class nsILoadAttribs : public nsISupports {
public:
// Copy the state of another nsILoadAttribs instance.
NS_IMETHOD Clone(nsILoadAttribs* aLoadAttribs) = 0;
// Bypass Proxy.
NS_IMETHOD SetBypassProxy(PRBool aBypass) = 0;
NS_IMETHOD GetBypassProxy(PRBool *aBypass) = 0;
// Local IP address.
NS_IMETHOD SetLocalIP(const PRUint32 aLocalIP) = 0;
NS_IMETHOD GetLocalIP(PRUint32 *aLocalIP) = 0;
// Reload method.
NS_IMETHOD SetReloadType(nsURLReloadType aType) = 0;
NS_IMETHOD GetReloadType(nsURLReloadType* aResult) = 0;
// Load method
NS_IMETHOD SetLoadType(nsURLLoadType aType) = 0;
NS_IMETHOD GetLoadType(nsURLLoadType* aResult) = 0;
};
/* Creation routines. */
extern NS_NET nsresult NS_NewLoadAttribs(nsILoadAttribs** aInstancePtrResult);
#endif // nsILoadAttribs_h___

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

@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 4; 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 nsIPostToServer_h___
#define nsIPostToServer_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nspr.h"
/* EADF7B41-EBC0-11d1-BEAE-00805F8A66DC */
#define NS_IPOSTTOSERVER_IID \
{ 0xeadf7b41, 0xebc0, 0x11d1, \
{ 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } }
struct nsIPostToServer : public nsISupports
{
NS_IMETHOD SendFile(const char *aFile) = 0;
NS_IMETHOD SendData(const char *aBuffer, PRUint32 aLength) = 0;
NS_IMETHOD SendDataFromFile(const char *aFile) = 0;
};
#define NS_IPOSTTOSERVER_ALREADY_POSTING NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_NETWORK, 1)
#endif /* nsIPostToServer_h___ */

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

@ -0,0 +1,76 @@
/* -*- 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 nsIStreamListener_h___
#define nsIStreamListener_h___
#include "nsIStreamObserver.h"
/* forward declaration */
class nsIInputStream;
class nsString;
class nsIURL;
struct nsStreamBindingInfo {
PRBool seekable;
/* ...more... */
};
/* 45d234d0-c6c9-11d1-bea2-00805f8a66dc */
#define NS_ISTREAMLISTENER_IID \
{ 0x45d234d0, 0xc6c9, 0x11d1, \
{0xbe, 0xa2, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
/**
* The nsIStreamListener interface provides the necessary notifications
* during both synchronous and asynchronous URL loading.
* This is a preliminary interface which <B>will</B> change over time!
* <BR><BR>
* An instance of this interface is passed to nsINetService::Open(...) to
* allow the client to receive status and notifications during the loading
* of the URL.
* <BR><BR>
* Over time this interface will provide the same functionality as the
* IBindStatusCallback interface in the MS INET-SDK...
*/
class nsIStreamListener : public nsIStreamObserver {
public:
/**
* Return information regarding the current URL load.<BR>
* The info structure that is passed in is filled out and returned
* to the caller.
*
* This method is currently not called.
*/
NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) = 0;
/**
* Notify the client that data is available in the input stream. This
* method is called whenver data is written into the input stream by the
* networking library...<BR><BR>
*
* @param pIStream The input stream containing the data. This stream can
* be either a blocking or non-blocking stream.
* @param length The amount of data that was just pushed into the stream.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream,
PRUint32 aLength) = 0;
};
#endif /* nsIStreamListener_h___ */

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

@ -0,0 +1,77 @@
/* -*- 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 nsIStreamObserver_h___
#define nsIStreamObserver_h___
#include "nsISupports.h"
#include "nscore.h"
/* forward declaration */
class nsIInputStream;
class nsString;
class nsIURL;
/* 97566110-ff60-11d1-beb9-00805f8a66dc */
#define NS_ISTREAMOBSERVER_IID \
{ 0x97566110, 0xff60, 0x11d1, \
{0xbe, 0xb9, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
class nsIStreamObserver : 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.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType) = 0;
/**
* Notify the observer that progress as occurred for the URL load.<BR>
*/
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) = 0;
/**
* Notify the observer with a status message for the URL load.<BR>
*/
NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* 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>
*
* 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(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg) = 0;
};
/* Generic status codes for OnStopBinding */
#define NS_BINDING_SUCCEEDED NS_OK
#define NS_BINDING_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 1)
#define NS_BINDING_ABORTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
#endif /* nsIStreamObserver_h___ */

127
network/public/nsIURL.h Normal file
Просмотреть файл

@ -0,0 +1,127 @@
/* -*- 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 nsIURL_h___
#define nsIURL_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsILoadAttribs.h"
class nsIInputStream;
class nsIStreamListener;
class nsString;
class nsIURLGroup;
#define NS_IURL_IID \
{ 0x6ecb2900, 0x93b5, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
class nsIURL : public nsISupports {
public:
/** Equality operator */
NS_IMETHOD_(PRBool) Equals(const nsIURL *aURL) const = 0;
// XXX Temporary...
virtual PRBool operator==(const nsIURL &aURL) const {
NS_ASSERTION(0, "change your code to use the Equals method");
return PR_FALSE;
}
/** Accessors */
//@{
/** @return string originally used to construct the URL */
NS_IMETHOD GetSpec(const char* *result) const = 0;
NS_IMETHOD SetSpec(const char* spec) = 0;
/** @return protocol part of the URL */
NS_IMETHOD GetProtocol(const char* *result) const = 0;
NS_IMETHOD SetProtocol(const char* protocol) = 0;
/** @return host part of the URL */
NS_IMETHOD GetHost(const char* *result) const = 0;
NS_IMETHOD SetHost(const char* host) = 0;
/** @return ref part of the URL */
NS_IMETHOD GetHostPort(PRUint32 *result) const = 0;
NS_IMETHOD SetHostPort(PRUint32 port) = 0;
/** @return file part of the URL */
NS_IMETHOD GetFile(const char* *result) const = 0;
NS_IMETHOD SetFile(const char* file) = 0;
/** @return ref part of the URL */
NS_IMETHOD GetRef(const char* *result) const = 0;
NS_IMETHOD SetRef(const char* ref) = 0;
/** @return search part of the URL */
NS_IMETHOD GetSearch(const char* *result) const = 0;
NS_IMETHOD SetSearch(const char* search) = 0;
NS_IMETHOD GetContainer(nsISupports* *result) const = 0;
NS_IMETHOD SetContainer(nsISupports* container) = 0;
NS_IMETHOD GetLoadAttribs(nsILoadAttribs* *result) const = 0;
NS_IMETHOD SetLoadAttribs(nsILoadAttribs* loadAttribs) = 0;
NS_IMETHOD GetURLGroup(nsIURLGroup* *result) const = 0;
NS_IMETHOD SetURLGroup(nsIURLGroup* group) = 0;
//@}
NS_IMETHOD SetPostHeader(const char* name, const char* value) = 0;
NS_IMETHOD SetPostData(nsIInputStream* input) = 0;
/** Write the URL to aString, overwriting previous contents. */
NS_IMETHOD ToString(PRUnichar* *aString) const = 0;
};
// XXXwhh (re)move these...
/** Create a new URL, interpreting aSpec as relative to aURL (if non-null). */
extern NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
const nsString& aSpec,
const nsIURL* aBaseURL = nsnull,
nsISupports* aContainer = nsnull,
nsIURLGroup* aGroup = nsnull);
/**
* Utility routine to take a url (may be nsnull) and a base url (may
* be empty), and a url spec and combine them properly into a new
* absolute url.
*/
extern NS_NET nsresult NS_MakeAbsoluteURL(nsIURL* aURL,
const nsString& aBaseURL,
const nsString& aSpec,
nsString& aResult);
extern NS_NET nsresult NS_OpenURL(nsIURL* aURL, nsIStreamListener* aConsumer);
extern NS_NET nsresult NS_OpenURL(nsIURL* aURL, nsIInputStream* *aNewStream,
nsIStreamListener* aConsumer = nsnull);
#endif /* nsIURL_h___ */