added logic to the connect to vpn button
This commit is contained in:
parent
35d4222c7a
commit
116fa6777b
27 changed files with 293 additions and 125 deletions
|
@ -12,6 +12,33 @@ using namespace amnezia;
|
|||
|
||||
class QTimer;
|
||||
|
||||
//todo change name
|
||||
namespace Vpn
|
||||
{
|
||||
Q_NAMESPACE
|
||||
enum ConnectionState {
|
||||
Unknown,
|
||||
Disconnected,
|
||||
Preparing,
|
||||
Connecting,
|
||||
Connected,
|
||||
Disconnecting,
|
||||
Reconnecting,
|
||||
Error
|
||||
};
|
||||
Q_ENUM_NS(ConnectionState)
|
||||
|
||||
static void declareQmlVpnConnectionStateEnum() {
|
||||
qmlRegisterUncreatableMetaObject(
|
||||
Vpn::staticMetaObject,
|
||||
"ConnectionState",
|
||||
1, 0,
|
||||
"ConnectionState",
|
||||
"Error: only enums"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VpnProtocol : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -20,10 +47,7 @@ public:
|
|||
explicit VpnProtocol(const QJsonObject& configuration, QObject* parent = nullptr);
|
||||
virtual ~VpnProtocol() override = default;
|
||||
|
||||
enum VpnConnectionState {Unknown, Disconnected, Preparing, Connecting, Connected, Disconnecting, Reconnecting, Error};
|
||||
Q_ENUM(VpnConnectionState)
|
||||
|
||||
static QString textConnectionState(VpnConnectionState connectionState);
|
||||
static QString textConnectionState(Vpn::ConnectionState connectionState);
|
||||
|
||||
virtual ErrorCode prepare() { return ErrorCode::NoError; }
|
||||
|
||||
|
@ -32,7 +56,7 @@ public:
|
|||
virtual ErrorCode start() = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
VpnConnectionState connectionState() const;
|
||||
Vpn::ConnectionState connectionState() const;
|
||||
ErrorCode lastError() const;
|
||||
QString textConnectionState() const;
|
||||
void setLastError(ErrorCode lastError);
|
||||
|
@ -44,7 +68,7 @@ public:
|
|||
|
||||
signals:
|
||||
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||
void connectionStateChanged(VpnProtocol::VpnConnectionState state);
|
||||
void connectionStateChanged(Vpn::ConnectionState state);
|
||||
void timeoutTimerEvent();
|
||||
void protocolError(amnezia::ErrorCode e);
|
||||
|
||||
|
@ -52,13 +76,13 @@ public slots:
|
|||
virtual void onTimeout(); // todo: remove?
|
||||
|
||||
void setBytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||
void setConnectionState(VpnProtocol::VpnConnectionState state);
|
||||
void setConnectionState(Vpn::ConnectionState state);
|
||||
|
||||
protected:
|
||||
void startTimeoutTimer();
|
||||
void stopTimeoutTimer();
|
||||
|
||||
VpnConnectionState m_connectionState;
|
||||
Vpn::ConnectionState m_connectionState;
|
||||
|
||||
QString m_routeGateway;
|
||||
QString m_vpnLocalAddress;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue