Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
NetworkDevice.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorServiceNetwork/phosphorservicenetwork_export.h>
7
8#include <QObject>
9#include <QString>
10
11#include <memory>
12
13class QDBusConnection;
14
15namespace PhosphorServiceNetwork {
16
22class PHOSPHORSERVICENETWORK_EXPORT NetworkDevice : public QObject
23{
24 Q_OBJECT
25 Q_DISABLE_COPY_MOVE(NetworkDevice)
26
27 Q_PROPERTY(QString interfaceName READ interfaceName NOTIFY interfaceNameChanged)
28 Q_PROPERTY(QString dbusPath READ dbusPath CONSTANT)
29 Q_PROPERTY(uint stateReason READ stateReason NOTIFY detailsChanged)
30 Q_PROPERTY(uint bitrate READ bitrate NOTIFY detailsChanged)
31 Q_PROPERTY(QString ipAddress READ ipAddress NOTIFY detailsChanged)
32 Q_PROPERTY(qint64 lastScan READ lastScan NOTIFY detailsChanged)
34 Q_PROPERTY(DeviceState state READ state NOTIFY stateChanged)
35 Q_PROPERTY(bool managed READ managed NOTIFY managedChanged)
48
49public:
50 // Mirrors org.freedesktop.NetworkManager.Device `DeviceType` (NM 1.0+,
51 // see NetworkManager's NMDeviceType). Values are wire constants; the
52 // enum is sparse (3 and 4 are unused upstream, and NM's OVS/WPAN/6LoWPAN
53 // types at 24-28 are intentionally not modelled, so the table ends at
54 // Wireguard=29). Unrecognised raw values map to Unknown rather than
55 // casting to an enumerator we don't declare.
59 Wifi = 2,
62 Wimax = 7,
63 Modem = 8,
65 Bond = 10,
66 Vlan = 11,
67 Adsl = 12,
68 Bridge = 13,
69 Generic = 14,
70 Team = 15,
71 Tun = 16,
73 Macvlan = 18,
74 Vxlan = 19,
75 Veth = 20,
76 Macsec = 21,
77 Dummy = 22,
78 Ppp = 23,
80 };
81 Q_ENUM(DeviceType)
82
83 // Mirrors org.freedesktop.NetworkManager.Device `State` (NMDeviceState).
84 // Values are sparse (multiples of ten); unrecognised raw values map to
85 // UnknownState.
101 Q_ENUM(DeviceState)
102
103 explicit NetworkDevice(const QString& dbusPath, QObject* parent = nullptr);
104 NetworkDevice(QDBusConnection connection, const QString& dbusPath, QObject* parent = nullptr);
105 ~NetworkDevice() override;
106
107 [[nodiscard]] QString dbusPath() const;
108 [[nodiscard]] QString interfaceName() const;
109 [[nodiscard]] DeviceType deviceType() const;
110 [[nodiscard]] DeviceState state() const;
111 [[nodiscard]] bool managed() const;
112 [[nodiscard]] QString activeAccessPointPath() const;
113 [[nodiscard]] uint stateReason() const;
114 [[nodiscard]] uint bitrate() const;
115 [[nodiscard]] QString ipAddress() const;
116 [[nodiscard]] qint64 lastScan() const;
117
118Q_SIGNALS:
125
126private Q_SLOTS:
127 void _q_onIpChanged(const QString& iface, const QVariantMap& changed, const QStringList& invalidated);
128 void _q_onPropertiesChanged(const QString& iface, const QVariantMap& changed, const QStringList& invalidated);
129
130private:
131 class Private;
132 std::unique_ptr<Private> d;
133};
134
135} // namespace PhosphorServiceNetwork
DeviceState
Definition NetworkDevice.h:86
@ IpCheck
Definition NetworkDevice.h:95
@ IpConfig
Definition NetworkDevice.h:94
@ UnknownState
Definition NetworkDevice.h:87
@ Config
Definition NetworkDevice.h:92
@ Prepare
Definition NetworkDevice.h:91
@ Failed
Definition NetworkDevice.h:99
@ Disconnected
Definition NetworkDevice.h:90
@ Activated
Definition NetworkDevice.h:97
@ NeedAuth
Definition NetworkDevice.h:93
@ Secondaries
Definition NetworkDevice.h:96
@ Unmanaged
Definition NetworkDevice.h:88
@ Deactivating
Definition NetworkDevice.h:98
@ Unavailable
Definition NetworkDevice.h:89
DeviceType
D-Bus path of the access point this device is currently associated with, or empty when it is associat...
Definition NetworkDevice.h:56
@ Adsl
Definition NetworkDevice.h:67
@ Macvlan
Definition NetworkDevice.h:73
@ Bridge
Definition NetworkDevice.h:68
@ Veth
Definition NetworkDevice.h:75
@ Macsec
Definition NetworkDevice.h:76
@ Modem
Definition NetworkDevice.h:63
@ Dummy
Definition NetworkDevice.h:77
@ Infiniband
Definition NetworkDevice.h:64
@ IpTunnel
Definition NetworkDevice.h:72
@ Unknown
Definition NetworkDevice.h:57
@ Team
Definition NetworkDevice.h:70
@ Ethernet
Definition NetworkDevice.h:58
@ Tun
Definition NetworkDevice.h:71
@ Ppp
Definition NetworkDevice.h:78
@ Bluetooth
Definition NetworkDevice.h:60
@ Generic
Definition NetworkDevice.h:69
@ Wifi
Definition NetworkDevice.h:59
@ OlpcMesh
Definition NetworkDevice.h:61
@ Vlan
Definition NetworkDevice.h:66
@ Wireguard
Definition NetworkDevice.h:79
@ Vxlan
Definition NetworkDevice.h:74
@ Bond
Definition NetworkDevice.h:65
@ Wimax
Definition NetworkDevice.h:62
NetworkDevice(const QString &dbusPath, QObject *parent=nullptr)
Definition AccessPoint.h:13