From: Vibhav Pant vibhavp@gmail.com
--- dlls/windows.devices.bluetooth/Makefile.in | 2 +- .../bluetoothadapter.c | 28 +++++++++++++++++-- .../tests/bluetooth.c | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/dlls/windows.devices.bluetooth/Makefile.in b/dlls/windows.devices.bluetooth/Makefile.in index e084548f7e6..06141de8ad8 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 = \ async.c \ diff --git a/dlls/windows.devices.bluetooth/bluetoothadapter.c b/dlls/windows.devices.bluetooth/bluetoothadapter.c index f2e69e67407..c2c13f1d622 100644 --- a/dlls/windows.devices.bluetooth/bluetoothadapter.c +++ b/dlls/windows.devices.bluetooth/bluetoothadapter.c @@ -19,6 +19,8 @@ */
#include "private.h" +#include "bthsdpdef.h" +#include "bluetoothapis.h" #include "setupapi.h" #include "wine/debug.h"
@@ -208,6 +210,7 @@ struct bluetoothadapter { IBluetoothAdapter IBluetoothAdapter_iface; HSTRING id; + HANDLE radio; LONG ref; };
@@ -253,6 +256,7 @@ static ULONG WINAPI bluetoothadapter_Release( IBluetoothAdapter *iface ) if (!ref) { WindowsDeleteString( impl->id ); + CloseHandle( impl->radio ); free( impl ); } return ref; @@ -285,8 +289,19 @@ static HRESULT WINAPI bluetoothadapter_get_DeviceId( IBluetoothAdapter *iface, H
static HRESULT WINAPI bluetoothadapter_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 err; + + TRACE( "iface %p, addr %p\n", iface, addr ); + + info.dwSize = sizeof( info ); + err = BluetoothGetRadioInfo( impl->radio, &info ); + if (err) + return HRESULT_FROM_WIN32( GetLastError() ); + + *addr = info.address.ullLong; + return S_OK; }
static HRESULT WINAPI bluetoothadapter_get_IsClassicSupported( IBluetoothAdapter *iface, boolean *value ) @@ -362,6 +377,15 @@ static HRESULT bluetoothadapter_create( const WCHAR *device_path, IBluetoothAdap return ret; }
+ impl->radio = CreateFileW( device_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, NULL); + if (impl->radio == INVALID_HANDLE_VALUE) + { + WindowsDeleteString( impl->id ); + free( impl ); + return HRESULT_FROM_WIN32( GetLastError() ); + } + impl->IBluetoothAdapter_iface.lpVtbl = &bluetooth_adapter_vtbl; impl->ref = 1; *adapter = &impl->IBluetoothAdapter_iface; diff --git a/dlls/windows.devices.bluetooth/tests/bluetooth.c b/dlls/windows.devices.bluetooth/tests/bluetooth.c index ec256174118..583d512ac93 100644 --- a/dlls/windows.devices.bluetooth/tests/bluetooth.c +++ b/dlls/windows.devices.bluetooth/tests/bluetooth.c @@ -342,7 +342,7 @@ static void test_BluetoothAdapterStatics(void) WindowsDeleteString( str );
hr = IBluetoothAdapter_get_BluetoothAddress( adapter, &address ); - todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); + ok( hr == S_OK, "got hr %#lx.\n", hr );
hr = IBluetoothAdapter_get_IsLowEnergySupported( adapter, &value ); todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr );