Making it easier to duplicate and later factor.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/Makefile.in | 1 + dlls/windows.gaming.input/async.c | 119 ++++++++++---------- dlls/windows.gaming.input/async_private.idl | 46 ++++++++ dlls/windows.gaming.input/force_feedback.c | 10 +- dlls/windows.gaming.input/private.h | 2 +- dlls/windows.gaming.input/provider.idl | 15 --- 6 files changed, 114 insertions(+), 79 deletions(-) create mode 100644 dlls/windows.gaming.input/async_private.idl
diff --git a/dlls/windows.gaming.input/Makefile.in b/dlls/windows.gaming.input/Makefile.in index 1342a4f9dde..34936b79996 100644 --- a/dlls/windows.gaming.input/Makefile.in +++ b/dlls/windows.gaming.input/Makefile.in @@ -3,6 +3,7 @@ IMPORTS = combase uuid user32 dinput8 setupapi hid
SOURCES = \ async.c \ + async_private.idl \ classes.idl \ condition_effect.c \ constant_effect.c \ diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c index d70994289f1..a916db6a90d 100644 --- a/dlls/windows.gaming.input/async.c +++ b/dlls/windows.gaming.input/async.c @@ -1,4 +1,4 @@ -/* WinRT Windows.Gaming.Input implementation +/* WinRT IAsync* implementation * * Copyright 2022 Bernhard Kölbl for CodeWeavers * Copyright 2022 Rémi Bernon for CodeWeavers @@ -18,8 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define WIDL_using_Wine_Internal #include "private.h" -#include "provider.h" +#include "initguid.h" +#include "async_private.h"
#include "wine/debug.h"
@@ -30,7 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(input);
struct async_info { - IWineAsyncInfoImpl IWineAsyncInfoImpl_iface; + IAsyncInfoImpl IAsyncInfoImpl_iface; IAsyncInfo IAsyncInfo_iface; IInspectable *IInspectable_outer; LONG ref; @@ -41,29 +43,29 @@ struct async_info IUnknown *param;
CRITICAL_SECTION cs; - IWineAsyncOperationCompletedHandler *handler; + IAsyncOperationCompletedHandlerImpl *handler; PROPVARIANT result; AsyncStatus status; HRESULT hr; };
-static inline struct async_info *impl_from_IWineAsyncInfoImpl( IWineAsyncInfoImpl *iface ) +static inline struct async_info *impl_from_IAsyncInfoImpl( IAsyncInfoImpl *iface ) { - return CONTAINING_RECORD( iface, struct async_info, IWineAsyncInfoImpl_iface ); + return CONTAINING_RECORD( iface, struct async_info, IAsyncInfoImpl_iface ); }
-static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFIID iid, void **out ) +static HRESULT WINAPI async_impl_QueryInterface( IAsyncInfoImpl *iface, REFIID iid, void **out ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
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_IWineAsyncInfoImpl )) + IsEqualGUID( iid, &IID_IAsyncInfoImpl )) { - IInspectable_AddRef( (*out = &impl->IWineAsyncInfoImpl_iface) ); + IInspectable_AddRef( (*out = &impl->IAsyncInfoImpl_iface) ); return S_OK; }
@@ -78,26 +80,27 @@ static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFI return E_NOINTERFACE; }
-static ULONG WINAPI async_impl_AddRef( IWineAsyncInfoImpl *iface ) +static ULONG WINAPI async_impl_AddRef( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref ); return ref; }
-static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) +static ULONG WINAPI async_impl_Release( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref );
if (!ref) { - if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); + if (impl->handler && impl->handler != HANDLER_NOT_SET) IAsyncOperationCompletedHandlerImpl_Release( impl->handler ); IAsyncInfo_Close( &impl->IAsyncInfo_iface ); if (impl->param) IUnknown_Release( impl->param ); if (impl->invoker) IUnknown_Release( impl->invoker ); + PropVariantClear( &impl->result ); impl->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &impl->cs ); free( impl ); @@ -106,9 +109,9 @@ static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) return ref; }
-static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) +static HRESULT WINAPI async_impl_put_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl *handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -118,7 +121,7 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine else if (impl->handler != HANDLER_NOT_SET) hr = E_ILLEGAL_DELEGATE_ASSIGNMENT; else if ((impl->handler = handler)) { - IWineAsyncOperationCompletedHandler_AddRef( impl->handler ); + IAsyncOperationCompletedHandlerImpl_AddRef( impl->handler );
if (impl->status > Started) { @@ -127,8 +130,8 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs );
- IWineAsyncOperationCompletedHandler_Invoke( handler, operation, status ); - IWineAsyncOperationCompletedHandler_Release( handler ); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler );
return S_OK; } @@ -138,9 +141,9 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine return hr; }
-static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler **handler ) +static HRESULT WINAPI async_impl_get_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl **handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -148,15 +151,15 @@ static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWine EnterCriticalSection( &impl->cs ); if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; if (impl->handler == NULL || impl->handler == HANDLER_NOT_SET) *handler = NULL; - else IWineAsyncOperationCompletedHandler_AddRef( (*handler = impl->handler) ); + else IAsyncOperationCompletedHandlerImpl_AddRef( (*handler = impl->handler) ); LeaveCriticalSection( &impl->cs );
return hr; }
-static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARIANT *result ) +static HRESULT WINAPI async_impl_get_Result( IAsyncInfoImpl *iface, PROPVARIANT *result ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = E_ILLEGAL_METHOD_CALL;
TRACE( "iface %p, result %p.\n", iface, result ); @@ -172,9 +175,9 @@ static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARI return hr; }
-static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) +static HRESULT WINAPI async_impl_Start( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
TRACE( "iface %p.\n", iface );
@@ -185,13 +188,13 @@ static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) return S_OK; }
-static const struct IWineAsyncInfoImplVtbl async_impl_vtbl = +static const struct IAsyncInfoImplVtbl async_impl_vtbl = { /* IUnknown methods */ async_impl_QueryInterface, async_impl_AddRef, async_impl_Release, - /* IWineAsyncInfoImpl */ + /* IAsyncInfoImpl */ async_impl_put_Completed, async_impl_get_Completed, async_impl_get_Result, @@ -301,9 +304,9 @@ static const struct IAsyncInfoVtbl async_info_vtbl =
static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *iface, TP_WORK *work ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); IInspectable *operation = impl->IInspectable_outer; - PROPVARIANT result; + PROPVARIANT result = {0}; HRESULT hr;
hr = impl->callback( impl->invoker, impl->param, &result ); @@ -315,13 +318,13 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *
if (impl->handler != NULL && impl->handler != HANDLER_NOT_SET) { - IWineAsyncOperationCompletedHandler *handler = impl->handler; + IAsyncOperationCompletedHandlerImpl *handler = impl->handler; AsyncStatus status = impl->status; impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs );
- IWineAsyncOperationCompletedHandler_Invoke( handler, operation, status ); - IWineAsyncOperationCompletedHandler_Release( handler ); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler ); } else LeaveCriticalSection( &impl->cs );
@@ -332,13 +335,13 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void * }
static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, - IInspectable *outer, IWineAsyncInfoImpl **out ) + IInspectable *outer, IAsyncInfoImpl **out ) { struct async_info *impl; HRESULT hr;
if (!(impl = calloc( 1, sizeof(struct async_info) ))) return E_OUTOFMEMORY; - impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; + impl->IAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; impl->IAsyncInfo_iface.lpVtbl = &async_info_vtbl; impl->IInspectable_outer = outer; impl->ref = 1; @@ -346,7 +349,7 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper impl->callback = callback; impl->handler = HANDLER_NOT_SET; impl->status = Started; - if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IWineAsyncInfoImpl_iface, NULL ))) + if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IAsyncInfoImpl_iface, NULL ))) { hr = HRESULT_FROM_WIN32( GetLastError() ); free( impl ); @@ -359,14 +362,14 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper InitializeCriticalSectionEx( &impl->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO ); impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)( __FILE__ ": async_info.cs" );
- *out = &impl->IWineAsyncInfoImpl_iface; + *out = &impl->IAsyncInfoImpl_iface; return S_OK; }
struct async_bool { IAsyncOperation_boolean IAsyncOperation_boolean_iface; - IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; + IAsyncInfoImpl *IAsyncInfoImpl_inner; LONG ref; };
@@ -390,7 +393,7 @@ static HRESULT WINAPI async_bool_QueryInterface( IAsyncOperation_boolean *iface, return S_OK; }
- return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); + return IAsyncInfoImpl_QueryInterface( impl->IAsyncInfoImpl_inner, iid, out ); }
static ULONG WINAPI async_bool_AddRef( IAsyncOperation_boolean *iface ) @@ -411,7 +414,7 @@ static ULONG WINAPI async_bool_Release( IAsyncOperation_boolean *iface ) { /* guard against re-entry if inner releases an outer iface */ InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); }
@@ -439,18 +442,18 @@ static HRESULT WINAPI async_bool_GetTrustLevel( IAsyncOperation_boolean *iface,
static HRESULT WINAPI async_bool_put_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean *bool_handler ) { - IWineAsyncOperationCompletedHandler *handler = (IWineAsyncOperationCompletedHandler *)bool_handler; + IAsyncOperationCompletedHandlerImpl *handler = (IAsyncOperationCompletedHandlerImpl *)bool_handler; struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, handler ); + return IAsyncInfoImpl_put_Completed( impl->IAsyncInfoImpl_inner, handler ); }
static HRESULT WINAPI async_bool_get_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean **bool_handler ) { - IWineAsyncOperationCompletedHandler **handler = (IWineAsyncOperationCompletedHandler **)bool_handler; + IAsyncOperationCompletedHandlerImpl **handler = (IAsyncOperationCompletedHandlerImpl **)bool_handler; struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, handler ); + return IAsyncInfoImpl_get_Completed( impl->IAsyncInfoImpl_inner, handler ); }
static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOOLEAN *results ) @@ -461,7 +464,7 @@ static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOO
TRACE( "iface %p, results %p.\n", iface, results );
- hr = IWineAsyncInfoImpl_get_Result( impl->IWineAsyncInfoImpl_inner, &result ); + hr = IAsyncInfoImpl_get_Result( impl->IAsyncInfoImpl_inner, &result );
*results = result.boolVal; PropVariantClear( &result ); @@ -495,10 +498,10 @@ HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, asyn impl->IAsyncOperation_boolean_iface.lpVtbl = &async_bool_vtbl; impl->ref = 1;
- if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IWineAsyncInfoImpl_inner )) || - FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) + if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IAsyncInfoImpl_inner )) || + FAILED(hr = IAsyncInfoImpl_Start( impl->IAsyncInfoImpl_inner ))) { - if (impl->IWineAsyncInfoImpl_inner) IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + if (impl->IAsyncInfoImpl_inner) IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); return hr; } @@ -511,7 +514,7 @@ HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, asyn struct async_result { IAsyncOperation_ForceFeedbackLoadEffectResult IAsyncOperation_ForceFeedbackLoadEffectResult_iface; - IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; + IAsyncInfoImpl *IAsyncInfoImpl_inner; LONG ref; };
@@ -535,7 +538,7 @@ static HRESULT WINAPI async_result_QueryInterface( IAsyncOperation_ForceFeedback return S_OK; }
- return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); + return IAsyncInfoImpl_QueryInterface( impl->IAsyncInfoImpl_inner, iid, out ); }
static ULONG WINAPI async_result_AddRef( IAsyncOperation_ForceFeedbackLoadEffectResult *iface ) @@ -556,7 +559,7 @@ static ULONG WINAPI async_result_Release( IAsyncOperation_ForceFeedbackLoadEffec { /* guard against re-entry if inner releases an outer iface */ InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); }
@@ -586,14 +589,14 @@ static HRESULT WINAPI async_result_put_Completed( IAsyncOperation_ForceFeedbackL { struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler *)handler ); + return IAsyncInfoImpl_put_Completed( impl->IAsyncInfoImpl_inner, (IAsyncOperationCompletedHandlerImpl *)handler ); }
static HRESULT WINAPI async_result_get_Completed( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, IAsyncOperationCompletedHandler_ForceFeedbackLoadEffectResult **handler ) { struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler **)handler ); + return IAsyncInfoImpl_get_Completed( impl->IAsyncInfoImpl_inner, (IAsyncOperationCompletedHandlerImpl **)handler ); }
static HRESULT WINAPI async_result_GetResults( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, ForceFeedbackLoadEffectResult *results ) @@ -604,7 +607,7 @@ static HRESULT WINAPI async_result_GetResults( IAsyncOperation_ForceFeedbackLoad
TRACE( "iface %p, results %p.\n", iface, results );
- hr = IWineAsyncInfoImpl_get_Result( impl->IWineAsyncInfoImpl_inner, &result ); + hr = IAsyncInfoImpl_get_Result( impl->IAsyncInfoImpl_inner, &result );
*results = result.ulVal; PropVariantClear( &result ); @@ -638,10 +641,10 @@ HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface.lpVtbl = &async_result_vtbl; impl->ref = 1;
- if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface, &impl->IWineAsyncInfoImpl_inner )) || - FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) + if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface, &impl->IAsyncInfoImpl_inner )) || + FAILED(hr = IAsyncInfoImpl_Start( impl->IAsyncInfoImpl_inner ))) { - if (impl->IWineAsyncInfoImpl_inner) IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + if (impl->IAsyncInfoImpl_inner) IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); return hr; } diff --git a/dlls/windows.gaming.input/async_private.idl b/dlls/windows.gaming.input/async_private.idl new file mode 100644 index 00000000000..10741572601 --- /dev/null +++ b/dlls/windows.gaming.input/async_private.idl @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Rémi Bernon for CodeWeavers + * + * 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 + */ + +#pragma makedep header + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "propidl.idl"; +import "inspectable.idl"; +import "asyncinfo.idl"; +import "windowscontracts.idl"; + +namespace Wine.Internal { + /* type-pruning version of AsyncOperationCompletedHandlerImpl<T> */ + delegate HRESULT AsyncOperationCompletedHandlerImpl([in] IInspectable *async, [in] AsyncStatus status); + + [ + uuid(d81ab70d-82e0-481c-983d-401225d98a2c) + ] + interface IAsyncInfoImpl : IUnknown + { + [propput] HRESULT Completed([in] AsyncOperationCompletedHandlerImpl *handler); + [propget] HRESULT Completed([out, retval] AsyncOperationCompletedHandlerImpl **handler); + [propget] HRESULT Result([out, retval] PROPVARIANT *result); + HRESULT Start(); + } + + typedef HRESULT (*async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); +} diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index a272daee25f..a8631e60c4a 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -601,7 +601,7 @@ static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum return hr; }
-static HRESULT WINAPI motor_load_effect_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) +static HRESULT motor_load_effect_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { struct effect *effect = impl_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); IForceFeedbackMotor *motor = (IForceFeedbackMotor *)invoker; @@ -692,7 +692,7 @@ static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface ) return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_STOPALL ); }
-static HRESULT WINAPI motor_try_disable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) +static HRESULT motor_try_disable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr; @@ -710,7 +710,7 @@ static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncO return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_disable_async, async_op ); }
-static HRESULT WINAPI motor_try_enable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) +static HRESULT motor_try_enable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr; @@ -728,7 +728,7 @@ static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOp return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_enable_async, async_op ); }
-static HRESULT WINAPI motor_try_reset_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) +static HRESULT motor_try_reset_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr; @@ -746,7 +746,7 @@ static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOpe return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_reset_async, async_op ); }
-static HRESULT WINAPI motor_unload_effect_async( IUnknown *iface, IUnknown *param, PROPVARIANT *result ) +static HRESULT motor_unload_effect_async( IUnknown *iface, IUnknown *param, PROPVARIANT *result ) { struct effect *effect = impl_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); IDirectInputEffect *dinput_effect; diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index f53d5b5bc37..e345ca425aa 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -43,6 +43,7 @@ #include "wine/list.h"
#include "provider.h" +#include "async_private.h"
extern HINSTANCE windows_gaming_input; extern ICustomGameControllerFactory *controller_factory; @@ -76,7 +77,6 @@ extern void event_handlers_notify( struct list *list, IInspectable *element ); extern HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ); extern HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IInspectable *outer, IWineForceFeedbackEffectImpl **out );
-typedef HRESULT (WINAPI *async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); extern HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_boolean **out ); extern HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, diff --git a/dlls/windows.gaming.input/provider.idl b/dlls/windows.gaming.input/provider.idl index e7b6e96b8aa..039948bc0b6 100644 --- a/dlls/windows.gaming.input/provider.idl +++ b/dlls/windows.gaming.input/provider.idl @@ -24,7 +24,6 @@
import "propidl.idl"; import "inspectable.idl"; -import "asyncinfo.idl"; import "eventtoken.idl"; import "windowscontracts.idl"; import "windows.foundation.idl"; @@ -46,9 +45,6 @@ namespace Windows.Gaming.Input.Custom { interface IWineGameControllerProvider; runtimeclass WineGameControllerProvider;
- /* type-pruning version of AsyncOperationCompletedHandler<T> */ - delegate HRESULT WineAsyncOperationCompletedHandler([in] IInspectable *async, [in] AsyncStatus status); - enum WineGameControllerType { Joystick = 0, @@ -195,17 +191,6 @@ namespace Windows.Gaming.Input.Custom { [in, optional] WineForceFeedbackEffectEnvelope *envelope); }
- [ - uuid(83f377ee-c799-11ec-9d64-0242ac120002) - ] - interface IWineAsyncInfoImpl : IUnknown - { - [propput] HRESULT Completed([in] WineAsyncOperationCompletedHandler *handler); - [propget] HRESULT Completed([out, retval] WineAsyncOperationCompletedHandler **handler); - [propget] HRESULT Result([out, retval] PROPVARIANT *result); - HRESULT Start(); - } - [ marshaling_behavior(agile), threading(both)
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.media.speech/Makefile.in | 1 + dlls/windows.media.speech/async.c | 948 ++++++++++---------- dlls/windows.media.speech/async_private.idl | 46 + dlls/windows.media.speech/private.h | 9 +- dlls/windows.media.speech/recognizer.c | 20 +- dlls/windows.media.speech/synthesizer.c | 28 +- dlls/windows.media.speech/tests/speech.c | 28 +- 7 files changed, 602 insertions(+), 478 deletions(-) create mode 100644 dlls/windows.media.speech/async_private.idl
diff --git a/dlls/windows.media.speech/Makefile.in b/dlls/windows.media.speech/Makefile.in index 5be66d8367e..e21fc2162c2 100644 --- a/dlls/windows.media.speech/Makefile.in +++ b/dlls/windows.media.speech/Makefile.in @@ -3,6 +3,7 @@ IMPORTS = combase uuid
SOURCES = \ async.c \ + async_private.idl \ classes.idl \ event_handlers.c \ listconstraint.c \ diff --git a/dlls/windows.media.speech/async.c b/dlls/windows.media.speech/async.c index 2b2dc394305..bc484616cc0 100644 --- a/dlls/windows.media.speech/async.c +++ b/dlls/windows.media.speech/async.c @@ -1,6 +1,7 @@ -/* WinRT Windows.Media.Speech implementation +/* WinRT IAsync* implementation * * Copyright 2022 Bernhard Kölbl for CodeWeavers + * Copyright 2022 Rémi Bernon for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,742 +18,787 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define WIDL_using_Wine_Internal #include "private.h" +#include "initguid.h" +#include "async_private.h"
#include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(speech); +WINE_DEFAULT_DEBUG_CHANNEL(input);
#define Closed 4 #define HANDLER_NOT_SET ((void *)~(ULONG_PTR)0)
-/* - * - * IAsyncAction - * - */ - -struct async_void +struct async_info { - IAsyncAction IAsyncAction_iface; + IAsyncInfoImpl IAsyncInfoImpl_iface; IAsyncInfo IAsyncInfo_iface; + IInspectable *IInspectable_outer; LONG ref;
- IAsyncActionCompletedHandler *handler; - - async_action_callback callback; + async_operation_callback callback; TP_WORK *async_run_work; - IInspectable *invoker; + IUnknown *invoker; + IUnknown *param;
CRITICAL_SECTION cs; + IAsyncOperationCompletedHandlerImpl *handler; + PROPVARIANT result; AsyncStatus status; HRESULT hr; };
-static inline struct async_void *impl_from_IAsyncAction( IAsyncAction *iface ) +static inline struct async_info *impl_from_IAsyncInfoImpl( IAsyncInfoImpl *iface ) { - return CONTAINING_RECORD(iface, struct async_void, IAsyncAction_iface); + return CONTAINING_RECORD( iface, struct async_info, IAsyncInfoImpl_iface ); }
-HRESULT WINAPI async_void_QueryInterface( IAsyncAction *iface, REFIID iid, void **out ) +static HRESULT WINAPI async_impl_QueryInterface( IAsyncInfoImpl *iface, REFIID iid, void **out ) { - struct async_void *impl = impl_from_IAsyncAction(iface); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
- TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), 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_IAsyncAction)) + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IAsyncInfoImpl )) { - IInspectable_AddRef((*out = &impl->IAsyncAction_iface)); + IInspectable_AddRef( (*out = &impl->IAsyncInfoImpl_iface) ); return S_OK; }
- if (IsEqualGUID(iid, &IID_IAsyncInfo)) + if (IsEqualGUID( iid, &IID_IAsyncInfo )) { - IInspectable_AddRef((*out = &impl->IAsyncInfo_iface)); + IInspectable_AddRef( (*out = &impl->IAsyncInfo_iface) ); return S_OK; }
- WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
-ULONG WINAPI async_void_AddRef( IAsyncAction *iface ) +static ULONG WINAPI async_impl_AddRef( IAsyncInfoImpl *iface ) { - struct async_void *impl = impl_from_IAsyncAction(iface); - ULONG ref = InterlockedIncrement(&impl->ref); - TRACE("iface %p, ref %lu.\n", iface, ref); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); return ref; }
-ULONG WINAPI async_void_Release( IAsyncAction *iface ) +static ULONG WINAPI async_impl_Release( IAsyncInfoImpl *iface ) { - struct async_void *impl = impl_from_IAsyncAction(iface); - ULONG ref = InterlockedDecrement(&impl->ref); - TRACE("iface %p, ref %lu.\n", iface, ref); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref );
if (!ref) { - IAsyncInfo_Close(&impl->IAsyncInfo_iface); - - if (impl->invoker) - IInspectable_Release(impl->invoker); - if (impl->handler && impl->handler != HANDLER_NOT_SET) - IAsyncActionCompletedHandler_Release(impl->handler); - + if (impl->handler && impl->handler != HANDLER_NOT_SET) IAsyncOperationCompletedHandlerImpl_Release( impl->handler ); + IAsyncInfo_Close( &impl->IAsyncInfo_iface ); + if (impl->param) IUnknown_Release( impl->param ); + if (impl->invoker) IUnknown_Release( impl->invoker ); + PropVariantClear( &impl->result ); impl->cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&impl->cs); - free(impl); + DeleteCriticalSection( &impl->cs ); + free( impl ); }
return ref; }
-HRESULT WINAPI async_void_GetIids( IAsyncAction *iface, ULONG *iid_count, IID **iids ) -{ - FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids); - return E_NOTIMPL; -} - -HRESULT WINAPI async_void_GetRuntimeClassName( IAsyncAction *iface, HSTRING *class_name ) -{ - FIXME("iface %p, class_name %p stub!\n", iface, class_name); - return E_NOTIMPL; -} - -HRESULT WINAPI async_void_GetTrustLevel( IAsyncAction *iface, TrustLevel *trust_level ) -{ - FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); - return E_NOTIMPL; -} - -HRESULT WINAPI async_void_put_Completed( IAsyncAction *iface, IAsyncActionCompletedHandler *handler ) +static HRESULT WINAPI async_impl_put_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl *handler ) { - struct async_void *impl = impl_from_IAsyncAction(iface); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
- TRACE("iface %p, handler %p.\n", iface, handler); - - EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - hr = E_ILLEGAL_METHOD_CALL; - else if (impl->handler != HANDLER_NOT_SET) - hr = E_ILLEGAL_DELEGATE_ASSIGNMENT; - /* - impl->handler can only be set once with async_void_put_Completed, - so by default we set a non HANDLER_NOT_SET value, in this case handler. - */ + TRACE( "iface %p, handler %p.\n", iface, handler ); + + EnterCriticalSection( &impl->cs ); + if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; + else if (impl->handler != HANDLER_NOT_SET) hr = E_ILLEGAL_DELEGATE_ASSIGNMENT; else if ((impl->handler = handler)) { - IAsyncActionCompletedHandler_AddRef(impl->handler); + IAsyncOperationCompletedHandlerImpl_AddRef( impl->handler );
if (impl->status > Started) { - IAsyncAction *action = &impl->IAsyncAction_iface; + IInspectable *operation = impl->IInspectable_outer; AsyncStatus status = impl->status; impl->handler = NULL; /* Prevent concurrent invoke. */ - LeaveCriticalSection(&impl->cs); + LeaveCriticalSection( &impl->cs );
- IAsyncActionCompletedHandler_Invoke(handler, action, status); - IAsyncActionCompletedHandler_Release(handler); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler );
return S_OK; } } - LeaveCriticalSection(&impl->cs); + LeaveCriticalSection( &impl->cs );
return hr; }
-HRESULT WINAPI async_void_get_Completed( IAsyncAction *iface, IAsyncActionCompletedHandler **handler ) +static HRESULT WINAPI async_impl_get_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl **handler ) { - struct async_void *impl = impl_from_IAsyncAction(iface); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
- FIXME("iface %p, handler %p semi stub!\n", iface, handler); + TRACE( "iface %p, handler %p.\n", iface, handler );
- EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - hr = E_ILLEGAL_METHOD_CALL; - *handler = (impl->handler != HANDLER_NOT_SET) ? impl->handler : NULL; - LeaveCriticalSection(&impl->cs); + EnterCriticalSection( &impl->cs ); + if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; + if (impl->handler == NULL || impl->handler == HANDLER_NOT_SET) *handler = NULL; + else IAsyncOperationCompletedHandlerImpl_AddRef( (*handler = impl->handler) ); + LeaveCriticalSection( &impl->cs );
return hr; }
-HRESULT WINAPI async_void_GetResults( IAsyncAction *iface ) +static HRESULT WINAPI async_impl_get_Result( IAsyncInfoImpl *iface, PROPVARIANT *result ) { - /* According to the docs, this function doesn't return anything, so it's left empty. */ - TRACE("iface %p.\n", iface); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); + HRESULT hr = E_ILLEGAL_METHOD_CALL; + + TRACE( "iface %p, result %p.\n", iface, result ); + + EnterCriticalSection( &impl->cs ); + if (impl->status == Completed || impl->status == Error) + { + PropVariantCopy( result, &impl->result ); + hr = impl->hr; + } + LeaveCriticalSection( &impl->cs ); + + return hr; +} + +static HRESULT WINAPI async_impl_Start( IAsyncInfoImpl *iface ) +{ + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); + + TRACE( "iface %p.\n", iface ); + + /* keep the async alive in the callback */ + IInspectable_AddRef( impl->IInspectable_outer ); + SubmitThreadpoolWork( impl->async_run_work ); + return S_OK; }
-static const struct IAsyncActionVtbl async_void_vtbl = +static const struct IAsyncInfoImplVtbl async_impl_vtbl = { /* IUnknown methods */ - async_void_QueryInterface, - async_void_AddRef, - async_void_Release, - /* IInspectable methods */ - async_void_GetIids, - async_void_GetRuntimeClassName, - async_void_GetTrustLevel, - /* IAsyncAction methods */ - async_void_put_Completed, - async_void_get_Completed, - async_void_GetResults + async_impl_QueryInterface, + async_impl_AddRef, + async_impl_Release, + /* IAsyncInfoImpl */ + async_impl_put_Completed, + async_impl_get_Completed, + async_impl_get_Result, + async_impl_Start, };
-/* - * - * IAsyncInfo for IAsyncAction - * - */ - -DEFINE_IINSPECTABLE_(async_void_info, IAsyncInfo, struct async_void, impl_from_async_void_IAsyncInfo, IAsyncInfo_iface, &impl->IAsyncAction_iface) +DEFINE_IINSPECTABLE_OUTER( async_info, IAsyncInfo, struct async_info, IInspectable_outer )
-static HRESULT WINAPI async_void_info_get_Id( IAsyncInfo *iface, UINT32 *id ) +static HRESULT WINAPI async_info_get_Id( IAsyncInfo *iface, UINT32 *id ) { - FIXME("iface %p, id %p stub!\n", iface, id); - return E_NOTIMPL; + struct async_info *impl = impl_from_IAsyncInfo( iface ); + HRESULT hr = S_OK; + + TRACE( "iface %p, id %p.\n", iface, id ); + + EnterCriticalSection( &impl->cs ); + if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; + *id = 1; + LeaveCriticalSection( &impl->cs ); + + return hr; }
-static HRESULT WINAPI async_void_info_get_Status( IAsyncInfo *iface, AsyncStatus *status ) +static HRESULT WINAPI async_info_get_Status( IAsyncInfo *iface, AsyncStatus *status ) { - struct async_void *impl = impl_from_async_void_IAsyncInfo(iface); + struct async_info *impl = impl_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
- TRACE("iface %p, status %p.\n", iface, status); + TRACE( "iface %p, status %p.\n", iface, status );
- EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - hr = E_ILLEGAL_METHOD_CALL; + EnterCriticalSection( &impl->cs ); + if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; *status = impl->status; - LeaveCriticalSection(&impl->cs); + LeaveCriticalSection( &impl->cs );
return hr; }
-static HRESULT WINAPI async_void_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) +static HRESULT WINAPI async_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) { - struct async_void *impl = impl_from_async_void_IAsyncInfo(iface); + struct async_info *impl = impl_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
- TRACE("iface %p, error_code %p.\n", iface, error_code); + TRACE( "iface %p, error_code %p.\n", iface, error_code );
- EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - *error_code = hr = E_ILLEGAL_METHOD_CALL; - else - *error_code = impl->hr; - LeaveCriticalSection(&impl->cs); + EnterCriticalSection( &impl->cs ); + if (impl->status == Closed) *error_code = hr = E_ILLEGAL_METHOD_CALL; + else *error_code = impl->hr; + LeaveCriticalSection( &impl->cs );
return hr; }
-static HRESULT WINAPI async_void_info_Cancel( IAsyncInfo *iface ) +static HRESULT WINAPI async_info_Cancel( IAsyncInfo *iface ) { - struct async_void *impl = impl_from_async_void_IAsyncInfo(iface); + struct async_info *impl = impl_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
- TRACE("iface %p.\n", iface); + TRACE( "iface %p.\n", iface );
- EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - hr = E_ILLEGAL_METHOD_CALL; - else if (impl->status == Started) - impl->status = Canceled; - LeaveCriticalSection(&impl->cs); + EnterCriticalSection( &impl->cs ); + if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; + else if (impl->status == Started) impl->status = Canceled; + LeaveCriticalSection( &impl->cs );
return hr; }
-static HRESULT WINAPI async_void_info_Close( IAsyncInfo *iface ) +static HRESULT WINAPI async_info_Close( IAsyncInfo *iface ) { - struct async_void *impl = impl_from_async_void_IAsyncInfo(iface); + struct async_info *impl = impl_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
- TRACE("iface %p.\n", iface); + TRACE( "iface %p.\n", iface );
- EnterCriticalSection(&impl->cs); + EnterCriticalSection( &impl->cs ); if (impl->status == Started) hr = E_ILLEGAL_STATE_CHANGE; else if (impl->status != Closed) { - CloseThreadpoolWork(impl->async_run_work); + CloseThreadpoolWork( impl->async_run_work ); impl->async_run_work = NULL; impl->status = Closed; } - LeaveCriticalSection(&impl->cs); + LeaveCriticalSection( &impl->cs );
return hr; }
-static const struct IAsyncInfoVtbl async_void_info_vtbl = +static const struct IAsyncInfoVtbl async_info_vtbl = { /* IUnknown methods */ - async_void_info_QueryInterface, - async_void_info_AddRef, - async_void_info_Release, + async_info_QueryInterface, + async_info_AddRef, + async_info_Release, /* IInspectable methods */ - async_void_info_GetIids, - async_void_info_GetRuntimeClassName, - async_void_info_GetTrustLevel, + async_info_GetIids, + async_info_GetRuntimeClassName, + async_info_GetTrustLevel, /* IAsyncInfo */ - async_void_info_get_Id, - async_void_info_get_Status, - async_void_info_get_ErrorCode, - async_void_info_Cancel, - async_void_info_Close + async_info_get_Id, + async_info_get_Status, + async_info_get_ErrorCode, + async_info_Cancel, + async_info_Close, };
-static void CALLBACK async_void_run_cb(TP_CALLBACK_INSTANCE *instance, void *data, TP_WORK *work) +static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *iface, TP_WORK *work ) { - IAsyncAction *action = data; - struct async_void *impl = impl_from_IAsyncAction(action); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); + IInspectable *operation = impl->IInspectable_outer; + PROPVARIANT result = {0}; HRESULT hr;
- hr = impl->callback(impl->invoker); - - EnterCriticalSection(&impl->cs); - if (impl->status < Closed) - impl->status = FAILED(hr) ? Error : Completed; + hr = impl->callback( impl->invoker, impl->param, &result );
+ EnterCriticalSection( &impl->cs ); + if (impl->status != Closed) impl->status = FAILED(hr) ? Error : Completed; + PropVariantCopy( &impl->result, &result ); impl->hr = hr;
if (impl->handler != NULL && impl->handler != HANDLER_NOT_SET) { - IAsyncActionCompletedHandler*handler = impl->handler; + IAsyncOperationCompletedHandlerImpl *handler = impl->handler; AsyncStatus status = impl->status; impl->handler = NULL; /* Prevent concurrent invoke. */ - LeaveCriticalSection(&impl->cs); + LeaveCriticalSection( &impl->cs );
- IAsyncActionCompletedHandler_Invoke(handler, action, status); - IAsyncActionCompletedHandler_Release(handler); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler ); } - else LeaveCriticalSection(&impl->cs); + else LeaveCriticalSection( &impl->cs ); + + /* release refcount acquired in Start */ + IInspectable_Release( operation );
- IAsyncAction_Release(action); + PropVariantClear( &result ); }
-HRESULT async_action_create( IInspectable *invoker, async_action_callback callback, IAsyncAction **out ) +static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, + IInspectable *outer, IAsyncInfoImpl **out ) { - struct async_void *impl; - - TRACE("invoker %p, callback %p, out %p.\n", invoker, callback, out); - - if (!(impl = calloc(1, sizeof(*impl)))) - { - *out = NULL; - return E_OUTOFMEMORY; - } + struct async_info *impl; + HRESULT hr;
- impl->IAsyncAction_iface.lpVtbl = &async_void_vtbl; - impl->IAsyncInfo_iface.lpVtbl = &async_void_info_vtbl; + if (!(impl = calloc( 1, sizeof(struct async_info) ))) return E_OUTOFMEMORY; + impl->IAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; + impl->IAsyncInfo_iface.lpVtbl = &async_info_vtbl; + impl->IInspectable_outer = outer; impl->ref = 1;
- impl->handler = HANDLER_NOT_SET; impl->callback = callback; + impl->handler = HANDLER_NOT_SET; impl->status = Started; - - if (!(impl->async_run_work = CreateThreadpoolWork(async_void_run_cb, &impl->IAsyncAction_iface, NULL))) + if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IAsyncInfoImpl_iface, NULL ))) { - free(impl); - return HRESULT_FROM_WIN32(GetLastError()); + hr = HRESULT_FROM_WIN32( GetLastError() ); + free( impl ); + return hr; }
- if (invoker) IInspectable_AddRef((impl->invoker = invoker)); + if ((impl->invoker = invoker)) IUnknown_AddRef( impl->invoker ); + if ((impl->param = param)) IUnknown_AddRef( impl->param );
- InitializeCriticalSectionEx(&impl->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); - impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": async_action.cs"); + InitializeCriticalSectionEx( &impl->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO ); + impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)( __FILE__ ": async_info.cs" );
- /* AddRef to keep the obj alive in the callback. */ - IAsyncAction_AddRef(&impl->IAsyncAction_iface); - SubmitThreadpoolWork(impl->async_run_work); - - *out = &impl->IAsyncAction_iface; - TRACE("created %p\n", *out); + *out = &impl->IAsyncInfoImpl_iface; return S_OK; }
-/* - * - * IAsyncOperation<IInspectable*> - * - */ - -struct async_inspectable +struct async_bool { - IAsyncOperation_IInspectable IAsyncOperation_IInspectable_iface; - IAsyncInfo IAsyncInfo_iface; - const GUID *iid; + IAsyncOperation_boolean IAsyncOperation_boolean_iface; + IAsyncInfoImpl *IAsyncInfoImpl_inner; LONG ref; - - IAsyncOperationCompletedHandler_IInspectable *handler; - IInspectable *result; - - async_operation_inspectable_callback callback; - TP_WORK *async_run_work; - IInspectable *invoker; - - CRITICAL_SECTION cs; - AsyncStatus status; - HRESULT hr; };
-static inline struct async_inspectable *impl_from_IAsyncOperation_IInspectable(IAsyncOperation_IInspectable *iface) +static inline struct async_bool *impl_from_IAsyncOperation_boolean( IAsyncOperation_boolean *iface ) { - return CONTAINING_RECORD(iface, struct async_inspectable, IAsyncOperation_IInspectable_iface); + return CONTAINING_RECORD( iface, struct async_bool, IAsyncOperation_boolean_iface ); }
-static HRESULT WINAPI async_inspectable_QueryInterface( IAsyncOperation_IInspectable *iface, REFIID iid, void **out ) +static HRESULT WINAPI async_bool_QueryInterface( IAsyncOperation_boolean *iface, REFIID iid, void **out ) { - struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); + struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface );
- TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), 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, impl->iid)) + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IAsyncOperation_boolean )) { - IInspectable_AddRef((*out = &impl->IAsyncOperation_IInspectable_iface)); + IInspectable_AddRef( (*out = &impl->IAsyncOperation_boolean_iface) ); return S_OK; }
- if (IsEqualGUID(iid, &IID_IAsyncInfo)) - { - IInspectable_AddRef((*out = &impl->IAsyncInfo_iface)); - return S_OK; - } - - WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); - *out = NULL; - return E_NOINTERFACE; + return IAsyncInfoImpl_QueryInterface( impl->IAsyncInfoImpl_inner, iid, out ); }
-static ULONG WINAPI async_inspectable_AddRef( IAsyncOperation_IInspectable *iface ) +static ULONG WINAPI async_bool_AddRef( IAsyncOperation_boolean *iface ) { - struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); - ULONG ref = InterlockedIncrement(&impl->ref); - TRACE("iface %p, ref %lu.\n", iface, ref); + struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); return ref; }
-static ULONG WINAPI async_inspectable_Release( IAsyncOperation_IInspectable *iface ) +static ULONG WINAPI async_bool_Release( IAsyncOperation_boolean *iface ) { - struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); - - ULONG ref = InterlockedDecrement(&impl->ref); - TRACE("iface %p, ref %lu.\n", iface, ref); + struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref );
if (!ref) { - IAsyncInfo_Close(&impl->IAsyncInfo_iface); - - if (impl->invoker) - IInspectable_Release(impl->invoker); - if (impl->handler && impl->handler != HANDLER_NOT_SET) - IAsyncOperationCompletedHandler_IInspectable_Release(impl->handler); - if (impl->result) - IInspectable_Release(impl->result); - - impl->cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&impl->cs); - free(impl); + /* guard against re-entry if inner releases an outer iface */ + InterlockedIncrement( &impl->ref ); + IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); + free( impl ); }
return ref; }
-static HRESULT WINAPI async_inspectable_GetIids( IAsyncOperation_IInspectable *iface, ULONG *iid_count, IID **iids ) +static HRESULT WINAPI async_bool_GetIids( IAsyncOperation_boolean *iface, ULONG *iid_count, IID **iids ) { - FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids); + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); return E_NOTIMPL; }
-static HRESULT WINAPI async_inspectable_GetRuntimeClassName( IAsyncOperation_IInspectable *iface, HSTRING *class_name ) +static HRESULT WINAPI async_bool_GetRuntimeClassName( IAsyncOperation_boolean *iface, HSTRING *class_name ) { - FIXME("iface %p, class_name %p stub!\n", iface, class_name); - return E_NOTIMPL; + return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<Boolean>", + ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<Boolean>"), + class_name ); }
-static HRESULT WINAPI async_inspectable_GetTrustLevel( IAsyncOperation_IInspectable *iface, TrustLevel *trust_level ) +static HRESULT WINAPI async_bool_GetTrustLevel( IAsyncOperation_boolean *iface, TrustLevel *trust_level ) { - FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); return E_NOTIMPL; }
-static HRESULT WINAPI async_inspectable_put_Completed( IAsyncOperation_IInspectable *iface, - IAsyncOperationCompletedHandler_IInspectable *handler ) +static HRESULT WINAPI async_bool_put_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean *bool_handler ) { - struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); - HRESULT hr = S_OK; + IAsyncOperationCompletedHandlerImpl *handler = (IAsyncOperationCompletedHandlerImpl *)bool_handler; + struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + TRACE( "iface %p, handler %p.\n", iface, handler ); + return IAsyncInfoImpl_put_Completed( impl->IAsyncInfoImpl_inner, handler ); +}
- TRACE("iface %p, handler %p.\n", iface, handler); - - EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - hr = E_ILLEGAL_METHOD_CALL; - else if (impl->handler != HANDLER_NOT_SET) - hr = E_ILLEGAL_DELEGATE_ASSIGNMENT; - /* - impl->handler can only be set once with async_inspectable_put_Completed, - so by default we set a non HANDLER_NOT_SET value, in this case handler. - */ - else if ((impl->handler = handler)) - { - IAsyncOperationCompletedHandler_IInspectable_AddRef(impl->handler); +static HRESULT WINAPI async_bool_get_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean **bool_handler ) +{ + IAsyncOperationCompletedHandlerImpl **handler = (IAsyncOperationCompletedHandlerImpl **)bool_handler; + struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + TRACE( "iface %p, handler %p.\n", iface, handler ); + return IAsyncInfoImpl_get_Completed( impl->IAsyncInfoImpl_inner, handler ); +}
- if (impl->status > Started) - { - IAsyncOperation_IInspectable *operation = &impl->IAsyncOperation_IInspectable_iface; - AsyncStatus status = impl->status; - impl->handler = NULL; /* Prevent concurrent invoke. */ - LeaveCriticalSection(&impl->cs); +static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOOLEAN *results ) +{ + struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + PROPVARIANT result = {.vt = VT_BOOL}; + HRESULT hr;
- IAsyncOperationCompletedHandler_IInspectable_Invoke(handler, operation, status); - IAsyncOperationCompletedHandler_IInspectable_Release(handler); + TRACE( "iface %p, results %p.\n", iface, results );
- return S_OK; - } - } - LeaveCriticalSection(&impl->cs); + hr = IAsyncInfoImpl_get_Result( impl->IAsyncInfoImpl_inner, &result );
+ *results = result.boolVal; + PropVariantClear( &result ); return hr; }
-static HRESULT WINAPI async_inspectable_get_Completed( IAsyncOperation_IInspectable *iface, - IAsyncOperationCompletedHandler_IInspectable **handler ) +static const struct IAsyncOperation_booleanVtbl async_bool_vtbl = { - struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); - HRESULT hr = S_OK; + /* IUnknown methods */ + async_bool_QueryInterface, + async_bool_AddRef, + async_bool_Release, + /* IInspectable methods */ + async_bool_GetIids, + async_bool_GetRuntimeClassName, + async_bool_GetTrustLevel, + /* IAsyncOperation<boolean> */ + async_bool_put_Completed, + async_bool_get_Completed, + async_bool_GetResults, +};
- FIXME("iface %p, handler %p semi stub!\n", iface, handler); +HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, + IAsyncOperation_boolean **out ) +{ + struct async_bool *impl; + HRESULT hr;
- EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - hr = E_ILLEGAL_METHOD_CALL; - *handler = (impl->handler != HANDLER_NOT_SET) ? impl->handler : NULL; - LeaveCriticalSection(&impl->cs); + *out = NULL; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; + impl->IAsyncOperation_boolean_iface.lpVtbl = &async_bool_vtbl; + impl->ref = 1;
- return hr; + if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IAsyncInfoImpl_inner )) || + FAILED(hr = IAsyncInfoImpl_Start( impl->IAsyncInfoImpl_inner ))) + { + if (impl->IAsyncInfoImpl_inner) IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); + free( impl ); + return hr; + } + + *out = &impl->IAsyncOperation_boolean_iface; + TRACE( "created IAsyncOperation_boolean %p\n", *out ); + return S_OK; }
-static HRESULT WINAPI async_inspectable_GetResults( IAsyncOperation_IInspectable *iface, IInspectable **results ) +struct async_action { - /* NOTE: Despite the name, this function only returns one result! */ - struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); - HRESULT hr; + IAsyncAction IAsyncAction_iface; + IAsyncInfoImpl *IAsyncInfoImpl_inner; + LONG ref; +}; + +static inline struct async_action *impl_from_IAsyncAction( IAsyncAction *iface ) +{ + return CONTAINING_RECORD( iface, struct async_action, IAsyncAction_iface ); +} + +static HRESULT WINAPI async_action_QueryInterface( IAsyncAction *iface, REFIID iid, void **out ) +{ + struct async_action *impl = impl_from_IAsyncAction( iface );
- TRACE("iface %p, results %p.\n", iface, results); + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
- EnterCriticalSection(&impl->cs); - if (impl->status != Completed && impl->status != Error) - hr = E_ILLEGAL_METHOD_CALL; - else if (!impl->result) - hr = E_UNEXPECTED; - else + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IAsyncAction )) { - *results = impl->result; - impl->result = NULL; /* NOTE: AsyncOperation gives up it's reference to result here! */ - hr = impl->hr; + IInspectable_AddRef( (*out = &impl->IAsyncAction_iface) ); + return S_OK; } - LeaveCriticalSection(&impl->cs);
- return hr; + return IAsyncInfoImpl_QueryInterface( impl->IAsyncInfoImpl_inner, iid, out ); }
-static const struct IAsyncOperation_IInspectableVtbl async_inspectable_vtbl = +static ULONG WINAPI async_action_AddRef( IAsyncAction *iface ) { - /* IUnknown methods */ - async_inspectable_QueryInterface, - async_inspectable_AddRef, - async_inspectable_Release, - /* IInspectable methods */ - async_inspectable_GetIids, - async_inspectable_GetRuntimeClassName, - async_inspectable_GetTrustLevel, - /* IAsyncOperation<IInspectable*> */ - async_inspectable_put_Completed, - async_inspectable_get_Completed, - async_inspectable_GetResults -}; + struct async_action *impl = impl_from_IAsyncAction( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +}
-/* - * - * IAsyncInfo for IAsyncOperation<IInspectable*> - * - */ +static ULONG WINAPI async_action_Release( IAsyncAction *iface ) +{ + struct async_action *impl = impl_from_IAsyncAction( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + + if (!ref) + { + /* guard against re-entry if inner releases an outer iface */ + InterlockedIncrement( &impl->ref ); + IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); + free( impl ); + }
-DEFINE_IINSPECTABLE_(async_inspectable_info, IAsyncInfo, struct async_inspectable, - async_inspectable_impl_from_IAsyncInfo, IAsyncInfo_iface, &impl->IAsyncOperation_IInspectable_iface) + return ref; +}
-static HRESULT WINAPI async_inspectable_info_get_Id( IAsyncInfo *iface, UINT32 *id ) +static HRESULT WINAPI async_action_GetIids( IAsyncAction *iface, ULONG *iid_count, IID **iids ) { - FIXME("iface %p, id %p stub!\n", iface, id); + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); return E_NOTIMPL; }
-static HRESULT WINAPI async_inspectable_info_get_Status( IAsyncInfo *iface, AsyncStatus *status ) +static HRESULT WINAPI async_action_GetRuntimeClassName( IAsyncAction *iface, HSTRING *class_name ) { - struct async_inspectable *impl = async_inspectable_impl_from_IAsyncInfo(iface); - HRESULT hr = S_OK; + return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<Boolean>", + ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<Boolean>"), + class_name ); +}
- TRACE("iface %p, status %p.\n", iface, status); +static HRESULT WINAPI async_action_GetTrustLevel( IAsyncAction *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +}
- EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - hr = E_ILLEGAL_METHOD_CALL; - *status = impl->status; - LeaveCriticalSection(&impl->cs); +static HRESULT WINAPI async_action_put_Completed( IAsyncAction *iface, IAsyncActionCompletedHandler *bool_handler ) +{ + IAsyncOperationCompletedHandlerImpl *handler = (IAsyncOperationCompletedHandlerImpl *)bool_handler; + struct async_action *impl = impl_from_IAsyncAction( iface ); + TRACE( "iface %p, handler %p.\n", iface, handler ); + return IAsyncInfoImpl_put_Completed( impl->IAsyncInfoImpl_inner, handler ); +} + +static HRESULT WINAPI async_action_get_Completed( IAsyncAction *iface, IAsyncActionCompletedHandler **bool_handler ) +{ + IAsyncOperationCompletedHandlerImpl **handler = (IAsyncOperationCompletedHandlerImpl **)bool_handler; + struct async_action *impl = impl_from_IAsyncAction( iface ); + TRACE( "iface %p, handler %p.\n", iface, handler ); + return IAsyncInfoImpl_get_Completed( impl->IAsyncInfoImpl_inner, handler ); +} + +static HRESULT WINAPI async_action_GetResults( IAsyncAction *iface ) +{ + struct async_action *impl = impl_from_IAsyncAction( iface ); + PROPVARIANT result; + HRESULT hr;
+ TRACE( "iface %p.\n", iface ); + + PropVariantInit( &result ); + hr = IAsyncInfoImpl_get_Result( impl->IAsyncInfoImpl_inner, &result ); + PropVariantClear( &result ); return hr; }
-static HRESULT WINAPI async_inspectable_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) +static const struct IAsyncActionVtbl async_action_vtbl = { - struct async_inspectable *impl = async_inspectable_impl_from_IAsyncInfo(iface); - HRESULT hr = S_OK; + /* IUnknown methods */ + async_action_QueryInterface, + async_action_AddRef, + async_action_Release, + /* IInspectable methods */ + async_action_GetIids, + async_action_GetRuntimeClassName, + async_action_GetTrustLevel, + /* IAsyncOperation<boolean> */ + async_action_put_Completed, + async_action_get_Completed, + async_action_GetResults, +};
- TRACE("iface %p, error_code %p.\n", iface, error_code); +HRESULT async_action_create( IUnknown *invoker, async_operation_callback callback, IAsyncAction **out ) +{ + struct async_action *impl; + HRESULT hr;
- EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - *error_code = hr = E_ILLEGAL_METHOD_CALL; - else - *error_code = impl->hr; - LeaveCriticalSection(&impl->cs); + *out = NULL; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; + impl->IAsyncAction_iface.lpVtbl = &async_action_vtbl; + impl->ref = 1;
- return hr; + if (FAILED(hr = async_info_create( invoker, NULL, callback, (IInspectable *)&impl->IAsyncAction_iface, &impl->IAsyncInfoImpl_inner )) || + FAILED(hr = IAsyncInfoImpl_Start( impl->IAsyncInfoImpl_inner ))) + { + if (impl->IAsyncInfoImpl_inner) IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); + free( impl ); + return hr; + } + + *out = &impl->IAsyncAction_iface; + TRACE( "created IAsyncAction %p\n", *out ); + return S_OK; }
-static HRESULT WINAPI async_inspectable_info_Cancel( IAsyncInfo *iface ) +struct async_inspectable { - struct async_inspectable *impl = async_inspectable_impl_from_IAsyncInfo(iface); - HRESULT hr = S_OK; + IAsyncOperation_IInspectable IAsyncOperation_IInspectable_iface; + IAsyncInfoImpl *IAsyncInfoImpl_inner; + LONG ref; + const GUID *iid; +}; + +static inline struct async_inspectable *impl_from_IAsyncOperation_IInspectable( IAsyncOperation_IInspectable *iface ) +{ + return CONTAINING_RECORD( iface, struct async_inspectable, IAsyncOperation_IInspectable_iface ); +} + +static HRESULT WINAPI async_inspectable_QueryInterface( IAsyncOperation_IInspectable *iface, REFIID iid, void **out ) +{ + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface );
- TRACE("iface %p.\n", iface); + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
- EnterCriticalSection(&impl->cs); - if (impl->status == Closed) - hr = E_ILLEGAL_METHOD_CALL; - else if (impl->status == Started) - impl->status = Canceled; - LeaveCriticalSection(&impl->cs); + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, impl->iid )) + { + IInspectable_AddRef( (*out = &impl->IAsyncOperation_IInspectable_iface) ); + return S_OK; + }
- return hr; + return IAsyncInfoImpl_QueryInterface( impl->IAsyncInfoImpl_inner, iid, out ); }
-static HRESULT WINAPI async_inspectable_info_Close( IAsyncInfo *iface ) +static ULONG WINAPI async_inspectable_AddRef( IAsyncOperation_IInspectable *iface ) { - struct async_inspectable *impl = async_inspectable_impl_from_IAsyncInfo(iface); - HRESULT hr = S_OK; + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +}
- TRACE("iface %p.\n", iface); +static ULONG WINAPI async_inspectable_Release( IAsyncOperation_IInspectable *iface ) +{ + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref );
- EnterCriticalSection(&impl->cs); - if (impl->status == Started) - hr = E_ILLEGAL_STATE_CHANGE; - else if (impl->status != Closed) + if (!ref) { - CloseThreadpoolWork(impl->async_run_work); - impl->async_run_work = NULL; - impl->status = Closed; + /* guard against re-entry if inner releases an outer iface */ + InterlockedIncrement( &impl->ref ); + IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); + free( impl ); } - LeaveCriticalSection(&impl->cs);
- return hr; + return ref; }
-static const struct IAsyncInfoVtbl async_inspectable_info_vtbl = +static HRESULT WINAPI async_inspectable_GetIids( IAsyncOperation_IInspectable *iface, ULONG *iid_count, IID **iids ) { - /* IUnknown methods */ - async_inspectable_info_QueryInterface, - async_inspectable_info_AddRef, - async_inspectable_info_Release, - /* IInspectable methods */ - async_inspectable_info_GetIids, - async_inspectable_info_GetRuntimeClassName, - async_inspectable_info_GetTrustLevel, - /* IAsyncInfo */ - async_inspectable_info_get_Id, - async_inspectable_info_get_Status, - async_inspectable_info_get_ErrorCode, - async_inspectable_info_Cancel, - async_inspectable_info_Close -}; + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +}
-static void CALLBACK async_inspectable_run_cb(TP_CALLBACK_INSTANCE *instance, void *data, TP_WORK *work) +static HRESULT WINAPI async_inspectable_GetRuntimeClassName( IAsyncOperation_IInspectable *iface, HSTRING *class_name ) { - IAsyncOperation_IInspectable *operation = data; - IInspectable *result = NULL; - struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(operation); - HRESULT hr; + return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<IInspectable>", + ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<IInspectable>"), + class_name ); +}
- hr = impl->callback(impl->invoker, &result); +static HRESULT WINAPI async_inspectable_GetTrustLevel( IAsyncOperation_IInspectable *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +}
- EnterCriticalSection(&impl->cs); - if (impl->status < Closed) - impl->status = FAILED(hr) ? Error : Completed; +static HRESULT WINAPI async_inspectable_put_Completed( IAsyncOperation_IInspectable *iface, IAsyncOperationCompletedHandler_IInspectable *bool_handler ) +{ + IAsyncOperationCompletedHandlerImpl *handler = (IAsyncOperationCompletedHandlerImpl *)bool_handler; + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); + TRACE( "iface %p, handler %p.\n", iface, handler ); + return IAsyncInfoImpl_put_Completed( impl->IAsyncInfoImpl_inner, handler ); +}
- impl->result = result; - impl->hr = hr; +static HRESULT WINAPI async_inspectable_get_Completed( IAsyncOperation_IInspectable *iface, IAsyncOperationCompletedHandler_IInspectable **bool_handler ) +{ + IAsyncOperationCompletedHandlerImpl **handler = (IAsyncOperationCompletedHandlerImpl **)bool_handler; + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); + TRACE( "iface %p, handler %p.\n", iface, handler ); + return IAsyncInfoImpl_get_Completed( impl->IAsyncInfoImpl_inner, handler ); +}
- if (impl->handler != NULL && impl->handler != HANDLER_NOT_SET) - { - IAsyncOperationCompletedHandler_IInspectable *handler = impl->handler; - AsyncStatus status = impl->status; - impl->handler = NULL; /* Prevent concurrent invoke. */ - LeaveCriticalSection(&impl->cs); +static HRESULT WINAPI async_inspectable_GetResults( IAsyncOperation_IInspectable *iface, IInspectable **results ) +{ + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); + PROPVARIANT result = {.vt = VT_UNKNOWN}; + HRESULT hr;
- IAsyncOperationCompletedHandler_IInspectable_Invoke(handler, operation, status); - IAsyncOperationCompletedHandler_IInspectable_Release(handler); + TRACE( "iface %p, results %p.\n", iface, results ); + + if (SUCCEEDED(hr = IAsyncInfoImpl_get_Result( impl->IAsyncInfoImpl_inner, &result ))) + { + if ((*results = (IInspectable *)result.punkVal)) IInspectable_AddRef( *results ); + PropVariantClear( &result ); } - else LeaveCriticalSection(&impl->cs);
- IAsyncOperation_IInspectable_Release(operation); + return hr; }
-HRESULT async_operation_inspectable_create( const GUID *iid, - IInspectable *invoker, - async_operation_inspectable_callback callback, +static const struct IAsyncOperation_IInspectableVtbl async_inspectable_vtbl = +{ + /* IUnknown methods */ + async_inspectable_QueryInterface, + async_inspectable_AddRef, + async_inspectable_Release, + /* IInspectable methods */ + async_inspectable_GetIids, + async_inspectable_GetRuntimeClassName, + async_inspectable_GetTrustLevel, + /* IAsyncOperation<IInspectable> */ + async_inspectable_put_Completed, + async_inspectable_get_Completed, + async_inspectable_GetResults, +}; + +HRESULT async_operation_inspectable_create( const GUID *iid, IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_IInspectable **out ) { struct async_inspectable *impl; - - TRACE("iid %s, invoker %p, callback %p, out %p.\n", debugstr_guid(iid), invoker, callback, out); + HRESULT hr;
*out = NULL; - if (!(impl = calloc(1, sizeof(*impl)))) return E_OUTOFMEMORY; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IAsyncOperation_IInspectable_iface.lpVtbl = &async_inspectable_vtbl; - impl->IAsyncInfo_iface.lpVtbl = &async_inspectable_info_vtbl; - impl->iid = iid; impl->ref = 1; + impl->iid = iid;
- impl->handler = HANDLER_NOT_SET; - impl->callback = callback; - impl->status = Started; - - if (!(impl->async_run_work = CreateThreadpoolWork(async_inspectable_run_cb, &impl->IAsyncOperation_IInspectable_iface, NULL))) + if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_IInspectable_iface, &impl->IAsyncInfoImpl_inner )) || + FAILED(hr = IAsyncInfoImpl_Start( impl->IAsyncInfoImpl_inner ))) { - free(impl); - return HRESULT_FROM_WIN32(GetLastError()); + if (impl->IAsyncInfoImpl_inner) IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); + free( impl ); + return hr; }
- if (invoker) IInspectable_AddRef((impl->invoker = invoker)); - - InitializeCriticalSectionEx(&impl->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); - impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": async_operation.cs"); - - /* AddRef to keep the obj alive in the callback. */ - IAsyncOperation_IInspectable_AddRef(&impl->IAsyncOperation_IInspectable_iface); - SubmitThreadpoolWork(impl->async_run_work); - *out = &impl->IAsyncOperation_IInspectable_iface; - TRACE("created %p\n", *out); + TRACE( "created IAsyncOperation_IInspectable %p\n", *out ); return S_OK; } diff --git a/dlls/windows.media.speech/async_private.idl b/dlls/windows.media.speech/async_private.idl new file mode 100644 index 00000000000..10741572601 --- /dev/null +++ b/dlls/windows.media.speech/async_private.idl @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Rémi Bernon for CodeWeavers + * + * 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 + */ + +#pragma makedep header + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "propidl.idl"; +import "inspectable.idl"; +import "asyncinfo.idl"; +import "windowscontracts.idl"; + +namespace Wine.Internal { + /* type-pruning version of AsyncOperationCompletedHandlerImpl<T> */ + delegate HRESULT AsyncOperationCompletedHandlerImpl([in] IInspectable *async, [in] AsyncStatus status); + + [ + uuid(d81ab70d-82e0-481c-983d-401225d98a2c) + ] + interface IAsyncInfoImpl : IUnknown + { + [propput] HRESULT Completed([in] AsyncOperationCompletedHandlerImpl *handler); + [propget] HRESULT Completed([out, retval] AsyncOperationCompletedHandlerImpl **handler); + [propget] HRESULT Result([out, retval] PROPVARIANT *result); + HRESULT Start(); + } + + typedef HRESULT (*async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); +} diff --git a/dlls/windows.media.speech/private.h b/dlls/windows.media.speech/private.h index e80d73ec1fb..fb5b936fb01 100644 --- a/dlls/windows.media.speech/private.h +++ b/dlls/windows.media.speech/private.h @@ -43,6 +43,8 @@
#include "wine/list.h"
+#include "async_private.h" + /* * * Windows.Media.SpeechRecognition @@ -70,11 +72,8 @@ struct vector_iids const GUID *view; };
-typedef HRESULT (*async_action_callback)( IInspectable *invoker ); -typedef HRESULT (*async_operation_inspectable_callback)( IInspectable *invoker, IInspectable **result ); - -HRESULT async_action_create( IInspectable *invoker, async_action_callback callback, IAsyncAction **out ); -HRESULT async_operation_inspectable_create( const GUID *iid, IInspectable *invoker, async_operation_inspectable_callback callback, +HRESULT async_action_create( IUnknown *invoker, async_operation_callback callback, IAsyncAction **out ); +HRESULT async_operation_inspectable_create( const GUID *iid, IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_IInspectable **out );
HRESULT typed_event_handlers_append( struct list *list, ITypedEventHandler_IInspectable_IInspectable *handler, EventRegistrationToken *token ); diff --git a/dlls/windows.media.speech/recognizer.c b/dlls/windows.media.speech/recognizer.c index a98970d35f9..5c83beec063 100644 --- a/dlls/windows.media.speech/recognizer.c +++ b/dlls/windows.media.speech/recognizer.c @@ -382,7 +382,7 @@ static HRESULT WINAPI session_set_AutoStopSilenceTimeout( ISpeechContinuousRecog return E_NOTIMPL; }
-static HRESULT session_start_async( IInspectable *invoker ) +static HRESULT session_start_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { return S_OK; } @@ -431,7 +431,7 @@ static HRESULT WINAPI session_StartWithModeAsync( ISpeechContinuousRecognitionSe return E_NOTIMPL; }
-static HRESULT session_stop_async( IInspectable *invoker ) +static HRESULT session_stop_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { return S_OK; } @@ -487,7 +487,7 @@ static HRESULT WINAPI session_CancelAsync( ISpeechContinuousRecognitionSession * return E_NOTIMPL; }
-static HRESULT session_pause_async( IInspectable *invoker ) +static HRESULT session_pause_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { return S_OK; } @@ -725,9 +725,17 @@ static HRESULT WINAPI recognizer_get_UIOptions( ISpeechRecognizer *iface, ISpeec return E_NOTIMPL; }
-static HRESULT recognizer_compile_constraints_async( IInspectable *invoker, IInspectable **result ) +static HRESULT recognizer_compile_constraints_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - return compilation_result_create(SpeechRecognitionResultStatus_Success, (ISpeechRecognitionCompilationResult **) result); + ISpeechRecognitionCompilationResult *compilation; + HRESULT hr; + + if (SUCCEEDED(hr = compilation_result_create(SpeechRecognitionResultStatus_Success, &compilation))) + { + result->vt = VT_UNKNOWN; + result->punkVal = (IUnknown *)compilation; + } + return hr; }
static HRESULT WINAPI recognizer_CompileConstraintsAsync( ISpeechRecognizer *iface, @@ -735,7 +743,7 @@ static HRESULT WINAPI recognizer_CompileConstraintsAsync( ISpeechRecognizer *ifa { IAsyncOperation_IInspectable **value = (IAsyncOperation_IInspectable **)operation; FIXME("iface %p, operation %p semi-stub!\n", iface, operation); - return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechRecognitionCompilationResult, NULL, recognizer_compile_constraints_async, value); + return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechRecognitionCompilationResult, NULL, NULL, recognizer_compile_constraints_async, value); }
static HRESULT WINAPI recognizer_RecognizeAsync( ISpeechRecognizer *iface, diff --git a/dlls/windows.media.speech/synthesizer.c b/dlls/windows.media.speech/synthesizer.c index 39d14b84ab7..80968333c8a 100644 --- a/dlls/windows.media.speech/synthesizer.c +++ b/dlls/windows.media.speech/synthesizer.c @@ -375,29 +375,45 @@ static HRESULT WINAPI synthesizer_GetTrustLevel( ISpeechSynthesizer *iface, Trus return E_NOTIMPL; }
-static HRESULT synthesizer_synthesize_text_to_stream_async( IInspectable *invoker, IInspectable **result ) +static HRESULT synthesizer_synthesize_text_to_stream_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - return synthesis_stream_create((ISpeechSynthesisStream **)result); + ISpeechSynthesisStream *stream; + HRESULT hr; + + if (SUCCEEDED(hr = synthesis_stream_create(&stream))) + { + result->vt = VT_UNKNOWN; + result->punkVal = (IUnknown *)stream; + } + return hr; }
static HRESULT WINAPI synthesizer_SynthesizeTextToStreamAsync( ISpeechSynthesizer *iface, HSTRING text, IAsyncOperation_SpeechSynthesisStream **operation ) { TRACE("iface %p, text %p, operation %p.\n", iface, text, operation); - return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechSynthesisStream, NULL, + return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechSynthesisStream, NULL, NULL, synthesizer_synthesize_text_to_stream_async, (IAsyncOperation_IInspectable **)operation); }
-static HRESULT synthesizer_synthesize_ssml_to_stream_async( IInspectable *invoker, IInspectable **result ) +static HRESULT synthesizer_synthesize_ssml_to_stream_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - return synthesis_stream_create((ISpeechSynthesisStream **)result); + ISpeechSynthesisStream *stream; + HRESULT hr; + + if (SUCCEEDED(hr = synthesis_stream_create(&stream))) + { + result->vt = VT_UNKNOWN; + result->punkVal = (IUnknown *)stream; + } + return hr; }
static HRESULT WINAPI synthesizer_SynthesizeSsmlToStreamAsync( ISpeechSynthesizer *iface, HSTRING ssml, IAsyncOperation_SpeechSynthesisStream **operation ) { TRACE("iface %p, ssml %p, operation %p.\n", iface, ssml, operation); - return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechSynthesisStream, NULL, + return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechSynthesisStream, NULL, NULL, synthesizer_synthesize_ssml_to_stream_async, (IAsyncOperation_IInspectable **)operation); }
diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c index ea1487d379c..7da2457bf38 100644 --- a/dlls/windows.media.speech/tests/speech.c +++ b/dlls/windows.media.speech/tests/speech.c @@ -431,9 +431,9 @@ static void check_async_info_( unsigned int line, IInspectable *async_obj, UINT3
async_id = 0xdeadbeef; hr = IAsyncInfo_get_Id(async_info, &async_id); - if (expect_status < 4) todo_wine ok_(__FILE__, line)(hr == S_OK, "IAsyncInfo_get_Id returned %#lx\n", hr); - else todo_wine ok_(__FILE__, line)(hr == E_ILLEGAL_METHOD_CALL, "IAsyncInfo_get_Id returned %#lx\n", hr); - todo_wine ok_(__FILE__, line)(async_id == expect_id, "got async_id %#x\n", async_id); + if (expect_status < 4) ok_(__FILE__, line)(hr == S_OK, "IAsyncInfo_get_Id returned %#lx\n", hr); + else ok_(__FILE__, line)(hr == E_ILLEGAL_METHOD_CALL, "IAsyncInfo_get_Id returned %#lx\n", hr); + todo_wine_if(expect_id != 1) ok_(__FILE__, line)(async_id == expect_id, "got async_id %#x\n", async_id);
async_status = 0xdeadbeef; hr = IAsyncInfo_get_Status(async_info, &async_status); @@ -787,7 +787,7 @@ static void test_SpeechSynthesizer(void) IVectorView_IMediaMarker *media_markers = NULL; IVectorView_VoiceInformation *voices = NULL; IInstalledVoicesStatic *voices_static = NULL; - ISpeechSynthesisStream *ss_stream = NULL; + ISpeechSynthesisStream *ss_stream = NULL, *tmp; IVoiceInformation *voice; IInspectable *inspectable = NULL, *tmp_inspectable = NULL; IAgileObject *agile_object = NULL, *tmp_agile_object = NULL; @@ -943,6 +943,14 @@ static void test_SpeechSynthesizer(void) hr = IAsyncOperation_SpeechSynthesisStream_GetResults(operation_ss_stream, &ss_stream); ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr);
+ tmp = (void *)0xdeadbeef; + hr = IAsyncOperation_SpeechSynthesisStream_GetResults(operation_ss_stream, &tmp); + ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr); + todo_wine ok(tmp == NULL, "Got %p.\n", tmp); + if (tmp && tmp != (void *)0xdeadbeef) ISpeechSynthesisStream_Release(tmp); + + IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream); + hr = ISpeechSynthesisStream_get_Markers(ss_stream, &media_markers); ok(hr == S_OK, "ISpeechSynthesisStream_get_Markers failed, hr %#lx\n", hr); check_interface(media_markers, &IID_IVectorView_IMediaMarker, TRUE); @@ -955,8 +963,6 @@ static void test_SpeechSynthesizer(void) ref = ISpeechSynthesisStream_Release(ss_stream); ok(ref == 0, "Got unexpected ref %lu.\n", ref);
- IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream); - /* Test SynthesizeSsmlToStreamAsync */ hr = WindowsCreateString(simple_ssml, wcslen(simple_ssml), &str2); ok(hr == S_OK, "WindowsCreateString failed, hr %#lx\n", hr); @@ -975,12 +981,11 @@ static void test_SpeechSynthesizer(void) ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr); check_interface(ss_stream, &IID_ISpeechSynthesisStream, TRUE); check_interface(ss_stream, &IID_IAgileObject, TRUE); + IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream);
ref = ISpeechSynthesisStream_Release(ss_stream); ok(ref == 0, "Got unexpected ref %lu.\n", ref);
- IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream); - operation_ss_stream = (void *)0xdeadbeef; hr = ISpeechSynthesizer_SynthesizeSsmlToStreamAsync(synthesizer, NULL, &operation_ss_stream); /* Broken on Win 8 + 8.1 */ @@ -1283,10 +1288,13 @@ static void test_SpeechRecognizer(void) ok(result_status == SpeechRecognitionResultStatus_Success, "Got unexpected status %#x.\n", result_status);
ref = ISpeechRecognitionCompilationResult_Release(compilation_result); - ok(!ref , "Got unexpected ref %lu.\n", ref); + todo_wine ok(!ref , "Got unexpected ref %lu.\n", ref);
+ compilation_result = (void *)0xdeadbeef; hr = IAsyncOperation_SpeechRecognitionCompilationResult_GetResults(operation, &compilation_result); - ok(hr == E_UNEXPECTED, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(hr == E_UNEXPECTED, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(compilation_result == NULL, "Got %p.\n", compilation_result); + if (compilation_result && compilation_result != (void *)0xdeadbeef) ISpeechRecognitionCompilationResult_Release(compilation_result);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_QueryInterface(operation, &IID_IAsyncInfo, (void **)&info); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/cryptowinrt/Makefile.in | 4 +- dlls/cryptowinrt/async.c | 102 +++++++++--------- .../{provider.idl => async_private.idl} | 19 ++-- dlls/cryptowinrt/credentials.c | 2 +- dlls/cryptowinrt/private.h | 3 +- 5 files changed, 66 insertions(+), 64 deletions(-) rename dlls/cryptowinrt/{provider.idl => async_private.idl} (67%)
diff --git a/dlls/cryptowinrt/Makefile.in b/dlls/cryptowinrt/Makefile.in index 8d9d23a6cc2..5101fc88bf3 100644 --- a/dlls/cryptowinrt/Makefile.in +++ b/dlls/cryptowinrt/Makefile.in @@ -3,7 +3,7 @@ IMPORTS = combase bcrypt uuid
SOURCES = \ async.c \ + async_private.idl \ classes.idl \ credentials.c \ - main.c \ - provider.idl + main.c diff --git a/dlls/cryptowinrt/async.c b/dlls/cryptowinrt/async.c index 5c3d718ae2d..3ad5d965cb9 100644 --- a/dlls/cryptowinrt/async.c +++ b/dlls/cryptowinrt/async.c @@ -1,4 +1,4 @@ -/* CryptoWinRT Implementation +/* WinRT IAsync* implementation * * Copyright 2022 Bernhard Kölbl for CodeWeavers * Copyright 2022 Rémi Bernon for CodeWeavers @@ -18,18 +18,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define WIDL_using_Wine_Internal #include "private.h" +#include "initguid.h" +#include "async_private.h"
#include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(crypto); +WINE_DEFAULT_DEBUG_CHANNEL(input);
#define Closed 4 #define HANDLER_NOT_SET ((void *)~(ULONG_PTR)0)
struct async_info { - IWineAsyncInfoImpl IWineAsyncInfoImpl_iface; + IAsyncInfoImpl IAsyncInfoImpl_iface; IAsyncInfo IAsyncInfo_iface; IInspectable *IInspectable_outer; LONG ref; @@ -40,29 +43,29 @@ struct async_info IUnknown *param;
CRITICAL_SECTION cs; - IWineAsyncOperationCompletedHandler *handler; + IAsyncOperationCompletedHandlerImpl *handler; PROPVARIANT result; AsyncStatus status; HRESULT hr; };
-static inline struct async_info *impl_from_IWineAsyncInfoImpl( IWineAsyncInfoImpl *iface ) +static inline struct async_info *impl_from_IAsyncInfoImpl( IAsyncInfoImpl *iface ) { - return CONTAINING_RECORD( iface, struct async_info, IWineAsyncInfoImpl_iface ); + return CONTAINING_RECORD( iface, struct async_info, IAsyncInfoImpl_iface ); }
-static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFIID iid, void **out ) +static HRESULT WINAPI async_impl_QueryInterface( IAsyncInfoImpl *iface, REFIID iid, void **out ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
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_IWineAsyncInfoImpl )) + IsEqualGUID( iid, &IID_IAsyncInfoImpl )) { - IInspectable_AddRef( (*out = &impl->IWineAsyncInfoImpl_iface) ); + IInspectable_AddRef( (*out = &impl->IAsyncInfoImpl_iface) ); return S_OK; }
@@ -77,26 +80,27 @@ static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFI return E_NOINTERFACE; }
-static ULONG WINAPI async_impl_AddRef( IWineAsyncInfoImpl *iface ) +static ULONG WINAPI async_impl_AddRef( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref ); return ref; }
-static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) +static ULONG WINAPI async_impl_Release( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref );
if (!ref) { - if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); + if (impl->handler && impl->handler != HANDLER_NOT_SET) IAsyncOperationCompletedHandlerImpl_Release( impl->handler ); IAsyncInfo_Close( &impl->IAsyncInfo_iface ); if (impl->param) IUnknown_Release( impl->param ); if (impl->invoker) IUnknown_Release( impl->invoker ); + PropVariantClear( &impl->result ); impl->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &impl->cs ); free( impl ); @@ -105,9 +109,9 @@ static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) return ref; }
-static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) +static HRESULT WINAPI async_impl_put_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl *handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -117,7 +121,7 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine else if (impl->handler != HANDLER_NOT_SET) hr = E_ILLEGAL_DELEGATE_ASSIGNMENT; else if ((impl->handler = handler)) { - IWineAsyncOperationCompletedHandler_AddRef( impl->handler ); + IAsyncOperationCompletedHandlerImpl_AddRef( impl->handler );
if (impl->status > Started) { @@ -126,8 +130,8 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs );
- IWineAsyncOperationCompletedHandler_Invoke( handler, operation, status ); - IWineAsyncOperationCompletedHandler_Release( handler ); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler );
return S_OK; } @@ -137,9 +141,9 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine return hr; }
-static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler **handler ) +static HRESULT WINAPI async_impl_get_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl **handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -147,15 +151,15 @@ static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWine EnterCriticalSection( &impl->cs ); if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; if (impl->handler == NULL || impl->handler == HANDLER_NOT_SET) *handler = NULL; - else IWineAsyncOperationCompletedHandler_AddRef( (*handler = impl->handler) ); + else IAsyncOperationCompletedHandlerImpl_AddRef( (*handler = impl->handler) ); LeaveCriticalSection( &impl->cs );
return hr; }
-static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARIANT *result ) +static HRESULT WINAPI async_impl_get_Result( IAsyncInfoImpl *iface, PROPVARIANT *result ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = E_ILLEGAL_METHOD_CALL;
TRACE( "iface %p, result %p.\n", iface, result ); @@ -171,9 +175,9 @@ static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARI return hr; }
-static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) +static HRESULT WINAPI async_impl_Start( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
TRACE( "iface %p.\n", iface );
@@ -184,13 +188,13 @@ static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) return S_OK; }
-static const struct IWineAsyncInfoImplVtbl async_impl_vtbl = +static const struct IAsyncInfoImplVtbl async_impl_vtbl = { /* IUnknown methods */ async_impl_QueryInterface, async_impl_AddRef, async_impl_Release, - /* IWineAsyncInfoImpl */ + /* IAsyncInfoImpl */ async_impl_put_Completed, async_impl_get_Completed, async_impl_get_Result, @@ -300,9 +304,9 @@ static const struct IAsyncInfoVtbl async_info_vtbl =
static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *iface, TP_WORK *work ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); IInspectable *operation = impl->IInspectable_outer; - PROPVARIANT result; + PROPVARIANT result = {0}; HRESULT hr;
hr = impl->callback( impl->invoker, impl->param, &result ); @@ -314,13 +318,13 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *
if (impl->handler != NULL && impl->handler != HANDLER_NOT_SET) { - IWineAsyncOperationCompletedHandler *handler = impl->handler; + IAsyncOperationCompletedHandlerImpl *handler = impl->handler; AsyncStatus status = impl->status; impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs );
- IWineAsyncOperationCompletedHandler_Invoke( handler, operation, status ); - IWineAsyncOperationCompletedHandler_Release( handler ); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler ); } else LeaveCriticalSection( &impl->cs );
@@ -331,13 +335,13 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void * }
static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, - IInspectable *outer, IWineAsyncInfoImpl **out ) + IInspectable *outer, IAsyncInfoImpl **out ) { struct async_info *impl; HRESULT hr;
if (!(impl = calloc( 1, sizeof(struct async_info) ))) return E_OUTOFMEMORY; - impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; + impl->IAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; impl->IAsyncInfo_iface.lpVtbl = &async_info_vtbl; impl->IInspectable_outer = outer; impl->ref = 1; @@ -345,7 +349,7 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper impl->callback = callback; impl->handler = HANDLER_NOT_SET; impl->status = Started; - if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IWineAsyncInfoImpl_iface, NULL ))) + if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IAsyncInfoImpl_iface, NULL ))) { hr = HRESULT_FROM_WIN32( GetLastError() ); free( impl ); @@ -358,14 +362,14 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper InitializeCriticalSectionEx( &impl->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO ); impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)( __FILE__ ": async_info.cs" );
- *out = &impl->IWineAsyncInfoImpl_iface; + *out = &impl->IAsyncInfoImpl_iface; return S_OK; }
struct async_bool { IAsyncOperation_boolean IAsyncOperation_boolean_iface; - IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; + IAsyncInfoImpl *IAsyncInfoImpl_inner; LONG ref; };
@@ -389,7 +393,7 @@ static HRESULT WINAPI async_bool_QueryInterface( IAsyncOperation_boolean *iface, return S_OK; }
- return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); + return IAsyncInfoImpl_QueryInterface( impl->IAsyncInfoImpl_inner, iid, out ); }
static ULONG WINAPI async_bool_AddRef( IAsyncOperation_boolean *iface ) @@ -410,7 +414,7 @@ static ULONG WINAPI async_bool_Release( IAsyncOperation_boolean *iface ) { /* guard against re-entry if inner releases an outer iface */ InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); }
@@ -438,18 +442,18 @@ static HRESULT WINAPI async_bool_GetTrustLevel( IAsyncOperation_boolean *iface,
static HRESULT WINAPI async_bool_put_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean *bool_handler ) { - IWineAsyncOperationCompletedHandler *handler = (IWineAsyncOperationCompletedHandler *)bool_handler; + IAsyncOperationCompletedHandlerImpl *handler = (IAsyncOperationCompletedHandlerImpl *)bool_handler; struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler *)handler ); + return IAsyncInfoImpl_put_Completed( impl->IAsyncInfoImpl_inner, handler ); }
static HRESULT WINAPI async_bool_get_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean **bool_handler ) { - IWineAsyncOperationCompletedHandler **handler = (IWineAsyncOperationCompletedHandler **)bool_handler; + IAsyncOperationCompletedHandlerImpl **handler = (IAsyncOperationCompletedHandlerImpl **)bool_handler; struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler **)handler ); + return IAsyncInfoImpl_get_Completed( impl->IAsyncInfoImpl_inner, handler ); }
static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOOLEAN *results ) @@ -460,7 +464,7 @@ static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOO
TRACE( "iface %p, results %p.\n", iface, results );
- hr = IWineAsyncInfoImpl_get_Result( impl->IWineAsyncInfoImpl_inner, &result ); + hr = IAsyncInfoImpl_get_Result( impl->IAsyncInfoImpl_inner, &result );
*results = result.boolVal; PropVariantClear( &result ); @@ -494,10 +498,10 @@ HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, asyn impl->IAsyncOperation_boolean_iface.lpVtbl = &async_bool_vtbl; impl->ref = 1;
- if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IWineAsyncInfoImpl_inner )) || - FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) + if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IAsyncInfoImpl_inner )) || + FAILED(hr = IAsyncInfoImpl_Start( impl->IAsyncInfoImpl_inner ))) { - if (impl->IWineAsyncInfoImpl_inner) IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + if (impl->IAsyncInfoImpl_inner) IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); return hr; } diff --git a/dlls/cryptowinrt/provider.idl b/dlls/cryptowinrt/async_private.idl similarity index 67% rename from dlls/cryptowinrt/provider.idl rename to dlls/cryptowinrt/async_private.idl index 7196119dba0..10741572601 100644 --- a/dlls/cryptowinrt/provider.idl +++ b/dlls/cryptowinrt/async_private.idl @@ -1,5 +1,4 @@ /* - * Copyright 2022 Mohamad Al-Jaf * Copyright 2022 Rémi Bernon for CodeWeavers * * This library is free software; you can redistribute it and/or @@ -26,22 +25,22 @@ import "propidl.idl"; import "inspectable.idl"; import "asyncinfo.idl"; -import "eventtoken.idl"; import "windowscontracts.idl"; -import "windows.foundation.idl";
-namespace Windows.Security.Credentials { - /* type-pruning version of AsyncOperationCompletedHandler<T> */ - delegate HRESULT WineAsyncOperationCompletedHandler([in] IInspectable *async, [in] AsyncStatus status); +namespace Wine.Internal { + /* type-pruning version of AsyncOperationCompletedHandlerImpl<T> */ + delegate HRESULT AsyncOperationCompletedHandlerImpl([in] IInspectable *async, [in] AsyncStatus status);
[ - uuid(83f377ee-c799-11ec-9d64-0242ac120002) + uuid(d81ab70d-82e0-481c-983d-401225d98a2c) ] - interface IWineAsyncInfoImpl : IUnknown + interface IAsyncInfoImpl : IUnknown { - [propput] HRESULT Completed([in] WineAsyncOperationCompletedHandler *handler); - [propget] HRESULT Completed([out, retval] WineAsyncOperationCompletedHandler **handler); + [propput] HRESULT Completed([in] AsyncOperationCompletedHandlerImpl *handler); + [propget] HRESULT Completed([out, retval] AsyncOperationCompletedHandlerImpl **handler); [propget] HRESULT Result([out, retval] PROPVARIANT *result); HRESULT Start(); } + + typedef HRESULT (*async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); } diff --git a/dlls/cryptowinrt/credentials.c b/dlls/cryptowinrt/credentials.c index e23c5d94696..960c5fabf8f 100644 --- a/dlls/cryptowinrt/credentials.c +++ b/dlls/cryptowinrt/credentials.c @@ -118,7 +118,7 @@ static const struct IActivationFactoryVtbl factory_vtbl =
DEFINE_IINSPECTABLE( credentials_statics, IKeyCredentialManagerStatics, struct credentials_statics, IActivationFactory_iface );
-static HRESULT WINAPI is_supported_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) +static HRESULT is_supported_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { result->vt = VT_BOOL; result->boolVal = FALSE; diff --git a/dlls/cryptowinrt/private.h b/dlls/cryptowinrt/private.h index 3ce3620118c..f48b8e721c4 100644 --- a/dlls/cryptowinrt/private.h +++ b/dlls/cryptowinrt/private.h @@ -37,11 +37,10 @@ #define WIDL_using_Windows_Security_Credentials #include "windows.security.credentials.h"
-#include "provider.h" +#include "async_private.h"
extern IActivationFactory *credentials_activation_factory;
-typedef HRESULT (WINAPI *async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); extern HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_boolean **out );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.devices.enumeration/Makefile.in | 2 +- dlls/windows.devices.enumeration/async.c | 196 +++++++++--------- .../{async.idl => async_private.idl} | 14 +- dlls/windows.devices.enumeration/main.c | 5 +- dlls/windows.devices.enumeration/private.h | 7 +- 5 files changed, 119 insertions(+), 105 deletions(-) rename dlls/windows.devices.enumeration/{async.idl => async_private.idl} (70%)
diff --git a/dlls/windows.devices.enumeration/Makefile.in b/dlls/windows.devices.enumeration/Makefile.in index 1d3bf5a69a3..5e3f6fbb6fa 100644 --- a/dlls/windows.devices.enumeration/Makefile.in +++ b/dlls/windows.devices.enumeration/Makefile.in @@ -4,7 +4,7 @@ IMPORTS = advapi32 combase setupapi uuid SOURCES = \ access.c \ async.c \ - async.idl \ + async_private.idl \ classes.idl \ event_handlers.c \ information.c \ diff --git a/dlls/windows.devices.enumeration/async.c b/dlls/windows.devices.enumeration/async.c index ffb05d6c004..852c5870b67 100644 --- a/dlls/windows.devices.enumeration/async.c +++ b/dlls/windows.devices.enumeration/async.c @@ -1,4 +1,6 @@ -/* Copyright 2022 Bernhard Kölbl for CodeWeavers +/* WinRT IAsync* implementation + * + * Copyright 2022 Bernhard Kölbl for CodeWeavers * Copyright 2022 Rémi Bernon for CodeWeavers * * This library is free software; you can redistribute it and/or @@ -16,20 +18,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define WIDL_using_Wine_Internal #include "private.h" -#include <initguid.h> -#include "async.h" +#include "initguid.h" +#include "async_private.h"
-#include <wine/debug.h> +#include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(enumeration); +WINE_DEFAULT_DEBUG_CHANNEL(input);
#define Closed 4 #define HANDLER_NOT_SET ((void *)~(ULONG_PTR)0)
struct async_info { - IWineAsyncInfoImpl IWineAsyncInfoImpl_iface; + IAsyncInfoImpl IAsyncInfoImpl_iface; IAsyncInfo IAsyncInfo_iface; IInspectable *IInspectable_outer; LONG ref; @@ -40,29 +43,29 @@ struct async_info IUnknown *param;
CRITICAL_SECTION cs; - IWineAsyncOperationCompletedHandler *handler; + IAsyncOperationCompletedHandlerImpl *handler; PROPVARIANT result; AsyncStatus status; HRESULT hr; };
-static inline struct async_info *impl_from_IWineAsyncInfoImpl( IWineAsyncInfoImpl *iface ) +static inline struct async_info *impl_from_IAsyncInfoImpl( IAsyncInfoImpl *iface ) { - return CONTAINING_RECORD( iface, struct async_info, IWineAsyncInfoImpl_iface ); + return CONTAINING_RECORD( iface, struct async_info, IAsyncInfoImpl_iface ); }
-static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFIID iid, void **out ) +static HRESULT WINAPI async_impl_QueryInterface( IAsyncInfoImpl *iface, REFIID iid, void **out ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
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_IWineAsyncInfoImpl )) + IsEqualGUID( iid, &IID_IAsyncInfoImpl )) { - IInspectable_AddRef( (*out = &impl->IWineAsyncInfoImpl_iface) ); + IInspectable_AddRef( (*out = &impl->IAsyncInfoImpl_iface) ); return S_OK; }
@@ -77,26 +80,27 @@ static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFI return E_NOINTERFACE; }
-static ULONG WINAPI async_impl_AddRef( IWineAsyncInfoImpl *iface ) +static ULONG WINAPI async_impl_AddRef( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref ); return ref; }
-static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) +static ULONG WINAPI async_impl_Release( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref );
if (!ref) { - if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); + if (impl->handler && impl->handler != HANDLER_NOT_SET) IAsyncOperationCompletedHandlerImpl_Release( impl->handler ); IAsyncInfo_Close( &impl->IAsyncInfo_iface ); if (impl->param) IUnknown_Release( impl->param ); if (impl->invoker) IUnknown_Release( impl->invoker ); + PropVariantClear( &impl->result ); impl->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &impl->cs ); free( impl ); @@ -105,9 +109,9 @@ static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) return ref; }
-static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) +static HRESULT WINAPI async_impl_put_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl *handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -117,7 +121,7 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine else if (impl->handler != HANDLER_NOT_SET) hr = E_ILLEGAL_DELEGATE_ASSIGNMENT; else if ((impl->handler = handler)) { - IWineAsyncOperationCompletedHandler_AddRef( impl->handler ); + IAsyncOperationCompletedHandlerImpl_AddRef( impl->handler );
if (impl->status > Started) { @@ -126,8 +130,8 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs );
- IWineAsyncOperationCompletedHandler_Invoke( handler, operation, status ); - IWineAsyncOperationCompletedHandler_Release( handler ); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler );
return S_OK; } @@ -137,9 +141,9 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine return hr; }
-static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler **handler ) +static HRESULT WINAPI async_impl_get_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl **handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -147,15 +151,15 @@ static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWine EnterCriticalSection( &impl->cs ); if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; if (impl->handler == NULL || impl->handler == HANDLER_NOT_SET) *handler = NULL; - else IWineAsyncOperationCompletedHandler_AddRef( (*handler = impl->handler) ); + else IAsyncOperationCompletedHandlerImpl_AddRef( (*handler = impl->handler) ); LeaveCriticalSection( &impl->cs );
return hr; }
-static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARIANT *result ) +static HRESULT WINAPI async_impl_get_Result( IAsyncInfoImpl *iface, PROPVARIANT *result ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = E_ILLEGAL_METHOD_CALL;
TRACE( "iface %p, result %p.\n", iface, result ); @@ -171,9 +175,9 @@ static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARI return hr; }
-static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) +static HRESULT WINAPI async_impl_Start( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
TRACE( "iface %p.\n", iface );
@@ -184,13 +188,13 @@ static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) return S_OK; }
-static const struct IWineAsyncInfoImplVtbl async_impl_vtbl = +static const struct IAsyncInfoImplVtbl async_impl_vtbl = { /* IUnknown methods */ async_impl_QueryInterface, async_impl_AddRef, async_impl_Release, - /* IWineAsyncInfoImpl */ + /* IAsyncInfoImpl */ async_impl_put_Completed, async_impl_get_Completed, async_impl_get_Result, @@ -300,9 +304,9 @@ static const struct IAsyncInfoVtbl async_info_vtbl =
static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *iface, TP_WORK *work ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); IInspectable *operation = impl->IInspectable_outer; - PROPVARIANT result; + PROPVARIANT result = {0}; HRESULT hr;
hr = impl->callback( impl->invoker, impl->param, &result ); @@ -314,13 +318,13 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *
if (impl->handler != NULL && impl->handler != HANDLER_NOT_SET) { - IWineAsyncOperationCompletedHandler *handler = impl->handler; + IAsyncOperationCompletedHandlerImpl *handler = impl->handler; AsyncStatus status = impl->status; impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs );
- IWineAsyncOperationCompletedHandler_Invoke( handler, operation, status ); - IWineAsyncOperationCompletedHandler_Release( handler ); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler ); } else LeaveCriticalSection( &impl->cs );
@@ -331,13 +335,13 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void * }
static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, - IInspectable *outer, IWineAsyncInfoImpl **out ) + IInspectable *outer, IAsyncInfoImpl **out ) { struct async_info *impl; HRESULT hr;
if (!(impl = calloc( 1, sizeof(struct async_info) ))) return E_OUTOFMEMORY; - impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; + impl->IAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; impl->IAsyncInfo_iface.lpVtbl = &async_info_vtbl; impl->IInspectable_outer = outer; impl->ref = 1; @@ -345,7 +349,7 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper impl->callback = callback; impl->handler = HANDLER_NOT_SET; impl->status = Started; - if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IWineAsyncInfoImpl_iface, NULL ))) + if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IAsyncInfoImpl_iface, NULL ))) { hr = HRESULT_FROM_WIN32( GetLastError() ); free( impl ); @@ -358,51 +362,52 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper InitializeCriticalSectionEx( &impl->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO ); impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)( __FILE__ ": async_info.cs" );
- *out = &impl->IWineAsyncInfoImpl_iface; + *out = &impl->IAsyncInfoImpl_iface; return S_OK; }
-struct async_result +struct async_inspectable { - IAsyncOperation_DeviceInformationCollection IAsyncOperation_DeviceInformationCollection_iface; - IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; + IAsyncOperation_IInspectable IAsyncOperation_IInspectable_iface; + IAsyncInfoImpl *IAsyncInfoImpl_inner; LONG ref; + const GUID *iid; };
-static inline struct async_result *impl_from_IAsyncOperation_DeviceInformationCollection( IAsyncOperation_DeviceInformationCollection *iface ) +static inline struct async_inspectable *impl_from_IAsyncOperation_IInspectable( IAsyncOperation_IInspectable *iface ) { - return CONTAINING_RECORD( iface, struct async_result, IAsyncOperation_DeviceInformationCollection_iface ); + return CONTAINING_RECORD( iface, struct async_inspectable, IAsyncOperation_IInspectable_iface ); }
-static HRESULT WINAPI async_result_QueryInterface( IAsyncOperation_DeviceInformationCollection *iface, REFIID iid, void **out ) +static HRESULT WINAPI async_inspectable_QueryInterface( IAsyncOperation_IInspectable *iface, REFIID iid, void **out ) { - struct async_result *impl = impl_from_IAsyncOperation_DeviceInformationCollection( iface ); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface );
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_IAsyncOperation_DeviceInformationCollection )) + IsEqualGUID( iid, impl->iid )) { - IInspectable_AddRef( (*out = &impl->IAsyncOperation_DeviceInformationCollection_iface) ); + IInspectable_AddRef( (*out = &impl->IAsyncOperation_IInspectable_iface) ); return S_OK; }
- return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); + return IAsyncInfoImpl_QueryInterface( impl->IAsyncInfoImpl_inner, iid, out ); }
-static ULONG WINAPI async_result_AddRef( IAsyncOperation_DeviceInformationCollection *iface ) +static ULONG WINAPI async_inspectable_AddRef( IAsyncOperation_IInspectable *iface ) { - struct async_result *impl = impl_from_IAsyncOperation_DeviceInformationCollection( iface ); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref ); return ref; }
-static ULONG WINAPI async_result_Release( IAsyncOperation_DeviceInformationCollection *iface ) +static ULONG WINAPI async_inspectable_Release( IAsyncOperation_IInspectable *iface ) { - struct async_result *impl = impl_from_IAsyncOperation_DeviceInformationCollection( iface ); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref );
@@ -410,97 +415,102 @@ static ULONG WINAPI async_result_Release( IAsyncOperation_DeviceInformationColle { /* guard against re-entry if inner releases an outer iface */ InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); }
return ref; }
-static HRESULT WINAPI async_result_GetIids( IAsyncOperation_DeviceInformationCollection *iface, ULONG *iid_count, IID **iids ) +static HRESULT WINAPI async_inspectable_GetIids( IAsyncOperation_IInspectable *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 async_result_GetRuntimeClassName( IAsyncOperation_DeviceInformationCollection *iface, HSTRING *class_name ) +static HRESULT WINAPI async_inspectable_GetRuntimeClassName( IAsyncOperation_IInspectable *iface, HSTRING *class_name ) { - return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<Windows.Devices.Enumeration.DeviceInformationCollection>", - ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<Windows.Devices.Enumeration.DeviceInformationCollection>"), + return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<IInspectable>", + ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<IInspectable>"), class_name ); }
-static HRESULT WINAPI async_result_GetTrustLevel( IAsyncOperation_DeviceInformationCollection *iface, TrustLevel *trust_level ) +static HRESULT WINAPI async_inspectable_GetTrustLevel( IAsyncOperation_IInspectable *iface, TrustLevel *trust_level ) { FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); return E_NOTIMPL; }
-static HRESULT WINAPI async_result_put_Completed( IAsyncOperation_DeviceInformationCollection *iface, IAsyncOperationCompletedHandler_DeviceInformationCollection *handler ) +static HRESULT WINAPI async_inspectable_put_Completed( IAsyncOperation_IInspectable *iface, IAsyncOperationCompletedHandler_IInspectable *bool_handler ) { - struct async_result *impl = impl_from_IAsyncOperation_DeviceInformationCollection( iface ); + IAsyncOperationCompletedHandlerImpl *handler = (IAsyncOperationCompletedHandlerImpl *)bool_handler; + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler *)handler ); + return IAsyncInfoImpl_put_Completed( impl->IAsyncInfoImpl_inner, handler ); }
-static HRESULT WINAPI async_result_get_Completed( IAsyncOperation_DeviceInformationCollection *iface, IAsyncOperationCompletedHandler_DeviceInformationCollection **handler ) +static HRESULT WINAPI async_inspectable_get_Completed( IAsyncOperation_IInspectable *iface, IAsyncOperationCompletedHandler_IInspectable **bool_handler ) { - struct async_result *impl = impl_from_IAsyncOperation_DeviceInformationCollection( iface ); + IAsyncOperationCompletedHandlerImpl **handler = (IAsyncOperationCompletedHandlerImpl **)bool_handler; + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler **)handler ); + return IAsyncInfoImpl_get_Completed( impl->IAsyncInfoImpl_inner, handler ); }
-static HRESULT WINAPI async_result_GetResults( IAsyncOperation_DeviceInformationCollection *iface, IVectorView_DeviceInformation **results ) +static HRESULT WINAPI async_inspectable_GetResults( IAsyncOperation_IInspectable *iface, IInspectable **results ) { - struct async_result *impl = impl_from_IAsyncOperation_DeviceInformationCollection( iface ); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable( iface ); PROPVARIANT result = {.vt = VT_UNKNOWN}; HRESULT hr;
TRACE( "iface %p, results %p.\n", iface, results );
- hr = IWineAsyncInfoImpl_get_Result( impl->IWineAsyncInfoImpl_inner, &result ); - if (SUCCEEDED( hr )) - hr = IUnknown_QueryInterface( result.punkVal, &IID_IVectorView_DeviceInformation, (void **)results ); - PropVariantClear( &result ); + if (SUCCEEDED(hr = IAsyncInfoImpl_get_Result( impl->IAsyncInfoImpl_inner, &result ))) + { + if ((*results = (IInspectable *)result.punkVal)) IInspectable_AddRef( *results ); + PropVariantClear( &result ); + } + return hr; }
-static const struct IAsyncOperation_DeviceInformationCollectionVtbl async_result_vtbl = +static const struct IAsyncOperation_IInspectableVtbl async_inspectable_vtbl = { /* IUnknown methods */ - async_result_QueryInterface, - async_result_AddRef, - async_result_Release, + async_inspectable_QueryInterface, + async_inspectable_AddRef, + async_inspectable_Release, /* IInspectable methods */ - async_result_GetIids, - async_result_GetRuntimeClassName, - async_result_GetTrustLevel, - /* IAsyncOperation<DeviceInformationCollection> */ - async_result_put_Completed, - async_result_get_Completed, - async_result_GetResults, + async_inspectable_GetIids, + async_inspectable_GetRuntimeClassName, + async_inspectable_GetTrustLevel, + /* IAsyncOperation<IInspectable> */ + async_inspectable_put_Completed, + async_inspectable_get_Completed, + async_inspectable_GetResults, };
-HRESULT async_operation_device_info_collection_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, - IAsyncOperation_DeviceInformationCollection **out ) +HRESULT async_operation_inspectable_create( const GUID *iid, IUnknown *invoker, IUnknown *param, async_operation_callback callback, + IAsyncOperation_IInspectable **out ) { - struct async_result *impl; + struct async_inspectable *impl; HRESULT hr;
*out = NULL; if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; - impl->IAsyncOperation_DeviceInformationCollection_iface.lpVtbl = &async_result_vtbl; + impl->IAsyncOperation_IInspectable_iface.lpVtbl = &async_inspectable_vtbl; impl->ref = 1; + impl->iid = iid;
- if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_DeviceInformationCollection_iface, &impl->IWineAsyncInfoImpl_inner )) || - FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) + if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_IInspectable_iface, &impl->IAsyncInfoImpl_inner )) || + FAILED(hr = IAsyncInfoImpl_Start( impl->IAsyncInfoImpl_inner ))) { - if (impl->IWineAsyncInfoImpl_inner) IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + if (impl->IAsyncInfoImpl_inner) IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); return hr; }
- *out = &impl->IAsyncOperation_DeviceInformationCollection_iface; - TRACE( "created IAsyncOperation_DeviceInformationCollection %p\n", *out ); + *out = &impl->IAsyncOperation_IInspectable_iface; + TRACE( "created IAsyncOperation_IInspectable %p\n", *out ); return S_OK; } diff --git a/dlls/windows.devices.enumeration/async.idl b/dlls/windows.devices.enumeration/async_private.idl similarity index 70% rename from dlls/windows.devices.enumeration/async.idl rename to dlls/windows.devices.enumeration/async_private.idl index 88e1a76f547..10741572601 100644 --- a/dlls/windows.devices.enumeration/async.idl +++ b/dlls/windows.devices.enumeration/async_private.idl @@ -27,18 +27,20 @@ import "inspectable.idl"; import "asyncinfo.idl"; import "windowscontracts.idl";
-namespace Windows.Devices.Enumeration { - /* type-pruning version of AsyncOperationCompletedHandler<T> */ - delegate HRESULT WineAsyncOperationCompletedHandler([in] IInspectable *async, [in] AsyncStatus status); +namespace Wine.Internal { + /* type-pruning version of AsyncOperationCompletedHandlerImpl<T> */ + delegate HRESULT AsyncOperationCompletedHandlerImpl([in] IInspectable *async, [in] AsyncStatus status);
[ uuid(d81ab70d-82e0-481c-983d-401225d98a2c) ] - interface IWineAsyncInfoImpl : IUnknown + interface IAsyncInfoImpl : IUnknown { - [propput] HRESULT Completed([in] WineAsyncOperationCompletedHandler *handler); - [propget] HRESULT Completed([out, retval] WineAsyncOperationCompletedHandler **handler); + [propput] HRESULT Completed([in] AsyncOperationCompletedHandlerImpl *handler); + [propget] HRESULT Completed([out, retval] AsyncOperationCompletedHandlerImpl **handler); [propget] HRESULT Result([out, retval] PROPVARIANT *result); HRESULT Start(); } + + typedef HRESULT (*async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); } diff --git a/dlls/windows.devices.enumeration/main.c b/dlls/windows.devices.enumeration/main.c index ba7edaa5199..df582f76523 100644 --- a/dlls/windows.devices.enumeration/main.c +++ b/dlls/windows.devices.enumeration/main.c @@ -334,7 +334,7 @@ static HRESULT WINAPI device_statics_CreateFromIdAsyncAdditionalProperties( IDev return E_NOTIMPL; }
-static HRESULT WINAPI find_all_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) +static HRESULT find_all_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { static const struct vector_iids iids = { @@ -411,7 +411,8 @@ static HRESULT WINAPI device_statics_FindAllAsync( IDeviceInformationStatics *if IAsyncOperation_DeviceInformationCollection **op ) { TRACE( "iface %p, op %p\n", iface, op ); - return async_operation_device_info_collection_result_create( (IUnknown *)iface, NULL, find_all_async, op ); + return async_operation_inspectable_create( &IID_IAsyncOperation_DeviceInformationCollection, (IUnknown *)iface, NULL, + find_all_async, (IAsyncOperation_IInspectable **)op ); }
static HRESULT WINAPI device_statics_FindAllAsyncDeviceClass( IDeviceInformationStatics *iface, DeviceClass class, diff --git a/dlls/windows.devices.enumeration/private.h b/dlls/windows.devices.enumeration/private.h index f9a866d5f59..cc5be350379 100644 --- a/dlls/windows.devices.enumeration/private.h +++ b/dlls/windows.devices.enumeration/private.h @@ -39,6 +39,8 @@
#include "wine/list.h"
+#include "async_private.h" + struct vector_iids { const GUID *vector; @@ -54,9 +56,8 @@ HRESULT typed_event_handlers_remove( struct list *list, EventRegistrationToken * HRESULT typed_event_handlers_notify( struct list *list, IInspectable *sender, IInspectable *args ); HRESULT typed_event_handlers_clear( struct list *list );
-typedef HRESULT (WINAPI *async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); -extern HRESULT async_operation_device_info_collection_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, - IAsyncOperation_DeviceInformationCollection **out ); +extern HRESULT async_operation_inspectable_create( const GUID *iid, IUnknown *invoker, IUnknown *param, async_operation_callback callback, + IAsyncOperation_IInspectable **out ); extern HRESULT vector_create( const struct vector_iids *iids, void **out ); extern HRESULT device_information_create( const WCHAR *path, IDeviceInformation **info );
From: Rémi Bernon rbernon@codeweavers.com
--- .../Makefile.in | 4 +- .../async.c | 105 +++++++++--------- .../{provider.idl => async_private.idl} | 18 +-- .../main.c | 2 +- .../private.h | 3 +- 5 files changed, 67 insertions(+), 65 deletions(-) rename dlls/windows.security.credentials.ui.userconsentverifier/{provider.idl => async_private.idl} (67%)
diff --git a/dlls/windows.security.credentials.ui.userconsentverifier/Makefile.in b/dlls/windows.security.credentials.ui.userconsentverifier/Makefile.in index 82ed7ea79dc..a32cc0c5d33 100644 --- a/dlls/windows.security.credentials.ui.userconsentverifier/Makefile.in +++ b/dlls/windows.security.credentials.ui.userconsentverifier/Makefile.in @@ -3,6 +3,6 @@ IMPORTS = combase
SOURCES = \ async.c \ + async_private.idl \ classes.idl \ - main.c \ - provider.idl + main.c diff --git a/dlls/windows.security.credentials.ui.userconsentverifier/async.c b/dlls/windows.security.credentials.ui.userconsentverifier/async.c index 89edb50ce3c..252b9f06b80 100644 --- a/dlls/windows.security.credentials.ui.userconsentverifier/async.c +++ b/dlls/windows.security.credentials.ui.userconsentverifier/async.c @@ -1,4 +1,4 @@ -/* WinRT Windows.Security.Credentials.UI Implementation +/* WinRT IAsync* implementation * * Copyright 2022 Bernhard Kölbl for CodeWeavers * Copyright 2022 Rémi Bernon for CodeWeavers @@ -18,17 +18,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define WIDL_using_Wine_Internal #include "private.h" +#include "initguid.h" +#include "async_private.h" + #include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(credentials); +WINE_DEFAULT_DEBUG_CHANNEL(input);
#define Closed 4 #define HANDLER_NOT_SET ((void *)~(ULONG_PTR)0)
struct async_info { - IWineAsyncInfoImpl IWineAsyncInfoImpl_iface; + IAsyncInfoImpl IAsyncInfoImpl_iface; IAsyncInfo IAsyncInfo_iface; IInspectable *IInspectable_outer; LONG ref; @@ -39,29 +43,29 @@ struct async_info IUnknown *param;
CRITICAL_SECTION cs; - IWineAsyncOperationCompletedHandler *handler; + IAsyncOperationCompletedHandlerImpl *handler; PROPVARIANT result; AsyncStatus status; HRESULT hr; };
-static inline struct async_info *impl_from_IWineAsyncInfoImpl( IWineAsyncInfoImpl *iface ) +static inline struct async_info *impl_from_IAsyncInfoImpl( IAsyncInfoImpl *iface ) { - return CONTAINING_RECORD( iface, struct async_info, IWineAsyncInfoImpl_iface ); + return CONTAINING_RECORD( iface, struct async_info, IAsyncInfoImpl_iface ); }
-static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFIID iid, void **out ) +static HRESULT WINAPI async_impl_QueryInterface( IAsyncInfoImpl *iface, REFIID iid, void **out ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
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_IWineAsyncInfoImpl )) + IsEqualGUID( iid, &IID_IAsyncInfoImpl )) { - IInspectable_AddRef( (*out = &impl->IWineAsyncInfoImpl_iface) ); + IInspectable_AddRef( (*out = &impl->IAsyncInfoImpl_iface) ); return S_OK; }
@@ -76,26 +80,27 @@ static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFI return E_NOINTERFACE; }
-static ULONG WINAPI async_impl_AddRef( IWineAsyncInfoImpl *iface ) +static ULONG WINAPI async_impl_AddRef( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref ); return ref; }
-static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) +static ULONG WINAPI async_impl_Release( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); TRACE( "iface %p, ref %lu.\n", iface, ref );
if (!ref) { - if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); + if (impl->handler && impl->handler != HANDLER_NOT_SET) IAsyncOperationCompletedHandlerImpl_Release( impl->handler ); IAsyncInfo_Close( &impl->IAsyncInfo_iface ); if (impl->param) IUnknown_Release( impl->param ); if (impl->invoker) IUnknown_Release( impl->invoker ); + PropVariantClear( &impl->result ); impl->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &impl->cs ); free( impl ); @@ -104,9 +109,9 @@ static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) return ref; }
-static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) +static HRESULT WINAPI async_impl_put_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl *handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -116,7 +121,7 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine else if (impl->handler != HANDLER_NOT_SET) hr = E_ILLEGAL_DELEGATE_ASSIGNMENT; else if ((impl->handler = handler)) { - IWineAsyncOperationCompletedHandler_AddRef( impl->handler ); + IAsyncOperationCompletedHandlerImpl_AddRef( impl->handler );
if (impl->status > Started) { @@ -125,8 +130,8 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs );
- IWineAsyncOperationCompletedHandler_Invoke( handler, operation, status ); - IWineAsyncOperationCompletedHandler_Release( handler ); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler );
return S_OK; } @@ -136,9 +141,9 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine return hr; }
-static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler **handler ) +static HRESULT WINAPI async_impl_get_Completed( IAsyncInfoImpl *iface, IAsyncOperationCompletedHandlerImpl **handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -146,15 +151,15 @@ static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWine EnterCriticalSection( &impl->cs ); if (impl->status == Closed) hr = E_ILLEGAL_METHOD_CALL; if (impl->handler == NULL || impl->handler == HANDLER_NOT_SET) *handler = NULL; - else IWineAsyncOperationCompletedHandler_AddRef( (*handler = impl->handler) ); + else IAsyncOperationCompletedHandlerImpl_AddRef( (*handler = impl->handler) ); LeaveCriticalSection( &impl->cs );
return hr; }
-static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARIANT *result ) +static HRESULT WINAPI async_impl_get_Result( IAsyncInfoImpl *iface, PROPVARIANT *result ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); HRESULT hr = E_ILLEGAL_METHOD_CALL;
TRACE( "iface %p, result %p.\n", iface, result ); @@ -170,9 +175,9 @@ static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARI return hr; }
-static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) +static HRESULT WINAPI async_impl_Start( IAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface );
TRACE( "iface %p.\n", iface );
@@ -183,13 +188,13 @@ static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) return S_OK; }
-static const struct IWineAsyncInfoImplVtbl async_impl_vtbl = +static const struct IAsyncInfoImplVtbl async_impl_vtbl = { /* IUnknown methods */ async_impl_QueryInterface, async_impl_AddRef, async_impl_Release, - /* IWineAsyncInfoImpl */ + /* IAsyncInfoImpl */ async_impl_put_Completed, async_impl_get_Completed, async_impl_get_Result, @@ -299,9 +304,9 @@ static const struct IAsyncInfoVtbl async_info_vtbl =
static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *iface, TP_WORK *work ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = impl_from_IAsyncInfoImpl( iface ); IInspectable *operation = impl->IInspectable_outer; - PROPVARIANT result; + PROPVARIANT result = {0}; HRESULT hr;
hr = impl->callback( impl->invoker, impl->param, &result ); @@ -313,13 +318,13 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *
if (impl->handler != NULL && impl->handler != HANDLER_NOT_SET) { - IWineAsyncOperationCompletedHandler *handler = impl->handler; + IAsyncOperationCompletedHandlerImpl *handler = impl->handler; AsyncStatus status = impl->status; impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs );
- IWineAsyncOperationCompletedHandler_Invoke( handler, operation, status ); - IWineAsyncOperationCompletedHandler_Release( handler ); + IAsyncOperationCompletedHandlerImpl_Invoke( handler, operation, status ); + IAsyncOperationCompletedHandlerImpl_Release( handler ); } else LeaveCriticalSection( &impl->cs );
@@ -330,13 +335,13 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void * }
static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, - IInspectable *outer, IWineAsyncInfoImpl **out ) + IInspectable *outer, IAsyncInfoImpl **out ) { struct async_info *impl; HRESULT hr;
if (!(impl = calloc( 1, sizeof(struct async_info) ))) return E_OUTOFMEMORY; - impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; + impl->IAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; impl->IAsyncInfo_iface.lpVtbl = &async_info_vtbl; impl->IInspectable_outer = outer; impl->ref = 1; @@ -344,7 +349,7 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper impl->callback = callback; impl->handler = HANDLER_NOT_SET; impl->status = Started; - if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IWineAsyncInfoImpl_iface, NULL ))) + if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IAsyncInfoImpl_iface, NULL ))) { hr = HRESULT_FROM_WIN32( GetLastError() ); free( impl ); @@ -357,14 +362,14 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper InitializeCriticalSectionEx( &impl->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO ); impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)( __FILE__ ": async_info.cs" );
- *out = &impl->IWineAsyncInfoImpl_iface; + *out = &impl->IAsyncInfoImpl_iface; return S_OK; }
struct async_user_consent_verifier_availability { IAsyncOperation_UserConsentVerifierAvailability IAsyncOperation_UserConsentVerifierAvailability_iface; - IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; + IAsyncInfoImpl *IAsyncInfoImpl_inner; LONG ref; };
@@ -388,7 +393,7 @@ static HRESULT WINAPI async_user_consent_verifier_availability_QueryInterface( I return S_OK; }
- return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); + return IAsyncInfoImpl_QueryInterface( impl->IAsyncInfoImpl_inner, iid, out ); }
static ULONG WINAPI async_user_consent_verifier_availability_AddRef( IAsyncOperation_UserConsentVerifierAvailability *iface ) @@ -409,7 +414,7 @@ static ULONG WINAPI async_user_consent_verifier_availability_Release( IAsyncOper { /* guard against re-entry if inner releases an outer iface */ InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); }
@@ -436,21 +441,19 @@ static HRESULT WINAPI async_user_consent_verifier_availability_GetTrustLevel( IA }
static HRESULT WINAPI async_user_consent_verifier_availability_put_Completed( IAsyncOperation_UserConsentVerifierAvailability *iface, - IAsyncOperationCompletedHandler_UserConsentVerifierAvailability *UserConsentVerifierAvailability_handler ) + IAsyncOperationCompletedHandler_UserConsentVerifierAvailability *handler ) { - IWineAsyncOperationCompletedHandler *handler = (IWineAsyncOperationCompletedHandler *)UserConsentVerifierAvailability_handler; struct async_user_consent_verifier_availability *impl = impl_from_IAsyncOperation_UserConsentVerifierAvailability( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler *)handler ); + return IAsyncInfoImpl_put_Completed( impl->IAsyncInfoImpl_inner, (IAsyncOperationCompletedHandlerImpl *)handler ); }
static HRESULT WINAPI async_user_consent_verifier_availability_get_Completed( IAsyncOperation_UserConsentVerifierAvailability *iface, - IAsyncOperationCompletedHandler_UserConsentVerifierAvailability **UserConsentVerifierAvailability_handler ) + IAsyncOperationCompletedHandler_UserConsentVerifierAvailability **handler ) { - IWineAsyncOperationCompletedHandler **handler = (IWineAsyncOperationCompletedHandler **)UserConsentVerifierAvailability_handler; struct async_user_consent_verifier_availability *impl = impl_from_IAsyncOperation_UserConsentVerifierAvailability( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); - return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler **)handler ); + return IAsyncInfoImpl_get_Completed( impl->IAsyncInfoImpl_inner, (IAsyncOperationCompletedHandlerImpl **)handler ); }
static HRESULT WINAPI async_user_consent_verifier_availability_GetResults( IAsyncOperation_UserConsentVerifierAvailability *iface, UserConsentVerifierAvailability *results ) @@ -461,7 +464,7 @@ static HRESULT WINAPI async_user_consent_verifier_availability_GetResults( IAsyn
TRACE( "iface %p, results %p.\n", iface, results );
- hr = IWineAsyncInfoImpl_get_Result( impl->IWineAsyncInfoImpl_inner, &result ); + hr = IAsyncInfoImpl_get_Result( impl->IAsyncInfoImpl_inner, &result );
*results = result.ulVal; PropVariantClear( &result ); @@ -495,10 +498,10 @@ HRESULT async_operation_user_consent_verifier_availability_create( IUnknown *inv impl->IAsyncOperation_UserConsentVerifierAvailability_iface.lpVtbl = &async_user_consent_verifier_availability_vtbl; impl->ref = 1;
- if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_UserConsentVerifierAvailability_iface, &impl->IWineAsyncInfoImpl_inner )) || - FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) + if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_UserConsentVerifierAvailability_iface, &impl->IAsyncInfoImpl_inner )) || + FAILED(hr = IAsyncInfoImpl_Start( impl->IAsyncInfoImpl_inner ))) { - if (impl->IWineAsyncInfoImpl_inner) IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + if (impl->IAsyncInfoImpl_inner) IAsyncInfoImpl_Release( impl->IAsyncInfoImpl_inner ); free( impl ); return hr; } diff --git a/dlls/windows.security.credentials.ui.userconsentverifier/provider.idl b/dlls/windows.security.credentials.ui.userconsentverifier/async_private.idl similarity index 67% rename from dlls/windows.security.credentials.ui.userconsentverifier/provider.idl rename to dlls/windows.security.credentials.ui.userconsentverifier/async_private.idl index 36ffe4e174d..10741572601 100644 --- a/dlls/windows.security.credentials.ui.userconsentverifier/provider.idl +++ b/dlls/windows.security.credentials.ui.userconsentverifier/async_private.idl @@ -25,22 +25,22 @@ import "propidl.idl"; import "inspectable.idl"; import "asyncinfo.idl"; -import "eventtoken.idl"; import "windowscontracts.idl"; -import "windows.foundation.idl";
-namespace Windows.Security.Credentials.UI { - /* type-pruning version of AsyncOperationCompletedHandler<T> */ - delegate HRESULT WineAsyncOperationCompletedHandler([in] IInspectable *async, [in] AsyncStatus status); +namespace Wine.Internal { + /* type-pruning version of AsyncOperationCompletedHandlerImpl<T> */ + delegate HRESULT AsyncOperationCompletedHandlerImpl([in] IInspectable *async, [in] AsyncStatus status);
[ - uuid(83f377ee-c799-11ec-9d64-0242ac120002) + uuid(d81ab70d-82e0-481c-983d-401225d98a2c) ] - interface IWineAsyncInfoImpl : IUnknown + interface IAsyncInfoImpl : IUnknown { - [propput] HRESULT Completed([in] WineAsyncOperationCompletedHandler *handler); - [propget] HRESULT Completed([out, retval] WineAsyncOperationCompletedHandler **handler); + [propput] HRESULT Completed([in] AsyncOperationCompletedHandlerImpl *handler); + [propget] HRESULT Completed([out, retval] AsyncOperationCompletedHandlerImpl **handler); [propget] HRESULT Result([out, retval] PROPVARIANT *result); HRESULT Start(); } + + typedef HRESULT (*async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); } diff --git a/dlls/windows.security.credentials.ui.userconsentverifier/main.c b/dlls/windows.security.credentials.ui.userconsentverifier/main.c index 352515a1848..e3c5e783f6d 100644 --- a/dlls/windows.security.credentials.ui.userconsentverifier/main.c +++ b/dlls/windows.security.credentials.ui.userconsentverifier/main.c @@ -118,7 +118,7 @@ static const struct IActivationFactoryVtbl factory_vtbl =
DEFINE_IINSPECTABLE( user_consent_verifier_statics, IUserConsentVerifierStatics, struct user_consent_verifier_statics, IActivationFactory_iface )
-static HRESULT WINAPI check_availability_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) +static HRESULT check_availability_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { result->vt = VT_UI4; result->ulVal = UserConsentVerifierAvailability_DeviceNotPresent; diff --git a/dlls/windows.security.credentials.ui.userconsentverifier/private.h b/dlls/windows.security.credentials.ui.userconsentverifier/private.h index 5edeb299792..efdc35b57d2 100644 --- a/dlls/windows.security.credentials.ui.userconsentverifier/private.h +++ b/dlls/windows.security.credentials.ui.userconsentverifier/private.h @@ -35,9 +35,8 @@ #define WIDL_using_Windows_Security_Credentials_UI #include "windows.security.credentials.ui.h"
-#include "provider.h" +#include "async_private.h"
-typedef HRESULT (WINAPI *async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); extern HRESULT async_operation_user_consent_verifier_availability_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_UserConsentVerifierAvailability **out );
Alfred Agrell (@Alcaro) commented about dlls/cryptowinrt/async.c:
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#define WIDL_using_Wine_Internal #include "private.h" +#include "initguid.h" +#include "async_private.h"
#include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(crypto); +WINE_DEFAULT_DEBUG_CHANNEL(input);
You sure you want to change the debug channel? If you want the files to be identical, maybe rename the channel to iasync, or something.
Same goes for three other async.c in this MR.
On Mon May 12 13:35:23 2025 +0000, Alfred Agrell wrote:
You sure you want to change the debug channel? If you want the files to be identical, maybe rename the channel to iasync, or something. Same goes for three other async.c in this MR.
Right, forgot about that.