ToDoList.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:265k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * ToDoList.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements To Do List application.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  * removed!
  164.  * removed!
  165.  * removed!
  166.  *
  167.  * removed!
  168.  * removed!
  169.  * removed!
  170.  *
  171.  * removed!
  172.  * removed!
  173.  * removed!
  174.  *
  175.  * removed!
  176.  * removed!
  177.  * removed!
  178.  *
  179.  * removed!
  180.  * removed!
  181.  * removed!
  182.  *
  183.  * removed!
  184.  * removed!
  185.  * removed!
  186.  *
  187.  * removed!
  188.  * removed!
  189.  * removed!
  190.  *
  191.  * removed!
  192.  * removed!
  193.  * removed!
  194.  *
  195.  * removed!
  196.  * removed!
  197.  * removed!
  198.  *
  199.  * removed!
  200.  * removed!
  201.  * removed!
  202.  *
  203.  * removed!
  204.  * removed!
  205.  * removed!
  206.  *
  207.  * removed!
  208.  * removed!
  209.  * removed!
  210.  *
  211.  * removed!
  212.  * removed!
  213.  * removed!
  214.  *
  215.  * removed!
  216.  * removed!
  217.  * removed!
  218.  *
  219.  * removed!
  220.  * removed!
  221.  * removed!
  222.  *
  223.  * removed!
  224.  * removed!
  225.  * removed!
  226.  *
  227.  * removed!
  228.  * removed!
  229.  * removed!
  230.  *
  231.  * removed!
  232.  * removed!
  233.  * removed!
  234.  *
  235.  * removed!
  236.  * removed!
  237.  * removed!
  238.  *
  239.  * removed!
  240.  * removed!
  241.  * removed!
  242.  *
  243.  * removed!
  244.  * removed!
  245.  * removed!
  246.  *
  247.  * removed!
  248.  * removed!
  249.  * removed!
  250.  *
  251.  * removed!
  252.  * removed!
  253.  * removed!
  254.  *
  255.  * removed!
  256.  * removed!
  257.  * removed!
  258.  *
  259.  * removed!
  260.  * removed!
  261.  * removed!
  262.  *
  263.  * removed!
  264.  * removed!
  265.  * removed!
  266.  *
  267.  * removed!
  268.  * removed!
  269.  * removed!
  270.  *
  271.  * removed!
  272.  * removed!
  273.  * removed!
  274.  *
  275.  * removed!
  276.  * removed!
  277.  * removed!
  278.  *
  279.  * removed!
  280.  * removed!
  281.  * removed!
  282.  *
  283.  * removed!
  284.  * removed!
  285.  * removed!
  286.  *
  287.  * removed!
  288.  * removed!
  289.  * removed!
  290.  *
  291.  * removed!
  292.  * removed!
  293.  * removed!
  294.  *
  295.  * removed!
  296.  * removed!
  297.  * removed!
  298.  *
  299.  * removed!
  300.  * removed!
  301.  * removed!
  302.  *
  303.  * removed!
  304.  * removed!
  305.  * removed!
  306.  *
  307.  * removed!
  308.  * removed!
  309.  * removed!
  310.  *
  311.  * removed!
  312.  * removed!
  313.  * removed!
  314.  *
  315.  * removed!
  316.  * removed!
  317.  * removed!
  318.  *
  319.  * removed!
  320.  * removed!
  321.  * removed!
  322.  *
  323.  * removed!
  324.  * removed!
  325.  * removed!
  326.  *
  327.  * removed!
  328.  * removed!
  329.  * removed!
  330.  *
  331.  * removed!
  332.  * removed!
  333.  * removed!
  334.  *
  335.  * removed!
  336.  * removed!
  337.  * removed!
  338.  *
  339.  * removed!
  340.  * removed!
  341.  * removed!
  342.  *
  343.  * removed!
  344.  * removed!
  345.  * removed!
  346.  *
  347.  * removed!
  348.  * removed!
  349.  * removed!
  350.  *
  351.  * removed!
  352.  * removed!
  353.  * removed!
  354.  *
  355.  * removed!
  356.  * removed!
  357.  * removed!
  358.  *
  359.  * removed!
  360.  * removed!
  361.  * removed!
  362.  *
  363.  * removed!
  364.  * removed!
  365.  * removed!
  366.  *
  367.  * removed!
  368.  * removed!
  369.  * removed!
  370.  *
  371.  * removed!
  372.  * removed!
  373.  * removed!
  374.  *
  375.  * removed!
  376.  * removed!
  377.  * removed!
  378.  *
  379.  * removed!
  380.  * removed!
  381.  * removed!
  382.  *
  383.  * removed!
  384.  * removed!
  385.  * removed!
  386.  *
  387.  * removed!
  388.  * removed!
  389.  * removed!
  390.  *
  391.  * removed!
  392.  * removed!
  393.  * removed!
  394.  *
  395.  * removed!
  396.  * removed!
  397.  * removed!
  398.  *
  399.  * removed!
  400.  * removed!
  401.  * removed!
  402.  *
  403.  * removed!
  404.  * removed!
  405.  * removed!
  406.  *
  407.  * removed!
  408.  * removed!
  409.  * removed!
  410.  *
  411.  * removed!
  412.  * removed!
  413.  * removed!
  414.  *
  415.  *------------------------------------------------------------------------------
  416.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  417.  *============================================================================
  418.  ****************************************************************************/
  419. /**
  420.  * Copyright Notice
  421.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  422.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  423.  *  (It is illegal to remove this copyright notice from this software or any
  424.  *  portion of it)
  425.  */
  426. /**************************************************************
  427.    FILENAME : ToDoList.c
  428.    PURPOSE     : To Do List Application
  429.    REMARKS     : nil
  430.    AUTHOR      : Arvind
  431.    DATE     : 29th Oct, 2003
  432. **************************************************************/
  433. #ifndef _MMI_TODOLIST_C
  434. #define _MMI_TODOLIST_C
  435. #include "MMI_features.h"
  436. #ifdef __MMI_TODOLIST__
  437. /*  Include: MMI header file */
  438. #include "StdC.h"
  439. #include "L4Dr.h"
  440. #include "L4Dr1.h"
  441. #include "GlobalConstants.h"
  442. #include "DebugInitDef.h"
  443. #include "CustMenuRes.h"
  444. #include "CustDataRes.h"
  445. #include "ProtocolEvents.h"
  446. #include "EventsGprot.h"
  447. #include "TimerEvents.h"
  448. #include "GlobalDefs.h"
  449. #include "HistoryGprot.h"
  450. #include "wgui_categories.h"
  451. #include "wgui_categories_inputs.h"
  452. #include "wgui_categories_popup.h"
  453. #include "CommonScreens.h"
  454. #include "mainmenudef.h"
  455. #include "DateTimeGprot.h"
  456. #include "AlarmFrameworkProt.h"
  457. #include "ToDoListDef.h"
  458. #include "ToDoListEnum.h"
  459. #include "NVRAMType.h"
  460. #include "NVRAMProt.h"
  461. #include "NVRAMEnum.h"
  462. #include "Nvram_enums.h"
  463. #include "NVRAMHwMapFile.h"
  464. #include "Organizerdef.h"
  465. #include "SubLCDHistoryGprot.h"
  466. #include "AlarmGprot.h"
  467. #include "gpioInc.h"
  468. #include "ProfileGprots.h"
  469. #include "KeyBrd.h"
  470. #include "WrapperGprot.h"
  471. #include "vCalendar.h"
  472. #include "vObjects.h"
  473. #include "vCalendar.h"
  474. #include "SimDetectionGexdcl.h"
  475. #include "SimDetectionGprot.h"
  476. #include "app_datetime.h"
  477. #if defined (__MMI_CLNDR_ICON_SUPPORT__) || defined (__MMI_BIRTHDAY_REMINDER__)
  478. #include "CalendarDef.h"
  479. #endif 
  480. #ifdef __MMI_BIRTHDAY_REMINDER__
  481. #include "SMSapi.h"
  482. #include "PhoneBookGprot.h"
  483. #include "ScrMemMgrGprot.h"
  484. #include "CallManagementGprot.h"
  485. #include "wapadp.h"
  486. #endif 
  487. #ifdef __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__
  488. #include "CalendarProt.h"
  489. #endif /* __MMI_CLNDR_WEEKLY_VIEW_SUPPORT__ */ 
  490. #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  491. #include "JMMSGprot.h"
  492. #endif 
  493. #ifdef __J2ME__
  494. #include "j2me_custom_option.h"
  495. #if defined(SUPPORT_JSR_75_PIM)
  496. #include "app_datetime.h"
  497. #include "ToDoListDB.h"
  498. #endif
  499. #endif
  500. /* SyncML */
  501. #ifdef __SYNCML_SUPPORT__
  502. #include "SyncMLDef.h"
  503. #include "SyncMLGProt.h"
  504. #include "FileSystemDef.h"
  505. #endif /* __SYNCML_SUPPORT__ */ 
  506. /*  Include: PS header file */
  507. /* ... Add More PS header */
  508. /* 
  509.  * Define
  510.  */
  511. /* 
  512.  * Typedef 
  513.  */
  514. tdl_context_struct g_tdl_cntx;
  515. /* 
  516.  * Local Variable
  517.  */
  518. // buffer used in inline editors */
  519. /* 
  520.  * Local Function
  521.  */
  522. /* 
  523.  * Global Variable
  524.  */
  525. extern U8 gAlmDayOfWeek[];
  526. S8 *gAlmOnOffStringforTDL[NUM_STATE_FOR_TDL];  /* array to store on/off state of an alarm */
  527. extern U8 gAlmDaysStates[];
  528. extern wgui_inline_item wgui_inline_items[];
  529. /* Add yearly for Anniversary */
  530. const U8 g_tdl_freq_set[TODO_FREQ_NUM + 1] =
  531.     {ALM_FREQ_ONCE, ALM_FREQ_EVERYDAY, ALM_FREQ_DAYS, ALM_FREQ_WEEKLY, ALM_FREQ_MONTHLY, ALM_FREQ_YEARLY};
  532. S8 gnoteString[MAX_TODO_LIST_NOTE];
  533. U16 gTDLicon[NUM_OF_TDL];
  534. #ifdef __MMI_ADVANCED_TODO__
  535. S8 glocationString[MAX_TODO_LIST_NOTE];
  536. S8 *gTdlPriorityString[NUM_OF_TASK_PRIORITY];   /* array to store on/off state of an alarm */
  537. #endif /* __MMI_ADVANCED_TODO__ */ 
  538. /* 
  539.  * Global Function
  540.  */
  541. /*****************************************************************************
  542.  * FUNCTION
  543.  *  InitToDoListApp
  544.  * DESCRIPTION
  545.  *  Set highlight handlers and retrieve data from NVRAM.
  546.  *  Register key handlers.
  547.  * PARAMETERS
  548.  *  void
  549.  * RETURNS
  550.  *  void
  551.  *****************************************************************************/
  552. void InitToDoListApp(void)
  553. {
  554.     /*----------------------------------------------------------------*/
  555.     /* Local Variables                                                */
  556.     /*----------------------------------------------------------------*/
  557.     /*----------------------------------------------------------------*/
  558.     /* Code Body                                                      */
  559.     /*----------------------------------------------------------------*/
  560.     SetHiliteHandler(ORGANIZER_TODOLIST_MENU, HighlightTDLMenu);
  561.     SetHiliteHandler(MITEM_TODO_LIST_VIEW, HighlightTdlView);
  562.     SetHiliteHandler(MITEM_TODO_LIST_ADD, HighlightTdlAdd);
  563.     SetHiliteHandler(MITEM_TODO_LIST_EDIT, HighlightTdlEdit);
  564.     SetHiliteHandler(MITEM_TODO_LIST_DELETE, HighlightTdlDelete);
  565.     SetHiliteHandler(MITEM_TODO_LIST_DELETE_ALL, HighlightTdlDeleteAll);
  566.     SetHiliteHandler(MITEM_TODO_LIST_SAVE, mmi_tdl_highlight_hdlr_note_option_save);
  567.     SetHiliteHandler(MITEM_TODO_LIST_USE_TEMPLATE, mmi_tdl_highlight_hdlr_note_option_template);
  568.     SetHiliteHandler(MITEM_TODO_LIST_BOPOMOFO, mmi_tdl_highlight_hdlr_note_option_input_method);
  569.     
  570. #if defined(SUPPORT_JSR_75_PIM)
  571.     mmi_tdl_evtdb_handler_init();
  572. #endif
  573. #ifdef __MMI_ADVANCED_TODO__
  574.     SetHiliteHandler(MITEM_TODO_LIST_MEETING, mmi_tdl_highlight_meeting);
  575.     SetHiliteHandler(MITEM_TODO_LIST_COURSE, mmi_tdl_highlight_course);
  576.     SetHiliteHandler(MITEM_TODO_LIST_DATE, mmi_tdl_highlight_date);
  577.     SetHiliteHandler(MITEM_TODO_LIST_CALL, mmi_tdl_highlight_call);
  578.     SetHiliteHandler(MITEM_TODO_LIST_ANNIVERSARY, mmi_tdl_highlight_anniversary);
  579.     SetHiliteHandler(MITEM_TODO_LIST_REMINDER, mmi_tdl_highlight_reminder);
  580. #endif /* __MMI_ADVANCED_TODO__ */ 
  581. #ifdef __MMI_BIRTHDAY_REMINDER__
  582.     SetHiliteHandler(MITEM_BIRTHDAY_OPTION_MAKE_CALL, mmi_birthday_highlight_make_call);
  583.     SetHiliteHandler(MITEM_BIRTHDAY_OPTION_SEND_SMS, mmi_birthday_highlight_send_sms);
  584. #ifdef MMS_SUPPORT
  585.     SetHiliteHandler(MITEM_BIRTHDAY_OPTION_SEND_MMS, mmi_birthday_highlight_send_mms);
  586. #endif /*# MMS_SUPPORT */
  587. #endif /* __MMI_BIRTHDAY_REMINDER__ */ 
  588.     TDLReadFromNvram();
  589. }
  590. /*****************************************************************************
  591.  * FUNCTION
  592.  *  TDLExpiryHandler
  593.  * DESCRIPTION
  594.  *  CallBack handler to execute todolist expiry.
  595.  * PARAMETERS
  596.  *  index           [IN]        
  597.  *  period          [?]         
  598.  *  power_on        [IN]        
  599.  *  BOOL(?)         [IN]        Power status
  600.  *  U8(?)           [IN]        Index of alarm item
  601.  * RETURNS
  602.  *  void
  603.  *****************************************************************************/
  604. U8 TDLExpiryHandler(U8 index, U16 *period, BOOL power_on)
  605. {
  606.     /*----------------------------------------------------------------*/
  607.     /* Local Variables                                                */
  608.     /*----------------------------------------------------------------*/
  609.     /*----------------------------------------------------------------*/
  610.     /* Code Body                                                      */
  611.     /*----------------------------------------------------------------*/
  612.     if (power_on)
  613.     {
  614.         EntryTDLReminder();
  615.         *period = ALM_DEFAULT_EXPIRY_PERIOD;
  616.         return ALM_HAS_IND;
  617.     }
  618.     else
  619.     {
  620.         EntryTDLReminder();
  621.         *period = ALM_WITHOUD_EXPIRY_PERIOD;
  622.         return ALM_HAS_NO_IND;
  623.     }
  624. }
  625. /*****************************************************************************
  626.  * FUNCTION
  627.  *  TDLExpiryTimeCBH
  628.  * DESCRIPTION
  629.  *  Callback handler to get information of todolist expiry setting.
  630.  * PARAMETERS
  631.  *  index           [IN]            
  632.  *  alarmTime       [?]             
  633.  *  Freq            [?]             
  634.  *  WeekDays        [?]             
  635.  *  MYTIME(?)       [IN/OUT]        Expiry time set by user
  636.  *  U8(?)           [IN/OUT]        Expiry days of week
  637.  * RETURNS
  638.  *  void
  639.  *****************************************************************************/
  640. void TDLExpiryTimeCBH(U8 index, MYTIME *alarmTime, U8 *Freq, U8 *WeekDays, MYTIME *preReminder)
  641. {
  642.     /*----------------------------------------------------------------*/
  643.     /* Local Variables                                                */
  644.     /*----------------------------------------------------------------*/
  645.     /*----------------------------------------------------------------*/
  646.     /* Code Body                                                      */
  647.     /*----------------------------------------------------------------*/
  648. #ifdef __MMI_ADVANCED_TODO__
  649.     mmi_tdl_compute_reminder_time(&g_tdl_cntx.TaskList[index], preReminder);
  650. #endif 
  651.     *alarmTime = g_tdl_cntx.TaskList[index].StartTime;
  652.     *Freq = g_tdl_freq_set[g_tdl_cntx.TaskList[index].Repeat];
  653.     *WeekDays = g_tdl_cntx.TaskList[index].Days;
  654. }
  655. /*****************************************************************************
  656.  * FUNCTION
  657.  *  TDLReInitQueueCBH
  658.  * DESCRIPTION
  659.  *  Reinit todolist to alarm queue
  660.  * PARAMETERS
  661.  *  void
  662.  * RETURNS
  663.  *  void
  664.  *****************************************************************************/
  665. void TDLReInitQueueCBH(void)
  666. {
  667.     /*----------------------------------------------------------------*/
  668.     /* Local Variables                                                */
  669.     /*----------------------------------------------------------------*/
  670.     MYTIME currTime;
  671. #ifdef __MMI_ADVANCED_TODO__
  672.     MYTIME alarmTime, incTime;
  673. #endif 
  674.     U8 i;
  675.     /*----------------------------------------------------------------*/
  676.     /* Code Body                                                      */
  677.     /*----------------------------------------------------------------*/
  678.     DTGetRTCTime(&currTime);
  679.     for (i = 0; i < NUM_OF_TDL; i++)
  680.     {
  681.         if (g_tdl_cntx.TaskList[i].Present == 1 && g_tdl_cntx.TaskList[i].Alarm >= TODO_LIST_ALARM_ON)
  682.         {
  683.             if (g_tdl_freq_set[g_tdl_cntx.TaskList[i].Repeat] == ALM_FREQ_ONCE)
  684.             {
  685.             #ifdef __MMI_ADVANCED_TODO__
  686.                 memset(&incTime, 0, sizeof(MYTIME));
  687.                 memcpy(&alarmTime, &g_tdl_cntx.TaskList[i].StartTime, sizeof(MYTIME));
  688.                 mmi_tdl_compute_reminder_time(&g_tdl_cntx.TaskList[i], &incTime);
  689.             #ifdef MMI_ON_WIN32
  690.                 DecrementTime(alarmTime, incTime, & alarmTime);
  691.             #else
  692.                 applib_dt_decrease_time(
  693.                     (applib_time_struct*) & alarmTime,
  694.                     (applib_time_struct*) & incTime,
  695.                     (applib_time_struct*) & alarmTime);
  696.             #endif            
  697.                 if (CompareTime(alarmTime, currTime, NULL) == TIME_GREATER)
  698.             #else /* __MMI_ADVANCED_TODO__ */ 
  699.                 if (CompareTime(g_tdl_cntx.TaskList[i].StartTime, currTime, NULL) == TIME_GREATER)
  700.             #endif /* __MMI_ADVANCED_TODO__ */ 
  701.                 {
  702.                     AlmInsertIntoQueue((U8) (i + ALM_TDL_START), FALSE);
  703.                 }
  704.             }
  705.             else
  706.             {
  707.                 AlmInsertIntoQueue((U8) (i + ALM_TDL_START), FALSE);
  708.             }
  709.         }
  710.     }
  711. }
  712. /*****************************************************************************
  713.  * FUNCTION
  714.  *  TDLFCBInit
  715.  * DESCRIPTION
  716.  *  Set callback function needed by alarm framework
  717.  * PARAMETERS
  718.  *  void
  719.  * RETURNS
  720.  *  void
  721.  *****************************************************************************/
  722. void TDLFCBInit(void)
  723. {
  724.     /*----------------------------------------------------------------*/
  725.     /* Local Variables                                                */
  726.     /*----------------------------------------------------------------*/
  727.     /*----------------------------------------------------------------*/
  728.     /* Code Body                                                      */
  729.     /*----------------------------------------------------------------*/
  730.     mmi_alm_set_start_index(ALM_TYPE_TDL, ALM_TDL_START);
  731.     AlmSetExpiryTimeCB(ALM_TYPE_TDL, TDLExpiryTimeCBH);
  732.     AlmSetExpiryHandlerCB(ALM_TYPE_TDL, TDLExpiryHandler);
  733.     AlmSetInitHandlerCB(ALM_TYPE_TDL, InitToDoListApp, TDLReInitQueueCBH);
  734.     AlmSetStopAlarmCB(ALM_TYPE_TDL, TDLExitReminderScreen);
  735. }
  736. /*****************************************************************************
  737.  * FUNCTION
  738.  *  HighlightTDLMenu
  739.  * DESCRIPTION
  740.  *  Highlight handler of To Do List menu item.
  741.  *  Register key handlers.
  742.  * PARAMETERS
  743.  *  void
  744.  * RETURNS
  745.  *  void
  746.  *****************************************************************************/
  747. void HighlightTDLMenu(void)
  748. {
  749.     /*----------------------------------------------------------------*/
  750.     /* Local Variables                                                */
  751.     /*----------------------------------------------------------------*/
  752.     /*----------------------------------------------------------------*/
  753.     /* Code Body                                                      */
  754.     /*----------------------------------------------------------------*/
  755.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  756.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  757.     SetLeftSoftkeyFunction(TDLShowAllList, KEY_EVENT_UP);
  758.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  759.     SetKeyHandler(TDLShowAllList, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  760.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  761. }
  762. /*****************************************************************************
  763.  * FUNCTION
  764.  *  DeInitToDoListApp
  765.  * DESCRIPTION
  766.  *  Deinitialize To Do List application
  767.  * PARAMETERS
  768.  *  void
  769.  * RETURNS
  770.  *  void
  771.  *****************************************************************************/
  772. void DeInitToDoListApp(void)
  773. {
  774.     /*----------------------------------------------------------------*/
  775.     /* Local Variables                                                */
  776.     /*----------------------------------------------------------------*/
  777.     /*----------------------------------------------------------------*/
  778.     /* Code Body                                                      */
  779.     /*----------------------------------------------------------------*/
  780. }
  781. /*****************************************************************************
  782.  * FUNCTION
  783.  *  HighlightTDLTaskList
  784.  * DESCRIPTION
  785.  *  Highlight handler of to do list task list, store the index of selected task.
  786.  * PARAMETERS
  787.  *  nIndex      [IN]        Index of selected task.
  788.  * RETURNS
  789.  *  void
  790.  *****************************************************************************/
  791. void HighlightTDLTaskList(S32 nIndex)
  792. {
  793.     /*----------------------------------------------------------------*/
  794.     /* Local Variables                                                */
  795.     /*----------------------------------------------------------------*/
  796.     /*----------------------------------------------------------------*/
  797.     /* Code Body                                                      */
  798.     /*----------------------------------------------------------------*/
  799. #ifndef __MMI_BIRTHDAY_REMINDER__
  800.     g_tdl_cntx.CurrSelectedTask = (U8) nIndex;
  801. #else /* __MMI_BIRTHDAY_REMINDER__ */ 
  802.     if (nIndex < g_tdl_cntx.TotalListedTask)
  803.     {
  804.         g_tdl_cntx.CurrSelectedTask = (U8) nIndex;
  805.         SetLeftSoftkeyFunction(EntryTDLTaskListOption, KEY_EVENT_UP);
  806. if (g_tdl_cntx.IsCalledByCalender >= MMI_TRUE)
  807. {
  808. SetKeyHandler(mmi_tdl_get_next_day_redraw, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  809. SetKeyHandler(mmi_tdl_get_previous_day_redraw, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  810. }
  811. else
  812. {
  813. SetKeyHandler(mmi_tdl_task_list_goback, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  814. SetKeyHandler(EntryTDLTaskListOption, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  815. }
  816.         /* Himanshu Fix MAUI_00228900 START */
  817.     #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  818.         if (mmi_jmms_is_from_jmms() > 0)
  819.         {
  820.             ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  821.             SetLeftSoftkeyFunction(mmi_jmms_insert_vcal_tdl, KEY_EVENT_UP);
  822.             SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  823.         }
  824.     #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */ 
  825.         /* Himanshu Fix MAUI_00228900 END */
  826.     }
  827.     else if (nIndex >= g_tdl_cntx.TotalListedTask &&
  828.              nIndex < mmi_clndr_get_daily_birthday_amount(g_tdl_cntx.ClndrDate.nDay) + g_tdl_cntx.TotalListedTask)
  829.     {
  830.         g_tdl_cntx.CurrHighlightBRIndex = g_tdl_cntx.PBIndexList[nIndex - g_tdl_cntx.TotalListedTask];
  831.         
  832.         if (mmi_bootup_is_sim_valid())
  833.         {
  834.             SetLeftSoftkeyFunction(mmi_entry_birthday_option_screen, KEY_EVENT_UP);
  835.             SetKeyHandler(mmi_entry_birthday_option_screen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  836.             /* Himanshu Fix MAUI_00228900 START */
  837.         #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  838.             if (mmi_jmms_is_from_jmms() > 0)
  839.             {
  840.                 ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  841.                 SetLeftSoftkeyFunction(mmi_jmms_insert_vcal_tdl, KEY_EVENT_UP);
  842.                 SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  843.             }
  844.         #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */ 
  845.             /* Himanshu Fix MAUI_00228900 END */
  846.         }
  847.         else
  848.         {
  849.             ChangeLeftSoftkey(0, 0);
  850.             SetLeftSoftkeyFunction(NULL, KEY_EVENT_UP);
  851.             SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  852.         }
  853.             
  854.     }
  855. #endif /* __MMI_BIRTHDAY_REMINDER__ */ 
  856. }
  857. /*****************************************************************************
  858.  * FUNCTION
  859.  *  TDLGetTotalItem
  860.  * DESCRIPTION
  861.  *  Get number of present task
  862.  * PARAMETERS
  863.  *  void
  864.  * RETURNS
  865.  *  number of task
  866.  *****************************************************************************/
  867. U8 TDLGetTotalItem(void)
  868. {
  869.     /*----------------------------------------------------------------*/
  870.     /* Local Variables                                                */
  871.     /*----------------------------------------------------------------*/
  872.     S32 i;
  873.     U8 TotalItem = 0;
  874.     /*----------------------------------------------------------------*/
  875.     /* Code Body                                                      */
  876.     /*----------------------------------------------------------------*/
  877.     for (i = 0; i < NUM_OF_TDL; i++)
  878.         if (g_tdl_cntx.TaskList[i].Present == 1)
  879.         {
  880.             TotalItem++;
  881.         }
  882.     return TotalItem;
  883. }
  884. /*****************************************************************************
  885.  * FUNCTION
  886.  *  mmi_tdl_task_list_goback
  887.  * DESCRIPTION
  888.  *  
  889.  * PARAMETERS
  890.  *  void
  891.  * RETURNS
  892.  *  void
  893.  *****************************************************************************/
  894. void mmi_tdl_task_list_goback(void)
  895. {
  896.     /*----------------------------------------------------------------*/
  897.     /* Local Variables                                                */
  898.     /*----------------------------------------------------------------*/
  899.     /*----------------------------------------------------------------*/
  900.     /* Code Body                                                      */
  901.     /*----------------------------------------------------------------*/
  902.     if (IsScreenPresent(SCR_TDL_TASK_LIST))
  903.     {
  904.         GoBackToHistory(SCR_TDL_TASK_LIST);
  905.     }
  906. #ifdef __MMI_ADVANCED_TODO__
  907.     else if (IsScreenPresent(SCR_ID_CLNDR_SCREEN))
  908.     {
  909.         GoBackToHistory(SCR_ID_CLNDR_SCREEN);
  910.     }
  911. #endif /* __MMI_ADVANCED_TODO__ */ 
  912.     else
  913.     {
  914.         GoBackHistory();
  915.     }
  916. }
  917. #ifdef __MMI_ADVANCED_TODO__
  918. /*****************************************************************************
  919.  * FUNCTION
  920.  *  EntryTDLTaskList
  921.  * DESCRIPTION
  922.  *  Entry function of To Do List application
  923.  * PARAMETERS
  924.  *  void
  925.  * RETURNS
  926.  *  void
  927.  *****************************************************************************/
  928. void EntryTDLTaskList(void)
  929. {
  930.     /*----------------------------------------------------------------*/
  931.     /* Local Variables                                                */
  932.     /*----------------------------------------------------------------*/
  933.     U8 *guiBuffer;
  934.     S32 TotalItem = 0;
  935.     GetAsyncItemFuncPtr createMenuPtr;
  936.     S8 datestring[CLNDR_DATE_STRING_LENGTH + 1];    /* yyyy/mm/dd */
  937.     S8 title[(CLNDR_DATE_STRING_LENGTH + 1) * ENCODING_LENGTH];
  938. #ifdef __MMI_BIRTHDAY_REMINDER__
  939.     U16 bm;
  940. #endif     
  941.     /*----------------------------------------------------------------*/
  942.     /* Code Body                                                      */
  943.     /*----------------------------------------------------------------*/
  944.     EntryNewScreen(SCR_TDL_TASK_LIST, ExitTDLTaskList, EntryTDLTaskList, NULL);
  945.     
  946. #ifdef __MMI_ADVANCED_TODO__
  947.     if (g_tdl_cntx.DateUpdate == 1)
  948.     {
  949.         if (IsScreenPresent(SCR_TDL_TASK_LIST))  
  950.         {
  951.             DeleteNScrId(SCR_TDL_TASK_LIST);
  952.         }
  953.     }
  954. #endif /* __MMI_ADVANCED_TODO__ */ 
  955.     memset(title, 0, (CLNDR_DATE_STRING_LENGTH + 1) * ENCODING_LENGTH);
  956. #ifdef __MMI_BIRTHDAY_REMINDER__
  957.     /* Since PBIndexList is screen based memory, it need to be searched for every time entering TDL daily view */
  958.     if (g_tdl_cntx.IsCalledByCalender == CLNDR_MONTHLY_VIEW)
  959.     {
  960.         mmi_tdl_construct_birthday_memory();
  961.         mmi_clndr_set_birthday_table(g_tdl_cntx.ClndrDate.nYear, g_tdl_cntx.ClndrDate.nMonth);
  962.         bm = mmi_clndr_get_daily_birthday_amount(g_tdl_cntx.ClndrDate.nDay);
  963.         memset(g_tdl_cntx.PBIndexList, 0, sizeof(U16) * bm);
  964.         mmi_clndr_get_daily_birthday_info(
  965.         g_tdl_cntx.ClndrDate.nYear,
  966.         g_tdl_cntx.ClndrDate.nMonth,
  967.         g_tdl_cntx.ClndrDate.nDay,
  968.         bm,
  969.         g_tdl_cntx.PBIndexList);
  970.     }
  971. #endif 
  972.     if (g_tdl_cntx.IsListModified == TRUE)
  973.     {
  974.     #ifdef __MMI_CALENDAR_V2__
  975.         if (g_tdl_cntx.IsCalledByCalender == CLNDR_MONTHLY_VIEW)        /* Match the Date and list them */
  976.         {
  977.             TDLMakeListOfSelectedDate(CLNDR_MONTHLY_VIEW);
  978.         }
  979.         else if (g_tdl_cntx.IsCalledByCalender == CLNDR_WEEKLY_VIEW)
  980.         {
  981.             mmi_tdl_get_period_task();
  982.         }
  983.     #else /* __MMI_CALENDAR_V2__ */ 
  984.         if (g_tdl_cntx.IsCalledByCalender >= MMI_TRUE)
  985.         {
  986.             TDLMakeListOfSelectedDate(MMI_TRUE);
  987.         }
  988.     #endif /* __MMI_CALENDAR_V2__ */ 
  989.         else    /* Set the Current Date and list the task in descending order. */
  990.         {
  991.             TDLMakeListOfAllTask();
  992.         }
  993.         g_tdl_cntx.IsListModified = FALSE;
  994.     }
  995. #ifdef __MMI_BIRTHDAY_REMINDER__
  996.     if (g_tdl_cntx.IsCalledByCalender == CLNDR_MONTHLY_VIEW)
  997.     {
  998.         TotalItem = g_tdl_cntx.TotalListedTask + mmi_clndr_get_daily_birthday_amount(g_tdl_cntx.ClndrDate.nDay);
  999.     }
  1000.     else
  1001.     {
  1002.         TotalItem = g_tdl_cntx.TotalListedTask;
  1003.     }
  1004. #else 
  1005.     TotalItem = g_tdl_cntx.TotalListedTask;
  1006. #endif 
  1007.     guiBuffer = GetCurrGuiBuffer(SCR_TDL_TASK_LIST);
  1008.     SetParentHandler(0);
  1009.     if (g_tdl_cntx.IsCalledByCalender >= MMI_TRUE)
  1010.     {
  1011.         mmi_tdl_get_date_string(
  1012.             g_tdl_cntx.ClndrDate.nYear,
  1013.             g_tdl_cntx.ClndrDate.nMonth,
  1014.             g_tdl_cntx.ClndrDate.nDay,
  1015.             datestring);
  1016.         createMenuPtr = mmi_tdl_get_daily_async_items;
  1017.         AnsiiToUnicodeString(title, datestring);
  1018.         wgui_set_touch_title_bar_buttons();
  1019.     #ifdef __MMI_TOUCH_SCREEN__
  1020.             register_touch_button_handlers(mmi_tdl_get_previous_day_redraw, NULL, mmi_tdl_get_next_day_redraw, NULL);
  1021.     #endif        
  1022.     }
  1023.     else
  1024.     {
  1025.         createMenuPtr = mmi_tdl_get_all_async_items;
  1026.         pfnUnicodeStrcpy(title, GetString(STR_TODO_LIST_CAP_TASK_LIST));
  1027.     }
  1028.     RegisterHighlightHandler(HighlightTDLTaskList);
  1029.     if (TotalItem == 0) /* display <Empty> */
  1030.     {
  1031.         ShowCategory85Screen(
  1032.             (U8*) title,
  1033.             0,
  1034.             STR_GLOBAL_OPTIONS,
  1035.             0,
  1036.             STR_GLOBAL_BACK,
  1037.             0,
  1038.             TotalItem,
  1039.             createMenuPtr,
  1040.             NULL,
  1041.             0,
  1042.             IMG_GLOBAL_OK,
  1043.             IMG_GLOBAL_OK,
  1044.             guiBuffer);
  1045.         g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_ADD;
  1046.     #ifdef __MMI_ADVANCED_TODO__
  1047.         SetLeftSoftkeyFunction(mmi_tdl_entry_select_task_type, KEY_EVENT_UP);
  1048.         SetKeyHandler(mmi_tdl_entry_select_task_type, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1049.     #else /* __MMI_ADVANCED_TODO__ */ 
  1050.         SetLeftSoftkeyFunction(TdlExecEdit, KEY_EVENT_UP);
  1051.         SetKeyHandler(TdlExecEdit, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1052.     #endif /* __MMI_ADVANCED_TODO__ */ 
  1053.         /* if task full, disable LSK */
  1054.         if (g_tdl_cntx.IsCalledByCalender)
  1055.         {
  1056.             if (TDLGetTotalItem() == NUM_OF_TDL)
  1057.             {
  1058.                 ChangeLeftSoftkey(0, 0);
  1059.                 SetLeftSoftkeyFunction(NULL, KEY_EVENT_UP);
  1060.                 SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1061.             }
  1062.         }
  1063.     #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  1064.         if (mmi_jmms_is_from_jmms() > 0)
  1065.         {
  1066.             ChangeLeftSoftkey(0, 0);
  1067.             SetLeftSoftkeyFunction(NULL, KEY_EVENT_UP);
  1068.             SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1069.         }
  1070.     #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */ 
  1071.     }
  1072.     else    /* display list of task */
  1073.     {
  1074.         ShowCategory85Screen(
  1075.             (U8*) title,
  1076.             0,
  1077.             STR_GLOBAL_OPTIONS,
  1078.             0,
  1079.             STR_GLOBAL_BACK,
  1080.             0,
  1081.             TotalItem,
  1082.             createMenuPtr,
  1083.             NULL,
  1084.             0,
  1085.         IMG_TODO_LIST_ICON_REMINDER,
  1086.         IMG_TODO_LIST_ICON_ALARM,
  1087.             guiBuffer);
  1088.         //SetLeftSoftkeyFunction(EntryTDLTaskListOption, KEY_EVENT_UP);
  1089.         //SetKeyHandler(EntryTDLTaskListOption, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1090.     #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  1091.         if (mmi_jmms_is_from_jmms() > 0)
  1092.         {
  1093.             ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  1094.             SetLeftSoftkeyFunction(mmi_jmms_insert_vcal_tdl, KEY_EVENT_UP);
  1095.             SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1096.         }
  1097.     #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */ 
  1098.     }
  1099.     /* Register function for right soft key */
  1100.     SetRightSoftkeyFunction(mmi_tdl_task_list_goback, KEY_EVENT_UP);
  1101.     SetKeyHandler(mmi_tdl_task_list_goback, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1102.     if (g_tdl_cntx.IsCalledByCalender >= MMI_TRUE)
  1103.     {
  1104.         SetKeyHandler(mmi_tdl_get_next_day_redraw, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1105.         SetKeyHandler(mmi_tdl_get_previous_day_redraw, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1106.     }
  1107. }
  1108. /*****************************************************************************
  1109.  * FUNCTION
  1110.  *  mmi_tdl_get_all_async_items
  1111.  * DESCRIPTION
  1112.  *  
  1113.  * PARAMETERS
  1114.  *  start_index     [IN]        
  1115.  *  menuData        [?]         
  1116.  *  num_item        [IN]        
  1117.  * RETURNS
  1118.  *  
  1119.  *****************************************************************************/
  1120. S32 mmi_tdl_get_all_async_items(S32 start_index, gui_iconlist_menu_item *menuData, S32 num_item)
  1121. {
  1122.     /*----------------------------------------------------------------*/
  1123.     /* Local Variables                                                */
  1124.     /*----------------------------------------------------------------*/
  1125.     S8 dateStr[CLNDR_DATE_STRING_LENGTH + 1];   /* YYYY/MM/DD */
  1126.     MYTIME todoTime;
  1127.     U32 i, count = 0;
  1128.     /*----------------------------------------------------------------*/
  1129.     /* Code Body                                                      */
  1130.     /*----------------------------------------------------------------*/
  1131.     if (start_index < g_tdl_cntx.TotalListedTask)
  1132.     {
  1133.         /* construct task list */
  1134.         for (i = start_index; count < num_item && i < g_tdl_cntx.TotalListedTask; i++, count++)
  1135.         {
  1136.             memcpy(&todoTime, &(g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]].StartTime), sizeof(MYTIME));
  1137.             mmi_tdl_get_date_string(todoTime.nYear, todoTime.nMonth, todoTime.nDay, dateStr);
  1138.             AnsiiToUnicodeString((S8*) menuData[count].item_list[0], dateStr);
  1139.             pfnUnicodeStrcpy(
  1140.                 (S8*) menuData[count].item_list[1],
  1141.                 (S8*) g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]].Note);
  1142.             /* Alarm */
  1143.             if (g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]].Alarm >= TODO_LIST_ALARM_ON)
  1144.             {
  1145.                     menuData[count].image_list[0] = (PU8) GetImage(IMG_TODO_LIST_ICON_ALARM);
  1146.             }
  1147.             else
  1148.             {
  1149.                 menuData[count].image_list[0] = 0;
  1150.             }
  1151.             /* Type */
  1152.             menuData[count].image_list[1] =
  1153.                 (PU8)
  1154.                 GetImage((U16) (g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]].Type + IMG_TODO_LIST_ICON_REMINDER));
  1155.         }
  1156.     }
  1157.     return num_item;
  1158. }
  1159. /*****************************************************************************
  1160.  * FUNCTION
  1161.  *  mmi_tdl_get_daily_async_items
  1162.  * DESCRIPTION
  1163.  *  
  1164.  * PARAMETERS
  1165.  *  start_index     [IN]        
  1166.  *  menuData        [?]         
  1167.  *  num_item        [IN]        
  1168.  * RETURNS
  1169.  *  
  1170.  *****************************************************************************/
  1171. S32 mmi_tdl_get_daily_async_items(S32 start_index, gui_iconlist_menu_item *menuData, S32 num_item)
  1172. {
  1173.     /*----------------------------------------------------------------*/
  1174.     /* Local Variables                                                */
  1175.     /*----------------------------------------------------------------*/
  1176.     S8 timeStr[CLNDR_TIME_STRING_LENGTH * 2 + 1 + 1];   /* MM:SS-MM:SS */
  1177.     U32 i, count = 0;
  1178. #ifdef __MMI_BIRTHDAY_REMINDER__
  1179.     U8 pbNumber[MAX_PB_NUMBER_LENGTH + 1], pbName[(MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH];    /* used to get phone number. */
  1180. #endif 
  1181.     /*----------------------------------------------------------------*/
  1182.     /* Code Body                                                      */
  1183.     /*----------------------------------------------------------------*/
  1184.     if (start_index < g_tdl_cntx.TotalListedTask)
  1185.     {
  1186.         /* construct task list */
  1187.         for (i = start_index; count < num_item && i < g_tdl_cntx.TotalListedTask; i++, count++)
  1188.         {
  1189.             mmi_tdl_get_time_string(
  1190.                 &(g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]]),
  1191.                 &(g_tdl_cntx.ClndrDate),
  1192.                 timeStr);
  1193.             AnsiiToUnicodeString((S8*) menuData[count].item_list[0], timeStr);
  1194.             pfnUnicodeStrcpy(
  1195.                 (S8*) menuData[count].item_list[1],
  1196.                 (S8*) g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]].Note);
  1197.             /* Alarm */
  1198.             if (g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]].Alarm >= TODO_LIST_ALARM_ON)
  1199.             {
  1200.                 menuData[count].image_list[0] = (PU8) GetImage(IMG_TODO_LIST_ICON_ALARM);
  1201.             }
  1202.             else
  1203.             {
  1204.                 menuData[count].image_list[0] = 0;
  1205.             }
  1206.             /* Type */
  1207.             menuData[count].image_list[1] =
  1208.                 (PU8)
  1209.                 GetImage((U16) (g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]].Type + IMG_TODO_LIST_ICON_REMINDER));
  1210.         }
  1211.     }
  1212. #ifdef __MMI_BIRTHDAY_REMINDER__
  1213.     if (count < num_item)   /* display birthday */
  1214.     {
  1215.         memset(timeStr, 0, CLNDR_TIME_STRING_LENGTH + 1);   /* 00:00n */
  1216.         sprintf(timeStr, "%02d:%02d", 0, 0);
  1217. i = count + start_index - g_tdl_cntx.TotalListedTask;
  1218.         for (; count < num_item && i < mmi_clndr_get_daily_birthday_amount(g_tdl_cntx.ClndrDate.nDay);
  1219.              i++, count++)
  1220.         {
  1221.             AnsiiToUnicodeString((S8*) menuData[count].item_list[0], timeStr);
  1222.             
  1223.             memset(pbNumber, 0, MAX_PB_NUMBER_LENGTH + 1);
  1224.             memset(pbName, 0, (MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH);
  1225.         
  1226.             mmi_phb_get_name_number(g_tdl_cntx.PBIndexList[i], 
  1227.                 pbName,
  1228.                 pbNumber);
  1229.             pfnUnicodeStrcpy((S8*)menuData[count].item_list[1], (S8*)pbName);            
  1230.             
  1231.             if (pfnUnicodeStrlen((S8*) menuData[count].item_list[1]) == 0)
  1232.             {
  1233.                 memcpy(menuData[count].item_list[1], GetString(STR_GLOBAL_EMPTY), (pfnUnicodeStrlen(GetString(STR_GLOBAL_EMPTY)) + 1) * ENCODING_LENGTH);                
  1234.             }
  1235.             menuData[count].image_list[0] = 0;
  1236.             menuData[count].image_list[1] = (PU8) GetImage(IMG_TODO_LIST_BIRTHDAY_REMINDER);            
  1237.         }
  1238.     }
  1239. #endif /* __MMI_BIRTHDAY_REMINDER__ */ 
  1240.     return count;
  1241. }
  1242. /*****************************************************************************
  1243.  * FUNCTION
  1244.  *  mmi_tdl_get_time_string
  1245.  * DESCRIPTION
  1246.  *  
  1247.  * PARAMETERS
  1248.  *  task            [?]         
  1249.  *  year            [IN]        
  1250.  *  month           [IN]        
  1251.  *  day             [IN]        
  1252.  *  timeString      [?]         
  1253.  * RETURNS
  1254.  *  void
  1255.  *****************************************************************************/
  1256. void mmi_tdl_get_time_string(ToDoListNode *task, MYTIME* seletedDate, S8 *timeString)
  1257. {
  1258.     /*----------------------------------------------------------------*/
  1259.     /* Local Variables                                                */
  1260.     /*----------------------------------------------------------------*/
  1261.     S8 *timeString2;
  1262.     U8 IsStartDay = 0;
  1263.     MYTIME startTime;
  1264.     MYTIME endTime;
  1265.     /*----------------------------------------------------------------*/
  1266.     /* Code Body                                                      */
  1267.     /*----------------------------------------------------------------*/
  1268.     memset(timeString, 0, CLNDR_TIME_STRING_LENGTH * 2 + 1 + 1);
  1269.     memcpy(&startTime, &(task->StartTime), sizeof(MYTIME));
  1270.     memcpy(&endTime, &(task->EndTime), sizeof(MYTIME));
  1271.     if (startTime.nYear == seletedDate->nYear && startTime.nMonth == seletedDate->nMonth && startTime.nDay == seletedDate->nDay)
  1272.     {
  1273.         IsStartDay = MMI_TRUE;
  1274.     }
  1275.     
  1276.     /* start time */
  1277.     if (task->Type == TDL_TASK_REMINDER && g_tdl_freq_set[task->Repeat] == ALM_FREQ_ONCE && IsStartDay == MMI_FALSE)
  1278.     {
  1279.         sprintf((S8*) timeString, "%02d:%02d", 0, 0);
  1280.     }
  1281.     else
  1282.     {
  1283.         sprintf((S8*) timeString, "%02d:%02d", startTime.nHour, startTime.nMin);
  1284.     }
  1285.     switch (task->Type)
  1286.     {
  1287.         case TDL_TASK_MEETING:
  1288.         case TDL_TASK_COURSE:
  1289.         case TDL_TASK_REMINDER:
  1290.             /* time separator */
  1291.             timeString[CLNDR_TIME_STRING_LENGTH] = '-';
  1292.             /* end time */
  1293.             timeString2 = timeString + CLNDR_TIME_STRING_LENGTH + 1;
  1294.             if (task->Type == TDL_TASK_REMINDER && g_tdl_freq_set[task->Repeat] == ALM_FREQ_ONCE)
  1295.             {               
  1296.                 if (endTime.nYear != seletedDate->nYear ||
  1297.                     endTime.nMonth != seletedDate->nMonth ||
  1298.                     endTime.nDay != seletedDate->nDay)
  1299.                 {
  1300.                     sprintf((S8*) timeString2, "%02d:%02d", 23, 59);
  1301.                     return;
  1302.                 }
  1303.             }
  1304.             sprintf((S8*) timeString2, "%02d:%02d", endTime.nHour, endTime.nMin);            
  1305.             break;
  1306.         default:
  1307.             break;
  1308.     }
  1309. }
  1310. /*****************************************************************************
  1311.  * FUNCTION
  1312.  *  mmi_tdl_get_date_string
  1313.  * DESCRIPTION
  1314.  *  
  1315.  * PARAMETERS
  1316.  *  year            [IN]        
  1317.  *  month           [IN]        
  1318.  *  day             [IN]        
  1319.  *  timeString      [?]         
  1320.  * RETURNS
  1321.  *  void
  1322.  *****************************************************************************/
  1323. void mmi_tdl_get_date_string(U16 year, U8 month, U8 day, S8 *timeString)
  1324. {
  1325.     /*----------------------------------------------------------------*/
  1326.     /* Local Variables                                                */
  1327.     /*----------------------------------------------------------------*/
  1328.     /*----------------------------------------------------------------*/
  1329.     /* Code Body                                                      */
  1330.     /*----------------------------------------------------------------*/
  1331.     memset(timeString, 0, CLNDR_DATE_STRING_LENGTH + 1);
  1332.     sprintf(timeString, "%04d/%02d/%02d", year, month, day);
  1333. }
  1334. /*****************************************************************************
  1335.  * FUNCTION
  1336.  *  mmi_tdl_get_next_day_redraw
  1337.  * DESCRIPTION
  1338.  *  
  1339.  * PARAMETERS
  1340.  *  void
  1341.  * RETURNS
  1342.  *  void
  1343.  *****************************************************************************/
  1344. void mmi_tdl_get_next_day_redraw(void)
  1345. {
  1346.     /*----------------------------------------------------------------*/
  1347.     /* Local Variables                                                */
  1348.     /*----------------------------------------------------------------*/
  1349.     MYTIME incTime;
  1350.     S8 datestring[CLNDR_DATE_STRING_LENGTH + 1];    /* yyyy/mm/dd */
  1351.     /*----------------------------------------------------------------*/
  1352.     /* Code Body                                                      */
  1353.     /*----------------------------------------------------------------*/
  1354.     /* Check date */
  1355.     if (g_tdl_cntx.ClndrDate.nYear == CLNDR_END_YEAR && g_tdl_cntx.ClndrDate.nMonth == 12 && g_tdl_cntx.ClndrDate.nDay == 31)
  1356.     {
  1357.         DisplayPopup(
  1358.         (U8*) GetString(STR_CLNDR_OUT_OF_CALENDAR),
  1359.         IMG_GLOBAL_WARNING,
  1360.         0,
  1361.         UI_POPUP_NOTIFYDURATION_TIME,
  1362.         (U8) WARNING_TONE);
  1363.         
  1364.         return;
  1365.     }
  1366.         
  1367.     /* Update Date */
  1368.     memset(&incTime, 0, sizeof(MYTIME));
  1369.     incTime.nDay = 1;
  1370.     IncrementTime(g_tdl_cntx.ClndrDate, incTime, &(g_tdl_cntx.ClndrDate));
  1371.     /* Month is changed, set birthday information. */
  1372.     if (g_tdl_cntx.ClndrDate.nDay== 1)
  1373.     {
  1374.         mmi_clndr_set_birthday_table(g_tdl_cntx.ClndrDate.nYear, g_tdl_cntx.ClndrDate.nMonth);
  1375.     }    
  1376.     /* Update Title */
  1377.     mmi_tdl_get_date_string(
  1378.         g_tdl_cntx.ClndrDate.nYear,
  1379.         g_tdl_cntx.ClndrDate.nMonth,
  1380.         g_tdl_cntx.ClndrDate.nDay,
  1381.         datestring);
  1382.     /* TDL Updation flag */
  1383.     g_tdl_cntx.IsListModified = TRUE;
  1384.     g_tdl_cntx.DateUpdate = 1;
  1385.     EntryTDLTaskList();
  1386.     g_tdl_cntx.DateUpdate = 0;
  1387. }
  1388. /*****************************************************************************
  1389.  * FUNCTION
  1390.  *  mmi_tdl_get_previous_day_redraw
  1391.  * DESCRIPTION
  1392.  *  
  1393.  * PARAMETERS
  1394.  *  void
  1395.  * RETURNS
  1396.  *  void
  1397.  *****************************************************************************/
  1398. void mmi_tdl_get_previous_day_redraw(void)
  1399. {
  1400.     /*----------------------------------------------------------------*/
  1401.     /* Local Variables                                                */
  1402.     /*----------------------------------------------------------------*/
  1403.     MYTIME incTime;
  1404.     S8 datestring[CLNDR_DATE_STRING_LENGTH + 1];    /* yyyy/mm/dd */
  1405.     /*----------------------------------------------------------------*/
  1406.     /* Code Body                                                      */
  1407.     /*----------------------------------------------------------------*/
  1408.     /* Check date */
  1409.     if (g_tdl_cntx.ClndrDate.nYear == CLNDR_START_YEAR && g_tdl_cntx.ClndrDate.nMonth == 1 && g_tdl_cntx.ClndrDate.nDay == 1)
  1410.     {
  1411.         DisplayPopup(
  1412.         (U8*) GetString(STR_CLNDR_OUT_OF_CALENDAR),
  1413.         IMG_GLOBAL_WARNING,
  1414.         0,
  1415.         UI_POPUP_NOTIFYDURATION_TIME,
  1416.         (U8) WARNING_TONE);
  1417.         
  1418.         return;
  1419.     }
  1420.     
  1421.     /* Update Date */
  1422.     memset(&incTime, 0, sizeof(MYTIME));
  1423.     incTime.nDay = 1;
  1424.     DecrementTime(g_tdl_cntx.ClndrDate, incTime, &(g_tdl_cntx.ClndrDate));
  1425.     /* Month is changed, set birthday information. */
  1426. #ifdef MMI_ON_WIN32
  1427.     if (g_tdl_cntx.ClndrDate.nDay== LastDayOfMonth(g_tdl_cntx.ClndrDate.nMonth, g_tdl_cntx.ClndrDate.nYear))
  1428.     {
  1429.         mmi_clndr_set_birthday_table(g_tdl_cntx.ClndrDate.nYear, g_tdl_cntx.ClndrDate.nMonth);
  1430.     }  
  1431. #else
  1432.     if (g_tdl_cntx.ClndrDate.nDay== applib_dt_last_day_of_mon(g_tdl_cntx.ClndrDate.nMonth, g_tdl_cntx.ClndrDate.nYear))
  1433.     {
  1434.         mmi_clndr_set_birthday_table(g_tdl_cntx.ClndrDate.nYear, g_tdl_cntx.ClndrDate.nMonth);
  1435.     }    
  1436. #endif    
  1437.     /* Update Title */
  1438.     mmi_tdl_get_date_string(
  1439.         g_tdl_cntx.ClndrDate.nYear,
  1440.         g_tdl_cntx.ClndrDate.nMonth,
  1441.         g_tdl_cntx.ClndrDate.nDay,
  1442.         datestring);
  1443.     /* TDL Updation flag */
  1444.     g_tdl_cntx.IsListModified = TRUE;
  1445.     g_tdl_cntx.DateUpdate = 1;
  1446.     EntryTDLTaskList();
  1447.     g_tdl_cntx.DateUpdate = 0;
  1448. }
  1449. #else /* __MMI_ADVANCED_TODO__ */ 
  1450. /*****************************************************************************
  1451.  * FUNCTION
  1452.  *  EntryTDLTaskList
  1453.  * DESCRIPTION
  1454.  *  Entry function of To Do List application
  1455.  * PARAMETERS
  1456.  *  void
  1457.  * RETURNS
  1458.  *  void
  1459.  *****************************************************************************/
  1460. void EntryTDLTaskList(void)
  1461. {
  1462.     /*----------------------------------------------------------------*/
  1463.     /* Local Variables                                                */
  1464.     /*----------------------------------------------------------------*/
  1465.     U8 *guiBuffer;
  1466.     S32 i;
  1467.     S32 TotalItem = 0;
  1468.     U16 nEmptyId = STR_TODO_LIST_EMPTY;
  1469.     /*----------------------------------------------------------------*/
  1470.     /* Code Body                                                      */
  1471.     /*----------------------------------------------------------------*/
  1472. #ifdef __SYNCML_SUPPORT__
  1473.     /* popup "please wait" when syncML is executing */
  1474.     if (mmi_syncml_is_tdl_sync_now())
  1475.     {
  1476.         DisplayPopup(
  1477.             (U8*) GetString(STR_ID_SYNC_PLEASE_WAIT),
  1478.             IMG_GLOBAL_WARNING,
  1479.             1,
  1480.             UI_POPUP_NOTIFYDURATION_TIME,
  1481.             (U8) WARNING_TONE);
  1482.             return;
  1483.     }
  1484. #endif
  1485.     EntryNewScreen(SCR_TDL_TASK_LIST, ExitTDLTaskList, EntryTDLTaskList, NULL);
  1486.     if (g_tdl_cntx.IsListModified == TRUE)
  1487.     {
  1488.     #ifdef __MMI_CALENDAR_V2__
  1489.         if (g_tdl_cntx.IsCalledByCalender == CLNDR_MONTHLY_VIEW)        /* Match the Date and list them */
  1490.         {
  1491.             TDLMakeListOfSelectedDate(CLNDR_MONTHLY_VIEW);
  1492.         }
  1493.         else if (g_tdl_cntx.IsCalledByCalender == CLNDR_WEEKLY_VIEW)
  1494.         {
  1495.             mmi_tdl_get_period_task();
  1496.         }
  1497.     #else /* __MMI_CALENDAR_V2__ */ 
  1498.         if (g_tdl_cntx.IsCalledByCalender == MMI_TRUE)  /* Match the Date and list them */
  1499.         {
  1500.             TDLMakeListOfSelectedDate(MMI_TRUE);
  1501.         }
  1502.     #endif /* __MMI_CALENDAR_V2__ */ 
  1503.         else    /* Set the Current Date and list the task in descending order. */
  1504.         {
  1505.             TDLMakeListOfAllTask();
  1506.         }
  1507.         g_tdl_cntx.IsListModified = FALSE;
  1508.     }
  1509.     TotalItem = g_tdl_cntx.TotalListedTask;
  1510.     guiBuffer = GetCurrGuiBuffer(SCR_TDL_TASK_LIST);
  1511.     SetParentHandler(0);
  1512.     RegisterHighlightHandler(HighlightTDLTaskList);
  1513.     if (TotalItem == 0) /* display <Empty> */
  1514.     {
  1515.         ShowCategory1Screen(
  1516.             STR_TODO_LIST_CAP_TASK_LIST,
  1517.             GetRootTitleIcon(ORGANIZER_TODOLIST_MENU),
  1518.             STR_TODO_LIST_ADD,
  1519.             0,
  1520.             STR_GLOBAL_BACK,
  1521.             0,
  1522.             1,
  1523.             &nEmptyId,
  1524.             0,
  1525.             guiBuffer);
  1526.         g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_ADD;
  1527.         SetLeftSoftkeyFunction(TdlExecEdit, KEY_EVENT_UP);
  1528.         SetKeyHandler(TdlExecEdit, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1529.         /* if task full, disable LSK */
  1530.         if (g_tdl_cntx.IsCalledByCalender)
  1531.         {
  1532.             if (TDLGetTotalItem() == NUM_OF_TDL)
  1533.             {
  1534.                 ChangeLeftSoftkey(0, 0);
  1535.                 SetLeftSoftkeyFunction(NULL, KEY_EVENT_UP);
  1536.                 SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1537.             }
  1538.         }
  1539.     #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  1540.         if (mmi_jmms_is_from_jmms() > 0)
  1541.         {
  1542.             ChangeLeftSoftkey(0, 0);
  1543.             SetLeftSoftkeyFunction(NULL, KEY_EVENT_UP);
  1544.             SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1545.         }
  1546.     #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */ 
  1547.     }
  1548.     else    /* display list of task */
  1549.     {
  1550.         /* construct task list */
  1551.         for (i = 0; i < g_tdl_cntx.TotalListedTask; i++)
  1552.         {
  1553.             pfnUnicodeStrcpy((S8*) subMenuDataPtrs[i], (S8*) g_tdl_cntx.TaskList[g_tdl_cntx.SortedList[i]].Note);
  1554.             gTDLicon[i] = IMG_TODO_ICON;
  1555.         }
  1556.         ShowCategory84Screen(
  1557.             STR_TODO_LIST_CAP_TASK_LIST,
  1558.             GetRootTitleIcon(ORGANIZER_TODOLIST_MENU),
  1559.             STR_GLOBAL_OPTIONS,
  1560.             IMG_GLOBAL_OPTIONS,
  1561.             STR_GLOBAL_BACK,
  1562.             IMG_GLOBAL_BACK,
  1563.             TotalItem,
  1564.             (U8 **) subMenuDataPtrs,
  1565.             (U16*) gTDLicon,
  1566.             0,
  1567.             0,
  1568.             guiBuffer);
  1569.         SetLeftSoftkeyFunction(EntryTDLTaskListOption, KEY_EVENT_UP);
  1570.         SetKeyHandler(EntryTDLTaskListOption, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1571.     #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  1572.         if (mmi_jmms_is_from_jmms() > 0)
  1573.         {
  1574.             ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  1575.             SetLeftSoftkeyFunction(mmi_jmms_insert_vcal_tdl, KEY_EVENT_UP);
  1576.             SetKeyHandler(NULL, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1577.         }
  1578.     #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */ 
  1579.     }
  1580.     /* Register function for right soft key */
  1581.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1582.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1583. }
  1584. #endif /* __MMI_ADVANCED_TODO__ */ 
  1585. /*****************************************************************************
  1586.  * FUNCTION
  1587.  *  ExitTDLTaskList
  1588.  * DESCRIPTION
  1589.  *  
  1590.  * PARAMETERS
  1591.  *  void
  1592.  * RETURNS
  1593.  *  void
  1594.  *****************************************************************************/
  1595. void ExitTDLTaskList(void)
  1596. {
  1597.     /*----------------------------------------------------------------*/
  1598.     /* Local Variables                                                */
  1599.     /*----------------------------------------------------------------*/
  1600.     /*----------------------------------------------------------------*/
  1601.     /* Code Body                                                      */
  1602.     /*----------------------------------------------------------------*/
  1603. #ifdef __MMI_ADVANCED_TODO__
  1604.     mmi_clndr_set_date(&g_tdl_cntx.ClndrDate);
  1605. #endif 
  1606. #ifdef __MMI_BIRTHDAY_REMINDER__
  1607.     mmi_tdl_destruct_birthday_memory();
  1608. #endif 
  1609. }
  1610. /*****************************************************************************
  1611.  * FUNCTION
  1612.  *  TdlExecView
  1613.  * DESCRIPTION
  1614.  *  Execute View option
  1615.  * PARAMETERS
  1616.  *  void
  1617.  * RETURNS
  1618.  *  void
  1619.  *****************************************************************************/
  1620. void TdlExecView(void)
  1621. {
  1622.     /*----------------------------------------------------------------*/
  1623.     /* Local Variables                                                */
  1624.     /*----------------------------------------------------------------*/
  1625.     /*----------------------------------------------------------------*/
  1626.     /* Code Body                                                      */
  1627.     /*----------------------------------------------------------------*/
  1628.     if (g_tdl_cntx.TotalListedTask != 0)
  1629.     {
  1630.         g_tdl_cntx.CurrTaskIndex = g_tdl_cntx.SortedList[g_tdl_cntx.CurrSelectedTask];
  1631.     }
  1632.     g_tdl_cntx.SelectedItemInView = 0;
  1633.     TDLInitInlineVariables();
  1634.     EntryTDLViewTask();
  1635. }
  1636. /*****************************************************************************
  1637.  * FUNCTION
  1638.  *  HighlightTdlView
  1639.  * DESCRIPTION
  1640.  *  Highlight handler of View option
  1641.  * PARAMETERS
  1642.  *  void
  1643.  * RETURNS
  1644.  *  void
  1645.  *****************************************************************************/
  1646. void HighlightTdlView(void)
  1647. {
  1648.     /*----------------------------------------------------------------*/
  1649.     /* Local Variables                                                */
  1650.     /*----------------------------------------------------------------*/
  1651.     /*----------------------------------------------------------------*/
  1652.     /* Code Body                                                      */
  1653.     /*----------------------------------------------------------------*/
  1654.     g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_VIEW;
  1655.     SetLeftSoftkeyFunction(TdlExecView, KEY_EVENT_UP);
  1656.     SetKeyHandler(TdlExecView, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1657. }
  1658. /*****************************************************************************
  1659.  * FUNCTION
  1660.  *  TdlExecEdit
  1661.  * DESCRIPTION
  1662.  *  Execute Edit option
  1663.  * PARAMETERS
  1664.  *  void
  1665.  * RETURNS
  1666.  *  void
  1667.  *****************************************************************************/
  1668. void TdlExecEdit(void)
  1669. {
  1670.     /*----------------------------------------------------------------*/
  1671.     /* Local Variables                                                */
  1672.     /*----------------------------------------------------------------*/
  1673.     /*----------------------------------------------------------------*/
  1674.     /* Code Body                                                      */
  1675.     /*----------------------------------------------------------------*/
  1676.     if (g_tdl_cntx.TotalListedTask != 0)
  1677.     {
  1678.         g_tdl_cntx.CurrTaskIndex = g_tdl_cntx.SortedList[g_tdl_cntx.CurrSelectedTask];
  1679.     }
  1680.     g_tdl_cntx.IsDOWSet = 0;
  1681.     g_tdl_cntx.SelectedItemInView = 0;
  1682.     TDLInitInlineVariables();
  1683.     EntryTDLEditTask();
  1684. }
  1685. /*****************************************************************************
  1686.  * FUNCTION
  1687.  *  TdlExecDelete
  1688.  * DESCRIPTION
  1689.  *  Execute Delete option
  1690.  * PARAMETERS
  1691.  *  void
  1692.  * RETURNS
  1693.  *  void
  1694.  *****************************************************************************/
  1695. void TdlExecDelete(void)
  1696. {
  1697.     /*----------------------------------------------------------------*/
  1698.     /* Local Variables                                                */
  1699.     /*----------------------------------------------------------------*/
  1700.     /*----------------------------------------------------------------*/
  1701.     /* Code Body                                                      */
  1702.     /*----------------------------------------------------------------*/
  1703.     if (g_tdl_cntx.TotalListedTask != 0)
  1704.     {
  1705.         g_tdl_cntx.CurrTaskIndex = g_tdl_cntx.SortedList[g_tdl_cntx.CurrSelectedTask];
  1706.     }
  1707.     EntryTDLDelete();
  1708. }
  1709. /*****************************************************************************
  1710.  * FUNCTION
  1711.  *  HighlightTdlEdit
  1712.  * DESCRIPTION
  1713.  *  Highlight handler of Edit option
  1714.  * PARAMETERS
  1715.  *  void
  1716.  * RETURNS
  1717.  *  void
  1718.  *****************************************************************************/
  1719. void HighlightTdlEdit(void)
  1720. {
  1721.     /*----------------------------------------------------------------*/
  1722.     /* Local Variables                                                */
  1723.     /*----------------------------------------------------------------*/
  1724.     /*----------------------------------------------------------------*/
  1725.     /* Code Body                                                      */
  1726.     /*----------------------------------------------------------------*/
  1727.     g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_EDIT;
  1728.     SetLeftSoftkeyFunction(TdlExecEdit, KEY_EVENT_UP);
  1729.     SetKeyHandler(TdlExecEdit, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1730. }
  1731. /*****************************************************************************
  1732.  * FUNCTION
  1733.  *  HighlightTdlAdd
  1734.  * DESCRIPTION
  1735.  *  Highlight handler of Add option
  1736.  * PARAMETERS
  1737.  *  void
  1738.  * RETURNS
  1739.  *  void
  1740.  *****************************************************************************/
  1741. void HighlightTdlAdd(void)
  1742. {
  1743.     /*----------------------------------------------------------------*/
  1744.     /* Local Variables                                                */
  1745.     /*----------------------------------------------------------------*/
  1746.     /*----------------------------------------------------------------*/
  1747.     /* Code Body                                                      */
  1748.     /*----------------------------------------------------------------*/
  1749.     g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_ADD;
  1750. #ifdef __MMI_ADVANCED_TODO__
  1751.     SetLeftSoftkeyFunction(mmi_tdl_entry_select_task_type, KEY_EVENT_UP);
  1752.     SetKeyHandler(mmi_tdl_entry_select_task_type, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1753. #else /* __MMI_ADVANCED_TODO__ */ 
  1754.     SetLeftSoftkeyFunction(TdlExecEdit, KEY_EVENT_UP);
  1755.     SetKeyHandler(TdlExecEdit, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1756. #endif /* __MMI_ADVANCED_TODO__ */ 
  1757. }
  1758. /*****************************************************************************
  1759.  * FUNCTION
  1760.  *  HighlightTdlDelete
  1761.  * DESCRIPTION
  1762.  *  Highlight handler of Delete option
  1763.  * PARAMETERS
  1764.  *  void
  1765.  * RETURNS
  1766.  *  void
  1767.  *****************************************************************************/
  1768. void HighlightTdlDelete(void)
  1769. {
  1770.     /*----------------------------------------------------------------*/
  1771.     /* Local Variables                                                */
  1772.     /*----------------------------------------------------------------*/
  1773.     /*----------------------------------------------------------------*/
  1774.     /* Code Body                                                      */
  1775.     /*----------------------------------------------------------------*/
  1776.     g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_DELETE;
  1777.     SetLeftSoftkeyFunction(TdlExecDelete, KEY_EVENT_UP);
  1778.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1779. }
  1780. /*****************************************************************************
  1781.  * FUNCTION
  1782.  *  HighlightTdlDeleteAll
  1783.  * DESCRIPTION
  1784.  *  Highlight handler of Delete All option
  1785.  * PARAMETERS
  1786.  *  void
  1787.  * RETURNS
  1788.  *  void
  1789.  *****************************************************************************/
  1790. void HighlightTdlDeleteAll(void)
  1791. {
  1792.     /*----------------------------------------------------------------*/
  1793.     /* Local Variables                                                */
  1794.     /*----------------------------------------------------------------*/
  1795.     /*----------------------------------------------------------------*/
  1796.     /* Code Body                                                      */
  1797.     /*----------------------------------------------------------------*/
  1798.     g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_DELETE_ALL;
  1799.     SetLeftSoftkeyFunction(EntryTDLDeleteAll, KEY_EVENT_UP);
  1800.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1801. }
  1802. /*****************************************************************************
  1803.  * FUNCTION
  1804.  *  EntryTDLTaskListOption
  1805.  * DESCRIPTION
  1806.  *  Show option list
  1807.  * PARAMETERS
  1808.  *  void
  1809.  * RETURNS
  1810.  *  void
  1811.  *****************************************************************************/
  1812. void EntryTDLTaskListOption(void)
  1813. {
  1814.     /*----------------------------------------------------------------*/
  1815.     /* Local Variables                                                */
  1816.     /*----------------------------------------------------------------*/
  1817.     U8 *guiBuffer;
  1818.     U16 nStrItemList[6];    /* Stores the strings id of submenus returned */
  1819.     U16 nNumofItem;         /* Stores no of children in the submenu */
  1820.     U16 MenuId;
  1821.     /*----------------------------------------------------------------*/
  1822.     /* Code Body                                                      */
  1823.     /*----------------------------------------------------------------*/
  1824.     EntryNewScreen(SCR_TDL_OPTION_LIST, NULL, EntryTDLTaskListOption, NULL);
  1825.     /* view, add, edit, delete, delete all */
  1826.     if (TDLGetTotalItem() < NUM_OF_TDL)
  1827.     {
  1828.         MenuId = MITEM_TODO_LIST_TASK_OPTION_1;
  1829.     }
  1830.     else    /* view, edit, delete, delete all */
  1831.     {
  1832.         MenuId = MITEM_TODO_LIST_TASK_OPTION_2;
  1833.     }
  1834.     nNumofItem = GetNumOfChild(MenuId);
  1835.     GetSequenceStringIds(MenuId, nStrItemList);
  1836.     SetParentHandler(MenuId);
  1837.     guiBuffer = GetCurrGuiBuffer(SCR_TDL_OPTION_LIST);
  1838.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1839. #if defined(__MMI_VCALENDAR__) && defined(MMI_ON_HARDWARE_P)
  1840.     if (mmi_bootup_is_sim_valid() == MMI_FALSE
  1841. #ifdef __FLIGHT_MODE_SUPPORT__
  1842.         || mmi_bootup_get_active_flight_mode() == 1
  1843. #endif 
  1844.         )   /* diamond, 2005/09/19 hide this item in flight mode */
  1845.         nNumofItem--;
  1846. #endif /* defined(__MMI_VCALENDAR__) && defined(MMI_ON_HARDWARE_P) */ 
  1847.     ShowCategory15Screen(
  1848.         STR_TODO_LIST_CAP_OPTION,
  1849.         GetRootTitleIcon(ORGANIZER_TODOLIST_MENU),
  1850.         STR_GLOBAL_OK,
  1851.         IMG_GLOBAL_OK,
  1852.         STR_GLOBAL_BACK,
  1853.         IMG_GLOBAL_BACK,
  1854.         nNumofItem,
  1855.         nStrItemList,
  1856.         (U16*) gIndexIconsImageList,
  1857.         LIST_MENU,
  1858.         0,
  1859.         guiBuffer);
  1860.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1861.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1862. }
  1863. /*****************************************************************************
  1864.  * FUNCTION
  1865.  *  HighlightTDLViewInlineItem
  1866.  * DESCRIPTION
  1867.  *  Highlight handler of items in View screen
  1868.  *  Register key handlers.
  1869.  * PARAMETERS
  1870.  *  index       [IN]        
  1871.  * RETURNS
  1872.  *  void
  1873.  *****************************************************************************/
  1874. void HighlightTDLViewInlineItem(S32 index)
  1875. {
  1876.     /*----------------------------------------------------------------*/
  1877.     /* Local Variables                                                */
  1878.     /*----------------------------------------------------------------*/
  1879.     /*----------------------------------------------------------------*/
  1880.     /* Code Body                                                      */
  1881.     /*----------------------------------------------------------------*/
  1882.     g_tdl_cntx.SelectedItemInView = (U8) index;
  1883.     ChangeLeftSoftkey(STR_TODO_LIST_LSK_EDIT, 0);
  1884.     SetLeftSoftkeyFunction(EditToDoListTask, KEY_EVENT_UP);
  1885. }
  1886. /*****************************************************************************
  1887.  * FUNCTION
  1888.  *  EntryTDLViewTask
  1889.  * DESCRIPTION
  1890.  *  Display task information using an inline editor screen.
  1891.  * PARAMETERS
  1892.  *  void
  1893.  * RETURNS
  1894.  *  void
  1895.  *****************************************************************************/
  1896. void EntryTDLViewTask(void)
  1897. {
  1898.     /*----------------------------------------------------------------*/
  1899.     /* Local Variables                                                */
  1900.     /*----------------------------------------------------------------*/
  1901.     U8 *guiBuffer;
  1902.     U8 *inputBuffer;
  1903.     U16 inputBufferSize;
  1904.     U8 inline_total;
  1905. #ifdef __MMI_ADVANCED_TODO__
  1906.     U16 ToDoList_View_icon_list[MAX_INLINE_ITEM_TODO_LIST];
  1907. #else /* __MMI_ADVANCED_TODO__ */ 
  1908.     U16 ToDoList_View_icon_list[MAX_INLINE_ITEM_TODO_LIST] = 
  1909.     {
  1910.         IMG_TODO_LIST_DATE, IMG_TODO_LIST_TIME, IMG_TODO_LIST_NOTE,
  1911.         0, IMG_TODO_LIST_ALARM, 0, IMG_TODO_LIST_REPEAT, 0, 0
  1912.     };
  1913. #endif /* __MMI_ADVANCED_TODO__ */ 
  1914.     /*----------------------------------------------------------------*/
  1915.     /* Code Body                                                      */
  1916.     /*----------------------------------------------------------------*/
  1917.     EntryNewScreen(SCR_TDL_TASK_VIEW, ExitTDLViewTask, NULL, NULL);
  1918.     InitializeCategory57Screen();
  1919.     guiBuffer = GetCurrGuiBuffer(SCR_TDL_TASK_VIEW);
  1920.     inputBuffer = GetCurrNInputBuffer(SCR_TDL_TASK_VIEW, &inputBufferSize);
  1921.     SetParentHandler(0);
  1922.     inline_total = TDLFillInlineStructForView();
  1923. #ifdef __MMI_ADVANCED_TODO__
  1924.     memset(&ToDoList_View_icon_list, 0, sizeof(U16) * MAX_INLINE_ITEM_TODO_LIST);
  1925.     mmi_tdl_set_inline_icon(ToDoList_View_icon_list, inline_total);
  1926. #endif /* __MMI_ADVANCED_TODO__ */ 
  1927.     RegisterHighlightHandler(HighlightTDLViewInlineItem);
  1928.     if (inputBuffer != NULL)
  1929.     {
  1930.         SetCategory57Data(wgui_inline_items, MAX_INLINE_ITEM_TODO_LIST, inputBuffer);
  1931.     }
  1932.     ShowCategory57Screen(
  1933.         STR_TODO_LIST_CAP_VIEW,
  1934.         GetRootTitleIcon(ORGANIZER_TODOLIST_MENU),
  1935.         STR_TODO_LIST_LSK_EDIT,
  1936.         IMG_GLOBAL_OK,
  1937.         STR_GLOBAL_BACK,
  1938.         IMG_GLOBAL_BACK,
  1939.         inline_total,
  1940.         ToDoList_View_icon_list,
  1941.         wgui_inline_items,
  1942.         0,
  1943.         guiBuffer);
  1944.     SetRightSoftkeyFunction(mmi_tdl_task_list_goback, KEY_EVENT_DOWN);
  1945. }
  1946. /*****************************************************************************
  1947.  * FUNCTION
  1948.  *  ExitTDLViewTask
  1949.  * DESCRIPTION
  1950.  *  Exit function of View screen.
  1951.  * PARAMETERS
  1952.  *  void
  1953.  * RETURNS
  1954.  *  void
  1955.  *****************************************************************************/
  1956. void ExitTDLViewTask(void)
  1957. {
  1958.     /*----------------------------------------------------------------*/
  1959.     /* Local Variables                                                */
  1960.     /*----------------------------------------------------------------*/
  1961.     history ScrDA;  /* Variable to hold the history data */
  1962.     S16 nHistory = 0;
  1963.     U16 size;
  1964.     /*----------------------------------------------------------------*/
  1965.     /* Code Body                                                      */
  1966.     /*----------------------------------------------------------------*/
  1967.     CloseCategory57Screen();
  1968.     ScrDA.scrnID = SCR_TDL_TASK_VIEW;
  1969.     ScrDA.entryFuncPtr = EntryTDLViewTask;
  1970.     pfnUnicodeStrcpy((S8*) ScrDA.inputBuffer, (S8*) & nHistory);
  1971.     GetCategoryHistory(ScrDA.guiBuffer);
  1972.     size = (U16) GetCategory57DataSize();
  1973.     GetCategory57Data((U8*) ScrDA.inputBuffer);
  1974.     AddNHistory(ScrDA, size);
  1975. }
  1976. /*****************************************************************************
  1977.  * FUNCTION
  1978.  *  EditToDoListTask
  1979.  * DESCRIPTION
  1980.  *  Edit to do list task from View screen
  1981.  * PARAMETERS
  1982.  *  void
  1983.  * RETURNS
  1984.  *  void
  1985.  *****************************************************************************/
  1986. void EditToDoListTask(void)
  1987. {
  1988.     /*----------------------------------------------------------------*/
  1989.     /* Local Variables                                                */
  1990.     /*----------------------------------------------------------------*/
  1991.     /*----------------------------------------------------------------*/
  1992.     /* Code Body                                                      */
  1993.     /*----------------------------------------------------------------*/
  1994.     g_tdl_cntx.CurrHiliteOption = TODO_LIST_TASK_OPTION_EDIT;
  1995.     EntryTDLEditTask();
  1996. }
  1997. /*****************************************************************************
  1998.  * FUNCTION
  1999.  *  HighlightTDLEditInlineItem
  2000.  * DESCRIPTION
  2001.  *  Highlight handler of edit task screen.
  2002.  * PARAMETERS
  2003.  *  index       [IN]        
  2004.  * RETURNS
  2005.  *  void
  2006.  *****************************************************************************/
  2007. void HighlightTDLEditInlineItem(S32 index)
  2008. {
  2009.     /*----------------------------------------------------------------*/
  2010.     /* Local Variables                                                */
  2011.     /*----------------------------------------------------------------*/
  2012.     /*----------------------------------------------------------------*/
  2013.     /* Code Body                                                      */
  2014.     /*----------------------------------------------------------------*/
  2015. #ifdef __MMI_ADVANCED_TODO__
  2016.     if (index == g_tdl_cntx.NoteIndex || index == g_tdl_cntx.LocationIndex)
  2017.     {
  2018.         g_tdl_cntx.HilitedInlineEditor = index;
  2019.         if (index == g_tdl_cntx.LocationIndex)
  2020.         {
  2021.             pfnUnicodeStrcpy(glocationString, g_tdl_cntx.LocationBuff);
  2022.         }
  2023.         else
  2024.         {
  2025.             pfnUnicodeStrcpy(gnoteString, g_tdl_cntx.NoteBuff);
  2026.         }
  2027.         ChangeLeftSoftkey(STR_TODO_LIST_LSK_EDIT, 0);
  2028.         SetLeftSoftkeyFunction(EntryTDLEditNote, KEY_EVENT_UP);
  2029.     }
  2030. #else /* __MMI_ADVANCED_TODO__ */ 
  2031.     if (index == g_tdl_cntx.NoteIndex)
  2032.     {
  2033.         pfnUnicodeStrcpy(gnoteString, g_tdl_cntx.NoteBuff);
  2034. ChangeLeftSoftkey(STR_TODO_LIST_LSK_EDIT, 0);
  2035.         SetLeftSoftkeyFunction(EntryTDLEditNote, KEY_EVENT_UP);
  2036.     }
  2037. #endif /* __MMI_ADVANCED_TODO__ */ 
  2038. #if defined(__MMI_VCALENDAR__) && defined(MMI_ON_HARDWARE_P)
  2039.     if (g_tdl_cntx.CurrHiliteOption == TODO_FROM_FMGR || g_tdl_cntx.CurrHiliteOption == TODO_FROM_NETWORK)
  2040.     {
  2041.         ChangeRightSoftkey(STR_GLOBAL_DONE, 0);
  2042.         SetRightSoftkeyFunction(EntryTDLSaveConfirm, KEY_EVENT_UP);
  2043.     }
  2044. #endif /* defined(__MMI_VCALENDAR__) && defined(MMI_ON_HARDWARE_P) */ 
  2045. }
  2046. /*****************************************************************************
  2047.  * FUNCTION
  2048.  *  EntryTDLEditTask
  2049.  * DESCRIPTION
  2050.  *  Entry edit task screen of To Do List.
  2051.  * PARAMETERS
  2052.  *  void
  2053.  * RETURNS
  2054.  *  void
  2055.  *****************************************************************************/
  2056. void EntryTDLEditTask(void)
  2057. {
  2058.     /*----------------------------------------------------------------*/
  2059.     /* Local Variables                                                */
  2060.     /*----------------------------------------------------------------*/
  2061.     U8 *guiBuffer;
  2062.     U8 *inputBuffer;
  2063.     U16 inputBufferSize;
  2064.     U8 inline_total;
  2065. #ifdef __MMI_ADVANCED_TODO__
  2066.     U16 ToDoList_View_icon_list[MAX_INLINE_ITEM_TODO_LIST];
  2067. #else /* __MMI_ADVANCED_TODO__ */ 
  2068.     U16 ToDoList_View_icon_list[MAX_INLINE_ITEM_TODO_LIST] = 
  2069.     {
  2070.         IMG_TODO_LIST_DATE, IMG_TODO_LIST_TIME, IMG_TODO_LIST_NOTE,
  2071.         0, IMG_TODO_LIST_ALARM, 0, IMG_TODO_LIST_REPEAT, 0, 0
  2072.     };
  2073. #endif /* __MMI_ADVANCED_TODO__ */ 
  2074.     /*----------------------------------------------------------------*/
  2075.     /* Code Body                                                      */
  2076.     /*----------------------------------------------------------------*/
  2077. #ifdef __SYNCML_SUPPORT__
  2078.     /* popup "please wait" when syncML is executing */
  2079.     if (mmi_syncml_is_tdl_sync_now())
  2080.     {
  2081.         DisplayPopup(
  2082.             (U8*) GetString(STR_ID_SYNC_PLEASE_WAIT),
  2083.             IMG_GLOBAL_WARNING,
  2084.             1,
  2085.             UI_POPUP_NOTIFYDURATION_TIME,
  2086.             (U8) WARNING_TONE);
  2087.             return;
  2088.     }
  2089. #endif
  2090.     EntryNewScreen(SCR_TDL_TASK_EDIT, ExitTDLEditTask, NULL, NULL);
  2091.     InitializeCategory57Screen();
  2092.     guiBuffer = GetCurrGuiBuffer(SCR_TDL_TASK_EDIT);
  2093.     inputBuffer = GetCurrNInputBuffer(SCR_TDL_TASK_EDIT, &inputBufferSize);
  2094.     SetParentHandler(0);
  2095.     inline_total = TDLFillInlineStruct();
  2096. #ifdef __MMI_ADVANCED_TODO__
  2097.     memset(&ToDoList_View_icon_list, 0, sizeof(U16) * MAX_INLINE_ITEM_TODO_LIST);
  2098.     mmi_tdl_set_inline_icon(ToDoList_View_icon_list, inline_total);
  2099. #endif /* __MMI_ADVANCED_TODO__ */ 
  2100.     RegisterHighlightHandler(HighlightTDLEditInlineItem);
  2101.     if (inputBuffer != NULL)
  2102.     {
  2103.         SetCategory57Data(wgui_inline_items, MAX_INLINE_ITEM_TODO_LIST, inputBuffer);
  2104.     }
  2105.     if (TDLIsTaskChanged() && GetInlineDoneFlag(guiBuffer) == 0)
  2106.     {
  2107.         SetInlineDoneFlag(guiBuffer);
  2108.     }
  2109.     ShowCategory57Screen(
  2110.         STR_TODO_LIST_LSK_EDIT,
  2111.         GetRootTitleIcon(ORGANIZER_TODOLIST_MENU),
  2112.         STR_TODO_LIST_LSK_EDIT,
  2113.         IMG_GLOBAL_OK,
  2114.         STR_GLOBAL_BACK,
  2115.         IMG_GLOBAL_BACK,
  2116.         inline_total,
  2117.         ToDoList_View_icon_list,
  2118.         wgui_inline_items,
  2119.         g_tdl_cntx.SelectedItemInView,
  2120.         guiBuffer);
  2121.     SetCategory57RightSoftkeyFunctions(EntryTDLSaveConfirm, GoBackHistory);
  2122. #if defined(__MMI_VCALENDAR__) && defined(MMI_ON_HARDWARE_P)
  2123.     if (g_tdl_cntx.CurrHiliteOption == TODO_FROM_FMGR)
  2124.     {
  2125.         ChangeRightSoftkey(STR_GLOBAL_DONE, IMG_GLOBAL_BACK);
  2126.         SetRightSoftkeyFunction(EntryTDLSaveConfirm, KEY_EVENT_UP);
  2127.     }
  2128. #endif /* defined(__MMI_VCALENDAR__) && defined(MMI_ON_HARDWARE_P) */ 
  2129. }
  2130. /*****************************************************************************
  2131.  * FUNCTION
  2132.  *  ExitTDLEditTask
  2133.  * DESCRIPTION
  2134.  *  Exit function of edit task screen.
  2135.  * PARAMETERS
  2136.  *  void
  2137.  * RETURNS
  2138.  *  void
  2139.  *****************************************************************************/
  2140. void ExitTDLEditTask(void)
  2141. {
  2142.     /*----------------------------------------------------------------*/
  2143.     /* Local Variables                                                */
  2144.     /*----------------------------------------------------------------*/
  2145.     history ScrDA;  /* Variable to hold the history data */
  2146.     S16 nHistory = 0;
  2147.     U16 size;
  2148.     /*----------------------------------------------------------------*/
  2149.     /* Code Body                                                      */
  2150.     /*----------------------------------------------------------------*/
  2151.     CloseCategory57Screen();
  2152.     ScrDA.scrnID = SCR_TDL_TASK_EDIT;
  2153.     ScrDA.entryFuncPtr = EntryTDLEditTask;
  2154.     pfnUnicodeStrcpy((S8*) ScrDA.inputBuffer, (S8*) & nHistory);
  2155.     GetCategoryHistory(ScrDA.guiBuffer);
  2156.     size = (U16) GetCategory57DataSize();
  2157.     GetCategory57Data((U8*) ScrDA.inputBuffer);
  2158.     AddNHistory(ScrDA, size);
  2159. }
  2160. /*****************************************************************************
  2161.  * FUNCTION
  2162.  *  TDLGotoListOrOptionScreen
  2163.  * DESCRIPTION
  2164.  *  Go back to task list or option screen when giving up save.
  2165.  * PARAMETERS
  2166.  *  void
  2167.  * RETURNS
  2168.  *  void
  2169.  *****************************************************************************/
  2170. void TDLGotoListOrOptionScreen(void)
  2171. {
  2172.     /*----------------------------------------------------------------*/
  2173.     /* Local Variables                                                */
  2174.     /*----------------------------------------------------------------*/
  2175.     /*----------------------------------------------------------------*/
  2176.     /* Code Body                                                      */
  2177.     /*----------------------------------------------------------------*/
  2178.     if (g_tdl_cntx.TotalListedTask == 0)
  2179.     {
  2180.         GoBackToHistory(SCR_TDL_TASK_LIST);
  2181.     }
  2182.     else
  2183.     {
  2184.         GoBackToHistory(SCR_TDL_OPTION_LIST);
  2185.     }
  2186. }
  2187. /*****************************************************************************
  2188.  * FUNCTION
  2189.  *  mmi_tdl_is_valid_fields
  2190.  * DESCRIPTION
  2191.  *  Retrieve user input from inline editor screen and save to global context.
  2192.  * PARAMETERS
  2193.  *  tdlItem     [?]
  2194.  * RETURNS
  2195.  *  void
  2196.  *****************************************************************************/
  2197. U16 mmi_tdl_is_valid_fields(ToDoListNode *tdlItem)
  2198. {
  2199.     /*----------------------------------------------------------------*/
  2200.     /* Local Variables                                                */
  2201.     /*----------------------------------------------------------------*/
  2202.     TIME_EQUALITY equality;
  2203.     MMI_TDL_ERROR_ENUM errorCode = MMI_TDL_SUCCESS;
  2204.     MYTIME currTime;
  2205. #ifdef __MMI_ADVANCED_TODO__
  2206.     MYTIME incTime, alarmTime;
  2207. #endif 
  2208.     /*----------------------------------------------------------------*/
  2209.     /* Code Body                                                      */
  2210.     /*----------------------------------------------------------------*/
  2211.     GetDateTime(&currTime);
  2212. #ifdef __MMI_ADVANCED_TODO__
  2213.     memset(&incTime, 0, sizeof(MYTIME));
  2214.     memcpy(&alarmTime, tdlItem, sizeof(MYTIME));
  2215.     mmi_tdl_compute_reminder_time(tdlItem, &incTime);
  2216. #ifdef MMI_ON_WIN32
  2217.     DecrementTime(alarmTime, incTime, &alarmTime);
  2218. #else
  2219.     applib_dt_decrease_time(
  2220.         (applib_time_struct*) & alarmTime,
  2221.         (applib_time_struct*) & incTime,
  2222.         (applib_time_struct*) & alarmTime);
  2223. #endif
  2224.     equality = CompareTime(alarmTime, currTime, NULL);
  2225. #else /* __MMI_ADVANCED_TODO__ */ 
  2226.     equality = CompareTime(tdlItem->StartTime, currTime, NULL);
  2227. #endif /* __MMI_ADVANCED_TODO__ */ 
  2228.     /* Check note */
  2229.     if (pfnUnicodeStrlen((S8*) tdlItem->Note) == 0)
  2230.     {
  2231.         return MMI_TDL_INVALID_NOTES;
  2232.     }
  2233.     /* Check alarm */
  2234.     if (tdlItem->Alarm >= TODO_LIST_ALARM_TOTAL)
  2235.     {
  2236.         return MMI_TDL_INVALID_ALARM;
  2237.     }
  2238.     /* disable alarm state if already expired */
  2239.     if (g_tdl_freq_set[tdlItem->Repeat] == ALM_FREQ_ONCE && equality != TIME_GREATER)   /* already expired */
  2240.     {
  2241.         if (tdlItem->Alarm >= TODO_LIST_ALARM_ON)
  2242.         {
  2243.             errorCode =  MMI_TDL_EXPIRED_ALARM;
  2244.         }
  2245.     }
  2246.     /* Check repeat */
  2247.     if (tdlItem->Repeat >= TODO_FREQ_NUM)
  2248.     {
  2249.         return MMI_TDL_REPEAT_OUT_OF_BOUNDARY;
  2250.     }
  2251. #ifdef __MMI_ADVANCED_TODO__
  2252.     /* if task duration is more than one day, repeat should set as "once" */
  2253.     if (tdlItem->Type == TDL_TASK_REMINDER && 
  2254.         (tdlItem->StartTime.nYear != tdlItem->EndTime.nYear ||tdlItem->StartTime.nMonth!= tdlItem->EndTime.nMonth || tdlItem->StartTime.nSec != tdlItem->EndTime.nSec) &&
  2255.         g_tdl_freq_set[tdlItem->Repeat] != ALM_FREQ_ONCE)
  2256.     {
  2257.         return MMI_TDL_INVALID_REPEAT;
  2258.     }
  2259. #endif
  2260.     /* Check Days */
  2261.     if (g_tdl_freq_set[tdlItem->Repeat] == ALM_FREQ_DAYS && tdlItem->Days == 0)
  2262.     {
  2263.         tdlItem->Repeat = mmi_alm_get_freq_order(TODO_FREQ_NUM, g_tdl_freq_set, ALM_FREQ_ONCE);
  2264.     }
  2265.     return errorCode;
  2266. }
  2267. /*****************************************************************************
  2268.  * FUNCTION
  2269.  *  TDLSaveTask
  2270.  * DESCRIPTION
  2271.  *  Retrieve user input from inline editor screen and save to NVRAM.
  2272.  * PARAMETERS
  2273.  *  void
  2274.  * RETURNS
  2275.  *  void
  2276.  *****************************************************************************/
  2277. void TDLSaveTask(void)
  2278. {
  2279.     /*----------------------------------------------------------------*/
  2280.     /* Local Variables                                                */
  2281.     /*----------------------------------------------------------------*/
  2282.     U8 i, j;
  2283.     U8 OldStatus;
  2284.     U16 doneStr = STR_GLOBAL_DONE;
  2285.     U16 errorCode;
  2286.     /*----------------------------------------------------------------*/
  2287.     /* Code Body                                                      */
  2288.     /*----------------------------------------------------------------*/
  2289.     i = g_tdl_cntx.CurrTaskIndex;
  2290.     /* note */
  2291.     if (pfnUnicodeStrlen(g_tdl_cntx.NoteBuff) == 0)