SVN_SILENT
[kdenetwork.git] / krdc / vnc / vncclientthread.h
blob3c3b338f43af54f5def7065bba49295b1181263d
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
4 **
5 ** This file is part of KDE.
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; see the file COPYING. If not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ** Boston, MA 02110-1301, USA.
22 ****************************************************************************/
24 #ifndef VNCCLIENTTHREAD_H
25 #define VNCCLIENTTHREAD_H
27 #include "remoteview.h"
29 #include <QQueue>
30 #include <QThread>
31 #include <QImage>
32 #include <QMutex>
34 extern "C" {
35 #include <rfb/rfbclient.h>
38 class ClientEvent
40 public:
41 virtual ~ClientEvent();
43 virtual void fire(rfbClient*) = 0;
46 class KeyClientEvent : public ClientEvent
48 public:
49 KeyClientEvent(int key, int pressed)
50 : m_key(key), m_pressed(pressed) {}
52 void fire(rfbClient*);
54 private:
55 int m_key;
56 int m_pressed;
59 class PointerClientEvent : public ClientEvent
61 public:
62 PointerClientEvent(int x, int y, int buttonMask)
63 : m_x(x), m_y(y), m_buttonMask(buttonMask) {}
65 void fire(rfbClient*);
67 private:
68 int m_x;
69 int m_y;
70 int m_buttonMask;
73 class ClientCutEvent : public ClientEvent
75 public:
76 ClientCutEvent(char *text)
77 : text(text) {}
79 void fire(rfbClient*);
81 private:
82 char *text;
85 class VncClientThread: public QThread
87 Q_OBJECT
89 public:
90 explicit VncClientThread();
91 ~VncClientThread();
92 const QImage image(int x = 0, int y = 0, int w = 0, int h = 0);
93 void setImage(const QImage &img);
94 void emitUpdated(int x, int y, int w, int h);
95 void emitGotCut(const QString &text);
96 void stop();
97 void setHost(const QString &host);
98 void setPort(int port);
99 void setQuality(RemoteView::Quality quality);
100 void setPassword(const QString &password) {
101 m_password = password;
103 const QString password() const {
104 return m_password;
107 RemoteView::Quality quality() const;
109 signals:
110 void imageUpdated(int x, int y, int w, int h);
111 void gotCut(const QString &text);
112 void passwordRequest();
113 void outputErrorMessage(const QString &message);
115 public slots:
116 void mouseEvent(int x, int y, int buttonMask);
117 void keyEvent(int key, bool pressed);
118 void clientCut(const QString &text);
120 protected:
121 void run();
123 private:
124 static char* passwdHandler(rfbClient *cl);
125 static void outputHandler(const char *format, ...);
127 QImage m_image;
128 rfbClient *cl;
129 QString m_host;
130 QString m_password;
131 int m_port;
132 QMutex mutex;
133 RemoteView::Quality m_quality;
134 QQueue<ClientEvent* > m_eventQueue;
136 volatile bool m_stopped;
137 volatile bool m_passwordError;
139 private slots:
140 void checkOutputErrorMessage();
143 #endif