VirtualBox

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

Last change on this file since 977 was 436, checked in by vboxsync, 18 years ago

Main: Added USBDevice to the DeviceType enum to provide USB device activity (search for USB_DEVICE_ACTIVITY in ConsoleImpl.cpp). Thanks to MS COM C++ bingings polluting the global namespace with enum values, I had to rename the USBDevice class to OUSBDevice (and to add the COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_BEGIN macro for even more flexible collection declarations).

  • 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 COM class implementation
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#include "USBDeviceImpl.h"
23
24
25// constructor / destructor
26/////////////////////////////////////////////////////////////////////////////
27
28OUSBDevice::OUSBDevice()
29{
30 mVendorId = 0;
31 mProductId = 0;
32 mRevision = 0;
33
34 mPort = 0;
35 mRemote = FALSE;
36}
37
38OUSBDevice::~OUSBDevice()
39{
40}
41
42
43// public initializer/uninitializer for internal purposes only
44/////////////////////////////////////////////////////////////////////////////
45
46/**
47 * Initializes the USB device object.
48 *
49 * @returns COM result indicator
50 * @param aUSBDevice The USB device (interface) to clone.
51 */
52HRESULT OUSBDevice::init(IUSBDevice *aUSBDevice)
53{
54 AutoLock lock(this);
55 AssertReturn (!isReady(), E_UNEXPECTED);
56
57 HRESULT hrc = aUSBDevice->COMGETTER(VendorId)(&mVendorId);
58 ComAssertComRCRet (hrc, hrc);
59 ComAssertRet (mVendorId, E_INVALIDARG);
60
61 hrc = aUSBDevice->COMGETTER(ProductId)(&mProductId);
62 ComAssertComRCRet (hrc, hrc);
63 ComAssertRet (mProductId, E_INVALIDARG);
64
65 hrc = aUSBDevice->COMGETTER(Revision)(&mRevision);
66 ComAssertComRCRet (hrc, hrc);
67
68 hrc = aUSBDevice->COMGETTER(Manufacturer)(mManufacturer.asOutParam());
69 ComAssertComRCRet (hrc, hrc);
70
71 hrc = aUSBDevice->COMGETTER(Product)(mProduct.asOutParam());
72 ComAssertComRCRet (hrc, hrc);
73
74 hrc = aUSBDevice->COMGETTER(SerialNumber)(mSerialNumber.asOutParam());
75 ComAssertComRCRet (hrc, hrc);
76
77 hrc = aUSBDevice->COMGETTER(Address)(mAddress.asOutParam());
78 ComAssertComRCRet (hrc, hrc);
79
80 hrc = aUSBDevice->COMGETTER(Port)(&mPort);
81 ComAssertComRCRet (hrc, hrc);
82
83 hrc = aUSBDevice->COMGETTER(Remote)(&mRemote);
84 ComAssertComRCRet (hrc, hrc);
85
86 hrc = aUSBDevice->COMGETTER(Id)(mId.asOutParam());
87 ComAssertComRCRet (hrc, hrc);
88
89 setReady(true);
90 return S_OK;
91}
92
93
94// IUSBDevice properties
95/////////////////////////////////////////////////////////////////////////////
96
97/**
98 * Returns the GUID.
99 *
100 * @returns COM status code
101 * @param aId Address of result variable.
102 */
103STDMETHODIMP OUSBDevice::COMGETTER(Id)(GUIDPARAMOUT aId)
104{
105 if (!aId)
106 return E_POINTER;
107
108 AutoLock lock(this);
109 CHECK_READY();
110
111 mId.cloneTo(aId);
112 return S_OK;
113}
114
115
116/**
117 * Returns the vendor Id.
118 *
119 * @returns COM status code
120 * @param aVendorId Where to store the vendor id.
121 */
122STDMETHODIMP OUSBDevice::COMGETTER(VendorId)(USHORT *aVendorId)
123{
124 if (!aVendorId)
125 return E_POINTER;
126
127 AutoLock lock(this);
128 CHECK_READY();
129
130 *aVendorId = mVendorId;
131 return S_OK;
132}
133
134
135/**
136 * Returns the product Id.
137 *
138 * @returns COM status code
139 * @param aProductId Where to store the product id.
140 */
141STDMETHODIMP OUSBDevice::COMGETTER(ProductId)(USHORT *aProductId)
142{
143 if (!aProductId)
144 return E_POINTER;
145
146 AutoLock lock(this);
147 CHECK_READY();
148
149 *aProductId = mProductId;
150 return S_OK;
151}
152
153
154/**
155 * Returns the revision BCD.
156 *
157 * @returns COM status code
158 * @param aRevision Where to store the revision BCD.
159 */
160STDMETHODIMP OUSBDevice::COMGETTER(Revision)(USHORT *aRevision)
161{
162 if (!aRevision)
163 return E_POINTER;
164
165 AutoLock lock(this);
166 CHECK_READY();
167
168 *aRevision = mRevision;
169 return S_OK;
170}
171
172/**
173 * Returns the manufacturer string.
174 *
175 * @returns COM status code
176 * @param aManufacturer Where to put the return string.
177 */
178STDMETHODIMP OUSBDevice::COMGETTER(Manufacturer)(BSTR *aManufacturer)
179{
180 if (!aManufacturer)
181 return E_POINTER;
182
183 AutoLock lock(this);
184 CHECK_READY();
185
186 mManufacturer.cloneTo(aManufacturer);
187 return S_OK;
188}
189
190
191/**
192 * Returns the product string.
193 *
194 * @returns COM status code
195 * @param aProduct Where to put the return string.
196 */
197STDMETHODIMP OUSBDevice::COMGETTER(Product)(BSTR *aProduct)
198{
199 if (!aProduct)
200 return E_POINTER;
201
202 AutoLock lock(this);
203 CHECK_READY();
204
205 mProduct.cloneTo(aProduct);
206 return S_OK;
207}
208
209
210/**
211 * Returns the serial number string.
212 *
213 * @returns COM status code
214 * @param aSerialNumber Where to put the return string.
215 */
216STDMETHODIMP OUSBDevice::COMGETTER(SerialNumber)(BSTR *aSerialNumber)
217{
218 if (!aSerialNumber)
219 return E_POINTER;
220
221 AutoLock lock(this);
222 CHECK_READY();
223
224 mSerialNumber.cloneTo(aSerialNumber);
225 return S_OK;
226}
227
228
229/**
230 * Returns the host specific device address.
231 *
232 * @returns COM status code
233 * @param aAddress Where to put the return string.
234 */
235STDMETHODIMP OUSBDevice::COMGETTER(Address)(BSTR *aAddress)
236{
237 if (!aAddress)
238 return E_POINTER;
239
240 AutoLock lock(this);
241 CHECK_READY();
242
243 mAddress.cloneTo(aAddress);
244 return S_OK;
245}
246
247STDMETHODIMP OUSBDevice::COMGETTER(Port)(USHORT *aPort)
248{
249 if (!aPort)
250 return E_POINTER;
251
252 AutoLock lock(this);
253 CHECK_READY();
254
255 *aPort = mPort;
256 return S_OK;
257}
258
259STDMETHODIMP OUSBDevice::COMGETTER(Remote)(BOOL *aRemote)
260{
261 if (!aRemote)
262 return E_POINTER;
263
264 AutoLock lock(this);
265 CHECK_READY();
266
267 *aRemote = mRemote;
268 return S_OK;
269}
270
271// private methods
272/////////////////////////////////////////////////////////////////////////////
273
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