From: Vibhav Pant vibhavp@gmail.com
--- .../bluetoothdevice.c | 136 +++++++++++++++++- dlls/windows.devices.bluetooth/main.c | 2 + dlls/windows.devices.bluetooth/private.h | 1 + .../tests/bluetooth.c | 4 +- 4 files changed, 140 insertions(+), 3 deletions(-)
diff --git a/dlls/windows.devices.bluetooth/bluetoothdevice.c b/dlls/windows.devices.bluetooth/bluetoothdevice.c index 6eff705c352..1c1a13c381c 100644 --- a/dlls/windows.devices.bluetooth/bluetoothdevice.c +++ b/dlls/windows.devices.bluetooth/bluetoothdevice.c @@ -1,4 +1,4 @@ -/* BluetoothDevice Implementation +/* BluetoothDevice, BluetoothLEDevice Implementation * * Copyright 2025 Vibhav Pant * @@ -155,6 +155,131 @@ static const IBluetoothDeviceStaticsVtbl bluetoothdevice_statics_vtbl = bluetoothdevice_statics_GetDeviceSelector, };
+struct bluetoothledevice_statics +{ + IActivationFactory IActivationFactory_iface; + IBluetoothLEDeviceStatics IBluetoothLEDeviceStatics_iface; + LONG ref; +}; + +static inline struct bluetoothledevice_statics *ble_device_impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct bluetoothledevice_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI ble_device_factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct bluetoothledevice_statics *impl = ble_device_impl_from_IActivationFactory( iface ); + + TRACE( "(%p, %s, %p) %ld\n", iface, debugstr_guid( iid ), out, impl->ref ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IActivationFactory )) + { + IActivationFactory_AddRef(( *out = &impl->IActivationFactory_iface )); + return S_OK; + } + if (IsEqualGUID( iid, &IID_IBluetoothLEDeviceStatics )) + { + IBluetoothLEDeviceStatics_AddRef(( *out = &impl->IBluetoothLEDeviceStatics_iface )); + return S_OK; + } + *out = NULL; + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + return E_NOINTERFACE; +} + +static ULONG WINAPI ble_device_factory_AddRef( IActivationFactory *iface ) +{ + struct bluetoothledevice_statics *impl = ble_device_impl_from_IActivationFactory( iface ); + TRACE( "(%p)\n", iface ); + return InterlockedIncrement( &impl->ref ); +} + +static ULONG WINAPI ble_device_factory_Release( IActivationFactory *iface ) +{ + struct bluetoothledevice_statics *impl = ble_device_impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "(%p)\n", iface ); + return ref; +} + +static HRESULT WINAPI ble_device_factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "(%p, %p, %p): stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI ble_device_factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) +{ + FIXME( "(%p, %p): stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI ble_device_factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *level ) +{ + FIXME( "(%p, %p): stub!\n", iface, level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI ble_device_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +{ + FIXME( "(%p, %p): stub!\n", iface, instance ); + return E_NOTIMPL; +} + +static const struct IActivationFactoryVtbl ble_device_factory_vtbl = +{ + ble_device_factory_QueryInterface, + ble_device_factory_AddRef, + ble_device_factory_Release, + /* IInspectable */ + ble_device_factory_GetIids, + ble_device_factory_GetRuntimeClassName, + ble_device_factory_GetTrustLevel, + /* IActivationFactory */ + ble_device_factory_ActivateInstance +}; + +DEFINE_IINSPECTABLE( bluetoothledevice_statics, IBluetoothLEDeviceStatics, struct bluetoothledevice_statics, IActivationFactory_iface ); + +static HRESULT WINAPI bluetoothledevice_statics_FromIdAsync( IBluetoothLEDeviceStatics *iface, HSTRING id, IAsyncOperation_BluetoothLEDevice **async_op ) +{ + FIXME( "(%p, %s, %p): stub!\n", iface, debugstr_hstring( id ), async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothledevice_statics_FromBluetoothAddressAsync( IBluetoothLEDeviceStatics *iface, UINT64 addr, IAsyncOperation_BluetoothLEDevice **async_op ) +{ + FIXME( "(%p, %#I64x, %p): stub!\n", iface, addr, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothledevice_statics_GetDeviceSelector( IBluetoothLEDeviceStatics *iface, HSTRING *result ) +{ + FIXME( "(%p, %p): stub!\n", iface, result ); + return E_NOTIMPL; +} + +static const IBluetoothLEDeviceStaticsVtbl bluetoothledevice_statics_vtbl = +{ + /* IUnknown */ + bluetoothledevice_statics_QueryInterface, + bluetoothledevice_statics_AddRef, + bluetoothledevice_statics_Release, + /* IInspectable */ + bluetoothledevice_statics_GetIids, + bluetoothledevice_statics_GetRuntimeClassName, + bluetoothledevice_statics_GetTrustLevel, + /* IBluetoothLEDeviceStatics */ + bluetoothledevice_statics_FromIdAsync, + bluetoothledevice_statics_FromBluetoothAddressAsync, + bluetoothledevice_statics_GetDeviceSelector +}; + + static struct bluetoothdevice_statics bluetoothdevice_statics = { {&factory_vtbl}, @@ -163,3 +288,12 @@ static struct bluetoothdevice_statics bluetoothdevice_statics = };
IActivationFactory *bluetoothdevice_statics_factory = &bluetoothdevice_statics.IActivationFactory_iface; + +static struct bluetoothledevice_statics bluetoothledevice_statics = +{ + {&ble_device_factory_vtbl}, + {&bluetoothledevice_statics_vtbl}, + 1 +}; + +IActivationFactory *bluetoothledevice_statics_factory = &bluetoothledevice_statics.IActivationFactory_iface; diff --git a/dlls/windows.devices.bluetooth/main.c b/dlls/windows.devices.bluetooth/main.c index b94599103a8..83fd2100f06 100644 --- a/dlls/windows.devices.bluetooth/main.c +++ b/dlls/windows.devices.bluetooth/main.c @@ -42,6 +42,8 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **fa IActivationFactory_QueryInterface( bluetoothadapter_factory, &IID_IActivationFactory, (void **)factory ); if (!wcscmp( buffer, RuntimeClass_Windows_Devices_Bluetooth_BluetoothDevice )) IActivationFactory_QueryInterface( bluetoothdevice_statics_factory, &IID_IActivationFactory, (void **)factory ); + if (!wcscmp( buffer, RuntimeClass_Windows_Devices_Bluetooth_BluetoothLEDevice )) + IActivationFactory_QueryInterface( bluetoothledevice_statics_factory, &IID_IActivationFactory, (void **)factory );
if (*factory) return S_OK; return CLASS_E_CLASSNOTAVAILABLE; diff --git a/dlls/windows.devices.bluetooth/private.h b/dlls/windows.devices.bluetooth/private.h index bffef9a9346..c72488c2edc 100644 --- a/dlls/windows.devices.bluetooth/private.h +++ b/dlls/windows.devices.bluetooth/private.h @@ -41,6 +41,7 @@
extern IActivationFactory *bluetoothadapter_factory; extern IActivationFactory *bluetoothdevice_statics_factory; +extern IActivationFactory *bluetoothledevice_statics_factory;
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ static inline impl_type *impl_from( iface_type *iface ) \ diff --git a/dlls/windows.devices.bluetooth/tests/bluetooth.c b/dlls/windows.devices.bluetooth/tests/bluetooth.c index 83f25d821af..5b78e1e176d 100644 --- a/dlls/windows.devices.bluetooth/tests/bluetooth.c +++ b/dlls/windows.devices.bluetooth/tests/bluetooth.c @@ -302,10 +302,10 @@ static void test_BluetoothLEDeviceStatics( void ) WindowsCreateString( class_name, wcslen( class_name ), &str ); hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void *)&factory ); WindowsDeleteString( str ); - todo_wine ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr ); + ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr ); if (hr == REGDB_E_CLASSNOTREG) { - todo_wine win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) ); + win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) ); return; } check_interface( factory, &IID_IUnknown );