VirtualBox

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

Last change on this file since 4753 was 4404, checked in by vboxsync, 17 years ago

Fixed the initialization of the remote USB channel.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.4 KB
Line 
1/** @file
2 *
3 * VBox Console VRDP Helper class and implementation of IRemoteDisplayInfo
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * 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/HGCM.h>
23
24#include <VBox/VRDPAuth.h>
25
26#include <VBox/HostServices/VBoxClipboardExt.h>
27
28#ifdef VRDP_NO_COM
29#include "SchemaDefs.h"
30#endif /* VRDP_NO_COM */
31
32// ConsoleVRDPServer
33///////////////////////////////////////////////////////////////////////////////
34
35/* Member of Console. Helper class for VRDP server management. Not a COM class. */
36class ConsoleVRDPServer
37{
38public:
39 ConsoleVRDPServer (Console *console);
40 ~ConsoleVRDPServer ();
41
42 int Launch (void);
43#ifdef VRDP_NO_COM
44 void NotifyAbsoluteMouse (bool fGuestWantsAbsolute)
45 {
46 m_fGuestWantsAbsolute = fGuestWantsAbsolute;
47 }
48
49 void EnableConnections (void);
50 void MousePointerUpdate (const VRDPCOLORPOINTER *pPointer);
51 void MousePointerHide (void);
52#else
53 void SetCallback (void);
54#endif /* VRDP_NO_COM */
55 void Stop (void);
56
57 VRDPAuthResult Authenticate (const Guid &uuid, VRDPAuthGuestJudgement guestJudgement,
58 const char *pszUser, const char *pszPassword, const char *pszDomain,
59 uint32_t u32ClientId);
60
61 void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
62
63#ifdef VRDP_NO_COM
64 void USBBackendCreate (uint32_t u32ClientId, void **ppvIntercept);
65#else
66 void USBBackendCreate (uint32_t u32ClientId, PFNVRDPUSBCALLBACK *ppfn, void **ppv);
67#endif /* VRDP_NO_COM */
68 void USBBackendDelete (uint32_t u32ClientId);
69
70 void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
71 void USBBackendReleasePointer (const Guid *pGuid);
72
73 /* Private interface for the RemoteUSBBackend destructor. */
74 void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
75
76 /* Private methods for the Remote USB thread. */
77 RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
78
79 void notifyRemoteUSBThreadRunning (RTTHREAD thread);
80 bool isRemoteUSBThreadRunning (void);
81 void waitRemoteUSBThreadEvent (unsigned cMillies);
82
83#ifdef VRDP_NO_COM
84 void ClipboardCreate (uint32_t u32ClientId);
85#else
86 void ClipboardCreate (uint32_t u32ClientId, PFNVRDPCLIPBOARDCALLBACK *ppfn, void **ppv);
87#endif /* VRDP_NO_COM */
88 void ClipboardDelete (uint32_t u32ClientId);
89
90 /*
91 * Forwarders to VRDP server library.
92 */
93 void SendUpdate (unsigned uScreenId, void *pvUpdate, uint32_t cbUpdate) const;
94 void SendResize (void) const;
95 void SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const;
96#ifdef VRDP_NO_COM
97#else
98 void SetFramebuffer (IFramebuffer *framebuffer, uint32_t fFlags) const;
99#endif /* VRDP_NO_COM */
100
101 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format) const;
102 void SendAudioVolume (uint16_t left, uint16_t right) const;
103 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const;
104
105 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const;
106
107private:
108 /* Note: This is not a ComObjPtr here, because the ConsoleVRDPServer object
109 * is actually just a part of the Console.
110 */
111 Console *mConsole;
112
113#ifdef VBOX_VRDP
114 HVRDPSERVER mhServer;
115
116 static bool loadVRDPLibrary (void);
117
118 /** Static because will never load this more than once! */
119 static RTLDRMOD mVRDPLibrary;
120
121#ifdef VRDP_NO_COM
122 static PFNVRDPCREATESERVER mpfnVRDPCreateServer;
123
124 static VRDPENTRYPOINTS_1 *mpEntryPoints;
125 static VRDPCALLBACKS_1 mCallbacks;
126
127 static DECLCALLBACK(int) VRDPCallbackQueryProperty (void *pvCallback, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
128 static DECLCALLBACK(int) VRDPCallbackClientLogon (void *pvCallback, uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
129 static DECLCALLBACK(void) VRDPCallbackClientConnect (void *pvCallback, uint32_t u32ClientId);
130 static DECLCALLBACK(void) VRDPCallbackClientDisconnect (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercepted);
131 static DECLCALLBACK(int) VRDPCallbackIntercept (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercept, void **ppvIntercept);
132 static DECLCALLBACK(int) VRDPCallbackUSB (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint8_t u8Code, const void *pvRet, uint32_t cbRet);
133 static DECLCALLBACK(int) VRDPCallbackClipboard (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
134 static DECLCALLBACK(bool) VRDPCallbackFramebufferQuery (void *pvCallback, unsigned uScreenId, VRDPFRAMEBUFFERINFO *pInfo);
135 static DECLCALLBACK(void) VRDPCallbackFramebufferLock (void *pvCallback, unsigned uScreenId);
136 static DECLCALLBACK(void) VRDPCallbackFramebufferUnlock (void *pvCallback, unsigned uScreenId);
137 static DECLCALLBACK(void) VRDPCallbackInput (void *pvCallback, int type, const void *pvInput, unsigned cbInput);
138 static DECLCALLBACK(void) VRDPCallbackVideoModeHint (void *pvCallback, unsigned cWidth, unsigned cHeight, unsigned cBitsPerPixel, unsigned uScreenId);
139
140 bool m_fGuestWantsAbsolute;
141 int m_mousex;
142 int m_mousey;
143
144 IFramebuffer *maFramebuffers[SchemaDefs::MaxGuestMonitors];
145
146 IConsoleCallback *mConsoleCallback;
147#else
148 // VRDP API function pointers
149 static int (VBOXCALL *mpfnVRDPStartServer) (IConsole *pConsole, IVRDPServer *pVRDPServer, HVRDPSERVER *phServer);
150 static int (VBOXCALL *mpfnVRDPSetFramebuffer) (HVRDPSERVER hServer, IFramebuffer *pFramebuffer, uint32_t fFlags);
151 static void (VBOXCALL *mpfnVRDPSetCallback) (HVRDPSERVER hServer, VRDPSERVERCALLBACK *pcallback, void *pvUser);
152 static void (VBOXCALL *mpfnVRDPShutdownServer) (HVRDPSERVER hServer);
153 static void (VBOXCALL *mpfnVRDPSendUpdateBitmap)(HVRDPSERVER hServer, unsigned uScreenId, unsigned x, unsigned y, unsigned w, unsigned h);
154 static void (VBOXCALL *mpfnVRDPSendResize) (HVRDPSERVER hServer);
155 static void (VBOXCALL *mpfnVRDPSendAudioSamples)(HVRDPSERVER hserver, void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format);
156 static void (VBOXCALL *mpfnVRDPSendAudioVolume) (HVRDPSERVER hserver, uint16_t left, uint16_t right);
157 static void (VBOXCALL *mpfnVRDPSendUSBRequest) (HVRDPSERVER hserver, uint32_t u32ClientId, void *pvParms, uint32_t cbParms);
158 static void (VBOXCALL *mpfnVRDPSendUpdate) (HVRDPSERVER hServer, unsigned uScreenId, void *pvUpdate, uint32_t cbUpdate);
159 static void (VBOXCALL *mpfnVRDPQueryInfo) (HVRDPSERVER hserver, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
160 static void (VBOXCALL *mpfnVRDPClipboard) (HVRDPSERVER hserver, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData, uint32_t *pcbActualRead);
161#endif /* VRDP_NO_COM */
162#endif /* VBOX_VRDP */
163
164 RTCRITSECT mCritSect;
165
166 int lockConsoleVRDPServer (void);
167 void unlockConsoleVRDPServer (void);
168
169 int mcClipboardRefs;
170 HGCMSVCEXTHANDLE mhClipboard;
171 PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback;
172
173 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
174 static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
175
176#ifdef VBOX_WITH_USB
177 RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
178 RemoteUSBBackend *usbBackendFind (uint32_t u32ClientId);
179
180 typedef struct _USBBackends
181 {
182 RemoteUSBBackend *pHead;
183 RemoteUSBBackend *pTail;
184
185 RTTHREAD thread;
186
187 bool fThreadRunning;
188
189 RTSEMEVENT event;
190 } USBBackends;
191
192 USBBackends mUSBBackends;
193
194 void remoteUSBThreadStart (void);
195 void remoteUSBThreadStop (void);
196#endif /* VBOX_WITH_USB */
197
198 /* External authentication library handle. The library is loaded in the
199 * Authenticate method and unloaded at the object destructor.
200 */
201 RTLDRMOD mAuthLibrary;
202 PVRDPAUTHENTRY mpfnAuthEntry;
203 PVRDPAUTHENTRY2 mpfnAuthEntry2;
204};
205
206
207class Console;
208
209class ATL_NO_VTABLE RemoteDisplayInfo :
210 public VirtualBoxSupportErrorInfoImpl <RemoteDisplayInfo, IRemoteDisplayInfo>,
211 public VirtualBoxSupportTranslation <RemoteDisplayInfo>,
212 public VirtualBoxBase,
213 public IRemoteDisplayInfo
214{
215public:
216
217 DECLARE_NOT_AGGREGATABLE(RemoteDisplayInfo)
218
219 DECLARE_PROTECT_FINAL_CONSTRUCT()
220
221 BEGIN_COM_MAP(RemoteDisplayInfo)
222 COM_INTERFACE_ENTRY(ISupportErrorInfo)
223 COM_INTERFACE_ENTRY(IRemoteDisplayInfo)
224 END_COM_MAP()
225
226 NS_DECL_ISUPPORTS
227
228 HRESULT FinalConstruct();
229 void FinalRelease();
230
231 /* Public initializer/uninitializer for internal purposes only. */
232 HRESULT init (Console *aParent);
233 void uninit();
234
235 /* IRemoteDisplayInfo properties */
236 #define DECL_GETTER(_aType, _aName) STDMETHOD(COMGETTER(_aName)) (_aType *a##_aName)
237 DECL_GETTER (BOOL, Active);
238 DECL_GETTER (ULONG, NumberOfClients);
239 DECL_GETTER (LONG64, BeginTime);
240 DECL_GETTER (LONG64, EndTime);
241 DECL_GETTER (ULONG64, BytesSent);
242 DECL_GETTER (ULONG64, BytesSentTotal);
243 DECL_GETTER (ULONG64, BytesReceived);
244 DECL_GETTER (ULONG64, BytesReceivedTotal);
245 DECL_GETTER (BSTR, User);
246 DECL_GETTER (BSTR, Domain);
247 DECL_GETTER (BSTR, ClientName);
248 DECL_GETTER (BSTR, ClientIP);
249 DECL_GETTER (ULONG, ClientVersion);
250 DECL_GETTER (ULONG, EncryptionStyle);
251 #undef DECL_GETTER
252
253 /* For VirtualBoxSupportErrorInfoImpl. */
254 static const wchar_t *getComponentName() { return L"RemoteDisplayInfo"; }
255
256private:
257
258 ComObjPtr <Console, ComWeakRef> mParent;
259};
260
261#endif // ____H_CONSOLEVRDPSERVER
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