summaryrefslogtreecommitdiffstats
path: root/netwerk/dns/mdns/nsIDNSServiceDiscovery.idl
blob: 23c678ecccdbeded342e62272f819e93658f8155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsICancelable;
interface nsIPropertyBag2;

/**
 * Service information
 */
[scriptable, uuid(670ed0f9-2fa5-4544-bf1e-ea58ac179374)]
interface nsIDNSServiceInfo : nsISupports
{
  /**
   * The host name of the service. (E.g. "Android.local.")
   * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
   */
  attribute AUTF8String host;

  /**
   * The IP address of the service.
   * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
   */
  attribute AUTF8String address;

  /**
   * The port number of the service. (E.g. 80)
   * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
   */
  attribute unsigned short port;

  /**
   * The service name of the service for display. (E.g. "My TV")
   * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
   */
  attribute AUTF8String serviceName;

  /**
   * The type of the service. (E.g. "_http._tcp")
   * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
   */
  attribute AUTF8String serviceType;

  /**
   * The domain name of the service. (E.g. "local.")
   * @throws NS_ERROR_NOT_INITIALIZED when getting unset value.
   */
  attribute AUTF8String domainName;

  /**
   * The attributes of the service.
   */
  attribute nsIPropertyBag2 attributes;
};

/**
 * The callback interface for service discovery
 */
[scriptable, uuid(3025b7f2-97bb-435b-b43d-26731b3f5fc4)]
interface nsIDNSServiceDiscoveryListener : nsISupports
{
  /**
   * Callback when the discovery begins.
   * @param   aServiceType
   *          the service type of |startDiscovery|.
   */
  void onDiscoveryStarted(in AUTF8String aServiceType);

  /**
   * Callback when the discovery ends.
   * @param   aServiceType
   *          the service type of |startDiscovery|.
   */
  void onDiscoveryStopped(in AUTF8String aServiceType);

  /**
   * Callback when the a service is found.
   * @param   aServiceInfo
   *          the info about the found service, where |serviceName|, |aServiceType|, and |domainName| are set.
   */
  void onServiceFound(in nsIDNSServiceInfo aServiceInfo);

  /**
   * Callback when the a service is lost.
   * @param   aServiceInfo
   *          the info about the lost service, where |serviceName|, |aServiceType|, and |domainName| are set.
   */
  void onServiceLost(in nsIDNSServiceInfo aServiceInfo);

  /**
   * Callback when the discovery cannot start.
   * @param   aServiceType
   *          the service type of |startDiscovery|.
   * @param   aErrorCode
   *          the error code.
   */
  void onStartDiscoveryFailed(in AUTF8String aServiceType, in long aErrorCode);

  /**
   * Callback when the discovery cannot stop.
   * @param   aServiceType
   *          the service type of |startDiscovery|.
   * @param   aErrorCode
   *          the error code.
   */
  void onStopDiscoveryFailed(in AUTF8String aServiceType, in long aErrorCode);
};

/**
 * The callback interface for service registration
 */
[scriptable, uuid(e165e4be-abf4-4963-a66d-ed3ca116e5e4)]
interface nsIDNSRegistrationListener : nsISupports
{
  const long ERROR_SERVICE_NOT_RUNNING = -65563;

  /**
   * Callback when the service is registered successfully.
   * @param   aServiceInfo
   *          the info about the registered service,
   *          where |serviceName|, |aServiceType|, and |domainName| are set.
   */
  void onServiceRegistered(in nsIDNSServiceInfo aServiceInfo);

  /**
   * Callback when the service is unregistered successfully.
   * @param   aServiceInfo
   *          the info about the unregistered service.
   */
  void onServiceUnregistered(in nsIDNSServiceInfo aServiceInfo);

  /**
   * Callback when the service cannot be registered.
   * @param   aServiceInfo
   *          the info about the service to be registered.
   * @param   aErrorCode
   *          the error code.
   */
  void onRegistrationFailed(in nsIDNSServiceInfo aServiceInfo, in long aErrorCode);

  /**
   * Callback when the service cannot be unregistered.
   * @param   aServiceInfo
   *          the info about the registered service.
   * @param   aErrorCode
   *          the error code.
   */
  void onUnregistrationFailed(in nsIDNSServiceInfo aServiceInfo, in long aErrorCode);
};

/**
 * The callback interface for service resolve
 */
[scriptable, uuid(24ee6408-648e-421d-accf-c6e5adeccf97)]
interface nsIDNSServiceResolveListener : nsISupports
{
  /**
   * Callback when the service is resolved successfully.
   * @param   aServiceInfo
   *          the info about the resolved service, where |host| and |port| are set.
   */
  void onServiceResolved(in nsIDNSServiceInfo aServiceInfo);

  /**
   * Callback when the service cannot be resolved.
   * @param   aServiceInfo
   *          the info about the service to be resolved.
   * @param   aErrorCode
   *          the error code.
   */
  void onResolveFailed(in nsIDNSServiceInfo aServiceInfo, in long aErrorCode);
};

/**
 * The interface for DNS service discovery/registration/resolve
 */
[scriptable, uuid(6487899b-beb1-455a-ba65-e4fd465066d7)]
interface nsIDNSServiceDiscovery : nsISupports
{
  /**
   * Browse for instances of a service.
   * @param   aServiceType
   *          the service type to be discovered, E.g. "_http._tcp".
   * @param   aListener
   *          callback interface for discovery notifications.
   * @return  An object that can be used to cancel the service discovery.
   */
  nsICancelable startDiscovery(in AUTF8String aServiceType, in nsIDNSServiceDiscoveryListener aListener);

  /**
   * Register a service that is discovered via |startDiscovery| and |resolveService| calls.
   * @param   aServiceInfo
   *          the service information to be registered.
   *          |port| and |aServiceType| are required attributes.
   * @param   aListener
   *          callback interface for registration notifications.
   * @return  An object that can be used to cancel the service registration.
   */
  nsICancelable registerService(in nsIDNSServiceInfo aServiceInfo, in nsIDNSRegistrationListener aListener);

  /**
   * Resolve a service name discovered via |startDiscovery| to a target host name, port number.
   * @param   aServiceInfo
   *          the service information to be registered.
   *          |serviceName|, |aServiceType|, and |domainName| are required attributes as reported to the |onServiceFound| callback.
   * @param   aListener
   *          callback interface for registration notifications.
   */
  void resolveService(in nsIDNSServiceInfo aServiceInfo, in nsIDNSServiceResolveListener aListener);
};

%{ C++
#define DNSSERVICEDISCOVERY_CONTRACT_ID \
  "@mozilla.org/toolkit/components/mdnsresponder/dns-sd;1"
#define DNSSERVICEINFO_CONTRACT_ID \
  "@mozilla.org/toolkit/components/mdnsresponder/dns-info;1"
%}