static DWORD WINAPI dbus_thread( void *arg ) { static const char udisks_match[] = "type='signal'," "interface='org.freedesktop.UDisks'," "sender='org.freedesktop.UDisks'"; DBusError error; p_dbus_error_init( &error ); if (!(connection = p_dbus_bus_get( DBUS_BUS_SYSTEM, &error ))) { WARN( "failed to get system dbus connection: %s\n", error.message ); p_dbus_error_free( &error ); return 1; } if (p_dbus_connection_add_filter( connection, udisks_filter, NULL, NULL )) p_dbus_bus_add_match( connection, udisks_match, &error ); if (!udisks_enumerate_devices()) { p_dbus_bus_remove_match( connection, udisks_match, &error ); p_dbus_connection_remove_filter( connection, udisks_filter, NULL ); #ifdef SONAME_LIBHAL if (!hal_enumerate_devices()) { p_dbus_connection_close( connection ); p_dbus_error_free( &error ); return 1; } #endif } __TRY { while (p_dbus_connection_read_write_dispatch( connection, -1 )) /* nothing */ ; } __EXCEPT( assert_fault ) { WARN( "dbus assertion failure, disabling support\n" ); return 1; } __ENDTRY; p_dbus_connection_close( connection ); return 0; }
static DWORD WINAPI dbus_thread( void *arg ) { static const char udisks_match[] = "type='signal'," "interface='org.freedesktop.UDisks'," "sender='org.freedesktop.UDisks'"; static const char udisks2_match_interfaces[] = "type='signal'," "interface='org.freedesktop.DBus.ObjectManager'," "path='/org/freedesktop/UDisks2'"; static const char udisks2_match_properties[] = "type='signal'," "interface='org.freedesktop.DBus.Properties'"; DBusError error; p_dbus_error_init( &error ); if (!(connection = p_dbus_bus_get( DBUS_BUS_SYSTEM, &error ))) { WARN( "failed to get system dbus connection: %s\n", error.message ); p_dbus_error_free( &error ); return 1; } /* first try UDisks2 */ p_dbus_connection_add_filter( connection, udisks_filter, NULL, NULL ); p_dbus_bus_add_match( connection, udisks2_match_interfaces, &error ); p_dbus_bus_add_match( connection, udisks2_match_properties, &error ); if (udisks2_add_devices( NULL )) goto found; p_dbus_bus_remove_match( connection, udisks2_match_interfaces, &error ); p_dbus_bus_remove_match( connection, udisks2_match_properties, &error ); /* then try UDisks */ p_dbus_bus_add_match( connection, udisks_match, &error ); if (udisks_enumerate_devices()) goto found; p_dbus_bus_remove_match( connection, udisks_match, &error ); p_dbus_connection_remove_filter( connection, udisks_filter, NULL ); /* then finally HAL */ #ifdef SONAME_LIBHAL if (!hal_enumerate_devices()) { p_dbus_error_free( &error ); return 1; } #endif found: __TRY { while (p_dbus_connection_read_write_dispatch( connection, -1 )) /* nothing */ ; } __EXCEPT( assert_fault ) { WARN( "dbus assertion failure, disabling support\n" ); return 1; } __ENDTRY; return 0; }