Changeset 17553 in vbox
- Timestamp:
- Mar 9, 2009 9:34:22 AM (16 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r17419 r17553 591 591 else 592 592 { 593 ComPtr <IUSBDeviceCollection> coll;594 CHECK_ERROR_BREAK (console, COMGETTER(USBDevices)( coll.asOutParam()));593 SafeIfaceArray <IUSBDevice> coll; 594 CHECK_ERROR_BREAK (console, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(coll))); 595 595 ComPtr <IUSBDevice> dev; 596 CHECK_ERROR_BREAK (coll, FindByAddress (Bstr (a->argv [2]), dev.asOutParam())); 596 CHECK_ERROR_BREAK (console, FindUSBDeviceByAddress (Bstr (a->argv [2]), 597 dev.asOutParam())); 597 598 CHECK_ERROR_BREAK (dev, COMGETTER(Id) (usbId.asOutParam())); 598 599 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r17336 r17553 1313 1313 RTPrintf ("Currently Attached USB Devices:\n\n"); 1314 1314 1315 ComPtr <IUSBDeviceCollection> coll; 1316 CHECK_ERROR_RET (console, COMGETTER(USBDevices) (coll.asOutParam()), rc); 1317 1318 ComPtr <IUSBDeviceEnumerator> en; 1319 CHECK_ERROR_RET (coll, Enumerate (en.asOutParam()), rc); 1320 1321 BOOL more = FALSE; 1322 ASSERT(SUCCEEDED(rc = en->HasMore (&more))); 1323 if (FAILED(rc)) 1324 return rc; 1325 1326 if (!more) 1315 SafeIfaceArray <IUSBDevice> coll; 1316 CHECK_ERROR_RET (console, COMGETTER(USBDevices) (ComSafeArrayAsOutParam(coll)), rc); 1317 1318 if (coll.size() == 0) 1327 1319 { 1328 1320 if (details != VMINFO_MACHINEREADABLE) … … 1330 1322 } 1331 1323 else 1332 while (more)1333 1324 { 1334 ComPtr <IUSBDevice> dev; 1335 ASSERT(SUCCEEDED(rc = en->GetNext (dev.asOutParam()))); 1336 if (FAILED(rc)) 1337 return rc; 1338 1339 /* Query info. */ 1340 Guid id; 1341 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc); 1342 USHORT usVendorId; 1343 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc); 1344 USHORT usProductId; 1345 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc); 1346 USHORT bcdRevision; 1347 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc); 1348 1349 if (details == VMINFO_MACHINEREADABLE) 1350 RTPrintf("USBAttachedUUID%d=\"%S\"\n" 1351 "USBAttachedVendorId%d=\"%#06x\"\n" 1352 "USBAttachedProductId%d=\"%#06x\"\n" 1353 "USBAttachedRevision%d=\"%#04x%02x\"\n", 1354 index + 1, id.toString().raw(), 1355 index + 1, usVendorId, 1356 index + 1, usProductId, 1357 index + 1, bcdRevision >> 8, bcdRevision & 0xff); 1358 else 1359 RTPrintf("UUID: %S\n" 1360 "VendorId: 0x%04x (%04X)\n" 1361 "ProductId: 0x%04x (%04X)\n" 1362 "Revision: %u.%u (%02u%02u)\n", 1363 id.toString().raw(), 1364 usVendorId, usVendorId, usProductId, usProductId, 1365 bcdRevision >> 8, bcdRevision & 0xff, 1366 bcdRevision >> 8, bcdRevision & 0xff); 1367 1368 /* optional stuff. */ 1369 Bstr bstr; 1370 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc); 1371 if (!bstr.isEmpty()) 1325 for (index = 0; index < coll.size(); ++index) 1372 1326 { 1327 ComPtr <IUSBDevice> dev = coll[index]; 1328 1329 /* Query info. */ 1330 Guid id; 1331 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc); 1332 USHORT usVendorId; 1333 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc); 1334 USHORT usProductId; 1335 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc); 1336 USHORT bcdRevision; 1337 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc); 1338 1373 1339 if (details == VMINFO_MACHINEREADABLE) 1374 RTPrintf("USBAttachedManufacturer%d=\"%lS\"\n", index + 1, bstr.raw()); 1340 RTPrintf("USBAttachedUUID%zu=\"%S\"\n" 1341 "USBAttachedVendorId%zu=\"%#06x\"\n" 1342 "USBAttachedProductId%zu=\"%#06x\"\n" 1343 "USBAttachedRevision%zu=\"%#04x%02x\"\n", 1344 index + 1, id.toString().raw(), 1345 index + 1, usVendorId, 1346 index + 1, usProductId, 1347 index + 1, bcdRevision >> 8, bcdRevision & 0xff); 1375 1348 else 1376 RTPrintf("Manufacturer: %lS\n", bstr.raw()); 1349 RTPrintf("UUID: %S\n" 1350 "VendorId: 0x%04x (%04X)\n" 1351 "ProductId: 0x%04x (%04X)\n" 1352 "Revision: %u.%u (%02u%02u)\n", 1353 id.toString().raw(), 1354 usVendorId, usVendorId, usProductId, usProductId, 1355 bcdRevision >> 8, bcdRevision & 0xff, 1356 bcdRevision >> 8, bcdRevision & 0xff); 1357 1358 /* optional stuff. */ 1359 Bstr bstr; 1360 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc); 1361 if (!bstr.isEmpty()) 1362 { 1363 if (details == VMINFO_MACHINEREADABLE) 1364 RTPrintf("USBAttachedManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw()); 1365 else 1366 RTPrintf("Manufacturer: %lS\n", bstr.raw()); 1367 } 1368 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc); 1369 if (!bstr.isEmpty()) 1370 { 1371 if (details == VMINFO_MACHINEREADABLE) 1372 RTPrintf("USBAttachedProduct%zu=\"%lS\"\n", index + 1, bstr.raw()); 1373 else 1374 RTPrintf("Product: %lS\n", bstr.raw()); 1375 } 1376 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc); 1377 if (!bstr.isEmpty()) 1378 { 1379 if (details == VMINFO_MACHINEREADABLE) 1380 RTPrintf("USBAttachedSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw()); 1381 else 1382 RTPrintf("SerialNumber: %lS\n", bstr.raw()); 1383 } 1384 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc); 1385 if (!bstr.isEmpty()) 1386 { 1387 if (details == VMINFO_MACHINEREADABLE) 1388 RTPrintf("USBAttachedAddress%zu=\"%lS\"\n", index + 1, bstr.raw()); 1389 else 1390 RTPrintf("Address: %lS\n", bstr.raw()); 1391 } 1392 1393 if (details != VMINFO_MACHINEREADABLE) 1394 RTPrintf("\n"); 1377 1395 } 1378 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);1379 if (!bstr.isEmpty())1380 {1381 if (details == VMINFO_MACHINEREADABLE)1382 RTPrintf("USBAttachedProduct%d=\"%lS\"\n", index + 1, bstr.raw());1383 else1384 RTPrintf("Product: %lS\n", bstr.raw());1385 }1386 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);1387 if (!bstr.isEmpty())1388 {1389 if (details == VMINFO_MACHINEREADABLE)1390 RTPrintf("USBAttachedSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());1391 else1392 RTPrintf("SerialNumber: %lS\n", bstr.raw());1393 }1394 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);1395 if (!bstr.isEmpty())1396 {1397 if (details == VMINFO_MACHINEREADABLE)1398 RTPrintf("USBAttachedAddress%d=\"%lS\"\n", index + 1, bstr.raw());1399 else1400 RTPrintf("Address: %lS\n", bstr.raw());1401 }1402 1403 if (details != VMINFO_MACHINEREADABLE)1404 RTPrintf("\n");1405 1406 ASSERT(SUCCEEDED(rc = en->HasMore (&more)));1407 if (FAILED(rc))1408 return rc;1409 1410 index ++;1411 1396 } 1412 1397 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r17377 r17553 1976 1976 mDevicesUSBMenu->setEnabled (isRunningOrPaused); 1977 1977 1978 CUSBDevice Enumerator en = cconsole.GetUSBDevices().Enumerate();1979 while (en.HasMore())1978 CUSBDeviceVector devsvec = cconsole.GetUSBDevices(); 1979 for (int i = 0; i < devsvec.size(); ++i) 1980 1980 { 1981 CUSBDevice usb = en.GetNext();1981 CUSBDevice usb = devsvec[i]; 1982 1982 info += QString ("<br><b><nobr>%1</nobr></b>") 1983 1983 .arg (vboxGlobal().details (usb)); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r17476 r17553 5544 5544 { 5545 5545 CUSBDevice attachedUSB = 5546 mConsole. GetUSBDevices().FindById (usb.GetId());5546 mConsole.FindUSBDeviceById (usb.GetId()); 5547 5547 action->setChecked (!attachedUSB.isNull()); 5548 5548 action->setEnabled (dev.GetState() != -
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 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r17419 r17553 5568 5568 <interface 5569 5569 name="IConsole" extends="$unknown" 5570 uuid=" e3c6d4a1-a935-47ca-b16d-f9e9c496e53e"5570 uuid="3d458cf1-d8aa-4593-84db-41de9e7242d8" 5571 5571 wsmap="managed" 5572 5572 > … … 5650 5650 </attribute> 5651 5651 5652 <attribute name="USBDevices" type="IUSBDevice Collection" readonly="yes">5652 <attribute name="USBDevices" type="IUSBDevice" readonly="yes" safearray="yes"> 5653 5653 <desc> 5654 5654 Collection of USB devices currently attached to the virtual … … 6020 6020 <param name="device" type="IUSBDevice" dir="return"> 6021 6021 <desc>Detached USB device.</desc> 6022 </param> 6023 </method> 6024 6025 <method name="findUSBDeviceByAddress"> 6026 <desc> 6027 Searches for a USB device with the given host address. 6028 6029 <result name="VBOX_E_OBJECT_NOT_FOUND"> 6030 Given @c name does not correspond to any USB device. 6031 </result> 6032 6033 <see>IUSBDevice::address</see> 6034 </desc> 6035 <param name="name" type="wstring" dir="in"> 6036 <desc> 6037 Address of the USB device (as assigned by the host) to 6038 search for. 6039 </desc> 6040 </param> 6041 <param name="device" type="IUSBDevice" dir="return"> 6042 <desc>Found USB device object.</desc> 6043 </param> 6044 </method> 6045 6046 <method name="findUSBDeviceById"> 6047 <desc> 6048 Searches for a USB device with the given UUID. 6049 6050 <result name="VBOX_E_OBJECT_NOT_FOUND"> 6051 Given @c id does not correspond to any USB device. 6052 </result> 6053 6054 <see>IUSBDevice::id</see> 6055 </desc> 6056 <param name="id" type="uuid" dir="in"> 6057 <desc>UUID of the USB device to search for.</desc> 6058 </param> 6059 <param name="device" type="IUSBDevice" dir="return"> 6060 <desc>Found USB device object.</desc> 6022 6061 </param> 6023 6062 </method> … … 10998 11037 --> 10999 11038 11000 <enumerator11001 name="IUSBDeviceEnumerator" type="IUSBDevice"11002 uuid="aefe00f7-eb8a-454b-9ea4-fd5ad93c0e99"11003 />11004 11005 <collection11006 name="IUSBDeviceCollection" type="IUSBDevice"11007 enumerator="IUSBDeviceEnumerator"11008 uuid="e31f3248-90dd-4ca2-95f0-6b36042d96a2"11009 readonly="yes"11010 >11011 <method name="findById">11012 <desc>11013 Searches this collection for a USB device with the given UUID.11014 <note>11015 The method returns an error if the given UUID does not11016 correspond to any USB device in the collection.11017 </note>11018 <see>IUSBDevice::id</see>11019 </desc>11020 <param name="id" type="uuid" dir="in">11021 <desc>UUID of the USB device to search for.</desc>11022 </param>11023 <param name="device" type="IUSBDevice" dir="return">11024 <desc>Found USB device object.</desc>11025 </param>11026 </method>11027 11028 <method name="findByAddress">11029 <desc>11030 Searches this collection for a USB device with the given11031 host address.11032 <note>11033 The method returns an error if the given address does not11034 correspond to any USB device in the collection.11035 </note>11036 <see>IUSBDevice::address</see>11037 </desc>11038 <param name="name" type="wstring" dir="in">11039 <desc>11040 Address of the USB device (as assigned by the host) to11041 search for.11042 </desc>11043 </param>11044 <param name="device" type="IUSBDevice" dir="return">11045 <desc>Found USB device object.</desc>11046 </param>11047 </method>11048 11049 </collection>11050 11051 11039 <interface 11052 11040 name="IUSBDevice" extends="$unknown" -
trunk/src/VBox/Main/include/ConsoleImpl.h
r17275 r17553 115 115 STDMETHOD(COMGETTER(Display)) (IDisplay **aDisplay); 116 116 STDMETHOD(COMGETTER(Debugger)) (IMachineDebugger **aDebugger); 117 STDMETHOD(COMGETTER(USBDevices)) ( IUSBDeviceCollection **aUSBDevices);117 STDMETHOD(COMGETTER(USBDevices)) (ComSafeArrayOut (IUSBDevice *, aUSBDevices)); 118 118 STDMETHOD(COMGETTER(RemoteUSBDevices)) (IHostUSBDeviceCollection **aRemoteUSBDevices); 119 119 STDMETHOD(COMGETTER(RemoteDisplayInfo)) (IRemoteDisplayInfo **aRemoteDisplayInfo); … … 139 139 STDMETHOD(AttachUSBDevice) (IN_GUID aId); 140 140 STDMETHOD(DetachUSBDevice) (IN_GUID aId, IUSBDevice **aDevice); 141 STDMETHOD(FindUSBDeviceByAddress) (IN_BSTR aAddress, IUSBDevice **aDevice); 142 STDMETHOD(FindUSBDeviceById) (IN_GUID aId, IUSBDevice **aDevice); 141 143 STDMETHOD(CreateSharedFolder) (IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable); 142 144 STDMETHOD(RemoveSharedFolder) (IN_BSTR aName); -
trunk/src/VBox/Main/include/USBDeviceImpl.h
r15051 r17553 6 6 7 7 /* 8 * Copyright (C) 2006-200 8Sun Microsystems, Inc.8 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 26 26 #include "VirtualBoxBase.h" 27 #include "Collection.h"28 27 #include "Logging.h" 29 28 … … 121 120 }; 122 121 123 COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_BEGIN (ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)124 125 STDMETHOD(FindById) (IN_GUID aId, IUSBDevice **aDevice)126 {127 Guid idToFind = aId;128 if (idToFind.isEmpty())129 return E_INVALIDARG;130 if (!aDevice)131 return E_POINTER;132 133 *aDevice = NULL;134 Vector::value_type found;135 Vector::iterator it = vec.begin();136 while (!found && it != vec.end())137 {138 Guid id;139 (*it)->COMGETTER(Id) (id.asOutParam());140 if (id == idToFind)141 found = *it;142 ++ it;143 }144 145 if (!found)146 {147 return setErrorNoLog (E_INVALIDARG, OUSBDeviceCollection::tr (148 "Could not find a USB device with UUID {%s}"),149 idToFind.toString().raw());150 }151 152 return found.queryInterfaceTo (aDevice);153 }154 155 STDMETHOD(FindByAddress) (IN_BSTR aAddress, IUSBDevice **aDevice)156 {157 if (!aAddress)158 return E_INVALIDARG;159 if (!aDevice)160 return E_POINTER;161 162 *aDevice = NULL;163 Vector::value_type found;164 Vector::iterator it = vec.begin();165 while (!found && it != vec.end())166 {167 Bstr address;168 (*it)->COMGETTER(Address) (address.asOutParam());169 if (address == aAddress)170 found = *it;171 ++ it;172 }173 174 if (!found)175 return setErrorNoLog (E_INVALIDARG, OUSBDeviceCollection::tr (176 "Could not find a USB device with address '%ls'"),177 aAddress);178 179 return found.queryInterfaceTo (aDevice);180 }181 182 COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_END (ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)183 184 122 #endif // ____H_USBDEVICEIMPL 185 123 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/xpcom/module.cpp
r16966 r17553 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 83 83 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole) 84 84 85 COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)86 85 COM_IMPL_READONLY_ENUM_AND_COLLECTION_EX(ComObjPtr <RemoteUSBDevice>, IHostUSBDevice, RemoteUSBDevice) 87 86 … … 163 162 164 163 NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components) 165 164 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/xpcom/server.cpp
r17394 r17553 246 246 #endif 247 247 248 #ifdef VBOX_WITH_USB249 COM_IMPL_READONLY_ENUM_AND_COLLECTION_AS(IfaceUSBDevice, IUSBDevice)250 #endif251 252 248 //////////////////////////////////////////////////////////////////////////////// 253 249
Note:
See TracChangeset
for help on using the changeset viewer.