VirtualBox

source: vbox/trunk/src/VBox/Main/include/ConsoleVRDPServer.h@ 28973

Last change on this file since 28973 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.0 KB
Line 
1/* $Id: ConsoleVRDPServer.h 28800 2010-04-27 08:22:32Z vboxsync $ */
2
3/** @file
4 *
5 * VBox Console VRDP Helper class and implementation of IRemoteDisplayInfo
6 */
7
8/*
9 * Copyright (C) 2006-2008 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifndef ____H_CONSOLEVRDPSERVER
21#define ____H_CONSOLEVRDPSERVER
22
23#include "RemoteUSBBackend.h"
24#include <hgcm/HGCM.h>
25
26#include <VBox/VRDPAuth.h>
27
28#include <VBox/HostServices/VBoxClipboardExt.h>
29
30#include "SchemaDefs.h"
31
32// ConsoleVRDPServer
33///////////////////////////////////////////////////////////////////////////////
34
35#ifdef VBOX_WITH_VRDP
36typedef struct _VRDPInputSynch
37{
38 int cGuestNumLockAdaptions;
39 int cGuestCapsLockAdaptions;
40
41 bool fGuestNumLock;
42 bool fGuestCapsLock;
43 bool fGuestScrollLock;
44
45 bool fClientNumLock;
46 bool fClientCapsLock;
47 bool fClientScrollLock;
48} VRDPInputSynch;
49#endif /* VBOX_WITH_VRDP */
50
51/* Member of Console. Helper class for VRDP server management. Not a COM class. */
52class ConsoleVRDPServer
53{
54public:
55 ConsoleVRDPServer (Console *console);
56 ~ConsoleVRDPServer ();
57
58 int Launch (void);
59
60 void NotifyAbsoluteMouse (bool fGuestWantsAbsolute)
61 {
62#ifdef VBOX_WITH_VRDP
63 m_fGuestWantsAbsolute = fGuestWantsAbsolute;
64#else
65 NOREF(fGuestWantsAbsolute);
66#endif /* VBOX_WITH_VRDP */
67 }
68
69 void NotifyKeyboardLedsChange (BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
70 {
71#ifdef VBOX_WITH_VRDP
72 bool fGuestNumLock = (fNumLock != FALSE);
73 bool fGuestCapsLock = (fCapsLock != FALSE);
74 bool fGuestScrollLock = (fScrollLock != FALSE);
75
76 /* Might need to resynch in case the guest itself changed the LED status. */
77 if (m_InputSynch.fClientNumLock != fGuestNumLock)
78 {
79 m_InputSynch.cGuestNumLockAdaptions = 2;
80 }
81
82 if (m_InputSynch.fClientCapsLock != fGuestCapsLock)
83 {
84 m_InputSynch.cGuestCapsLockAdaptions = 2;
85 }
86
87 m_InputSynch.fGuestNumLock = fGuestNumLock;
88 m_InputSynch.fGuestCapsLock = fGuestCapsLock;
89 m_InputSynch.fGuestScrollLock = fGuestScrollLock;
90#else
91 NOREF(fNumLock);
92 NOREF(fCapsLock);
93 NOREF(fScrollLock);
94#endif /* VBOX_WITH_VRDP */
95 }
96
97 void EnableConnections (void);
98 void DisconnectClient (uint32_t u32ClientId, bool fReconnect);
99 void MousePointerUpdate (const VRDPCOLORPOINTER *pPointer);
100 void MousePointerHide (void);
101
102 void Stop (void);
103
104 VRDPAuthResult Authenticate (const Guid &uuid, VRDPAuthGuestJudgement guestJudgement,
105 const char *pszUser, const char *pszPassword, const char *pszDomain,
106 uint32_t u32ClientId);
107
108 void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
109
110 void USBBackendCreate (uint32_t u32ClientId, void **ppvIntercept);
111 void USBBackendDelete (uint32_t u32ClientId);
112
113 void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
114 void USBBackendReleasePointer (const Guid *pGuid);
115
116 /* Private interface for the RemoteUSBBackend destructor. */
117 void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
118
119 /* Private methods for the Remote USB thread. */
120 RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
121
122 void notifyRemoteUSBThreadRunning (RTTHREAD thread);
123 bool isRemoteUSBThreadRunning (void);
124 void waitRemoteUSBThreadEvent (RTMSINTERVAL cMillies);
125
126 void ClipboardCreate (uint32_t u32ClientId);
127 void ClipboardDelete (uint32_t u32ClientId);
128
129 /*
130 * Forwarders to VRDP server library.
131 */
132 void SendUpdate (unsigned uScreenId, void *pvUpdate, uint32_t cbUpdate) const;
133 void SendResize (void) const;
134 void SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const;
135
136 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format) const;
137 void SendAudioVolume (uint16_t left, uint16_t right) const;
138 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const;
139
140 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const;
141
142private:
143 /* Note: This is not a ComObjPtr here, because the ConsoleVRDPServer object
144 * is actually just a part of the Console.
145 */
146 Console *mConsole;
147
148#ifdef VBOX_WITH_VRDP
149 HVRDPSERVER mhServer;
150
151 static bool loadVRDPLibrary (void);
152
153 /** Static because will never load this more than once! */
154 static RTLDRMOD mVRDPLibrary;
155
156 static PFNVRDPCREATESERVER mpfnVRDPCreateServer;
157
158 static VRDPENTRYPOINTS_1 *mpEntryPoints;
159 static VRDPCALLBACKS_1 mCallbacks;
160
161 static DECLCALLBACK(int) VRDPCallbackQueryProperty (void *pvCallback, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
162 static DECLCALLBACK(int) VRDPCallbackClientLogon (void *pvCallback, uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
163 static DECLCALLBACK(void) VRDPCallbackClientConnect (void *pvCallback, uint32_t u32ClientId);
164 static DECLCALLBACK(void) VRDPCallbackClientDisconnect (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercepted);
165 static DECLCALLBACK(int) VRDPCallbackIntercept (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercept, void **ppvIntercept);
166 static DECLCALLBACK(int) VRDPCallbackUSB (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint8_t u8Code, const void *pvRet, uint32_t cbRet);
167 static DECLCALLBACK(int) VRDPCallbackClipboard (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
168 static DECLCALLBACK(bool) VRDPCallbackFramebufferQuery (void *pvCallback, unsigned uScreenId, VRDPFRAMEBUFFERINFO *pInfo);
169 static DECLCALLBACK(void) VRDPCallbackFramebufferLock (void *pvCallback, unsigned uScreenId);
170 static DECLCALLBACK(void) VRDPCallbackFramebufferUnlock (void *pvCallback, unsigned uScreenId);
171 static DECLCALLBACK(void) VRDPCallbackInput (void *pvCallback, int type, const void *pvInput, unsigned cbInput);
172 static DECLCALLBACK(void) VRDPCallbackVideoModeHint (void *pvCallback, unsigned cWidth, unsigned cHeight, unsigned cBitsPerPixel, unsigned uScreenId);
173
174 bool m_fGuestWantsAbsolute;
175 int m_mousex;
176 int m_mousey;
177
178 IFramebuffer *maFramebuffers[SchemaDefs::MaxGuestMonitors];
179
180 IConsoleCallback *mConsoleCallback;
181
182 VRDPInputSynch m_InputSynch;
183
184 int32_t mVRDPBindPort;
185#endif /* VBOX_WITH_VRDP */
186
187 RTCRITSECT mCritSect;
188
189 int lockConsoleVRDPServer (void);
190 void unlockConsoleVRDPServer (void);
191
192 int mcClipboardRefs;
193 HGCMSVCEXTHANDLE mhClipboard;
194 PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback;
195
196 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
197 static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
198
199#ifdef VBOX_WITH_USB
200 RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
201 RemoteUSBBackend *usbBackendFind (uint32_t u32ClientId);
202
203 typedef struct _USBBackends
204 {
205 RemoteUSBBackend *pHead;
206 RemoteUSBBackend *pTail;
207
208 RTTHREAD thread;
209
210 bool fThreadRunning;
211
212 RTSEMEVENT event;
213 } USBBackends;
214
215 USBBackends mUSBBackends;
216
217 void remoteUSBThreadStart (void);
218 void remoteUSBThreadStop (void);
219#endif /* VBOX_WITH_USB */
220
221 /* External authentication library handle. The library is loaded in the
222 * Authenticate method and unloaded at the object destructor.
223 */
224 RTLDRMOD mAuthLibrary;
225 PVRDPAUTHENTRY mpfnAuthEntry;
226 PVRDPAUTHENTRY2 mpfnAuthEntry2;
227};
228
229
230class Console;
231
232class ATL_NO_VTABLE RemoteDisplayInfo :
233 public VirtualBoxBase,
234 public VirtualBoxSupportErrorInfoImpl<RemoteDisplayInfo, IRemoteDisplayInfo>,
235 public VirtualBoxSupportTranslation<RemoteDisplayInfo>,
236 VBOX_SCRIPTABLE_IMPL(IRemoteDisplayInfo)
237{
238public:
239
240 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (RemoteDisplayInfo)
241
242 DECLARE_NOT_AGGREGATABLE(RemoteDisplayInfo)
243
244 DECLARE_PROTECT_FINAL_CONSTRUCT()
245
246 BEGIN_COM_MAP(RemoteDisplayInfo)
247 COM_INTERFACE_ENTRY(ISupportErrorInfo)
248 COM_INTERFACE_ENTRY(IRemoteDisplayInfo)
249 COM_INTERFACE_ENTRY(IDispatch)
250 END_COM_MAP()
251
252 DECLARE_EMPTY_CTOR_DTOR (RemoteDisplayInfo)
253
254 HRESULT FinalConstruct();
255 void FinalRelease();
256
257 /* Public initializer/uninitializer for internal purposes only. */
258 HRESULT init (Console *aParent);
259 void uninit();
260
261 /* IRemoteDisplayInfo properties */
262 #define DECL_GETTER(_aType, _aName) STDMETHOD(COMGETTER(_aName)) (_aType *a##_aName)
263 DECL_GETTER (BOOL, Active);
264 DECL_GETTER (LONG, Port);
265 DECL_GETTER (ULONG, NumberOfClients);
266 DECL_GETTER (LONG64, BeginTime);
267 DECL_GETTER (LONG64, EndTime);
268 DECL_GETTER (ULONG64, BytesSent);
269 DECL_GETTER (ULONG64, BytesSentTotal);
270 DECL_GETTER (ULONG64, BytesReceived);
271 DECL_GETTER (ULONG64, BytesReceivedTotal);
272 DECL_GETTER (BSTR, User);
273 DECL_GETTER (BSTR, Domain);
274 DECL_GETTER (BSTR, ClientName);
275 DECL_GETTER (BSTR, ClientIP);
276 DECL_GETTER (ULONG, ClientVersion);
277 DECL_GETTER (ULONG, EncryptionStyle);
278 #undef DECL_GETTER
279
280 /* For VirtualBoxSupportErrorInfoImpl. */
281 static const wchar_t *getComponentName() { return L"RemoteDisplayInfo"; }
282
283private:
284
285 Console * const mParent;
286};
287
288#endif // ____H_CONSOLEVRDPSERVER
289/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette