Changeset View
Changeset View
Standalone View
Standalone View
src/activeconnection.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
50 | { | 50 | { | ||
51 | } | 51 | } | ||
52 | 52 | | |||
53 | NetworkManager::ActiveConnection::State NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(uint state) | 53 | NetworkManager::ActiveConnection::State NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(uint state) | ||
54 | { | 54 | { | ||
55 | return (NetworkManager::ActiveConnection::State)state; | 55 | return (NetworkManager::ActiveConnection::State)state; | ||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | NetworkManager::ActiveConnection::StateChangeReason NetworkManager::ActiveConnectionPrivate::convertActiveConnectionStateReason(uint reason) | ||||
59 | { | ||||
60 | return static_cast<NetworkManager::ActiveConnection::StateChangeReason>(reason); | ||||
61 | } | ||||
62 | | ||||
58 | NetworkManager::ActiveConnection::ActiveConnection(const QString &path, QObject *parent) | 63 | NetworkManager::ActiveConnection::ActiveConnection(const QString &path, QObject *parent) | ||
59 | : QObject(parent), d_ptr(new ActiveConnectionPrivate(path, this)) | 64 | : QObject(parent), d_ptr(new ActiveConnectionPrivate(path, this)) | ||
60 | { | 65 | { | ||
61 | Q_D(ActiveConnection); | 66 | Q_D(ActiveConnection); | ||
62 | 67 | | |||
63 | // Get all ActiveConnection's at once | 68 | // Get all ActiveConnection's at once | ||
64 | QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); | 69 | QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); | ||
65 | if (!initialProperties.isEmpty()) { | 70 | if (!initialProperties.isEmpty()) { | ||
66 | d->propertiesChanged(initialProperties); | 71 | d->propertiesChanged(initialProperties); | ||
67 | } | 72 | } | ||
68 | 73 | | |||
69 | #ifndef NMQT_STATIC | 74 | #ifndef NMQT_STATIC | ||
70 | #if NM_CHECK_VERSION(1, 4, 0) | 75 | #if NM_CHECK_VERSION(1, 4, 0) | ||
71 | QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, | 76 | QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, | ||
72 | QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); | 77 | QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); | ||
73 | #else | 78 | #else | ||
74 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); | 79 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); | ||
75 | #endif | 80 | #endif | ||
76 | #endif | 81 | #endif | ||
77 | 82 | | |||
78 | #ifdef NMQT_STATIC | 83 | #ifdef NMQT_STATIC | ||
79 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); | 84 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); | ||
80 | #endif | 85 | #endif | ||
81 | 86 | | |||
87 | #if NM_CHECK_VERSION(1, 8, 0) | ||||
88 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::StateChanged, d, &ActiveConnectionPrivate::stateChanged); | ||||
89 | #endif | ||||
90 | | ||||
82 | #ifndef NMQT_STATIC | 91 | #ifndef NMQT_STATIC | ||
83 | /* | 92 | /* | ||
84 | * Workaround: Re-check connection state before we watch changes in case it gets changed too quickly | 93 | * Workaround: Re-check connection state before we watch changes in case it gets changed too quickly | ||
85 | * BUG:352326 | 94 | * BUG:352326 | ||
86 | */ | 95 | */ | ||
87 | d->recheckProperties(); | 96 | d->recheckProperties(); | ||
88 | #endif | 97 | #endif | ||
89 | } | 98 | } | ||
90 | 99 | | |||
91 | NetworkManager::ActiveConnection::ActiveConnection(ActiveConnectionPrivate &dd, QObject *parent) | 100 | NetworkManager::ActiveConnection::ActiveConnection(ActiveConnectionPrivate &dd, QObject *parent) | ||
92 | : QObject(parent), d_ptr(&dd) | 101 | : QObject(parent), d_ptr(&dd) | ||
93 | { | 102 | { | ||
94 | Q_D(ActiveConnection); | 103 | Q_D(ActiveConnection); | ||
95 | 104 | | |||
96 | #ifndef NMQT_STATIC | 105 | #ifndef NMQT_STATIC | ||
97 | #if NM_CHECK_VERSION(1, 4, 0) | 106 | #if NM_CHECK_VERSION(1, 4, 0) | ||
98 | QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, | 107 | QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, | ||
99 | QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); | 108 | QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); | ||
100 | #else | 109 | #else | ||
101 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); | 110 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); | ||
102 | #endif | 111 | #endif | ||
103 | #endif | 112 | #endif | ||
104 | 113 | | |||
114 | #if NM_CHECK_VERSION(1, 8, 0) | ||||
115 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::StateChanged, d, &ActiveConnectionPrivate::stateChanged); | ||||
116 | #endif | ||||
117 | | ||||
105 | #ifdef NMQT_STATIC | 118 | #ifdef NMQT_STATIC | ||
106 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); | 119 | connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); | ||
107 | #endif | 120 | #endif | ||
108 | 121 | | |||
109 | #ifndef NMQT_STATIC | 122 | #ifndef NMQT_STATIC | ||
110 | /* | 123 | /* | ||
111 | * Workaround: Re-check connection state before we watch changes in case it gets changed too quickly | 124 | * Workaround: Re-check connection state before we watch changes in case it gets changed too quickly | ||
112 | * BUG:352326 | 125 | * BUG:352326 | ||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Line(s) | 284 | Q_FOREACH (const QString &property, properties) { | |||
277 | 290 | | |||
278 | QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(message); | 291 | QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(message); | ||
279 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this); | 292 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this); | ||
280 | 293 | | |||
281 | connect(watcher, &QDBusPendingCallWatcher::finished, [watcher, q, this, property] () { | 294 | connect(watcher, &QDBusPendingCallWatcher::finished, [watcher, q, this, property] () { | ||
282 | watcher->deleteLater(); | 295 | watcher->deleteLater(); | ||
283 | if (property == QLatin1String("State")) { | 296 | if (property == QLatin1String("State")) { | ||
284 | state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(iface.state()); | 297 | state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(iface.state()); | ||
298 | // FIXME keeping for backward compatibility | ||||
285 | Q_EMIT q->stateChanged(state); | 299 | Q_EMIT q->stateChanged(state); | ||
300 | Q_EMIT q->stateChangedWithReason(state, ActiveConnection::UnknownReason); | ||||
286 | } | 301 | } | ||
287 | if (property == QLatin1String("Ip4Config")) { | 302 | if (property == QLatin1String("Ip4Config")) { | ||
288 | ipV4ConfigPath = iface.ip4Config().path(); | 303 | ipV4ConfigPath = iface.ip4Config().path(); | ||
289 | Q_EMIT q->ipV4ConfigChanged(); | 304 | Q_EMIT q->ipV4ConfigChanged(); | ||
290 | } else if (property == QLatin1String("Ip6Config")) { | 305 | } else if (property == QLatin1String("Ip6Config")) { | ||
291 | ipV6ConfigPath = iface.ip6Config().path(); | 306 | ipV6ConfigPath = iface.ip6Config().path(); | ||
292 | Q_EMIT q->ipV6ConfigChanged(); | 307 | Q_EMIT q->ipV6ConfigChanged(); | ||
293 | } else if (property == QLatin1String("Dhcp4Config")) { | 308 | } else if (property == QLatin1String("Dhcp4Config")) { | ||
Show All 11 Lines | |||||
305 | { | 320 | { | ||
306 | Q_UNUSED(invalidatedProperties); | 321 | Q_UNUSED(invalidatedProperties); | ||
307 | 322 | | |||
308 | if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.Connection.Active")) { | 323 | if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.Connection.Active")) { | ||
309 | propertiesChanged(properties); | 324 | propertiesChanged(properties); | ||
310 | } | 325 | } | ||
311 | } | 326 | } | ||
312 | 327 | | |||
328 | void NetworkManager::ActiveConnectionPrivate::stateChanged(uint newState, uint reason) | ||||
329 | { | ||||
330 | Q_Q(ActiveConnection); | ||||
331 | | ||||
332 | state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(newState); | ||||
333 | NetworkManager::ActiveConnection::StateChangeReason stateChangeReason = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionStateReason(reason); | ||||
334 | Q_EMIT q->stateChanged(state); | ||||
335 | Q_EMIT q->stateChangedWithReason(state, stateChangeReason); | ||||
336 | } | ||||
337 | | ||||
313 | void NetworkManager::ActiveConnectionPrivate::propertiesChanged(const QVariantMap &properties) | 338 | void NetworkManager::ActiveConnectionPrivate::propertiesChanged(const QVariantMap &properties) | ||
314 | { | 339 | { | ||
315 | // qCDebug(NMQT) << Q_FUNC_INFO << properties; | 340 | // qCDebug(NMQT) << Q_FUNC_INFO << properties; | ||
316 | 341 | | |||
317 | QVariantMap::const_iterator it = properties.constBegin(); | 342 | QVariantMap::const_iterator it = properties.constBegin(); | ||
318 | while (it != properties.constEnd()) { | 343 | while (it != properties.constEnd()) { | ||
319 | propertyChanged(it.key(), it.value()); | 344 | propertyChanged(it.key(), it.value()); | ||
320 | ++it; | 345 | ++it; | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 350 | { | |||
393 | } else if (property == QLatin1String("Master")) { | 418 | } else if (property == QLatin1String("Master")) { | ||
394 | master = qdbus_cast<QDBusObjectPath>(value).path(); | 419 | master = qdbus_cast<QDBusObjectPath>(value).path(); | ||
395 | Q_EMIT q->masterChanged(master); | 420 | Q_EMIT q->masterChanged(master); | ||
396 | } else if (property == QLatin1String("SpecificObject")) { | 421 | } else if (property == QLatin1String("SpecificObject")) { | ||
397 | specificObject = qdbus_cast<QDBusObjectPath>(value).path(); | 422 | specificObject = qdbus_cast<QDBusObjectPath>(value).path(); | ||
398 | Q_EMIT q->specificObjectChanged(specificObject); | 423 | Q_EMIT q->specificObjectChanged(specificObject); | ||
399 | } else if (property == QLatin1String("State")) { | 424 | } else if (property == QLatin1String("State")) { | ||
400 | state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(value.toUInt()); | 425 | state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(value.toUInt()); | ||
426 | #if !NM_CHECK_VERSION(1, 8, 0) | ||||
427 | // FIXME keeping for backward compatibility, do not emit state changed as there is additional signal for changed state | ||||
401 | Q_EMIT q->stateChanged(state); | 428 | Q_EMIT q->stateChanged(state); | ||
429 | Q_EMIT q->stateChangedReason(state, ActiveConnection::UnknownReason); | ||||
430 | #endif | ||||
402 | } else if (property == QLatin1String("Vpn")) { | 431 | } else if (property == QLatin1String("Vpn")) { | ||
403 | vpn = value.toBool(); | 432 | vpn = value.toBool(); | ||
404 | Q_EMIT q->vpnChanged(vpn); | 433 | Q_EMIT q->vpnChanged(vpn); | ||
405 | } else if (property == QLatin1String("Uuid")) { | 434 | } else if (property == QLatin1String("Uuid")) { | ||
406 | uuid = value.toString(); | 435 | uuid = value.toString(); | ||
407 | Q_EMIT q->uuidChanged(uuid); | 436 | Q_EMIT q->uuidChanged(uuid); | ||
408 | } else if (property == QLatin1String("Devices")) { | 437 | } else if (property == QLatin1String("Devices")) { | ||
409 | devices.clear(); | 438 | devices.clear(); | ||
Show All 9 Lines |