API Documentation
Loading...
Searching...
No Matches
VncClientWidget.h
Go to the documentation of this file.
1#pragma once
2#include "VNCInterface/Headers/VncDefines.h"
4#include <NDEVR/Device.h>
7#include "Base/Headers/Time.h"
8#include <QWidget>
9#include <QtWidgets>
10#include <QtNetwork>
11#include <QRegion>
12#include <QKeyEvent>
13namespace NDEVR
14{
15 class TcpServer;
16 struct VncScreen
17 {
19 QRect rect;
21 };
22 class VncClientWidget;
23 class VncDevice : public Device
24 {
25 Q_OBJECT
26 public:
27 explicit VncDevice(VncClientWidget* parent);
29 void update() override;
30 [[nodiscard]] virtual TimeSpan updateInterval() const override;
31 bool connectToVncServer(const String& ip, const String& password, int port = 5900);
36
37
38 bool postEvent(QEvent* event);
39 void postKeyEvent(QKeyEvent* event, bool is_down);
40
41 protected:
42 void waitToRead(uint04 size) const;
43 bool sendCommand(const char* const command, uint04 min_response_size, uint04 retry_count);
44
46 void sendContinuousUpdateRequest(bool enable);
47 void sendUpdateFrameBufferRequest(bool force_refresh_all);
48 void sendRequestDesktopSize(QSize size, fltp08 scale_factor = 1.0);
49 void sendMouseEvent(const MouseEvent& event);
50 void sendKeyEvent(bool is_pressed, QKeyEvent* event);
51 void sendKeyEvent(bool is_pressed, const KeyEvent& event);
52 bool setupVncConnection(const String& password);
54
55 QByteArray desHash(QByteArray challenge, QString passStr);
56 uint02 makeU16(quint8 l, quint8 h);
57 uint04 makeU32(quint16 l, quint16 h);
58 uint04 makeU32(quint8 lowest, quint8 low, quint8 high, quint8 highest);
59 static quint32 TranslateRfbKey(int key, bool modifier);
61 void setFrameBufferSize(const QSize& size);
62 private slots:
63 void onServerMessage();
64 protected:
65 NDEVRMouseManager m_mouse_manager;
67 QTcpSocket* m_socket;
74 PixelFormat m_pixel_format;
79 int m_port;
80
83 bool m_setup_connection = false;
90 bool m_is_ready = false;
91
92 };
93 class VncClientWidget : public QWidget
94 {
95 static constexpr uint01 s_screen_count = 2;
96 Q_OBJECT
97 public:
98 explicit VncClientWidget(QWidget* parent = 0);
100 void mousePressEvent(QMouseEvent* event) override;
101 bool connectToVncServer(const String& ip, const String& password, int port = 5900);
104 void tryRefreshScreen(bool force_refresh_all);
105 void setResizeTcpServer(TcpServer* server, fltp08 size_multiplier);
106 void setMouse(const Vector<2, uint04>& hotspot, QImage mouse);
107 QImage* imageToRender();
109 void commit(const QRegion& region);
110 protected:
111 bool event(QEvent* event) override;
112 void paintEvent(QPaintEvent*) override;
113 void keyPressEvent(QKeyEvent* event) override;
114 void keyReleaseEvent(QKeyEvent* event) override;
115 void resizeEvent(QResizeEvent* event) override;
116 private:
117 VncDevice* m_device;
118 TcpServer* m_tcp_server;
119 fltp08 m_size_multiplier;
120 QImage m_screen_buffer[s_screen_count];
121 uint01 m_screen_index = 0;
122 bool m_is_painting;
123 };
124}
125
126
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A root class which describes some physical object, such as a Motor, Sensor, or Connection....
Definition Device.h:52
A class which describes a user key press.
Definition Event.h:49
Vector< 3, fltp08 > size() const
Definition Event.h:295
The core String class for the NDEVR API.
Definition String.h:69
A TcpServer allows the software to recieve socket connections from external sources.
Definition TcpServer.h:17
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
Definition VncClientWidget.h:94
void setMouse(const Vector< 2, uint04 > &hotspot, QImage mouse)
void keyReleaseEvent(QKeyEvent *event) override
void paintEvent(QPaintEvent *) override
void tryRefreshScreen(bool force_refresh_all)
bool event(QEvent *event) override
void setResizeTcpServer(TcpServer *server, fltp08 size_multiplier)
void keyPressEvent(QKeyEvent *event) override
void mousePressEvent(QMouseEvent *event) override
void commit(const QRegion &region)
void resizeEvent(QResizeEvent *event) override
VncClientWidget(QWidget *parent=0)
bool connectToVncServer(const String &ip, const String &password, int port=5900)
Definition VncClientWidget.h:24
Buffer< VncScreen > m_screens
Definition VncClientWidget.h:73
void readFrameBufferMessage()
uint04 makeU32(quint16 l, quint16 h)
void sendKeyEvent(bool is_pressed, QKeyEvent *event)
bool m_supports_continuous_updates
Definition VncClientWidget.h:86
void sendMouseEvent(const MouseEvent &event)
fltp04 m_jpg_quality
Definition VncClientWidget.h:81
PixelFormat m_pixel_format
Definition VncClientWidget.h:74
void sendRequestDesktopSize(QSize size, fltp08 scale_factor=1.0)
Time m_last_full_refresh_time
Definition VncClientWidget.h:69
Buffer< bool > m_key_down_events
Definition VncClientWidget.h:76
void update() override
String m_connection
Definition VncClientWidget.h:72
bool m_is_ready
Definition VncClientWidget.h:90
Buffer< KeyEvent > m_key_events
Definition VncClientWidget.h:75
QByteArray desHash(QByteArray challenge, QString passStr)
BitFlag m_mouse_button_flag
Definition VncClientWidget.h:77
VncDevice(VncClientWidget *parent)
void disconnectFromVncServer()
int m_port
Definition VncClientWidget.h:79
uint04 makeU32(quint8 lowest, quint8 low, quint8 high, quint8 highest)
void waitToRead(uint04 size) const
void sendUpdateFrameBufferRequest(bool force_refresh_all)
void sendContinuousUpdateRequest(bool enable)
QSize m_frame_size
Definition VncClientWidget.h:68
void requestFullRefresh()
bool m_has_sent_frame_request
Definition VncClientWidget.h:82
bool postEvent(QEvent *event)
QImage m_copy_image
Definition VncClientWidget.h:78
bool m_request_full_refresh
Definition VncClientWidget.h:84
static quint32 TranslateRfbKey(int key, bool modifier)
bool m_supports_extended_size
Definition VncClientWidget.h:87
void postKeyEvent(QKeyEvent *event, bool is_down)
bool m_setup_connection
Definition VncClientWidget.h:83
bool m_request_disconnect
Definition VncClientWidget.h:88
Time m_last_refresh_time
Definition VncClientWidget.h:70
void setFrameBufferSize(const QSize &size)
bool sendCommand(const char *const command, uint04 min_response_size, uint04 retry_count)
bool m_is_continuous_mode
Definition VncClientWidget.h:85
VncClientWidget * m_widget
Definition VncClientWidget.h:66
bool isConnectedToServer()
void sendKeyEvent(bool is_pressed, const KeyEvent &event)
bool connectToVncServer()
QTcpSocket * m_socket
Definition VncClientWidget.h:67
NDEVRMouseManager m_mouse_manager
Definition VncClientWidget.h:65
uint02 makeU16(quint8 l, quint8 h)
String m_password
Definition VncClientWidget.h:71
bool setupVncConnection(const String &password)
bool m_request_client_resize
Definition VncClientWidget.h:89
bool connectToVncServer(const String &ip, const String &password, int port=5900)
virtual TimeSpan updateInterval() const override
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:88
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Definition VncClientWidget.h:17
uint04 id
Definition VncClientWidget.h:18
QRect rect
Definition VncClientWidget.h:19
uint04 flags
Definition VncClientWidget.h:20