From: Vibhav Pant vibhavp@gmail.com
--- dlls/windows.devices.bluetooth/Makefile.in | 1 + .../bluetoothdevice.c | 165 ++++++++++++++++++ dlls/windows.devices.bluetooth/main.c | 2 + dlls/windows.devices.bluetooth/private.h | 3 + .../tests/bluetooth.c | 2 +- 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 dlls/windows.devices.bluetooth/bluetoothdevice.c
diff --git a/dlls/windows.devices.bluetooth/Makefile.in b/dlls/windows.devices.bluetooth/Makefile.in index 216c1f7ae9b..89f3fc78abc 100644 --- a/dlls/windows.devices.bluetooth/Makefile.in +++ b/dlls/windows.devices.bluetooth/Makefile.in @@ -3,5 +3,6 @@ IMPORTS = combase
SOURCES = \ bluetoothadapter.c \ + bluetoothdevice.c \ classes.idl \ main.c diff --git a/dlls/windows.devices.bluetooth/bluetoothdevice.c b/dlls/windows.devices.bluetooth/bluetoothdevice.c new file mode 100644 index 00000000000..6eff705c352 --- /dev/null +++ b/dlls/windows.devices.bluetooth/bluetoothdevice.c @@ -0,0 +1,165 @@ +/* BluetoothDevice Implementation + * + * Copyright 2025 Vibhav Pant + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL( bluetooth ); + +struct bluetoothdevice_statics +{ + IActivationFactory IActivationFactory_iface; + IBluetoothDeviceStatics IBluetoothDeviceStatics_iface; + LONG ref; +}; + +static inline struct bluetoothdevice_statics *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct bluetoothdevice_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct bluetoothdevice_statics *impl = 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_IBluetoothDeviceStatics)) + { + IBluetoothDeviceStatics_AddRef(( *out = &impl->IBluetoothDeviceStatics_iface )); + return S_OK; + } + *out = NULL; + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + return E_NOINTERFACE; +} + +static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +{ + struct bluetoothdevice_statics *impl = impl_from_IActivationFactory( iface ); + TRACE( "(%p)\n", iface ); + return InterlockedIncrement( &impl->ref ); +} + +static ULONG WINAPI factory_Release( IActivationFactory *iface ) +{ + struct bluetoothdevice_statics *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "(%p)\n", iface ); + return ref; +} + +static HRESULT WINAPI 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 factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) +{ + FIXME( "(%p, %p): stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *level ) +{ + FIXME( "(%p, %p): stub!\n", iface, level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +{ + FIXME( "(%p, %p): stub!\n", iface, instance ); + return E_NOTIMPL; +} + +static const struct IActivationFactoryVtbl factory_vtbl = +{ + factory_QueryInterface, + factory_AddRef, + factory_Release, + /* IInspectable */ + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, + /* IActivationFactory */ + factory_ActivateInstance +}; + +DEFINE_IINSPECTABLE( bluetoothdevice_statics, IBluetoothDeviceStatics, struct bluetoothdevice_statics, IActivationFactory_iface ); + +static HRESULT WINAPI bluetoothdevice_statics_FromIdAsync( IBluetoothDeviceStatics *iface, HSTRING id, IAsyncOperation_BluetoothDevice **async_op ) +{ + FIXME( "(%p, %s, %p): stub!\n", iface, debugstr_hstring( id ), async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothdevice_statics_FromHostNameAsync( IBluetoothDeviceStatics *iface, IHostName *name, IAsyncOperation_BluetoothDevice **async_op ) +{ + FIXME( "(%p, %p, %p): stub!\n", iface, name, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothdevice_statics_FromBluetoothAddressAsync( IBluetoothDeviceStatics *iface, + UINT64 address, + IAsyncOperation_BluetoothDevice **async_op ) +{ + FIXME( "(%p, %#I64x, %p): stub!\n", iface, address, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothdevice_statics_GetDeviceSelector( IBluetoothDeviceStatics *iface, HSTRING *value ) +{ + FIXME( "(%p, %p): stub!\n", iface, value ); + *value = NULL; + return E_NOTIMPL; +} + +static const IBluetoothDeviceStaticsVtbl bluetoothdevice_statics_vtbl = +{ + bluetoothdevice_statics_QueryInterface, + bluetoothdevice_statics_AddRef, + bluetoothdevice_statics_Release, + /* IInspectable */ + bluetoothdevice_statics_GetIids, + bluetoothdevice_statics_GetRuntimeClassName, + bluetoothdevice_statics_GetTrustLevel, + /* IBluetoothDeviceStatics */ + bluetoothdevice_statics_FromIdAsync, + bluetoothdevice_statics_FromHostNameAsync, + bluetoothdevice_statics_FromBluetoothAddressAsync, + bluetoothdevice_statics_GetDeviceSelector, +}; + +static struct bluetoothdevice_statics bluetoothdevice_statics = +{ + {&factory_vtbl}, + {&bluetoothdevice_statics_vtbl}, + 1 +}; + +IActivationFactory *bluetoothdevice_statics_factory = &bluetoothdevice_statics.IActivationFactory_iface; diff --git a/dlls/windows.devices.bluetooth/main.c b/dlls/windows.devices.bluetooth/main.c index d4e608d2f1f..b94599103a8 100644 --- a/dlls/windows.devices.bluetooth/main.c +++ b/dlls/windows.devices.bluetooth/main.c @@ -40,6 +40,8 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **fa
if (!wcscmp( buffer, RuntimeClass_Windows_Devices_Bluetooth_BluetoothAdapter )) 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 (*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 746aa1e66ee..3b81cb319a8 100644 --- a/dlls/windows.devices.bluetooth/private.h +++ b/dlls/windows.devices.bluetooth/private.h @@ -32,10 +32,13 @@ #define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Foundation_Collections #include "windows.foundation.h" +#define WIDL_using_Windows_Networking +#include "windows.networking.h" #define WIDL_using_Windows_Devices_Bluetooth #include "windows.devices.bluetooth.h"
extern IActivationFactory *bluetoothadapter_factory; +extern IActivationFactory *bluetoothdevice_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 3dbb4b77d91..1ded17982ff 100644 --- a/dlls/windows.devices.bluetooth/tests/bluetooth.c +++ b/dlls/windows.devices.bluetooth/tests/bluetooth.c @@ -106,7 +106,7 @@ static void test_BluetoothDeviceStatics( 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) { win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) );