• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

krdc

  • sources
  • kde-4.12
  • kdenetwork
  • krdc
  • vnc
vncclientthread.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007 - 2013 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.
11 **
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.
16 **
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.
21 **
22 ****************************************************************************/
23 
24 #ifndef VNCCLIENTTHREAD_H
25 #define VNCCLIENTTHREAD_H
26 
27 #ifdef QTONLY
28  #include <QDebug>
29  #define kDebug(n) qDebug()
30  #define kError(n) qDebug()
31  #define kBacktrace() ""
32  #define i18n tr
33 #else
34  #include <KDebug>
35  #include <KLocale>
36 #endif
37 
38 #include "remoteview.h"
39 
40 #include <QQueue>
41 #include <QThread>
42 #include <QImage>
43 #include <QMutex>
44 
45 extern "C" {
46 #include <rfb/rfbclient.h>
47 }
48 
49 class ClientEvent
50 {
51 public:
52  virtual ~ClientEvent();
53 
54  virtual void fire(rfbClient*) = 0;
55 };
56 
57 class KeyClientEvent : public ClientEvent
58 {
59 public:
60  KeyClientEvent(int key, int pressed)
61  : m_key(key), m_pressed(pressed) {}
62 
63  void fire(rfbClient*);
64 
65 private:
66  int m_key;
67  int m_pressed;
68 };
69 
70 class PointerClientEvent : public ClientEvent
71 {
72 public:
73  PointerClientEvent(int x, int y, int buttonMask)
74  : m_x(x), m_y(y), m_buttonMask(buttonMask) {}
75 
76  void fire(rfbClient*);
77 
78 private:
79  int m_x;
80  int m_y;
81  int m_buttonMask;
82 };
83 
84 class ClientCutEvent : public ClientEvent
85 {
86 public:
87  explicit ClientCutEvent(const QString &text)
88  : text(text) {}
89 
90  void fire(rfbClient*);
91 
92 private:
93  QString text;
94 };
95 
96 class VncClientThread: public QThread
97 {
98  Q_OBJECT
99 
100 public:
101  Q_ENUMS(ColorDepth)
102 
103  enum ColorDepth {
104  bpp32,
105  bpp16,
106  bpp8
107  };
108 
109  explicit VncClientThread(QObject *parent = 0);
110  ~VncClientThread();
111  const QImage image(int x = 0, int y = 0, int w = 0, int h = 0);
112  void setImage(const QImage &img);
113  void emitUpdated(int x, int y, int w, int h);
114  void emitGotCut(const QString &text);
115  void stop();
116  void setHost(const QString &host);
117  void setPort(int port);
118  void setQuality(RemoteView::Quality quality);
119  void setPassword(const QString &password) {
120  m_password = password;
121  }
122  const QString password() const {
123  return m_password;
124  }
125  void setUsername(const QString &username) {
126  m_username = username;
127  }
128  const QString username() const {
129  return m_username;
130  }
131 
132  RemoteView::Quality quality() const;
133  ColorDepth colorDepth() const;
134  uint8_t *frameBuffer;
135 
136 signals:
137  void imageUpdated(int x, int y, int w, int h);
138  void gotCut(const QString &text);
139  void passwordRequest(bool includingUsername = false);
140  void outputErrorMessage(const QString &message);
141 
148  void clientStateChanged(RemoteView::RemoteStatus status, const QString &details);
149 
150 public slots:
151  void mouseEvent(int x, int y, int buttonMask);
152  void keyEvent(int key, bool pressed);
153  void clientCut(const QString &text);
154 
155 protected:
156  void run();
157 
158 private:
159  void setClientColorDepth(rfbClient *cl, ColorDepth cd);
160  void setColorDepth(ColorDepth colorDepth);
161 
162  // These static methods are callback functions for libvncclient. Each
163  // of them calls back into the corresponding member function via some
164  // TLS-based logic.
165  static rfbBool newclientStatic(rfbClient *cl);
166  static void updatefbStatic(rfbClient *cl, int x, int y, int w, int h);
167  static void cuttextStatic(rfbClient *cl, const char *text, int textlen);
168  static char *passwdHandlerStatic(rfbClient *cl);
169  static rfbCredential *credentialHandlerStatic(rfbClient *cl, int credentialType);
170  static void outputHandlerStatic(const char *format, ...);
171 
172  // Member functions corresponding to the above static methods.
173  rfbBool newclient();
174  void updatefb(int x, int y, int w, int h);
175  void cuttext(const char *text, int textlen);
176  char *passwdHandler();
177  rfbCredential *credentialHandler(int credentialType);
178  void outputHandler(const char *format, ...);
179 
180  QImage m_image;
181  rfbClient *cl;
182  QString m_host;
183  QString m_password;
184  QString m_username;
185  int m_port;
186  QMutex mutex;
187  RemoteView::Quality m_quality;
188  ColorDepth m_colorDepth;
189  QQueue<ClientEvent* > m_eventQueue;
190  //color table for 8bit indexed colors
191  QVector<QRgb> m_colorTable;
192  QString outputErrorMessageString;
193 
194  volatile bool m_stopped;
195  volatile bool m_passwordError;
196 
200  struct {
205  int intervalSeconds;
209  int failedProbes;
213  bool set;
217  volatile bool failed;
218  } m_keepalive;
219 
220  // Initialise the VNC client library object.
221  bool clientCreate(bool reinitialising);
222 
223  // Uninitialise the VNC client library object.
224  void clientDestroy();
225 
226  // Turn on keepalive support.
227  void clientSetKeepalive();
228 
229  // Record a state change.
230  void clientStateChange(RemoteView::RemoteStatus status, const QString &details);
231  QString m_previousDetails;
232 
233 private slots:
234  void checkOutputErrorMessage();
235 };
236 
237 #endif
VncClientThread::bpp8
Definition: vncclientthread.h:106
VncClientThread::mouseEvent
void mouseEvent(int x, int y, int buttonMask)
Definition: vncclientthread.cpp:658
RemoteView::Quality
Quality
Definition: remoteview.h:67
RemoteView::RemoteStatus
RemoteStatus
State of the connection.
Definition: remoteview.h:108
VncClientThread::bpp32
Definition: vncclientthread.h:104
VncClientThread::setQuality
void setQuality(RemoteView::Quality quality)
Definition: vncclientthread.cpp:387
VncClientThread::password
const QString password() const
Definition: vncclientthread.h:122
PointerClientEvent::fire
void fire(rfbClient *)
Definition: vncclientthread.cpp:643
VncClientThread::colorDepth
ColorDepth colorDepth() const
Definition: vncclientthread.cpp:414
VncClientThread::setUsername
void setUsername(const QString &username)
Definition: vncclientthread.h:125
VncClientThread::clientStateChanged
void clientStateChanged(RemoteView::RemoteStatus status, const QString &details)
When we connect/disconnect/reconnect/etc., this signal will be emitted.
ClientCutEvent::fire
void fire(rfbClient *)
Definition: vncclientthread.cpp:653
VncClientThread::keyEvent
void keyEvent(int key, bool pressed)
Definition: vncclientthread.cpp:667
KeyClientEvent::KeyClientEvent
KeyClientEvent(int key, int pressed)
Definition: vncclientthread.h:60
QObject
VncClientThread::quality
RemoteView::Quality quality() const
Definition: vncclientthread.cpp:409
ClientEvent::~ClientEvent
virtual ~ClientEvent()
Definition: vncclientthread.cpp:639
VncClientThread::gotCut
void gotCut(const QString &text)
ClientCutEvent::ClientCutEvent
ClientCutEvent(const QString &text)
Definition: vncclientthread.h:87
ClientCutEvent
Definition: vncclientthread.h:84
VncClientThread::imageUpdated
void imageUpdated(int x, int y, int w, int h)
VncClientThread::passwordRequest
void passwordRequest(bool includingUsername=false)
VncClientThread::run
void run()
Definition: vncclientthread.cpp:451
ClientEvent
Definition: vncclientthread.h:49
PointerClientEvent
Definition: vncclientthread.h:70
VncClientThread::emitGotCut
void emitGotCut(const QString &text)
Definition: vncclientthread.cpp:440
VncClientThread::outputErrorMessage
void outputErrorMessage(const QString &message)
VncClientThread::failed
volatile bool failed
Did keepalive detect a disconnect?
Definition: vncclientthread.h:217
VncClientThread::username
const QString username() const
Definition: vncclientthread.h:128
VncClientThread::set
bool set
Was keepalive successfully set?
Definition: vncclientthread.h:213
VncClientThread::ColorDepth
ColorDepth
Definition: vncclientthread.h:103
VncClientThread::setHost
void setHost(const QString &host)
Definition: vncclientthread.cpp:375
VncClientThread::image
const QImage image(int x=0, int y=0, int w=0, int h=0)
Definition: vncclientthread.cpp:425
VncClientThread::VncClientThread
VncClientThread(QObject *parent=0)
Definition: vncclientthread.cpp:326
VncClientThread::setPassword
void setPassword(const QString &password)
Definition: vncclientthread.h:119
VncClientThread::failedProbes
int failedProbes
Number of failed probes required to recognise a disconnect.
Definition: vncclientthread.h:209
VncClientThread::emitUpdated
void emitUpdated(int x, int y, int w, int h)
Definition: vncclientthread.cpp:435
VncClientThread::clientCut
void clientCut(const QString &text)
Definition: vncclientthread.cpp:676
VncClientThread::setPort
void setPort(int port)
Definition: vncclientthread.cpp:381
VncClientThread::intervalSeconds
int intervalSeconds
Number of seconds between probes.
Definition: vncclientthread.h:205
VncClientThread::stop
void stop()
Definition: vncclientthread.cpp:445
remoteview.h
VncClientThread::frameBuffer
uint8_t * frameBuffer
Definition: vncclientthread.h:134
VncClientThread
Definition: vncclientthread.h:96
VncClientThread::setImage
void setImage(const QImage &img)
Definition: vncclientthread.cpp:419
VncClientThread::~VncClientThread
~VncClientThread()
Definition: vncclientthread.cpp:349
ClientEvent::fire
virtual void fire(rfbClient *)=0
QThread
KeyClientEvent
Definition: vncclientthread.h:57
VncClientThread::bpp16
Definition: vncclientthread.h:105
KeyClientEvent::fire
void fire(rfbClient *)
Definition: vncclientthread.cpp:648
PointerClientEvent::PointerClientEvent
PointerClientEvent(int x, int y, int buttonMask)
Definition: vncclientthread.h:73
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:04 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

krdc

Skip menu "krdc"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal