From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.devices.enumeration/main.c | 24 +++++++++++++++---- .../tests/devices.c | 18 +++++++------- 2 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/dlls/windows.devices.enumeration/main.c b/dlls/windows.devices.enumeration/main.c index 1f3b09f8960..a67369b6e07 100644 --- a/dlls/windows.devices.enumeration/main.c +++ b/dlls/windows.devices.enumeration/main.c @@ -33,6 +33,9 @@ struct device_watcher
struct list stopped_handlers; HSTRING filter; + + CRITICAL_SECTION cs; + DeviceWatcherStatus status; };
static inline struct device_watcher *impl_from_IDeviceWatcher( IDeviceWatcher *iface ) @@ -78,6 +81,8 @@ static ULONG WINAPI device_watcher_Release( IDeviceWatcher *iface ) { typed_event_handlers_clear( &impl->stopped_handlers ); WindowsDeleteString( impl->filter ); + impl->cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection( &impl->cs ); free( impl ); }
@@ -170,10 +175,17 @@ static HRESULT WINAPI device_watcher_remove_Stopped( IDeviceWatcher *iface, Even return typed_event_handlers_remove( &impl->stopped_handlers, &token ); }
-static HRESULT WINAPI device_watcher_Status( IDeviceWatcher *iface, DeviceWatcherStatus *status ) +static HRESULT WINAPI device_watcher_get_Status( IDeviceWatcher *iface, DeviceWatcherStatus *status ) { - FIXME( "iface %p, status %p stub!\n", iface, status ); - return E_NOTIMPL; + struct device_watcher *impl = impl_from_IDeviceWatcher( iface ); + + TRACE( "iface %p, status %p\n", iface, status ); + + EnterCriticalSection( &impl->cs ); + *status = impl->status; + LeaveCriticalSection( &impl->cs ); + + return S_OK; }
static HRESULT WINAPI device_watcher_Start( IDeviceWatcher *iface ) @@ -215,7 +227,7 @@ static const struct IDeviceWatcherVtbl device_watcher_vtbl = device_watcher_remove_EnumerationCompleted, device_watcher_add_Stopped, device_watcher_remove_Stopped, - device_watcher_Status, + device_watcher_get_Status, device_watcher_Start, device_watcher_Stop, }; @@ -237,6 +249,10 @@ static HRESULT device_watcher_create( HSTRING filter, IDeviceWatcher **out )
list_init( &impl->stopped_handlers );
+ InitializeCriticalSectionEx( &impl->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO ); + impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": device_watcher.cs"); + impl->status = DeviceWatcherStatus_Created; + *out = &impl->IDeviceWatcher_iface; TRACE( "created DeviceWatcher %p\n", *out ); return S_OK; diff --git a/dlls/windows.devices.enumeration/tests/devices.c b/dlls/windows.devices.enumeration/tests/devices.c index fc3b227527d..2dc5b1433dc 100644 --- a/dlls/windows.devices.enumeration/tests/devices.c +++ b/dlls/windows.devices.enumeration/tests/devices.c @@ -391,13 +391,13 @@ static void test_DeviceInformation( void ) ok( hr == S_OK, "got hr %#lx\n", hr );
hr = IDeviceWatcher_get_Status( device_watcher, &status ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); - todo_wine ok( status == DeviceWatcherStatus_Created, "got status %u\n", status ); + ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( status == DeviceWatcherStatus_Created, "got status %u\n", status );
hr = IDeviceWatcher_Start( device_watcher ); ok( hr == S_OK, "got hr %#lx\n", hr ); hr = IDeviceWatcher_get_Status( device_watcher, &status ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( hr == S_OK, "got hr %#lx\n", hr ); todo_wine ok( status == DeviceWatcherStatus_Started, "got status %u\n", status );
ref = IDeviceWatcher_AddRef( device_watcher ); @@ -407,7 +407,7 @@ static void test_DeviceInformation( void ) ok( !WaitForSingleObject( stopped_handler.event, 1000 ), "wait for stopped_handler.event failed\n" );
hr = IDeviceWatcher_get_Status( device_watcher, &status ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( hr == S_OK, "got hr %#lx\n", hr ); todo_wine ok( status == DeviceWatcherStatus_Stopped, "got status %u\n", status ); ok( stopped_handler.invoked, "stopped_handler not invoked\n" ); ok( stopped_handler.args == NULL, "stopped_handler not invoked\n" ); @@ -438,13 +438,13 @@ static void test_DeviceInformation( void ) ok( hr == S_OK, "got hr %#lx\n", hr );
hr = IDeviceWatcher_get_Status( device_watcher, &status ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); - todo_wine ok( status == DeviceWatcherStatus_Created, "got status %u\n", status ); + ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( status == DeviceWatcherStatus_Created, "got status %u\n", status );
hr = IDeviceWatcher_Start( device_watcher ); ok( hr == S_OK, "got hr %#lx\n", hr ); hr = IDeviceWatcher_get_Status( device_watcher, &status ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( hr == S_OK, "got hr %#lx\n", hr ); todo_wine ok( status == DeviceWatcherStatus_Started, "got status %u\n", status );
ref = IDeviceWatcher_AddRef( device_watcher ); @@ -454,7 +454,7 @@ static void test_DeviceInformation( void ) ok( !WaitForSingleObject( stopped_handler.event, 1000 ), "wait for stopped_handler.event failed\n" );
hr = IDeviceWatcher_get_Status( device_watcher, &status ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( hr == S_OK, "got hr %#lx\n", hr ); todo_wine ok( status == DeviceWatcherStatus_Stopped, "got status %u\n", status ); ok( stopped_handler.invoked, "stopped_handler not invoked\n" ); ok( stopped_handler.args == NULL, "stopped_handler not invoked\n" ); @@ -477,7 +477,7 @@ static void test_DeviceInformation( void ) todo_wine ok( !WaitForSingleObject( enumerated_handler.event, 5000 ), "wait for enumerated_handler.event failed\n" ); todo_wine ok( added_handler.devices_added > 0, "devices_added should be greater than 0\n" ); hr = IDeviceWatcher_get_Status( device_watcher, &status ); - todo_wine ok( hr == S_OK, "got hr %#lx\n", hr ); + ok( hr == S_OK, "got hr %#lx\n", hr ); todo_wine ok( status == DeviceWatcherStatus_EnumerationCompleted, "got status %u\n", status );
hr = IDeviceWatcher_Start( device_watcher );