File indexing completed on 2025-03-23 12:49:51
0001 /* 0002 SPDX-FileCopyrightText: 2013 Lukáš Tinkl <ltinkl@redhat.com> 0003 SPDX-FileCopyrightText: 2014 Jan Grulich <jgrulich@redhat.com> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #include "device_p.h" 0009 #include "gredevice_p.h" 0010 #include "manager.h" 0011 0012 NetworkManager::GreDevicePrivate::GreDevicePrivate(const QString &path, GreDevice *q) 0013 : DevicePrivate(path, q) 0014 #ifdef NMQT_STATIC 0015 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) 0016 #else 0017 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) 0018 #endif 0019 { 0020 } 0021 0022 NetworkManager::GreDevicePrivate::~GreDevicePrivate() 0023 { 0024 } 0025 0026 NetworkManager::GreDevice::GreDevice(const QString &path, QObject *parent) 0027 : Device(*new GreDevicePrivate(path, this), parent) 0028 { 0029 Q_D(GreDevice); 0030 0031 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); 0032 if (!initialProperties.isEmpty()) { 0033 d->propertiesChanged(initialProperties); 0034 } 0035 0036 } 0037 0038 NetworkManager::GreDevice::~GreDevice() 0039 { 0040 } 0041 0042 NetworkManager::Device::Type NetworkManager::GreDevice::type() const 0043 { 0044 return NetworkManager::Device::Gre; 0045 } 0046 0047 ushort NetworkManager::GreDevice::inputFlags() const 0048 { 0049 Q_D(const GreDevice); 0050 return d->inputFlags; 0051 } 0052 0053 ushort NetworkManager::GreDevice::outputFlags() const 0054 { 0055 Q_D(const GreDevice); 0056 return d->outputFlags; 0057 } 0058 0059 uint NetworkManager::GreDevice::inputKey() const 0060 { 0061 Q_D(const GreDevice); 0062 return d->inputKey; 0063 } 0064 0065 uint NetworkManager::GreDevice::outputKey() const 0066 { 0067 Q_D(const GreDevice); 0068 return d->outputKey; 0069 } 0070 0071 QString NetworkManager::GreDevice::localEnd() const 0072 { 0073 Q_D(const GreDevice); 0074 return d->localEnd; 0075 } 0076 0077 QString NetworkManager::GreDevice::remoteEnd() const 0078 { 0079 Q_D(const GreDevice); 0080 return d->remoteEnd; 0081 } 0082 0083 QString NetworkManager::GreDevice::parent() const 0084 { 0085 Q_D(const GreDevice); 0086 return d->parent; 0087 } 0088 0089 bool NetworkManager::GreDevice::pathMtuDiscovery() const 0090 { 0091 Q_D(const GreDevice); 0092 return d->pathMtuDiscovery; 0093 } 0094 0095 uchar NetworkManager::GreDevice::tos() const 0096 { 0097 Q_D(const GreDevice); 0098 return d->tos; 0099 } 0100 0101 uchar NetworkManager::GreDevice::ttl() const 0102 { 0103 Q_D(const GreDevice); 0104 return d->ttl; 0105 } 0106 0107 void NetworkManager::GreDevicePrivate::propertyChanged(const QString &property, const QVariant &value) 0108 { 0109 Q_Q(GreDevice); 0110 0111 if (property == QLatin1String("InputFlags")) { 0112 inputFlags = static_cast<ushort>(value.toUInt()); 0113 Q_EMIT q->inputFlagsChanged(inputFlags); 0114 } else if (property == QLatin1String("OutputFlags")) { 0115 outputFlags = static_cast<ushort>(value.toUInt()); 0116 Q_EMIT q->outputFlagsChanged(outputFlags); 0117 } else if (property == QLatin1String("InputKey")) { 0118 inputKey = value.toUInt(); 0119 Q_EMIT q->inputKeyChanged(inputKey); 0120 } else if (property == QLatin1String("OutputKey")) { 0121 outputKey = value.toUInt(); 0122 Q_EMIT q->outputKeyChanged(outputKey); 0123 } else if (property == QLatin1String("Local")) { 0124 localEnd = value.toString(); 0125 Q_EMIT q->localEndChanged(localEnd); 0126 } else if (property == QLatin1String("Remote")) { 0127 remoteEnd = value.toString(); 0128 Q_EMIT q->remoteEndChanged(remoteEnd); 0129 } else if (property == QLatin1String("Parent")) { 0130 parent = value.toString(); 0131 Q_EMIT q->parentChanged(parent); 0132 } else if (property == QLatin1String("PathMtuDiscovery")) { 0133 pathMtuDiscovery = value.toBool(); 0134 Q_EMIT q->pathMtuDiscoveryChanged(pathMtuDiscovery); 0135 } else if (property == QLatin1String("Tos")) { 0136 tos = static_cast<uchar>(value.toUInt()); 0137 Q_EMIT q->tosChanged(tos); 0138 } else if (property == QLatin1String("Ttl")) { 0139 ttl = static_cast<uchar>(value.toUInt()); 0140 Q_EMIT q->ttlChanged(ttl); 0141 } else { 0142 DevicePrivate::propertyChanged(property, value); 0143 } 0144 } 0145 0146 #include "moc_gredevice.cpp" 0147 #include "moc_gredevice_p.cpp"