mountmgr.sys: start detecting USB devices
Damjan Jovanovic
damjan.jov at gmail.com
Wed Mar 2 11:52:26 CST 2011
Changelog:
* mountmgr.sys: start detecting USB devices
Damjan Jovanovic
-------------- next part --------------
diff --git a/dlls/mountmgr.sys/hal.c b/dlls/mountmgr.sys/hal.c
index 82a70e9..b936242 100644
--- a/dlls/mountmgr.sys/hal.c
+++ b/dlls/mountmgr.sys/hal.c
@@ -60,6 +60,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mountmgr);
DO_FUNC(libhal_ctx_set_device_removed); \
DO_FUNC(libhal_ctx_shutdown); \
DO_FUNC(libhal_device_get_property_bool); \
+ DO_FUNC(libhal_device_get_property_int); \
DO_FUNC(libhal_device_get_property_string); \
DO_FUNC(libhal_device_add_property_watch); \
DO_FUNC(libhal_device_remove_property_watch); \
@@ -133,6 +134,47 @@ static GUID *parse_uuid( GUID *guid, const char *str )
return NULL;
}
+static void process_usb_device( LibHalContext *ctx, const char *udi )
+{
+ DBusError error;
+ char *subsystem = NULL;
+ BOOL has_serial;
+ char *serial = NULL;
+ unsigned short vendor_id;
+ unsigned short product_id;
+ int bus_number;
+
+ p_dbus_error_init( &error );
+
+ if (!(subsystem = p_libhal_device_get_property_string( ctx, udi, "info.subsystem", &error )))
+ goto done;
+ if (strcmp( subsystem, "usb_device" ))
+ goto done;
+
+ serial = p_libhal_device_get_property_string( ctx, udi, "usb_device.serial", NULL );
+ has_serial = (serial != NULL);
+
+ vendor_id = p_libhal_device_get_property_int( ctx, udi, "usb_device.vendor_id", &error );
+ if (p_dbus_error_is_set( &error ))
+ goto done;
+
+ product_id = p_libhal_device_get_property_int( ctx, udi, "usb_device.product_id", &error );
+ if (p_dbus_error_is_set( &error ))
+ goto done;
+
+ bus_number = p_libhal_device_get_property_int( ctx, udi, "usb_device.bus_number", &error );
+ if (p_dbus_error_is_set( &error ))
+ goto done;
+
+ WINE_TRACE("Found USB device with VendorId=0x%04X ProductId=0x%04X Serial=%s Bus=%d\n",
+ vendor_id, product_id, has_serial ? wine_dbgstr_a(serial) : "", bus_number);
+
+done:
+ if (serial) p_libhal_free_string( serial );
+ if (subsystem) p_libhal_free_string( subsystem );
+ p_dbus_error_free( &error );
+}
+
/* HAL callback for new device */
static void new_device( LibHalContext *ctx, const char *udi )
{
@@ -148,7 +190,10 @@ static void new_device( LibHalContext *ctx, const char *udi )
p_dbus_error_init( &error );
if (!(device = p_libhal_device_get_property_string( ctx, udi, "block.device", &error )))
+ {
+ process_usb_device( ctx, udi );
goto done;
+ }
if (!(mount_point = p_libhal_device_get_property_string( ctx, udi, "volume.mount_point", &error )))
goto done;
More information about the wine-patches
mailing list