FreeCalypso > hg > fc-magnetite
comparison src/aci2/bmi/MmiTimeDate.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /******************************************************************************* | |
2 | |
3 CONDAT (UK) | |
4 | |
5 ******************************************************************************** | |
6 | |
7 This software product is the property of Condat (UK) Ltd and may not be | |
8 disclosed to any third party without the express permission of the owner. | |
9 | |
10 ******************************************************************************** | |
11 | |
12 $Project name: Basic MMI | |
13 $Project code: BMI (6349) | |
14 $Module: MMI | |
15 $File: MmiTimeDate.c | |
16 $Revision: 1.0 | |
17 | |
18 $Author: Condat(UK) | |
19 $Date: 22/02/01 | |
20 | |
21 ******************************************************************************** | |
22 | |
23 Description: | |
24 | |
25 | |
26 | |
27 ******************************************************************************** | |
28 | |
29 $History: MmiMain.c | |
30 | |
31 Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh | |
32 Description: Mp3 Ringer Implementation | |
33 Solution: The Midi Ringer application has been enhanced to support mp3 as ringer. | |
34 The interface function names have been modified. | |
35 | |
36 Apr 05, 2005 REF: ENH 29994 xdeepadh | |
37 Description: Implementation of Generic Midi Ringer and Modification of existing Midi Test Application | |
38 Solution: Generic Midi Ringer and Midi Test Application were implemented. | |
39 | |
40 Jan 06,2004 REF: CRR 27859 xkundadu | |
41 Description: Clock: Alarm does not go off even if timer times out. | |
42 Solution: If the mfw_td_set_alarm() function fails, display the | |
43 'Write Failed" message. | |
44 | |
45 Oct 14, 2004 REF: CRR 25756 xnkulkar | |
46 Description: Alarm setting not allowed | |
47 Solution: We are checking the time format (12/24 Hour) and accordingly setting the | |
48 format flag. Also the conversion of time from 24 to 12 or 12 to 24 hour format is done | |
49 before displaying it on the alarm editor screen. | |
50 | |
51 25/10/00 Original Condat(UK) BMI version. | |
52 | |
53 $End | |
54 | |
55 *******************************************************************************/ | |
56 | |
57 | |
58 #define ENTITY_MFW | |
59 | |
60 /* includes */ | |
61 #include <string.h> | |
62 #include <stdio.h> | |
63 #include <stdlib.h> | |
64 | |
65 #if defined (NEW_FRAME) | |
66 | |
67 #include "typedefs.h" | |
68 #include "vsi.h" | |
69 #include "pei.h" | |
70 #include "custom.h" | |
71 #include "gsm.h" | |
72 | |
73 #else | |
74 | |
75 #include "STDDEFS.H" | |
76 #include "custom.h" | |
77 #include "gsm.h" | |
78 #include "vsi.h" | |
79 | |
80 #endif | |
81 #include "mfw_sys.h" | |
82 #include "prim.h" | |
83 | |
84 | |
85 #include "mfw_mfw.h" | |
86 #include "mfw_win.h" | |
87 | |
88 #include "mfw_kbd.h" | |
89 /* SPR#1428 - SH - New Editor changes */ | |
90 #ifndef NEW_EDITOR | |
91 #include "mfw_edt.h" | |
92 #endif | |
93 #include "mfw_lng.h" | |
94 #include "mfw_tim.h" | |
95 #include "mfw_icn.h" | |
96 #include "mfw_mnu.h" | |
97 #include "mfw_phb.h" | |
98 #include "mfw_cm.h" | |
99 #include "mfw_sim.h" | |
100 #include "mfw_nm.h" | |
101 #include "mfw_sat.h" | |
102 #include "mfw_phb.h" | |
103 #include "ksd.h" | |
104 #include "psa.h" | |
105 #include "mfw_sms.h" | |
106 #include "mfw_sat.h" | |
107 #include "Mfw_td.h"/*SPR 2639*/ | |
108 | |
109 #include "dspl.h" | |
110 | |
111 #include "gdi.h" //ES!! | |
112 | |
113 #include "MmiMmi.h" | |
114 #include "MmiDummy.h" | |
115 #include "MmiDialogs.h" | |
116 #include "MmiLists.h" | |
117 | |
118 #include "MmiSoftKeys.h" | |
119 #include "Mmiicons.h" | |
120 #include "MmiMenu.h" | |
121 #include "MmiMain.h" | |
122 #include "MmiIdle.h" | |
123 #include "MmiStart.h" | |
124 #include "MmiPins.h" | |
125 #include "MmiTimeDate.h" | |
126 #include "MmiSounds.h" | |
127 /* SPR#1428 - SH - New Editor changes */ | |
128 #ifdef NEW_EDITOR | |
129 #include "ATBCommon.h" | |
130 #include "ATBDisplay.h" | |
131 #include "ATBEditor.h" | |
132 #include "AUIEditor.h" | |
133 #else | |
134 #include "MmiEditor.h" | |
135 #endif | |
136 | |
137 #include "audio.h" | |
138 #include "cus_aci.h" | |
139 #include "mmiColours.h" | |
140 | |
141 // Apr 05, 2005 REF: ENH 29994 xdeepadh | |
142 #ifdef FF_MIDI_RINGER | |
143 #include "mmiCall.h" | |
144 #include "mfw_midi.h" | |
145 extern T_call call_data; | |
146 #endif | |
147 void alarm_screen(void); // RAVI | |
148 int time_date_cb(T_MFW_EVENT event,void* para);/*SPR 2639 handles events from MFW*/ | |
149 | |
150 T_MFW_DATE alarmDate;/*SPR 2639 we need a global to store the alarm date */ | |
151 //#ifdef NEW_EDITOR | |
152 T_MFW_TIME alarmTime; /*SPR 2639*/ | |
153 //#endif | |
154 | |
155 /* SPR#1428 - SH - New Editor changes. | |
156 * Time and date module pretty much rewritten to use new formatted input of editor. | |
157 */ | |
158 | |
159 #ifdef NEW_EDITOR | |
160 | |
161 /* LOCAL FUNCTION PROTOTYPES */ | |
162 T_MFW_HND tida_create(T_MFW_HND parent_win); | |
163 static int tida_win_cb (T_MFW_EVENT event, T_MFW_WIN * win); | |
164 static void tida_exec_cb(T_MFW_HND win, USHORT event, SHORT value, void * parameter); | |
165 T_MFW_HND tida_edit_create(T_MFW_HND parent, USHORT Identifier, USHORT TitleId, char *buffer, char *formatString); | |
166 void tida_edit_cb(T_MFW_HND win, USHORT Identifier, SHORT value); | |
167 void tida_show_dlg(T_MFW_HND win, USHORT textId1, USHORT textId2); | |
168 UBYTE tida_check_date(char *datestring); | |
169 UBYTE tida_check_time(char *timestring); | |
170 | |
171 #define MAX_DIG_TIDA 20 /* Max size of buffer, arbitrary value */ | |
172 | |
173 /* TIME/DATE main structure */ | |
174 | |
175 typedef struct | |
176 { | |
177 T_MMI_CONTROL mmi_control; | |
178 T_MFW_HND parent_win; | |
179 T_MFW_HND win; /* The main time/date window */ | |
180 T_MFW_HND edit_win; /* The editor window */ | |
181 char buffer[MAX_DIG_TIDA]; /* Buffer to store currently edited time/date */ | |
182 } T_tida; | |
183 | |
184 #else /* NEW_EDITOR */ | |
185 | |
186 /* OLD VERSION */ | |
187 | |
188 static int tida_edt_kbd_long_cb (MfwEvt e, MfwKbd *kc); | |
189 static void tida_edt_tim_out_cb(T_MFW_EVENT event,T_MFW_TIM * t); | |
190 static int check_time (T_MFW_HND win, void * edt_dat); | |
191 static int check_date (T_MFW_HND win, void * edt_dat); | |
192 static int tida_edt_kbd_cb (MfwEvt e, MfwKbd *kc); | |
193 static void tida_editor(T_MFW_HND win, USHORT event, SHORT value, void * parameter); | |
194 static int tida_edt_win_cb (T_MFW_EVENT event,T_MFW_WIN * win); | |
195 static int tida_win_cb (T_MFW_EVENT event, T_MFW_WIN * win); | |
196 static void tida_main(T_MFW_HND win, USHORT event, SHORT value, void * parameter); | |
197 static void reset_edt_attr_sett(int editZone, U32 colIndex, U8 font,U8 mode, | |
198 U8 *controls, char *text,U16 size,MfwEdtAttr* attr); | |
199 | |
200 static MfwHnd win; /* our window */ | |
201 static DisplayData DisplayInfo; | |
202 | |
203 #define MAX_DIG_TIDA 20 /* size of buffer (??) */ | |
204 #define MAX_LEN_DATE 11 /* maximum number of digits date*/ | |
205 #define MAX_LEN_TIME 6 /* maximum number of digits time*/ | |
206 #define DATE_TEXT_X 0 | |
207 #define DATE_TEXT_Y 0 | |
208 | |
209 typedef enum | |
210 { | |
211 ALARM, | |
212 SETTING | |
213 } timeDateMode; | |
214 | |
215 typedef struct | |
216 { | |
217 T_MMI_CONTROL mmi_control; | |
218 T_MFW_HND parent_win; | |
219 T_MFW_HND tida_win; | |
220 USHORT display_id1; | |
221 USHORT display_id2; | |
222 DAT_TIME_CASE state; /* setting state */ | |
223 } T_tida; | |
224 | |
225 typedef struct | |
226 { | |
227 T_MMI_CONTROL mmi_control; | |
228 T_MFW_HND parent_win; | |
229 T_MFW_HND tida_edt_win; | |
230 T_MFW_HND kbd_handle; | |
231 T_MFW_HND kbd_long_handle; | |
232 T_MFW_HND editor_handle; | |
233 T_MFW_HND tim_out_handle; | |
234 DAT_TIME_CASE state; /* setting state */ | |
235 char edtbuf1[MAX_DIG_TIDA]; | |
236 MfwEdtAttr edit1Attr; | |
237 UBYTE index; | |
238 }T_tida_edt; | |
239 | |
240 | |
241 | |
242 /* | |
243 * Settings menu subs: | |
244 */ | |
245 | |
246 #define TIMERCLEAR 2500 | |
247 | |
248 //Flag to indicate whether we're setting the current or alarm date/time. | |
249 static UBYTE DateTimeEntryMode; | |
250 | |
251 extern UBYTE getcurrentAlarmTone(void); //mmisounds | |
252 #endif /* NEW_EDITOR */ | |
253 | |
254 T_MFW_HND td_handle; | |
255 /* FUNCTIONS BELOW ARE COMMON TO OLD AND NEW VERSION */ | |
256 | |
257 /*SPR 2639 removed function alarm_check()*/ | |
258 | |
259 | |
260 /******************************************************************************* | |
261 | |
262 $Function: time_date_init | |
263 | |
264 $Description: initialises time and date | |
265 | |
266 $Returns: none. | |
267 | |
268 $Arguments: none | |
269 | |
270 *******************************************************************************/ | |
271 void time_date_init() | |
272 { mfw_td_init(); | |
273 | |
274 td_handle = mfw_td_create(NULL, MFW_TD_ALARM, time_date_cb); | |
275 } | |
276 /******************************************************************************* | |
277 | |
278 $Function: time_date_init | |
279 | |
280 $Description: deletes mfw td | |
281 | |
282 $Returns: none. | |
283 | |
284 $Arguments: none | |
285 | |
286 *******************************************************************************/ | |
287 void time_date_delete() | |
288 { | |
289 mfw_td_delete(td_handle); | |
290 mfw_td_exit(); | |
291 } | |
292 /******************************************************************************* | |
293 | |
294 $Function: time_date_cb | |
295 | |
296 $Description: handles alarm event from MFW | |
297 | |
298 $Returns: none. | |
299 | |
300 $Arguments: none | |
301 | |
302 *******************************************************************************/ | |
303 int time_date_cb(T_MFW_EVENT event,void* para) | |
304 { TRACE_EVENT_P1("time_date_cb():%d",event); | |
305 alarm_screen(); | |
306 | |
307 return 1; // RAVI. | |
308 } | |
309 | |
310 | |
311 /******************************************************************************* | |
312 | |
313 $Function: alarm_screen_cb added for SPR 2184 | |
314 | |
315 $Description: Handles alarm screen keypresses | |
316 | |
317 $Returns: none. | |
318 | |
319 $Arguments: window handle, identifier, reason(key pressed) | |
320 | |
321 *******************************************************************************/ | |
322 void alarm_screen_cb(T_MFW_HND win, USHORT identifier, UBYTE reason) | |
323 { UBYTE currentAlarm; | |
324 | |
325 // Apr 05, 2005 REF: ENH 29994 xdeepadh | |
326 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh | |
327 /*get current alarm id*/ | |
328 /*stop alarm*/ | |
329 #ifdef FF_MIDI_RINGER | |
330 mfw_ringer_stop(sounds_midi_ringer_stop_cb); | |
331 #else | |
332 currentAlarm=getcurrentAlarmTone(); | |
333 #ifdef FF_MMI_RINGTONE /*MSL Stop */ | |
334 audio_StopSoundbyID( AUDIO_BUZZER, ALARMTONE_SELECT); | |
335 #else | |
336 audio_StopSoundbyID(AUDIO_BUZZER, currentAlarm); | |
337 #endif | |
338 #endif | |
339 | |
340 } | |
341 | |
342 | |
343 /******************************************************************************* | |
344 | |
345 $Function: alarm_screen | |
346 | |
347 $Description: displays alarm screen | |
348 | |
349 $Returns: none. | |
350 | |
351 $Arguments: none | |
352 | |
353 *******************************************************************************/ | |
354 void alarm_screen(void) | |
355 { | |
356 T_MFW_HND idle_win = idle_get_window(); | |
357 T_DISPLAY_DATA display_info; | |
358 T_MFW_TIME* time; | |
359 static char text[25]; | |
360 UBYTE currentAlarm;/*SPR 2184*/ | |
361 | |
362 | |
363 TRACE_EVENT("alarm_screen"); | |
364 | |
365 /*SPR 2639, convert function to use new MFW functions*/ | |
366 time = mfw_td_get_time(); | |
367 | |
368 sprintf(text, "%02d:%02d", time->hour, time->minute); | |
369 // Apr 05, 2005 REF: ENH 29994 xdeepadh | |
370 /*SPR 2639 get current alarm id and play it*/ | |
371 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh | |
372 //If Alarm is recieved , while in call screen,dont play the tone. | |
373 #ifdef FF_MIDI_RINGER | |
374 if((!(call_data.calls.numCalls))) | |
375 { | |
376 mfw_ringer_start(AS_RINGER_MODE_ALARM,FALSE,sounds_midi_ringer_start_cb); | |
377 } | |
378 #else | |
379 currentAlarm=getcurrentAlarmTone(); | |
380 #ifdef FF_MMI_RINGTONE /* MSL Alarm Tone */ | |
381 audio_PlaySoundID( AUDIO_BUZZER, ALARMTONE_SELECT, 0 , AUDIO_PLAY_INFINITE); | |
382 #else | |
383 audio_PlaySoundID( AUDIO_BUZZER, currentAlarm, 0 , AUDIO_PLAY_INFINITE); | |
384 #endif | |
385 #endif | |
386 /*SPR 2639 end*/ | |
387 | |
388 | |
389 dlg_initDisplayData_TextId( &display_info, TxtSoftOK, TxtNull, TxtAlarm, TxtNull , COLOUR_STATUS); | |
390 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)alarm_screen_cb, FOREVER, KEY_CLEAR|KEY_LEFT|KEY_RIGHT ); | |
391 display_info.TextString2 = text; | |
392 | |
393 | |
394 /* Call Info Screen | |
395 */ | |
396 info_dialog( idle_win, &display_info ); | |
397 | |
398 } | |
399 | |
400 | |
401 | |
402 | |
403 /******************************************************************************* | |
404 | |
405 $Function: clear_alarm | |
406 | |
407 $Description: handles menu option to cancel any existing alarm setting | |
408 | |
409 $Returns: status int | |
410 | |
411 $Arguments: menu and item (not used) | |
412 | |
413 *******************************************************************************/ | |
414 int clear_alarm(MfwMnu* m, MfwMnuItem* i) | |
415 { T_MFW_HND win = mfwParent( mfw_header() ); | |
416 T_DISPLAY_DATA display_info; | |
417 | |
418 | |
419 /*SPR 2639, changed to use new MFW functions*/ | |
420 mfw_td_cancel_alarm(); | |
421 | |
422 dlg_initDisplayData_TextId( &display_info, TxtSoftOK, TxtNull, TxtAlarm, TxtCancelled , COLOUR_STATUS); | |
423 dlg_initDisplayData_events( &display_info, NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT ); | |
424 | |
425 /* Call Info Screen | |
426 */ | |
427 info_dialog( win, &display_info ); | |
428 | |
429 | |
430 return MFW_EVENT_CONSUMED; | |
431 | |
432 } | |
433 | |
434 | |
435 /******************************************************************************* | |
436 | |
437 $Function: twelve_hour_clock | |
438 | |
439 $Description: handles selection of twleve hour clock in menu | |
440 | |
441 $Returns: status int | |
442 | |
443 $Arguments: menu and item (not used) | |
444 | |
445 *******************************************************************************/ | |
446 int twelve_hour_clock(MfwMnu* m, MfwMnuItem* i) | |
447 { T_MFW_HND win = mfwParent( mfw_header() ); | |
448 T_DISPLAY_DATA display_info; | |
449 // char text[25]; // RAVI | |
450 | |
451 setClockFormat(MFW_TIME_FORMAT_12HOUR);/*SPR 2639*/ | |
452 | |
453 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtClockSetTo, TxtTwelveHour, COLOUR_STATUS); | |
454 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT ); | |
455 | |
456 /* Call Info Screen | |
457 */ | |
458 | |
459 info_dialog( win, &display_info ); | |
460 return MFW_EVENT_CONSUMED; | |
461 | |
462 } | |
463 /******************************************************************************* | |
464 | |
465 $Function: twentyfour_hour_clock | |
466 | |
467 $Description: handles selection of twleve hour clock in menu | |
468 | |
469 $Returns: status int | |
470 | |
471 $Arguments: menu and item (not used) | |
472 *******************************************************************************/ | |
473 int twentyfour_hour_clock(MfwMnu* m, MfwMnuItem* i) | |
474 { T_MFW_HND win = mfwParent( mfw_header() ); | |
475 T_DISPLAY_DATA display_info; | |
476 // char text[25]; // RAVI | |
477 | |
478 setClockFormat(MFW_TIME_FORMAT_24HOUR);/*SPR 2639*/ | |
479 | |
480 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtClockSetTo, TxtTwentyfourHour, COLOUR_STATUS); | |
481 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT ); | |
482 | |
483 /* Call Info Screen | |
484 */ | |
485 | |
486 info_dialog( win, &display_info ); | |
487 return MFW_EVENT_CONSUMED; | |
488 | |
489 } | |
490 | |
491 | |
492 /******************************************************************************* | |
493 | |
494 $Function: alarmTimeDate | |
495 | |
496 $Description: Called when user selects alarm in menu. Begins editor to enter | |
497 desired alarm time and date. | |
498 | |
499 $Returns: status int | |
500 | |
501 $Arguments: menu and item (not used) | |
502 | |
503 *******************************************************************************/ | |
504 int alarmTimeDate(MfwMnu* m, MfwMnuItem* i) | |
505 { | |
506 /* SPR#1428 - SH - New Editor changes */ | |
507 #ifdef NEW_EDITOR | |
508 T_MFW_HND idle_win = idle_get_window(); | |
509 T_MFW_HND win = tida_create(idle_win); /* Parent_window is idle */ | |
510 | |
511 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
512 T_tida *data = (T_tida *)win_data->user; | |
513 | |
514 TRACE_FUNCTION ("MmiTimeDate:alarmTimeDate()"); | |
515 | |
516 if(data->win) | |
517 { | |
518 SEND_EVENT(data->win, TIDA_ALARMDATE,0,0); | |
519 | |
520 } | |
521 #else /* NEW_EDITOR */ | |
522 T_MFW_HND idle_win = idle_get_window(); | |
523 T_MFW_HND win = date_time_create(idle_win);// parent_window is idle | |
524 | |
525 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
526 T_tida * tida_data = (T_tida *)win_data->user; | |
527 | |
528 TRACE_FUNCTION ("MmiTimeDate:alarmTimeDate()"); | |
529 mfw_td_get_alarm(&alarmTime, &alarmDate); | |
530 tida_data->state = DATE_ENTRY; | |
531 DateTimeEntryMode = ALARM; | |
532 | |
533 if(tida_data->tida_win) | |
534 { | |
535 SEND_EVENT(tida_data->tida_win,DATE_ENTRY,0,tida_data); | |
536 | |
537 } | |
538 #endif /* NEW_EDITOR */ | |
539 return 1; | |
540 } | |
541 | |
542 /******************************************************************************* | |
543 | |
544 $Function: settingsTimeDate | |
545 | |
546 $Description: settings date and time menu function | |
547 | |
548 $Returns: none. | |
549 | |
550 $Arguments: | |
551 | |
552 *******************************************************************************/ | |
553 int settingsTimeDate(MfwMnu* m, MfwMnuItem* i) | |
554 { | |
555 /* SPR#1428 - SH - New Editor changes */ | |
556 #ifdef NEW_EDITOR | |
557 T_MFW_HND idle_win = idle_get_window(); | |
558 T_MFW_HND win = tida_create(idle_win); /* Parent_window is idle */ | |
559 | |
560 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
561 T_tida *data = (T_tida *)win_data->user; | |
562 | |
563 TRACE_FUNCTION ("MmiTimeDate:settingsTimeDate()"); | |
564 | |
565 if(data->win) | |
566 { | |
567 SEND_EVENT(data->win, TIDA_DATE,0,0); | |
568 | |
569 } | |
570 #else /* NEW_EDITOR */ | |
571 T_MFW_HND idle_win = idle_get_window(); | |
572 T_MFW_HND win = date_time_create(idle_win);// parent_window is idle | |
573 | |
574 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
575 T_tida * tida_data = (T_tida *)win_data->user; | |
576 | |
577 TRACE_FUNCTION ("MmiTimeDate:settingsTimeDate()"); | |
578 | |
579 tida_data->state = DATE_ENTRY; | |
580 DateTimeEntryMode = SETTING; | |
581 | |
582 if(tida_data->tida_win) | |
583 { | |
584 SEND_EVENT(tida_data->tida_win,DATE_ENTRY,0,tida_data); | |
585 | |
586 } | |
587 #endif /* NEW_EDITOR */ | |
588 | |
589 return 1; | |
590 } | |
591 | |
592 | |
593 /* SPR#1428 - SH - New Editor changes | |
594 * New time/date code below. Uses tida_exec_cb as main "object". */ | |
595 | |
596 #ifdef NEW_EDITOR | |
597 | |
598 /******************************************************************************* | |
599 | |
600 $Function: tida_create | |
601 | |
602 $Description: Create the main time/date window | |
603 | |
604 $Returns: The window handle | |
605 | |
606 $Arguments: parent_win - The parent window | |
607 | |
608 *******************************************************************************/ | |
609 | |
610 T_MFW_HND tida_create(T_MFW_HND parent_win) | |
611 { | |
612 T_MFW_WIN * win_data; | |
613 | |
614 T_tida * data = (T_tida *)ALLOC_MEMORY (sizeof (T_tida)); | |
615 data->win = win_create (parent_win, 0, MfwWinVisible, (T_MFW_CB)tida_win_cb); | |
616 | |
617 TRACE_FUNCTION("MmiTimeDate:date_time_create"); | |
618 | |
619 if (data->win EQ 0) | |
620 return 0; | |
621 | |
622 /* | |
623 * Create window handler | |
624 */ | |
625 data->mmi_control.dialog = (T_DIALOG_FUNC)tida_exec_cb;/* dialog main function */ | |
626 data->mmi_control.data = data; | |
627 data->parent_win = parent_win; | |
628 win_data = ((T_MFW_HDR *)data->win)->data; | |
629 win_data->user = (void *) data; | |
630 | |
631 | |
632 /* | |
633 * return window handle | |
634 */ | |
635 | |
636 return data->win; | |
637 } | |
638 | |
639 | |
640 /******************************************************************************* | |
641 | |
642 $Function: tida_destroy | |
643 | |
644 $Description: Destroy the main time/date window | |
645 | |
646 $Returns: None | |
647 | |
648 $Arguments: win - The main time/date window | |
649 | |
650 *******************************************************************************/ | |
651 | |
652 T_MFW_HND tida_destroy(T_MFW_HND win) | |
653 { | |
654 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
655 T_tida *data = (T_tida *)win_data->user;//tida main data | |
656 | |
657 if (win == NULL) | |
658 { | |
659 TRACE_EVENT ("Error : tida_destroy called with NULL Pointer"); | |
660 return; | |
661 } | |
662 | |
663 if (data->win) | |
664 { | |
665 win_delete(data->win); | |
666 } | |
667 | |
668 if (data) | |
669 { | |
670 FREE_MEMORY((void *)data, sizeof(T_tida)); | |
671 } | |
672 | |
673 return; | |
674 } | |
675 | |
676 | |
677 /******************************************************************************* | |
678 | |
679 $Function: tida_win_cb | |
680 | |
681 $Description: Window callback function for time and date. This is a non-displaying | |
682 window, so does nothing! | |
683 | |
684 $Returns: None. | |
685 | |
686 $Arguments: | |
687 | |
688 *******************************************************************************/ | |
689 | |
690 static int tida_win_cb (T_MFW_EVENT event, T_MFW_WIN * win) | |
691 { | |
692 TRACE_FUNCTION ("MmiTimeDate: tida_win_cb"); | |
693 | |
694 return 1; // RAVI - Return changed to Return 1. | |
695 } | |
696 | |
697 | |
698 /******************************************************************************* | |
699 | |
700 $Function: tida_exec_cb | |
701 | |
702 $Description: Main dialog function for time and date | |
703 | |
704 $Returns: None. | |
705 | |
706 $Arguments: | |
707 | |
708 *******************************************************************************/ | |
709 | |
710 static void tida_exec_cb(T_MFW_HND win, USHORT event, SHORT value, void * parameter) | |
711 { | |
712 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
713 T_tida *data = (T_tida *)win_data->user;//tida main data | |
714 | |
715 T_MFW_TIME* currclock; /*SPR 2639*/ | |
716 T_MFW_DATE* currdate; | |
717 | |
718 TRACE_FUNCTION("MmiTimeDate:tida_main"); | |
719 | |
720 | |
721 | |
722 | |
723 switch(event) | |
724 { | |
725 case TIDA_INIT: | |
726 break; | |
727 | |
728 case TIDA_DATE: | |
729 /*SPR 2639*/ | |
730 currdate = mfw_td_get_date(); | |
731 /* No date is set */ | |
732 if (currdate->day == 0) | |
733 { | |
734 sprintf(data->buffer, "dd/mm/yyyy"); | |
735 } | |
736 /* Date is already set */ | |
737 else | |
738 { | |
739 sprintf(data->buffer, "%02.02d/%02d/%04d", currdate->day, currdate->month, currdate->year); | |
740 } | |
741 | |
742 data->edit_win = tida_edit_create(win, event, TxtEnterDate, data->buffer, "NN\\/NN\\/NNNN"); | |
743 break; | |
744 | |
745 case TIDA_TIME: | |
746 currclock = mfw_td_get_time();/*SPR 2639*/ | |
747 // Issue Number : MMI-SPR-12159 on 07/04/04 by Rashmi C N and Deepa M D | |
748 // change by Sasken ( Rashmi C N and Deepa M D) on April 07th 2004 | |
749 // Bug : In 12 hour fomrat the AM and PM was not being set | |
750 // Solution : Displaying the am/pm for editing in the time edit screen. | |
751 | |
752 if(currclock->format==MFW_TIME_FORMAT_12HOUR) | |
753 { | |
754 if(currclock->PM_flag) | |
755 sprintf(data->buffer, "%02d:%02d pm", currclock->hour, currclock->minute); | |
756 else | |
757 sprintf(data->buffer, "%02d:%02d am", currclock->hour, currclock->minute); | |
758 data->edit_win = tida_edit_create(win, event, TxtEnterTime, data->buffer, "NN\\:NN\\aa"); | |
759 } | |
760 else | |
761 { | |
762 sprintf(data->buffer, "%02d:%02d", mfw_td_convert_to_24_hour(currclock), currclock->minute); | |
763 data->edit_win = tida_edit_create(win, event, TxtEnterTime, data->buffer, "NN\\:NN"); | |
764 } | |
765 break; | |
766 | |
767 case TIDA_ALARMDATE: | |
768 /*SPR 2639*/ | |
769 mfw_td_get_alarm(&alarmTime, &alarmDate); | |
770 /* No date is set */ | |
771 if (alarmDate.day == 0)/*SPR 2639*/ | |
772 { currdate = mfw_td_get_date(); | |
773 /* If date is set, insert today's date */ | |
774 if (currdate->day!=0) | |
775 { | |
776 sprintf(data->buffer, "%02d/%02d/%04d", currdate->day, currdate->month, currdate->year); | |
777 } | |
778 else | |
779 { | |
780 sprintf(data->buffer, "dd/mm/yyyy"); | |
781 } | |
782 } | |
783 /* Date is already set */ | |
784 else | |
785 {/*SPR 2639*/ | |
786 sprintf(data->buffer, "%02d/%02d/%04d", alarmDate.day, alarmDate.month, alarmDate.year); | |
787 } | |
788 | |
789 data->edit_win = tida_edit_create(win, event, TxtEnterDate, data->buffer, "NN\\/NN\\/NNNN"); | |
790 break; | |
791 | |
792 case TIDA_ALARMTIME: | |
793 /*SPR 2639*/ | |
794 //sprintf(data->buffer,"%02d:%02d",alarmTime.hour, alarmTime.minute); | |
795 //data->edit_win = tida_edit_create(win, event, TxtEnterTime, data->buffer, "NN\\:NN"); | |
796 | |
797 // xnkulkar SPR-25756: Alarm setting not allowed | |
798 // Check the time format set and accordingly convert the time before displaying on | |
799 // the editor screen. | |
800 currclock = mfw_td_get_time(); | |
801 if(alarmTime.format!= currclock->format) | |
802 { | |
803 alarmTime.format = currclock->format; | |
804 if(currclock->format == MFW_TIME_FORMAT_12HOUR) | |
805 { //converting from 24 hour alram format to 12 hour alarm format | |
806 if (alarmTime.hour < 12) | |
807 { | |
808 alarmTime.PM_flag=0; | |
809 } | |
810 else | |
811 { //if after noon | |
812 alarmTime.PM_flag=1; | |
813 alarmTime.hour = alarmTime.hour-12; | |
814 } | |
815 } | |
816 else | |
817 { //converting from 12 hour alram format to 24 hour alarm format | |
818 if (alarmTime.PM_flag == TRUE) | |
819 { // | |
820 alarmTime.hour = alarmTime.hour + 12; | |
821 } | |
822 else | |
823 { //if midnight, set the hour to 0 | |
824 if (alarmTime.hour == 12) | |
825 alarmTime.hour = 0; | |
826 } | |
827 } | |
828 } | |
829 | |
830 // xnkulkar SPR-25756: Alarm setting not allowed | |
831 // Now proceed with displaying the alarm time with am/pm in alarm time edit screen | |
832 // if the format is 12 hour. | |
833 if(alarmTime.format == MFW_TIME_FORMAT_12HOUR) | |
834 { | |
835 if(alarmTime.PM_flag) | |
836 sprintf(data->buffer, "%02d:%02d pm",alarmTime.hour, alarmTime.minute); | |
837 else | |
838 sprintf(data->buffer, "%02d:%02d am", alarmTime.hour, alarmTime.minute); | |
839 data->edit_win = tida_edit_create(win, event, TxtEnterTime, data->buffer, "NN\\:NN\\aa"); | |
840 } | |
841 else | |
842 { | |
843 sprintf(data->buffer,"%02d:%02d", mfw_td_convert_to_24_hour(&alarmTime), alarmTime.minute); | |
844 data->edit_win = tida_edit_create(win, event, TxtEnterTime, data->buffer, "NN\\:NN"); | |
845 } | |
846 break; | |
847 | |
848 case TIDA_SAVE: | |
849 tida_show_dlg(win, TxtSaved, TxtNull); | |
850 AUI_edit_Destroy(data->edit_win); | |
851 tida_destroy(data->win); | |
852 break; | |
853 // Jan 06,2004 REF: CRR 27859 xkundadu | |
854 // Description: Clock: Alarm does not go off even if timer times out. | |
855 // Solution: If the mfw_td_set_alarm() function fails, display the | |
856 // 'Write Failed" message. | |
857 | |
858 //Could not write the alarm details to FFS. | |
859 case TIDA_SAVEFAILED: | |
860 tida_show_dlg(win, TxtWrite, TxtFailed); | |
861 AUI_edit_Destroy(data->edit_win); | |
862 tida_destroy(data->win); | |
863 break; | |
864 } | |
865 | |
866 return; | |
867 } | |
868 | |
869 /******************************************************************************* | |
870 | |
871 $Function: tida_edit_create | |
872 | |
873 $Description: Creates an editor with the supplied properties | |
874 | |
875 $Returns: The editor window. | |
876 | |
877 $Arguments: parent - The parent window | |
878 Identifier - ID used in callback to identify type of editor | |
879 TitleId - The title of the editor | |
880 buffer - The text buffer | |
881 formatString - The formatting that governs the input | |
882 | |
883 *******************************************************************************/ | |
884 | |
885 T_MFW_HND tida_edit_create(T_MFW_HND parent, USHORT Identifier, USHORT TitleId, char *buffer, char *formatString) | |
886 { | |
887 T_AUI_EDITOR_DATA editor_data; | |
888 AUI_edit_SetDefault(&editor_data); | |
889 AUI_edit_SetDisplay(&editor_data, TIMEDATE_EDITOR_AREA, COLOUR_EDITOR, EDITOR_FONT); | |
890 AUI_edit_SetEvents(&editor_data, Identifier, FALSE, FOREVER, (T_AUI_EDIT_CB)tida_edit_cb); | |
891 AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtSoftBack, TitleId, NULL); | |
892 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)buffer, strlen(formatString)); | |
893 AUI_edit_SetFormatStr(&editor_data, formatString, FALSE, 0); | |
894 AUI_edit_SetMode(&editor_data, ED_MODE_FORMATTED, ED_CURSOR_UNDERLINE); | |
895 return AUI_edit_Start(parent, &editor_data); | |
896 } | |
897 | |
898 | |
899 /******************************************************************************* | |
900 | |
901 $Function: tida_edit_cb | |
902 | |
903 $Description: Callback function for editor | |
904 | |
905 $Returns: None | |
906 | |
907 $Arguments: win - The main time/date window | |
908 Identifier - ID used in callback to identify type of editor | |
909 value - What prompted the callback | |
910 | |
911 *******************************************************************************/ | |
912 | |
913 void tida_edit_cb(T_MFW_HND win, USHORT Identifier, SHORT value) | |
914 { | |
915 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
916 T_tida *data = (T_tida *)win_data->user;//tida main data | |
917 int minute, hour, day, month, year; | |
918 T_MFW_TIME_FORMAT current_format; | |
919 char pmFlag; | |
920 | |
921 T_MFW_TIME* currclock; /*SPR 2639*/ //, *tempclock; // RAVI | |
922 T_MFW_DATE* currdate; | |
923 | |
924 | |
925 | |
926 | |
927 switch(value) | |
928 { | |
929 /* Terminate editor */ | |
930 case INFO_KCD_HUP: | |
931 case INFO_KCD_RIGHT: | |
932 AUI_edit_Destroy(data->edit_win); | |
933 | |
934 /* If on the time editing screen, go back to the date editing screen. | |
935 * Otherwise exit. */ | |
936 | |
937 switch(Identifier) | |
938 { | |
939 case TIDA_TIME: | |
940 SEND_EVENT(data->win, TIDA_DATE, 0, 0); | |
941 break; | |
942 | |
943 case TIDA_ALARMTIME: | |
944 SEND_EVENT(data->win, TIDA_ALARMDATE, 0, 0); | |
945 break; | |
946 | |
947 default: | |
948 tida_destroy(win); | |
949 break; | |
950 } | |
951 break; | |
952 | |
953 /* OK */ | |
954 case INFO_KCD_LEFT: | |
955 switch(Identifier) | |
956 { | |
957 case TIDA_DATE: | |
958 if (tida_check_date(data->buffer)) | |
959 { | |
960 currdate = mfw_td_get_date(); | |
961 sscanf(data->buffer, "%d/%d/%d", &day, &month, &year); | |
962 currdate->day = day; | |
963 currdate->month = month; | |
964 currdate->year = year; | |
965 mfw_td_set_date(currdate);/*SPR 2639*/ | |
966 AUI_edit_Destroy(data->edit_win); | |
967 SEND_EVENT(data->win, TIDA_TIME, 0, 0); | |
968 } | |
969 else | |
970 { | |
971 tida_show_dlg(data->win, TxtNotAllowed, TxtNull); | |
972 } | |
973 break; | |
974 | |
975 case TIDA_TIME: | |
976 if (tida_check_time(data->buffer)) | |
977 { currclock = mfw_td_get_time();/*SPR 2639*/ | |
978 current_format = (T_MFW_TIME_FORMAT)currclock->format; | |
979 if(current_format==MFW_TIME_FORMAT_12HOUR) | |
980 sscanf(data->buffer, "%d:%d %c", &hour, &minute,&pmFlag); | |
981 else | |
982 sscanf(data->buffer, "%d:%d", &hour, &minute); | |
983 currclock->hour = hour; | |
984 currclock->minute = minute; | |
985 currclock->second = 0; | |
986 // Issue Number : MMI-SPR-12159 on 07/04/04 by Rashmi C N and Deepa M D | |
987 // change by Sasken ( Rashmi C N and Deepa M D) on April 07th 2004 | |
988 // Bug : In 12 hour fomrat the AM and PM was not being set | |
989 // Solution : Setting the PM flag of the rtc. | |
990 | |
991 if(pmFlag=='p') | |
992 { | |
993 currclock->PM_flag=1; | |
994 } | |
995 else | |
996 { | |
997 currclock->PM_flag=0; | |
998 } | |
999 | |
1000 // Issue Number : MMI-SPR-12159 on 07/04/04 by Rashmi C N and Deepa M D | |
1001 // change by Sasken ( Rashmi C N and Deepa M D) on April 07th 2004 | |
1002 // Bug : The AM PM for 12 hour fomrat was not being shown, Also there were some bugs with the 12 hour fomat | |
1003 // Solution : The following line was commented, to take the time format from the rtc instead of | |
1004 //setting it to 24 hour format | |
1005 | |
1006 //currclock->format = MFW_TIME_FORMAT_24HOUR; | |
1007 mfw_td_set_time(currclock);/*SPR 2639*/ | |
1008 mfw_td_set_time_format(current_format); | |
1009 SEND_EVENT(data->win, TIDA_SAVE, 0, 0); | |
1010 } | |
1011 else | |
1012 { | |
1013 tida_show_dlg(data->win, TxtNotAllowed, TxtNull); | |
1014 } | |
1015 break; | |
1016 | |
1017 case TIDA_ALARMDATE: | |
1018 if (tida_check_date(data->buffer)) | |
1019 { | |
1020 sscanf(data->buffer, "%d/%d/%d", &day, &month, &year); | |
1021 alarmDate.day = (UBYTE)day; | |
1022 alarmDate.month = (UBYTE) month; | |
1023 alarmDate.year = (USHORT)year; | |
1024 AUI_edit_Destroy(data->edit_win); | |
1025 SEND_EVENT(data->win, TIDA_ALARMTIME, 0, 0);/*SPR2639*/ | |
1026 | |
1027 } | |
1028 else | |
1029 { | |
1030 tida_show_dlg(data->win, TxtNotAllowed, TxtNull); | |
1031 } | |
1032 break; | |
1033 | |
1034 case TIDA_ALARMTIME: | |
1035 if (tida_check_time(data->buffer)) | |
1036 { | |
1037 // xnkulkar SPR-25756: Alarm setting not allowed | |
1038 // get the current time and format and set the time format flag acordingly | |
1039 currclock = mfw_td_get_time(); | |
1040 current_format = (T_MFW_TIME_FORMAT)currclock->format; | |
1041 if(current_format==MFW_TIME_FORMAT_12HOUR) | |
1042 sscanf(data->buffer, "%d:%d %c", &hour, &minute,&pmFlag); | |
1043 else | |
1044 sscanf(data->buffer, "%d:%d", &hour, &minute); | |
1045 | |
1046 alarmTime.hour = (UBYTE)hour; | |
1047 alarmTime.minute = (UBYTE)minute; | |
1048 alarmTime.second = 0; | |
1049 alarmTime.format = currclock->format; | |
1050 | |
1051 // xnkulkar SPR-25756: Alarm setting not allowed | |
1052 // Depending on the current time format (12/24 Hour), | |
1053 // set the PM_flag. | |
1054 if(pmFlag=='p') | |
1055 { | |
1056 alarmTime.PM_flag=1; | |
1057 } | |
1058 else | |
1059 { | |
1060 alarmTime.PM_flag=0; | |
1061 } | |
1062 // Now that we have the required info, set the alarm | |
1063 | |
1064 // Jan 06,2004 REF: CRR 27859 xkundadu | |
1065 // Description: Clock: Alarm does not go off even if timer times out. | |
1066 // Solution: If the mfw_td_set_alarm() function fails, display the | |
1067 // 'Write Failed" message. | |
1068 | |
1069 if(mfw_td_set_alarm(&alarmTime, &alarmDate) == MfwResOk) | |
1070 { | |
1071 | |
1072 TRACE_EVENT("Set Alarm success"); | |
1073 SEND_EVENT(data->win, TIDA_SAVE, 0, 0); | |
1074 } | |
1075 else | |
1076 { | |
1077 TRACE_EVENT("Set Alarm Failed"); | |
1078 SEND_EVENT(data->win, TIDA_SAVEFAILED, 0, 0); | |
1079 } | |
1080 } | |
1081 else | |
1082 { // time entered is not within the valid range | |
1083 tida_show_dlg(data->win, TxtNotAllowed, TxtNull); | |
1084 } | |
1085 break; | |
1086 } | |
1087 break; | |
1088 | |
1089 default: | |
1090 break; | |
1091 } | |
1092 | |
1093 return; | |
1094 } | |
1095 | |
1096 | |
1097 /******************************************************************************* | |
1098 | |
1099 $Function: tida_show_dlg | |
1100 | |
1101 $Description: Displays a dialog | |
1102 | |
1103 $Returns: None. | |
1104 | |
1105 $Arguments: win - The parent window | |
1106 textId - Will display "<textId> Not Allowed" | |
1107 *******************************************************************************/ | |
1108 | |
1109 void tida_show_dlg(T_MFW_HND win, USHORT textId1, USHORT textId2) | |
1110 { | |
1111 T_DISPLAY_DATA display_info; | |
1112 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, textId1, textId2, COLOUR_STATUS); | |
1113 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT ); | |
1114 | |
1115 /* Call Info Screen | |
1116 */ | |
1117 | |
1118 info_dialog( win, &display_info ); | |
1119 | |
1120 return; | |
1121 } | |
1122 | |
1123 | |
1124 /******************************************************************************* | |
1125 | |
1126 $Function: tida_check_date | |
1127 | |
1128 $Description: Checks a date to see if it's valid | |
1129 | |
1130 $Returns: TRUE if it's valid, FALSE otherwise | |
1131 | |
1132 $Arguments: datestring - The date string | |
1133 | |
1134 *******************************************************************************/ | |
1135 | |
1136 UBYTE tida_check_date(char *datestring) | |
1137 { | |
1138 int day; | |
1139 int month; | |
1140 int year; | |
1141 | |
1142 sscanf(datestring, "%d/%d/%d", &day, &month, &year); | |
1143 | |
1144 TRACE_EVENT_P1("String: %s", datestring); | |
1145 TRACE_EVENT_P3("Day: %d, Month: %d, Year: %d", day, month, year); | |
1146 | |
1147 /* Check for quick fails... */ | |
1148 | |
1149 if (year<2000 || day<1 || day>31 || month<1 || month>12) | |
1150 return FALSE; | |
1151 | |
1152 /* Check 'day' */ | |
1153 | |
1154 switch(month) | |
1155 { | |
1156 case 4: /* Apr */ | |
1157 case 6: /* Jun */ | |
1158 case 9: /* Sep */ | |
1159 case 11: /* Nov */ | |
1160 if (day>30) | |
1161 return FALSE; | |
1162 break; | |
1163 | |
1164 case 2: /* Feb */ | |
1165 /* Leap year... */ | |
1166 if ((year%4==0) && (year%400!=0)) | |
1167 { | |
1168 if (day>29) | |
1169 return FALSE; | |
1170 } | |
1171 else | |
1172 { | |
1173 if (day>28) | |
1174 return FALSE; | |
1175 } | |
1176 break; | |
1177 } | |
1178 | |
1179 return TRUE; | |
1180 } | |
1181 | |
1182 | |
1183 /******************************************************************************* | |
1184 | |
1185 $Function: tida_check_time | |
1186 | |
1187 $Description: Checks a time to see if it's valid | |
1188 | |
1189 $Returns: TRUE if it's valid, FALSE otherwise | |
1190 | |
1191 $Arguments: timestring - The time string | |
1192 | |
1193 *******************************************************************************/ | |
1194 | |
1195 UBYTE tida_check_time(char *timestring) | |
1196 { | |
1197 int hour; | |
1198 int minute; | |
1199 char ampmFlag; | |
1200 if(getClockFormat()==MFW_TIME_FORMAT_12HOUR) | |
1201 sscanf(timestring, "%d:%d %c", &hour, &minute,&mFlag); | |
1202 else | |
1203 sscanf(timestring, "%d:%d", &hour, &minute); | |
1204 | |
1205 TRACE_EVENT_P1("String: %s", timestring); | |
1206 TRACE_EVENT_P2("Hour %d, minute %d", hour, minute); | |
1207 | |
1208 // Issue Number : MMI-SPR-12159 on 07/04/04 by Rashmi C N and Deepa M D | |
1209 // change by Sasken ( Rashmi C N and Deepa M D) on April 07th 2004 | |
1210 // Bug : In 12 hour fomrat the AM and PM was not being set | |
1211 // Solution : Validation for 12 hour format | |
1212 if (((getClockFormat() == MFW_TIME_FORMAT_24HOUR) && (hour<0 || hour>23 || minute<0 || minute>59)) | |
1213 ||((getClockFormat()== MFW_TIME_FORMAT_12HOUR) && (hour<0 || hour>12 || minute<0 || minute>59 || ( ampmFlag!='p' && ampmFlag!='a'))) | |
1214 ) | |
1215 return FALSE; | |
1216 | |
1217 return TRUE; | |
1218 } | |
1219 | |
1220 #else /* NEW_EDITOR */ | |
1221 | |
1222 /* OLD VERSION */ | |
1223 | |
1224 /******************************************************************************* | |
1225 | |
1226 $Function: date_time_create | |
1227 | |
1228 $Description: create main dialog for time and date (SINGLE_DYNAMIC) | |
1229 | |
1230 $Returns: none. | |
1231 | |
1232 $Arguments: | |
1233 | |
1234 *******************************************************************************/ | |
1235 T_MFW_HND date_time_create (T_MFW_HND parent_window) | |
1236 { | |
1237 T_MFW_WIN * win; | |
1238 | |
1239 T_tida * data = (T_tida *)ALLOC_MEMORY (sizeof (T_tida)); | |
1240 data->tida_win = win_create (parent_window, 0, MfwWinVisible, (T_MFW_CB)tida_win_cb); | |
1241 | |
1242 TRACE_FUNCTION("MmiTimeDate:date_time_create"); | |
1243 | |
1244 if (data->tida_win EQ 0) | |
1245 return 0; | |
1246 | |
1247 /* | |
1248 * Create window handler | |
1249 */ | |
1250 data->mmi_control.dialog = (T_DIALOG_FUNC)tida_main;/* dialog main function */ | |
1251 data->mmi_control.data = data; | |
1252 data->parent_win = parent_window; | |
1253 win = ((T_MFW_HDR *)data->tida_win)->data; | |
1254 win->user = (void *) data; | |
1255 | |
1256 | |
1257 /* | |
1258 * return window handle | |
1259 */ | |
1260 | |
1261 mfwSetSignallingMethod(1); | |
1262 winShow(data->tida_win); | |
1263 | |
1264 | |
1265 return data->tida_win; | |
1266 } | |
1267 /******************************************************************************* | |
1268 | |
1269 $Function: date_time_destroy | |
1270 | |
1271 $Description: destroy main dialog for time and date | |
1272 | |
1273 $Returns: none. | |
1274 | |
1275 $Arguments: | |
1276 | |
1277 *******************************************************************************/ | |
1278 void date_time_destroy (T_MFW_HND own_window) | |
1279 { | |
1280 T_tida * data; | |
1281 T_MFW_WIN * win; | |
1282 | |
1283 if (own_window) | |
1284 { | |
1285 TRACE_EVENT("MmiTimeDate:date_time_destroy"); | |
1286 win = ((T_MFW_HDR *)own_window)->data; | |
1287 data = (T_tida *)win->user; | |
1288 | |
1289 if(data) | |
1290 { | |
1291 win_delete (data->tida_win); | |
1292 FREE_MEMORY((void *)data,(sizeof(T_tida))); | |
1293 } | |
1294 } | |
1295 } | |
1296 /******************************************************************************* | |
1297 | |
1298 $Function: date_time_edt_create | |
1299 | |
1300 $Description: create editor dialog for time and date(SINGLE_DYNAMIC) | |
1301 | |
1302 $Returns: none. | |
1303 | |
1304 $Arguments: | |
1305 | |
1306 *******************************************************************************/ | |
1307 T_MFW_HND date_time_edt_create(T_MFW_HND parent_window) | |
1308 { | |
1309 T_tida_edt * data = (T_tida_edt *)ALLOC_MEMORY (sizeof (T_tida_edt)); | |
1310 | |
1311 T_MFW_WIN * win; | |
1312 | |
1313 data->tida_edt_win = win_create (parent_window, 0, MfwWinVisible, (T_MFW_CB)tida_edt_win_cb); | |
1314 | |
1315 TRACE_FUNCTION("MmiTimeDate:date_time_edt_create"); | |
1316 | |
1317 if (data->tida_edt_win EQ 0) | |
1318 return 0; | |
1319 | |
1320 /* | |
1321 * Create window handler | |
1322 */ | |
1323 data->mmi_control.dialog = (T_DIALOG_FUNC)tida_editor; | |
1324 data->mmi_control.data = data; | |
1325 data->parent_win = parent_window; | |
1326 win = ((T_MFW_HDR *)data->tida_edt_win)->data; | |
1327 win->user = (void *) data; | |
1328 /* | |
1329 * Create any other handler | |
1330 */ | |
1331 editor_attr_init(&data->edit1Attr, TIMEDATE_EDITOR_AREA, edtCurBar1 | edtModOverWr, 0, (char*)data->edtbuf1,MAX_DIG_TIDA,COLOUR_EDITOR_XX ); | |
1332 | |
1333 data->tim_out_handle = tim_create(data->tida_edt_win,TIMERCLEAR,(T_MFW_CB)tida_edt_tim_out_cb); | |
1334 data->editor_handle = edt_create(data->tida_edt_win,&data->edit1Attr,0,0); | |
1335 data->kbd_handle = kbd_create(data->tida_edt_win,KEY_ALL,(T_MFW_CB)tida_edt_kbd_cb); | |
1336 data->kbd_long_handle = kbd_create(data->tida_edt_win,KEY_ALL | KEY_LONG,(T_MFW_CB)tida_edt_kbd_long_cb); | |
1337 /* | |
1338 * return window handle | |
1339 */ | |
1340 return data->tida_edt_win; | |
1341 } | |
1342 /******************************************************************************* | |
1343 | |
1344 $Function: date_time_edt_destroy | |
1345 | |
1346 $Description: destroy editor dialog for time and date | |
1347 | |
1348 $Returns: none. | |
1349 | |
1350 $Arguments: | |
1351 | |
1352 *******************************************************************************/ | |
1353 void date_time_edt_destroy (T_MFW_HND own_window) | |
1354 { | |
1355 T_tida_edt * data ; | |
1356 T_MFW_WIN * win; | |
1357 | |
1358 | |
1359 if (own_window) | |
1360 { | |
1361 TRACE_FUNCTION ("MmiTimeDate:date_time_edt_destroy"); | |
1362 | |
1363 win = ((T_MFW_HDR *)own_window)->data; | |
1364 data = (T_tida_edt *)win->user; | |
1365 | |
1366 if(data) | |
1367 { | |
1368 win_delete (data->tida_edt_win); | |
1369 FREE_MEMORY((void *)data,(sizeof(T_tida_edt))); | |
1370 } | |
1371 } | |
1372 } | |
1373 /******************************************************************************* | |
1374 | |
1375 $Function: tida_main | |
1376 | |
1377 $Description: main dialog function for time and date | |
1378 | |
1379 $Returns: none. | |
1380 | |
1381 $Arguments: | |
1382 | |
1383 *******************************************************************************/ | |
1384 static void tida_main(T_MFW_HND win, USHORT event, SHORT value, void * parameter) | |
1385 { | |
1386 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
1387 T_tida * tida_data = (T_tida *)win_data->user;//tida main data | |
1388 T_tida_edt * tida_edt_data = (T_tida_edt *) parameter;//tida editor data | |
1389 T_MFW_HND tida_edt_win; | |
1390 T_DISPLAY_DATA display_info; | |
1391 | |
1392 TRACE_FUNCTION("MmiTimeDate:tida_main"); | |
1393 | |
1394 switch(event) | |
1395 { | |
1396 case DATE_SHOW: | |
1397 tida_data->state = DATE_SHOW; | |
1398 tida_data->display_id1 = TxtEnterDate; | |
1399 tida_edt_win = date_time_edt_create(tida_data->tida_win); | |
1400 if(tida_edt_win) | |
1401 { | |
1402 SEND_EVENT(tida_edt_win,event,0,tida_data); | |
1403 } | |
1404 break; | |
1405 case DATE_ENTRY: | |
1406 tida_data->state = DATE_ENTRY; | |
1407 tida_data->display_id1 = TxtEnterDate; | |
1408 tida_edt_win = date_time_edt_create(tida_data->tida_win); | |
1409 { | |
1410 SEND_EVENT(tida_edt_win,event,0,tida_data); | |
1411 } | |
1412 break; | |
1413 case TIME_ENTRY: | |
1414 tida_data->state = TIME_ENTRY; | |
1415 tida_data->display_id1 = TxtEnterTime; | |
1416 tida_edt_win = date_time_edt_create(tida_data->tida_win); | |
1417 { | |
1418 SEND_EVENT(tida_edt_win,event,0,tida_data); | |
1419 } | |
1420 break; | |
1421 case TIME_SHOW: | |
1422 tida_data->state = TIME_SHOW; | |
1423 tida_data->display_id1 = TxtEnterTime; | |
1424 tida_edt_win = date_time_edt_create(tida_data->tida_win); | |
1425 if(tida_edt_win) | |
1426 { | |
1427 SEND_EVENT(tida_edt_win,event,0,tida_data); | |
1428 } | |
1429 break; | |
1430 case ENTRY_OK: | |
1431 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtSaved, TxtNull, COLOUR_STATUS); | |
1432 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)tida_info_cb, THREE_SECS, KEY_ALL ); | |
1433 display_info.Identifier = SAVED; | |
1434 info_dialog(tida_data->tida_win,&display_info); /* information screen "Saved" */ | |
1435 break; | |
1436 case SAVED: | |
1437 case TIDA_ABORT: | |
1438 case TIDA_CLEAR: | |
1439 case TIDA_TO_IDLE: | |
1440 date_time_destroy(tida_data->tida_win); | |
1441 break; | |
1442 default: | |
1443 break; | |
1444 } | |
1445 } | |
1446 /******************************************************************************* | |
1447 | |
1448 $Function: tida_info_cb | |
1449 | |
1450 $Description: callback function from info dialog for time and date | |
1451 | |
1452 $Returns: none. | |
1453 | |
1454 $Arguments: | |
1455 | |
1456 *******************************************************************************/ | |
1457 void tida_info_cb(T_MFW_HND win, USHORT identifier, UBYTE reasons) | |
1458 { | |
1459 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
1460 T_tida * tida_data = (T_tida *)win_data->user; | |
1461 | |
1462 TRACE_FUNCTION ("MmiTimeDate: tida_info_cb"); | |
1463 | |
1464 switch(identifier) | |
1465 { | |
1466 case SAVED: | |
1467 SEND_EVENT(tida_data->tida_win,identifier,0,NULL); | |
1468 break; | |
1469 default: | |
1470 break; | |
1471 } | |
1472 } | |
1473 | |
1474 /******************************************************************************* | |
1475 | |
1476 $Function: tida_win_cb | |
1477 | |
1478 $Description: windows main callback function for time and date | |
1479 | |
1480 $Returns: none. | |
1481 | |
1482 $Arguments: | |
1483 | |
1484 *******************************************************************************/ | |
1485 static int tida_win_cb (T_MFW_EVENT event, T_MFW_WIN * win) | |
1486 { | |
1487 TRACE_FUNCTION ("MmiTimeDate: tida_win_cb"); | |
1488 if (event EQ MfwWinVisible) | |
1489 { | |
1490 /* | |
1491 * Top Window has no output | |
1492 */ | |
1493 dspl_ClearAll(); | |
1494 return 1; | |
1495 } | |
1496 return 0; | |
1497 } | |
1498 /******************************************************************************* | |
1499 | |
1500 $Function: tida_edt_win_cb | |
1501 | |
1502 $Description: windows callback function for editor for time and date | |
1503 | |
1504 $Returns: none. | |
1505 | |
1506 $Arguments: | |
1507 | |
1508 *******************************************************************************/ | |
1509 static int tida_edt_win_cb (T_MFW_EVENT event,T_MFW_WIN * win) | |
1510 { | |
1511 | |
1512 | |
1513 T_tida_edt * edt_data = (T_tida_edt *)win->user;//tida edt data | |
1514 T_MFW_WIN * win_tida =((T_MFW_HDR *)edt_data->parent_win)->data; | |
1515 T_tida * tida_data = (T_tida *)win_tida->user; // tida main data | |
1516 char lin1[MAX_LEN_DATE]; | |
1517 char lin2[MAX_LEN_TIME]; | |
1518 T_MFW_TIME* currclock; /*SPR 2639*/ | |
1519 T_MFW_DATE* currdate; | |
1520 //T_MFW_TIME alarmTime; /*SPR 2639*/ | |
1521 | |
1522 | |
1523 currclock = mfw_td_get_time(&currclock);/*SPR 2639*/ | |
1524 currdate = mfw_td_get_date(&currdate); | |
1525 | |
1526 | |
1527 TRACE_FUNCTION ("MmiTimeDate:tida_edt_win_cb"); | |
1528 | |
1529 if (event EQ MfwWinVisible) | |
1530 { | |
1531 dspl_ClearAll(); | |
1532 PROMPT(DATE_TEXT_X,DATE_TEXT_Y,0,tida_data->display_id1); | |
1533 softKeys_displayId(TxtSoftOK,TxtSoftBack,0,COLOUR_EDITOR_XX); | |
1534 | |
1535 | |
1536 if(tida_data->state EQ DATE_SHOW) | |
1537 { | |
1538 if ((DateTimeEntryMode == SETTING) || (alarmDate.day == 0)) | |
1539 { if (currdate->day == 0) //if no date set | |
1540 sprintf(lin1,"dd/mm/yyyy"); | |
1541 else | |
1542 sprintf(lin1,"%02d/%02d/%04d",currdate->day,currdate->month,currdate->year); | |
1543 } | |
1544 else | |
1545 sprintf(lin1,"%02d/%02d/%04d",alarmDate.day,alarmDate.month,alarmDate.year); | |
1546 | |
1547 strncpy(edt_data->edtbuf1,lin1,MAX_LEN_DATE); | |
1548 edtShow(edt_data->editor_handle); | |
1549 } | |
1550 else if(tida_data->state EQ DATE_ENTRY) | |
1551 { | |
1552 if ((DateTimeEntryMode == SETTING) || (alarmDate.day == 0)) | |
1553 { if (currdate->day == 0) | |
1554 sprintf(lin1,"dd/mm/yyyy");//if no date set | |
1555 else | |
1556 sprintf(lin1,"%02d/%02d/%04d",currdate->day,currdate->month,currdate->year); | |
1557 } | |
1558 else | |
1559 { | |
1560 sprintf(lin1,"%02d/%02d/%04d",alarmDate.day,alarmDate.month,alarmDate.year); | |
1561 } | |
1562 strncpy(edt_data->edtbuf1,lin1,MAX_LEN_DATE); | |
1563 edt_data->index = 0; | |
1564 edtShow(edt_data->editor_handle); | |
1565 softKeys_displayId(TxtSoftOK,TxtSoftBack,0,COLOUR_EDITOR_XX); | |
1566 } | |
1567 else if(tida_data->state EQ TIME_ENTRY) | |
1568 { | |
1569 if ((DateTimeEntryMode == SETTING) || (alarmDate.day==0)) | |
1570 sprintf(lin2,"%02d:%02d",mfw_td_convert_to_24_hour(currclock), currclock->minute); | |
1571 else | |
1572 sprintf(lin2,"%02d:%02d",alarmTime.hour, alarmTime.minute); | |
1573 strncpy(edt_data->edtbuf1,lin2,MAX_LEN_TIME); | |
1574 edt_data->index = 0; | |
1575 edtShow(edt_data->editor_handle); | |
1576 softKeys_displayId(TxtSoftOK,TxtSoftBack,0,COLOUR_EDITOR_XX); | |
1577 } | |
1578 else if(tida_data->state EQ TIME_SHOW) | |
1579 { if ((DateTimeEntryMode == SETTING) || (alarmDate.day == 0)) | |
1580 sprintf(lin2,"%02d:%02d",mfw_td_convert_to_24_hour(currclock), currclock->minute); | |
1581 else | |
1582 sprintf(lin2,"%02d:%02d",alarmTime.hour, alarmTime.minute); | |
1583 strncpy(edt_data->edtbuf1,lin2,MAX_LEN_TIME); | |
1584 edtShow(edt_data->editor_handle); | |
1585 } | |
1586 return 1; | |
1587 } | |
1588 return 0; | |
1589 | |
1590 } | |
1591 /******************************************************************************* | |
1592 | |
1593 $Function: tida_editor | |
1594 | |
1595 $Description: dialog function for editor for time and date | |
1596 | |
1597 $Returns: none. | |
1598 | |
1599 $Arguments: | |
1600 | |
1601 *******************************************************************************/ | |
1602 static void tida_editor(T_MFW_HND win, USHORT event, SHORT value, void * parameter) | |
1603 { | |
1604 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
1605 T_tida_edt * edt_data = (T_tida_edt *)win_data->user; | |
1606 | |
1607 | |
1608 T_tida * tida_data = (T_tida *)parameter;//tida main data | |
1609 | |
1610 edt_data->state = tida_data->state; | |
1611 | |
1612 TRACE_FUNCTION("MmiTimeDate:tida_editor"); | |
1613 | |
1614 /* | |
1615 * depending on event | |
1616 */ | |
1617 switch (event) | |
1618 { | |
1619 case DATE_SHOW: | |
1620 case TIME_SHOW: | |
1621 memset(edt_data->edtbuf1, '\0', sizeof(edt_data->edtbuf1));/* initial buffer */ | |
1622 edt_data->index = 0; | |
1623 winShow(edt_data->tida_edt_win); | |
1624 break; | |
1625 case DATE_ENTRY: | |
1626 case TIME_ENTRY: | |
1627 winShow(edt_data->tida_edt_win); | |
1628 break; | |
1629 default: | |
1630 break; | |
1631 } | |
1632 } | |
1633 /******************************************************************************* | |
1634 | |
1635 $Function: tida_edt_kbd_cb | |
1636 | |
1637 $Description: keyboard event handler for time and date | |
1638 | |
1639 $Returns: none. | |
1640 | |
1641 $Arguments: | |
1642 | |
1643 *******************************************************************************/ | |
1644 static int tida_edt_kbd_cb (MfwEvt e, MfwKbd *kc) | |
1645 { | |
1646 | |
1647 T_MFW_HND win = mfw_parent(mfw_header()); | |
1648 | |
1649 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
1650 T_tida_edt * edt_data = (T_tida_edt *)win_data->user;//tida edt data | |
1651 | |
1652 T_MFW_WIN * win_tida =((T_MFW_HDR *)edt_data->parent_win)->data; | |
1653 T_tida * tida_data = (T_tida *)win_tida->user; // tida main data | |
1654 | |
1655 char lin1[MAX_LEN_DATE]; | |
1656 char lin2[MAX_LEN_TIME]; | |
1657 T_MFW_TIME* currclock; /*SPR 2639*/ | |
1658 currclock = mfw_td_get_time();/*SPR 2639*/ | |
1659 | |
1660 TRACE_FUNCTION ("MmiTimeDate: tida_edt_kbd_cb"); | |
1661 | |
1662 switch(kc->code) | |
1663 { | |
1664 case KCD_0: | |
1665 case KCD_1: | |
1666 case KCD_2: | |
1667 case KCD_3: | |
1668 case KCD_4: | |
1669 case KCD_5: | |
1670 case KCD_6: | |
1671 case KCD_7: | |
1672 case KCD_8: | |
1673 case KCD_9: | |
1674 if(edt_data->state EQ DATE_ENTRY) /* date entering */ | |
1675 { | |
1676 if(edt_data->index < (MAX_LEN_DATE - 1)) | |
1677 { | |
1678 if((edt_data->index NEQ 2) && (edt_data->index NEQ 5)) | |
1679 { | |
1680 edt_data->edtbuf1[edt_data->index] = '0' + kc->code; | |
1681 edtChar(edt_data->editor_handle,edt_data->edtbuf1[edt_data->index]); | |
1682 edt_data->index++; | |
1683 } | |
1684 | |
1685 if((edt_data->index EQ 2) || (edt_data->index EQ 5)) | |
1686 { | |
1687 edtChar(edt_data->editor_handle,'/'); | |
1688 edt_data->edtbuf1[edt_data->index] = '/'; | |
1689 edt_data->index++; | |
1690 } | |
1691 } | |
1692 } | |
1693 else if(edt_data->state EQ TIME_ENTRY) /* time entering */ | |
1694 { | |
1695 if(edt_data->index < (MAX_LEN_TIME -1)) | |
1696 { | |
1697 if(edt_data->index NEQ 2) | |
1698 { | |
1699 edt_data->edtbuf1[edt_data->index] = '0' + kc->code; | |
1700 edtChar(edt_data->editor_handle,edt_data->edtbuf1[edt_data->index]); | |
1701 edt_data->index++; | |
1702 } | |
1703 if(edt_data->index EQ 2) | |
1704 { | |
1705 edtChar(edt_data->editor_handle,':'); | |
1706 edt_data->edtbuf1[edt_data->index] = ':'; | |
1707 edt_data->index++; | |
1708 } | |
1709 } | |
1710 } | |
1711 break; | |
1712 case KCD_MNUSELECT: | |
1713 case KCD_LEFT: /* select and ok button */ | |
1714 if(edt_data->state EQ DATE_ENTRY) | |
1715 { | |
1716 if(check_date(win,edt_data)) | |
1717 { | |
1718 | |
1719 TRACE_EVENT("datecheck ok"); | |
1720 edtClear(edt_data->editor_handle); | |
1721 edtHide(edt_data->editor_handle); /* verification date successfull */ | |
1722 date_time_edt_destroy(edt_data->tida_edt_win); | |
1723 SEND_EVENT(tida_data->tida_win,TIME_ENTRY,0,tida_data); | |
1724 | |
1725 } | |
1726 else | |
1727 { | |
1728 memset(edt_data->edtbuf1, '\0', sizeof(edt_data->edtbuf1));/* initial buffer */ | |
1729 edt_data->index = 0; | |
1730 | |
1731 sprintf(lin1,"dd/mm/yyyy"); | |
1732 strncpy(edt_data->edtbuf1,lin1,MAX_LEN_DATE); | |
1733 edtReset(edt_data->editor_handle); | |
1734 edtShow(edt_data->editor_handle); | |
1735 } | |
1736 } | |
1737 else if(edt_data->state EQ TIME_ENTRY) | |
1738 { | |
1739 if(check_time(win,edt_data)) | |
1740 { | |
1741 TRACE_EVENT("timecheck ok"); | |
1742 edtClear(edt_data->editor_handle); | |
1743 edtHide(edt_data->editor_handle); /* verification date successfull */ | |
1744 date_time_edt_destroy(edt_data->tida_edt_win); | |
1745 SEND_EVENT(tida_data->tida_win,ENTRY_OK,0,tida_data); | |
1746 } | |
1747 else | |
1748 { | |
1749 memset(edt_data->edtbuf1, '\0', sizeof(edt_data->edtbuf1));/* initial buffer */ | |
1750 edt_data->index = 0; | |
1751 | |
1752 sprintf(lin2,"%02d:%02d",mfw_td_convert_to_24_hour(currclock), currclock->minute); | |
1753 strncpy(edt_data->edtbuf1,lin2,MAX_LEN_TIME); | |
1754 edtReset(edt_data->editor_handle); | |
1755 edtShow(edt_data->editor_handle); | |
1756 } | |
1757 } | |
1758 else if(edt_data->state EQ DATE_SHOW) | |
1759 { | |
1760 date_time_edt_destroy(edt_data->tida_edt_win); | |
1761 SEND_EVENT(tida_data->tida_win,DATE_ENTRY,0,tida_data); | |
1762 } /* start date entering */ | |
1763 | |
1764 else if(edt_data->state EQ TIME_SHOW) | |
1765 { | |
1766 date_time_edt_destroy(edt_data->tida_edt_win); | |
1767 SEND_EVENT(tida_data->tida_win,TIME_ENTRY,0,tida_data); /* start time entering */ | |
1768 } | |
1769 break; | |
1770 case KCD_RIGHT: /* back to previous menu */ | |
1771 date_time_edt_destroy(edt_data->tida_edt_win); | |
1772 SEND_EVENT(tida_data->tida_win,TIDA_ABORT,0,tida_data); | |
1773 break; | |
1774 case KCD_MNUUP: /* cursor to right */ | |
1775 if((edt_data->state EQ DATE_ENTRY) || (edt_data->state EQ TIME_ENTRY)) /* cursor to rigt */ | |
1776 { | |
1777 edt_data->index++; | |
1778 edtChar(edt_data->editor_handle,ecRight); | |
1779 | |
1780 if(((edt_data->state EQ DATE_ENTRY) && ((edt_data->index EQ 2)||(edt_data->index EQ 5))) || ((edt_data->state EQ TIME_ENTRY) && (edt_data->index EQ 2))) | |
1781 { | |
1782 edt_data->index++; | |
1783 edtChar(edt_data->editor_handle,ecRight); | |
1784 } | |
1785 | |
1786 } | |
1787 break; | |
1788 case KCD_HUP: | |
1789 case KCD_MNUDOWN: /* cursor to left or clear */ | |
1790 if((!(edt_data->state EQ DATE_SHOW)) && (!(edt_data->state EQ TIME_SHOW))) | |
1791 { | |
1792 if(edt_data->state EQ DATE_ENTRY) | |
1793 { | |
1794 if(edt_data->index EQ 0) | |
1795 ; | |
1796 else | |
1797 edt_data->index--; | |
1798 | |
1799 if((edt_data->index EQ 2)||(edt_data->index EQ 5)) | |
1800 { | |
1801 if(edt_data->index EQ 0) | |
1802 ; | |
1803 else | |
1804 edt_data->index--; | |
1805 | |
1806 edtChar(edt_data->editor_handle,ecLeft); | |
1807 edtChar(edt_data->editor_handle,ecLeft); | |
1808 } | |
1809 else | |
1810 edtChar(edt_data->editor_handle,ecLeft); | |
1811 } | |
1812 if(edt_data->state EQ TIME_ENTRY) | |
1813 { | |
1814 if(edt_data->index EQ 0) | |
1815 ; | |
1816 else | |
1817 edt_data->index--; | |
1818 | |
1819 if(edt_data->index EQ 2) | |
1820 { | |
1821 if(edt_data->index EQ 0) | |
1822 ; | |
1823 else | |
1824 edt_data->index--; | |
1825 | |
1826 edtChar(edt_data->editor_handle,ecLeft); | |
1827 edtChar(edt_data->editor_handle,ecLeft); | |
1828 } | |
1829 else | |
1830 edtChar(edt_data->editor_handle,ecLeft); | |
1831 } | |
1832 } | |
1833 else | |
1834 timStart(edt_data->tim_out_handle); /* waiting for release clear otherwise to previous screen */ | |
1835 break; | |
1836 default: | |
1837 return MFW_EVENT_CONSUMED; | |
1838 } | |
1839 return MFW_EVENT_CONSUMED; | |
1840 } | |
1841 | |
1842 /******************************************************************************* | |
1843 | |
1844 $Function: check_date | |
1845 | |
1846 $Description: check date after date entering | |
1847 | |
1848 $Returns: none. | |
1849 | |
1850 $Arguments: | |
1851 | |
1852 *******************************************************************************/ | |
1853 static int check_date (T_MFW_HND win, void * edt_dat) | |
1854 { | |
1855 U8 i; | |
1856 T_tida_edt * edt_data = (T_tida_edt *)edt_dat; | |
1857 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
1858 T_tida * tida_data = (T_tida *)win_data->user; | |
1859 T_MFW_DATE tempdate; | |
1860 | |
1861 char internday[3]; | |
1862 char internmonth[3]; | |
1863 char internyear[5]; | |
1864 | |
1865 char debug[20]; | |
1866 T_MFW_TIME* currclock; /*SPR 2639*/ | |
1867 T_MFW_DATE* currdate; | |
1868 //T_MFW_TIME alarmTime; /*SPR 2639*/ | |
1869 | |
1870 | |
1871 currclock= mfw_td_get_time();/*SPR 2639*/ | |
1872 currdate =mfw_td_get_date(); | |
1873 | |
1874 TRACE_FUNCTION ("MmiTimeDate:check_date"); | |
1875 | |
1876 memset(internday, '\0', sizeof(internday));/* initial string */ | |
1877 memset(internmonth, '\0', sizeof(internmonth)); | |
1878 memset(internyear, '\0', sizeof(internyear)); | |
1879 | |
1880 internday[0] = edt_data->edtbuf1[0]; | |
1881 internday[1] = edt_data->edtbuf1[1]; | |
1882 internmonth[0] = edt_data->edtbuf1[3]; | |
1883 internmonth[1] = edt_data->edtbuf1[4]; | |
1884 for(i = 0;i<4;i++) | |
1885 { | |
1886 internyear[i] = edt_data->edtbuf1[6+i]; | |
1887 } | |
1888 | |
1889 tempdate.month = atoi(internmonth); | |
1890 if((tempdate.month > 12) || (tempdate.month < 1)) | |
1891 return FALSE; | |
1892 | |
1893 tempdate.day = atoi(internday); | |
1894 if((tempdate.day > 30) || (tempdate.day < 1)) | |
1895 { | |
1896 if(tempdate.day EQ 31) | |
1897 { | |
1898 switch(tempdate.month) | |
1899 { | |
1900 case 1: | |
1901 case 3: | |
1902 case 5: | |
1903 case 7: | |
1904 case 8: | |
1905 case 10: | |
1906 case 12: | |
1907 break; | |
1908 default: | |
1909 return FALSE; | |
1910 | |
1911 } | |
1912 } | |
1913 else | |
1914 return FALSE; | |
1915 } | |
1916 | |
1917 tempdate.year = atoi(internyear); | |
1918 | |
1919 if(tempdate.year < 2000) | |
1920 return FALSE; | |
1921 | |
1922 if((tempdate.month EQ 2) && (tempdate.day EQ 29)) | |
1923 { | |
1924 if(!(tempdate.year%4) || (tempdate.year EQ 2000)) | |
1925 { | |
1926 if(DateTimeEntryMode == ALARM) | |
1927 { | |
1928 alarmDate.day = tempdate.day; | |
1929 alarmDate.month = tempdate.month; | |
1930 alarmDate.year = tempdate.year; | |
1931 } | |
1932 else | |
1933 { | |
1934 | |
1935 currdate->day = tempdate.day; | |
1936 currdate->month = tempdate.month; | |
1937 currdate->year = tempdate.year; | |
1938 mfw_td_set_date(currdate);/*SPR 2639*/ | |
1939 } | |
1940 return TRUE; | |
1941 } | |
1942 else | |
1943 return FALSE; | |
1944 } | |
1945 else | |
1946 { | |
1947 if(DateTimeEntryMode == ALARM) | |
1948 { | |
1949 | |
1950 | |
1951 alarmDate.day = tempdate.day; | |
1952 alarmDate.month = tempdate.month; | |
1953 alarmDate.year = tempdate.year; | |
1954 | |
1955 } | |
1956 else | |
1957 { | |
1958 currdate->day = tempdate.day; | |
1959 currdate->month = tempdate.month; | |
1960 currdate->year = tempdate.year; | |
1961 } | |
1962 mfw_td_set_date(currdate);/*SPR 2639*/ | |
1963 return TRUE; | |
1964 } | |
1965 } | |
1966 /******************************************************************************* | |
1967 | |
1968 $Function: check_time | |
1969 | |
1970 $Description: check time after time entering | |
1971 | |
1972 $Returns: none. | |
1973 | |
1974 $Arguments: | |
1975 | |
1976 *******************************************************************************/ | |
1977 static int check_time (T_MFW_HND win, void * edt_dat) | |
1978 { | |
1979 T_tida_edt * edt_data = (T_tida_edt *)edt_dat; | |
1980 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
1981 T_tida * tida_data = (T_tida *)win_data->user; | |
1982 T_MFW_TIME tempclock; | |
1983 char debug[50]; | |
1984 char internmin[3]; | |
1985 char internhour[3]; | |
1986 T_MFW_TIME* currclock; /*SPR 2639*/ | |
1987 T_MFW_DATE* currdate; | |
1988 T_MFW_TIME_FORMAT current_format; | |
1989 //T_MFW_TIME alarmTime; /*SPR 2639*/ | |
1990 | |
1991 currclock = mfw_td_get_time();/*SPR 2639*/ | |
1992 currdate = mfw_td_get_date(); | |
1993 | |
1994 current_format = currclock->format; | |
1995 memset(internmin, '\0', sizeof(internmin));/* initial string */ | |
1996 memset(internhour, '\0', sizeof(internhour)); | |
1997 | |
1998 internhour[0] = edt_data->edtbuf1[0]; | |
1999 internhour[1] = edt_data->edtbuf1[1]; | |
2000 internmin[0] = edt_data->edtbuf1[3]; | |
2001 internmin[1] = edt_data->edtbuf1[4]; | |
2002 | |
2003 tempclock.hour = atoi(internhour); | |
2004 if(tempclock.hour > 23) | |
2005 return FALSE; | |
2006 | |
2007 tempclock.minute = atoi(internmin); | |
2008 if(tempclock.minute >59) | |
2009 return FALSE; | |
2010 if (DateTimeEntryMode == ALARM) | |
2011 { | |
2012 alarmTime.hour = tempclock.hour; /*SPR 2639*/ | |
2013 alarmTime.minute = tempclock.minute; | |
2014 alarmTime.format = MFW_TIME_FORMAT_24HOUR; | |
2015 mfw_td_set_alarm(&alarmTime, &alarmDate); | |
2016 } | |
2017 else | |
2018 { | |
2019 | |
2020 | |
2021 currclock->hour = tempclock.hour; | |
2022 currclock->minute = tempclock.minute; | |
2023 currclock->format = MFW_TIME_FORMAT_24HOUR; | |
2024 mfw_td_set_time(currclock);/*SPR 2639*/ | |
2025 mfw_td_set_time_format(current_format); | |
2026 } | |
2027 | |
2028 return TRUE; | |
2029 } | |
2030 /******************************************************************************* | |
2031 | |
2032 $Function: tida_edt_tim_out_cb | |
2033 | |
2034 $Description: Callback function for timer for time and date | |
2035 | |
2036 $Returns: none. | |
2037 | |
2038 $Arguments: | |
2039 | |
2040 *******************************************************************************/ | |
2041 static void tida_edt_tim_out_cb(T_MFW_EVENT event,T_MFW_TIM * t) | |
2042 { | |
2043 T_MFW_HND win = mfw_parent(mfw_header()); | |
2044 | |
2045 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
2046 T_tida_edt * tida_edt_data = (T_tida_edt *)win_data->user; | |
2047 | |
2048 T_MFW_WIN * win_tida =((T_MFW_HDR *)tida_edt_data->parent_win)->data; | |
2049 T_tida * tida_data = (T_tida *)win_tida->user; // tida main data | |
2050 | |
2051 date_time_edt_destroy(tida_edt_data->tida_edt_win); | |
2052 SEND_EVENT(tida_data->tida_win,TIDA_CLEAR,0,tida_data); | |
2053 | |
2054 } | |
2055 /******************************************************************************* | |
2056 | |
2057 $Function: tida_edt_kbd_long_cb | |
2058 | |
2059 $Description: keyboard long event handler for time and date | |
2060 | |
2061 $Returns: none. | |
2062 | |
2063 $Arguments: | |
2064 | |
2065 *******************************************************************************/ | |
2066 static int tida_edt_kbd_long_cb (MfwEvt e, MfwKbd *kc) | |
2067 { | |
2068 T_MFW_HND win = mfw_parent(mfw_header()); | |
2069 | |
2070 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
2071 T_tida_edt * edt_data = (T_tida_edt *)win_data->user;//tida edt data | |
2072 | |
2073 T_MFW_WIN * win_tida =((T_MFW_HDR *)edt_data->parent_win)->data; | |
2074 T_tida * tida_data = (T_tida *)win_tida->user; // tida main data | |
2075 | |
2076 TRACE_FUNCTION("MmiTimeDate:tida_edt_kbd_long_cb"); | |
2077 | |
2078 if ((e & KEY_CLEAR) && (e & KEY_LONG)) | |
2079 { | |
2080 | |
2081 if((!(edt_data->state EQ DATE_SHOW)) && (!(edt_data->state EQ TIME_SHOW))) | |
2082 { | |
2083 | |
2084 if(edt_data->state EQ DATE_ENTRY) | |
2085 { | |
2086 date_time_edt_destroy(edt_data->tida_edt_win); | |
2087 SEND_EVENT(tida_data->tida_win,DATE_SHOW,0,tida_data); | |
2088 } | |
2089 else if(edt_data->state EQ TIME_ENTRY) | |
2090 { | |
2091 date_time_edt_destroy(edt_data->tida_edt_win); | |
2092 | |
2093 SEND_EVENT(tida_data->tida_win,TIME_ENTRY,0,tida_data); | |
2094 | |
2095 } | |
2096 return MFW_EVENT_CONSUMED; | |
2097 | |
2098 } | |
2099 else | |
2100 { | |
2101 timStop(edt_data->tim_out_handle); | |
2102 date_time_edt_destroy(edt_data->tida_edt_win); | |
2103 SEND_EVENT(tida_data->tida_win,TIDA_TO_IDLE,0,tida_data); | |
2104 return MFW_EVENT_CONSUMED; | |
2105 } | |
2106 } | |
2107 else | |
2108 return MFW_EVENT_CONSUMED; | |
2109 } | |
2110 #endif /* NEW_EDITOR */ | |
2111 |