NetworkManagerQt

teamdevice.cpp
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
13NetworkManager::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
23NetworkManager::TeamDevicePrivate::~TeamDevicePrivate()
24{
25}
26
27NetworkManager::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(d->iface.staticInterfaceName(), path);
33 if (!initialProperties.isEmpty()) {
34 d->propertiesChanged(initialProperties);
35 }
36}
37
38NetworkManager::TeamDevice::~TeamDevice()
39{
40}
41
46
47bool NetworkManager::TeamDevice::carrier() const
48{
49 Q_D(const TeamDevice);
50
51 return d->carrier;
52}
53
54QString NetworkManager::TeamDevice::hwAddress() const
55{
56 Q_D(const TeamDevice);
57
58 return d->hwAddress;
59}
60
61QStringList NetworkManager::TeamDevice::slaves() const
62{
63 Q_D(const TeamDevice);
64 return d->slaves;
65}
66
67QString NetworkManager::TeamDevice::config() const
68{
69 Q_D(const TeamDevice);
70 return d->config;
71}
72
73void 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(carrier);
80 } else if (property == QLatin1String("HwAddress")) {
81 hwAddress = value.toString();
82 Q_EMIT q->hwAddressChanged(hwAddress);
83 } else if (property == QLatin1String("Slaves")) {
85 const QList<QDBusObjectPath> opList = qdbus_cast<QList<QDBusObjectPath>>(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"
Type
Device type.
Definition device.h:191
@ Team
Team master device.
Definition device.h:207
A team device interface.
Definition teamdevice.h:21
Type type() const override
Retrieves the interface type.
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.