Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #7218 from alivedise/bugzilla/824457-v2

Bug 824457 - Make FTU Wifi usable
  • Loading branch information...
commit 1084057e7a55b41d77e867027f2b1f57efeca274 2 parents 33d5b65 + 12ee1d2
@alivedise alivedise authored
View
13 apps/communications/ftu/js/ui.js
@@ -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) {
View
19 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 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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.