- Timestamp:
- Feb 1, 2011 2:30:31 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/HostImpl.h
r35638 r35813 129 129 HRESULT buildDVDDrivesList(MediaList &list); 130 130 HRESULT buildFloppyDrivesList(MediaList &list); 131 HRESULT findHostDriveByNameOrId(DeviceType_T mediumType, const Utf8Str &strNameOrId, ComObjPtr<Medium> &pMedium); 131 132 132 133 #if defined(RT_OS_SOLARIS) && defined(VBOX_USE_LIBHAL) -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r35809 r35813 393 393 ComPtr<IProgress> progress; 394 394 395 int r = NetIfCreateHostOnlyNetworkInterface(m->pParent, 396 hif.asOutParam(), 395 int r = NetIfCreateHostOnlyNetworkInterface(m->pParent, 396 hif.asOutParam(), 397 397 progress.asOutParam(), 398 398 it->c_str()); … … 1307 1307 CheckComArgOutPointerValid(aDrive); 1308 1308 1309 *aDrive = NULL; 1310 1311 SafeIfaceArray<IMedium> drivevec; 1312 HRESULT rc = COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(drivevec)); 1313 if (FAILED(rc)) return rc; 1314 1315 for (size_t i = 0; i < drivevec.size(); ++i) 1316 { 1317 ComPtr<IMedium> drive = drivevec[i]; 1318 Bstr name, location, id; 1319 rc = drive->COMGETTER(Name)(name.asOutParam()); 1320 if (FAILED(rc)) return rc; 1321 rc = drive->COMGETTER(Location)(location.asOutParam()); 1322 if (FAILED(rc)) return rc; 1323 rc = drive->COMGETTER(Id)(id.asOutParam()); 1324 if (FAILED(rc)) return rc; 1325 if ( name == aName 1326 || location == aName 1327 || (!Guid(aName).isEmpty() && aName == id)) 1328 return drive.queryInterfaceTo(aDrive); 1329 } 1330 1331 return setError(VBOX_E_OBJECT_NOT_FOUND, 1332 Medium::tr("The host DVD drive named '%ls' could not be found"), aName); 1309 ComObjPtr<Medium>medium; 1310 HRESULT rc = findHostDriveByNameOrId(DeviceType_DVD, Utf8Str(aName), medium); 1311 if (SUCCEEDED(rc)) 1312 return medium.queryInterfaceTo(aDrive); 1313 else 1314 return setError(rc, Medium::tr("The host DVD drive named '%ls' could not be found"), aName); 1333 1315 } 1334 1316 … … 1340 1322 *aDrive = NULL; 1341 1323 1342 SafeIfaceArray<IMedium> drivevec; 1343 HRESULT rc = COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(drivevec)); 1344 if (FAILED(rc)) return rc; 1345 1346 for (size_t i = 0; i < drivevec.size(); ++i) 1347 { 1348 ComPtr<IMedium> drive = drivevec[i]; 1349 Bstr name; 1350 rc = drive->COMGETTER(Name)(name.asOutParam()); 1351 if (FAILED(rc)) return rc; 1352 if (name == aName) 1353 return drive.queryInterfaceTo(aDrive); 1354 } 1355 1356 return setError(VBOX_E_OBJECT_NOT_FOUND, 1357 Medium::tr("The host floppy drive named '%ls' could not be found"), aName); 1324 ComObjPtr<Medium>medium; 1325 HRESULT rc = findHostDriveByNameOrId(DeviceType_Floppy, Utf8Str(aName), medium); 1326 if (SUCCEEDED(rc)) 1327 return medium.queryInterfaceTo(aDrive); 1328 else 1329 return setError(rc, Medium::tr("The host floppy drive named '%ls' could not be found"), aName); 1358 1330 } 1359 1331 … … 1758 1730 { 1759 1731 Medium *pThis = *it; 1732 AutoCaller mediumCaller(pThis); 1733 AutoReadLock mediumLock(pThis COMMA_LOCKVAL_SRC_POS); 1760 1734 if (pThis->getId() == uuid) 1761 1735 { … … 1796 1770 { 1797 1771 Medium *pThis = *it; 1772 AutoCaller mediumCaller(pThis); 1773 AutoReadLock mediumLock(pThis COMMA_LOCKVAL_SRC_POS); 1798 1774 if (pThis->getLocationFull() == strLocationFull) 1799 1775 { … … 1805 1781 1806 1782 return VBOX_E_OBJECT_NOT_FOUND; 1783 } 1784 1785 /** 1786 * Goes through the list of host drives that would be returned by getDrives() 1787 * and looks for a host drive with the given name, location or ID. If found, 1788 * it sets pMedium to that drive; otherwise returns VBOX_E_OBJECT_NOT_FOUND. 1789 * 1790 * @param mediumType Must be DeviceType_DVD or DeviceType_Floppy. 1791 * @param strNameOrId Name or full location or UUID of host drive to look for. 1792 * @param pMedium Medium object, if found… 1793 * @return VBOX_E_OBJECT_NOT_FOUND if not found, or S_OK if found, or errors from getDrives(). 1794 */ 1795 HRESULT Host::findHostDriveByNameOrId(DeviceType_T mediumType, 1796 const Utf8Str &strNameOrId, 1797 ComObjPtr<Medium> &pMedium) 1798 { 1799 MediaList *pllMedia; 1800 1801 AutoWriteLock wlock(m->drivesLock COMMA_LOCKVAL_SRC_POS); 1802 1803 Guid uuid(strNameOrId); 1804 if (!uuid.isEmpty()) 1805 return findHostDriveById(mediumType, uuid, true /* fRefresh */, pMedium); 1806 1807 // string is not a syntactically valid UUID: try a name then 1808 return findHostDriveByName(mediumType, strNameOrId, true /* fRefresh */, pMedium); 1807 1809 } 1808 1810
Note:
See TracChangeset
for help on using the changeset viewer.