Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[vpn] Forward local AutoConnect property changes to connman. JB#42691
So that UI can actually manipulate it
  • Loading branch information
monich committed Sep 19, 2018
1 parent e9c1aa8 commit 3a3b0d0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/vpnmodel.cpp
Expand Up @@ -572,8 +572,6 @@ void VpnModel::activateConnection(const QString &path)

ConnmanServiceProxy* proxy = vpnServices_.value(path);
if (proxy) {
// TODO: Maybe possible to remove after Sailfish OS 2.2.1 release.
proxy->SetProperty(autoConnectKey, QDBusVariant(true));
QDBusPendingCall call = proxy->Connect();
qCDebug(lcVpnLog) << "Connect to vpn" << path;

Expand All @@ -596,7 +594,6 @@ void VpnModel::deactivateConnection(const QString &path)
qCInfo(lcVpnLog) << "Disconnect" << path;
ConnmanServiceProxy* proxy = vpnServices_.value(path);
if (proxy) {
proxy->SetProperty(autoConnectKey, QDBusVariant(false));
QDBusPendingCall call = proxy->Disconnect();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, path](QDBusPendingCallWatcher *watcher) {
Expand Down Expand Up @@ -811,6 +808,14 @@ VpnConnection *VpnModel::newConnection(const QString &path)
}
});

connect(conn, &VpnConnection::autoConnectChanged, conn, [this, conn]() {
qCInfo(lcVpnLog) << "VPN autoconnect changed:" << conn->name() << conn->autoConnect();
ConnmanServiceProxy* proxy = vpnServices_.value(conn->path());
if (proxy) {
proxy->SetProperty(autoConnectKey, QDBusVariant(conn->autoConnect()));
}
});

return conn;
}

Expand Down

0 comments on commit 3a3b0d0

Please sign in to comment.