Qt 4.8
Public Types | Public Functions | Private Types | Private Slots | Private Functions | Properties | List of all members
QVNCServer Class Reference

#include <qscreenvnc_p.h>

Inheritance diagram for QVNCServer:
QObject QObject

Public Types

enum  ClientMsg {
  SetPixelFormat = 0, FixColourMapEntries = 1, SetEncodings = 2, FramebufferUpdateRequest = 3,
  KeyEvent = 4, PointerEvent = 5, ClientCutText = 6, SetPixelFormat = 0,
  FixColourMapEntries = 1, SetEncodings = 2, FramebufferUpdateRequest = 3, KeyEvent = 4,
  PointerEvent = 5, ClientCutText = 6
}
 
enum  ClientMsg {
  SetPixelFormat = 0, FixColourMapEntries = 1, SetEncodings = 2, FramebufferUpdateRequest = 3,
  KeyEvent = 4, PointerEvent = 5, ClientCutText = 6, SetPixelFormat = 0,
  FixColourMapEntries = 1, SetEncodings = 2, FramebufferUpdateRequest = 3, KeyEvent = 4,
  PointerEvent = 5, ClientCutText = 6
}
 
enum  ServerMsg { FramebufferUpdate = 0, SetColourMapEntries = 1, FramebufferUpdate = 0, SetColourMapEntries = 1 }
 
enum  ServerMsg { FramebufferUpdate = 0, SetColourMapEntries = 1, FramebufferUpdate = 0, SetColourMapEntries = 1 }
 

Public Functions

int clientBytesPerPixel () const
 
int clientBytesPerPixel () const
 
QTcpSocketclientSocket () const
 
QTcpSocketclientSocket () const
 
void convertPixels (char *dst, const char *src, int count) const
 
void convertPixels (char *dst, const char *src, int count) const
 
QVNCDirtyMapdirtyMap () const
 
QVNCDirtyMapdirtyMap () const
 
bool doPixelConversion () const
 
bool doPixelConversion () const
 
bool hasClientCursor () const
 
bool isConnected () const
 
bool isConnected () const
 
 QVNCServer (QVNCScreen *screen)
 
 QVNCServer (QVNCScreen *screen, int id)
 
 QVNCServer (QVNCScreen *screen)
 
 QVNCServer (QVNCScreen *screen, int id)
 
QVNCScreenscreen () const
 
QVNCScreenscreen () const
 
QImage screenImage () const
 
QImagescreenImage () const
 
void setCursor (QVNCCursor *c)
 
void setDirty ()
 
void setDirty ()
 
void setDirtyCursor ()
 
void setDirtyCursor ()
 
void setRefreshRate (int rate)
 
void setRefreshRate (int rate)
 
 ~QVNCServer ()
 
 ~QVNCServer ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Types

enum  ClientState {
  Unconnected, Protocol, Init, Connected,
  Unconnected, Protocol, Init, Connected
}
 
enum  ClientState {
  Unconnected, Protocol, Init, Connected,
  Unconnected, Protocol, Init, Connected
}
 

Private Slots

void checkUpdate ()
 
void checkUpdate ()
 
void discardClient ()
 
void discardClient ()
 
void newConnection ()
 
void newConnection ()
 
void readClient ()
 
void readClient ()
 

Private Functions

void clientCutText ()
 
void clientCutText ()
 
void frameBufferUpdateRequest ()
 
void frameBufferUpdateRequest ()
 
void init (uint port)
 
void init (uint port)
 
void keyEvent ()
 
void keyEvent ()
 
bool pixelConversionNeeded () const
 
bool pixelConversionNeeded () const
 
void pointerEvent ()
 
void pointerEvent ()
 
void setEncodings ()
 
void setEncodings ()
 
void setPixelFormat ()
 
void setPixelFormat ()
 

Properties

Qt::MouseButtons buttons
 
QTcpSocketclient
 
QVNCCursorcursor
 
int cutTextPending
 
bool dirtyCursor
 
QRfbEncoderencoder
 
int encodingsPending
 
bool handleMsg
 
Qt::KeyboardModifiers keymod
 
quint8 msgType
 
bool needConversion
 
QRfbPixelFormat pixelFormat
 
QVNCClientCursorqvnc_cursor
 
QVNCScreenqvnc_screen
 
int refreshRate
 
bool sameEndian
 
QTcpServerserverSocket
 
ClientState state
 
uint supportCopyRect: 1
 
uint supportCoRRE: 1
 
uint supportCursor: 1
 
uint supportDesktopSize: 1
 
uint supportHextile: 1
 
uint supportRRE: 1
 
uint supportZRLE: 1
 
bool swapBytes
 
QTimertimer
 
bool wantUpdate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 431 of file qscreenvnc_p.h.

Enumerations

◆ ClientMsg [1/2]

Enumerator
SetPixelFormat 
FixColourMapEntries 
SetEncodings 
FramebufferUpdateRequest 
KeyEvent 
PointerEvent 
ClientCutText 
SetPixelFormat 
FixColourMapEntries 
SetEncodings 
FramebufferUpdateRequest 
KeyEvent 
PointerEvent 
ClientCutText 

Definition at line 444 of file qscreenvnc_p.h.

◆ ClientMsg [2/2]

Enumerator
SetPixelFormat 
FixColourMapEntries 
SetEncodings 
FramebufferUpdateRequest 
KeyEvent 
PointerEvent 
ClientCutText 
SetPixelFormat 
FixColourMapEntries 
SetEncodings 
FramebufferUpdateRequest 
KeyEvent 
PointerEvent 
ClientCutText 

Definition at line 450 of file qvncserver.h.

◆ ClientState [1/2]

Enumerator
Unconnected 
Protocol 
Init 
Connected 
Unconnected 
Protocol 
Init 
Connected 

Definition at line 487 of file qscreenvnc_p.h.

◆ ClientState [2/2]

Enumerator
Unconnected 
Protocol 
Init 
Connected 
Unconnected 
Protocol 
Init 
Connected 

Definition at line 494 of file qvncserver.h.

◆ ServerMsg [1/2]

Enumerator
FramebufferUpdate 
SetColourMapEntries 
FramebufferUpdate 
SetColourMapEntries 

Definition at line 452 of file qscreenvnc_p.h.

◆ ServerMsg [2/2]

Enumerator
FramebufferUpdate 
SetColourMapEntries 
FramebufferUpdate 
SetColourMapEntries 

Definition at line 458 of file qvncserver.h.

Constructors and Destructors

◆ QVNCServer() [1/4]

QVNCServer::QVNCServer ( QVNCScreen screen)

Definition at line 572 of file qscreenvnc_qws.cpp.

573  : qvnc_screen(screen)
574 {
575  init(5900);
576 }
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
void init(uint port)

◆ QVNCServer() [2/4]

QVNCServer::QVNCServer ( QVNCScreen screen,
int  id 
)

Definition at line 578 of file qscreenvnc_qws.cpp.

579  : qvnc_screen(screen)
580 {
581  init(5900 + id);
582 }
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
void init(uint port)

◆ ~QVNCServer() [1/2]

QVNCServer::~QVNCServer ( )

Definition at line 613 of file qscreenvnc_qws.cpp.

614 {
615  delete encoder;
616  encoder = 0;
617  delete client;
618  client = 0;
619 #ifndef QT_NO_QWS_CURSOR
620  delete qvnc_cursor;
621  qvnc_cursor = 0;
622 #endif
623 }
QRfbEncoder * encoder
Definition: qscreenvnc_p.h:518
QTcpSocket * client
Definition: qscreenvnc_p.h:490
QVNCClientCursor * qvnc_cursor
Definition: qscreenvnc_p.h:515

◆ QVNCServer() [3/4]

QVNCServer::QVNCServer ( QVNCScreen screen)

◆ QVNCServer() [4/4]

QVNCServer::QVNCServer ( QVNCScreen screen,
int  id 
)

◆ ~QVNCServer() [2/2]

QVNCServer::~QVNCServer ( )

Functions

◆ checkUpdate [1/2]

void QVNCServer::checkUpdate ( )
privateslot

Definition at line 2009 of file qscreenvnc_qws.cpp.

Referenced by frameBufferUpdateRequest(), init(), and QVNCDirtyMap::QVNCDirtyMap().

2010 {
2011  if (!wantUpdate)
2012  return;
2013 
2014  if (dirtyCursor) {
2015 #ifndef QT_NO_QWS_CURSOR
2017  qvnc_cursor->write();
2018 #endif
2019  dirtyCursor = false;
2020  wantUpdate = false;
2021  return;
2022  }
2023 
2024  if (dirtyMap()->numDirty > 0) {
2025  if (encoder)
2026  encoder->write();
2027  wantUpdate = false;
2028  }
2029 }
virtual void write()=0
QRfbEncoder * encoder
Definition: qscreenvnc_p.h:518
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool wantUpdate
Definition: qscreenvnc_p.h:505
bool dirtyCursor
Definition: qscreenvnc_p.h:511
void write() const
QVNCDirtyMap * dirtyMap() const
Definition: qscreenvnc_p.h:462
QVNCClientCursor * qvnc_cursor
Definition: qscreenvnc_p.h:515

◆ checkUpdate [2/2]

void QVNCServer::checkUpdate ( )
privateslot

◆ clientBytesPerPixel() [1/2]

int QVNCServer::clientBytesPerPixel ( ) const
inline

◆ clientBytesPerPixel() [2/2]

int QVNCServer::clientBytesPerPixel ( ) const
inline

Definition at line 463 of file qvncserver.h.

463  {
464  return pixelFormat.bitsPerPixel / 8;
465  }
QRfbPixelFormat pixelFormat
Definition: qscreenvnc_p.h:494

◆ clientCutText() [1/2]

void QVNCServer::clientCutText ( )
private

Definition at line 1052 of file qscreenvnc_qws.cpp.

Referenced by buttonChange(), and readClient().

1053 {
1054  QRfbClientCutText ev;
1055 
1056  if (cutTextPending == 0 && ev.read(client)) {
1057  cutTextPending = ev.length;
1058  if (!cutTextPending)
1059  handleMsg = false;
1060  }
1061 
1063  char *text = new char [cutTextPending+1];
1064  client->read(text, cutTextPending);
1065  delete [] text;
1066  cutTextPending = 0;
1067  handleMsg = false;
1068  }
1069 }
qint64 bytesAvailable() const
Returns the number of incoming bytes that are waiting to be read.
int cutTextPending
Definition: qscreenvnc_p.h:497
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Definition: qiodevice.cpp:791
bool read(QTcpSocket *s)
QTcpSocket * client
Definition: qscreenvnc_p.h:490
bool handleMsg
Definition: qscreenvnc_p.h:493
#define text
Definition: qobjectdefs.h:80

◆ clientCutText() [2/2]

void QVNCServer::clientCutText ( )
private

◆ clientSocket() [1/2]

QTcpSocket* QVNCServer::clientSocket ( ) const
inline

◆ clientSocket() [2/2]

QTcpSocket* QVNCServer::clientSocket ( ) const
inline

Definition at line 469 of file qvncserver.h.

469 { return client; }
QTcpSocket * client
Definition: qscreenvnc_p.h:490

◆ convertPixels() [1/2]

void QVNCServer::convertPixels ( char *  dst,
const char *  src,
int  count 
) const

Definition at line 1432 of file qscreenvnc_qws.cpp.

Referenced by buttonChange(), QVNCCursor::sendClientCursor(), QRfbMultiColorHextile< SRC >::setColor(), QVNCClientCursor::write(), QRfbRawEncoder::write(), QRfbSingleColorHextile< SRC >::write(), QRfbDualColorHextile< SRC >::write(), QRfbMultiColorHextile< SRC >::write(), and QRfbHextileEncoder< SRC >::write().

1433 {
1434  const int screendepth = qvnc_screen->depth();
1435  const bool isBgr = qvnc_screen->pixelType() == QScreen::BGRPixel;
1436 
1437  // cutoffs
1438 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
1439  if (!swapBytes)
1440 #endif
1441  if (sameEndian) {
1442  if (screendepth == pixelFormat.bitsPerPixel) { // memcpy cutoffs
1443 
1444  switch (screendepth) {
1445  case 32:
1446  memcpy(dst, src, count * sizeof(quint32));
1447  return;
1448  case 16:
1449  if (pixelFormat.redBits == 5
1450  && pixelFormat.greenBits == 6
1451  && pixelFormat.blueBits == 5)
1452  {
1453  memcpy(dst, src, count * sizeof(quint16));
1454  return;
1455  }
1456  }
1457  } else if (screendepth == 16 && pixelFormat.bitsPerPixel == 32) {
1458 #if defined(__i386__) // Currently fails on ARM if dst is not 4 byte aligned
1459  const quint32 *src32 = reinterpret_cast<const quint32*>(src);
1460  quint32 *dst32 = reinterpret_cast<quint32*>(dst);
1461  int count32 = count * sizeof(quint16) / sizeof(quint32);
1462  while (count32--) {
1463  const quint32 s = *src32++;
1464  quint32 result1;
1465  quint32 result2;
1466 
1467  // red
1468  result1 = ((s & 0xf8000000) | ((s & 0xe0000000) >> 5)) >> 8;
1469  result2 = ((s & 0x0000f800) | ((s & 0x0000e000) >> 5)) << 8;
1470 
1471  // green
1472  result1 |= ((s & 0x07e00000) | ((s & 0x06000000) >> 6)) >> 11;
1473  result2 |= ((s & 0x000007e0) | ((s & 0x00000600) >> 6)) << 5;
1474 
1475  // blue
1476  result1 |= ((s & 0x001f0000) | ((s & 0x001c0000) >> 5)) >> 13;
1477  result2 |= ((s & 0x0000001f) | ((s & 0x0000001c) >> 5)) << 3;
1478 
1479  *dst32++ = result2;
1480  *dst32++ = result1;
1481  }
1482  if (count & 0x1) {
1483  const quint16 *src16 = reinterpret_cast<const quint16*>(src);
1484  *dst32 = qt_conv16ToRgb(src16[count - 1]);
1485  }
1486  return;
1487 #endif
1488  }
1489  }
1490 
1491  const int bytesPerPixel = (pixelFormat.bitsPerPixel + 7) / 8;
1492 
1493 // nibble = 0;
1494 
1495  for (int i = 0; i < count; ++i) {
1496  int r, g, b;
1497 
1498  switch (screendepth) {
1499 #if 0
1500  case 4: {
1501  if (!nibble) {
1502  r = ((*src) & 0x0f) << 4;
1503  } else {
1504  r = (*src) & 0xf0;
1505  src++;
1506  }
1507  nibble = !nibble;
1508  g = b = r;
1509  break;
1510  }
1511 #endif
1512  case 8: {
1513  QRgb rgb = qvnc_screen->clut()[int(*src)];
1514  r = qRed(rgb);
1515  g = qGreen(rgb);
1516  b = qBlue(rgb);
1517  src++;
1518  break;
1519  }
1520 #ifdef QT_QWS_DEPTH_12
1521  case 12: {
1522  quint32 p = quint32(*reinterpret_cast<const qrgb444*>(src));
1523  r = qRed(p);
1524  g = qGreen(p);
1525  b = qBlue(p);
1526  src += sizeof(qrgb444);
1527  break;
1528  }
1529 #endif
1530 #ifdef QT_QWS_DEPTH_15
1531  case 15: {
1532  quint32 p = quint32(*reinterpret_cast<const qrgb555*>(src));
1533  r = qRed(p);
1534  g = qGreen(p);
1535  b = qBlue(p);
1536  src += sizeof(qrgb555);
1537  break;
1538  }
1539 #endif
1540  case 16: {
1541  quint16 p = *reinterpret_cast<const quint16*>(src);
1542 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
1543  if (swapBytes)
1544  p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8);
1545 #endif
1546  r = (p >> 11) & 0x1f;
1547  g = (p >> 5) & 0x3f;
1548  b = p & 0x1f;
1549  r <<= 3;
1550  g <<= 2;
1551  b <<= 3;
1552  src += sizeof(quint16);
1553  break;
1554  }
1555 #ifdef QT_QWS_DEPTH_18
1556  case 18: {
1557  quint32 p = quint32(*reinterpret_cast<const qrgb666*>(src));
1558  r = qRed(p);
1559  g = qGreen(p);
1560  b = qBlue(p);
1561  src += sizeof(qrgb666);
1562  break;
1563  }
1564 #endif
1565 #ifdef QT_QWS_DEPTH_24
1566  case 24: {
1567  quint32 p = quint32(*reinterpret_cast<const qrgb888*>(src));
1568  r = qRed(p);
1569  g = qGreen(p);
1570  b = qBlue(p);
1571  src += sizeof(qrgb888);
1572  break;
1573  }
1574 #endif
1575  case 32: {
1576  quint32 p = *reinterpret_cast<const quint32*>(src);
1577  r = (p >> 16) & 0xff;
1578  g = (p >> 8) & 0xff;
1579  b = p & 0xff;
1580  src += sizeof(quint32);
1581  break;
1582  }
1583  default: {
1584  r = g = b = 0;
1585  qDebug("QVNCServer: don't support %dbpp display", screendepth);
1586  return;
1587  }
1588  }
1589 
1590 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
1591  if (swapBytes ^ isBgr)
1592 #else
1593  if (isBgr)
1594 #endif
1595  qSwap(r, b);
1596 
1597  r >>= (8 - pixelFormat.redBits);
1598  g >>= (8 - pixelFormat.greenBits);
1599  b >>= (8 - pixelFormat.blueBits);
1600 
1601  int pixel = (r << pixelFormat.redShift) |
1602  (g << pixelFormat.greenShift) |
1603  (b << pixelFormat.blueShift);
1604 
1605  if (sameEndian || pixelFormat.bitsPerPixel == 8) {
1606  memcpy(dst, &pixel, bytesPerPixel); // XXX: do a simple for-loop instead?
1607  dst += bytesPerPixel;
1608  continue;
1609  }
1610 
1611 
1612  if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
1613  switch (pixelFormat.bitsPerPixel) {
1614  case 16:
1615  pixel = (((pixel & 0x0000ff00) << 8) |
1616  ((pixel & 0x000000ff) << 24));
1617  break;
1618  case 32:
1619  pixel = (((pixel & 0xff000000) >> 24) |
1620  ((pixel & 0x00ff0000) >> 8) |
1621  ((pixel & 0x0000ff00) << 8) |
1622  ((pixel & 0x000000ff) << 24));
1623  break;
1624  default:
1625  qDebug("Cannot handle %d bpp client", pixelFormat.bitsPerPixel);
1626  }
1627  } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian
1628  switch (pixelFormat.bitsPerPixel) {
1629  case 16:
1630  pixel = (((pixel & 0xff000000) >> 8) |
1631  ((pixel & 0x00ff0000) << 8));
1632  break;
1633  case 32:
1634  pixel = (((pixel & 0xff000000) >> 24) |
1635  ((pixel & 0x00ff0000) >> 8) |
1636  ((pixel & 0x0000ff00) << 8) |
1637  ((pixel & 0x000000ff) << 24));
1638  break;
1639  default:
1640  qDebug("Cannot handle %d bpp client",
1642  break;
1643  }
1644  }
1645  memcpy(dst, &pixel, bytesPerPixel); // XXX: simple for-loop instead?
1646  dst += bytesPerPixel;
1647  }
1648 }
unsigned int QRgb
Definition: qrgb.h:53
QRfbPixelFormat pixelFormat
Definition: qscreenvnc_p.h:494
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
static int bytesPerPixel(QImage::Format format)
bool swapBytes
Definition: qscreenvnc_p.h:509
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
Q_CORE_EXPORT void qDebug(const char *,...)
PixelType pixelType() const
Returns the pixel storage format of the screen.
Definition: qscreen_qws.h:231
virtual int depth() const
Reimplement in subclass to return current depth of the screen.
Definition: fb_base.h:163
unsigned short quint16
Definition: qglobal.h:936
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
QRgb qt_conv16ToRgb(ushort c)
Definition: qscreen_qws.h:104
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
#define rgb(r, g, b)
Definition: qcolor_p.cpp:130
QRgb * clut()
Returns a pointer to the screen&#39;s color lookup table (i.
Definition: qscreen_qws.h:245
unsigned int quint32
Definition: qglobal.h:938
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60
bool sameEndian
Definition: qscreenvnc_p.h:506

◆ convertPixels() [2/2]

void QVNCServer::convertPixels ( char *  dst,
const char *  src,
int  count 
) const

◆ dirtyMap() [1/2]

QVNCDirtyMap* QVNCServer::dirtyMap ( ) const
inline

Definition at line 462 of file qscreenvnc_p.h.

Referenced by newConnection(), setDirty(), QRfbRawEncoder::write(), and QRfbHextileEncoder< SRC >::write().

462 { return qvnc_screen->d_ptr->dirty; }
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
QVNCDirtyMap * dirty
Definition: qscreenvnc_p.h:253
QVNCScreenPrivate * d_ptr

◆ dirtyMap() [2/2]

QVNCDirtyMap* QVNCServer::dirtyMap ( ) const
inline

Definition at line 468 of file qvncserver.h.

468 { return qvnc_screen->dirtyMap(); }
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
QVNCDirtyMap * dirtyMap()

◆ discardClient [1/2]

void QVNCServer::discardClient ( )
privateslot

Definition at line 2031 of file qscreenvnc_qws.cpp.

Referenced by newConnection(), QVNCDirtyMap::QVNCDirtyMap(), readClient(), and setPixelFormat().

2032 {
2033  timer->stop();
2034  state = Unconnected;
2035  delete encoder;
2036  encoder = 0;
2037 #ifndef QT_NO_QWS_CURSOR
2038  delete qvnc_cursor;
2039  qvnc_cursor = 0;
2040 #endif
2043 }
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
QRfbEncoder * encoder
Definition: qscreenvnc_p.h:518
static QWSServer * instance()
QTimer * timer
Definition: qscreenvnc_p.h:488
ClientState state
Definition: qscreenvnc_p.h:491
void enablePainting(bool)
Enables painting onto the screen if enable is true; otherwise painting is disabled.
QScreen * screen() const
Returns the real screen used by the proxy screen.
void stop()
Stops the timer.
Definition: qtimer.cpp:284
QVNCScreenPrivate * d_ptr
QVNCClientCursor * qvnc_cursor
Definition: qscreenvnc_p.h:515

◆ discardClient [2/2]

void QVNCServer::discardClient ( )
privateslot

◆ doPixelConversion() [1/2]

bool QVNCServer::doPixelConversion ( ) const
inline

Definition at line 465 of file qscreenvnc_p.h.

Referenced by QRfbRawEncoder::write(), and QRfbHextileEncoder< SRC >::write().

465 { return needConversion; }
bool needConversion
Definition: qscreenvnc_p.h:507

◆ doPixelConversion() [2/2]

bool QVNCServer::doPixelConversion ( ) const
inline

Definition at line 471 of file qvncserver.h.

471 { return needConversion; }
bool needConversion
Definition: qscreenvnc_p.h:507

◆ frameBufferUpdateRequest() [1/2]

void QVNCServer::frameBufferUpdateRequest ( )
private

Definition at line 1006 of file qscreenvnc_qws.cpp.

Referenced by readClient().

1007 {
1009 
1010  if (ev.read(client)) {
1011  if (!ev.incremental) {
1012  QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h);
1013  r.translate(qvnc_screen->offset());
1014  qvnc_screen->d_ptr->setDirty(r, true);
1015  }
1016  wantUpdate = true;
1017  checkUpdate();
1018  handleMsg = false;
1019  }
1020 }
quint16 x
Definition: qscreenvnc_p.h:152
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
void setDirty(const QRect &rect, bool force=false)
bool wantUpdate
Definition: qscreenvnc_p.h:505
quint16 h
Definition: qscreenvnc_p.h:155
QTcpSocket * client
Definition: qscreenvnc_p.h:490
quint16 w
Definition: qscreenvnc_p.h:154
quint16 y
Definition: qscreenvnc_p.h:153
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool handleMsg
Definition: qscreenvnc_p.h:493
QVNCScreenPrivate * d_ptr
QPoint offset() const
Returns the logical offset of the screen, i.

◆ frameBufferUpdateRequest() [2/2]

void QVNCServer::frameBufferUpdateRequest ( )
private

◆ hasClientCursor()

bool QVNCServer::hasClientCursor ( ) const
inline

Definition at line 467 of file qscreenvnc_p.h.

Referenced by QVNCCursor::move(), QVNCCursor::set(), QRfbRawEncoder::write(), and QRfbHextileEncoder< SRC >::write().

467 { return qvnc_cursor != 0; }
QVNCClientCursor * qvnc_cursor
Definition: qscreenvnc_p.h:515

◆ init() [1/2]

void QVNCServer::init ( uint  port)
private

Definition at line 584 of file qscreenvnc_qws.cpp.

Referenced by QVNCServer().

585 {
586  handleMsg = false;
587  client = 0;
588  encodingsPending = 0;
589  cutTextPending = 0;
590  keymod = 0;
591  state = Unconnected;
592  dirtyCursor = false;
593 
594  refreshRate = 25;
595  timer = new QTimer(this);
596  timer->setSingleShot(true);
597  connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
598 
599  serverSocket = new QTcpServer(this);
601  qDebug() << "QVNCServer could not connect:" << serverSocket->errorString();
602  else
603  qDebug("QVNCServer created on port %d", port);
604 
606 
607 #ifndef QT_NO_QWS_CURSOR
608  qvnc_cursor = 0;
609 #endif
610  encoder = 0;
611 }
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
QRfbEncoder * encoder
Definition: qscreenvnc_p.h:518
QTimer * timer
Definition: qscreenvnc_p.h:488
#define SLOT(a)
Definition: qobjectdefs.h:226
Qt::KeyboardModifiers keymod
Definition: qscreenvnc_p.h:495
int cutTextPending
Definition: qscreenvnc_p.h:497
bool listen(const QHostAddress &address=QHostAddress::Any, quint16 port=0)
Tells the server to listen for incoming connections on address address and port port.
Definition: qtcpserver.cpp:281
ClientState state
Definition: qscreenvnc_p.h:491
QString errorString() const
Returns a human readable description of the last error that occurred.
Definition: qtcpserver.cpp:663
QTcpServer * serverSocket
Definition: qscreenvnc_p.h:489
Q_CORE_EXPORT void qDebug(const char *,...)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
int encodingsPending
Definition: qscreenvnc_p.h:496
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool dirtyCursor
Definition: qscreenvnc_p.h:511
void newConnection()
QTcpSocket * client
Definition: qscreenvnc_p.h:490
The QTcpServer class provides a TCP-based server.
Definition: qtcpserver.h:61
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
bool handleMsg
Definition: qscreenvnc_p.h:493
QVNCClientCursor * qvnc_cursor
Definition: qscreenvnc_p.h:515

◆ init() [2/2]

void QVNCServer::init ( uint  port)
private

◆ isConnected() [1/2]

bool QVNCServer::isConnected ( ) const
inline

Definition at line 441 of file qscreenvnc_p.h.

Referenced by QVNCScreenPrivate::QVNCScreenPrivate().

441 { return state == Connected; }
ClientState state
Definition: qscreenvnc_p.h:491

◆ isConnected() [2/2]

bool QVNCServer::isConnected ( ) const
inline

Definition at line 447 of file qvncserver.h.

447 { return state == Connected; }
ClientState state
Definition: qscreenvnc_p.h:491

◆ keyEvent() [1/2]

void QVNCServer::keyEvent ( )
private

Definition at line 1032 of file qscreenvnc_qws.cpp.

Referenced by buttonChange(), and readClient().

1033 {
1034  QRfbKeyEvent ev;
1035 
1036  if (ev.read(client)) {
1037  if (ev.keycode == Qt::Key_Shift)
1038  keymod = ev.down ? keymod | Qt::ShiftModifier :
1040  else if (ev.keycode == Qt::Key_Control)
1043  else if (ev.keycode == Qt::Key_Alt)
1044  keymod = ev.down ? keymod | Qt::AltModifier :
1046  if (ev.unicode || ev.keycode)
1047  QWSServer::sendKeyEvent(ev.unicode, ev.keycode, keymod, ev.down, false);
1048  handleMsg = false;
1049  }
1050 }
Qt::KeyboardModifiers keymod
Definition: qscreenvnc_p.h:495
bool read(QTcpSocket *s)
static void sendKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat)
Sends the given key event.
QTcpSocket * client
Definition: qscreenvnc_p.h:490
Definition: qnamespace.h:54
bool handleMsg
Definition: qscreenvnc_p.h:493

◆ keyEvent() [2/2]

void QVNCServer::keyEvent ( )
private

◆ newConnection [1/2]

void QVNCServer::newConnection ( )
privateslot

Definition at line 633 of file qscreenvnc_qws.cpp.

Referenced by init().

634 {
635  if (client)
636  delete client;
637 
639  connect(client,SIGNAL(readyRead()),this,SLOT(readClient()));
640  connect(client,SIGNAL(disconnected()),this,SLOT(discardClient()));
641  handleMsg = false;
642  encodingsPending = 0;
643  cutTextPending = 0;
644  supportHextile = false;
645  wantUpdate = false;
646 
647  timer->start(1000 / refreshRate);
648  dirtyMap()->reset();
649 
650  // send protocol version
651  const char *proto = "RFB 003.003\n";
652  client->write(proto, 12);
653  state = Protocol;
654 
657 }
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
static QWSServer * instance()
QTimer * timer
Definition: qscreenvnc_p.h:488
#define SLOT(a)
Definition: qobjectdefs.h:226
int cutTextPending
Definition: qscreenvnc_p.h:497
ClientState state
Definition: qscreenvnc_p.h:491
bool wantUpdate
Definition: qscreenvnc_p.h:505
QTcpServer * serverSocket
Definition: qscreenvnc_p.h:489
#define SIGNAL(a)
Definition: qobjectdefs.h:227
uint supportHextile
Definition: qscreenvnc_p.h:501
int encodingsPending
Definition: qscreenvnc_p.h:496
void enablePainting(bool)
Enables painting onto the screen if enable is true; otherwise painting is disabled.
virtual QTcpSocket * nextPendingConnection()
Returns the next pending connection as a connected QTcpSocket object.
Definition: qtcpserver.cpp:554
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void discardClient()
QTcpSocket * client
Definition: qscreenvnc_p.h:490
QVNCDirtyMap * dirtyMap() const
Definition: qscreenvnc_p.h:462
QScreen * screen() const
Returns the real screen used by the proxy screen.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249
bool handleMsg
Definition: qscreenvnc_p.h:493
QVNCScreenPrivate * d_ptr

◆ newConnection [2/2]

void QVNCServer::newConnection ( )
privateslot

◆ pixelConversionNeeded() [1/2]

bool QVNCServer::pixelConversionNeeded ( ) const
private

Definition at line 1393 of file qscreenvnc_qws.cpp.

Referenced by buttonChange(), and setPixelFormat().

1394 {
1395  if (!sameEndian)
1396  return true;
1397 
1398 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
1399  if (qvnc_screen->swapBytes())
1400  return true;
1401 #endif
1402 
1403  const int screendepth = qvnc_screen->depth();
1404  if (screendepth != pixelFormat.bitsPerPixel)
1405  return true;
1406 
1407  switch (screendepth) {
1408  case 32:
1409  case 24:
1410  return false;
1411  case 18:
1412  return (pixelFormat.redBits == 6
1413  && pixelFormat.greenBits == 6
1414  && pixelFormat.blueBits == 6);
1415  case 16:
1416  return (pixelFormat.redBits == 5
1417  && pixelFormat.greenBits == 6
1418  && pixelFormat.blueBits == 5);
1419  case 15:
1420  return (pixelFormat.redBits == 5
1421  && pixelFormat.greenBits == 5
1422  && pixelFormat.blueBits == 5);
1423  case 12:
1424  return (pixelFormat.redBits == 4
1425  && pixelFormat.greenBits == 4
1426  && pixelFormat.blueBits == 4);
1427  }
1428  return true;
1429 }
QRfbPixelFormat pixelFormat
Definition: qscreenvnc_p.h:494
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
bool swapBytes() const
virtual int depth() const
Reimplement in subclass to return current depth of the screen.
Definition: fb_base.h:163
bool sameEndian
Definition: qscreenvnc_p.h:506

◆ pixelConversionNeeded() [2/2]

bool QVNCServer::pixelConversionNeeded ( ) const
private

◆ pointerEvent() [1/2]

void QVNCServer::pointerEvent ( )
private

Definition at line 1022 of file qscreenvnc_qws.cpp.

Referenced by buttonChange(), and readClient().

1023 {
1024  QRfbPointerEvent ev;
1025  if (ev.read(client)) {
1026  const QPoint offset = qvnc_screen->offset();
1027  QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons);
1028  handleMsg = false;
1029  }
1030 }
static void sendMouseEvent(const QPoint &pos, int state, int wheel=0)
Send a mouse event.
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
bool read(QTcpSocket *s)
QTcpSocket * client
Definition: qscreenvnc_p.h:490
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool handleMsg
Definition: qscreenvnc_p.h:493
QPoint offset() const
Returns the logical offset of the screen, i.

◆ pointerEvent() [2/2]

void QVNCServer::pointerEvent ( )
private

◆ readClient [1/2]

void QVNCServer::readClient ( )
privateslot

Definition at line 659 of file qscreenvnc_qws.cpp.

Referenced by newConnection().

660 {
661  switch (state) {
662  case Protocol:
663  if (client->bytesAvailable() >= 12) {
664  char proto[13];
665  client->read(proto, 12);
666  proto[12] = '\0';
667  qDebug("Client protocol version %s", proto);
668  // No authentication
669  quint32 auth = htonl(1);
670  client->write((char *) &auth, sizeof(auth));
671  state = Init;
672  }
673  break;
674 
675  case Init:
676  if (client->bytesAvailable() >= 1) {
677  quint8 shared;
678  client->read((char *) &shared, 1);
679 
680  // Server Init msg
681  QRfbServerInit sim;
683  switch (qvnc_screen->depth()) {
684  case 32:
685  format.bitsPerPixel = 32;
686  format.depth = 32;
687  format.bigEndian = 0;
688  format.trueColor = true;
689  format.redBits = 8;
690  format.greenBits = 8;
691  format.blueBits = 8;
692  format.redShift = 16;
693  format.greenShift = 8;
694  format.blueShift = 0;
695  break;
696 
697  case 24:
698  format.bitsPerPixel = 24;
699  format.depth = 24;
700  format.bigEndian = 0;
701  format.trueColor = true;
702  format.redBits = 8;
703  format.greenBits = 8;
704  format.blueBits = 8;
705  format.redShift = 16;
706  format.greenShift = 8;
707  format.blueShift = 0;
708  break;
709 
710  case 18:
711  format.bitsPerPixel = 24;
712  format.depth = 18;
713  format.bigEndian = 0;
714  format.trueColor = true;
715  format.redBits = 6;
716  format.greenBits = 6;
717  format.blueBits = 6;
718  format.redShift = 12;
719  format.greenShift = 6;
720  format.blueShift = 0;
721  break;
722 
723  case 16:
724  format.bitsPerPixel = 16;
725  format.depth = 16;
726  format.bigEndian = 0;
727  format.trueColor = true;
728  format.redBits = 5;
729  format.greenBits = 6;
730  format.blueBits = 5;
731  format.redShift = 11;
732  format.greenShift = 5;
733  format.blueShift = 0;
734  break;
735 
736  case 15:
737  format.bitsPerPixel = 16;
738  format.depth = 15;
739  format.bigEndian = 0;
740  format.trueColor = true;
741  format.redBits = 5;
742  format.greenBits = 5;
743  format.blueBits = 5;
744  format.redShift = 10;
745  format.greenShift = 5;
746  format.blueShift = 0;
747  break;
748 
749  case 12:
750  format.bitsPerPixel = 16;
751  format.depth = 12;
752  format.bigEndian = 0;
753  format.trueColor = true;
754  format.redBits = 4;
755  format.greenBits = 4;
756  format.blueBits = 4;
757  format.redShift = 8;
758  format.greenShift = 4;
759  format.blueShift = 0;
760  break;
761 
762  case 8:
763  case 4:
764  format.bitsPerPixel = 8;
765  format.depth = 8;
766  format.bigEndian = 0;
767  format.trueColor = false;
768  format.redBits = 0;
769  format.greenBits = 0;
770  format.blueBits = 0;
771  format.redShift = 0;
772  format.greenShift = 0;
773  format.blueShift = 0;
774  break;
775 
776  default:
777  qDebug("QVNC cannot drive depth %d", qvnc_screen->depth());
778  discardClient();
779  return;
780  }
781  sim.width = qvnc_screen->deviceWidth();
783  sim.setName("Qt for Embedded Linux VNC Server");
784  sim.write(client);
785  state = Connected;
786  }
787  break;
788 
789  case Connected:
790  do {
791  if (!handleMsg) {
792  client->read((char *)&msgType, 1);
793  handleMsg = true;
794  }
795  if (handleMsg) {
796  switch (msgType ) {
797  case SetPixelFormat:
798  setPixelFormat();
799  break;
800  case FixColourMapEntries:
801  qDebug("Not supported: FixColourMapEntries");
802  handleMsg = false;
803  break;
804  case SetEncodings:
805  setEncodings();
806  break;
809  break;
810  case KeyEvent:
811  keyEvent();
812  break;
813  case PointerEvent:
814  pointerEvent();
815  break;
816  case ClientCutText:
817  clientCutText();
818  break;
819  default:
820  qDebug("Unknown message type: %d", (int)msgType);
821  handleMsg = false;
822  }
823  }
824  } while (!handleMsg && client->bytesAvailable());
825  break;
826  default:
827  break;
828  }
829 }
void frameBufferUpdateRequest()
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
void setEncodings()
qint64 bytesAvailable() const
Returns the number of incoming bytes that are waiting to be read.
void setPixelFormat()
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
unsigned char quint8
Definition: qglobal.h:934
ClientState state
Definition: qscreenvnc_p.h:491
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Definition: qiodevice.cpp:791
void setName(const char *n)
Q_CORE_EXPORT void qDebug(const char *,...)
virtual int depth() const
Reimplement in subclass to return current depth of the screen.
Definition: fb_base.h:163
QRfbPixelFormat format
Definition: qscreenvnc_p.h:192
void discardClient()
QTcpSocket * client
Definition: qscreenvnc_p.h:490
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
void write(QTcpSocket *s)
void clientCutText()
unsigned int quint32
Definition: qglobal.h:938
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
bool handleMsg
Definition: qscreenvnc_p.h:493
quint8 msgType
Definition: qscreenvnc_p.h:492

◆ readClient [2/2]

void QVNCServer::readClient ( )
privateslot

◆ screen() [1/2]

QVNCScreen* QVNCServer::screen ( ) const
inline

◆ screen() [2/2]

QVNCScreen* QVNCServer::screen ( ) const
inline

Definition at line 467 of file qvncserver.h.

467 { return qvnc_screen; }
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513

◆ screenImage() [1/2]

QImage * QVNCServer::screenImage ( ) const
inline

Definition at line 2002 of file qscreenvnc_qws.cpp.

Referenced by QVNCDirtyMap::QVNCDirtyMap(), QRfbRawEncoder::write(), and QRfbHextileEncoder< SRC >::write().

2003 {
2007 }
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
int linestep() const
QImage::Format pixelFormat() const
Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a suppor...
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
uchar * base() const

◆ screenImage() [2/2]

QImage* QVNCServer::screenImage ( ) const

◆ setCursor()

void QVNCServer::setCursor ( QVNCCursor c)
inline

Definition at line 476 of file qvncserver.h.

Referenced by QVNCScreen::QVNCScreen().

476 { cursor = c; }
unsigned char c[8]
Definition: qnumeric_p.h:62
QVNCCursor * cursor
Definition: qvncserver.h:527

◆ setDirty() [1/2]

void QVNCServer::setDirty ( )

Definition at line 625 of file qscreenvnc_qws.cpp.

Referenced by QVNCScreenPrivate::QVNCScreenPrivate().

626 {
627  if (state == Connected && !timer->isActive() &&
628  ((dirtyMap()->numDirty > 0) || dirtyCursor)) {
629  timer->start();
630  }
631 }
QTimer * timer
Definition: qscreenvnc_p.h:488
ClientState state
Definition: qscreenvnc_p.h:491
bool dirtyCursor
Definition: qscreenvnc_p.h:511
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
Definition: qtimer.h:69
QVNCDirtyMap * dirtyMap() const
Definition: qscreenvnc_p.h:462
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249

◆ setDirty() [2/2]

void QVNCServer::setDirty ( )

◆ setDirtyCursor() [1/2]

void QVNCServer::setDirtyCursor ( )
inline

Definition at line 440 of file qscreenvnc_p.h.

Referenced by QVNCCursor::changeCursor(), QVNCClientCursor::set(), and QVNCCursor::setCursorMode().

440 { dirtyCursor = true; setDirty(); }
bool dirtyCursor
Definition: qscreenvnc_p.h:511

◆ setDirtyCursor() [2/2]

void QVNCServer::setDirtyCursor ( )
inline

Definition at line 446 of file qvncserver.h.

446 { dirtyCursor = true; setDirty(); }
bool dirtyCursor
Definition: qscreenvnc_p.h:511

◆ setEncodings() [1/2]

void QVNCServer::setEncodings ( )
private

Definition at line 875 of file qscreenvnc_qws.cpp.

Referenced by readClient().

876 {
877  QRfbSetEncodings enc;
878 
879  if (!encodingsPending && enc.read(client)) {
880  encodingsPending = enc.count;
881  if (!encodingsPending)
882  handleMsg = false;
883  }
884 
885  if (encoder) {
886  delete encoder;
887  encoder = 0;
888  }
889 
890  enum Encodings {
891  Raw = 0,
892  CopyRect = 1,
893  RRE = 2,
894  CoRRE = 4,
895  Hextile = 5,
896  ZRLE = 16,
897  Cursor = -239,
898  DesktopSize = -223
899  };
900 
901  if (encodingsPending && (unsigned)client->bytesAvailable() >=
902  encodingsPending * sizeof(quint32)) {
903  for (int i = 0; i < encodingsPending; ++i) {
904  qint32 enc;
905  client->read((char *)&enc, sizeof(qint32));
906  enc = ntohl(enc);
907 #ifdef QT_QWS_VNC_DEBUG
908  qDebug("QVNCServer::setEncodings: %d", enc);
909 #endif
910  switch (enc) {
911  case Raw:
912  if (!encoder) {
913  encoder = new QRfbRawEncoder(this);
914 #ifdef QT_QWS_VNC_DEBUG
915  qDebug("QVNCServer::setEncodings: using raw");
916 #endif
917  }
918  break;
919  case CopyRect:
920  supportCopyRect = true;
921  break;
922  case RRE:
923  supportRRE = true;
924  break;
925  case CoRRE:
926  supportCoRRE = true;
927  break;
928  case Hextile:
929  supportHextile = true;
930  if (encoder)
931  break;
932  switch (qvnc_screen->depth()) {
933 #ifdef QT_QWS_DEPTH_8
934  case 8:
936  break;
937 #endif
938 #ifdef QT_QWS_DEPTH_12
939  case 12:
941  break;
942 #endif
943 #ifdef QT_QWS_DEPTH_15
944  case 15:
946  break;
947 #endif
948 #ifdef QT_QWS_DEPTH_16
949  case 16:
951  break;
952 #endif
953 #ifdef QT_QWS_DEPTH_18
954  case 18:
956  break;
957 #endif
958 #ifdef QT_QWS_DEPTH_24
959  case 24:
961  break;
962 #endif
963 #ifdef QT_QWS_DEPTH_32
964  case 32:
966  break;
967 #endif
968  default:
969  break;
970  }
971 #ifdef QT_QWS_VNC_DEBUG
972  qDebug("QVNCServer::setEncodings: using hextile");
973 #endif
974  break;
975  case ZRLE:
976  supportZRLE = true;
977  break;
978  case Cursor:
979  supportCursor = true;
980 #ifndef QT_NO_QWS_CURSOR
982  delete qvnc_cursor;
983  qvnc_cursor = new QVNCClientCursor(this);
984  }
985 #endif
986  break;
987  case DesktopSize:
988  supportDesktopSize = true;
989  break;
990  default:
991  break;
992  }
993  }
994  handleMsg = false;
995  encodingsPending = 0;
996  }
997 
998  if (!encoder) {
999  encoder = new QRfbRawEncoder(this);
1000 #ifdef QT_QWS_VNC_DEBUG
1001  qDebug("QVNCServer::setEncodings: fallback using raw");
1002 #endif
1003  }
1004 }
int qint32
Definition: qglobal.h:937
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
QRfbEncoder * encoder
Definition: qscreenvnc_p.h:518
qint64 bytesAvailable() const
Returns the number of incoming bytes that are waiting to be read.
uint supportCursor
Definition: qscreenvnc_p.h:503
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Definition: qiodevice.cpp:791
Q_CORE_EXPORT void qDebug(const char *,...)
bool isAccelerated() const
Returns true if the cursor is accelerated; otherwise false.
Definition: qscreen_qws.h:153
uint supportRRE
Definition: qscreenvnc_p.h:499
uint supportDesktopSize
Definition: qscreenvnc_p.h:504
uint supportHextile
Definition: qscreenvnc_p.h:501
virtual int depth() const
Reimplement in subclass to return current depth of the screen.
Definition: fb_base.h:163
int encodingsPending
Definition: qscreenvnc_p.h:496
bool read(QTcpSocket *s)
QTcpSocket * client
Definition: qscreenvnc_p.h:490
uint supportZRLE
Definition: qscreenvnc_p.h:502
uint supportCopyRect
Definition: qscreenvnc_p.h:498
unsigned int quint32
Definition: qglobal.h:938
QScreen * screen() const
Returns the real screen used by the proxy screen.
Q_GUI_EXPORT QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67
uint supportCoRRE
Definition: qscreenvnc_p.h:500
bool handleMsg
Definition: qscreenvnc_p.h:493
QVNCClientCursor * qvnc_cursor
Definition: qscreenvnc_p.h:515

◆ setEncodings() [2/2]

void QVNCServer::setEncodings ( )
private

◆ setPixelFormat() [1/2]

void QVNCServer::setPixelFormat ( )
private

Definition at line 843 of file qscreenvnc_qws.cpp.

Referenced by readClient().

844 {
845  if (client->bytesAvailable() >= 19) {
846  char buf[3];
847  client->read(buf, 3); // just padding
849 #ifdef QT_QWS_VNC_DEBUG
850  qDebug("Want format: %d %d %d %d %d %d %d %d %d %d",
852  int(pixelFormat.depth),
853  int(pixelFormat.bigEndian),
854  int(pixelFormat.trueColor),
855  int(pixelFormat.redBits),
856  int(pixelFormat.greenBits),
857  int(pixelFormat.blueBits),
858  int(pixelFormat.redShift),
859  int(pixelFormat.greenShift),
860  int(pixelFormat.blueShift));
861 #endif
862  if (!pixelFormat.trueColor) {
863  qDebug("Can only handle true color clients");
864  discardClient();
865  }
866  handleMsg = false;
867  sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!pixelFormat.bigEndian;
869 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
871 #endif
872  }
873 }
QRfbPixelFormat pixelFormat
Definition: qscreenvnc_p.h:494
QVNCScreen * qvnc_screen
Definition: qscreenvnc_p.h:513
qint64 bytesAvailable() const
Returns the number of incoming bytes that are waiting to be read.
bool swapBytes() const
bool swapBytes
Definition: qscreenvnc_p.h:509
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Definition: qiodevice.cpp:791
Q_CORE_EXPORT void qDebug(const char *,...)
void read(QTcpSocket *s)
bool pixelConversionNeeded() const
void discardClient()
QTcpSocket * client
Definition: qscreenvnc_p.h:490
bool needConversion
Definition: qscreenvnc_p.h:507
bool handleMsg
Definition: qscreenvnc_p.h:493
bool sameEndian
Definition: qscreenvnc_p.h:506

◆ setPixelFormat() [2/2]

void QVNCServer::setPixelFormat ( )
private

◆ setRefreshRate() [1/2]

void QVNCServer::setRefreshRate ( int  rate)
inline

Definition at line 442 of file qscreenvnc_p.h.

Referenced by QVNCScreen::initDevice(), and QVNCScreenPrivate::QVNCScreenPrivate().

442 { refreshRate = rate; }

◆ setRefreshRate() [2/2]

void QVNCServer::setRefreshRate ( int  rate)
inline

Definition at line 448 of file qvncserver.h.

448 { refreshRate = rate; }

Properties

◆ buttons

Qt::MouseButtons QVNCServer::buttons
private

Definition at line 503 of file qvncserver.h.

◆ client

QTcpSocket * QVNCServer::client
private

◆ cursor

QVNCCursor* QVNCServer::cursor
private

Definition at line 527 of file qvncserver.h.

◆ cutTextPending

int QVNCServer::cutTextPending
private

Definition at line 497 of file qscreenvnc_p.h.

Referenced by clientCutText(), init(), and newConnection().

◆ dirtyCursor

bool QVNCServer::dirtyCursor
private

Definition at line 511 of file qscreenvnc_p.h.

Referenced by init(), and setDirty().

◆ encoder

QRfbEncoder * QVNCServer::encoder
private

◆ encodingsPending

int QVNCServer::encodingsPending
private

Definition at line 496 of file qscreenvnc_p.h.

Referenced by init(), newConnection(), and setEncodings().

◆ handleMsg

bool QVNCServer::handleMsg
private

◆ keymod

Qt::KeyboardModifiers QVNCServer::keymod
private

Definition at line 495 of file qscreenvnc_p.h.

Referenced by init(), and keyEvent().

◆ msgType

quint8 QVNCServer::msgType
private

Definition at line 492 of file qscreenvnc_p.h.

Referenced by readClient().

◆ needConversion

bool QVNCServer::needConversion
private

Definition at line 507 of file qscreenvnc_p.h.

Referenced by setPixelFormat().

◆ pixelFormat

QRfbPixelFormat QVNCServer::pixelFormat
private

Definition at line 494 of file qscreenvnc_p.h.

Referenced by convertPixels(), pixelConversionNeeded(), and setPixelFormat().

◆ qvnc_cursor

QVNCClientCursor* QVNCServer::qvnc_cursor
private

Definition at line 515 of file qscreenvnc_p.h.

Referenced by init(), setEncodings(), and ~QVNCServer().

◆ qvnc_screen

QVNCScreen * QVNCServer::qvnc_screen
private

◆ refreshRate

int QVNCServer::refreshRate
private

Definition at line 512 of file qscreenvnc_p.h.

Referenced by init(), and newConnection().

◆ sameEndian

bool QVNCServer::sameEndian
private

Definition at line 506 of file qscreenvnc_p.h.

Referenced by convertPixels(), pixelConversionNeeded(), and setPixelFormat().

◆ serverSocket

QTcpServer * QVNCServer::serverSocket
private

Definition at line 489 of file qscreenvnc_p.h.

Referenced by init(), and newConnection().

◆ state

ClientState QVNCServer::state
private

Definition at line 491 of file qscreenvnc_p.h.

Referenced by init(), newConnection(), readClient(), and setDirty().

◆ supportCopyRect

uint QVNCServer::supportCopyRect
private

Definition at line 498 of file qscreenvnc_p.h.

Referenced by setEncodings().

◆ supportCoRRE

uint QVNCServer::supportCoRRE
private

Definition at line 500 of file qscreenvnc_p.h.

Referenced by setEncodings().

◆ supportCursor

uint QVNCServer::supportCursor
private

Definition at line 503 of file qscreenvnc_p.h.

Referenced by setEncodings().

◆ supportDesktopSize

uint QVNCServer::supportDesktopSize
private

Definition at line 504 of file qscreenvnc_p.h.

Referenced by setEncodings().

◆ supportHextile

uint QVNCServer::supportHextile
private

Definition at line 501 of file qscreenvnc_p.h.

Referenced by newConnection(), and setEncodings().

◆ supportRRE

uint QVNCServer::supportRRE
private

Definition at line 499 of file qscreenvnc_p.h.

Referenced by setEncodings().

◆ supportZRLE

uint QVNCServer::supportZRLE
private

Definition at line 502 of file qscreenvnc_p.h.

Referenced by setEncodings().

◆ swapBytes

bool QVNCServer::swapBytes
private

Definition at line 509 of file qscreenvnc_p.h.

Referenced by convertPixels(), and setPixelFormat().

◆ timer

QTimer * QVNCServer::timer
private

Definition at line 488 of file qscreenvnc_p.h.

Referenced by init(), newConnection(), and setDirty().

◆ wantUpdate

bool QVNCServer::wantUpdate
private

Definition at line 505 of file qscreenvnc_p.h.

Referenced by frameBufferUpdateRequest(), and newConnection().


The documentation for this class was generated from the following files: