Commit 91627230 authored by Raine Makelainen's avatar Raine Makelainen

Merge branch 'jb41636' into 'master'

[systemsettings-vpn] Disconnect VPN when removed from the model. Fixes JB#41636

See merge request mer-core/nemo-qml-plugin-systemsettings!51
parents 5a1b8b64 edc00777
...@@ -487,21 +487,31 @@ void VpnModel::modifyConnection(const QString &path, const QVariantMap &properti ...@@ -487,21 +487,31 @@ void VpnModel::modifyConnection(const QString &path, const QVariantMap &properti
void VpnModel::deleteConnection(const QString &path) void VpnModel::deleteConnection(const QString &path)
{ {
if (VpnConnection *conn = connection(path)) { if (VpnConnection *conn = connection(path)) {
Q_UNUSED(conn) if (conn->state() == VpnModel::Ready || conn->state() == VpnModel::Configuration) {
auto it = connections_.find(path);
QDBusPendingCall call = connmanVpn_.Remove(QDBusObjectPath(path)); if (it != connections_.end()) {
ConnmanVpnConnectionProxy *proxy(*it);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); QDBusPendingCall call = proxy->Disconnect();
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, path](QDBusPendingCallWatcher *watcher) { QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
QDBusPendingReply<void> reply = *watcher; connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, path](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater(); watcher->deleteLater();
// Regardless of reply status let's remove it.
if (reply.isError()) { deleteConnection(path);
qCWarning(lcVpnLog) << "Unable to delete Connman VPN connection:" << path << ":" << reply.error().message(); });
} else {
qCWarning(lcVpnLog) << "Deleted connection:" << path;
} }
}); } else {
QDBusPendingCall call = connmanVpn_.Remove(QDBusObjectPath(path));
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 delete Connman VPN connection:" << path << ":" << reply.error().message();
} else {
qCWarning(lcVpnLog) << "Deleted connection:" << path;
}
});
}
} else { } else {
qCWarning(lcVpnLog) << "Unable to delete unknown connection:" << path; qCWarning(lcVpnLog) << "Unable to delete unknown connection:" << path;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment