VirtualBox

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

Last change on this file since 2522 was 2522, checked in by vboxsync, 18 years ago

VRDP multiconnection clipboard. The VRDP server always works in multiconnection mode.

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