nsIDNSServiceDiscovery.idl 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsISupports.idl"
  5. interface nsICancelable;
  6. interface nsIPropertyBag2;
  7. /**
  8. * Service information
  9. */
  10. [scriptable, uuid(670ed0f9-2fa5-4544-bf1e-ea58ac179374)]
  11. interface nsIDNSServiceInfo : nsISupports
  12. {
  13. /**
  14. * The host name of the service. (E.g. "Android.local.")
  15. * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
  16. */
  17. attribute AUTF8String host;
  18. /**
  19. * The IP address of the service.
  20. * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
  21. */
  22. attribute AUTF8String address;
  23. /**
  24. * The port number of the service. (E.g. 80)
  25. * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
  26. */
  27. attribute unsigned short port;
  28. /**
  29. * The service name of the service for display. (E.g. "My TV")
  30. * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
  31. */
  32. attribute AUTF8String serviceName;
  33. /**
  34. * The type of the service. (E.g. "_http._tcp")
  35. * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
  36. */
  37. attribute AUTF8String serviceType;
  38. /**
  39. * The domain name of the service. (E.g. "local.")
  40. * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
  41. */
  42. attribute AUTF8String domainName;
  43. /**
  44. * The attributes of the service.
  45. */
  46. attribute nsIPropertyBag2 attributes;
  47. };
  48. /**
  49. * The callback interface for service discovery
  50. */
  51. [scriptable, uuid(3025b7f2-97bb-435b-b43d-26731b3f5fc4)]
  52. interface nsIDNSServiceDiscoveryListener : nsISupports
  53. {
  54. /**
  55. * Callback when the discovery begins.
  56. * @param aServiceType
  57. * the service type of |startDiscovery|.
  58. */
  59. void onDiscoveryStarted(in AUTF8String aServiceType);
  60. /**
  61. * Callback when the discovery ends.
  62. * @param aServiceType
  63. * the service type of |startDiscovery|.
  64. */
  65. void onDiscoveryStopped(in AUTF8String aServiceType);
  66. /**
  67. * Callback when the a service is found.
  68. * @param aServiceInfo
  69. * the info about the found service, where |serviceName|, |aServiceType|, and |domainName| are set.
  70. */
  71. void onServiceFound(in nsIDNSServiceInfo aServiceInfo);
  72. /**
  73. * Callback when the a service is lost.
  74. * @param aServiceInfo
  75. * the info about the lost service, where |serviceName|, |aServiceType|, and |domainName| are set.
  76. */
  77. void onServiceLost(in nsIDNSServiceInfo aServiceInfo);
  78. /**
  79. * Callback when the discovery cannot start.
  80. * @param aServiceType
  81. * the service type of |startDiscovery|.
  82. * @param aErrorCode
  83. * the error code.
  84. */
  85. void onStartDiscoveryFailed(in AUTF8String aServiceType, in long aErrorCode);
  86. /**
  87. * Callback when the discovery cannot stop.
  88. * @param aServiceType
  89. * the service type of |startDiscovery|.
  90. * @param aErrorCode
  91. * the error code.
  92. */
  93. void onStopDiscoveryFailed(in AUTF8String aServiceType, in long aErrorCode);
  94. };
  95. /**
  96. * The callback interface for service registration
  97. */
  98. [scriptable, uuid(e165e4be-abf4-4963-a66d-ed3ca116e5e4)]
  99. interface nsIDNSRegistrationListener : nsISupports
  100. {
  101. const long ERROR_SERVICE_NOT_RUNNING = -65563;
  102. /**
  103. * Callback when the service is registered successfully.
  104. * @param aServiceInfo
  105. * the info about the registered service,
  106. * where |serviceName|, |aServiceType|, and |domainName| are set.
  107. */
  108. void onServiceRegistered(in nsIDNSServiceInfo aServiceInfo);
  109. /**
  110. * Callback when the service is unregistered successfully.
  111. * @param aServiceInfo
  112. * the info about the unregistered service.
  113. */
  114. void onServiceUnregistered(in nsIDNSServiceInfo aServiceInfo);
  115. /**
  116. * Callback when the service cannot be registered.
  117. * @param aServiceInfo
  118. * the info about the service to be registered.
  119. * @param aErrorCode
  120. * the error code.
  121. */
  122. void onRegistrationFailed(in nsIDNSServiceInfo aServiceInfo, in long aErrorCode);
  123. /**
  124. * Callback when the service cannot be unregistered.
  125. * @param aServiceInfo
  126. * the info about the registered service.
  127. * @param aErrorCode
  128. * the error code.
  129. */
  130. void onUnregistrationFailed(in nsIDNSServiceInfo aServiceInfo, in long aErrorCode);
  131. };
  132. /**
  133. * The callback interface for service resolve
  134. */
  135. [scriptable, uuid(24ee6408-648e-421d-accf-c6e5adeccf97)]
  136. interface nsIDNSServiceResolveListener : nsISupports
  137. {
  138. /**
  139. * Callback when the service is resolved successfully.
  140. * @param aServiceInfo
  141. * the info about the resolved service, where |host| and |port| are set.
  142. */
  143. void onServiceResolved(in nsIDNSServiceInfo aServiceInfo);
  144. /**
  145. * Callback when the service cannot be resolved.
  146. * @param aServiceInfo
  147. * the info about the service to be resolved.
  148. * @param aErrorCode
  149. * the error code.
  150. */
  151. void onResolveFailed(in nsIDNSServiceInfo aServiceInfo, in long aErrorCode);
  152. };
  153. /**
  154. * The interface for DNS service discovery/registration/resolve
  155. */
  156. [scriptable, uuid(6487899b-beb1-455a-ba65-e4fd465066d7)]
  157. interface nsIDNSServiceDiscovery : nsISupports
  158. {
  159. /**
  160. * Browse for instances of a service.
  161. * @param aServiceType
  162. * the service type to be discovered, E.g. "_http._tcp".
  163. * @param aListener
  164. * callback interface for discovery notifications.
  165. * @return An object that can be used to cancel the service discovery.
  166. */
  167. nsICancelable startDiscovery(in AUTF8String aServiceType, in nsIDNSServiceDiscoveryListener aListener);
  168. /**
  169. * Register a service that is discovered via |startDiscovery| and |resolveService| calls.
  170. * @param aServiceInfo
  171. * the service information to be registered.
  172. * |port| and |aServiceType| are required attributes.
  173. * @param aListener
  174. * callback interface for registration notifications.
  175. * @return An object that can be used to cancel the service registration.
  176. */
  177. nsICancelable registerService(in nsIDNSServiceInfo aServiceInfo, in nsIDNSRegistrationListener aListener);
  178. /**
  179. * Resolve a service name discovered via |startDiscovery| to a target host name, port number.
  180. * @param aServiceInfo
  181. * the service information to be registered.
  182. * |serviceName|, |aServiceType|, and |domainName| are required attributes as reported to the |onServiceFound| callback.
  183. * @param aListener
  184. * callback interface for registration notifications.
  185. */
  186. void resolveService(in nsIDNSServiceInfo aServiceInfo, in nsIDNSServiceResolveListener aListener);
  187. };
  188. %{ C++
  189. #define DNSSERVICEDISCOVERY_CONTRACT_ID \
  190. "@mozilla.org/toolkit/components/mdnsresponder/dns-sd;1"
  191. #define DNSSERVICEINFO_CONTRACT_ID \
  192. "@mozilla.org/toolkit/components/mdnsresponder/dns-info;1"
  193. %}