From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- .../bluetoothadapter.c | 44 +++++++++++++++++++ dlls/windows.devices.bluetooth/main.c | 2 +- dlls/windows.devices.bluetooth/private.h | 40 +++++++++++++++++ .../tests/bluetooth.c | 6 +++ 4 files changed, 91 insertions(+), 1 deletion(-)
diff --git a/dlls/windows.devices.bluetooth/bluetoothadapter.c b/dlls/windows.devices.bluetooth/bluetoothadapter.c index a165031293a..367cd464e42 100644 --- a/dlls/windows.devices.bluetooth/bluetoothadapter.c +++ b/dlls/windows.devices.bluetooth/bluetoothadapter.c @@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(bluetooth); struct bluetoothadapter { IActivationFactory IActivationFactory_iface; + IBluetoothAdapterStatics IBluetoothAdapterStatics_iface; LONG ref; };
@@ -49,6 +50,13 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IBluetoothAdapterStatics )) + { + *out = &impl->IBluetoothAdapterStatics_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -107,9 +115,45 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
+DEFINE_IINSPECTABLE( bluetoothadapter_statics, IBluetoothAdapterStatics, struct bluetoothadapter, IActivationFactory_iface ) + +static HRESULT WINAPI bluetoothadapter_statics_GetDeviceSelector( IBluetoothAdapterStatics *iface, HSTRING *result ) +{ + FIXME( "iface %p, result %p stub!\n", iface, result ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothadapter_statics_FromIdAsync( IBluetoothAdapterStatics *iface, HSTRING id, IAsyncOperation_BluetoothAdapter **operation ) +{ + FIXME( "iface %p, id %s, operation %p stub!\n", iface, debugstr_hstring(id), operation ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothadapter_statics_GetDefaultAsync( IBluetoothAdapterStatics *iface, IAsyncOperation_BluetoothAdapter **operation ) +{ + FIXME( "iface %p, operation %p stub!\n", iface, operation ); + return E_NOTIMPL; +} + +static const struct IBluetoothAdapterStaticsVtbl bluetoothadapter_statics_vtbl = +{ + bluetoothadapter_statics_QueryInterface, + bluetoothadapter_statics_AddRef, + bluetoothadapter_statics_Release, + /* IInspectable methods */ + bluetoothadapter_statics_GetIids, + bluetoothadapter_statics_GetRuntimeClassName, + bluetoothadapter_statics_GetTrustLevel, + /* IBluetoothAdapterStatics methods */ + bluetoothadapter_statics_GetDeviceSelector, + bluetoothadapter_statics_FromIdAsync, + bluetoothadapter_statics_GetDefaultAsync, +}; + static struct bluetoothadapter bluetoothadapter_statics = { {&factory_vtbl}, + {&bluetoothadapter_statics_vtbl}, 1, };
diff --git a/dlls/windows.devices.bluetooth/main.c b/dlls/windows.devices.bluetooth/main.c index 532c9eeee0b..810b00d90fd 100644 --- a/dlls/windows.devices.bluetooth/main.c +++ b/dlls/windows.devices.bluetooth/main.c @@ -24,7 +24,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(bluetooth);
-static const char *debugstr_hstring( HSTRING hstr ) +const char *debugstr_hstring( HSTRING hstr ) { const WCHAR *str; UINT32 len; diff --git a/dlls/windows.devices.bluetooth/private.h b/dlls/windows.devices.bluetooth/private.h index 56c553b6280..079cef62bb5 100644 --- a/dlls/windows.devices.bluetooth/private.h +++ b/dlls/windows.devices.bluetooth/private.h @@ -35,6 +35,46 @@ #define WIDL_using_Windows_Devices_Bluetooth #include "windows.devices.bluetooth.h"
+extern const char *debugstr_hstring( HSTRING hstr ); + extern IActivationFactory *bluetoothadapter_factory;
+#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ + static inline impl_type *impl_from( iface_type *iface ) \ + { \ + return CONTAINING_RECORD( iface, impl_type, iface_mem ); \ + } \ + static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \ + } \ + static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_AddRef( (IInspectable *)(expr) ); \ + } \ + static ULONG WINAPI pfx##_Release( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_Release( (IInspectable *)(expr) ); \ + } \ + static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \ + } \ + static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \ + } \ + static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \ + } +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface ) + #endif diff --git a/dlls/windows.devices.bluetooth/tests/bluetooth.c b/dlls/windows.devices.bluetooth/tests/bluetooth.c index bb212ca6ac9..bf9e94dfb69 100644 --- a/dlls/windows.devices.bluetooth/tests/bluetooth.c +++ b/dlls/windows.devices.bluetooth/tests/bluetooth.c @@ -49,6 +49,7 @@ static void check_interface_( unsigned int line, void *obj, const IID *iid ) static void test_BluetoothAdapterStatics(void) { static const WCHAR *bluetoothadapter_statics_name = L"Windows.Devices.Bluetooth.BluetoothAdapter"; + IBluetoothAdapterStatics *bluetoothadapter_statics; IActivationFactory *factory; HSTRING str; HRESULT hr; @@ -70,6 +71,11 @@ static void test_BluetoothAdapterStatics(void) check_interface( factory, &IID_IInspectable ); check_interface( factory, &IID_IAgileObject );
+ hr = IActivationFactory_QueryInterface( factory, &IID_IBluetoothAdapterStatics, (void **)&bluetoothadapter_statics ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + ref = IBluetoothAdapterStatics_Release( bluetoothadapter_statics ); + ok( ref == 2, "got ref %ld.\n", ref ); ref = IActivationFactory_Release( factory ); ok( ref == 1, "got ref %ld.\n", ref ); }