NetworkManagerQt

activeconnection.h
1/*
2 SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net>
3 SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza <lamarque@kde.org>
4 SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#ifndef NETWORKMANAGERQT_ACTIVECONNECTION_H
10#define NETWORKMANAGERQT_ACTIVECONNECTION_H
11
12#include <QObject>
13#include <QSharedPointer>
14
15#include "connection.h"
16#include "dhcp4config.h"
17#include "dhcp6config.h"
18#include "ipconfig.h"
19#include <networkmanagerqt/networkmanagerqt_export.h>
20
21namespace NetworkManager
22{
23class ActiveConnectionPrivate;
24
25/**
26 * An active connection
27 */
28class NETWORKMANAGERQT_EXPORT ActiveConnection : public QObject
29{
30 Q_OBJECT
31
32public:
34 typedef QList<Ptr> List;
35 /**
36 * Enum describing possible active connection states
37 */
38 enum State {
39 Unknown = 0, /**< The active connection is in an unknown state */
40 Activating, /**< The connection is activating */
41 Activated, /**< The connection is activated */
42 Deactivating, /**< The connection is being torn down and cleaned up */
43 Deactivated, /**< The connection is no longer active */
44 };
45
46 enum Reason {
47 UknownReason = 0, /**< The reason for the active connection state change is unknown */
48 None, /**< No reason was given for the active connection state change */
49 UserDisconnected, /**< The active connection changed state because the user disconnected it */
50 DeviceDisconnected, /**< The active connection changed state because the device it was using was disconnected */
51 ServiceStopped, /**< The service providing the VPN connection was stopped */
52 IpConfigInvalid, /**< The IP config of the active connection was invalid */
53 ConnectTimeout, /**< The connection attempt to the VPN service timed out */
54 ServiceStartTimeout, /**< A timeout occurred while starting the service providing the VPN connection */
55 ServiceStartFailed, /**< Starting the service providing the VPN connection failed */
56 NoSecrets, /**< Necessary secrets for the connection were not provided */
57 LoginFailed, /**< Authentication to the server failed */
58 ConnectionRemoved, /**< The connection was deleted from settings */
59 DependencyFailed, /**< Master connection of this connection failed to activate */
60 DeviceRealizeFailed, /**< Could not create the software device link */
61 DeviceRemoved, /**< The device this connection depended on disappeared */
62 };
63
64 /**
65 * Creates a new ActiveConnection object.
66 *
67 * @param path the DBus path of the device
68 */
69 explicit ActiveConnection(const QString &path, QObject *parent = nullptr);
70
71 /**
72 * Destroys an ActiveConnection object.
73 */
74 ~ActiveConnection() override;
75
76 /**
77 * Returns true is this object holds a valid connection
78 */
79 bool isValid() const;
80 /**
81 * Return path of the connection object
82 */
83 QString path() const;
84 /**
85 * Returns a valid NetworkManager::Connection object
86 */
87 Connection::Ptr connection() const;
88 /**
89 * Whether this connection has the default IPv4 route
90 */
91 bool default4() const;
92 /**
93 * Whether this connection has the default IPv6 route
94 */
95 bool default6() const;
96 /**
97 * The Ip4Config object describing the configuration of the
98 * connection. Only valid when the connection is in the
99 * NM_ACTIVE_CONNECTION_STATE_ACTIVATED state
100 */
101 IpConfig ipV4Config() const;
102 /**
103 * The Ip6Config object describing the configuration of the
104 * connection. Only valid when the connection is in the
105 * NM_ACTIVE_CONNECTION_STATE_ACTIVATED state
106 */
107 IpConfig ipV6Config() const;
108 /**
109 * The Dhcp4Config object describing the DHCP options
110 * returned by the DHCP server (assuming the connection used DHCP). Only
111 * valid when the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED
112 * state
113 */
114 Dhcp4Config::Ptr dhcp4Config() const;
115 /**
116 * The Dhcp6Config object describing the DHCP options
117 * returned by the DHCP server (assuming the connection used DHCP). Only
118 * valid when the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED
119 * state
120 */
121 Dhcp6Config::Ptr dhcp6Config() const;
122 /**
123 * The Id of the connection
124 */
125 QString id() const;
126 /**
127 * The type of the connection
128 */
129 NetworkManager::ConnectionSettings::ConnectionType type() const;
130 /**
131 * Returns the uni of master device if the connection is a slave.
132 */
133 QString master() const;
134 /**
135 * The path of the specific object associated with the connection.
136 */
137 QString specificObject() const;
138 /**
139 * The current state of the connection
140 */
142 /**
143 * Whether this is a VPN connection
144 */
145 bool vpn() const;
146 /**
147 * The UUID of the connection.
148 */
149 QString uuid() const;
150 /**
151 * List of devices UNIs which are part of this connection.
152 */
153 QStringList devices() const;
154
155Q_SIGNALS:
156 /**
157 * This signal is emitted when the connection path has changed
158 */
160 /**
161 * The state of the default IPv4 route changed
162 */
163 void default4Changed(bool isDefault);
164 /**
165 * The state of the default IPv6 route changed
166 */
167 void default6Changed(bool isDefault);
168 /**
169 * Emitted when the DHCP configuration for IPv4 of this network has changed.
170 */
172 /**
173 * Emitted when the DHCP configuration for IPv6 of this network has changed.
174 */
176 /**
177 * Emitted when the IPv4 configuration of this network has changed.
178 */
180 /**
181 * Emitted when the IPv6 configuration of this network has changed.
182 */
184 /**
185 * The @p id changed
186 */
187 void idChanged(const QString &id);
188 /**
189 * The @p type changed
190 */
191 void typeChanged(NetworkManager::ConnectionSettings::ConnectionType type);
192 /**
193 * The master device changed.
194 */
195 void masterChanged(const QString &uni);
196 /**
197 * The @p path to the specific object changed
198 */
200 /**
201 * The @p state changed
202 */
204 /**
205 * The @p state changed because of reason @p reason
206 * (never emitted in runtime NM < 1.8.0)
207 */
209 /**
210 * The VPN property changed.
211 */
212 void vpnChanged(bool isVpn);
213 /**
214 * The @p uuid changed.
215 */
216 void uuidChanged(const QString &uuid);
217 /**
218 * The list of devices changed.
219 */
221
222protected:
223 NETWORKMANAGERQT_NO_EXPORT explicit ActiveConnection(ActiveConnectionPrivate &dd, QObject *parent = nullptr);
224
225 ActiveConnectionPrivate *const d_ptr;
226
227private:
228 Q_DECLARE_PRIVATE(ActiveConnection)
229};
230
231} // namespace NetworkManager
232#endif // NETWORKMANAGERQT_ACTIVECONNECTION_H
void ipV6ConfigChanged()
Emitted when the IPv6 configuration of this network has changed.
void vpnChanged(bool isVpn)
The VPN property changed.
void ipV4ConfigChanged()
Emitted when the IPv4 configuration of this network has changed.
void stateChangedReason(NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
The state changed because of reason reason (never emitted in runtime NM < 1.8.0)
void connectionChanged(const NetworkManager::Connection::Ptr &connection)
This signal is emitted when the connection path has changed.
State
Enum describing possible active connection states.
@ Deactivating
The connection is being torn down and cleaned up.
@ Activating
The connection is activating.
@ Deactivated
The connection is no longer active.
@ Activated
The connection is activated.
void uuidChanged(const QString &uuid)
The uuid changed.
void dhcp4ConfigChanged()
Emitted when the DHCP configuration for IPv4 of this network has changed.
void stateChanged(NetworkManager::ActiveConnection::State state)
The state changed.
@ ConnectionRemoved
The connection was deleted from settings.
@ DeviceDisconnected
The active connection changed state because the device it was using was disconnected.
@ DeviceRemoved
The device this connection depended on disappeared.
@ ServiceStartTimeout
A timeout occurred while starting the service providing the VPN connection.
@ UserDisconnected
The active connection changed state because the user disconnected it.
@ NoSecrets
Necessary secrets for the connection were not provided.
@ DeviceRealizeFailed
Could not create the software device link.
@ DependencyFailed
Master connection of this connection failed to activate.
@ None
No reason was given for the active connection state change.
@ IpConfigInvalid
The IP config of the active connection was invalid.
@ LoginFailed
Authentication to the server failed.
@ ServiceStopped
The service providing the VPN connection was stopped.
@ ConnectTimeout
The connection attempt to the VPN service timed out.
@ ServiceStartFailed
Starting the service providing the VPN connection failed.
void dhcp6ConfigChanged()
Emitted when the DHCP configuration for IPv6 of this network has changed.
void default4Changed(bool isDefault)
The state of the default IPv4 route changed.
void idChanged(const QString &id)
The id changed.
void typeChanged(NetworkManager::ConnectionSettings::ConnectionType type)
The type changed.
void masterChanged(const QString &uni)
The master device changed.
void default6Changed(bool isDefault)
The state of the default IPv6 route changed.
void devicesChanged()
The list of devices changed.
void specificObjectChanged(const QString &path)
The path to the specific object changed.
This class represents IP configuration.
Definition ipconfig.h:28
This class allows querying the underlying system to discover the available network interfaces and rea...
Definition accesspoint.h:21
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.