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 | |
12 | NetworkManager::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 | |
23 | NetworkManager::BondDevice::~BondDevice() |
24 | { |
25 | } |
26 | |
27 | NetworkManager::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(interfaceName: d->iface.staticInterfaceName(), path); |
33 | if (!initialProperties.isEmpty()) { |
34 | d->propertiesChanged(properties: initialProperties); |
35 | } |
36 | |
37 | } |
38 | |
39 | NetworkManager::BondDevicePrivate::~BondDevicePrivate() |
40 | { |
41 | } |
42 | |
43 | NetworkManager::Device::Type NetworkManager::BondDevice::type() const |
44 | { |
45 | return NetworkManager::Device::Bond; |
46 | } |
47 | |
48 | bool NetworkManager::BondDevice::carrier() const |
49 | { |
50 | Q_D(const BondDevice); |
51 | |
52 | return d->carrier; |
53 | } |
54 | |
55 | QString NetworkManager::BondDevice::hwAddress() const |
56 | { |
57 | Q_D(const BondDevice); |
58 | |
59 | return d->hwAddress; |
60 | } |
61 | |
62 | QStringList NetworkManager::BondDevice::slaves() const |
63 | { |
64 | Q_D(const BondDevice); |
65 | |
66 | return d->slaves; |
67 | } |
68 | |
69 | void 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(plugged: carrier); |
76 | } else if (property == QLatin1String("HwAddress" )) { |
77 | hwAddress = value.toString(); |
78 | Q_EMIT q->hwAddressChanged(address: hwAddress); |
79 | } else if (property == QLatin1String("Slaves" )) { |
80 | QStringList list; |
81 | const QList<QDBusObjectPath> opList = qdbus_cast<QList<QDBusObjectPath>>(v: 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" |
94 | |