From 1d971cb8fb1637bc4e4d2f4ca29b07ff023e975a Mon Sep 17 00:00:00 2001 From: Chuck Lee Date: Mon, 28 Apr 2014 15:50:11 +0800 Subject: [PATCH] Bug 917175 - 0003. DOM API implementation. r=mrbkap --- dom/wifi/DOMWifiManager.js | 18 ++++++++++++++++++ dom/wifi/WifiWorker.js | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/dom/wifi/DOMWifiManager.js b/dom/wifi/DOMWifiManager.js index e36ca081754..977251b669c 100644 --- a/dom/wifi/DOMWifiManager.js +++ b/dom/wifi/DOMWifiManager.js @@ -96,6 +96,7 @@ DOMWifiManager.prototype = { "WifiManager:setStaticIpMode:Return:OK", "WifiManager:setStaticIpMode:Return:NO", "WifiManager:importCert:Return:OK", "WifiManager:importCert:Return:NO", "WifiManager:getImportedCerts:Return:OK", "WifiManager:getImportedCerts:Return:NO", + "WifiManager:deleteCert:Return:OK", "WifiManager:deleteCert:Return:NO", "WifiManager:wifiDown", "WifiManager:wifiUp", "WifiManager:onconnecting", "WifiManager:onassociate", "WifiManager:onconnect", "WifiManager:ondisconnect", @@ -288,6 +289,14 @@ DOMWifiManager.prototype = { Services.DOMRequest.fireError(request, msg.data); break; + case "WifiManager:deleteCert:Return:OK": + Services.DOMRequest.fireSuccess(request, msg.data); + break; + + case "WifiManager:deleteCert:Return:NO": + Services.DOMRequest.fireError(request, msg.data); + break; + case "WifiManager:wifiDown": this._enabled = false; this._currentNetwork = null; @@ -452,6 +461,15 @@ DOMWifiManager.prototype = { return request; }, + deleteCert: function nsIDOMWifiManager_deleteCert(certNickname) { + var request = this.createRequest(); + this._sendMessageForRequest("WifiManager:deleteCert", + { + certNickname: certNickname + }, request); + return request; + }, + get enabled() { return this._enabled; }, diff --git a/dom/wifi/WifiWorker.js b/dom/wifi/WifiWorker.js index 8721de2fe2e..35ef3d11278 100644 --- a/dom/wifi/WifiWorker.js +++ b/dom/wifi/WifiWorker.js @@ -1379,6 +1379,15 @@ var WifiManager = (function() { caInfo.certNickname); } + manager.deleteCert = function(caInfo, callback) { + var id = idgen++; + if (callback) { + controlCallbacks[id] = callback; + } + + wifiCertService.deleteCert(id, caInfo.certNickname); + } + return manager; })(); @@ -1647,6 +1656,7 @@ function WifiWorker() { "WifiManager:setStaticIpMode", "WifiManager:importCert", "WifiManager:getImportedCerts", + "WifiManager:deleteCert", "child-process-shutdown"]; messages.forEach((function(msgName) { @@ -2605,6 +2615,9 @@ WifiWorker.prototype = { case "WifiManager:getImportedCerts": this.getImportedCerts(msg); break; + case "WifiManager:deleteCert": + this.deleteCert(msg); + break; case "WifiManager:getState": { let i; if ((i = this._domManagers.indexOf(msg.manager)) === -1) { @@ -3157,6 +3170,15 @@ WifiWorker.prototype = { self._sendMessage(message, true, importedCerts, msg); }, + deleteCert: function deleteCert(msg) { + const message = "WifiManager:deleteCert:Return"; + let self = this; + + WifiManager.deleteCert(msg.data, function(data) { + self._sendMessage(message, data.status === 0, "Delete Cert failed", msg); + }); + }, + // 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"; },