Changeset 17553 in vbox for trunk/src/VBox/Main/ConsoleImpl.cpp
- Timestamp:
- Mar 9, 2009 9:34:22 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r17360 r17553 1265 1265 } 1266 1266 1267 STDMETHODIMP Console::COMGETTER(USBDevices) ( IUSBDeviceCollection **aUSBDevices)1268 { 1269 CheckComArgOut PointerValid(aUSBDevices);1267 STDMETHODIMP Console::COMGETTER(USBDevices) (ComSafeArrayOut (IUSBDevice *, aUSBDevices)) 1268 { 1269 CheckComArgOutSafeArrayPointerValid(aUSBDevices); 1270 1270 1271 1271 AutoCaller autoCaller (this); … … 1274 1274 AutoReadLock alock (this); 1275 1275 1276 ComObjPtr <OUSBDeviceCollection> collection; 1277 collection.createObject(); 1278 collection->init (mUSBDevices); 1279 collection.queryInterfaceTo (aUSBDevices); 1276 SafeIfaceArray <IUSBDevice> collection (mUSBDevices); 1277 collection.detachTo (ComSafeArrayOutArg(aUSBDevices)); 1280 1278 1281 1279 return S_OK; … … 1333 1331 } 1334 1332 1333 1335 1334 // IConsole methods 1336 1335 ///////////////////////////////////////////////////////////////////////////// 1336 1337 1337 1338 1338 STDMETHODIMP Console::PowerUp (IProgress **aProgress) … … 2073 2073 return setError (VBOX_E_PDM_ERROR, 2074 2074 tr ("The virtual machine does not have a USB controller")); 2075 #endif /* !VBOX_WITH_USB */ 2076 } 2077 2078 STDMETHODIMP Console::FindUSBDeviceByAddress(IN_BSTR aAddress, IUSBDevice **aDevice) 2079 { 2080 #ifdef VBOX_WITH_USB 2081 CheckComArgNotNull(aAddress); 2082 CheckComArgOutPointerValid(aDevice); 2083 2084 *aDevice = NULL; 2085 2086 SafeIfaceArray <IUSBDevice> devsvec; 2087 HRESULT rc = COMGETTER(USBDevices) (ComSafeArrayAsOutParam(devsvec)); 2088 CheckComRCReturnRC (rc); 2089 2090 for (size_t i = 0; i < devsvec.size(); ++i) 2091 { 2092 Bstr address; 2093 rc = devsvec[i]->COMGETTER(Address) (address.asOutParam()); 2094 CheckComRCReturnRC (rc); 2095 if (address == aAddress) 2096 { 2097 ComObjPtr<OUSBDevice> found; 2098 found.createObject(); 2099 found->init (devsvec[i]); 2100 return found.queryInterfaceTo (aDevice); 2101 } 2102 } 2103 2104 return setErrorNoLog (VBOX_E_OBJECT_NOT_FOUND, tr ( 2105 "Could not find a USB device with address '%ls'"), 2106 aAddress); 2107 2108 #else /* !VBOX_WITH_USB */ 2109 return E_NOTIMPL; 2110 #endif /* !VBOX_WITH_USB */ 2111 } 2112 2113 STDMETHODIMP Console::FindUSBDeviceById(IN_GUID aId, IUSBDevice **aDevice) 2114 { 2115 #ifdef VBOX_WITH_USB 2116 CheckComArgExpr(aId, Guid (aId).isEmpty() == false); 2117 CheckComArgOutPointerValid(aDevice); 2118 2119 *aDevice = NULL; 2120 2121 SafeIfaceArray <IUSBDevice> devsvec; 2122 HRESULT rc = COMGETTER(USBDevices) (ComSafeArrayAsOutParam(devsvec)); 2123 CheckComRCReturnRC (rc); 2124 2125 for (size_t i = 0; i < devsvec.size(); ++i) 2126 { 2127 Guid id; 2128 rc = devsvec[i]->COMGETTER(Id) (id.asOutParam()); 2129 CheckComRCReturnRC (rc); 2130 if (id == aId) 2131 { 2132 ComObjPtr<OUSBDevice> found; 2133 found.createObject(); 2134 found->init(devsvec[i]); 2135 return found.queryInterfaceTo (aDevice); 2136 } 2137 } 2138 2139 return setErrorNoLog (VBOX_E_OBJECT_NOT_FOUND, tr ( 2140 "Could not find a USB device with uuid {%RTuuid}"), 2141 Guid (aId).raw()); 2142 2143 #else /* !VBOX_WITH_USB */ 2144 return E_NOTIMPL; 2075 2145 #endif /* !VBOX_WITH_USB */ 2076 2146 }
Note:
See TracChangeset
for help on using the changeset viewer.