nmcli: refactor to be readable/extensible
This commit is contained in:
parent
ba5dfbd4c4
commit
3f58823762
1 changed files with 267 additions and 244 deletions
|
|
@ -32,6 +32,29 @@ Singleton {
|
||||||
property list<var> activeProcesses: []
|
property list<var> activeProcesses: []
|
||||||
property var debugLogger: null
|
property var debugLogger: null
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
readonly property string deviceTypeWifi: "wifi"
|
||||||
|
readonly property string deviceTypeEthernet: "ethernet"
|
||||||
|
readonly property string connectionTypeWireless: "802-11-wireless"
|
||||||
|
readonly property string nmcliCommandDevice: "device"
|
||||||
|
readonly property string nmcliCommandConnection: "connection"
|
||||||
|
readonly property string nmcliCommandWifi: "wifi"
|
||||||
|
readonly property string nmcliCommandRadio: "radio"
|
||||||
|
readonly property string deviceStatusFields: "DEVICE,TYPE,STATE,CONNECTION"
|
||||||
|
readonly property string connectionListFields: "NAME,TYPE"
|
||||||
|
readonly property string wirelessSsidField: "802-11-wireless.ssid"
|
||||||
|
readonly property string networkListFields: "SSID,SIGNAL,SECURITY"
|
||||||
|
readonly property string networkDetailFields: "ACTIVE,SIGNAL,FREQ,SSID,BSSID,SECURITY"
|
||||||
|
readonly property string securityKeyMgmt: "802-11-wireless-security.key-mgmt"
|
||||||
|
readonly property string securityPsk: "802-11-wireless-security.psk"
|
||||||
|
readonly property string keyMgmtWpaPsk: "wpa-psk"
|
||||||
|
readonly property string connectionParamType: "type"
|
||||||
|
readonly property string connectionParamConName: "con-name"
|
||||||
|
readonly property string connectionParamIfname: "ifname"
|
||||||
|
readonly property string connectionParamSsid: "ssid"
|
||||||
|
readonly property string connectionParamPassword: "password"
|
||||||
|
readonly property string connectionParamBssid: "802-11-wireless.bssid"
|
||||||
|
|
||||||
function setDebugLogger(logger: var): void {
|
function setDebugLogger(logger: var): void {
|
||||||
root.debugLogger = logger;
|
root.debugLogger = logger;
|
||||||
}
|
}
|
||||||
|
|
@ -48,6 +71,128 @@ Singleton {
|
||||||
log(message);
|
log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function detectPasswordRequired(error: string): bool {
|
||||||
|
if (!error || error.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (error.includes("Secrets were required") ||
|
||||||
|
error.includes("Secrets were required, but not provided") ||
|
||||||
|
error.includes("No secrets provided") ||
|
||||||
|
error.includes("802-11-wireless-security.psk") ||
|
||||||
|
error.includes("password for") ||
|
||||||
|
(error.includes("password") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
||||||
|
(error.includes("Secrets") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
||||||
|
(error.includes("802.11") && !error.includes("Connection activated") && !error.includes("successfully"))) &&
|
||||||
|
!error.includes("Connection activated") &&
|
||||||
|
!error.includes("successfully");
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseNetworkOutput(output: string): list<var> {
|
||||||
|
if (!output || output.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const PLACEHOLDER = "STRINGWHICHHOPEFULLYWONTBEUSED";
|
||||||
|
const rep = new RegExp("\\\\:", "g");
|
||||||
|
const rep2 = new RegExp(PLACEHOLDER, "g");
|
||||||
|
|
||||||
|
const allNetworks = output.trim().split("\n")
|
||||||
|
.filter(line => line && line.length > 0)
|
||||||
|
.map(n => {
|
||||||
|
const net = n.replace(rep, PLACEHOLDER).split(":");
|
||||||
|
return {
|
||||||
|
active: net[0] === "yes",
|
||||||
|
strength: parseInt(net[1] || "0", 10) || 0,
|
||||||
|
frequency: parseInt(net[2] || "0", 10) || 0,
|
||||||
|
ssid: (net[3]?.replace(rep2, ":") ?? "").trim(),
|
||||||
|
bssid: (net[4]?.replace(rep2, ":") ?? "").trim(),
|
||||||
|
security: (net[5] ?? "").trim()
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter(n => n.ssid && n.ssid.length > 0);
|
||||||
|
|
||||||
|
return allNetworks;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deduplicateNetworks(networks: list<var>): list<var> {
|
||||||
|
if (!networks || networks.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const networkMap = new Map();
|
||||||
|
for (const network of networks) {
|
||||||
|
const existing = networkMap.get(network.ssid);
|
||||||
|
if (!existing) {
|
||||||
|
networkMap.set(network.ssid, network);
|
||||||
|
} else {
|
||||||
|
if (network.active && !existing.active) {
|
||||||
|
networkMap.set(network.ssid, network);
|
||||||
|
} else if (!network.active && !existing.active) {
|
||||||
|
if (network.strength > existing.strength) {
|
||||||
|
networkMap.set(network.ssid, network);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Array.from(networkMap.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
function isConnectionCommand(command: list<string>): bool {
|
||||||
|
if (!command || command.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return command.includes(root.nmcliCommandWifi) || command.includes(root.nmcliCommandConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDeviceStatusOutput(output: string, filterType: string): list<var> {
|
||||||
|
if (!output || output.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const interfaces = [];
|
||||||
|
const lines = output.trim().split("\n");
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
const parts = line.split(":");
|
||||||
|
if (parts.length >= 2) {
|
||||||
|
const deviceType = parts[1];
|
||||||
|
let shouldInclude = false;
|
||||||
|
|
||||||
|
if (filterType === root.deviceTypeWifi && deviceType === root.deviceTypeWifi) {
|
||||||
|
shouldInclude = true;
|
||||||
|
} else if (filterType === root.deviceTypeEthernet && deviceType === root.deviceTypeEthernet) {
|
||||||
|
shouldInclude = true;
|
||||||
|
} else if (filterType === "both" && (deviceType === root.deviceTypeWifi || deviceType === root.deviceTypeEthernet)) {
|
||||||
|
shouldInclude = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldInclude) {
|
||||||
|
interfaces.push({
|
||||||
|
device: parts[0] || "",
|
||||||
|
type: parts[1] || "",
|
||||||
|
state: parts[2] || "",
|
||||||
|
connection: parts[3] || ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return interfaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isConnectedState(state: string): bool {
|
||||||
|
if (!state || state.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state === "100 (connected)" ||
|
||||||
|
state === "connected" ||
|
||||||
|
state.startsWith("connected");
|
||||||
|
}
|
||||||
|
|
||||||
function executeCommand(args: list<string>, callback: var): void {
|
function executeCommand(args: list<string>, callback: var): void {
|
||||||
const proc = commandProc.createObject(root);
|
const proc = commandProc.createObject(root);
|
||||||
proc.command = ["nmcli", ...args];
|
proc.command = ["nmcli", ...args];
|
||||||
|
|
@ -68,68 +213,42 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeviceStatus(callback: var): void {
|
function getDeviceStatus(callback: var): void {
|
||||||
executeCommand(["-t", "-f", "DEVICE,TYPE,STATE,CONNECTION", "device", "status"], (result) => {
|
executeCommand(["-t", "-f", root.deviceStatusFields, root.nmcliCommandDevice, "status"], (result) => {
|
||||||
if (callback) callback(result.output);
|
if (callback) callback(result.output);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWirelessInterfaces(callback: var): void {
|
function getWirelessInterfaces(callback: var): void {
|
||||||
executeCommand(["-t", "-f", "DEVICE,TYPE,STATE,CONNECTION", "device", "status"], (result) => {
|
executeCommand(["-t", "-f", root.deviceStatusFields, root.nmcliCommandDevice, "status"], (result) => {
|
||||||
const interfaces = [];
|
const interfaces = parseDeviceStatusOutput(result.output, root.deviceTypeWifi);
|
||||||
const lines = result.output.trim().split("\n");
|
|
||||||
for (const line of lines) {
|
|
||||||
const parts = line.split(":");
|
|
||||||
if (parts.length >= 2 && parts[1] === "wifi") {
|
|
||||||
interfaces.push({
|
|
||||||
device: parts[0] || "",
|
|
||||||
type: parts[1] || "",
|
|
||||||
state: parts[2] || "",
|
|
||||||
connection: parts[3] || ""
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
root.wirelessInterfaces = interfaces;
|
root.wirelessInterfaces = interfaces;
|
||||||
if (callback) callback(interfaces);
|
if (callback) callback(interfaces);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEthernetInterfaces(callback: var): void {
|
function getEthernetInterfaces(callback: var): void {
|
||||||
executeCommand(["-t", "-f", "DEVICE,TYPE,STATE,CONNECTION", "device", "status"], (result) => {
|
executeCommand(["-t", "-f", root.deviceStatusFields, root.nmcliCommandDevice, "status"], (result) => {
|
||||||
const interfaces = [];
|
const interfaces = parseDeviceStatusOutput(result.output, root.deviceTypeEthernet);
|
||||||
const devices = [];
|
const devices = [];
|
||||||
const lines = result.output.trim().split("\n");
|
|
||||||
for (const line of lines) {
|
for (const iface of interfaces) {
|
||||||
const parts = line.split(":");
|
const connected = isConnectedState(iface.state);
|
||||||
if (parts.length >= 2 && parts[1] === "ethernet") {
|
|
||||||
const device = parts[0] || "";
|
devices.push({
|
||||||
const type = parts[1] || "";
|
interface: iface.device,
|
||||||
const state = parts[2] || "";
|
type: iface.type,
|
||||||
const connection = parts[3] || "";
|
state: iface.state,
|
||||||
|
connection: iface.connection,
|
||||||
const connected = state === "100 (connected)" || state === "connected" || state.startsWith("connected");
|
connected: connected,
|
||||||
|
ipAddress: "",
|
||||||
interfaces.push({
|
gateway: "",
|
||||||
device: device,
|
dns: [],
|
||||||
type: type,
|
subnet: "",
|
||||||
state: state,
|
macAddress: "",
|
||||||
connection: connection
|
speed: ""
|
||||||
});
|
});
|
||||||
|
|
||||||
devices.push({
|
|
||||||
interface: device,
|
|
||||||
type: type,
|
|
||||||
state: state,
|
|
||||||
connection: connection,
|
|
||||||
connected: connected,
|
|
||||||
ipAddress: "",
|
|
||||||
gateway: "",
|
|
||||||
dns: [],
|
|
||||||
subnet: "",
|
|
||||||
macAddress: "",
|
|
||||||
speed: ""
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
root.ethernetInterfaces = interfaces;
|
root.ethernetInterfaces = interfaces;
|
||||||
root.ethernetDevices = devices;
|
root.ethernetDevices = devices;
|
||||||
if (callback) callback(interfaces);
|
if (callback) callback(interfaces);
|
||||||
|
|
@ -138,7 +257,7 @@ Singleton {
|
||||||
|
|
||||||
function connectEthernet(connectionName: string, interfaceName: string, callback: var): void {
|
function connectEthernet(connectionName: string, interfaceName: string, callback: var): void {
|
||||||
if (connectionName && connectionName.length > 0) {
|
if (connectionName && connectionName.length > 0) {
|
||||||
executeCommand(["connection", "up", connectionName], (result) => {
|
executeCommand([root.nmcliCommandConnection, "up", connectionName], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
getEthernetInterfaces(() => {});
|
getEthernetInterfaces(() => {});
|
||||||
|
|
@ -152,7 +271,7 @@ Singleton {
|
||||||
if (callback) callback(result);
|
if (callback) callback(result);
|
||||||
});
|
});
|
||||||
} else if (interfaceName && interfaceName.length > 0) {
|
} else if (interfaceName && interfaceName.length > 0) {
|
||||||
executeCommand(["device", "connect", interfaceName], (result) => {
|
executeCommand([root.nmcliCommandDevice, "connect", interfaceName], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
getEthernetInterfaces(() => {});
|
getEthernetInterfaces(() => {});
|
||||||
|
|
@ -174,7 +293,7 @@ Singleton {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
executeCommand(["connection", "down", connectionName], (result) => {
|
executeCommand([root.nmcliCommandConnection, "down", connectionName], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
root.ethernetDeviceDetails = null;
|
root.ethernetDeviceDetails = null;
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
|
|
@ -186,31 +305,19 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllInterfaces(callback: var): void {
|
function getAllInterfaces(callback: var): void {
|
||||||
executeCommand(["-t", "-f", "DEVICE,TYPE,STATE,CONNECTION", "device", "status"], (result) => {
|
executeCommand(["-t", "-f", root.deviceStatusFields, root.nmcliCommandDevice, "status"], (result) => {
|
||||||
const interfaces = [];
|
const interfaces = parseDeviceStatusOutput(result.output, "both");
|
||||||
const lines = result.output.trim().split("\n");
|
|
||||||
for (const line of lines) {
|
|
||||||
const parts = line.split(":");
|
|
||||||
if (parts.length >= 2 && (parts[1] === "wifi" || parts[1] === "ethernet")) {
|
|
||||||
interfaces.push({
|
|
||||||
device: parts[0] || "",
|
|
||||||
type: parts[1] || "",
|
|
||||||
state: parts[2] || "",
|
|
||||||
connection: parts[3] || ""
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (callback) callback(interfaces);
|
if (callback) callback(interfaces);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInterfaceConnected(interfaceName: string, callback: var): void {
|
function isInterfaceConnected(interfaceName: string, callback: var): void {
|
||||||
executeCommand(["device", "status"], (result) => {
|
executeCommand([root.nmcliCommandDevice, "status"], (result) => {
|
||||||
const lines = result.output.trim().split("\n");
|
const lines = result.output.trim().split("\n");
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const parts = line.split(/\s+/);
|
const parts = line.split(/\s+/);
|
||||||
if (parts.length >= 3 && parts[0] === interfaceName) {
|
if (parts.length >= 3 && parts[0] === interfaceName) {
|
||||||
const connected = parts[2] === "connected" || parts[2].startsWith("connected");
|
const connected = isConnectedState(parts[2]);
|
||||||
if (callback) callback(connected);
|
if (callback) callback(connected);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -258,9 +365,9 @@ Singleton {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cmd = ["device", "wifi", "connect", ssid];
|
let cmd = [root.nmcliCommandDevice, root.nmcliCommandWifi, "connect", ssid];
|
||||||
if (password && password.length > 0) {
|
if (password && password.length > 0) {
|
||||||
cmd.push("password", password);
|
cmd.push(root.connectionParamPassword, password);
|
||||||
}
|
}
|
||||||
executeCommand(cmd, (result) => {
|
executeCommand(cmd, (result) => {
|
||||||
if (result.needsPassword && callback) {
|
if (result.needsPassword && callback) {
|
||||||
|
|
@ -283,14 +390,14 @@ Singleton {
|
||||||
|
|
||||||
function createConnectionWithPassword(ssid: string, bssidUpper: string, password: string, callback: var): void {
|
function createConnectionWithPassword(ssid: string, bssidUpper: string, password: string, callback: var): void {
|
||||||
checkAndDeleteConnection(ssid, () => {
|
checkAndDeleteConnection(ssid, () => {
|
||||||
const cmd = ["connection", "add",
|
const cmd = [root.nmcliCommandConnection, "add",
|
||||||
"type", "wifi",
|
root.connectionParamType, root.deviceTypeWifi,
|
||||||
"con-name", ssid,
|
root.connectionParamConName, ssid,
|
||||||
"ifname", "*",
|
root.connectionParamIfname, "*",
|
||||||
"ssid", ssid,
|
root.connectionParamSsid, ssid,
|
||||||
"802-11-wireless.bssid", bssidUpper,
|
root.connectionParamBssid, bssidUpper,
|
||||||
"802-11-wireless-security.key-mgmt", "wpa-psk",
|
root.securityKeyMgmt, root.keyMgmtWpaPsk,
|
||||||
"802-11-wireless-security.psk", password];
|
root.securityPsk, password];
|
||||||
|
|
||||||
executeCommand(cmd, (result) => {
|
executeCommand(cmd, (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
|
@ -307,7 +414,7 @@ Singleton {
|
||||||
activateConnection(ssid, callback);
|
activateConnection(ssid, callback);
|
||||||
} else {
|
} else {
|
||||||
log("Connection profile creation failed, trying fallback...");
|
log("Connection profile creation failed, trying fallback...");
|
||||||
let fallbackCmd = ["device", "wifi", "connect", ssid, "password", password];
|
let fallbackCmd = [root.nmcliCommandDevice, root.nmcliCommandWifi, "connect", ssid, root.connectionParamPassword, password];
|
||||||
executeCommand(fallbackCmd, (fallbackResult) => {
|
executeCommand(fallbackCmd, (fallbackResult) => {
|
||||||
if (callback) callback(fallbackResult);
|
if (callback) callback(fallbackResult);
|
||||||
});
|
});
|
||||||
|
|
@ -318,9 +425,9 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkAndDeleteConnection(ssid: string, callback: var): void {
|
function checkAndDeleteConnection(ssid: string, callback: var): void {
|
||||||
executeCommand(["connection", "show", ssid], (result) => {
|
executeCommand([root.nmcliCommandConnection, "show", ssid], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
executeCommand(["connection", "delete", ssid], (deleteResult) => {
|
executeCommand([root.nmcliCommandConnection, "delete", ssid], (deleteResult) => {
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
@ -332,13 +439,13 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function activateConnection(connectionName: string, callback: var): void {
|
function activateConnection(connectionName: string, callback: var): void {
|
||||||
executeCommand(["connection", "up", connectionName], (result) => {
|
executeCommand([root.nmcliCommandConnection, "up", connectionName], (result) => {
|
||||||
if (callback) callback(result);
|
if (callback) callback(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSavedConnections(callback: var): void {
|
function loadSavedConnections(callback: var): void {
|
||||||
executeCommand(["-t", "-f", "NAME,TYPE", "connection", "show"], (result) => {
|
executeCommand(["-t", "-f", root.connectionListFields, root.nmcliCommandConnection, "show"], (result) => {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
root.savedConnections = [];
|
root.savedConnections = [];
|
||||||
root.savedConnectionSsids = [];
|
root.savedConnectionSsids = [];
|
||||||
|
|
@ -362,7 +469,7 @@ Singleton {
|
||||||
const type = parts[1];
|
const type = parts[1];
|
||||||
connections.push(name);
|
connections.push(name);
|
||||||
|
|
||||||
if (type === "802-11-wireless") {
|
if (type === root.connectionTypeWireless) {
|
||||||
wifiConnections.push(name);
|
wifiConnections.push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -387,7 +494,7 @@ Singleton {
|
||||||
const connectionName = root.wifiConnectionQueue[root.currentSsidQueryIndex];
|
const connectionName = root.wifiConnectionQueue[root.currentSsidQueryIndex];
|
||||||
root.currentSsidQueryIndex++;
|
root.currentSsidQueryIndex++;
|
||||||
|
|
||||||
executeCommand(["-t", "-f", "802-11-wireless.ssid", "connection", "show", connectionName], (result) => {
|
executeCommand(["-t", "-f", root.wirelessSsidField, root.nmcliCommandConnection, "show", connectionName], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
processSsidOutput(result.output);
|
processSsidOutput(result.output);
|
||||||
}
|
}
|
||||||
|
|
@ -456,7 +563,7 @@ Singleton {
|
||||||
conn && conn.toLowerCase().trim() === ssid.toLowerCase().trim()
|
conn && conn.toLowerCase().trim() === ssid.toLowerCase().trim()
|
||||||
) || ssid;
|
) || ssid;
|
||||||
|
|
||||||
executeCommand(["connection", "delete", connectionName], (result) => {
|
executeCommand([root.nmcliCommandConnection, "delete", connectionName], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
loadSavedConnections(() => {});
|
loadSavedConnections(() => {});
|
||||||
|
|
@ -468,11 +575,11 @@ Singleton {
|
||||||
|
|
||||||
function disconnect(interfaceName: string, callback: var): void {
|
function disconnect(interfaceName: string, callback: var): void {
|
||||||
if (interfaceName && interfaceName.length > 0) {
|
if (interfaceName && interfaceName.length > 0) {
|
||||||
executeCommand(["device", "disconnect", interfaceName], (result) => {
|
executeCommand([root.nmcliCommandDevice, "disconnect", interfaceName], (result) => {
|
||||||
if (callback) callback(result.success ? result.output : "");
|
if (callback) callback(result.success ? result.output : "");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
executeCommand(["device", "disconnect", "wifi"], (result) => {
|
executeCommand([root.nmcliCommandDevice, "disconnect", root.deviceTypeWifi], (result) => {
|
||||||
if (callback) callback(result.success ? result.output : "");
|
if (callback) callback(result.success ? result.output : "");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -480,13 +587,13 @@ Singleton {
|
||||||
|
|
||||||
function disconnectFromNetwork(): void {
|
function disconnectFromNetwork(): void {
|
||||||
if (active && active.ssid) {
|
if (active && active.ssid) {
|
||||||
executeCommand(["connection", "down", active.ssid], (result) => {
|
executeCommand([root.nmcliCommandConnection, "down", active.ssid], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
getNetworks(() => {});
|
getNetworks(() => {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
executeCommand(["device", "disconnect", "wifi"], (result) => {
|
executeCommand([root.nmcliCommandDevice, "disconnect", root.deviceTypeWifi], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
getNetworks(() => {});
|
getNetworks(() => {});
|
||||||
}
|
}
|
||||||
|
|
@ -495,7 +602,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeviceDetails(interfaceName: string, callback: var): void {
|
function getDeviceDetails(interfaceName: string, callback: var): void {
|
||||||
executeCommand(["device", "show", interfaceName], (result) => {
|
executeCommand([root.nmcliCommandDevice, "show", interfaceName], (result) => {
|
||||||
if (callback) callback(result.output);
|
if (callback) callback(result.output);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -511,7 +618,7 @@ Singleton {
|
||||||
const parts = line.split(":");
|
const parts = line.split(":");
|
||||||
if (parts.length >= 4) {
|
if (parts.length >= 4) {
|
||||||
const state = parts[2] || "";
|
const state = parts[2] || "";
|
||||||
if (state === "connected" || state.startsWith("connected")) {
|
if (isConnectedState(state)) {
|
||||||
connected = true;
|
connected = true;
|
||||||
activeIf = parts[0] || "";
|
activeIf = parts[0] || "";
|
||||||
activeConn = parts[3] || "";
|
activeConn = parts[3] || "";
|
||||||
|
|
@ -530,7 +637,7 @@ Singleton {
|
||||||
|
|
||||||
function bringInterfaceUp(interfaceName: string, callback: var): void {
|
function bringInterfaceUp(interfaceName: string, callback: var): void {
|
||||||
if (interfaceName && interfaceName.length > 0) {
|
if (interfaceName && interfaceName.length > 0) {
|
||||||
executeCommand(["device", "connect", interfaceName], (result) => {
|
executeCommand([root.nmcliCommandDevice, "connect", interfaceName], (result) => {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
|
|
@ -542,7 +649,7 @@ Singleton {
|
||||||
|
|
||||||
function bringInterfaceDown(interfaceName: string, callback: var): void {
|
function bringInterfaceDown(interfaceName: string, callback: var): void {
|
||||||
if (interfaceName && interfaceName.length > 0) {
|
if (interfaceName && interfaceName.length > 0) {
|
||||||
executeCommand(["device", "disconnect", interfaceName], (result) => {
|
executeCommand([root.nmcliCommandDevice, "disconnect", interfaceName], (result) => {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
|
|
@ -553,9 +660,9 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function scanWirelessNetworks(interfaceName: string, callback: var): void {
|
function scanWirelessNetworks(interfaceName: string, callback: var): void {
|
||||||
let cmd = ["device", "wifi", "rescan"];
|
let cmd = [root.nmcliCommandDevice, root.nmcliCommandWifi, "rescan"];
|
||||||
if (interfaceName && interfaceName.length > 0) {
|
if (interfaceName && interfaceName.length > 0) {
|
||||||
cmd.push("ifname", interfaceName);
|
cmd.push(root.connectionParamIfname, interfaceName);
|
||||||
}
|
}
|
||||||
executeCommand(cmd, (result) => {
|
executeCommand(cmd, (result) => {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
|
|
@ -570,7 +677,7 @@ Singleton {
|
||||||
|
|
||||||
function enableWifi(enabled: bool, callback: var): void {
|
function enableWifi(enabled: bool, callback: var): void {
|
||||||
const cmd = enabled ? "on" : "off";
|
const cmd = enabled ? "on" : "off";
|
||||||
executeCommand(["radio", "wifi", cmd], (result) => {
|
executeCommand([root.nmcliCommandRadio, root.nmcliCommandWifi, cmd], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
getWifiStatus((status) => {
|
getWifiStatus((status) => {
|
||||||
root.wifiEnabled = status;
|
root.wifiEnabled = status;
|
||||||
|
|
@ -588,7 +695,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWifiStatus(callback: var): void {
|
function getWifiStatus(callback: var): void {
|
||||||
executeCommand(["radio", "wifi"], (result) => {
|
executeCommand([root.nmcliCommandRadio, root.nmcliCommandWifi], (result) => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const enabled = result.output.trim() === "enabled";
|
const enabled = result.output.trim() === "enabled";
|
||||||
root.wifiEnabled = enabled;
|
root.wifiEnabled = enabled;
|
||||||
|
|
@ -600,48 +707,14 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNetworks(callback: var): void {
|
function getNetworks(callback: var): void {
|
||||||
executeCommand(["-g", "ACTIVE,SIGNAL,FREQ,SSID,BSSID,SECURITY", "d", "w"], (result) => {
|
executeCommand(["-g", root.networkDetailFields, "d", "w"], (result) => {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
if (callback) callback([]);
|
if (callback) callback([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PLACEHOLDER = "STRINGWHICHHOPEFULLYWONTBEUSED";
|
const allNetworks = parseNetworkOutput(result.output);
|
||||||
const rep = new RegExp("\\\\:", "g");
|
const networks = deduplicateNetworks(allNetworks);
|
||||||
const rep2 = new RegExp(PLACEHOLDER, "g");
|
|
||||||
|
|
||||||
const allNetworks = result.output.trim().split("\n")
|
|
||||||
.filter(line => line && line.length > 0)
|
|
||||||
.map(n => {
|
|
||||||
const net = n.replace(rep, PLACEHOLDER).split(":");
|
|
||||||
return {
|
|
||||||
active: net[0] === "yes",
|
|
||||||
strength: parseInt(net[1] || "0", 10) || 0,
|
|
||||||
frequency: parseInt(net[2] || "0", 10) || 0,
|
|
||||||
ssid: (net[3]?.replace(rep2, ":") ?? "").trim(),
|
|
||||||
bssid: (net[4]?.replace(rep2, ":") ?? "").trim(),
|
|
||||||
security: (net[5] ?? "").trim()
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.filter(n => n.ssid && n.ssid.length > 0);
|
|
||||||
|
|
||||||
const networkMap = new Map();
|
|
||||||
for (const network of allNetworks) {
|
|
||||||
const existing = networkMap.get(network.ssid);
|
|
||||||
if (!existing) {
|
|
||||||
networkMap.set(network.ssid, network);
|
|
||||||
} else {
|
|
||||||
if (network.active && !existing.active) {
|
|
||||||
networkMap.set(network.ssid, network);
|
|
||||||
} else if (!network.active && !existing.active) {
|
|
||||||
if (network.strength > existing.strength) {
|
|
||||||
networkMap.set(network.ssid, network);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const networks = Array.from(networkMap.values());
|
|
||||||
const rNetworks = root.networks;
|
const rNetworks = root.networks;
|
||||||
|
|
||||||
const destroyed = rNetworks.filter(rn => !networks.find(n =>
|
const destroyed = rNetworks.filter(rn => !networks.find(n =>
|
||||||
|
|
@ -678,9 +751,9 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWirelessSSIDs(interfaceName: string, callback: var): void {
|
function getWirelessSSIDs(interfaceName: string, callback: var): void {
|
||||||
let cmd = ["-t", "-f", "SSID,SIGNAL,SECURITY", "device", "wifi", "list"];
|
let cmd = ["-t", "-f", root.networkListFields, root.nmcliCommandDevice, root.nmcliCommandWifi, "list"];
|
||||||
if (interfaceName && interfaceName.length > 0) {
|
if (interfaceName && interfaceName.length > 0) {
|
||||||
cmd.push("ifname", interfaceName);
|
cmd.push(root.connectionParamIfname, interfaceName);
|
||||||
}
|
}
|
||||||
executeCommand(cmd, (result) => {
|
executeCommand(cmd, (result) => {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
@ -721,6 +794,43 @@ Singleton {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handlePasswordRequired(proc: var, error: string, output: string, exitCode: int): bool {
|
||||||
|
if (!proc || !error || error.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isConnectionCommand(proc.command) || !root.pendingConnection || !root.pendingConnection.callback) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const needsPassword = detectPasswordRequired(error);
|
||||||
|
|
||||||
|
if (needsPassword && !proc.callbackCalled && root.pendingConnection) {
|
||||||
|
connectionCheckTimer.stop();
|
||||||
|
immediateCheckTimer.stop();
|
||||||
|
immediateCheckTimer.checkCount = 0;
|
||||||
|
const pending = root.pendingConnection;
|
||||||
|
root.pendingConnection = null;
|
||||||
|
proc.callbackCalled = true;
|
||||||
|
const result = {
|
||||||
|
success: false,
|
||||||
|
output: output || "",
|
||||||
|
error: error,
|
||||||
|
exitCode: exitCode,
|
||||||
|
needsPassword: true
|
||||||
|
};
|
||||||
|
if (pending.callback) {
|
||||||
|
pending.callback(result);
|
||||||
|
}
|
||||||
|
if (proc.callback && proc.callback !== pending.callback) {
|
||||||
|
proc.callback(result);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
component CommandProcess: Process {
|
component CommandProcess: Process {
|
||||||
id: proc
|
id: proc
|
||||||
property var callback: null
|
property var callback: null
|
||||||
|
|
@ -745,43 +855,8 @@ Singleton {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
const error = text.trim();
|
const error = text.trim();
|
||||||
if (error && error.length > 0) {
|
if (error && error.length > 0) {
|
||||||
const isConnectionCommand = proc.command && proc.command.length > 0 &&
|
const output = (stdoutCollector && stdoutCollector.text) ? stdoutCollector.text : "";
|
||||||
(proc.command.includes("wifi") || proc.command.includes("connection"));
|
handlePasswordRequired(proc, error, output, -1);
|
||||||
|
|
||||||
if (isConnectionCommand && root.pendingConnection && root.pendingConnection.callback) {
|
|
||||||
const needsPassword = (error.includes("Secrets were required") ||
|
|
||||||
error.includes("Secrets were required, but not provided") ||
|
|
||||||
error.includes("No secrets provided") ||
|
|
||||||
error.includes("802-11-wireless-security.psk") ||
|
|
||||||
error.includes("password for") ||
|
|
||||||
(error.includes("password") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
|
||||||
(error.includes("Secrets") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
|
||||||
(error.includes("802.11") && !error.includes("Connection activated") && !error.includes("successfully"))) &&
|
|
||||||
!error.includes("Connection activated") &&
|
|
||||||
!error.includes("successfully");
|
|
||||||
|
|
||||||
if (needsPassword && !proc.callbackCalled && root.pendingConnection) {
|
|
||||||
connectionCheckTimer.stop();
|
|
||||||
immediateCheckTimer.stop();
|
|
||||||
immediateCheckTimer.checkCount = 0;
|
|
||||||
const pending = root.pendingConnection;
|
|
||||||
root.pendingConnection = null;
|
|
||||||
proc.callbackCalled = true;
|
|
||||||
const result = {
|
|
||||||
success: false,
|
|
||||||
output: (stdoutCollector && stdoutCollector.text) ? stdoutCollector.text : "",
|
|
||||||
error: error,
|
|
||||||
exitCode: -1,
|
|
||||||
needsPassword: true
|
|
||||||
};
|
|
||||||
if (pending.callback) {
|
|
||||||
pending.callback(result);
|
|
||||||
}
|
|
||||||
if (proc.callback && proc.callback !== pending.callback) {
|
|
||||||
proc.callback(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -798,44 +873,16 @@ Singleton {
|
||||||
const output = (stdoutCollector && stdoutCollector.text) ? stdoutCollector.text : "";
|
const output = (stdoutCollector && stdoutCollector.text) ? stdoutCollector.text : "";
|
||||||
const error = (stderrCollector && stderrCollector.text) ? stderrCollector.text : "";
|
const error = (stderrCollector && stderrCollector.text) ? stderrCollector.text : "";
|
||||||
const success = proc.exitCode === 0;
|
const success = proc.exitCode === 0;
|
||||||
|
const cmdIsConnection = isConnectionCommand(proc.command);
|
||||||
|
|
||||||
const isConnectionCommand = proc.command && proc.command.length > 0 &&
|
if (handlePasswordRequired(proc, error, output, proc.exitCode)) {
|
||||||
(proc.command.includes("wifi") || proc.command.includes("connection"));
|
|
||||||
const needsPassword = isConnectionCommand && error && error.length > 0 &&
|
|
||||||
(error.includes("Secrets were required") ||
|
|
||||||
error.includes("Secrets were required, but not provided") ||
|
|
||||||
error.includes("No secrets provided") ||
|
|
||||||
error.includes("802-11-wireless-security.psk") ||
|
|
||||||
error.includes("password for") ||
|
|
||||||
(error.includes("password") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
|
||||||
(error.includes("Secrets") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
|
||||||
(error.includes("802.11") && !error.includes("Connection activated") && !error.includes("successfully"))) &&
|
|
||||||
!error.includes("Connection activated") &&
|
|
||||||
!error.includes("successfully");
|
|
||||||
|
|
||||||
if (needsPassword && root.pendingConnection && root.pendingConnection.callback) {
|
|
||||||
connectionCheckTimer.stop();
|
|
||||||
immediateCheckTimer.stop();
|
|
||||||
immediateCheckTimer.checkCount = 0;
|
|
||||||
const pending = root.pendingConnection;
|
|
||||||
root.pendingConnection = null;
|
|
||||||
proc.callbackCalled = true;
|
|
||||||
const result = {
|
|
||||||
success: false,
|
|
||||||
output: output,
|
|
||||||
error: error,
|
|
||||||
exitCode: proc.exitCode,
|
|
||||||
needsPassword: true
|
|
||||||
};
|
|
||||||
if (pending.callback) {
|
|
||||||
pending.callback(result);
|
|
||||||
}
|
|
||||||
if (proc.callback && proc.callback !== pending.callback) {
|
|
||||||
proc.callback(result);
|
|
||||||
}
|
|
||||||
proc.processFinished();
|
proc.processFinished();
|
||||||
return;
|
return;
|
||||||
} else if (!success && isConnectionCommand && root.pendingConnection) {
|
}
|
||||||
|
|
||||||
|
const needsPassword = cmdIsConnection && detectPasswordRequired(error);
|
||||||
|
|
||||||
|
if (!success && cmdIsConnection && root.pendingConnection) {
|
||||||
const failedSsid = root.pendingConnection.ssid;
|
const failedSsid = root.pendingConnection.ssid;
|
||||||
root.connectionFailed(failedSsid);
|
root.connectionFailed(failedSsid);
|
||||||
}
|
}
|
||||||
|
|
@ -891,20 +938,8 @@ Singleton {
|
||||||
if (proc && proc.stderr && proc.stderr.text) {
|
if (proc && proc.stderr && proc.stderr.text) {
|
||||||
const error = proc.stderr.text.trim();
|
const error = proc.stderr.text.trim();
|
||||||
if (error && error.length > 0) {
|
if (error && error.length > 0) {
|
||||||
const isConnectionCommand = proc.command && proc.command.length > 0 &&
|
if (isConnectionCommand(proc.command)) {
|
||||||
(proc.command.includes("wifi") || proc.command.includes("connection"));
|
const needsPassword = detectPasswordRequired(error);
|
||||||
|
|
||||||
if (isConnectionCommand) {
|
|
||||||
const needsPassword = (error.includes("Secrets were required") ||
|
|
||||||
error.includes("Secrets were required, but not provided") ||
|
|
||||||
error.includes("No secrets provided") ||
|
|
||||||
error.includes("802-11-wireless-security.psk") ||
|
|
||||||
error.includes("password for") ||
|
|
||||||
(error.includes("password") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
|
||||||
(error.includes("Secrets") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
|
||||||
(error.includes("802.11") && !error.includes("Connection activated") && !error.includes("successfully"))) &&
|
|
||||||
!error.includes("Connection activated") &&
|
|
||||||
!error.includes("successfully");
|
|
||||||
|
|
||||||
if (needsPassword && !proc.callbackCalled && root.pendingConnection) {
|
if (needsPassword && !proc.callbackCalled && root.pendingConnection) {
|
||||||
const pending = root.pendingConnection;
|
const pending = root.pendingConnection;
|
||||||
|
|
@ -983,20 +1018,8 @@ Singleton {
|
||||||
if (proc && proc.stderr && proc.stderr.text) {
|
if (proc && proc.stderr && proc.stderr.text) {
|
||||||
const error = proc.stderr.text.trim();
|
const error = proc.stderr.text.trim();
|
||||||
if (error && error.length > 0) {
|
if (error && error.length > 0) {
|
||||||
const isConnectionCommand = proc.command && proc.command.length > 0 &&
|
if (isConnectionCommand(proc.command)) {
|
||||||
(proc.command.includes("wifi") || proc.command.includes("connection"));
|
const needsPassword = detectPasswordRequired(error);
|
||||||
|
|
||||||
if (isConnectionCommand) {
|
|
||||||
const needsPassword = (error.includes("Secrets were required") ||
|
|
||||||
error.includes("Secrets were required, but not provided") ||
|
|
||||||
error.includes("No secrets provided") ||
|
|
||||||
error.includes("802-11-wireless-security.psk") ||
|
|
||||||
error.includes("password for") ||
|
|
||||||
(error.includes("password") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
|
||||||
(error.includes("Secrets") && !error.includes("Connection activated") && !error.includes("successfully")) ||
|
|
||||||
(error.includes("802.11") && !error.includes("Connection activated") && !error.includes("successfully"))) &&
|
|
||||||
!error.includes("Connection activated") &&
|
|
||||||
!error.includes("successfully");
|
|
||||||
|
|
||||||
if (needsPassword && !proc.callbackCalled && root.pendingConnection && root.pendingConnection.callback) {
|
if (needsPassword && !proc.callbackCalled && root.pendingConnection && root.pendingConnection.callback) {
|
||||||
connectionCheckTimer.stop();
|
connectionCheckTimer.stop();
|
||||||
|
|
@ -1076,7 +1099,7 @@ Singleton {
|
||||||
function getWirelessDeviceDetails(interfaceName: string, callback: var): void {
|
function getWirelessDeviceDetails(interfaceName: string, callback: var): void {
|
||||||
if (!interfaceName || interfaceName.length === 0) {
|
if (!interfaceName || interfaceName.length === 0) {
|
||||||
const activeInterface = root.wirelessInterfaces.find(iface => {
|
const activeInterface = root.wirelessInterfaces.find(iface => {
|
||||||
return iface.state === "connected" || iface.state.startsWith("connected");
|
return isConnectedState(iface.state);
|
||||||
});
|
});
|
||||||
if (activeInterface && activeInterface.device) {
|
if (activeInterface && activeInterface.device) {
|
||||||
interfaceName = activeInterface.device;
|
interfaceName = activeInterface.device;
|
||||||
|
|
@ -1102,7 +1125,7 @@ Singleton {
|
||||||
function getEthernetDeviceDetails(interfaceName: string, callback: var): void {
|
function getEthernetDeviceDetails(interfaceName: string, callback: var): void {
|
||||||
if (!interfaceName || interfaceName.length === 0) {
|
if (!interfaceName || interfaceName.length === 0) {
|
||||||
const activeInterface = root.ethernetInterfaces.find(iface => {
|
const activeInterface = root.ethernetInterfaces.find(iface => {
|
||||||
return iface.state === "connected" || iface.state.startsWith("connected");
|
return isConnectedState(iface.state);
|
||||||
});
|
});
|
||||||
if (activeInterface && activeInterface.device) {
|
if (activeInterface && activeInterface.device) {
|
||||||
interfaceName = activeInterface.device;
|
interfaceName = activeInterface.device;
|
||||||
|
|
@ -1179,7 +1202,7 @@ Singleton {
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: rescanProc
|
id: rescanProc
|
||||||
command: ["nmcli", "dev", "wifi", "list", "--rescan", "yes"]
|
command: ["nmcli", "dev", root.nmcliCommandWifi, "list", "--rescan", "yes"]
|
||||||
onExited: {
|
onExited: {
|
||||||
getNetworks(() => {});
|
getNetworks(() => {});
|
||||||
}
|
}
|
||||||
|
|
@ -1217,7 +1240,7 @@ Singleton {
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (root.wirelessInterfaces.length > 0) {
|
if (root.wirelessInterfaces.length > 0) {
|
||||||
const activeWireless = root.wirelessInterfaces.find(iface => {
|
const activeWireless = root.wirelessInterfaces.find(iface => {
|
||||||
return iface.state === "connected" || iface.state.startsWith("connected");
|
return isConnectedState(iface.state);
|
||||||
});
|
});
|
||||||
if (activeWireless && activeWireless.device) {
|
if (activeWireless && activeWireless.device) {
|
||||||
getWirelessDeviceDetails(activeWireless.device, () => {});
|
getWirelessDeviceDetails(activeWireless.device, () => {});
|
||||||
|
|
@ -1226,7 +1249,7 @@ Singleton {
|
||||||
|
|
||||||
if (root.ethernetInterfaces.length > 0) {
|
if (root.ethernetInterfaces.length > 0) {
|
||||||
const activeEthernet = root.ethernetInterfaces.find(iface => {
|
const activeEthernet = root.ethernetInterfaces.find(iface => {
|
||||||
return iface.state === "connected" || iface.state.startsWith("connected");
|
return isConnectedState(iface.state);
|
||||||
});
|
});
|
||||||
if (activeEthernet && activeEthernet.device) {
|
if (activeEthernet && activeEthernet.device) {
|
||||||
getEthernetDeviceDetails(activeEthernet.device, () => {});
|
getEthernetDeviceDetails(activeEthernet.device, () => {});
|
||||||
|
|
@ -1258,7 +1281,7 @@ Singleton {
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
if (root.wirelessInterfaces.length > 0) {
|
if (root.wirelessInterfaces.length > 0) {
|
||||||
const activeWireless = root.wirelessInterfaces.find(iface => {
|
const activeWireless = root.wirelessInterfaces.find(iface => {
|
||||||
return iface.state === "connected" || iface.state.startsWith("connected");
|
return isConnectedState(iface.state);
|
||||||
});
|
});
|
||||||
if (activeWireless && activeWireless.device) {
|
if (activeWireless && activeWireless.device) {
|
||||||
getWirelessDeviceDetails(activeWireless.device, () => {});
|
getWirelessDeviceDetails(activeWireless.device, () => {});
|
||||||
|
|
@ -1267,7 +1290,7 @@ Singleton {
|
||||||
|
|
||||||
if (root.ethernetInterfaces.length > 0) {
|
if (root.ethernetInterfaces.length > 0) {
|
||||||
const activeEthernet = root.ethernetInterfaces.find(iface => {
|
const activeEthernet = root.ethernetInterfaces.find(iface => {
|
||||||
return iface.state === "connected" || iface.state.startsWith("connected");
|
return isConnectedState(iface.state);
|
||||||
});
|
});
|
||||||
if (activeEthernet && activeEthernet.device) {
|
if (activeEthernet && activeEthernet.device) {
|
||||||
getEthernetDeviceDetails(activeEthernet.device, () => {});
|
getEthernetDeviceDetails(activeEthernet.device, () => {});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue