Bug 728029 - Only attempt to connect to Mozilla or Mozilla Guest after we actually have scan results. r=cjones

--HG--
extra : rebase_source : de4fbd2d7a71c06a621aaa6b4e312909eb6dac7f
This commit is contained in:
Blake Kaplan 2012-02-16 15:38:17 +01:00
parent 74ffd06481
commit da7b97f3fd

View File

@ -821,7 +821,12 @@ function nsWifiWorker() {
this.networks = Object.create(null);
WifiManager.onstatechange = function() {
debug("State change: " + self.state + " -> " + this.state);
if (self.state === "SCANNING" && this.state === "INACTIVE") {
self.state = this.state;
}
function connectToMozilla() {
if (self.state === "INACTIVE") {
// We're not trying to connect so try to find an open Mozilla network.
// TODO Remove me in favor of UI and a way to select a network.
@ -855,9 +860,8 @@ function nsWifiWorker() {
});
});
}
self.state = this.state;
}
this.waitForScan(connectToMozilla);
WifiManager.onscanresultsavailable = function() {
debug("Scan results are available! Asking for them.");
@ -874,6 +878,10 @@ function nsWifiWorker() {
else if (!match)
debug("Match didn't find anything for: " + lines[i]);
}
if (self.wantScanResults) {
self.wantScanResults();
}
});
}
@ -898,6 +906,18 @@ nsWifiWorker.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWorkerHolder,
Ci.nsIWifi]),
// Internal methods.
waitForScan: function(callback) {
if (this.wantScanResults) {
var older = this.wantScanResults;
this.wantScanResults = function() { callback(); older(); };
} else {
this.wantScanResults = callback;
}
},
// nsIWifi
setWifiEnabled: function(enable) {
WifiManager.setWifiEnabled(enable, function (ok) {
debug(ok);