mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 745114 - Collapse the various status change callbacks into a single callback. r=cjones a=b2g-only
This commit is contained in:
parent
c4d27e8a68
commit
6d5ff2bdc2
@ -141,26 +141,26 @@ DOMWifiManager.prototype = {
|
||||
case "WifiManager:onconnecting":
|
||||
this._currentNetwork = msg.network;
|
||||
this._connectionStatus = "connecting";
|
||||
this._fireOnConnecting(msg.network);
|
||||
this._fireStatusChangeEvent();
|
||||
break;
|
||||
|
||||
case "WifiManager:onassociate":
|
||||
this._currentNetwork = msg.network;
|
||||
this._connectionStatus = "associated";
|
||||
this._fireOnAssociate(msg.network);
|
||||
this._fireStatusChangeEvent();
|
||||
break;
|
||||
|
||||
case "WifiManager:onconnect":
|
||||
this._currentNetwork = msg.network;
|
||||
this._connectionStatus = "connected";
|
||||
this._fireOnConnect(msg.network);
|
||||
this._fireStatusChangeEvent();
|
||||
break;
|
||||
|
||||
case "WifiManager:ondisconnect":
|
||||
this._fireOnDisconnect(this._currentNetwork);
|
||||
this._currentNetwork = null;
|
||||
this._connectionStatus = "disconnected";
|
||||
this._lastConnectionInfo = null;
|
||||
this._fireStatusChangeEvent();
|
||||
break;
|
||||
|
||||
case "WifiManager:connectionInfoUpdate":
|
||||
@ -170,24 +170,12 @@ DOMWifiManager.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_fireOnConnecting: function onConnecting(network) {
|
||||
if (this._onConnecting)
|
||||
this._onConnecting.handleEvent(new WifiStateChangeEvent(network));
|
||||
},
|
||||
|
||||
_fireOnAssociate: function onAssociate(network) {
|
||||
if (this._onAssociate)
|
||||
this._onAssociate.handleEvent(new WifiStateChangeEvent(network));
|
||||
},
|
||||
|
||||
_fireOnConnect: function onConnect(network) {
|
||||
if (this._onConnect)
|
||||
this._onConnect.handleEvent(new WifiStateChangeEvent(network));
|
||||
},
|
||||
|
||||
_fireOnDisconnect: function onDisconnect(network) {
|
||||
if (this._onDisconnect)
|
||||
this._onDisconnect.handleEvent(new WifiStateChangeEvent(network));
|
||||
_fireStatusChangeEvent: function StatusChangeEvent() {
|
||||
if (this._onStatusChange) {
|
||||
var event = new WifiStatusChangeEvent(this._currentNetwork,
|
||||
this._connectionStatus);
|
||||
this._onStatusChange.handleEvent(event);
|
||||
}
|
||||
},
|
||||
|
||||
_fireConnectionInfoUpdate: function connectionInfoUpdate(info) {
|
||||
@ -251,28 +239,10 @@ DOMWifiManager.prototype = {
|
||||
return this._lastConnectionInfo;
|
||||
},
|
||||
|
||||
set onconnecting(callback) {
|
||||
set onstatuschange(callback) {
|
||||
if (!this._hasPrivileges)
|
||||
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
|
||||
this._onConnecting = callback;
|
||||
},
|
||||
|
||||
set onassociate(callback) {
|
||||
if (!this._hasPrivileges)
|
||||
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
|
||||
this._onAssociate = callback;
|
||||
},
|
||||
|
||||
set onconnect(callback) {
|
||||
if (!this._hasPrivileges)
|
||||
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
|
||||
this._onConnect = callback;
|
||||
},
|
||||
|
||||
set ondisconnect(callback) {
|
||||
if (!this._hasPrivileges)
|
||||
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
|
||||
this._onDisconnect = callback;
|
||||
this._onStatusChange = callback;
|
||||
},
|
||||
|
||||
set connectionInfoUpdate(callback) {
|
||||
@ -282,16 +252,16 @@ DOMWifiManager.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
function WifiStateChangeEvent(network) {
|
||||
function WifiStatusChangeEvent(network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
WifiStateChangeEvent.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMWifiStateChangeEvent]),
|
||||
WifiStatusChangeEvent.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMWifiStatusChangeEvent]),
|
||||
|
||||
classInfo: XPCOMUtils.generateCI({classID: Components.ID("{f28c1ae7-4db7-4a4d-bb06-737eb04ad700}"),
|
||||
contractID: "@mozilla.org/wifi/statechange-event;1",
|
||||
interfaces: [Ci.nsIDOMWifiStateChangeEvent],
|
||||
interfaces: [Ci.nsIDOMWifiStatusChangeEvent],
|
||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||
classDescription: "Wifi State Change Event"})
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ interface nsIWifi : nsISupports {
|
||||
void shutdown();
|
||||
};
|
||||
|
||||
[scriptable, uuid(36e4137b-dc8b-47e2-a90c-6adfb731fc41)]
|
||||
[scriptable, uuid(e3d5a7d7-6abd-4ac2-83dc-5315ec08a1c3)]
|
||||
interface nsIDOMWifiManager : nsISupports {
|
||||
/**
|
||||
* TODO Remove in favor of a settings API.
|
||||
@ -116,22 +116,24 @@ interface nsIDOMWifiManager : nsISupports {
|
||||
readonly attribute jsval connectionInformation;
|
||||
|
||||
/**
|
||||
* These four functions serve as state notification listeners.
|
||||
* onconnecting: Fires when we start the process of connecting to a
|
||||
* network.
|
||||
* onassociate: Fires when we have connected to an access point but do not
|
||||
* yet have an IP address.
|
||||
* onconnect: Fires once we are fully connected to an access point and can
|
||||
* access the internet.
|
||||
* ondisconnect: Fires when we either fail to connect to an access point
|
||||
* (transition: onassociate -> ondisconnect) or when we were
|
||||
* connected to a network but have disconnected for any
|
||||
* reason (transition: onconnect -> ondisconnect).
|
||||
* State notification listeners. These all take an
|
||||
* nsIDOMWifiStatusChangeEvent 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 onconnecting;
|
||||
attribute nsIDOMEventListener onassociate;
|
||||
attribute nsIDOMEventListener onconnect;
|
||||
attribute nsIDOMEventListener ondisconnect;
|
||||
attribute nsIDOMEventListener onstatuschange;
|
||||
|
||||
/**
|
||||
* An event listener that is called with information about the signal
|
||||
@ -141,12 +143,18 @@ interface nsIDOMWifiManager : nsISupports {
|
||||
};
|
||||
|
||||
[scriptable, uuid(4674c6f1-ea64-44db-ac2f-e7bd6514dfd6)]
|
||||
interface nsIDOMWifiStateChangeEvent : nsIDOMEvent {
|
||||
interface nsIDOMWifiStatusChangeEvent : nsIDOMEvent {
|
||||
/**
|
||||
* Network object with a SSID field describing the network affected by
|
||||
* this change.
|
||||
* this change. This might be null.
|
||||
*/
|
||||
readonly attribute jsval network;
|
||||
|
||||
/**
|
||||
* String describing the current status of the wifi manager. See above for
|
||||
* the possible values.
|
||||
*/
|
||||
readonly attribute string status;
|
||||
};
|
||||
|
||||
[scriptable, uuid(5c9ee332-dd98-4227-b7fc-768418fd50e3)]
|
||||
|
Loading…
Reference in New Issue
Block a user