Files
qt5-legatus-legacy/Lts/Plugins/ProjectionWorkstation/Common/pws_vnc_handler.h
T
2026-08-13 18:33:10 +02:00

71 lines
2.0 KiB
C++
Executable File

/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "pws_rfb_protocol.h"
#include <QObject>
#include <QTcpSocket>
#include <QDataStream>
#include <QHostAddress>
#include <Plugins/ProjectionWorkstation/Common/pwscommon_export.h>
#include <LtsProjectionWorkstation/logger.h>
namespace ProjectionWorkstation
{
class PWSCOMMON_EXPORT VncHandler : public QObject
{
Q_OBJECT
public:
VncHandler(const QHostAddress &host, quint16 port, QObject *parent = nullptr);
void setNextExpectedMessageType(RfbProtocol::STC::Type type) { m_nextType = type; }
void connectToHost();
void connectToHost(const QHostAddress &host, quint16 port);
void writeData(const QByteArray &data);
signals:
void connected();
void disconnected();
void frameBufferUpdateReceived(const QVector<RfbProtocol::RfbRectangle> &rectangles);
void beepReceived();
void cutTextReceived(const QString &txt);
private slots:
void onReadyRead();
void slotOnDisconnected();
void error();
private:
bool handleData(QDataStream &stream);
bool handleFrameBufferUpdate(QDataStream &stream);
bool handleSetColormap(QDataStream &stream);
bool handleRingBell(QDataStream &stream);
bool handleServerCuttext(QDataStream &stream);
void resetHandler();
bool handleVersion(const RfbProtocol::STC::RfbVersion &version);
bool handleSupportedSecurityTypes(const RfbProtocol::STC::RfbSupportedSecurityTypes &supportedTypes);
bool handleVncAuthentication(const RfbProtocol::STC::RfbVncAuthentication &authentication);
static quint64 convertPassword(const char *password);
static quint8 reverseByte(quint8 b);
bool handleSecurityResult(const RfbProtocol::STC::RfbSecurityResult &result);
bool handleServerInit(const RfbProtocol::STC::RfbServerInit &serverInit);
LtsProjectionWorkstation::LOGGER_T m_logger;
RfbProtocol::STC::Type m_nextType;
RfbProtocol::STC::RfbServerInit m_serverInit;
QTcpSocket *m_socket;
QByteArray m_buffer;
QHostAddress m_host;
quint16 m_port;
};
} // ProjectionWorkstation