diff options
Diffstat (limited to 'services/Nmcli.qml')
| -rw-r--r-- | services/Nmcli.qml | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/services/Nmcli.qml b/services/Nmcli.qml index 4e45b41..5fb0c6c 100644 --- a/services/Nmcli.qml +++ b/services/Nmcli.qml @@ -14,6 +14,7 @@ Singleton { property string activeInterface: "" property string activeConnection: "" property bool wifiEnabled: true + readonly property bool scanning: rescanProc.running readonly property list<AccessPoint> networks: [] readonly property AccessPoint active: networks.find(n => n.active) ?? null property list<string> savedConnections: [] @@ -235,6 +236,10 @@ Singleton { } } + function connectToNetwork(ssid: string, password: string, bssid: string, callback: var): void { + connectWireless(ssid, password, bssid, callback); + } + function connectWireless(ssid: string, password: string, bssid: string, callback: var, retryCount: int): void { const hasBssid = bssid !== undefined && bssid !== null && bssid.length > 0; const retries = retryCount !== undefined ? retryCount : 0; @@ -473,6 +478,22 @@ Singleton { } } + function disconnectFromNetwork(): void { + if (active && active.ssid) { + executeCommand(["connection", "down", active.ssid], (result) => { + if (result.success) { + getNetworks(() => {}); + } + }); + } else { + executeCommand(["device", "disconnect", "wifi"], (result) => { + if (result.success) { + getNetworks(() => {}); + } + }); + } + } + function getDeviceDetails(interfaceName: string, callback: var): void { executeCommand(["device", "show", interfaceName], (result) => { if (callback) callback(result.output); @@ -543,6 +564,10 @@ Singleton { }); } + function rescanWifi(): void { + rescanProc.running = true; + } + function enableWifi(enabled: bool, callback: var): void { const cmd = enabled ? "on" : "off"; executeCommand(["radio", "wifi", cmd], (result) => { @@ -1153,6 +1178,14 @@ Singleton { } Process { + id: rescanProc + command: ["nmcli", "dev", "wifi", "list", "--rescan", "yes"] + onExited: { + getNetworks(() => {}); + } + } + + Process { id: monitorProc running: true command: ["nmcli", "monitor"] |