From: Vibhav Pant <vibhavp@gmail.com> --- dlls/windows.devices.bluetooth/Makefile.in | 2 +- .../bluetoothadapter.c | 22 +++++++++++++++++-- dlls/windows.devices.bluetooth/private.h | 2 ++ .../tests/bluetooth.c | 6 ++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dlls/windows.devices.bluetooth/Makefile.in b/dlls/windows.devices.bluetooth/Makefile.in index c931ba78706..0e0364f2a3f 100644 --- a/dlls/windows.devices.bluetooth/Makefile.in +++ b/dlls/windows.devices.bluetooth/Makefile.in @@ -1,5 +1,5 @@ MODULE = windows.devices.bluetooth.dll -IMPORTS = combase setupapi +IMPORTS = bluetoothapis combase setupapi SOURCES = \ advertisement.c \ diff --git a/dlls/windows.devices.bluetooth/bluetoothadapter.c b/dlls/windows.devices.bluetooth/bluetoothadapter.c index 917b60d00be..2c2450d39df 100644 --- a/dlls/windows.devices.bluetooth/bluetoothadapter.c +++ b/dlls/windows.devices.bluetooth/bluetoothadapter.c @@ -199,6 +199,7 @@ struct bluetoothadapter { IBluetoothAdapter IBluetoothAdapter_iface; HSTRING id; + HANDLE radio; LONG ref; }; @@ -243,6 +244,7 @@ static WINAPI ULONG bluetoothadapter_Release( IBluetoothAdapter *iface ) if (!ref) { WindowsDeleteString( impl->id ); + CloseHandle( impl->radio ); free( impl ); } return ref; @@ -275,8 +277,17 @@ static HRESULT WINAPI bluetoothadapter_get_DeviceId( IBluetoothAdapter *iface, H static HRESULT WINAPI bluetoothadpter_get_BluetoothAddress( IBluetoothAdapter *iface, UINT64 *addr ) { - FIXME( "iface %p, addr %p stub!\n", iface, addr ); - return E_NOTIMPL; + struct bluetoothadapter *impl = impl_from_IBluetoothAdapter( iface ); + BLUETOOTH_RADIO_INFO info = {0}; + DWORD ret; + + TRACE( "iface %p, addr %p\n", iface, addr ); + + info.dwSize = sizeof( info ); + ret = BluetoothGetRadioInfo( impl->radio, &info ); + if (!ret) + *addr = info.address.ullLong; + return HRESULT_FROM_WIN32( ret ); } static HRESULT WINAPI bluetoothadapter_get_IsClassicSupported( IBluetoothAdapter *iface, boolean *value ) @@ -343,8 +354,15 @@ static HRESULT create_bluetoothadapter( const WCHAR *path, IBluetoothAdapter **o if (!(impl = calloc( 1, sizeof( *impl ) ))) return E_OUTOFMEMORY; impl->IBluetoothAdapter_iface.lpVtbl = &bluetoothadapter_vtbl; + impl->radio = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL ); + if (impl->radio == INVALID_HANDLE_VALUE) + { + free( impl ); + return HRESULT_FROM_WIN32( GetLastError() ); + } if (FAILED((hr = WindowsCreateString( path, wcslen( path ), &impl->id )))) { + CloseHandle( impl->radio ); free( impl ); return hr; } diff --git a/dlls/windows.devices.bluetooth/private.h b/dlls/windows.devices.bluetooth/private.h index 1e7f9a2440c..48cc5c04447 100644 --- a/dlls/windows.devices.bluetooth/private.h +++ b/dlls/windows.devices.bluetooth/private.h @@ -29,6 +29,8 @@ #include "activation.h" #include "bthdef.h" +#include "bthsdpdef.h" +#include "bluetoothapis.h" #define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Foundation_Collections diff --git a/dlls/windows.devices.bluetooth/tests/bluetooth.c b/dlls/windows.devices.bluetooth/tests/bluetooth.c index 3ccc4117e5e..b53021a2cb2 100644 --- a/dlls/windows.devices.bluetooth/tests/bluetooth.c +++ b/dlls/windows.devices.bluetooth/tests/bluetooth.c @@ -433,8 +433,8 @@ static void test_BluetoothAdapterStatics(void) address = 0; hr = IBluetoothAdapter_get_BluetoothAddress( adapter1, &address ); - todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); - todo_wine ok( address, "got address %#I64x.\n", address ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + ok( address, "got address %#I64x.\n", address ); radio_find = BluetoothFindFirstRadio( ¶ms, &radio ); ok( radio_find != NULL, "Got radio_find %p\n", radio_find ); @@ -454,7 +454,7 @@ static void test_BluetoothAdapterStatics(void) if (!BluetoothFindNextRadio( radio_find, &radio )) break; } BluetoothFindRadioClose( radio_find ); - todo_wine ok( found, "got found %d\n", found ); + ok( found, "got found %d\n", found ); hr = IBluetoothAdapter_get_IsLowEnergySupported( adapter1, &bool_val ); todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10006