📄 vncserver.h
字号:
// Copyright (C) 2006 Teamviewer GmbH. All Rights Reserved.
// Copyright (C) 2002 Ultr@VNC Team Members. All Rights Reserved.
// Copyright (C) 2000-2002 Const Kaplinsky. All Rights Reserved.
// Copyright (C) 2002 RealVNC Ltd. All Rights Reserved.
// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
//
// This file is part of TeamViewer.
//
// TeamViewer is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// If the source code for TeamViewer is not available from the place
// whence you received this file, check http://www.teamviewer.com
// for information on obtaining it.
// vncServer.h
// vncServer class handles the following functions:
// - Allowing clients to be dynamically added and removed
// - Propagating updates from the local vncDesktop object
// to all the connected clients
// - Propagating mouse movements and keyboard events from
// clients to the local vncDesktop
// It also creates the vncSockConnect
// servers, which respectively allow connections via sockets
// and via the ORB interface
#pragma once
class vncServer;
extern bool isQuickSupport;
#if (!defined(_WINVNC_VNCSERVER))
#define _WINVNC_VNCSERVER
// Custom
#include "vncSockConnect.h"
#include "vncHTTPConnect.h"
#include "vncClient.h"
#include "vncPasswd.h"
#include "roGateway.h"
#include "teamviewerinfo.h"
// Includes
typedef BOOL (WINAPI *WTSREGISTERSESSIONNOTIFICATION)(HWND, DWORD);
typedef BOOL (WINAPI *WTSUNREGISTERSESSIONNOTIFICATION)(HWND);
#define WM_WTSSESSION_CHANGE 0x02B1
#define WTS_CONSOLE_CONNECT 0x1
#define WTS_CONSOLE_DISCONNECT 0x2
#define WTS_REMOTE_CONNECT 0x3
#define WTS_REMOTE_DISCONNECT 0x4
#define WTS_SESSION_LOGON 0x5
#define WTS_SESSION_LOGOFF 0x6
#define WTS_SESSION_LOCK 0x7
#define WTS_SESSION_UNLOCK 0x8
#define WTS_SESSION_REMOTE_CONTROL 0x9
// Define a datatype to handle lists of windows we wish to notify
typedef std::list<HWND> vncNotifyList;
// Some important constants;
const int MAX_CLIENTS = 128;
// Staudenmeyerd@2005
/* Values are stored to registry - don't change order, add new items to end of list! */
enum IncomingConnections
{
ConnectionViewerOpened = 0,
ConnectionConfirmation,
ConnectionPassword,
ConnectionNone,
ConnectionAfterAuthentication
};
enum UpdateHandling
{
UpdateHandlingOptimizeQuality,
UpdateHandlingOptimizeSpeed
};
// Wenn Lizenznummer "RC" beinhaltet (Release Candidate), wird auch bei Download von DynGate
// ein RC an Dateinamen angef黦t, um das dynamische Nachladen einer neuen DynGate-Testversion zu
// erm鰃lichen
#define TEAMVIEWER_VERSION "2.43b"
// Changelog moved to Wiki
// The vncServer class itself
class vncServer
{
public:
// Constructor/destructor
vncServer();
~vncServer();
// Client handling functions
virtual vncClientId AddClient(VSocket *socket, BOOL auth, BOOL shared);
virtual vncClientId AddClient(VSocket *socket, BOOL auth, BOOL shared, string clientname, SYSTEMTIME start);
virtual vncClientId AddClient(VSocket *socket, BOOL auth, BOOL shared,rfbProtocolVersionMsg *protocolMsg);
virtual vncClientId AddClient(VSocket *socket, BOOL auth, BOOL shared,
int capability, rfbProtocolVersionMsg *protocolMsg, string clientname, SYSTEMTIME start);
virtual BOOL Authenticated(vncClientId client);
virtual void KillClient(vncClientId client);
virtual void KillClient(LPSTR szClientName); // sf@2002
virtual void TextChatClient(LPSTR szClientName); // sf@2002
virtual UINT AuthClientCount();
virtual UINT UnauthClientCount();
virtual void KillAuthClients();
virtual void ListAuthClients(HWND hListBox);
virtual void WaitUntilAuthEmpty();
virtual void KillUnauthClients();
virtual void WaitUntilUnauthEmpty();
// Are any clients ready to send updates?
virtual BOOL UpdateWanted();
// Has at least one client had a remote event?
virtual BOOL RemoteEventReceived();
// Client info retrieval/setup
virtual vncClient* GetClient(vncClientId clientid);
virtual vncClientList ClientList();
virtual void SetCapability(vncClientId client, int capability);
virtual void SetKeyboardEnabled(vncClientId client, BOOL enabled);
virtual void SetPointerEnabled(vncClientId client, BOOL enabled);
virtual int GetCapability(vncClientId client);
virtual const char* GetClientName(vncClientId client);
// Let a client remove itself
virtual void RemoveClient(vncClientId client, bool keepDesktop=false);
// Connect/disconnect notification
virtual BOOL AddNotify(HWND hwnd);
virtual BOOL RemNotify(HWND hwnd);
// Modif sf@2002 - Single Window
virtual void SingleWindow(BOOL fEnabled) { m_SingleWindow = fEnabled; };
virtual BOOL SingleWindow() { return m_SingleWindow; };
virtual void SetSingleWindowName(const char *szName);
virtual char *GetWindowName() { return m_szWindowName; };
virtual vncDesktop* GetDesktopPointer() {return m_desktop;}
virtual void SetNewSWSize(long w,long h,BOOL desktop);
virtual void SetSWOffset(int x,int y);
virtual void SetScreenOffset(int x,int y,int type);
virtual BOOL All_clients_initialalized();
// Lock to protect the client list from concurrency - lock when reading/updating client list
omni_mutex m_clientsLock;
UINT m_port;
UINT m_port_http; // TightVNC 1.2.7
protected:
// Send a notification message
virtual void DoNotify(UINT message, WPARAM wparam, LPARAM lparam);
public:
// Update handling, used by the screen server
virtual rfb::UpdateTracker &GetUpdateTracker() {return m_update_tracker;};
virtual void UpdateMouse();
virtual void UpdateClipText(const char* text);
virtual void UpdatePalette();
virtual void UpdateLocalFormat();
// Polling mode handling
virtual void PollUnderCursor(BOOL enable) {m_poll_undercursor = enable;};
virtual BOOL PollUnderCursor() {return m_poll_undercursor;};
virtual void PollForeground(BOOL enable) {m_poll_foreground = enable;};
virtual BOOL PollForeground() {return m_poll_foreground;};
virtual void PollFullScreen(BOOL enable) {m_poll_fullscreen = enable;};
virtual BOOL PollFullScreen() {return m_poll_fullscreen;};
virtual void Driver(BOOL enable);
virtual BOOL Driver() {return m_driver;};
virtual void Hook(BOOL enable);
virtual BOOL Hook() {return m_hook;};
virtual void SetHookings();
virtual void PollConsoleOnly(BOOL enable) {m_poll_consoleonly = enable;};
virtual BOOL PollConsoleOnly() {return m_poll_consoleonly;};
virtual void PollOnEventOnly(BOOL enable) {m_poll_oneventonly = enable;};
virtual BOOL PollOnEventOnly() {return m_poll_oneventonly;};
// Client manipulation of the clipboard
virtual void UpdateLocalClipText(LPSTR text);
// Name and port number handling
// TightVNC 1.2.7
virtual void SetName(const char * name);
virtual void SetPorts(const UINT port_rfb, const UINT port_http);
virtual UINT GetPort() { return m_port; };
virtual UINT GetHttpPort() { return m_port_http; };
// RealVNC method
/*
virtual void SetPort(const UINT port);
virtual UINT GetPort();
*/
virtual void SetAutoPortSelect(const BOOL autoport) {
if (autoport && !m_autoportselect)
{
BOOL sockconnect = SockConnected();
SockConnect(FALSE);
m_autoportselect = autoport;
SockConnect(sockconnect);
}
else
{
m_autoportselect = autoport;
}
};
virtual BOOL AutoPortSelect() {return m_autoportselect;};
// Password set/retrieve. Note that these functions now handle the encrypted
// form, not the plaintext form. The buffer passwed MUST be MAXPWLEN in size.
virtual void SetPassword(const char *passwd);
virtual void GetPassword(char *passwd);
char* Version();
// Remote input handling
virtual void EnableRemoteInputs(BOOL enable);
virtual BOOL RemoteInputsEnabled();
// Local input handling
virtual void DisableLocalInputs(BOOL disable);
virtual BOOL LocalInputsDisabled();
// General connection handling
virtual void SetConnectPriority(UINT priority) {m_connect_pri = priority;};
virtual UINT ConnectPriority() {return m_connect_pri;};
// Socket connection handling
virtual BOOL SockConnect(BOOL on);
virtual BOOL SockConnected();
virtual BOOL SetLoopbackOnly(BOOL loopbackOnly);
virtual BOOL LoopbackOnly();
// Tray icon disposition
virtual BOOL SetDisableTrayIcon(BOOL disableTrayIcon);
virtual BOOL GetDisableTrayIcon();
virtual BOOL SetAllowEditClients(BOOL AllowEditClients);
virtual BOOL GetAllowEditClients();
// HTTP daemon handling
virtual BOOL EnableHTTPConnect(BOOL enable);
virtual BOOL HTTPConnectEnabled() {return m_enableHttpConn;};
virtual void GetScreenInfo(int &width, int &height, int &depth);
// Allow connections if no password is set?
virtual void SetAuthRequired(BOOL reqd) {m_passwd_required = reqd;};
virtual BOOL AuthRequired() {return m_passwd_required;};
// Handling of per-client connection authorisation
virtual void SetAuthHosts(const char *hostlist);
virtual char *AuthHosts();
enum AcceptQueryReject {aqrAccept, aqrQuery, aqrReject};
virtual AcceptQueryReject VerifyHost(const char *hostname);
// Blacklisting of machines which fail connection attempts too often
// Such machines will fail VerifyHost for a short period
virtual void AddAuthHostsBlacklist(const char *machine);
virtual void RemAuthHostsBlacklist(const char *machine);
// Connection querying settings
virtual void SetQuerySetting(const UINT setting) {m_querysetting = setting;};
virtual UINT QuerySetting() {return m_querysetting;};
virtual void SetQueryAccept(const UINT setting) {m_queryaccept = setting;};
virtual UINT QueryAccept()
{
if(isQuickSupport)
{
return true;
}
else
{
return m_queryaccept;
}
};
virtual void SetQueryTimeout(const UINT setting) {m_querytimeout = setting;};
virtual UINT QueryTimeout()
{
if(isQuickSupport)
{
return 8;
}
else
{
return m_querytimeout;
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -