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 | * \class NetworkManager::VpnConnection |
25 | * \inheaderfile NetworkManagerQt/VpnConnection |
26 | * \inmodule NetworkManagerQt |
27 | * |
28 | * \brief An active VPN connection. |
29 | */ |
30 | class NETWORKMANAGERQT_EXPORT VpnConnection : public ActiveConnection |
31 | { |
32 | Q_OBJECT |
33 | |
34 | public: |
35 | /*! |
36 | * \typedef NetworkManager::VpnConnection::Ptr |
37 | */ |
38 | typedef QSharedPointer<VpnConnection> Ptr; |
39 | /*! |
40 | * \typedef NetworkManager::VpnConnection::List |
41 | */ |
42 | typedef QList<Ptr> List; |
43 | /*! |
44 | * Enum describing the possible VPN connection states |
45 | * |
46 | * \value Unknown |
47 | * The state of the VPN connection is unknown. |
48 | * \value Prepare |
49 | * The VPN connection is preparing to connect. |
50 | * \value NeedAuth |
51 | * The VPN connection needs authorization credentials. |
52 | * \value Connecting |
53 | * The VPN connection is being established. |
54 | * \value GettingIpConfig |
55 | * The VPN connection is getting an IP address. |
56 | * \value Activated |
57 | * The VPN connection is active. |
58 | * \value Failed |
59 | * The VPN connection failed. |
60 | * \value Disconnected |
61 | * The VPN connection is disconnected. |
62 | */ |
63 | enum State { |
64 | Unknown = 0, |
65 | Prepare, |
66 | NeedAuth, |
67 | Connecting, |
68 | GettingIpConfig, |
69 | Activated, |
70 | Failed, |
71 | Disconnected, |
72 | }; |
73 | Q_ENUM(State) |
74 | |
75 | /*! |
76 | * |
77 | * \value UnknownReason |
78 | * The reason for the VPN connection state change is unknown. |
79 | * \value NoneReason |
80 | * No reason was given for the VPN connection state change. |
81 | * \value UserDisconnectedReason |
82 | * The VPN connection changed state because the user disconnected it. |
83 | * \value DeviceDisconnectedReason |
84 | * The VPN connection changed state because the device it was using was disconnected. |
85 | * \value ServiceStoppedReason |
86 | * The service providing the VPN connection was stopped. |
87 | * \value IpConfigInvalidReason |
88 | * The IP config of the VPN connection was invalid. |
89 | * \value ConnectTimeoutReason |
90 | * The connection attempt to the VPN service timed out. |
91 | * \value ServiceStartTimeoutReason |
92 | * A timeout occurred while starting the service providing the VPN connection. |
93 | * \value ServiceStartFailedReason |
94 | * Starting the service starting the service providing the VPN connection failed. |
95 | * \value NoSecretsReason |
96 | * Necessary secrets for the VPN connection were not provided. |
97 | * \value LoginFailedReason |
98 | * Authentication to the VPN server failed. |
99 | * \value ConnectionRemovedReason |
100 | * The connection was deleted from settings. |
101 | */ |
102 | enum StateChangeReason { |
103 | UnknownReason = 0, |
104 | NoneReason, |
105 | UserDisconnectedReason, |
106 | DeviceDisconnectedReason, |
107 | ServiceStoppedReason, |
108 | IpConfigInvalidReason, |
109 | ConnectTimeoutReason, |
110 | ServiceStartTimeoutReason, |
111 | ServiceStartFailedReason, |
112 | NoSecretsReason, |
113 | LoginFailedReason, |
114 | ConnectionRemovedReason, |
115 | }; |
116 | Q_ENUM(StateChangeReason) |
117 | |
118 | /*! |
119 | * Creates a new VpnConnection object. |
120 | * |
121 | * \a path the DBus path of the device |
122 | */ |
123 | explicit VpnConnection(const QString &path, QObject *parent = nullptr); |
124 | /*! |
125 | * Destroys a VpnConnection object. |
126 | */ |
127 | ~VpnConnection() override; |
128 | /*! |
129 | * Return the current login banner |
130 | */ |
131 | QString banner() const; |
132 | /*! |
133 | * returns the current state |
134 | */ |
135 | NetworkManager::VpnConnection::State state() const; |
136 | /*! |
137 | * operator for casting an ActiveConnection into a VpnConnection. Returns 0 if this |
138 | * object is not a VPN connection. Introduced to make it possible to create a VpnConnection |
139 | * object for every active connection, without creating an ActiveConnection object, checking |
140 | * if it's a VPN connection, deleting the ActiveConnection and creating a VpnConnection |
141 | */ |
142 | operator VpnConnection *(); |
143 | |
144 | Q_SIGNALS: |
145 | /*! |
146 | * This signal is emitted when the connection \a banner has changed |
147 | */ |
148 | void bannerChanged(const QString &banner); |
149 | /*! |
150 | * This signal is emitted when the VPN connection \a state has changed |
151 | */ |
152 | void stateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason); |
153 | |
154 | private: |
155 | Q_DECLARE_PRIVATE(VpnConnection) |
156 | }; |
157 | |
158 | } // namespace NetworkManager |
159 | #endif // NETWORKMANAGERQT_VPNCONNECTION_H |
160 | |