kernel32: Improve the stub for GetThreadPreferredUILanguages.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-04-29 10:14:35 +02:00 committed by Alexandre Julliard
parent 57b7a9937d
commit c90845cf93
4 changed files with 77 additions and 42 deletions

View File

@ -1048,28 +1048,10 @@ INT WINAPI GetSystemDefaultLocaleName(LPWSTR localename, INT len)
return LCIDToLocaleName(lcid, localename, len, 0);
}
/***********************************************************************
* GetSystemPreferredUILanguages (KERNEL32.@)
*/
BOOL WINAPI GetSystemPreferredUILanguages(DWORD flags, ULONG* count, WCHAR* buffer, ULONG* size)
static BOOL get_dummy_preferred_ui_language( DWORD flags, ULONG *count, WCHAR *buffer, ULONG *size )
{
LCTYPE type;
int lsize;
if (flags & ~(MUI_LANGUAGE_NAME | MUI_LANGUAGE_ID | MUI_MACHINE_LANGUAGE_SETTINGS))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if ((flags & MUI_LANGUAGE_NAME) && (flags & MUI_LANGUAGE_ID))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (*size && !buffer)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
FIXME("(0x%x %p %p %p) returning a dummy value (current locale)\n", flags, count, buffer, size);
@ -1109,6 +1091,49 @@ BOOL WINAPI GetSystemPreferredUILanguages(DWORD flags, ULONG* count, WCHAR* buff
*count = 1;
TRACE("returned variable content: %d, \"%s\", %d\n", *count, debugstr_w(buffer), *size);
return TRUE;
}
/***********************************************************************
* GetSystemPreferredUILanguages (KERNEL32.@)
*/
BOOL WINAPI GetSystemPreferredUILanguages(DWORD flags, ULONG* count, WCHAR* buffer, ULONG* size)
{
if (flags & ~(MUI_LANGUAGE_NAME | MUI_LANGUAGE_ID | MUI_MACHINE_LANGUAGE_SETTINGS))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if ((flags & MUI_LANGUAGE_NAME) && (flags & MUI_LANGUAGE_ID))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (*size && !buffer)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return get_dummy_preferred_ui_language( flags, count, buffer, size );
}
/***********************************************************************
* SetThreadPreferredUILanguages (KERNEL32.@)
*/
BOOL WINAPI SetThreadPreferredUILanguages( DWORD flags, PCZZWSTR buffer, PULONG count )
{
FIXME( "%u, %p, %p\n", flags, buffer, count );
return TRUE;
}
/***********************************************************************
* GetThreadPreferredUILanguages (KERNEL32.@)
*/
BOOL WINAPI GetThreadPreferredUILanguages( DWORD flags, ULONG *count, WCHAR *buf, ULONG *size )
{
FIXME( "%08x, %p, %p %p\n", flags, count, buf, size );
return get_dummy_preferred_ui_language( flags, count, buf, size );
}
/***********************************************************************

View File

@ -98,6 +98,7 @@ static INT (WINAPI *pGetGeoInfoA)(GEOID, GEOTYPE, LPSTR, INT, LANGID);
static INT (WINAPI *pGetGeoInfoW)(GEOID, GEOTYPE, LPWSTR, INT, LANGID);
static BOOL (WINAPI *pEnumSystemGeoID)(GEOCLASS, GEOID, GEO_ENUMPROC);
static BOOL (WINAPI *pGetSystemPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*);
static BOOL (WINAPI *pGetThreadPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*);
static void InitFunctionPointers(void)
{
@ -127,6 +128,7 @@ static void InitFunctionPointers(void)
X(GetGeoInfoW);
X(EnumSystemGeoID);
X(GetSystemPreferredUILanguages);
X(GetThreadPreferredUILanguages);
#undef X
}
@ -4770,6 +4772,32 @@ static void test_GetSystemPreferredUILanguages(void)
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
}
static void test_GetThreadPreferredUILanguages(void)
{
BOOL ret;
ULONG count, size;
WCHAR *buf;
if (!pGetThreadPreferredUILanguages)
{
win_skip("GetThreadPreferredUILanguages is not available.\n");
return;
}
size = count = 0;
ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID|MUI_UI_FALLBACK, &count, NULL, &size);
ok(ret, "got %u\n", GetLastError());
ok(count, "expected count > 0\n");
ok(size, "expected size > 0\n");
count = 0;
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size * sizeof(WCHAR));
ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID|MUI_UI_FALLBACK, &count, buf, &size);
ok(ret, "got %u\n", GetLastError());
ok(count, "expected count > 0\n");
HeapFree(GetProcessHeap(), 0, buf);
}
START_TEST(locale)
{
InitFunctionPointers();
@ -4813,6 +4841,7 @@ START_TEST(locale)
test_EnumSystemGeoID();
test_invariant();
test_GetSystemPreferredUILanguages();
test_GetThreadPreferredUILanguages();
/* this requires collation table patch to make it MS compatible */
if (0) test_sorting();
}

View File

@ -887,26 +887,6 @@ BOOL WINAPI GetThreadIOPendingFlag( HANDLE thread, PBOOL io_pending )
return TRUE;
}
/***********************************************************************
* SetThreadPreferredUILanguages (KERNEL32.@)
*/
BOOL WINAPI SetThreadPreferredUILanguages( DWORD flags, PCZZWSTR buffer, PULONG count )
{
FIXME( "%u, %p, %p\n", flags, buffer, count );
return TRUE;
}
/***********************************************************************
* GetThreadPreferredUILanguages (KERNEL32.@)
*/
BOOL WINAPI GetThreadPreferredUILanguages( DWORD flags, PULONG count, PCZZWSTR buffer, PULONG buffersize )
{
FIXME( "%u, %p, %p %p\n", flags, count, buffer, buffersize );
*count = 0;
*buffersize = 0;
return TRUE;
}
/***********************************************************************
* CallbackMayRunLong (KERNEL32.@)
*/

View File

@ -909,6 +909,7 @@ WINBASEAPI LCID WINAPI GetSystemDefaultLCID(void);
WINBASEAPI LANGID WINAPI GetSystemDefaultUILanguage(void);
WINBASEAPI BOOL WINAPI GetSystemPreferredUILanguages(DWORD,ULONG*,WCHAR*,ULONG*);
WINBASEAPI LCID WINAPI GetThreadLocale(void);
WINBASEAPI BOOL WINAPI GetThreadPreferredUILanguages(DWORD,ULONG*,WCHAR*,ULONG*);
WINBASEAPI INT WINAPI GetTimeFormatA(LCID,DWORD,const SYSTEMTIME*,LPCSTR,LPSTR,INT);
WINBASEAPI INT WINAPI GetTimeFormatEx(LPCWSTR,DWORD,const SYSTEMTIME*,LPCWSTR,LPWSTR,INT);
WINBASEAPI INT WINAPI GetTimeFormatW(LCID,DWORD,const SYSTEMTIME*,LPCWSTR,LPWSTR,INT);