1/*
2 SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org>
3 SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#include "wireddevice.h"
9#include "manager.h"
10#include "manager_p.h"
11#include "wireddevice_p.h"
12
13#include "nmdebug.h"
14
15NetworkManager::WiredDevicePrivate::WiredDevicePrivate(const QString &path, WiredDevice *q)
16 : DevicePrivate(path, q)
17#ifdef NMQT_STATIC
18 , wiredIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
19#else
20 , wiredIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
21#endif
22 , bitrate(0)
23 , carrier(false)
24{
25}
26
27NetworkManager::WiredDevicePrivate::~WiredDevicePrivate()
28{
29}
30
31NetworkManager::WiredDevice::WiredDevice(const QString &path, QObject *parent)
32 : Device(*new NetworkManager::WiredDevicePrivate(path, this), parent)
33{
34 Q_D(WiredDevice);
35#ifdef NMQT_STATIC
36 connect(&d->wiredIface, &OrgFreedesktopNetworkManagerDeviceWiredInterface::PropertiesChanged, d, &WiredDevicePrivate::propertiesChanged);
37#endif
38 // Get all WiredDevices's properties at once
39 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(interfaceName: d->wiredIface.staticInterfaceName(), path);
40 if (!initialProperties.isEmpty()) {
41 d->propertiesChanged(properties: initialProperties);
42 }
43
44
45}
46
47NetworkManager::WiredDevice::~WiredDevice()
48{
49}
50
51NetworkManager::Device::Type NetworkManager::WiredDevice::type() const
52{
53 return NetworkManager::Device::Ethernet;
54}
55
56QString NetworkManager::WiredDevice::hardwareAddress() const
57{
58 Q_D(const NetworkManager::WiredDevice);
59 return d->hardwareAddress;
60}
61
62QString NetworkManager::WiredDevice::permanentHardwareAddress() const
63{
64 Q_D(const NetworkManager::WiredDevice);
65 return d->permanentHardwareAddress;
66}
67
68int NetworkManager::WiredDevice::bitRate() const
69{
70 Q_D(const NetworkManager::WiredDevice);
71 return d->bitrate;
72}
73
74bool NetworkManager::WiredDevice::carrier() const
75{
76 Q_D(const NetworkManager::WiredDevice);
77 return d->carrier;
78}
79
80QStringList NetworkManager::WiredDevice::s390SubChannels() const
81{
82 Q_D(const NetworkManager::WiredDevice);
83 return d->s390SubChannels;
84}
85
86void NetworkManager::WiredDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
87{
88 Q_Q(NetworkManager::WiredDevice);
89
90 if (property == QLatin1String("Carrier")) {
91 carrier = value.toBool();
92 Q_EMIT q->carrierChanged(plugged: carrier);
93 } else if (property == QLatin1String("HwAddress")) {
94 hardwareAddress = value.toString();
95 Q_EMIT q->hardwareAddressChanged(hwAddress: hardwareAddress);
96 } else if (property == QLatin1String("PermHwAddress")) {
97 permanentHardwareAddress = value.toString();
98 Q_EMIT q->permanentHardwareAddressChanged(permHwAddress: permanentHardwareAddress);
99 } else if (property == QLatin1String("Speed")) {
100 bitrate = value.toUInt() * 1000;
101 Q_EMIT q->bitRateChanged(bitRate: bitrate);
102 } else if (property == QLatin1String("S390Subchannels")) {
103 s390SubChannels = value.toStringList();
104 Q_EMIT q->s390SubChannelsChanged(channels: s390SubChannels);
105 } else {
106 DevicePrivate::propertyChanged(property, value);
107 }
108}
109
110#include "moc_wireddevice.cpp"
111#include "moc_wireddevice_p.cpp"
112

source code of networkmanager-qt/src/wireddevice.cpp