Refactoring
This commit is contained in:
parent
13f9764853
commit
5eede71667
21 changed files with 566 additions and 220 deletions
64
client/protocols/vpnprotocol.h
Normal file
64
client/protocols/vpnprotocol.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#ifndef VPNPROTOCOL_H
|
||||
#define VPNPROTOCOL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/defs.h"
|
||||
using namespace amnezia;
|
||||
|
||||
class QTimer;
|
||||
class Communicator;
|
||||
|
||||
class VpnProtocol : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VpnProtocol(const QString& args = QString(), QObject* parent = nullptr);
|
||||
virtual ~VpnProtocol() override = default;
|
||||
|
||||
enum class ConnectionState {Unknown, Disconnected, Preparing, Connecting, Connected, Disconnecting, TunnelReconnecting, Error};
|
||||
|
||||
static Communicator* communicator();
|
||||
static QString textConnectionState(ConnectionState connectionState);
|
||||
static void initializeCommunicator(QObject* parent = nullptr);
|
||||
|
||||
|
||||
virtual bool connected() const;
|
||||
virtual bool disconnected() const;
|
||||
virtual ErrorCode start() = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
ConnectionState connectionState() const;
|
||||
ErrorCode lastError() const;
|
||||
QString textConnectionState() const;
|
||||
void setLastError(ErrorCode lastError);
|
||||
|
||||
signals:
|
||||
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||
void connectionStateChanged(VpnProtocol::ConnectionState state);
|
||||
void timeoutTimerEvent();
|
||||
|
||||
protected slots:
|
||||
virtual void onTimeout();
|
||||
|
||||
protected:
|
||||
void startTimeoutTimer();
|
||||
void stopTimeoutTimer();
|
||||
|
||||
virtual void setBytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||
virtual void setConnectionState(VpnProtocol::ConnectionState state);
|
||||
|
||||
static Communicator* m_communicator;
|
||||
|
||||
ConnectionState m_connectionState;
|
||||
|
||||
private:
|
||||
QTimer* m_timeoutTimer;
|
||||
ErrorCode m_lastError;
|
||||
quint64 m_receivedBytes;
|
||||
quint64 m_sentBytes;
|
||||
};
|
||||
|
||||
#endif // VPNPROTOCOL_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue