From: Vibhav Pant vibhavp@gmail.com
--- dlls/winebth.sys/winebth.c | 51 ++++++++++++++++++++++++++++++++------ include/ddk/bthguid.h | 6 +++++ 2 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/dlls/winebth.sys/winebth.c b/dlls/winebth.sys/winebth.c index e8fe328e18a..47ed062725a 100644 --- a/dlls/winebth.sys/winebth.c +++ b/dlls/winebth.sys/winebth.c @@ -29,8 +29,10 @@ #include <winbase.h> #include <winternl.h> #include <winnls.h> +#include <wtypes.h> #include <initguid.h> #include <devpkey.h> +#include <propkey.h> #include <bthsdpdef.h> #include <bluetoothapis.h> #include <bthdef.h> @@ -947,6 +949,45 @@ static void bluetooth_radio_remove_remote_device( struct winebluetooth_watcher_e winebluetooth_device_free( event.device ); }
+/* Caller should hold device->props_cs. */ +static void bluetooth_device_set_properties( struct bluetooth_remote_device *device, + const struct winebluetooth_device_properties *props, + winebluetooth_device_props_mask_t mask ) +{ + WCHAR addr_str[13]; + + /* Windows uses upper-case for Bluetooth_DeviceAddress. */ + swprintf( addr_str, ARRAY_SIZE( addr_str ), L"%02X%02X%02X%02X%02X%02X", props->address.rgBytes[0], props->address.rgBytes[1], + props->address.rgBytes[2], props->address.rgBytes[3], props->address.rgBytes[4], props->address.rgBytes[5] ); + + if (mask & WINEBLUETOOTH_DEVICE_PROPERTY_ADDRESS) + { + IoSetDevicePropertyData( device->device_obj, &DEVPKEY_Bluetooth_DeviceAddress, LOCALE_NEUTRAL, 0, + DEVPROP_TYPE_STRING, sizeof( addr_str ), addr_str ); + if (device->bthle_symlink_name.Buffer) + IoSetDeviceInterfacePropertyData( &device->bthle_symlink_name, + (DEVPROPKEY *)&PKEY_DeviceInterface_Bluetooth_DeviceAddress, + LOCALE_NEUTRAL, 0, DEVPROP_TYPE_STRING, sizeof( addr_str ), addr_str ); + } + if (mask & WINEBLUETOOTH_DEVICE_PROPERTY_CLASS) + { + IoSetDevicePropertyData( device->device_obj, &DEVPKEY_Bluetooth_ClassOfDevice, LOCALE_NEUTRAL, 0, + DEVPROP_TYPE_UINT32, sizeof( props->class ), (void *)&props->class ); + } + if (mask & WINEBLUETOOTH_DEVICE_PROPERTY_CONNECTED && props->connected) + { + FILETIME time = {0}; + + GetSystemTimeAsFileTime( &time ); + IoSetDevicePropertyData( device->device_obj, &DEVPKEY_Bluetooth_LastConnectedTime, LOCALE_NEUTRAL, 0, + DEVPROP_TYPE_FILETIME, sizeof( time ), (void *)&time ); + if (device->bthle_symlink_name.Buffer) + IoSetDeviceInterfacePropertyData( &device->bthle_symlink_name, + (DEVPROPKEY *)&PKEY_DeviceInterface_Bluetooth_LastConnectedTime, + LOCALE_NEUTRAL, 0, DEVPROP_TYPE_FILETIME, sizeof( time ), (void *)&time ); + } +} + static void bluetooth_radio_update_device_props( struct winebluetooth_watcher_event_device_props_changed event ) { BTH_DEVICE_INFO device_new_info = {0}; @@ -988,6 +1029,7 @@ static void bluetooth_radio_update_device_props( struct winebluetooth_watcher_ev if (event.changed_props_mask & WINEBLUETOOTH_DEVICE_PROPERTY_CLASS) device->props.class = event.props.class; winebluetooth_device_properties_to_info( device->props_mask, &device->props, &device_new_info ); + bluetooth_device_set_properties( device, &device->props, device->props_mask ); LeaveCriticalSection( &device->props_cs ); LeaveCriticalSection( &radio->remote_devices_cs );
@@ -1616,21 +1658,14 @@ static NTSTATUS WINAPI remote_device_pdo_pnp( DEVICE_OBJECT *device_obj, struct } case IRP_MN_START_DEVICE: { - WCHAR addr_str[13]; - BLUETOOTH_ADDRESS addr; - EnterCriticalSection( &ext->props_cs ); if (ext->le && !IoRegisterDeviceInterface( device_obj, &GUID_BLUETOOTHLE_DEVICE_INTERFACE, NULL, &ext->bthle_symlink_name )) IoSetDeviceInterfaceState( &ext->bthle_symlink_name, TRUE ); ext->started = TRUE; - addr = ext->props.address; + bluetooth_device_set_properties( ext, &ext->props, ext->props_mask ); LeaveCriticalSection( &ext->props_cs ); - swprintf( addr_str, ARRAY_SIZE( addr_str ), L"%02x%02x%02x%02x%02x%02x", addr.rgBytes[0], addr.rgBytes[1], - addr.rgBytes[2], addr.rgBytes[3], addr.rgBytes[4], addr.rgBytes[5] ); - IoSetDevicePropertyData( device_obj, &DEVPKEY_Bluetooth_DeviceAddress, LOCALE_NEUTRAL, 0, DEVPROP_TYPE_STRING, - sizeof( addr_str ), addr_str ); ret = STATUS_SUCCESS; break; } diff --git a/include/ddk/bthguid.h b/include/ddk/bthguid.h index d042e13a37b..d8122263cb8 100644 --- a/include/ddk/bthguid.h +++ b/include/ddk/bthguid.h @@ -21,5 +21,11 @@
/* DEVPROP_TYPE_STRING */ DEFINE_DEVPROPKEY( DEVPKEY_Bluetooth_DeviceAddress, 0x2bd67d8b,0x8beb,0x48d5,0x87,0xe0,0x6c,0xda,0x34,0x28,0x04,0x0a,1 ); +/* DEVPROP_TYPE_UINT32 */ +DEFINE_DEVPROPKEY( DEVPKEY_Bluetooth_DeviceFlags, 0x2bd67d8b,0x8beb,0x48d5,0x87,0xe0,0x6c,0xda,0x34,0x28,0x04,0x0a,3 ); +/* DEVPROP_TYPE_UINT32 */ +DEFINE_DEVPROPKEY( DEVPKEY_Bluetooth_ClassOfDevice, 0x2bd67d8b,0x8beb,0x48d5,0x87,0xe0,0x6c,0xda,0x34,0x28,0x04,0x0a,10 ); +/* DEVPROP_TYPE_FILETIME */ +DEFINE_DEVPROPKEY( DEVPKEY_Bluetooth_LastConnectedTime, 0x2bd67d8b,0x8beb,0x48d5,0x87,0xe0,0x6c,0xda,0x34,0x28,0x04,0x0a,11 );
#endif