2001-09-29 00:14:13 +04: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-08 01:33:30 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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
|
|
|
*
|
2001-09-29 00:14:13 +04: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.
|
|
|
|
*
|
2001-09-29 00:14:13 +04: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 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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-08 01:33:30 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
interface nsIProtocolHandler;
|
2001-04-10 10:01:08 +04:00
|
|
|
interface nsIChannel;
|
1999-06-08 01:33:30 +04:00
|
|
|
interface nsIURI;
|
2001-06-22 02:02:47 +04:00
|
|
|
interface nsIURLParser;
|
|
|
|
interface nsIFile;
|
1999-06-08 01:33:30 +04:00
|
|
|
|
2000-01-27 11:57:14 +03:00
|
|
|
[scriptable, uuid(ab7c3a84-d488-11d3-8cda-0060b0fc14a3)]
|
1999-06-08 01:33:30 +04:00
|
|
|
interface nsIIOService : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns a protocol handler for a given URI scheme.
|
2001-09-08 16:47:05 +04:00
|
|
|
*
|
|
|
|
* @param scheme URI scheme
|
|
|
|
* @return reference to nsIProtcolHandler
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
1999-10-12 05:39:37 +04:00
|
|
|
nsIProtocolHandler getProtocolHandler(in string scheme);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
2001-08-08 00:42:57 +04:00
|
|
|
/**
|
2001-09-13 06:21:05 +04:00
|
|
|
* Returns the protocol flags for a given scheme.
|
2001-08-08 14:03:29 +04:00
|
|
|
*
|
|
|
|
* @param scheme URI scheme
|
2001-09-13 06:21:05 +04:00
|
|
|
* @return returns unsigned long for protocol flags
|
2001-08-08 00:42:57 +04:00
|
|
|
*/
|
2001-09-13 06:21:05 +04:00
|
|
|
unsigned long getProtocolFlags(in string scheme);
|
2001-08-08 00:42:57 +04:00
|
|
|
|
1999-06-08 01:33:30 +04: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.
|
2001-09-08 16:47:05 +04:00
|
|
|
*
|
|
|
|
* @param aSpec URI spec (http, ftp, etc)
|
|
|
|
* @param aBaseURI nsIURI to construct the actual URI from
|
|
|
|
* @return reference to a new nsIURI object
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
1999-10-12 05:39:37 +04:00
|
|
|
nsIURI newURI(in string aSpec, in nsIURI aBaseURI);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
2001-06-22 02:02:47 +04:00
|
|
|
/**
|
|
|
|
* This method constructs a new file URI
|
|
|
|
*
|
2001-09-08 16:47:05 +04:00
|
|
|
* @param aSpec nsIFile
|
|
|
|
* @return reference to a new nsIURI object
|
2001-06-22 02:02:47 +04:00
|
|
|
*/
|
|
|
|
nsIURI newFileURI(in nsIFile aSpec);
|
|
|
|
|
1999-06-08 01:33:30 +04:00
|
|
|
/**
|
1999-11-17 11:14:52 +03:00
|
|
|
* Creates a channel for a given URI. The notificationCallbacks argument
|
2001-09-08 16:47:05 +04:00
|
|
|
* 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.
|
1999-10-26 13:16:24 +04:00
|
|
|
*
|
2001-09-08 16:47:05 +04:00
|
|
|
* @param aURI - nsIURI to make a channel from
|
|
|
|
* @return a reference to the new nsIChannel object
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
2000-03-29 07:58:50 +04:00
|
|
|
nsIChannel newChannelFromURI(in nsIURI aURI);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience routine that first creates a URI by calling NewURI, and
|
|
|
|
* then passes the URI to NewChannelFromURI.
|
2000-03-29 07:58:50 +04:00
|
|
|
*
|
2001-09-08 16:47:05 +04:00
|
|
|
* @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.
|
|
|
|
*
|
|
|
|
* @param aSpec URI spec to select the appropriate protocol handler
|
|
|
|
* @param aBaseURI a base URI to create a channel to
|
|
|
|
* @return a reference to the new nsIChannel object
|
1999-06-08 01:33:30 +04:00
|
|
|
*/
|
2000-03-29 07:58:50 +04:00
|
|
|
nsIChannel newChannel(in string aSpec, in nsIURI aBaseURI);
|
1999-06-08 01:33:30 +04:00
|
|
|
|
2000-01-27 11:57:14 +03:00
|
|
|
/**
|
2001-09-08 16:47:05 +04: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 11:57:14 +03:00
|
|
|
*/
|
|
|
|
attribute boolean offline;
|
|
|
|
|
2001-06-06 04:10:09 +04:00
|
|
|
/**
|
|
|
|
* Checks if a port number is banned.
|
|
|
|
*
|
2001-09-08 16:47:05 +04:00
|
|
|
* |allowPort| will check a list of "known-to-do-bad-things"
|
|
|
|
* port numbers. If the given port is found on the blacklist,
|
|
|
|
* |allowPort| will ask the protocol handler if it wishes to override.
|
|
|
|
* Scheme can be null.
|
2001-06-06 04:10:09 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
boolean allowPort(in long port, in string scheme);
|
|
|
|
|
2000-01-27 11:57:14 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// URL parsing utilities
|
|
|
|
|
1999-11-12 09:13:13 +03:00
|
|
|
/**
|
|
|
|
* Utility for protocol implementors -- extracts the scheme from a URL
|
|
|
|
* string, consistently and according to spec.
|
|
|
|
* @param urlString - the URL string to parse
|
2001-09-08 16:47:05 +04:00
|
|
|
* @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.
|
1999-11-12 09:13:13 +03:00
|
|
|
*
|
|
|
|
* @return NS_OK - if successful
|
2001-09-08 16:47:05 +04:00
|
|
|
* @return NS_ERROR_MALFORMED_URI - if the urlString is not of
|
|
|
|
* the right form
|
1999-11-12 09:13:13 +03:00
|
|
|
*/
|
2001-06-22 02:02:47 +04:00
|
|
|
string extractScheme(in string urlString,
|
|
|
|
out unsigned long schemeStartPos,
|
|
|
|
out unsigned long schemeEndPos);
|
|
|
|
|
|
|
|
|
|
|
|
nsIURLParser getParserForScheme(in string scheme);
|
|
|
|
|
2001-08-08 14:03:29 +04:00
|
|
|
string extractUrlPart(in string urlString,
|
|
|
|
in short flag,
|
|
|
|
out unsigned long startPos,
|
|
|
|
out unsigned long endPos);
|
2001-06-22 02:02:47 +04:00
|
|
|
|
2000-01-05 05:44:23 +03:00
|
|
|
|
2000-03-29 07:58:50 +04:00
|
|
|
/**
|
2001-09-08 16:47:05 +04:00
|
|
|
* Constants for the mask in the call to extractUrlPart
|
2001-11-16 05:09:13 +03:00
|
|
|
*
|
|
|
|
* XXX these should really be enumerated in left-to-right order!
|
2000-03-29 07:58:50 +04:00
|
|
|
*/
|
|
|
|
const short url_Scheme = (1<<0);
|
|
|
|
const short url_Username = (1<<1);
|
|
|
|
const short url_Password = (1<<2);
|
|
|
|
const short url_Host = (1<<3);
|
|
|
|
const short url_Directory = (1<<4);
|
|
|
|
const short url_FileBaseName = (1<<5);
|
|
|
|
const short url_FileExtension = (1<<6);
|
|
|
|
const short url_Param = (1<<7);
|
|
|
|
const short url_Query = (1<<8);
|
|
|
|
const short url_Ref = (1<<9);
|
2001-09-14 09:47:54 +04:00
|
|
|
const short url_Path = (1<<10);
|
2001-10-19 06:28:06 +04:00
|
|
|
const short url_Port = (1<<11);
|
2000-01-25 00:28:28 +03:00
|
|
|
|
2000-01-27 11:57:14 +03:00
|
|
|
/**
|
|
|
|
* Get port from string.
|
2001-09-08 16:47:05 +04:00
|
|
|
*
|
|
|
|
* @param str URI-style string
|
|
|
|
* @return port number
|
2000-01-27 11:57:14 +03:00
|
|
|
*/
|
|
|
|
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 "/".
|
2001-09-08 16:47:05 +04:00
|
|
|
*
|
|
|
|
* @param relativePath a relative URI
|
|
|
|
* @param basePath a base URI
|
|
|
|
* @return a new string, representing canonical uri
|
2000-01-27 11:57:14 +03:00
|
|
|
*/
|
|
|
|
string resolveRelativePath(in string relativePath,
|
|
|
|
in string basePath);
|
2001-12-19 03:55:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* conversions between nsILocalFile and a file url string
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getURLSpecFromFile
|
|
|
|
* gets a file:// url out of an nsIFile
|
|
|
|
* @param file the file to extract the path from
|
|
|
|
* @return a file:// style url string
|
|
|
|
*/
|
|
|
|
string getURLSpecFromFile(in nsIFile file);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* initFileFromURL
|
|
|
|
* Sets the native path of the file given the url string
|
|
|
|
* @param file the file to initialize with the given spec
|
|
|
|
* @param url the url string which will be used to initialize the file
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void initFileFromURLSpec(in nsIFile file, in string url);
|
1999-06-08 01:33:30 +04:00
|
|
|
};
|