dom/wifi/nsIWifi.idl
author Till Schneidereit <tschneidereit@gmail.com>
Thu, 06 Sep 2012 17:43:22 +0200
changeset 108068 2f83e74b38ff702f57ce22df899f531c9b252ec0
parent 107772 9020feae5d3c3160c3f4c08dadcf8a29b4ba571b
child 111561 8381cb18f0f6bd3e0ac550515d215921b60dcdd1
permissions -rw-r--r--
Bug 786743 - Disable JS minification for debug builds.

/* 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"
#include "nsIDOMDOMRequest.idl"
#include "nsIDOMEvent.idl"
#include "nsINetworkManager.idl"

interface nsIVariant;

[scriptable, function, uuid(c675c7c3-5261-480a-98f3-69934c9ab7c6)]
interface nsIWifiTetheringCallback : nsISupports
{
  /**
   * Callback function used to report status to NetworkManager.
   * result: 0: success, others: fail.
   * networkInterface: report wifi network interface's name.
   */
  void wifiTetheringEnabledChange(in jsval result,
                                  in nsINetworkInterface networkInterface);
};

[scriptable, uuid(65649c30-d312-11e1-9b23-0800200c9a66)]
interface nsIWifi : nsISupports
{
    /**
     * Shutdown the wifi system.
     */
    void shutdown();
    /**
     * Request to enable/disable Wifi Tethering.
     * enabled: true or false.
     * callback: report status to NetworkManager.
     */
    void setWifiTethering(in boolean enabled, in nsIWifiTetheringCallback callback);
};

[scriptable, uuid(540674a6-edbe-11e1-87c9-dbcd31c74284)]
interface nsIDOMWifiManager : nsISupports
{
    /**
     * Returns the list of currently available networks as well as the list of
     * currently configured 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.
     */
    nsIDOMDOMRequest getNetworks();

    /**
     * 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.
     */
    nsIDOMDOMRequest associate(in jsval 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.
     */
    nsIDOMDOMRequest forget(in jsval 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.
     * onsuccess: We have successfully started/canceled wps.
     * onerror: We have failed to start/cancel wps.
     */
    nsIDOMDOMRequest wps(in jsval detail);

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

    /**
     * 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 jsval connection;

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

    /**
     * State notification listeners. These all take an
     * nsIDOMMozWifiStatusChangeEvent 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 nsIDOMEventListener onstatuschange;

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

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

[scriptable, builtinclass, uuid(f3ef70b0-b2d3-4eb5-8ea4-008f8d330cd6)]
interface nsIDOMMozWifiStatusChangeEvent : nsIDOMEvent
{
    /**
     * Network object with a SSID field describing the network affected by
     * this change. This might be null.
     */
    readonly attribute nsIVariant network;

    /**
     * String describing the current status of the wifi manager. See above for
     * the possible values.
     */
    readonly attribute DOMString status;

    [noscript] void initMozWifiStatusChangeEvent(in DOMString aType,
                                                 in boolean aCanBubble,
                                                 in boolean aCancelable,
                                                 in nsIVariant aNetwork,
                                                 in DOMString status);
};

[scriptable, builtinclass, uuid(34994296-d694-4aed-953d-fc25ee25c050)]
interface nsIDOMMozWifiConnectionInfoEvent : nsIDOMEvent
{
    /**
     * Network object with an SSID field.
     */
    readonly attribute nsIVariant network;

    /**
     * Strength of the signal to network, in dBm between -55 and -100 dBm.
     */
    readonly attribute short signalStrength;

    /**
     * Relative signal strength between 0 and 100.
     */
    readonly attribute short relSignalStrength;

    /**
     * Link speed in Mb/s.
     */
    readonly attribute long linkSpeed;

    [noscript] void initMozWifiConnectionInfoEvent(in DOMString aType,
                                                   in boolean aCanBubble,
                                                   in boolean aCancelable,
                                                   in nsIVariant aNetwork,
                                                   in short signalStrength,
                                                   in short relSignalStrength,
                                                   in long linkSpeed);
};