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.

XserverDesktop.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2009-2015 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. // XserverDesktop.h
  21. //
  22. #ifndef __XSERVERDESKTOP_H__
  23. #define __XSERVERDESKTOP_H__
  24. #ifdef HAVE_DIX_CONFIG_H
  25. #include <dix-config.h>
  26. #endif
  27. #include <map>
  28. #include <stdint.h>
  29. #include <rfb/SDesktop.h>
  30. #include <rfb/HTTPServer.h>
  31. #include <rfb/PixelBuffer.h>
  32. #include <rfb/Configuration.h>
  33. #include <rfb/VNCServerST.h>
  34. #include <rdr/SubstitutingInStream.h>
  35. #include <unixcommon.h>
  36. #include "Input.h"
  37. namespace rfb {
  38. class VNCServerST;
  39. }
  40. namespace network { class SocketListener; class Socket; class SocketServer; }
  41. class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
  42. public rdr::Substitutor,
  43. public rfb::VNCServerST::QueryConnectionHandler,
  44. public rfb::Timer::Callback {
  45. public:
  46. XserverDesktop(int screenIndex,
  47. std::list<network::SocketListener*> listeners_,
  48. std::list<network::SocketListener*> httpListeners_,
  49. const char* name, const rfb::PixelFormat &pf,
  50. int width, int height, void* fbptr, int stride);
  51. virtual ~XserverDesktop();
  52. // methods called from X server code
  53. void blockUpdates();
  54. void unblockUpdates();
  55. void setFramebuffer(int w, int h, void* fbptr, int stride);
  56. void refreshScreenLayout();
  57. void bell();
  58. void setLEDState(unsigned int state);
  59. void serverCutText(const char* str, int len);
  60. void setDesktopName(const char* name);
  61. void setCursor(int width, int height, int hotX, int hotY,
  62. const unsigned char *rgbaData);
  63. void add_changed(const rfb::Region &region);
  64. void add_copied(const rfb::Region &dest, const rfb::Point &delta);
  65. void handleSocketEvent(int fd, bool read, bool write);
  66. void blockHandler(int* timeout);
  67. void addClient(network::Socket* sock, bool reverse);
  68. void disconnectClients();
  69. // QueryConnect methods called from X server code
  70. // getQueryConnect()
  71. // Returns information about the currently waiting query
  72. // (or an id of 0 if there is none waiting)
  73. void getQueryConnect(uint32_t* opaqueId, const char** address,
  74. const char** username, int *timeout);
  75. // approveConnection()
  76. // Used by X server code to supply the result of a query.
  77. void approveConnection(uint32_t opaqueId, bool accept,
  78. const char* rejectMsg=0);
  79. // rfb::SDesktop callbacks
  80. virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
  81. virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
  82. virtual void clientCutText(const char* str, int len);
  83. virtual unsigned int setScreenLayout(int fb_width, int fb_height,
  84. const rfb::ScreenSet& layout);
  85. // rfb::PixelBuffer callbacks
  86. virtual void grabRegion(const rfb::Region& r);
  87. // rdr::Substitutor callback
  88. virtual char* substitute(const char* varName);
  89. // rfb::VNCServerST::QueryConnectionHandler callback
  90. virtual rfb::VNCServerST::queryResult queryConnection(network::Socket* sock,
  91. const char* userName,
  92. char** reason);
  93. protected:
  94. bool handleListenerEvent(int fd,
  95. std::list<network::SocketListener*>* sockets,
  96. network::SocketServer* sockserv);
  97. bool handleSocketEvent(int fd,
  98. network::SocketServer* sockserv,
  99. bool read, bool write);
  100. virtual bool handleTimeout(rfb::Timer* t);
  101. private:
  102. int screenIndex;
  103. rfb::VNCServerST* server;
  104. rfb::HTTPServer* httpServer;
  105. std::list<network::SocketListener*> listeners;
  106. std::list<network::SocketListener*> httpListeners;
  107. bool directFbptr;
  108. uint32_t queryConnectId;
  109. network::Socket* queryConnectSocket;
  110. rfb::CharArray queryConnectAddress;
  111. rfb::CharArray queryConnectUsername;
  112. rfb::Timer queryConnectTimer;
  113. OutputIdMap outputIdMap;
  114. rfb::Point oldCursorPos;
  115. };
  116. #endif