Commit 2942261c authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

windows.globalization: Add stub dll.

parent e319a463
...@@ -1660,6 +1660,7 @@ enable_wevtsvc ...@@ -1660,6 +1660,7 @@ enable_wevtsvc
enable_wiaservc enable_wiaservc
enable_wimgapi enable_wimgapi
enable_windows_gaming_input enable_windows_gaming_input
enable_windows_globalization
enable_windows_media_speech enable_windows_media_speech
enable_windowscodecs enable_windowscodecs
enable_windowscodecsext enable_windowscodecsext
...@@ -21126,6 +21127,8 @@ wine_fn_config_makefile dlls/winaspi.dll16 enable_win16 ...@@ -21126,6 +21127,8 @@ wine_fn_config_makefile dlls/winaspi.dll16 enable_win16
wine_fn_config_makefile dlls/windebug.dll16 enable_win16 wine_fn_config_makefile dlls/windebug.dll16 enable_win16
wine_fn_config_makefile dlls/windows.gaming.input enable_windows_gaming_input wine_fn_config_makefile dlls/windows.gaming.input enable_windows_gaming_input
wine_fn_config_makefile dlls/windows.gaming.input/tests enable_tests wine_fn_config_makefile dlls/windows.gaming.input/tests enable_tests
wine_fn_config_makefile dlls/windows.globalization enable_windows_globalization
wine_fn_config_makefile dlls/windows.globalization/tests enable_tests
wine_fn_config_makefile dlls/windows.media.speech enable_windows_media_speech wine_fn_config_makefile dlls/windows.media.speech enable_windows_media_speech
wine_fn_config_makefile dlls/windows.media.speech/tests enable_tests wine_fn_config_makefile dlls/windows.media.speech/tests enable_tests
wine_fn_config_makefile dlls/windowscodecs enable_windowscodecs wine_fn_config_makefile dlls/windowscodecs enable_windowscodecs
......
...@@ -3803,6 +3803,8 @@ WINE_CONFIG_MAKEFILE(dlls/winaspi.dll16,enable_win16) ...@@ -3803,6 +3803,8 @@ WINE_CONFIG_MAKEFILE(dlls/winaspi.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/windebug.dll16,enable_win16) WINE_CONFIG_MAKEFILE(dlls/windebug.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/windows.gaming.input) WINE_CONFIG_MAKEFILE(dlls/windows.gaming.input)
WINE_CONFIG_MAKEFILE(dlls/windows.gaming.input/tests) WINE_CONFIG_MAKEFILE(dlls/windows.gaming.input/tests)
WINE_CONFIG_MAKEFILE(dlls/windows.globalization)
WINE_CONFIG_MAKEFILE(dlls/windows.globalization/tests)
WINE_CONFIG_MAKEFILE(dlls/windows.media.speech) WINE_CONFIG_MAKEFILE(dlls/windows.media.speech)
WINE_CONFIG_MAKEFILE(dlls/windows.media.speech/tests) WINE_CONFIG_MAKEFILE(dlls/windows.media.speech/tests)
WINE_CONFIG_MAKEFILE(dlls/windowscodecs) WINE_CONFIG_MAKEFILE(dlls/windowscodecs)
......
MODULE = windows.globalization.dll
IMPORTS = combase uuid
EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \
main.c
IDL_SRCS = classes.idl
/*
* Runtime Classes for windows.globalization.dll
*
* Copyright 2021 Rémi Bernon for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma makedep register
#include "windows.system.userprofile.idl"
/* WinRT Windows.Globalization implementation
*
* Copyright 2021 Rémi Bernon for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winstring.h"
#include "wine/debug.h"
#include "objbase.h"
#include "initguid.h"
#include "activation.h"
#include "windows.foundation.h"
WINE_DEFAULT_DEBUG_CHANNEL(locale);
static const char *debugstr_hstring(HSTRING hstr)
{
const WCHAR *str;
UINT32 len;
if (hstr && !((ULONG_PTR)hstr >> 16)) return "(invalid)";
str = WindowsGetStringRawBuffer(hstr, &len);
return wine_dbgstr_wn(str, len);
}
struct windows_globalization
{
IActivationFactory IActivationFactory_iface;
LONG ref;
};
static inline struct windows_globalization *impl_from_IActivationFactory(IActivationFactory *iface)
{
return CONTAINING_RECORD(iface, struct windows_globalization, IActivationFactory_iface);
}
static HRESULT STDMETHODCALLTYPE windows_globalization_QueryInterface(
IActivationFactory *iface, REFIID iid, void **out)
{
struct windows_globalization *impl = impl_from_IActivationFactory(iface);
TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
if (IsEqualGUID(iid, &IID_IUnknown) ||
IsEqualGUID(iid, &IID_IInspectable) ||
IsEqualGUID(iid, &IID_IAgileObject) ||
IsEqualGUID(iid, &IID_IActivationFactory))
{
IUnknown_AddRef(iface);
*out = &impl->IActivationFactory_iface;
return S_OK;
}
FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
*out = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE windows_globalization_AddRef(
IActivationFactory *iface)
{
struct windows_globalization *impl = impl_from_IActivationFactory(iface);
ULONG ref = InterlockedIncrement(&impl->ref);
TRACE("iface %p, ref %u.\n", iface, ref);
return ref;
}
static ULONG STDMETHODCALLTYPE windows_globalization_Release(
IActivationFactory *iface)
{
struct windows_globalization *impl = impl_from_IActivationFactory(iface);
ULONG ref = InterlockedDecrement(&impl->ref);
TRACE("iface %p, ref %u.\n", iface, ref);
return ref;
}
static HRESULT STDMETHODCALLTYPE windows_globalization_GetIids(
IActivationFactory *iface, ULONG *iid_count, IID **iids)
{
FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE windows_globalization_GetRuntimeClassName(
IActivationFactory *iface, HSTRING *class_name)
{
FIXME("iface %p, class_name %p stub!\n", iface, class_name);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE windows_globalization_GetTrustLevel(
IActivationFactory *iface, TrustLevel *trust_level)
{
FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE windows_globalization_ActivateInstance(
IActivationFactory *iface, IInspectable **instance)
{
FIXME("iface %p, instance %p stub!\n", iface, instance);
return E_NOTIMPL;
}
static const struct IActivationFactoryVtbl activation_factory_vtbl =
{
windows_globalization_QueryInterface,
windows_globalization_AddRef,
windows_globalization_Release,
/* IInspectable methods */
windows_globalization_GetIids,
windows_globalization_GetRuntimeClassName,
windows_globalization_GetTrustLevel,
/* IActivationFactory methods */
windows_globalization_ActivateInstance,
};
static struct windows_globalization windows_globalization =
{
{&activation_factory_vtbl},
0
};
HRESULT WINAPI DllCanUnloadNow(void)
{
return S_FALSE;
}
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out)
{
FIXME("clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid), debugstr_guid(riid), out);
return CLASS_E_CLASSNOTAVAILABLE;
}
HRESULT WINAPI DllGetActivationFactory(HSTRING classid, IActivationFactory **factory)
{
TRACE("classid %s, factory %p.\n", debugstr_hstring(classid), factory);
*factory = &windows_globalization.IActivationFactory_iface;
IUnknown_AddRef(*factory);
return S_OK;
}
TESTDLL = windows.globalization.dll
IMPORTS = uuid
C_SRCS = \
globalization.c
/*
* Copyright 2021 Rémi Bernon for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winstring.h"
#include "initguid.h"
#include "roapi.h"
#define WIDL_using_Windows_Foundation
#define WIDL_using_Windows_Foundation_Collections
#include "windows.foundation.h"
#define WIDL_using_Windows_System_UserProfile
#include "windows.system.userprofile.h"
#include "wine/test.h"
static HRESULT (WINAPI *pRoActivateInstance)(HSTRING, IInspectable **);
static HRESULT (WINAPI *pRoGetActivationFactory)(HSTRING, REFIID, void **);
static HRESULT (WINAPI *pRoInitialize)(RO_INIT_TYPE);
static void (WINAPI *pRoUninitialize)(void);
static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
static WCHAR *(WINAPI *pWindowsGetStringRawBuffer)(HSTRING, UINT32 *);
static void test_GlobalizationPreferences(void)
{
static const WCHAR *class_name = L"Windows.System.UserProfile.GlobalizationPreferences";
IGlobalizationPreferencesStatics *preferences_statics = NULL;
IVectorView_HSTRING *languages = NULL;
IActivationFactory *factory = NULL;
IInspectable *inspectable = NULL, *tmp_inspectable = NULL;
IAgileObject *agile_object = NULL, *tmp_agile_object = NULL;
HSTRING str, tmp_str;
BOOLEAN found;
HRESULT hr;
UINT32 len;
WCHAR *buf, locale[LOCALE_NAME_MAX_LENGTH], *country, *tmp;
UINT32 i, size;
GetUserDefaultLocaleName(locale, LOCALE_NAME_MAX_LENGTH);
if ((tmp = wcsrchr(locale, '_'))) *tmp = 0;
if (!(tmp = wcschr(locale, '-')) || (wcslen(tmp) > 3 && !(tmp = wcschr(tmp + 1, '-')))) country = wcsdup(L"US");
else country = wcsdup(tmp + 1);
GetUserDefaultLocaleName(locale, LOCALE_NAME_MAX_LENGTH);
hr = pRoInitialize(RO_INIT_MULTITHREADED);
ok(hr == S_OK, "RoInitialize failed, hr %#x\n", hr);
hr = pWindowsCreateString(class_name, wcslen(class_name), &str);
ok(hr == S_OK, "WindowsCreateString failed, hr %#x\n", hr);
hr = pRoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "RoGetActivationFactory failed, hr %#x\n", hr);
if (hr == REGDB_E_CLASSNOTREG)
{
win_skip("%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w(class_name));
pWindowsDeleteString(str);
pRoUninitialize();
free(country);
return;
}
hr = IActivationFactory_QueryInterface(factory, &IID_IInspectable, (void **)&inspectable);
ok(hr == S_OK, "IActivationFactory_QueryInterface IID_IInspectable failed, hr %#x\n", hr);
hr = IActivationFactory_QueryInterface(factory, &IID_IAgileObject, (void **)&agile_object);
ok(hr == S_OK, "IActivationFactory_QueryInterface IID_IAgileObject failed, hr %#x\n", hr);
hr = IActivationFactory_QueryInterface(factory, &IID_IGlobalizationPreferencesStatics, (void **)&preferences_statics);
todo_wine ok(hr == S_OK, "IActivationFactory_QueryInterface IID_IGlobalizationPreferencesStatics failed, hr %#x\n", hr);
if (FAILED(hr)) goto done;
hr = IGlobalizationPreferencesStatics_QueryInterface(preferences_statics, &IID_IInspectable, (void **)&tmp_inspectable);
ok(hr == S_OK, "IGlobalizationPreferencesStatics_QueryInterface IID_IInspectable failed, hr %#x\n", hr);
ok(tmp_inspectable == inspectable, "IGlobalizationPreferencesStatics_QueryInterface IID_IInspectable returned %p, expected %p\n", tmp_inspectable, inspectable);
IInspectable_Release(tmp_inspectable);
hr = IGlobalizationPreferencesStatics_QueryInterface(preferences_statics, &IID_IAgileObject, (void **)&tmp_agile_object);
ok(hr == S_OK, "IGlobalizationPreferencesStatics_QueryInterface IID_IAgileObject failed, hr %#x\n", hr);
ok(tmp_agile_object == agile_object, "IGlobalizationPreferencesStatics_QueryInterface IID_IAgileObject returned %p, expected %p\n", tmp_agile_object, agile_object);
IAgileObject_Release(tmp_agile_object);
hr = IGlobalizationPreferencesStatics_get_HomeGeographicRegion(preferences_statics, &tmp_str);
ok(hr == S_OK, "IGlobalizationPreferencesStatics_get_HomeGeographicRegion failed, hr %#x\n", hr);
buf = pWindowsGetStringRawBuffer(tmp_str, &len);
ok(buf != NULL && len > 0, "WindowsGetStringRawBuffer returned buf %p, len %u\n", buf, len);
ok(wcslen(country) == len && !memcmp(buf, country, len),
"IGlobalizationPreferencesStatics_get_HomeGeographicRegion returned len %u, str %s, expected %s\n",
len, wine_dbgstr_w(buf), wine_dbgstr_w(country));
pWindowsDeleteString(tmp_str);
hr = IGlobalizationPreferencesStatics_get_Languages(preferences_statics, &languages);
ok(hr == S_OK, "IGlobalizationPreferencesStatics_get_Languages failed, hr %#x\n", hr);
hr = IVectorView_HSTRING_QueryInterface(languages, &IID_IInspectable, (void **)&tmp_inspectable);
ok(hr == S_OK, "IVectorView_HSTRING_QueryInterface failed, hr %#x\n", hr);
ok(tmp_inspectable != inspectable, "IVectorView_HSTRING_QueryInterface returned %p, expected %p\n", tmp_inspectable, inspectable);
IInspectable_Release(tmp_inspectable);
hr = IVectorView_HSTRING_QueryInterface(languages, &IID_IAgileObject, (void **)&tmp_agile_object);
ok(hr == S_OK, "IVectorView_HSTRING_QueryInterface failed, hr %#x\n", hr);
ok(tmp_agile_object != agile_object, "IVectorView_HSTRING_QueryInterface IID_IAgileObject returned agile_object\n");
IAgileObject_Release(tmp_agile_object);
size = 0xdeadbeef;
hr = IVectorView_HSTRING_get_Size(languages, &size);
ok(hr == S_OK, "IVectorView_HSTRING_get_Size failed, hr %#x\n", hr);
ok(size != 0 && size != 0xdeadbeef, "IVectorView_HSTRING_get_Size returned %u\n", size);
hr = IVectorView_HSTRING_GetAt(languages, 0, &tmp_str);
ok(hr == S_OK, "IVectorView_HSTRING_GetAt failed, hr %#x\n", hr);
buf = pWindowsGetStringRawBuffer(tmp_str, &len);
ok(buf != NULL && len > 0, "WindowsGetStringRawBuffer returned buf %p, len %u\n", buf, len);
ok(wcslen(locale) == len && !memcmp(buf, locale, len),
"IGlobalizationPreferencesStatics_get_Languages 0 returned len %u, str %s, expected %s\n",
len, wine_dbgstr_w(buf), wine_dbgstr_w(locale));
i = 0xdeadbeef;
found = FALSE;
hr = IVectorView_HSTRING_IndexOf(languages, tmp_str, &i, &found);
ok(hr == S_OK, "IVectorView_HSTRING_IndexOf failed, hr %#x\n", hr);
ok(i == 0 && found == TRUE, "IVectorView_HSTRING_IndexOf returned size %d, found %d\n", size, found);
pWindowsDeleteString(tmp_str);
tmp_str = (HSTRING)0xdeadbeef;
hr = IVectorView_HSTRING_GetAt(languages, size, &tmp_str);
ok(hr == E_BOUNDS, "IVectorView_HSTRING_GetAt failed, hr %#x\n", hr);
ok(tmp_str == NULL, "IVectorView_HSTRING_GetAt returned %p\n", tmp_str);
IVectorView_HSTRING_Release(languages);
IGlobalizationPreferencesStatics_Release(preferences_statics);
done:
IAgileObject_Release(agile_object);
IInspectable_Release(inspectable);
IActivationFactory_Release(factory);
pWindowsDeleteString(str);
pRoUninitialize();
free(country);
}
START_TEST(globalization)
{
HMODULE combase;
if (!(combase = LoadLibraryW(L"combase.dll")))
{
win_skip("Failed to load combase.dll, skipping tests\n");
return;
}
#define LOAD_FUNCPTR(x) \
if (!(p##x = (void*)GetProcAddress(combase, #x))) \
{ \
win_skip("Failed to find %s in combase.dll, skipping tests.\n", #x); \
return; \
}
LOAD_FUNCPTR(RoActivateInstance);
LOAD_FUNCPTR(RoGetActivationFactory);
LOAD_FUNCPTR(RoInitialize);
LOAD_FUNCPTR(RoUninitialize);
LOAD_FUNCPTR(WindowsCreateString);
LOAD_FUNCPTR(WindowsDeleteString);
LOAD_FUNCPTR(WindowsGetStringRawBuffer);
#undef LOAD_FUNCPTR
test_GlobalizationPreferences();
}
1 stdcall -private DllCanUnloadNow()
2 stdcall -private DllGetActivationFactory(ptr ptr)
3 stdcall -private DllGetClassObject(ptr ptr ptr)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment