NetworkManagerQt

bridgedevice.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 "bridgedevice_p.h"
8#include "manager_p.h"
9
10NetworkManager::BridgeDevicePrivate::BridgeDevicePrivate(const QString &path, BridgeDevice *q)
11 : DevicePrivate(path, q)
12#ifdef NMQT_STATIC
13 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
14#else
15 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
16#endif
17 , carrier(false)
18{
19}
20
21NetworkManager::BridgeDevicePrivate::~BridgeDevicePrivate()
22{
23}
24
25NetworkManager::BridgeDevice::BridgeDevice(const QString &path, QObject *parent)
26 : Device(*new BridgeDevicePrivate(path, this), parent)
27{
28 Q_D(BridgeDevice);
29
30 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path);
31 if (!initialProperties.isEmpty()) {
32 d->propertiesChanged(initialProperties);
33 }
34}
35
36NetworkManager::BridgeDevice::~BridgeDevice()
37{
38}
39
44
45bool NetworkManager::BridgeDevice::carrier() const
46{
47 Q_D(const BridgeDevice);
48
49 return d->carrier;
50}
51
52QString NetworkManager::BridgeDevice::hwAddress() const
53{
54 Q_D(const BridgeDevice);
55
56 return d->hwAddress;
57}
58
59QStringList NetworkManager::BridgeDevice::slaves() const
60{
61 Q_D(const BridgeDevice);
62
63 return d->slaves;
64}
65
66void NetworkManager::BridgeDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
67{
68 Q_Q(BridgeDevice);
69
70 if (property == QLatin1String("Carrier")) {
71 carrier = value.toBool();
72 Q_EMIT q->carrierChanged(carrier);
73 } else if (property == QLatin1String("HwAddress")) {
74 hwAddress = value.toString();
75 Q_EMIT q->hwAddressChanged(hwAddress);
76 } else if (property == QLatin1String("Slaves")) {
78 const QList<QDBusObjectPath> opList = qdbus_cast<QList<QDBusObjectPath>>(value);
79 for (const QDBusObjectPath &op : opList) {
80 list << op.path();
81 }
82 slaves = list;
83 Q_EMIT q->slavesChanged(slaves);
84 } else {
85 DevicePrivate::propertyChanged(property, value);
86 }
87}
88
89#include "moc_bridgedevice.cpp"
A bridge device interface.
Type type() const override
Retrieves the interface type.
Type
Device type.
Definition device.h:191
@ Bridge
Bridge virtual device.
Definition device.h:205
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 Fri Nov 8 2024 11:48:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.