您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

VNCServerWin32.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. #ifndef __VNCSERVER_WIN32_H__
  19. #define __VNCSERVER_WIN32_H__
  20. #include <winsock2.h>
  21. #include <network/TcpSocket.h>
  22. #include <rfb/VNCServerST.h>
  23. #include <rfb_win32/RegConfig.h>
  24. #include <rfb_win32/SDisplay.h>
  25. #include <rfb_win32/SocketManager.h>
  26. #include <rfb_win32/TCharArray.h>
  27. #include <winvnc/QueryConnectDialog.h>
  28. #include <winvnc/JavaViewer.h>
  29. #include <winvnc/ManagedListener.h>
  30. namespace winvnc {
  31. class STrayIconThread;
  32. class VNCServerWin32 : rfb::VNCServerST::QueryConnectionHandler,
  33. rfb::win32::SocketManager::AddressChangeNotifier,
  34. rfb::win32::RegConfig::Callback,
  35. rfb::win32::EventHandler {
  36. public:
  37. VNCServerWin32();
  38. virtual ~VNCServerWin32();
  39. // Run the server in the current thread
  40. int run();
  41. // Cause the run() call to return
  42. // THREAD-SAFE
  43. void stop();
  44. // Determine whether a viewer is active
  45. // THREAD-SAFE
  46. bool isServerInUse() const {return isDesktopStarted;}
  47. // Connect out to the specified VNC Viewer
  48. // THREAD-SAFE
  49. bool addNewClient(const char* client);
  50. // Disconnect all connected clients
  51. // THREAD-SAFE
  52. bool disconnectClients(const char* reason=0);
  53. // Call used to notify VNCServerST of user accept/reject query completion
  54. // CALLED FROM AcceptConnectDialog THREAD
  55. void queryConnectionComplete();
  56. // Where to read the configuration settings from
  57. static const TCHAR* RegConfigPath;
  58. bool getClientsInfo(rfb::ListConnInfo* LCInfo);
  59. bool setClientsStatus(rfb::ListConnInfo* LCInfo);
  60. protected:
  61. // VNCServerST::QueryConnectionHandler interface
  62. // Callback used to prompt user to accept or reject a connection.
  63. // CALLBACK IN VNCServerST "HOST" THREAD
  64. virtual rfb::VNCServerST::queryResult queryConnection(network::Socket* sock,
  65. const char* userName,
  66. char** reason);
  67. // SocketManager::AddressChangeNotifier interface
  68. // Used to keep tray icon up to date
  69. virtual void processAddressChange(network::SocketListener* sl);
  70. // RegConfig::Callback interface
  71. // Called via the EventManager whenver RegConfig sees the registry change
  72. virtual void regConfigChanged();
  73. // EventHandler interface
  74. // Used to perform queued commands
  75. virtual void processEvent(HANDLE event);
  76. protected:
  77. // Perform a particular internal function in the server thread
  78. typedef enum {NoCommand, DisconnectClients, AddClient, QueryConnectionComplete, SetClientsStatus, GetClientsInfo} Command;
  79. bool queueCommand(Command cmd, const void* data, int len, bool wait=true);
  80. Command command;
  81. const void* commandData;
  82. int commandDataLen;
  83. rfb::Mutex commandLock;
  84. rfb::Condition commandSig;
  85. rfb::win32::Handle commandEvent;
  86. rfb::win32::Handle sessionEvent;
  87. // VNCServerWin32 Server-internal state
  88. rfb::win32::SDisplay desktop;
  89. rfb::VNCServerST vncServer;
  90. rfb::Mutex runLock;
  91. rfb::Thread* hostThread;
  92. bool runServer;
  93. bool isDesktopStarted;
  94. JavaViewerServer httpServer;
  95. rfb::win32::SocketManager sockMgr;
  96. rfb::win32::RegConfig config;
  97. ManagedListener rfbSock;
  98. ManagedListener httpSock;
  99. STrayIconThread* trayIcon;
  100. QueryConnectDialog* queryConnectDialog;
  101. };
  102. };
  103. #endif