gecko-dev/netwerk/base/public/nsIIOService.idl

196 lines
7.0 KiB
Plaintext

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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.org 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.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsIChannel.idl"
interface nsIProtocolHandler;
interface nsIURI;
interface nsIInterfaceRequestor;
interface nsIStreamObserver;
interface nsIStreamListener;
interface nsIEventQueue;
interface nsIBufferInputStream;
interface nsIInputStream;
interface nsIBufferOutputStream;
interface nsIFileChannel;
interface nsILoadGroup;
interface nsILoadGroupObserver;
interface nsIFile;
interface nsIInputStream;
interface nsIOutputStream;
[scriptable, uuid(ab7c3a84-d488-11d3-8cda-0060b0fc14a3)]
interface nsIIOService : nsISupports
{
/**
* Returns a protocol handler for a given URI scheme.
*/
nsIProtocolHandler getProtocolHandler(in string scheme);
/**
* This method constructs a new URI by first determining the scheme
* of the URI spec, and then delegating the construction of the URI
* to the protocol handler for that scheme. QueryInterface can be used
* on the resulting URI object to obtain a more specific type of URI.
*/
nsIURI newURI(in string aSpec, in nsIURI aBaseURI);
/**
* Creates a channel for a given URI. The notificationCallbacks argument
* is used to obtain the appropriate callbacks for the URI's protocol from the
* application.
*
* @param originalURI - Specifies the original URI which caused the creation
* of this channel. This can occur when the construction of one channel
* (e.g. for resource:) causes another channel to be created on its behalf
* (e.g. a file: channel), or if a redirect occurs, causing the current
* URL to become different from the original URL. If NULL, the aURI parameter
* will be used as the originalURI instead.
*/
nsIChannel newChannelFromURI(in string verb,
in nsIURI aURI,
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
/**
* Convenience routine that first creates a URI by calling NewURI, and
* then passes the URI to NewChannelFromURI.
*/
nsIChannel newChannel(in string verb,
in string aSpec,
in nsIURI aBaseURI,
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
/**
* Get the application name string that will be used as part
* of a HTTP request.
*/
readonly attribute wstring appCodeName;
/**
* Get the application version string that will be used as part
* of a HTTP request.
*/
readonly attribute wstring appVersion;
/**
* Get the application name.
*/
readonly attribute wstring appName;
/**
* Get the translation of the application. The value for language
* is usually a 2-letter code such as "en" and occasionally a
* five-character code to indicate a language subtype, such as "zh_CN".
*/
attribute wstring language;
/**
* Get the current platform (machine type).
*/
readonly attribute wstring platform;
/**
* Get the HTTP advertised user agent string.
*/
readonly attribute wstring userAgent;
/**
* Returns true if networking is in "offline" mode. When in offline mode, attempts
* to access the network will fail (although this is not necessarily corrolated with
* whether there is actually a network available -- that's hard to detect without
* causing the dialer to come up).
*/
attribute boolean offline;
////////////////////////////////////////////////////////////////////////////
// URL parsing utilities
/**
* Utility for protocol implementors -- extracts the scheme from a URL
* string, consistently and according to spec.
* @param urlString - the URL string to parse
* @param schemeStartPos - the resulting starting position of the scheme substring
* (may skip over whitespace)
* @param schemeEndPos - the resulting ending position of the scheme substring
* (the position of the colon)
* @param scheme - an allocated substring containing the scheme. If this parameter
* is null going into the routine, then the scheme is not allocated and
* returned. Free with nsCRT::free.
*
* @return NS_OK - if successful
* @return NS_ERROR_MALFORMED_URI - if the urlString is not of the right form
*/
void extractScheme(in string urlString,
out unsigned long schemeStartPos,
out unsigned long schemeEndPos,
out string scheme);
/**
* Encode characters into % escaped hexcodes.
*/
string escape(in string str, in short mask);
/**
* Decode % escaped hex codes into character values.
*/
string unescape(in string str);
/**
* Get port from string.
*/
long extractPort(in string str);
/**
* Resolves a relative path string containing "." and ".."
* with respect to a base path (assumed to already be resolved).
* For example, resolving "../../foo/./bar/../baz.html" w.r.t.
* "/a/b/c/d/e/" yields "/a/b/c/foo/baz.html". Attempting to
* ascend above the base results in the NS_ERROR_MALFORMED_URI
* exception. If basePath is null, it treats it as "/".
*/
string resolveRelativePath(in string relativePath,
in string basePath);
};
%{C++
#define NS_IOSERVICE_CID \
{ /* 9ac9e770-18bc-11d3-9337-00104ba0fd40 */ \
0x9ac9e770, \
0x18bc, \
0x11d3, \
{0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
%}