From: Julian Klemann jklemann@codeweavers.com
Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=53328 --- dlls/windows.devices.enumeration/main.c | 135 +++++++++++++++++++++--- include/windows.devices.enumeration.idl | 68 ++++++++++++ 2 files changed, 186 insertions(+), 17 deletions(-)
diff --git a/dlls/windows.devices.enumeration/main.c b/dlls/windows.devices.enumeration/main.c index b5cc5b63e14..b6cab670bce 100644 --- a/dlls/windows.devices.enumeration/main.c +++ b/dlls/windows.devices.enumeration/main.c @@ -1,6 +1,7 @@ /* WinRT Windows.Devices.Enumeration implementation * * Copyright 2021 Gijs Vermeulen + * Copyright 2022 Julian Klemann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -35,6 +36,46 @@ #define WIDL_using_Windows_Devices_Enumeration #include "windows.devices.enumeration.h"
+#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 ) +#define DEFINE_IINSPECTABLE_OUTER( pfx, iface_type, impl_type, outer_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, impl->outer_iface ) + WINE_DEFAULT_DEBUG_CHANNEL(enumeration);
static const char *debugstr_hstring(HSTRING hstr) @@ -49,6 +90,7 @@ static const char *debugstr_hstring(HSTRING hstr) struct windows_devices_enumeration { IActivationFactory IActivationFactory_iface; + IDeviceInformationStatics2 IDeviceInformationStatics2_iface; LONG ref; };
@@ -57,18 +99,24 @@ static inline struct windows_devices_enumeration *impl_from_IActivationFactory(I return CONTAINING_RECORD(iface, struct windows_devices_enumeration, IActivationFactory_iface); }
-static HRESULT WINAPI windows_devices_enumeration_QueryInterface( +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out) { + struct windows_devices_enumeration *impl = impl_from_IActivationFactory(iface); + TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IInspectable) || - IsEqualGUID(iid, &IID_IAgileObject) || IsEqualGUID(iid, &IID_IActivationFactory)) { - IUnknown_AddRef(iface); - *out = iface; + IInspectable_AddRef((*out = &impl->IActivationFactory_iface)); + return S_OK; + } + + if (IsEqualGUID(iid, &IID_IDeviceInformationStatics2)) + { + IInspectable_AddRef((*out = &impl->IDeviceInformationStatics2_iface)); return S_OK; }
@@ -77,7 +125,7 @@ static HRESULT WINAPI windows_devices_enumeration_QueryInterface( return E_NOINTERFACE; }
-static ULONG WINAPI windows_devices_enumeration_AddRef( +static ULONG WINAPI factory_AddRef( IActivationFactory *iface) { struct windows_devices_enumeration *impl = impl_from_IActivationFactory(iface); @@ -86,7 +134,7 @@ static ULONG WINAPI windows_devices_enumeration_AddRef( return ref; }
-static ULONG WINAPI windows_devices_enumeration_Release( +static ULONG WINAPI factory_Release( IActivationFactory *iface) { struct windows_devices_enumeration *impl = impl_from_IActivationFactory(iface); @@ -95,28 +143,28 @@ static ULONG WINAPI windows_devices_enumeration_Release( return ref; }
-static HRESULT WINAPI windows_devices_enumeration_GetIids( +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 windows_devices_enumeration_GetRuntimeClassName( +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 windows_devices_enumeration_GetTrustLevel( +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 windows_devices_enumeration_ActivateInstance( +static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance) { FIXME("iface %p, instance %p stub!\n", iface, instance); @@ -125,20 +173,73 @@ static HRESULT WINAPI windows_devices_enumeration_ActivateInstance(
static const struct IActivationFactoryVtbl activation_factory_vtbl = { - windows_devices_enumeration_QueryInterface, - windows_devices_enumeration_AddRef, - windows_devices_enumeration_Release, + factory_QueryInterface, + factory_AddRef, + factory_Release, /* IInspectable methods */ - windows_devices_enumeration_GetIids, - windows_devices_enumeration_GetRuntimeClassName, - windows_devices_enumeration_GetTrustLevel, + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, /* IActivationFactory methods */ - windows_devices_enumeration_ActivateInstance, + factory_ActivateInstance, +}; + +DEFINE_IINSPECTABLE(device_statics2, IDeviceInformationStatics2, struct windows_devices_enumeration, IActivationFactory_iface); + +static HRESULT WINAPI device_statics2_GetAqsFilterFromDeviceClass( + IDeviceInformationStatics2 *iface, DeviceClass deviceClass, HSTRING *aqsFilter) +{ + FIXME("iface %p, deviceClass %u, aqsFilter %p stub!\n", iface, deviceClass, aqsFilter); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_statics2_CreateFromIdAsync( + IDeviceInformationStatics2 *iface, HSTRING deviceId, IIterable_HSTRING *additionalProperties, + DeviceInformationKind kind, IAsyncOperation_DeviceInformation **asyncOperation) +{ + FIXME("iface %p, deviceId %s, additionalProperties %p, kind %u, asyncOperation %p stub!\n", + iface, debugstr_hstring(deviceId), additionalProperties, kind, asyncOperation); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_statics2_FindAllAsync( + IDeviceInformationStatics2 *iface, HSTRING filter, IIterable_HSTRING *additionalProperties, + DeviceInformationKind kind, IAsyncOperation_DeviceInformationCollection **asyncOperation) +{ + FIXME("iface %p, filter %s, additionalProperties %p, kind %u, asyncOperation %p stub!\n", + iface, debugstr_hstring(filter), additionalProperties, kind, asyncOperation); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_statics2_CreateWatcher( + IDeviceInformationStatics2 *iface, HSTRING filter, IIterable_HSTRING *additionalProperties, + DeviceInformationKind kind, IDeviceWatcher **watcher) +{ + FIXME("iface %p, filter %s, additionalProperties %p, kind %u, watcher %p stub!\n", + iface, debugstr_hstring(filter), additionalProperties, kind, watcher); + return E_NOTIMPL; +} + +static const struct IDeviceInformationStatics2Vtbl device_statics2_vtbl = +{ + device_statics2_QueryInterface, + device_statics2_AddRef, + device_statics2_Release, + /* IInspectable methods */ + device_statics2_GetIids, + device_statics2_GetRuntimeClassName, + device_statics2_GetTrustLevel, + /* IDeviceInformationStatics2 methods */ + device_statics2_GetAqsFilterFromDeviceClass, + device_statics2_CreateFromIdAsync, + device_statics2_FindAllAsync, + device_statics2_CreateWatcher };
static struct windows_devices_enumeration windows_devices_enumeration = { {&activation_factory_vtbl}, + {&device_statics2_vtbl}, 1 };
diff --git a/include/windows.devices.enumeration.idl b/include/windows.devices.enumeration.idl index f47df3795fa..a7cab7aba3d 100644 --- a/include/windows.devices.enumeration.idl +++ b/include/windows.devices.enumeration.idl @@ -28,6 +28,8 @@ import "windows.storage.streams.idl"; import "windows.foundation.idl";
namespace Windows.Devices.Enumeration { + typedef enum DeviceClass DeviceClass; + typedef enum DeviceInformationKind DeviceInformationKind; typedef enum DeviceWatcherStatus DeviceWatcherStatus; typedef enum Panel Panel;
@@ -38,6 +40,7 @@ namespace Windows.Devices.Enumeration { interface IEnclosureLocation;
runtimeclass DeviceInformation; + runtimeclass DeviceInformationCollection; runtimeclass DeviceInformationUpdate; runtimeclass DeviceThumbnail; runtimeclass DeviceWatcher; @@ -46,9 +49,11 @@ namespace Windows.Devices.Enumeration { declare { interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Devices.Enumeration.DeviceInformation *>; + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Devices.Enumeration.DeviceInformationCollection *>; interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Devices.Enumeration.DeviceThumbnail *>; interface Windows.Foundation.Collections.IMapView<HSTRING, IInspectable *>; interface Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceInformation *>; + interface Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceInformationCollection *>; interface Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceThumbnail *>; interface Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *, IInspectable *>; interface Windows.Foundation.TypedEventHandler<Windows.Devices.Enumeration.DeviceWatcher *, Windows.Devices.Enumeration.DeviceInformation *>; @@ -57,6 +62,35 @@ namespace Windows.Devices.Enumeration { }
namespace Windows.Devices.Enumeration { + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + enum DeviceClass + { + All = 0, + AudioCapture = 1, + AudioRender = 2, + PortableStorageDevice = 3, + VideoCapture = 4, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + ImageScanner = 5, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + Location = 6 + }; + + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + enum DeviceInformationKind + { + Unknown = 0, + DeviceInterface = 1, + DeviceContainer = 2, + Device = 3, + DeviceInterfaceClass = 4, + AssociationEndpoint = 5, + AssociationEndpointContainer = 6, + AssociationEndpointService = 7, + [contract(Windows.Foundation.UniversalApiContract, 7.0)] + DevicePanel = 8 + }; + enum DeviceWatcherStatus { Created = 0, @@ -142,6 +176,28 @@ namespace Windows.Devices.Enumeration { [propget] HRESULT Panel([out, retval] Windows.Devices.Enumeration.Panel *value); }
+ [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Devices.Enumeration.DeviceInformation), + uuid(493b4f34-a84f-45fd-9167-15d1cb1bd1f9) + ] + interface IDeviceInformationStatics2 : IInspectable + { + HRESULT GetAqsFilterFromDeviceClass([in] Windows.Devices.Enumeration.DeviceClass deviceClass, [out, retval] HSTRING *filter); + [overload("CreateFromIdAsync")] HRESULT CreateFromIdAsyncWithKindAndAdditionalProperties([in] HSTRING deviceId, + [in] Windows.Foundation.Collections.IIterable<HSTRING> *additionalProperties, + [in] Windows.Devices.Enumeration.DeviceInformationKind kind, + [out, retval] Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceInformation *> **asyncOperation); + [overload("FindAllAsync")] HRESULT FindAllAsyncWithKindAqsFilterAndAdditionalProperties([in] HSTRING filter, + [in] Windows.Foundation.Collections.IIterable<HSTRING> *additionalProperties, + [in] Windows.Devices.Enumeration.DeviceInformationKind kind, + [out, retval] Windows.Foundation.IAsyncOperation<Windows.Devices.Enumeration.DeviceInformationCollection *> **asyncOperation); + [overload("CreateWatcher")] HRESULT CreateWatcherWithKindAqsFilterAndAdditionalProperties([in] HSTRING filter, + [in] Windows.Foundation.Collections.IIterable<HSTRING> *additionalProperties, + [in] Windows.Devices.Enumeration.DeviceInformationKind kind, + [out, retval] Windows.Devices.Enumeration.DeviceWatcher **watcher); + } + [ contract(Windows.Foundation.UniversalApiContract, 1.0), marshaling_behavior(agile), @@ -155,6 +211,18 @@ namespace Windows.Devices.Enumeration { [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.Devices.Enumeration.IDeviceInformation2; }
+ [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + ] + runtimeclass DeviceInformationCollection + { + /* FIXME: This should be: + [default] interface Windows.Foundation.Collections.IVectorView<Windows.Devices.Enumeration.DeviceInformation *>; + interface Windows.Foundation.Collections.IIterable<Windows.Devices.Enumeration.DeviceInformation *>; */ + [default] interface IInspectable; + } + [ marshaling_behavior(agile), ]