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()