File indexing completed on 2025-03-16 12:58:27
0001 /* 0002 SPDX-FileCopyrightText: 2019 Jan Grulich <jgrulich@redhat.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "wireguarddevice.h" 0008 #include "manager_p.h" 0009 #include "wireguarddevice_p.h" 0010 0011 NetworkManager::WireGuardDevicePrivate::WireGuardDevicePrivate(const QString &path, WireGuardDevice *q) 0012 : DevicePrivate(path, q) 0013 #ifdef NMQT_STATIC 0014 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) 0015 #else 0016 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) 0017 #endif 0018 , listenPort(0) 0019 , fwMark(0) 0020 { 0021 } 0022 0023 NetworkManager::WireGuardDevicePrivate::~WireGuardDevicePrivate() 0024 { 0025 } 0026 0027 NetworkManager::WireGuardDevice::WireGuardDevice(const QString &path, QObject *parent) 0028 : Device(*new WireGuardDevicePrivate(path, this), parent) 0029 { 0030 Q_D(WireGuardDevice); 0031 0032 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); 0033 if (!initialProperties.isEmpty()) { 0034 d->propertiesChanged(initialProperties); 0035 } 0036 } 0037 0038 NetworkManager::WireGuardDevice::~WireGuardDevice() 0039 { 0040 } 0041 0042 NetworkManager::Device::Type NetworkManager::WireGuardDevice::type() const 0043 { 0044 return NetworkManager::Device::WireGuard; 0045 } 0046 0047 QByteArray NetworkManager::WireGuardDevice::publicKey() const 0048 { 0049 Q_D(const WireGuardDevice); 0050 0051 return d->publicKey; 0052 } 0053 0054 uint NetworkManager::WireGuardDevice::listenPort() const 0055 { 0056 Q_D(const WireGuardDevice); 0057 0058 return d->listenPort; 0059 } 0060 0061 uint NetworkManager::WireGuardDevice::fwMark() const 0062 { 0063 Q_D(const WireGuardDevice); 0064 0065 return d->fwMark; 0066 } 0067 0068 void NetworkManager::WireGuardDevicePrivate::propertyChanged(const QString &property, const QVariant &value) 0069 { 0070 Q_Q(WireGuardDevice); 0071 0072 if (property == QLatin1String("PublicKey")) { 0073 publicKey = value.toByteArray(); 0074 Q_EMIT q->publicKeyChanged(publicKey); 0075 } else if (property == QLatin1String("ListenPort")) { 0076 listenPort = value.toUInt(); 0077 Q_EMIT q->listenPortChanged(listenPort); 0078 } else if (property == QLatin1String("FwMark")) { 0079 fwMark = value.toUInt(); 0080 Q_EMIT q->fwMarkChanged(fwMark); 0081 } else { 0082 DevicePrivate::propertyChanged(property, value); 0083 } 0084 } 0085 0086 #include "moc_wireguarddevice.cpp"