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