Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | enum WifiWPSMethod { |
michael@0 | 6 | "pbc", |
michael@0 | 7 | "pin", |
michael@0 | 8 | "cancel" |
michael@0 | 9 | }; |
michael@0 | 10 | |
michael@0 | 11 | enum ConnectionStatus { |
michael@0 | 12 | "connecting", |
michael@0 | 13 | "associated", |
michael@0 | 14 | "connected", |
michael@0 | 15 | "disconnected", |
michael@0 | 16 | "wps-timeout", |
michael@0 | 17 | "wps-failed", |
michael@0 | 18 | "wps-overlapped", |
michael@0 | 19 | "connectingfailed" |
michael@0 | 20 | }; |
michael@0 | 21 | |
michael@0 | 22 | dictionary WifiWPSInfo { |
michael@0 | 23 | WifiWPSMethod method; |
michael@0 | 24 | DOMString? pin; |
michael@0 | 25 | DOMString? bssid; |
michael@0 | 26 | }; |
michael@0 | 27 | |
michael@0 | 28 | dictionary NetworkProperties { |
michael@0 | 29 | DOMString ssid; |
michael@0 | 30 | sequence<DOMString>? security; |
michael@0 | 31 | sequence<DOMString>? capabilities; |
michael@0 | 32 | boolean known; |
michael@0 | 33 | boolean connected; |
michael@0 | 34 | boolean hidden; |
michael@0 | 35 | DOMString bssid; |
michael@0 | 36 | DOMString signalStrength; |
michael@0 | 37 | long relSignalStrength; |
michael@0 | 38 | DOMString psk; |
michael@0 | 39 | DOMString wep; |
michael@0 | 40 | DOMString wep_key0; |
michael@0 | 41 | DOMString wep_key1; |
michael@0 | 42 | DOMString wep_key2; |
michael@0 | 43 | DOMString wep_key3; |
michael@0 | 44 | long wep_tx_keyidx; |
michael@0 | 45 | long priority; |
michael@0 | 46 | long scan_ssid; |
michael@0 | 47 | DOMString keyManagement; |
michael@0 | 48 | DOMString identity; |
michael@0 | 49 | DOMString password; |
michael@0 | 50 | DOMString auth_alg; |
michael@0 | 51 | DOMString phase1; |
michael@0 | 52 | DOMString phase2; |
michael@0 | 53 | DOMString eap; |
michael@0 | 54 | DOMString pin; |
michael@0 | 55 | boolean dontConnect; |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | [Constructor(optional NetworkProperties properties), |
michael@0 | 59 | JSImplementation="@mozilla.org/mozwifinetwork;1", |
michael@0 | 60 | Func="Navigator::HasWifiManagerSupport"] |
michael@0 | 61 | interface MozWifiNetwork { |
michael@0 | 62 | readonly attribute DOMString ssid; |
michael@0 | 63 | [Constant, Cached] readonly attribute sequence<DOMString>? security; |
michael@0 | 64 | [Constant, Cached] readonly attribute sequence<DOMString>? capabilities; |
michael@0 | 65 | readonly attribute boolean known; |
michael@0 | 66 | readonly attribute boolean connected; |
michael@0 | 67 | readonly attribute boolean hidden; |
michael@0 | 68 | |
michael@0 | 69 | attribute DOMString? bssid; |
michael@0 | 70 | attribute DOMString? signalStrength; |
michael@0 | 71 | attribute long? relSignalStrength; |
michael@0 | 72 | attribute DOMString? psk; |
michael@0 | 73 | attribute DOMString? wep; |
michael@0 | 74 | attribute DOMString? wep_key0; |
michael@0 | 75 | attribute DOMString? wep_key1; |
michael@0 | 76 | attribute DOMString? wep_key2; |
michael@0 | 77 | attribute DOMString? wep_key3; |
michael@0 | 78 | attribute long? wep_tx_keyidx; |
michael@0 | 79 | attribute long? priority; |
michael@0 | 80 | attribute long? scan_ssid; |
michael@0 | 81 | attribute DOMString? keyManagement; |
michael@0 | 82 | attribute DOMString? identity; |
michael@0 | 83 | attribute DOMString? password; |
michael@0 | 84 | attribute DOMString? auth_alg; |
michael@0 | 85 | attribute DOMString? phase1; |
michael@0 | 86 | attribute DOMString? phase2; |
michael@0 | 87 | attribute DOMString? eap; |
michael@0 | 88 | attribute DOMString? pin; |
michael@0 | 89 | attribute boolean? dontConnect; |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | [JSImplementation="@mozilla.org/mozwificonnection;1", |
michael@0 | 93 | ChromeOnly] |
michael@0 | 94 | interface MozWifiConnection { |
michael@0 | 95 | readonly attribute ConnectionStatus status; |
michael@0 | 96 | readonly attribute MozWifiNetwork? network; |
michael@0 | 97 | }; |
michael@0 | 98 | |
michael@0 | 99 | [JSImplementation="@mozilla.org/mozwificonnectioninfo;1", |
michael@0 | 100 | ChromeOnly] |
michael@0 | 101 | interface MozWifiConnectionInfo { |
michael@0 | 102 | readonly attribute short signalStrength; |
michael@0 | 103 | readonly attribute short relSignalStrength; |
michael@0 | 104 | readonly attribute long linkSpeed; |
michael@0 | 105 | readonly attribute DOMString? ipAddress; |
michael@0 | 106 | }; |
michael@0 | 107 | |
michael@0 | 108 | dictionary IPConfiguration { |
michael@0 | 109 | boolean enabled; |
michael@0 | 110 | DOMString ipaddr; |
michael@0 | 111 | DOMString proxy; |
michael@0 | 112 | short maskLength; |
michael@0 | 113 | DOMString gateway; |
michael@0 | 114 | DOMString dns1; |
michael@0 | 115 | DOMString dns2; |
michael@0 | 116 | }; |
michael@0 | 117 | |
michael@0 | 118 | [JSImplementation="@mozilla.org/wifimanager;1", |
michael@0 | 119 | NavigatorProperty="mozWifiManager", |
michael@0 | 120 | Func="Navigator::HasWifiManagerSupport"] |
michael@0 | 121 | interface MozWifiManager : EventTarget { |
michael@0 | 122 | /** |
michael@0 | 123 | * Returns the list of currently available networks. |
michael@0 | 124 | * onsuccess: We have obtained the current list of networks. request.value |
michael@0 | 125 | * is an object whose property names are SSIDs and values are |
michael@0 | 126 | * network objects. |
michael@0 | 127 | * onerror: We were unable to obtain a list of property names. |
michael@0 | 128 | */ |
michael@0 | 129 | DOMRequest getNetworks(); |
michael@0 | 130 | |
michael@0 | 131 | /** |
michael@0 | 132 | * Returns the list of networks known to the system that will be |
michael@0 | 133 | * automatically connected to if they're in range. |
michael@0 | 134 | * onsuccess: request.value is an object whose property names are |
michael@0 | 135 | * SSIDs and values are network objects. |
michael@0 | 136 | * onerror: We were unable to obtain a list of known networks. |
michael@0 | 137 | */ |
michael@0 | 138 | DOMRequest getKnownNetworks(); |
michael@0 | 139 | |
michael@0 | 140 | /** |
michael@0 | 141 | * Takes one of the networks returned from getNetworks and tries to |
michael@0 | 142 | * connect to it. |
michael@0 | 143 | * @param network A network object with information about the network, |
michael@0 | 144 | * such as the SSID, key management desired, etc. |
michael@0 | 145 | * onsuccess: We have started attempting to associate with the network. |
michael@0 | 146 | * request.value is true. |
michael@0 | 147 | * onerror: We were unable to select the network. This most likely means a |
michael@0 | 148 | * configuration error. |
michael@0 | 149 | */ |
michael@0 | 150 | DOMRequest associate(MozWifiNetwork network); |
michael@0 | 151 | |
michael@0 | 152 | /** |
michael@0 | 153 | * Given a network, removes it from the list of networks that we'll |
michael@0 | 154 | * automatically connect to. In order to re-connect to the network, it is |
michael@0 | 155 | * necessary to call associate on it. |
michael@0 | 156 | * @param network A network object with the SSID of the network to remove. |
michael@0 | 157 | * onsuccess: We have removed this network. If we were previously |
michael@0 | 158 | * connected to it, we have started reconnecting to the next |
michael@0 | 159 | * network in the list. |
michael@0 | 160 | * onerror: We were unable to remove the network. |
michael@0 | 161 | */ |
michael@0 | 162 | DOMRequest forget(MozWifiNetwork network); |
michael@0 | 163 | |
michael@0 | 164 | /** |
michael@0 | 165 | * Wi-Fi Protected Setup functionality. |
michael@0 | 166 | * @param detail WPS detail which has 'method' and 'pin' field. |
michael@0 | 167 | * The possible method field values are: |
michael@0 | 168 | * - pbc: The Push Button Configuration. |
michael@0 | 169 | * - pin: The PIN configuration. |
michael@0 | 170 | * - cancel: Request to cancel WPS in progress. |
michael@0 | 171 | * If method field is 'pin', 'pin' field can exist and has |
michael@0 | 172 | * a PIN number. |
michael@0 | 173 | * If method field is 'pin', 'bssid' field can exist and has |
michael@0 | 174 | * a opposite BSSID. |
michael@0 | 175 | * onsuccess: We have successfully started/canceled wps. |
michael@0 | 176 | * onerror: We have failed to start/cancel wps. |
michael@0 | 177 | */ |
michael@0 | 178 | DOMRequest wps(optional WifiWPSInfo detail); |
michael@0 | 179 | |
michael@0 | 180 | /** |
michael@0 | 181 | * Turn on/off wifi power saving mode. |
michael@0 | 182 | * @param enabled true or false. |
michael@0 | 183 | * onsuccess: We have successfully turn on/off wifi power saving mode. |
michael@0 | 184 | * onerror: We have failed to turn on/off wifi power saving mode. |
michael@0 | 185 | */ |
michael@0 | 186 | DOMRequest setPowerSavingMode(boolean enabled); |
michael@0 | 187 | |
michael@0 | 188 | /** |
michael@0 | 189 | * Given a network, configure using static IP instead of running DHCP |
michael@0 | 190 | * @param network A network object with the SSID of the network to set static ip. |
michael@0 | 191 | * @param info info should have following field: |
michael@0 | 192 | * - enabled True to enable static IP, false to use DHCP |
michael@0 | 193 | * - ipaddr configured static IP address |
michael@0 | 194 | * - proxy configured proxy server address |
michael@0 | 195 | * - maskLength configured mask length |
michael@0 | 196 | * - gateway configured gateway address |
michael@0 | 197 | * - dns1 configured first DNS server address |
michael@0 | 198 | * - dns2 configured seconf DNS server address |
michael@0 | 199 | * onsuccess: We have successfully configure the static ip mode. |
michael@0 | 200 | * onerror: We have failed to configure the static ip mode. |
michael@0 | 201 | */ |
michael@0 | 202 | DOMRequest setStaticIpMode(MozWifiNetwork network, optional IPConfiguration info); |
michael@0 | 203 | |
michael@0 | 204 | /** |
michael@0 | 205 | * Given a network, configure http proxy when using wifi. |
michael@0 | 206 | * @param network A network object with the SSID of the network to set http proxy. |
michael@0 | 207 | * @param info info should have following field: |
michael@0 | 208 | * - httpProxyHost ip address of http proxy. |
michael@0 | 209 | * - httpProxyPort port of http proxy, set 0 to use default port 8080. |
michael@0 | 210 | * set info to null to clear http proxy. |
michael@0 | 211 | * onsuccess: We have successfully configure http proxy. |
michael@0 | 212 | * onerror: We have failed to configure http proxy. |
michael@0 | 213 | */ |
michael@0 | 214 | DOMRequest setHttpProxy(MozWifiNetwork network, any info); |
michael@0 | 215 | |
michael@0 | 216 | /** |
michael@0 | 217 | * Returns whether or not wifi is currently enabled. |
michael@0 | 218 | */ |
michael@0 | 219 | readonly attribute boolean enabled; |
michael@0 | 220 | |
michael@0 | 221 | /** |
michael@0 | 222 | * Returns the MAC address of the wifi adapter. |
michael@0 | 223 | */ |
michael@0 | 224 | readonly attribute DOMString macAddress; |
michael@0 | 225 | |
michael@0 | 226 | /** |
michael@0 | 227 | * An non-null object containing the following information: |
michael@0 | 228 | * - status ("disconnected", "connecting", "associated", "connected") |
michael@0 | 229 | * - network |
michael@0 | 230 | * |
michael@0 | 231 | * Note that the object returned is read only. Any changes required must |
michael@0 | 232 | * be done by calling other APIs. |
michael@0 | 233 | */ |
michael@0 | 234 | readonly attribute MozWifiConnection connection; |
michael@0 | 235 | |
michael@0 | 236 | /** |
michael@0 | 237 | * A connectionInformation object with the same information found in an |
michael@0 | 238 | * nsIDOMMozWifiConnectionInfoEvent (but without the network). |
michael@0 | 239 | * If we are not currently connected to a network, this will be null. |
michael@0 | 240 | */ |
michael@0 | 241 | readonly attribute MozWifiConnectionInfo? connectionInformation; |
michael@0 | 242 | |
michael@0 | 243 | /** |
michael@0 | 244 | * State notification listeners. These all take an |
michael@0 | 245 | * nsIDOMMozWifiStatusChangeEvent with the new status and a network (which |
michael@0 | 246 | * may be null). |
michael@0 | 247 | * |
michael@0 | 248 | * The possible statuses are: |
michael@0 | 249 | * - connecting: Fires when we start the process of connecting to a |
michael@0 | 250 | * network. |
michael@0 | 251 | * - associated: Fires when we have connected to an access point but do |
michael@0 | 252 | * not yet have an IP address. |
michael@0 | 253 | * - connected: Fires once we are fully connected to an access point and |
michael@0 | 254 | * can access the internet. |
michael@0 | 255 | * - disconnected: Fires when we either fail to connect to an access |
michael@0 | 256 | * point (transition: associated -> disconnected) or |
michael@0 | 257 | * when we were connected to a network but have |
michael@0 | 258 | * disconnected for any reason (transition: connected -> |
michael@0 | 259 | * disconnected). |
michael@0 | 260 | */ |
michael@0 | 261 | attribute EventHandler onstatuschange; |
michael@0 | 262 | |
michael@0 | 263 | /** |
michael@0 | 264 | * An event listener that is called with information about the signal |
michael@0 | 265 | * strength and link speed every 5 seconds. |
michael@0 | 266 | */ |
michael@0 | 267 | attribute EventHandler onconnectionInfoUpdate; |
michael@0 | 268 | |
michael@0 | 269 | /** |
michael@0 | 270 | * These two events fire when the wifi system is brought online or taken |
michael@0 | 271 | * offline. |
michael@0 | 272 | */ |
michael@0 | 273 | attribute EventHandler onenabled; |
michael@0 | 274 | attribute EventHandler ondisabled; |
michael@0 | 275 | }; |