From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- .../network_information.c | 84 +++++++++++++++++++ .../windows.networking.connectivity/private.h | 40 +++++++++ .../tests/connectivity.c | 6 ++ 3 files changed, 130 insertions(+)
diff --git a/dlls/windows.networking.connectivity/network_information.c b/dlls/windows.networking.connectivity/network_information.c index 62b5f3680f1..2e203cea88e 100644 --- a/dlls/windows.networking.connectivity/network_information.c +++ b/dlls/windows.networking.connectivity/network_information.c @@ -21,9 +21,12 @@
WINE_DEFAULT_DEBUG_CHANNEL(connectivity);
+static EventRegistrationToken dummy_cookie = {.value = 0xdeadbeef}; + struct network_information_statics { IActivationFactory IActivationFactory_iface; + INetworkInformationStatics INetworkInformationStatics_iface; LONG ref; };
@@ -48,6 +51,13 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_INetworkInformationStatics )) + { + *out = &impl->INetworkInformationStatics_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -106,9 +116,83 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
+DEFINE_IINSPECTABLE( network_information_statics, INetworkInformationStatics, struct network_information_statics, IActivationFactory_iface ) + +static HRESULT WINAPI network_information_statics_GetConnectionProfiles( INetworkInformationStatics *iface, IVectorView_ConnectionProfile **value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI network_information_statics_GetInternetConnectionProfile( INetworkInformationStatics *iface, IConnectionProfile **value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI network_information_statics_GetLanIdentifiers( INetworkInformationStatics *iface, IVectorView_LanIdentifier **value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI network_information_statics_GetHostNames( INetworkInformationStatics *iface, IVectorView_HostName **value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI network_information_statics_GetProxyConfigurationAsync( INetworkInformationStatics *iface, IUriRuntimeClass *uri, IAsyncOperation_ProxyConfiguration **value ) +{ + FIXME( "iface %p, uri %p, value %p stub!\n", iface, uri, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI network_information_statics_GetSortedEndpointPairs( INetworkInformationStatics *iface, IIterable_EndpointPair *endpoint, + HostNameSortOptions options, IVectorView_EndpointPair **value ) +{ + FIXME( "iface %p, endpoint %p, options %d, value %p stub!\n", iface, endpoint, options, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI network_information_statics_add_NetworkStatusChanged( INetworkInformationStatics *iface, INetworkStatusChangedEventHandler *handler, + EventRegistrationToken *cookie ) +{ + FIXME( "iface %p, handler %p, cookie %p stub!\n", iface, handler, cookie ); + *cookie = dummy_cookie; + return S_OK; +} + +static HRESULT WINAPI network_information_statics_remove_NetworkStatusChanged( INetworkInformationStatics *iface, EventRegistrationToken cookie ) +{ + FIXME( "iface %p, cookie %#I64x stub!\n", iface, cookie.value ); + return S_OK; +} + +static const struct INetworkInformationStaticsVtbl network_information_statics_vtbl = +{ + network_information_statics_QueryInterface, + network_information_statics_AddRef, + network_information_statics_Release, + /* IInspectable methods */ + network_information_statics_GetIids, + network_information_statics_GetRuntimeClassName, + network_information_statics_GetTrustLevel, + /* INetworkInformationStatics methods */ + network_information_statics_GetConnectionProfiles, + network_information_statics_GetInternetConnectionProfile, + network_information_statics_GetLanIdentifiers, + network_information_statics_GetHostNames, + network_information_statics_GetProxyConfigurationAsync, + network_information_statics_GetSortedEndpointPairs, + network_information_statics_add_NetworkStatusChanged, + network_information_statics_remove_NetworkStatusChanged, +}; + static struct network_information_statics network_information_statics = { {&factory_vtbl}, + {&network_information_statics_vtbl}, 1, };
diff --git a/dlls/windows.networking.connectivity/private.h b/dlls/windows.networking.connectivity/private.h index 0055b143d4f..9cff12a6cc6 100644 --- a/dlls/windows.networking.connectivity/private.h +++ b/dlls/windows.networking.connectivity/private.h @@ -34,9 +34,49 @@ #define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Foundation_Collections #include "windows.foundation.h" +#define WIDL_using_Windows_Networking #define WIDL_using_Windows_Networking_Connectivity #include "windows.networking.connectivity.h" +#include "windows.networking.h"
extern IActivationFactory *network_information_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.connectivity/tests/connectivity.c b/dlls/windows.networking.connectivity/tests/connectivity.c index 83bd13ff0e4..b49d2ca3a19 100644 --- a/dlls/windows.networking.connectivity/tests/connectivity.c +++ b/dlls/windows.networking.connectivity/tests/connectivity.c @@ -48,6 +48,7 @@ static void check_interface_( unsigned int line, void *obj, const IID *iid ) static void test_NetworkInformationStatics(void) { static const WCHAR *network_information_statics_name = L"Windows.Networking.Connectivity.NetworkInformation"; + INetworkInformationStatics *network_information_statics; IActivationFactory *factory; HSTRING str; HRESULT hr; @@ -69,6 +70,11 @@ static void test_NetworkInformationStatics(void) check_interface( factory, &IID_IInspectable ); check_interface( factory, &IID_IAgileObject );
+ hr = IActivationFactory_QueryInterface( factory, &IID_INetworkInformationStatics, (void **)&network_information_statics ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + ref = INetworkInformationStatics_Release( network_information_statics ); + ok( ref == 2, "got ref %ld.\n", ref ); ref = IActivationFactory_Release( factory ); ok( ref == 1, "got ref %ld.\n", ref ); }