VirtualBox

Ignore:
Timestamp:
Dec 5, 2008 9:47:30 PM (16 years ago)
Author:
vboxsync
Message:

Main: load libdbus-1 dynamically on Linux hosts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/linux/HostHardwareLinux.cpp

    r14992 r15057  
    4949# include <linux/cdrom.h>
    5050# ifdef VBOX_WITH_DBUS
    51 #  include <dbus/dbus.h>
    52 /* These are defined by the dbus headers and by VBox header files. */
    53 #  undef TRUE
    54 #  undef FALSE
     51#  include <vbox-dbus.h>
    5552# endif
    5653# include <errno.h>
     
    7774#ifdef VBOX_WITH_DBUS
    7875static int halInit(DBusConnection **ppConnection);
     76/* This must be extern to be used in the RTMemAutoPtr template */
     77extern void halShutdown (DBusConnection *pConnection);
    7978static int halFindDeviceStringMatch (DBusConnection *pConnection,
    8079                                     const char *pszKey, const char *pszValue,
     
    103102#if defined(RT_OS_LINUX)
    104103#ifdef VBOX_WITH_DBUS
    105         if (RT_SUCCESS (rc) && (!success || testing()))
     104        if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing()))
    106105            rc = getDriveInfoFromHal(&mDVDList, true /* isDVD */, &success);
    107106#endif /* VBOX_WITH_DBUS defined */
     
    153152#if defined(RT_OS_LINUX)
    154153#ifdef VBOX_WITH_DBUS
    155         if (RT_SUCCESS (rc) && (!success || testing()))
     154        if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing()))
    156155            rc = getDriveInfoFromHal(&mFloppyList, false /* isDVD */, &success);
    157156#endif /* VBOX_WITH_DBUS defined */
     
    403402    ~autoDBusError ()
    404403    {
    405         if (dbus_error_is_set (&mError))
     404        if (IsSet())
    406405            dbus_error_free (&mError);
    407406    }
    408407    DBusError &get () { return mError; }
    409     bool IsSet () { return dbus_error_is_set (&mError); }
     408    bool IsSet ()
     409    {
     410        Assert ((mError.name == NULL) == (mError.message == NULL));
     411        return (mError.name != NULL);
     412    }
    410413    bool HasName (const char *pszName)
    411414    {
    412         return dbus_error_has_name (&mError, pszName);
     415        Assert ((mError.name == NULL) == (mError.message == NULL));
     416        return (RTStrCmp (mError.name, pszName) == 0);
    413417    }
    414418    void FlowLog ()
     
    449453                            "interface='org.freedesktop.Hal.Manager',"
    450454                            "sender='org.freedesktop.Hal',"
    451                             "path='/org/freedesktop/Hal/Manager'", &dbusError.get());
     455                            "path='/org/freedesktop/Hal/Manager'",
     456                            &dbusError.get());
    452457        halSuccess = !dbusError.IsSet();
    453458    }
     
    458463    dbusError.FlowLog();
    459464    return rc;
     465}
     466
     467/**
     468 * Helper function for shutting down a connection to hal
     469 * @param   pConnection  the connection handle
     470 */
     471/* static */
     472void halShutdown (DBusConnection *pConnection)
     473{
     474    AssertReturnVoid(VALID_PTR (pConnection));
     475    LogFlowFunc (("pConnection=%p\n", pConnection));
     476    autoDBusError dbusError;
     477
     478    dbus_bus_remove_match (pConnection,
     479                           "type='signal',"
     480                           "interface='org.freedesktop.Hal.Manager',"
     481                           "sender='org.freedesktop.Hal',"
     482                           "path='/org/freedesktop/Hal/Manager'",
     483                           &dbusError.get());
     484    dbus_connection_unref (pConnection);
     485    LogFlowFunc(("returning\n"));
     486    dbusError.FlowLog();
    460487}
    461488
     
    624651
    625652    rc = halInit (&pConnection);
    626     RTMemAutoPtr <DBusConnection, dbus_connection_unref> dbusConnection;
     653    RTMemAutoPtr <DBusConnection, halShutdown> dbusConnection;
    627654    dbusConnection = pConnection;
    628655    if (!dbusConnection)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette