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 {
|
2020-01-04 15:30:55 +03:00
|
|
|
id: checker
|
|
|
|
|
2019-12-02 22:56:38 +03:00
|
|
|
property bool connected: false
|
2020-01-04 15:30:55 +03:00
|
|
|
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() {
|
|
|
|
console.log("services changed");
|
|
|
|
go();
|
|
|
|
}
|
|
|
|
|
|
|
|
function go() {
|
|
|
|
console.log("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")) {
|
2020-01-04 15:30:55 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2020-01-04 15:30:55 +03:00
|
|
|
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
|
|
|
}
|