ReactOS 0.4.15-dev-8219-ge8b88cf
timezone.c File Reference
#include "timedate.h"
#include <tzlib.h>
Include dependency graph for timezone.c:

Go to the source code of this file.

Classes

struct  _TIMEZONE_ENTRY
 

Typedefs

typedef struct _TIMEZONE_ENTRY TIMEZONE_ENTRY
 
typedef struct _TIMEZONE_ENTRYPTIMEZONE_ENTRY
 

Functions

static PTIMEZONE_ENTRY GetLargerTimeZoneEntry (LONG Bias, LPWSTR lpDescription)
 
static LONG RetrieveTimeZone (IN HKEY hZoneKey, IN PVOID Context)
 
static VOID CreateTimeZoneList (VOID)
 
static VOID DestroyTimeZoneList (VOID)
 
static VOID ShowTimeZoneList (HWND hwnd)
 
static VOID SetLocalTimeZone (HWND hwnd)
 
INT_PTR CALLBACK TimeZonePageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static HBITMAP hBitmap = NULL
 
static int cxSource
 
static int cySource
 
PTIMEZONE_ENTRY TimeZoneListHead = NULL
 
PTIMEZONE_ENTRY TimeZoneListTail = NULL
 

Typedef Documentation

◆ PTIMEZONE_ENTRY

◆ TIMEZONE_ENTRY

Function Documentation

◆ CreateTimeZoneList()

static VOID CreateTimeZoneList ( VOID  )
static

Definition at line 139 of file timezone.c.

140{
142}
#define NULL
Definition: types.h:112
static LONG RetrieveTimeZone(IN HKEY hZoneKey, IN PVOID Context)
Definition: timezone.c:59
VOID EnumerateTimeZoneList(IN PENUM_TIMEZONE_CALLBACK Callback, IN PVOID Context OPTIONAL)
Definition: tzlib.c:223

Referenced by TimeZonePageProc().

◆ DestroyTimeZoneList()

static VOID DestroyTimeZoneList ( VOID  )
static

Definition at line 145 of file timezone.c.

146{
148
149 while (TimeZoneListHead != NULL)
150 {
152
153 TimeZoneListHead = Entry->Next;
154 if (TimeZoneListHead != NULL)
155 {
157 }
158
160 }
161
163}
PTIMEZONE_ENTRY TimeZoneListHead
Definition: timezone.c:29
PTIMEZONE_ENTRY TimeZoneListTail
Definition: timezone.c:30
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
base of all file and directory entries
Definition: entries.h:83
Definition: timezone.c:16
struct _TIMEZONE_ENTRY * Prev
Definition: timezone.c:17

Referenced by TimeZonePageProc().

◆ GetLargerTimeZoneEntry()

static PTIMEZONE_ENTRY GetLargerTimeZoneEntry ( LONG  Bias,
LPWSTR  lpDescription 
)
static

Definition at line 34 of file timezone.c.

37{
39
41 while (Entry != NULL)
42 {
43 if (Entry->TimezoneInfo.Bias < Bias)
44 return Entry;
45
46 if (Entry->TimezoneInfo.Bias == Bias)
47 {
48 if (_wcsicmp(Entry->Description, lpDescription) > 0)
49 return Entry;
50 }
51
52 Entry = Entry->Next;
53 }
54
55 return NULL;
56}
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by RetrieveTimeZone().

◆ RetrieveTimeZone()

static LONG RetrieveTimeZone ( IN HKEY  hZoneKey,
IN PVOID  Context 
)
static

Definition at line 59 of file timezone.c.

62{
63 LONG lError;
65 PTIMEZONE_ENTRY Current;
66 ULONG DescriptionSize;
67 ULONG StandardNameSize;
68 ULONG DaylightNameSize;
69
71 if (Entry == NULL)
72 {
74 }
75
76 DescriptionSize = sizeof(Entry->Description);
77 StandardNameSize = sizeof(Entry->StandardName);
78 DaylightNameSize = sizeof(Entry->DaylightName);
79
80 lError = QueryTimeZoneData(hZoneKey,
81 NULL,
82 &Entry->TimezoneInfo,
83 Entry->Description,
84 &DescriptionSize,
85 Entry->StandardName,
86 &StandardNameSize,
87 Entry->DaylightName,
88 &DaylightNameSize);
89 if (lError != ERROR_SUCCESS)
90 {
92 return lError;
93 }
94
95 if (TimeZoneListHead == NULL &&
97 {
98 Entry->Prev = NULL;
99 Entry->Next = NULL;
102 }
103 else
104 {
105 Current = GetLargerTimeZoneEntry(Entry->TimezoneInfo.Bias, Entry->Description);
106 if (Current != NULL)
107 {
108 if (Current == TimeZoneListHead)
109 {
110 /* Prepend to head */
111 Entry->Prev = NULL;
112 Entry->Next = TimeZoneListHead;
115 }
116 else
117 {
118 /* Insert before current */
119 Entry->Prev = Current->Prev;
120 Entry->Next = Current;
121 Current->Prev->Next = Entry;
122 Current->Prev = Entry;
123 }
124 }
125 else
126 {
127 /* Append to tail */
128 Entry->Prev = TimeZoneListTail;
129 Entry->Next = NULL;
132 }
133 }
134
135 return ERROR_SUCCESS;
136}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
static PTIMEZONE_ENTRY GetLargerTimeZoneEntry(LONG Bias, LPWSTR lpDescription)
Definition: timezone.c:34
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)
long LONG
Definition: pedump.c:60
struct _TIMEZONE_ENTRY * Next
Definition: timezone.c:18
uint32_t ULONG
Definition: typedefs.h:59
LONG QueryTimeZoneData(IN HKEY hZoneKey, OUT PULONG Index OPTIONAL, OUT PREG_TZI_FORMAT TimeZoneInfo, OUT PWCHAR Description OPTIONAL, IN OUT PULONG DescriptionSize OPTIONAL, OUT PWCHAR StandardName OPTIONAL, IN OUT PULONG StandardNameSize OPTIONAL, OUT PWCHAR DaylightName OPTIONAL, IN OUT PULONG DaylightNameSize OPTIONAL)
Definition: tzlib.c:141

Referenced by CreateTimeZoneList().

◆ SetLocalTimeZone()

static VOID SetLocalTimeZone ( HWND  hwnd)
static

Definition at line 226 of file timezone.c.

227{
228 TIME_ZONE_INFORMATION TimeZoneInformation;
230 DWORD dwIndex;
231 DWORD i;
232
233 dwIndex = (DWORD)SendMessageW(hwnd,
235 0,
236 0);
237
238 i = 0;
240 while (i < dwIndex)
241 {
242 if (Entry == NULL)
243 return;
244
245 i++;
246 Entry = Entry->Next;
247 }
248
249 wcscpy(TimeZoneInformation.StandardName,
250 Entry->StandardName);
251 wcscpy(TimeZoneInformation.DaylightName,
252 Entry->DaylightName);
253
254 TimeZoneInformation.Bias = Entry->TimezoneInfo.Bias;
255 TimeZoneInformation.StandardBias = Entry->TimezoneInfo.StandardBias;
256 TimeZoneInformation.DaylightBias = Entry->TimezoneInfo.DaylightBias;
257
258 memcpy(&TimeZoneInformation.StandardDate,
259 &Entry->TimezoneInfo.StandardDate,
260 sizeof(SYSTEMTIME));
261 memcpy(&TimeZoneInformation.DaylightDate,
262 &Entry->TimezoneInfo.DaylightDate,
263 sizeof(SYSTEMTIME));
264
265 /* Set time zone information */
266 SetTimeZoneInformation(&TimeZoneInformation);
267}
BOOL WINAPI SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
Definition: timezone.c:316
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DWORD
Definition: nt_native.h:44
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
SYSTEMTIME DaylightDate
Definition: winbase.h:1211
WCHAR DaylightName[32]
Definition: winbase.h:1210
WCHAR StandardName[32]
Definition: winbase.h:1207
SYSTEMTIME StandardDate
Definition: winbase.h:1208
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define CB_GETCURSEL
Definition: winuser.h:1943
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by TimeZonePageProc().

◆ ShowTimeZoneList()

static VOID ShowTimeZoneList ( HWND  hwnd)
static

Definition at line 167 of file timezone.c.

168{
169 TIME_ZONE_INFORMATION TimeZoneInfo;
171 DWORD dwCount;
172 DWORD dwIndex = 0;
173 BOOL bFound = FALSE;
174
175 if (GetTimeZoneInformation(&TimeZoneInfo) == TIME_ZONE_ID_INVALID)
176 {
177 /* Failed to retrieve current time-zone info, reset it */
178 ZeroMemory(&TimeZoneInfo, sizeof(TimeZoneInfo));
179 }
180
181 for (Entry = TimeZoneListHead; Entry != NULL; Entry = Entry->Next)
182 {
183 dwCount = SendMessageW(hwnd,
185 0,
186 (LPARAM)Entry->Description);
187 if (dwCount == CB_ERR || dwCount == CB_ERRSPACE)
188 continue;
189
190 /* If the time-zone was found in the list, skip the tests */
191 if (bFound)
192 continue;
193
194 if (*TimeZoneInfo.StandardName && *Entry->StandardName)
195 {
196 /* Compare by name */
197 if (wcscmp(Entry->StandardName, TimeZoneInfo.StandardName) == 0)
198 {
199 dwIndex = dwCount;
200 bFound = TRUE;
201 }
202 }
203 else
204 {
205 /* Compare by date and bias */
206 if ((Entry->TimezoneInfo.Bias == TimeZoneInfo.Bias) &&
207 (Entry->TimezoneInfo.StandardBias == TimeZoneInfo.StandardBias) &&
208 (Entry->TimezoneInfo.DaylightBias == TimeZoneInfo.DaylightBias) &&
209 (memcmp(&Entry->TimezoneInfo.StandardDate, &TimeZoneInfo.StandardDate, sizeof(SYSTEMTIME)) == 0) &&
210 (memcmp(&Entry->TimezoneInfo.DaylightDate, &TimeZoneInfo.DaylightDate, sizeof(SYSTEMTIME)) == 0))
211 {
212 dwIndex = dwCount;
213 bFound = TRUE;
214 }
215 }
216 }
217
220 (WPARAM)dwIndex,
221 0);
222}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
unsigned int BOOL
Definition: ntddk_ex.h:94
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ZeroMemory
Definition: winbase.h:1712
#define TIME_ZONE_ID_INVALID
Definition: winbase.h:286
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define CB_ERRSPACE
Definition: winuser.h:2436
#define CB_ERR
Definition: winuser.h:2435
#define CB_SETCURSEL
Definition: winuser.h:1961
#define CB_ADDSTRING
Definition: winuser.h:1936

Referenced by TimeZonePageProc().

◆ TimeZonePageProc()

INT_PTR CALLBACK TimeZonePageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 272 of file timezone.c.

276{
278
279 switch (uMsg)
280 {
281 case WM_INITDIALOG:
282 {
285
288
290 if (hBitmap != NULL)
291 {
292 GetObjectW(hBitmap, sizeof(bitmap), &bitmap);
293
294 cxSource = bitmap.bmWidth;
295 cySource = bitmap.bmHeight;
296 }
297 break;
298 }
299
300 case WM_DRAWITEM:
301 {
302 LPDRAWITEMSTRUCT lpDrawItem;
303 lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
304 if(lpDrawItem->CtlID == IDC_WORLD_BACKGROUND)
305 {
306 HDC hdcMem;
307 hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
308 if (hdcMem != NULL)
309 {
311 StretchBlt(lpDrawItem->hDC, lpDrawItem->rcItem.left, lpDrawItem->rcItem.top,
312 lpDrawItem->rcItem.right - lpDrawItem->rcItem.left,
313 lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top,
316 }
317 }
318 }
319 break;
320
321 case WM_COMMAND:
324 {
325 /* Enable the 'Apply' button */
326 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
327 }
328 break;
329
330 case WM_DESTROY:
333 break;
334
335 case WM_NOTIFY:
336 {
337 LPNMHDR lpnm = (LPNMHDR)lParam;
338
339 switch (lpnm->code)
340 {
341 case PSN_APPLY:
342 {
344 BM_GETCHECK, 0, 0) != BST_UNCHECKED);
347 return TRUE;
348 }
349
350 default:
351 break;
352 }
353 }
354 break;
355 }
356
357 return FALSE;
358}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HINSTANCE hApplet
Definition: access.c:17
#define IDC_WORLD_BACKGROUND
Definition: resource.h:18
#define IDC_TIMEZONELIST
Definition: resource.h:16
#define IDC_WORLD
Definition: resource.h:19
#define IDC_AUTODAYLIGHT
Definition: resource.h:17
static VOID CreateTimeZoneList(VOID)
Definition: timezone.c:139
static VOID SetLocalTimeZone(HWND hwnd)
Definition: timezone.c:226
static int cySource
Definition: timezone.c:27
static int cxSource
Definition: timezone.c:27
static HBITMAP hBitmap
Definition: timezone.c:26
static VOID DestroyTimeZoneList(VOID)
Definition: timezone.c:145
static VOID ShowTimeZoneList(HWND hwnd)
Definition: timezone.c:167
pKey DeleteObject()
static HDC
Definition: imagelist.c:92
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define PSNRET_NOERROR
Definition: prsht.h:129
#define WM_NOTIFY
Definition: richedit.h:61
Definition: bl.h:1331
Definition: uimain.c:89
UINT code
Definition: winuser.h:3159
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define SetWindowLongPtr
Definition: treelist.c:70
#define HIWORD(l)
Definition: typedefs.h:247
VOID SetAutoDaylight(IN BOOL EnableAutoDaylightTime)
Definition: tzlib.c:323
BOOL GetAutoDaylight(VOID)
Definition: tzlib.c:283
HDC hdcMem
Definition: welcome.c:104
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define IMAGE_BITMAP
Definition: winuser.h:211
#define BST_UNCHECKED
Definition: winuser.h:199
#define WM_COMMAND
Definition: winuser.h:1740
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2234
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1645
#define CBN_SELCHANGE
Definition: winuser.h:1979
#define BM_SETCHECK
Definition: winuser.h:1921
struct tagNMHDR * LPNMHDR
HWND WINAPI GetParent(_In_ HWND)
#define DWLP_MSGRESULT
Definition: winuser.h:870
#define LR_DEFAULTCOLOR
Definition: winuser.h:1087
#define BN_CLICKED
Definition: winuser.h:1925
#define WM_DESTROY
Definition: winuser.h:1609
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SendDlgItemMessage
Definition: winuser.h:5851
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1918

Referenced by Applet().

Variable Documentation

◆ cxSource

int cxSource
static

Definition at line 27 of file timezone.c.

Referenced by TimeZonePageProc().

◆ cySource

int cySource
static

Definition at line 27 of file timezone.c.

Referenced by TimeZonePageProc().

◆ hBitmap

HBITMAP hBitmap = NULL
static

Definition at line 26 of file timezone.c.

Referenced by _write_bitmap(), add_ruler_units(), AddContentTab(), ATL::CImage::Attach(), ATL::CImage::AttachInternal(), BitBltFromClipboard(), BITMAP_CopyBitmap(), BitmapFromClipboardDIB(), BitmapToClipboardDIB(), C1_DrawLabel(), cicConvertBlackBKGBitmap(), cicCreateDitherBrush(), cicCreateMaskBmp(), cicMirrorBitmap(), ClipboardReadBitmap(), ImageModel::CopyBitmap(), create_test_bitmap(), CCicLibMenuItem::CreateBitmap(), CreateCaret(), CreateDIBitmap(), CreateDIBSection(), ATL::CImage::Detach(), DoLoadImageFile(), EMFDRV_StretchBlt(), Get16BitD3DFormat(), GetClipboardDataDimensions(), GetDIBHeight(), GetDIBWidth(), GreGetBitmapDimension(), GreGetDIBitsInternal(), ImageList_AddMasked(), Imm32DrawBitmap(), DragSourceHelper::InitializeFromBitmap(), InitializeImage(), IntSetDIBits(), ImageModel::IsBlackAndWhite(), IWICImagingFactory_CreateBitmapFromHBITMAP_Proxy_W(), LoadCardBitmapsFromLibrary(), MDI_AugmentFrameMenu(), MFDRV_StretchBlt(), msi_load_picture(), NT5_DrawBaseBackground(), NT5_DrawLogoffIcon(), NtGdiGetBitmapBits(), NtGdiGetBitmapDimension(), NtGdiSetBitmapBits(), NtGdiSetBitmapDimension(), NtGdiStretchDIBitsInternal(), NtUserCreateCaret(), OnDestroy(), OnPaint(), CAppScrnshotPreview::PaintOnDC(), Preview_CreateToolBar(), ImageModel::PushBlackAndWhite(), SaveDIBToFile(), serializeBMP(), CardWindow::SetBackImage(), CUIFBitmapDC::SetBitmap(), CMenuDeskBar::SetBitmap(), SetBitmapAndInfo(), SetDIBits(), START_TEST(), STATIC_PaintBitmapfn(), STATIC_SetBitmap(), STATIC_WindowProc(), StaticWndProc_common(), T1_DrawLabels(), Test_Bitmap(), Test_BitmapEntry(), Test_CompatBitmapEntry(), test_data_cache_cache(), Test_Dibsection(), Test_DIBSectionEntry(), test_emf_BitBlt(), test_marshal_HBITMAP(), Test_PatBlt_Params(), TimeZonePageProc(), TOOLBAR_ReplaceBitmap(), and TrayIcon_GetProcessorUsageIcon().

◆ TimeZoneListHead

◆ TimeZoneListTail

PTIMEZONE_ENTRY TimeZoneListTail = NULL

Definition at line 30 of file timezone.c.

Referenced by DestroyTimeZoneList(), and RetrieveTimeZone().