NetworkManagerQt

wireguarddevice.cpp
1/*
2 SPDX-FileCopyrightText: 2019 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "wireguarddevice.h"
8#include "manager_p.h"
9#include "wireguarddevice_p.h"
10
11NetworkManager::WireGuardDevicePrivate::WireGuardDevicePrivate(const QString &path, WireGuardDevice *q)
12 : DevicePrivate(path, q)
13#ifdef NMQT_STATIC
14 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
15#else
16 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
17#endif
18 , listenPort(0)
19 , fwMark(0)
20{
21}
22
23NetworkManager::WireGuardDevicePrivate::~WireGuardDevicePrivate()
24{
25}
26
27NetworkManager::WireGuardDevice::WireGuardDevice(const QString &path, QObject *parent)
28 : Device(*new WireGuardDevicePrivate(path, this), parent)
29{
30 Q_D(WireGuardDevice);
31
32 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path);
33 if (!initialProperties.isEmpty()) {
34 d->propertiesChanged(initialProperties);
35 }
36}
37
38NetworkManager::WireGuardDevice::~WireGuardDevice()
39{
40}
41
46
47QByteArray NetworkManager::WireGuardDevice::publicKey() const
48{
49 Q_D(const WireGuardDevice);
50
51 return d->publicKey;
52}
53
54uint NetworkManager::WireGuardDevice::listenPort() const
55{
56 Q_D(const WireGuardDevice);
57
58 return d->listenPort;
59}
60
61uint NetworkManager::WireGuardDevice::fwMark() const
62{
63 Q_D(const WireGuardDevice);
64
65 return d->fwMark;
66}
67
68void NetworkManager::WireGuardDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
69{
70 Q_Q(WireGuardDevice);
71
72 if (property == QLatin1String("PublicKey")) {
73 publicKey = value.toByteArray();
74 Q_EMIT q->publicKeyChanged(publicKey);
75 } else if (property == QLatin1String("ListenPort")) {
76 listenPort = value.toUInt();
77 Q_EMIT q->listenPortChanged(listenPort);
78 } else if (property == QLatin1String("FwMark")) {
79 fwMark = value.toUInt();
80 Q_EMIT q->fwMarkChanged(fwMark);
81 } else {
82 DevicePrivate::propertyChanged(property, value);
83 }
84}
85
86#include "moc_wireguarddevice.cpp"
Type
Device type.
Definition device.h:191
@ WireGuard
WireGuard Device.
Definition device.h:222
A WireGuard device interface.
Type type() const override
Retrieves the interface type.
QString path(const QString &relativePath)
QByteArray toByteArray() const const
uint toUInt(bool *ok) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.