From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/windows.ui/tests/uisettings.c | 22 +++++- dlls/windows.ui/uisettings.c | 120 ++++++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 3 deletions(-)
diff --git a/dlls/windows.ui/tests/uisettings.c b/dlls/windows.ui/tests/uisettings.c index 18603e53d46..24a3a809585 100644 --- a/dlls/windows.ui/tests/uisettings.c +++ b/dlls/windows.ui/tests/uisettings.c @@ -53,6 +53,8 @@ static void test_UISettings_Statics(void) { static const WCHAR *uisettings_name = L"Windows.UI.ViewManagement.UISettings"; IActivationFactory *factory; + IUISettings3 *uisettings3; + IInspectable *inspectable; HSTRING str; HRESULT hr; LONG ref; @@ -61,7 +63,6 @@ static void test_UISettings_Statics(void) 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) { @@ -73,6 +74,25 @@ static void test_UISettings_Statics(void) check_interface( factory, &IID_IInspectable, TRUE ); check_interface( factory, &IID_IAgileObject, FALSE );
+ hr = IActivationFactory_QueryInterface( factory, &IID_IUISettings3, (void **)&uisettings3 ); + ok( hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr ); + + hr = RoActivateInstance( str, &inspectable ); + ok( hr == S_OK, "Got unexpected hr %#lx.\n", hr ); + WindowsDeleteString( str ); + + hr = IInspectable_QueryInterface( inspectable, &IID_IUISettings3, (void **)&uisettings3 ); + ok( hr == S_OK || broken( hr == E_NOINTERFACE ), "Got unexpected hr %#lx.\n", hr ); + if (FAILED( hr )) + { + win_skip( "IUISettings3 not supported.\n" ); + goto skip_uisettings3; + } + + IUISettings3_Release( uisettings3 ); + +skip_uisettings3: + IInspectable_Release( inspectable ); ref = IActivationFactory_Release( factory ); ok( ref == 1, "got ref %ld.\n", ref ); } diff --git a/dlls/windows.ui/uisettings.c b/dlls/windows.ui/uisettings.c index 1ce1096d708..aa72c3567ad 100644 --- a/dlls/windows.ui/uisettings.c +++ b/dlls/windows.ui/uisettings.c @@ -23,6 +23,109 @@
WINE_DEFAULT_DEBUG_CHANNEL(ui);
+struct uisettings +{ + IUISettings3 IUISettings3_iface; + LONG ref; +}; + +static inline struct uisettings *impl_from_IUISettings3( IUISettings3 *iface ) +{ + return CONTAINING_RECORD( iface, struct uisettings, IUISettings3_iface ); +} + +static HRESULT WINAPI uisettings3_QueryInterface( IUISettings3 *iface, REFIID iid, void **out ) +{ + struct uisettings *impl = impl_from_IUISettings3( 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_IUISettings3)) + { + *out = &impl->IUISettings3_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 uisettings3_AddRef( IUISettings3 *iface ) +{ + struct uisettings *impl = impl_from_IUISettings3( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI uisettings3_Release( IUISettings3 *iface ) +{ + struct uisettings *impl = impl_from_IUISettings3( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + + TRACE( "iface %p, ref %lu.\n", iface, ref ); + + if (!ref) + free(impl); + + return ref; +} + +static HRESULT WINAPI uisettings3_GetIids( IUISettings3 *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 uisettings3_GetRuntimeClassName( IUISettings3 *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI uisettings3_GetTrustLevel( IUISettings3 *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI uisettings3_GetColorValue( IUISettings3 *iface, UIColorType type, Color *value ) +{ + FIXME( "iface %p, type %d, color %p stub!\n", iface, type, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI uisettings3_add_ColorValuesChanged( IUISettings3 *iface, ITypedEventHandler_UISettings_IInspectable *handler, EventRegistrationToken *cookie ) +{ + FIXME( "iface %p, handler %p, cookie %p stub!\n", iface, handler, cookie ); + return E_NOTIMPL; +} + +static HRESULT WINAPI uisettings3_remove_ColorValuesChanged( IUISettings3 *iface, EventRegistrationToken cookie ) +{ + FIXME( "iface %p, cookie %#I64x stub!\n", iface, cookie.value ); + return E_NOTIMPL; +} + +static const struct IUISettings3Vtbl uisettings3_vtbl = +{ + uisettings3_QueryInterface, + uisettings3_AddRef, + uisettings3_Release, + /* IInspectable methods */ + uisettings3_GetIids, + uisettings3_GetRuntimeClassName, + uisettings3_GetTrustLevel, + /* IUISettings3 methods */ + uisettings3_GetColorValue, + uisettings3_add_ColorValuesChanged, + uisettings3_remove_ColorValuesChanged, +}; + struct uisettings_statics { IActivationFactory IActivationFactory_iface; @@ -90,8 +193,21 @@ static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLev
static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { - FIXME( "iface %p, instance %p stub!\n", iface, instance ); - return E_NOTIMPL; + struct uisettings *impl; + + TRACE("iface %p, instance %p.\n", iface, instance); + + if (!(impl = calloc(1, sizeof(*impl)))) + { + *instance = NULL; + return E_OUTOFMEMORY; + } + + impl->IUISettings3_iface.lpVtbl = &uisettings3_vtbl; + impl->ref = 1; + + *instance = (IInspectable *)&impl->IUISettings3_iface; + return S_OK; }
static const struct IActivationFactoryVtbl factory_vtbl =