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 b3bd366370f..4ce43116944 100644 --- a/dlls/winebth.sys/dbus.c +++ b/dlls/winebth.sys/dbus.c @@ -899,6 +899,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 ); } @@ -1049,6 +1065,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 5c0376c4324..0ff8cfdce8e 100644 --- a/dlls/winebth.sys/winebth.c +++ b/dlls/winebth.sys/winebth.c @@ -446,6 +446,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; @@ -475,6 +499,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 0646a18409f..b5ee1bc0908 100644 --- a/dlls/winebth.sys/winebth_priv.h +++ b/dlls/winebth.sys/winebth_priv.h @@ -197,6 +197,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 @@ -223,12 +224,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