Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
NetworkHost.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
9
10#include <QDBusObjectPath>
11#include <QList>
12#include <QObject>
13#include <QString>
14
15#include <memory>
16
17class QDBusConnection;
18
19namespace PhosphorServiceNetwork {
20
21class AccessPoint;
23
29class PHOSPHORSERVICENETWORK_EXPORT NetworkHost : public QObject
30{
31 Q_OBJECT
32 Q_DISABLE_COPY_MOVE(NetworkHost)
37 Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
38 Q_PROPERTY(bool available READ available NOTIFY availableChanged)
40 Q_PROPERTY(bool wwanSupported READ wwanSupported NOTIFY wwanChanged)
41 Q_PROPERTY(bool wwanEnabled READ wwanEnabled WRITE setWwanEnabled NOTIFY wwanChanged)
42 Q_PROPERTY(bool wwanHardwareEnabled READ wwanHardwareEnabled NOTIFY wwanChanged)
44
45public:
46 // Mirrors org.freedesktop.NetworkManager `Connectivity` (NMConnectivityState).
47 // Contiguous 0..4; unrecognised raw values map to UnknownConnectivity.
55 Q_ENUM(Connectivity)
56
57 explicit NetworkHost(QObject* parent = nullptr);
58 explicit NetworkHost(QDBusConnection connection, QObject* parent = nullptr);
59 ~NetworkHost() override;
60
61 [[nodiscard]] bool networkingEnabled() const;
62 [[nodiscard]] bool available() const;
63 [[nodiscard]] bool wirelessHardwareEnabled() const;
64 [[nodiscard]] bool wwanSupported() const;
65 [[nodiscard]] bool wwanEnabled() const;
66 [[nodiscard]] bool wwanHardwareEnabled() const;
67 void setWwanEnabled(bool enabled);
68 [[nodiscard]] QString connectivityCheckUri() const;
69 Q_INVOKABLE void refresh();
71 [[nodiscard]] bool wirelessEnabled() const;
76 void setWirelessEnabled(bool enabled);
77 [[nodiscard]] Connectivity connectivity() const;
78 [[nodiscard]] QString primaryConnectionType() const;
79 [[nodiscard]] int deviceCount() const;
80 [[nodiscard]] QList<NetworkDevice*> devices() const;
81 [[nodiscard]] Q_INVOKABLE PhosphorServiceNetwork::NetworkDevice* deviceAt(int index) const;
82
89 Q_INVOKABLE void scanWifi();
90
97
106 const QString& passphrase = {}, bool autoConnect = true,
108
109Q_SIGNALS:
121 // Completion of the D-Bus request, not successful association. Device
122 // state remains the authority for connection success and authentication.
123 void operationFinished(const QString& operation, const QString& path, const QString& errorName);
124
125private Q_SLOTS:
126 void _q_onPropertiesChanged(const QString& iface, const QVariantMap& changed, const QStringList& invalidated);
127 void _q_onDeviceAdded(const QDBusObjectPath& path);
128 void _q_onDeviceRemoved(const QDBusObjectPath& path);
129
130private:
131 class Private;
132 std::unique_ptr<Private> d;
133};
134
135} // namespace PhosphorServiceNetwork
One org.freedesktop.NetworkManager.AccessPoint — a Wi-Fi network as seen by a wireless device's last ...
Definition AccessPoint.h:22
One saved profile — an org.freedesktop.NetworkManager.Settings.Connection.
Definition NetworkConnection.h:20
One org.freedesktop.NetworkManager.Device object.
Definition NetworkDevice.h:23
void operationFinished(const QString &operation, const QString &path, const QString &errorName)
void setWirelessEnabled(bool enabled)
Toggle the global Wi-Fi radio (NetworkManager WirelessEnabled).
NetworkHost(QObject *parent=nullptr)
void scanWifi()
Trigger a Wi-Fi scan on every managed Wi-Fi device (NM Device.Wireless.RequestScan).
Connectivity connectivity() const
void deviceAdded(PhosphorServiceNetwork::NetworkDevice *device)
QList< NetworkDevice * > devices() const
Connectivity
Definition NetworkHost.h:48
@ NoConnectivity
Definition NetworkHost.h:50
@ Portal
Definition NetworkHost.h:51
@ UnknownConnectivity
Definition NetworkHost.h:49
@ Full
Definition NetworkHost.h:53
@ Limited
Definition NetworkHost.h:52
void activateConnection(PhosphorServiceNetwork::NetworkConnection *connection, PhosphorServiceNetwork::NetworkDevice *device)
Activate an existing saved connection on a device (NM ActivateConnection).
void disconnectDevice(PhosphorServiceNetwork::NetworkDevice *device)
void deviceRemoved(PhosphorServiceNetwork::NetworkDevice *device)
PhosphorServiceNetwork::NetworkDevice * deviceAt(int index) const
void connectToAccessPoint(PhosphorServiceNetwork::NetworkDevice *device, PhosphorServiceNetwork::AccessPoint *accessPoint, const QString &passphrase={}, bool autoConnect=true, PhosphorServiceNetwork::NetworkConnection *existing=nullptr)
Create and activate a new Wi-Fi connection for an access point (NM AddAndActivateConnection).
Definition AccessPoint.h:13