VirtualBox

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

Last change on this file since 35550 was 35374, checked in by vboxsync, 14 years ago

hgcm -> main

  • 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 35374 2010-12-30 14:42:15Z 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/HostServices/VBoxClipboardExt.h>
27
28#include "SchemaDefs.h"
29
30// ConsoleVRDPServer
31///////////////////////////////////////////////////////////////////////////////
32
33typedef struct _VRDPInputSynch
34{
35 int cGuestNumLockAdaptions;
36 int cGuestCapsLockAdaptions;
37
38 bool fGuestNumLock;
39 bool fGuestCapsLock;
40 bool fGuestScrollLock;
41
42 bool fClientNumLock;
43 bool fClientCapsLock;
44 bool fClientScrollLock;
45} VRDPInputSynch;
46
47/* Member of Console. Helper class for VRDP server management. Not a COM class. */
48class ConsoleVRDPServer
49{
50public:
51 ConsoleVRDPServer (Console *console);
52 ~ConsoleVRDPServer ();
53
54 int Launch (void);
55
56 void NotifyAbsoluteMouse (bool fGuestWantsAbsolute)
57 {
58 m_fGuestWantsAbsolute = fGuestWantsAbsolute;
59 }
60
61 void NotifyKeyboardLedsChange (BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
62 {
63 bool fGuestNumLock = (fNumLock != FALSE);
64 bool fGuestCapsLock = (fCapsLock != FALSE);
65 bool fGuestScrollLock = (fScrollLock != FALSE);
66
67 /* Might need to resync in case the guest itself changed the LED status. */
68 if (m_InputSynch.fClientNumLock != fGuestNumLock)
69 {
70 m_InputSynch.cGuestNumLockAdaptions = 2;
71 }
72
73 if (m_InputSynch.fClientCapsLock != fGuestCapsLock)
74 {
75 m_InputSynch.cGuestCapsLockAdaptions = 2;
76 }
77
78 m_InputSynch.fGuestNumLock = fGuestNumLock;
79 m_InputSynch.fGuestCapsLock = fGuestCapsLock;
80 m_InputSynch.fGuestScrollLock = fGuestScrollLock;
81 }
82
83 void EnableConnections (void);
84 void DisconnectClient (uint32_t u32ClientId, bool fReconnect);
85 void MousePointerUpdate (const VRDECOLORPOINTER *pPointer);
86 void MousePointerHide (void);
87
88 void Stop (void);
89
90 AuthResult Authenticate (const Guid &uuid, AuthGuestJudgement guestJudgement,
91 const char *pszUser, const char *pszPassword, const char *pszDomain,
92 uint32_t u32ClientId);
93
94 void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
95
96 void USBBackendCreate (uint32_t u32ClientId, void **ppvIntercept);
97 void USBBackendDelete (uint32_t u32ClientId);
98
99 void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
100 void USBBackendReleasePointer (const Guid *pGuid);
101
102 /* Private interface for the RemoteUSBBackend destructor. */
103 void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
104
105 /* Private methods for the Remote USB thread. */
106 RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
107
108 void notifyRemoteUSBThreadRunning (RTTHREAD thread);
109 bool isRemoteUSBThreadRunning (void);
110 void waitRemoteUSBThreadEvent (RTMSINTERVAL cMillies);
111
112 void ClipboardCreate (uint32_t u32ClientId);
113 void ClipboardDelete (uint32_t u32ClientId);
114
115 /*
116 * Forwarders to VRDP server library.
117 */
118 void SendUpdate (unsigned uScreenId, void *pvUpdate, uint32_t cbUpdate) const;
119 void SendResize (void) const;
120 void SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const;
121
122 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDEAUDIOFORMAT format) const;
123 void SendAudioVolume (uint16_t left, uint16_t right) const;
124 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const;
125
126 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const;
127
128 int SendAudioInputBegin(void **ppvUserCtx,
129 void *pvContext,
130 uint32_t cSamples,
131 uint32_t iSampleHz,
132 uint32_t cChannels,
133 uint32_t cBits);
134
135 void SendAudioInputEnd(void *pvUserCtx);
136
137private:
138 /* Note: This is not a ComObjPtr here, because the ConsoleVRDPServer object
139 * is actually just a part of the Console.
140 */
141 Console *mConsole;
142
143 HVRDESERVER mhServer;
144 int mServerInterfaceVersion;
145
146 static int loadVRDPLibrary (const char *pszLibraryName);
147
148 /** Static because will never load this more than once! */
149 static RTLDRMOD mVRDPLibrary;
150
151 static PFNVRDECREATESERVER mpfnVRDECreateServer;
152
153 static VRDEENTRYPOINTS_3 mEntryPoints;
154 static VRDEENTRYPOINTS_3 *mpEntryPoints;
155 static VRDECALLBACKS_3 mCallbacks;
156
157 static DECLCALLBACK(int) VRDPCallbackQueryProperty (void *pvCallback, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
158 static DECLCALLBACK(int) VRDPCallbackClientLogon (void *pvCallback, uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
159 static DECLCALLBACK(void) VRDPCallbackClientConnect (void *pvCallback, uint32_t u32ClientId);
160 static DECLCALLBACK(void) VRDPCallbackClientDisconnect (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercepted);
161 static DECLCALLBACK(int) VRDPCallbackIntercept (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercept, void **ppvIntercept);
162 static DECLCALLBACK(int) VRDPCallbackUSB (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint8_t u8Code, const void *pvRet, uint32_t cbRet);
163 static DECLCALLBACK(int) VRDPCallbackClipboard (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
164 static DECLCALLBACK(bool) VRDPCallbackFramebufferQuery (void *pvCallback, unsigned uScreenId, VRDEFRAMEBUFFERINFO *pInfo);
165 static DECLCALLBACK(void) VRDPCallbackFramebufferLock (void *pvCallback, unsigned uScreenId);
166 static DECLCALLBACK(void) VRDPCallbackFramebufferUnlock (void *pvCallback, unsigned uScreenId);
167 static DECLCALLBACK(void) VRDPCallbackInput (void *pvCallback, int type, const void *pvInput, unsigned cbInput);
168 static DECLCALLBACK(void) VRDPCallbackVideoModeHint (void *pvCallback, unsigned cWidth, unsigned cHeight, unsigned cBitsPerPixel, unsigned uScreenId);
169 static DECLCALLBACK(void) VRDECallbackAudioIn (void *pvCallback, void *pvCtx, uint32_t u32ClientId, uint32_t u32Event, const void *pvData, uint32_t cbData);
170
171 bool m_fGuestWantsAbsolute;
172 int m_mousex;
173 int m_mousey;
174
175 IFramebuffer *maFramebuffers[SchemaDefs::MaxGuestMonitors];
176
177 IEventListener *mConsoleListener;
178
179 VRDPInputSynch m_InputSynch;
180
181 int32_t mVRDPBindPort;
182
183 RTCRITSECT mCritSect;
184
185 int lockConsoleVRDPServer (void);
186 void unlockConsoleVRDPServer (void);
187
188 int mcClipboardRefs;
189 HGCMSVCEXTHANDLE mhClipboard;
190 PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback;
191
192 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
193 static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
194
195#ifdef VBOX_WITH_USB
196 RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
197 RemoteUSBBackend *usbBackendFind (uint32_t u32ClientId);
198
199 typedef struct _USBBackends
200 {
201 RemoteUSBBackend *pHead;
202 RemoteUSBBackend *pTail;
203
204 RTTHREAD thread;
205
206 bool fThreadRunning;
207
208 RTSEMEVENT event;
209 } USBBackends;
210
211 USBBackends mUSBBackends;
212
213 void remoteUSBThreadStart (void);
214 void remoteUSBThreadStop (void);
215#endif /* VBOX_WITH_USB */
216
217 /* External authentication library handle. The library is loaded in the
218 * Authenticate method and unloaded at the object destructor.
219 */
220 RTLDRMOD mAuthLibrary;
221 PAUTHENTRY mpfnAuthEntry;
222 PAUTHENTRY2 mpfnAuthEntry2;
223 PAUTHENTRY3 mpfnAuthEntry3;
224
225 uint32_t volatile mu32AudioInputClientId;
226};
227
228
229class Console;
230
231class ATL_NO_VTABLE VRDEServerInfo :
232 public VirtualBoxBase,
233 VBOX_SCRIPTABLE_IMPL(IVRDEServerInfo)
234{
235public:
236
237 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VRDEServerInfo, IVRDEServerInfo)
238
239 DECLARE_NOT_AGGREGATABLE(VRDEServerInfo)
240
241 DECLARE_PROTECT_FINAL_CONSTRUCT()
242
243 BEGIN_COM_MAP(VRDEServerInfo)
244 COM_INTERFACE_ENTRY(ISupportErrorInfo)
245 COM_INTERFACE_ENTRY(IVRDEServerInfo)
246 COM_INTERFACE_ENTRY(IDispatch)
247 END_COM_MAP()
248
249 DECLARE_EMPTY_CTOR_DTOR (VRDEServerInfo)
250
251 HRESULT FinalConstruct();
252 void FinalRelease();
253
254 /* Public initializer/uninitializer for internal purposes only. */
255 HRESULT init (Console *aParent);
256 void uninit();
257
258 /* IVRDEServerInfo properties */
259 #define DECL_GETTER(_aType, _aName) STDMETHOD(COMGETTER(_aName)) (_aType *a##_aName)
260 DECL_GETTER (BOOL, Active);
261 DECL_GETTER (LONG, Port);
262 DECL_GETTER (ULONG, NumberOfClients);
263 DECL_GETTER (LONG64, BeginTime);
264 DECL_GETTER (LONG64, EndTime);
265 DECL_GETTER (LONG64, BytesSent);
266 DECL_GETTER (LONG64, BytesSentTotal);
267 DECL_GETTER (LONG64, BytesReceived);
268 DECL_GETTER (LONG64, BytesReceivedTotal);
269 DECL_GETTER (BSTR, User);
270 DECL_GETTER (BSTR, Domain);
271 DECL_GETTER (BSTR, ClientName);
272 DECL_GETTER (BSTR, ClientIP);
273 DECL_GETTER (ULONG, ClientVersion);
274 DECL_GETTER (ULONG, EncryptionStyle);
275 #undef DECL_GETTER
276
277private:
278
279 Console * const mParent;
280};
281
282#endif // ____H_CONSOLEVRDPSERVER
283/* 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