NetworkManagerQt

vlandevice.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 "device_p.h"
8#include "manager.h"
9#include "vlandevice_p.h"
10
11NetworkManager::VlanDevicePrivate::VlanDevicePrivate(const QString &path, VlanDevice *q)
12 : DevicePrivate(path, q)
13#ifdef NMQT_STATIC
14 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
15#else
16 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
17#endif
18 , carrier(false)
19{
20}
21
22NetworkManager::VlanDevice::~VlanDevice()
23{
24}
25
26NetworkManager::VlanDevice::VlanDevice(const QString &path, QObject *parent)
27 : Device(*new VlanDevicePrivate(path, this), parent)
28{
29 Q_D(VlanDevice);
30
31 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path);
32 if (!initialProperties.isEmpty()) {
33 d->propertiesChanged(initialProperties);
34 }
35}
36
37NetworkManager::VlanDevicePrivate::~VlanDevicePrivate()
38{
39}
40
45
46bool NetworkManager::VlanDevice::carrier() const
47{
48 Q_D(const VlanDevice);
49
50 return d->carrier;
51}
52
53QString NetworkManager::VlanDevice::hwAddress() const
54{
55 Q_D(const VlanDevice);
56
57 return d->hwAddress;
58}
59
60NetworkManager::Device::Ptr NetworkManager::VlanDevice::parent() const
61{
62 if (NetworkManager::checkVersion(1, 0, 0)) {
63 Q_D(const VlanDevice);
64
66 } else {
67 return NetworkManager::Device::Ptr(nullptr);
68 }
69}
70
71uint NetworkManager::VlanDevice::vlanId() const
72{
73 Q_D(const VlanDevice);
74
75 return d->vlanId;
76}
77
78void NetworkManager::VlanDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
79{
80 Q_Q(VlanDevice);
81
82 if (property == QLatin1String("Carrier")) {
83 carrier = value.toBool();
84 Q_EMIT q->carrierChanged(carrier);
85 } else if (property == QLatin1String("HwAddress")) {
86 hwAddress = value.toString();
87 Q_EMIT q->hwAddressChanged(hwAddress);
88 } else if (property == QLatin1String("Parent")) {
89 parent = value.value<QDBusObjectPath>().path();
90 Q_EMIT q->parentChanged(parent);
91 } else if (property == QLatin1String("VlanId")) {
92 vlanId = value.toUInt();
93 Q_EMIT q->vlanIdChanged(vlanId);
94 } else {
95 DevicePrivate::propertyChanged(property, value);
96 }
97}
98
99#include "moc_vlandevice.cpp"
100#include "moc_vlandevice_p.cpp"
Type
Device type.
Definition device.h:191
@ Vlan
Vlan virtual device.
Definition device.h:203
A vlan device interface.
Definition vlandevice.h:21
Type type() const override
Retrieves the interface type.
QString path(const QString &relativePath)
NETWORKMANAGERQT_EXPORT Device::Ptr findNetworkInterface(const QString &uni)
Find a new NetworkInterface object given its UNI.
Definition manager.cpp:1026
NETWORKMANAGERQT_EXPORT bool checkVersion(const int x, const int y, const int z)
Checks if NetworkManager version is at least x.y.z.
Definition manager.cpp:239
bool toBool() const const
QString toString() const const
uint toUInt(bool *ok) const const
T value() const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.