From 1a5709501f94014d41987b956338bb6424b9f90c Mon Sep 17 00:00:00 2001 From: sr Date: Mon, 4 Feb 2013 19:50:31 +0100 Subject: Initial commit --- src/client/net/serverconnection.h | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/client/net/serverconnection.h (limited to 'src/client/net/serverconnection.h') diff --git a/src/client/net/serverconnection.h b/src/client/net/serverconnection.h new file mode 100644 index 0000000..afb8204 --- /dev/null +++ b/src/client/net/serverconnection.h @@ -0,0 +1,62 @@ +#ifndef _PVSSERVERCONNECTION_H_ +#define _PVSSERVERCONNECTION_H_ + +#include +#include "../../shared/networkmessage.h" +#include "../connectwindow/connectwindow.h" + +class BlankScreen; + +class ServerConnection : public QObject +{ +Q_OBJECT + +private: + QSslSocket *_socket; + BlankScreen *_blank; + int _timerId; + int _jpegQuality; + int _authed; + + NetworkMessage _fromServer, _toServer; + QByteArray _expectedFingerprint; + QString _passwd; + QByteArray _myChallenge; + QByteArray _sessionName; + QByteArray _certHash; + + void handleMsg(); + +public: + ServerConnection(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash); + void disconnectFromServer(); + ~ServerConnection(); + const inline bool isConnected() const + { + return _socket != NULL && _socket->state() == QAbstractSocket::ConnectedState; + } + + void sendMessage(NetworkMessage& message); + +protected: + void timerEvent(QTimerEvent *event); + +private slots: + void sslErrors(const QList & errors); // triggered for errors that occur during SSL negotiation + void sock_dataArrival(); // triggered if data is available for reading + void sock_closed(); // triggered if the socket is closed + void sock_error(QAbstractSocket::SocketError errcode); // triggered if an error occurs on the socket + void sock_connected(); // triggered if the connection is established and ready to use + + void onVncServerStartStop(int port, QString& ropass, QString& rwpass); // triggered if the local vnc server was started + + void onVncViewerStartStop(const bool started, const int clientId); + +signals: + void openVnc(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId); + void closeVnc(); + void stateChange(ConnectWindow::ConnectionState state); + +}; + +#endif -- cgit v1.2.3-55-g7522