VirtualBox

source: vbox/trunk/src/VBox/Main/RemoteUSBDeviceImpl.cpp@ 3254

Last change on this file since 3254 was 2981, checked in by vboxsync, 17 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/** @file
2 *
3 * VirtualBox IHostUSBDevice COM interface implementation
4 * for remote (VRDP) USB devices
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23#include "RemoteUSBDeviceImpl.h"
24#include "Logging.h"
25
26#include <VBox/err.h>
27
28#include <VBox/vrdpusb.h>
29
30// constructor / destructor
31/////////////////////////////////////////////////////////////////////////////
32
33DEFINE_EMPTY_CTOR_DTOR (RemoteUSBDevice)
34
35HRESULT RemoteUSBDevice::FinalConstruct()
36{
37 return S_OK;
38}
39
40void RemoteUSBDevice::FinalRelease()
41{
42 if (isReady())
43 uninit();
44}
45
46// public initializer/uninitializer for internal purposes only
47/////////////////////////////////////////////////////////////////////////////
48
49/** @todo (sunlover) REMOTE_USB Device states. */
50
51/**
52 * Initializes the remote USB device object.
53 */
54#ifdef VRDP_MC
55HRESULT RemoteUSBDevice::init (uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevDesc)
56#else
57HRESULT RemoteUSBDevice::init (VRDPUSBDEVICEDESC *pDevDesc)
58#endif /* VRDP_MC */
59{
60 LogFlowMember (("RemoteUSBDevice::init()\n"));
61
62 AutoLock alock (this);
63 ComAssertRet (!isReady(), E_UNEXPECTED);
64
65 mId.create();
66
67 mVendorId = pDevDesc->idVendor;
68 mProductId = pDevDesc->idProduct;
69 mRevision = pDevDesc->bcdRev;
70
71 mManufacturer = pDevDesc->oManufacturer? (char *)pDevDesc + pDevDesc->oManufacturer: "";
72 mProduct = pDevDesc->oProduct? (char *)pDevDesc + pDevDesc->oProduct: "";
73 mSerialNumber = pDevDesc->oSerialNumber? (char *)pDevDesc + pDevDesc->oSerialNumber: "";
74
75 char id[64];
76#ifdef VRDP_MC
77 RTStrPrintf(id, sizeof (id), REMOTE_USB_BACKEND_PREFIX_S "0x%08X&0x%08X", pDevDesc->id, u32ClientId);
78#else
79 RTStrPrintf(id, sizeof (id), REMOTE_USB_BACKEND_PREFIX_S "0x%08X", pDevDesc->id);
80#endif /* VRDP_MC */
81 mAddress = id;
82
83 mPort = pDevDesc->idPort;
84
85 mState = USBDeviceState_USBDeviceAvailable;
86
87 mDirty = false;
88 mDevId = pDevDesc->id;
89
90#ifdef VRDP_MC
91 mClientId = u32ClientId;
92#endif /* VRDP_MC */
93
94 setReady (true);
95 return S_OK;
96}
97
98
99/**
100 * Uninitializes the instance and sets the ready flag to FALSE.
101 * Called either from FinalRelease() or by the parent when it gets destroyed.
102 */
103void RemoteUSBDevice::uninit()
104{
105 LogFlowMember (("RemoteUSBDevice::uninit()\n"));
106
107 AutoLock alock (this);
108 AssertReturn (isReady(), (void) 0);
109
110 setReady (false);
111}
112
113// IUSBDevice properties
114/////////////////////////////////////////////////////////////////////////////
115
116STDMETHODIMP RemoteUSBDevice::COMGETTER(Id) (GUIDPARAMOUT aId)
117{
118 if (!aId)
119 return E_INVALIDARG;
120
121 AutoLock alock (this);
122 CHECK_READY();
123
124 mId.cloneTo (aId);
125 return S_OK;
126}
127
128STDMETHODIMP RemoteUSBDevice::COMGETTER(VendorId) (USHORT *aVendorId)
129{
130 if (!aVendorId)
131 return E_INVALIDARG;
132
133 AutoLock alock (this);
134 CHECK_READY();
135
136 *aVendorId = mVendorId;
137 return S_OK;
138}
139
140STDMETHODIMP RemoteUSBDevice::COMGETTER(ProductId) (USHORT *aProductId)
141{
142 if (!aProductId)
143 return E_INVALIDARG;
144
145 AutoLock alock (this);
146 CHECK_READY();
147
148 *aProductId = mProductId;
149 return S_OK;
150}
151
152STDMETHODIMP RemoteUSBDevice::COMGETTER(Revision) (USHORT *aRevision)
153{
154 if (!aRevision)
155 return E_INVALIDARG;
156
157 AutoLock alock (this);
158 CHECK_READY();
159
160 *aRevision = mRevision;
161 return S_OK;
162}
163
164STDMETHODIMP RemoteUSBDevice::COMGETTER(Manufacturer) (BSTR *aManufacturer)
165{
166 if (!aManufacturer)
167 return E_INVALIDARG;
168
169 AutoLock alock (this);
170 CHECK_READY();
171
172 mManufacturer.cloneTo (aManufacturer);
173 return S_OK;
174}
175
176STDMETHODIMP RemoteUSBDevice::COMGETTER(Product) (BSTR *aProduct)
177{
178 if (!aProduct)
179 return E_INVALIDARG;
180
181 AutoLock alock (this);
182 CHECK_READY();
183
184 mProduct.cloneTo (aProduct);
185 return S_OK;
186}
187
188STDMETHODIMP RemoteUSBDevice::COMGETTER(SerialNumber) (BSTR *aSerialNumber)
189{
190 if (!aSerialNumber)
191 return E_INVALIDARG;
192
193 AutoLock alock (this);
194 CHECK_READY();
195
196 mSerialNumber.cloneTo (aSerialNumber);
197 return S_OK;
198}
199
200STDMETHODIMP RemoteUSBDevice::COMGETTER(Address) (BSTR *aAddress)
201{
202 if (!aAddress)
203 return E_INVALIDARG;
204
205 AutoLock alock (this);
206 CHECK_READY();
207
208 mAddress.cloneTo (aAddress);
209 return S_OK;
210}
211
212STDMETHODIMP RemoteUSBDevice::COMGETTER(Port) (USHORT *aPort)
213{
214 if (!aPort)
215 return E_INVALIDARG;
216
217 AutoLock alock (this);
218 CHECK_READY();
219
220 *aPort = mPort;
221 return S_OK;
222}
223
224STDMETHODIMP RemoteUSBDevice::COMGETTER(Remote) (BOOL *aRemote)
225{
226 if (!aRemote)
227 return E_INVALIDARG;
228
229 AutoLock alock (this);
230 CHECK_READY();
231
232 /* RemoteUSBDevice is always remote. */
233 *aRemote = TRUE;
234 return S_OK;
235}
236
237// IHostUSBDevice properties
238/////////////////////////////////////////////////////////////////////////////
239
240STDMETHODIMP RemoteUSBDevice::COMGETTER(State) (USBDeviceState_T *aState)
241{
242 if (!aState)
243 return E_POINTER;
244
245 AutoLock lock (this);
246 CHECK_READY();
247
248 *aState = mState;
249 return S_OK;
250}
251
252// public methods only for internal purposes
253////////////////////////////////////////////////////////////////////////////////
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