Bug 783742 - Add support for WPS PIN method. r=mrbkap
authorMasashi Honma <masashi.honma@gmail.com>
Wed, 22 Aug 2012 12:41:31 -0700
changeset 105099 4666c4ccea092752dd84d4354359c1d084786b0e
parent 105098 ca3a3ff0af73b6e885b2c2de97f249cacf8dd099
child 105100 517169ca9082facd14f12058c71ebad9b9e7a0cd
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersmrbkap
bugs783742
milestone17.0a1
Bug 783742 - Add support for WPS PIN method. r=mrbkap
dom/wifi/DOMWifiManager.js
dom/wifi/WifiWorker.js
--- a/dom/wifi/DOMWifiManager.js
+++ b/dom/wifi/DOMWifiManager.js
@@ -162,17 +162,17 @@ DOMWifiManager.prototype = {
 
       case "WifiManager:forget:Return:NO":
         request = this.takeRequest(msg.rid);
         Services.DOMRequest.fireError(request, msg.data);
         break;
 
       case "WifiManager:wps:Return:OK":
         request = this.takeRequest(msg.rid);
-        Services.DOMRequest.fireSuccess(request, true);
+        Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
         break;
 
       case "WifiManager:wps:Return:NO":
         request = this.takeRequest(msg.rid);
         Services.DOMRequest.fireError(request, msg.data);
         break;
 
       case "WifiManager:wifiDown":
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -273,16 +273,21 @@ var WifiManager = (function() {
     scanModeActive = setActive;
     doSetScanModeCommand(setActive, callback);
   }
 
   function wpsPbcCommand(callback) {
     doBooleanCommand("WPS_PBC", "OK", callback);
   }
 
+  function wpsPinCommand(pin, callback) {
+    doStringCommand("WPS_PIN any" + (pin === undefined ? "" : (" " + pin)),
+                    callback);
+  }
+
   function wpsCancelCommand(callback) {
     doBooleanCommand("WPS_CANCEL", "OK", callback);
   }
 
   function startDriverCommand(callback) {
     doBooleanCommand("DRIVER START", "OK");
   }
 
@@ -1171,16 +1176,17 @@ var WifiManager = (function() {
   }
   manager.getMacAddress = getMacAddressCommand;
   manager.getScanResults = scanResultsCommand;
   manager.setScanMode = function(mode, callback) {
     setScanModeCommand(mode === "active", callback);
   }
   manager.scan = scanCommand;
   manager.wpsPbc = wpsPbcCommand;
+  manager.wpsPin = wpsPinCommand;
   manager.wpsCancel = wpsCancelCommand;
   manager.getRssiApprox = getRssiApproxCommand;
   manager.getLinkSpeed = getLinkSpeedCommand;
   manager.getDhcpInfo = function() { return dhcpInfo; }
   manager.getConnectionInfo = (sdkVersion >= 15)
                               ? getConnectionInfoICS
                               : getConnectionInfoGB;
   return manager;
@@ -2087,26 +2093,33 @@ WifiWorker.prototype = {
     let self = this;
     if (detail.method === "pbc") {
       WifiManager.wpsPbc(function(ok) {
         if (ok)
           self._sendMessage(message, true, true, rid, mid);
         else
           self._sendMessage(message, false, "WPS PBC failed", rid, mid);
       });
+    } else if (detail.method === "pin") {
+      WifiManager.wpsPin(detail.pin, function(pin) {
+        if (pin)
+          self._sendMessage(message, true, pin, rid, mid);
+        else
+          self._sendMessage(message, false, "WPS PIN failed", rid, mid);
+      });
     } else if (detail.method === "cancel") {
       WifiManager.wpsCancel(function(ok) {
         if (ok)
           self._sendMessage(message, true, true, rid, mid);
         else
           self._sendMessage(message, false, "WPS Cancel failed", rid, mid);
       });
     } else {
-      self._sendMessage(message, false, "Unknown wps method=" + detail.method +
-        " was received", rid, mid);
+      self._sendMessage(message, false, "Invalid WPS method=" + detail.method,
+                        rid, mid);
     }
   },
 
   // This is a bit ugly, but works. In particular, this depends on the fact
   // that RadioManager never actually tries to get the worker from us.
   get worker() { throw "Not implemented"; },
 
   shutdown: function() {