Bug 923443 - Pre-populate WiFi networks to allow associating with a network without connecting to it. r=vchang
authorCarmen Jimenez <cjc@tid.es>
Mon, 10 Feb 2014 18:05:13 +0100
changeset 169787 5ba2e35f4d4851bb3a44f71733e70f5852e3c144
parent 169741 9019cc90719ca7cc25c4ed33127f5e174b9f93b0
child 169788 a66eb5385fdee3856675873508d0c71fe305e2b4
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersvchang
bugs923443
milestone30.0a1
Bug 923443 - Pre-populate WiFi networks to allow associating with a network without connecting to it. r=vchang
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -2631,22 +2631,26 @@ WifiWorker.prototype = {
 
     WifiManager.setWifiApEnabled(enabled, configuration, callback);
   },
 
   associate: function(msg) {
     const MAX_PRIORITY = 9999;
     const message = "WifiManager:associate:Return";
     let network = msg.data;
+
+    let privnet = network;
+    let dontConnect = privnet.dontConnect;
+    delete privnet.dontConnect;
+
     if (!WifiManager.enabled) {
       this._sendMessage(message, false, "Wifi is disabled", msg);
       return;
     }
 
-    let privnet = network;
     let self = this;
     function networkReady() {
       // saveConfig now before we disable most of the other networks.
       function selectAndConnect() {
         WifiManager.enableNetwork(privnet.netId, true, function (ok) {
           if (ok)
             self._needToEnableNetworks = true;
           if (WifiManager.state === "DISCONNECTED" ||
@@ -2655,20 +2659,25 @@ WifiWorker.prototype = {
               self._sendMessage(message, ok, ok, msg);
             });
           } else {
             self._sendMessage(message, ok, ok, msg);
           }
         });
       }
 
-      if (self._highestPriority >= MAX_PRIORITY)
-        self._reprioritizeNetworks(selectAndConnect);
-      else
-        WifiManager.saveConfig(selectAndConnect);
+      var selectAndConnectOrReturn = dontConnect ?
+        function() {
+          self._sendMessage(message, true, "Wifi has been recorded", msg);
+        } : selectAndConnect;
+      if (self._highestPriority >= MAX_PRIORITY) {
+        self._reprioritizeNetworks(selectAndConnectOrReturn);
+      } else {
+        WifiManager.saveConfig(selectAndConnectOrReturn);
+      }
     }
 
     let ssid = privnet.ssid;
     let networkKey = getNetworkKey(privnet);
     let configured;
 
     if (networkKey in this._addingNetworks) {
       this._sendMessage(message, false, "Racing associates");