1 /****************************************************************************
3 ** Copyright (C) 2007-2008 Urs Wolfer <uwolfer @ kde.org>
5 ** This file is part of KDE.
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
29 #define kDebug(n) qDebug()
30 #define kBacktrace() ""
37 #include "remoteview.h"
45 #include <rfb/rfbclient.h>
51 virtual ~ClientEvent();
53 virtual void fire(rfbClient*) = 0;
56 class KeyClientEvent : public ClientEvent
59 KeyClientEvent(int key, int pressed)
60 : m_key(key), m_pressed(pressed) {}
62 void fire(rfbClient*);
69 class PointerClientEvent : public ClientEvent
72 PointerClientEvent(int x, int y, int buttonMask)
73 : m_x(x), m_y(y), m_buttonMask(buttonMask) {}
75 void fire(rfbClient*);
83 class ClientCutEvent : public ClientEvent
86 ClientCutEvent(const QString &text)
89 void fire(rfbClient*);
95 class VncClientThread: public QThread
100 explicit VncClientThread(QObject *parent = 0);
102 const QImage image(int x = 0, int y = 0, int w = 0, int h = 0);
103 void setImage(const QImage &img);
104 void emitUpdated(int x, int y, int w, int h);
105 void emitGotCut(const QString &text);
107 void setHost(const QString &host);
108 void setPort(int port);
109 void setListenPort(int port) { m_listen_port = port; }
110 void setQuality(RemoteView::Quality quality);
111 void setPassword(const QString &password);
112 const QString password() const { return m_password; }
113 RemoteView::Quality quality() const;
116 void imageUpdated(int x, int y, int w, int h);
117 void gotCut(const QString &text);
118 void passwordRequest();
119 void outputErrorMessage(const QString &message);
122 void mouseEvent(int x, int y, int buttonMask);
123 void keyEvent(int key, bool pressed);
124 void clientCut(const QString &text);
130 void checkOutputErrorMessage();
133 //callbacks for libvncclient
134 static rfbBool newclient(rfbClient *cl);
135 static void updatefb(rfbClient *cl, int x, int y, int w, int h);
136 static void cuttext(rfbClient *cl, const char *text, int textlen);
137 static char* passwdHandler(rfbClient *cl);
138 static void outputHandler(const char *format, ...);
140 uint8_t *m_frameBuffer;
145 int m_port, m_listen_port;
147 RemoteView::Quality m_quality;
148 QQueue<ClientEvent* > m_eventQueue;
150 volatile bool m_stopped;
151 volatile bool m_passwordError;