VirtualBox

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

Last change on this file since 4041 was 3278, checked in by vboxsync, 17 years ago

Removed some obsolete VRDP code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 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 */
54HRESULT RemoteUSBDevice::init (uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevDesc)
55{
56 LogFlowMember (("RemoteUSBDevice::init()\n"));
57
58 AutoLock alock (this);
59 ComAssertRet (!isReady(), E_UNEXPECTED);
60
61 mId.create();
62
63 mVendorId = pDevDesc->idVendor;
64 mProductId = pDevDesc->idProduct;
65 mRevision = pDevDesc->bcdRev;
66
67 mManufacturer = pDevDesc->oManufacturer? (char *)pDevDesc + pDevDesc->oManufacturer: "";
68 mProduct = pDevDesc->oProduct? (char *)pDevDesc + pDevDesc->oProduct: "";
69 mSerialNumber = pDevDesc->oSerialNumber? (char *)pDevDesc + pDevDesc->oSerialNumber: "";
70
71 char id[64];
72 RTStrPrintf(id, sizeof (id), REMOTE_USB_BACKEND_PREFIX_S "0x%08X&0x%08X", pDevDesc->id, u32ClientId);
73 mAddress = id;
74
75 mPort = pDevDesc->idPort;
76
77 mState = USBDeviceState_USBDeviceAvailable;
78
79 mDirty = false;
80 mDevId = pDevDesc->id;
81
82 mClientId = u32ClientId;
83
84 setReady (true);
85 return S_OK;
86}
87
88
89/**
90 * Uninitializes the instance and sets the ready flag to FALSE.
91 * Called either from FinalRelease() or by the parent when it gets destroyed.
92 */
93void RemoteUSBDevice::uninit()
94{
95 LogFlowMember (("RemoteUSBDevice::uninit()\n"));
96
97 AutoLock alock (this);
98 AssertReturn (isReady(), (void) 0);
99
100 setReady (false);
101}
102
103// IUSBDevice properties
104/////////////////////////////////////////////////////////////////////////////
105
106STDMETHODIMP RemoteUSBDevice::COMGETTER(Id) (GUIDPARAMOUT aId)
107{
108 if (!aId)
109 return E_INVALIDARG;
110
111 AutoLock alock (this);
112 CHECK_READY();
113
114 mId.cloneTo (aId);
115 return S_OK;
116}
117
118STDMETHODIMP RemoteUSBDevice::COMGETTER(VendorId) (USHORT *aVendorId)
119{
120 if (!aVendorId)
121 return E_INVALIDARG;
122
123 AutoLock alock (this);
124 CHECK_READY();
125
126 *aVendorId = mVendorId;
127 return S_OK;
128}
129
130STDMETHODIMP RemoteUSBDevice::COMGETTER(ProductId) (USHORT *aProductId)
131{
132 if (!aProductId)
133 return E_INVALIDARG;
134
135 AutoLock alock (this);
136 CHECK_READY();
137
138 *aProductId = mProductId;
139 return S_OK;
140}
141
142STDMETHODIMP RemoteUSBDevice::COMGETTER(Revision) (USHORT *aRevision)
143{
144 if (!aRevision)
145 return E_INVALIDARG;
146
147 AutoLock alock (this);
148 CHECK_READY();
149
150 *aRevision = mRevision;
151 return S_OK;
152}
153
154STDMETHODIMP RemoteUSBDevice::COMGETTER(Manufacturer) (BSTR *aManufacturer)
155{
156 if (!aManufacturer)
157 return E_INVALIDARG;
158
159 AutoLock alock (this);
160 CHECK_READY();
161
162 mManufacturer.cloneTo (aManufacturer);
163 return S_OK;
164}
165
166STDMETHODIMP RemoteUSBDevice::COMGETTER(Product) (BSTR *aProduct)
167{
168 if (!aProduct)
169 return E_INVALIDARG;
170
171 AutoLock alock (this);
172 CHECK_READY();
173
174 mProduct.cloneTo (aProduct);
175 return S_OK;
176}
177
178STDMETHODIMP RemoteUSBDevice::COMGETTER(SerialNumber) (BSTR *aSerialNumber)
179{
180 if (!aSerialNumber)
181 return E_INVALIDARG;
182
183 AutoLock alock (this);
184 CHECK_READY();
185
186 mSerialNumber.cloneTo (aSerialNumber);
187 return S_OK;
188}
189
190STDMETHODIMP RemoteUSBDevice::COMGETTER(Address) (BSTR *aAddress)
191{
192 if (!aAddress)
193 return E_INVALIDARG;
194
195 AutoLock alock (this);
196 CHECK_READY();
197
198 mAddress.cloneTo (aAddress);
199 return S_OK;
200}
201
202STDMETHODIMP RemoteUSBDevice::COMGETTER(Port) (USHORT *aPort)
203{
204 if (!aPort)
205 return E_INVALIDARG;
206
207 AutoLock alock (this);
208 CHECK_READY();
209
210 *aPort = mPort;
211 return S_OK;
212}
213
214STDMETHODIMP RemoteUSBDevice::COMGETTER(Remote) (BOOL *aRemote)
215{
216 if (!aRemote)
217 return E_INVALIDARG;
218
219 AutoLock alock (this);
220 CHECK_READY();
221
222 /* RemoteUSBDevice is always remote. */
223 *aRemote = TRUE;
224 return S_OK;
225}
226
227// IHostUSBDevice properties
228/////////////////////////////////////////////////////////////////////////////
229
230STDMETHODIMP RemoteUSBDevice::COMGETTER(State) (USBDeviceState_T *aState)
231{
232 if (!aState)
233 return E_POINTER;
234
235 AutoLock lock (this);
236 CHECK_READY();
237
238 *aState = mState;
239 return S_OK;
240}
241
242// public methods only for internal purposes
243////////////////////////////////////////////////////////////////////////////////
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