From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56106 --- dlls/windows.storage/classes.idl | 1 + dlls/windows.storage/private.h | 40 ++++++++++++++++++ dlls/windows.storage/streams.c | 47 +++++++++++++++++++++ dlls/windows.storage/tests/storage.c | 6 +++ include/windows.storage.streams.idl | 61 ++++++++++++++++------------ 5 files changed, 130 insertions(+), 25 deletions(-)
diff --git a/dlls/windows.storage/classes.idl b/dlls/windows.storage/classes.idl index 0fca4cd1269..8a7be135572 100644 --- a/dlls/windows.storage/classes.idl +++ b/dlls/windows.storage/classes.idl @@ -20,4 +20,5 @@
#pragma makedep register
+#define _WINDOWS_STORAGE #include "windows.storage.streams.idl" diff --git a/dlls/windows.storage/private.h b/dlls/windows.storage/private.h index cf8307d8980..62c9d226d07 100644 --- a/dlls/windows.storage/private.h +++ b/dlls/windows.storage/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_Storage #define WIDL_using_Windows_Storage_Streams +#include "windows.storage.h" #include "windows.storage.streams.h"
extern IActivationFactory *random_access_stream_reference_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.storage/streams.c b/dlls/windows.storage/streams.c index b82b760e5e7..d8fddedd34d 100644 --- a/dlls/windows.storage/streams.c +++ b/dlls/windows.storage/streams.c @@ -24,6 +24,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage); struct random_access_stream_reference_statics { IActivationFactory IActivationFactory_iface; + IRandomAccessStreamReferenceStatics IRandomAccessStreamReferenceStatics_iface; LONG ref; };
@@ -48,6 +49,13 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IRandomAccessStreamReferenceStatics )) + { + *out = &impl->IRandomAccessStreamReferenceStatics_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 +114,48 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
+DEFINE_IINSPECTABLE( random_access_stream_reference_statics, IRandomAccessStreamReferenceStatics, struct random_access_stream_reference_statics, IActivationFactory_iface ) + +static HRESULT WINAPI random_access_stream_reference_statics_CreateFromFile( IRandomAccessStreamReferenceStatics *iface, IStorageFile *file, + IRandomAccessStreamReference **stream_reference ) +{ + FIXME( "iface %p, file %p, stream_reference %p stub!\n", iface, file, stream_reference ); + return E_NOTIMPL; +} + +static HRESULT WINAPI random_access_stream_reference_statics_CreateFromUri( IRandomAccessStreamReferenceStatics *iface, IUriRuntimeClass *uri, + IRandomAccessStreamReference **stream_reference ) +{ + FIXME( "iface %p, uri %p, stream_reference %p stub!\n", iface, uri, stream_reference ); + return E_NOTIMPL; +} + +static HRESULT WINAPI random_access_stream_reference_statics_CreateFromStream( IRandomAccessStreamReferenceStatics *iface, IRandomAccessStream *stream, + IRandomAccessStreamReference **stream_reference ) +{ + FIXME( "iface %p, stream %p, stream_reference %p stub!\n", iface, stream, stream_reference ); + return E_NOTIMPL; +} + +static const struct IRandomAccessStreamReferenceStaticsVtbl random_access_stream_reference_statics_vtbl = +{ + random_access_stream_reference_statics_QueryInterface, + random_access_stream_reference_statics_AddRef, + random_access_stream_reference_statics_Release, + /* IInspectable methods */ + random_access_stream_reference_statics_GetIids, + random_access_stream_reference_statics_GetRuntimeClassName, + random_access_stream_reference_statics_GetTrustLevel, + /* IRandomAccessStreamReferenceStatics methods */ + random_access_stream_reference_statics_CreateFromFile, + random_access_stream_reference_statics_CreateFromUri, + random_access_stream_reference_statics_CreateFromStream, +}; + static struct random_access_stream_reference_statics random_access_stream_reference_statics = { {&factory_vtbl}, + {&random_access_stream_reference_statics_vtbl}, 0, };
diff --git a/dlls/windows.storage/tests/storage.c b/dlls/windows.storage/tests/storage.c index 769b9ddf74e..be928411d81 100644 --- a/dlls/windows.storage/tests/storage.c +++ b/dlls/windows.storage/tests/storage.c @@ -49,6 +49,7 @@ static void check_interface_( unsigned int line, void *obj, const IID *iid, BOOL static void test_RandomAccessStreamReference(void) { static const WCHAR *random_access_stream_reference_statics_name = L"Windows.Storage.Streams.RandomAccessStreamReference"; + IRandomAccessStreamReferenceStatics *random_access_stream_reference_statics = (void *)0xdeadbeef; IActivationFactory *factory = (void *)0xdeadbeef; HSTRING str = NULL; HRESULT hr; @@ -69,6 +70,11 @@ static void test_RandomAccessStreamReference(void) check_interface( factory, &IID_IInspectable, FALSE ); check_interface( factory, &IID_IAgileObject, TRUE /* Supported after Windows 10 1607 */ );
+ hr = IActivationFactory_QueryInterface( factory, &IID_IRandomAccessStreamReferenceStatics, (void **)&random_access_stream_reference_statics ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + ref = IRandomAccessStreamReferenceStatics_Release( random_access_stream_reference_statics ); + ok( ref == 1, "got ref %ld.\n", ref ); ref = IActivationFactory_Release( factory ); ok( ref == 0, "got ref %ld.\n", ref ); } diff --git a/include/windows.storage.streams.idl b/include/windows.storage.streams.idl index 22e4c63c9b9..6c0dde02f5c 100644 --- a/include/windows.storage.streams.idl +++ b/include/windows.storage.streams.idl @@ -50,11 +50,18 @@ namespace Windows.Storage.Streams { runtimeclass Buffer; runtimeclass DataWriter; runtimeclass DataWriterStoreOperation; +#ifndef _WINTYPES runtimeclass InMemoryRandomAccessStream; runtimeclass RandomAccessStream; runtimeclass RandomAccessStreamReference; +#endif
declare { + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IBuffer *>; + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IOutputStream *>; + interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IBuffer *>; + interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IOutputStream *>; +#ifndef _WINTYPES interface Windows.Foundation.Collections.IIterable<Windows.Storage.Streams.IRandomAccessStream *>; interface Windows.Foundation.Collections.IIterator<Windows.Storage.Streams.IRandomAccessStream *>; interface Windows.Foundation.Collections.IMapView<HSTRING, Windows.Storage.Streams.RandomAccessStreamReference *>; @@ -62,19 +69,16 @@ namespace Windows.Storage.Streams { interface Windows.Foundation.Collections.IVectorView<Windows.Storage.Streams.IRandomAccessStream *>; interface Windows.Foundation.Collections.IVector<Windows.Storage.Streams.IRandomAccessStream *>; interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Foundation.Collections.IMapView<HSTRING, Windows.Storage.Streams.RandomAccessStreamReference *> *>; - interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IBuffer *>; - interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IOutputStream *>; interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IRandomAccessStream *>; interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IRandomAccessStreamReference *>; interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IRandomAccessStreamWithContentType *>; interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.RandomAccessStreamReference *>; interface Windows.Foundation.IAsyncOperation<Windows.Foundation.Collections.IMapView<HSTRING, Windows.Storage.Streams.RandomAccessStreamReference *> *>; - interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IBuffer *>; - interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IOutputStream *>; interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IRandomAccessStream *>; interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IRandomAccessStreamReference *>; interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IRandomAccessStreamWithContentType *>; interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.RandomAccessStreamReference *>; +#endif }
[ @@ -191,6 +195,7 @@ namespace Windows.Storage.Streams { HRESULT FlushAsync([out, retval] Windows.Foundation.IAsyncOperation<boolean> **operation); }
+#ifndef _WINTYPES [ contract(Windows.Foundation.UniversalApiContract, 1.0), uuid(905a0fe1-bc53-11df-8c49-001e4fc686da), @@ -250,61 +255,65 @@ namespace Windows.Storage.Streams { Windows.Storage.Streams.IContentTypeProvider { } +#endif
+#ifndef _WINDOWS_STORAGE [ + activatable(Windows.Storage.Streams.IBufferFactory, Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0), marshaling_behavior(agile), - static(Windows.Storage.Streams.IRandomAccessStreamStatics, Windows.Foundation.UniversalApiContract, 1.0) + static(Windows.Storage.Streams.IBufferStatics, Windows.Foundation.UniversalApiContract, 1.0), + threading(both) ] - runtimeclass RandomAccessStream + runtimeclass Buffer { + [default] interface Windows.Storage.Streams.IBuffer; }
[ activatable(Windows.Foundation.UniversalApiContract, 1.0), + activatable(Windows.Storage.Streams.IDataWriterFactory, Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0), - marshaling_behavior(agile) + marshaling_behavior(agile), + threading(both) ] - runtimeclass InMemoryRandomAccessStream + runtimeclass DataWriter { - [default] interface Windows.Storage.Streams.IRandomAccessStream; - interface Windows.Storage.Streams.IOutputStream; + [default] interface Windows.Storage.Streams.IDataWriter; interface Windows.Foundation.IClosable; - interface Windows.Storage.Streams.IInputStream; }
[ - activatable(Windows.Storage.Streams.IBufferFactory, Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0), - marshaling_behavior(agile), - static(Windows.Storage.Streams.IBufferStatics, Windows.Foundation.UniversalApiContract, 1.0), - threading(both) + marshaling_behavior(agile) ] - runtimeclass Buffer + runtimeclass DataWriterStoreOperation { - [default] interface Windows.Storage.Streams.IBuffer; + [default] interface Windows.Foundation.IAsyncOperation<UINT32>; } +#endif
+#ifndef _WINTYPES [ activatable(Windows.Foundation.UniversalApiContract, 1.0), - activatable(Windows.Storage.Streams.IDataWriterFactory, Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0), - marshaling_behavior(agile), - threading(both) + marshaling_behavior(agile) ] - runtimeclass DataWriter + runtimeclass InMemoryRandomAccessStream { - [default] interface Windows.Storage.Streams.IDataWriter; + [default] interface Windows.Storage.Streams.IRandomAccessStream; + interface Windows.Storage.Streams.IOutputStream; interface Windows.Foundation.IClosable; + interface Windows.Storage.Streams.IInputStream; }
[ contract(Windows.Foundation.UniversalApiContract, 1.0), - marshaling_behavior(agile) + marshaling_behavior(agile), + static(Windows.Storage.Streams.IRandomAccessStreamStatics, Windows.Foundation.UniversalApiContract, 1.0) ] - runtimeclass DataWriterStoreOperation + runtimeclass RandomAccessStream { - [default] interface Windows.Foundation.IAsyncOperation<UINT32>; }
[ @@ -316,4 +325,6 @@ namespace Windows.Storage.Streams { { [default] interface Windows.Storage.Streams.IRandomAccessStreamReference; } +#endif + }