Rémi Bernon : windows.globalization: Implement IGlobalizationPreferencesStatics::HomeGeographicRegion.

Alexandre Julliard julliard at winehq.org
Fri Mar 26 16:03:31 CDT 2021


Module: wine
Branch: master
Commit: 6cffc2dc1a9d2ef665e0bfbebc991ca0199fba87
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6cffc2dc1a9d2ef665e0bfbebc991ca0199fba87

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Mar 26 10:24:57 2021 +0100

windows.globalization: Implement IGlobalizationPreferencesStatics::HomeGeographicRegion.

Returning the user default country.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/windows.globalization/main.c                | 12 ++++++++++--
 dlls/windows.globalization/tests/globalization.c | 15 +++++----------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/dlls/windows.globalization/main.c b/dlls/windows.globalization/main.c
index 17bb49a1c4e..84813152047 100644
--- a/dlls/windows.globalization/main.c
+++ b/dlls/windows.globalization/main.c
@@ -225,8 +225,16 @@ static HRESULT STDMETHODCALLTYPE globalization_preferences_get_Languages(
 static HRESULT STDMETHODCALLTYPE globalization_preferences_get_HomeGeographicRegion(
         IGlobalizationPreferencesStatics *iface, HSTRING* out)
 {
-    FIXME("iface %p, out %p stub!\n", iface, out);
-    return E_NOTIMPL;
+    WCHAR country[16];
+
+    TRACE("iface %p, out %p.\n", iface, out);
+
+    if (!GetUserDefaultGeoName(country, 16))
+        return E_FAIL;
+
+    TRACE("returning country %s\n", debugstr_w(country));
+
+    return WindowsCreateString(country, wcslen(country), out);
 }
 
 static HRESULT STDMETHODCALLTYPE globalization_preferences_get_WeekStartsOn(
diff --git a/dlls/windows.globalization/tests/globalization.c b/dlls/windows.globalization/tests/globalization.c
index 1918322b7a2..00d9cee5b0d 100644
--- a/dlls/windows.globalization/tests/globalization.c
+++ b/dlls/windows.globalization/tests/globalization.c
@@ -55,14 +55,11 @@ static void test_GlobalizationPreferences(void)
     BOOLEAN found;
     HRESULT hr;
     UINT32 len;
-    WCHAR *buf, locale[LOCALE_NAME_MAX_LENGTH], *country, *tmp;
+    WCHAR *buf, locale[LOCALE_NAME_MAX_LENGTH], country[16];
     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);
+    GetUserDefaultGeoName(country, 16);
 
     hr = pRoInitialize(RO_INIT_MULTITHREADED);
     ok(hr == S_OK, "RoInitialize failed, hr %#x\n", hr);
@@ -77,7 +74,6 @@ static void test_GlobalizationPreferences(void)
         win_skip("%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w(class_name));
         pWindowsDeleteString(str);
         pRoUninitialize();
-        free(country);
         return;
     }
 
@@ -101,8 +97,7 @@ static void test_GlobalizationPreferences(void)
     IAgileObject_Release(tmp_agile_object);
 
     hr = IGlobalizationPreferencesStatics_get_HomeGeographicRegion(preferences_statics, &tmp_str);
-    todo_wine ok(hr == S_OK, "IGlobalizationPreferencesStatics_get_HomeGeographicRegion failed, hr %#x\n", hr);
-    if (FAILED(hr)) goto done;
+    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);
@@ -113,7 +108,8 @@ static void test_GlobalizationPreferences(void)
     pWindowsDeleteString(tmp_str);
 
     hr = IGlobalizationPreferencesStatics_get_Languages(preferences_statics, &languages);
-    ok(hr == S_OK, "IGlobalizationPreferencesStatics_get_Languages failed, hr %#x\n", hr);
+    todo_wine ok(hr == S_OK, "IGlobalizationPreferencesStatics_get_Languages failed, hr %#x\n", hr);
+    if (FAILED(hr)) goto done;
 
     hr = IVectorView_HSTRING_QueryInterface(languages, &IID_IInspectable, (void **)&tmp_inspectable);
     ok(hr == S_OK, "IVectorView_HSTRING_QueryInterface failed, hr %#x\n", hr);
@@ -164,7 +160,6 @@ done:
     pWindowsDeleteString(str);
 
     pRoUninitialize();
-    free(country);
 }
 
 START_TEST(globalization)




More information about the wine-cvs mailing list