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(interfaceName: d->iface.staticInterfaceName(), path);
31 if (!initialProperties.isEmpty()) {
32 d->propertiesChanged(properties: initialProperties);
33 }
34}
35
36NetworkManager::BridgeDevice::~BridgeDevice()
37{
38}
39
40NetworkManager::Device::Type NetworkManager::BridgeDevice::type() const
41{
42 return NetworkManager::Device::Bridge;
43}
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(plugged: carrier);
73 } else if (property == QLatin1String("HwAddress")) {
74 hwAddress = value.toString();
75 Q_EMIT q->hwAddressChanged(address: hwAddress);
76 } else if (property == QLatin1String("Slaves")) {
77 QStringList list;
78 const QList<QDBusObjectPath> opList = qdbus_cast<QList<QDBusObjectPath>>(v: 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"
90

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