VirtualBox

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

Last change on this file since 2602 was 2527, checked in by vboxsync, 17 years ago

Check VRDP multiconnection property. A new external authentication prototype for multiconnection.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1/** @file
2 *
3 * VBox Console VRDP Helper class and implementation of IRemoteDisplayInfo
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung 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 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef ____H_CONSOLEVRDPSERVER
23#define ____H_CONSOLEVRDPSERVER
24
25#include "RemoteUSBBackend.h"
26#include <hgcm/HGCM.h>
27
28#include <VBox/VRDPAuth.h>
29
30#include <VBox/HostServices/VBoxClipboardExt.h>
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 void SetCallback (void);
44 void Stop (void);
45
46 VRDPAuthResult Authenticate (const Guid &uuid, VRDPAuthGuestJudgement guestJudgement,
47 const char *pszUser, const char *pszPassword, const char *pszDomain,
48 uint32_t u32ClientId);
49
50 void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
51
52#ifdef VRDP_MC
53 void USBBackendCreate (uint32_t u32ClientId, PFNVRDPUSBCALLBACK *ppfn, void **ppv);
54 void USBBackendDelete (uint32_t u32ClientId);
55
56 void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
57 void USBBackendReleasePointer (const Guid *pGuid);
58
59 /* Private interface for the RemoteUSBBackend destructor. */
60 void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
61
62 /* Private methods for the Remote USB thread. */
63 RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
64
65 void notifyRemoteUSBThreadRunning (RTTHREAD thread);
66 bool isRemoteUSBThreadRunning (void);
67 void waitRemoteUSBThreadEvent (unsigned cMillies);
68
69 void ClipboardCreate (uint32_t u32ClientId, PFNVRDPCLIPBOARDCALLBACK *ppfn, void **ppv);
70 void ClipboardDelete (uint32_t u32ClientId);
71#else
72 void CreateUSBBackend (PFNVRDPUSBCALLBACK *ppfn, void **ppv);
73 void DeleteUSBBackend (void);
74
75 void *GetUSBBackendPointer (void);
76#endif /* VRDP_MC */
77
78 /*
79 * Forwarders to VRDP server library.
80 */
81 void SendUpdate (void *pvUpdate, uint32_t cbUpdate) const;
82 void SendResize (void) const;
83 void SendUpdateBitmap (uint32_t x, uint32_t y, uint32_t w, uint32_t h) const;
84 void SetFramebuffer (IFramebuffer *framebuffer, uint32_t fFlags) const;
85
86 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format) const;
87 void SendAudioVolume (uint16_t left, uint16_t right) const;
88#ifdef VRDP_MC
89 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const;
90#else
91 void SendUSBRequest (void *pvParms, uint32_t cbParms) const;
92#endif /* VRDP_MC */
93
94 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const;
95
96private:
97 /* Note: This is not a ComObjPtr here, because the ConsoleVRDPServer object
98 * is actually just a part of the Console.
99 */
100 Console *mConsole;
101
102#ifdef VBOX_VRDP
103 HVRDPSERVER mhServer;
104
105 static bool loadVRDPLibrary (void);
106
107 /** Static because will never load this more than once! */
108 static RTLDRMOD mVRDPLibrary;
109
110 // VRDP API function pointers
111 static int (VBOXCALL *mpfnVRDPStartServer) (IConsole *pConsole, IVRDPServer *pVRDPServer, HVRDPSERVER *phServer);
112 static int (VBOXCALL *mpfnVRDPSetFramebuffer) (HVRDPSERVER hServer, IFramebuffer *pFramebuffer, uint32_t fFlags);
113 static void (VBOXCALL *mpfnVRDPSetCallback) (HVRDPSERVER hServer, VRDPSERVERCALLBACK *pcallback, void *pvUser);
114 static void (VBOXCALL *mpfnVRDPShutdownServer) (HVRDPSERVER hServer);
115 static void (VBOXCALL *mpfnVRDPSendUpdateBitmap)(HVRDPSERVER hServer, unsigned x, unsigned y, unsigned w, unsigned h);
116 static void (VBOXCALL *mpfnVRDPSendResize) (HVRDPSERVER hServer);
117 static void (VBOXCALL *mpfnVRDPSendAudioSamples)(HVRDPSERVER hserver, void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format);
118 static void (VBOXCALL *mpfnVRDPSendAudioVolume) (HVRDPSERVER hserver, uint16_t left, uint16_t right);
119#ifdef VRDP_MC
120 static void (VBOXCALL *mpfnVRDPSendUSBRequest) (HVRDPSERVER hserver, uint32_t u32ClientId, void *pvParms, uint32_t cbParms);
121#else
122 static void (VBOXCALL *mpfnVRDPSendUSBRequest) (HVRDPSERVER hserver, void *pvParms, uint32_t cbParms);
123#endif /* VRDP_MC */
124 static void (VBOXCALL *mpfnVRDPSendUpdate) (HVRDPSERVER hServer, void *pvUpdate, uint32_t cbUpdate);
125 static void (VBOXCALL *mpfnVRDPQueryInfo) (HVRDPSERVER hserver, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
126 static void (VBOXCALL *mpfnVRDPClipboard) (HVRDPSERVER hserver, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData, uint32_t *pcbActualRead);
127#endif /* VBOX_VRDP */
128
129#ifdef VRDP_MC
130 RTCRITSECT mCritSect;
131
132 int lockConsoleVRDPServer (void);
133 void unlockConsoleVRDPServer (void);
134
135 int mcClipboardRefs;
136 HGCMSVCEXTHANDLE mhClipboard;
137 PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback;
138
139 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
140 static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
141
142#ifdef VBOX_WITH_USB
143 RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
144 RemoteUSBBackend *usbBackendFind (uint32_t u32ClientId);
145
146 typedef struct _USBBackends
147 {
148 RemoteUSBBackend *pHead;
149 RemoteUSBBackend *pTail;
150
151 RTTHREAD thread;
152
153 bool fThreadRunning;
154
155 RTSEMEVENT event;
156 } USBBackends;
157
158 USBBackends mUSBBackends;
159
160 void remoteUSBThreadStart (void);
161 void remoteUSBThreadStop (void);
162#endif /* VBOX_WITH_USB */
163#else
164#ifdef VBOX_WITH_USB
165 /* The remote USB backend object is created only if the client
166 * asks for USB channel. The object is created in the vrdp_InterceptUSB
167 * callback.
168 */
169 RemoteUSBBackend *mRemoteUSBBackend;
170#endif /* VBOX_WITH_USB */
171#endif /* VRDP_MC */
172
173 /* External authentication library handle. The library is loaded in the
174 * Authenticate method and unloaded at the object destructor.
175 */
176 RTLDRMOD mAuthLibrary;
177 PVRDPAUTHENTRY mpfnAuthEntry;
178 PVRDPAUTHENTRY2 mpfnAuthEntry2;
179};
180
181
182class Console;
183
184class ATL_NO_VTABLE RemoteDisplayInfo :
185 public VirtualBoxSupportErrorInfoImpl <RemoteDisplayInfo, IRemoteDisplayInfo>,
186 public VirtualBoxSupportTranslation <RemoteDisplayInfo>,
187 public VirtualBoxBase,
188 public IRemoteDisplayInfo
189{
190public:
191
192 DECLARE_NOT_AGGREGATABLE(RemoteDisplayInfo)
193
194 DECLARE_PROTECT_FINAL_CONSTRUCT()
195
196 BEGIN_COM_MAP(RemoteDisplayInfo)
197 COM_INTERFACE_ENTRY(ISupportErrorInfo)
198 COM_INTERFACE_ENTRY(IRemoteDisplayInfo)
199 END_COM_MAP()
200
201 NS_DECL_ISUPPORTS
202
203 HRESULT FinalConstruct();
204 void FinalRelease();
205
206 /* Public initializer/uninitializer for internal purposes only. */
207 HRESULT init (Console *aParent);
208 void uninit();
209
210 /* IRemoteDisplayInfo properties */
211 #define DECL_GETTER(_aType, _aName) STDMETHOD(COMGETTER(_aName)) (_aType *a##_aName)
212 DECL_GETTER (BOOL, Active);
213 DECL_GETTER (ULONG, NumberOfClients);
214 DECL_GETTER (LONG64, BeginTime);
215 DECL_GETTER (LONG64, EndTime);
216 DECL_GETTER (ULONG64, BytesSent);
217 DECL_GETTER (ULONG64, BytesSentTotal);
218 DECL_GETTER (ULONG64, BytesReceived);
219 DECL_GETTER (ULONG64, BytesReceivedTotal);
220 DECL_GETTER (BSTR, User);
221 DECL_GETTER (BSTR, Domain);
222 DECL_GETTER (BSTR, ClientName);
223 DECL_GETTER (BSTR, ClientIP);
224 DECL_GETTER (ULONG, ClientVersion);
225 DECL_GETTER (ULONG, EncryptionStyle);
226 #undef DECL_GETTER
227
228 /* For VirtualBoxSupportErrorInfoImpl. */
229 static const wchar_t *getComponentName() { return L"RemoteDisplayInfo"; }
230
231private:
232
233 ComObjPtr <Console, ComWeakRef> mParent;
234};
235
236#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