File indexing completed on 2025-03-16 12:58:27
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 "manager.h" 0009 #include "vlandevice_p.h" 0010 0011 NetworkManager::VlanDevicePrivate::VlanDevicePrivate(const QString &path, VlanDevice *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 , carrier(false) 0019 { 0020 } 0021 0022 NetworkManager::VlanDevice::~VlanDevice() 0023 { 0024 } 0025 0026 NetworkManager::VlanDevice::VlanDevice(const QString &path, QObject *parent) 0027 : Device(*new VlanDevicePrivate(path, this), parent) 0028 { 0029 Q_D(VlanDevice); 0030 0031 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); 0032 if (!initialProperties.isEmpty()) { 0033 d->propertiesChanged(initialProperties); 0034 } 0035 } 0036 0037 NetworkManager::VlanDevicePrivate::~VlanDevicePrivate() 0038 { 0039 } 0040 0041 NetworkManager::Device::Type NetworkManager::VlanDevice::type() const 0042 { 0043 return NetworkManager::Device::Vlan; 0044 } 0045 0046 bool NetworkManager::VlanDevice::carrier() const 0047 { 0048 Q_D(const VlanDevice); 0049 0050 return d->carrier; 0051 } 0052 0053 QString NetworkManager::VlanDevice::hwAddress() const 0054 { 0055 Q_D(const VlanDevice); 0056 0057 return d->hwAddress; 0058 } 0059 0060 NetworkManager::Device::Ptr NetworkManager::VlanDevice::parent() const 0061 { 0062 if (NetworkManager::checkVersion(1, 0, 0)) { 0063 Q_D(const VlanDevice); 0064 0065 return NetworkManager::findNetworkInterface(d->parent); 0066 } else { 0067 return NetworkManager::Device::Ptr(nullptr); 0068 } 0069 } 0070 0071 uint NetworkManager::VlanDevice::vlanId() const 0072 { 0073 Q_D(const VlanDevice); 0074 0075 return d->vlanId; 0076 } 0077 0078 void NetworkManager::VlanDevicePrivate::propertyChanged(const QString &property, const QVariant &value) 0079 { 0080 Q_Q(VlanDevice); 0081 0082 if (property == QLatin1String("Carrier")) { 0083 carrier = value.toBool(); 0084 Q_EMIT q->carrierChanged(carrier); 0085 } else if (property == QLatin1String("HwAddress")) { 0086 hwAddress = value.toString(); 0087 Q_EMIT q->hwAddressChanged(hwAddress); 0088 } else if (property == QLatin1String("Parent")) { 0089 parent = value.value<QDBusObjectPath>().path(); 0090 Q_EMIT q->parentChanged(parent); 0091 } else if (property == QLatin1String("VlanId")) { 0092 vlanId = value.toUInt(); 0093 Q_EMIT q->vlanIdChanged(vlanId); 0094 } else { 0095 DevicePrivate::propertyChanged(property, value); 0096 } 0097 } 0098 0099 #include "moc_vlandevice.cpp" 0100 #include "moc_vlandevice_p.cpp"