michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: enum WifiWPSMethod { michael@0: "pbc", michael@0: "pin", michael@0: "cancel" michael@0: }; michael@0: michael@0: enum ConnectionStatus { michael@0: "connecting", michael@0: "associated", michael@0: "connected", michael@0: "disconnected", michael@0: "wps-timeout", michael@0: "wps-failed", michael@0: "wps-overlapped", michael@0: "connectingfailed" michael@0: }; michael@0: michael@0: dictionary WifiWPSInfo { michael@0: WifiWPSMethod method; michael@0: DOMString? pin; michael@0: DOMString? bssid; michael@0: }; michael@0: michael@0: dictionary NetworkProperties { michael@0: DOMString ssid; michael@0: sequence? security; michael@0: sequence? capabilities; michael@0: boolean known; michael@0: boolean connected; michael@0: boolean hidden; michael@0: DOMString bssid; michael@0: DOMString signalStrength; michael@0: long relSignalStrength; michael@0: DOMString psk; michael@0: DOMString wep; michael@0: DOMString wep_key0; michael@0: DOMString wep_key1; michael@0: DOMString wep_key2; michael@0: DOMString wep_key3; michael@0: long wep_tx_keyidx; michael@0: long priority; michael@0: long scan_ssid; michael@0: DOMString keyManagement; michael@0: DOMString identity; michael@0: DOMString password; michael@0: DOMString auth_alg; michael@0: DOMString phase1; michael@0: DOMString phase2; michael@0: DOMString eap; michael@0: DOMString pin; michael@0: boolean dontConnect; michael@0: }; michael@0: michael@0: [Constructor(optional NetworkProperties properties), michael@0: JSImplementation="@mozilla.org/mozwifinetwork;1", michael@0: Func="Navigator::HasWifiManagerSupport"] michael@0: interface MozWifiNetwork { michael@0: readonly attribute DOMString ssid; michael@0: [Constant, Cached] readonly attribute sequence? security; michael@0: [Constant, Cached] readonly attribute sequence? capabilities; michael@0: readonly attribute boolean known; michael@0: readonly attribute boolean connected; michael@0: readonly attribute boolean hidden; michael@0: michael@0: attribute DOMString? bssid; michael@0: attribute DOMString? signalStrength; michael@0: attribute long? relSignalStrength; michael@0: attribute DOMString? psk; michael@0: attribute DOMString? wep; michael@0: attribute DOMString? wep_key0; michael@0: attribute DOMString? wep_key1; michael@0: attribute DOMString? wep_key2; michael@0: attribute DOMString? wep_key3; michael@0: attribute long? wep_tx_keyidx; michael@0: attribute long? priority; michael@0: attribute long? scan_ssid; michael@0: attribute DOMString? keyManagement; michael@0: attribute DOMString? identity; michael@0: attribute DOMString? password; michael@0: attribute DOMString? auth_alg; michael@0: attribute DOMString? phase1; michael@0: attribute DOMString? phase2; michael@0: attribute DOMString? eap; michael@0: attribute DOMString? pin; michael@0: attribute boolean? dontConnect; michael@0: }; michael@0: michael@0: [JSImplementation="@mozilla.org/mozwificonnection;1", michael@0: ChromeOnly] michael@0: interface MozWifiConnection { michael@0: readonly attribute ConnectionStatus status; michael@0: readonly attribute MozWifiNetwork? network; michael@0: }; michael@0: michael@0: [JSImplementation="@mozilla.org/mozwificonnectioninfo;1", michael@0: ChromeOnly] michael@0: interface MozWifiConnectionInfo { michael@0: readonly attribute short signalStrength; michael@0: readonly attribute short relSignalStrength; michael@0: readonly attribute long linkSpeed; michael@0: readonly attribute DOMString? ipAddress; michael@0: }; michael@0: michael@0: dictionary IPConfiguration { michael@0: boolean enabled; michael@0: DOMString ipaddr; michael@0: DOMString proxy; michael@0: short maskLength; michael@0: DOMString gateway; michael@0: DOMString dns1; michael@0: DOMString dns2; michael@0: }; michael@0: michael@0: [JSImplementation="@mozilla.org/wifimanager;1", michael@0: NavigatorProperty="mozWifiManager", michael@0: Func="Navigator::HasWifiManagerSupport"] michael@0: interface MozWifiManager : EventTarget { michael@0: /** michael@0: * Returns the list of currently available networks. michael@0: * onsuccess: We have obtained the current list of networks. request.value michael@0: * is an object whose property names are SSIDs and values are michael@0: * network objects. michael@0: * onerror: We were unable to obtain a list of property names. michael@0: */ michael@0: DOMRequest getNetworks(); michael@0: michael@0: /** michael@0: * Returns the list of networks known to the system that will be michael@0: * automatically connected to if they're in range. michael@0: * onsuccess: request.value is an object whose property names are michael@0: * SSIDs and values are network objects. michael@0: * onerror: We were unable to obtain a list of known networks. michael@0: */ michael@0: DOMRequest getKnownNetworks(); michael@0: michael@0: /** michael@0: * Takes one of the networks returned from getNetworks and tries to michael@0: * connect to it. michael@0: * @param network A network object with information about the network, michael@0: * such as the SSID, key management desired, etc. michael@0: * onsuccess: We have started attempting to associate with the network. michael@0: * request.value is true. michael@0: * onerror: We were unable to select the network. This most likely means a michael@0: * configuration error. michael@0: */ michael@0: DOMRequest associate(MozWifiNetwork network); michael@0: michael@0: /** michael@0: * Given a network, removes it from the list of networks that we'll michael@0: * automatically connect to. In order to re-connect to the network, it is michael@0: * necessary to call associate on it. michael@0: * @param network A network object with the SSID of the network to remove. michael@0: * onsuccess: We have removed this network. If we were previously michael@0: * connected to it, we have started reconnecting to the next michael@0: * network in the list. michael@0: * onerror: We were unable to remove the network. michael@0: */ michael@0: DOMRequest forget(MozWifiNetwork network); michael@0: michael@0: /** michael@0: * Wi-Fi Protected Setup functionality. michael@0: * @param detail WPS detail which has 'method' and 'pin' field. michael@0: * The possible method field values are: michael@0: * - pbc: The Push Button Configuration. michael@0: * - pin: The PIN configuration. michael@0: * - cancel: Request to cancel WPS in progress. michael@0: * If method field is 'pin', 'pin' field can exist and has michael@0: * a PIN number. michael@0: * If method field is 'pin', 'bssid' field can exist and has michael@0: * a opposite BSSID. michael@0: * onsuccess: We have successfully started/canceled wps. michael@0: * onerror: We have failed to start/cancel wps. michael@0: */ michael@0: DOMRequest wps(optional WifiWPSInfo detail); michael@0: michael@0: /** michael@0: * Turn on/off wifi power saving mode. michael@0: * @param enabled true or false. michael@0: * onsuccess: We have successfully turn on/off wifi power saving mode. michael@0: * onerror: We have failed to turn on/off wifi power saving mode. michael@0: */ michael@0: DOMRequest setPowerSavingMode(boolean enabled); michael@0: michael@0: /** michael@0: * Given a network, configure using static IP instead of running DHCP michael@0: * @param network A network object with the SSID of the network to set static ip. michael@0: * @param info info should have following field: michael@0: * - enabled True to enable static IP, false to use DHCP michael@0: * - ipaddr configured static IP address michael@0: * - proxy configured proxy server address michael@0: * - maskLength configured mask length michael@0: * - gateway configured gateway address michael@0: * - dns1 configured first DNS server address michael@0: * - dns2 configured seconf DNS server address michael@0: * onsuccess: We have successfully configure the static ip mode. michael@0: * onerror: We have failed to configure the static ip mode. michael@0: */ michael@0: DOMRequest setStaticIpMode(MozWifiNetwork network, optional IPConfiguration info); michael@0: michael@0: /** michael@0: * Given a network, configure http proxy when using wifi. michael@0: * @param network A network object with the SSID of the network to set http proxy. michael@0: * @param info info should have following field: michael@0: * - httpProxyHost ip address of http proxy. michael@0: * - httpProxyPort port of http proxy, set 0 to use default port 8080. michael@0: * set info to null to clear http proxy. michael@0: * onsuccess: We have successfully configure http proxy. michael@0: * onerror: We have failed to configure http proxy. michael@0: */ michael@0: DOMRequest setHttpProxy(MozWifiNetwork network, any info); michael@0: michael@0: /** michael@0: * Returns whether or not wifi is currently enabled. michael@0: */ michael@0: readonly attribute boolean enabled; michael@0: michael@0: /** michael@0: * Returns the MAC address of the wifi adapter. michael@0: */ michael@0: readonly attribute DOMString macAddress; michael@0: michael@0: /** michael@0: * An non-null object containing the following information: michael@0: * - status ("disconnected", "connecting", "associated", "connected") michael@0: * - network michael@0: * michael@0: * Note that the object returned is read only. Any changes required must michael@0: * be done by calling other APIs. michael@0: */ michael@0: readonly attribute MozWifiConnection connection; michael@0: michael@0: /** michael@0: * A connectionInformation object with the same information found in an michael@0: * nsIDOMMozWifiConnectionInfoEvent (but without the network). michael@0: * If we are not currently connected to a network, this will be null. michael@0: */ michael@0: readonly attribute MozWifiConnectionInfo? connectionInformation; michael@0: michael@0: /** michael@0: * State notification listeners. These all take an michael@0: * nsIDOMMozWifiStatusChangeEvent with the new status and a network (which michael@0: * may be null). michael@0: * michael@0: * The possible statuses are: michael@0: * - connecting: Fires when we start the process of connecting to a michael@0: * network. michael@0: * - associated: Fires when we have connected to an access point but do michael@0: * not yet have an IP address. michael@0: * - connected: Fires once we are fully connected to an access point and michael@0: * can access the internet. michael@0: * - disconnected: Fires when we either fail to connect to an access michael@0: * point (transition: associated -> disconnected) or michael@0: * when we were connected to a network but have michael@0: * disconnected for any reason (transition: connected -> michael@0: * disconnected). michael@0: */ michael@0: attribute EventHandler onstatuschange; michael@0: michael@0: /** michael@0: * An event listener that is called with information about the signal michael@0: * strength and link speed every 5 seconds. michael@0: */ michael@0: attribute EventHandler onconnectionInfoUpdate; michael@0: michael@0: /** michael@0: * These two events fire when the wifi system is brought online or taken michael@0: * offline. michael@0: */ michael@0: attribute EventHandler onenabled; michael@0: attribute EventHandler ondisabled; michael@0: };