blob: 8d4a43677d71e529185f7c0bf6abdb0bb9910c1b (
plain) (
tree)
|
|
/*
# 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 "../../shared/networkmessage.h"
namespace Ui{
class ConnectWindow;
}
class ServerConnection;
/**
* Class for handling the client connection.
* Display toolbar with menu bar for connect or disconnect to pvs manager and
* show current connection status.
* For connecting with manager, user is able to set sessionName. If connection works
* correctly flashy green checkmark is shown.
*/
class ConnectWindow : public QWidget
{
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:
Ui::ConnectWindow *_ui;
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:
explicit 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);
void showEvent(QShowEvent* event);
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
|