1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox Remote USB backend
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek 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_REMOTEUSBBACKEND
|
---|
23 | #define ____H_REMOTEUSBBACKEND
|
---|
24 |
|
---|
25 | #include "RemoteUSBDeviceImpl.h"
|
---|
26 |
|
---|
27 | #include <VBox/vrdpapi.h>
|
---|
28 | #include <VBox/vrdpusb.h>
|
---|
29 |
|
---|
30 | typedef enum
|
---|
31 | {
|
---|
32 | RDLIdle = 0,
|
---|
33 | RDLReqSent,
|
---|
34 | RDLObtained
|
---|
35 | } RDLState;
|
---|
36 |
|
---|
37 | class Console;
|
---|
38 | class ConsoleVRDPServer;
|
---|
39 |
|
---|
40 | /* How many remote devices can be attached to a remote client.
|
---|
41 | * Normally a client computer has 2-8 physical USB ports, so 16 devices
|
---|
42 | * should be usually enough.
|
---|
43 | */
|
---|
44 | #define VRDP_MAX_USB_DEVICES_PER_CLIENT (16)
|
---|
45 |
|
---|
46 | class RemoteUSBBackendListable
|
---|
47 | {
|
---|
48 | public:
|
---|
49 | RemoteUSBBackendListable *pNext;
|
---|
50 | RemoteUSBBackendListable *pPrev;
|
---|
51 |
|
---|
52 | RemoteUSBBackendListable() : pNext (NULL), pPrev (NULL) {};
|
---|
53 | };
|
---|
54 |
|
---|
55 | class RemoteUSBBackend: public RemoteUSBBackendListable
|
---|
56 | {
|
---|
57 | public:
|
---|
58 | RemoteUSBBackend(Console *console, ConsoleVRDPServer *server, uint32_t u32ClientId);
|
---|
59 | ~RemoteUSBBackend();
|
---|
60 |
|
---|
61 | uint32_t ClientId (void) { return mu32ClientId; }
|
---|
62 |
|
---|
63 | void AddRef (void);
|
---|
64 | void Release (void);
|
---|
65 |
|
---|
66 | void QueryVRDPCallbackPointer (PFNVRDPUSBCALLBACK *ppfn, void **ppv);
|
---|
67 |
|
---|
68 | REMOTEUSBCALLBACK *GetBackendCallbackPointer (void) { return &mCallback; }
|
---|
69 |
|
---|
70 | void NotifyDelete (void);
|
---|
71 |
|
---|
72 | void PollRemoteDevices (void);
|
---|
73 |
|
---|
74 | public: /* Functions for internal use. */
|
---|
75 | ConsoleVRDPServer *VRDPServer (void) { return mServer; };
|
---|
76 |
|
---|
77 | bool pollingEnabledURB (void) { return mfPollURB; }
|
---|
78 |
|
---|
79 | int saveDeviceList (const void *pvList, uint32_t cbList);
|
---|
80 |
|
---|
81 | int negotiateResponse (const VRDPUSBREQNEGOTIATERET *pret);
|
---|
82 |
|
---|
83 | int reapURB (const void *pvBody, uint32_t cbBody);
|
---|
84 |
|
---|
85 | void request (void);
|
---|
86 | void release (void);
|
---|
87 |
|
---|
88 | PREMOTEUSBDEVICE deviceFromId (VRDPUSBDEVID id);
|
---|
89 |
|
---|
90 | void addDevice (PREMOTEUSBDEVICE pDevice);
|
---|
91 | void removeDevice (PREMOTEUSBDEVICE pDevice);
|
---|
92 |
|
---|
93 | bool addUUID (const Guid *pUuid);
|
---|
94 | bool findUUID (const Guid *pUuid);
|
---|
95 | void removeUUID (const Guid *pUuid);
|
---|
96 |
|
---|
97 | private:
|
---|
98 | Console *mConsole;
|
---|
99 | ConsoleVRDPServer *mServer;
|
---|
100 |
|
---|
101 | int cRefs;
|
---|
102 |
|
---|
103 | uint32_t mu32ClientId;
|
---|
104 |
|
---|
105 | RTCRITSECT mCritsect;
|
---|
106 |
|
---|
107 | REMOTEUSBCALLBACK mCallback;
|
---|
108 |
|
---|
109 | bool mfHasDeviceList;
|
---|
110 |
|
---|
111 | void *mpvDeviceList;
|
---|
112 | uint32_t mcbDeviceList;
|
---|
113 |
|
---|
114 | typedef enum {
|
---|
115 | PollRemoteDevicesStatus_Negotiate,
|
---|
116 | PollRemoteDevicesStatus_WaitNegotiateResponse,
|
---|
117 | PollRemoteDevicesStatus_SendRequest,
|
---|
118 | PollRemoteDevicesStatus_WaitResponse,
|
---|
119 | PollRemoteDevicesStatus_Dereferenced
|
---|
120 | } PollRemoteDevicesStatus;
|
---|
121 |
|
---|
122 | PollRemoteDevicesStatus menmPollRemoteDevicesStatus;
|
---|
123 |
|
---|
124 | bool mfPollURB;
|
---|
125 |
|
---|
126 | PREMOTEUSBDEVICE mpDevices;
|
---|
127 |
|
---|
128 | bool mfWillBeDeleted;
|
---|
129 |
|
---|
130 | Guid aGuids[VRDP_MAX_USB_DEVICES_PER_CLIENT];
|
---|
131 | };
|
---|
132 |
|
---|
133 | #endif /* ____H_REMOTEUSBBACKEND */
|
---|