2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-06-07 21:33:30 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00: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-07 21:33:30 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00: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-07 21:33:30 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-06-07 21:33:30 +00:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
interface nsIProtocolHandler;
|
2001-04-10 06:01:08 +00:00
|
|
|
interface nsIChannel;
|
1999-06-07 21:33:30 +00:00
|
|
|
interface nsIURI;
|
2001-06-21 22:02:47 +00:00
|
|
|
interface nsIFile;
|
1999-06-07 21:33:30 +00:00
|
|
|
|
2002-08-08 19:08:59 +00:00
|
|
|
/**
|
|
|
|
* nsIIOService provides a set of utility functions for necko. The interface
|
|
|
|
* duplicates many of the nsIProtocolHandler methods in a protocol handler
|
|
|
|
* independent way (e.g., NewURI sniffs the scheme to determine which protocol
|
|
|
|
* handler's NewURI should be invoked). nsIIOService also provides a set of
|
|
|
|
* URL parsing utility functions. These are provided to make the programmers
|
|
|
|
* job easier and in some cases to improve performance by eliminating
|
|
|
|
* intermediate data structures and interfaces.
|
|
|
|
*
|
|
|
|
* @status UNDER_REVIEW
|
|
|
|
*/
|
2000-01-27 08:57:14 +00:00
|
|
|
[scriptable, uuid(ab7c3a84-d488-11d3-8cda-0060b0fc14a3)]
|
1999-06-07 21:33:30 +00:00
|
|
|
interface nsIIOService : nsISupports
|
|
|
|
{
|
2002-08-08 19:08:59 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* Protocol handler utilities
|
|
|
|
*/
|
|
|
|
|
1999-06-07 21:33:30 +00:00
|
|
|
/**
|
|
|
|
* Returns a protocol handler for a given URI scheme.
|
2001-09-08 12:47:05 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* @param aScheme the URI scheme
|
|
|
|
* @return reference to corresponding nsIProtocolHandler
|
1999-06-07 21:33:30 +00:00
|
|
|
*/
|
2002-08-08 19:08:59 +00:00
|
|
|
nsIProtocolHandler getProtocolHandler(in string aScheme);
|
1999-06-07 21:33:30 +00:00
|
|
|
|
2001-08-07 20:42:57 +00:00
|
|
|
/**
|
2001-09-13 02:21:05 +00:00
|
|
|
* Returns the protocol flags for a given scheme.
|
2001-08-08 10:03:29 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* @param aScheme the URI scheme
|
|
|
|
* @return value of corresponding nsIProtocolHandler::protocolFlags
|
2001-08-07 20:42:57 +00:00
|
|
|
*/
|
2002-08-08 19:08:59 +00:00
|
|
|
unsigned long getProtocolFlags(in string aScheme);
|
2001-08-07 20:42:57 +00:00
|
|
|
|
1999-06-07 21:33:30 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2002-08-08 19:08:59 +00:00
|
|
|
*
|
2002-03-06 07:48:55 +00:00
|
|
|
* @see nsIProtocolHandler::newURI
|
1999-06-07 21:33:30 +00:00
|
|
|
*/
|
2002-03-06 07:48:55 +00:00
|
|
|
nsIURI newURI(in AUTF8String aSpec,
|
|
|
|
in string aOriginCharset,
|
|
|
|
in nsIURI aBaseURI);
|
1999-06-07 21:33:30 +00:00
|
|
|
|
2001-06-21 22:02:47 +00:00
|
|
|
/**
|
2002-08-08 19:08:59 +00:00
|
|
|
* This method constructs a new URI from a nsIFile.
|
2001-06-21 22:02:47 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* @param aFile specifies the file path
|
2002-03-06 07:48:55 +00:00
|
|
|
* @return reference to a new nsIURI object
|
2001-06-21 22:02:47 +00:00
|
|
|
*/
|
2002-03-06 07:48:55 +00:00
|
|
|
nsIURI newFileURI(in nsIFile aFile);
|
2001-06-21 22:02:47 +00:00
|
|
|
|
1999-06-07 21:33:30 +00:00
|
|
|
/**
|
2002-08-08 19:08:59 +00:00
|
|
|
* Creates a channel for a given URI.
|
1999-10-26 09:16:24 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* @param aURI nsIURI from which to make a channel
|
|
|
|
* @return reference to the new nsIChannel object
|
1999-06-07 21:33:30 +00:00
|
|
|
*/
|
2000-03-29 03:58:50 +00:00
|
|
|
nsIChannel newChannelFromURI(in nsIURI aURI);
|
1999-06-07 21:33:30 +00:00
|
|
|
|
|
|
|
/**
|
2002-08-08 19:08:59 +00:00
|
|
|
* Equivalent to newChannelFromURI(newURI(...))
|
1999-06-07 21:33:30 +00:00
|
|
|
*/
|
2002-03-06 07:48:55 +00:00
|
|
|
nsIChannel newChannel(in AUTF8String aSpec,
|
|
|
|
in string aOriginCharset,
|
|
|
|
in nsIURI aBaseURI);
|
1999-06-07 21:33:30 +00:00
|
|
|
|
2000-01-27 08:57:14 +00:00
|
|
|
/**
|
2001-09-08 12:47:05 +00:00
|
|
|
* 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).
|
2000-01-27 08:57:14 +00:00
|
|
|
*/
|
|
|
|
attribute boolean offline;
|
|
|
|
|
2001-06-06 00:10:09 +00:00
|
|
|
/**
|
2002-08-08 19:08:59 +00:00
|
|
|
* Checks if a port number is banned. This involves consulting a black-
|
|
|
|
* list of port numbers corresponding to services that may be easily
|
|
|
|
* exploitable. If the given port is found on the black-list, then the
|
|
|
|
* protocol handler (corresponding to aScheme) will be asked if it wishes
|
|
|
|
* to override the IO service's decision to block the port. This gives
|
|
|
|
* the protocol handler ultimate control over its own security policy
|
|
|
|
* while ensuring reasonable, default protection.
|
2001-06-06 00:10:09 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* @see nsIProtocolHandler::allowPort
|
2001-06-06 00:10:09 +00:00
|
|
|
*/
|
2002-08-08 19:08:59 +00:00
|
|
|
boolean allowPort(in long aPort, in string aScheme);
|
2001-06-06 00:10:09 +00:00
|
|
|
|
2000-01-27 08:57:14 +00:00
|
|
|
|
2002-08-08 19:08:59 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* URL parsing utilities
|
1999-11-12 06:13:13 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* The set of methods provided here is intentionally limited. Most of
|
|
|
|
* Necko's URL parsing functionality is provided via nsIURI. This is
|
|
|
|
* done to ensure a common point of access to URL parsing, which is
|
|
|
|
* protocol dependent. Do not try to parse a random URL string as the
|
|
|
|
* result will likely differ (perhaps only in some subtle way) from the
|
|
|
|
* value of the corresponding nsIURI attribute. Violating this rule
|
|
|
|
* may make your code vulnerable to various kinds of security exploits.
|
|
|
|
* DON'T RISK IT! --darin
|
2002-03-06 07:48:55 +00:00
|
|
|
*/
|
2001-06-21 22:02:47 +00:00
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
/**
|
2002-08-08 19:08:59 +00:00
|
|
|
* Utility to extract the scheme from a URL string, consistently and
|
|
|
|
* according to spec (see RFC 2396).
|
2002-03-06 07:48:55 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* @param aSpec the URL string to parse
|
|
|
|
* @return URL scheme
|
2001-11-16 02:09:13 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.
|
2000-03-29 03:58:50 +00:00
|
|
|
*/
|
2002-08-08 19:08:59 +00:00
|
|
|
ACString extractScheme(in AUTF8String urlString);
|
2000-01-24 21:28:28 +00:00
|
|
|
|
2000-01-27 08:57:14 +00:00
|
|
|
/**
|
2002-08-08 19:08:59 +00:00
|
|
|
* Converts the nsIFile to the corresponding URL string. NOTE: under
|
|
|
|
* some platforms this is a lossy conversion (e.g., Mac Carbon build).
|
|
|
|
* If the nsIFile is a local file, then the result will be a file://
|
|
|
|
* URL string.
|
2002-03-06 07:48:55 +00:00
|
|
|
*
|
2002-08-08 19:08:59 +00:00
|
|
|
* The resulting string may contain URL-escaped characters.
|
2001-12-19 00:55:42 +00:00
|
|
|
*/
|
2002-03-06 07:48:55 +00:00
|
|
|
AUTF8String getURLSpecFromFile(in nsIFile file);
|
2001-12-19 00:55:42 +00:00
|
|
|
|
|
|
|
/**
|
2002-08-08 19:08:59 +00:00
|
|
|
* Converts the URL string into the corresponding nsIFile if possible.
|
|
|
|
* A local file will be created if the URL string begins with file://.
|
2001-12-19 00:55:42 +00:00
|
|
|
*/
|
2002-08-08 19:08:59 +00:00
|
|
|
nsIFile getFileFromURLSpec(in AUTF8String url);
|
1999-06-07 21:33:30 +00:00
|
|
|
};
|