зеркало из https://github.com/mozilla/gecko-dev.git
Bug 978709 - 4.g/6: WifiNetworkInterface changes. r=vicamo
This commit is contained in:
Родитель
e0d1e7c4ca
Коммит
1d9cbf76fd
|
@ -894,11 +894,10 @@ var WifiManager = (function() {
|
|||
WifiNetworkInterface.registered = true;
|
||||
}
|
||||
WifiNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
|
||||
WifiNetworkInterface.ip = null;
|
||||
WifiNetworkInterface.netmask = null;
|
||||
WifiNetworkInterface.gateway = null;
|
||||
WifiNetworkInterface.dns1 = null;
|
||||
WifiNetworkInterface.dns2 = null;
|
||||
WifiNetworkInterface.ips = [];
|
||||
WifiNetworkInterface.prefixLengths = [];
|
||||
WifiNetworkInterface.gateways = [];
|
||||
WifiNetworkInterface.dnses = [];
|
||||
Services.obs.notifyObservers(WifiNetworkInterface,
|
||||
kNetworkInterfaceStateChangedTopic,
|
||||
null);
|
||||
|
@ -1518,18 +1517,38 @@ let WifiNetworkInterface = {
|
|||
|
||||
name: null,
|
||||
|
||||
ip: null,
|
||||
ips: [],
|
||||
|
||||
prefixLength: 0,
|
||||
prefixLengths: [],
|
||||
|
||||
dns1: null,
|
||||
dnses: [],
|
||||
|
||||
dns2: null,
|
||||
gateways: [],
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
function WifiScanResult() {}
|
||||
|
@ -1928,11 +1947,10 @@ function WifiWorker() {
|
|||
|
||||
WifiNetworkInterface.state =
|
||||
Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
|
||||
WifiNetworkInterface.ip = null;
|
||||
WifiNetworkInterface.prefixLength = 0;
|
||||
WifiNetworkInterface.gateway = null;
|
||||
WifiNetworkInterface.dns1 = null;
|
||||
WifiNetworkInterface.dns2 = null;
|
||||
WifiNetworkInterface.ips = [];
|
||||
WifiNetworkInterface.prefixLengths = [];
|
||||
WifiNetworkInterface.gateways = [];
|
||||
WifiNetworkInterface.dnses = [];
|
||||
Services.obs.notifyObservers(WifiNetworkInterface,
|
||||
kNetworkInterfaceStateChangedTopic,
|
||||
null);
|
||||
|
@ -1957,20 +1975,29 @@ function WifiWorker() {
|
|||
};
|
||||
|
||||
WifiManager.onnetworkconnected = function() {
|
||||
if (!this.info) {
|
||||
if (!this.info || !this.info.ipaddr_str) {
|
||||
debug("Network information is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
let maskLength =
|
||||
netHelpers.getMaskLength(netHelpers.stringToIP(this.info.mask_str));
|
||||
if (!maskLength) {
|
||||
maskLength = 32; // max prefix for IPv4.
|
||||
}
|
||||
WifiNetworkInterface.state =
|
||||
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
|
||||
WifiNetworkInterface.ip = this.info.ipaddr_str;
|
||||
WifiNetworkInterface.prefixLength = maskLength;
|
||||
WifiNetworkInterface.gateway = this.info.gateway_str;
|
||||
WifiNetworkInterface.dns1 = this.info.dns1_str;
|
||||
WifiNetworkInterface.dns2 = this.info.dns2_str;
|
||||
WifiNetworkInterface.ips = [this.info.ipaddr_str];
|
||||
WifiNetworkInterface.prefixLengths = [maskLength];
|
||||
WifiNetworkInterface.gateways = [this.info.gateway_str];
|
||||
if (typeof this.info.dns1_str == "string" &&
|
||||
this.info.dns1_str.length) {
|
||||
WifiNetworkInterface.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);
|
||||
}
|
||||
Services.obs.notifyObservers(WifiNetworkInterface,
|
||||
kNetworkInterfaceStateChangedTopic,
|
||||
null);
|
||||
|
|
Загрузка…
Ссылка в новой задаче