nsIIOService.idl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #include "nsISupports.idl"
  38. interface nsIProtocolHandler;
  39. interface nsIChannel;
  40. interface nsIURI;
  41. interface nsIFile;
  42. /**
  43. * nsIIOService provides a set of network utility functions. This interface
  44. * duplicates many of the nsIProtocolHandler methods in a protocol handler
  45. * independent way (e.g., NewURI inspects the scheme in order to delegate
  46. * creation of the new URI to the appropriate protocol handler). nsIIOService
  47. * also provides a set of URL parsing utility functions. These are provided
  48. * as a convenience to the programmer and in some cases to improve performance
  49. * by eliminating intermediate data structures and interfaces.
  50. *
  51. * @status FROZEN
  52. */
  53. [scriptable, uuid(bddeda3f-9020-4d12-8c70-984ee9f7935e)]
  54. interface nsIIOService : nsISupports
  55. {
  56. /**
  57. * Returns a protocol handler for a given URI scheme.
  58. *
  59. * @param aScheme the URI scheme
  60. * @return reference to corresponding nsIProtocolHandler
  61. */
  62. nsIProtocolHandler getProtocolHandler(in string aScheme);
  63. /**
  64. * Returns the protocol flags for a given scheme.
  65. *
  66. * @param aScheme the URI scheme
  67. * @return value of corresponding nsIProtocolHandler::protocolFlags
  68. */
  69. unsigned long getProtocolFlags(in string aScheme);
  70. /**
  71. * This method constructs a new URI by determining the scheme of the
  72. * URI spec, and then delegating the construction of the URI to the
  73. * protocol handler for that scheme. QueryInterface can be used on
  74. * the resulting URI object to obtain a more specific type of URI.
  75. *
  76. * @see nsIProtocolHandler::newURI
  77. */
  78. nsIURI newURI(in AUTF8String aSpec,
  79. in string aOriginCharset,
  80. in nsIURI aBaseURI);
  81. /**
  82. * This method constructs a new URI from a nsIFile.
  83. *
  84. * @param aFile specifies the file path
  85. * @return reference to a new nsIURI object
  86. */
  87. nsIURI newFileURI(in nsIFile aFile);
  88. /**
  89. * Creates a channel for a given URI.
  90. *
  91. * @param aURI nsIURI from which to make a channel
  92. * @return reference to the new nsIChannel object
  93. */
  94. nsIChannel newChannelFromURI(in nsIURI aURI);
  95. /**
  96. * Equivalent to newChannelFromURI(newURI(...))
  97. */
  98. nsIChannel newChannel(in AUTF8String aSpec,
  99. in string aOriginCharset,
  100. in nsIURI aBaseURI);
  101. /**
  102. * Returns true if networking is in "offline" mode. When in offline mode,
  103. * attempts to access the network will fail (although this is not
  104. * necessarily corrolated with whether there is actually a network
  105. * available -- that's hard to detect without causing the dialer to
  106. * come up).
  107. */
  108. attribute boolean offline;
  109. /**
  110. * Checks if a port number is banned. This involves consulting a list of
  111. * unsafe ports, corresponding to network services that may be easily
  112. * exploitable. If the given port is considered unsafe, then the protocol
  113. * handler (corresponding to aScheme) will be asked whether it wishes to
  114. * override the IO service's decision to block the port. This gives the
  115. * protocol handler ultimate control over its own security policy while
  116. * ensuring reasonable, default protection.
  117. *
  118. * @see nsIProtocolHandler::allowPort
  119. */
  120. boolean allowPort(in long aPort, in string aScheme);
  121. /**
  122. * Utility to extract the scheme from a URL string, consistently and
  123. * according to spec (see RFC 2396).
  124. *
  125. * NOTE: Most URL parsing is done via nsIURI, and in fact the scheme
  126. * can also be extracted from a URL string via nsIURI. This method
  127. * is provided purely as an optimization.
  128. *
  129. * @param aSpec the URL string to parse
  130. * @return URL scheme
  131. *
  132. * @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.
  133. */
  134. ACString extractScheme(in AUTF8String urlString);
  135. };