Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | "use strict"; |
michael@0 | 8 | |
michael@0 | 9 | const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; |
michael@0 | 10 | |
michael@0 | 11 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 12 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 13 | Cu.import("resource://gre/modules/DOMRequestHelper.jsm"); |
michael@0 | 14 | |
michael@0 | 15 | const DEBUG = false; // set to false to suppress debug messages |
michael@0 | 16 | |
michael@0 | 17 | const DOMWIFIMANAGER_CONTRACTID = "@mozilla.org/wifimanager;1"; |
michael@0 | 18 | const DOMWIFIMANAGER_CID = Components.ID("{c9b5f09e-25d2-40ca-aef4-c4d13d93c706}"); |
michael@0 | 19 | |
michael@0 | 20 | function MozWifiNetwork() { |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | MozWifiNetwork.prototype = { |
michael@0 | 24 | |
michael@0 | 25 | init: function(aWindow) { |
michael@0 | 26 | this._window = aWindow; |
michael@0 | 27 | }, |
michael@0 | 28 | |
michael@0 | 29 | __init: function(obj) { |
michael@0 | 30 | for (let key in obj) { |
michael@0 | 31 | this[key] = obj[key]; |
michael@0 | 32 | } |
michael@0 | 33 | }, |
michael@0 | 34 | |
michael@0 | 35 | classID: Components.ID("{c01fd751-43c0-460a-8b64-abf652ec7220}"), |
michael@0 | 36 | contractID: "@mozilla.org/mozwifinetwork;1", |
michael@0 | 37 | QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, |
michael@0 | 38 | Ci.nsIDOMGlobalPropertyInitializer]) |
michael@0 | 39 | }; |
michael@0 | 40 | |
michael@0 | 41 | function MozWifiConnection(obj) { |
michael@0 | 42 | this.status = obj.status; |
michael@0 | 43 | this.network = obj.network; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | MozWifiConnection.prototype = { |
michael@0 | 47 | classID: Components.ID("{23579da4-201b-4319-bd42-9b7f337343ac}"), |
michael@0 | 48 | contractID: "@mozilla.org/mozwificonnection;1", |
michael@0 | 49 | QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]) |
michael@0 | 50 | }; |
michael@0 | 51 | |
michael@0 | 52 | function MozWifiConnectionInfo(obj) { |
michael@0 | 53 | this.signalStrength = obj.signalStrength; |
michael@0 | 54 | this.relSignalStrength = obj.relSignalStrength; |
michael@0 | 55 | this.linkSpeed = obj.linkSpeed; |
michael@0 | 56 | this.ipAddress = obj.ipAddress; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | MozWifiConnectionInfo.prototype = { |
michael@0 | 60 | classID: Components.ID("{83670352-6ed4-4c35-8de9-402296a1959c}"), |
michael@0 | 61 | contractID: "@mozilla.org/mozwificonnectioninfo;1", |
michael@0 | 62 | QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]) |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | function DOMWifiManager() { |
michael@0 | 66 | this.defineEventHandlerGetterSetter("onstatuschange"); |
michael@0 | 67 | this.defineEventHandlerGetterSetter("onconnectionInfoUpdate"); |
michael@0 | 68 | this.defineEventHandlerGetterSetter("onenabled"); |
michael@0 | 69 | this.defineEventHandlerGetterSetter("ondisabled"); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | DOMWifiManager.prototype = { |
michael@0 | 73 | __proto__: DOMRequestIpcHelper.prototype, |
michael@0 | 74 | classDescription: "DOMWifiManager", |
michael@0 | 75 | classID: DOMWIFIMANAGER_CID, |
michael@0 | 76 | contractID: DOMWIFIMANAGER_CONTRACTID, |
michael@0 | 77 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer, |
michael@0 | 78 | Ci.nsISupportsWeakReference, |
michael@0 | 79 | Ci.nsIObserver]), |
michael@0 | 80 | |
michael@0 | 81 | // nsIDOMGlobalPropertyInitializer implementation |
michael@0 | 82 | init: function(aWindow) { |
michael@0 | 83 | // Maintain this state for synchronous APIs. |
michael@0 | 84 | this._currentNetwork = null; |
michael@0 | 85 | this._connectionStatus = "disconnected"; |
michael@0 | 86 | this._enabled = false; |
michael@0 | 87 | this._lastConnectionInfo = null; |
michael@0 | 88 | |
michael@0 | 89 | const messages = ["WifiManager:getNetworks:Return:OK", "WifiManager:getNetworks:Return:NO", |
michael@0 | 90 | "WifiManager:getKnownNetworks:Return:OK", "WifiManager:getKnownNetworks:Return:NO", |
michael@0 | 91 | "WifiManager:associate:Return:OK", "WifiManager:associate:Return:NO", |
michael@0 | 92 | "WifiManager:forget:Return:OK", "WifiManager:forget:Return:NO", |
michael@0 | 93 | "WifiManager:wps:Return:OK", "WifiManager:wps:Return:NO", |
michael@0 | 94 | "WifiManager:setPowerSavingMode:Return:OK", "WifiManager:setPowerSavingMode:Return:NO", |
michael@0 | 95 | "WifiManager:setHttpProxy:Return:OK", "WifiManager:setHttpProxy:Return:NO", |
michael@0 | 96 | "WifiManager:setStaticIpMode:Return:OK", "WifiManager:setStaticIpMode:Return:NO", |
michael@0 | 97 | "WifiManager:wifiDown", "WifiManager:wifiUp", |
michael@0 | 98 | "WifiManager:onconnecting", "WifiManager:onassociate", |
michael@0 | 99 | "WifiManager:onconnect", "WifiManager:ondisconnect", |
michael@0 | 100 | "WifiManager:onwpstimeout", "WifiManager:onwpsfail", |
michael@0 | 101 | "WifiManager:onwpsoverlap", "WifiManager:connectionInfoUpdate", |
michael@0 | 102 | "WifiManager:onconnectingfailed"]; |
michael@0 | 103 | this.initDOMRequestHelper(aWindow, messages); |
michael@0 | 104 | this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncMessageSender); |
michael@0 | 105 | |
michael@0 | 106 | var state = this._mm.sendSyncMessage("WifiManager:getState")[0]; |
michael@0 | 107 | if (state) { |
michael@0 | 108 | this._currentNetwork = this._convertWifiNetwork(state.network); |
michael@0 | 109 | this._lastConnectionInfo = this._convertConnectionInfo(state.connectionInfo); |
michael@0 | 110 | this._enabled = state.enabled; |
michael@0 | 111 | this._connectionStatus = state.status; |
michael@0 | 112 | this._macAddress = state.macAddress; |
michael@0 | 113 | } else { |
michael@0 | 114 | this._currentNetwork = null; |
michael@0 | 115 | this._lastConnectionInfo = null; |
michael@0 | 116 | this._enabled = false; |
michael@0 | 117 | this._connectionStatus = "disconnected"; |
michael@0 | 118 | this._macAddress = ""; |
michael@0 | 119 | } |
michael@0 | 120 | }, |
michael@0 | 121 | |
michael@0 | 122 | _convertWifiNetworkToJSON: function(aNetwork) { |
michael@0 | 123 | let json = {}; |
michael@0 | 124 | |
michael@0 | 125 | for (let key in aNetwork) { |
michael@0 | 126 | // In WifiWorker.js there are lots of check using "key in network". |
michael@0 | 127 | // So if the value of any property of WifiNetwork is undefined, do not clone it. |
michael@0 | 128 | if (aNetwork[key] != undefined) { |
michael@0 | 129 | json[key] = aNetwork[key]; |
michael@0 | 130 | } |
michael@0 | 131 | } |
michael@0 | 132 | return json; |
michael@0 | 133 | }, |
michael@0 | 134 | |
michael@0 | 135 | _convertWifiNetwork: function(aNetwork) { |
michael@0 | 136 | let network = aNetwork ? new this._window.MozWifiNetwork(aNetwork) : null; |
michael@0 | 137 | return network; |
michael@0 | 138 | }, |
michael@0 | 139 | |
michael@0 | 140 | _convertWifiNetworks: function(aNetworks) { |
michael@0 | 141 | let networks = []; |
michael@0 | 142 | for (let i in aNetworks) { |
michael@0 | 143 | networks.push(this._convertWifiNetwork(aNetworks[i])); |
michael@0 | 144 | } |
michael@0 | 145 | return networks; |
michael@0 | 146 | }, |
michael@0 | 147 | |
michael@0 | 148 | _convertConnection: function(aConn) { |
michael@0 | 149 | let conn = aConn ? new MozWifiConnection(aConn) : null; |
michael@0 | 150 | return conn; |
michael@0 | 151 | }, |
michael@0 | 152 | |
michael@0 | 153 | _convertConnectionInfo: function(aInfo) { |
michael@0 | 154 | let info = aInfo ? new MozWifiConnectionInfo(aInfo) : null; |
michael@0 | 155 | return info; |
michael@0 | 156 | }, |
michael@0 | 157 | |
michael@0 | 158 | _sendMessageForRequest: function(name, data, request) { |
michael@0 | 159 | let id = this.getRequestId(request); |
michael@0 | 160 | this._mm.sendAsyncMessage(name, { data: data, rid: id, mid: this._id }); |
michael@0 | 161 | }, |
michael@0 | 162 | |
michael@0 | 163 | receiveMessage: function(aMessage) { |
michael@0 | 164 | let msg = aMessage.json; |
michael@0 | 165 | if (msg.mid && msg.mid != this._id) |
michael@0 | 166 | return; |
michael@0 | 167 | |
michael@0 | 168 | let request; |
michael@0 | 169 | if (msg.rid) { |
michael@0 | 170 | request = this.takeRequest(msg.rid); |
michael@0 | 171 | if (!request) { |
michael@0 | 172 | return; |
michael@0 | 173 | } |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | switch (aMessage.name) { |
michael@0 | 177 | case "WifiManager:getNetworks:Return:OK": |
michael@0 | 178 | Services.DOMRequest.fireSuccess(request, this._convertWifiNetworks(msg.data)); |
michael@0 | 179 | break; |
michael@0 | 180 | |
michael@0 | 181 | case "WifiManager:getNetworks:Return:NO": |
michael@0 | 182 | Services.DOMRequest.fireError(request, "Unable to scan for networks"); |
michael@0 | 183 | break; |
michael@0 | 184 | |
michael@0 | 185 | case "WifiManager:getKnownNetworks:Return:OK": |
michael@0 | 186 | Services.DOMRequest.fireSuccess(request, this._convertWifiNetworks(msg.data)); |
michael@0 | 187 | break; |
michael@0 | 188 | |
michael@0 | 189 | case "WifiManager:getKnownNetworks:Return:NO": |
michael@0 | 190 | Services.DOMRequest.fireError(request, "Unable to get known networks"); |
michael@0 | 191 | break; |
michael@0 | 192 | |
michael@0 | 193 | case "WifiManager:associate:Return:OK": |
michael@0 | 194 | Services.DOMRequest.fireSuccess(request, true); |
michael@0 | 195 | break; |
michael@0 | 196 | |
michael@0 | 197 | case "WifiManager:associate:Return:NO": |
michael@0 | 198 | Services.DOMRequest.fireError(request, "Unable to add the network"); |
michael@0 | 199 | break; |
michael@0 | 200 | |
michael@0 | 201 | case "WifiManager:forget:Return:OK": |
michael@0 | 202 | Services.DOMRequest.fireSuccess(request, true); |
michael@0 | 203 | break; |
michael@0 | 204 | |
michael@0 | 205 | case "WifiManager:forget:Return:NO": |
michael@0 | 206 | Services.DOMRequest.fireError(request, msg.data); |
michael@0 | 207 | break; |
michael@0 | 208 | |
michael@0 | 209 | case "WifiManager:wps:Return:OK": |
michael@0 | 210 | Services.DOMRequest.fireSuccess(request, msg.data); |
michael@0 | 211 | break; |
michael@0 | 212 | |
michael@0 | 213 | case "WifiManager:wps:Return:NO": |
michael@0 | 214 | Services.DOMRequest.fireError(request, msg.data); |
michael@0 | 215 | break; |
michael@0 | 216 | |
michael@0 | 217 | case "WifiManager:setPowerSavingMode:Return:OK": |
michael@0 | 218 | Services.DOMRequest.fireSuccess(request, msg.data); |
michael@0 | 219 | break; |
michael@0 | 220 | |
michael@0 | 221 | case "WifiManager:setPowerSavingMode:Return:NO": |
michael@0 | 222 | Services.DOMRequest.fireError(request, msg.data); |
michael@0 | 223 | break; |
michael@0 | 224 | |
michael@0 | 225 | case "WifiManager:setHttpProxy:Return:OK": |
michael@0 | 226 | Services.DOMRequest.fireSuccess(request, msg.data); |
michael@0 | 227 | break; |
michael@0 | 228 | |
michael@0 | 229 | case "WifiManager:setHttpProxy:Return:NO": |
michael@0 | 230 | Services.DOMRequest.fireError(request, msg.data); |
michael@0 | 231 | break; |
michael@0 | 232 | |
michael@0 | 233 | case "WifiManager:setStaticIpMode:Return:OK": |
michael@0 | 234 | Services.DOMRequest.fireSuccess(request, msg.data); |
michael@0 | 235 | break; |
michael@0 | 236 | |
michael@0 | 237 | case "WifiManager:setStaticIpMode:Return:NO": |
michael@0 | 238 | Services.DOMRequest.fireError(request, msg.data); |
michael@0 | 239 | break; |
michael@0 | 240 | |
michael@0 | 241 | case "WifiManager:wifiDown": |
michael@0 | 242 | this._enabled = false; |
michael@0 | 243 | this._currentNetwork = null; |
michael@0 | 244 | this._fireEnabledOrDisabled(false); |
michael@0 | 245 | break; |
michael@0 | 246 | |
michael@0 | 247 | case "WifiManager:wifiUp": |
michael@0 | 248 | this._enabled = true; |
michael@0 | 249 | this._macAddress = msg.macAddress; |
michael@0 | 250 | this._fireEnabledOrDisabled(true); |
michael@0 | 251 | break; |
michael@0 | 252 | |
michael@0 | 253 | case "WifiManager:onconnecting": |
michael@0 | 254 | this._currentNetwork = this._convertWifiNetwork(msg.network); |
michael@0 | 255 | this._connectionStatus = "connecting"; |
michael@0 | 256 | this._fireStatusChangeEvent(); |
michael@0 | 257 | break; |
michael@0 | 258 | |
michael@0 | 259 | case "WifiManager:onassociate": |
michael@0 | 260 | this._currentNetwork = this._convertWifiNetwork(msg.network); |
michael@0 | 261 | this._connectionStatus = "associated"; |
michael@0 | 262 | this._fireStatusChangeEvent(); |
michael@0 | 263 | break; |
michael@0 | 264 | |
michael@0 | 265 | case "WifiManager:onconnect": |
michael@0 | 266 | this._currentNetwork = this._convertWifiNetwork(msg.network); |
michael@0 | 267 | this._connectionStatus = "connected"; |
michael@0 | 268 | this._fireStatusChangeEvent(); |
michael@0 | 269 | break; |
michael@0 | 270 | |
michael@0 | 271 | case "WifiManager:ondisconnect": |
michael@0 | 272 | this._currentNetwork = null; |
michael@0 | 273 | this._connectionStatus = "disconnected"; |
michael@0 | 274 | this._lastConnectionInfo = null; |
michael@0 | 275 | this._fireStatusChangeEvent(); |
michael@0 | 276 | break; |
michael@0 | 277 | |
michael@0 | 278 | case "WifiManager:onwpstimeout": |
michael@0 | 279 | this._currentNetwork = null; |
michael@0 | 280 | this._connectionStatus = "wps-timedout"; |
michael@0 | 281 | this._lastConnectionInfo = null; |
michael@0 | 282 | this._fireStatusChangeEvent(); |
michael@0 | 283 | break; |
michael@0 | 284 | |
michael@0 | 285 | case "WifiManager:onwpsfail": |
michael@0 | 286 | this._currentNetwork = null; |
michael@0 | 287 | this._connectionStatus = "wps-failed"; |
michael@0 | 288 | this._lastConnectionInfo = null; |
michael@0 | 289 | this._fireStatusChangeEvent(); |
michael@0 | 290 | break; |
michael@0 | 291 | |
michael@0 | 292 | case "WifiManager:onwpsoverlap": |
michael@0 | 293 | this._currentNetwork = null; |
michael@0 | 294 | this._connectionStatus = "wps-overlapped"; |
michael@0 | 295 | this._lastConnectionInfo = null; |
michael@0 | 296 | this._fireStatusChangeEvent(); |
michael@0 | 297 | break; |
michael@0 | 298 | |
michael@0 | 299 | case "WifiManager:connectionInfoUpdate": |
michael@0 | 300 | this._lastConnectionInfo = this._convertConnectionInfo(msg); |
michael@0 | 301 | this._fireConnectionInfoUpdate(msg); |
michael@0 | 302 | break; |
michael@0 | 303 | case "WifiManager:onconnectingfailed": |
michael@0 | 304 | this._currentNetwork = null; |
michael@0 | 305 | this._connectionStatus = "connectingfailed"; |
michael@0 | 306 | this._lastConnectionInfo = null; |
michael@0 | 307 | this._fireStatusChangeEvent(); |
michael@0 | 308 | break; |
michael@0 | 309 | } |
michael@0 | 310 | }, |
michael@0 | 311 | |
michael@0 | 312 | _fireStatusChangeEvent: function StatusChangeEvent() { |
michael@0 | 313 | var event = new this._window.MozWifiStatusChangeEvent("statuschange", |
michael@0 | 314 | { network: this._currentNetwork, |
michael@0 | 315 | status: this._connectionStatus |
michael@0 | 316 | }); |
michael@0 | 317 | this.__DOM_IMPL__.dispatchEvent(event); |
michael@0 | 318 | }, |
michael@0 | 319 | |
michael@0 | 320 | _fireConnectionInfoUpdate: function onConnectionInfoUpdate(info) { |
michael@0 | 321 | var evt = new this._window.MozWifiConnectionInfoEvent("connectioninfoupdate", |
michael@0 | 322 | { network: this._currentNetwork, |
michael@0 | 323 | signalStrength: info.signalStrength, |
michael@0 | 324 | relSignalStrength: info.relSignalStrength, |
michael@0 | 325 | linkSpeed: info.linkSpeed, |
michael@0 | 326 | ipAddress: info.ipAddress, |
michael@0 | 327 | }); |
michael@0 | 328 | this.__DOM_IMPL__.dispatchEvent(evt); |
michael@0 | 329 | }, |
michael@0 | 330 | |
michael@0 | 331 | _fireEnabledOrDisabled: function enabledDisabled(enabled) { |
michael@0 | 332 | var evt = new this._window.Event(enabled ? "enabled" : "disabled"); |
michael@0 | 333 | this.__DOM_IMPL__.dispatchEvent(evt); |
michael@0 | 334 | }, |
michael@0 | 335 | |
michael@0 | 336 | getNetworks: function getNetworks() { |
michael@0 | 337 | var request = this.createRequest(); |
michael@0 | 338 | this._sendMessageForRequest("WifiManager:getNetworks", null, request); |
michael@0 | 339 | return request; |
michael@0 | 340 | }, |
michael@0 | 341 | |
michael@0 | 342 | getKnownNetworks: function getKnownNetworks() { |
michael@0 | 343 | var request = this.createRequest(); |
michael@0 | 344 | this._sendMessageForRequest("WifiManager:getKnownNetworks", null, request); |
michael@0 | 345 | return request; |
michael@0 | 346 | }, |
michael@0 | 347 | |
michael@0 | 348 | associate: function associate(network) { |
michael@0 | 349 | var request = this.createRequest(); |
michael@0 | 350 | this._sendMessageForRequest("WifiManager:associate", |
michael@0 | 351 | this._convertWifiNetworkToJSON(network), request); |
michael@0 | 352 | return request; |
michael@0 | 353 | }, |
michael@0 | 354 | |
michael@0 | 355 | forget: function forget(network) { |
michael@0 | 356 | var request = this.createRequest(); |
michael@0 | 357 | this._sendMessageForRequest("WifiManager:forget", |
michael@0 | 358 | this._convertWifiNetworkToJSON(network), request); |
michael@0 | 359 | return request; |
michael@0 | 360 | }, |
michael@0 | 361 | |
michael@0 | 362 | wps: function wps(detail) { |
michael@0 | 363 | var request = this.createRequest(); |
michael@0 | 364 | this._sendMessageForRequest("WifiManager:wps", detail, request); |
michael@0 | 365 | return request; |
michael@0 | 366 | }, |
michael@0 | 367 | |
michael@0 | 368 | setPowerSavingMode: function setPowerSavingMode(enabled) { |
michael@0 | 369 | var request = this.createRequest(); |
michael@0 | 370 | this._sendMessageForRequest("WifiManager:setPowerSavingMode", enabled, request); |
michael@0 | 371 | return request; |
michael@0 | 372 | }, |
michael@0 | 373 | |
michael@0 | 374 | setHttpProxy: function setHttpProxy(network, info) { |
michael@0 | 375 | var request = this.createRequest(); |
michael@0 | 376 | this._sendMessageForRequest("WifiManager:setHttpProxy", |
michael@0 | 377 | { network: this._convertWifiNetworkToJSON(network), info:info}, request); |
michael@0 | 378 | return request; |
michael@0 | 379 | }, |
michael@0 | 380 | |
michael@0 | 381 | setStaticIpMode: function setStaticIpMode(network, info) { |
michael@0 | 382 | var request = this.createRequest(); |
michael@0 | 383 | this._sendMessageForRequest("WifiManager:setStaticIpMode", |
michael@0 | 384 | { network: this._convertWifiNetworkToJSON(network), info: info}, request); |
michael@0 | 385 | return request; |
michael@0 | 386 | }, |
michael@0 | 387 | |
michael@0 | 388 | get enabled() { |
michael@0 | 389 | return this._enabled; |
michael@0 | 390 | }, |
michael@0 | 391 | |
michael@0 | 392 | get macAddress() { |
michael@0 | 393 | return this._macAddress; |
michael@0 | 394 | }, |
michael@0 | 395 | |
michael@0 | 396 | get connection() { |
michael@0 | 397 | let _connection = this._convertConnection({ status: this._connectionStatus, |
michael@0 | 398 | network: this._currentNetwork, |
michael@0 | 399 | }); |
michael@0 | 400 | return _connection; |
michael@0 | 401 | }, |
michael@0 | 402 | |
michael@0 | 403 | get connectionInformation() { |
michael@0 | 404 | return this._lastConnectionInfo; |
michael@0 | 405 | }, |
michael@0 | 406 | |
michael@0 | 407 | defineEventHandlerGetterSetter: function(name) { |
michael@0 | 408 | Object.defineProperty(this, name, { |
michael@0 | 409 | get: function() { |
michael@0 | 410 | return this.__DOM_IMPL__.getEventHandler(name); |
michael@0 | 411 | }, |
michael@0 | 412 | set: function(handler) { |
michael@0 | 413 | this.__DOM_IMPL__.setEventHandler(name, handler); |
michael@0 | 414 | } |
michael@0 | 415 | }); |
michael@0 | 416 | }, |
michael@0 | 417 | }; |
michael@0 | 418 | |
michael@0 | 419 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ |
michael@0 | 420 | DOMWifiManager, MozWifiNetwork, MozWifiConnection, MozWifiConnectionInfo |
michael@0 | 421 | ]); |
michael@0 | 422 | |
michael@0 | 423 | let debug; |
michael@0 | 424 | if (DEBUG) { |
michael@0 | 425 | debug = function (s) { |
michael@0 | 426 | dump("-*- DOMWifiManager component: " + s + "\n"); |
michael@0 | 427 | }; |
michael@0 | 428 | } else { |
michael@0 | 429 | debug = function (s) {}; |
michael@0 | 430 | } |