VirtualBox

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

Last change on this file since 40752 was 40626, checked in by vboxsync, 13 years ago

ConsoleVRDPServer: use the new mouse pointers inteface for VRDE.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.8 KB
Line 
1/* $Id: ConsoleVRDPServer.h 40626 2012-03-26 09:01:06Z vboxsync $ */
2/** @file
3 * VBox Console VRDE Server Helper class and implementation of IVRDEServerInfo
4 */
5
6/*
7 * Copyright (C) 2006-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_CONSOLEVRDPSERVER
19#define ____H_CONSOLEVRDPSERVER
20
21#include "RemoteUSBBackend.h"
22#include "HGCM.h"
23
24#include <VBox/VBoxAuth.h>
25
26#include <VBox/RemoteDesktop/VRDEImage.h>
27#include <VBox/RemoteDesktop/VRDEMousePtr.h>
28
29#include <VBox/HostServices/VBoxClipboardExt.h>
30
31#include "SchemaDefs.h"
32
33// ConsoleVRDPServer
34///////////////////////////////////////////////////////////////////////////////
35
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
50/* Member of Console. Helper class for VRDP server management. Not a COM class. */
51class ConsoleVRDPServer
52{
53public:
54 ConsoleVRDPServer (Console *console);
55 ~ConsoleVRDPServer ();
56
57 int Launch (void);
58
59 void NotifyAbsoluteMouse (bool fGuestWantsAbsolute)
60 {
61 m_fGuestWantsAbsolute = fGuestWantsAbsolute;
62 }
63
64 void NotifyKeyboardLedsChange (BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
65 {
66 bool fGuestNumLock = (fNumLock != FALSE);
67 bool fGuestCapsLock = (fCapsLock != FALSE);
68 bool fGuestScrollLock = (fScrollLock != FALSE);
69
70 /* Might need to resync in case the guest itself changed the LED status. */
71 if (m_InputSynch.fClientNumLock != fGuestNumLock)
72 {
73 m_InputSynch.cGuestNumLockAdaptions = 2;
74 }
75
76 if (m_InputSynch.fClientCapsLock != fGuestCapsLock)
77 {
78 m_InputSynch.cGuestCapsLockAdaptions = 2;
79 }
80
81 m_InputSynch.fGuestNumLock = fGuestNumLock;
82 m_InputSynch.fGuestCapsLock = fGuestCapsLock;
83 m_InputSynch.fGuestScrollLock = fGuestScrollLock;
84 }
85
86 void EnableConnections (void);
87 void DisconnectClient (uint32_t u32ClientId, bool fReconnect);
88 int MousePointer(BOOL alpha, ULONG xHot, ULONG yHot, ULONG width, ULONG height, const uint8_t *pu8Shape);
89 void MousePointerUpdate (const VRDECOLORPOINTER *pPointer);
90 void MousePointerHide (void);
91
92 void Stop (void);
93
94 AuthResult Authenticate (const Guid &uuid, AuthGuestJudgement guestJudgement,
95 const char *pszUser, const char *pszPassword, const char *pszDomain,
96 uint32_t u32ClientId);
97
98 void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
99
100 void USBBackendCreate (uint32_t u32ClientId, void **ppvIntercept);
101 void USBBackendDelete (uint32_t u32ClientId);
102
103 void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
104 void USBBackendReleasePointer (const Guid *pGuid);
105
106 /* Private interface for the RemoteUSBBackend destructor. */
107 void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
108
109 /* Private methods for the Remote USB thread. */
110 RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
111
112 void notifyRemoteUSBThreadRunning (RTTHREAD thread);
113 bool isRemoteUSBThreadRunning (void);
114 void waitRemoteUSBThreadEvent (RTMSINTERVAL cMillies);
115
116 void ClipboardCreate (uint32_t u32ClientId);
117 void ClipboardDelete (uint32_t u32ClientId);
118
119 /*
120 * Forwarders to VRDP server library.
121 */
122 void SendUpdate (unsigned uScreenId, void *pvUpdate, uint32_t cbUpdate) const;
123 void SendResize (void) const;
124 void SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const;
125
126 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDEAUDIOFORMAT format) const;
127 void SendAudioVolume (uint16_t left, uint16_t right) const;
128 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const;
129
130 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const;
131
132 int SendAudioInputBegin(void **ppvUserCtx,
133 void *pvContext,
134 uint32_t cSamples,
135 uint32_t iSampleHz,
136 uint32_t cChannels,
137 uint32_t cBits);
138
139 void SendAudioInputEnd(void *pvUserCtx);
140#ifdef VBOX_WITH_USB_VIDEO
141 int GetVideoFrameDimensions(uint16_t *pu16Heigh, uint16_t *pu16Width);
142 int SendVideoSreamOn(bool fFetch);
143#endif
144
145private:
146 /* Note: This is not a ComObjPtr here, because the ConsoleVRDPServer object
147 * is actually just a part of the Console.
148 */
149 Console *mConsole;
150
151 HVRDESERVER mhServer;
152 int mServerInterfaceVersion;
153
154 static int loadVRDPLibrary (const char *pszLibraryName);
155
156 /** Static because will never load this more than once! */
157 static RTLDRMOD mVRDPLibrary;
158
159 static PFNVRDECREATESERVER mpfnVRDECreateServer;
160
161 static VRDEENTRYPOINTS_4 mEntryPoints;
162 static VRDEENTRYPOINTS_4 *mpEntryPoints;
163 static VRDECALLBACKS_4 mCallbacks;
164
165 static DECLCALLBACK(int) VRDPCallbackQueryProperty (void *pvCallback, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
166 static DECLCALLBACK(int) VRDPCallbackClientLogon (void *pvCallback, uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
167 static DECLCALLBACK(void) VRDPCallbackClientConnect (void *pvCallback, uint32_t u32ClientId);
168 static DECLCALLBACK(void) VRDPCallbackClientDisconnect (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercepted);
169 static DECLCALLBACK(int) VRDPCallbackIntercept (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercept, void **ppvIntercept);
170 static DECLCALLBACK(int) VRDPCallbackUSB (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint8_t u8Code, const void *pvRet, uint32_t cbRet);
171 static DECLCALLBACK(int) VRDPCallbackClipboard (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
172 static DECLCALLBACK(bool) VRDPCallbackFramebufferQuery (void *pvCallback, unsigned uScreenId, VRDEFRAMEBUFFERINFO *pInfo);
173 static DECLCALLBACK(void) VRDPCallbackFramebufferLock (void *pvCallback, unsigned uScreenId);
174 static DECLCALLBACK(void) VRDPCallbackFramebufferUnlock (void *pvCallback, unsigned uScreenId);
175 static DECLCALLBACK(void) VRDPCallbackInput (void *pvCallback, int type, const void *pvInput, unsigned cbInput);
176 static DECLCALLBACK(void) VRDPCallbackVideoModeHint (void *pvCallback, unsigned cWidth, unsigned cHeight, unsigned cBitsPerPixel, unsigned uScreenId);
177 static DECLCALLBACK(void) VRDECallbackAudioIn (void *pvCallback, void *pvCtx, uint32_t u32ClientId, uint32_t u32Event, const void *pvData, uint32_t cbData);
178
179 bool m_fGuestWantsAbsolute;
180 int m_mousex;
181 int m_mousey;
182
183 IFramebuffer *maFramebuffers[SchemaDefs::MaxGuestMonitors];
184
185 ComPtr<IEventListener> mConsoleListener;
186
187 VRDPInputSynch m_InputSynch;
188
189 int32_t mVRDPBindPort;
190
191 RTCRITSECT mCritSect;
192
193 int lockConsoleVRDPServer (void);
194 void unlockConsoleVRDPServer (void);
195
196 int mcClipboardRefs;
197 HGCMSVCEXTHANDLE mhClipboard;
198 PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback;
199
200 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
201 static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
202
203#ifdef VBOX_WITH_USB
204 RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
205 RemoteUSBBackend *usbBackendFind (uint32_t u32ClientId);
206
207 typedef struct _USBBackends
208 {
209 RemoteUSBBackend *pHead;
210 RemoteUSBBackend *pTail;
211
212 RTTHREAD thread;
213
214 bool fThreadRunning;
215
216 RTSEMEVENT event;
217 } USBBackends;
218
219 USBBackends mUSBBackends;
220
221 void remoteUSBThreadStart (void);
222 void remoteUSBThreadStop (void);
223#endif /* VBOX_WITH_USB */
224
225 /* External authentication library handle. The library is loaded in the
226 * Authenticate method and unloaded at the object destructor.
227 */
228 RTLDRMOD mAuthLibrary;
229 PAUTHENTRY mpfnAuthEntry;
230 PAUTHENTRY2 mpfnAuthEntry2;
231 PAUTHENTRY3 mpfnAuthEntry3;
232
233 uint32_t volatile mu32AudioInputClientId;
234
235 static DECLCALLBACK(void) H3DORBegin(const void *pvContext, void **ppvInstance,
236 const char *pszFormat);
237 static DECLCALLBACK(void) H3DORGeometry(void *pvInstance,
238 int32_t x, int32_t y, uint32_t w, uint32_t h);
239 static DECLCALLBACK(void) H3DORVisibleRegion(void *pvInstance,
240 uint32_t cRects, RTRECT *paRects);
241 static DECLCALLBACK(void) H3DORFrame(void *pvInstance,
242 void *pvData, uint32_t cbData);
243 static DECLCALLBACK(void) H3DOREnd(void *pvInstance);
244 static DECLCALLBACK(int) H3DORContextProperty(const void *pvContext, uint32_t index,
245 void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
246
247 void remote3DRedirect(void);
248
249 /*
250 * VRDE server optional interfaces.
251 */
252
253 /* Image update interface. */
254 bool m_fInterfaceImage;
255 VRDEIMAGECALLBACKS m_interfaceCallbacksImage;
256 VRDEIMAGEINTERFACE m_interfaceImage;
257 static DECLCALLBACK(int) VRDEImageCbNotify (void *pvContext,
258 void *pvUser,
259 HVRDEIMAGE hVideo,
260 uint32_t u32Id,
261 void *pvData,
262 uint32_t cbData);
263 /* Mouse pointer interface. */
264 VRDEMOUSEPTRINTERFACE m_interfaceMousePtr;
265};
266
267
268class Console;
269
270class ATL_NO_VTABLE VRDEServerInfo :
271 public VirtualBoxBase,
272 VBOX_SCRIPTABLE_IMPL(IVRDEServerInfo)
273{
274public:
275
276 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VRDEServerInfo, IVRDEServerInfo)
277
278 DECLARE_NOT_AGGREGATABLE(VRDEServerInfo)
279
280 DECLARE_PROTECT_FINAL_CONSTRUCT()
281
282 BEGIN_COM_MAP(VRDEServerInfo)
283 VBOX_DEFAULT_INTERFACE_ENTRIES(IVRDEServerInfo)
284 END_COM_MAP()
285
286 DECLARE_EMPTY_CTOR_DTOR (VRDEServerInfo)
287
288 HRESULT FinalConstruct();
289 void FinalRelease();
290
291 /* Public initializer/uninitializer for internal purposes only. */
292 HRESULT init (Console *aParent);
293 void uninit();
294
295 /* IVRDEServerInfo properties */
296 #define DECL_GETTER(_aType, _aName) STDMETHOD(COMGETTER(_aName)) (_aType *a##_aName)
297 DECL_GETTER (BOOL, Active);
298 DECL_GETTER (LONG, Port);
299 DECL_GETTER (ULONG, NumberOfClients);
300 DECL_GETTER (LONG64, BeginTime);
301 DECL_GETTER (LONG64, EndTime);
302 DECL_GETTER (LONG64, BytesSent);
303 DECL_GETTER (LONG64, BytesSentTotal);
304 DECL_GETTER (LONG64, BytesReceived);
305 DECL_GETTER (LONG64, BytesReceivedTotal);
306 DECL_GETTER (BSTR, User);
307 DECL_GETTER (BSTR, Domain);
308 DECL_GETTER (BSTR, ClientName);
309 DECL_GETTER (BSTR, ClientIP);
310 DECL_GETTER (ULONG, ClientVersion);
311 DECL_GETTER (ULONG, EncryptionStyle);
312 #undef DECL_GETTER
313
314private:
315
316 Console * const mParent;
317};
318
319#endif // ____H_CONSOLEVRDPSERVER
320/* 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