Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54699
I added the complete `windows.networking.idl` file since it was small and in case it's needed for mingw build.
-- v3: windows.networking.hostname: Implement IHostName::get_RawName().
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Needed by Windows.Networking.Connectivity.IPInformation. --- include/windows.foundation.idl | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/windows.foundation.idl b/include/windows.foundation.idl index d89541740a7..60b690401d6 100644 --- a/include/windows.foundation.idl +++ b/include/windows.foundation.idl @@ -86,6 +86,7 @@ namespace Windows.Foundation { interface Windows.Foundation.AsyncOperationCompletedHandler<boolean>; interface Windows.Foundation.IAsyncOperation<IInspectable *>; interface Windows.Foundation.IAsyncOperation<boolean>; + interface Windows.Foundation.IReference<BYTE>; interface Windows.Foundation.IReference<INT32>; interface Windows.Foundation.TypedEventHandler<IInspectable *, IInspectable *>; interface Windows.Foundation.TypedEventHandler<Windows.Foundation.IMemoryBufferReference *, IInspectable *>;
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Needed by Windows.Networking.HostName. --- include/Makefile.in | 1 + include/windows.networking.connectivity.idl | 66 +++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 include/windows.networking.connectivity.idl
diff --git a/include/Makefile.in b/include/Makefile.in index 48f43dfa372..dcce4b9bd41 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -833,6 +833,7 @@ SOURCES = \ windows.media.idl \ windows.media.speechrecognition.idl \ windows.media.speechsynthesis.idl \ + windows.networking.connectivity.idl \ windows.perception.spatial.idl \ windows.perception.spatial.surfaces.idl \ windows.security.credentials.idl \ diff --git a/include/windows.networking.connectivity.idl b/include/windows.networking.connectivity.idl new file mode 100644 index 00000000000..8c6489ba13b --- /dev/null +++ b/include/windows.networking.connectivity.idl @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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 + */ + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; +/* import "windows.networking.idl"; */ +import "windows.storage.streams.idl"; + +namespace Windows.Networking.Connectivity { + interface IIPInformation; + interface INetworkAdapter; + + runtimeclass IPInformation; + runtimeclass NetworkAdapter; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Networking.Connectivity.IPInformation), + uuid(d85145e0-138f-47d7-9b3a-36bb488cef33) + ] + interface IIPInformation : IInspectable + { + [propget] HRESULT NetworkAdapter([out, retval] Windows.Networking.Connectivity.NetworkAdapter **value); + [propget] HRESULT PrefixLength([out, retval] Windows.Foundation.IReference<BYTE> **value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile) + ] + runtimeclass IPInformation + { + [default] interface Windows.Networking.Connectivity.IIPInformation; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + ] + runtimeclass NetworkAdapter + { + [default] interface Windows.Networking.Connectivity.INetworkAdapter; + } +}
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- include/Makefile.in | 1 + include/windows.networking.idl | 173 +++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 include/windows.networking.idl
diff --git a/include/Makefile.in b/include/Makefile.in index dcce4b9bd41..e657f71b871 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -834,6 +834,7 @@ SOURCES = \ windows.media.speechrecognition.idl \ windows.media.speechsynthesis.idl \ windows.networking.connectivity.idl \ + windows.networking.idl \ windows.perception.spatial.idl \ windows.perception.spatial.surfaces.idl \ windows.security.credentials.idl \ diff --git a/include/windows.networking.idl b/include/windows.networking.idl new file mode 100644 index 00000000000..e864a3bb1ad --- /dev/null +++ b/include/windows.networking.idl @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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 + */ + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; +import "windows.networking.connectivity.idl"; + +namespace Windows.Networking { + typedef enum DomainNameType DomainNameType; + typedef enum HostNameSortOptions HostNameSortOptions; + typedef enum HostNameType HostNameType; + + interface IEndpointPair; + interface IEndpointPairFactory; + interface IHostName; + interface IHostNameFactory; + interface IHostNameStatics; + + runtimeclass EndpointPair; + runtimeclass HostName; + + declare { + interface Windows.Foundation.Collections.IIterable<Windows.Networking.EndpointPair *>; + interface Windows.Foundation.Collections.IIterable<Windows.Networking.HostName *>; + interface Windows.Foundation.Collections.IIterator<Windows.Networking.EndpointPair *>; + interface Windows.Foundation.Collections.IIterator<Windows.Networking.HostName *>; + interface Windows.Foundation.Collections.IVectorView<Windows.Networking.EndpointPair *>; + interface Windows.Foundation.Collections.IVectorView<Windows.Networking.HostName *>; + interface Windows.Foundation.Collections.IVector<Windows.Networking.HostName *>; + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Foundation.Collections.IVectorView<Windows.Networking.EndpointPair *> *>; + interface Windows.Foundation.IAsyncOperation<Windows.Foundation.Collections.IVectorView<Windows.Networking.EndpointPair *> *>; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum DomainNameType + { + Suffix = 0, + FullyQualified = 1, + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + flags + ] + enum HostNameSortOptions + { + None = 0x0, + OptimizeForLongConnections = 0x2, + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum HostNameType + { + DomainName = 0, + Ipv4 = 1, + Ipv6 = 2, + Bluetooth = 3, + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Networking.EndpointPair), + uuid(33a0aa36-f8fa-4b30-b856-76517c3bd06d) + ] + interface IEndpointPair : IInspectable + { + [propget] HRESULT LocalHostName([out, retval] Windows.Networking.HostName **value); + [propput] HRESULT LocalHostName([in] Windows.Networking.HostName *value); + [propget] HRESULT LocalServiceName([out, retval] HSTRING *value); + [propput] HRESULT LocalServiceName([in] HSTRING value); + [propget] HRESULT RemoteHostName([out, retval] Windows.Networking.HostName **value); + [propput] HRESULT RemoteHostName([in] Windows.Networking.HostName *value); + [propget] HRESULT RemoteServiceName([out, retval] HSTRING *value); + [propput] HRESULT RemoteServiceName([in] HSTRING value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Networking.EndpointPair), + uuid(b609d971-64e0-442b-aa6f-cc8c8f181f78) + ] + interface IEndpointPairFactory : IInspectable + { + HRESULT CreateEndpointPair([in] Windows.Networking.HostName *host, [in] HSTRING service, + [in] Windows.Networking.HostName *remote_host, [in] HSTRING remote_service, + [out, retval] Windows.Networking.EndpointPair **value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Networking.HostName), + uuid(bf8ecaad-ed96-49a7-9084-d416cae88dcb) + ] + interface IHostName : IInspectable + { + [propget] HRESULT IPInformation([out, retval] Windows.Networking.Connectivity.IPInformation **value); + [propget] HRESULT RawName([out, retval] HSTRING *value); + [propget] HRESULT DisplayName([out, retval] HSTRING *value); + [propget] HRESULT CanonicalName([out, retval] HSTRING *value); + [propget] HRESULT Type([out, retval] Windows.Networking.HostNameType *value); + HRESULT IsEqual([in] Windows.Networking.HostName *name, [out, retval] boolean *equal); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Networking.HostName), + uuid(458c23ed-712f-4576-adf1-c20b2c643558) + ] + interface IHostNameFactory : IInspectable + { + HRESULT CreateHostName([in] HSTRING name, [out, retval] Windows.Networking.HostName **value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Networking.HostName), + uuid(f68cd4bf-a388-4e8b-91ea-54dd6dd901c0) + ] + interface IHostNameStatics : IInspectable + { + HRESULT Compare([in] HSTRING value1, [in] HSTRING value2, [out, retval] INT32 *result); + } + + [ + activatable(Windows.Networking.IEndpointPairFactory, Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + threading(both) + ] + runtimeclass EndpointPair + { + [default] interface Windows.Networking.IEndpointPair; + } + + [ + activatable(Windows.Networking.IHostNameFactory, Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Networking.IHostNameStatics, Windows.Foundation.UniversalApiContract, 1.0), + threading(both) + ] + runtimeclass HostName + { + [default] interface Windows.Networking.IHostName; + [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.Foundation.IStringable; + } +}
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- configure.ac | 2 + dlls/windows.networking.hostname/Makefile.in | 9 ++ dlls/windows.networking.hostname/classes.idl | 23 ++++ dlls/windows.networking.hostname/hostname.c | 116 ++++++++++++++++++ dlls/windows.networking.hostname/main.c | 46 +++++++ dlls/windows.networking.hostname/private.h | 40 ++++++ .../tests/Makefile.in | 5 + .../tests/hostname.c | 87 +++++++++++++ .../windows.networking.hostname.spec | 12 ++ 9 files changed, 340 insertions(+) create mode 100644 dlls/windows.networking.hostname/Makefile.in create mode 100644 dlls/windows.networking.hostname/classes.idl create mode 100644 dlls/windows.networking.hostname/hostname.c create mode 100644 dlls/windows.networking.hostname/main.c create mode 100644 dlls/windows.networking.hostname/private.h create mode 100644 dlls/windows.networking.hostname/tests/Makefile.in create mode 100644 dlls/windows.networking.hostname/tests/hostname.c create mode 100644 dlls/windows.networking.hostname/windows.networking.hostname.spec
diff --git a/configure.ac b/configure.ac index 6e1b8250cc1..abc1a0ea910 100644 --- a/configure.ac +++ b/configure.ac @@ -3148,6 +3148,8 @@ WINE_CONFIG_MAKEFILE(dlls/windows.media.speech) WINE_CONFIG_MAKEFILE(dlls/windows.media.speech/tests) WINE_CONFIG_MAKEFILE(dlls/windows.media) WINE_CONFIG_MAKEFILE(dlls/windows.media/tests) +WINE_CONFIG_MAKEFILE(dlls/windows.networking.hostname) +WINE_CONFIG_MAKEFILE(dlls/windows.networking.hostname/tests) WINE_CONFIG_MAKEFILE(dlls/windows.networking) WINE_CONFIG_MAKEFILE(dlls/windows.perception.stub) WINE_CONFIG_MAKEFILE(dlls/windows.perception.stub/tests) diff --git a/dlls/windows.networking.hostname/Makefile.in b/dlls/windows.networking.hostname/Makefile.in new file mode 100644 index 00000000000..72ef78cc716 --- /dev/null +++ b/dlls/windows.networking.hostname/Makefile.in @@ -0,0 +1,9 @@ +MODULE = windows.networking.hostname.dll +IMPORTS = combase + +C_SRCS = \ + hostname.c \ + main.c + +IDL_SRCS = \ + classes.idl diff --git a/dlls/windows.networking.hostname/classes.idl b/dlls/windows.networking.hostname/classes.idl new file mode 100644 index 00000000000..bf04d3e88bc --- /dev/null +++ b/dlls/windows.networking.hostname/classes.idl @@ -0,0 +1,23 @@ +/* + * Runtime Classes for windows.networking.hostname.dll + * + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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 + */ + +#pragma makedep register + +#include "windows.networking.idl" diff --git a/dlls/windows.networking.hostname/hostname.c b/dlls/windows.networking.hostname/hostname.c new file mode 100644 index 00000000000..95c6f6387ae --- /dev/null +++ b/dlls/windows.networking.hostname/hostname.c @@ -0,0 +1,116 @@ +/* WinRT Windows.Networking.Hostname Hostname Implementation + * + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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(hostname); + +struct hostname +{ + IActivationFactory IActivationFactory_iface; + LONG ref; +}; + +static inline struct hostname *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct hostname, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct hostname *impl = impl_from_IActivationFactory( iface ); + + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IActivationFactory )) + { + *out = &impl->IActivationFactory_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +{ + struct hostname *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI factory_Release( IActivationFactory *iface ) +{ + struct hostname *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +{ + FIXME( "iface %p, instance %p stub!\n", iface, instance ); + return E_NOTIMPL; +} + +static const struct IActivationFactoryVtbl factory_vtbl = +{ + factory_QueryInterface, + factory_AddRef, + factory_Release, + /* IInspectable methods */ + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, + /* IActivationFactory methods */ + factory_ActivateInstance, +}; + +static struct hostname hostname_statics = +{ + {&factory_vtbl}, + 1, +}; + +IActivationFactory *hostname_factory = &hostname_statics.IActivationFactory_iface; diff --git a/dlls/windows.networking.hostname/main.c b/dlls/windows.networking.hostname/main.c new file mode 100644 index 00000000000..72ef6517b3d --- /dev/null +++ b/dlls/windows.networking.hostname/main.c @@ -0,0 +1,46 @@ +/* WinRT Windows.Networking.Hostname Implementation + * + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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 "initguid.h" +#include "private.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(hostname); + +HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID riid, void **out ) +{ + FIXME( "clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid), debugstr_guid(riid), out ); + return CLASS_E_CLASSNOTAVAILABLE; +} + +HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **factory ) +{ + const WCHAR *buffer = WindowsGetStringRawBuffer( classid, NULL ); + + TRACE( "class %s, factory %p.\n", debugstr_hstring(classid), factory ); + + *factory = NULL; + + if (!wcscmp( buffer, RuntimeClass_Windows_Networking_HostName )) + IActivationFactory_QueryInterface( hostname_factory, &IID_IActivationFactory, (void **)factory ); + + if (*factory) return S_OK; + return CLASS_E_CLASSNOTAVAILABLE; +} diff --git a/dlls/windows.networking.hostname/private.h b/dlls/windows.networking.hostname/private.h new file mode 100644 index 00000000000..98728895b90 --- /dev/null +++ b/dlls/windows.networking.hostname/private.h @@ -0,0 +1,40 @@ +/* WinRT Windows.Networking.Hostname Implementation + * + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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 + */ + +#ifndef __WINE_WINDOWS_NETWORKING_HOSTNAME_PRIVATE_H +#define __WINE_WINDOWS_NETWORKING_HOSTNAME_PRIVATE_H + +#include <stdarg.h> + +#define COBJMACROS +#include "windef.h" +#include "winbase.h" +#include "winstring.h" + +#include "activation.h" + +#define WIDL_using_Windows_Foundation +#define WIDL_using_Windows_Foundation_Collections +#include "windows.foundation.h" +#define WIDL_using_Windows_Networking +#include "windows.networking.h" + +extern IActivationFactory *hostname_factory; + +#endif diff --git a/dlls/windows.networking.hostname/tests/Makefile.in b/dlls/windows.networking.hostname/tests/Makefile.in new file mode 100644 index 00000000000..62c923a32aa --- /dev/null +++ b/dlls/windows.networking.hostname/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = windows.networking.hostname.dll +IMPORTS = combase + +C_SRCS = \ + hostname.c diff --git a/dlls/windows.networking.hostname/tests/hostname.c b/dlls/windows.networking.hostname/tests/hostname.c new file mode 100644 index 00000000000..4380b7992ba --- /dev/null +++ b/dlls/windows.networking.hostname/tests/hostname.c @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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 + */ +#define COBJMACROS +#include "initguid.h" +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "winstring.h" + +#include "roapi.h" + +#define WIDL_using_Windows_Foundation +#define WIDL_using_Windows_Foundation_Collections +#include "windows.foundation.h" +#define WIDL_using_Windows_Networking +#include "windows.networking.h" + +#include "wine/test.h" + +#define check_interface( obj, iid ) check_interface_( __LINE__, obj, iid ) +static void check_interface_( unsigned int line, void *obj, const IID *iid ) +{ + IUnknown *iface = obj; + IUnknown *unk; + HRESULT hr; + + hr = IUnknown_QueryInterface( iface, iid, (void **)&unk ); + ok_(__FILE__, line)( hr == S_OK, "got hr %#lx.\n", hr ); + IUnknown_Release( unk ); +} + +static void test_HostnameStatics(void) +{ + static const WCHAR *hostname_statics_name = L"Windows.Networking.HostName"; + IActivationFactory *factory; + HSTRING str; + HRESULT hr; + LONG ref; + + hr = WindowsCreateString( hostname_statics_name, wcslen( hostname_statics_name ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory ); + WindowsDeleteString( str ); + 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( hostname_statics_name ) ); + return; + } + + check_interface( factory, &IID_IUnknown ); + check_interface( factory, &IID_IInspectable ); + check_interface( factory, &IID_IAgileObject ); + + ref = IActivationFactory_Release( factory ); + ok( ref == 1, "got ref %ld.\n", ref ); +} + + +START_TEST(hostname) +{ + HRESULT hr; + + hr = RoInitialize( RO_INIT_MULTITHREADED ); + ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr ); + + test_HostnameStatics(); + + RoUninitialize(); +} diff --git a/dlls/windows.networking.hostname/windows.networking.hostname.spec b/dlls/windows.networking.hostname/windows.networking.hostname.spec new file mode 100644 index 00000000000..4be1deb9e48 --- /dev/null +++ b/dlls/windows.networking.hostname/windows.networking.hostname.spec @@ -0,0 +1,12 @@ +@ stub CreateEndpointPairFromSockAddrs +@ stub CreateHostNameFromSockAddr +@ stub CreateHostNameFromString +@ stub CreateNetworkAdapterFromGuid +@ stub GetAllHostNames +@ stub GetSortedEndpointPairs +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetActivationFactory(ptr ptr) +@ stdcall -private DllGetClassObject(ptr ptr ptr) +@ stdcall -private DllMain(long long ptr) +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer()
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/windows.networking.hostname/hostname.c | 58 +++++++++++++++++++++ dlls/windows.networking.hostname/private.h | 39 ++++++++++++++ 2 files changed, 97 insertions(+)
diff --git a/dlls/windows.networking.hostname/hostname.c b/dlls/windows.networking.hostname/hostname.c index 95c6f6387ae..4af9a42211e 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 { IActivationFactory IActivationFactory_iface; + IHostName IHostName_iface; LONG ref; };
@@ -107,9 +108,66 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
+DEFINE_IINSPECTABLE( hostname, IHostName, struct hostname, IActivationFactory_iface ) + +static HRESULT WINAPI hostname_get_IPInformation( IHostName *iface, IIPInformation **value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI hostname_get_RawName( IHostName *iface, HSTRING *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI hostname_get_DisplayName( IHostName *iface, HSTRING *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI hostname_get_CanonicalName( IHostName *iface, HSTRING *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI hostname_get_Type( IHostName *iface, HostNameType *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI hostname_IsEqual( IHostName *iface, IHostName *name, boolean *equal ) +{ + FIXME( "iface %p, name %p, equal %p stub!\n", iface, name, equal ); + return E_NOTIMPL; +} + +static const struct IHostNameVtbl hostname_vtbl = +{ + hostname_QueryInterface, + hostname_AddRef, + hostname_Release, + /* IInspectable methods */ + hostname_GetIids, + hostname_GetRuntimeClassName, + hostname_GetTrustLevel, + /* IHostName methods */ + hostname_get_IPInformation, + hostname_get_RawName, + hostname_get_DisplayName, + hostname_get_CanonicalName, + hostname_get_Type, + hostname_IsEqual, +}; + static struct hostname hostname_statics = { {&factory_vtbl}, + {&hostname_vtbl}, 1, };
diff --git a/dlls/windows.networking.hostname/private.h b/dlls/windows.networking.hostname/private.h index 98728895b90..a07690911c5 100644 --- a/dlls/windows.networking.hostname/private.h +++ b/dlls/windows.networking.hostname/private.h @@ -33,8 +33,47 @@ #define WIDL_using_Windows_Foundation_Collections #include "windows.foundation.h" #define WIDL_using_Windows_Networking +#define WIDL_using_Windows_Networking_Connectivity #include "windows.networking.h"
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
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/windows.networking.hostname/hostname.c | 30 +++++++++++++++++++ .../tests/hostname.c | 6 ++++ 2 files changed, 36 insertions(+)
diff --git a/dlls/windows.networking.hostname/hostname.c b/dlls/windows.networking.hostname/hostname.c index 4af9a42211e..0bf76664126 100644 --- a/dlls/windows.networking.hostname/hostname.c +++ b/dlls/windows.networking.hostname/hostname.c @@ -26,6 +26,7 @@ struct hostname { IActivationFactory IActivationFactory_iface; IHostName IHostName_iface; + IHostNameFactory IHostNameFactory_iface; LONG ref; };
@@ -50,6 +51,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; @@ -164,10 +172,32 @@ static const struct IHostNameVtbl hostname_vtbl = hostname_IsEqual, };
+DEFINE_IINSPECTABLE( hostnamefactory, IHostNameFactory, struct hostname, IActivationFactory_iface ) + +static HRESULT WINAPI hostnamefactory_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 hostnamefactory_vtbl = +{ + hostnamefactory_QueryInterface, + hostnamefactory_AddRef, + hostnamefactory_Release, + /* IInspectable methods */ + hostnamefactory_GetIids, + hostnamefactory_GetRuntimeClassName, + hostnamefactory_GetTrustLevel, + /* IHostNameFactory methods */ + hostnamefactory_CreateHostName, +}; + static struct hostname hostname_statics = { {&factory_vtbl}, {&hostname_vtbl}, + {&hostnamefactory_vtbl}, 1, };
diff --git a/dlls/windows.networking.hostname/tests/hostname.c b/dlls/windows.networking.hostname/tests/hostname.c index 4380b7992ba..e91eb8474a9 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 ); }
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- .../tests/hostname.c | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/dlls/windows.networking.hostname/tests/hostname.c b/dlls/windows.networking.hostname/tests/hostname.c index e91eb8474a9..f5abed5c8ad 100644 --- a/dlls/windows.networking.hostname/tests/hostname.c +++ b/dlls/windows.networking.hostname/tests/hostname.c @@ -48,10 +48,13 @@ 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"; + static const WCHAR *ip = L"192.168.0.0"; IHostNameFactory *hostnamefactory; IActivationFactory *factory; - HSTRING str; + HSTRING str, rawname; + IHostName *hostname; HRESULT hr; + INT32 res; LONG ref;
hr = WindowsCreateString( hostname_statics_name, wcslen( hostname_statics_name ), &str ); @@ -72,7 +75,29 @@ static void test_HostnameStatics(void)
hr = IActivationFactory_QueryInterface( factory, &IID_IHostNameFactory, (void **)&hostnamefactory ); ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = WindowsCreateString( ip, wcslen( ip ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + hr = IHostNameFactory_CreateHostName( hostnamefactory, NULL, &hostname ); + todo_wine ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr ); + hr = IHostNameFactory_CreateHostName( hostnamefactory, str, NULL ); + todo_wine ok( hr == E_POINTER, "got hr %#lx.\n", hr ); + hr = IHostNameFactory_CreateHostName( hostnamefactory, NULL, NULL ); + todo_wine ok( hr == E_POINTER, "got hr %#lx.\n", hr ); + hr = IHostNameFactory_CreateHostName( hostnamefactory, str, &hostname ); + todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); + todo_wine ok( hostname != NULL, "got NULL hostname %p.\n", hostname ); + + hr = IHostName_get_RawName( hostname, NULL ); + todo_wine ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr ); + hr = IHostName_get_RawName( hostname, &rawname ); + todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = WindowsCompareStringOrdinal( str, rawname, &res ); + todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); + todo_wine ok( !res, "got unexpected string %s.\n", debugstr_hstring(rawname) );
+ WindowsDeleteString( str ); + WindowsDeleteString( rawname ); ref = IHostNameFactory_Release( hostnamefactory ); ok( ref == 2, "got ref %ld.\n", ref ); ref = IActivationFactory_Release( factory );
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54699 --- dlls/windows.networking.hostname/hostname.c | 19 +++++++++++++++++-- .../tests/hostname.c | 10 +++++----- 2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/dlls/windows.networking.hostname/hostname.c b/dlls/windows.networking.hostname/hostname.c index 0bf76664126..39047982771 100644 --- a/dlls/windows.networking.hostname/hostname.c +++ b/dlls/windows.networking.hostname/hostname.c @@ -28,6 +28,8 @@ struct hostname IHostName IHostName_iface; IHostNameFactory IHostNameFactory_iface; LONG ref; + + HSTRING rawname; };
static inline struct hostname *impl_from_IActivationFactory( IActivationFactory *iface ) @@ -176,8 +178,21 @@ DEFINE_IINSPECTABLE( hostnamefactory, IHostNameFactory, struct hostname, IActiva
static HRESULT WINAPI hostnamefactory_CreateHostName( IHostNameFactory *iface, HSTRING name, IHostName **value ) { - FIXME( "iface %p, name %s, value %p stub!\n", iface, debugstr_hstring(name), value ); - return E_NOTIMPL; + struct hostname *impl; + + TRACE( "iface %p, name %s, value %p\n", iface, debugstr_hstring(name), value ); + + if (!value) return E_POINTER; + if (!name) return E_INVALIDARG; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; + + impl->IHostName_iface.lpVtbl = &hostname_vtbl; + impl->ref = 1; + impl->rawname = name; + + *value = &impl->IHostName_iface; + TRACE( "created IHostName %p.\n", *value ); + return S_OK; }
static const struct IHostNameFactoryVtbl hostnamefactory_vtbl = diff --git a/dlls/windows.networking.hostname/tests/hostname.c b/dlls/windows.networking.hostname/tests/hostname.c index f5abed5c8ad..b81fe2173b4 100644 --- a/dlls/windows.networking.hostname/tests/hostname.c +++ b/dlls/windows.networking.hostname/tests/hostname.c @@ -79,14 +79,14 @@ static void test_HostnameStatics(void) ok( hr == S_OK, "got hr %#lx.\n", hr );
hr = IHostNameFactory_CreateHostName( hostnamefactory, NULL, &hostname ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr ); hr = IHostNameFactory_CreateHostName( hostnamefactory, str, NULL ); - todo_wine ok( hr == E_POINTER, "got hr %#lx.\n", hr ); + ok( hr == E_POINTER, "got hr %#lx.\n", hr ); hr = IHostNameFactory_CreateHostName( hostnamefactory, NULL, NULL ); - todo_wine ok( hr == E_POINTER, "got hr %#lx.\n", hr ); + ok( hr == E_POINTER, "got hr %#lx.\n", hr ); hr = IHostNameFactory_CreateHostName( hostnamefactory, str, &hostname ); - todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); - todo_wine ok( hostname != NULL, "got NULL hostname %p.\n", hostname ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + ok( hostname != NULL, "got NULL hostname %p.\n", hostname );
hr = IHostName_get_RawName( hostname, NULL ); todo_wine ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr );
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/windows.networking.hostname/hostname.c | 8 ++++++-- dlls/windows.networking.hostname/tests/hostname.c | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/dlls/windows.networking.hostname/hostname.c b/dlls/windows.networking.hostname/hostname.c index 39047982771..97bdd9b6ccd 100644 --- a/dlls/windows.networking.hostname/hostname.c +++ b/dlls/windows.networking.hostname/hostname.c @@ -128,8 +128,12 @@ static HRESULT WINAPI hostname_get_IPInformation( IHostName *iface, IIPInformati
static HRESULT WINAPI hostname_get_RawName( IHostName *iface, HSTRING *value ) { - FIXME( "iface %p, value %p stub!\n", iface, value ); - return E_NOTIMPL; + struct hostname *impl = impl_from_IHostName( iface ); + + TRACE( "iface %p, value %p.\n", iface, value ); + + if (!value) return E_INVALIDARG; + return WindowsDuplicateString( impl->rawname, value ); }
static HRESULT WINAPI hostname_get_DisplayName( IHostName *iface, HSTRING *value ) diff --git a/dlls/windows.networking.hostname/tests/hostname.c b/dlls/windows.networking.hostname/tests/hostname.c index b81fe2173b4..e37c957a7a0 100644 --- a/dlls/windows.networking.hostname/tests/hostname.c +++ b/dlls/windows.networking.hostname/tests/hostname.c @@ -89,12 +89,12 @@ static void test_HostnameStatics(void) ok( hostname != NULL, "got NULL hostname %p.\n", hostname );
hr = IHostName_get_RawName( hostname, NULL ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr ); + ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr ); hr = IHostName_get_RawName( hostname, &rawname ); - todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); hr = WindowsCompareStringOrdinal( str, rawname, &res ); - todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); - todo_wine ok( !res, "got unexpected string %s.\n", debugstr_hstring(rawname) ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + ok( !res, "got unexpected string %s.\n", debugstr_hstring(rawname) );
WindowsDeleteString( str ); WindowsDeleteString( rawname );
**v3:** - Remove `stub!` from the `TRACE` in `IHostName::get_RawName()`.
Rémi Bernon (@rbernon) commented about dlls/windows.networking.hostname/hostname.c:
hostname_IsEqual,
};
+DEFINE_IINSPECTABLE( hostnamefactory, IHostNameFactory, struct hostname, IActivationFactory_iface )
Fwiw I often find that converting camel case to snake case more directly gives more readable and consistent results. For instance that would be `host_name` and `host_name_factory` (eventually cutting off some components if the names gets too long). Not a big deal though but feel free to make an update if you like.
Rémi Bernon (@rbernon) commented about dlls/windows.networking.hostname/hostname.c:
- 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(hostname);
+struct hostname +{
- IActivationFactory IActivationFactory_iface;
- LONG ref;
+};
This would be the `statics` part of the class, so it should be named `<class>_statics` and will only include the static interfaces.
Rémi Bernon (@rbernon) commented about dlls/windows.networking.hostname/hostname.c:
struct hostname { IActivationFactory IActivationFactory_iface;
- IHostName IHostName_iface; LONG ref;
};
If you add a test you will see that the `IActivationFactory` object doesn't implement `IHostName`, so it would be a separate struct. I think it should be added at the same time you implement `CreateHostName` as it is what will create instances of it.