Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
vncthread.h
Go to the documentation of this file.
1 /*
2  # Copyright (c) 2009, 2010 - OpenSLX Project, Computer Center University of
3  # Freiburg
4  #
5  # This program is free software distributed under the GPL version 2.
6  # See http://openslx.org/COPYING
7  #
8  # If you have any feedback please consult http://openslx.org/feedback and
9  # send your suggestions, praise, or complaints to feedback@openslx.org
10  #
11  # General information about OpenSLX can be found at http://openslx.org/
12  */
13 
14 #ifndef VNCCLIENTTHREAD_H_
15 #define VNCCLIENTTHREAD_H_
16 
17 #include <QtCore>
18 #include <QImage>
19 #include <QThread>
20 #include <QSharedPointer>
21 
22 class QPainter;
23 
24 extern "C"
25 {
26 #include <rfb/rfbclient.h>
27 }
28 
36 class VncThread : public QThread
37 {
38  Q_OBJECT
39 
40 private:
41  rfbClient *_client{};
42 
43  QString _host;
44  int _port;
45  QString _passwd;
46  int _quality;
47 
48  QSharedPointer<QImage> _img;
49 
50  volatile bool _connected{};
51  volatile bool _run;
52  bool _started;
53 
54  void calcScaling();
55  void processImageUpdate(int x, int y, int w, int h);
56  void emitStarted();
57 
58  // Callbacks for rfb lib. make them class members so the callbacks can access private members of the class.
59 
60  static void updateImage(rfbClient *client, int x, int y, int w, int h);
61  static char* passwdHandler(rfbClient *client);
62  static rfbBool frameBufferHandler(rfbClient *client);
63 
64 public:
65  VncThread(QString host, int port, QString passwd, int quality);
66  ~VncThread() override;
67 
68  QString getDesktopName() const;
69  bool isConnected() const { return _connected; }
70  void stop() { _run = false; }
71  const QSharedPointer<QImage>& getFrameBuffer() { return _img; }
72  void run() override;
73 
74  int const static HIGH = 0;
75  int const static MEDIUM = 1;
76  int const static LOW = 2;
77 
78 signals:
79  void imageUpdated(const int x, const int y, const int w, const int h);
80  void projectionStarted();
81  void projectionStopped();
82 
83 };
84 
85 #endif /* VNCCLIENTTHREAD_H_ */
QString _passwd
Definition: vncthread.h:45
VncThread(QString host, int port, QString passwd, int quality)
Initialize this VNC client connection worker thread.
Definition: vncthread.cpp:34
void run() override
Worker thread's mainloop, connecting to the VNC server and handling the connection.
Definition: vncthread.cpp:71
void projectionStopped()
int static const MEDIUM
Definition: vncthread.h:75
void emitStarted()
Definition: vncthread.cpp:161
const QSharedPointer< QImage > & getFrameBuffer()
Definition: vncthread.h:71
~VncThread() override
Definition: vncthread.cpp:46
QString getDesktopName() const
Get name of the VNC server's desktop.
Definition: vncthread.cpp:139
void projectionStarted()
QString _host
Definition: vncthread.h:43
int _quality
Definition: vncthread.h:46
void processImageUpdate(int x, int y, int w, int h)
Handle update of an area of the VNC framebuffer.
Definition: vncthread.cpp:156
VncThread - communicate with VNC server, scale image if necessary.
Definition: vncthread.h:36
bool _started
Definition: vncthread.h:52
static char * passwdHandler(rfbClient *client)
Callback for the vnc client lib: The VNC server is requesting a password.
Definition: vncthread.cpp:175
volatile bool _run
Definition: vncthread.h:51
void imageUpdated(const int x, const int y, const int w, const int h)
int static const HIGH
Definition: vncthread.h:74
bool isConnected() const
Definition: vncthread.h:69
void calcScaling()
void stop()
Definition: vncthread.h:70
rfbClient * _client
Definition: vncthread.h:41
volatile bool _connected
Definition: vncthread.h:50
int _port
Definition: vncthread.h:44
int static const LOW
Definition: vncthread.h:76
QSharedPointer< QImage > _img
Definition: vncthread.h:48
static rfbBool frameBufferHandler(rfbClient *client)
Callback for the vnc client lib: The size of the remote screen has been changed, so we're supposed to...
Definition: vncthread.cpp:188
static void updateImage(rfbClient *client, int x, int y, int w, int h)
Callback for the vnc client lib: A part of the frame buffer has changed.
Definition: vncthread.cpp:263