Module: wine Branch: master Commit: e814a2b1cbc6743d9b92bb55603f632d3a62c909 URL: https://gitlab.winehq.org/wine/wine/-/commit/e814a2b1cbc6743d9b92bb55603f632...
Author: Mohamad Al-Jaf mohamadaljaf@gmail.com Date: Mon Jul 3 01:59:32 2023 -0400
windows.networking.hostname: Add IHostNameFactory stub interface.
---
dlls/windows.networking.hostname/hostname.c | 30 +++++++++++++++++ dlls/windows.networking.hostname/private.h | 39 +++++++++++++++++++++++ dlls/windows.networking.hostname/tests/hostname.c | 6 ++++ 3 files changed, 75 insertions(+)
diff --git a/dlls/windows.networking.hostname/hostname.c b/dlls/windows.networking.hostname/hostname.c index 7a914f4ded4..538e897963f 100644 --- a/dlls/windows.networking.hostname/hostname.c +++ b/dlls/windows.networking.hostname/hostname.c @@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(hostname); struct hostname_statics { IActivationFactory IActivationFactory_iface; + IHostNameFactory IHostNameFactory_iface; LONG ref; };
@@ -49,6 +50,13 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IHostNameFactory )) + { + *out = &impl->IHostNameFactory_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,31 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
+DEFINE_IINSPECTABLE( hostname_factory, IHostNameFactory, struct hostname_statics, IActivationFactory_iface ) + +static HRESULT WINAPI hostname_factory_CreateHostName( IHostNameFactory *iface, HSTRING name, IHostName **value ) +{ + FIXME( "iface %p, name %s, value %p stub!\n", iface, debugstr_hstring(name), value ); + return E_NOTIMPL; +} + +static const struct IHostNameFactoryVtbl hostname_factory_vtbl = +{ + hostname_factory_QueryInterface, + hostname_factory_AddRef, + hostname_factory_Release, + /* IInspectable methods */ + hostname_factory_GetIids, + hostname_factory_GetRuntimeClassName, + hostname_factory_GetTrustLevel, + /* IHostNameFactory methods */ + hostname_factory_CreateHostName, +}; + static struct hostname_statics hostname_statics = { {&factory_vtbl}, + {&hostname_factory_vtbl}, 1, };
diff --git a/dlls/windows.networking.hostname/private.h b/dlls/windows.networking.hostname/private.h index 98728895b90..55faba8cc96 100644 --- a/dlls/windows.networking.hostname/private.h +++ b/dlls/windows.networking.hostname/private.h @@ -37,4 +37,43 @@
extern IActivationFactory *hostname_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.networking.hostname/tests/hostname.c b/dlls/windows.networking.hostname/tests/hostname.c index 1e1a7de94af..edb20f1fa44 100644 --- a/dlls/windows.networking.hostname/tests/hostname.c +++ b/dlls/windows.networking.hostname/tests/hostname.c @@ -48,6 +48,7 @@ static void check_interface_( unsigned int line, void *obj, const IID *iid ) static void test_HostnameStatics(void) { static const WCHAR *hostname_statics_name = L"Windows.Networking.HostName"; + IHostNameFactory *hostnamefactory; IActivationFactory *factory; HSTRING str; HRESULT hr; @@ -69,6 +70,11 @@ static void test_HostnameStatics(void) check_interface( factory, &IID_IInspectable ); check_interface( factory, &IID_IAgileObject );
+ hr = IActivationFactory_QueryInterface( factory, &IID_IHostNameFactory, (void **)&hostnamefactory ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + ref = IHostNameFactory_Release( hostnamefactory ); + ok( ref == 2, "got ref %ld.\n", ref ); ref = IActivationFactory_Release( factory ); ok( ref == 1, "got ref %ld.\n", ref ); }