VirtualBox

source: vbox/trunk/src/VBox/Main/USBDeviceImpl.cpp@ 16560

Last change on this file since 16560 was 15051, checked in by vboxsync, 15 years ago

Main: Cleaned up the long standing const BSTR = const (OLECHAR *) on WIn32 vs (const PRunichar) * on XPCOM clash. Cleaned up BSTR/GUID macros (IN_BSTR replaces INPTR BSTR, IN_GUID replaces INPTR GUIDPARAM, OUT_GUID replaces GUIDPARAMOUT).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
RevLine 
[13659]1/* $Id: USBDeviceImpl.cpp 15051 2008-12-05 17:20:00Z vboxsync $ */
2
[1]3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
[13659]9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
[1]10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
[5999]14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
[8155]18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
[1]22 */
23
24#include "USBDeviceImpl.h"
25
26
27// constructor / destructor
28/////////////////////////////////////////////////////////////////////////////
29
[13659]30DEFINE_EMPTY_CTOR_DTOR (OUSBDevice)
31
32HRESULT OUSBDevice::FinalConstruct()
[1]33{
[13659]34 return S_OK;
[1]35}
36
[13659]37void OUSBDevice::FinalRelease()
[1]38{
[13659]39 uninit ();
[1]40}
41
42// public initializer/uninitializer for internal purposes only
43/////////////////////////////////////////////////////////////////////////////
44
45/**
46 * Initializes the USB device object.
47 *
48 * @returns COM result indicator
49 * @param aUSBDevice The USB device (interface) to clone.
50 */
[436]51HRESULT OUSBDevice::init(IUSBDevice *aUSBDevice)
[1]52{
[13659]53 LogFlowThisFunc (("aUSBDevice=%p\n", aUSBDevice));
[1]54
[13659]55 ComAssertRet (aUSBDevice, E_INVALIDARG);
56
57 /* Enclose the state transition NotReady->InInit->Ready */
58 AutoInitSpan autoInitSpan (this);
[14579]59 AssertReturn (autoInitSpan.isOk(), E_FAIL);
[13659]60
61 HRESULT hrc = aUSBDevice->COMGETTER(VendorId)(&unconst (mData.vendorId));
[1]62 ComAssertComRCRet (hrc, hrc);
[13659]63 ComAssertRet (mData.vendorId, E_INVALIDARG);
[1]64
[13659]65 hrc = aUSBDevice->COMGETTER(ProductId)(&unconst (mData.productId));
[1]66 ComAssertComRCRet (hrc, hrc);
[13659]67 ComAssertRet (mData.productId, E_INVALIDARG);
[1]68
[13659]69 hrc = aUSBDevice->COMGETTER(Revision)(&unconst (mData.revision));
[1]70 ComAssertComRCRet (hrc, hrc);
71
[13659]72 hrc = aUSBDevice->COMGETTER(Manufacturer)(unconst (mData.manufacturer).asOutParam());
[1]73 ComAssertComRCRet (hrc, hrc);
74
[13659]75 hrc = aUSBDevice->COMGETTER(Product)(unconst (mData.product).asOutParam());
[1]76 ComAssertComRCRet (hrc, hrc);
77
[13659]78 hrc = aUSBDevice->COMGETTER(SerialNumber)(unconst (mData.serialNumber).asOutParam());
[1]79 ComAssertComRCRet (hrc, hrc);
80
[13659]81 hrc = aUSBDevice->COMGETTER(Address)(unconst (mData.address).asOutParam());
[1]82 ComAssertComRCRet (hrc, hrc);
83
[13659]84 hrc = aUSBDevice->COMGETTER(Port)(&unconst (mData.port));
[1]85 ComAssertComRCRet (hrc, hrc);
86
[13659]87 hrc = aUSBDevice->COMGETTER(Port)(&unconst (mData.version));
[5528]88 ComAssertComRCRet (hrc, hrc);
89
[13659]90 hrc = aUSBDevice->COMGETTER(Port)(&unconst (mData.portVersion));
[5528]91 ComAssertComRCRet (hrc, hrc);
92
[13659]93 hrc = aUSBDevice->COMGETTER(Remote)(&unconst (mData.remote));
[1]94 ComAssertComRCRet (hrc, hrc);
95
[13659]96 hrc = aUSBDevice->COMGETTER(Id)(unconst (mData.id).asOutParam());
[1]97 ComAssertComRCRet (hrc, hrc);
98
[13659]99 /* Confirm a successful initialization */
100 autoInitSpan.setSucceeded();
101
[1]102 return S_OK;
103}
104
[13659]105/**
106 * Uninitializes the instance and sets the ready flag to FALSE.
107 * Called either from FinalRelease() or by the parent when it gets destroyed.
108 */
109void OUSBDevice::uninit()
110{
111 LogFlowThisFunc (("\n"));
[1]112
[13659]113 /* Enclose the state transition Ready->InUninit->NotReady */
114 AutoUninitSpan autoUninitSpan (this);
115 if (autoUninitSpan.uninitDone())
116 return;
117
118 unconst (mData.id).clear();
119
120 unconst (mData.vendorId) = 0;
121 unconst (mData.productId) = 0;
122 unconst (mData.revision) = 0;
123
124 unconst (mData.manufacturer).setNull();
125 unconst (mData.product).setNull();
126 unconst (mData.serialNumber).setNull();
127
128 unconst (mData.address).setNull();
129
130 unconst (mData.port) = 0;
131 unconst (mData.version) = 1;
132 unconst (mData.portVersion) = 1;
133
134 unconst (mData.remote) = FALSE;
135}
136
[1]137// IUSBDevice properties
138/////////////////////////////////////////////////////////////////////////////
139
140/**
141 * Returns the GUID.
142 *
143 * @returns COM status code
144 * @param aId Address of result variable.
145 */
[15051]146STDMETHODIMP OUSBDevice::COMGETTER(Id)(OUT_GUID aId)
[1]147{
[14972]148 CheckComArgOutPointerValid(aId);
[1]149
[13659]150 AutoCaller autoCaller (this);
151 CheckComRCReturnRC (autoCaller.rc());
[1]152
[13659]153 /* this is const, no need to lock */
154 mData.id.cloneTo (aId);
155
[1]156 return S_OK;
157}
158
159
160/**
161 * Returns the vendor Id.
162 *
163 * @returns COM status code
164 * @param aVendorId Where to store the vendor id.
165 */
[436]166STDMETHODIMP OUSBDevice::COMGETTER(VendorId)(USHORT *aVendorId)
[1]167{
[14972]168 CheckComArgOutPointerValid(aVendorId);
[1]169
[13659]170 AutoCaller autoCaller (this);
171 CheckComRCReturnRC (autoCaller.rc());
[1]172
[13659]173 /* this is const, no need to lock */
174 *aVendorId = mData.vendorId;
175
[1]176 return S_OK;
177}
178
179
180/**
181 * Returns the product Id.
182 *
183 * @returns COM status code
184 * @param aProductId Where to store the product id.
185 */
[436]186STDMETHODIMP OUSBDevice::COMGETTER(ProductId)(USHORT *aProductId)
[1]187{
[14972]188 CheckComArgOutPointerValid(aProductId);
[1]189
[13659]190 AutoCaller autoCaller (this);
191 CheckComRCReturnRC (autoCaller.rc());
[1]192
[13659]193 /* this is const, no need to lock */
194 *aProductId = mData.productId;
195
[1]196 return S_OK;
197}
198
199
200/**
201 * Returns the revision BCD.
202 *
203 * @returns COM status code
204 * @param aRevision Where to store the revision BCD.
205 */
[436]206STDMETHODIMP OUSBDevice::COMGETTER(Revision)(USHORT *aRevision)
[1]207{
[14972]208 CheckComArgOutPointerValid(aRevision);
[1]209
[13659]210 AutoCaller autoCaller (this);
211 CheckComRCReturnRC (autoCaller.rc());
[1]212
[13659]213 /* this is const, no need to lock */
214 *aRevision = mData.revision;
215
[1]216 return S_OK;
217}
218
219/**
220 * Returns the manufacturer string.
221 *
222 * @returns COM status code
223 * @param aManufacturer Where to put the return string.
224 */
[436]225STDMETHODIMP OUSBDevice::COMGETTER(Manufacturer)(BSTR *aManufacturer)
[1]226{
[14972]227 CheckComArgOutPointerValid(aManufacturer);
[1]228
[13659]229 AutoCaller autoCaller (this);
230 CheckComRCReturnRC (autoCaller.rc());
[1]231
[13659]232 /* this is const, no need to lock */
233 mData.manufacturer.cloneTo (aManufacturer);
234
[1]235 return S_OK;
236}
237
238
239/**
240 * Returns the product string.
241 *
242 * @returns COM status code
243 * @param aProduct Where to put the return string.
244 */
[436]245STDMETHODIMP OUSBDevice::COMGETTER(Product)(BSTR *aProduct)
[1]246{
[14972]247 CheckComArgOutPointerValid(aProduct);
[1]248
[13659]249 AutoCaller autoCaller (this);
250 CheckComRCReturnRC (autoCaller.rc());
[1]251
[13659]252 /* this is const, no need to lock */
253 mData.product.cloneTo (aProduct);
254
[1]255 return S_OK;
256}
257
258
259/**
260 * Returns the serial number string.
261 *
262 * @returns COM status code
263 * @param aSerialNumber Where to put the return string.
264 */
[436]265STDMETHODIMP OUSBDevice::COMGETTER(SerialNumber)(BSTR *aSerialNumber)
[1]266{
[14972]267 CheckComArgOutPointerValid(aSerialNumber);
[1]268
[13659]269 AutoCaller autoCaller (this);
270 CheckComRCReturnRC (autoCaller.rc());
[1]271
[13659]272 /* this is const, no need to lock */
273 mData.serialNumber.cloneTo (aSerialNumber);
274
[1]275 return S_OK;
276}
277
278
279/**
280 * Returns the host specific device address.
281 *
282 * @returns COM status code
283 * @param aAddress Where to put the return string.
284 */
[436]285STDMETHODIMP OUSBDevice::COMGETTER(Address)(BSTR *aAddress)
[1]286{
[14972]287 CheckComArgOutPointerValid(aAddress);
[1]288
[13659]289 AutoCaller autoCaller (this);
290 CheckComRCReturnRC (autoCaller.rc());
[1]291
[13659]292 /* this is const, no need to lock */
293 mData.address.cloneTo (aAddress);
294
[1]295 return S_OK;
296}
297
[436]298STDMETHODIMP OUSBDevice::COMGETTER(Port)(USHORT *aPort)
[1]299{
[14972]300 CheckComArgOutPointerValid(aPort);
[1]301
[13659]302 AutoCaller autoCaller (this);
303 CheckComRCReturnRC (autoCaller.rc());
[1]304
[13659]305 /* this is const, no need to lock */
306 *aPort = mData.port;
307
[1]308 return S_OK;
309}
310
[5528]311STDMETHODIMP OUSBDevice::COMGETTER(Version)(USHORT *aVersion)
312{
[14972]313 CheckComArgOutPointerValid(aVersion);
[5528]314
[13659]315 AutoCaller autoCaller (this);
316 CheckComRCReturnRC (autoCaller.rc());
[5528]317
[13659]318 /* this is const, no need to lock */
319 *aVersion = mData.version;
320
[5528]321 return S_OK;
322}
323
324STDMETHODIMP OUSBDevice::COMGETTER(PortVersion)(USHORT *aPortVersion)
325{
[14972]326 CheckComArgOutPointerValid(aPortVersion);
[5528]327
[13659]328 AutoCaller autoCaller (this);
329 CheckComRCReturnRC (autoCaller.rc());
[5528]330
[13659]331 /* this is const, no need to lock */
332 *aPortVersion = mData.portVersion;
333
[5528]334 return S_OK;
335}
336
[436]337STDMETHODIMP OUSBDevice::COMGETTER(Remote)(BOOL *aRemote)
[1]338{
[14972]339 CheckComArgOutPointerValid(aRemote);
[1]340
[13659]341 AutoCaller autoCaller (this);
342 CheckComRCReturnRC (autoCaller.rc());
[1]343
[13659]344 /* this is const, no need to lock */
345 *aRemote = mData.remote;
346
[1]347 return S_OK;
348}
349
350// private methods
351/////////////////////////////////////////////////////////////////////////////
[14772]352/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use