From b6c1760727dae433570ef0dffb985c751d4dc0bc Mon Sep 17 00:00:00 2001 From: Shaun Ren Date: Thu, 8 Feb 2024 20:20:36 -0500 Subject: [PATCH] sapi: Implement ISpeechObjectToken::GetDescription. --- dlls/sapi/Makefile.in | 2 +- dlls/sapi/tests/Makefile.in | 2 +- dlls/sapi/tests/token.c | 58 +++++++++++++++++++++++++++++++++++-- dlls/sapi/token.c | 23 +++++++++++++-- 4 files changed, 79 insertions(+), 6 deletions(-) diff --git a/dlls/sapi/Makefile.in b/dlls/sapi/Makefile.in index 008d0f74545..24a1e055766 100644 --- a/dlls/sapi/Makefile.in +++ b/dlls/sapi/Makefile.in @@ -1,5 +1,5 @@ MODULE = sapi.dll -IMPORTS = uuid ole32 user32 advapi32 +IMPORTS = uuid ole32 oleaut32 user32 advapi32 DELAYIMPORTS = winmm SOURCES = \ diff --git a/dlls/sapi/tests/Makefile.in b/dlls/sapi/tests/Makefile.in index 4c107d5e994..4e792f2daae 100644 --- a/dlls/sapi/tests/Makefile.in +++ b/dlls/sapi/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = sapi.dll -IMPORTS = ole32 user32 advapi32 winmm +IMPORTS = ole32 oleaut32 user32 advapi32 winmm SOURCES = \ automation.c \ diff --git a/dlls/sapi/tests/token.c b/dlls/sapi/tests/token.c index 543b19ec69a..a651eb47c62 100644 --- a/dlls/sapi/tests/token.c +++ b/dlls/sapi/tests/token.c @@ -657,7 +657,7 @@ static IClassFactory test_class_cf = { &ClassFactoryVtbl }; static void test_object_token(void) { - static const WCHAR test_token_id[] = L"HKEY_LOCAL_MACHINE\\Software\\Wine\\Winetest\\sapi\\TestToken"; + static const WCHAR test_token_id[] = L"HKEY_LOCAL_MACHINE\\Software\\Winetest\\sapi\\TestToken"; ISpObjectToken *token; IDispatch *disp; @@ -665,6 +665,7 @@ static void test_object_token(void) ISpDataKey *sub_key; HRESULT hr; LPWSTR tempW, token_id; + BSTR tempB; ISpObjectTokenCategory *cat; DWORD regid; IUnknown *obj; @@ -863,11 +864,64 @@ static void test_object_token(void) CoTaskMemFree( tempW ); } + hr = ISpObjectToken_SetStringValue( token, L"409", L"409 - TestToken" ); + ok( hr == S_OK, "got %08lx\n", hr ); + hr = ISpObjectToken_SetStringValue( token, L"407", L"407 - TestToken" ); + ok( hr == S_OK, "got %08lx\n", hr ); + hr = ISpObjectToken_SetStringValue( token, L"E40C", L"E40C - TestToken" ); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ISpObjectToken_QueryInterface( token, &IID_ISpeechObjectToken, (void **)&speech_token ); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = ISpeechObjectToken_GetDescription( speech_token, 0x409, NULL ); + ok( hr == E_POINTER, "got %08lx\n", hr ); + + tempB = NULL; + hr = ISpeechObjectToken_GetDescription( speech_token, 0x409, &tempB ); + ok( hr == S_OK, "got %08lx\n", hr ); + ok( tempB && !wcscmp( tempB, L"409 - TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) ); + SysFreeString( tempB ); + + tempB = NULL; + hr = ISpeechObjectToken_GetDescription( speech_token, 0x10407, &tempB ); + ok( hr == S_OK, "got %08lx\n", hr ); + ok( tempB && !wcscmp( tempB, L"407 - TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) ); + SysFreeString( tempB ); + + tempB = NULL; + hr = ISpeechObjectToken_GetDescription( speech_token, 0xE40C, &tempB ); + ok( hr == S_OK, "got %08lx\n", hr ); + ok( tempB && !wcscmp( tempB, L"E40C - TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) ); + SysFreeString( tempB ); + + tempB = (BSTR)0xdeadbeef; + hr = ISpeechObjectToken_GetDescription( speech_token, 0x406, &tempB ); + ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr ); + ok( tempB == (BSTR)0xdeadbeef || broken(tempB == NULL) /* < win7 */, "got %p\n", tempB ); + + hr = ISpObjectToken_SetStringValue( token, NULL, L"TestToken" ); + ok( hr == S_OK, "got %08lx\n", hr ); + + tempB = NULL; + hr = ISpeechObjectToken_GetDescription( speech_token, 0x406, &tempB ); + ok( hr == S_OK, "got %08lx\n", hr ); + ok( tempB && !wcscmp( tempB, L"TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) ); + SysFreeString( tempB ); + + tempB = NULL; + hr = ISpeechObjectToken_GetDescription( speech_token, 0x0, &tempB ); + ok( hr == S_OK, "got %08lx\n", hr ); + ok( tempB && !wcscmp( tempB, L"TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) ); + SysFreeString( tempB ); + + ISpeechObjectToken_Release( speech_token ); + ISpObjectToken_Release( test_class_token ); IUnknown_Release( obj ); ISpObjectToken_Release( token ); - RegDeleteTreeA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest\\sapi" ); + RegDeleteTreeA( HKEY_LOCAL_MACHINE, "Software\\Winetest\\sapi" ); } START_TEST(token) diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index 53b64a4383f..e5d87505e34 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -1829,8 +1829,27 @@ static HRESULT WINAPI speech_token_get_Category( ISpeechObjectToken *iface, static HRESULT WINAPI speech_token_GetDescription( ISpeechObjectToken *iface, LONG locale, BSTR *desc ) { - FIXME( "stub\n" ); - return E_NOTIMPL; + struct object_token *This = impl_from_ISpeechObjectToken( iface ); + WCHAR langid[5]; + WCHAR *desc_wstr = NULL; + HRESULT hr; + + TRACE( "(%p)->(%#lx %p)\n", This, locale, desc ); + + if (!desc) return E_POINTER; + + swprintf( langid, ARRAY_SIZE( langid ), L"%X", LANGIDFROMLCID( locale ) ); + + hr = ISpObjectToken_GetStringValue( &This->ISpObjectToken_iface, langid, &desc_wstr ); + if (hr == SPERR_NOT_FOUND) + hr = ISpObjectToken_GetStringValue( &This->ISpObjectToken_iface, NULL, &desc_wstr ); + if (FAILED(hr)) + return hr; + + *desc = SysAllocString( desc_wstr ); + + CoTaskMemFree( desc_wstr ); + return *desc ? S_OK : E_OUTOFMEMORY; } static HRESULT WINAPI speech_token_SetId( ISpeechObjectToken *iface,