1 | /* $Id: RemoteUSBDeviceImpl.h 17684 2009-03-11 12:15:33Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox IHostUSBDevice COM interface implementation
|
---|
6 | * for remote (VRDP) USB devices
|
---|
7 | */
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * Copyright (C) 2006-2009 Sun Microsystems, Inc.
|
---|
11 | *
|
---|
12 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | * available from http://www.virtualbox.org. This file is free software;
|
---|
14 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | * General Public License (GPL) as published by the Free Software
|
---|
16 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 | *
|
---|
20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
21 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
22 | * additional information or have any questions.
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef ____H_REMOTEUSBDEVICEIMPL
|
---|
26 | #define ____H_REMOTEUSBDEVICEIMPL
|
---|
27 |
|
---|
28 | #include "VirtualBoxBase.h"
|
---|
29 |
|
---|
30 | struct _VRDPUSBDEVICEDESC;
|
---|
31 | typedef _VRDPUSBDEVICEDESC VRDPUSBDEVICEDESC;
|
---|
32 |
|
---|
33 | class ATL_NO_VTABLE RemoteUSBDevice :
|
---|
34 | public VirtualBoxBaseNEXT,
|
---|
35 | public VirtualBoxSupportErrorInfoImpl <RemoteUSBDevice, IHostUSBDevice>,
|
---|
36 | public VirtualBoxSupportTranslation <RemoteUSBDevice>,
|
---|
37 | public IHostUSBDevice
|
---|
38 | {
|
---|
39 | public:
|
---|
40 |
|
---|
41 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (OUSBDevice)
|
---|
42 |
|
---|
43 | DECLARE_NOT_AGGREGATABLE (RemoteUSBDevice)
|
---|
44 |
|
---|
45 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
46 |
|
---|
47 | BEGIN_COM_MAP (RemoteUSBDevice)
|
---|
48 | COM_INTERFACE_ENTRY (ISupportErrorInfo)
|
---|
49 | COM_INTERFACE_ENTRY (IHostUSBDevice)
|
---|
50 | COM_INTERFACE_ENTRY (IUSBDevice)
|
---|
51 | END_COM_MAP()
|
---|
52 |
|
---|
53 | NS_DECL_ISUPPORTS
|
---|
54 |
|
---|
55 | DECLARE_EMPTY_CTOR_DTOR (RemoteUSBDevice)
|
---|
56 |
|
---|
57 | HRESULT FinalConstruct();
|
---|
58 | void FinalRelease();
|
---|
59 |
|
---|
60 | // public initializer/uninitializer for internal purposes only
|
---|
61 | HRESULT init(uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevDesc);
|
---|
62 | void uninit();
|
---|
63 |
|
---|
64 | // IUSBDevice properties
|
---|
65 | STDMETHOD(COMGETTER(Id)) (OUT_GUID aId);
|
---|
66 | STDMETHOD(COMGETTER(VendorId)) (USHORT *aVendorId);
|
---|
67 | STDMETHOD(COMGETTER(ProductId)) (USHORT *aProductId);
|
---|
68 | STDMETHOD(COMGETTER(Revision)) (USHORT *aRevision);
|
---|
69 | STDMETHOD(COMGETTER(Manufacturer)) (BSTR *aManufacturer);
|
---|
70 | STDMETHOD(COMGETTER(Product)) (BSTR *aProduct);
|
---|
71 | STDMETHOD(COMGETTER(SerialNumber)) (BSTR *aSerialNumber);
|
---|
72 | STDMETHOD(COMGETTER(Address)) (BSTR *aAddress);
|
---|
73 | STDMETHOD(COMGETTER(Port)) (USHORT *aPort);
|
---|
74 | STDMETHOD(COMGETTER(Version)) (USHORT *aVersion);
|
---|
75 | STDMETHOD(COMGETTER(PortVersion)) (USHORT *aPortVersion);
|
---|
76 | STDMETHOD(COMGETTER(Remote)) (BOOL *aRemote);
|
---|
77 |
|
---|
78 | // IHostUSBDevice properties
|
---|
79 | STDMETHOD(COMGETTER(State)) (USBDeviceState_T *aState);
|
---|
80 |
|
---|
81 | // public methods only for internal purposes
|
---|
82 | bool dirty (void) const { return mData.dirty; }
|
---|
83 | void dirty (bool aDirty) { mData.dirty = aDirty; }
|
---|
84 |
|
---|
85 | uint16_t devId (void) const { return mData.devId; }
|
---|
86 | uint32_t clientId (void) { return mData.clientId; }
|
---|
87 |
|
---|
88 | bool captured (void) const { return mData.state == USBDeviceState_Captured; }
|
---|
89 | void captured (bool aCaptured)
|
---|
90 | {
|
---|
91 | if (aCaptured)
|
---|
92 | {
|
---|
93 | Assert(mData.state == USBDeviceState_Available);
|
---|
94 | mData.state = USBDeviceState_Captured;
|
---|
95 | }
|
---|
96 | else
|
---|
97 | {
|
---|
98 | Assert(mData.state == USBDeviceState_Captured);
|
---|
99 | mData.state = USBDeviceState_Available;
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | // for VirtualBoxSupportErrorInfoImpl
|
---|
104 | static const wchar_t *getComponentName() { return L"RemoteUSBDevice"; }
|
---|
105 |
|
---|
106 | private:
|
---|
107 |
|
---|
108 | struct Data
|
---|
109 | {
|
---|
110 | Data() : vendorId (0), productId (0), revision (0), port (0), version (1),
|
---|
111 | portVersion (1), dirty (FALSE), devId (0), clientId (0) {}
|
---|
112 |
|
---|
113 | const Guid id;
|
---|
114 |
|
---|
115 | const uint16_t vendorId;
|
---|
116 | const uint16_t productId;
|
---|
117 | const uint16_t revision;
|
---|
118 |
|
---|
119 | const Bstr manufacturer;
|
---|
120 | const Bstr product;
|
---|
121 | const Bstr serialNumber;
|
---|
122 |
|
---|
123 | const Bstr address;
|
---|
124 |
|
---|
125 | const uint16_t port;
|
---|
126 | const uint16_t version;
|
---|
127 | const uint16_t portVersion;
|
---|
128 |
|
---|
129 | USBDeviceState_T state;
|
---|
130 | bool dirty;
|
---|
131 |
|
---|
132 | const uint16_t devId;
|
---|
133 | const uint32_t clientId;
|
---|
134 | };
|
---|
135 |
|
---|
136 | Data mData;
|
---|
137 | };
|
---|
138 |
|
---|
139 | #endif // ____H_REMOTEUSBDEVICEIMPL
|
---|
140 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|