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_VPNCONNECTION_H |
10 | #define NETWORKMANAGERQT_VPNCONNECTION_H |
11 | |
12 | #include <networkmanagerqt/networkmanagerqt_export.h> |
13 | |
14 | #include "activeconnection.h" |
15 | |
16 | #include <QObject> |
17 | |
18 | namespace NetworkManager |
19 | { |
20 | class Device; |
21 | class VpnConnectionPrivate; |
22 | |
23 | /** |
24 | * An active VPN connection |
25 | */ |
26 | class NETWORKMANAGERQT_EXPORT VpnConnection : public ActiveConnection |
27 | { |
28 | Q_OBJECT |
29 | |
30 | public: |
31 | typedef QSharedPointer<VpnConnection> Ptr; |
32 | typedef QList<Ptr> List; |
33 | /** |
34 | * Enum describing the possible VPN connection states |
35 | */ |
36 | enum State { |
37 | Unknown = 0, /**< The state of the VPN connection is unknown. */ |
38 | Prepare, /**< The VPN connection is preparing to connect. */ |
39 | NeedAuth, /**< The VPN connection needs authorization credentials. */ |
40 | Connecting, /**< The VPN connection is being established. */ |
41 | GettingIpConfig, /**< The VPN connection is getting an IP address. */ |
42 | Activated, /**< The VPN connection is active. */ |
43 | Failed, /**< The VPN connection failed. */ |
44 | Disconnected, /**< The VPN connection is disconnected. */ |
45 | }; |
46 | Q_ENUM(State) |
47 | |
48 | enum StateChangeReason { |
49 | UnknownReason = 0, /**< The reason for the VPN connection state change is unknown.*/ |
50 | NoneReason, /**< No reason was given for the VPN connection state change. */ |
51 | UserDisconnectedReason, /**< The VPN connection changed state because the user disconnected it. */ |
52 | DeviceDisconnectedReason, /**< The VPN connection changed state because the device it was using was disconnected. */ |
53 | ServiceStoppedReason, /**< The service providing the VPN connection was stopped. */ |
54 | IpConfigInvalidReason, /**< The IP config of the VPN connection was invalid. */ |
55 | ConnectTimeoutReason, /**< The connection attempt to the VPN service timed out. */ |
56 | ServiceStartTimeoutReason, /**< A timeout occurred while starting the service providing the VPN connection. */ |
57 | ServiceStartFailedReason, /**< Starting the service starting the service providing the VPN connection failed. */ |
58 | NoSecretsReason, /**< Necessary secrets for the VPN connection were not provided. */ |
59 | LoginFailedReason, /**< Authentication to the VPN server failed. */ |
60 | ConnectionRemovedReason, /**< The connection was deleted from settings. */ |
61 | }; |
62 | Q_ENUM(StateChangeReason) |
63 | |
64 | /** |
65 | * Creates a new VpnConnection object. |
66 | * |
67 | * @param path the DBus path of the device |
68 | */ |
69 | explicit VpnConnection(const QString &path, QObject *parent = nullptr); |
70 | /** |
71 | * Destroys a VpnConnection object. |
72 | */ |
73 | ~VpnConnection() override; |
74 | /** |
75 | * Return the current login banner |
76 | */ |
77 | QString banner() const; |
78 | /** |
79 | * returns the current state |
80 | */ |
81 | NetworkManager::VpnConnection::State state() const; |
82 | /** |
83 | * operator for casting an ActiveConnection into a VpnConnection. Returns 0 if this |
84 | * object is not a VPN connection. Introduced to make it possible to create a VpnConnection |
85 | * object for every active connection, without creating an ActiveConnection object, checking |
86 | * if it's a VPN connection, deleting the ActiveConnection and creating a VpnConnection |
87 | */ |
88 | operator VpnConnection *(); |
89 | |
90 | Q_SIGNALS: |
91 | /** |
92 | * This signal is emitted when the connection @p banner has changed |
93 | */ |
94 | void bannerChanged(const QString &banner); |
95 | /** |
96 | * This signal is emitted when the VPN connection @p state has changed |
97 | */ |
98 | void stateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason); |
99 | |
100 | private: |
101 | Q_DECLARE_PRIVATE(VpnConnection) |
102 | }; |
103 | |
104 | } // namespace NetworkManager |
105 | #endif // NETWORKMANAGERQT_VPNCONNECTION_H |
106 | |