Changeset 23223 in vbox for trunk/src/VBox/Main/HostImpl.cpp
- Timestamp:
- Sep 22, 2009 3:50:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostImpl.cpp
r22615 r23223 94 94 95 95 #include "HostImpl.h" 96 #include "HostDVDDriveImpl.h"97 #include "HostFloppyDriveImpl.h"98 96 #include "HostNetworkInterfaceImpl.h" 99 97 #ifdef VBOX_WITH_USB … … 314 312 * @param drives address of result pointer 315 313 */ 316 STDMETHODIMP Host::COMGETTER(DVDDrives) (ComSafeArrayOut(IHostDVDDrive*, aDrives))314 STDMETHODIMP Host::COMGETTER(DVDDrives)(ComSafeArrayOut(IMedium *, aDrives)) 317 315 { 318 316 CheckComArgOutSafeArrayPointerValid(aDrives); … … 323 321 AutoWriteLock alock(this); 324 322 325 std::list< ComObjPtr< HostDVDDrive> > list;323 std::list< ComObjPtr<Medium> > list; 326 324 HRESULT rc = S_OK; 327 325 try … … 338 336 { 339 337 driveName[0] = *p; 340 ComObjPtr< HostDVDDrive> hostDVDDriveObj;338 ComObjPtr<Medium> hostDVDDriveObj; 341 339 hostDVDDriveObj.createObject(); 342 hostDVDDriveObj->init (Bstr(driveName));343 list.push_back 340 hostDVDDriveObj->init(mParent, DeviceType_DVD, Bstr(driveName)); 341 list.push_back(hostDVDDriveObj); 344 342 } 345 343 p += _tcslen(p) + 1; … … 364 362 if (validateDevice(cdromDrive, true)) 365 363 { 366 ComObjPtr< HostDVDDrive> hostDVDDriveObj;364 ComObjPtr<Medium> hostDVDDriveObj; 367 365 hostDVDDriveObj.createObject(); 368 hostDVDDriveObj->init (Bstr(cdromDrive));369 list.push_back 366 hostDVDDriveObj->init(mParent, DeviceType_DVD, Bstr(cdromDrive)); 367 list.push_back(hostDVDDriveObj); 370 368 } 371 369 cdromDrive = strtok(NULL, ":"); … … 378 376 if (validateDevice("/cdrom/cdrom0", true)) 379 377 { 380 ComObjPtr< HostDVDDrive> hostDVDDriveObj;378 ComObjPtr<Medium> hostDVDDriveObj; 381 379 hostDVDDriveObj.createObject(); 382 hostDVDDriveObj->init (Bstr("cdrom/cdrom0"));383 list.push_back 380 hostDVDDriveObj->init(mParent, DeviceType_DVD, Bstr("cdrom/cdrom0")); 381 list.push_back(hostDVDDriveObj); 384 382 } 385 383 … … 394 392 SUCCEEDED(rc) && it != mHostDrives.DVDEnd(); ++it) 395 393 { 396 ComObjPtr<HostDVDDrive> hostDVDDriveObj; 397 Bstr device(it->mDevice); 398 Bstr udi(it->mUdi); 394 ComObjPtr<Medium> hostDVDDriveObj; 395 Bstr location(it->mDevice); 399 396 Bstr description(it->mDescription); 400 397 if (SUCCEEDED(rc)) 401 398 rc = hostDVDDriveObj.createObject(); 402 399 if (SUCCEEDED(rc)) 403 rc = hostDVDDriveObj->init (device, udi, description);400 rc = hostDVDDriveObj->init(mParent, DeviceType_DVD, location, description); 404 401 if (SUCCEEDED(rc)) 405 402 list.push_back(hostDVDDriveObj); … … 409 406 while (cur) 410 407 { 411 ComObjPtr< HostDVDDrive> hostDVDDriveObj;408 ComObjPtr<Medium> hostDVDDriveObj; 412 409 hostDVDDriveObj.createObject(); 413 410 hostDVDDriveObj->init(Bstr(cur->szName)); … … 430 427 #endif 431 428 432 SafeIfaceArray<I HostDVDDrive> array(list);429 SafeIfaceArray<IMedium> array(list); 433 430 array.detachTo(ComSafeArrayOutArg(aDrives)); 434 431 } … … 446 443 * @param drives address of result pointer 447 444 */ 448 STDMETHODIMP Host::COMGETTER(FloppyDrives) (ComSafeArrayOut(IHostFloppyDrive*, aDrives))445 STDMETHODIMP Host::COMGETTER(FloppyDrives)(ComSafeArrayOut(IMedium *, aDrives)) 449 446 { 450 447 CheckComArgOutPointerValid(aDrives); … … 455 452 AutoWriteLock alock(this); 456 453 457 std::list<ComObjPtr< HostFloppyDrive> > list;454 std::list<ComObjPtr<Medium> > list; 458 455 HRESULT rc = S_OK; 459 456 … … 471 468 { 472 469 driveName[0] = *p; 473 ComObjPtr< HostFloppyDrive> hostFloppyDriveObj;470 ComObjPtr<Medium> hostFloppyDriveObj; 474 471 hostFloppyDriveObj.createObject(); 475 hostFloppyDriveObj->init (Bstr(driveName));476 list.push_back 472 hostFloppyDriveObj->init(mParent, DeviceType_Floppy, Bstr(driveName)); 473 list.push_back(hostFloppyDriveObj); 477 474 } 478 475 p += _tcslen(p) + 1; … … 485 482 SUCCEEDED(rc) && it != mHostDrives.FloppyEnd(); ++it) 486 483 { 487 ComObjPtr<HostFloppyDrive> hostFloppyDriveObj; 488 Bstr device(it->mDevice); 489 Bstr udi(it->mUdi); 484 ComObjPtr<Medium> hostFloppyDriveObj; 485 Bstr location(it->mDevice); 490 486 Bstr description(it->mDescription); 491 487 if (SUCCEEDED(rc)) 492 488 rc = hostFloppyDriveObj.createObject(); 493 489 if (SUCCEEDED(rc)) 494 rc = hostFloppyDriveObj->init (device, udi, description);490 rc = hostFloppyDriveObj->init(mParent, DeviceType_Floppy, location, description); 495 491 if (SUCCEEDED(rc)) 496 492 list.push_back(hostFloppyDriveObj); … … 500 496 #endif 501 497 502 SafeIfaceArray<I HostFloppyDrive> collection(list);498 SafeIfaceArray<IMedium> collection(list); 503 499 collection.detachTo(ComSafeArrayOutArg(aDrives)); 504 500 } … … 1481 1477 * @retval list drives found will be attached to this list 1482 1478 */ 1483 bool Host::getDVDInfoFromHal(std::list <ComObjPtr< HostDVDDrive> > &list)1479 bool Host::getDVDInfoFromHal(std::list <ComObjPtr<Medium> > &list) 1484 1480 { 1485 1481 bool halSuccess = false; … … 1559 1555 description = product; 1560 1556 } 1561 ComObjPtr< HostDVDDrive> hostDVDDriveObj;1557 ComObjPtr<Medium> hostDVDDriveObj; 1562 1558 hostDVDDriveObj.createObject(); 1563 1559 hostDVDDriveObj->init (Bstr (devNode), … … 1574 1570 gDBusErrorFree(&dbusError); 1575 1571 } 1576 ComObjPtr< HostDVDDrive> hostDVDDriveObj;1572 ComObjPtr<Medium> hostDVDDriveObj; 1577 1573 hostDVDDriveObj.createObject(); 1578 1574 hostDVDDriveObj->init (Bstr (devNode), … … 1653 1649 * @retval list drives found will be attached to this list 1654 1650 */ 1655 bool Host::getFloppyInfoFromHal(std::list <ComObjPtr< HostFloppyDrive> > &list)1651 bool Host::getFloppyInfoFromHal(std::list <ComObjPtr<Medium> > &list) 1656 1652 { 1657 1653 bool halSuccess = false; … … 1723 1719 description = product; 1724 1720 } 1725 ComObjPtr< HostFloppyDrive> hostFloppyDrive;1721 ComObjPtr<Medium> hostFloppyDrive; 1726 1722 hostFloppyDrive.createObject(); 1727 1723 hostFloppyDrive->init (Bstr (devNode), … … 1738 1734 gDBusErrorFree(&dbusError); 1739 1735 } 1740 ComObjPtr< HostFloppyDrive> hostFloppyDrive;1736 ComObjPtr<Medium> hostFloppyDrive; 1741 1737 hostFloppyDrive.createObject(); 1742 1738 hostFloppyDrive->init (Bstr (devNode), … … 1811 1807 * Helper function to parse the given mount file and add found entries 1812 1808 */ 1813 void Host::parseMountTable(char *mountTable, std::list <ComObjPtr< HostDVDDrive> > &list)1809 void Host::parseMountTable(char *mountTable, std::list <ComObjPtr<Medium> > &list) 1814 1810 { 1815 1811 #ifdef RT_OS_LINUX … … 1861 1857 if (validateDevice(mnt_dev, true)) 1862 1858 { 1863 ComObjPtr< HostDVDDrive> hostDVDDriveObj;1859 ComObjPtr<Medium> hostDVDDriveObj; 1864 1860 hostDVDDriveObj.createObject(); 1865 1861 hostDVDDriveObj->init (Bstr (mnt_dev)); … … 1893 1889 if (validateDevice(rawDevName, true)) 1894 1890 { 1895 ComObjPtr< HostDVDDrive> hostDVDDriveObj;1891 ComObjPtr<Medium> hostDVDDriveObj; 1896 1892 hostDVDDriveObj.createObject(); 1897 1893 hostDVDDriveObj->init (Bstr (rawDevName)); … … 2123 2119 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 2124 2120 2125 STDMETHODIMP Host::FindHostDVDDrive(IN_BSTR aName, I HostDVDDrive**aDrive)2121 STDMETHODIMP Host::FindHostDVDDrive(IN_BSTR aName, IMedium **aDrive) 2126 2122 { 2127 2123 CheckComArgNotNull(aName); … … 2130 2126 *aDrive = NULL; 2131 2127 2132 SafeIfaceArray<I HostDVDDrive> drivevec;2133 HRESULT rc = COMGETTER(DVDDrives) 2128 SafeIfaceArray<IMedium> drivevec; 2129 HRESULT rc = COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(drivevec)); 2134 2130 CheckComRCReturnRC(rc); 2135 2131 2136 2132 for (size_t i = 0; i < drivevec.size(); ++i) 2137 2133 { 2134 ComPtr<IMedium> drive = drivevec[i]; 2135 Bstr name, location; 2136 rc = drive->COMGETTER(Name)(name.asOutParam()); 2137 CheckComRCReturnRC(rc); 2138 rc = drive->COMGETTER(Location)(location.asOutParam()); 2139 CheckComRCReturnRC(rc); 2140 if (name == aName || location == aName) 2141 return drive.queryInterfaceTo(aDrive); 2142 } 2143 2144 return setError(VBOX_E_OBJECT_NOT_FOUND, 2145 Medium::tr("The host DVD drive named '%ls' could not be found"), aName); 2146 } 2147 2148 STDMETHODIMP Host::FindHostFloppyDrive(IN_BSTR aName, IMedium **aDrive) 2149 { 2150 CheckComArgNotNull(aName); 2151 CheckComArgOutPointerValid(aDrive); 2152 2153 *aDrive = NULL; 2154 2155 SafeIfaceArray<IMedium> drivevec; 2156 HRESULT rc = COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(drivevec)); 2157 CheckComRCReturnRC(rc); 2158 2159 for (size_t i = 0; i < drivevec.size(); ++i) 2160 { 2161 ComPtr<IMedium> drive = drivevec[i]; 2138 2162 Bstr name; 2139 rc = drive vec[i]->COMGETTER(Name)(name.asOutParam());2163 rc = drive->COMGETTER(Name)(name.asOutParam()); 2140 2164 CheckComRCReturnRC(rc); 2141 2165 if (name == aName) 2142 { 2143 ComObjPtr<HostDVDDrive> found; 2144 found.createObject(); 2145 Bstr udi, description; 2146 rc = drivevec[i]->COMGETTER(Udi) (udi.asOutParam()); 2147 CheckComRCReturnRC(rc); 2148 rc = drivevec[i]->COMGETTER(Description) (description.asOutParam()); 2149 CheckComRCReturnRC(rc); 2150 found->init(name, udi, description); 2151 return found.queryInterfaceTo(aDrive); 2152 } 2153 } 2154 2155 return setError (VBOX_E_OBJECT_NOT_FOUND, HostDVDDrive::tr ( 2156 "The host DVD drive named '%ls' could not be found"), aName); 2157 } 2158 2159 STDMETHODIMP Host::FindHostFloppyDrive(IN_BSTR aName, IHostFloppyDrive **aDrive) 2160 { 2161 CheckComArgNotNull(aName); 2162 CheckComArgOutPointerValid(aDrive); 2163 2164 *aDrive = NULL; 2165 2166 SafeIfaceArray<IHostFloppyDrive> drivevec; 2167 HRESULT rc = COMGETTER(FloppyDrives) (ComSafeArrayAsOutParam(drivevec)); 2168 CheckComRCReturnRC(rc); 2169 2170 for (size_t i = 0; i < drivevec.size(); ++i) 2171 { 2172 Bstr name; 2173 rc = drivevec[i]->COMGETTER(Name) (name.asOutParam()); 2174 CheckComRCReturnRC(rc); 2175 if (name == aName) 2176 { 2177 ComObjPtr<HostFloppyDrive> found; 2178 found.createObject(); 2179 Bstr udi, description; 2180 rc = drivevec[i]->COMGETTER(Udi) (udi.asOutParam()); 2181 CheckComRCReturnRC(rc); 2182 rc = drivevec[i]->COMGETTER(Description) (description.asOutParam()); 2183 CheckComRCReturnRC(rc); 2184 found->init(name, udi, description); 2185 return found.queryInterfaceTo(aDrive); 2186 } 2187 } 2188 2189 return setError (VBOX_E_OBJECT_NOT_FOUND, HostFloppyDrive::tr ( 2190 "The host floppy drive named '%ls' could not be found"), aName); 2166 return drive.queryInterfaceTo(aDrive); 2167 } 2168 2169 return setError(VBOX_E_OBJECT_NOT_FOUND, 2170 Medium::tr("The host floppy drive named '%ls' could not be found"), aName); 2191 2171 } 2192 2172
Note:
See TracChangeset
for help on using the changeset viewer.