NetworkManagerQt

wireddevice.cpp
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(d->wiredIface.staticInterfaceName(), path);
40 if (!initialProperties.isEmpty()) {
41 d->propertiesChanged(initialProperties);
42 }
43
44
45}
46
47NetworkManager::WiredDevice::~WiredDevice()
48{
49}
50
55
56QString NetworkManager::WiredDevice::hardwareAddress() const
57{
59 return d->hardwareAddress;
60}
61
62QString NetworkManager::WiredDevice::permanentHardwareAddress() const
63{
65 return d->permanentHardwareAddress;
66}
67
68int NetworkManager::WiredDevice::bitRate() const
69{
71 return d->bitrate;
72}
73
74bool NetworkManager::WiredDevice::carrier() const
75{
77 return d->carrier;
78}
79
80QStringList NetworkManager::WiredDevice::s390SubChannels() const
81{
83 return d->s390SubChannels;
84}
85
86void NetworkManager::WiredDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
87{
89
90 if (property == QLatin1String("Carrier")) {
91 carrier = value.toBool();
92 Q_EMIT q->carrierChanged(carrier);
93 } else if (property == QLatin1String("HwAddress")) {
94 hardwareAddress = value.toString();
95 Q_EMIT q->hardwareAddressChanged(hardwareAddress);
96 } else if (property == QLatin1String("PermHwAddress")) {
97 permanentHardwareAddress = value.toString();
98 Q_EMIT q->permanentHardwareAddressChanged(permanentHardwareAddress);
99 } else if (property == QLatin1String("Speed")) {
100 bitrate = value.toUInt() * 1000;
101 Q_EMIT q->bitRateChanged(bitrate);
102 } else if (property == QLatin1String("S390Subchannels")) {
103 s390SubChannels = value.toStringList();
104 Q_EMIT q->s390SubChannelsChanged(s390SubChannels);
105 } else {
106 DevicePrivate::propertyChanged(property, value);
107 }
108}
109
110#include "moc_wireddevice.cpp"
111#include "moc_wireddevice_p.cpp"
Type
Device type.
Definition device.h:191
@ Ethernet
Ieee8023 wired ethernet.
Definition device.h:193
A wired device interface.
Definition wireddevice.h:24
Type type() const override
Return the type.
QString path(const QString &relativePath)
This class allows querying the underlying system to discover the available network interfaces and rea...
Definition accesspoint.h:21
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
bool toBool() const const
QString toString() const const
QStringList toStringList() const const
uint toUInt(bool *ok) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.