VirtualBox

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

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

Main: separate internal machine data structs into MachineImplPrivate.h to significantly speed up compilation and for better interface separation; remove obsolete ConsoleEvents.h file

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.7 KB
Line 
1/* $Id: ConsoleVRDPServer.h 30760 2010-07-09 13:12:04Z 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
23class Console;
24class RemoteUSBBackend;
25
26#include <hgcm/HGCM.h>
27
28#include <VBox/VRDPAuth.h>
29
30#include <VBox/HostServices/VBoxClipboardExt.h>
31
32#include "SchemaDefs.h"
33
34// ConsoleVRDPServer
35///////////////////////////////////////////////////////////////////////////////
36
37#ifdef VBOX_WITH_VRDP
38typedef struct _VRDPInputSynch
39{
40 int cGuestNumLockAdaptions;
41 int cGuestCapsLockAdaptions;
42
43 bool fGuestNumLock;
44 bool fGuestCapsLock;
45 bool fGuestScrollLock;
46
47 bool fClientNumLock;
48 bool fClientCapsLock;
49 bool fClientScrollLock;
50} VRDPInputSynch;
51#endif /* VBOX_WITH_VRDP */
52
53/* Member of Console. Helper class for VRDP server management. Not a COM class. */
54class ConsoleVRDPServer
55{
56public:
57 ConsoleVRDPServer(Console *console);
58 ~ConsoleVRDPServer();
59
60 int Launch (void);
61
62 void NotifyAbsoluteMouse (bool fGuestWantsAbsolute)
63 {
64#ifdef VBOX_WITH_VRDP
65 m_fGuestWantsAbsolute = fGuestWantsAbsolute;
66#else
67 NOREF(fGuestWantsAbsolute);
68#endif /* VBOX_WITH_VRDP */
69 }
70
71 void NotifyKeyboardLedsChange (BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
72 {
73#ifdef VBOX_WITH_VRDP
74 bool fGuestNumLock = (fNumLock != FALSE);
75 bool fGuestCapsLock = (fCapsLock != FALSE);
76 bool fGuestScrollLock = (fScrollLock != FALSE);
77
78 /* Might need to resynch in case the guest itself changed the LED status. */
79 if (m_InputSynch.fClientNumLock != fGuestNumLock)
80 {
81 m_InputSynch.cGuestNumLockAdaptions = 2;
82 }
83
84 if (m_InputSynch.fClientCapsLock != fGuestCapsLock)
85 {
86 m_InputSynch.cGuestCapsLockAdaptions = 2;
87 }
88
89 m_InputSynch.fGuestNumLock = fGuestNumLock;
90 m_InputSynch.fGuestCapsLock = fGuestCapsLock;
91 m_InputSynch.fGuestScrollLock = fGuestScrollLock;
92#else
93 NOREF(fNumLock);
94 NOREF(fCapsLock);
95 NOREF(fScrollLock);
96#endif /* VBOX_WITH_VRDP */
97 }
98
99 void EnableConnections (void);
100 void DisconnectClient (uint32_t u32ClientId, bool fReconnect);
101 void MousePointerUpdate (const VRDPCOLORPOINTER *pPointer);
102 void MousePointerHide (void);
103
104 void Stop (void);
105
106 VRDPAuthResult Authenticate (const Guid &uuid, VRDPAuthGuestJudgement guestJudgement,
107 const char *pszUser, const char *pszPassword, const char *pszDomain,
108 uint32_t u32ClientId);
109
110 void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
111
112 void USBBackendCreate (uint32_t u32ClientId, void **ppvIntercept);
113 void USBBackendDelete (uint32_t u32ClientId);
114
115 void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
116 void USBBackendReleasePointer (const Guid *pGuid);
117
118 /* Private interface for the RemoteUSBBackend destructor. */
119 void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
120
121 /* Private methods for the Remote USB thread. */
122 RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
123
124 void notifyRemoteUSBThreadRunning (RTTHREAD thread);
125 bool isRemoteUSBThreadRunning (void);
126 void waitRemoteUSBThreadEvent (RTMSINTERVAL cMillies);
127
128 void ClipboardCreate (uint32_t u32ClientId);
129 void ClipboardDelete (uint32_t u32ClientId);
130
131 /*
132 * Forwarders to VRDP server library.
133 */
134 void SendUpdate (unsigned uScreenId, void *pvUpdate, uint32_t cbUpdate) const;
135 void SendResize (void) const;
136 void SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const;
137
138 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format) const;
139 void SendAudioVolume (uint16_t left, uint16_t right) const;
140 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const;
141
142 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const;
143
144private:
145 /* Note: This is not a ComObjPtr here, because the ConsoleVRDPServer object
146 * is actually just a part of the Console.
147 */
148 Console *mConsole;
149
150#ifdef VBOX_WITH_VRDP
151 HVRDPSERVER mhServer;
152
153 static bool loadVRDPLibrary (void);
154
155 /** Static because will never load this more than once! */
156 static RTLDRMOD mVRDPLibrary;
157
158 static PFNVRDPCREATESERVER mpfnVRDPCreateServer;
159
160 static VRDPENTRYPOINTS_1 *mpEntryPoints;
161 static VRDPCALLBACKS_1 mCallbacks;
162
163 static DECLCALLBACK(int) VRDPCallbackQueryProperty (void *pvCallback, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
164 static DECLCALLBACK(int) VRDPCallbackClientLogon (void *pvCallback, uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
165 static DECLCALLBACK(void) VRDPCallbackClientConnect (void *pvCallback, uint32_t u32ClientId);
166 static DECLCALLBACK(void) VRDPCallbackClientDisconnect (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercepted);
167 static DECLCALLBACK(int) VRDPCallbackIntercept (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercept, void **ppvIntercept);
168 static DECLCALLBACK(int) VRDPCallbackUSB (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint8_t u8Code, const void *pvRet, uint32_t cbRet);
169 static DECLCALLBACK(int) VRDPCallbackClipboard (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
170 static DECLCALLBACK(bool) VRDPCallbackFramebufferQuery (void *pvCallback, unsigned uScreenId, VRDPFRAMEBUFFERINFO *pInfo);
171 static DECLCALLBACK(void) VRDPCallbackFramebufferLock (void *pvCallback, unsigned uScreenId);
172 static DECLCALLBACK(void) VRDPCallbackFramebufferUnlock (void *pvCallback, unsigned uScreenId);
173 static DECLCALLBACK(void) VRDPCallbackInput (void *pvCallback, int type, const void *pvInput, unsigned cbInput);
174 static DECLCALLBACK(void) VRDPCallbackVideoModeHint (void *pvCallback, unsigned cWidth, unsigned cHeight, unsigned cBitsPerPixel, unsigned uScreenId);
175
176 bool m_fGuestWantsAbsolute;
177 int m_mousex;
178 int m_mousey;
179
180 IFramebuffer *maFramebuffers[SchemaDefs::MaxGuestMonitors];
181
182 IEventListener *mConsoleListener;
183
184 VRDPInputSynch m_InputSynch;
185
186 int32_t mVRDPBindPort;
187#endif /* VBOX_WITH_VRDP */
188
189 RTCRITSECT mCritSect;
190
191 int lockConsoleVRDPServer (void);
192 void unlockConsoleVRDPServer (void);
193
194 int mcClipboardRefs;
195 HGCMSVCEXTHANDLE mhClipboard;
196 PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback;
197
198 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
199 static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
200
201#ifdef VBOX_WITH_USB
202 RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
203 RemoteUSBBackend *usbBackendFind (uint32_t u32ClientId);
204
205 typedef struct _USBBackends
206 {
207 RemoteUSBBackend *pHead;
208 RemoteUSBBackend *pTail;
209
210 RTTHREAD thread;
211
212 bool fThreadRunning;
213
214 RTSEMEVENT event;
215 } USBBackends;
216
217 USBBackends mUSBBackends;
218
219 void remoteUSBThreadStart (void);
220 void remoteUSBThreadStop (void);
221#endif /* VBOX_WITH_USB */
222
223 /* External authentication library handle. The library is loaded in the
224 * Authenticate method and unloaded at the object destructor.
225 */
226 RTLDRMOD mAuthLibrary;
227 PVRDPAUTHENTRY mpfnAuthEntry;
228 PVRDPAUTHENTRY2 mpfnAuthEntry2;
229};
230
231
232class Console;
233
234class ATL_NO_VTABLE RemoteDisplayInfo :
235 public VirtualBoxBase,
236 VBOX_SCRIPTABLE_IMPL(IRemoteDisplayInfo)
237{
238public:
239
240 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(RemoteDisplayInfo, IRemoteDisplayInfo)
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
280private:
281
282 Console * const mParent;
283};
284
285#endif // ____H_CONSOLEVRDPSERVER
286/* 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