Changeset 15057 in vbox for trunk/src/VBox/Main/linux/HostHardwareLinux.cpp
- Timestamp:
- Dec 5, 2008 9:47:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/linux/HostHardwareLinux.cpp
r14992 r15057 49 49 # include <linux/cdrom.h> 50 50 # 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> 55 52 # endif 56 53 # include <errno.h> … … 77 74 #ifdef VBOX_WITH_DBUS 78 75 static int halInit(DBusConnection **ppConnection); 76 /* This must be extern to be used in the RTMemAutoPtr template */ 77 extern void halShutdown (DBusConnection *pConnection); 79 78 static int halFindDeviceStringMatch (DBusConnection *pConnection, 80 79 const char *pszKey, const char *pszValue, … … 103 102 #if defined(RT_OS_LINUX) 104 103 #ifdef VBOX_WITH_DBUS 105 if (RT_SUCCESS (rc) && (!success || testing()))104 if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing())) 106 105 rc = getDriveInfoFromHal(&mDVDList, true /* isDVD */, &success); 107 106 #endif /* VBOX_WITH_DBUS defined */ … … 153 152 #if defined(RT_OS_LINUX) 154 153 #ifdef VBOX_WITH_DBUS 155 if (RT_SUCCESS (rc) && (!success || testing()))154 if (RT_SUCCESS (rc) && VBoxDBusCheckPresence() && (!success || testing())) 156 155 rc = getDriveInfoFromHal(&mFloppyList, false /* isDVD */, &success); 157 156 #endif /* VBOX_WITH_DBUS defined */ … … 403 402 ~autoDBusError () 404 403 { 405 if ( dbus_error_is_set (&mError))404 if (IsSet()) 406 405 dbus_error_free (&mError); 407 406 } 408 407 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 } 410 413 bool HasName (const char *pszName) 411 414 { 412 return dbus_error_has_name (&mError, pszName); 415 Assert ((mError.name == NULL) == (mError.message == NULL)); 416 return (RTStrCmp (mError.name, pszName) == 0); 413 417 } 414 418 void FlowLog () … … 449 453 "interface='org.freedesktop.Hal.Manager'," 450 454 "sender='org.freedesktop.Hal'," 451 "path='/org/freedesktop/Hal/Manager'", &dbusError.get()); 455 "path='/org/freedesktop/Hal/Manager'", 456 &dbusError.get()); 452 457 halSuccess = !dbusError.IsSet(); 453 458 } … … 458 463 dbusError.FlowLog(); 459 464 return rc; 465 } 466 467 /** 468 * Helper function for shutting down a connection to hal 469 * @param pConnection the connection handle 470 */ 471 /* static */ 472 void 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(); 460 487 } 461 488 … … 624 651 625 652 rc = halInit (&pConnection); 626 RTMemAutoPtr <DBusConnection, dbus_connection_unref> dbusConnection;653 RTMemAutoPtr <DBusConnection, halShutdown> dbusConnection; 627 654 dbusConnection = pConnection; 628 655 if (!dbusConnection)
Note:
See TracChangeset
for help on using the changeset viewer.