VirtualBox

Ignore:
Timestamp:
Jan 22, 2009 3:39:48 PM (16 years ago)
Author:
vboxsync
Message:

Main/Linux: fixes and clean ups in the DBus code

File:
1 edited

Legend:

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

    r16137 r16178  
    7979extern void VBoxHalShutdown (DBusConnection *pConnection);
    8080extern void VBoxHalShutdownPrivate (DBusConnection *pConnection);
     81extern void VBoxDBusConnectionUnref(DBusConnection *pConnection);
     82extern void VBoxDBusConnectionCloseAndUnref(DBusConnection *pConnection);
     83extern void VBoxDBusMessageUnref(DBusMessage *pMessage);
    8184
    8285static int halInit(RTMemAutoPtr <DBusConnection, VBoxHalShutdown> *pConnection);
     
    109112#if defined(RT_OS_LINUX)
    110113#ifdef VBOX_WITH_DBUS
    111         if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing()))
     114        if (RT_SUCCESS (rc) && RT_SUCCESS(VBoxLoadDBusLib()) && (!success || testing()))
    112115            rc = getDriveInfoFromHal(&mDVDList, true /* isDVD */, &success);
    113116#endif /* VBOX_WITH_DBUS defined */
     
    154157#if defined(RT_OS_LINUX)
    155158#ifdef VBOX_WITH_DBUS
    156         if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing()))
     159        if (   RT_SUCCESS (rc)
     160            && RT_SUCCESS(VBoxLoadDBusLib())
     161            && (!success || testing()))
    157162            rc = getDriveInfoFromHal(&mFloppyList, false /* isDVD */, &success);
    158163#endif /* VBOX_WITH_DBUS defined */
     
    197202#if defined(RT_OS_LINUX)
    198203#ifdef VBOX_WITH_DBUS
    199         if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing()))
     204        if (   RT_SUCCESS (rc)
     205            && RT_SUCCESS(VBoxLoadDBusLib())
     206            && (!success || testing()))
    200207            rc = getUSBDeviceInfoFromHal(&mDeviceList, &halSuccess);
    201208        /* Try the old API if the new one *succeeded* as only one of them will
     
    226233    /** A flag to say that we wish to interrupt the current wait. */
    227234    bool mInterrupt;
     235    /** Constructor */
     236    Context() : mTriggered(false), mInterrupt(false) {}
    228237#endif  /* defined RT_OS_LINUX && defined VBOX_WITH_DBUS */
    229238};
     
    238247    int rc = VINF_SUCCESS;
    239248
    240     if (VBoxDBusCheckPresence())
    241     {
    242         mContext = new Context;
     249    mContext = new Context;
     250    if (RT_SUCCESS(VBoxLoadDBusLib()))
     251    {
    243252        for (unsigned i = 0; RT_SUCCESS(rc) && i < 5 && !mContext->mConnection; ++i)
    244253        {
     
    617626    autoDBusError dbusError;
    618627
    619     RTMemAutoPtr <DBusConnection, VBoxDBusConnectionUnref> dbusConnection;
     628    RTMemAutoPtr <DBusConnection, VBoxDBusConnectionCloseAndUnref> dbusConnection;
    620629    dbusConnection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &dbusError.get());
    621630    if (!dbusConnection)
     
    650659 * @param   pConnection  the connection handle
    651660 */
    652 /* static */
     661/* extern */
    653662void VBoxHalShutdown (DBusConnection *pConnection)
    654663{
     
    672681 * @param   pConnection  the connection handle
    673682 */
    674 /* static */
     683/* extern */
    675684void VBoxHalShutdownPrivate (DBusConnection *pConnection)
    676685{
     
    689698    LogFlowFunc(("returning\n"));
    690699    dbusError.FlowLog();
     700}
     701
     702/** Wrapper around dbus_connection_unref.  We need this to use it as a real
     703 * function in auto pointers, as a function pointer won't wash here. */
     704/* extern */
     705void VBoxDBusConnectionUnref(DBusConnection *pConnection)
     706{
     707    dbus_connection_unref(pConnection);
     708}
     709
     710/**
     711 * This function closes and unrefs a private connection to dbus.  It should
     712 * only be called once no-one else is referencing the connection.
     713 */
     714/* extern */
     715void VBoxDBusConnectionCloseAndUnref(DBusConnection *pConnection)
     716{
     717    dbus_connection_close(pConnection);
     718    dbus_connection_unref(pConnection);
     719}
     720
     721/** Wrapper around dbus_message_unref.  We need this to use it as a real
     722 * function in auto pointers, as a function pointer won't wash here. */
     723/* extern */
     724void VBoxDBusMessageUnref(DBusMessage *pMessage)
     725{
     726    dbus_message_unref(pMessage);
    691727}
    692728
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