Changeset 2917 in vbox
- Timestamp:
- May 29, 2007 2:17:19 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure
r2678 r2917 30 30 WITH_QT=1 31 31 WITH_SDL_TTF=1 32 WITH_HAL=1 32 33 CC="gcc" 33 34 CXX="g++" … … 54 55 INCPNG="" 55 56 LIBPNG="-lpng" 57 CFLAGSHAL="-I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include" 58 LIBHAL="-lhal -ldbus-1" 56 59 QTDIR="/usr/qt/3 /usr/lib/qt3 /usr/lib/qt-3.3 /usr/share/qt3 /usr/lib64/qt-3.3" 57 60 KBUILDDIR="`cd $(dirname $0); pwd`/kBuild" … … 999 1002 1000 1003 # 1004 # Check for the libhal library for obtaining hardware information on Linux 1005 # 1006 function check_libhal() 1007 { 1008 test_header libhal 1009 pc_cflagshal=`pkg-config hal --cflags 2>/dev/null` 1010 pc_libhal=`pkg-config hal --libs 2>/dev/null` 1011 if [ ! -z "$pc_cflagshal" ] 1012 then # is this acceptable? 1013 CFLAGSHAL=$pc_cflagshal 1014 LIBHAL=$pc_libhal 1015 fi 1016 echo ' 1017 #include <cstdio> 1018 #include <libhal.h> 1019 extern "C" int main(void) 1020 { 1021 DBusError dbusError; 1022 dbus_error_init (&dbusError); 1023 LibHalContext *halContext = libhal_ctx_new(); 1024 if (halContext != 0) 1025 { 1026 libhal_ctx_free(halContext); 1027 } 1028 return 0; 1029 } 1030 ' > .tmp_src.cc 1031 if test_compile "$CFLAGSHAL $LIBHAL" libhal libhal; then 1032 log_success "found" 1033 cnf_append "LIB_HAL_CFLAGS" "$CFLAGSHAL" 1034 cnf_append "LIB_HAL_LIBS" `echo $LIBHAL | sed 's+-l++g'` 1035 cnf_append "VBOX_WITH_LIBHAL" "1" 1036 fi 1037 } 1038 1039 1040 # 1001 1041 # Show help 1002 1042 # … … 1012 1052 --disable-sdl-ttf disable SDL_ttf detection 1013 1053 --build-xalan build xalan & xerces from shipped sources 1054 --without-hal do not use libhal, even if it is available 1014 1055 1015 1056 Paths: 1016 --with-gcc=PATH position of the gcc compiler [$CC]1017 --with-g++=PATH position of the g++ compiler [$CXX]1057 --with-gcc=PATH location of the gcc compiler [$CC] 1058 --with-g++=PATH location of the g++ compiler [$CXX] 1018 1059 --with-kbuild=DIR kbuild directory [$KBUILDDIR] 1019 --with-iasl=PATH the position of the iasl compiler [$IASL] 1060 --with-iasl=PATH location of the iasl compiler [$IASL] 1061 --with-hal-cflags=FLAGS cflags for libhal [$CFLAGSHAL] 1062 --with-hal=LIB location of the libhal libraries [$LIBHAL] 1020 1063 --with-linux=DIR Linux kernel source directory [$LINUX] 1021 --with-mkisofs=PATH position of mkisofs [$MKISOFS]1064 --with-mkisofs=PATH location of mkisofs [$MKISOFS] 1022 1065 --with-qt-dir=DIR directory for QT headers/libraries [$QTDIR] 1023 --with-xalan=LIB position of the xalan library [$LIBXALAN]1024 --with-xerces=LIB position of the xerces library [$LIBXERCES]1066 --with-xalan=LIB location of the xalan library [$LIBXALAN] 1067 --with-xerces=LIB location of the xerces library [$LIBXERCES] 1025 1068 1026 1069 Build type: … … 1060 1103 QTDIR=`echo $option | cut -d'=' -f2` 1061 1104 ;; 1105 --with-hal-dir=*) 1106 INCHAL=`echo $option | cut -d'=' -f2` 1107 ;; 1108 --with-hal=*) 1109 LIBHAL=`echo $option | cut -d'=' -f2` 1110 ;; 1062 1111 --with-iasl=*) 1063 1112 IASL=`echo $option | cut -d'=' -f2` … … 1083 1132 --disable-qt) 1084 1133 WITH_QT=0 1134 ;; 1135 --without-hal) 1136 WITH_HAL=0 1085 1137 ;; 1086 1138 --build-debug|-d) … … 1207 1259 [ "$OS" = "linux" ] && check_linux 1208 1260 [ "$OS" = "linux" ] && check_compiler_h 1261 [ "$OS" = "linux" -a "$WITH_HAL" = "1" ] && check_libhal 1209 1262 1210 1263 # success! -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r2868 r2917 1552 1552 { 1553 1553 case CEnums::HostDriveCaptured: 1554 name = tr ("Host Drive ", "DVD-ROM tooltip") + 1555 dvd.GetHostDrive().GetName(); 1554 { 1555 QString description = dvd.GetHostDrive().GetDescription(); 1556 if (description.isEmpty()) 1557 { 1558 name = tr ("Host Drive ", "DVD-ROM tooltip") + 1559 dvd.GetHostDrive().GetName(); 1560 } 1561 else 1562 { 1563 name = tr ("Host Drive ", "DVD-ROM tooltip") + 1564 description; 1565 } 1556 1566 break; 1567 } 1557 1568 case CEnums::ImageMounted: 1558 1569 name = dvd.GetImage().GetFilePath(); … … 2187 2198 CHostDVDDrive hostDVD = en.GetNext(); 2188 2199 /** @todo set icon */ 2189 int id = devicesMountDVDMenu->insertItem ( 2190 tr ("Host Drive ") + hostDVD.GetName() 2191 ); 2200 QString description = hostDVD.GetDescription(); 2201 int id; 2202 if (description.isEmpty()) 2203 { 2204 id = devicesMountDVDMenu->insertItem ( 2205 tr ("Host Drive ") + hostDVD.GetName() 2206 ); 2207 } 2208 else 2209 { 2210 id = devicesMountDVDMenu->insertItem ( 2211 tr ("Host Drive ") + description 2212 ); 2213 } 2192 2214 hostDVDMap [id] = hostDVD; 2193 2215 if (machine_state != CEnums::Running) -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r2834 r2917 1173 1173 { 1174 1174 CHostDVDDrive drv = dvd.GetHostDrive(); 1175 QString description = drv.GetDescription(); 1176 if (description.isEmpty()) 1177 { 1175 1178 item = item.arg (tr ("Host Drive", "details report (DVD)"), 1176 1179 drv.GetName()); 1180 } 1181 else 1182 { 1183 item = item.arg (tr ("Host Drive", "details report (DVD)"), 1184 description); 1185 } 1177 1186 break; 1178 1187 } -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r2915 r2917 1426 1426 CHostDVDDrive hostDVD = en.GetNext(); 1427 1427 /// @todo (r=dmik) set icon? 1428 cbHostDVD->insertItem (hostDVD.GetName(), id); 1428 QString description = hostDVD.GetDescription(); 1429 if (description.isEmpty()) 1430 { 1431 cbHostDVD->insertItem (hostDVD.GetName(), id); 1432 } 1433 else 1434 { 1435 cbHostDVD->insertItem (description, id); 1436 } 1429 1437 hostDVDs [id] = hostDVD; 1430 1438 ++ id; … … 1438 1446 CHostDVDDrive drv = dvd.GetHostDrive(); 1439 1447 QString name = drv.GetName(); 1448 QString description = drv.GetDescription(); 1440 1449 if (coll.FindByName (name).isNull()) 1441 1450 { … … 1444 1453 * add it to the end of the list with a special mark 1445 1454 */ 1446 cbHostDVD->insertItem ("* " + name); 1455 if (description.isEmpty()) 1456 { 1457 cbHostDVD->insertItem ("* " + name); 1458 } 1459 else 1460 { 1461 cbHostDVD->insertItem ("* " + description); 1462 } 1447 1463 cbHostDVD->setCurrentItem (cbHostDVD->count() - 1); 1448 1464 } … … 1450 1466 { 1451 1467 /* this will select the correct item from the prepared list */ 1452 cbHostDVD->setCurrentText (name); 1468 if (description.isEmpty()) 1469 { 1470 cbHostDVD->setCurrentText (name); 1471 } 1472 else 1473 { 1474 cbHostDVD->setCurrentText (description); 1475 } 1453 1476 } 1454 1477 rbHostDVD->setChecked (true); -
trunk/src/VBox/Main/HostDVDDriveImpl.cpp
r1 r2917 52 52 } 53 53 54 /** 55 * Initializes the host object. 56 * 57 * @returns COM result indicator 58 * @param driveName name of the drive 59 * @param driveDescription human readable description of the drive 60 */ 61 HRESULT HostDVDDrive::init (INPTR BSTR driveName, INPTR BSTR driveDescription) 62 { 63 ComAssertRet (driveName, E_INVALIDARG); 64 ComAssertRet (driveDescription, E_INVALIDARG); 65 66 AutoLock lock(this); 67 mDriveName = driveName; 68 mDriveDescription = driveDescription; 69 setReady(true); 70 return S_OK; 71 } 72 54 73 // IHostDVDDrive properties 55 74 ///////////////////////////////////////////////////////////////////////////// … … 70 89 return S_OK; 71 90 } 91 92 /** 93 * Returns the description of the host drive 94 * 95 * @returns COM status code 96 * @param driveDescription address of result pointer 97 */ 98 STDMETHODIMP HostDVDDrive::COMGETTER(Description) (BSTR *driveDescription) 99 { 100 if (!driveDescription) 101 return E_POINTER; 102 AutoLock lock(this); 103 CHECK_READY(); 104 mDriveDescription.cloneTo(driveDescription); 105 return S_OK; 106 } -
trunk/src/VBox/Main/HostImpl.cpp
r2805 r2917 31 31 #define _LINUX_BYTEORDER_GENERIC_H 32 32 #include <linux/cdrom.h> 33 #ifdef VBOX_USE_LIBHAL 34 # include <libhal.h> 35 /* These are defined by libhal.h and by VBox header files. */ 36 # undef TRUE 37 # undef FALSE 38 #endif 33 39 #include <errno.h> 34 40 #endif /* __LINUX __ */ … … 190 196 delete[] hostDrives; 191 197 #elif defined(__LINUX__) 192 // On Linux, the situation is much more complex. There is no simple API so 193 // we will take a more creative approach. As there is only a heuristical 194 // approach on Linux, we'll allow the user to specify a list of host CDROMs 195 // using and an environment variable. 198 #ifdef VBOX_USE_LIBHAL 199 if (!getDVDInfoFromHal(list)) /* Playing with #defines in this way is nasty, I know. */ 200 #endif /* USE_LIBHAL defined */ 201 // On Linux without hal, the situation is much more complex. We will take a 202 // heuristical approach and also allow the user to specify a list of host 203 // CDROMs using an environment variable. 196 204 // The general strategy is to try some known device names and see of they 197 205 // exist. At last, we'll enumerate the /etc/fstab file (luckily there's an 198 206 // API to parse it) for CDROM devices. Ok, let's start! 199 207 200 if (getenv("VBOX_CDROM")) 201 { 202 char *cdromEnv = strdupa(getenv("VBOX_CDROM")); 203 char *cdromDrive; 204 cdromDrive = strtok(cdromEnv, ":"); 205 while (cdromDrive) 206 { 207 if (validateDevice(cdromDrive, true)) 208 { 209 if (getenv("VBOX_CDROM")) 210 { 211 char *cdromEnv = strdupa(getenv("VBOX_CDROM")); 212 char *cdromDrive; 213 cdromDrive = strtok(cdromEnv, ":"); 214 while (cdromDrive) 208 215 { 209 ComObjPtr <HostDVDDrive> hostDVDDriveObj; 210 hostDVDDriveObj.createObject(); 211 hostDVDDriveObj->init (Bstr (cdromDrive)); 212 list.push_back (hostDVDDriveObj); 216 if (validateDevice(cdromDrive, true)) 217 { 218 ComObjPtr <HostDVDDrive> hostDVDDriveObj; 219 hostDVDDriveObj.createObject(); 220 hostDVDDriveObj->init (Bstr (cdromDrive)); 221 list.push_back (hostDVDDriveObj); 222 } 223 cdromDrive = strtok(NULL, ":"); 213 224 } 214 cdromDrive = strtok(NULL, ":"); 215 } 216 } 217 else 218 { 219 // this is a good guess usually 220 if (validateDevice("/dev/cdrom", true)) 221 { 222 ComObjPtr <HostDVDDrive> hostDVDDriveObj; 223 hostDVDDriveObj.createObject(); 224 hostDVDDriveObj->init (Bstr ("/dev/cdrom")); 225 list.push_back (hostDVDDriveObj); 226 } 227 228 // check the mounted drives 229 parseMountTable((char*)"/etc/mtab", list); 230 231 // check the drives that can be mounted 232 parseMountTable((char*)"/etc/fstab", list); 225 } 226 else 227 { 228 // this is a good guess usually 229 if (validateDevice("/dev/cdrom", true)) 230 { 231 ComObjPtr <HostDVDDrive> hostDVDDriveObj; 232 hostDVDDriveObj.createObject(); 233 hostDVDDriveObj->init (Bstr ("/dev/cdrom")); 234 list.push_back (hostDVDDriveObj); 235 } 236 237 // check the mounted drives 238 parseMountTable((char*)"/etc/mtab", list); 239 240 // check the drives that can be mounted 241 parseMountTable((char*)"/etc/fstab", list); 242 } 233 243 } 234 244 #elif defined(__DARWIN__) … … 1380 1390 1381 1391 #ifdef __LINUX__ 1392 # ifdef VBOX_USE_LIBHAL 1393 /** 1394 * Helper function to query the hal subsystem for information about DVD drives attached to the 1395 * system. 1396 * 1397 * @returns true if at least one drive was found, false otherwise 1398 * @retval list drives found will be attached to this list 1399 */ 1400 bool Host::getDVDInfoFromHal(std::list <ComObjPtr <HostDVDDrive> > &list) 1401 { 1402 bool halSuccess = false; 1403 DBusError dbusError; 1404 dbus_error_init (&dbusError); 1405 DBusConnection *dbusConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbusError); 1406 if (dbusConnection != 0) 1407 { 1408 LibHalContext *halContext = libhal_ctx_new(); 1409 if (halContext != 0) 1410 { 1411 if (libhal_ctx_set_dbus_connection (halContext, dbusConnection)) 1412 { 1413 if (libhal_ctx_init(halContext, &dbusError)) 1414 { 1415 int numDevices; 1416 char **halDevices = libhal_find_device_by_capability(halContext, 1417 "storage.cdrom", &numDevices, &dbusError); 1418 if (halDevices != 0) 1419 { 1420 for (int i = 0; i < numDevices; i++) 1421 { 1422 char *devNode = libhal_device_get_property_string(halContext, 1423 halDevices[i], "block.device", &dbusError); 1424 if (devNode != 0) 1425 { 1426 if (validateDevice(devNode, true)) 1427 { 1428 char description[256]; 1429 char *vendor, *product; 1430 /* We have at least one hit, so operation successful :) */ 1431 halSuccess = true; 1432 vendor = libhal_device_get_property_string(halContext, 1433 halDevices[i], "info.vendor", &dbusError); 1434 product = libhal_device_get_property_string(halContext, 1435 halDevices[i], "info.product", &dbusError); 1436 if ((product != 0)) 1437 { 1438 if (vendor != 0 && vendor[0] != 0) 1439 { 1440 RTStrPrintf(description, sizeof(description), 1441 "%s %s (%s)", vendor, product, devNode); 1442 } 1443 else 1444 { 1445 RTStrPrintf(description, sizeof(description), 1446 "%s (%s)", product, devNode); 1447 } 1448 ComObjPtr <HostDVDDrive> hostDVDDriveObj; 1449 hostDVDDriveObj.createObject(); 1450 hostDVDDriveObj->init (Bstr (devNode), Bstr (description)); 1451 list.push_back (hostDVDDriveObj); 1452 } 1453 else 1454 { 1455 ComObjPtr <HostDVDDrive> hostDVDDriveObj; 1456 hostDVDDriveObj.createObject(); 1457 hostDVDDriveObj->init (Bstr (devNode)); 1458 list.push_back (hostDVDDriveObj); 1459 } 1460 } 1461 else 1462 { 1463 LogRel(("Host::COMGETTER(DVDDrives): failed to validate the block device %s as a DVD drive\n")); 1464 } 1465 libhal_free_string(devNode); 1466 } 1467 else 1468 { 1469 LogRel(("Host::COMGETTER(DVDDrives): failed to get property \"block.device\" for device %s. dbus error: %s (%s)\n", 1470 halDevices[i], dbusError.name, dbusError.message)); 1471 dbus_error_free(&dbusError); 1472 } 1473 } 1474 libhal_free_string_array(halDevices); 1475 } 1476 else 1477 { 1478 LogRel(("Host::COMGETTER(DVDDrives): failed to get devices with capability \"storage.cdrom\". dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1479 dbus_error_free(&dbusError); 1480 } 1481 if (!libhal_ctx_shutdown(halContext, &dbusError)) /* what now? */ 1482 { 1483 LogRel(("Host::COMGETTER(DVDDrives): failed to shutdown the libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1484 dbus_error_free(&dbusError); 1485 } 1486 } 1487 else 1488 { 1489 LogRel(("Host::COMGETTER(DVDDrives): failed to initialise libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1490 dbus_error_free(&dbusError); 1491 } 1492 libhal_ctx_free(halContext); 1493 } 1494 else 1495 { 1496 LogRel(("Host::COMGETTER(DVDDrives): failed to set libhal connection to dbus.\n")); 1497 } 1498 } 1499 else 1500 { 1501 LogRel(("Host::COMGETTER(DVDDrives): failed to get a libhal context - out of memory?\n")); 1502 } 1503 dbus_connection_unref(dbusConnection); 1504 } 1505 else 1506 { 1507 LogRel(("Host::COMGETTER(DVDDrives): failed to connect to dbus. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1508 dbus_error_free(&dbusError); 1509 } 1510 return halSuccess; 1511 } 1512 # endif /* VBOX_USE_HAL defined */ 1513 1382 1514 /** 1383 1515 * Helper function to parse the given mount file and add found entries -
trunk/src/VBox/Main/Makefile.kmk
r2754 r2917 153 153 $(PATH_LIB)/VBoxCOM$(VBOX_SUFF_LIB) 154 154 endif 155 ifdef VBOX_WITH_LIBHAL 156 VBoxSVC_CXXFLAGS += \ 157 $(LIB_HAL_CFLAGS) 158 VBoxSVC_LIBS += \ 159 $(LIB_HAL_LIBS) 160 VBoxSVC_DEFS += \ 161 VBOX_USE_LIBHAL 162 endif 163 155 164 VBoxSVC_SOURCES = \ 156 165 Logging.cpp \ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r2674 r2917 3499 3499 <desc>Returns the platform device identifier.</desc> 3500 3500 </attribute> 3501 <attribute name="description" type="wstring" readonly="yes"> 3502 <desc>Returns a human readable description for the drive.</desc> 3503 </attribute> 3501 3504 3502 3505 </interface> -
trunk/src/VBox/Main/include/HostDVDDriveImpl.h
r1 r2917 50 50 // public initializer/uninitializer for internal purposes only 51 51 HRESULT init (INPTR BSTR driveName); 52 HRESULT init (INPTR BSTR driveName, INPTR BSTR driveDescription); 52 53 53 54 // IHostDVDDrive properties 54 55 STDMETHOD(COMGETTER(Name)) (BSTR *driveName); 56 STDMETHOD(COMGETTER(Description)) (BSTR *driveDescription); 55 57 56 58 // public methods for internal purposes only … … 64 66 65 67 Bstr mDriveName; 68 Bstr mDriveDescription; 66 69 }; 67 70 -
trunk/src/VBox/Main/include/HostImpl.h
r2333 r2917 131 131 132 132 #ifdef __LINUX__ 133 # ifdef VBOX_USE_LIBHAL 134 bool getDVDInfoFromHal(std::list <ComObjPtr <HostDVDDrive> > &list); 135 # endif 133 136 void parseMountTable(char *mountTable, std::list <ComObjPtr <HostDVDDrive> > &list); 134 137 bool validateDevice(const char *deviceNode, bool isCDROM);
Note:
See TracChangeset
for help on using the changeset viewer.