From: Vibhav Pant vibhavp@gmail.com
--- dlls/winebth.sys/dbus.c | 39 ++++++++++++++++++++++++++++++++ dlls/winebth.sys/unixlib.c | 10 ++++++++ dlls/winebth.sys/unixlib.h | 7 ++++++ dlls/winebth.sys/unixlib_priv.h | 1 + dlls/winebth.sys/winebluetooth.c | 10 ++++++++ dlls/winebth.sys/winebth.c | 35 ++++++++++++++++++++++++++++ dlls/winebth.sys/winebth_priv.h | 1 + include/wine/winebth.h | 1 + 8 files changed, 104 insertions(+)
diff --git a/dlls/winebth.sys/dbus.c b/dlls/winebth.sys/dbus.c index f0b97401a94..2823e95d1d7 100644 --- a/dlls/winebth.sys/dbus.c +++ b/dlls/winebth.sys/dbus.c @@ -491,6 +491,45 @@ NTSTATUS bluez_adapter_stop_discovery( void *connection, const char *adapter_pat return STATUS_SUCCESS; }
+NTSTATUS bluez_adapter_remove_device( void *connection, const char *adapter_path, const char *device_path ) +{ + DBusMessage *request, *reply = NULL; + DBusError error; + NTSTATUS status; + + TRACE( "(%p, %s, %s)\n", connection, debugstr_a( adapter_path ), debugstr_a( device_path ) ); + + request = p_dbus_message_new_method_call( BLUEZ_DEST, adapter_path, BLUEZ_INTERFACE_ADAPTER, "RemoveDevice" ); + if (!request) + return STATUS_NO_MEMORY; + + if (!p_dbus_message_append_args( request, DBUS_TYPE_OBJECT_PATH, &device_path, DBUS_TYPE_INVALID )) + { + p_dbus_message_unref( request ); + return STATUS_NO_MEMORY; + } + + p_dbus_error_init( &error ); + status = bluez_dbus_send_and_wait_for_reply( connection, request, &reply, &error ); + if (status) + { + p_dbus_error_free( &error ); + return status; + } + if (!reply) + { + ERR( "Failed to remove device %s on adapter %s: %s: %s\n", debugstr_a( device_path ), + debugstr_a( adapter_path ), debugstr_a( error.name ), debugstr_a( error.message ) ); + status = bluez_dbus_error_to_ntstatus( &error ); + p_dbus_error_free( &error ); + return status; + } + p_dbus_message_unref( reply ); + p_dbus_error_free( &error ); + + return STATUS_SUCCESS; +} + NTSTATUS bluez_adapter_set_prop( void *connection, struct bluetooth_adapter_set_prop_params *params ) { DBusMessage *request, *reply; diff --git a/dlls/winebth.sys/unixlib.c b/dlls/winebth.sys/unixlib.c index 7a9b80487c2..249137dd502 100644 --- a/dlls/winebth.sys/unixlib.c +++ b/dlls/winebth.sys/unixlib.c @@ -208,6 +208,15 @@ static NTSTATUS bluetooth_adapter_stop_discovery( void *args ) return bluez_adapter_stop_discovery( dbus_connection, params->adapter->str ); }
+ +static NTSTATUS bluetooth_adapter_remove_device( void *args ) +{ + struct bluetooth_adapter_remove_device_params *params = args; + + if (!dbus_connection) return STATUS_NOT_SUPPORTED; + return bluez_adapter_remove_device( dbus_connection, params->adapter->str, params->device->str ); +} + static NTSTATUS bluetooth_auth_agent_enable_incoming( void *args ) { if (!dbus_connection) return STATUS_NOT_SUPPORTED; @@ -248,6 +257,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] = { bluetooth_adapter_get_unique_name, bluetooth_adapter_start_discovery, bluetooth_adapter_stop_discovery, + bluetooth_adapter_remove_device, bluetooth_adapter_free,
bluetooth_device_free, diff --git a/dlls/winebth.sys/unixlib.h b/dlls/winebth.sys/unixlib.h index c10964b5bc7..7357f777804 100644 --- a/dlls/winebth.sys/unixlib.h +++ b/dlls/winebth.sys/unixlib.h @@ -85,6 +85,12 @@ struct bluetooth_adapter_stop_discovery_params unix_name_t adapter; };
+struct bluetooth_adapter_remove_device_params +{ + unix_name_t adapter; + unix_name_t device; +}; + struct bluetooth_auth_send_response_params { unix_name_t device; @@ -108,6 +114,7 @@ enum bluetoothapis_funcs unix_bluetooth_adapter_get_unique_name, unix_bluetooth_adapter_start_discovery, unix_bluetooth_adapter_stop_discovery, + unix_bluetooth_adapter_remove_device, unix_bluetooth_adapter_free,
unix_bluetooth_device_free, diff --git a/dlls/winebth.sys/unixlib_priv.h b/dlls/winebth.sys/unixlib_priv.h index 8853adec1a3..a9c1bc0f080 100644 --- a/dlls/winebth.sys/unixlib_priv.h +++ b/dlls/winebth.sys/unixlib_priv.h @@ -54,6 +54,7 @@ extern NTSTATUS bluez_adapter_set_prop( void *connection, struct bluetooth_adapter_set_prop_params *params ); extern NTSTATUS bluez_adapter_start_discovery( void *connection, const char *adapter_path ); extern NTSTATUS bluez_adapter_stop_discovery( void *connection, const char *adapter_path ); +extern NTSTATUS bluez_adapter_remove_device( void *connection, const char *adapter_path, const char *device_path); extern NTSTATUS bluez_auth_agent_request_default( void *connection ); extern NTSTATUS bluez_auth_agent_start( void *connection, void **ctx ); extern NTSTATUS bluez_auth_agent_stop( void *connection, void *ctx ); diff --git a/dlls/winebth.sys/winebluetooth.c b/dlls/winebth.sys/winebluetooth.c index f3a16adf951..ca234b98f4b 100644 --- a/dlls/winebth.sys/winebluetooth.c +++ b/dlls/winebth.sys/winebluetooth.c @@ -87,6 +87,16 @@ NTSTATUS winebluetooth_radio_stop_discovery( winebluetooth_radio_t radio ) return UNIX_BLUETOOTH_CALL(bluetooth_adapter_stop_discovery, ¶ms); }
+NTSTATUS winebluetooth_radio_remove_device( winebluetooth_radio_t radio, winebluetooth_device_t device ) +{ + struct bluetooth_adapter_remove_device_params params = {0}; + + TRACE( "(%p, %p)\n", (void *)radio.handle, (void *)device.handle ); + params.adapter = radio.handle; + params.device = device.handle; + return UNIX_BLUETOOTH_CALL( bluetooth_adapter_remove_device, ¶ms ); +} + NTSTATUS winebluetooth_auth_agent_enable_incoming( void ) { return UNIX_BLUETOOTH_CALL( bluetooth_auth_agent_enable_incoming, NULL ); diff --git a/dlls/winebth.sys/winebth.c b/dlls/winebth.sys/winebth.c index 8bace437a18..694c9f1d629 100644 --- a/dlls/winebth.sys/winebth.c +++ b/dlls/winebth.sys/winebth.c @@ -329,6 +329,41 @@ static NTSTATUS WINAPI dispatch_bluetooth( DEVICE_OBJECT *device, IRP *irp ) LeaveCriticalSection( &ext->remote_devices_cs ); break; } + case IOCTL_WINEBTH_RADIO_REMOVE_DEVICE: + { + const BTH_ADDR *param = irp->AssociatedIrp.SystemBuffer; + struct bluetooth_remote_device *device; + + if (!param) + { + status = STATUS_INVALID_PARAMETER; + break; + } + if (insize < sizeof( *param )) + { + status = STATUS_INVALID_BUFFER_SIZE; + break; + } + + status = STATUS_NOT_FOUND; + EnterCriticalSection( &ext->remote_devices_cs ); + LIST_FOR_EACH_ENTRY( device, &ext->remote_devices, struct bluetooth_remote_device, entry ) + { + BOOL matches; + EnterCriticalSection( &device->props_cs ); + matches = device->props_mask & WINEBLUETOOTH_DEVICE_PROPERTY_ADDRESS && + device->props.address.ullLong == *param && device->props.paired; + LeaveCriticalSection( &device->props_cs ); + + if (matches) + { + status = winebluetooth_radio_remove_device( ext->radio, device->device ); + break; + } + } + LeaveCriticalSection( &ext->remote_devices_cs ); + break; + } default: FIXME( "Unimplemented IOCTL code: %#lx\n", code ); break; diff --git a/dlls/winebth.sys/winebth_priv.h b/dlls/winebth.sys/winebth_priv.h index e37ac20f140..5456acdd7a3 100644 --- a/dlls/winebth.sys/winebth_priv.h +++ b/dlls/winebth.sys/winebth_priv.h @@ -199,6 +199,7 @@ NTSTATUS winebluetooth_radio_set_property( winebluetooth_radio_t radio, union winebluetooth_property *property ); NTSTATUS winebluetooth_radio_start_discovery( winebluetooth_radio_t radio ); NTSTATUS winebluetooth_radio_stop_discovery( winebluetooth_radio_t radio ); +NTSTATUS winebluetooth_radio_remove_device( winebluetooth_radio_t radio, winebluetooth_device_t device ); NTSTATUS winebluetooth_auth_agent_enable_incoming( void );
void winebluetooth_device_free( winebluetooth_device_t device ); diff --git a/include/wine/winebth.h b/include/wine/winebth.h index d8ff41a6a61..df75684c8b1 100644 --- a/include/wine/winebth.h +++ b/include/wine/winebth.h @@ -32,6 +32,7 @@ /* Ask the system's Bluetooth service to send all incoming authentication requests to Wine. */ #define IOCTL_WINEBTH_AUTH_REGISTER CTL_CODE(FILE_DEVICE_BLUETOOTH, 0xa8, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_WINEBTH_RADIO_SEND_AUTH_RESPONSE CTL_CODE(FILE_DEVICE_BLUETOOTH, 0xa9, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_WINEBTH_RADIO_REMOVE_DEVICE CTL_CODE(FILE_DEVICE_BLUETOOTH, 0xab, METHOD_BUFFERED, FILE_ANY_ACCESS)
DEFINE_GUID( GUID_WINEBTH_AUTHENTICATION_REQUEST, 0xca67235f, 0xf621, 0x4c27, 0x85, 0x65, 0xa4, 0xd5, 0x5e, 0xa1, 0x26, 0xe8 );