1999-06-08 01:33:30 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (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/
|
1999-06-08 01:33:30 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* 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.
|
1999-06-08 01:33:30 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-06-08 01:33:30 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
|
|
|
|
1999-06-12 06:53:21 +04:00
|
|
|
#include "nsIRequest.idl"
|
1999-06-08 01:33:30 +04:00
|
|
|
|
|
|
|
interface nsIURI;
|
|
|
|
interface nsIInputStream;
|
|
|
|
interface nsIOutputStream;
|
|
|
|
interface nsIStreamObserver;
|
|
|
|
interface nsIStreamListener;
|
1999-07-31 10:53:12 +04:00
|
|
|
interface nsILoadGroup;
|
1999-11-18 10:36:41 +03:00
|
|
|
interface nsIInterfaceRequestor;
|
1999-06-08 01:33:30 +04:00
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
typedef unsigned long nsLoadFlags;
|
|
|
|
|
1999-06-08 01:33:30 +04:00
|
|
|
/**
|
|
|
|
* nsIChannel is the abstract base class for transports and URLs.
|
|
|
|
* It's abstract in that it doesn't provide a means to specify the
|
|
|
|
* location/destination of the data being accessed.
|
|
|
|
*/
|
1999-10-26 13:16:24 +04:00
|
|
|
[scriptable, uuid(2d905684-8b5c-11d3-8cd9-0060b0fc14a3)]
|
1999-06-12 06:53:21 +04:00
|
|
|
interface nsIChannel : nsIRequest
|
1999-06-08 01:33:30 +04:00
|
|
|
{
|
|
|
|
/**
|
1999-10-26 13:16:24 +04:00
|
|
|
* Returns the original URL used to construct the channel.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIURI originalURI;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the URL to which the channel currently refers.
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
|
|
|
readonly attribute nsIURI URI;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens a blocking input stream to the URL's specified source.
|
1999-06-11 05:37:43 +04:00
|
|
|
* @param startPosition - The offset from the start of the data
|
|
|
|
* from which to read.
|
|
|
|
* @param readCount - The number of bytes to read. If -1, everything
|
|
|
|
* up to the end of the data is read. If greater than the end of
|
|
|
|
* the data, the amount available is returned in the stream.
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
1999-10-06 12:26:01 +04:00
|
|
|
nsIInputStream openInputStream(in unsigned long startPosition,
|
1999-06-11 05:37:43 +04:00
|
|
|
in long readCount);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens a blocking output stream to the URL's specified destination.
|
1999-06-11 05:37:43 +04:00
|
|
|
* @param startPosition - The offset from the start of the data
|
|
|
|
* from which to begin writing.
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
1999-10-06 12:26:01 +04:00
|
|
|
nsIOutputStream openOutputStream(in unsigned long startPosition);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the channel asynchronously. The nsIStreamObserver's OnStartRequest
|
|
|
|
* method is called back when the channel actually becomes open, providing
|
|
|
|
* the content type. Its OnStopRequest method is called when the channel
|
|
|
|
* becomes closed.
|
|
|
|
*/
|
|
|
|
void asyncOpen(in nsIStreamObserver observer,
|
|
|
|
in nsISupports ctxt);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads asynchronously from the URL's specified source. Notifications
|
|
|
|
* are provided to the stream listener on the thread of the specified
|
|
|
|
* event queue.
|
|
|
|
* The startPosition argument designates the offset in the source where
|
|
|
|
* the data will be read.
|
|
|
|
* If the readCount == -1 then all the available data is delivered to
|
|
|
|
* the stream listener.
|
|
|
|
*/
|
1999-10-06 12:26:01 +04:00
|
|
|
void asyncRead(in unsigned long startPosition,
|
1999-06-08 01:33:30 +04:00
|
|
|
in long readCount,
|
|
|
|
in nsISupports ctxt,
|
1999-07-20 12:46:33 +04:00
|
|
|
in nsIStreamListener listener);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes asynchronously to the URL's specified destination. Notifications
|
|
|
|
* are provided to the stream observer on the thread of the specified
|
|
|
|
* event queue.
|
|
|
|
* The startPosition argument designates the offset in the destination where
|
|
|
|
* the data will be written.
|
|
|
|
* If the writeCount == -1, then all the available data in the input
|
|
|
|
* stream is written.
|
|
|
|
*/
|
1999-10-06 12:26:01 +04:00
|
|
|
void asyncWrite(in nsIInputStream fromStream,
|
1999-06-08 01:33:30 +04:00
|
|
|
in unsigned long startPosition,
|
|
|
|
in long writeCount,
|
|
|
|
in nsISupports ctxt,
|
1999-07-20 12:46:33 +04:00
|
|
|
in nsIStreamObserver observer);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
1999-06-22 04:19:58 +04:00
|
|
|
/**
|
1999-06-25 02:58:42 +04:00
|
|
|
* Load attribute flags. These may be or'd together.
|
|
|
|
*
|
|
|
|
* Note that more will follow for each protocol's implementation of a channel,
|
|
|
|
* although channel writers have to be careful to not let the flag bits
|
|
|
|
* overlap. Otherwise, users won't be able to create a single flag word
|
|
|
|
* of load attributes that applies to a number of different channel types.
|
1999-06-22 04:19:58 +04:00
|
|
|
*/
|
1999-07-16 15:14:36 +04:00
|
|
|
const unsigned long LOAD_NORMAL = 0; /* no special load attributes -- use defaults */
|
|
|
|
const unsigned long LOAD_BACKGROUND = 1 << 0; /* don't deliver status notifications to the
|
|
|
|
* nsIProgressEventSink, or keep this load from
|
|
|
|
* completing the nsILoadGroup it may belong to */
|
1999-06-25 02:58:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Accesses the load attributes for the channel. E.g. setting the load
|
|
|
|
* attributes with the LOAD_QUIET bit set causes the loading process to
|
1999-07-16 15:14:36 +04:00
|
|
|
* not deliver status notifications to the program performing the load,
|
|
|
|
* and to not contribute to keeping any nsILoadGroup it may be contained
|
|
|
|
* in from firing its OnLoadComplete notification.
|
1999-06-25 02:58:42 +04:00
|
|
|
*/
|
1999-10-06 12:26:01 +04:00
|
|
|
attribute nsLoadFlags loadAttributes;
|
1999-06-22 04:19:58 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the content MIME type of the channel if available. Note that the
|
|
|
|
* content type can often be wrongly specified (wrong file extension, wrong
|
|
|
|
* MIME type, wrong document type stored on a server, etc.) and the caller
|
|
|
|
* most likely wants to verify with the actual data.
|
|
|
|
*/
|
1999-10-06 12:26:01 +04:00
|
|
|
readonly attribute string contentType;
|
1999-07-16 15:14:36 +04:00
|
|
|
|
1999-09-11 22:45:36 +04:00
|
|
|
/**
|
|
|
|
* Returns the length of the data assiciated with the channel if available.
|
|
|
|
* If the length is unknown then -1 is returned.
|
|
|
|
*/
|
1999-10-06 12:26:01 +04:00
|
|
|
readonly attribute long contentLength;
|
1999-09-09 09:07:30 +04:00
|
|
|
|
1999-08-30 01:58:42 +04:00
|
|
|
/**
|
1999-09-11 22:45:36 +04:00
|
|
|
* Accesses the owner corresponding to the entity that is
|
|
|
|
* responsible for this channel. Used by security code to grant
|
|
|
|
* or diminish privileges to mobile code loaded from this channel.
|
1999-08-30 01:58:42 +04:00
|
|
|
*/
|
1999-10-06 12:26:01 +04:00
|
|
|
attribute nsISupports owner;
|
1999-08-30 01:58:42 +04:00
|
|
|
|
1999-07-31 10:53:12 +04:00
|
|
|
/**
|
1999-11-17 11:14:52 +03:00
|
|
|
* Accesses the load group in which the channel is a currently a member.
|
1999-07-31 10:53:12 +04:00
|
|
|
*/
|
1999-11-17 11:14:52 +03:00
|
|
|
attribute nsILoadGroup loadGroup;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accesses the capabilities callbacks of the channel. This is set by clients
|
|
|
|
* who wish to provide a means to receive progress, status and protocol-specific
|
|
|
|
* notifications.
|
|
|
|
*/
|
1999-11-18 10:36:41 +03:00
|
|
|
attribute nsIInterfaceRequestor notificationCallbacks;
|
1999-07-31 10:53:12 +04:00
|
|
|
|
1999-06-08 01:33:30 +04:00
|
|
|
};
|
|
|
|
|
1999-11-03 08:09:20 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* nsIInputStreamChannel is an interface that allows for the initialization
|
|
|
|
* of a simple nsIChannel that is constructed from a single input stream and
|
|
|
|
* associated content type. Input stream channels only allow the input stream
|
|
|
|
* to be accessed, not the output stream.
|
|
|
|
*/
|
|
|
|
[scriptable, uuid(bfbf843a-8b89-11d3-8cd9-0060b0fc14a3)]
|
|
|
|
interface nsIInputStreamChannel : nsIChannel
|
|
|
|
{
|
1999-11-30 07:50:42 +03:00
|
|
|
void init(in nsIURI uri,
|
1999-11-03 08:09:20 +03:00
|
|
|
in string contentType,
|
|
|
|
in long contentLength,
|
|
|
|
in nsIInputStream inStr,
|
1999-11-17 11:14:52 +03:00
|
|
|
in nsILoadGroup aLoadGroup,
|
1999-11-18 10:36:41 +03:00
|
|
|
in nsIInterfaceRequestor notificationCallbacks,
|
1999-11-17 11:14:52 +03:00
|
|
|
in nsLoadFlags loadAttributes,
|
1999-11-03 08:09:20 +03:00
|
|
|
in nsIURI originalURI);
|
|
|
|
};
|
|
|
|
|
|
|
|
%{C++
|
|
|
|
|
|
|
|
#define NS_INPUTSTREAMCHANNEL_CID \
|
|
|
|
{ /* 436d84f8-8b8a-11d3-8cd9-0060b0fc14a3 */ \
|
|
|
|
0x436d84f8, \
|
|
|
|
0x8b8a, \
|
|
|
|
0x11d3, \
|
|
|
|
{0x8c, 0xd9, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
|
|
|
}
|
|
|
|
|
|
|
|
%}
|