nsIProtocolHandler.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM c:/mozilla/netwerk/base/public/nsIProtocolHandler.idl
  3. */
  4. #ifndef __gen_nsIProtocolHandler_h__
  5. #define __gen_nsIProtocolHandler_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 nsIURI; /* forward declaration */
  14. class nsIChannel; /* forward declaration */
  15. /* starting interface: nsIProtocolHandler */
  16. #define NS_IPROTOCOLHANDLER_IID_STR "15fd6940-8ea7-11d3-93ad-00104ba0fd40"
  17. #define NS_IPROTOCOLHANDLER_IID \
  18. {0x15fd6940, 0x8ea7, 0x11d3, \
  19. { 0x93, 0xad, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40 }}
  20. /**
  21. * nsIProtocolHandler
  22. *
  23. * @status FROZEN
  24. */
  25. class NS_NO_VTABLE nsIProtocolHandler : public nsISupports {
  26. public:
  27. NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPROTOCOLHANDLER_IID)
  28. /**
  29. * The scheme of this protocol (e.g., "file").
  30. */
  31. /* readonly attribute ACString scheme; */
  32. NS_IMETHOD GetScheme(nsACString & aScheme) = 0;
  33. /**
  34. * The default port is the port that this protocol normally uses.
  35. * If a port does not make sense for the protocol (e.g., "about:")
  36. * then -1 will be returned.
  37. */
  38. /* readonly attribute long defaultPort; */
  39. NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort) = 0;
  40. /**
  41. * Returns the protocol specific flags (see flag definitions below).
  42. */
  43. /* readonly attribute unsigned long protocolFlags; */
  44. NS_IMETHOD GetProtocolFlags(PRUint32 *aProtocolFlags) = 0;
  45. /**
  46. * Makes a URI object that is suitable for loading by this protocol,
  47. * where the URI string is given as an UTF-8 string. The caller may
  48. * provide the charset from which the URI string originated, so that
  49. * the URI string can be translated back to that charset (if necessary)
  50. * before communicating with, for example, the origin server of the URI
  51. * string. (Many servers do not support UTF-8 IRIs at the present time,
  52. * so we must be careful about tracking the native charset of the origin
  53. * server.)
  54. *
  55. * @param aSpec - the URI string in UTF-8 encoding. depending
  56. * on the protocol implementation, unicode character
  57. * sequences may or may not be %xx escaped.
  58. * @param aOriginCharset - the charset of the document from which this URI
  59. * string originated. this corresponds to the
  60. * charset that should be used when communicating
  61. * this URI to an origin server, for example. if
  62. * null, then UTF-8 encoding is assumed (i.e.,
  63. * no charset transformation from aSpec).
  64. * @param aBaseURI - if null, aSpec must specify an absolute URI.
  65. * otherwise, aSpec may be resolved relative
  66. * to aBaseURI, depending on the protocol.
  67. * If the protocol has no concept of relative
  68. * URI aBaseURI will simply be ignored.
  69. */
  70. /* nsIURI newURI (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */
  71. NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) = 0;
  72. /**
  73. * Constructs a new channel from the given URI for this protocol handler.
  74. */
  75. /* nsIChannel newChannel (in nsIURI aURI); */
  76. NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval) = 0;
  77. /**
  78. * Allows a protocol to override blacklisted ports.
  79. *
  80. * This method will be called when there is an attempt to connect to a port
  81. * that is blacklisted. For example, for most protocols, port 25 (Simple Mail
  82. * Transfer) is banned. When a URI containing this "known-to-do-bad-things"
  83. * port number is encountered, this function will be called to ask if the
  84. * protocol handler wants to override the ban.
  85. */
  86. /* boolean allowPort (in long port, in string scheme); */
  87. NS_IMETHOD AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) = 0;
  88. /**************************************************************************
  89. * Constants for the protocol flags (the first is the default mask, the
  90. * others are deviations):
  91. *
  92. * NOTE: Implementation must ignore any flags they do not understand.
  93. */
  94. /**
  95. * standard full URI with authority component and concept of relative
  96. * URIs (http, ftp, ...)
  97. */
  98. enum { URI_STD = 0U };
  99. /**
  100. * no concept of relative URIs (about, javascript, finger, ...)
  101. */
  102. enum { URI_NORELATIVE = 1U };
  103. /**
  104. * no authority component (file, ...)
  105. */
  106. enum { URI_NOAUTH = 2U };
  107. /**
  108. * This protocol handler can be proxied via a proxy (socks or http)
  109. * (e.g., irc, smtp, http, etc.). If the protocol supports transparent
  110. * proxying, the handler should implement nsIProxiedProtocolHandler.
  111. *
  112. * If it supports only HTTP proxying, then it need not support
  113. * nsIProxiedProtocolHandler, but should instead set the ALLOWS_PROXY_HTTP
  114. * flag (see below).
  115. *
  116. * @see nsIProxiedProtocolHandler
  117. */
  118. enum { ALLOWS_PROXY = 4U };
  119. /**
  120. * This protocol handler can be proxied using a http proxy (e.g., http,
  121. * ftp, etc.). nsIIOService::newChannelFromURI will feed URIs from this
  122. * protocol handler to the HTTP protocol handler instead. This flag is
  123. * ignored if ALLOWS_PROXY is not set.
  124. */
  125. enum { ALLOWS_PROXY_HTTP = 8U };
  126. };
  127. /* Use this macro when declaring classes that implement this interface. */
  128. #define NS_DECL_NSIPROTOCOLHANDLER \
  129. NS_IMETHOD GetScheme(nsACString & aScheme); \
  130. NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort); \
  131. NS_IMETHOD GetProtocolFlags(PRUint32 *aProtocolFlags); \
  132. NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval); \
  133. NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval); \
  134. NS_IMETHOD AllowPort(PRInt32 port, const char *scheme, PRBool *_retval); \
  135. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  136. #define NS_FORWARD_NSIPROTOCOLHANDLER(_to) \
  137. NS_IMETHOD GetScheme(nsACString & aScheme) { return _to GetScheme(aScheme); } \
  138. NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort) { return _to GetDefaultPort(aDefaultPort); } \
  139. NS_IMETHOD GetProtocolFlags(PRUint32 *aProtocolFlags) { return _to GetProtocolFlags(aProtocolFlags); } \
  140. NS_IMETHOD NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval) { return _to NewURI(aSpec, aOriginCharset, aBaseURI, _retval); } \
  141. NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval) { return _to NewChannel(aURI, _retval); } \
  142. NS_IMETHOD AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) { return _to AllowPort(port, scheme, _retval); } \
  143. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  144. #define NS_FORWARD_SAFE_NSIPROTOCOLHANDLER(_to) \
  145. NS_IMETHOD GetScheme(nsACString & aScheme) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetScheme(aScheme); } \
  146. NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDefaultPort(aDefaultPort); } \
  147. NS_IMETHOD GetProtocolFlags(PRUint32 *aProtocolFlags) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetProtocolFlags(aProtocolFlags); } \
  148. 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); } \
  149. NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewChannel(aURI, _retval); } \
  150. NS_IMETHOD AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->AllowPort(port, scheme, _retval); } \
  151. #if 0
  152. /* Use the code below as a template for the implementation class for this interface. */
  153. /* Header file */
  154. class nsProtocolHandler : public nsIProtocolHandler
  155. {
  156. public:
  157. NS_DECL_ISUPPORTS
  158. NS_DECL_NSIPROTOCOLHANDLER
  159. nsProtocolHandler();
  160. private:
  161. ~nsProtocolHandler();
  162. protected:
  163. /* additional members */
  164. };
  165. /* Implementation file */
  166. NS_IMPL_ISUPPORTS1(nsProtocolHandler, nsIProtocolHandler)
  167. nsProtocolHandler::nsProtocolHandler()
  168. {
  169. /* member initializers and constructor code */
  170. }
  171. nsProtocolHandler::~nsProtocolHandler()
  172. {
  173. /* destructor code */
  174. }
  175. /* readonly attribute ACString scheme; */
  176. NS_IMETHODIMP nsProtocolHandler::GetScheme(nsACString & aScheme)
  177. {
  178. return NS_ERROR_NOT_IMPLEMENTED;
  179. }
  180. /* readonly attribute long defaultPort; */
  181. NS_IMETHODIMP nsProtocolHandler::GetDefaultPort(PRInt32 *aDefaultPort)
  182. {
  183. return NS_ERROR_NOT_IMPLEMENTED;
  184. }
  185. /* readonly attribute unsigned long protocolFlags; */
  186. NS_IMETHODIMP nsProtocolHandler::GetProtocolFlags(PRUint32 *aProtocolFlags)
  187. {
  188. return NS_ERROR_NOT_IMPLEMENTED;
  189. }
  190. /* nsIURI newURI (in AUTF8String aSpec, in string aOriginCharset, in nsIURI aBaseURI); */
  191. NS_IMETHODIMP nsProtocolHandler::NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
  192. {
  193. return NS_ERROR_NOT_IMPLEMENTED;
  194. }
  195. /* nsIChannel newChannel (in nsIURI aURI); */
  196. NS_IMETHODIMP nsProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval)
  197. {
  198. return NS_ERROR_NOT_IMPLEMENTED;
  199. }
  200. /* boolean allowPort (in long port, in string scheme); */
  201. NS_IMETHODIMP nsProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
  202. {
  203. return NS_ERROR_NOT_IMPLEMENTED;
  204. }
  205. /* End of implementation class template. */
  206. #endif
  207. /**
  208. * Protocol handlers are registered with XPCOM under the following CONTRACTID prefix:
  209. */
  210. #define NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "@mozilla.org/network/protocol;1?name="
  211. /**
  212. * For example, "@mozilla.org/network/protocol;1?name=http"
  213. */
  214. #endif /* __gen_nsIProtocolHandler_h__ */