mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1167132 - Part 3: [NetworkManager] Move network information into a separate interface (Wifi). r=hchang
This commit is contained in:
parent
4814a82ec4
commit
637babbd6a
@ -490,39 +490,44 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
|
||||
let _p2pNetworkInterface = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface]),
|
||||
|
||||
state: Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED,
|
||||
type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI_P2P,
|
||||
name: P2P_INTERFACE_NAME,
|
||||
ips: [],
|
||||
prefixLengths: [],
|
||||
dnses: [],
|
||||
gateways: [],
|
||||
info: {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInfo]),
|
||||
|
||||
state: Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED,
|
||||
type: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI_P2P,
|
||||
name: P2P_INTERFACE_NAME,
|
||||
ips: [],
|
||||
prefixLengths: [],
|
||||
dnses: [],
|
||||
gateways: [],
|
||||
|
||||
getAddresses: function (ips, prefixLengths) {
|
||||
ips.value = this.ips.slice();
|
||||
prefixLengths.value = this.prefixLengths.slice();
|
||||
|
||||
return this.ips.length;
|
||||
},
|
||||
|
||||
getGateways: function (count) {
|
||||
if (count) {
|
||||
count.value = this.gateways.length;
|
||||
}
|
||||
return this.gateways.slice();
|
||||
},
|
||||
|
||||
getDnses: function (count) {
|
||||
if (count) {
|
||||
count.value = this.dnses.length;
|
||||
}
|
||||
return this.dnses.slice();
|
||||
}
|
||||
},
|
||||
|
||||
httpProxyHost: null,
|
||||
httpProxyPort: null,
|
||||
|
||||
// help
|
||||
registered: false,
|
||||
|
||||
getAddresses: function (ips, prefixLengths) {
|
||||
ips.value = this.ips.slice();
|
||||
prefixLengths.value = this.prefixLengths.slice();
|
||||
|
||||
return this.ips.length;
|
||||
},
|
||||
|
||||
getGateways: function (count) {
|
||||
if (count) {
|
||||
count.value = this.gateways.length;
|
||||
}
|
||||
return this.gateways.slice();
|
||||
},
|
||||
|
||||
getDnses: function (count) {
|
||||
if (count) {
|
||||
count.value = this.dnses.length;
|
||||
}
|
||||
return this.dnses.slice();
|
||||
}
|
||||
registered: false
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
@ -1419,10 +1424,10 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
|
||||
}
|
||||
|
||||
// Update p2p network interface.
|
||||
_p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
|
||||
_p2pNetworkInterface.ips = [GO_NETWORK_INTERFACE.ip];
|
||||
_p2pNetworkInterface.prefixLengths = [GO_NETWORK_INTERFACE.maskLength];
|
||||
_p2pNetworkInterface.gateways = [GO_NETWORK_INTERFACE.ip];
|
||||
_p2pNetworkInterface.info.state = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
|
||||
_p2pNetworkInterface.info.ips = [GO_NETWORK_INTERFACE.ip];
|
||||
_p2pNetworkInterface.info.prefixLengths = [GO_NETWORK_INTERFACE.maskLength];
|
||||
_p2pNetworkInterface.info.gateways = [GO_NETWORK_INTERFACE.ip];
|
||||
handleP2pNetworkInterfaceStateChanged();
|
||||
|
||||
_groupInfo.networkInterface = _p2pNetworkInterface;
|
||||
@ -1454,18 +1459,18 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
|
||||
if (!maskLength) {
|
||||
maskLength = 32; // max prefix for IPv4.
|
||||
}
|
||||
_p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
|
||||
_p2pNetworkInterface.ips = [dhcpData.info.ipaddr_str];
|
||||
_p2pNetworkInterface.prefixLengths = [maskLength];
|
||||
_p2pNetworkInterface.info.state = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
|
||||
_p2pNetworkInterface.info.ips = [dhcpData.info.ipaddr_str];
|
||||
_p2pNetworkInterface.info.prefixLengths = [maskLength];
|
||||
if (typeof dhcpData.info.dns1_str == "string" &&
|
||||
dhcpData.info.dns1_str.length) {
|
||||
_p2pNetworkInterface.dnses.push(dhcpData.info.dns1_str);
|
||||
_p2pNetworkInterface.info.dnses.push(dhcpData.info.dns1_str);
|
||||
}
|
||||
if (typeof dhcpData.info.dns2_str == "string" &&
|
||||
dhcpData.info.dns2_str.length) {
|
||||
_p2pNetworkInterface.dnses.push(dhcpData.info.dns2_str);
|
||||
_p2pNetworkInterface.info.dnses.push(dhcpData.info.dns2_str);
|
||||
}
|
||||
_p2pNetworkInterface.gateways = [dhcpData.info.gateway_str];
|
||||
_p2pNetworkInterface.info.gateways = [dhcpData.info.gateway_str];
|
||||
handleP2pNetworkInterfaceStateChanged();
|
||||
|
||||
_groupInfo.networkInterface = _p2pNetworkInterface;
|
||||
@ -1476,11 +1481,11 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
|
||||
}
|
||||
|
||||
function resetP2pNetworkInterface() {
|
||||
_p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
|
||||
_p2pNetworkInterface.ips = [];
|
||||
_p2pNetworkInterface.prefixLengths = [];
|
||||
_p2pNetworkInterface.dnses = [];
|
||||
_p2pNetworkInterface.gateways = [];
|
||||
_p2pNetworkInterface.info.state = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
|
||||
_p2pNetworkInterface.info.ips = [];
|
||||
_p2pNetworkInterface.info.prefixLengths = [];
|
||||
_p2pNetworkInterface.info.dnses = [];
|
||||
_p2pNetworkInterface.info.gateways = [];
|
||||
}
|
||||
|
||||
function registerP2pNetworkInteface() {
|
||||
@ -1523,7 +1528,7 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
|
||||
}
|
||||
|
||||
// Update p2p network interface.
|
||||
_p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
|
||||
_p2pNetworkInterface.info.state = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
|
||||
handleP2pNetworkInterfaceStateChanged();
|
||||
|
||||
if (P2P_ROLE_GO === aInfo.role) {
|
||||
|
@ -403,8 +403,8 @@ var WifiManager = (function() {
|
||||
WifiNetworkInterface.httpProxyHost = network.httpProxyHost;
|
||||
WifiNetworkInterface.httpProxyPort = network.httpProxyPort;
|
||||
|
||||
if (WifiNetworkInterface.state ==
|
||||
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
|
||||
if (WifiNetworkInterface.info.state ==
|
||||
Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
|
||||
gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
|
||||
}
|
||||
}
|
||||
@ -1014,16 +1014,17 @@ var WifiManager = (function() {
|
||||
if (enabled) {
|
||||
manager.state = "INITIALIZING";
|
||||
// Register as network interface.
|
||||
WifiNetworkInterface.name = manager.ifname;
|
||||
WifiNetworkInterface.info.name = manager.ifname;
|
||||
if (!WifiNetworkInterface.registered) {
|
||||
gNetworkManager.registerNetworkInterface(WifiNetworkInterface);
|
||||
WifiNetworkInterface.registered = true;
|
||||
}
|
||||
WifiNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
|
||||
WifiNetworkInterface.ips = [];
|
||||
WifiNetworkInterface.prefixLengths = [];
|
||||
WifiNetworkInterface.gateways = [];
|
||||
WifiNetworkInterface.dnses = [];
|
||||
WifiNetworkInterface.info.state =
|
||||
Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
|
||||
WifiNetworkInterface.info.ips = [];
|
||||
WifiNetworkInterface.info.prefixLengths = [];
|
||||
WifiNetworkInterface.info.gateways = [];
|
||||
WifiNetworkInterface.info.dnses = [];
|
||||
gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
|
||||
|
||||
prepareForStartup(function() {
|
||||
@ -1168,7 +1169,8 @@ var WifiManager = (function() {
|
||||
|
||||
function doStartWifiTethering() {
|
||||
cancelWaitForDriverReadyTimer();
|
||||
WifiNetworkInterface.name = libcutils.property_get("wifi.tethering.interface", manager.ifname);
|
||||
WifiNetworkInterface.info.name =
|
||||
libcutils.property_get("wifi.tethering.interface", manager.ifname);
|
||||
gTetheringService.setWifiTethering(enabled, WifiNetworkInterface,
|
||||
configuration, function(result) {
|
||||
if (result) {
|
||||
@ -1783,55 +1785,59 @@ let WifiNetworkInterface = {
|
||||
|
||||
// nsINetworkInterface
|
||||
|
||||
NETWORK_STATE_UNKNOWN: Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN,
|
||||
NETWORK_STATE_CONNECTING: Ci.nsINetworkInterface.CONNECTING,
|
||||
NETWORK_STATE_CONNECTED: Ci.nsINetworkInterface.CONNECTED,
|
||||
NETWORK_STATE_DISCONNECTING: Ci.nsINetworkInterface.DISCONNECTING,
|
||||
NETWORK_STATE_DISCONNECTED: Ci.nsINetworkInterface.DISCONNECTED,
|
||||
NETWORK_STATE_UNKNOWN: Ci.nsINetworkInfo.NETWORK_STATE_UNKNOWN,
|
||||
NETWORK_STATE_CONNECTING: Ci.nsINetworkInfo.CONNECTING,
|
||||
NETWORK_STATE_CONNECTED: Ci.nsINetworkInfo.CONNECTED,
|
||||
NETWORK_STATE_DISCONNECTING: Ci.nsINetworkInfo.DISCONNECTING,
|
||||
NETWORK_STATE_DISCONNECTED: Ci.nsINetworkInfo.DISCONNECTED,
|
||||
|
||||
state: Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN,
|
||||
NETWORK_TYPE_WIFI: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
|
||||
NETWORK_TYPE_MOBILE: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE,
|
||||
NETWORK_TYPE_MOBILE_MMS: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS,
|
||||
NETWORK_TYPE_MOBILE_SUPL: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL,
|
||||
|
||||
NETWORK_TYPE_WIFI: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
||||
NETWORK_TYPE_MOBILE: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE,
|
||||
NETWORK_TYPE_MOBILE_MMS: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS,
|
||||
NETWORK_TYPE_MOBILE_SUPL: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL,
|
||||
info: {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInfo]),
|
||||
|
||||
type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
||||
state: Ci.nsINetworkInfo.NETWORK_STATE_UNKNOWN,
|
||||
|
||||
name: null,
|
||||
type: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
|
||||
|
||||
ips: [],
|
||||
name: null,
|
||||
|
||||
prefixLengths: [],
|
||||
ips: [],
|
||||
|
||||
dnses: [],
|
||||
prefixLengths: [],
|
||||
|
||||
gateways: [],
|
||||
dnses: [],
|
||||
|
||||
gateways: [],
|
||||
|
||||
getAddresses: function (ips, prefixLengths) {
|
||||
ips.value = this.ips.slice();
|
||||
prefixLengths.value = this.prefixLengths.slice();
|
||||
|
||||
return this.ips.length;
|
||||
},
|
||||
|
||||
getGateways: function (count) {
|
||||
if (count) {
|
||||
count.value = this.gateways.length;
|
||||
}
|
||||
return this.gateways.slice();
|
||||
},
|
||||
|
||||
getDnses: function (count) {
|
||||
if (count) {
|
||||
count.value = this.dnses.length;
|
||||
}
|
||||
return this.dnses.slice();
|
||||
}
|
||||
},
|
||||
|
||||
httpProxyHost: null,
|
||||
|
||||
httpProxyPort: null,
|
||||
|
||||
getAddresses: function (ips, prefixLengths) {
|
||||
ips.value = this.ips.slice();
|
||||
prefixLengths.value = this.prefixLengths.slice();
|
||||
|
||||
return this.ips.length;
|
||||
},
|
||||
|
||||
getGateways: function (count) {
|
||||
if (count) {
|
||||
count.value = this.gateways.length;
|
||||
}
|
||||
return this.gateways.slice();
|
||||
},
|
||||
|
||||
getDnses: function (count) {
|
||||
if (count) {
|
||||
count.value = this.dnses.length;
|
||||
}
|
||||
return this.dnses.slice();
|
||||
}
|
||||
httpProxyPort: null
|
||||
};
|
||||
|
||||
function WifiScanResult() {}
|
||||
@ -2252,8 +2258,8 @@ function WifiWorker() {
|
||||
case "DISCONNECTED":
|
||||
// wpa_supplicant may give us a "DISCONNECTED" event even if
|
||||
// we are already in "DISCONNECTED" state.
|
||||
if ((WifiNetworkInterface.state ===
|
||||
Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED) &&
|
||||
if ((WifiNetworkInterface.info.state ===
|
||||
Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED) &&
|
||||
(this.prevState === "INITIALIZING" ||
|
||||
this.prevState === "DISCONNECTED" ||
|
||||
this.prevState === "INTERFACE_DISABLED" ||
|
||||
@ -2285,13 +2291,16 @@ function WifiWorker() {
|
||||
}
|
||||
});
|
||||
|
||||
WifiNetworkInterface.state =
|
||||
Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
|
||||
WifiNetworkInterface.ips = [];
|
||||
WifiNetworkInterface.prefixLengths = [];
|
||||
WifiNetworkInterface.gateways = [];
|
||||
WifiNetworkInterface.dnses = [];
|
||||
WifiNetworkInterface.info.state =
|
||||
Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
|
||||
|
||||
// Update network infterface first then clear properties.
|
||||
gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
|
||||
WifiNetworkInterface.info.ips = [];
|
||||
WifiNetworkInterface.info.prefixLengths = [];
|
||||
WifiNetworkInterface.info.gateways = [];
|
||||
WifiNetworkInterface.info.dnses = [];
|
||||
|
||||
|
||||
break;
|
||||
case "WPS_TIMEOUT":
|
||||
@ -2333,18 +2342,18 @@ function WifiWorker() {
|
||||
WifiNetworkInterface.httpProxyPort = netConnect.httpProxyPort;
|
||||
}
|
||||
|
||||
WifiNetworkInterface.state =
|
||||
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
|
||||
WifiNetworkInterface.ips = [this.info.ipaddr_str];
|
||||
WifiNetworkInterface.prefixLengths = [maskLength];
|
||||
WifiNetworkInterface.gateways = [this.info.gateway_str];
|
||||
WifiNetworkInterface.info.state =
|
||||
Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
|
||||
WifiNetworkInterface.info.ips = [this.info.ipaddr_str];
|
||||
WifiNetworkInterface.info.prefixLengths = [maskLength];
|
||||
WifiNetworkInterface.info.gateways = [this.info.gateway_str];
|
||||
if (typeof this.info.dns1_str == "string" &&
|
||||
this.info.dns1_str.length) {
|
||||
WifiNetworkInterface.dnses.push(this.info.dns1_str);
|
||||
WifiNetworkInterface.info.dnses.push(this.info.dns1_str);
|
||||
}
|
||||
if (typeof this.info.dns2_str == "string" &&
|
||||
this.info.dns2_str.length) {
|
||||
WifiNetworkInterface.dnses.push(this.info.dns2_str);
|
||||
WifiNetworkInterface.info.dnses.push(this.info.dns2_str);
|
||||
}
|
||||
gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user