summaryrefslogtreecommitdiffstats
path: root/dom/webidl/MozWifiP2pManager.webidl
blob: 58ac1f7bed71e5f3b71fb70e25dc07d2b49b67fd (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
/* 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 WPSMethod {
  "pbc",
  "keypad",
  "display"
};

dictionary WPSInfo {
  WPSMethod method;
  DOMString pin;
};

[JSImplementation="@mozilla.org/wifip2pgroupowner;1",
 Func="Navigator::HasWifiManagerSupport"]
interface MozWifiP2pGroupOwner {
  readonly attribute DOMString groupName;
  readonly attribute DOMString macAddress;
  readonly attribute DOMString ipAddress;
  readonly attribute DOMString passphrase;
  readonly attribute DOMString ssid;
  readonly attribute any wpsCapabilities;
  readonly attribute unsigned long freq;
  readonly attribute boolean isLocal;
};

[JSImplementation="@mozilla.org/wifip2pmanager;1",
 NavigatorProperty="mozWifiP2pManager",
 Func="Navigator::HasWifiManagerSupport"]
interface MozWifiP2pManager : EventTarget
{
  /**
   * Enable/Disable wifi direct scan.
   *
   * onsuccess: Succeeded in starting/stopping wifi direct scan.
   * onerror:   Failed to start/stop wifi direct scan.
   *
   */
  DOMRequest setScanEnabled(boolean enabled);

  /**
   * Connect to a peer with given configuration.
   *
   * @param address The peer MAC address we are going to connect.
   * @param wpsMethod The WPS method we want to use.
   * @param goIntent Number from 0 ~ 15 to indicate how much we want to be
   *                 the group owner.
   *
   * onsuccess: Succeeded in issueing a 'connect' request. It doesn't mean we
   *            have connected to the peer.
   *
   * onerror:   Failed to issue a 'connect' request, probably due to an
   *            invalid peer address, unsupported wps method or any
   *            preliminary error.
   *
   **/
  DOMRequest connect(DOMString address, WPSMethod wpsMethod, optional byte goIntent);

  /**
   * Disconnect with a peer.
   *
   * @param address The mac address of the peer.
   *
   * onsuccess: Succeeded to issue a 'disconnect' request. It doesn't mean we
   *            have disconnected with the peer.
   *
   * onerror:   Failed to issue a 'disconnect' request, probably due to the
   *            invalid peer address or any preliminary error.
   *
   */
  DOMRequest disconnect(DOMString address);

  /**
   * Get peer list
   *
   * onsuccess: Command success, req.result contains an array of peer objects.
   * onerror: Command failed.
   *
   * Peer object format:
   *   .address          MAC address of the peer (string)
   *   .name             the peer's device name (string)
   *   .isGroupOwner     if the peer is the group owner (boolean)
   *   .wpsCapabilities  array of the supported |WPSMethod|
   *   .connectionStatus one of { "disconnected", "connecting", "connected", "disconnecting" }
   *
   */
  DOMRequest getPeerList();

  /**
   * Set pairing confirmation result.
   *
   * @param accepted Boolean to indicate whether we accepted the request or not.
   * @param pin The user input pin number if the wps method is keypad.
   *
   * onsuccess: Command succeeded.
   * onerror:   Command failed.
   *
   */
  DOMRequest setPairingConfirmation(boolean accepted, optional DOMString pin);

  /**
   * Set device name.
   *
   * @param devieName The new device name we are going to set.
   *
   * onsuccess: Command succeeded.
   * onerror:   Command failed.
   *
   */
  DOMRequest setDeviceName(DOMString deviceName);

  /**
   * Returns if Wifi Direct is enabled.
   *
   */
  readonly attribute boolean enabled;

  /**
   * The current group owner, null if none.
   */
  readonly attribute MozWifiP2pGroupOwner? groupOwner;

  /**
   * An event listener that is called whenever the Wifi Direct peer list is
   * updated. Use getPeerList() to get the up-to-date peer list.
   */
  attribute EventHandler onpeerinfoupdate;

  /**
   * An event listener that is called whenever Wifi Direct status changed.
   * The address of the changed peer will be stored in event.peerList.
   * See MozWifiP2pStatusChangeEvent.webidl.
   */
  attribute EventHandler onstatuschange;

  /**
   * An event listener that is called whenever Wifi Direct is enabled.
   */
  attribute EventHandler onenabled;

  /**
   * An event listener that is called whenever Wifi Direct is disabled.
   */
  attribute EventHandler ondisabled;
};