File indexing completed on 2024-03-24 04:03:02
0001 /* 0002 SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net> 0003 SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza <lamarque@kde.org> 0004 SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef NETWORKMANAGERQT_VPNCONNECTION_H 0010 #define NETWORKMANAGERQT_VPNCONNECTION_H 0011 0012 #include <networkmanagerqt/networkmanagerqt_export.h> 0013 0014 #include "activeconnection.h" 0015 0016 #include <QObject> 0017 0018 namespace NetworkManager 0019 { 0020 class Device; 0021 class VpnConnectionPrivate; 0022 0023 /** 0024 * An active VPN connection 0025 */ 0026 class NETWORKMANAGERQT_EXPORT VpnConnection : public ActiveConnection 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 typedef QSharedPointer<VpnConnection> Ptr; 0032 typedef QList<Ptr> List; 0033 /** 0034 * Enum describing the possible VPN connection states 0035 */ 0036 enum State { 0037 Unknown = 0, /**< The state of the VPN connection is unknown. */ 0038 Prepare, /**< The VPN connection is preparing to connect. */ 0039 NeedAuth, /**< The VPN connection needs authorization credentials. */ 0040 Connecting, /**< The VPN connection is being established. */ 0041 GettingIpConfig, /**< The VPN connection is getting an IP address. */ 0042 Activated, /**< The VPN connection is active. */ 0043 Failed, /**< The VPN connection failed. */ 0044 Disconnected, /**< The VPN connection is disconnected. */ 0045 }; 0046 Q_ENUM(State) 0047 0048 enum StateChangeReason { 0049 UnknownReason = 0, /**< The reason for the VPN connection state change is unknown.*/ 0050 NoneReason, /**< No reason was given for the VPN connection state change. */ 0051 UserDisconnectedReason, /**< The VPN connection changed state because the user disconnected it. */ 0052 DeviceDisconnectedReason, /**< The VPN connection changed state because the device it was using was disconnected. */ 0053 ServiceStoppedReason, /**< The service providing the VPN connection was stopped. */ 0054 IpConfigInvalidReason, /**< The IP config of the VPN connection was invalid. */ 0055 ConnectTimeoutReason, /**< The connection attempt to the VPN service timed out. */ 0056 ServiceStartTimeoutReason, /**< A timeout occurred while starting the service providing the VPN connection. */ 0057 ServiceStartFailedReason, /**< Starting the service starting the service providing the VPN connection failed. */ 0058 NoSecretsReason, /**< Necessary secrets for the VPN connection were not provided. */ 0059 LoginFailedReason, /**< Authentication to the VPN server failed. */ 0060 ConnectionRemovedReason, /**< The connection was deleted from settings. */ 0061 }; 0062 Q_ENUM(StateChangeReason) 0063 0064 /** 0065 * Creates a new VpnConnection object. 0066 * 0067 * @param path the DBus path of the device 0068 */ 0069 explicit VpnConnection(const QString &path, QObject *parent = nullptr); 0070 /** 0071 * Destroys a VpnConnection object. 0072 */ 0073 ~VpnConnection() override; 0074 /** 0075 * Return the current login banner 0076 */ 0077 QString banner() const; 0078 /** 0079 * returns the current state 0080 */ 0081 NetworkManager::VpnConnection::State state() const; 0082 /** 0083 * operator for casting an ActiveConnection into a VpnConnection. Returns 0 if this 0084 * object is not a VPN connection. Introduced to make it possible to create a VpnConnection 0085 * object for every active connection, without creating an ActiveConnection object, checking 0086 * if it's a VPN connection, deleting the ActiveConnection and creating a VpnConnection 0087 */ 0088 operator VpnConnection *(); 0089 0090 Q_SIGNALS: 0091 /** 0092 * This signal is emitted when the connection @p banner has changed 0093 */ 0094 void bannerChanged(const QString &banner); 0095 /** 0096 * This signal is emitted when the VPN connection @p state has changed 0097 */ 0098 void stateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason); 0099 0100 private: 0101 Q_DECLARE_PRIVATE(VpnConnection) 0102 }; 0103 0104 } // namespace NetworkManager 0105 #endif // NETWORKMANAGERQT_VPNCONNECTION_H