summaryrefslogtreecommitdiffstats
path: root/src/client/connectwindow/connectwindow.h
diff options
context:
space:
mode:
authorsr2013-02-04 19:50:31 +0100
committersr2013-02-04 19:50:31 +0100
commit1a5709501f94014d41987b956338bb6424b9f90c (patch)
treed3b93fe8dc406bca56aff147ef5cc4cbf9ed6be0 /src/client/connectwindow/connectwindow.h
parentTest (diff)
downloadpvs2-1a5709501f94014d41987b956338bb6424b9f90c.tar.gz
pvs2-1a5709501f94014d41987b956338bb6424b9f90c.tar.xz
pvs2-1a5709501f94014d41987b956338bb6424b9f90c.zip
Initial commit
Diffstat (limited to 'src/client/connectwindow/connectwindow.h')
-rw-r--r--src/client/connectwindow/connectwindow.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/client/connectwindow/connectwindow.h b/src/client/connectwindow/connectwindow.h
new file mode 100644
index 0000000..d8f9ab9
--- /dev/null
+++ b/src/client/connectwindow/connectwindow.h
@@ -0,0 +1,95 @@
+/*
+ # Copyright (c) 2013 - OpenSLX Project, Computer Center University of
+ # Freiburg
+ #
+ # This program is free software distributed under the GPL version 2.
+ # See http://openslx.org/COPYING
+ #
+ # If you have any feedback please consult http://openslx.org/feedback and
+ # send your suggestions, praise, or complaints to feedback@openslx.org
+ #
+ # General information about OpenSLX can be found at http://openslx.org/
+ # ---------------------------------------------------------------------
+ # - Allow user to connect/disconnect to/from server
+ */
+
+#ifndef PVSCONNECTWINDOW_H_
+#define PVSCONNECTWINDOW_H_
+
+#include <QtGui>
+#include <QUdpSocket>
+#include <QSslSocket>
+#include "ui_connect.h"
+
+#include "../../shared/networkmessage.h"
+
+class ServerConnection;
+
+class ConnectWindow : public QDialog, private Ui_Dialog
+{
+Q_OBJECT
+
+public:
+ 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:
+ bool _connected;
+ int _timerDiscover, _timerHide;
+ ServerConnection *_connection;
+ ConnectionState _state;
+ int _hashErrorCount, _hashSslErrorCount, _certErrorCount, _ipErrorCount;
+ int _discoveryInterval;
+
+ QByteArray _nameBytes;
+ QByteArray _salt2;
+ QUdpSocket _discoverySocket;
+ NetworkMessage _packet;
+
+ void setState(const ConnectionState state);
+ void updateState();
+
+public:
+ ConnectWindow(QWidget *parent = NULL);
+ virtual ~ConnectWindow();
+
+ void setConnected(const bool connected);
+
+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);
+
+protected slots:
+ void onOkClick();
+ void onCancelClick();
+ void onUdpReadyRead();
+ void onConnectionStateChange(ConnectWindow::ConnectionState state);
+ void onConnectionClosed(QObject* connection);
+ //void onSsl
+
+signals:
+ void disconnect();
+ void connected(ServerConnection* connection);
+
+};
+
+#endif