comparison src/ui3/bmi/MmiTimeDate.c @ 420:e8ddbb0837ed

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