[PATCH 5/5] winecfg: Add time zone selection page

Dmitry Timoshkov dmitry at codeweavers.com
Mon Jul 30 09:04:13 CDT 2007


>From a7c5d520034a5227e6084b854c21dd427f7c92f5 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry at codeweavers.com>
Date: Mon, 30 Jul 2007 22:56:02 +0900
Subject: [PATCH 5/5] winecfg: Add time zone selection page

---
 programs/winecfg/Bg.rc       |    1 +
 programs/winecfg/Cs.rc       |    1 +
 programs/winecfg/De.rc       |    1 +
 programs/winecfg/En.rc       |    9 ++
 programs/winecfg/Es.rc       |    1 +
 programs/winecfg/Fi.rc       |    1 +
 programs/winecfg/Fr.rc       |    1 +
 programs/winecfg/Hu.rc       |    1 +
 programs/winecfg/It.rc       |    1 +
 programs/winecfg/Ja.rc       |    1 +
 programs/winecfg/Ko.rc       |    1 +
 programs/winecfg/Makefile.in |    1 +
 programs/winecfg/Nl.rc       |    1 +
 programs/winecfg/No.rc       |    3 +-
 programs/winecfg/Pl.rc       |    1 +
 programs/winecfg/Pt.rc       |    1 +
 programs/winecfg/Ro.rc       |    1 +
 programs/winecfg/Ru.rc       |    1 +
 programs/winecfg/Si.rc       |    1 +
 programs/winecfg/Tr.rc       |    1 +
 programs/winecfg/main.c      |   16 +++-
 programs/winecfg/resource.h  |    9 ++-
 programs/winecfg/time.c      |  279 ++++++++++++++++++++++++++++++++++++++++++
 programs/winecfg/winecfg.h   |    1 +
 24 files changed, 332 insertions(+), 3 deletions(-)
 create mode 100644 programs/winecfg/time.c

diff --git a/programs/winecfg/Bg.rc b/programs/winecfg/Bg.rc
index 0680edf..e24da7b 100644
--- a/programs/winecfg/Bg.rc
+++ b/programs/winecfg/Bg.rc
@@ -223,6 +223,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Няма настроен звуков драйвер.\n\nЗа вас беше избран драйвер по подразбиране.\nМоже да го използвате или да изберете друг.\n\nТрябва да щракнете на Потвърди, за да влезе в сила избора."
     IDS_SHELL_FOLDER        "Папка"
     IDS_LINKS_TO            "Връзка към"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Cs.rc b/programs/winecfg/Cs.rc
index 1073744..2a8aecb 100644
--- a/programs/winecfg/Cs.rc
+++ b/programs/winecfg/Cs.rc
@@ -225,6 +225,7 @@ BEGIN
     IDS_AUDIO_MISSING       "V registrech chybн zбznam o vybranйm zvukovйm ovladaиi.\n\nAutomaticky byl zvolen doporuиenэ ovladaи.\nMщћete pouћнt tento ovladaи nebo si z ostatnнch dostupnэch vybrat jinэ.\n\nDokud nekliknete na tlaинtko Provйst, nebude vybranэ ovladaи pouћit."
     IDS_SHELL_FOLDER        "Domбcн adresбшe"
     IDS_LINKS_TO            "Odkaz na"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/De.rc b/programs/winecfg/De.rc
index 3bd2846..ca3e69c 100644
--- a/programs/winecfg/De.rc
+++ b/programs/winecfg/De.rc
@@ -221,6 +221,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Zur Zeit ist kein Audio Treiber in der Registry eingetragen.\n\nEin bevorzugter Treiber wurde fьr Sie ausgewдhlt.\nSie kцnnen diesen Treiber nutzen oder einen anderen verfьgbaren Treiber auswдhlen.\n\nSie mьssen auf Anwenden klicken, damit die Дnderung ьbernommen wird."
     IDS_SHELL_FOLDER        "Shell-Ordner"
     IDS_LINKS_TO            "Verknьpft mit"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/En.rc b/programs/winecfg/En.rc
index 9d19a62..f7e0ca2 100644
--- a/programs/winecfg/En.rc
+++ b/programs/winecfg/En.rc
@@ -202,6 +202,14 @@ BEGIN
     PUSHBUTTON      "Browse",IDC_BROWSE_SFPATH,215,195,30,13,WS_DISABLED
 END
 
+IDD_TIMEZONECFG DIALOG DISCARDABLE  0, 0, 260, 250
+STYLE WS_CHILD | WS_DISABLED
+FONT 8, "MS Shell Dlg"
+BEGIN
+    LTEXT "Choose your Time Zone:",IDC_STATIC,7,7,232,8
+    COMBOBOX IDC_TIME_TZCOMBO,7,17,236,250,CBS_SORT|CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_WINE_VERSION        "CVS"
@@ -223,6 +231,7 @@ BEGIN
     IDS_AUDIO_MISSING       "There is no audio driver currently specified in the registry.\n\nA recommended driver has been selected for you.\nYou can use this driver or select another driver if available.\n\nYou must click Apply for the selection to take effect."
     IDS_SHELL_FOLDER        "Shell Folder"
     IDS_LINKS_TO            "Links to"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Es.rc b/programs/winecfg/Es.rc
index 28b237d..8df61a9 100644
--- a/programs/winecfg/Es.rc
+++ b/programs/winecfg/Es.rc
@@ -221,6 +221,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Actualmente no hay ningъn manejador de audio especificado en el registro.\n\nSe ha seleccionado para usted un manejador recomendado. Puede usar йste o seleccionar otro manejador disponible.\n\nDebe pulsar Aplicar para que la selecciуn surja efecto."
     IDS_SHELL_FOLDER        "Carpeta del sistema"
     IDS_LINKS_TO            "Enlaza a"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Fi.rc b/programs/winecfg/Fi.rc
index a19c5ba..8d8ca86 100644
--- a/programs/winecfg/Fi.rc
+++ b/programs/winecfg/Fi.rc
@@ -220,6 +220,7 @@ BEGIN
     IDS_THEMEFILE_SELECT    "Valitse teematiedosto"
     IDS_SHELL_FOLDER        "Shell Folder"
     IDS_LINKS_TO            "Links to"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Fr.rc b/programs/winecfg/Fr.rc
index 8dc733c..1b5f849 100644
--- a/programs/winecfg/Fr.rc
+++ b/programs/winecfg/Fr.rc
@@ -221,6 +221,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Aucun pilote audio n'est actuellement dйfini.\n\nLe pilote recommandй a йtй sйlectionnй pour vous.\nVous pouvez utiliser ce pilote ou en sйlectionner un autre si disponible.\n\nVous devez cliquer sur Appliquer pour que la sйlection prenne effet."
     IDS_SHELL_FOLDER        "Dossier systиme"
     IDS_LINKS_TO            "Liй а"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Hu.rc b/programs/winecfg/Hu.rc
index aa22659..5d26560 100644
--- a/programs/winecfg/Hu.rc
+++ b/programs/winecfg/Hu.rc
@@ -217,6 +217,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Jelenleg nincs hangmeghajtу kivбlasztva a regisztrбciуs adatbбzisban.\n\nEgy ajбnlott meghajtуprogram ki lett vбlasztva Цnnek.\nЦn hasznбlhatja ezt a meghajtуt, vagy vбlaszthat mбsikat ha elйrhetх.\n\nЦnnek az alkalmazбsra kell kattintani a kivбlasztбs йrvйnybe lйptetйsйhez."
     IDS_SHELL_FOLDER        "Rendszermappa"
     IDS_LINKS_TO            "Ide linkel"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/It.rc b/programs/winecfg/It.rc
index db0f86f..3396f5d 100644
--- a/programs/winecfg/It.rc
+++ b/programs/winecfg/It.rc
@@ -132,4 +132,5 @@ BEGIN
     IDS_TAB_GENERAL         "Generale"
     IDS_TAB_DLLS            "Librerie"
     IDS_TAB_DRIVES          "Drive"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
diff --git a/programs/winecfg/Ja.rc b/programs/winecfg/Ja.rc
index 207dff3..de694d7 100644
--- a/programs/winecfg/Ja.rc
+++ b/programs/winecfg/Ja.rc
@@ -215,6 +215,7 @@ BEGIN
     IDS_THEMEFILE_SELECT    "ѓeЃ[ѓ}ѓtѓ@ѓCѓ‹‚р‘I‚с‚Е‚­‚ѕ‚і‚ў"
     IDS_SHELL_FOLDER        "Shell Folder"
     IDS_LINKS_TO            "Links to"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Ko.rc b/programs/winecfg/Ko.rc
index fe20fc4..34d7734 100644
--- a/programs/winecfg/Ko.rc
+++ b/programs/winecfg/Ko.rc
@@ -223,6 +223,7 @@ BEGIN
     IDS_AUDIO_MISSING       "ЗцАз ·№БцЅєЖ®ё®їЎ їАµрїА µе¶уАМ№ц°Ў БцБ¤µЗѕо АЦБц ѕКЅАґПґЩ.\n\nГЯГµ µе¶уАМ№ц°Ў ј±ЕГѕъЅАґПґЩ.\nАМ µе¶уАМ№цё¦ »зїлЗП°ЕіЄ °ЎґЙЗС ґЩёҐ µе¶уАМ№цё¦ ј±ЕГЗТ јц АЦЅАґПґЩ.\n\nј±ЕГ »зЗЧАМ Иї°ъё¦ іЄЕёі»±в А§ЗШј­ґВ Аыїл №цЖ°А» ґ­·ЇѕЯ ЗХґПґЩ."
     IDS_SHELL_FOLDER        "Ѕ© Жъґх"
     IDS_LINKS_TO            "ї©±вїЎ ї¬°б"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Makefile.in b/programs/winecfg/Makefile.in
index 74c18b3..2615459 100644
--- a/programs/winecfg/Makefile.in
+++ b/programs/winecfg/Makefile.in
@@ -16,6 +16,7 @@ C_SRCS = \
 	libraries.c \
 	main.c \
 	theme.c \
+	time.c \
 	winecfg.c \
 	x11drvdlg.c
 
diff --git a/programs/winecfg/Nl.rc b/programs/winecfg/Nl.rc
index f24da7b..de4b865 100644
--- a/programs/winecfg/Nl.rc
+++ b/programs/winecfg/Nl.rc
@@ -224,6 +224,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Op dit moment is er geen stuurprogramma voor geluid gespecificeerd in de registry.\n\nEen aanbevolen stuurbestand is voor u geselecteerd.\nU kunt dit stuurbestand gebruiken of (indien beschikbaar) een ander selecteren.\n\nKlik op 'Toepassen' om deze selectie te activeren."
     IDS_SHELL_FOLDER        "Persoonlijke map"
     IDS_LINKS_TO            "Verwijst naar"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/No.rc b/programs/winecfg/No.rc
index e9d4187..b82441e 100644
--- a/programs/winecfg/No.rc
+++ b/programs/winecfg/No.rc
@@ -220,8 +220,9 @@ BEGIN
     IDS_AUDIO_MISSING       "Ingen lyddriver er oppgitt i registeret.\n\nEn anbefalt driver er valgt for deg;\nbruk den eller velg en annen,\n\nog trykk «Bruk» for at endringene skal tre i kraft."
     IDS_SHELL_FOLDER        "Skallkatalog"
     IDS_LINKS_TO            "Peker til"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
-    
+
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_DLL_WARNING         "Endring av lastingsrekkefшlgen for dette biblioteket anbefales ikke.\nEr du sikker pе at du vil gjшre det?"
diff --git a/programs/winecfg/Pl.rc b/programs/winecfg/Pl.rc
index 6f0b2c4..cc12d5c 100644
--- a/programs/winecfg/Pl.rc
+++ b/programs/winecfg/Pl.rc
@@ -226,6 +226,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Nie wybrano sterownika dџwiкku.\n\nZalecany sterownik zostaі wіaњnie zaznaczony.\nMoїesz go uїyж lub wybraж jakiњ inny.\n\nAby wybуr zostaі zapamiкtany uїyj 'Zastosuj'."
     IDS_SHELL_FOLDER        "Folder"
     IDS_LINKS_TO            "Dowi№zany do"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Pt.rc b/programs/winecfg/Pt.rc
index 13d9f56..67b73c7 100644
--- a/programs/winecfg/Pt.rc
+++ b/programs/winecfg/Pt.rc
@@ -261,4 +261,5 @@ BEGIN
     IDS_TAB_GENERAL         "Geral"
     IDS_TAB_DLLS            "Bibliotecas"
     IDS_TAB_DRIVES          "Unidades"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
diff --git a/programs/winecfg/Ro.rc b/programs/winecfg/Ro.rc
index df5efd9..f91b98a 100644
--- a/programs/winecfg/Ro.rc
+++ b/programs/winecfg/Ro.rc
@@ -222,6 +222,7 @@ BEGIN
     IDS_AUDIO_MISSING       "There is no audio driver currently specified in the registry.\n\nA recommended driver has been selected for you.\nYou can use this driver or select another driver if available.\n\nYou must click Apply for the selection to take effect."
     IDS_SHELL_FOLDER        "Shell Folder"
     IDS_LINKS_TO            "Legat la"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Ru.rc b/programs/winecfg/Ru.rc
index 1d094a1..b646aa7 100644
--- a/programs/winecfg/Ru.rc
+++ b/programs/winecfg/Ru.rc
@@ -222,6 +222,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Конфигурация звукового драйвера не найдена.\n\nВыбран драйвер по умолчанию. Если необходимо, вы можете выбрать другой из списка доступных драйверов.\n\nДля сохранения изменений нажмите кнопку Применить."
     IDS_SHELL_FOLDER        "Стандартные папки"
     IDS_LINKS_TO            "Связано с"
+    IDS_TAB_TIMEZONE        "Часовой пояс"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/Si.rc b/programs/winecfg/Si.rc
index bdbeff2..f648265 100644
--- a/programs/winecfg/Si.rc
+++ b/programs/winecfg/Si.rc
@@ -89,4 +89,5 @@ BEGIN
     IDS_TAB_GENERAL         "General"
     IDS_TAB_DLLS            "Libraries"
     IDS_TAB_DRIVES          "Drives"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
diff --git a/programs/winecfg/Tr.rc b/programs/winecfg/Tr.rc
index dec0419..07e8d02 100644
--- a/programs/winecfg/Tr.rc
+++ b/programs/winecfg/Tr.rc
@@ -220,6 +220,7 @@ BEGIN
     IDS_AUDIO_MISSING       "Sistem kaydэnda belirlenmiю bir ses sьrьcьsь yok.\n\nЦnerilen bir sьrьcь sizin iзin seзildi.\nBu sьrьcьyь kullanabilir veya varsa baюka bir sьrьcьyь seзebilirsiniz.\n\nSeзimin etkili olabilmesi iзin Uygula'yэ tэklamalэsэnэz."
     IDS_SHELL_FOLDER        "Klasцr"
     IDS_LINKS_TO            "Hedef Dizin"
+    IDS_TAB_TIMEZONE        "Time Zone"
 END
 
 STRINGTABLE DISCARDABLE
diff --git a/programs/winecfg/main.c b/programs/winecfg/main.c
index 6fc77f7..f2a0712 100644
--- a/programs/winecfg/main.c
+++ b/programs/winecfg/main.c
@@ -21,6 +21,8 @@
  *
  */
 
+#include <assert.h>
+
 #define WIN32_LEAN_AND_MEAN
 
 #define NONAMELESSUNION
@@ -78,7 +80,7 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
     return FALSE;
 }
 
-#define NUM_PROPERTY_PAGES 7
+#define NUM_PROPERTY_PAGES 8
 
 static INT_PTR
 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
@@ -159,6 +161,16 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
     psp[pg].lParam = 0;
     pg++;
 
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
+    psp[pg].dwFlags = PSP_USETITLE;
+    psp[pg].hInstance = hInstance;
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_TIMEZONECFG);
+    psp[pg].u2.pszIcon = NULL;
+    psp[pg].pfnDlgProc = TimeZoneDlgProc;
+    psp[pg].pszTitle =  load_string (IDS_TAB_TIMEZONE);
+    psp[pg].lParam = 0;
+    pg++;
+
     /*
      * Fill out the (General) PROPSHEETPAGE data structure 
      * for the property sheet
@@ -173,6 +185,8 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
     psp[pg].lParam = 0;
     pg++;
 
+    assert(pg == NUM_PROPERTY_PAGES);
+
     /*
      * Fill out the PROPSHEETHEADER
      */
diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h
index 811a115..7653f3d 100644
--- a/programs/winecfg/resource.h
+++ b/programs/winecfg/resource.h
@@ -41,7 +41,9 @@
 #define IDS_THEMEFILE_SELECT            15
 #define IDS_SHELL_FOLDER                16
 #define IDS_LINKS_TO                    17
-#define IDS_WINECFG_TITLE_APP           18   /* App specific title */
+#define IDS_TAB_TIMEZONE                18
+#define IDS_WINECFG_TITLE_APP           99   /* App specific title */
+
 #define IDD_MAINDLG                     101
 #define IDB_WINE                        104
 #define IDD_ABOUTCFG                    107
@@ -50,8 +52,11 @@
 #define IDD_GRAPHCFG                    110
 #define IDD_DLLCFG                      111
 #define IDD_DRIVECFG                    112
+#define IDD_TIMEZONECFG                 113
 #define IDD_DESKTOP_INTEGRATION         115
+
 #define IDB_WINE_LOGO                   200
+
 #define IDC_TABABOUT                    1001
 #define IDC_APPLYBTN                    1002
 #define IDC_WINVER                      1012
@@ -228,3 +233,5 @@
 #define IDC_SYSPARAMS_ACTIVE_TITLE_TEXT 8413
 #define IDC_SYSPARAMS_INACTIVE_TITLE    8414
 #define IDC_SYSPARAMS_INACTIVE_TITLE_TEXT 8415
+
+#define IDC_TIME_TZCOMBO                9001
diff --git a/programs/winecfg/time.c b/programs/winecfg/time.c
new file mode 100644
index 0000000..b4e9d4c
--- /dev/null
+++ b/programs/winecfg/time.c
@@ -0,0 +1,279 @@
+/*
+ * Time zone configuration
+ *
+ * Copyright (c) 2007 Dmitry Timoshkov
+ *
+ * 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 "config.h"
+#include "wine/port.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winecfg.h"
+#include "resource.h"
+
+#include <wine/debug.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
+
+static const WCHAR szStandardNameW[] = {'S','t','a','n','d','a','r','d','N','a','m','e',0};
+static const WCHAR szDaylightNameW[] = {'D','a','y','l','i','g','h','t','N','a','m','e',0};
+
+static BOOL init_tz_data(HWND hDlg)
+{
+    HKEY hKey;
+    char buf[128];
+    DWORD idx, len;
+
+    SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_RESETCONTENT, 0, 0);
+
+    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                     "Software\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
+                     0, KEY_READ, &hKey) != ERROR_SUCCESS)
+    {
+        WINE_WARN("Unable to open the time zones key\n");
+        return FALSE;
+    }
+
+    idx = 0;
+    len = sizeof(buf);
+    while (RegEnumKeyEx(hKey, idx++, buf, &len, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
+    {
+        static const WCHAR stdW[] = { 'S','t','d',0 };
+        static const WCHAR dltW[] = { 'D','l','t',0 };
+        static const WCHAR tziW[] = { 'T','Z','I',0 };
+        DWORD n;
+        TIME_ZONE_INFORMATION *tzi;
+        HKEY hSubkey;
+        struct tz_reg_data
+        {
+            LONG bias;
+            LONG std_bias;
+            LONG dlt_bias;
+            SYSTEMTIME std_date;
+            SYSTEMTIME dlt_date;
+        } data;
+
+        if (RegOpenKeyEx(hKey, buf, 0, KEY_READ, &hSubkey) != ERROR_SUCCESS)
+        {
+            WINE_WARN("Unable to open subkey %s\n", buf);
+            continue;
+        }
+
+        tzi = HeapAlloc(GetProcessHeap(), 0, sizeof(*tzi));
+
+        len = sizeof(tzi->StandardName);
+        RegQueryValueExW(hSubkey, stdW, NULL, NULL, (LPBYTE)tzi->StandardName, &len);
+        len = sizeof(tzi->DaylightName);
+        RegQueryValueExW(hSubkey, dltW, NULL, NULL, (LPBYTE)tzi->DaylightName, &len);
+        len = sizeof(data);
+        RegQueryValueExW(hSubkey, tziW, NULL, NULL, (LPBYTE)&data, &len);
+        if (len != sizeof(data))
+            WINE_WARN("got strange data len %u\n", len);
+
+        tzi->Bias = data.bias;
+        tzi->StandardBias = data.std_bias;
+        tzi->DaylightBias = data.dlt_bias;
+        tzi->StandardDate = data.std_date;
+        tzi->DaylightDate = data.dlt_date;
+
+        /* FIXME: TZ registry data in Wine doesn't have (GMT+xx) prefix */
+        if (tzi->Bias <= 0)
+            sprintf(buf, "(GMT+%02d:%02d) ", -tzi->Bias / 60, abs(tzi->Bias) % 60);
+        else
+            sprintf(buf, "(GMT-%02d:%02d) ", tzi->Bias / 60, tzi->Bias % 60);
+
+        len = sizeof(buf) - strlen(buf);
+        RegQueryValueExA(hSubkey, "Display", NULL, NULL, (LPBYTE)buf + strlen(buf), &len);
+
+        WINE_TRACE("%s, bias %d, std: %s,%d,%u/%02u/%04u, dlt: %s,%d,%u/%02u/%04u\n",
+            buf, tzi->Bias,
+            wine_dbgstr_w(tzi->StandardName), tzi->StandardBias,
+            tzi->StandardDate.wDay, tzi->StandardDate.wMonth, tzi->StandardDate.wYear,
+            wine_dbgstr_w(tzi->DaylightName), tzi->DaylightBias,
+            tzi->DaylightDate.wDay, tzi->DaylightDate.wMonth, tzi->DaylightDate.wYear);
+
+        n = SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_ADDSTRING, 0, (LPARAM)buf);
+        SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_SETITEMDATA, n, (LPARAM)tzi);
+
+        RegCloseKey(hSubkey);
+
+        /* reset len */
+        len = sizeof(buf);
+    }
+    RegCloseKey(hKey);
+
+    return TRUE;
+}
+
+static void free_tz_data(HWND hDlg)
+{
+    DWORD idx = 0;
+
+    while (1)
+    {
+        void *data;
+
+        data = (void *)SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_GETITEMDATA, idx++, 0);
+
+        if ((LONG_PTR)data == CB_ERR) break;
+
+        HeapFree(GetProcessHeap(), 0, data);
+    }
+}
+
+static BOOL save_tz_data(HWND hDlg)
+{
+    TIME_ZONE_INFORMATION *tzi;
+    int idx;
+    HKEY hKey;
+
+    idx = SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_GETCURSEL, 0, 0);
+    if (idx == CB_ERR) return FALSE;
+
+    tzi = (TIME_ZONE_INFORMATION *)SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_GETITEMDATA, idx, 0);
+    if ((LONG_PTR)tzi == CB_ERR) return FALSE;
+
+    WINE_TRACE("Saving bias %d, std: %s,%d,%u/%02u/%04u, dlt: %s,%d,%u/%02u/%04u\n",
+        tzi->Bias,
+        wine_dbgstr_w(tzi->StandardName), tzi->StandardBias,
+        tzi->StandardDate.wDay, tzi->StandardDate.wMonth, tzi->StandardDate.wYear,
+        wine_dbgstr_w(tzi->DaylightName), tzi->DaylightBias,
+        tzi->DaylightDate.wDay, tzi->DaylightDate.wMonth, tzi->DaylightDate.wYear);
+
+    if (RegCreateKey(HKEY_LOCAL_MACHINE,
+                     "System\\CurrentControlSet\\Control\\TimezoneInformation",
+                     &hKey) != ERROR_SUCCESS)
+    {
+        WINE_WARN("Unable to create the time zone information key\n");
+        return FALSE;
+    }
+
+    RegSetValueEx(hKey, "Bias", 0, REG_DWORD, (LPBYTE)&tzi->Bias, sizeof(DWORD));
+
+    RegSetValueExW(hKey, szStandardNameW, 0, REG_SZ, (LPBYTE)tzi->StandardName,
+                   (lstrlenW(tzi->StandardName) + 1) * sizeof(WCHAR));
+    RegSetValueEx(hKey, "StandardBias", 0, REG_DWORD, (LPBYTE)&tzi->StandardBias, sizeof(DWORD));
+    RegSetValueEx(hKey, "StandardStart", 0, REG_BINARY, (LPBYTE)&tzi->StandardDate, sizeof(tzi->StandardDate));
+
+    RegSetValueExW(hKey, szDaylightNameW, 0, REG_SZ, (LPBYTE)tzi->DaylightName,
+                   (lstrlenW(tzi->DaylightName) + 1) * sizeof(WCHAR));
+    RegSetValueEx(hKey, "DaylightBias", 0, REG_DWORD, (LPBYTE)&tzi->DaylightBias, sizeof(DWORD));
+    RegSetValueEx(hKey, "DaylightStart", 0, REG_BINARY, (LPBYTE)&tzi->DaylightDate, sizeof(tzi->StandardDate));
+
+    RegCloseKey(hKey);
+
+    return TRUE;
+}
+
+static void select_current_tz(HWND hDlg)
+{
+    DWORD len, idx;
+    HKEY hKey;
+    TIME_ZONE_INFORMATION tzi;
+
+    SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_SETCURSEL, 0, 0);
+
+    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                     "System\\CurrentControlSet\\Control\\TimezoneInformation",
+                     0, KEY_READ, &hKey) != ERROR_SUCCESS)
+    {
+        WINE_WARN("There is no stored time zone information\n");
+        return;
+    }
+
+    len = tzi.Bias;
+    RegQueryValueEx(hKey, "Bias", NULL, NULL, (LPBYTE)&tzi.Bias, &len);
+    len = tzi.StandardBias;
+    RegQueryValueEx(hKey, "StandardBias", NULL, NULL, (LPBYTE)&tzi.StandardBias, &len);
+    len = tzi.DaylightBias;
+    RegQueryValueEx(hKey, "DaylightBias", NULL, NULL, (LPBYTE)&tzi.DaylightBias, &len);
+
+    len = sizeof(tzi.StandardName);
+    RegQueryValueExW(hKey, szStandardNameW, NULL, NULL, (LPBYTE)&tzi.StandardName, &len);
+    len = sizeof(tzi.DaylightName);
+    RegQueryValueExW(hKey, szDaylightNameW, NULL, NULL, (LPBYTE)&tzi.DaylightName, &len);
+
+    RegCloseKey(hKey);
+
+    idx = 0;
+
+    while (1)
+    {
+        TIME_ZONE_INFORMATION *data;
+
+        data = (void *)SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_GETITEMDATA, idx, 0);
+
+        if ((LONG_PTR)data == CB_ERR) break;
+
+        if (tzi.Bias == data->Bias &&
+            tzi.StandardBias == data->StandardBias &&
+            tzi.DaylightBias == data->DaylightBias &&
+            !lstrcmpW(tzi.StandardName, data->StandardName) &&
+            !lstrcmpW(tzi.DaylightName, data->DaylightName))
+        {
+            SendDlgItemMessage(hDlg, IDC_TIME_TZCOMBO, CB_SETCURSEL, idx, 0);
+            break;
+        }
+
+        idx++;
+    }
+}
+
+INT_PTR CALLBACK TimeZoneDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    switch (uMsg)
+    {
+    case WM_INITDIALOG:
+        init_tz_data(hDlg);
+        select_current_tz(hDlg);
+        return TRUE;
+
+    case WM_DESTROY:
+        free_tz_data(hDlg);
+        return TRUE;
+
+    case WM_COMMAND:
+        switch (wParam)
+        {
+        case MAKEWPARAM(IDC_TIME_TZCOMBO, CBN_SELCHANGE):
+            SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
+            break;
+        }
+        return TRUE;
+
+    case WM_NOTIFY:
+        switch (((LPNMHDR)lParam)->code)
+        {
+        case PSN_APPLY:
+            if (save_tz_data(hDlg))
+                SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
+            break;
+        }
+        return TRUE;
+    }
+
+    return FALSE;
+}
diff --git a/programs/winecfg/winecfg.h b/programs/winecfg/winecfg.h
index e23c7bb..79e2bf9 100644
--- a/programs/winecfg/winecfg.h
+++ b/programs/winecfg/winecfg.h
@@ -82,6 +82,7 @@ INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 INT_PTR CALLBACK ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK TimeZoneDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 /* Drive management  */
 void load_drives(void);
-- 
1.5.2.3






More information about the wine-patches mailing list