1 | /* |
2 | SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org> |
3 | SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza <lamarque@kde.org> |
4 | SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.com> |
5 | SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
8 | */ |
9 | |
10 | #ifndef NETWORKMANAGERQT_DEVICE_H |
11 | #define NETWORKMANAGERQT_DEVICE_H |
12 | |
13 | #include <QObject> |
14 | #include <QSharedPointer> |
15 | |
16 | #include "activeconnection.h" |
17 | #include "devicestatistics.h" |
18 | #include "dhcp4config.h" |
19 | #include "dhcp6config.h" |
20 | #include "generictypes.h" |
21 | #include "ipconfig.h" |
22 | #include <networkmanagerqt/networkmanagerqt_export.h> |
23 | |
24 | namespace NetworkManager |
25 | { |
26 | class DevicePrivate; |
27 | class DeviceStateReason; |
28 | class DeviceStateReasonPrivate; |
29 | |
30 | /*! |
31 | * \class NetworkManager::Device |
32 | * \inheaderfile NetworkManagerQt/Device |
33 | * \inmodule NetworkManagerQt |
34 | * |
35 | * \brief This class represents a common device interface. |
36 | */ |
37 | class NETWORKMANAGERQT_EXPORT Device : public QObject |
38 | { |
39 | Q_OBJECT |
40 | |
41 | /*! |
42 | * \property NetworkManager::Device::uni |
43 | */ |
44 | Q_PROPERTY(QString uni READ uni) |
45 | |
46 | /*! |
47 | * \property NetworkManager::Device::interfaceName |
48 | */ |
49 | Q_PROPERTY(QString interfaceName READ interfaceName) |
50 | |
51 | /*! |
52 | * \property NetworkManager::Device::ipInterfaceName |
53 | */ |
54 | Q_PROPERTY(QString ipInterfaceName READ ipInterfaceName) |
55 | |
56 | /*! |
57 | * \property NetworkManager::Device::driver |
58 | */ |
59 | Q_PROPERTY(QString driver READ driver) |
60 | |
61 | /*! |
62 | * \property NetworkManager::Device::driverVersion |
63 | */ |
64 | Q_PROPERTY(QString driverVersion READ driverVersion) |
65 | |
66 | /*! |
67 | * \property NetworkManager::Device::firmwareVersion |
68 | */ |
69 | Q_PROPERTY(QString firmwareVersion READ firmwareVersion) |
70 | |
71 | /*! |
72 | * \property NetworkManager::Device::genericCapabilities |
73 | */ |
74 | Q_PROPERTY(QVariant genericCapabilities READ capabilitiesV) |
75 | |
76 | /*! |
77 | * \property NetworkManager::Device::ipV4Address |
78 | */ |
79 | Q_PROPERTY(QHostAddress ipV4Address READ ipV4Address) |
80 | |
81 | /*! |
82 | * \property NetworkManager::Device::managed |
83 | */ |
84 | Q_PROPERTY(bool managed READ managed WRITE setManaged) |
85 | |
86 | /*! |
87 | * \property NetworkManager::Device::mtu |
88 | */ |
89 | Q_PROPERTY(uint mtu READ mtu) |
90 | |
91 | /*! |
92 | * \property NetworkManager::Device::InterfaceFlags |
93 | */ |
94 | Q_PROPERTY(Interfaceflags InterfaceFlags READ interfaceFlags) |
95 | |
96 | /*! |
97 | * \property NetworkManager::Device::nmPluginMissing |
98 | */ |
99 | Q_PROPERTY(bool nmPluginMissing READ nmPluginMissing) |
100 | |
101 | /*! |
102 | * \property NetworkManager::Device::metered |
103 | */ |
104 | Q_PROPERTY(MeteredStatus metered READ metered) |
105 | |
106 | /*! |
107 | * \property NetworkManager::Device::udi |
108 | */ |
109 | Q_PROPERTY(QString udi READ udi) |
110 | |
111 | /*! |
112 | * \property NetworkManager::Device::firmwareMissing |
113 | */ |
114 | Q_PROPERTY(bool firmwareMissing READ firmwareMissing) |
115 | |
116 | /*! |
117 | * \property NetworkManager::Device::autoconnect |
118 | */ |
119 | Q_PROPERTY(bool autoconnect READ autoconnect WRITE setAutoconnect) |
120 | |
121 | /*! |
122 | * \property NetworkManager::Device::stateReason |
123 | */ |
124 | Q_PROPERTY(DeviceStateReason stateReason READ stateReason) |
125 | |
126 | /*! |
127 | * \property NetworkManager::Device::state |
128 | */ |
129 | Q_PROPERTY(State state READ state) |
130 | |
131 | /*! |
132 | * \property NetworkManager::Device::deviceStatistics |
133 | */ |
134 | Q_PROPERTY(NetworkManager::DeviceStatistics::Ptr deviceStatistics READ deviceStatistics) |
135 | |
136 | public: |
137 | /*! |
138 | * \typedef NetworkManager::Device::Ptr |
139 | */ |
140 | typedef QSharedPointer<Device> Ptr; |
141 | /*! |
142 | * \typedef NetworkManager::Device::List |
143 | */ |
144 | typedef QList<Ptr> List; |
145 | /*! |
146 | * |
147 | * Device connection states describe the possible states of a |
148 | * network connection from the user's point of view. For |
149 | * simplicity, states from several different layers are present - |
150 | * this is a high level view |
151 | * |
152 | * \value UnknownState |
153 | * The device is in an unknown state |
154 | * \value Unmanaged |
155 | * The device is recognized but not managed by NetworkManager |
156 | * \value Unavailable |
157 | * The device cannot be used (carrier off, rfkill, etc) |
158 | * \value Disconnected |
159 | * The device is not connected |
160 | * \value Preparing |
161 | * The device is preparing to connect |
162 | * \value ConfiguringHardware |
163 | * The device is being configured |
164 | * \value NeedAuth |
165 | * The device is awaiting secrets necessary to continue connection |
166 | * \value ConfiguringIp |
167 | * The IP settings of the device are being requested and configured |
168 | * \value CheckingIp |
169 | * The device's IP connectivity ability is being determined |
170 | * \value WaitingForSecondaries |
171 | * The device is waiting for secondary connections to be activated |
172 | * \value Activated |
173 | * The device is active |
174 | * \value Deactivating |
175 | * The device's network connection is being torn down |
176 | * \value Failed |
177 | * The device is in a failure state following an attempt to activate it |
178 | */ |
179 | enum State { |
180 | UnknownState = 0, |
181 | Unmanaged = 10, |
182 | Unavailable = 20, |
183 | Disconnected = 30, |
184 | Preparing = 40, |
185 | ConfiguringHardware = 50, |
186 | NeedAuth = 60, |
187 | ConfiguringIp = 70, |
188 | CheckingIp = 80, |
189 | WaitingForSecondaries = 90, |
190 | Activated = 100, |
191 | Deactivating = 110, |
192 | Failed = 120, |
193 | }; |
194 | Q_ENUM(State) |
195 | |
196 | /*! |
197 | * |
198 | * Enums describing the reason for a connection state change |
199 | * \note StateChangeReasons NewActivation, ParentChanged, ParentManagedChanged are available in runtime NM >= 1.0.4 |
200 | * |
201 | * \value UnknownReason |
202 | * \value NoReason |
203 | * \value NowManagedReason |
204 | * \value NowUnmanagedReason |
205 | * \value ConfigFailedReason |
206 | * \value ConfigUnavailableReason |
207 | * \value ConfigExpiredReason |
208 | * \value NoSecretsReason |
209 | * \value AuthSupplicantDisconnectReason |
210 | * \value AuthSupplicantConfigFailedReason |
211 | * \value AuthSupplicantFailedReason |
212 | * \value AuthSupplicantTimeoutReason |
213 | * \value PppStartFailedReason |
214 | * \value PppDisconnectReason |
215 | * \value PppFailedReason |
216 | * \value DhcpStartFailedReason |
217 | * \value DhcpErrorReason |
218 | * \value DhcpFailedReason |
219 | * \value SharedStartFailedReason |
220 | * \value SharedFailedReason |
221 | * \value AutoIpStartFailedReason |
222 | * \value AutoIpErrorReason |
223 | * \value AutoIpFailedReason |
224 | * \value ModemBusyReason |
225 | * \value ModemNoDialToneReason |
226 | * \value ModemNoCarrierReason |
227 | * \value ModemDialTimeoutReason |
228 | * \value ModemDialFailedReason |
229 | * \value ModemInitFailedReason |
230 | * \value GsmApnSelectFailedReason |
231 | * \value GsmNotSearchingReason |
232 | * \value GsmRegistrationDeniedReason |
233 | * \value GsmRegistrationTimeoutReason |
234 | * \value GsmRegistrationFailedReason |
235 | * \value GsmPinCheckFailedReason |
236 | * \value FirmwareMissingReason |
237 | * \value DeviceRemovedReason |
238 | * \value SleepingReason |
239 | * \value ConnectionRemovedReason |
240 | * \value UserRequestedReason |
241 | * \value CarrierReason |
242 | * \value ConnectionAssumedReason |
243 | * \value SupplicantAvailableReason |
244 | * \value ModemNotFoundReason |
245 | * \value BluetoothFailedReason |
246 | * \value GsmSimNotInserted |
247 | * \value GsmSimPinRequired |
248 | * \value GsmSimPukRequired |
249 | * \value GsmSimWrong |
250 | * \value InfiniBandMode |
251 | * \value DependencyFailed |
252 | * \value Br2684Failed |
253 | * \value ModemManagerUnavailable |
254 | * \value SsidNotFound |
255 | * \value SecondaryConnectionFailed |
256 | * \value DcbFcoeFailed |
257 | * \value TeamdControlFailed |
258 | * \value ModemFailed |
259 | * \value ModemAvailable |
260 | * \value SimPinIncorrect |
261 | * \value NewActivation |
262 | * \value ParentChanged |
263 | * \value ParentManagedChanged |
264 | * \value Reserved |
265 | */ |
266 | enum StateChangeReason { |
267 | UnknownReason = 0, |
268 | NoReason = 1, |
269 | NowManagedReason = 2, |
270 | NowUnmanagedReason = 3, |
271 | ConfigFailedReason = 4, |
272 | ConfigUnavailableReason = 5, |
273 | ConfigExpiredReason = 6, |
274 | NoSecretsReason = 7, |
275 | AuthSupplicantDisconnectReason = 8, |
276 | AuthSupplicantConfigFailedReason = 9, |
277 | AuthSupplicantFailedReason = 10, |
278 | AuthSupplicantTimeoutReason = 11, |
279 | PppStartFailedReason = 12, |
280 | PppDisconnectReason = 13, |
281 | PppFailedReason = 14, |
282 | DhcpStartFailedReason = 15, |
283 | DhcpErrorReason = 16, |
284 | DhcpFailedReason = 17, |
285 | SharedStartFailedReason = 18, |
286 | SharedFailedReason = 19, |
287 | AutoIpStartFailedReason = 20, |
288 | AutoIpErrorReason = 21, |
289 | AutoIpFailedReason = 22, |
290 | ModemBusyReason = 23, |
291 | ModemNoDialToneReason = 24, |
292 | ModemNoCarrierReason = 25, |
293 | ModemDialTimeoutReason = 26, |
294 | ModemDialFailedReason = 27, |
295 | ModemInitFailedReason = 28, |
296 | GsmApnSelectFailedReason = 29, |
297 | GsmNotSearchingReason = 30, |
298 | GsmRegistrationDeniedReason = 31, |
299 | GsmRegistrationTimeoutReason = 32, |
300 | GsmRegistrationFailedReason = 33, |
301 | GsmPinCheckFailedReason = 34, |
302 | FirmwareMissingReason = 35, |
303 | DeviceRemovedReason = 36, |
304 | SleepingReason = 37, |
305 | ConnectionRemovedReason = 38, |
306 | UserRequestedReason = 39, |
307 | CarrierReason = 40, |
308 | ConnectionAssumedReason = 41, |
309 | SupplicantAvailableReason = 42, |
310 | ModemNotFoundReason = 43, |
311 | BluetoothFailedReason = 44, |
312 | GsmSimNotInserted = 45, |
313 | GsmSimPinRequired = 46, |
314 | GsmSimPukRequired = 47, |
315 | GsmSimWrong = 48, |
316 | InfiniBandMode = 49, |
317 | DependencyFailed = 50, |
318 | Br2684Failed = 51, |
319 | ModemManagerUnavailable = 52, |
320 | SsidNotFound = 53, |
321 | SecondaryConnectionFailed = 54, |
322 | DcbFcoeFailed = 55, |
323 | TeamdControlFailed = 56, |
324 | ModemFailed = 57, |
325 | ModemAvailable = 58, |
326 | SimPinIncorrect = 59, |
327 | NewActivation = 60, |
328 | ParentChanged = 61, |
329 | ParentManagedChanged = 62, |
330 | Reserved = 65536, |
331 | }; |
332 | Q_ENUM(StateChangeReason) |
333 | |
334 | /*! |
335 | * |
336 | * \value UnknownStatus |
337 | * The device metered status is unknown. |
338 | * \value Yes |
339 | * The device is metered and the value was statically set. |
340 | * \value No |
341 | * The device is not metered and the value was statically set. |
342 | * \value GuessYes |
343 | * The device is metered and the value was guessed. |
344 | * \value GuessNo |
345 | * The device is not metered and the value was guessed. |
346 | */ |
347 | enum MeteredStatus { |
348 | UnknownStatus = 0, |
349 | Yes = 1, |
350 | No = 2, |
351 | GuessYes = 3, |
352 | GuessNo = 4, |
353 | }; |
354 | Q_ENUM(MeteredStatus) |
355 | |
356 | /*! |
357 | * |
358 | * Possible device capabilities |
359 | * |
360 | * \value IsManageable |
361 | * denotes that the device can be controlled by this API |
362 | * \value SupportsCarrierDetect |
363 | * the device informs us when it is plugged in to the medium |
364 | */ |
365 | enum Capability { |
366 | IsManageable = 0x1, |
367 | SupportsCarrierDetect = 0x2, |
368 | }; |
369 | Q_ENUM(Capability) |
370 | Q_DECLARE_FLAGS(Capabilities, Capability) |
371 | Q_FLAG(Capabilities) |
372 | |
373 | /*! |
374 | * |
375 | * Possible device interfaceflags |
376 | * |
377 | * \value None |
378 | * no flags set |
379 | * \value Up |
380 | * Corresponds to kernel IFF_UP |
381 | * \value LowerUp |
382 | * Corresponds to kernel IFF_LOWER_UP |
383 | * \value Carrier |
384 | * the interface has carrier |
385 | */ |
386 | enum Interfaceflag { |
387 | None = NM_DEVICE_INTERFACE_FLAG_NONE, |
388 | Up = NM_DEVICE_INTERFACE_FLAG_UP, |
389 | LowerUp = NM_DEVICE_INTERFACE_FLAG_LOWER_UP, |
390 | Carrier = NM_DEVICE_INTERFACE_FLAG_CARRIER |
391 | }; |
392 | Q_ENUM(Interfaceflag) |
393 | Q_DECLARE_FLAGS(Interfaceflags, Interfaceflag) |
394 | Q_FLAG(Interfaceflags) |
395 | |
396 | /*! |
397 | * |
398 | * Device type |
399 | * |
400 | * \value UnknownType |
401 | * Unknown device type |
402 | * \value Ethernet |
403 | * Ieee8023 wired ethernet |
404 | * \value Wifi |
405 | * the Ieee80211 family of wireless networks |
406 | * \value Unused1 |
407 | * Currently unused |
408 | * \value Unused2 |
409 | * Currently unused |
410 | * \value Bluetooth |
411 | * network bluetooth device (usually a cell phone) |
412 | * \value OlpcMesh |
413 | * OLPC Mesh networking device |
414 | * \value Wimax |
415 | * WiMax WWAN technology |
416 | * \value Modem |
417 | * POTS, GSM, CDMA or LTE modems |
418 | * \value InfiniBand |
419 | * Infiniband network device |
420 | * \value Bond |
421 | * Bond virtual device |
422 | * \value Vlan |
423 | * Vlan virtual device |
424 | * \value Adsl |
425 | * ADSL modem device |
426 | * \value Bridge |
427 | * Bridge virtual device |
428 | * \value Generic |
429 | * Generic device |
430 | * \value Team |
431 | * Team master device |
432 | * \value Gre |
433 | * Gre virtual device. Deprecated, use IpTunnel instead |
434 | * \value MacVlan |
435 | * MacVlan virtual device |
436 | * \value Tun |
437 | * Tun virtual device |
438 | * \value Veth |
439 | * Veth virtual device |
440 | * \value IpTunnel |
441 | * IP Tunneling Device |
442 | * \value VxLan |
443 | * Vxlan Device |
444 | * \value MacSec |
445 | * MacSec Device |
446 | * \value Dummy |
447 | * Dummy Device |
448 | * \value Ppp |
449 | * Ppp Device |
450 | * \value OvsInterface |
451 | * OvsInterface Device |
452 | * \value OvsPort |
453 | * OvsPort Device |
454 | * \value OvsBridge |
455 | * OvsBridge Device |
456 | * \value Wpan |
457 | * Wpan Device |
458 | * \value Lowpan |
459 | * Lowpan Device |
460 | * \value WireGuard |
461 | * WireGuard Device |
462 | * \value WifiP2P |
463 | * WifiP2P Device |
464 | * \value VRF |
465 | * VRF (Virtual Routing and Forwarding) Device |
466 | * \value Loopback |
467 | * Loopback Device |
468 | */ |
469 | enum Type { |
470 | UnknownType = NM_DEVICE_TYPE_UNKNOWN, |
471 | Ethernet = NM_DEVICE_TYPE_ETHERNET, |
472 | Wifi = NM_DEVICE_TYPE_WIFI, |
473 | Unused1 = NM_DEVICE_TYPE_UNUSED1, |
474 | Unused2 = NM_DEVICE_TYPE_UNUSED2, |
475 | Bluetooth = NM_DEVICE_TYPE_BT, |
476 | OlpcMesh = NM_DEVICE_TYPE_OLPC_MESH, |
477 | Wimax = NM_DEVICE_TYPE_WIMAX, |
478 | Modem = NM_DEVICE_TYPE_MODEM, |
479 | InfiniBand = NM_DEVICE_TYPE_INFINIBAND, |
480 | Bond = NM_DEVICE_TYPE_BOND, |
481 | Vlan = NM_DEVICE_TYPE_VLAN, |
482 | Adsl = NM_DEVICE_TYPE_ADSL, |
483 | Bridge = NM_DEVICE_TYPE_BRIDGE, |
484 | Generic = NM_DEVICE_TYPE_GENERIC, |
485 | Team = NM_DEVICE_TYPE_TEAM, |
486 | Gre, |
487 | MacVlan, |
488 | Tun, |
489 | Veth, |
490 | IpTunnel, |
491 | VxLan, |
492 | MacSec, |
493 | Dummy, |
494 | Ppp, |
495 | OvsInterface, |
496 | OvsPort, |
497 | OvsBridge, |
498 | Wpan, |
499 | Lowpan, |
500 | WireGuard, |
501 | WifiP2P, |
502 | VRF, |
503 | Loopback, |
504 | }; |
505 | Q_ENUM(Type) |
506 | Q_DECLARE_FLAGS(Types, Type) |
507 | Q_FLAG(Types) |
508 | |
509 | /*! |
510 | * Creates a new device object. |
511 | * |
512 | * \a path UNI of the device |
513 | */ |
514 | explicit Device(const QString &path, QObject *parent = nullptr); |
515 | /*! |
516 | * Destroys a device object. |
517 | */ |
518 | ~Device() override; |
519 | /*! |
520 | * Retrieves the interface type. This is a virtual function that will return the |
521 | * proper type of all sub-classes. |
522 | * |
523 | * Returns the NetworkManager::Device::Type that corresponds to this device. |
524 | */ |
525 | virtual Type type() const; |
526 | /*! |
527 | * Retrieves the Unique Network Identifier (UNI) of the device. |
528 | * This identifier is unique for each network and network interface in the system. |
529 | * |
530 | * Returns the Unique Network Identifier of the current device |
531 | */ |
532 | QString uni() const; |
533 | /*! |
534 | * The current active connection for this device |
535 | * |
536 | * Returns A valid ActiveConnection object or NULL if no active connection was found |
537 | */ |
538 | NetworkManager::ActiveConnection::Ptr activeConnection() const; |
539 | /*! |
540 | * Returns available connections for this device |
541 | * |
542 | * Returns List of availables connection |
543 | */ |
544 | Connection::List availableConnections(); |
545 | /*! |
546 | * The system name for the network device |
547 | */ |
548 | QString interfaceName() const; |
549 | /*! |
550 | * The name of the device's data interface when available. This property |
551 | * may not refer to the actual data interface until the device has |
552 | * successfully established a data connection, indicated by the device's |
553 | * state() becoming ACTIVATED. |
554 | */ |
555 | QString ipInterfaceName() const; |
556 | /*! |
557 | * Handle for the system driver controlling this network interface |
558 | */ |
559 | QString driver() const; |
560 | /*! |
561 | * The driver version. |
562 | */ |
563 | QString driverVersion() const; |
564 | /*! |
565 | * The firmware version. |
566 | */ |
567 | QString firmwareVersion() const; |
568 | /*! |
569 | * Reapplies connection settings on the interface. |
570 | */ |
571 | QDBusPendingReply<> reapplyConnection(const NMVariantMapMap &connection, qulonglong version_id, uint flags); |
572 | /*! |
573 | * Disconnects a device and prevents the device from automatically |
574 | * activating further connections without user intervention. |
575 | */ |
576 | QDBusPendingReply<> disconnectInterface(); |
577 | /*! |
578 | * Deletes a software device from NetworkManager and removes the interface from the system. |
579 | * The method returns an error when called for a hardware device. |
580 | * |
581 | * \since 5.8.0 |
582 | * |
583 | */ |
584 | QDBusPendingReply<> deleteInterface(); |
585 | /*! |
586 | * returns the current IPv4 address without the prefix |
587 | * \sa ipV4Config() |
588 | * \sa ipV6Config() |
589 | * \deprecated |
590 | */ |
591 | QHostAddress ipV4Address() const; |
592 | /*! |
593 | * Get the current IPv4 configuration of this device. |
594 | * Only valid when device is Activated. |
595 | */ |
596 | IpConfig ipV4Config() const; |
597 | /*! |
598 | * Get the current IPv6 configuration of this device. |
599 | * Only valid when device is Activated. |
600 | */ |
601 | IpConfig ipV6Config() const; |
602 | |
603 | /*! |
604 | * Get the DHCP options returned by the DHCP server |
605 | * or a null pointer if the device is not Activated or does not |
606 | * use DHCP configuration. |
607 | */ |
608 | Dhcp4Config::Ptr dhcp4Config() const; |
609 | |
610 | /*! |
611 | * Get the DHCP options returned by the DHCP server |
612 | * or a null pointer if the device is not Activated or does not |
613 | * use DHCP configuration. |
614 | */ |
615 | Dhcp6Config::Ptr dhcp6Config() const; |
616 | |
617 | /*! |
618 | * Retrieves the activation status of this network interface. |
619 | * |
620 | * Returns true if this network interface is active, false otherwise |
621 | */ |
622 | bool isActive() const; |
623 | |
624 | /*! |
625 | * Retrieves the device is valid. |
626 | * |
627 | * Returns true if this device interface is valid, false otherwise |
628 | */ |
629 | bool isValid() const; |
630 | |
631 | /*! |
632 | * Retrieves the current state of the device. |
633 | * This is a high level view of the device. It is user oriented, so |
634 | * actually it provides state coming from different layers. |
635 | * |
636 | * Returns the current connection state |
637 | * \sa Device::State |
638 | */ |
639 | State state() const; |
640 | /*! |
641 | * Retrieves the maximum speed as reported by the device. |
642 | * Note that this is only a design related piece of information, and that |
643 | * the device might not reach this maximum. |
644 | * |
645 | * Returns the device's maximum speed |
646 | */ |
647 | int designSpeed() const; |
648 | /*! |
649 | * Retrieves the capabilities supported by this device. |
650 | * |
651 | * Returns the capabilities of the device |
652 | */ |
653 | Capabilities capabilities() const; |
654 | /*! |
655 | * |
656 | */ |
657 | QVariant capabilitiesV() const; |
658 | /*! |
659 | * Is the device currently being managed by NetworkManager? |
660 | */ |
661 | bool managed() const; |
662 | /*! |
663 | * Sets the managed flag for the device |
664 | * |
665 | * \since 6.18.0 |
666 | */ |
667 | void setManaged(bool managed); |
668 | /*! |
669 | * The up or down flag for the device |
670 | */ |
671 | Interfaceflags interfaceFlags() const; |
672 | /*! |
673 | * Is the firmware needed by the device missing? |
674 | */ |
675 | bool firmwareMissing() const; |
676 | /*! |
677 | * If the device is allowed to autoconnect. |
678 | */ |
679 | bool autoconnect() const; |
680 | /*! |
681 | * The current state and reason for changing to that state. |
682 | */ |
683 | DeviceStateReason stateReason() const; |
684 | /*! |
685 | * Retrieves the Unique Device Identifier (UDI) of the device. |
686 | * This identifier is unique for each device in the system. |
687 | */ |
688 | QString udi() const; |
689 | |
690 | /*! |
691 | * Returns If non-empty, an (opaque) indicator of the physical network |
692 | * port associated with the device. This can be used to recognize |
693 | * when two seemingly-separate hardware devices are actually just |
694 | * different virtual interfaces to the same physical port. |
695 | * |
696 | * \since 0.9.9.0 |
697 | */ |
698 | QString physicalPortId() const; |
699 | /*! |
700 | * The device MTU (maximum transmission unit) |
701 | * \since 0.9.9.0 |
702 | */ |
703 | uint mtu() const; |
704 | |
705 | /*! |
706 | * Returns If TRUE, indicates the NetworkManager plugin for the device is likely |
707 | * missing or misconfigured. |
708 | * \since 5.14.0 |
709 | */ |
710 | bool nmPluginMissing() const; |
711 | |
712 | /*! |
713 | * Returns Whether the amount of traffic flowing through the device is |
714 | * subject to limitations, for example set by service providers. |
715 | * \since 5.14.0 |
716 | */ |
717 | MeteredStatus metered() const; |
718 | |
719 | /*! |
720 | * If true, indicates the device is allowed to autoconnect. |
721 | * If false, manual intervention is required before the device |
722 | * will automatically connect to a known network, such as activating |
723 | * a connection using the device, or setting this property to \a true. |
724 | */ |
725 | void setAutoconnect(bool autoconnect); |
726 | |
727 | /*! |
728 | * Returns Device Statistics interface |
729 | */ |
730 | DeviceStatistics::Ptr deviceStatistics() const; |
731 | |
732 | /*! |
733 | * Retrieves a specialized interface to interact with the device corresponding |
734 | * to a given device interface. |
735 | * |
736 | * Returns a pointer to the device interface if it exists, \a 0 otherwise |
737 | */ |
738 | template<class DevIface> |
739 | DevIface *as() |
740 | { |
741 | return qobject_cast<DevIface *>(this); |
742 | } |
743 | |
744 | /*! |
745 | * Retrieves a specialized interface to interact with the device corresponding |
746 | * to a given device interface. |
747 | * |
748 | * Returns a pointer to the device interface if it exists, 0 otherwise |
749 | */ |
750 | template<class DevIface> |
751 | const DevIface *as() const |
752 | { |
753 | return qobject_cast<const DevIface *>(this); |
754 | } |
755 | |
756 | Q_SIGNALS: |
757 | /*! |
758 | * This signal is emitted when the device's link status changed. |
759 | * |
760 | * \a newstate the new state of the connection |
761 | * |
762 | * \a oldstate the previous state of the connection |
763 | * |
764 | * \a reason the reason for the state change, if any. ReasonNone where the backend |
765 | * provides no reason. |
766 | * |
767 | * \sa Device::State |
768 | * \sa Device::StateChangeReason |
769 | */ |
770 | void stateChanged(NetworkManager::Device::State newstate, NetworkManager::Device::State oldstate, NetworkManager::Device::StateChangeReason reason); |
771 | |
772 | /*! |
773 | * Emitted when the autoconnect of this network has changed. |
774 | */ |
775 | void activeConnectionChanged(); |
776 | |
777 | /*! |
778 | * Emitted when the autoconnect of this network has changed. |
779 | */ |
780 | void autoconnectChanged(); |
781 | |
782 | /*! |
783 | * Emitted when the list of avaiable connections of this network has changed. |
784 | */ |
785 | void availableConnectionChanged(); |
786 | |
787 | /*! |
788 | * Emitted when a new connection is available |
789 | */ |
790 | void availableConnectionAppeared(const QString &connection); |
791 | |
792 | /*! |
793 | * Emitted when the connection is no longer available |
794 | */ |
795 | void availableConnectionDisappeared(const QString &connection); |
796 | |
797 | /*! |
798 | * Emitted when the capabilities of this network has changed. |
799 | */ |
800 | void capabilitiesChanged(); |
801 | |
802 | /*! |
803 | * Emitted when the DHCP configuration for IPv4 of this network has changed. |
804 | */ |
805 | void dhcp4ConfigChanged(); |
806 | |
807 | /*! |
808 | * Emitted when the DHCP configuration for IPv6 of this network has changed. |
809 | */ |
810 | void dhcp6ConfigChanged(); |
811 | |
812 | /*! |
813 | * Emitted when the driver of this network has changed. |
814 | */ |
815 | void driverChanged(); |
816 | |
817 | /*! |
818 | * Emitted when the driver version of this network has changed. |
819 | */ |
820 | void driverVersionChanged(); |
821 | |
822 | /*! |
823 | * Emitted when the firmware missing state of this network has changed. |
824 | */ |
825 | void firmwareMissingChanged(); |
826 | |
827 | /*! |
828 | * Emitted when the firmware version of this network has changed. |
829 | */ |
830 | void firmwareVersionChanged(); |
831 | |
832 | /*! |
833 | * Emitted when the interface name of this network has changed. |
834 | */ |
835 | void interfaceNameChanged(); |
836 | |
837 | /*! |
838 | * Emitted when the IPv4 address of this network has changed. |
839 | */ |
840 | void ipV4AddressChanged(); |
841 | |
842 | /*! |
843 | * Emitted when the IPv4 configuration of this network has changed. |
844 | */ |
845 | void ipV4ConfigChanged(); |
846 | |
847 | /*! |
848 | * Emitted when the IPv6 configuration of this network has changed. |
849 | */ |
850 | void ipV6ConfigChanged(); |
851 | |
852 | /*! |
853 | * Emitted when the ip interface name of this network has changed. |
854 | */ |
855 | void ipInterfaceChanged(); |
856 | |
857 | /*! |
858 | * Emitted when the managed state of this network has changed. |
859 | */ |
860 | void managedChanged(); |
861 | |
862 | /*! |
863 | * Emitted when the up or down state of the device |
864 | * \since 1.22 |
865 | * \note will always return NM_DEVICE_INTERFACE_FLAG_NONE when runtime NM < 1.22 |
866 | */ |
867 | void interfaceFlagsChanged(); |
868 | |
869 | /*! |
870 | * Emitted when the physical port ID changes. |
871 | * \sa physicalPortId() |
872 | * \since 0.9.9.0 |
873 | */ |
874 | void physicalPortIdChanged(); |
875 | |
876 | /*! |
877 | * Emitted when the maximum transmission unit has changed |
878 | * \since 0.9.9.0 |
879 | */ |
880 | void mtuChanged(); |
881 | |
882 | /*! |
883 | * Emitted when NmPluginMissing property has changed |
884 | * \since 5.14.0 |
885 | * \sa nmPluginMissing |
886 | */ |
887 | void nmPluginMissingChanged(bool nmPluginMissing); |
888 | |
889 | /*! |
890 | * Emitted when metered property has changed |
891 | * \since 5.14.0 |
892 | * \sa metered |
893 | */ |
894 | void meteredChanged(MeteredStatus metered); |
895 | |
896 | /*! |
897 | * Emitted when the connection state of this network has changed. |
898 | */ |
899 | void connectionStateChanged(); |
900 | |
901 | /*! |
902 | * Emitted when the state reason of this network has changed. |
903 | */ |
904 | void stateReasonChanged(); |
905 | |
906 | /*! |
907 | * Emitted when the Unique Device Identifier of this device has changed. |
908 | */ |
909 | void udiChanged(); |
910 | |
911 | protected: |
912 | NETWORKMANAGERQT_NO_EXPORT Device(DevicePrivate &dd, QObject *parent); |
913 | |
914 | DevicePrivate *const d_ptr; |
915 | |
916 | private: |
917 | Q_DECLARE_PRIVATE(Device) |
918 | }; |
919 | |
920 | Q_DECLARE_OPERATORS_FOR_FLAGS(Device::Capabilities) |
921 | Q_DECLARE_OPERATORS_FOR_FLAGS(Device::Types) |
922 | Q_DECLARE_OPERATORS_FOR_FLAGS(Device::Interfaceflags) |
923 | |
924 | /*! |
925 | * \class NetworkManager::DeviceStateReason |
926 | * \inheaderfile NetworkManagerQt/Device |
927 | * \inmodule NetworkManagerQt |
928 | */ |
929 | class NETWORKMANAGERQT_EXPORT DeviceStateReason |
930 | { |
931 | public: |
932 | /*! |
933 | */ |
934 | DeviceStateReason(Device::State state, Device::StateChangeReason reason); |
935 | /*! |
936 | */ |
937 | DeviceStateReason(const DeviceStateReason &); |
938 | /*! |
939 | */ |
940 | ~DeviceStateReason(); |
941 | /*! |
942 | */ |
943 | Device::State state() const; |
944 | /*! |
945 | */ |
946 | Device::StateChangeReason reason() const; |
947 | /*! |
948 | */ |
949 | DeviceStateReason &operator=(const DeviceStateReason &); |
950 | |
951 | private: |
952 | Q_DECLARE_PRIVATE(DeviceStateReason) |
953 | |
954 | DeviceStateReasonPrivate *const d_ptr; |
955 | }; |
956 | |
957 | } |
958 | |
959 | #endif |
960 | |