| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2013 Lukáš Tinkl <ltinkl@redhat.com> |
| 3 | SPDX-FileCopyrightText: 2014 Jan Grulich <jgrulich@redhat.com> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | |
| 8 | #include "device_p.h" |
| 9 | #include "gredevice_p.h" |
| 10 | #include "manager.h" |
| 11 | |
| 12 | NetworkManager::GreDevicePrivate::GreDevicePrivate(const QString &path, GreDevice *q) |
| 13 | : DevicePrivate(path, q) |
| 14 | #ifdef NMQT_STATIC |
| 15 | , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) |
| 16 | #else |
| 17 | , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) |
| 18 | #endif |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | NetworkManager::GreDevicePrivate::~GreDevicePrivate() |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | NetworkManager::GreDevice::GreDevice(const QString &path, QObject *parent) |
| 27 | : Device(*new GreDevicePrivate(path, this), parent) |
| 28 | { |
| 29 | Q_D(GreDevice); |
| 30 | |
| 31 | QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(interfaceName: d->iface.staticInterfaceName(), path); |
| 32 | if (!initialProperties.isEmpty()) { |
| 33 | d->propertiesChanged(properties: initialProperties); |
| 34 | } |
| 35 | |
| 36 | } |
| 37 | |
| 38 | NetworkManager::GreDevice::~GreDevice() |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | NetworkManager::Device::Type NetworkManager::GreDevice::type() const |
| 43 | { |
| 44 | return NetworkManager::Device::Gre; |
| 45 | } |
| 46 | |
| 47 | ushort NetworkManager::GreDevice::inputFlags() const |
| 48 | { |
| 49 | Q_D(const GreDevice); |
| 50 | return d->inputFlags; |
| 51 | } |
| 52 | |
| 53 | ushort NetworkManager::GreDevice::outputFlags() const |
| 54 | { |
| 55 | Q_D(const GreDevice); |
| 56 | return d->outputFlags; |
| 57 | } |
| 58 | |
| 59 | uint NetworkManager::GreDevice::inputKey() const |
| 60 | { |
| 61 | Q_D(const GreDevice); |
| 62 | return d->inputKey; |
| 63 | } |
| 64 | |
| 65 | uint NetworkManager::GreDevice::outputKey() const |
| 66 | { |
| 67 | Q_D(const GreDevice); |
| 68 | return d->outputKey; |
| 69 | } |
| 70 | |
| 71 | QString NetworkManager::GreDevice::localEnd() const |
| 72 | { |
| 73 | Q_D(const GreDevice); |
| 74 | return d->localEnd; |
| 75 | } |
| 76 | |
| 77 | QString NetworkManager::GreDevice::remoteEnd() const |
| 78 | { |
| 79 | Q_D(const GreDevice); |
| 80 | return d->remoteEnd; |
| 81 | } |
| 82 | |
| 83 | QString NetworkManager::GreDevice::parent() const |
| 84 | { |
| 85 | Q_D(const GreDevice); |
| 86 | return d->parent; |
| 87 | } |
| 88 | |
| 89 | bool NetworkManager::GreDevice::pathMtuDiscovery() const |
| 90 | { |
| 91 | Q_D(const GreDevice); |
| 92 | return d->pathMtuDiscovery; |
| 93 | } |
| 94 | |
| 95 | uchar NetworkManager::GreDevice::tos() const |
| 96 | { |
| 97 | Q_D(const GreDevice); |
| 98 | return d->tos; |
| 99 | } |
| 100 | |
| 101 | uchar NetworkManager::GreDevice::ttl() const |
| 102 | { |
| 103 | Q_D(const GreDevice); |
| 104 | return d->ttl; |
| 105 | } |
| 106 | |
| 107 | void NetworkManager::GreDevicePrivate::propertyChanged(const QString &property, const QVariant &value) |
| 108 | { |
| 109 | Q_Q(GreDevice); |
| 110 | |
| 111 | if (property == QLatin1String("InputFlags" )) { |
| 112 | inputFlags = static_cast<ushort>(value.toUInt()); |
| 113 | Q_EMIT q->inputFlagsChanged(inputflags: inputFlags); |
| 114 | } else if (property == QLatin1String("OutputFlags" )) { |
| 115 | outputFlags = static_cast<ushort>(value.toUInt()); |
| 116 | Q_EMIT q->outputFlagsChanged(outputFlags); |
| 117 | } else if (property == QLatin1String("InputKey" )) { |
| 118 | inputKey = value.toUInt(); |
| 119 | Q_EMIT q->inputKeyChanged(inputKey); |
| 120 | } else if (property == QLatin1String("OutputKey" )) { |
| 121 | outputKey = value.toUInt(); |
| 122 | Q_EMIT q->outputKeyChanged(outputKey); |
| 123 | } else if (property == QLatin1String("Local" )) { |
| 124 | localEnd = value.toString(); |
| 125 | Q_EMIT q->localEndChanged(localEnd); |
| 126 | } else if (property == QLatin1String("Remote" )) { |
| 127 | remoteEnd = value.toString(); |
| 128 | Q_EMIT q->remoteEndChanged(remoteEnd); |
| 129 | } else if (property == QLatin1String("Parent" )) { |
| 130 | parent = value.toString(); |
| 131 | Q_EMIT q->parentChanged(parent); |
| 132 | } else if (property == QLatin1String("PathMtuDiscovery" )) { |
| 133 | pathMtuDiscovery = value.toBool(); |
| 134 | Q_EMIT q->pathMtuDiscoveryChanged(pathMtuDiscovery); |
| 135 | } else if (property == QLatin1String("Tos" )) { |
| 136 | tos = static_cast<uchar>(value.toUInt()); |
| 137 | Q_EMIT q->tosChanged(tos); |
| 138 | } else if (property == QLatin1String("Ttl" )) { |
| 139 | ttl = static_cast<uchar>(value.toUInt()); |
| 140 | Q_EMIT q->ttlChanged(ttl); |
| 141 | } else { |
| 142 | DevicePrivate::propertyChanged(property, value); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | #include "moc_gredevice.cpp" |
| 147 | #include "moc_gredevice_p.cpp" |
| 148 | |