NetworkManagerQt

fakenetwork/device.cpp
1/*
2 SPDX-FileCopyrightText: 2014 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.h"
8#include "activeconnection.h"
9
10#include <QDBusConnection>
11#include <QDBusMetaType>
12
13Device::Device(QObject *parent)
14 : QObject(parent)
15 , m_activeConnection(QDBusObjectPath("/"))
16 , m_autoconnect(true)
17 , m_capabilities(0)
18 , m_deviceType(0)
19 , m_dhcp4Config(QDBusObjectPath("/"))
20 , m_dhcp6Config(QDBusObjectPath("/"))
21 , m_firmwareMissing(false)
22 , m_interfaceFlags(NM_DEVICE_INTERFACE_FLAG_NONE)
23 , m_ip4Address(0)
24 , m_ip4Config(QDBusObjectPath("/"))
25 , m_ip6Config(QDBusObjectPath("/"))
26 , m_managed(true)
27 , m_mtu(0)
28 , m_state(30)
29{
30 qDBusRegisterMetaType<DeviceDBusStateReason>();
31}
32
33Device::~Device()
34{
35}
36
37QDBusObjectPath Device::activeConnection() const
38{
39 return m_activeConnection;
40}
41
42bool Device::autoconnect() const
43{
44 return m_autoconnect;
45}
46
47void Device::setAutoconnect(bool autoconnect)
48{
49 m_autoconnect = autoconnect;
50}
51
52QList<QDBusObjectPath> Device::availableConnections() const
53{
54 return m_availableConnections;
55}
56
57uint Device::capabilities() const
58{
59 return m_capabilities;
60}
61
62QString Device::deviceInterface() const
63{
64 if (m_deviceType == NetworkManager::Device::Ethernet) {
65 return QLatin1String("org.kde.fakenetwork.Device.Wired");
66 } else if (m_deviceType == NetworkManager::Device::Wifi) {
67 return QLatin1String("org.kde.fakenetwork.Device.Wireless");
68 }
69
70 return QLatin1String("org.kde.fakenetwork.Device.Wired");
71}
72
73QString Device::devicePath() const
74{
75 return m_devicePath;
76}
77
78void Device::setDevicePath(const QString &devicePath)
79{
80 m_devicePath = devicePath;
81}
82
83uint Device::deviceType() const
84{
85 return m_deviceType;
86}
87
88QDBusObjectPath Device::dhcp4Config() const
89{
90 return m_dhcp4Config;
91}
92
93QDBusObjectPath Device::dhcp6Config() const
94{
95 return m_dhcp6Config;
96}
97
98QString Device::driver() const
99{
100 return m_driver;
101}
102
103QString Device::driverVersion() const
104{
105 return m_driverVersion;
106}
107
108bool Device::firmwareMissing() const
109{
110 return m_firmwareMissing;
111}
112
113QString Device::firmwareVersion() const
114{
115 return m_firmwareVersion;
116}
117
118QString Device::interface() const
119{
120 return m_interface;
121}
122
123int Device::ip4Address() const
124{
125 return m_ip4Address;
126}
127
128QDBusObjectPath Device::ip4Config() const
129{
130 return m_ip4Config;
131}
132
133QDBusObjectPath Device::ip6Config() const
134{
135 return m_ip6Config;
136}
137
138QString Device::ipInterface() const
139{
140 return m_ipInterface;
141}
142
143uint Device::interfaceFlags() const
144{
145 return m_interfaceFlags;
146}
147
148bool Device::managed() const
149{
150 return m_managed;
151}
152
153uint Device::mtu() const
154{
155 return m_mtu;
156}
157
158uint Device::state() const
159{
160 return m_state;
161}
162
163DeviceDBusStateReason Device::stateReason() const
164{
165 return m_stateReason;
166}
167
168QString Device::udi() const
169{
170 return m_udi;
171}
172
173void Device::addAvailableConnection(const QDBusObjectPath &availableConnection)
174{
175 m_availableConnections << availableConnection;
176}
177
178void Device::removeAvailableConnection(const QDBusObjectPath &availableConnection)
179{
180 m_availableConnections.removeAll(availableConnection);
181}
182
183void Device::setActiveConnection(const QString &activeConnection)
184{
185 m_activeConnection = QDBusObjectPath(activeConnection);
186}
187
188void Device::setCapabilities(uint capabilities)
189{
190 m_capabilities = capabilities;
191}
192
193void Device::setDeviceType(uint deviceType)
194{
195 m_deviceType = deviceType;
196}
197
198void Device::setDhcp4Config(const QString &config)
199{
200 m_dhcp4Config = QDBusObjectPath(config);
201}
202
203void Device::setDhcp6Config(const QString &config)
204{
205 m_dhcp6Config = QDBusObjectPath(config);
206}
207
208void Device::setDriver(const QString &driver)
209{
210 m_driver = driver;
211}
212
213void Device::setDriverVersion(const QString &driverVersion)
214{
215 m_driverVersion = driverVersion;
216}
217
218void Device::setFirmwareMissing(bool firmwareMissing)
219{
220 m_firmwareMissing = firmwareMissing;
221}
222
223void Device::setFirmwareVersion(const QString &firmwareVersion)
224{
225 m_firmwareVersion = firmwareVersion;
226}
227
228void Device::setInterface(const QString &interface)
229{
230 m_interface = interface;
231}
232
233void Device::setInterfaceFlags(uint interfaceFlags)
234{
235 m_interfaceFlags = interfaceFlags;
236}
237
238void Device::setIp4Config(const QString &config)
239{
240 m_ip4Config = QDBusObjectPath(config);
241}
242
243void Device::setIp6Config(const QString &config)
244{
245 m_ip6Config = QDBusObjectPath(config);
246}
247
248void Device::setIpv4Address(int address)
249{
250 m_ip4Address = address;
251}
252
253void Device::setIpInterface(const QString &interface)
254{
255 m_ipInterface = interface;
256}
257
258void Device::setManaged(bool managed)
259{
260 m_managed = managed;
261}
262
263void Device::setMtu(uint mtu)
264{
265 m_mtu = mtu;
266}
267
268void Device::setState(uint state)
269{
270 uint previousState = m_state;
271 m_state = state;
272 m_stateReason.state = state;
273
274 QDBusMessage message = QDBusMessage::createSignal(m_devicePath, QLatin1String("org.kde.fakenetwork.Device"), QLatin1String("StateChanged"));
275 message << previousState << state << m_stateReason.reason;
277}
278
279void Device::setStateReason(const DeviceDBusStateReason &reason)
280{
281 m_stateReason = reason;
282}
283
284void Device::setUdi(const QString &udi)
285{
286 m_udi = udi;
287}
288
289void Device::Disconnect()
290{
291 // TODO
292}
293
294#include "moc_device.cpp"
@ Wifi
the Ieee80211 family of wireless networks
Definition device.h:194
@ Ethernet
Ieee8023 wired ethernet.
Definition device.h:193
Capabilities capabilities()
PostalAddress address(const QVariant &location)
bool send(const QDBusMessage &message) const const
QDBusConnection sessionBus()
QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
qsizetype removeAll(const AT &t)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.