Re-check connection state before we watch changes in case it gets changed too quickly

kdebz#352326
epel9
Jan Grulich 9 years ago
parent 1c8a7f42de
commit 81e45c4241

@ -2,7 +2,7 @@
Name: kf5-%{framework}
Version: 5.18.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A Tier 1 KDE Frameworks 5 module that wraps NetworkManager DBus API
Group: System Environment/Libraries
@ -18,6 +18,9 @@ URL: https://projects.kde.org/projects/frameworks/networkmanager-qt
%endif
Source0: http://download.kde.org/%{stable}/frameworks/%{versiondir}/%{framework}-%{version}.tar.xz
# https://bugs.kde.org/show_bug.cgi?id=352326
Patch0: nm-qt-active-connections.patch
BuildRequires: kf5-rpm-macros >= %{version}
BuildRequires: extra-cmake-modules >= %{version}
BuildRequires: qt5-qtbase-devel
@ -63,6 +66,8 @@ that use NetworkManager.
%prep
%setup -qn %{framework}-%{version}
%patch0 -p1 -b .nm-qt-active-connections
%build
mkdir -p %{_target_platform}
pushd %{_target_platform}
@ -90,6 +95,10 @@ make install/fast DESTDIR=%{buildroot} -C %{_target_platform}
%{_kf5_archdatadir}/mkspecs/modules/qt_NetworkManagerQt.pri
%changelog
* Tue Jan 05 2016 Jan Grulich <jgrulich@redhat.com> - 5.18.0-2
- Re-check connection state before we watch changes in case it gets changed too quickly
kdebz:#352326
* Sun Jan 03 2016 Daniel Vrátil <dvratil@fedoraproject.org> - 5.18.0-1
- KDE Frameworks 5.18.0

@ -0,0 +1,166 @@
diff --git a/src/activeconnection.cpp b/src/activeconnection.cpp
index f29ca67..cbfb909 100644
--- a/src/activeconnection.cpp
+++ b/src/activeconnection.cpp
@@ -108,36 +108,66 @@ NetworkManager::ActiveConnection::ActiveConnection(const QString &path, QObject
* Workaround: Re-check connection state before we watch changes in case it gets changed too quickly
* BUG:352326
*/
+ QStringList properties;
+ const QDBusObjectPath ip4ConfigObjectPath = d->iface.ip4Config();
+ const QDBusObjectPath ip6ConfigObjectPath = d->iface.ip6Config();
+ const QDBusObjectPath dhcp4ConfigObjectPath = d->iface.dhcp4Config();
+ const QDBusObjectPath dhcp6ConfigObjectPath = d->iface.dhcp6Config();
+
if (d->state != NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(d->iface.state())) {
- d->state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(d->iface.state());
- Q_EMIT stateChanged(d->state);
+ properties << QLatin1String("State");
}
#if NM_CHECK_VERSION(0, 9, 10)
- QDBusObjectPath ip4ConfigObjectPath = d->iface.ip4Config();
if (!ip4ConfigObjectPath.path().isNull() && ip4ConfigObjectPath.path() != d->ipV4ConfigPath) {
- d->ipV4ConfigPath = ip4ConfigObjectPath.path();
- Q_EMIT ipV4ConfigChanged();
+ properties << QLatin1String("Ip4Config");
}
- QDBusObjectPath ip6ConfigObjectPath = d->iface.ip6Config();
if (!ip6ConfigObjectPath.path().isNull() && ip6ConfigObjectPath.path() != d->ipV6ConfigPath) {
- d->ipV6ConfigPath = ip6ConfigObjectPath.path();
- Q_EMIT ipV6ConfigChanged();
+ properties << QLatin1String("Ip6Config");
}
- QDBusObjectPath dhcp4ConfigObjectPath = d->iface.dhcp4Config();
if (!dhcp4ConfigObjectPath.path().isNull() && dhcp4ConfigObjectPath.path() != d->dhcp4ConfigPath) {
- d->dhcp4ConfigPath = dhcp4ConfigObjectPath.path();
- Q_EMIT dhcp4ConfigChanged();
+ properties << QLatin1String("Dhcp4Config");
}
- QDBusObjectPath dhcp6ConfigObjectPath = d->iface.dhcp6Config();
if (!dhcp6ConfigObjectPath.path().isNull() && dhcp6ConfigObjectPath.path() != d->dhcp6ConfigPath) {
- d->dhcp6ConfigPath = dhcp6ConfigObjectPath.path();
- Q_EMIT dhcp6ConfigChanged();
+ properties << QLatin1String("Dhcp6Config");
}
#endif
+
+ Q_FOREACH (const QString &property, properties) {
+ QDBusMessage message = QDBusMessage::createMethodCall(NetworkManager::NetworkManagerPrivate::DBUS_SERVICE,
+ NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH,
+ NetworkManager::NetworkManagerPrivate::FDO_DBUS_PROPERTIES,
+ QLatin1String("Get"));
+ message << d->iface.staticInterfaceName() << property;
+
+ QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(message);
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
+
+ connect(watcher, &QDBusPendingCallWatcher::finished, [d, this, property] () {
+ if (property == QLatin1String("State")) {
+ d->state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(d->iface.state());
+ Q_EMIT stateChanged(d->state);
+ }
+#if NM_CHECK_VERSION(0, 9, 10)
+ if (property == QLatin1String("Ip4Config")) {
+ d->ipV4ConfigPath = d->iface.ip4Config().path();
+ Q_EMIT ipV4ConfigChanged();
+ } else if (property == QLatin1String("Ip6Config")) {
+ d->ipV6ConfigPath = d->iface.ip6Config().path();
+ Q_EMIT ipV6ConfigChanged();
+ } else if (property == QLatin1String("Dhcp4Config")) {
+ d->dhcp4ConfigPath = d->iface.dhcp4Config().path();
+ Q_EMIT dhcp4ConfigChanged();
+ } else if (property == QLatin1String("Dhcp6Config")) {
+ d->dhcp6ConfigPath = d->iface.dhcp6Config().path();
+ Q_EMIT dhcp6ConfigChanged();
+ }
+#endif
+ });
+ }
}
NetworkManager::ActiveConnection::ActiveConnection(ActiveConnectionPrivate &dd, QObject *parent)
@@ -151,36 +181,66 @@ NetworkManager::ActiveConnection::ActiveConnection(ActiveConnectionPrivate &dd,
* Workaround: Re-check connection state before we watch changes in case it gets changed too quickly
* BUG:352326
*/
+ QStringList properties;
+ const QDBusObjectPath ip4ConfigObjectPath = d->iface.ip4Config();
+ const QDBusObjectPath ip6ConfigObjectPath = d->iface.ip6Config();
+ const QDBusObjectPath dhcp4ConfigObjectPath = d->iface.dhcp4Config();
+ const QDBusObjectPath dhcp6ConfigObjectPath = d->iface.dhcp6Config();
+
if (d->state != NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(d->iface.state())) {
- d->state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(d->iface.state());
- Q_EMIT stateChanged(d->state);
+ properties << QLatin1String("State");
}
#if NM_CHECK_VERSION(0, 9, 10)
- QDBusObjectPath ip4ConfigObjectPath = d->iface.ip4Config();
if (!ip4ConfigObjectPath.path().isNull() && ip4ConfigObjectPath.path() != d->ipV4ConfigPath) {
- d->ipV4ConfigPath = ip4ConfigObjectPath.path();
- Q_EMIT ipV4ConfigChanged();
+ properties << QLatin1String("Ip4Config");
}
- QDBusObjectPath ip6ConfigObjectPath = d->iface.ip6Config();
if (!ip6ConfigObjectPath.path().isNull() && ip6ConfigObjectPath.path() != d->ipV6ConfigPath) {
- d->ipV6ConfigPath = ip6ConfigObjectPath.path();
- Q_EMIT ipV6ConfigChanged();
+ properties << QLatin1String("Ip6Config");
}
- QDBusObjectPath dhcp4ConfigObjectPath = d->iface.dhcp4Config();
if (!dhcp4ConfigObjectPath.path().isNull() && dhcp4ConfigObjectPath.path() != d->dhcp4ConfigPath) {
- d->dhcp4ConfigPath = dhcp4ConfigObjectPath.path();
- Q_EMIT dhcp4ConfigChanged();
+ properties << QLatin1String("Dhcp4Config");
}
- QDBusObjectPath dhcp6ConfigObjectPath = d->iface.dhcp6Config();
if (!dhcp6ConfigObjectPath.path().isNull() && dhcp6ConfigObjectPath.path() != d->dhcp6ConfigPath) {
- d->dhcp6ConfigPath = dhcp6ConfigObjectPath.path();
- Q_EMIT dhcp6ConfigChanged();
+ properties << QLatin1String("Dhcp6Config");
}
#endif
+
+ Q_FOREACH (const QString &property, properties) {
+ QDBusMessage message = QDBusMessage::createMethodCall(NetworkManager::NetworkManagerPrivate::DBUS_SERVICE,
+ NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH,
+ NetworkManager::NetworkManagerPrivate::FDO_DBUS_PROPERTIES,
+ QLatin1String("Get"));
+ message << d->iface.staticInterfaceName() << property;
+
+ QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(message);
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
+
+ connect(watcher, &QDBusPendingCallWatcher::finished, [d, this, property] () {
+ if (property == QLatin1String("State")) {
+ d->state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(d->iface.state());
+ Q_EMIT stateChanged(d->state);
+ }
+#if NM_CHECK_VERSION(0, 9, 10)
+ if (property == QLatin1String("Ip4Config")) {
+ d->ipV4ConfigPath = d->iface.ip4Config().path();
+ Q_EMIT ipV4ConfigChanged();
+ } else if (property == QLatin1String("Ip6Config")) {
+ d->ipV6ConfigPath = d->iface.ip6Config().path();
+ Q_EMIT ipV6ConfigChanged();
+ } else if (property == QLatin1String("Dhcp4Config")) {
+ d->dhcp4ConfigPath = d->iface.dhcp4Config().path();
+ Q_EMIT dhcp4ConfigChanged();
+ } else if (property == QLatin1String("Dhcp6Config")) {
+ d->dhcp6ConfigPath = d->iface.dhcp6Config().path();
+ Q_EMIT dhcp6ConfigChanged();
+ }
+#endif
+ });
+ }
}
NetworkManager::ActiveConnection::~ActiveConnection()
Loading…
Cancel
Save