VirtualBox

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

Last change on this file since 21525 was 19239, checked in by vboxsync, 16 years ago

Main: support for using VBox from Python on Windows (still certain limitation apply, such as enum visibility)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.1 KB
Line 
1/* $Id: ConsoleVRDPServer.h 19239 2009-04-28 13:19:14Z vboxsync $ */
2
3/** @file
4 *
5 * VBox Console VRDP Helper class and implementation of IRemoteDisplayInfo
6 */
7
8/*
9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_CONSOLEVRDPSERVER
25#define ____H_CONSOLEVRDPSERVER
26
27#include "RemoteUSBBackend.h"
28#include <hgcm/HGCM.h>
29
30#include <VBox/VRDPAuth.h>
31
32#include <VBox/HostServices/VBoxClipboardExt.h>
33
34#include "SchemaDefs.h"
35
36// ConsoleVRDPServer
37///////////////////////////////////////////////////////////////////////////////
38
39#ifdef VBOX_WITH_VRDP
40typedef struct _VRDPInputSynch
41{
42 int cGuestNumLockAdaptions;
43 int cGuestCapsLockAdaptions;
44
45 bool fGuestNumLock;
46 bool fGuestCapsLock;
47 bool fGuestScrollLock;
48
49 bool fClientNumLock;
50 bool fClientCapsLock;
51 bool fClientScrollLock;
52} VRDPInputSynch;
53#endif /* VBOX_WITH_VRDP */
54
55/* Member of Console. Helper class for VRDP server management. Not a COM class. */
56class ConsoleVRDPServer
57{
58public:
59 ConsoleVRDPServer (Console *console);
60 ~ConsoleVRDPServer ();
61
62 int Launch (void);
63
64 void NotifyAbsoluteMouse (bool fGuestWantsAbsolute)
65 {
66#ifdef VBOX_WITH_VRDP
67 m_fGuestWantsAbsolute = fGuestWantsAbsolute;
68#else
69 NOREF(fGuestWantsAbsolute);
70#endif /* VBOX_WITH_VRDP */
71 }
72
73 void NotifyKeyboardLedsChange (BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
74 {
75#ifdef VBOX_WITH_VRDP
76 bool fGuestNumLock = (fNumLock != FALSE);
77 bool fGuestCapsLock = (fCapsLock != FALSE);
78 bool fGuestScrollLock = (fScrollLock != FALSE);
79
80 /* Might need to resynch in case the guest itself changed the LED status. */
81 if (m_InputSynch.fClientNumLock != fGuestNumLock)
82 {
83 m_InputSynch.cGuestNumLockAdaptions = 2;
84 }
85
86 if (m_InputSynch.fClientCapsLock != fGuestCapsLock)
87 {
88 m_InputSynch.cGuestCapsLockAdaptions = 2;
89 }
90
91 m_InputSynch.fGuestNumLock = fGuestNumLock;
92 m_InputSynch.fGuestCapsLock = fGuestCapsLock;
93 m_InputSynch.fGuestScrollLock = fGuestScrollLock;
94#else
95 NOREF(fNumLock);
96 NOREF(fCapsLock);
97 NOREF(fScrollLock);
98#endif /* VBOX_WITH_VRDP */
99 }
100
101 void EnableConnections (void);
102 void DisconnectClient (uint32_t u32ClientId, bool fReconnect);
103 void MousePointerUpdate (const VRDPCOLORPOINTER *pPointer);
104 void MousePointerHide (void);
105
106 void Stop (void);
107
108 VRDPAuthResult Authenticate (const Guid &uuid, VRDPAuthGuestJudgement guestJudgement,
109 const char *pszUser, const char *pszPassword, const char *pszDomain,
110 uint32_t u32ClientId);
111
112 void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
113
114 void USBBackendCreate (uint32_t u32ClientId, void **ppvIntercept);
115 void USBBackendDelete (uint32_t u32ClientId);
116
117 void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
118 void USBBackendReleasePointer (const Guid *pGuid);
119
120 /* Private interface for the RemoteUSBBackend destructor. */
121 void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
122
123 /* Private methods for the Remote USB thread. */
124 RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
125
126 void notifyRemoteUSBThreadRunning (RTTHREAD thread);
127 bool isRemoteUSBThreadRunning (void);
128 void waitRemoteUSBThreadEvent (unsigned cMillies);
129
130 void ClipboardCreate (uint32_t u32ClientId);
131 void ClipboardDelete (uint32_t u32ClientId);
132
133 /*
134 * Forwarders to VRDP server library.
135 */
136 void SendUpdate (unsigned uScreenId, void *pvUpdate, uint32_t cbUpdate) const;
137 void SendResize (void) const;
138 void SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const;
139
140 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format) const;
141 void SendAudioVolume (uint16_t left, uint16_t right) const;
142 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const;
143
144 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const;
145
146private:
147 /* Note: This is not a ComObjPtr here, because the ConsoleVRDPServer object
148 * is actually just a part of the Console.
149 */
150 Console *mConsole;
151
152#ifdef VBOX_WITH_VRDP
153 HVRDPSERVER mhServer;
154
155 static bool loadVRDPLibrary (void);
156
157 /** Static because will never load this more than once! */
158 static RTLDRMOD mVRDPLibrary;
159
160 static PFNVRDPCREATESERVER mpfnVRDPCreateServer;
161
162 static VRDPENTRYPOINTS_1 *mpEntryPoints;
163 static VRDPCALLBACKS_1 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, VRDPFRAMEBUFFERINFO *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
178 bool m_fGuestWantsAbsolute;
179 int m_mousex;
180 int m_mousey;
181
182 IFramebuffer *maFramebuffers[SchemaDefs::MaxGuestMonitors];
183
184 IConsoleCallback *mConsoleCallback;
185
186 VRDPInputSynch m_InputSynch;
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 VirtualBoxBaseNEXT,
236 public VirtualBoxSupportErrorInfoImpl <RemoteDisplayInfo, IRemoteDisplayInfo>,
237 public VirtualBoxSupportTranslation <RemoteDisplayInfo>,
238 VBOX_SCRIPTABLE_IMPL(IRemoteDisplayInfo)
239{
240public:
241
242 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (RemoteDisplayInfo)
243
244 DECLARE_NOT_AGGREGATABLE(RemoteDisplayInfo)
245
246 DECLARE_PROTECT_FINAL_CONSTRUCT()
247
248 BEGIN_COM_MAP(RemoteDisplayInfo)
249 COM_INTERFACE_ENTRY(ISupportErrorInfo)
250 COM_INTERFACE_ENTRY(IRemoteDisplayInfo)
251 COM_INTERFACE_ENTRY(IDispatch)
252 END_COM_MAP()
253
254 NS_DECL_ISUPPORTS
255
256 DECLARE_EMPTY_CTOR_DTOR (RemoteDisplayInfo)
257
258 HRESULT FinalConstruct();
259 void FinalRelease();
260
261 /* Public initializer/uninitializer for internal purposes only. */
262 HRESULT init (Console *aParent);
263 void uninit();
264
265 /* IRemoteDisplayInfo properties */
266 #define DECL_GETTER(_aType, _aName) STDMETHOD(COMGETTER(_aName)) (_aType *a##_aName)
267 DECL_GETTER (BOOL, Active);
268 DECL_GETTER (ULONG, NumberOfClients);
269 DECL_GETTER (LONG64, BeginTime);
270 DECL_GETTER (LONG64, EndTime);
271 DECL_GETTER (ULONG64, BytesSent);
272 DECL_GETTER (ULONG64, BytesSentTotal);
273 DECL_GETTER (ULONG64, BytesReceived);
274 DECL_GETTER (ULONG64, BytesReceivedTotal);
275 DECL_GETTER (BSTR, User);
276 DECL_GETTER (BSTR, Domain);
277 DECL_GETTER (BSTR, ClientName);
278 DECL_GETTER (BSTR, ClientIP);
279 DECL_GETTER (ULONG, ClientVersion);
280 DECL_GETTER (ULONG, EncryptionStyle);
281 #undef DECL_GETTER
282
283 /* For VirtualBoxSupportErrorInfoImpl. */
284 static const wchar_t *getComponentName() { return L"RemoteDisplayInfo"; }
285
286private:
287
288 const ComObjPtr <Console, ComWeakRef> mParent;
289};
290
291#endif // ____H_CONSOLEVRDPSERVER
292/* 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