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