harbour-seaprint/qml/components/WifiChecker.qml

51 lines
1.5 KiB
QML
Raw Permalink Normal View History

2021-07-11 15:27:03 +03:00
import QtQuick 2.6
2019-12-02 22:56:38 +03:00
import Nemo.DBus 2.0
2019-12-02 22:56:06 +03:00
Item {
id: checker
2019-12-02 22:56:38 +03:00
property bool connected: false
property var ssid
2019-12-02 22:56:38 +03:00
DBusInterface {
bus: DBus.SystemBus
service: 'net.connman'
path: '/'
iface: 'net.connman.Manager'
signalsEnabled: true
Component.onCompleted: go()
function servicesChanged() {
go();
}
function go() {
call("GetServices", undefined,
function(result) {
for (var i = 0; i < result.length; i++) {
var entry = result[i][1];
if(entry.Type == "wifi" && (entry.State == "online" || entry.State == "ready")) {
if(checker.ssid != entry.Name) {
// For whatever reason, the onchanged signal triggers when there isn't really a change
// so don't update the ssid if it is the same
checker.ssid = entry.Name;
}
checker.connected = true;
2019-12-02 22:56:38 +03:00
return;
}
}
checker.ssid = undefined;
checker.connected = false;
2019-12-02 22:56:38 +03:00
},
function(error, message) {
console.log('call failed', error, 'message:', message);
})
}
2019-12-02 22:56:06 +03:00
2019-12-02 22:56:38 +03:00
}
2019-12-02 22:56:06 +03:00
}