nsIIOService.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM c:/mozilla/netwerk/base/public/nsIIOService.idl
  3. */
  4. #ifndef __gen_nsIIOService_h__
  5. #define __gen_nsIIOService_h__
  6. #ifndef __gen_nsISupports_h__
  7. #include "nsISupports.h"
  8. #endif
  9. /* For IDL files that don't want to include root IDL files. */
  10. #ifndef NS_NO_VTABLE
  11. #define NS_NO_VTABLE
  12. #endif
  13. class nsIProtocolHandler; /* forward declaration */
  14. class nsIChannel; /* forward declaration */
  15. class nsIURI; /* forward declaration */
  16. class nsIFile; /* forward declaration */
  17. /* starting interface: nsIIOService */
  18. #define NS_IIOSERVICE_IID_STR "bddeda3f-9020-4d12-8c70-984ee9f7935e"
  19. #define NS_IIOSERVICE_IID \
  20. {0xbddeda3f, 0x9020, 0x4d12, \
  21. { 0x8c, 0x70, 0x98, 0x4e, 0xe9, 0xf7, 0x93, 0x5e }}
  22. /**
  23. * nsIIOService provides a set of network utility functions. This interface
  24. * duplicates many of the nsIProtocolHandler methods in a protocol handler
  25. * independent way (e.g., NewURI inspects the scheme in order to delegate
  26. * creation of the new URI to the appropriate protocol handler). nsIIOService
  27. * also provides a set of URL parsing utility functions. These are provided
  28. * as a convenience to the programmer and in some cases to improve performance
  29. * by eliminating intermediate data structures and interfaces.
  30. *
  31. * @status FROZEN
  32. */
  33. class NS_NO_VTABLE nsIIOService : public nsISupports {
  34. public:
  35. NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIOSERVICE_IID)
  36. /**
  37. * Returns a protocol handler for a given URI scheme.
  38. *
  39. * @param aScheme the URI scheme
  40. * @return reference to corresponding nsIProtocolHandler
  41. */
  42. /* nsIProtocolHandler getProtocolHandler (in string aScheme); */
  43. NS_IMETHOD GetProtocolHandler(const char *aScheme, nsIProtocolHandler **_retval) = 0;
  44. /**
  45. * Returns the protocol flags for a given scheme.
  46. *
  47. * @param aScheme the URI scheme
  48. * @return value of corresponding nsIProtocolHandler::protocolFlags
  49. */
  50. /* unsigned long getProtocolFlags (in string aScheme); */
  51. NS_IMETHOD GetProtocolFlags(const char *aScheme, PRUint32 *_retval) = 0;
  52. /**
  53. * This method constructs a new URI by determining the scheme of the
  54. * URI spec, and then delegating the construction of the URI to the
  55. * protocol handler for that scheme. QueryInterface can be used on
  56. * the resulting URI object to obtain a more specific type of URI.
  57. *
  58. * @see nsIProtocolHandler::newURI
  59. */
  60. /* nsIURI newURI (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */
  61. NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) = 0;
  62. /**
  63. * This method constructs a new URI from a nsIFile.
  64. *
  65. * @param aFile specifies the file path
  66. * @return reference to a new nsIURI object
  67. */
  68. /* nsIURI newFileURI (in nsIFile aFile); */
  69. NS_IMETHOD NewFileURI(nsIFile *aFile, nsIURI **_retval) = 0;
  70. /**
  71. * Creates a channel for a given URI.
  72. *
  73. * @param aURI nsIURI from which to make a channel
  74. * @return reference to the new nsIChannel object
  75. */
  76. /* nsIChannel newChannelFromURI (in nsIURI aURI); */
  77. NS_IMETHOD NewChannelFromURI(nsIURI *aURI, nsIChannel **_retval) = 0;
  78. /**
  79. * Equivalent to newChannelFromURI(newURI(...))
  80. */
  81. /* nsIChannel newChannel (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */
  82. NS_IMETHOD NewChannel(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval) = 0;
  83. /**
  84. * Returns true if networking is in "offline" mode. When in offline mode,
  85. * attempts to access the network will fail (although this is not
  86. * necessarily corrolated with whether there is actually a network
  87. * available -- that's hard to detect without causing the dialer to
  88. * come up).
  89. */
  90. /* attribute boolean offline; */
  91. NS_IMETHOD GetOffline(PRBool *aOffline) = 0;
  92. NS_IMETHOD SetOffline(PRBool aOffline) = 0;
  93. /**
  94. * Checks if a port number is banned. This involves consulting a list of
  95. * unsafe ports, corresponding to network services that may be easily
  96. * exploitable. If the given port is considered unsafe, then the protocol
  97. * handler (corresponding to aScheme) will be asked whether it wishes to
  98. * override the IO service's decision to block the port. This gives the
  99. * protocol handler ultimate control over its own security policy while
  100. * ensuring reasonable, default protection.
  101. *
  102. * @see nsIProtocolHandler::allowPort
  103. */
  104. /* boolean allowPort (in long aPort, in string aScheme); */
  105. NS_IMETHOD AllowPort(PRInt32 aPort, const char *aScheme, PRBool *_retval) = 0;
  106. /**
  107. * Utility to extract the scheme from a URL string, consistently and
  108. * according to spec (see RFC 2396).
  109. *
  110. * NOTE: Most URL parsing is done via nsIURI, and in fact the scheme
  111. * can also be extracted from a URL string via nsIURI. This method
  112. * is provided purely as an optimization.
  113. *
  114. * @param aSpec the URL string to parse
  115. * @return URL scheme
  116. *
  117. * @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form.
  118. */
  119. /* ACString extractScheme (in AUTF8String urlString); */
  120. NS_IMETHOD ExtractScheme(const nsACString & urlString, nsACString & _retval) = 0;
  121. };
  122. /* Use this macro when declaring classes that implement this interface. */
  123. #define NS_DECL_NSIIOSERVICE \
  124. NS_IMETHOD GetProtocolHandler(const char *aScheme, nsIProtocolHandler **_retval); \
  125. NS_IMETHOD GetProtocolFlags(const char *aScheme, PRUint32 *_retval); \
  126. NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval); \
  127. NS_IMETHOD NewFileURI(nsIFile *aFile, nsIURI **_retval); \
  128. NS_IMETHOD NewChannelFromURI(nsIURI *aURI, nsIChannel **_retval); \
  129. NS_IMETHOD NewChannel(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval); \
  130. NS_IMETHOD GetOffline(PRBool *aOffline); \
  131. NS_IMETHOD SetOffline(PRBool aOffline); \
  132. NS_IMETHOD AllowPort(PRInt32 aPort, const char *aScheme, PRBool *_retval); \
  133. NS_IMETHOD ExtractScheme(const nsACString & urlString, nsACString & _retval);
  134. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  135. #define NS_FORWARD_NSIIOSERVICE(_to) \
  136. NS_IMETHOD GetProtocolHandler(const char *aScheme, nsIProtocolHandler **_retval) { return _to GetProtocolHandler(aScheme, _retval); } \
  137. NS_IMETHOD GetProtocolFlags(const char *aScheme, PRUint32 *_retval) { return _to GetProtocolFlags(aScheme, _retval); } \
  138. NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) { return _to NewURI(aSpec, aOriginCharset, aBaseURI, _retval); } \
  139. NS_IMETHOD NewFileURI(nsIFile *aFile, nsIURI **_retval) { return _to NewFileURI(aFile, _retval); } \
  140. NS_IMETHOD NewChannelFromURI(nsIURI *aURI, nsIChannel **_retval) { return _to NewChannelFromURI(aURI, _retval); } \
  141. NS_IMETHOD NewChannel(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval) { return _to NewChannel(aSpec, aOriginCharset, aBaseURI, _retval); } \
  142. NS_IMETHOD GetOffline(PRBool *aOffline) { return _to GetOffline(aOffline); } \
  143. NS_IMETHOD SetOffline(PRBool aOffline) { return _to SetOffline(aOffline); } \
  144. NS_IMETHOD AllowPort(PRInt32 aPort, const char *aScheme, PRBool *_retval) { return _to AllowPort(aPort, aScheme, _retval); } \
  145. NS_IMETHOD ExtractScheme(const nsACString & urlString, nsACString & _retval) { return _to ExtractScheme(urlString, _retval); }
  146. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  147. #define NS_FORWARD_SAFE_NSIIOSERVICE(_to) \
  148. NS_IMETHOD GetProtocolHandler(const char *aScheme, nsIProtocolHandler **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetProtocolHandler(aScheme, _retval); } \
  149. NS_IMETHOD GetProtocolFlags(const char *aScheme, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetProtocolFlags(aScheme, _retval); } \
  150. NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewURI(aSpec, aOriginCharset, aBaseURI, _retval); } \
  151. NS_IMETHOD NewFileURI(nsIFile *aFile, nsIURI **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewFileURI(aFile, _retval); } \
  152. NS_IMETHOD NewChannelFromURI(nsIURI *aURI, nsIChannel **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewChannelFromURI(aURI, _retval); } \
  153. NS_IMETHOD NewChannel(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewChannel(aSpec, aOriginCharset, aBaseURI, _retval); } \
  154. NS_IMETHOD GetOffline(PRBool *aOffline) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOffline(aOffline); } \
  155. NS_IMETHOD SetOffline(PRBool aOffline) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOffline(aOffline); } \
  156. NS_IMETHOD AllowPort(PRInt32 aPort, const char *aScheme, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->AllowPort(aPort, aScheme, _retval); } \
  157. NS_IMETHOD ExtractScheme(const nsACString & urlString, nsACString & _retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->ExtractScheme(urlString, _retval); }
  158. #if 0
  159. /* Use the code below as a template for the implementation class for this interface. */
  160. /* Header file */
  161. class nsIOService : public nsIIOService
  162. {
  163. public:
  164. NS_DECL_ISUPPORTS
  165. NS_DECL_NSIIOSERVICE
  166. nsIOService();
  167. private:
  168. ~nsIOService();
  169. protected:
  170. /* additional members */
  171. };
  172. /* Implementation file */
  173. NS_IMPL_ISUPPORTS1(nsIOService, nsIIOService)
  174. nsIOService::nsIOService()
  175. {
  176. /* member initializers and constructor code */
  177. }
  178. nsIOService::~nsIOService()
  179. {
  180. /* destructor code */
  181. }
  182. /* nsIProtocolHandler getProtocolHandler (in string aScheme); */
  183. NS_IMETHODIMP nsIOService::GetProtocolHandler(const char *aScheme, nsIProtocolHandler **_retval)
  184. {
  185. return NS_ERROR_NOT_IMPLEMENTED;
  186. }
  187. /* unsigned long getProtocolFlags (in string aScheme); */
  188. NS_IMETHODIMP nsIOService::GetProtocolFlags(const char *aScheme, PRUint32 *_retval)
  189. {
  190. return NS_ERROR_NOT_IMPLEMENTED;
  191. }
  192. /* nsIURI newURI (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */
  193. NS_IMETHODIMP nsIOService::NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
  194. {
  195. return NS_ERROR_NOT_IMPLEMENTED;
  196. }
  197. /* nsIURI newFileURI (in nsIFile aFile); */
  198. NS_IMETHODIMP nsIOService::NewFileURI(nsIFile *aFile, nsIURI **_retval)
  199. {
  200. return NS_ERROR_NOT_IMPLEMENTED;
  201. }
  202. /* nsIChannel newChannelFromURI (in nsIURI aURI); */
  203. NS_IMETHODIMP nsIOService::NewChannelFromURI(nsIURI *aURI, nsIChannel **_retval)
  204. {
  205. return NS_ERROR_NOT_IMPLEMENTED;
  206. }
  207. /* nsIChannel newChannel (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */
  208. NS_IMETHODIMP nsIOService::NewChannel(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval)
  209. {
  210. return NS_ERROR_NOT_IMPLEMENTED;
  211. }
  212. /* attribute boolean offline; */
  213. NS_IMETHODIMP nsIOService::GetOffline(PRBool *aOffline)
  214. {
  215. return NS_ERROR_NOT_IMPLEMENTED;
  216. }
  217. NS_IMETHODIMP nsIOService::SetOffline(PRBool aOffline)
  218. {
  219. return NS_ERROR_NOT_IMPLEMENTED;
  220. }
  221. /* boolean allowPort (in long aPort, in string aScheme); */
  222. NS_IMETHODIMP nsIOService::AllowPort(PRInt32 aPort, const char *aScheme, PRBool *_retval)
  223. {
  224. return NS_ERROR_NOT_IMPLEMENTED;
  225. }
  226. /* ACString extractScheme (in AUTF8String urlString); */
  227. NS_IMETHODIMP nsIOService::ExtractScheme(const nsACString & urlString, nsACString & _retval)
  228. {
  229. return NS_ERROR_NOT_IMPLEMENTED;
  230. }
  231. /* End of implementation class template. */
  232. #endif
  233. #endif /* __gen_nsIIOService_h__ */