Skip to content

Commit

Permalink
sapi: Implement ISpeechObjectToken::GetDescription.
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunren authored and julliard committed Feb 13, 2024
1 parent 23f360b commit b6c1760
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dlls/sapi/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MODULE = sapi.dll
IMPORTS = uuid ole32 user32 advapi32
IMPORTS = uuid ole32 oleaut32 user32 advapi32
DELAYIMPORTS = winmm

SOURCES = \
Expand Down
2 changes: 1 addition & 1 deletion dlls/sapi/tests/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TESTDLL = sapi.dll
IMPORTS = ole32 user32 advapi32 winmm
IMPORTS = ole32 oleaut32 user32 advapi32 winmm

SOURCES = \
automation.c \
Expand Down
58 changes: 56 additions & 2 deletions dlls/sapi/tests/token.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,15 @@ 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;
ISpeechObjectToken *speech_token;
ISpDataKey *sub_key;
HRESULT hr;
LPWSTR tempW, token_id;
BSTR tempB;
ISpObjectTokenCategory *cat;
DWORD regid;
IUnknown *obj;
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 21 additions & 2 deletions dlls/sapi/token.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b6c1760

Please sign in to comment.