VirtualBox

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

Last change on this file since 3330 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: 4.7 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek 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#ifndef ____H_USBDEVICEIMPL
23#define ____H_USBDEVICEIMPL
24
25#include "VirtualBoxBase.h"
26#include "Collection.h"
27
28
29/**
30 * Object class used for maintaining devices attached to a USB controller.
31 * Generally this contains much less information.
32 */
33class ATL_NO_VTABLE OUSBDevice :
34 public VirtualBoxSupportErrorInfoImpl<OUSBDevice, IUSBDevice>,
35 public VirtualBoxSupportTranslation<OUSBDevice>,
36 public VirtualBoxBase,
37 public IUSBDevice
38{
39public:
40
41 OUSBDevice();
42 virtual ~OUSBDevice();
43
44 DECLARE_NOT_AGGREGATABLE(OUSBDevice)
45
46 DECLARE_PROTECT_FINAL_CONSTRUCT()
47
48 BEGIN_COM_MAP(OUSBDevice)
49 COM_INTERFACE_ENTRY(ISupportErrorInfo)
50 COM_INTERFACE_ENTRY(IUSBDevice)
51 END_COM_MAP()
52
53 NS_DECL_ISUPPORTS
54
55 // public initializer/uninitializer for internal purposes only
56 HRESULT init(IUSBDevice *a_pUSBDevice);
57
58 // IUSBDevice properties
59 STDMETHOD(COMGETTER(Id))(GUIDPARAMOUT aId);
60 STDMETHOD(COMGETTER(VendorId))(USHORT *aVendorId);
61 STDMETHOD(COMGETTER(ProductId))(USHORT *aProductId);
62 STDMETHOD(COMGETTER(Revision))(USHORT *aRevision);
63 STDMETHOD(COMGETTER(Manufacturer))(BSTR *aManufacturer);
64 STDMETHOD(COMGETTER(Product))(BSTR *aProduct);
65 STDMETHOD(COMGETTER(SerialNumber))(BSTR *aSerialNumber);
66 STDMETHOD(COMGETTER(Address))(BSTR *aAddress);
67 STDMETHOD(COMGETTER(Port))(USHORT *aPort);
68 STDMETHOD(COMGETTER(Remote))(BOOL *aRemote);
69
70 // public methods only for internal purposes
71 const Guid &id() { return mId; }
72
73 // for VirtualBoxSupportErrorInfoImpl
74 static const wchar_t *getComponentName() { return L"USBDevice"; }
75
76private:
77 /** The UUID of this device. */
78 Guid mId;
79
80 /** The vendor id of this USB device. */
81 USHORT mVendorId;
82 /** The product id of this USB device. */
83 USHORT mProductId;
84 /** The product revision number of this USB device.
85 * (high byte = integer; low byte = decimal) */
86 USHORT mRevision;
87 /** The Manufacturer string. (Quite possibly NULL.) */
88 Bstr mManufacturer;
89 /** The Product string. (Quite possibly NULL.) */
90 Bstr mProduct;
91 /** The SerialNumber string. (Quite possibly NULL.) */
92 Bstr mSerialNumber;
93 /** The host specific address of the device. */
94 Bstr mAddress;
95
96 USHORT mPort;
97 BOOL mRemote;
98};
99
100COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_BEGIN (ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
101
102 STDMETHOD(FindById) (INPTR GUIDPARAM aId, IUSBDevice **aDevice)
103 {
104 Guid idToFind = aId;
105 if (idToFind.isEmpty())
106 return E_INVALIDARG;
107 if (!aDevice)
108 return E_POINTER;
109
110 *aDevice = NULL;
111 Vector::value_type found;
112 Vector::iterator it = vec.begin();
113 while (!found && it != vec.end())
114 {
115 Guid id;
116 (*it)->COMGETTER(Id) (id.asOutParam());
117 if (id == idToFind)
118 found = *it;
119 ++ it;
120 }
121
122 if (!found)
123 return setError (E_INVALIDARG, OUSBDeviceCollection::tr (
124 "Could not find a USB device with UUID {%s}"),
125 idToFind.toString().raw());
126
127 return found.queryInterfaceTo (aDevice);
128 }
129
130 STDMETHOD(FindByAddress) (INPTR BSTR aAddress, IUSBDevice **aDevice)
131 {
132 if (!aAddress)
133 return E_INVALIDARG;
134 if (!aDevice)
135 return E_POINTER;
136
137 *aDevice = NULL;
138 Vector::value_type found;
139 Vector::iterator it = vec.begin();
140 while (!found && it != vec.end())
141 {
142 Bstr address;
143 (*it)->COMGETTER(Address) (address.asOutParam());
144 if (address == aAddress)
145 found = *it;
146 ++ it;
147 }
148
149 if (!found)
150 return setError (E_INVALIDARG, OUSBDeviceCollection::tr (
151 "Could not find a USB device with address '%ls'"),
152 aAddress);
153
154 return found.queryInterfaceTo (aDevice);
155 }
156
157COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_END (ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
158
159#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