File indexing completed on 2024-04-14 03:57:44

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 "manager_p.h"
0009 #include "tundevice_p.h"
0010 
0011 NetworkManager::TunDevicePrivate::TunDevicePrivate(const QString &path, TunDevice *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 {
0019 }
0020 
0021 NetworkManager::TunDevicePrivate::~TunDevicePrivate()
0022 {
0023 }
0024 
0025 NetworkManager::TunDevice::TunDevice(const QString &path, QObject *parent)
0026     : Device(*new TunDevicePrivate(path, this), parent)
0027 {
0028     Q_D(TunDevice);
0029 
0030     QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path);
0031     if (!initialProperties.isEmpty()) {
0032         d->propertiesChanged(initialProperties);
0033     }
0034 }
0035 
0036 NetworkManager::TunDevice::~TunDevice()
0037 {
0038 }
0039 
0040 NetworkManager::Device::Type NetworkManager::TunDevice::type() const
0041 {
0042     return NetworkManager::Device::Tun;
0043 }
0044 
0045 qlonglong NetworkManager::TunDevice::owner() const
0046 {
0047     Q_D(const TunDevice);
0048     return d->owner;
0049 }
0050 
0051 qlonglong NetworkManager::TunDevice::group() const
0052 {
0053     Q_D(const TunDevice);
0054     return d->group;
0055 }
0056 
0057 QString NetworkManager::TunDevice::mode() const
0058 {
0059     Q_D(const TunDevice);
0060     return d->mode;
0061 }
0062 
0063 bool NetworkManager::TunDevice::multiQueue() const
0064 {
0065     Q_D(const TunDevice);
0066     return d->multiQueue;
0067 }
0068 
0069 bool NetworkManager::TunDevice::noPi() const
0070 {
0071     Q_D(const TunDevice);
0072     return d->noPi;
0073 }
0074 
0075 bool NetworkManager::TunDevice::vnetHdr() const
0076 {
0077     Q_D(const TunDevice);
0078     return d->vnetHdr;
0079 }
0080 
0081 QString NetworkManager::TunDevice::hwAddress() const
0082 {
0083     Q_D(const TunDevice);
0084     return d->hwAddress;
0085 }
0086 
0087 void NetworkManager::TunDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
0088 {
0089     Q_Q(TunDevice);
0090 
0091     if (property == QLatin1String("Owner")) {
0092         owner = value.toLongLong();
0093         Q_EMIT q->ownerChanged(owner);
0094     } else if (property == QLatin1String("Group")) {
0095         group = value.toLongLong();
0096         Q_EMIT q->groupChanged(group);
0097     } else if (property == QLatin1String("Mode")) {
0098         mode = value.toString();
0099         Q_EMIT q->modeChanged(mode);
0100     } else if (property == QLatin1String("MultiQueue")) {
0101         multiQueue = value.toBool();
0102         Q_EMIT q->multiQueueChanged(multiQueue);
0103     } else if (property == QLatin1String("NoPi")) {
0104         noPi = value.toBool();
0105         Q_EMIT q->noPiChanged(noPi);
0106     } else if (property == QLatin1String("VnetHdr")) {
0107         vnetHdr = value.toBool();
0108         Q_EMIT q->vnetHdrChanged(vnetHdr);
0109     } else if (property == QLatin1String("HwAddress")) {
0110         hwAddress = value.toString();
0111         Q_EMIT q->hwAddressChanged(hwAddress);
0112     } else {
0113         DevicePrivate::propertyChanged(property, value);
0114     }
0115 }
0116 
0117 #include "moc_tundevice.cpp"
0118 #include "moc_tundevice_p.cpp"