Skip to content

Commit

Permalink
[vpnmodel] Update autoConnect upon connect/disconnect. Contributes to…
Browse files Browse the repository at this point in the history
… JB#42710
  • Loading branch information
rainemak committed Aug 22, 2018
1 parent 1bf576d commit 0575c5c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/vpnmodel.cpp
Expand Up @@ -537,6 +537,8 @@ void VpnModel::activateConnection(const QString &path)
if (pendingDisconnects_.isEmpty()) {
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 Down Expand Up @@ -570,13 +572,13 @@ void VpnModel::deactivateConnection(const QString &path)
connect(connection, &VpnConnection::stateChanged, this, &VpnModel::updatePendingDisconnectState, Qt::UniqueConnection);
}

proxy->SetProperty(autoConnectKey, QDBusVariant(false));
QDBusPendingCall call = proxy->Disconnect();

QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, path](QDBusPendingCallWatcher *watcher) {
QDBusPendingReply<void> reply = *watcher;
watcher->deleteLater();

if (reply.isError()) {
qCWarning(lcVpnLog) << "Unable to deactivate Connman VPN connection:" << path << ":" << reply.error().message();
}
Expand Down

0 comments on commit 0575c5c

Please sign in to comment.