- Timestamp:
- Jul 31, 2007 8:36:16 AM (17 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostImpl.cpp
r3758 r3934 32 32 #include <linux/cdrom.h> 33 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 34 // # include <libhal.h> 35 // /* These are defined by libhal.h and by VBox header files. */ 36 // # undef TRUE 37 // # undef FALSE 38 #include "vbox-libhal.h" 38 39 #endif 39 40 #include <errno.h> … … 1530 1531 bool halSuccess = false; 1531 1532 DBusError dbusError; 1532 dbus_error_init (&dbusError); 1533 DBusConnection *dbusConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbusError); 1533 if (!LibHalCheckPresence()) 1534 return false; 1535 DBusErrorInit (&dbusError); 1536 DBusConnection *dbusConnection = DBusBusGet(DBUS_BUS_SYSTEM, &dbusError); 1534 1537 if (dbusConnection != 0) 1535 1538 { 1536 LibHalContext *halContext = libhal_ctx_new();1539 LibHalContext *halContext = LibHalCtxNew(); 1537 1540 if (halContext != 0) 1538 1541 { 1539 if ( libhal_ctx_set_dbus_connection (halContext, dbusConnection))1542 if (LibHalCtxSetDBusConnection (halContext, dbusConnection)) 1540 1543 { 1541 if ( libhal_ctx_init(halContext, &dbusError))1544 if (LibHalCtxInit(halContext, &dbusError)) 1542 1545 { 1543 1546 int numDevices; 1544 char **halDevices = libhal_find_device_by_capability(halContext,1547 char **halDevices = LibHalFindDeviceByCapability(halContext, 1545 1548 "storage.cdrom", &numDevices, &dbusError); 1546 1549 if (halDevices != 0) … … 1551 1554 for (int i = 0; i < numDevices; i++) 1552 1555 { 1553 char *devNode = libhal_device_get_property_string(halContext,1556 char *devNode = LibHalDeviceGetPropertyString(halContext, 1554 1557 halDevices[i], "block.device", &dbusError); 1555 1558 if (devNode != 0) … … 1561 1564 /* We do not check the error here, as this field may 1562 1565 not even exist. */ 1563 vendor = libhal_device_get_property_string(halContext,1566 vendor = LibHalDeviceGetPropertyString(halContext, 1564 1567 halDevices[i], "info.vendor", 0); 1565 product = libhal_device_get_property_string(halContext,1568 product = LibHalDeviceGetPropertyString(halContext, 1566 1569 halDevices[i], "info.product", &dbusError); 1567 1570 if ((product != 0 && product[0] != 0)) … … 1589 1592 LogRel(("Host::COMGETTER(DVDDrives): failed to get property \"info.product\" for device %s. dbus error: %s (%s)\n", 1590 1593 halDevices[i], dbusError.name, dbusError.message)); 1591 dbus_error_free(&dbusError);1594 DBusErrorFree(&dbusError); 1592 1595 } 1593 1596 ComObjPtr <HostDVDDrive> hostDVDDriveObj; … … 1599 1602 if (vendor != 0) 1600 1603 { 1601 libhal_free_string(vendor);1604 LibHalFreeString(vendor); 1602 1605 } 1603 1606 if (product != 0) 1604 1607 { 1605 libhal_free_string(product);1608 LibHalFreeString(product); 1606 1609 } 1607 1610 } … … 1610 1613 LogRel(("Host::COMGETTER(DVDDrives): failed to validate the block device %s as a DVD drive\n")); 1611 1614 } 1612 libhal_free_string(devNode);1615 LibHalFreeString(devNode); 1613 1616 } 1614 1617 else … … 1616 1619 LogRel(("Host::COMGETTER(DVDDrives): failed to get property \"block.device\" for device %s. dbus error: %s (%s)\n", 1617 1620 halDevices[i], dbusError.name, dbusError.message)); 1618 dbus_error_free(&dbusError);1621 DBusErrorFree(&dbusError); 1619 1622 } 1620 1623 } 1621 libhal_free_string_array(halDevices);1624 LibHalFreeStringArray(halDevices); 1622 1625 } 1623 1626 else 1624 1627 { 1625 1628 LogRel(("Host::COMGETTER(DVDDrives): failed to get devices with capability \"storage.cdrom\". dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1626 dbus_error_free(&dbusError);1629 DBusErrorFree(&dbusError); 1627 1630 } 1628 if (! libhal_ctx_shutdown(halContext, &dbusError)) /* what now? */1631 if (!LibHalCtxShutdown(halContext, &dbusError)) /* what now? */ 1629 1632 { 1630 1633 LogRel(("Host::COMGETTER(DVDDrives): failed to shutdown the libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1631 dbus_error_free(&dbusError);1634 DBusErrorFree(&dbusError); 1632 1635 } 1633 1636 } … … 1635 1638 { 1636 1639 LogRel(("Host::COMGETTER(DVDDrives): failed to initialise libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1637 dbus_error_free(&dbusError);1640 DBusErrorFree(&dbusError); 1638 1641 } 1639 libhal_ctx_free(halContext);1642 LibHalCtxFree(halContext); 1640 1643 } 1641 1644 else … … 1648 1651 LogRel(("Host::COMGETTER(DVDDrives): failed to get a libhal context - out of memory?\n")); 1649 1652 } 1650 dbus_connection_unref(dbusConnection);1653 DBusConnectionUnref(dbusConnection); 1651 1654 } 1652 1655 else 1653 1656 { 1654 1657 LogRel(("Host::COMGETTER(DVDDrives): failed to connect to dbus. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1655 dbus_error_free(&dbusError);1658 DBusErrorFree(&dbusError); 1656 1659 } 1657 1660 return halSuccess; … … 1670 1673 bool halSuccess = false; 1671 1674 DBusError dbusError; 1672 dbus_error_init (&dbusError); 1673 DBusConnection *dbusConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbusError); 1675 if (!LibHalCheckPresence()) 1676 return false; 1677 DBusErrorInit (&dbusError); 1678 DBusConnection *dbusConnection = DBusBusGet(DBUS_BUS_SYSTEM, &dbusError); 1674 1679 if (dbusConnection != 0) 1675 1680 { 1676 LibHalContext *halContext = libhal_ctx_new();1681 LibHalContext *halContext = LibHalCtxNew(); 1677 1682 if (halContext != 0) 1678 1683 { 1679 if ( libhal_ctx_set_dbus_connection (halContext, dbusConnection))1684 if (LibHalCtxSetDBusConnection (halContext, dbusConnection)) 1680 1685 { 1681 if ( libhal_ctx_init(halContext, &dbusError))1686 if (LibHalCtxInit(halContext, &dbusError)) 1682 1687 { 1683 1688 int numDevices; 1684 char **halDevices = libhal_find_device_by_capability(halContext,1689 char **halDevices = LibHalFindDeviceByCapability(halContext, 1685 1690 "storage", &numDevices, &dbusError); 1686 1691 if (halDevices != 0) … … 1691 1696 for (int i = 0; i < numDevices; i++) 1692 1697 { 1693 char *driveType = libhal_device_get_property_string(halContext,1698 char *driveType = LibHalDeviceGetPropertyString(halContext, 1694 1699 halDevices[i], "storage.drive_type", 0); 1695 1700 if (driveType != 0) … … 1697 1702 if (strcmp(driveType, "floppy") != 0) 1698 1703 { 1699 libhal_free_string(driveType);1704 LibHalFreeString(driveType); 1700 1705 continue; 1701 1706 } 1702 libhal_free_string(driveType);1707 LibHalFreeString(driveType); 1703 1708 } 1704 1709 else … … 1708 1713 continue; 1709 1714 } 1710 char *devNode = libhal_device_get_property_string(halContext,1715 char *devNode = LibHalDeviceGetPropertyString(halContext, 1711 1716 halDevices[i], "block.device", &dbusError); 1712 1717 if (devNode != 0) … … 1718 1723 /* We do not check the error here, as this field may 1719 1724 not even exist. */ 1720 vendor = libhal_device_get_property_string(halContext,1725 vendor = LibHalDeviceGetPropertyString(halContext, 1721 1726 halDevices[i], "info.vendor", 0); 1722 product = libhal_device_get_property_string(halContext,1727 product = LibHalDeviceGetPropertyString(halContext, 1723 1728 halDevices[i], "info.product", &dbusError); 1724 1729 if ((product != 0) && (product[0] != 0)) … … 1746 1751 LogRel(("Host::COMGETTER(FloppyDrives): failed to get property \"info.product\" for device %s. dbus error: %s (%s)\n", 1747 1752 halDevices[i], dbusError.name, dbusError.message)); 1748 dbus_error_free(&dbusError);1753 DBusErrorFree(&dbusError); 1749 1754 } 1750 1755 ComObjPtr <HostFloppyDrive> hostFloppyDrive; … … 1756 1761 if (vendor != 0) 1757 1762 { 1758 libhal_free_string(vendor);1763 LibHalFreeString(vendor); 1759 1764 } 1760 1765 if (product != 0) 1761 1766 { 1762 libhal_free_string(product);1767 LibHalFreeString(product); 1763 1768 } 1764 1769 } … … 1767 1772 LogRel(("Host::COMGETTER(FloppyDrives): failed to validate the block device %s as a floppy drive\n")); 1768 1773 } 1769 libhal_free_string(devNode);1774 LibHalFreeString(devNode); 1770 1775 } 1771 1776 else … … 1773 1778 LogRel(("Host::COMGETTER(FloppyDrives): failed to get property \"block.device\" for device %s. dbus error: %s (%s)\n", 1774 1779 halDevices[i], dbusError.name, dbusError.message)); 1775 dbus_error_free(&dbusError);1780 DBusErrorFree(&dbusError); 1776 1781 } 1777 1782 } 1778 libhal_free_string_array(halDevices);1783 LibHalFreeStringArray(halDevices); 1779 1784 } 1780 1785 else 1781 1786 { 1782 1787 LogRel(("Host::COMGETTER(FloppyDrives): failed to get devices with capability \"storage.cdrom\". dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1783 dbus_error_free(&dbusError);1788 DBusErrorFree(&dbusError); 1784 1789 } 1785 if (! libhal_ctx_shutdown(halContext, &dbusError)) /* what now? */1790 if (!LibHalCtxShutdown(halContext, &dbusError)) /* what now? */ 1786 1791 { 1787 1792 LogRel(("Host::COMGETTER(FloppyDrives): failed to shutdown the libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1788 dbus_error_free(&dbusError);1793 DBusErrorFree(&dbusError); 1789 1794 } 1790 1795 } … … 1792 1797 { 1793 1798 LogRel(("Host::COMGETTER(FloppyDrives): failed to initialise libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1794 dbus_error_free(&dbusError);1799 DBusErrorFree(&dbusError); 1795 1800 } 1796 libhal_ctx_free(halContext);1801 LibHalCtxFree(halContext); 1797 1802 } 1798 1803 else … … 1805 1810 LogRel(("Host::COMGETTER(FloppyDrives): failed to get a libhal context - out of memory?\n")); 1806 1811 } 1807 dbus_connection_unref(dbusConnection);1812 DBusConnectionUnref(dbusConnection); 1808 1813 } 1809 1814 else 1810 1815 { 1811 1816 LogRel(("Host::COMGETTER(FloppyDrives): failed to connect to dbus. dbus error: %s (%s)\n", dbusError.name, dbusError.message)); 1812 dbus_error_free(&dbusError);1817 DBusErrorFree(&dbusError); 1813 1818 } 1814 1819 return halSuccess; -
trunk/src/VBox/Main/Makefile.kmk
r3822 r3934 129 129 VBoxSVC_DEFS.win.x86 += _WIN32_WINNT=0x0500 130 130 VBoxSVC_DEFS.win.amd64 += _WIN32_WINNT=0x0510 131 VBoxSVC_DEFS.linux += VBOX_USE_LIBHAL 132 131 133 VBoxSVC_INCS = \ 132 134 include \ … … 146 148 $(LIB_VMM) \ 147 149 $(LIB_REM) 148 149 ifdef VBOX_WITH_LIBHAL150 VBoxSVC_CXXFLAGS += \151 $(LIB_HAL_CFLAGS)152 VBoxSVC_LIBPATH += \153 $(LIB_HAL_LIBPATH)154 VBoxSVC_LIBS += \155 $(LIB_HAL_LIBS)156 VBoxSVC_DEFS += \157 VBOX_USE_LIBHAL158 endif159 150 160 151 VBoxSVC_SOURCES = \ … … 203 194 win32/VBoxSVC.rc 204 195 196 VBoxSVC_SOURCES.linux = \ 197 linux/vbox-libhal.cpp 198 205 199 ifdef VBOX_WITH_XPCOM 206 200 VBoxSVC_SOURCES += \
Note:
See TracChangeset
for help on using the changeset viewer.