From afc69ca4ffb0e11d9d06b8ddd31ee40963f86f17 Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Wed, 28 May 2014 00:37:28 +0200 Subject: Outsource serverDiscovery. --- src/client/connectwindow/connectwindow.h | 53 ++++++++++++-------------------- 1 file changed, 19 insertions(+), 34 deletions(-) (limited to 'src/client/connectwindow/connectwindow.h') diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h index 9319e45..39eac86 100644 --- a/src/client/connectwindow/connectwindow.h +++ b/src/client/connectwindow/connectwindow.h @@ -20,6 +20,7 @@ #include #include #include "../../shared/networkmessage.h" +#include "../net/serverdiscovery.h" namespace Ui{ class ConnectWindow; @@ -38,54 +39,37 @@ class ConnectWindow : public QWidget Q_OBJECT public: - enum ConnectionState - { + enum ConnectionState { Idle, Scanning, Connecting, AwaitingChallenge, AwaitingChallengeResponse, LoggingIn, - InvalidIpList, - InvalidHash, // Hash of UDP reply invalid InvalidSslHash, // Hash of challenge inside SSL connection invalid InvalidCert, Connected }; -private: - Ui::ConnectWindow *_ui; - - bool _connected; - int _timerDiscover, _timerHide; - ServerConnection *_connection; - ConnectionState _state; - int _hashErrorCount, _hashSslErrorCount, _certErrorCount, _ipErrorCount; - int _discoveryInterval; - - QByteArray _sessionNameBytes; - QByteArray _salt2; - QUdpSocket _discoverySocket; - NetworkMessage _packet; - - void setState(const ConnectionState state); - void updateState(); - -public: explicit ConnectWindow(QWidget *parent = NULL); virtual ~ConnectWindow(); - void setConnected(const bool connected); void connectToSession(const QByteArray sessionName); +private: + Ui::ConnectWindow *_ui; + ServerConnection *_connection; + int _hashSslErrorCount; + ServerDiscovery _serverDiscovery; + ConnectionState _state; + QByteArray _sessionNameBytes; + NetworkMessage _packet; + bool _connected; + int _timerHide; + + void updateState(); + protected: - /* - void enterEvent(QEvent *e); - void leaveEvent(QEvent *e); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - */ void timerEvent(QTimerEvent* event); void closeEvent(QCloseEvent *e); void showEvent(QShowEvent* event); @@ -93,15 +77,16 @@ protected: protected slots: void onBtnConnection(); void onBtnHide(); - void onUdpReadyRead(); + void onConnectionStateChange(ConnectWindow::ConnectionState state); void onConnectionClosed(QObject* connection); - //void onSsl + void onConnectionDisconnected(); + // void onUdpReadyRead(); + void onServerDetected(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash); signals: void disconnect(); void connected(ServerConnection* connection); - }; #endif -- cgit v1.2.3-55-g7522