You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VNCServer.h 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2009-2019 Pierre Ossman for Cendio AB
  3. *
  4. * This is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This software is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this software; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17. * USA.
  18. */
  19. //
  20. // VNCServer - abstract interface implemented by the RFB library. The back-end
  21. // code calls the relevant methods as appropriate.
  22. #ifndef __RFB_VNCSERVER_H__
  23. #define __RFB_VNCSERVER_H__
  24. #include <rfb/UpdateTracker.h>
  25. #include <rfb/SSecurity.h>
  26. #include <rfb/ScreenSet.h>
  27. namespace network { class Socket; }
  28. namespace rfb {
  29. class VNCServer : public UpdateTracker {
  30. public:
  31. // addSocket() tells the server to serve the Socket. The caller
  32. // retains ownership of the Socket - the only way for the server
  33. // to discard a Socket is by calling shutdown() on it.
  34. // outgoing is set to true if the socket was created by connecting out
  35. // to another host, or false if the socket was created by accept()ing
  36. // an incoming connection.
  37. // accessRights allows to set the access rights to the server.
  38. virtual void addSocket(network::Socket* sock, bool outgoing=false,
  39. AccessRights accessRights = AccessDefault) = 0;
  40. // removeSocket() tells the server to stop serving the Socket. The
  41. // caller retains ownership of the Socket - the server must NOT
  42. // delete the Socket! This call is used mainly to cause per-Socket
  43. // resources to be freed.
  44. virtual void removeSocket(network::Socket* sock) = 0;
  45. // getSockets() gets a list of sockets. This can be used to generate an
  46. // fd_set for calling select().
  47. virtual void getSockets(std::list<network::Socket*>* sockets) = 0;
  48. // processSocketReadEvent() tells the server there is a Socket read event.
  49. // The implementation can indicate that the Socket is no longer active
  50. // by calling shutdown() on it. The caller will then call removeSocket()
  51. // soon after processSocketEvent returns, to allow any pre-Socket
  52. // resources to be tidied up.
  53. virtual void processSocketReadEvent(network::Socket* sock) = 0;
  54. // processSocketReadEvent() tells the server there is a Socket write event.
  55. // This is only necessary if the Socket has been put in non-blocking
  56. // mode and needs this callback to flush the buffer.
  57. virtual void processSocketWriteEvent(network::Socket* sock) = 0;
  58. // blockUpdates()/unblockUpdates() tells the server that the pixel buffer
  59. // is currently in flux and may not be accessed. The attributes of the
  60. // pixel buffer may still be accessed, but not the frame buffer itself.
  61. // Note that access must be unblocked the exact same number of times it
  62. // was blocked.
  63. virtual void blockUpdates() = 0;
  64. virtual void unblockUpdates() = 0;
  65. // setPixelBuffer() tells the server to use the given pixel buffer (and
  66. // optionally a modified screen layout). If this differs in size from
  67. // the previous pixel buffer, this may result in protocol messages being
  68. // sent, or clients being disconnected.
  69. virtual void setPixelBuffer(PixelBuffer* pb, const ScreenSet& layout) = 0;
  70. virtual void setPixelBuffer(PixelBuffer* pb) = 0;
  71. // setScreenLayout() modifies the current screen layout without changing
  72. // the pixelbuffer. Clients will be notified of the new layout.
  73. virtual void setScreenLayout(const ScreenSet& layout) = 0;
  74. // getPixelBuffer() returns a pointer to the PixelBuffer object.
  75. virtual const PixelBuffer* getPixelBuffer() const = 0;
  76. // requestClipboard() will result in a request to a client to
  77. // transfer its clipboard data. A call to
  78. // SDesktop::handleClipboardData() will be made once the data is
  79. // available.
  80. virtual void requestClipboard() = 0;
  81. // announceClipboard() informs all clients of changes to the
  82. // clipboard on the server. A client may later request the
  83. // clipboard data via SDesktop::handleClipboardRequest().
  84. virtual void announceClipboard(bool available) = 0;
  85. // sendClipboardData() transfers the clipboard data to a client
  86. // and should be called whenever a client has requested the
  87. // clipboard via SDesktop::handleClipboardRequest().
  88. virtual void sendClipboardData(const char* data) = 0;
  89. // bell() tells the server that it should make all clients make a bell sound.
  90. virtual void bell() = 0;
  91. // approveConnection() is called some time after
  92. // SDesktop::queryConnection() has been called, to accept or reject
  93. // the connection. The accept argument should be true for
  94. // acceptance, or false for rejection, in which case a string
  95. // reason may also be given.
  96. virtual void approveConnection(network::Socket* sock, bool accept,
  97. const char* reason = NULL) = 0;
  98. // - Close all currently-connected clients, by calling
  99. // their close() method with the supplied reason.
  100. virtual void closeClients(const char* reason) = 0;
  101. // getConnection() gets the SConnection for a particular Socket. If
  102. // the Socket is not recognised then null is returned.
  103. virtual SConnection* getConnection(network::Socket* sock) = 0;
  104. // setCursor() tells the server that the cursor has changed. The
  105. // cursorData argument contains width*height rgba quadruplets with
  106. // non-premultiplied alpha.
  107. virtual void setCursor(int width, int height, const Point& hotspot,
  108. const uint8_t* cursorData) = 0;
  109. // setCursorPos() tells the server the current position of the cursor, and
  110. // whether the server initiated that change (e.g. through another X11
  111. // client calling XWarpPointer()).
  112. virtual void setCursorPos(const Point& p, bool warped) = 0;
  113. // setName() tells the server what desktop title to supply to clients
  114. virtual void setName(const char* name) = 0;
  115. // setLEDState() tells the server what the current lock keys LED
  116. // state is
  117. virtual void setLEDState(unsigned int state) = 0;
  118. };
  119. }
  120. #endif