From: Vibhav Pant vibhavp@gmail.com
--- dlls/windows.devices.enumeration/Makefile.in | 1 + .../windows.devices.enumeration/information.c | 186 ++++++++++++++++++ dlls/windows.devices.enumeration/main.c | 14 +- dlls/windows.devices.enumeration/private.h | 2 + .../tests/devices.c | 2 +- 5 files changed, 201 insertions(+), 4 deletions(-) create mode 100644 dlls/windows.devices.enumeration/information.c
diff --git a/dlls/windows.devices.enumeration/Makefile.in b/dlls/windows.devices.enumeration/Makefile.in index 68110328964..dc4c60a05e7 100644 --- a/dlls/windows.devices.enumeration/Makefile.in +++ b/dlls/windows.devices.enumeration/Makefile.in @@ -7,5 +7,6 @@ SOURCES = \ async.idl \ classes.idl \ event_handlers.c \ + information.c \ main.c \ vector.c diff --git a/dlls/windows.devices.enumeration/information.c b/dlls/windows.devices.enumeration/information.c new file mode 100644 index 00000000000..d65d63795bb --- /dev/null +++ b/dlls/windows.devices.enumeration/information.c @@ -0,0 +1,186 @@ +/* DeviceInformation implementation. + * + * Copyright 2025 Vibhav Pant + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "private.h" + +#include <roapi.h> + +#include <wine/debug.h> +#include <wine/rbtree.h> + +WINE_DEFAULT_DEBUG_CHANNEL(enumeration); + +struct device_information +{ + IDeviceInformation IDeviceInformation_iface; + LONG ref; +}; + +static inline struct device_information *impl_DeviceInterface_from_IDeviceInformation( IDeviceInformation *iface ) +{ + return CONTAINING_RECORD( iface, struct device_information, IDeviceInformation_iface ); +} + +static HRESULT WINAPI device_information_QueryInterface( IDeviceInformation *iface, REFIID iid, void **out ) +{ + 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_IAgileObject ) || + IsEqualGUID( iid, &IID_IDeviceInformation )) + { + IUnknown_AddRef( iface ); + *out = iface; + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI device_information_AddRef( IDeviceInformation *iface ) +{ + struct device_information *impl = impl_DeviceInterface_from_IDeviceInformation( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI device_information_Release( IDeviceInformation *iface ) +{ + struct device_information *impl = impl_DeviceInterface_from_IDeviceInformation( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + + if (!ref) free( impl ); + return ref; +} + +static HRESULT WINAPI device_information_GetIids( IDeviceInformation *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 device_information_GetRuntimeClassName( IDeviceInformation *iface, HSTRING *class_name ) +{ + const static WCHAR *name = RuntimeClass_Windows_Devices_Enumeration_DeviceInformation; + TRACE( "iface %p, class_name %p\n", iface, class_name ); + return WindowsCreateString( name, wcslen( name ), class_name ); +} + +static HRESULT WINAPI device_information_GetTrustLevel( IDeviceInformation *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_get_Id( IDeviceInformation *iface, HSTRING *id ) +{ + FIXME( "iface %p, id %p stub!\n", iface, id ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_get_Name( IDeviceInformation *iface, HSTRING *name ) +{ + FIXME( "iface %p, name %p stub!\n", iface, name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_get_IsEnabled( IDeviceInformation *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_IsDefault( IDeviceInformation *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_get_EnclosureLocation( IDeviceInformation *iface, IEnclosureLocation **location ) +{ + FIXME( "iface %p, location %p stub!\n", iface, location ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_get_Properties( IDeviceInformation *iface, IMapView_HSTRING_IInspectable **properties ) +{ + FIXME( "iface %p, properties %p stub!\n", iface, properties ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_Update( IDeviceInformation *iface, IDeviceInformationUpdate *update ) +{ + FIXME( "iface %p, update %p stub!\n", iface, update ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_GetThumbnailAsync( IDeviceInformation *iface, IAsyncOperation_DeviceThumbnail **async ) +{ + FIXME( "iface %p, async %p stub!\n", iface, async ); + return E_NOTIMPL; +} + +static HRESULT WINAPI device_information_GetGlyphThumbnailAsync( IDeviceInformation *iface, + IAsyncOperation_DeviceThumbnail **async ) +{ + FIXME( "iface %p, async %p stub!\n", iface, async ); + return E_NOTIMPL; +} + +static const struct IDeviceInformationVtbl device_information_vtbl = +{ + /* IUnknown */ + device_information_QueryInterface, + device_information_AddRef, + device_information_Release, + /* IInspectable */ + device_information_GetIids, + device_information_GetRuntimeClassName, + device_information_GetTrustLevel, + /* IDeviceInformation */ + device_information_get_Id, + device_information_get_Name, + device_information_get_IsEnabled, + device_information_IsDefault, + device_information_get_EnclosureLocation, + device_information_get_Properties, + device_information_Update, + device_information_GetThumbnailAsync, + device_information_GetGlyphThumbnailAsync, +}; + +HRESULT device_information_create( IDeviceInformation **info ) +{ + struct device_information *impl; + + TRACE( "info %p\n", info ); + + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; + impl->IDeviceInformation_iface.lpVtbl = &device_information_vtbl; + impl->ref = 1; + + *info = &impl->IDeviceInformation_iface; + TRACE( "created DeviceInformation %p\n", impl ); + return S_OK; +} diff --git a/dlls/windows.devices.enumeration/main.c b/dlls/windows.devices.enumeration/main.c index 48c49a50125..9d36147a974 100644 --- a/dlls/windows.devices.enumeration/main.c +++ b/dlls/windows.devices.enumeration/main.c @@ -342,14 +342,22 @@ static HRESULT WINAPI find_all_async( IUnknown *invoker, IUnknown *param, PROPVA .iterable = &IID_IIterable_DeviceInformation, .iterator = &IID_IIterator_DeviceInformation, }; - HRESULT hr; - IVector_IInspectable *vector; IVectorView_DeviceInformation *view; + IDeviceInformation *device; + IVector_IInspectable *vector; + HRESULT hr;
FIXME( "invoker %p, param %p, result %p semi-stub!\n", invoker, param, result );
if (FAILED(hr = vector_create( &iids, (void *)&vector ))) return hr; - hr = IVector_IInspectable_GetView( vector, (void *)&view ); + + if (SUCCEEDED(hr = device_information_create( &device ))) + { + hr = IVector_IInspectable_Append( vector, (IInspectable *)device ); + IDeviceInformation_Release( device ); + } + + if (SUCCEEDED(hr)) hr = IVector_IInspectable_GetView( vector, (void *)&view ); IVector_IInspectable_Release( vector ); if (FAILED(hr)) return hr;
diff --git a/dlls/windows.devices.enumeration/private.h b/dlls/windows.devices.enumeration/private.h index 4063b0465f5..f0fa09a923a 100644 --- a/dlls/windows.devices.enumeration/private.h +++ b/dlls/windows.devices.enumeration/private.h @@ -58,6 +58,8 @@ typedef HRESULT (WINAPI *async_operation_callback)( IUnknown *invoker, IUnknown extern HRESULT async_operation_device_info_collection_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_DeviceInformationCollection **out ); extern HRESULT vector_create( const struct vector_iids *iids, void **out ); +extern HRESULT device_information_create( IDeviceInformation **info ); + #define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ static inline impl_type *impl_from( iface_type *iface ) \ { \ diff --git a/dlls/windows.devices.enumeration/tests/devices.c b/dlls/windows.devices.enumeration/tests/devices.c index a6c0ce0fe03..6617f71a611 100644 --- a/dlls/windows.devices.enumeration/tests/devices.c +++ b/dlls/windows.devices.enumeration/tests/devices.c @@ -302,7 +302,7 @@ static void test_DeviceInformation_obj( int line, IDeviceInformation *info ) boolean bool_val;
hr = IDeviceInformation_get_Id( info, &str ); - ok_(__FILE__, line)( hr == S_OK, "got hr %#lx\n", hr ); + todo_wine ok_(__FILE__, line)( hr == S_OK, "got hr %#lx\n", hr ); WindowsDeleteString( str ); str = NULL; hr = IDeviceInformation_get_Name( info, &str );