From: Vibhav Pant vibhavp@gmail.com
--- dlls/wintypes/propertyset.c | 126 +++++++++++++++++++++++++++++- dlls/wintypes/tests/propertyset.c | 2 +- 2 files changed, 124 insertions(+), 4 deletions(-)
diff --git a/dlls/wintypes/propertyset.c b/dlls/wintypes/propertyset.c index 55b97ad2d83..19c5b097347 100644 --- a/dlls/wintypes/propertyset.c +++ b/dlls/wintypes/propertyset.c @@ -28,6 +28,127 @@
WINE_DEFAULT_DEBUG_CHANNEL( wintypes );
+struct kvpair +{ + IKeyValuePair_HSTRING_IInspectable IKeyValuePair_HSTRING_IInspectable_iface; + LONG ref; +}; + +static inline struct kvpair * +impl_from_IKeyValuePair_HSTRING_IInspectable( IKeyValuePair_HSTRING_IInspectable *iface ) +{ + return CONTAINING_RECORD( iface, struct kvpair, IKeyValuePair_HSTRING_IInspectable_iface ); +} + +static HRESULT STDMETHODCALLTYPE kvpair_QueryInterface( IKeyValuePair_HSTRING_IInspectable *iface, + REFIID iid, void **out ) +{ + TRACE( "(%p, %p, %p)\n", iface, debugstr_guid( iid ), out ); + *out = NULL; + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IKeyValuePair_HSTRING_IInspectable )) + { + *out = iface; + IUnknown_AddRef( iface ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE kvpair_AddRef( IKeyValuePair_HSTRING_IInspectable *iface ) +{ + struct kvpair *impl; + + TRACE( "(%p)\n", iface ); + + impl = impl_from_IKeyValuePair_HSTRING_IInspectable( iface ); + return InterlockedIncrement( &impl->ref ); +} + +static ULONG STDMETHODCALLTYPE kvpair_Release( IKeyValuePair_HSTRING_IInspectable *iface ) +{ + struct kvpair *impl; + ULONG ref; + + TRACE( "(%p)\n", iface ); + + impl = impl_from_IKeyValuePair_HSTRING_IInspectable( iface ); + ref = InterlockedDecrement( &impl->ref ); + if (!ref) + free( impl ); + + return ref; +} + +static HRESULT STDMETHODCALLTYPE kvpair_GetIIDs( IKeyValuePair_HSTRING_IInspectable *iface, + ULONG *iid_count, IID **iids ) +{ + FIXME( "(%p, %p, %p) stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE +kvpair_GetRuntimeClassName( IKeyValuePair_HSTRING_IInspectable *iface, HSTRING *class_name ) +{ + FIXME( "(%p, %p) stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE kvpair_GetTrustLevel( IKeyValuePair_HSTRING_IInspectable *iface, + TrustLevel *trust_level ) +{ + FIXME( "(%p, %p) stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE kvpair_get_Key( IKeyValuePair_HSTRING_IInspectable *iface, + HSTRING *key ) +{ + FIXME( "(%p, %p) stub!\n", iface, key ); + *key = NULL; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE kvpair_get_Value( IKeyValuePair_HSTRING_IInspectable *iface, + IInspectable **value ) +{ + FIXME( "(%p, %p) stub!\n", iface, value ); + *value = NULL; + return E_NOTIMPL; +} + +const static IKeyValuePair_HSTRING_IInspectableVtbl kvpair_vtbl = +{ + kvpair_QueryInterface, + kvpair_AddRef, + kvpair_Release, + kvpair_GetIIDs, + kvpair_GetRuntimeClassName, + kvpair_GetTrustLevel, + kvpair_get_Key, + kvpair_get_Value, +}; + +static HRESULT kvpair_create( IKeyValuePair_HSTRING_IInspectable **kvpair ) +{ + struct kvpair *impl; + + TRACE( "(%p)\n", kvpair ); + + *kvpair = NULL; + impl = calloc( 1, sizeof( *impl ) ); + if (!impl) + return E_OUTOFMEMORY; + + impl->IKeyValuePair_HSTRING_IInspectable_iface.lpVtbl = &kvpair_vtbl; + impl->ref = 1; + *kvpair = &impl->IKeyValuePair_HSTRING_IInspectable_iface; + return S_OK; +} + struct iterator_kvpair_HSTRING_IInspectable { IIterator_IKeyValuePair_HSTRING_IInspectable IIterator_IKeyValuePair_HSTRING_IInspectable_iface; @@ -113,9 +234,8 @@ static HRESULT STDMETHODCALLTYPE iterator_kvpair_HSTRING_IInspectable_get_Current( IIterator_IKeyValuePair_HSTRING_IInspectable *iface, IKeyValuePair_HSTRING_IInspectable **kvpair ) { - FIXME( "(%p, %p) stub!\n", iface, kvpair ); - *kvpair = NULL; - return E_NOTIMPL; + FIXME( "(%p, %p) semi-stub!\n", iface, kvpair ); + return kvpair_create( kvpair ); }
static HRESULT STDMETHODCALLTYPE iterator_kvpair_HSTRING_IInspectable_HasCurrent( diff --git a/dlls/wintypes/tests/propertyset.c b/dlls/wintypes/tests/propertyset.c index a7a38d8ca4c..1a3725f8dbd 100644 --- a/dlls/wintypes/tests/propertyset.c +++ b/dlls/wintypes/tests/propertyset.c @@ -113,7 +113,7 @@ static void test_IPropertySet(void) if (SUCCEEDED( hr )) { hr = IIterable_IKeyValuePair_HSTRING_IInspectable_First( iterable, &iterator ); - todo_wine ok( SUCCEEDED( hr ), "got %#lx\n", hr ); + ok( SUCCEEDED( hr ), "got %#lx\n", hr ); if (SUCCEEDED( hr )) IIterator_IKeyValuePair_HSTRING_IInspectable_Release( iterator ); IIterable_IKeyValuePair_HSTRING_IInspectable_Release( iterable );