1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*
# Copyright (c) 2009, 2010 - 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/
*/
#ifndef VNCCLIENTTHREAD_H_
#define VNCCLIENTTHREAD_H_
#include <QtCore>
#include <QtGui/QImage>
extern "C"
{
#include <rfb/rfbclient.h>
}
class SomeEvent
{
public:
virtual ~SomeEvent();
virtual void fire(rfbClient*) = 0;
};
class KeyEvent : public SomeEvent
{
public:
KeyEvent(int key, int pressed)
: _key(key), _pressed(pressed) {}
void fire(rfbClient*);
private:
int _key;
int _pressed;
};
class PointerEvent : public SomeEvent
{
public:
PointerEvent(int x, int y, int buttonMask)
: _x(x), _y(y), _buttonMask(buttonMask) {}
void fire(rfbClient*);
private:
int _x;
int _y;
int _buttonMask;
};
class VNCClientThread: public QThread
{
Q_OBJECT
public:
VNCClientThread(QString host, int port, QString passwd, int quality, int updatefreq = 0);
~VNCClientThread();
void run();
QImage getImage();
QSize getSize();
int getUpdatefreq();
void setUpdatefreq(int updatefreq);
QString getDesktopName();
void mouseEvent(int x, int y, int buttonMask);
void keyEvent(int key, bool pressed);
bool isConnected()
{
return _connected;
}
static void updateImage(rfbClient *client, int x, int y, int w, int h);
static char* passwdHandler(rfbClient *client);
static rfbBool frameBufferHandler(rfbClient *client);
//rfbClient* getRfbClient();
bool terminate;
int const static HIGH = 0;
int const static MEDIUM = 1;
int const static LOW = 2;
Q_SIGNALS:
void imageUpdated(int x, int y, int w, int h);
private:
rfbClient *_client;
uint8_t *_frameBuffer;
QString _host;
int _port;
QString _passwd;
int _quality;
int _updatefreq;
QQueue<SomeEvent* > _eventQueue;
QImage _img;
QSize _clientSize;
bool _connected;
};
#endif /* VNCCLIENTTHREAD_H_ */
|