NetworkManagerQt

bonddevice.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "bonddevice_p.h"
8#include "device_p.h"
9#include "manager.h"
10#include "manager_p.h"
11
12NetworkManager::BondDevicePrivate::BondDevicePrivate(const QString &path, BondDevice *q)
13 : DevicePrivate(path, q)
14#ifdef NMQT_STATIC
15 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
16#else
17 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
18#endif
19 , carrier(false)
20{
21}
22
23NetworkManager::BondDevice::~BondDevice()
24{
25}
26
27NetworkManager::BondDevice::BondDevice(const QString &path, QObject *parent)
28 : Device(*new BondDevicePrivate(path, this), parent)
29{
30 Q_D(BondDevice);
31
32 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path);
33 if (!initialProperties.isEmpty()) {
34 d->propertiesChanged(initialProperties);
35 }
36
37}
38
39NetworkManager::BondDevicePrivate::~BondDevicePrivate()
40{
41}
42
47
48bool NetworkManager::BondDevice::carrier() const
49{
50 Q_D(const BondDevice);
51
52 return d->carrier;
53}
54
55QString NetworkManager::BondDevice::hwAddress() const
56{
57 Q_D(const BondDevice);
58
59 return d->hwAddress;
60}
61
62QStringList NetworkManager::BondDevice::slaves() const
63{
64 Q_D(const BondDevice);
65
66 return d->slaves;
67}
68
69void NetworkManager::BondDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
70{
71 Q_Q(BondDevice);
72
73 if (property == QLatin1String("Carrier")) {
74 carrier = value.toBool();
75 Q_EMIT q->carrierChanged(carrier);
76 } else if (property == QLatin1String("HwAddress")) {
77 hwAddress = value.toString();
78 Q_EMIT q->hwAddressChanged(hwAddress);
79 } else if (property == QLatin1String("Slaves")) {
81 const QList<QDBusObjectPath> opList = qdbus_cast<QList<QDBusObjectPath>>(value);
82 for (const QDBusObjectPath &op : opList) {
83 list << op.path();
84 }
85 slaves = list;
86 Q_EMIT q->slavesChanged(slaves);
87 } else {
88 DevicePrivate::propertyChanged(property, value);
89 }
90}
91
92#include "moc_bonddevice.cpp"
93#include "moc_bonddevice_p.cpp"
A bond device interface.
Definition bonddevice.h:21
Type type() const override
Retrieves the interface type.
Type
Device type.
Definition device.h:191
@ Bond
Bond virtual device.
Definition device.h:202
QString path(const QString &relativePath)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
bool toBool() const const
QString toString() 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.