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 | |
21 | namespace NetworkManager |
22 | { |
23 | class ActiveConnectionPrivate; |
24 | |
25 | /*! |
26 | * \class NetworkManager::ActiveConnection |
27 | * \inheaderfile NetworkManagerQt/ActiveConnection |
28 | * \inmodule NetworkManagerQt |
29 | * |
30 | * \brief An active connection. |
31 | */ |
32 | class NETWORKMANAGERQT_EXPORT ActiveConnection : public QObject |
33 | { |
34 | Q_OBJECT |
35 | |
36 | public: |
37 | /*! |
38 | * \typedef NetworkManager::ActiveConnection::Ptr |
39 | */ |
40 | typedef QSharedPointer<ActiveConnection> Ptr; |
41 | /*! |
42 | * \typedef NetworkManager::ActiveConnection::List |
43 | */ |
44 | typedef QList<Ptr> List; |
45 | |
46 | /*! |
47 | * |
48 | * Enum describing possible active connection states |
49 | * |
50 | * \value Unknown |
51 | * The active connection is in an unknown state |
52 | * \value Activating |
53 | * The connection is activating |
54 | * \value Activated |
55 | * The connection is activated |
56 | * \value Deactivating |
57 | * The connection is being torn down and cleaned up |
58 | * \value Deactivated |
59 | * The connection is no longer active |
60 | */ |
61 | enum State { |
62 | Unknown = 0, |
63 | Activating, |
64 | Activated, |
65 | Deactivating, |
66 | Deactivated, |
67 | }; |
68 | |
69 | /*! |
70 | * |
71 | * \value UknownReason |
72 | * The reason for the active connection state change is unknown |
73 | * \value None |
74 | * No reason was given for the active connection state change |
75 | * \value UserDisconnected |
76 | * The active connection changed state because the user disconnected it |
77 | * \value DeviceDisconnected |
78 | * The active connection changed state because the device it was using was disconnected |
79 | * \value ServiceStopped |
80 | * The service providing the VPN connection was stopped |
81 | * \value IpConfigInvalid |
82 | * The IP config of the active connection was invalid |
83 | * \value ConnectTimeout |
84 | * The connection attempt to the VPN service timed out |
85 | * \value ServiceStartTimeout |
86 | * A timeout occurred while starting the service providing the VPN connection |
87 | * \value ServiceStartFailed |
88 | * Starting the service providing the VPN connection failed |
89 | * \value NoSecrets |
90 | * Necessary secrets for the connection were not provided |
91 | * \value LoginFailed |
92 | * Authentication to the server failed |
93 | * \value ConnectionRemoved |
94 | * The connection was deleted from settings |
95 | * \value DependencyFailed |
96 | * Master connection of this connection failed to activate |
97 | * \value DeviceRealizeFailed |
98 | * Could not create the software device link |
99 | * \value DeviceRemoved |
100 | * The device this connection depended on disappeared |
101 | */ |
102 | enum Reason { |
103 | UknownReason = 0, |
104 | None, |
105 | UserDisconnected, |
106 | DeviceDisconnected, |
107 | ServiceStopped, |
108 | IpConfigInvalid, |
109 | ConnectTimeout, |
110 | ServiceStartTimeout, |
111 | ServiceStartFailed, |
112 | NoSecrets, |
113 | LoginFailed, |
114 | ConnectionRemoved, |
115 | DependencyFailed, |
116 | DeviceRealizeFailed, |
117 | DeviceRemoved, |
118 | }; |
119 | |
120 | /*! |
121 | * Creates a new ActiveConnection object. |
122 | * |
123 | * \a path the DBus path of the device |
124 | */ |
125 | explicit ActiveConnection(const QString &path, QObject *parent = nullptr); |
126 | |
127 | /*! |
128 | * Destroys an ActiveConnection object. |
129 | */ |
130 | ~ActiveConnection() override; |
131 | |
132 | /*! |
133 | * Returns true is this object holds a valid connection |
134 | */ |
135 | bool isValid() const; |
136 | /*! |
137 | * Return path of the connection object |
138 | */ |
139 | QString path() const; |
140 | /*! |
141 | * Returns a valid NetworkManager::Connection object |
142 | */ |
143 | Connection::Ptr connection() const; |
144 | /*! |
145 | * Whether this connection has the default IPv4 route |
146 | */ |
147 | bool default4() const; |
148 | /*! |
149 | * Whether this connection has the default IPv6 route |
150 | */ |
151 | bool default6() const; |
152 | /*! |
153 | * The Ip4Config object describing the configuration of the |
154 | * connection. Only valid when the connection is in the |
155 | * NM_ACTIVE_CONNECTION_STATE_ACTIVATED state |
156 | */ |
157 | IpConfig ipV4Config() const; |
158 | /*! |
159 | * The Ip6Config object describing the configuration of the |
160 | * connection. Only valid when the connection is in the |
161 | * NM_ACTIVE_CONNECTION_STATE_ACTIVATED state |
162 | */ |
163 | IpConfig ipV6Config() const; |
164 | /*! |
165 | * The Dhcp4Config object describing the DHCP options |
166 | * returned by the DHCP server (assuming the connection used DHCP). Only |
167 | * valid when the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED |
168 | * state |
169 | */ |
170 | Dhcp4Config::Ptr dhcp4Config() const; |
171 | /*! |
172 | * The Dhcp6Config object describing the DHCP options |
173 | * returned by the DHCP server (assuming the connection used DHCP). Only |
174 | * valid when the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED |
175 | * state |
176 | */ |
177 | Dhcp6Config::Ptr dhcp6Config() const; |
178 | /*! |
179 | * The Id of the connection |
180 | */ |
181 | QString id() const; |
182 | /*! |
183 | * The type of the connection |
184 | */ |
185 | NetworkManager::ConnectionSettings::ConnectionType type() const; |
186 | /*! |
187 | * Returns the uni of master device if the connection is a slave. |
188 | */ |
189 | QString master() const; |
190 | /*! |
191 | * The path of the specific object associated with the connection. |
192 | */ |
193 | QString specificObject() const; |
194 | /*! |
195 | * The current state of the connection |
196 | */ |
197 | NetworkManager::ActiveConnection::State state() const; |
198 | /*! |
199 | * Whether this is a VPN connection |
200 | */ |
201 | bool vpn() const; |
202 | /*! |
203 | * The UUID of the connection. |
204 | */ |
205 | QString uuid() const; |
206 | /*! |
207 | * List of devices UNIs which are part of this connection. |
208 | */ |
209 | QStringList devices() const; |
210 | |
211 | Q_SIGNALS: |
212 | /*! |
213 | * This signal is emitted when the connection path has changed |
214 | */ |
215 | void connectionChanged(const NetworkManager::Connection::Ptr &connection); |
216 | /*! |
217 | * The state of the default IPv4 route changed |
218 | */ |
219 | void default4Changed(bool isDefault); |
220 | /*! |
221 | * The state of the default IPv6 route changed |
222 | */ |
223 | void default6Changed(bool isDefault); |
224 | /*! |
225 | * Emitted when the DHCP configuration for IPv4 of this network has changed. |
226 | */ |
227 | void dhcp4ConfigChanged(); |
228 | /*! |
229 | * Emitted when the DHCP configuration for IPv6 of this network has changed. |
230 | */ |
231 | void dhcp6ConfigChanged(); |
232 | /*! |
233 | * Emitted when the IPv4 configuration of this network has changed. |
234 | */ |
235 | void ipV4ConfigChanged(); |
236 | /*! |
237 | * Emitted when the IPv6 configuration of this network has changed. |
238 | */ |
239 | void ipV6ConfigChanged(); |
240 | /*! |
241 | * The \a id changed |
242 | */ |
243 | void idChanged(const QString &id); |
244 | /*! |
245 | * The \a type changed |
246 | */ |
247 | void typeChanged(NetworkManager::ConnectionSettings::ConnectionType type); |
248 | /*! |
249 | * The master device changed. |
250 | */ |
251 | void masterChanged(const QString &uni); |
252 | /*! |
253 | * The \a path to the specific object changed |
254 | */ |
255 | void specificObjectChanged(const QString &path); |
256 | /*! |
257 | * The \a state changed |
258 | */ |
259 | void stateChanged(NetworkManager::ActiveConnection::State state); |
260 | /*! |
261 | * The \a state changed because of reason \a reason |
262 | * (never emitted in runtime NM < 1.8.0) |
263 | */ |
264 | void stateChangedReason(NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason); |
265 | /*! |
266 | * The VPN property changed. |
267 | */ |
268 | void vpnChanged(bool isVpn); |
269 | /*! |
270 | * The \a uuid changed. |
271 | */ |
272 | void uuidChanged(const QString &uuid); |
273 | /*! |
274 | * The list of devices changed. |
275 | */ |
276 | void devicesChanged(); |
277 | |
278 | protected: |
279 | /*! |
280 | */ |
281 | NETWORKMANAGERQT_NO_EXPORT explicit ActiveConnection(ActiveConnectionPrivate &dd, QObject *parent = nullptr); |
282 | |
283 | ActiveConnectionPrivate *const d_ptr; |
284 | |
285 | private: |
286 | Q_DECLARE_PRIVATE(ActiveConnection) |
287 | }; |
288 | |
289 | } // namespace NetworkManager |
290 | #endif // NETWORKMANAGERQT_ACTIVECONNECTION_H |
291 | |