Skip to content

Commit

Permalink
Reload VPN model if connman-vpn restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvogt committed Nov 4, 2016
1 parent 4bd2fee commit f9cffc7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/vpnmodel.cpp
Expand Up @@ -33,6 +33,7 @@
#include "vpnmodel.h"

#include <QDBusPendingCallWatcher>
#include <QDBusServiceWatcher>
#include <QDebug>


Expand Down Expand Up @@ -214,6 +215,20 @@ VpnModel::VpnModel(QObject *parent)
}
});

// If connman-vpn restarts, we need to discard and re-read the state
QDBusServiceWatcher *watcher = new QDBusServiceWatcher("net.connman.vpn", QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this);
connect(watcher, &QDBusServiceWatcher::serviceUnregistered, this, [this](const QString &) {
for (int i = 0, n = count(); i < n; ++i) {
get(i)->deleteLater();
}
clear();
setPopulated(false);
qDeleteAll(connections_);
});
connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, [this](const QString &) {
fetchVpnList();
});

fetchVpnList();
}

Expand Down

0 comments on commit f9cffc7

Please sign in to comment.