Files
amnezia-client/client/vpnconnection.h
T

60 lines
1.4 KiB
C++
Raw Normal View History

2020-12-26 15:03:51 +03:00
#ifndef VPNCONNECTION_H
#define VPNCONNECTION_H
#include <QObject>
#include <QString>
#include <QScopedPointer>
2021-02-02 01:47:40 +03:00
#include <QRemoteObjectNode>
2020-12-26 15:03:51 +03:00
2021-01-06 17:12:24 +03:00
#include "protocols/vpnprotocol.h"
#include "core/defs.h"
2021-02-03 15:42:36 +03:00
#include "core/ipcclient.h"
2021-01-26 15:01:15 +03:00
#include "settings.h"
2021-01-06 17:12:24 +03:00
using namespace amnezia;
2020-12-26 15:03:51 +03:00
class VpnConnection : public QObject
{
Q_OBJECT
public:
explicit VpnConnection(QObject* parent = nullptr);
2021-02-18 15:00:41 +03:00
~VpnConnection() override;
2020-12-26 15:03:51 +03:00
2021-01-09 19:55:16 +03:00
static QString bytesPerSecToText(quint64 bytes);
2020-12-26 15:03:51 +03:00
2021-01-06 17:12:24 +03:00
ErrorCode lastError() const;
2021-02-18 15:00:41 +03:00
ErrorCode createVpnConfiguration(const ServerCredentials &credentials, Protocol protocol);
2021-01-06 17:12:24 +03:00
ErrorCode connectToVpn(const ServerCredentials &credentials, Protocol protocol = Protocol::Any);
2020-12-26 15:03:51 +03:00
void disconnectFromVpn();
2021-02-18 15:00:41 +03:00
bool isConnected() const;
bool isDisconnected() const;
2021-01-15 23:36:35 +03:00
VpnProtocol::ConnectionState connectionState();
2021-02-18 15:00:41 +03:00
QSharedPointer<VpnProtocol> vpnProtocol() const;
2020-12-26 15:03:51 +03:00
signals:
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
void connectionStateChanged(VpnProtocol::ConnectionState state);
2021-01-08 16:51:58 +03:00
void vpnProtocolError(amnezia::ErrorCode error);
2020-12-26 15:03:51 +03:00
2021-02-18 15:00:41 +03:00
void serviceIsNotReady();
2020-12-26 15:03:51 +03:00
protected slots:
void onBytesChanged(quint64 receivedBytes, quint64 sentBytes);
void onConnectionStateChanged(VpnProtocol::ConnectionState state);
protected:
2021-02-18 15:00:41 +03:00
QSharedPointer<VpnProtocol> m_vpnProtocol;
2021-01-26 15:01:15 +03:00
private:
Settings m_settings;
2021-02-18 15:00:41 +03:00
QJsonObject m_vpnConfiguration;
2021-02-02 01:47:40 +03:00
2020-12-26 15:03:51 +03:00
};
#endif // VPNCONNECTION_H