Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

VNCServerWin32.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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/ManagedListener.h>
  29. namespace os {
  30. class Mutex;
  31. class Condition;
  32. class Thread;
  33. }
  34. namespace winvnc {
  35. class ListConnInfo;
  36. class STrayIconThread;
  37. class VNCServerWin32 : rfb::win32::QueryConnectionHandler,
  38. rfb::win32::SocketManager::AddressChangeNotifier,
  39. rfb::win32::RegConfig::Callback,
  40. rfb::win32::EventHandler {
  41. public:
  42. VNCServerWin32();
  43. virtual ~VNCServerWin32();
  44. // Run the server in the current thread
  45. int run();
  46. // Cause the run() call to return
  47. // THREAD-SAFE
  48. void stop();
  49. // Determine whether a viewer is active
  50. // THREAD-SAFE
  51. bool isServerInUse() const {return isDesktopStarted;}
  52. // Connect out to the specified VNC Viewer
  53. // THREAD-SAFE
  54. bool addNewClient(const char* client);
  55. // Disconnect all connected clients
  56. // THREAD-SAFE
  57. bool disconnectClients(const char* reason=0);
  58. // Call used to notify VNCServerST of user accept/reject query completion
  59. // CALLED FROM AcceptConnectDialog THREAD
  60. void queryConnectionComplete();
  61. // Where to read the configuration settings from
  62. static const TCHAR* RegConfigPath;
  63. bool getClientsInfo(ListConnInfo* LCInfo);
  64. bool setClientsStatus(ListConnInfo* LCInfo);
  65. protected:
  66. // QueryConnectionHandler interface
  67. // Callback used to prompt user to accept or reject a connection.
  68. // CALLBACK IN VNCServerST "HOST" THREAD
  69. virtual void queryConnection(network::Socket* sock,
  70. const char* userName);
  71. // SocketManager::AddressChangeNotifier interface
  72. // Used to keep tray icon up to date
  73. virtual void processAddressChange();
  74. // RegConfig::Callback interface
  75. // Called via the EventManager whenever RegConfig sees the registry change
  76. virtual void regConfigChanged();
  77. // EventHandler interface
  78. // Used to perform queued commands
  79. virtual void processEvent(HANDLE event);
  80. void getConnInfo(ListConnInfo * listConn);
  81. void setConnStatus(ListConnInfo* listConn);
  82. protected:
  83. // Perform a particular internal function in the server thread
  84. typedef enum {NoCommand, DisconnectClients, AddClient, QueryConnectionComplete, SetClientsStatus, GetClientsInfo} Command;
  85. bool queueCommand(Command cmd, const void* data, int len, bool wait=true);
  86. Command command;
  87. const void* commandData;
  88. int commandDataLen;
  89. os::Mutex* commandLock;
  90. os::Condition* commandSig;
  91. rfb::win32::Handle commandEvent;
  92. rfb::win32::Handle sessionEvent;
  93. // VNCServerWin32 Server-internal state
  94. rfb::win32::SDisplay desktop;
  95. rfb::VNCServerST vncServer;
  96. os::Mutex* runLock;
  97. DWORD thread_id;
  98. bool runServer;
  99. bool isDesktopStarted;
  100. rfb::win32::SocketManager sockMgr;
  101. rfb::win32::RegConfig config;
  102. ManagedListener rfbSock;
  103. STrayIconThread* trayIcon;
  104. QueryConnectDialog* queryConnectDialog;
  105. };
  106. };
  107. #endif