File indexing completed on 2025-03-16 12:58:27
0001 /* 0002 SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org> 0003 SPDX-FileCopyrightText: 2013 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 "wireddevice.h" 0009 #include "manager.h" 0010 #include "manager_p.h" 0011 #include "wireddevice_p.h" 0012 0013 #include "nmdebug.h" 0014 0015 NetworkManager::WiredDevicePrivate::WiredDevicePrivate(const QString &path, WiredDevice *q) 0016 : DevicePrivate(path, q) 0017 #ifdef NMQT_STATIC 0018 , wiredIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) 0019 #else 0020 , wiredIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) 0021 #endif 0022 , bitrate(0) 0023 , carrier(false) 0024 { 0025 } 0026 0027 NetworkManager::WiredDevicePrivate::~WiredDevicePrivate() 0028 { 0029 } 0030 0031 NetworkManager::WiredDevice::WiredDevice(const QString &path, QObject *parent) 0032 : Device(*new NetworkManager::WiredDevicePrivate(path, this), parent) 0033 { 0034 Q_D(WiredDevice); 0035 #ifdef NMQT_STATIC 0036 connect(&d->wiredIface, &OrgFreedesktopNetworkManagerDeviceWiredInterface::PropertiesChanged, d, &WiredDevicePrivate::propertiesChanged); 0037 #endif 0038 // Get all WiredDevices's properties at once 0039 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->wiredIface.staticInterfaceName(), path); 0040 if (!initialProperties.isEmpty()) { 0041 d->propertiesChanged(initialProperties); 0042 } 0043 0044 0045 } 0046 0047 NetworkManager::WiredDevice::~WiredDevice() 0048 { 0049 } 0050 0051 NetworkManager::Device::Type NetworkManager::WiredDevice::type() const 0052 { 0053 return NetworkManager::Device::Ethernet; 0054 } 0055 0056 QString NetworkManager::WiredDevice::hardwareAddress() const 0057 { 0058 Q_D(const NetworkManager::WiredDevice); 0059 return d->hardwareAddress; 0060 } 0061 0062 QString NetworkManager::WiredDevice::permanentHardwareAddress() const 0063 { 0064 Q_D(const NetworkManager::WiredDevice); 0065 return d->permanentHardwareAddress; 0066 } 0067 0068 int NetworkManager::WiredDevice::bitRate() const 0069 { 0070 Q_D(const NetworkManager::WiredDevice); 0071 return d->bitrate; 0072 } 0073 0074 bool NetworkManager::WiredDevice::carrier() const 0075 { 0076 Q_D(const NetworkManager::WiredDevice); 0077 return d->carrier; 0078 } 0079 0080 QStringList NetworkManager::WiredDevice::s390SubChannels() const 0081 { 0082 Q_D(const NetworkManager::WiredDevice); 0083 return d->s390SubChannels; 0084 } 0085 0086 void NetworkManager::WiredDevicePrivate::propertyChanged(const QString &property, const QVariant &value) 0087 { 0088 Q_Q(NetworkManager::WiredDevice); 0089 0090 if (property == QLatin1String("Carrier")) { 0091 carrier = value.toBool(); 0092 Q_EMIT q->carrierChanged(carrier); 0093 } else if (property == QLatin1String("HwAddress")) { 0094 hardwareAddress = value.toString(); 0095 Q_EMIT q->hardwareAddressChanged(hardwareAddress); 0096 } else if (property == QLatin1String("PermHwAddress")) { 0097 permanentHardwareAddress = value.toString(); 0098 Q_EMIT q->permanentHardwareAddressChanged(permanentHardwareAddress); 0099 } else if (property == QLatin1String("Speed")) { 0100 bitrate = value.toUInt() * 1000; 0101 Q_EMIT q->bitRateChanged(bitrate); 0102 } else if (property == QLatin1String("S390Subchannels")) { 0103 s390SubChannels = value.toStringList(); 0104 Q_EMIT q->s390SubChannelsChanged(s390SubChannels); 0105 } else { 0106 DevicePrivate::propertyChanged(property, value); 0107 } 0108 } 0109 0110 #include "moc_wireddevice.cpp" 0111 #include "moc_wireddevice_p.cpp"