mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Backed out 6 changesets (bug 811635) for B2G debug mochitest orange.
Backed out changeset 2da820ed2587 (bug 811635) Backed out changeset 3f7ee595646d (bug 811635) Backed out changeset 96772cc4e346 (bug 811635) Backed out changeset 61694318819a (bug 811635) Backed out changeset 687a84bf0785 (bug 811635) Backed out changeset 89b90ccdf603 (bug 811635)
This commit is contained in:
parent
d334947221
commit
a6327afd01
@ -402,8 +402,6 @@
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@BINPATH@/components/DOMWifiManager.js
|
||||
@BINPATH@/components/DOMWifiManager.manifest
|
||||
@BINPATH@/components/DOMWifiP2pManager.js
|
||||
@BINPATH@/components/DOMWifiP2pManager.manifest
|
||||
@BINPATH@/components/NetworkInterfaceListService.js
|
||||
@BINPATH@/components/NetworkInterfaceListService.manifest
|
||||
@BINPATH@/components/NetworkManager.js
|
||||
|
@ -1778,26 +1778,6 @@ Navigator::HasIccManagerSupport(JSContext* /* unused */,
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
|
||||
return win && CheckPermission(win, "mobileconnection");
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
Navigator::HasWifiManagerSupport(JSContext* /* unused */,
|
||||
JSObject* aGlobal)
|
||||
{
|
||||
// On XBL scope, the global object is NOT |window|. So we have
|
||||
// to use nsContentUtils::GetObjectPrincipal to get the principal
|
||||
// and test directly with permission manager.
|
||||
|
||||
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aGlobal);
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> permMgr =
|
||||
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(permMgr, false);
|
||||
|
||||
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
||||
permMgr->TestPermissionFromPrincipal(principal, "wifi-manage", &permission);
|
||||
return nsIPermissionManager::ALLOW_ACTION == permission;
|
||||
}
|
||||
#endif // MOZ_B2G_RIL
|
||||
|
||||
#ifdef MOZ_B2G_BT
|
||||
|
@ -264,8 +264,6 @@ public:
|
||||
JSObject* aGlobal);
|
||||
static bool HasIccManagerSupport(JSContext* /* unused */,
|
||||
JSObject* aGlobal);
|
||||
static bool HasWifiManagerSupport(JSContext* /* unused */,
|
||||
JSObject* aGlobal);
|
||||
#endif // MOZ_B2G_RIL
|
||||
#ifdef MOZ_B2G_BT
|
||||
static bool HasBluetoothSupport(JSContext* /* unused */, JSObject* aGlobal);
|
||||
|
@ -113,7 +113,6 @@ this.SystemMessagePermissionsTable = {
|
||||
"nfc-powerlevel-change": {
|
||||
"settings": ["read", "write"]
|
||||
},
|
||||
"wifip2p-pairing-request": { },
|
||||
};
|
||||
|
||||
this.SystemMessagePermissionsChecker = {
|
||||
|
@ -9,7 +9,7 @@ interface nsIWifiTetheringCallback;
|
||||
/**
|
||||
* Information about networks that is exposed to network manager API consumers.
|
||||
*/
|
||||
[scriptable, uuid(e2f5c6e0-4203-11e3-aa6e-0800200c9a66)]
|
||||
[scriptable, uuid(f4cf9d88-f962-4d29-9baa-fb295dad387b)]
|
||||
interface nsINetworkInterface : nsISupports
|
||||
{
|
||||
const long NETWORK_STATE_UNKNOWN = -1;
|
||||
@ -31,7 +31,6 @@ interface nsINetworkInterface : nsISupports
|
||||
const long NETWORK_TYPE_MOBILE = 1;
|
||||
const long NETWORK_TYPE_MOBILE_MMS = 2;
|
||||
const long NETWORK_TYPE_MOBILE_SUPL = 3;
|
||||
const long NETWORK_TYPE_WIFI_P2P = 4;
|
||||
|
||||
/**
|
||||
* Network type. One of the NETWORK_TYPE_* constants.
|
||||
|
@ -692,12 +692,6 @@ var interfaceNamesInGlobalScope =
|
||||
"MozWakeLock",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiConnectionInfoEvent", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiP2pGroupOwner", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiP2pManager", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiP2pStatusChangeEvent", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiStatusChangeEvent", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
@ -1,146 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
enum WPSMethod {
|
||||
"pbc",
|
||||
"keypad",
|
||||
"display"
|
||||
};
|
||||
|
||||
dictionary WPSInfo {
|
||||
WPSMethod method;
|
||||
DOMString pin;
|
||||
};
|
||||
|
||||
[JSImplementation="@mozilla.org/wifip2pgroupowner;1"]
|
||||
interface MozWifiP2pGroupOwner {
|
||||
readonly attribute DOMString groupName;
|
||||
readonly attribute DOMString macAddress;
|
||||
readonly attribute DOMString ipAddress;
|
||||
readonly attribute DOMString passphrase;
|
||||
readonly attribute DOMString ssid;
|
||||
readonly attribute any wpsCapabilities;
|
||||
readonly attribute unsigned long freq;
|
||||
readonly attribute boolean isLocal;
|
||||
};
|
||||
|
||||
[JSImplementation="@mozilla.org/wifip2pmanager;1",
|
||||
NavigatorProperty="mozWifiP2pManager",
|
||||
Func="Navigator::HasWifiManagerSupport"]
|
||||
interface MozWifiP2pManager : EventTarget
|
||||
{
|
||||
/**
|
||||
* Enable/Disable wifi direct scan.
|
||||
*
|
||||
* onsuccess: Succeeded in starting/stopping wifi direct scan.
|
||||
* onerror: Failed to start/stop wifi direct scan.
|
||||
*
|
||||
*/
|
||||
DOMRequest setScanEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Connect to a peer with given configuration.
|
||||
*
|
||||
* @param address The peer MAC address we are going to connect.
|
||||
* @param wpsMethod The WPS method we want to use.
|
||||
* @param goIntent Number from 0 ~ 15 to indicate how much we want to be
|
||||
* the group owner.
|
||||
*
|
||||
* onsuccess: Succeeded in issueing a 'connect' request. It doesn't mean we
|
||||
* have connected to the peer.
|
||||
*
|
||||
* onerror: Failed to issue a 'connect' request, probably due to an
|
||||
* invalid peer address, unsupported wps method or any
|
||||
* preliminary error.
|
||||
*
|
||||
**/
|
||||
DOMRequest connect(DOMString address, WPSMethod wpsMethod, optional byte goIntent);
|
||||
|
||||
/**
|
||||
* Disconnect with a peer.
|
||||
*
|
||||
* @param address The mac address of the peer.
|
||||
*
|
||||
* onsuccess: Succeeded to issue a 'disconnect' request. It doesn't mean we
|
||||
* have disconnected with the peer.
|
||||
*
|
||||
* onerror: Failed to issue a 'disconnect' request, probably due to the
|
||||
* invalid peer address or any preliminary error.
|
||||
*
|
||||
*/
|
||||
DOMRequest disconnect(DOMString address);
|
||||
|
||||
/**
|
||||
* Get peer list
|
||||
*
|
||||
* onsuccess: Command success, req.result contains an array of peer objects.
|
||||
* onerror: Command failed.
|
||||
*
|
||||
* Peer object format:
|
||||
* .address MAC address of the peer (string)
|
||||
* .name the peer's device name (string)
|
||||
* .isGroupOwner if the peer is the group owner (boolean)
|
||||
* .wpsCapabilities array of the supported |WPSMethod|
|
||||
* .connectionStatus one of { "disconnected", "connecting", "connected", "disconnecting" }
|
||||
*
|
||||
*/
|
||||
DOMRequest getPeerList();
|
||||
|
||||
/**
|
||||
* Set pairing confirmation result.
|
||||
*
|
||||
* @param accepted Boolean to indicate whether we accepted the request or not.
|
||||
* @param pin The user input pin number if the wps method is keypad.
|
||||
*
|
||||
* onsuccess: Command succeeded.
|
||||
* onerror: Command failed.
|
||||
*
|
||||
*/
|
||||
DOMRequest setPairingConfirmation(boolean accepted, optional DOMString pin);
|
||||
|
||||
/**
|
||||
* Set device name.
|
||||
*
|
||||
* @param devieName The new device name we are going to set.
|
||||
*
|
||||
* onsuccess: Command succeeded.
|
||||
* onerror: Command failed.
|
||||
*
|
||||
*/
|
||||
DOMRequest setDeviceName(DOMString deviceName);
|
||||
|
||||
/**
|
||||
* Returns if Wifi Direct is enabled.
|
||||
*
|
||||
*/
|
||||
readonly attribute boolean enabled;
|
||||
|
||||
/**
|
||||
* The current group owner, null if none.
|
||||
*/
|
||||
readonly attribute MozWifiP2pGroupOwner? groupOwner;
|
||||
|
||||
/**
|
||||
* An event listener that is called whenever the Wifi Direct peer list is
|
||||
* updated. Use getPeerList() to get the up-to-date peer list.
|
||||
*/
|
||||
attribute EventHandler onpeerinfoupdate;
|
||||
|
||||
/**
|
||||
* An event listener that is called whenever Wifi Direct status changed.
|
||||
* The address of the changed peer will be stored in event.peerList.
|
||||
* See MozWifiP2pStatusChangeEvent.webidl.
|
||||
*/
|
||||
attribute EventHandler onstatuschange;
|
||||
|
||||
/**
|
||||
* An event listener that is called whenever Wifi Direct is enabled.
|
||||
*/
|
||||
attribute EventHandler onenabled;
|
||||
|
||||
/**
|
||||
* An event listener that is called whenever Wifi Direct is disabled.
|
||||
*/
|
||||
attribute EventHandler ondisabled;
|
||||
};
|
@ -1,16 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Constructor(DOMString type, optional MozWifiP2pStatusChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
|
||||
interface MozWifiP2pStatusChangeEvent : Event
|
||||
{
|
||||
readonly attribute DOMString peerAddress;
|
||||
};
|
||||
|
||||
dictionary MozWifiP2pStatusChangeEventInit : EventInit
|
||||
{
|
||||
DOMString peerAddress = "";
|
||||
};
|
@ -537,8 +537,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
WEBIDL_FILES += [
|
||||
'MozSpeakerManager.webidl',
|
||||
'MozWifiConnectionInfoEvent.webidl',
|
||||
'MozWifiP2pManager.webidl',
|
||||
'MozWifiP2pStatusChangeEvent.webidl',
|
||||
'MozWifiStatusChangeEvent.webidl',
|
||||
]
|
||||
|
||||
|
@ -1,323 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
// interface MozWifiP2pGroupOwner implementation.
|
||||
|
||||
function MozWifiP2pGroupOwner(aGo) {
|
||||
this.groupName = aGo.groupName;
|
||||
this.macAddress = aGo.macAddress;
|
||||
this.ipAddress = aGo.ipAddress;
|
||||
this.passphrase = aGo.passphrase;
|
||||
this.ssid = aGo.ssid;
|
||||
this.wpsCapabilities = aGo.wpsCapabilities;
|
||||
this.freq = aGo.freq;
|
||||
this.isLocal = aGo.isLocal;
|
||||
}
|
||||
|
||||
MozWifiP2pGroupOwner.prototype = {
|
||||
classID: Components.ID("{a9b81450-349d-11e3-aa6e-0800200c9a66}"),
|
||||
contractID: "@mozilla.org/wifip2pgroupowner;1",
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports])
|
||||
};
|
||||
|
||||
// interface MozWifiP2pManager implementation.
|
||||
|
||||
const MOZ_WIFIP2PMANAGER_CONTRACTID = "@mozilla.org/wifip2pmanager;1";
|
||||
const MOZ_WIFIP2PMANAGER_CID = Components.ID("{8d9125a0-3498-11e3-aa6e-0800200c9a66}");
|
||||
|
||||
function MozWifiP2pManager() {
|
||||
this.defineEventHandlerGetterSetter("onstatuschange");
|
||||
this.defineEventHandlerGetterSetter("onpeerinfoupdate");
|
||||
this.defineEventHandlerGetterSetter("onenabled");
|
||||
this.defineEventHandlerGetterSetter("ondisabled");
|
||||
|
||||
this.currentPeer = null;
|
||||
this.enabled = false;
|
||||
this.groupOwner = null;
|
||||
}
|
||||
|
||||
// For smaller, read-only APIs, we expose any property that doesn't begin with
|
||||
// an underscore.
|
||||
function exposeReadOnly(obj) {
|
||||
let exposedProps = {};
|
||||
for (let i in obj) {
|
||||
if (i[0] === "_") {
|
||||
continue;
|
||||
}
|
||||
exposedProps[i] = "r";
|
||||
}
|
||||
|
||||
obj.__exposedProps__ = exposedProps;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function debug(msg) {
|
||||
if (DEBUG) {
|
||||
dump('-------------- MozWifiP2pManager: ' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
MozWifiP2pManager.prototype = {
|
||||
__proto__: DOMRequestIpcHelper.prototype,
|
||||
|
||||
classID: MOZ_WIFIP2PMANAGER_CID,
|
||||
contractID: MOZ_WIFIP2PMANAGER_CONTRACTID,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer,
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupports]),
|
||||
|
||||
//
|
||||
// nsIDOMGlobalPropertyInitializer implementation.
|
||||
//
|
||||
|
||||
init: function(aWindow) {
|
||||
const messages = ["WifiP2pManager:setScanEnabled:Return:OK",
|
||||
"WifiP2pManager:setScanEnabled:Return:NO",
|
||||
"WifiP2pManager:getPeerList:Return:OK",
|
||||
"WifiP2pManager:getPeerList:Return:NO",
|
||||
"WifiP2pManager:connect:Return:OK",
|
||||
"WifiP2pManager:connect:Return:NO",
|
||||
"WifiP2pManager:disconnect:Return:OK",
|
||||
"WifiP2pManager:disconnect:Return:NO",
|
||||
"WifiP2pManager:setPairingConfirmation:Return",
|
||||
"WifiP2pManager:setDeviceName:Return:OK",
|
||||
"WifiP2pManager:setDeviceName:Return:NO",
|
||||
|
||||
"WifiP2pManager:p2pDown",
|
||||
"WifiP2pManager:p2pUp",
|
||||
"WifiP2pManager:onconnecting",
|
||||
"WifiP2pManager:onconnected",
|
||||
"WifiP2pManager:ondisconnected",
|
||||
"WifiP2pManager:ongroupnstop",
|
||||
"WifiP2pManager:onconnectingfailed",
|
||||
"WifiP2pManager:onwpstimeout",
|
||||
"WifiP2pManager:onwpsfail",
|
||||
"WifiP2pManager:onpeerinfoupdate",
|
||||
];
|
||||
|
||||
this.initDOMRequestHelper(aWindow, messages);
|
||||
this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncMessageSender);
|
||||
|
||||
// Notify the internal a new DOM mananger is created.
|
||||
let state = this._mm.sendSyncMessage("WifiP2pManager:getState")[0];
|
||||
if (state) {
|
||||
debug('State: ' + JSON.stringify(state));
|
||||
} else {
|
||||
debug('Failed to get state');
|
||||
}
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
},
|
||||
|
||||
_sendMessageForRequest: function(name, data, request) {
|
||||
let id = this.getRequestId(request);
|
||||
this._mm.sendAsyncMessage(name, { data: data, rid: id, mid: this._id });
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
let msg = aMessage.json;
|
||||
if (msg.mid && msg.mid !== this._id) {
|
||||
return;
|
||||
}
|
||||
|
||||
let request;
|
||||
switch (aMessage.name) {
|
||||
case "WifiP2pManager:setScanEnabled:Return:OK":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:setScanEnabled:Return:NO":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireError(request, "Unable to enable/disable Wifi P2P peer discovery.");
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:getPeerList:Return:OK":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireSuccess(request, msg.data);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:getPeerList:Return:NO":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireError(request, "Unable to disable Wifi P2P peer discovery.");
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:connect:Return:OK":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:connect:Return:NO":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireError(request, "Unable to connect to Wifi P2P peer.");
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:disconnect:Return:OK":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:disconnect:Return:NO":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireError(request, "Unable to disconnect to Wifi P2P peer.");
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:setDeviceName:Return:OK":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireSuccess(request, exposeReadOnly(msg.data));
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:setDeviceName:Return:NO":
|
||||
request = this.takeRequest(msg.rid);
|
||||
Services.DOMRequest.fireError(request, "Unable to set device name.");
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:p2pDown":
|
||||
this.enabled = false;
|
||||
this.currentPeer = null;
|
||||
this._fireEnabledOrDisabled(false);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:p2pUp":
|
||||
this.enabled = true;
|
||||
this._fireEnabledOrDisabled(true);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:onconnecting":
|
||||
debug('onconnecting with peer: ' + JSON.stringify(msg.peer));
|
||||
this.currentPeer = msg.peer;
|
||||
this._fireStatusChangeEvent(msg.peer.address);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:onconnected":
|
||||
debug('onconnected with peer: ' + JSON.stringify(msg.peer));
|
||||
this.currentPeer = msg.peer;
|
||||
this.groupOwner = new MozWifiP2pGroupOwner(msg.groupOwner);
|
||||
this._fireStatusChangeEvent(msg.peer.address);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:ondisconnected":
|
||||
debug('ondisconnected with peer: ' + JSON.stringify(msg.peer));
|
||||
this.currentPeer = null;
|
||||
this.groupOwner = null;
|
||||
this._fireStatusChangeEvent(msg.peer.address);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:onconnectingfailed":
|
||||
this._fireStatusChangeEvent(null);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:onwpstimeout":
|
||||
this._fireStatusChangeEvent(null);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:onwpsfail":
|
||||
this._fireStatusChangeEvent(null);
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:onpeerinfoupdate":
|
||||
this._firePeerInfoUpdateEvent();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_firePeerInfoUpdateEvent: function PeerInfoUpdate() {
|
||||
let evt = new this._window.Event("peerinfoupdate");
|
||||
this.__DOM_IMPL__.dispatchEvent(evt);
|
||||
},
|
||||
|
||||
_fireStatusChangeEvent: function WifiP2pStatusChange(peerAddress) {
|
||||
let evt = new this._window.MozWifiP2pStatusChangeEvent("statuschange",
|
||||
{ peerAddress: peerAddress });
|
||||
this.__DOM_IMPL__.dispatchEvent(evt);
|
||||
},
|
||||
|
||||
_fireEnabledOrDisabled: function enabledDisabled(enabled) {
|
||||
let evt = new this._window.Event(enabled ? "enabled" : "disabled");
|
||||
this.__DOM_IMPL__.dispatchEvent(evt);
|
||||
},
|
||||
|
||||
//
|
||||
// WifiP2pManager.webidl implementation.
|
||||
//
|
||||
|
||||
enableScan: function () {
|
||||
let request = this.createRequest();
|
||||
this._sendMessageForRequest("WifiP2pManager:enableScan", null, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
disableScan: function () {
|
||||
let request = this.createRequest();
|
||||
this._sendMessageForRequest("WifiP2pManager:disableScan", null, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
setScanEnabled: function(enabled) {
|
||||
let request = this.createRequest();
|
||||
this._sendMessageForRequest("WifiP2pManager:setScanEnabled", enabled, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
connect: function (address, wpsMethod, goIntent) {
|
||||
let request = this.createRequest();
|
||||
let connectionInfo = { address: address, wpsMethod: wpsMethod, goIntent: goIntent };
|
||||
this._sendMessageForRequest("WifiP2pManager:connect", connectionInfo, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
disconnect: function (address) {
|
||||
let request = this.createRequest();
|
||||
this._sendMessageForRequest("WifiP2pManager:disconnect", address, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
getPeerList: function () {
|
||||
let request = this.createRequest();
|
||||
this._sendMessageForRequest("WifiP2pManager:getPeerList", null, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
setPairingConfirmation: function (accepted, pin) {
|
||||
let request = this.createRequest();
|
||||
let result = { accepted: accepted, pin: pin };
|
||||
this._sendMessageForRequest("WifiP2pManager:setPairingConfirmation", result, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
setDeviceName: function(newDeviceName) {
|
||||
let request = this.createRequest();
|
||||
this._sendMessageForRequest("WifiP2pManager:setDeviceName", newDeviceName, request);
|
||||
return request;
|
||||
},
|
||||
|
||||
// Helpers.
|
||||
defineEventHandlerGetterSetter: function(event) {
|
||||
Object.defineProperty(this, event, {
|
||||
get: function() {
|
||||
return this.__DOM_IMPL__.getEventHandler(event);
|
||||
},
|
||||
|
||||
set: function(handler) {
|
||||
this.__DOM_IMPL__.setEventHandler(event, handler);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MozWifiP2pManager, MozWifiP2pGroupOwner]);
|
@ -1,6 +0,0 @@
|
||||
# DOMWifiP2pManager.js
|
||||
component {8d9125a0-3498-11e3-aa6e-0800200c9a66} DOMWifiP2pManager.js
|
||||
contract @mozilla.org/wifip2pmanager;1 {8d9125a0-3498-11e3-aa6e-0800200c9a66}
|
||||
|
||||
component {a9b81450-349d-11e3-aa6e-0800200c9a66} DOMWifiP2pManager.js
|
||||
contract @mozilla.org/wifip2pgroupowner;1 {a9b81450-349d-11e3-aa6e-0800200c9a66}
|
@ -1,205 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["StateMachine"];
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
this.StateMachine = function(aDebugTag) {
|
||||
function debug(aMsg) {
|
||||
dump('-------------- StateMachine:' + aDebugTag + ': ' + aMsg);
|
||||
}
|
||||
|
||||
var sm = {};
|
||||
|
||||
var _initialState;
|
||||
var _curState;
|
||||
var _prevState;
|
||||
var _paused;
|
||||
var _eventQueue = [];
|
||||
var _deferredEventQueue = [];
|
||||
var _defaultEventHandler;
|
||||
|
||||
// Public interfaces.
|
||||
|
||||
sm.setDefaultEventHandler = function(aDefaultEventHandler) {
|
||||
_defaultEventHandler = aDefaultEventHandler;
|
||||
};
|
||||
|
||||
sm.start = function(aInitialState) {
|
||||
_initialState = aInitialState;
|
||||
sm.gotoState(_initialState);
|
||||
};
|
||||
|
||||
sm.sendEvent = function (aEvent) {
|
||||
if (!_initialState) {
|
||||
if (DEBUG) {
|
||||
debug('StateMachine is not running. Call StateMachine.start() first.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
_eventQueue.push(aEvent);
|
||||
asyncCall(handleFirstEvent);
|
||||
};
|
||||
|
||||
sm.getPreviousState = function() {
|
||||
return _prevState;
|
||||
};
|
||||
|
||||
sm.getCurrentState = function() {
|
||||
return _curState;
|
||||
};
|
||||
|
||||
// State object maker.
|
||||
// @param aName string for this state's name.
|
||||
// @param aDelegate object:
|
||||
// .handleEvent: required.
|
||||
// .enter: called before entering this state (optional).
|
||||
// .exit: called before exiting this state (optional).
|
||||
sm.makeState = function (aName, aDelegate) {
|
||||
if (!aDelegate.handleEvent) {
|
||||
throw "handleEvent is a required delegate function.";
|
||||
}
|
||||
var nop = function() {};
|
||||
return {
|
||||
name: aName,
|
||||
enter: (aDelegate.enter || nop),
|
||||
exit: (aDelegate.exit || nop),
|
||||
handleEvent: aDelegate.handleEvent
|
||||
};
|
||||
};
|
||||
|
||||
sm.deferEvent = function (aEvent) {
|
||||
// The definition of a 'deferred event' is:
|
||||
// We are not able to handle this event now but after receiving
|
||||
// certain event or entering a new state, we might be able to handle
|
||||
// it. For example, we couldn't handle CONNECT_EVENT in the
|
||||
// diconnecting state. But once we finish doing "disconnecting", we
|
||||
// could then handle CONNECT_EVENT!
|
||||
//
|
||||
// So, the deferred event may be handled in the following cases:
|
||||
// 1. Once we entered a new state.
|
||||
// 2. Once we handled a regular event.
|
||||
if (DEBUG) {
|
||||
debug('Deferring event: ' + JSON.stringify(aEvent));
|
||||
}
|
||||
_deferredEventQueue.push(aEvent);
|
||||
};
|
||||
|
||||
// Goto the new state. If the current state is null, the exit
|
||||
// function won't be called.
|
||||
sm.gotoState = function (aNewState) {
|
||||
if (_curState) {
|
||||
if (DEBUG) {
|
||||
debug("exiting state: " + _curState.name);
|
||||
}
|
||||
_curState.exit();
|
||||
}
|
||||
|
||||
_prevState = _curState;
|
||||
_curState = aNewState;
|
||||
|
||||
if (DEBUG) {
|
||||
debug("entering state: " + _curState.name);
|
||||
}
|
||||
_curState.enter();
|
||||
|
||||
// We are in the new state now. We got a chance to handle the
|
||||
// deferred events.
|
||||
handleDeferredEvents();
|
||||
|
||||
sm.resume();
|
||||
};
|
||||
|
||||
// No incoming event will be handled after you call pause().
|
||||
// (But they will be queued.)
|
||||
sm.pause = function() {
|
||||
_paused = true;
|
||||
};
|
||||
|
||||
// Continue to handle incoming events.
|
||||
sm.resume = function() {
|
||||
_paused = false;
|
||||
asyncCall(handleFirstEvent);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Private stuff
|
||||
//----------------------------------------------------------
|
||||
|
||||
function asyncCall(f) {
|
||||
Services.tm.currentThread.dispatch(f, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
function handleFirstEvent() {
|
||||
var hadDeferredEvents;
|
||||
|
||||
if (0 === _eventQueue.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_paused) {
|
||||
return; // The state machine is paused now.
|
||||
}
|
||||
|
||||
hadDeferredEvents = _deferredEventQueue.length > 0;
|
||||
|
||||
handleOneEvent(_eventQueue.shift()); // The handler may defer this event.
|
||||
|
||||
// We've handled one event. If we had deferred events before, now is
|
||||
// a good chance to handle them.
|
||||
if (hadDeferredEvents) {
|
||||
handleDeferredEvents();
|
||||
}
|
||||
|
||||
// Continue to handle the next regular event.
|
||||
handleFirstEvent();
|
||||
}
|
||||
|
||||
function handleDeferredEvents() {
|
||||
if (_deferredEventQueue.length && DEBUG) {
|
||||
debug('Handle deferred events: ' + _deferredEventQueue.length);
|
||||
}
|
||||
for (let i = 0; i < _deferredEventQueue.length; i++) {
|
||||
handleOneEvent(_deferredEventQueue.shift());
|
||||
}
|
||||
}
|
||||
|
||||
function handleOneEvent(aEvent)
|
||||
{
|
||||
if (DEBUG) {
|
||||
debug('Handling event: ' + JSON.stringify(aEvent));
|
||||
}
|
||||
|
||||
var handled = _curState.handleEvent(aEvent);
|
||||
|
||||
if (undefined === handled) {
|
||||
throw "handleEvent returns undefined: " + _curState.name;
|
||||
}
|
||||
if (!handled) {
|
||||
// Event is not handled in the current state. Try handleEventCommon().
|
||||
handled = (_defaultEventHandler ? _defaultEventHandler(aEvent) : handled);
|
||||
}
|
||||
if (undefined === handled) {
|
||||
throw "handleEventCommon returns undefined: " + _curState.name;
|
||||
}
|
||||
if (!handled) {
|
||||
if (DEBUG) {
|
||||
debug('!!!!!!!!! FIXME !!!!!!!!! Event not handled: ' + JSON.stringify(aEvent));
|
||||
}
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
return sm;
|
||||
};
|
@ -14,15 +14,8 @@ Cu.import("resource://gre/modules/systemlibs.js");
|
||||
|
||||
const SUPP_PROP = "init.svc.wpa_supplicant";
|
||||
const WPA_SUPPLICANT = "wpa_supplicant";
|
||||
const DEBUG = false;
|
||||
|
||||
this.WifiCommand = function(aControlMessage, aInterface) {
|
||||
function debug(msg) {
|
||||
if (DEBUG) {
|
||||
dump('-------------- WifiCommand: ' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
var command = {};
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -142,16 +135,14 @@ this.WifiCommand = function(aControlMessage, aInterface) {
|
||||
doStringCommand("LOG_LEVEL", callback);
|
||||
};
|
||||
|
||||
command.wpsPbc = function (iface, callback) {
|
||||
doBooleanCommand("WPS_PBC" + (iface ? (" interface=" + iface) : ""),
|
||||
"OK", callback);
|
||||
command.wpsPbc = function (callback) {
|
||||
doBooleanCommand("WPS_PBC", "OK", callback);
|
||||
};
|
||||
|
||||
command.wpsPin = function (detail, callback) {
|
||||
doStringCommand("WPS_PIN " +
|
||||
(detail.bssid === undefined ? "any" : detail.bssid) +
|
||||
(detail.pin === undefined ? "" : (" " + detail.pin)) +
|
||||
(detail.iface ? (" interface=" + detail.iface) : ""),
|
||||
(detail.pin === undefined ? "" : (" " + detail.pin)),
|
||||
callback);
|
||||
};
|
||||
|
||||
@ -346,89 +337,9 @@ this.WifiCommand = function(aControlMessage, aInterface) {
|
||||
});
|
||||
};
|
||||
|
||||
command.setDeviceName = function(deviceName, callback) {
|
||||
doBooleanCommand("SET device_name " + deviceName, "OK", callback);
|
||||
};
|
||||
|
||||
//-------------------------------------------------
|
||||
// P2P commands.
|
||||
//-------------------------------------------------
|
||||
|
||||
command.p2pProvDiscovery = function(address, wpsMethod, callback) {
|
||||
var command = "P2P_PROV_DISC " + address + " " + wpsMethod;
|
||||
doBooleanCommand(command, "OK", callback);
|
||||
};
|
||||
|
||||
command.p2pConnect = function(config, callback) {
|
||||
var command = "P2P_CONNECT " + config.address + " " + config.wpsMethodWithPin + " ";
|
||||
if (config.joinExistingGroup) {
|
||||
command += "join";
|
||||
} else {
|
||||
command += "go_intent=" + config.goIntent;
|
||||
}
|
||||
|
||||
debug('P2P connect command: ' + command);
|
||||
doBooleanCommand(command, "OK", callback);
|
||||
};
|
||||
|
||||
command.p2pGroupRemove = function(iface, callback) {
|
||||
debug("groupRemove()");
|
||||
doBooleanCommand("P2P_GROUP_REMOVE " + iface, "OK", callback);
|
||||
};
|
||||
|
||||
command.p2pEnable = function(detail, callback) {
|
||||
var commandChain = ["SET device_name " + detail.deviceName,
|
||||
"SET device_type " + detail.deviceType,
|
||||
"SET config_methods " + detail.wpsMethods,
|
||||
"P2P_SET conc_pref sta",
|
||||
"P2P_FLUSH"];
|
||||
|
||||
doBooleanCommandChain(commandChain, callback);
|
||||
};
|
||||
|
||||
command.p2pDisable = function(callback) {
|
||||
doBooleanCommand("P2P_SET disabled 1", "OK", callback);
|
||||
};
|
||||
|
||||
command.p2pEnableScan = function(timeout, callback) {
|
||||
doBooleanCommand("P2P_FIND " + timeout, "OK", callback);
|
||||
};
|
||||
|
||||
command.p2pDisableScan = function(callback) {
|
||||
doBooleanCommand("P2P_STOP_FIND", "OK", callback);
|
||||
};
|
||||
|
||||
command.p2pGetGroupCapab = function(address, callback) {
|
||||
command.p2pPeer(address, function(reply) {
|
||||
debug('p2p_peer reply: ' + reply);
|
||||
if (!reply) {
|
||||
callback(0);
|
||||
return;
|
||||
}
|
||||
var capab = /group_capab=0x([0-9a-fA-F]+)/.exec(reply)[1];
|
||||
if (!capab) {
|
||||
callback(0);
|
||||
} else {
|
||||
callback(parseInt(capab, 16));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
command.p2pPeer = function(address, callback) {
|
||||
doStringCommand("P2P_PEER " + address, callback);
|
||||
};
|
||||
|
||||
command.p2pGroupAdd = function(netId, callback) {
|
||||
doBooleanCommand("P2P_GROUP_ADD persistent=" + netId, callback);
|
||||
};
|
||||
|
||||
command.p2pReinvoke = function(netId, address, callback) {
|
||||
doBooleanCommand("P2P_INVITE persistent=" + netId + " peer=" + address, "OK", callback);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Private stuff.
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------
|
||||
// Helper functions.
|
||||
//--------------------------------------------------
|
||||
|
||||
function voidControlMessage(cmd, callback) {
|
||||
aControlMessage({ cmd: cmd, iface: aInterface }, function (data) {
|
||||
@ -480,10 +391,6 @@ this.WifiCommand = function(aControlMessage, aInterface) {
|
||||
});
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// Helper functions.
|
||||
//--------------------------------------------------
|
||||
|
||||
function stopProcess(service, process, callback) {
|
||||
var count = 0;
|
||||
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
|
@ -11,23 +11,16 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
|
||||
"@mozilla.org/network/service;1",
|
||||
"nsINetworkService");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkManager",
|
||||
"@mozilla.org/network/manager;1",
|
||||
"nsINetworkManager");
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["WifiNetUtil"];
|
||||
|
||||
const DHCP_PROP = "init.svc.dhcpcd";
|
||||
const DHCP = "dhcpcd";
|
||||
const DEBUG = false;
|
||||
|
||||
this.WifiNetUtil = function(controlMessage) {
|
||||
function debug(msg) {
|
||||
if (DEBUG) {
|
||||
dump('-------------- NetUtil: ' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
var util = {};
|
||||
|
||||
util.configureInterface = function(cfg, callback) {
|
||||
@ -74,14 +67,14 @@ this.WifiNetUtil = function(controlMessage) {
|
||||
});
|
||||
};
|
||||
|
||||
util.startDhcpServer = function (config, callback) {
|
||||
gNetworkService.setDhcpServer(true, config, function (error) {
|
||||
util.startDhcpServer = function (range, callback) {
|
||||
gNetworkManager.setDhcpServer(true, range, function (error) {
|
||||
callback(!error);
|
||||
});
|
||||
};
|
||||
|
||||
util.stopDhcpServer = function (callback) {
|
||||
gNetworkService.setDhcpServer(false, null, function (error) {
|
||||
gNetworkManager.setDhcpServer(false, null, function (error) {
|
||||
callback(!error);
|
||||
});
|
||||
};
|
||||
@ -142,7 +135,6 @@ this.WifiNetUtil = function(controlMessage) {
|
||||
|
||||
util.runIpConfig = function (name, data, callback) {
|
||||
if (!data) {
|
||||
debug("IP config failed to run");
|
||||
callback({ info: data });
|
||||
return;
|
||||
}
|
||||
@ -150,19 +142,16 @@ this.WifiNetUtil = function(controlMessage) {
|
||||
setProperty("net." + name + ".dns1", ipToString(data.dns1),
|
||||
function(ok) {
|
||||
if (!ok) {
|
||||
debug("Unable to set net.<ifname>.dns1");
|
||||
return;
|
||||
}
|
||||
setProperty("net." + name + ".dns2", ipToString(data.dns2),
|
||||
function(ok) {
|
||||
if (!ok) {
|
||||
debug("Unable to set net.<ifname>.dns2");
|
||||
return;
|
||||
}
|
||||
setProperty("net." + name + ".gw", ipToString(data.gateway),
|
||||
function(ok) {
|
||||
if (!ok) {
|
||||
debug("Unable to set net.<ifname>.gw");
|
||||
return;
|
||||
}
|
||||
callback({ info: data });
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,303 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
const CONNECTION_STATUS_DISCONNECTED = "disconnected";
|
||||
const CONNECTION_STATUS_CONNECTING = "connecting";
|
||||
const CONNECTION_STATUS_CONNECTED = "connected";
|
||||
const CONNECTION_STATUS_DISCONNECTING = "disconnecting";
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["WifiP2pWorkerObserver"];
|
||||
|
||||
// WifiP2pWorkerObserver resides in WifiWorker to handle DOM message
|
||||
// by either 1) returning internally maintained information or
|
||||
// 2) delegating to aDomMsgResponder. It is also responsible
|
||||
// for observing events from WifiP2pManager and dispatch to DOM.
|
||||
//
|
||||
// @param aDomMsgResponder handles DOM messages, including
|
||||
// - setScanEnabled
|
||||
// - connect
|
||||
// - disconnect
|
||||
// - setPairingConfirmation
|
||||
// The instance is actually WifiP2pManager.
|
||||
this.WifiP2pWorkerObserver = function(aDomMsgResponder) {
|
||||
function debug(aMsg) {
|
||||
if (DEBUG) {
|
||||
dump('-------------- WifiP2pWorkerObserver: ' + aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// Private member variables.
|
||||
let _localDevice;
|
||||
let _peerList = {}; // List of P2pDevice.
|
||||
let _domManagers = [];
|
||||
|
||||
// Constructor of P2pDevice. It will be exposed to DOM.
|
||||
//
|
||||
// @param aPeer object representing a P2P device:
|
||||
// .name: string for the device name.
|
||||
// .address: Mac address.
|
||||
// .isGroupOwner: boolean to indicate if this device is the group owner.
|
||||
// .wpsCapabilities: array of string of {"pbc", "display", "keypad"}.
|
||||
function P2pDevice(aPeer) {
|
||||
this.address = aPeer.address;
|
||||
this.name = (aPeer.name ? aPeer.name : aPeer.address);
|
||||
this.isGroupOwner = aPeer.isGroupOwner;
|
||||
this.wpsCapabilities = aPeer.wpsCapabilities;
|
||||
this.connectionStatus = CONNECTION_STATUS_DISCONNECTED;
|
||||
|
||||
// Since this object will be exposed to web, defined the exposed
|
||||
// properties here.
|
||||
this.__exposedProps__ = {
|
||||
address: "r",
|
||||
name: "r",
|
||||
isGroupOwner: "r",
|
||||
wpsCapabilities: "r",
|
||||
connectionStatus: "r"
|
||||
};
|
||||
}
|
||||
|
||||
// Constructor of P2pGroupOwner.
|
||||
//
|
||||
// @param aGroupOwner:
|
||||
// .macAddress
|
||||
// .ipAddress
|
||||
// .passphrase
|
||||
// .ssid
|
||||
// .freq
|
||||
// .isLocal
|
||||
function P2pGroupOwner(aGroupOwner) {
|
||||
this.macAddress = aGroupOwner.macAddress; // The identifier to get further information.
|
||||
this.ipAddress = aGroupOwner.ipAddress;
|
||||
this.passphrase = aGroupOwner.passphrase;
|
||||
this.ssid = aGroupOwner.ssid; // e.g. DIRECT-xy.
|
||||
this.freq = aGroupOwner.freq;
|
||||
this.isLocal = aGroupOwner.isLocal;
|
||||
|
||||
let detail = _peerList[aGroupOwner.macAddress];
|
||||
if (detail) {
|
||||
this.name = detail.name;
|
||||
this.wpsCapabilities = detail.wpsCapabilities;
|
||||
} else if (_localDevice.address === this.macAddress) {
|
||||
this.name = _localDevice.name;
|
||||
this.wpsCapabilities = _localDevice.wpsCapabilities;
|
||||
} else {
|
||||
debug("We don't know this group owner: " + aGroupOwner.macAddress);
|
||||
this.name = aGroupOwner.macAddress;
|
||||
this.wpsCapabilities = [];
|
||||
}
|
||||
}
|
||||
|
||||
function fireEvent(aMessage, aData) {
|
||||
debug('domManager: ' + JSON.stringify(_domManagers));
|
||||
_domManagers.forEach(function(manager) {
|
||||
// Note: We should never have a dead message manager here because we
|
||||
// observe our child message managers shutting down below.
|
||||
manager.sendAsyncMessage("WifiP2pManager:" + aMessage, aData);
|
||||
});
|
||||
}
|
||||
|
||||
function addDomManager(aMsg) {
|
||||
if (-1 === _domManagers.indexOf(aMsg.manager)) {
|
||||
_domManagers.push(aMsg.manager);
|
||||
}
|
||||
}
|
||||
|
||||
function returnMessage(aMessage, aSuccess, aData, aMsg) {
|
||||
let rMsg = aMessage + ":Return:" + (aSuccess ? "OK" : "NO");
|
||||
aMsg.manager.sendAsyncMessage(rMsg,
|
||||
{ data: aData, rid: aMsg.rid, mid: aMsg.mid });
|
||||
}
|
||||
|
||||
function handlePeerListUpdated() {
|
||||
fireEvent("onpeerinfoupdate", {});
|
||||
}
|
||||
|
||||
// Return a literal object as the constructed object.
|
||||
return {
|
||||
onLocalDeviceChanged: function(aDevice) {
|
||||
_localDevice = aDevice;
|
||||
debug('Local device updated to: ' + JSON.stringify(_localDevice));
|
||||
},
|
||||
|
||||
onEnabled: function() {
|
||||
_peerList = [];
|
||||
fireEvent("p2pUp", {});
|
||||
},
|
||||
|
||||
onDisbaled: function() {
|
||||
fireEvent("p2pDown", {});
|
||||
},
|
||||
|
||||
onPeerFound: function(aPeer) {
|
||||
let newFoundPeer = new P2pDevice(aPeer);
|
||||
let origianlPeer = _peerList[aPeer.address];
|
||||
_peerList[aPeer.address] = newFoundPeer;
|
||||
if (origianlPeer) {
|
||||
newFoundPeer.connectionStatus = origianlPeer.connectionStatus;
|
||||
}
|
||||
handlePeerListUpdated();
|
||||
},
|
||||
|
||||
onPeerLost: function(aPeer) {
|
||||
let lostPeer = _peerList[aPeer.address];
|
||||
if (!lostPeer) {
|
||||
debug('Unknown peer lost: ' + aPeer.address);
|
||||
return;
|
||||
}
|
||||
delete _peerList[aPeer.address];
|
||||
handlePeerListUpdated();
|
||||
},
|
||||
|
||||
onConnecting: function(aPeer) {
|
||||
let peer = _peerList[aPeer.address];
|
||||
if (!peer) {
|
||||
debug('Unknown peer connecting: ' + aPeer.address);
|
||||
peer = new P2pDevice(aPeer);
|
||||
_peerList[aPeer.address] = peer;
|
||||
handlePeerListUpdated();
|
||||
}
|
||||
peer.connectionStatus = CONNECTION_STATUS_CONNECTING;
|
||||
|
||||
fireEvent('onconnecting', { peer: peer });
|
||||
},
|
||||
|
||||
onConnected: function(aGroupOwner, aPeer) {
|
||||
let go = new P2pGroupOwner(aGroupOwner);
|
||||
let peer = _peerList[aPeer.address];
|
||||
if (!peer) {
|
||||
debug('Unknown peer connected: ' + aPeer.address);
|
||||
peer = new P2pDevice(aPeer);
|
||||
_peerList[aPeer.address] = peer;
|
||||
handlePeerListUpdated();
|
||||
}
|
||||
peer.connectionStatus = CONNECTION_STATUS_CONNECTED;
|
||||
peer.isGroupOwner = (aPeer.address === aGroupOwner.address);
|
||||
|
||||
fireEvent('onconnected', { groupOwner: go, peer: peer });
|
||||
},
|
||||
|
||||
onDisconnected: function(aPeer) {
|
||||
let peer = _peerList[aPeer.address];
|
||||
if (!peer) {
|
||||
debug('Unknown peer disconnected: ' + aPeer.address);
|
||||
return;
|
||||
}
|
||||
|
||||
peer.connectionStatus = CONNECTION_STATUS_DISCONNECTED;
|
||||
fireEvent('ondisconnected', { peer: peer });
|
||||
},
|
||||
|
||||
getObservedDOMMessages: function() {
|
||||
return [
|
||||
"WifiP2pManager:getState",
|
||||
"WifiP2pManager:getPeerList",
|
||||
"WifiP2pManager:setScanEnabled",
|
||||
"WifiP2pManager:connect",
|
||||
"WifiP2pManager:disconnect",
|
||||
"WifiP2pManager:setPairingConfirmation",
|
||||
"WifiP2pManager:setDeviceName"
|
||||
];
|
||||
},
|
||||
|
||||
onDOMMessage: function(aMessage) {
|
||||
let msg = aMessage.data || {};
|
||||
msg.manager = aMessage.target;
|
||||
|
||||
if ("child-process-shutdown" === aMessage.name) {
|
||||
let i;
|
||||
if (-1 !== (i = _domManagers.indexOf(msg.manager))) {
|
||||
_domManagers.splice(i, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aMessage.target.assertPermission("wifi-manage")) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aMessage.name) {
|
||||
case "WifiP2pManager:getState": // A new DOM manager is created.
|
||||
addDomManager(msg);
|
||||
return { peerList: _peerList, }; // Synchronous call. Simply return it.
|
||||
|
||||
case "WifiP2pManager:setScanEnabled":
|
||||
{
|
||||
let enabled = msg.data;
|
||||
|
||||
aDomMsgResponder.setScanEnabled(enabled, function(success) {
|
||||
returnMessage(aMessage.name, success, (success ? true : "ERROR"), msg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:getPeerList":
|
||||
{
|
||||
// Convert the object to an array.
|
||||
let peerArray = [];
|
||||
for (let key in _peerList) {
|
||||
if (_peerList.hasOwnProperty(key)) {
|
||||
peerArray.push(_peerList[key]);
|
||||
}
|
||||
}
|
||||
|
||||
returnMessage(aMessage.name, true, peerArray, msg);
|
||||
}
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:connect":
|
||||
{
|
||||
let peer = msg.data;
|
||||
|
||||
let onDoConnect = function(success) {
|
||||
returnMessage(aMessage.name, success, (success ? true : "ERROR"), msg);
|
||||
};
|
||||
|
||||
aDomMsgResponder.connect(peer.address, peer.wpsMethod,
|
||||
peer.goIntent, onDoConnect);
|
||||
}
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:disconnect":
|
||||
{
|
||||
let address = msg.data;
|
||||
|
||||
aDomMsgResponder.disconnect(address, function(success) {
|
||||
returnMessage(aMessage.name, success, (success ? true : "ERROR"), msg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:setPairingConfirmation":
|
||||
{
|
||||
let result = msg.data;
|
||||
aDomMsgResponder.setPairingConfirmation(result);
|
||||
returnMessage(aMessage.name, true, true, msg);
|
||||
}
|
||||
break;
|
||||
|
||||
case "WifiP2pManager:setDeviceName":
|
||||
{
|
||||
let newDeviceName = msg.data;
|
||||
aDomMsgResponder.setDeviceName(newDeviceName, function(success) {
|
||||
returnMessage(aMessage.name, success, (success ? true : "ERROR"), msg);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (0 === aMessage.name.indexOf("WifiP2pManager:")) {
|
||||
debug("DOM WifiP2pManager message not handled: " + aMessage.name);
|
||||
}
|
||||
} // End of switch.
|
||||
}
|
||||
};
|
||||
};
|
@ -5,7 +5,6 @@
|
||||
#include "WifiUtils.h"
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <cutils/properties.h>
|
||||
#include "prinit.h"
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "NetUtils.h"
|
||||
@ -35,14 +34,6 @@ GetSharedLibrary()
|
||||
return sWifiLib;
|
||||
}
|
||||
|
||||
static bool
|
||||
GetWifiP2pSupported()
|
||||
{
|
||||
char propP2pSupported[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.moz.wifi.p2p_supported", propP2pSupported, "0");
|
||||
return (0 == strcmp(propP2pSupported, "1"));
|
||||
}
|
||||
|
||||
// This is the same algorithm as in InflateUTF8StringToBuffer with Copy and
|
||||
// while ignoring invalids.
|
||||
// https://mxr.mozilla.org/mozilla-central/source/js/src/vm/CharacterEncoding.cpp#231
|
||||
@ -316,7 +307,7 @@ bool WpaSupplicant::ExecuteCommand(CommandOptions aOptions,
|
||||
} else if (aOptions.mCmd.EqualsLiteral("unload_driver")) {
|
||||
aResult.mStatus = mImpl->do_wifi_unload_driver();
|
||||
} else if (aOptions.mCmd.EqualsLiteral("start_supplicant")) {
|
||||
aResult.mStatus = mImpl->do_wifi_start_supplicant(GetWifiP2pSupported() ? 1 : 0);
|
||||
aResult.mStatus = mImpl->do_wifi_start_supplicant(0);
|
||||
} else if (aOptions.mCmd.EqualsLiteral("stop_supplicant")) {
|
||||
aResult.mStatus = mImpl->do_wifi_stop_supplicant(0);
|
||||
} else if (aOptions.mCmd.EqualsLiteral("connect_to_supplicant")) {
|
||||
|
@ -13,8 +13,6 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
Cu.import("resource://gre/modules/WifiCommand.jsm");
|
||||
Cu.import("resource://gre/modules/WifiNetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/WifiP2pManager.jsm");
|
||||
Cu.import("resource://gre/modules/WifiP2pWorkerObserver.jsm");
|
||||
|
||||
var DEBUG = false; // set to true to show debug messages.
|
||||
|
||||
@ -110,30 +108,16 @@ var WifiManager = (function() {
|
||||
unloadDriverEnabled: libcutils.property_get("ro.moz.wifi.unloaddriver") === "1",
|
||||
schedScanRecovery: libcutils.property_get("ro.moz.wifi.sched_scan_recover") === "false" ? false : true,
|
||||
driverDelay: libcutils.property_get("ro.moz.wifi.driverDelay"),
|
||||
p2pSupported: libcutils.property_get("ro.moz.wifi.p2p_supported") === "1",
|
||||
ifname: libcutils.property_get("wifi.interface")
|
||||
};
|
||||
}
|
||||
|
||||
let {sdkVersion, unloadDriverEnabled, schedScanRecovery, driverDelay, p2pSupported, ifname} = getStartupPrefs();
|
||||
let {sdkVersion, unloadDriverEnabled, schedScanRecovery, driverDelay, ifname} = getStartupPrefs();
|
||||
|
||||
let wifiListener = {
|
||||
onWaitEvent: function(event, iface) {
|
||||
if (manager.ifname === iface && handleEvent(event)) {
|
||||
waitForEvent(iface);
|
||||
} else if (p2pSupported) {
|
||||
if (WifiP2pManager.INTERFACE_NAME === iface) {
|
||||
// If the connection is closed, wifi.c::wifi_wait_for_event()
|
||||
// will still return 'CTRL-EVENT-TERMINATING - connection closed'
|
||||
// rather than blocking. So when we see this special event string,
|
||||
// just return immediately.
|
||||
const TERMINATED_EVENT = 'CTRL-EVENT-TERMINATING - connection closed';
|
||||
if (-1 !== event.indexOf(TERMINATED_EVENT)) {
|
||||
return;
|
||||
}
|
||||
p2pManager.handleEvent(event);
|
||||
waitForEvent(iface);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -151,29 +135,18 @@ var WifiManager = (function() {
|
||||
manager.schedScanRecovery = schedScanRecovery;
|
||||
manager.driverDelay = driverDelay ? parseInt(driverDelay, 10) : DRIVER_READY_WAIT;
|
||||
|
||||
// Regular Wifi stuff.
|
||||
var netUtil = WifiNetUtil(controlMessage);
|
||||
var wifiCommand = WifiCommand(controlMessage, manager.ifname);
|
||||
|
||||
// Wifi P2P stuff
|
||||
var p2pManager;
|
||||
if (p2pSupported) {
|
||||
let p2pCommand = WifiCommand(controlMessage, WifiP2pManager.INTERFACE_NAME);
|
||||
p2pManager = WifiP2pManager(p2pCommand, netUtil);
|
||||
}
|
||||
|
||||
let wifiService = Cc["@mozilla.org/wifi/service;1"];
|
||||
if (wifiService) {
|
||||
wifiService = wifiService.getService(Ci.nsIWifiProxyService);
|
||||
let interfaces = [manager.ifname];
|
||||
if (p2pSupported) {
|
||||
interfaces.push(WifiP2pManager.INTERFACE_NAME);
|
||||
}
|
||||
wifiService.start(wifiListener, interfaces, interfaces.length);
|
||||
} else {
|
||||
debug("No wifi service component available!");
|
||||
}
|
||||
|
||||
var wifiCommand = WifiCommand(controlMessage, manager.ifname);
|
||||
var netUtil = WifiNetUtil(controlMessage);
|
||||
|
||||
// Callbacks to invoke when a reply arrives from the wifi service.
|
||||
var controlCallbacks = Object.create(null);
|
||||
var idgen = 0;
|
||||
@ -271,7 +244,6 @@ var WifiManager = (function() {
|
||||
wifiCommand.doSetScanMode(true, function(ignore) {
|
||||
setBackgroundScan("OFF", function(turned, ignore) {
|
||||
reEnableBackgroundScan = turned;
|
||||
manager.handlePreWifiScan();
|
||||
wifiCommand.scan(function(ok) {
|
||||
wifiCommand.doSetScanMode(false, function(ignore) {
|
||||
// The result of scanCommand is the result of the actual SCAN
|
||||
@ -283,7 +255,6 @@ var WifiManager = (function() {
|
||||
});
|
||||
return;
|
||||
}
|
||||
manager.handlePreWifiScan();
|
||||
wifiCommand.scan(callback);
|
||||
}
|
||||
|
||||
@ -296,7 +267,6 @@ var WifiManager = (function() {
|
||||
if (ok)
|
||||
debugEnabled = wanted;
|
||||
});
|
||||
p2pManager.setDebug(DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
@ -785,7 +755,6 @@ var WifiManager = (function() {
|
||||
reEnableBackgroundScan = false;
|
||||
setBackgroundScan("ON", function() {});
|
||||
}
|
||||
manager.handlePostWifiScan();
|
||||
notify("scanresultsavailable");
|
||||
return true;
|
||||
}
|
||||
@ -817,10 +786,6 @@ var WifiManager = (function() {
|
||||
notify("supplicantconnection");
|
||||
callback();
|
||||
});
|
||||
|
||||
if (p2pSupported) {
|
||||
manager.enableP2p(function(success) {});
|
||||
}
|
||||
}
|
||||
|
||||
function prepareForStartup(callback) {
|
||||
@ -946,27 +911,19 @@ var WifiManager = (function() {
|
||||
// Note these following calls ignore errors. If we fail to kill the
|
||||
// supplicant gracefully, then we need to continue telling it to die
|
||||
// until it does.
|
||||
let doDisableWifi = function() {
|
||||
manager.state = "DISABLING";
|
||||
wifiCommand.terminateSupplicant(function (ok) {
|
||||
manager.connectionDropped(function () {
|
||||
wifiCommand.stopSupplicant(function (status) {
|
||||
wifiCommand.closeSupplicantConnection(function () {
|
||||
manager.state = "UNINITIALIZED";
|
||||
netUtil.disableInterface(manager.ifname, function (ok) {
|
||||
unloadDriver(WIFI_FIRMWARE_STATION, callback);
|
||||
});
|
||||
manager.state = "DISABLING";
|
||||
wifiCommand.terminateSupplicant(function (ok) {
|
||||
manager.connectionDropped(function () {
|
||||
wifiCommand.stopSupplicant(function (status) {
|
||||
wifiCommand.closeSupplicantConnection(function () {
|
||||
manager.state = "UNINITIALIZED";
|
||||
netUtil.disableInterface(manager.ifname, function (ok) {
|
||||
unloadDriver(WIFI_FIRMWARE_STATION, callback);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (p2pSupported) {
|
||||
p2pManager.setEnabled(false, { onDisabled: doDisableWifi });
|
||||
} else {
|
||||
doDisableWifi();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1178,11 +1135,6 @@ var WifiManager = (function() {
|
||||
wifiCommand.saveConfig(callback);
|
||||
}
|
||||
manager.enableNetwork = function(netId, disableOthers, callback) {
|
||||
if (p2pSupported) {
|
||||
// We have to stop wifi direct scan before associating to an AP.
|
||||
// Otherwise we will get a "REJECT" wpa supplicant event.
|
||||
p2pManager.setScanEnabled(false, function(success) {});
|
||||
}
|
||||
wifiCommand.enableNetwork(netId, disableOthers, callback);
|
||||
}
|
||||
manager.disableNetwork = function(netId, callback) {
|
||||
@ -1263,46 +1215,6 @@ var WifiManager = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
manager.handlePreWifiScan = function() {
|
||||
if (p2pSupported) {
|
||||
// Before doing regular wifi scan, we have to disable wifi direct
|
||||
// scan first. Otherwise we will never get the scan result.
|
||||
p2pManager.blockScan();
|
||||
}
|
||||
};
|
||||
|
||||
manager.handlePostWifiScan = function() {
|
||||
if (p2pSupported) {
|
||||
// After regular wifi scanning, we should restore the restricted
|
||||
// wifi direct scan.
|
||||
p2pManager.unblockScan();
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Public APIs for P2P.
|
||||
//
|
||||
|
||||
manager.p2pSupported = function() {
|
||||
return p2pSupported;
|
||||
};
|
||||
|
||||
manager.getP2pManager = function() {
|
||||
return p2pManager;
|
||||
};
|
||||
|
||||
manager.enableP2p = function(callback) {
|
||||
p2pManager.setEnabled(true, {
|
||||
onSupplicantConnected: function() {
|
||||
wifiService.waitForEvent(WifiP2pManager.INTERFACE_NAME);
|
||||
},
|
||||
|
||||
onEnabled: function(success) {
|
||||
callback(success);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return manager;
|
||||
})();
|
||||
|
||||
@ -1585,17 +1497,6 @@ function WifiWorker() {
|
||||
this._connectionInfoTimer = null;
|
||||
this._reconnectOnDisconnect = false;
|
||||
|
||||
// Create p2pObserver and assign to p2pManager.
|
||||
if (WifiManager.p2pSupported()) {
|
||||
this._p2pObserver = WifiP2pWorkerObserver(WifiManager.getP2pManager());
|
||||
WifiManager.getP2pManager().setObserver(this._p2pObserver);
|
||||
|
||||
// Add DOM message observerd by p2pObserver to the message listener as well.
|
||||
this._p2pObserver.getObservedDOMMessages().forEach((function(msgName) {
|
||||
this._mm.addMessageListener(msgName, this);
|
||||
}).bind(this));
|
||||
}
|
||||
|
||||
// Users of instances of nsITimer should keep a reference to the timer until
|
||||
// it is no longer needed in order to assure the timer is fired.
|
||||
this._callbackTimer = null;
|
||||
@ -1628,7 +1529,6 @@ function WifiWorker() {
|
||||
// wait for our next command) ensure that background scanning is on and
|
||||
// then try again.
|
||||
debug("Determined that scanning is stuck, turning on background scanning!");
|
||||
WifiManager.handlePostWifiScan();
|
||||
WifiManager.disconnect(function(ok) {});
|
||||
self._turnOnBackgroundScan = true;
|
||||
}
|
||||
@ -2404,15 +2304,6 @@ WifiWorker.prototype = {
|
||||
let msg = aMessage.data || {};
|
||||
msg.manager = aMessage.target;
|
||||
|
||||
if (WifiManager.p2pSupported()) {
|
||||
// If p2pObserver returns something truthy, return it!
|
||||
// Otherwise, continue to do the rest of tasks.
|
||||
var p2pRet = this._p2pObserver.onDOMMessage(aMessage);
|
||||
if (p2pRet) {
|
||||
return p2pRet;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: By the time we receive child-process-shutdown, the child process
|
||||
// has already forgotten its permissions so we do this before the
|
||||
// permissions check.
|
||||
@ -2502,6 +2393,79 @@ WifiWorker.prototype = {
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
getWifiScanResults: function(callback) {
|
||||
var count = 0;
|
||||
var timer = null;
|
||||
var self = this;
|
||||
|
||||
self.waitForScan(waitForScanCallback);
|
||||
doScan();
|
||||
function doScan() {
|
||||
WifiManager.scan(true, function (ok) {
|
||||
if (!ok) {
|
||||
if (!timer) {
|
||||
count = 0;
|
||||
timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
}
|
||||
|
||||
if (count++ >= 3) {
|
||||
timer = null;
|
||||
this.wantScanResults.splice(this.wantScanResults.indexOf(waitForScanCallback), 1);
|
||||
callback.onfailure();
|
||||
return;
|
||||
}
|
||||
|
||||
// Else it's still running, continue waiting.
|
||||
timer.initWithCallback(doScan, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function waitForScanCallback(networks) {
|
||||
if (networks === null) {
|
||||
callback.onfailure();
|
||||
return;
|
||||
}
|
||||
|
||||
var wifiScanResults = new Array();
|
||||
var net;
|
||||
for (let net in networks) {
|
||||
let value = networks[net];
|
||||
wifiScanResults.push(transformResult(value));
|
||||
}
|
||||
callback.onready(wifiScanResults.length, wifiScanResults);
|
||||
}
|
||||
|
||||
function transformResult(element) {
|
||||
var result = new WifiScanResult();
|
||||
result.connected = false;
|
||||
for (let id in element) {
|
||||
if (id === "__exposedProps__") {
|
||||
continue;
|
||||
}
|
||||
if (id === "security") {
|
||||
result[id] = 0;
|
||||
var security = element[id];
|
||||
for (let j = 0; j < security.length; j++) {
|
||||
if (security[j] === "WPA-PSK") {
|
||||
result[id] |= Ci.nsIWifiScanResult.WPA_PSK;
|
||||
} else if (security[j] === "WPA-EAP") {
|
||||
result[id] |= Ci.nsIWifiScanResult.WPA_EAP;
|
||||
} else if (security[j] === "WEP") {
|
||||
result[id] |= Ci.nsIWifiScanResult.WEP;
|
||||
} else {
|
||||
result[id] = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result[id] = element[id];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
getKnownNetworks: function(msg) {
|
||||
const message = "WifiManager:getKnownNetworks:Return";
|
||||
if (!WifiManager.enabled) {
|
||||
@ -2758,7 +2722,7 @@ WifiWorker.prototype = {
|
||||
let self = this;
|
||||
let detail = msg.data;
|
||||
if (detail.method === "pbc") {
|
||||
WifiManager.wpsPbc(WifiManager.ifname, function(ok) {
|
||||
WifiManager.wpsPbc(function(ok) {
|
||||
if (ok)
|
||||
self._sendMessage(message, true, true, msg);
|
||||
else
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMMozWifiConnectionInfoEvent.idl',
|
||||
'nsIDOMMozWifiP2pStatusChangeEvent.idl',
|
||||
'nsIDOMMozWifiStatusChangeEvent.idl',
|
||||
'nsIWifi.idl',
|
||||
'nsIWifiService.idl',
|
||||
@ -17,18 +16,13 @@ XPIDL_MODULE = 'dom_wifi'
|
||||
EXTRA_COMPONENTS += [
|
||||
'DOMWifiManager.js',
|
||||
'DOMWifiManager.manifest',
|
||||
'DOMWifiP2pManager.js',
|
||||
'DOMWifiP2pManager.manifest',
|
||||
'WifiWorker.js',
|
||||
'WifiWorker.manifest',
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'StateMachine.jsm',
|
||||
'WifiCommand.jsm',
|
||||
'WifiNetUtil.jsm',
|
||||
'WifiP2pManager.jsm',
|
||||
'WifiP2pWorkerObserver.jsm',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
|
@ -1,24 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIDOMEvent.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(82cad910-2019-11e3-8224-0800200c9a66)]
|
||||
interface nsIDOMMozWifiP2pStatusChangeEvent : nsIDOMEvent
|
||||
{
|
||||
/**
|
||||
* The mac address of the peer whose status has just changed.
|
||||
*/
|
||||
readonly attribute DOMString peerAddress;
|
||||
|
||||
[noscript] void initMozWifiP2pStatusChangeEvent(in DOMString aType,
|
||||
in boolean aCanBubble,
|
||||
in boolean aCancelable,
|
||||
in DOMString aPeerAddress);
|
||||
};
|
||||
|
||||
dictionary MozWifiP2pStatusChangeEventInit : EventInit
|
||||
{
|
||||
DOMString peerAddress;
|
||||
};
|
@ -24,7 +24,6 @@ simple_events = [
|
||||
'StyleSheetChangeEvent',
|
||||
'StyleSheetApplicableStateChangeEvent',
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
'MozWifiP2pStatusChangeEvent',
|
||||
'MozWifiStatusChangeEvent',
|
||||
'MozWifiConnectionInfoEvent',
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user