From: Vibhav Pant vibhavp@gmail.com
--- dlls/winebth.sys/dbus.c | 19 +++++++++++++++++++ dlls/winebth.sys/winebth.c | 27 +++++++++++++++++++++++++++ dlls/winebth.sys/winebth_priv.h | 7 +++++++ 3 files changed, 53 insertions(+)
diff --git a/dlls/winebth.sys/dbus.c b/dlls/winebth.sys/dbus.c index e7c2b71f135..13e4bbe29e5 100644 --- a/dlls/winebth.sys/dbus.c +++ b/dlls/winebth.sys/dbus.c @@ -909,6 +909,22 @@ static DBusHandlerResult bluez_filter( DBusConnection *conn, DBusMessage *msg, v event_list, BLUETOOTH_WATCHER_EVENT_TYPE_RADIO_REMOVED, event )) unix_name_free( radio_name ); } + else if (!strcmp( interfaces[i], BLUEZ_INTERFACE_DEVICE )) + { + struct unix_name *device; + union winebluetooth_watcher_event_data event; + + device = unix_name_get_or_create( object_path ); + if (!device) + { + ERR( "Failed to allocate memory for adapter path %s\n", object_path ); + continue; + } + event.device_removed.device.handle = (UINT_PTR)device; + if (!bluez_event_list_queue_new_event( event_list, BLUETOOTH_WATCHER_EVENT_TYPE_DEVICE_REMOVED, + event )) + unix_name_free( device ); + } } p_dbus_free_string_array( interfaces ); } @@ -1059,6 +1075,9 @@ static void bluez_watcher_free( struct bluez_watcher_ctx *watcher ) unix_name_free( (struct unix_name *)event1->event.device_added.radio.handle ); unix_name_free( (struct unix_name *)event1->event.device_added.device.handle ); break; + case BLUETOOTH_WATCHER_EVENT_TYPE_DEVICE_REMOVED: + unix_name_free( (struct unix_name *)event1->event.device_removed.device.handle ); + break; } free( event1 ); } diff --git a/dlls/winebth.sys/winebth.c b/dlls/winebth.sys/winebth.c index 6a66bedd8a4..7004955df10 100644 --- a/dlls/winebth.sys/winebth.c +++ b/dlls/winebth.sys/winebth.c @@ -452,6 +452,30 @@ static void bluetooth_radio_add_remote_device( struct winebluetooth_watcher_even winebluetooth_radio_free( event.radio ); }
+static void bluetooth_radio_remove_remote_device( struct winebluetooth_watcher_event_device_removed event ) +{ + struct bluetooth_radio *radio; + + EnterCriticalSection( &device_list_cs ); + LIST_FOR_EACH_ENTRY( radio, &device_list, struct bluetooth_radio, entry ) + { + struct bluetooth_remote_device *device, *next; + + EnterCriticalSection( &radio->remote_devices_cs ); + LIST_FOR_EACH_ENTRY_SAFE( device, next, &radio->remote_devices, struct bluetooth_remote_device, entry ) + { + list_remove( &device->entry ); + winebluetooth_device_free( device->device ); + DeleteCriticalSection( &device->props_cs ); + free( device ); + break; + } + LeaveCriticalSection( &radio->remote_devices_cs ); + } + LeaveCriticalSection( &device_list_cs ); + winebluetooth_device_free( event.device ); +} + static DWORD CALLBACK bluetooth_event_loop_thread_proc( void *arg ) { NTSTATUS status; @@ -481,6 +505,9 @@ static DWORD CALLBACK bluetooth_event_loop_thread_proc( void *arg ) case BLUETOOTH_WATCHER_EVENT_TYPE_DEVICE_ADDED: bluetooth_radio_add_remote_device( event->event_data.device_added ); break; + case BLUETOOTH_WATCHER_EVENT_TYPE_DEVICE_REMOVED: + bluetooth_radio_remove_remote_device( event->event_data.device_removed ); + break; default: FIXME( "Unknown bluetooth watcher event code: %#x\n", event->event_type ); } diff --git a/dlls/winebth.sys/winebth_priv.h b/dlls/winebth.sys/winebth_priv.h index 50c359c2494..fba1e0bfccd 100644 --- a/dlls/winebth.sys/winebth_priv.h +++ b/dlls/winebth.sys/winebth_priv.h @@ -200,6 +200,7 @@ enum winebluetooth_watcher_event_type BLUETOOTH_WATCHER_EVENT_TYPE_RADIO_REMOVED, BLUETOOTH_WATCHER_EVENT_TYPE_RADIO_PROPERTIES_CHANGED, BLUETOOTH_WATCHER_EVENT_TYPE_DEVICE_ADDED, + BLUETOOTH_WATCHER_EVENT_TYPE_DEVICE_REMOVED };
struct winebluetooth_watcher_event_radio_added @@ -226,12 +227,18 @@ struct winebluetooth_watcher_event_device_added winebluetooth_radio_t radio; };
+struct winebluetooth_watcher_event_device_removed +{ + winebluetooth_device_t device; +}; + union winebluetooth_watcher_event_data { struct winebluetooth_watcher_event_radio_added radio_added; winebluetooth_radio_t radio_removed; struct winebluetooth_watcher_event_radio_props_changed radio_props_changed; struct winebluetooth_watcher_event_device_added device_added; + struct winebluetooth_watcher_event_device_removed device_removed; };
struct winebluetooth_watcher_event