File indexing completed on 2024-04-14 14:30:37

0001 /*
0002     SPDX-FileCopyrightText: 2013 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 "device_p.h"
0008 #include "macvlandevice_p.h"
0009 #include "manager.h"
0010 
0011 NetworkManager::MacVlanDevicePrivate::MacVlanDevicePrivate(const QString &path, MacVlanDevice *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::MacVlanDevicePrivate::~MacVlanDevicePrivate()
0022 {
0023 }
0024 
0025 NetworkManager::MacVlanDevice::MacVlanDevice(const QString &path, QObject *parent)
0026     : Device(*new MacVlanDevicePrivate(path, this), parent)
0027 {
0028     Q_D(MacVlanDevice);
0029 
0030     QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path);
0031     if (!initialProperties.isEmpty()) {
0032         d->propertiesChanged(initialProperties);
0033     }
0034 }
0035 
0036 NetworkManager::MacVlanDevice::~MacVlanDevice()
0037 {
0038 }
0039 
0040 NetworkManager::Device::Type NetworkManager::MacVlanDevice::type() const
0041 {
0042     return NetworkManager::Device::MacVlan;
0043 }
0044 
0045 QString NetworkManager::MacVlanDevice::mode() const
0046 {
0047     Q_D(const MacVlanDevice);
0048     return d->mode;
0049 }
0050 
0051 bool NetworkManager::MacVlanDevice::noPromisc() const
0052 {
0053     Q_D(const MacVlanDevice);
0054     return d->noPromisc;
0055 }
0056 
0057 QString NetworkManager::MacVlanDevice::parent() const
0058 {
0059     Q_D(const MacVlanDevice);
0060     return d->parent;
0061 }
0062 
0063 void NetworkManager::MacVlanDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
0064 {
0065     Q_Q(MacVlanDevice);
0066 
0067     if (property == QLatin1String("Mode")) {
0068         mode = value.toString();
0069         Q_EMIT q->modeChanged(mode);
0070     } else if (property == QLatin1String("NoPromisc")) {
0071         noPromisc = value.toBool();
0072         Q_EMIT q->noPromiscChanged(noPromisc);
0073     } else if (property == QLatin1String("Parent")) {
0074         parent = value.toString();
0075         Q_EMIT q->parentChanged(parent);
0076     } else {
0077         DevicePrivate::propertyChanged(property, value);
0078     }
0079 }
0080 
0081 #include "moc_macvlandevice.cpp"
0082 #include "moc_macvlandevice_p.cpp"