Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
Connection.h
1// Author: Kang Lin <kl222@126.com>
2
3#ifndef CCONNECTION_H
4#define CCONNECTION_H
5
6#include "rfb/SConnection.h"
7#include "rfb/EncodeManager.h"
8#include "rfb/UpdateTracker.h"
9
10#include <QImage>
11#include <QRect>
12
13#include "Channel.h"
14#include "../../RabbitVNC/InStreamChannel.h"
15#include "../../RabbitVNC/OutStreamChannel.h"
16#include "ServiceTigerVNC.h"
17#include "ParameterServiceTigerVNC.h"
18#include "InputDevice.h"
19#include "Screen.h"
20
21class CConnection : public QObject, public rfb::SConnection
22{
23 Q_OBJECT
24
25public:
26 explicit CConnection(QSharedPointer<CChannel> channel, CParameterServiceTigerVNC* pPara);
27 virtual ~CConnection();
28
29 // SConnection interface
30public:
31 virtual void queryConnection(const char *userName) override;
32 virtual void authSuccess() override;
33
34 // SMsgHandler interface
35 virtual void clientInit(bool shared) override;
36 virtual void setDesktopSize(int fb_width, int fb_height, const rfb::ScreenSet &layout) override;
37 virtual void setPixelFormat(const rfb::PixelFormat &pf) override;
38 virtual void framebufferUpdateRequest(const rfb::Rect &r, bool incremental) override;
39 virtual void fence(rdr::U32 flags, unsigned len, const char data[]) override;
40 virtual void enableContinuousUpdates(bool enable, int x, int y, int w, int h) override;
41
42 // InputHandler interface
43 virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down) override;
44 virtual void pointerEvent(const rfb::Point& pos, int buttonMask) override;
45 virtual void clientCutText(const char* str) override;
46
47Q_SIGNALS:
48 void sigDisconnected();
49 void sigError(int nErr, const QString& szErr);
50
51private:
52 QSharedPointer<rfb::PixelBuffer> GetBufferFromQImage(QImage &img);
53 void writeNoDataUpdate();
54 void writeDataUpdate(QImage img, QRect rect);
55
56private Q_SLOTS:
57 void slotConnected();
58 void slotReadyRead();
59 void slotDisconnected();
60 void slotError(int nRet, const QString &szErr);
61 void slotDesktopUpdate(QImage img, QRect rect);
62
63private:
64 QSharedPointer<CChannel> m_Channel;
65 QSharedPointer<rdr::InStream> m_InStream;
66 QSharedPointer<rdr::OutStream> m_OutStream;
68 QSharedPointer<CInputDevice> m_InputDevice;
69
70 rfb::PixelFormat m_PixelFormat;
71
72 bool inProcessMessages;
73
74 bool pendingSyncFence, syncFence;
75 rdr::U32 fenceFlags;
76 unsigned fenceDataLen;
77 char *fenceData;
78
79 rfb::EncodeManager m_EncodeManager;
80 rfb::SimpleUpdateTracker m_Updates;
81 rfb::Region requested;
82 bool continuousUpdates;
83 rfb::Region cuRegion;
84
85};
86
87#endif // CCONNECTION_H