comparison g23m/condat/ms/src/mfw/mfw_td.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1
2 /*
3 +--------------------------------------------------------------------+
4 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_td.c $|
5 | $Author:: Es $ CONDAT GmbH $Revision:: 12 $|
6 | CREATED: 21.09.98 $Modtime:: 2.03.00 11:49 $|
7 | STATE : code |
8 +--------------------------------------------------------------------+
9
10 MODULE : MFW_TD
11
12 PURPOSE : time and date functions
13
14 EXPORT :
15
16 TO DO :
17
18 $History:: mfw_td.c
19
20 Jan 06,2004 REF: CRR 27859 xkundadu
21 Description: Clock: Alarm does not go off even if timer times out.
22 Solution: Check whether FFS is formatted before writing into FFS.
23 If it is not formatted, format it and create /mmi folder in FFS.
24
25 Aug 16, 2004 REF: CRR 24323 Deepa M.D
26 Bug:Clenup of sprintf used for tracing
27 Fix:Replace the char buf[]; sprintf (buf, "...", ...); TRACE_EVENT (buf); statements by TRACE_EVENT_PX $
28 *
29 // Issue Number : SPR#12159 on 07/04/04 by Rashmi C N and Deepa M D
30 */
31
32
33 #define ENTITY_MFW
34
35 #if defined (NEW_FRAME)
36
37 #include "typedefs.h"
38 #include "vsi.h"
39 #include "custom.h"
40 #include "gsm.h"
41
42 #else
43
44 #include "STDDEFS.H"
45 #include "custom.h"
46 #include "gsm.h"
47 #include "vsi.h"
48
49 #endif
50
51
52 #include "mfw_mfw.h"
53 #include "mfw_sys.h"
54 #include "drv_tmr.h"
55 #include "mfw_tim.h"
56 #include "Mfw_td.h"
57 #include "mfw_win.h"
58 #include "mfw_acie.h"
59 #include "dspl.h"
60
61 // Jan 06,2004 REF: CRR 27859 xkundadu
62 // Description: Clock: Alarm does not go off even if timer times out.
63 // Solution: Check whether FFS is formatted before writing into FFS.
64 // If it is not formatted, format it and create /mmi folder in FFS.
65
66 // Included this header file to call FFS related functions
67 #include "Mfw_ffs.h"
68
69 #define TD_STRING_LEN 15
70
71 #define ONE_MINUTE 60000
72
73 /***************************Prototypes****************************************
74 **/
75 void mfw_td_signal (MfwEvt event, void* para); // Used to send event to MMI.
76 int mfw_td_sign_exec (MfwHdr *cur_elem, MfwEvt event, T_MFW_TD_PARA *para); // Used by mfw_td_signal() function to send event to MMI.
77 GLOBAL BOOL mfw_td_response_cb (ULONG opc, void * data);
78 static int tdCommand (U32 cmd, void *h);
79
80 BOOL dates_match(T_MFW_DATE* date1, T_MFW_DATE* date2);//returns TRUE if date paarmeters are the same
81 BOOL times_match(T_MFW_TIME* time1, T_MFW_TIME* time2);//returns TRUE if time parameters are the same
82 //void mfw_td_alarm_callback(void* para);/*SPR 2639, alarm callback function no longer needed*/
83 int mfw_timer_cb(MfwEvt e, MfwTim *t);
84 extern int flash_formatted(void);
85 /***************************global variables****************************************
86 **/
87 EXTERN MfwHdr * current_mfw_elem;
88
89 T_MFW_TIME current_time;
90 T_MFW_DATE current_date;
91
92 /*SPR 2639, added alarm time and date as well as a timer handle global*/
93 T_MFW_TIME alarm_time;
94 T_MFW_DATE alarm_date;
95
96
97 MfwHnd timer_handle= NULL;
98
99 char time_string[TD_STRING_LEN];
100 char date_string[TD_STRING_LEN];
101 static int pSlot; /* primitive handler slot */
102
103
104 /***************************Public methods****************************************
105 **/
106
107 /*
108 +--------------------------------------------------------------------+
109 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
110 | STATE : code ROUTINE: mfw_td_init |
111 +--------------------------------------------------------------------+
112
113 PURPOSE : initialise time and date and create primitive handler
114
115 */
116
117 void mfw_td_init()
118 {
119 T_MFW_ALARM_INFO alarmInfo;/*SPR 2639*/
120
121
122 TRACE_EVENT("mfw_td_init");
123 /*
124 * install prim handler
125 */
126 pSlot = aci_create(mfw_td_response_cb,NULL);/*put in dummy callback handler*/
127 mfwCommand[MfwTypTd] = (MfwCb) tdCommand;
128
129
130 /*if clock not cleared*/
131 #ifndef WIN32
132 if(!rtc_clock_cleared())
133 { /*get time/date from driver and initialise these*/
134 rtc_get_time_date(&current_date, &current_time);
135 }
136 else
137 {
138 rtc_get_time_date(&current_date, &current_time);
139 /*use a default time/date*/
140 current_time.second = 0;
141 current_time.minute = 0;
142 current_time.hour = 0;
143
144 current_date.year = 2000;
145 current_date.month = 1;
146 current_date.day = 1;
147 mfw_td_set_time(&current_time);
148 mfw_td_set_date(&current_date);
149 mfw_td_set_time_format(MFW_TIME_FORMAT_24HOUR);
150 mfw_td_cancel_alarm();
151 }
152 /*SPR 2639, read alarm info from FFS rather than driver*/
153 ffs_fread("/mmi/alarminfo",&alarmInfo, sizeof(T_MFW_ALARM_INFO));
154
155 memcpy(&alarm_time, &alarmInfo.alarm_time, sizeof(T_MFW_TIME));
156 memcpy(&alarm_date, &alarmInfo.alarm_date, sizeof(T_MFW_DATE));
157 if (dates_match(&current_date, &alarm_date) && times_match(&current_time, &alarm_time))
158 { mfw_td_signal(MFW_TD_ALARM, NULL);}
159
160 timer_handle = timCreate(0,ONE_MINUTE,(MfwCb)mfw_timer_cb);
161 timStart(timer_handle);
162 /*SPR 2639, set to default values for simulation*/
163 #else
164 current_time.second = 0;
165 current_time.minute = 0;
166 current_time.hour = 0;
167 current_date.year = 2000;
168 current_date.month = 1;
169 current_date.day = 1;
170 alarm_time.second = 0;
171 alarm_time.minute = 0;
172 alarm_time.hour = 0;
173 alarm_date.year = 2000;
174 alarm_date.month = 1;
175 alarm_date.day = 1;
176 #endif
177
178 }
179 /*
180 +--------------------------------------------------------------------+
181 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
182 | STATE : code ROUTINE: mfw_td_create |
183 +--------------------------------------------------------------------+
184
185 PURPOSE : Link callback function with MFW+TD events
186
187 */
188 T_MFW_HND mfw_td_create(MfwHnd hWin, MfwEvt event, MfwCb cbfunc)
189 {
190 MfwHdr *hdr;
191 T_MFW_TD *para;
192
193 TRACE_EVENT("mfw_td_timer_create");
194
195 hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
196 para = (T_MFW_TD *) mfwAlloc(sizeof(T_MFW_TD));
197
198 if (!hdr || !para)
199 return 0;
200
201 para->emask = event;
202 para->handler = cbfunc;
203
204 hdr->data = para;
205 hdr->type = MfwTypTd;
206
207 return mfwInsert((MfwHdr *) hWin,hdr);
208
209
210 }
211 /*
212 +--------------------------------------------------------------------+
213 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
214 | STATE : code ROUTINE: mfw_td_set_time |
215 +--------------------------------------------------------------------+
216
217 PURPOSE : set the current time
218
219 */
220 MfwRes mfw_td_set_time(T_MFW_TIME* time)
221 { int result;
222
223 TRACE_EVENT("mfw_td_set_time");
224 #ifndef WIN32
225 result = rtc_set_time_date(&current_date, time);
226 if (result == 0)
227 { memcpy(&current_time, time, sizeof(T_MFW_TIME));
228 return MfwResOk;
229 }
230 TRACE_EVENT_P1("RTC driver Error:%d", result);
231 return MfwResErr;
232 #else/*SPR 2639*/
233 memcpy(&current_time, time, sizeof(T_MFW_TIME));
234 return MfwResOk;
235 #endif
236 }
237 /*
238 +--------------------------------------------------------------------+
239 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
240 | STATE : code ROUTINE: mfw_td_set_date |
241 +--------------------------------------------------------------------+
242
243 PURPOSE : set the current date
244
245 */
246 MfwRes mfw_td_set_date(T_MFW_DATE* date)
247 { int result;
248 TRACE_EVENT("mfw_td_set_date");
249 #ifndef WIN32
250 result = rtc_set_time_date(date, &current_time);
251 if (result == 0)
252 {
253 memcpy(&current_date, date, sizeof(T_MFW_DATE));
254 return MfwResOk;
255 }
256 TRACE_EVENT_P1("RTC driver Error:%d", result);
257
258 return MfwResErr;
259 #else/*SPR 2639*/
260 memcpy(&current_date, date, sizeof(T_MFW_DATE));
261 return MfwResOk;
262 #endif
263 }
264
265 /*
266 +--------------------------------------------------------------------+
267 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
268 | STATE : code ROUTINE: mfw_td_get_clock_str |
269 +--------------------------------------------------------------------+
270
271 PURPOSE : returns an ASCII string containing the current time
272
273 */
274 char* mfw_td_get_clock_str()
275 { TRACE_EVENT("mfw_td_get_clock_str");
276 /*SPR 2639, use global var, don't need to update time as it's already updated every minute*/
277 rtc_get_time_date(&current_date, &current_time);
278
279 // Issue Number : MMI-SPR-12159 on 07/04/04 by Rashmi C N and Deepa M D
280 // change by Sasken ( Rashmi C N and Deepa M D) on April 07th 2004
281 // Bug : The AM PM for 12 hour fomrat was not being displayed, Also there were some bugs with the 12 hour fomat
282 // Change 1: Uncommented the above line "rtc_get_time_date(&current_date, &current_time); "
283 // as the time was not getting refreshed when the time format was changed
284 // Change 2 : To display the time in appropriate format in idle screen
285
286 if(current_time.format==MFW_TIME_FORMAT_12HOUR)
287 {
288 if(current_time.PM_flag==1)
289 sprintf(time_string, "%02d:%02d pm ", current_time.hour, current_time.minute);
290 else
291 sprintf(time_string, "%02d:%02d am ", current_time.hour, current_time.minute);
292 }
293 else
294 sprintf(time_string, "%02d:%02d", current_time.hour, current_time.minute);
295 return time_string;
296 }
297 /*
298 +--------------------------------------------------------------------+
299 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
300 | STATE : code ROUTINE: mfw_td_get_date_str |
301 +--------------------------------------------------------------------+
302
303 PURPOSE : returns an ASCII string containing the current date
304
305 */
306 char* mfw_td_get_date_str()
307 { TRACE_EVENT("mfw_td_get_date_str");
308 /*SPR 2639, use global var, don't need to update time as it's already updated every minute*/
309 //rtc_get_time_date(&current_date, &current_time);
310 sprintf(date_string, "%02d/%02d/%04d", current_date.day, current_date.month, current_date.year);
311 return date_string;
312 }
313
314 /*
315 +--------------------------------------------------------------------+
316 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
317 | STATE : code ROUTINE: mfw_td_get_date |
318 +--------------------------------------------------------------------+
319
320 PURPOSE : returns the current date in a data structure
321
322 */
323 T_MFW_DATE* mfw_td_get_date()
324 { // int result; // RAVI
325 TRACE_EVENT("mfw_td_get_date");
326 /*SPR 2639*/
327 #ifndef WIN32
328 rtc_get_time_date(&current_date, &current_time);
329 #endif
330 return &current_date;
331 }
332 /*
333 +--------------------------------------------------------------------+
334 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
335 | STATE : code ROUTINE: mfw_td_get_time |
336 +--------------------------------------------------------------------+
337
338 PURPOSE : returns the current time in a data structure
339
340 */
341 T_MFW_TIME* mfw_td_get_time()
342 {
343 TRACE_EVENT("mfw_td_get_time");
344 /*SPR 2639*/
345 #ifndef WIN32
346 rtc_get_time_date(&current_date, &current_time);
347 #endif
348 return &current_time;
349 }
350
351
352
353 /*
354 +--------------------------------------------------------------------+
355 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
356 | STATE : code ROUTINE: mfw_td_set_alarm |
357 +--------------------------------------------------------------------+
358
359 PURPOSE : set alarm to date and time passed to function
360
361 */
362 MfwRes mfw_td_set_alarm(T_MFW_TIME* time, T_MFW_DATE* date)
363 {
364 /*SPR 2639*/
365 #ifndef WIN32
366 int result;
367 T_MFW_ALARM_INFO alarmInfo;
368
369 /*SPR 2639, save alarm info to FFS*/
370 /***************************Go-lite Optimization changes Start***********************/
371 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
372 TRACE_EVENT_P5("alarm Time:%d:%d, date %d/%d%d", time->hour, time->minute, date->day,
373 date->month, date->year);
374 /***************************Go-lite Optimization changes end***********************/
375 memcpy(&alarmInfo.alarm_time, time, sizeof(T_MFW_TIME));
376 memcpy(&alarmInfo.alarm_date, date, sizeof(T_MFW_DATE));
377
378 // Jan 06,2004 REF: CRR 27859 xkundadu
379 // Description: Clock: Alarm does not go off even if timer times out.
380 // Solution: Format FFS, if it is not formatted.Create mmi folder in FFS if it's not present.
381
382 // Check whether FFS is formatted or not.
383 if(flash_formatted() == FALSE)
384 {
385 TRACE_EVENT("FFS NOT formatted ");
386 // If FFS is not formatted, format the /mmi volume.
387 if(ffs_format("/mmi", 0x2BAD ) == EFFS_OK)
388 {
389 TRACE_EVENT("Format success");
390 }
391 else
392 {
393 TRACE_EVENT("FFS NOT formatted ");
394 //FFS Format failed return ERROR
395 return MfwResErr;
396 }
397
398 }
399 else
400 {
401 // Already formatted.
402 TRACE_EVENT("FFS formatted ");
403 }
404
405 //Create 'mmi' folder in FFS.
406 //If it is already there, ffs_mkdir() wont create it again.
407 switch(ffs_mkdir("/mmi") )
408 {
409 case EFFS_OK:
410 TRACE_EVENT("Created mmi!!");
411 break;
412 case EFFS_EXISTS:
413 TRACE_EVENT("EFFS_EXISTS!");
414 break;
415 case EFFS_NAMETOOLONG:
416 TRACE_EVENT("EFFS_NAMETOOLONG!");
417 break;
418 case EFFS_BADNAME:
419 TRACE_EVENT("EFFS_BADNAME!");
420 break;
421 case EFFS_NOSPACE:
422 TRACE_EVENT("EFFS_NOSPACE!");
423 case EFFS_FSFULL:
424 TRACE_EVENT("EFFS_FSFULL!");
425 break;
426 case EFFS_MEMORY:
427 TRACE_EVENT("EFFS_MEMORY!");
428 break;
429 case EFFS_MSGSEND:
430 TRACE_EVENT("EFFS_MSGSEND!");
431 break;
432 default:
433 TRACE_EVENT("default!");
434 break;
435
436 }
437
438
439 result =ffs_fwrite("/mmi/alarminfo",&alarmInfo, sizeof(T_MFW_ALARM_INFO));
440
441 if (result<0)
442 { TRACE_EVENT("RTC alarm files not written");
443 return MfwResErr;
444 }
445 #endif
446 TRACE_EVENT("mfw_td_set_alarm");
447 memcpy(&alarm_time, time, sizeof(T_MFW_TIME));
448 memcpy(&alarm_date, date, sizeof(T_MFW_DATE));
449
450 return MfwResOk;
451 }
452 /*
453 +--------------------------------------------------------------------+
454 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
455 | STATE : code ROUTINE: mfw_td_cancel_alarm |
456 +--------------------------------------------------------------------+
457
458 PURPOSE : Cancels the alarm setting
459
460 */
461 MfwRes mfw_td_cancel_alarm()
462 {
463 /*SPR 2639*/
464 #ifndef WIN32
465 int result;
466 T_MFW_ALARM_INFO alarmInfo;
467 /*SPR 2639*/
468 alarm_date.day = 0;/*Impossible date*/
469 alarm_date.month= 0;
470 alarm_date.year=0;
471
472 memcpy(&alarmInfo.alarm_time, &alarm_time, sizeof(T_MFW_TIME));
473 memcpy(&alarmInfo.alarm_date, &alarm_date, sizeof(T_MFW_DATE));
474 result =ffs_fwrite("/mmi/alarminfo",&alarmInfo, sizeof(T_MFW_ALARM_INFO));
475
476 if (result<0)
477 { TRACE_EVENT("RTC alarm file not written");
478 return MfwResErr;
479 }
480 #endif
481 TRACE_EVENT("mfw_td_cancel_alarm");
482 alarm_date.day = 0;/*Impossible date*/
483 alarm_date.month= 0;
484 alarm_date.year=0;
485 return MfwResOk;
486 }
487 /*
488 +--------------------------------------------------------------------+
489 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
490 | STATE : code ROUTINE: mfw_td_get_alarm |
491 +--------------------------------------------------------------------+
492
493 PURPOSE : gets the current alarm settings
494
495 */
496 MfwRes mfw_td_get_alarm(T_MFW_TIME* time, T_MFW_DATE* date)
497 {
498 /*SPR 2639*/
499 #ifndef WIN32
500 int result;
501 // char debug[50]; // RAVI
502 T_MFW_ALARM_INFO alarmInfo;
503
504 /*SPR 2639 copy alarm info from FFS to memory*/
505 result =ffs_fread("/mmi/alarminfo",&alarmInfo, sizeof(T_MFW_ALARM_INFO));
506 memcpy( time,&alarmInfo.alarm_time, sizeof(T_MFW_TIME));
507 memcpy( date,&alarmInfo.alarm_date, sizeof(T_MFW_DATE));
508 /*if that failed set to default values*/
509 if (result<0)
510 {
511 TRACE_EVENT("Alarm files don't exist");
512 time->minute=0;
513 time->second=0;
514 time->hour=0;
515
516 date->day = 0;
517 date->month=0;
518 date->year =0;
519
520 }
521 #endif
522 TRACE_EVENT("mfw_td_get_alarm");
523 memcpy(&alarm_time, time, sizeof(T_MFW_TIME));
524 memcpy(&alarm_date, date, sizeof(T_MFW_DATE));
525 return MfwResOk;
526
527
528 }
529 /*
530 +--------------------------------------------------------------------+
531 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
532 | STATE : code ROUTINE: mfw_td_set_time_format |
533 +--------------------------------------------------------------------+
534
535 PURPOSE : sets the time format of the clock
536
537 */
538 MfwRes mfw_td_set_time_format(T_MFW_TIME_FORMAT format)
539 {
540 int result;
541
542 TRACE_EVENT("mfw_td_time_format");
543 /*SPR 2639*/
544 #ifndef WIN32
545 result = rtc_set_time_format(format);
546 if (result == 0)
547 return MfwResOk;
548 TRACE_EVENT_P1("RTC driver Error:%d", result);
549 return MfwResErr;
550 #else
551 return MfwResOk;
552 #endif
553 }
554 /*
555 +--------------------------------------------------------------------+
556 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
557 | STATE : code ROUTINE: mfw_td_set_time_format |
558 +--------------------------------------------------------------------+
559
560 PURPOSE : sets the time format of the clock
561
562 */
563 void mfw_td_exit()
564 {
565 TRACE_FUNCTION("mfw_td_exit()");
566
567 /*
568 * remove prim handler
569 */
570 aci_delete(pSlot);
571 timDelete(timer_handle); /*SPR 2639, delete time handle*/
572
573 }
574 /***************************Private methods****************************************
575 **/
576 /*
577 +--------------------------------------------------------------------+
578 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
579 | STATE : code ROUTINE: dates_match |
580 +--------------------------------------------------------------------+
581
582 PURPOSE : returns TRUE if the two dates passed match
583
584 */
585 BOOL dates_match(T_MFW_DATE* date1, T_MFW_DATE* date2)
586 {
587 if (date1->year == date2->year)
588 if (date1->month == date2->month)
589 if (date1->day == date2->day)
590 return TRUE;
591 return FALSE;
592 }
593 /*
594 +--------------------------------------------------------------------+
595 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
596 | STATE : code ROUTINE: mfw_td_convert_to_24_hour |
597 +--------------------------------------------------------------------+
598
599 PURPOSE : converts a time to 24-hour format
600
601 */
602 UBYTE mfw_td_convert_to_24_hour(T_MFW_TIME* time)
603 {
604 if (time->format == MFW_TIME_FORMAT_24HOUR)
605 {
606 return time->hour;
607 }
608 /*SPR 2639, improved function*/
609 else
610 { /*if after noon*/
611 if (time->PM_flag == TRUE)
612 {
613 return (time->hour + 12);
614 }
615 else
616 { /*if midnight*/
617 if (time->hour == 12)
618 return 0;
619 else
620 return time->hour;
621 }
622 }
623 }
624 /*
625 +--------------------------------------------------------------------+
626 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
627 | STATE : code ROUTINE: times_match |
628 +--------------------------------------------------------------------+
629
630 PURPOSE : returns TRUE if time data strcutures passed match
631
632 */
633 BOOL times_match(T_MFW_TIME* time1, T_MFW_TIME* time2)
634 {
635 if (time1->minute == time2->minute)
636 {
637 if ( mfw_td_convert_to_24_hour(time1) == mfw_td_convert_to_24_hour(time2))
638 return TRUE;
639 }
640 return FALSE;
641
642 }
643
644 /*
645 +--------------------------------------------------------------------+
646 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
647 | STATE : code ROUTINE: mfw_td_signal |
648 +--------------------------------------------------------------------+
649
650 PURPOSE : called to pass event to MMI layer
651
652 */
653 void mfw_td_signal (MfwEvt event, void *para)
654 {
655 UBYTE temp = dspl_Enable(0);
656
657
658 if (mfwSignallingMethod EQ 0)
659 {
660 if (mfwFocus)
661 if (mfw_td_sign_exec(mfwFocus,event,para))
662 {
663 dspl_Enable(temp);
664 return;
665 }
666 if (mfwRoot)
667 mfw_td_sign_exec(mfwRoot,event,para);
668 }
669 else
670 {
671 MfwHdr * h = 0;
672
673 /*
674 * Focus set, then start here
675 */
676 if (mfwFocus)
677 h = mfwFocus;
678 /*
679 * Focus not set, then start root
680 */
681 if (!h)
682 h = mfwRoot;
683
684 /*
685 * No elements available, return
686 */
687
688 while (h)
689
690
691 {
692 /*
693 * Signal consumed, then return
694 */
695 if (mfw_td_sign_exec (h, event, para))
696 {
697 dspl_Enable(temp);
698 return;
699 }
700
701 /*
702 * All windows tried inclusive root
703 */
704 if (h == mfwRoot)
705 {
706 dspl_Enable(temp);
707 return;
708 }
709
710 /*
711 * get parent window
712 */
713 h = mfwParent(mfwParent(h));
714 if(h)
715 h = ((MfwWin * )(h->data))->elems;
716 }
717 mfw_td_sign_exec (mfwRoot, event, para);
718 }
719 dspl_Enable(temp);
720 return;
721 }
722 /*
723 +--------------------------------------------------------------------+
724 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
725 | STATE : code ROUTINE: mfw_td_sign_exec |
726 +--------------------------------------------------------------------+
727
728 PURPOSE : Used by mfw_td_signal() to pass event to MMI layer
729
730 */
731 int mfw_td_sign_exec (MfwHdr *cur_elem, MfwEvt event, T_MFW_TD_PARA *para)
732 {
733
734
735 while (cur_elem)
736 {
737
738
739
740 if (cur_elem->type == MfwTypTd)
741 {
742
743 T_MFW_TD *td_data;
744 td_data = (T_MFW_TD *) cur_elem->data;
745
746
747 if (td_data->emask & event)
748 {
749 td_data->event = event;
750
751 // Jan 06,2004 REF: CRR 27859 xkundadu
752 // Description: Clock: Alarm does not go off even if timer times out.
753 // Solution: Assign para to NULL, instead of *para = NULL which is not correct.
754
755 // para = NULL; /*we're not passing any data to MMI*/ // RAVI
756
757 if (td_data->handler)
758 {
759 // PATCH LE 06.06.00
760 // store current mfw elem
761 current_mfw_elem = cur_elem;
762 // END PATCH LE 06.06.00
763 if ((*(td_data->handler))(td_data->event,
764 (void *) &td_data->para))
765 return TRUE;
766 }
767 }
768 }
769 cur_elem = cur_elem->next;
770 }
771
772 return FALSE;
773
774 }
775
776 /*
777 +--------------------------------------------------------------------+
778 | PROJECT : MMI-Framework (8417) MODULE : MFW_TD |
779 | STATE : code ROUTINE : td_delete |
780 +--------------------------------------------------------------------+
781
782 PURPOSE : delete TD event handler
783
784 */
785
786 MfwRes mfw_td_delete (MfwHnd h)
787 {
788 TRACE_FUNCTION("mfw_td_delete()");
789
790
791 if (!h || !((MfwHdr *) h)->data)
792 return MfwResIllHnd;
793
794 if (!mfwRemove((MfwHdr *) h))
795 return MfwResIllHnd;
796
797 mfwFree((U8 *) ((MfwHdr *) h)->data,sizeof(T_MFW_TD));
798 mfwFree((U8 *) h,sizeof(MfwHdr));
799
800 return MfwResOk;
801 }
802 /*
803 +--------------------------------------------------------------------+
804 | PROJECT : MMI-Framework (8417) MODULE : MFW_TD |
805 | STATE : code ROUTINE : tdCommand |
806 +--------------------------------------------------------------------+
807
808 PURPOSE : handle mfw windows command
809
810 */
811
812 static int tdCommand (U32 cmd, void *h)
813 {
814 switch (cmd)
815 {
816 case MfwCmdDelete: /* delete me */
817 if (!h)
818 return 0;
819 mfw_td_delete(h);
820 return 1;
821 default:
822 break;
823 }
824
825 return 0;
826 }
827
828 /*
829 +--------------------------------------------------------------------+
830 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
831 | STATE : code ROUTINE: mfw_td_response_cb |
832 +--------------------------------------------------------------------+
833
834 PURPOSE : Response Callback Handler.
835
836 */
837
838 GLOBAL BOOL mfw_td_response_cb (ULONG opc, void * data)
839 {
840 TRACE_FUNCTION ("mfw_td_response_cb");
841
842
843 return FALSE; /* not processed by extension */
844 }
845
846 /*SPR 2639, removed alarm callback and added timer callback*/
847 /*
848 +--------------------------------------------------------------------+
849 | PROJECT: MMI-Framework (8417) MODULE: MFW_TD |
850 | STATE : code ROUTINE: mfw_timer_cb |
851 +--------------------------------------------------------------------+
852
853 PURPOSE : timer callback, called every minute to check alarm
854 */
855
856 int mfw_timer_cb(MfwEvt e, MfwTim *t)
857 { // char debug[60]; // RAVI
858 TRACE_EVENT("mfw_timer_cb()");
859
860 #ifndef WIN32
861 rtc_get_time_date(&current_date,&current_time);
862
863 timStart(timer_handle);/*restart timer */
864 /***************************Go-lite Optimization changes Start***********************/
865 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
866 TRACE_EVENT_P3("current date:%d/%d/%d",current_date.day, current_date.month, current_date.year);
867 TRACE_EVENT_P2("current time:%d/%d",current_time.hour, current_time.minute);
868 TRACE_EVENT_P2("format:%d,PM flag:%d",current_time.format, current_time.PM_flag);
869 TRACE_EVENT_P3("alarm date:%d/%d/%d",alarm_date.day, alarm_date.month, alarm_date.year);
870 TRACE_EVENT_P2("alarm time:%d/%d",alarm_time.hour, alarm_time.minute);
871 TRACE_EVENT_P2("format:%d,PM flag:%d",alarm_time.format, alarm_time.PM_flag);
872 /***************************Go-lite Optimization changes end***********************/
873 /*if alarm is set*/
874 if (alarm_date.day != NULL)
875 { if (dates_match(&current_date, &alarm_date))
876 { if (times_match(&current_time, &alarm_time))
877 {
878 mfw_td_signal(MFW_TD_ALARM, NULL);
879 mfw_td_cancel_alarm();
880
881 }
882 else
883 TRACE_EVENT("times don't match");
884 }
885 else
886 TRACE_EVENT("dates don't match");
887 }
888 #endif
889 return 1;
890 }