1 | /* |
2 | SPDX-FileCopyrightText: 2013 Lukáš Tinkl <ltinkl@redhat.com> |
3 | SPDX-FileCopyrightText: 2014 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 "device_p.h" |
9 | #include "manager.h" |
10 | #include "manager_p.h" |
11 | #include "teamdevice_p.h" |
12 | |
13 | NetworkManager::TeamDevicePrivate::TeamDevicePrivate(const QString &path, TeamDevice *q) |
14 | : DevicePrivate(path, q) |
15 | #ifdef NMQT_STATIC |
16 | , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) |
17 | #else |
18 | , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) |
19 | #endif |
20 | { |
21 | } |
22 | |
23 | NetworkManager::TeamDevicePrivate::~TeamDevicePrivate() |
24 | { |
25 | } |
26 | |
27 | NetworkManager::TeamDevice::TeamDevice(const QString &path, QObject *parent) |
28 | : Device(*new TeamDevicePrivate(path, this), parent) |
29 | { |
30 | Q_D(TeamDevice); |
31 | |
32 | QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(interfaceName: d->iface.staticInterfaceName(), path); |
33 | if (!initialProperties.isEmpty()) { |
34 | d->propertiesChanged(properties: initialProperties); |
35 | } |
36 | } |
37 | |
38 | NetworkManager::TeamDevice::~TeamDevice() |
39 | { |
40 | } |
41 | |
42 | NetworkManager::Device::Type NetworkManager::TeamDevice::type() const |
43 | { |
44 | return NetworkManager::Device::Team; |
45 | } |
46 | |
47 | bool NetworkManager::TeamDevice::carrier() const |
48 | { |
49 | Q_D(const TeamDevice); |
50 | |
51 | return d->carrier; |
52 | } |
53 | |
54 | QString NetworkManager::TeamDevice::hwAddress() const |
55 | { |
56 | Q_D(const TeamDevice); |
57 | |
58 | return d->hwAddress; |
59 | } |
60 | |
61 | QStringList NetworkManager::TeamDevice::slaves() const |
62 | { |
63 | Q_D(const TeamDevice); |
64 | return d->slaves; |
65 | } |
66 | |
67 | QString NetworkManager::TeamDevice::config() const |
68 | { |
69 | Q_D(const TeamDevice); |
70 | return d->config; |
71 | } |
72 | |
73 | void NetworkManager::TeamDevicePrivate::propertyChanged(const QString &property, const QVariant &value) |
74 | { |
75 | Q_Q(TeamDevice); |
76 | |
77 | if (property == QLatin1String("Carrier" )) { |
78 | carrier = value.toBool(); |
79 | Q_EMIT q->carrierChanged(plugged: carrier); |
80 | } else if (property == QLatin1String("HwAddress" )) { |
81 | hwAddress = value.toString(); |
82 | Q_EMIT q->hwAddressChanged(address: hwAddress); |
83 | } else if (property == QLatin1String("Slaves" )) { |
84 | QStringList list; |
85 | const QList<QDBusObjectPath> opList = qdbus_cast<QList<QDBusObjectPath>>(v: value); |
86 | for (const QDBusObjectPath &op : opList) { |
87 | list << op.path(); |
88 | } |
89 | slaves = list; |
90 | Q_EMIT q->slavesChanged(slaves); |
91 | } else if (property == QLatin1String("Config" )) { |
92 | config = value.toString(); |
93 | Q_EMIT q->configChanged(config); |
94 | } else { |
95 | DevicePrivate::propertyChanged(property, value); |
96 | } |
97 | } |
98 | |
99 | #include "moc_teamdevice.cpp" |
100 | #include "moc_teamdevice_p.cpp" |
101 | |