From: Vibhav Pant <vibhavp@gmail.com> --- dlls/winebth.sys/winebluetooth.c | 25 +++++++++++++++++++++++++ dlls/winebth.sys/winebth.c | 25 +++++++++++++++++++++++++ dlls/winebth.sys/winebth_priv.h | 3 +++ include/bthdef.h | 9 ++++++++- 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/dlls/winebth.sys/winebluetooth.c b/dlls/winebth.sys/winebluetooth.c index 5bab7230fa3..a95f12b1af4 100644 --- a/dlls/winebth.sys/winebluetooth.c +++ b/dlls/winebth.sys/winebluetooth.c @@ -29,6 +29,7 @@ #include <wine/debug.h> #include <wine/unixlib.h> +#include "bthdef.h" #include "winebth_priv.h" #include "unixlib.h" @@ -175,6 +176,20 @@ void winebluetooth_device_properties_to_info( winebluetooth_device_props_mask_t info->classOfDevice = props->class; info->flags |= BDIF_COD; } + if (props_mask & WINEBLUETOOTH_DEVICE_PROPERTY_BEARER_BREDR) + info->flags |= BDIF_BR; + if (props_mask & WINEBLUETOOTH_DEVICE_PROPERTY_BEARER_LE) + { + const struct winebluetooth_device_bearer_properties *le = &props->le; + + info->flags |= BDIF_LE; + if (le->props_mask & WINEBLUETOOTH_DEVICE_BEARER_PROPERTY_BONDED && le->bonded) + info->flags |= (BDIF_LE_PERSONAL | BDIF_LE_PAIRED); + if (le->props_mask & WINEBLUETOOTH_DEVICE_BEARER_PROPERTY_CONNECTED && le->connected) + info->flags |= BDIF_LE_CONNECTED; + if (le->props_mask & WINEBLUETOOTH_DEVICE_BEARER_PROPERTY_PAIRED && le->paired) + info->flags |= BDIF_LE_PAIRED; + } } NTSTATUS winebluetooth_auth_send_response( winebluetooth_device_t device, BLUETOOTH_AUTHENTICATION_METHOD method, @@ -272,6 +287,16 @@ NTSTATUS winebluetooth_get_event( struct winebluetooth_event *result ) return status; } +void winebluetooth_device_bearer_properties_update( struct winebluetooth_device_bearer_properties *props, + const struct winebluetooth_device_bearer_properties *new_props ) +{ + props->props_mask |= new_props->props_mask; + + if (new_props->props_mask & WINEBLUETOOTH_DEVICE_BEARER_PROPERTY_BONDED) props->bonded = new_props->bonded; + if (new_props->props_mask & WINEBLUETOOTH_DEVICE_BEARER_PROPERTY_CONNECTED) props->connected = new_props->connected; + if (new_props->props_mask & WINEBLUETOOTH_DEVICE_BEARER_PROPERTY_PAIRED) props->paired = new_props->paired; +} + NTSTATUS winebluetooth_init( void ) { NTSTATUS status; diff --git a/dlls/winebth.sys/winebth.c b/dlls/winebth.sys/winebth.c index dea7af365c0..7eb915a016d 100644 --- a/dlls/winebth.sys/winebth.c +++ b/dlls/winebth.sys/winebth.c @@ -46,6 +46,7 @@ #include <wine/list.h> #include "winebth_priv.h" +#include "winnt.h" WINE_DEFAULT_DEBUG_CHANNEL( winebth ); @@ -1146,6 +1147,8 @@ static void bluetooth_device_set_properties( struct bluetooth_remote_device *dev const struct winebluetooth_device_properties *props, winebluetooth_device_props_mask_t mask ) { + BTH_DEVICE_INFO info = {0}; + if (mask & WINEBLUETOOTH_DEVICE_PROPERTY_ADDRESS) { WCHAR addr_str[18], aep_id[59]; @@ -1168,6 +1171,10 @@ static void bluetooth_device_set_properties( struct bluetooth_remote_device *dev IoSetDeviceInterfacePropertyData( &device->bthle_symlink_name, (DEVPROPKEY *)&PKEY_DeviceInterface_Bluetooth_DeviceAddress, LOCALE_NEUTRAL, 0, DEVPROP_TYPE_STRING, 26, addr_str ); + if (device->bredr_symlink_name.Buffer) + IoSetDeviceInterfacePropertyData( &device->bredr_symlink_name, + (DEVPROPKEY *)&PKEY_DeviceInterface_Bluetooth_DeviceAddress, + LOCALE_NEUTRAL, 0, DEVPROP_TYPE_STRING, 26, addr_str ); swprintf( addr_str, ARRAY_SIZE( addr_str ), L"%02x:%02x:%02x:%02x:%02x:%02x", device_addr[0], device_addr[1], device_addr[2], device_addr[3], device_addr[4], device_addr[5] ); @@ -1188,7 +1195,21 @@ static void bluetooth_device_set_properties( struct bluetooth_remote_device *dev IoSetDeviceInterfacePropertyData( &device->bthle_symlink_name, (DEVPROPKEY *)&PKEY_DeviceInterface_Bluetooth_LastConnectedTime, LOCALE_NEUTRAL, 0, DEVPROP_TYPE_FILETIME, sizeof( time ), (void *)&time ); + if (device->bredr_symlink_name.Buffer) + IoSetDeviceInterfacePropertyData( &device->bredr_symlink_name, + (DEVPROPKEY *)&PKEY_DeviceInterface_Bluetooth_LastConnectedTime, + LOCALE_NEUTRAL, 0, DEVPROP_TYPE_FILETIME, sizeof( time ), (void *)&time ); } + + winebluetooth_device_properties_to_info( mask, props, &info ); + if (device->bthle_symlink_name.Buffer) + IoSetDeviceInterfacePropertyData( &device->bthle_symlink_name, + (DEVPROPKEY *)&PKEY_DeviceInterface_Bluetooth_Flags, LOCALE_NEUTRAL, 0, + DEVPROP_TYPE_UINT32, sizeof( info.flags ), &info.flags ); + if (device->bredr_symlink_name.Buffer) + IoSetDeviceInterfacePropertyData( &device->bredr_symlink_name, + (DEVPROPKEY *)&PKEY_DeviceInterface_Bluetooth_Flags, LOCALE_NEUTRAL, 0, + DEVPROP_TYPE_UINT32, sizeof( info.flags ), &info.flags ); } static void bluetooth_radio_update_device_props( struct winebluetooth_watcher_event_device_props_changed event ) @@ -1232,6 +1253,10 @@ static void bluetooth_radio_update_device_props( struct winebluetooth_watcher_ev device->props.trusted = event.props.trusted; if (event.changed_props_mask & WINEBLUETOOTH_DEVICE_PROPERTY_CLASS) device->props.class = event.props.class; + if (event.changed_props_mask & WINEBLUETOOTH_DEVICE_PROPERTY_BEARER_BREDR) + winebluetooth_device_bearer_properties_update( &device->props.bredr, &event.props.bredr ); + if (event.changed_props_mask & WINEBLUETOOTH_DEVICE_PROPERTY_BEARER_LE) + winebluetooth_device_bearer_properties_update( &device->props.le, &event.props.le ); winebluetooth_device_properties_to_info( device->props_mask, &device->props, &device_new_info ); bluetooth_device_set_properties( device, adapter_addr.rgBytes, &device->props, device->props_mask ); LeaveCriticalSection( &device->props_cs ); diff --git a/dlls/winebth.sys/winebth_priv.h b/dlls/winebth.sys/winebth_priv.h index 62cbed7326a..726b6208878 100644 --- a/dlls/winebth.sys/winebth_priv.h +++ b/dlls/winebth.sys/winebth_priv.h @@ -209,6 +209,9 @@ struct winebluetooth_device_bearer_properties BOOL connected; BOOL paired; }; + +void winebluetooth_device_bearer_properties_update( struct winebluetooth_device_bearer_properties *props, + const struct winebluetooth_device_bearer_properties *new_props ); struct winebluetooth_device_properties { BLUETOOTH_ADDRESS address; diff --git a/include/bthdef.h b/include/bthdef.h index b61d5b033d3..346d0ba94a3 100644 --- a/include/bthdef.h +++ b/include/bthdef.h @@ -49,7 +49,14 @@ typedef ULONGLONG BTH_ADDR, *PBTH_ADDR; #define BDIF_SSP_SUPPORTED 0x00000100 #define BDIF_SSP_PAIRED 0x00000200 -#define BDIF_SSP_MITM_PROTECTED 0x00000200 +#define BDIF_SSP_MITM_PROTECTED 0x00000400 + +#define BDIF_BR 0x00004000 +#define BDIF_LE 0x00008000 +#define BDIF_LE_PAIRED 0x00010000 +#define BDIF_LE_PERSONAL 0x00020000 +#define BDIF_LE_NAME 0x00400000 +#define BDIF_LE_CONNECTED 0x01000000 typedef struct _BTH_DEVICE_INFO { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11084