mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 10:42:42 +00:00
imm32: Rewrite ImmGetDescription(A|W).
This commit is contained in:
parent
85489a53f5
commit
e242e09432
|
@ -1728,52 +1728,49 @@ HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
* ImmGetDescriptionA (IMM32.@)
|
||||
* ImmGetDescriptionA (IMM32.@)
|
||||
*/
|
||||
UINT WINAPI ImmGetDescriptionA(
|
||||
HKL hKL, LPSTR lpszDescription, UINT uBufLen)
|
||||
UINT WINAPI ImmGetDescriptionA( HKL hkl, LPSTR bufferA, UINT lengthA )
|
||||
{
|
||||
WCHAR *buf;
|
||||
DWORD len;
|
||||
WCHAR *bufferW;
|
||||
DWORD lengthW;
|
||||
|
||||
TRACE("%p %p %d\n", hKL, lpszDescription, uBufLen);
|
||||
TRACE( "hkl %p, bufferA %p, lengthA %d\n", hkl, bufferA, lengthA );
|
||||
|
||||
/* find out how many characters in the unicode buffer */
|
||||
len = ImmGetDescriptionW( hKL, NULL, 0 );
|
||||
if (!len)
|
||||
return 0;
|
||||
if (!(lengthW = ImmGetDescriptionW( hkl, NULL, 0 ))) return 0;
|
||||
if (!(bufferW = malloc( (lengthW + 1) * sizeof(WCHAR) ))) return 0;
|
||||
lengthW = ImmGetDescriptionW( hkl, bufferW, lengthW + 1 );
|
||||
lengthA = WideCharToMultiByte( CP_ACP, 0, bufferW, lengthW, bufferA,
|
||||
bufferA ? lengthA : 0, NULL, NULL );
|
||||
if (bufferA) bufferA[lengthA] = 0;
|
||||
free( bufferW );
|
||||
|
||||
/* allocate a buffer of that size */
|
||||
buf = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR) );
|
||||
if( !buf )
|
||||
return 0;
|
||||
|
||||
/* fetch the unicode buffer */
|
||||
len = ImmGetDescriptionW( hKL, buf, len + 1 );
|
||||
|
||||
/* convert it back to ANSI */
|
||||
len = WideCharToMultiByte( CP_ACP, 0, buf, len + 1,
|
||||
lpszDescription, uBufLen, NULL, NULL );
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, buf );
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
return len - 1;
|
||||
return lengthA;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* ImmGetDescriptionW (IMM32.@)
|
||||
*/
|
||||
UINT WINAPI ImmGetDescriptionW(HKL hKL, LPWSTR lpszDescription, UINT uBufLen)
|
||||
UINT WINAPI ImmGetDescriptionW( HKL hkl, WCHAR *buffer, UINT length )
|
||||
{
|
||||
FIXME("(%p, %p, %d): semi stub\n", hKL, lpszDescription, uBufLen);
|
||||
WCHAR path[MAX_PATH];
|
||||
HKEY hkey = 0;
|
||||
DWORD size;
|
||||
|
||||
if (!hKL) return 0;
|
||||
if (!uBufLen) return lstrlenW(L"Wine XIM" );
|
||||
lstrcpynW( lpszDescription, L"Wine XIM", uBufLen );
|
||||
return lstrlenW( lpszDescription );
|
||||
TRACE( "hkl %p, buffer %p, length %u\n", hkl, buffer, length );
|
||||
|
||||
swprintf( path, ARRAY_SIZE(path), layouts_formatW, (ULONG)(ULONG_PTR)hkl );
|
||||
if (RegOpenKeyW( HKEY_LOCAL_MACHINE, path, &hkey )) return 0;
|
||||
|
||||
size = ARRAY_SIZE(path) * sizeof(WCHAR);
|
||||
if (RegGetValueW( hkey, NULL, L"Layout Text", RRF_RT_REG_SZ, NULL, path, &size )) *path = 0;
|
||||
RegCloseKey( hkey );
|
||||
|
||||
size = wcslen( path );
|
||||
if (!buffer) return size;
|
||||
|
||||
lstrcpynW( buffer, path, length );
|
||||
return wcslen( buffer );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -2851,10 +2851,8 @@ static void test_ImmGetDescription(void)
|
|||
ret = ImmGetDescriptionA( NULL, NULL, 100 );
|
||||
ok( !ret, "ImmGetDescriptionA returned %lu\n", ret );
|
||||
ret = ImmGetDescriptionW( hkl, bufferW, 100 );
|
||||
todo_wine
|
||||
ok( !ret, "ImmGetDescriptionW returned %lu\n", ret );
|
||||
ret = ImmGetDescriptionA( hkl, bufferA, 100 );
|
||||
todo_wine
|
||||
ok( !ret, "ImmGetDescriptionA returned %lu\n", ret );
|
||||
ret = GetLastError();
|
||||
ok( ret == 0xdeadbeef, "got error %lu\n", ret );
|
||||
|
@ -2868,46 +2866,33 @@ static void test_ImmGetDescription(void)
|
|||
memset( bufferA, 0xcd, sizeof(bufferA) );
|
||||
ret = ImmGetDescriptionA( hkl, bufferA, 2 );
|
||||
ok( ret == 0, "ImmGetDescriptionA returned %lu\n", ret );
|
||||
todo_wine
|
||||
ok( !strcmp( bufferA, "" ), "got bufferA %s\n", debugstr_a(bufferA) );
|
||||
|
||||
memset( bufferW, 0xcd, sizeof(bufferW) );
|
||||
ret = ImmGetDescriptionW( hkl, bufferW, 11 );
|
||||
todo_wine
|
||||
ok( ret == 10, "ImmGetDescriptionW returned %lu\n", ret );
|
||||
todo_wine
|
||||
ok( !wcscmp( bufferW, L"WineTest I" ), "got bufferW %s\n", debugstr_w(bufferW) );
|
||||
memset( bufferA, 0xcd, sizeof(bufferA) );
|
||||
ret = ImmGetDescriptionA( hkl, bufferA, 11 );
|
||||
todo_wine
|
||||
ok( ret == 0, "ImmGetDescriptionA returned %lu\n", ret );
|
||||
todo_wine
|
||||
ok( !strcmp( bufferA, "" ), "got bufferA %s\n", debugstr_a(bufferA) );
|
||||
|
||||
memset( bufferW, 0xcd, sizeof(bufferW) );
|
||||
ret = ImmGetDescriptionW( hkl, bufferW, 12 );
|
||||
todo_wine
|
||||
ok( ret == 11, "ImmGetDescriptionW returned %lu\n", ret );
|
||||
todo_wine
|
||||
ok( !wcscmp( bufferW, L"WineTest IM" ), "got bufferW %s\n", debugstr_w(bufferW) );
|
||||
memset( bufferA, 0xcd, sizeof(bufferA) );
|
||||
ret = ImmGetDescriptionA( hkl, bufferA, 12 );
|
||||
todo_wine
|
||||
ok( ret == 12, "ImmGetDescriptionA returned %lu\n", ret );
|
||||
todo_wine
|
||||
ok( !strcmp( bufferA, "WineTest IME" ), "got bufferA %s\n", debugstr_a(bufferA) );
|
||||
|
||||
memset( bufferW, 0xcd, sizeof(bufferW) );
|
||||
ret = ImmGetDescriptionW( hkl, bufferW, 13 );
|
||||
todo_wine
|
||||
ok( ret == 12, "ImmGetDescriptionW returned %lu\n", ret );
|
||||
todo_wine
|
||||
ok( !wcscmp( bufferW, L"WineTest IME" ), "got bufferW %s\n", debugstr_w(bufferW) );
|
||||
memset( bufferA, 0xcd, sizeof(bufferA) );
|
||||
ret = ImmGetDescriptionA( hkl, bufferA, 13 );
|
||||
todo_wine
|
||||
ok( ret == 12, "ImmGetDescriptionA returned %lu\n", ret );
|
||||
todo_wine
|
||||
ok( !strcmp( bufferA, "WineTest IME" ), "got bufferA %s\n", debugstr_a(bufferA) );
|
||||
|
||||
ime_cleanup( hkl );
|
||||
|
|
Loading…
Reference in a new issue