VirtualBox

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

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

Fixing Linux build.

  • 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
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);
124#endif
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 RTSEMEVENTMULTI mEventClipboardData;
137 void *mpvClipboardData;
138 uint32_t mcbClipboardData;
139 volatile uint32_t mfu32ClipboardWaitData;
140
141 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
142 static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
143
144#ifdef VBOX_WITH_USB
145 RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
146 RemoteUSBBackend *usbBackendFind (uint32_t u32ClientId);
147
148 typedef struct _USBBackends
149 {
150 RemoteUSBBackend *pHead;
151 RemoteUSBBackend *pTail;
152
153 RTTHREAD thread;
154
155 bool fThreadRunning;
156
157 RTSEMEVENT event;
158 } USBBackends;
159
160 USBBackends mUSBBackends;
161
162 void remoteUSBThreadStart (void);
163 void remoteUSBThreadStop (void);
164#endif /* VBOX_WITH_USB */
165#else
166#ifdef VBOX_WITH_USB
167 /* The remote USB backend object is created only if the client
168 * asks for USB channel. The object is created in the vrdp_InterceptUSB
169 * callback.
170 */
171 RemoteUSBBackend *mRemoteUSBBackend;
172#endif /* VBOX_WITH_USB */
173#endif /* VRDP_MC */
174
175 /* External authentication library handle. The library is loaded in the
176 * Authenticate method and unloaded at the object destructor.
177 */
178 RTLDRMOD mAuthLibrary;
179 PVRDPAUTHENTRY mpfnAuthEntry;
180};
181
182
183class Console;
184
185class ATL_NO_VTABLE RemoteDisplayInfo :
186 public VirtualBoxSupportErrorInfoImpl <RemoteDisplayInfo, IRemoteDisplayInfo>,
187 public VirtualBoxSupportTranslation <RemoteDisplayInfo>,
188 public VirtualBoxBase,
189 public IRemoteDisplayInfo
190{
191public:
192
193 DECLARE_NOT_AGGREGATABLE(RemoteDisplayInfo)
194
195 DECLARE_PROTECT_FINAL_CONSTRUCT()
196
197 BEGIN_COM_MAP(RemoteDisplayInfo)
198 COM_INTERFACE_ENTRY(ISupportErrorInfo)
199 COM_INTERFACE_ENTRY(IRemoteDisplayInfo)
200 END_COM_MAP()
201
202 NS_DECL_ISUPPORTS
203
204 HRESULT FinalConstruct();
205 void FinalRelease();
206
207 /* Public initializer/uninitializer for internal purposes only. */
208 HRESULT init (Console *aParent);
209 void uninit();
210
211 /* IRemoteDisplayInfo properties */
212 #define DECL_GETTER(_aType, _aName) STDMETHOD(COMGETTER(_aName)) (_aType *a##_aName)
213 DECL_GETTER (BOOL, Active);
214 DECL_GETTER (ULONG, NumberOfClients);
215 DECL_GETTER (LONG64, BeginTime);
216 DECL_GETTER (LONG64, EndTime);
217 DECL_GETTER (ULONG64, BytesSent);
218 DECL_GETTER (ULONG64, BytesSentTotal);
219 DECL_GETTER (ULONG64, BytesReceived);
220 DECL_GETTER (ULONG64, BytesReceivedTotal);
221 DECL_GETTER (BSTR, User);
222 DECL_GETTER (BSTR, Domain);
223 DECL_GETTER (BSTR, ClientName);
224 DECL_GETTER (BSTR, ClientIP);
225 DECL_GETTER (ULONG, ClientVersion);
226 DECL_GETTER (ULONG, EncryptionStyle);
227 #undef DECL_GETTER
228
229 /* For VirtualBoxSupportErrorInfoImpl. */
230 static const wchar_t *getComponentName() { return L"RemoteDisplayInfo"; }
231
232private:
233
234 ComObjPtr <Console, ComWeakRef> mParent;
235};
236
237#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