Closed
Bug 740079
Opened 13 years ago
Closed 13 years ago
B2G Wifi: Add a synchronous API to get the current wifi state
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
FIXED
mozilla14
People
(Reporter: mrbkap, Assigned: mrbkap)
References
Details
Attachments
(1 file, 2 obsolete files)
(deleted),
patch
|
kaze
:
feedback+
|
Details | Diff | Splinter Review |
Right now, the synchronous wireless APIs allow a page to get the "connected" network which is a boolean state: connected or not. We need to expose state like "connecting", "obtaining IP address", etc.
Comment 1•13 years ago
|
||
Either that, or more boolean properties. Iβm not sure which would be better.
Assignee | ||
Comment 2•13 years ago
|
||
This patch renames connectedNetwork -> connectionStatus. My eventual hope is to also add things like the BSS/security used and IP address. Right now it contains the connected network (under "network") and the current status (under "status"). The status names are strings that map to the events that we currently fire. This requires a couple of small changes to wifi.js.
Assignee: nobody → mrbkap
Status: NEW → ASSIGNED
Attachment #613221 -
Flags: review?(jones.chris.g)
Attachment #613221 -
Flags: feedback?(kaze)
Comment on attachment 613221 [details] [diff] [review] Proposed fix v1 >diff --git a/dom/wifi/nsIWifi.idl b/dom/wifi/nsIWifi.idl >index 91b7022..b2ae6c9 100644 >--- a/dom/wifi/nsIWifi.idl >+++ b/dom/wifi/nsIWifi.idl >@@ -99,9 +99,11 @@ interface nsIDOMWifiManager : nsISupports { > readonly attribute boolean enabled; > > /** >- * A network object describing the currently connected network. >+ * An object containing the following information: >+ * - status ("disconnected", "connecting", "associated", "connected") >+ * - network > */ >- readonly attribute jsval connectedNetwork; >+ readonly attribute jsval connectionStatus; > I shall bikeshed this, because I can! If we're going to change the interface here, how about calling this |connection|, so that clients can say |connection.status| instead of |connectionStatus.status|. Also, the object returned here can never be null, right? Should doc that. It's a little confusing to return an object |o| in which |o.status = "disconnected"| (e.g.) is a no-op, but I defer to DOM folks on API conventions. Implementation looks good, r=me with bikeshed painted.
Attachment #613221 -
Flags: review?(jones.chris.g) → review+
Comment 4•13 years ago
|
||
(In reply to Blake Kaplan (:mrbkap) from comment #2) > This patch renames connectedNetwork -> connectionStatus. If this means that weβll have: β’ `mozWifiManager.connection.network' returning a real network object (i.e. comparable with an element of the `getNetworks' output) β’ `mozWifiManager.connection.status' returning the state of the current/requested network then Iβm OK. As you mention, it will be easy to extend if we need more information (e.g. IP address, bandwidthβ¦).
Comment 5•13 years ago
|
||
Another thing: Iβd love to have an `onstatuschange' event to get along with the synchronous `status' property. There are a few use cases where this would be easier than a set of onconnect / onconnecting / ondisconnect / etc. event listeners and it would be more XHR-like.
Assignee | ||
Comment 6•13 years ago
|
||
Attachment #613221 -
Attachment is obsolete: true
Attachment #613221 -
Flags: feedback?(kaze)
Attachment #614735 -
Flags: feedback?(kaze)
Comment 7•13 years ago
|
||
>- get connectedNetwork() {
>+ get status() {
> if (!this._hasPrivileges)
> throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
>- return this._currentNetwork;
>+ return { status: this._connectionStatus, network: this._currentNetwork };
> },
Does that mean we get this?
β’ mozWifiManager.status.status
β’ mozWifiManager.status.network
If 'status' and 'network' are properties of the same JS object, Iβd prefer this object to carry a different name than 'status' (Chris suggested 'connection')β¦ but thatβs up to you, Iβll adapt the Gaia front-end accordingly when this lands.
Comment 8•13 years ago
|
||
Why not making this leave in navigator.mozConnection? Like: navigator.mozConnection.wifi.status navigator.mozConnection.wifi.network // or .ssid, don't know what .network is for exactly
Assignee | ||
Comment 9•13 years ago
|
||
(In reply to Mounir Lamouri (:volkmar) (:mounir) from comment #8) > Why not making this leave in navigator.mozConnection? The entirety of mozWifi(Manager) should live under mozConnection, IMO. gal and I actually talked about that in the beginning. I'll file a followup on doing that. > navigator.mozConnection.wifi.network // or .ssid, don't know what .network > is for exactly I'd prefer keeping ...network.ssid. That'll make it easier to add any additional information (like what security is available) later.
Assignee | ||
Comment 10•13 years ago
|
||
I grabbed the wrong brush the last time.
Attachment #614735 -
Attachment is obsolete: true
Attachment #614735 -
Flags: feedback?(kaze)
Attachment #615340 -
Flags: feedback?(kaze)
Updated•13 years ago
|
Attachment #615340 -
Flags: feedback?(kaze) → feedback+
Assignee | ||
Comment 11•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/14084207e9d1
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla14
Comment 12•13 years ago
|
||
(In reply to Fabien Cazenave (:kaze) from comment #5) > Another thing: Iβd love to have an `onstatuschange' event to get along with > the synchronous `status' property. There are a few use cases where this > would be easier than a set of onconnect / onconnecting / ondisconnect / etc. > event listeners and it would be more XHR-like. +1. File it? (In reply to Blake Kaplan (:mrbkap) from comment #9) > (In reply to Mounir Lamouri (:volkmar) (:mounir) from comment #8) > > Why not making this leave in navigator.mozConnection? > > The entirety of mozWifi(Manager) should live under mozConnection, IMO. gal > and I actually talked about that in the beginning. I'll file a followup on > doing that. In that case, we should perhaps move navigator.mozMobileConnection to .mozConnection.mobile as well. But I want to do that in a follow-up, too :)
Comment 13•13 years ago
|
||
(In reply to Philipp von Weitershausen [:philikon] from comment #12) > (In reply to Fabien Cazenave (:kaze) from comment #5) > > Another thing: Iβd love to have an `onstatuschange' event to get along with > > the synchronous `status' property. There are a few use cases where this > > would be easier than a set of onconnect / onconnecting / ondisconnect / etc. > > event listeners and it would be more XHR-like. > > +1. File it? Never mind... bug 745114 :)
You need to log in
before you can comment on or make changes to this bug.
Description
•