VirtualBox

source: vbox/trunk/src/VBox/Main/include/USBDeviceImpl.h@ 8707

Last change on this file since 8707 was 8701, checked in by vboxsync, 17 years ago

Oops, these RTLogPrintf's shouldn't be here.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_USBDEVICEIMPL
23#define ____H_USBDEVICEIMPL
24
25#include "VirtualBoxBase.h"
26#include "Collection.h"
27#include "Logging.h"
28
29
30/**
31 * Object class used for maintaining devices attached to a USB controller.
32 * Generally this contains much less information.
33 */
34class ATL_NO_VTABLE OUSBDevice :
35 public VirtualBoxSupportErrorInfoImpl<OUSBDevice, IUSBDevice>,
36 public VirtualBoxSupportTranslation<OUSBDevice>,
37 public VirtualBoxBase,
38 public IUSBDevice
39{
40public:
41
42 OUSBDevice();
43 virtual ~OUSBDevice();
44
45 DECLARE_NOT_AGGREGATABLE(OUSBDevice)
46
47 DECLARE_PROTECT_FINAL_CONSTRUCT()
48
49 BEGIN_COM_MAP(OUSBDevice)
50 COM_INTERFACE_ENTRY(ISupportErrorInfo)
51 COM_INTERFACE_ENTRY(IUSBDevice)
52 END_COM_MAP()
53
54 NS_DECL_ISUPPORTS
55
56 // public initializer/uninitializer for internal purposes only
57 HRESULT init(IUSBDevice *a_pUSBDevice);
58
59 // IUSBDevice properties
60 STDMETHOD(COMGETTER(Id))(GUIDPARAMOUT aId);
61 STDMETHOD(COMGETTER(VendorId))(USHORT *aVendorId);
62 STDMETHOD(COMGETTER(ProductId))(USHORT *aProductId);
63 STDMETHOD(COMGETTER(Revision))(USHORT *aRevision);
64 STDMETHOD(COMGETTER(Manufacturer))(BSTR *aManufacturer);
65 STDMETHOD(COMGETTER(Product))(BSTR *aProduct);
66 STDMETHOD(COMGETTER(SerialNumber))(BSTR *aSerialNumber);
67 STDMETHOD(COMGETTER(Address))(BSTR *aAddress);
68 STDMETHOD(COMGETTER(Port))(USHORT *aPort);
69 STDMETHOD(COMGETTER(Version))(USHORT *aVersion);
70 STDMETHOD(COMGETTER(PortVersion))(USHORT *aPortVersion);
71 STDMETHOD(COMGETTER(Remote))(BOOL *aRemote);
72
73 // public methods only for internal purposes
74 const Guid &id() { return mId; }
75
76 // for VirtualBoxSupportErrorInfoImpl
77 static const wchar_t *getComponentName() { return L"USBDevice"; }
78
79private:
80 /** The UUID of this device. */
81 Guid mId;
82
83 /** The vendor id of this USB device. */
84 USHORT mVendorId;
85 /** The product id of this USB device. */
86 USHORT mProductId;
87 /** The product revision number of this USB device.
88 * (high byte = integer; low byte = decimal) */
89 USHORT mRevision;
90 /** The Manufacturer string. (Quite possibly NULL.) */
91 Bstr mManufacturer;
92 /** The Product string. (Quite possibly NULL.) */
93 Bstr mProduct;
94 /** The SerialNumber string. (Quite possibly NULL.) */
95 Bstr mSerialNumber;
96 /** The host specific address of the device. */
97 Bstr mAddress;
98 /** The host port number. */
99 USHORT mPort;
100 /** The major USB version number of the device. */
101 USHORT mVersion;
102 /** The major USB version number of the port the device is attached to. */
103 USHORT mPortVersion;
104 /** Remote (VRDP) or local device. */
105 BOOL mRemote;
106};
107
108COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_BEGIN (ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
109
110 STDMETHOD(FindById) (INPTR GUIDPARAM aId, IUSBDevice **aDevice)
111 {
112 Guid idToFind = aId;
113 if (idToFind.isEmpty())
114 return E_INVALIDARG;
115 if (!aDevice)
116 return E_POINTER;
117
118 *aDevice = NULL;
119 Vector::value_type found;
120 Vector::iterator it = vec.begin();
121 while (!found && it != vec.end())
122 {
123 Guid id;
124 (*it)->COMGETTER(Id) (id.asOutParam());
125 if (id == idToFind)
126 found = *it;
127 ++ it;
128 }
129
130 if (!found)
131 {
132 return setError (E_INVALIDARG, OUSBDeviceCollection::tr (
133 "Could not find a USB device with UUID {%s}"),
134 idToFind.toString().raw());
135 }
136
137 return found.queryInterfaceTo (aDevice);
138 }
139
140 STDMETHOD(FindByAddress) (INPTR BSTR aAddress, IUSBDevice **aDevice)
141 {
142 if (!aAddress)
143 return E_INVALIDARG;
144 if (!aDevice)
145 return E_POINTER;
146
147 *aDevice = NULL;
148 Vector::value_type found;
149 Vector::iterator it = vec.begin();
150 while (!found && it != vec.end())
151 {
152 Bstr address;
153 (*it)->COMGETTER(Address) (address.asOutParam());
154 if (address == aAddress)
155 found = *it;
156 ++ it;
157 }
158
159 if (!found)
160 return setError (E_INVALIDARG, OUSBDeviceCollection::tr (
161 "Could not find a USB device with address '%ls'"),
162 aAddress);
163
164 return found.queryInterfaceTo (aDevice);
165 }
166
167COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_END (ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
168
169#endif // ____H_USBDEVICEIMPL
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