Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug 824457 - Make FTU Wifi usable #7218

Merged
merged 1 commit into from

2 participants

Alive.Kuo evelynhung
Alive.Kuo
Collaborator

No description provided.

apps/communications/ftu/js/wifi.js
@@ -9,6 +9,21 @@ var WifiManager = {
this.gCurrentNetwork = this.api.connection.network;
}
},
+ isConnectedTo: function wn_isConnectedTo(network) {
+ /**
+ * XXX the API should expose a 'connected' property on 'network',
+ * and 'gWifiManager.connection.network' should be comparable to 'network'.
+ * Until this is properly implemented, we just compare SSIDs to tell wether
evelynhung Collaborator

nit: ... we just compare SSIDs and capabilities to tell wether...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
apps/communications/ftu/js/ui.js
@@ -323,7 +323,8 @@ var UIManager = {
li.dataset.ssid = network.ssid;
// Show authentication method
var keys = network.capabilities;
- if (network.connected) {
+ // XXX: Should use capability as well as ssid
evelynhung Collaborator

You did it in the isConnectedTo function, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Alive.Kuo alivedise merged commit 1084057 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
13 apps/communications/ftu/js/ui.js
View
@@ -323,7 +323,7 @@ var UIManager = {
li.dataset.ssid = network.ssid;
// Show authentication method
var keys = network.capabilities;
- if (network.connected) {
+ if (WifiManager.isConnectedTo(network)) {
small.textContent = _('shortStatus-connected');
} else {
if (keys && keys.length) {
@@ -340,7 +340,11 @@ var UIManager = {
li.appendChild(ssidp);
li.appendChild(small);
// Append to DOM
- networksDOM.appendChild(li);
+ if (WifiManager.isConnectedTo(network)) {
+ networksDOM.insertBefore(li, networksDOM.firstChild);
+ } else {
+ networksDOM.appendChild(li);
+ }
}
}
},
@@ -352,8 +356,11 @@ var UIManager = {
},
updateNetworkStatus: function uim_uns(ssid, status) {
+ if (!document.getElementById(ssid))
+ return;
+
document.getElementById(ssid).
- querySelector('p:last-child').innerHTML = status;
+ querySelector('p:last-child').innerHTML = _('shortStatus-' + status);
},
updateDataConnectionStatus: function uim_udcs(status) {
19 apps/communications/ftu/js/wifi.js
View
@@ -9,6 +9,21 @@ var WifiManager = {
this.gCurrentNetwork = this.api.connection.network;
}
},
+ isConnectedTo: function wn_isConnectedTo(network) {
+ /**
+ * XXX the API should expose a 'connected' property on 'network',
+ * and 'gWifiManager.connection.network' should be comparable to 'network'.
+ * Until this is properly implemented, we just compare SSIDs and capabilities
+ * to tell wether the network is already connected or not.
+ */
+ var currentNetwork = this.api.connection.network;
+ if (!currentNetwork || this.api.connection.status != 'connected')
+ return false;
+ var key = network.ssid + '+' + network.capabilities.join('+');
+ var curkey = currentNetwork.ssid + '+' +
+ currentNetwork.capabilities.join('+');
+ return (key == curkey);
+ },
scan: function wn_scan(callback) {
if ('mozWifiManager' in window.navigator) {
var req = WifiManager.api.getNetworks();
@@ -84,6 +99,7 @@ var WifiManager = {
}
} else {
// Connect directly
+ this.gCurrentNetwork = network;
this.api.associate(network);
return;
}
@@ -113,6 +129,9 @@ var WifiManager = {
UIManager.updateNetworkStatus(self.ssid, event.status);
if (event.status == 'connected') {
self.isConnected = true;
+ if (self.networks && self.networks.length) {
+ UIManager.renderNetworks(self.networks);
+ }
} else {
self.isConnected = false;
}
Something went wrong with that request. Please try again.