From: Shaun Ren sren@codeweavers.com
--- dlls/sapi/tests/token.c | 30 ++++++++++ dlls/sapi/token.c | 129 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 153 insertions(+), 6 deletions(-)
diff --git a/dlls/sapi/tests/token.c b/dlls/sapi/tests/token.c index 0fe142f89a8..9350c304e41 100644 --- a/dlls/sapi/tests/token.c +++ b/dlls/sapi/tests/token.c @@ -246,12 +246,42 @@ static void test_token_enum(void) { ISpObjectTokenEnumBuilder *token_enum; HRESULT hr; + IDispatch *disp; + ISpeechObjectTokens *speech_tokens; ISpObjectToken *tokens[5]; ISpObjectToken *out_tokens[5]; WCHAR token_id[MAX_PATH]; ULONG count; int i;
+ hr = CoCreateInstance( &CLSID_SpObjectTokenEnum, NULL, CLSCTX_INPROC_SERVER, + &IID_ISpObjectTokenEnumBuilder, (void **)&token_enum ); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ISpObjectTokenEnumBuilder_QueryInterface( token_enum, + &IID_IDispatch, (void **)&disp ); + ok( hr == S_OK, "got %08lx\n", hr ); + IDispatch_Release( disp ); + + hr = ISpObjectTokenEnumBuilder_QueryInterface( token_enum, + &IID_ISpeechObjectTokens, + (void **)&speech_tokens ); + ok( hr == S_OK, "got %08lx\n", hr ); + ISpeechObjectTokens_Release( speech_tokens ); + + ISpObjectTokenEnumBuilder_Release( token_enum ); + + hr = CoCreateInstance( &CLSID_SpObjectTokenEnum, NULL, CLSCTX_INPROC_SERVER, + &IID_IDispatch, (void **)&disp ); + ok( hr == S_OK, "got %08lx\n", hr ); + IDispatch_Release( disp ); + + hr = CoCreateInstance( &CLSID_SpObjectTokenEnum, NULL, CLSCTX_INPROC_SERVER, + &IID_ISpeechObjectTokens, (void **)&speech_tokens ); + ok( hr == S_OK, "got %08lx\n", hr ); + ISpeechObjectTokens_Release( speech_tokens ); + + hr = CoCreateInstance( &CLSID_SpObjectTokenEnum, NULL, CLSCTX_INPROC_SERVER, &IID_ISpObjectTokenEnumBuilder, (void **)&token_enum ); ok( hr == S_OK, "got %08lx\n", hr ); diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index fd4efb9a95a..4688e6a07b9 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -579,6 +579,7 @@ struct token_with_score struct token_enum { ISpObjectTokenEnumBuilder ISpObjectTokenEnumBuilder_iface; + ISpeechObjectTokens ISpeechObjectTokens_iface; LONG ref;
BOOL init; @@ -593,6 +594,11 @@ static struct token_enum *impl_from_ISpObjectTokenEnumBuilder( ISpObjectTokenEnu return CONTAINING_RECORD( iface, struct token_enum, ISpObjectTokenEnumBuilder_iface ); }
+static struct token_enum *impl_from_ISpeechObjectTokens( ISpeechObjectTokens *iface ) +{ + return CONTAINING_RECORD( iface, struct token_enum, ISpeechObjectTokens_iface ); +} + static HRESULT WINAPI token_category_EnumTokens( ISpObjectTokenCategory *iface, LPCWSTR req, LPCWSTR opt, IEnumSpObjectTokens **enum_tokens ) @@ -765,15 +771,19 @@ static HRESULT WINAPI token_enum_QueryInterface( ISpObjectTokenEnumBuilder *ifac if (IsEqualIID( iid, &IID_IUnknown ) || IsEqualIID( iid, &IID_IEnumSpObjectTokens ) || IsEqualIID( iid, &IID_ISpObjectTokenEnumBuilder )) + *obj = &This->ISpObjectTokenEnumBuilder_iface; + else if (IsEqualIID( iid, &IID_IDispatch ) || + IsEqualIID( iid, &IID_ISpeechObjectTokens )) + *obj = &This->ISpeechObjectTokens_iface; + else { - ISpObjectTokenEnumBuilder_AddRef( iface ); - *obj = iface; - return S_OK; + *obj = NULL; + FIXME( "interface %s not implemented\n", debugstr_guid( iid ) ); + return E_NOINTERFACE; }
- FIXME( "interface %s not implemented\n", debugstr_guid( iid ) ); - *obj = NULL; - return E_NOINTERFACE; + IUnknown_AddRef( (IUnknown *)*obj ); + return S_OK; }
static ULONG WINAPI token_enum_AddRef( ISpObjectTokenEnumBuilder *iface ) @@ -1135,6 +1145,112 @@ const struct ISpObjectTokenEnumBuilderVtbl token_enum_vtbl = token_enum_Sort };
+static HRESULT WINAPI speech_tokens_QueryInterface( ISpeechObjectTokens *iface, + REFIID iid, void **obj ) +{ + struct token_enum *This = impl_from_ISpeechObjectTokens( iface ); + + TRACE( "(%p)->(%s %p)\n", This, debugstr_guid( iid ), obj ); + + return ISpObjectTokenEnumBuilder_QueryInterface( + &This->ISpObjectTokenEnumBuilder_iface, iid, obj ); +} + +static ULONG WINAPI speech_tokens_AddRef( ISpeechObjectTokens *iface ) +{ + struct token_enum *This = impl_from_ISpeechObjectTokens( iface ); + + TRACE( "(%p)\n", This ); + + return ISpObjectTokenEnumBuilder_AddRef( &This->ISpObjectTokenEnumBuilder_iface ); +} + +static ULONG WINAPI speech_tokens_Release( ISpeechObjectTokens *iface ) +{ + struct token_enum *This = impl_from_ISpeechObjectTokens( iface ); + + TRACE( "(%p)\n", This ); + + return ISpObjectTokenEnumBuilder_Release( &This->ISpObjectTokenEnumBuilder_iface ); +} + +static HRESULT WINAPI speech_tokens_GetTypeInfoCount( ISpeechObjectTokens *iface, + UINT *count ) +{ + + FIXME( "stub\n" ); + return E_NOTIMPL; +} + +static HRESULT WINAPI speech_tokens_GetTypeInfo( ISpeechObjectTokens *iface, + UINT index, + LCID lcid, + ITypeInfo **type_info ) +{ + FIXME( "stub\n" ); + return E_NOTIMPL; +} + +static HRESULT WINAPI speech_tokens_GetIDsOfNames( ISpeechObjectTokens *iface, + REFIID iid, + LPOLESTR *names, + UINT count, + LCID lcid, + DISPID *dispids ) +{ + FIXME( "stub\n" ); + return E_NOTIMPL; +} + +static HRESULT WINAPI speech_tokens_Invoke( ISpeechObjectTokens *iface, + DISPID dispid, + REFIID iid, + LCID lcid, + WORD flags, + DISPPARAMS *params, + VARIANT *result, + EXCEPINFO *excepinfo, + UINT *argerr ) +{ + FIXME( "stub\n" ); + return E_NOTIMPL; +} + +static HRESULT WINAPI speech_tokens_get_Count( ISpeechObjectTokens *iface, + LONG *count ) +{ + FIXME( "stub\n" ); + return E_NOTIMPL; +} + +static HRESULT WINAPI speech_tokens_Item( ISpeechObjectTokens *iface, + LONG index, ISpeechObjectToken **token ) +{ + FIXME( "stub\n" ); + return E_NOTIMPL; +} + +static HRESULT WINAPI speech_tokens_get__NewEnum( ISpeechObjectTokens *iface, + IUnknown **new_enum ) +{ + FIXME( "stub\n" ); + return E_NOTIMPL; +} + +static const ISpeechObjectTokensVtbl speech_tokens_vtbl = +{ + speech_tokens_QueryInterface, + speech_tokens_AddRef, + speech_tokens_Release, + speech_tokens_GetTypeInfoCount, + speech_tokens_GetTypeInfo, + speech_tokens_GetIDsOfNames, + speech_tokens_Invoke, + speech_tokens_get_Count, + speech_tokens_Item, + speech_tokens_get__NewEnum +}; + HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj ) { struct token_enum *This = malloc( sizeof(*This) ); @@ -1142,6 +1258,7 @@ HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj )
if (!This) return E_OUTOFMEMORY; This->ISpObjectTokenEnumBuilder_iface.lpVtbl = &token_enum_vtbl; + This->ISpeechObjectTokens_iface.lpVtbl = &speech_tokens_vtbl; This->ref = 1; This->req = NULL; This->opt = NULL;