summaryrefslogtreecommitdiff
path: root/dom/webidl/MozWifiManager.webidl
blob: dd5aa593206d24fadf1eb437a4ff0a653bbe13ae (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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/* 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/. */

enum WifiWPSMethod {
  "pbc",
  "pin",
  "cancel"
};

enum ConnectionStatus {
  "connecting",
  "authenticating",
  "associated",
  "connected",
  "disconnected",
  "wps-timedout",
  "wps-failed",
  "wps-overlapped",
  "connectingfailed"
};

dictionary WifiWPSInfo {
  WifiWPSMethod method;
  DOMString? pin;
  DOMString? bssid;
};

dictionary NetworkProperties {
  DOMString ssid;
  long mode;
  long frequency;
  sequence<DOMString>? security;
  sequence<DOMString>? capabilities;
  boolean known;
  boolean connected;
  boolean hidden;
  DOMString bssid;
  DOMString signalStrength;
  long relSignalStrength;
  DOMString psk;
  DOMString wep;
  DOMString wep_key0;
  DOMString wep_key1;
  DOMString wep_key2;
  DOMString wep_key3;
  long wep_tx_keyidx;
  long priority;
  long scan_ssid;
  DOMString keyManagement;
  DOMString identity;
  DOMString password;
  DOMString auth_alg;
  DOMString phase1;
  DOMString phase2;
  DOMString eap;
  DOMString pin;
  boolean dontConnect;
  DOMString serverCertificate;
  DOMString subjectMatch;
  DOMString userCertificate;
};

[Constructor(optional NetworkProperties properties),
 JSImplementation="@mozilla.org/mozwifinetwork;1",
 Func="Navigator::HasWifiManagerSupport"]
interface MozWifiNetwork {
  readonly attribute DOMString ssid;
  readonly attribute long mode;
  readonly attribute long frequency;
  [Constant, Cached] readonly attribute sequence<DOMString>? security;
  [Constant, Cached] readonly attribute sequence<DOMString>? capabilities;
  readonly attribute boolean known;
  readonly attribute boolean connected;
  readonly attribute boolean hidden;

           attribute DOMString? bssid;
           attribute DOMString? signalStrength;
           attribute long? relSignalStrength;
           attribute DOMString? psk;
           attribute DOMString? wep;
           attribute DOMString? wep_key0;
           attribute DOMString? wep_key1;
           attribute DOMString? wep_key2;
           attribute DOMString? wep_key3;
           attribute long? wep_tx_keyidx;
           attribute long? priority;
           attribute long? scan_ssid;
           attribute DOMString? keyManagement;
           attribute DOMString? identity;
           attribute DOMString? password;
           attribute DOMString? auth_alg;
           attribute DOMString? phase1;
           attribute DOMString? phase2;
           attribute DOMString? eap;
           attribute DOMString? pin;
           attribute boolean? dontConnect;
           attribute DOMString? serverCertificate;
           attribute DOMString? subjectMatch;
           attribute DOMString? userCertificate;
};

[JSImplementation="@mozilla.org/mozwificonnection;1",
 ChromeOnly]
interface MozWifiConnection {
  readonly attribute ConnectionStatus status;
  readonly attribute MozWifiNetwork? network;
};

[JSImplementation="@mozilla.org/mozwificonnectioninfo;1",
 ChromeOnly]
interface MozWifiConnectionInfo {
  readonly attribute short signalStrength;
  readonly attribute short relSignalStrength;
  readonly attribute long linkSpeed;
  readonly attribute DOMString? ipAddress;
};

dictionary IPConfiguration {
  boolean enabled;
  DOMString ipaddr;
  DOMString proxy;
  short maskLength;
  DOMString gateway;
  DOMString dns1;
  DOMString dns2;
};

[JSImplementation="@mozilla.org/wifimanager;1",
 NavigatorProperty="mozWifiManager",
 Func="Navigator::HasWifiManagerSupport",
 UnsafeInPrerendering]
interface MozWifiManager : EventTarget {
  /**
   * Turn on/off wifi functionality.
   * @param enable true for enable, false for disable.
   * onsuccess: Wifi enable/disable successfully, including no status change.
   * onerror: Wifi enable/disable failed or prohibited.
   */
  DOMRequest setWifiEnabled(boolean enabled);

  /**
   * Returns the list of currently available networks.
   * onsuccess: We have obtained the current list of networks. request.value
   *            is an object whose property names are SSIDs and values are
   *            network objects.
   * onerror: We were unable to obtain a list of property names.
   */
  DOMRequest getNetworks();

  /**
   * Returns the list of networks known to the system that will be
   * automatically connected to if they're in range.
   * onsuccess: request.value is an object whose property names are
   *            SSIDs and values are network objects.
   * onerror: We were unable to obtain a list of known networks.
   */
  DOMRequest getKnownNetworks();

  /**
   * Takes one of the networks returned from getNetworks and tries to
   * connect to it.
   * @param network A network object with information about the network,
   *                such as the SSID, key management desired, etc.
   * onsuccess: We have started attempting to associate with the network.
   *            request.value is true.
   * onerror: We were unable to select the network. This most likely means a
   *          configuration error.
   */
  DOMRequest associate(MozWifiNetwork network);

  /**
   * Given a network, removes it from the list of networks that we'll
   * automatically connect to. In order to re-connect to the network, it is
   * necessary to call associate on it.
   * @param network A network object with the SSID of the network to remove.
   * onsuccess: We have removed this network. If we were previously
   *            connected to it, we have started reconnecting to the next
   *            network in the list.
   * onerror: We were unable to remove the network.
   */
  DOMRequest forget(MozWifiNetwork network);

  /**
   * Wi-Fi Protected Setup functionality.
   * @param detail WPS detail which has 'method' and 'pin' field.
   *               The possible method field values are:
   *                 - pbc: The Push Button Configuration.
   *                 - pin: The PIN configuration.
   *                 - cancel: Request to cancel WPS in progress.
   *               If method field is 'pin', 'pin' field can exist and has
   *               a PIN number.
   *               If method field is 'pin', 'bssid' field can exist and has
   *               a opposite BSSID.
   * onsuccess: We have successfully started/canceled wps.
   * onerror: We have failed to start/cancel wps.
   */
  DOMRequest wps(optional WifiWPSInfo detail);

  /**
   * Turn on/off wifi power saving mode.
   * @param enabled true or false.
   * onsuccess: We have successfully turn on/off wifi power saving mode.
   * onerror: We have failed to turn on/off wifi power saving mode.
   */
  DOMRequest setPowerSavingMode(boolean enabled);

  /**
   * Given a network, configure using static IP instead of running DHCP
   * @param network A network object with the SSID of the network to set static ip.
   * @param info info should have following field:
   *        - enabled True to enable static IP, false to use DHCP
   *        - ipaddr configured static IP address
   *        - proxy configured proxy server address
   *        - maskLength configured mask length
   *        - gateway configured gateway address
   *        - dns1 configured first DNS server address
   *        - dns2 configured seconf DNS server address
   * onsuccess: We have successfully configure the static ip mode.
   * onerror: We have failed to configure the static ip mode.
   */
  DOMRequest setStaticIpMode(MozWifiNetwork network, optional IPConfiguration info);

  /**
   * Given a network, configure http proxy when using wifi.
   * @param network A network object with the SSID of the network to set http proxy.
   * @param info info should have following field:
   *        - httpProxyHost ip address of http proxy.
   *        - httpProxyPort port of http proxy, set 0 to use default port 8080.
   *        set info to null to clear http proxy.
   * onsuccess: We have successfully configure http proxy.
   * onerror: We have failed to configure http proxy.
   */
  DOMRequest setHttpProxy(MozWifiNetwork network, any info);

  /**
   * Import a certificate file, only support CA certificate now.
   * @param certBlob A Blob object containing raw data of certificate to be imported.
   *                 Supported format: binary/base64 encoded DER certificates.
   *                                   (.der/.crt/.cer/.pem)
   *                 Cause error if importing certificates already imported.
   * @param certPassword Password of certificate.
   * @param certNickname User assigned nickname for imported certificate.
   *                     Nickname must be unique, it causes error on redundant nickname.
   * onsuccess: We have successfully imported certificate. request.result is an
   *            object, containing information of imported CA:
   *            {
   *              nickname:  Nickname of imported CA, String.
   *              usage:     Supported usage of imported CA, Array of String,
   *                         includes: "ServerCert".
   *            }
   * onerror: We have failed to import certificate.
   */
  DOMRequest importCert(Blob certBlob,
                        DOMString certPassword,
                        DOMString certNickname);

  /**
   * Get list of imported WIFI certificates.
   * onsuccess: We have successfully gotten imported certificate list.
   *            request.result is an object using nickname as key, array of usage
   *            string as value.
   *            request.result[USAGE] = [CA_NICKNAME1, CA_NICKNAME2, ...]
   *            USAGE string includes: "ServerCert".
   * onerror: We have failed to list certificate.
   */
  DOMRequest getImportedCerts();

  /**
   * Delete an imported certificate.
   * @param certNickname Nickname of imported to be deleted.
   * onsuccess: We have successfully deleted certificate.
   * onerror: We have failed to delete certificate.
   */
  DOMRequest deleteCert(DOMString certNickname);

  /**
   * Returns whether or not wifi is currently enabled.
   */
  readonly attribute boolean enabled;

  /**
   * Returns the MAC address of the wifi adapter.
   */
  readonly attribute DOMString macAddress;

  /**
   * An non-null object containing the following information:
   *  - status ("disconnected", "connecting", "associated", "connected")
   *  - network
   *
   *  Note that the object returned is read only. Any changes required must
   *  be done by calling other APIs.
   */
  readonly attribute MozWifiConnection connection;

  /**
   * A connectionInformation object with the same information found in an
   * MozWifiConnectionInfoEvent (but without the network).
   * If we are not currently connected to a network, this will be null.
   */
  readonly attribute MozWifiConnectionInfo? connectionInformation;

  /**
   * Capabilities of Wifi.
   */
  readonly attribute MozWifiCapabilities? capabilities;

  /**
   * State notification listeners. These all take an
   * MozWifiStatusChangeEvent with the new status and a network (which may be
   * null).
   *
   * The possible statuses are:
   *   - connecting: Fires when we start the process of connecting to a
   *                 network.
   *   - associated: Fires when we have connected to an access point but do
   *                 not yet have an IP address.
   *   - connected: Fires once we are fully connected to an access point and
   *                can access the internet.
   *   - disconnected: Fires when we either fail to connect to an access
   *                   point (transition: associated -> disconnected) or
   *                   when we were connected to a network but have
   *                   disconnected for any reason (transition: connected ->
   *                   disconnected).
   */
  attribute EventHandler onstatuschange;

  /**
   * An event listener that is called with information about the signal
   * strength and link speed every 5 seconds.
   */
  attribute EventHandler onconnectioninfoupdate;

  /**
   * These two events fire when the wifi system is brought online or taken
   * offline.
   */
  attribute EventHandler onenabled;
  attribute EventHandler ondisabled;

  /**
   * An event listener that is called with information about the number
   * of wifi stations connected to wifi hotspot every 5 seconds.
   */
  attribute EventHandler onstationinfoupdate;
};