PageRenderTime 143ms CodeModel.GetById 60ms app.highlight 2ms RepoModel.GetById 79ms app.codeStats 0ms

/gecko_sdk/idl/nsIIOService.idl

http://firefox-mac-pdf.googlecode.com/
IDL | 169 lines | 28 code | 12 blank | 129 comment | 0 complexity | 99b25ce62d7b5964e1231037d2faf451 MD5 | raw file
  1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2/* ***** BEGIN LICENSE BLOCK *****
  3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4 *
  5 * The contents of this file are subject to the Mozilla Public License Version
  6 * 1.1 (the "License"); you may not use this file except in compliance with
  7 * the License. You may obtain a copy of the License at
  8 * http://www.mozilla.org/MPL/
  9 *
 10 * Software distributed under the License is distributed on an "AS IS" basis,
 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 12 * for the specific language governing rights and limitations under the
 13 * License.
 14 *
 15 * The Original Code is mozilla.org code.
 16 *
 17 * The Initial Developer of the Original Code is
 18 * Netscape Communications Corporation.
 19 * Portions created by the Initial Developer are Copyright (C) 1998
 20 * the Initial Developer. All Rights Reserved.
 21 *
 22 * Contributor(s):
 23 *
 24 * Alternatively, the contents of this file may be used under the terms of
 25 * either the GNU General Public License Version 2 or later (the "GPL"), or
 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 27 * in which case the provisions of the GPL or the LGPL are applicable instead
 28 * of those above. If you wish to allow use of your version of this file only
 29 * under the terms of either the GPL or the LGPL, and not to allow others to
 30 * use your version of this file under the terms of the MPL, indicate your
 31 * decision by deleting the provisions above and replace them with the notice
 32 * and other provisions required by the GPL or the LGPL. If you do not delete
 33 * the provisions above, a recipient may use your version of this file under
 34 * the terms of any one of the MPL, the GPL or the LGPL.
 35 *
 36 * ***** END LICENSE BLOCK ***** */
 37
 38#include "nsISupports.idl"
 39
 40interface nsIProtocolHandler;
 41interface nsIChannel;
 42interface nsIURI;
 43interface nsIFile;
 44
 45/**
 46 * nsIIOService provides a set of network utility functions.  This interface
 47 * duplicates many of the nsIProtocolHandler methods in a protocol handler
 48 * independent way (e.g., NewURI inspects the scheme in order to delegate
 49 * creation of the new URI to the appropriate protocol handler).  nsIIOService
 50 * also provides a set of URL parsing utility functions.  These are provided
 51 * as a convenience to the programmer and in some cases to improve performance
 52 * by eliminating intermediate data structures and interfaces.
 53 *
 54 * @status FROZEN
 55 */
 56[scriptable, uuid(bddeda3f-9020-4d12-8c70-984ee9f7935e)]
 57interface nsIIOService : nsISupports
 58{
 59    /**
 60     * Returns a protocol handler for a given URI scheme.
 61     *
 62     * @param aScheme the URI scheme
 63     * @return reference to corresponding nsIProtocolHandler
 64     */
 65    nsIProtocolHandler getProtocolHandler(in string aScheme);
 66
 67    /**
 68     * Returns the protocol flags for a given scheme.
 69     *
 70     * @param aScheme the URI scheme
 71     * @return value of corresponding nsIProtocolHandler::protocolFlags
 72     */
 73    unsigned long getProtocolFlags(in string aScheme);
 74
 75    /**
 76     * This method constructs a new URI by determining the scheme of the
 77     * URI spec, and then delegating the construction of the URI to the
 78     * protocol handler for that scheme. QueryInterface can be used on
 79     * the resulting URI object to obtain a more specific type of URI.
 80     *
 81     * @see nsIProtocolHandler::newURI
 82     */
 83    nsIURI newURI(in AUTF8String aSpec,
 84                  in string aOriginCharset,
 85                  in nsIURI aBaseURI);
 86
 87    /**
 88     * This method constructs a new URI from a nsIFile.
 89     *
 90     * @param aFile specifies the file path
 91     * @return reference to a new nsIURI object
 92     */
 93    nsIURI newFileURI(in nsIFile aFile);
 94
 95    /**
 96     * Creates a channel for a given URI.
 97     *
 98     * @param aURI nsIURI from which to make a channel
 99     * @return reference to the new nsIChannel object
100     */
101    nsIChannel newChannelFromURI(in nsIURI aURI);
102
103    /**
104     * Equivalent to newChannelFromURI(newURI(...))
105     */
106    nsIChannel newChannel(in AUTF8String aSpec,
107                          in string aOriginCharset,
108                          in nsIURI aBaseURI);
109
110    /**
111     * Returns true if networking is in "offline" mode. When in offline mode, 
112     * attempts to access the network will fail (although this does not 
113     * necessarily correlate with whether there is actually a network 
114     * available -- that's hard to detect without causing the dialer to 
115     * come up).
116     *
117     * Changing this fires observer notifications ... see below.
118     */
119    attribute boolean offline;
120
121    /**
122     * Checks if a port number is banned. This involves consulting a list of
123     * unsafe ports, corresponding to network services that may be easily
124     * exploitable. If the given port is considered unsafe, then the protocol
125     * handler (corresponding to aScheme) will be asked whether it wishes to
126     * override the IO service's decision to block the port. This gives the
127     * protocol handler ultimate control over its own security policy while
128     * ensuring reasonable, default protection.
129     *
130     * @see nsIProtocolHandler::allowPort
131     */
132    boolean allowPort(in long aPort, in string aScheme);
133
134    /**
135     * Utility to extract the scheme from a URL string, consistently and
136     * according to spec (see RFC 2396).
137     *
138     * NOTE: Most URL parsing is done via nsIURI, and in fact the scheme
139     * can also be extracted from a URL string via nsIURI.  This method
140     * is provided purely as an optimization.
141     *
142     * @param aSpec the URL string to parse
143     * @return URL scheme
144     *
145     * @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.
146     */
147    ACString extractScheme(in AUTF8String urlString);
148};
149
150%{C++
151/**
152 * We send notifications through nsIObserverService with topic
153 * NS_IOSERVICE_GOING_OFFLINE_TOPIC and data NS_IOSERVICE_OFFLINE
154 * when 'offline' has changed from false to true, and we are about
155 * to shut down network services such as DNS. When those
156 * services have been shut down, we send a notification with
157 * topic NS_IOSERVICE_OFFLINE_STATUS_TOPIC and data
158 * NS_IOSERVICE_OFFLINE.
159 *
160 * When 'offline' changes from true to false, then after
161 * network services have been restarted, we send a notification
162 * with topic NS_IOSERVICE_OFFLINE_STATUS_TOPIC and data
163 * NS_IOSERVICE_ONLINE.
164 */
165#define NS_IOSERVICE_GOING_OFFLINE_TOPIC  "network:offline-about-to-go-offline"
166#define NS_IOSERVICE_OFFLINE_STATUS_TOPIC "network:offline-status-changed"
167#define NS_IOSERVICE_OFFLINE              "offline"
168#define NS_IOSERVICE_ONLINE               "online"
169%}