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 | |
11 | NetworkManager::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 | |
22 | NetworkManager::VlanDevice::~VlanDevice() |
23 | { |
24 | } |
25 | |
26 | NetworkManager::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(interfaceName: d->iface.staticInterfaceName(), path); |
32 | if (!initialProperties.isEmpty()) { |
33 | d->propertiesChanged(properties: initialProperties); |
34 | } |
35 | } |
36 | |
37 | NetworkManager::VlanDevicePrivate::~VlanDevicePrivate() |
38 | { |
39 | } |
40 | |
41 | NetworkManager::Device::Type NetworkManager::VlanDevice::type() const |
42 | { |
43 | return NetworkManager::Device::Vlan; |
44 | } |
45 | |
46 | bool NetworkManager::VlanDevice::carrier() const |
47 | { |
48 | Q_D(const VlanDevice); |
49 | |
50 | return d->carrier; |
51 | } |
52 | |
53 | QString NetworkManager::VlanDevice::hwAddress() const |
54 | { |
55 | Q_D(const VlanDevice); |
56 | |
57 | return d->hwAddress; |
58 | } |
59 | |
60 | NetworkManager::Device::Ptr NetworkManager::VlanDevice::parent() const |
61 | { |
62 | if (NetworkManager::checkVersion(x: 1, y: 0, z: 0)) { |
63 | Q_D(const VlanDevice); |
64 | |
65 | return NetworkManager::findNetworkInterface(uni: d->parent); |
66 | } else { |
67 | return NetworkManager::Device::Ptr(nullptr); |
68 | } |
69 | } |
70 | |
71 | uint NetworkManager::VlanDevice::vlanId() const |
72 | { |
73 | Q_D(const VlanDevice); |
74 | |
75 | return d->vlanId; |
76 | } |
77 | |
78 | void 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(plugged: carrier); |
85 | } else if (property == QLatin1String("HwAddress" )) { |
86 | hwAddress = value.toString(); |
87 | Q_EMIT q->hwAddressChanged(address: hwAddress); |
88 | } else if (property == QLatin1String("Parent" )) { |
89 | parent = value.value<QDBusObjectPath>().path(); |
90 | Q_EMIT q->parentChanged(path: parent); |
91 | } else if (property == QLatin1String("VlanId" )) { |
92 | vlanId = value.toUInt(); |
93 | Q_EMIT q->vlanIdChanged(id: vlanId); |
94 | } else { |
95 | DevicePrivate::propertyChanged(property, value); |
96 | } |
97 | } |
98 | |
99 | #include "moc_vlandevice.cpp" |
100 | #include "moc_vlandevice_p.cpp" |
101 | |