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

MTK

开发平台:

C/C++

  1.                     UI_POPUP_NOTIFYDURATION_TIME,
  2.                     SUCCESS_TONE);
  3.                 return;
  4.             }
  5.         }
  6.     }
  7.     else if (idx == PRF_MENU_EXTMLD_DEL)
  8.     {
  9.         if (PmgDelExtMelodyById((U16) (PMG_EXT_MELODY_BEGIN + g_ext_melody_idx)) == MMI_TRUE)
  10.         {
  11.             DisplayPopup(
  12.                 (PU8) GetString(STR_GLOBAL_DONE),
  13.                 IMG_GLOBAL_ACTIVATED,
  14.                 1,
  15.                 UI_POPUP_NOTIFYDURATION_TIME,
  16.                 SUCCESS_TONE);
  17.             return;
  18.         }
  19.     }
  20.     else if (idx == PRF_MENU_EXTMLD_ADD)
  21.     {
  22.         mmi_alm_entry_tone_setup_ext_melody_drv();
  23.         return;
  24.     }
  25.     DisplayPopup(
  26.         (PU8) GetString(STR_GLOBAL_UNFINISHED),
  27.         IMG_GLOBAL_UNFINISHED,
  28.         1,
  29.         UI_POPUP_NOTIFYDURATION_TIME,
  30.         WARNING_TONE);
  31. }
  32. /*****************************************************************************
  33.  * FUNCTION
  34.  *  mmi_alm_tone_setup_convert_empty_slot_menu_list
  35.  * DESCRIPTION
  36.  *  
  37.  * PARAMETERS
  38.  *  idx     [IN]        
  39.  * RETURNS
  40.  *  void
  41.  *****************************************************************************/
  42. U8 mmi_alm_tone_setup_convert_empty_slot_menu_list(U8 idx)
  43. {
  44.     /*----------------------------------------------------------------*/
  45.     /* Local Variables                                                */
  46.     /*----------------------------------------------------------------*/
  47.     /*----------------------------------------------------------------*/
  48.     /* Code Body                                                      */
  49.     /*----------------------------------------------------------------*/
  50.     if (PmgIsEmptySlot(g_ext_melody_idx) == MMI_FALSE)  /* Not Empty slot */
  51.     {
  52.         return idx;
  53.     }
  54.     else
  55.     {
  56.         if (idx == 0)
  57.         {
  58.             return PRF_MENU_EXTMLD_ADD; /* PRF_MENU_EXTMLD_DONE */
  59.         }
  60.     #ifdef MMI_ON_HARDWARE_P
  61.         else
  62.         {
  63.             MMI_ASSERT(MMI_FALSE);
  64.         }
  65.     #endif /* MMI_ON_HARDWARE_P */ 
  66.     }
  67.     return PRF_MENU_EXTMLD_MAX;
  68. }
  69. /*****************************************************************************
  70.  * FUNCTION
  71.  *  mmi_alm_entry_tone_setup_ext_melody_drv
  72.  * DESCRIPTION
  73.  *  Fucntion for handling the selection of replace option of external melodies.
  74.  * PARAMETERS
  75.  *  void
  76.  * RETURNS
  77.  *  void
  78.  *****************************************************************************/
  79. void mmi_alm_entry_tone_setup_ext_melody_drv(void)
  80. {
  81.     /*----------------------------------------------------------------*/
  82.     /* Local Variables                                                */
  83.     /*----------------------------------------------------------------*/
  84.     U8 *nStrItemList[PRF_MENU_EXTMLD_DRV_MAX];
  85.     U8 nNumofItem = (U8) PRF_MENU_EXTMLD_DRV_MAX;
  86.     U8 *guiBuffer;
  87.     S16 CardDrv = -1;
  88.     /*----------------------------------------------------------------*/
  89.     /* Code Body                                                      */
  90.     /*----------------------------------------------------------------*/
  91. #if defined(__MMI_FILE_MANAGER__)
  92.     CardDrv = FS_GetDrive(FS_DRIVE_V_REMOVABLE, 1, FS_NO_ALT_DRIVE);
  93. #endif /* (defined(MMI_ON_HARDWARE_P) && defined(__MMI_FILE_MANAGER__) ) */
  94.     if (CardDrv > 0)    /* Card Storage is present */
  95.     {
  96.         nStrItemList[PRF_MENU_EXTMLD_DRV_PHONE] = (U8*) GetString(STR_PROFILES_RING_TONE_SETUP_DRV_PHONE);
  97.         nStrItemList[PRF_MENU_EXTMLD_DRV_CARD] = (U8*) GetString(STR_PROFILES_RING_TONE_SETUP_DRV_CARD);
  98.         EntryNewScreen(SCR_ID_ALM_TONE_SETUP_EXT_MELODY_DRV, NULL, mmi_alm_entry_tone_setup_ext_melody_drv, NULL);
  99.         guiBuffer = GetCurrGuiBuffer(SCR_ID_ALM_TONE_SETUP_EXT_MELODY_DRV);
  100.         RegisterHighlightHandler(mmi_alm_tone_setup_ext_melody_hilight_hdlr);
  101.         ShowCategory56Screen(
  102.             STR_ALARM_TONE_CAPTION,
  103.             IMG_PROFILES_TITLEE,
  104.             STR_GLOBAL_OK,
  105.             IMG_GLOBAL_OK,
  106.             STR_GLOBAL_BACK,
  107.             IMG_GLOBAL_BACK,
  108.             nNumofItem,
  109.             nStrItemList,
  110.             NULL,
  111.             0,
  112.             guiBuffer);
  113.         SetLeftSoftkeyFunction(mmi_alm_tone_setup_ext_melody_drv_select, KEY_EVENT_UP);
  114.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  115.     }
  116.     else    /* Card Storage not present */
  117.     {
  118.         extMldHlitItem = PRF_MENU_EXTMLD_DRV_PHONE;
  119.         mmi_alm_tone_setup_ext_melody_drv_select();
  120.     }
  121. }
  122. /*****************************************************************************
  123.  * FUNCTION
  124.  *  mmi_alm_tone_setup_ext_melody_drv_select
  125.  * DESCRIPTION
  126.  *  For displaying the the screen showing the drives.
  127.  * PARAMETERS
  128.  *  void
  129.  * RETURNS
  130.  *  void
  131.  *****************************************************************************/
  132. void mmi_alm_tone_setup_ext_melody_drv_select(void)
  133. {
  134. #if defined(__MMI_FILE_MANAGER__)
  135.     /*----------------------------------------------------------------*/
  136.     /* Local Variables                                                */
  137.     /*----------------------------------------------------------------*/
  138.     S16 phoneDrvLetter, cardDrvLetter;
  139.     S8 temp[3];
  140.     UI_character_type dir_phone_root[4];
  141.     UI_character_type dir_card_root[4];
  142.     FMGR_FILTER filter;
  143.     /*----------------------------------------------------------------*/
  144.     /* Code Body                                                      */
  145.     /*----------------------------------------------------------------*/
  146.     FMGR_FILTER_INIT(&filter);
  147.     FMGR_FILTER_SET_AUDIO(&filter);
  148.     FMGR_FILTER_SET(&filter, FMGR_TYPE_FOLDER);
  149.     FMGR_FILTER_SET(&filter, FMGR_TYPE_FOLDER_DOT);
  150.     phoneDrvLetter = FS_GetDrive(FS_DRIVE_V_NORMAL, 2, FS_DRIVE_I_SYSTEM | FS_DRIVE_V_NORMAL);
  151.     cardDrvLetter = FS_GetDrive(FS_DRIVE_V_REMOVABLE, 1, FS_NO_ALT_DRIVE);
  152.     sprintf(temp, "%c:\", (S8) phoneDrvLetter);
  153.     AnsiiToUnicodeString((S8*) dir_phone_root, temp);
  154.     sprintf(temp, "%c:\", (S8) cardDrvLetter);
  155.     AnsiiToUnicodeString((S8*) dir_card_root, temp);
  156.     if (extMldHlitItem == PRF_MENU_EXTMLD_DRV_CARD)
  157.     {
  158.         mmi_fmgr_select_path_and_enter(
  159.             APP_PROFILES,
  160.             FMGR_SELECT_FILE,
  161.             filter,
  162.             (PS8) dir_card_root,
  163.             mmi_alm_tone_setup_ext_melody_drv_select_callback);
  164.     }
  165.     else    /* if( extMldHlitItem == PRF_MENU_EXTMLD_DRV_PHONE) */
  166.     {
  167.         mmi_fmgr_select_path_and_enter(
  168.             APP_PROFILES,
  169.             FMGR_SELECT_FILE,
  170.             filter,
  171.             (PS8) dir_phone_root,
  172.             mmi_alm_tone_setup_ext_melody_drv_select_callback);
  173.     }
  174. #endif /* defined(__MMI_FILE_MANAGER__) */ /* (defined(MMI_ON_HARDWARE_P) && defined(__MMI_FILE_MANAGER__)  */
  175. }
  176. /*****************************************************************************
  177.  * FUNCTION
  178.  *  mmi_alm_tone_setup_ext_melody_drv_select_callback
  179.  * DESCRIPTION
  180.  *  The call back function called when the user selects some file for replacing an external melody.
  181.  * PARAMETERS
  182.  *  path            [?]         
  183.  *  is_short        [IN]        
  184.  * RETURNS
  185.  *  void
  186.  *****************************************************************************/
  187. void mmi_alm_tone_setup_ext_melody_drv_select_callback(void *path, int is_short)
  188. {
  189.     /*----------------------------------------------------------------*/
  190.     /* Local Variables                                                */
  191.     /*----------------------------------------------------------------*/
  192.     S8 *filepath = (S8*) path;
  193.     PMG_ADDFILE_ERRNO err = PMG_ADDFILE_ERR_UNKNOWN;
  194.     /*----------------------------------------------------------------*/
  195.     /* Code Body                                                      */
  196.     /*----------------------------------------------------------------*/
  197.     if (filepath)
  198.     {
  199.         if (PmgCheckImyMidFileSize(filepath) == PMG_ADDFILE_ERR_FILE_TOO_LARGE)
  200.         {
  201.             err = PMG_ADDFILE_ERR_FILE_TOO_LARGE;
  202.         }
  203.         else
  204.         {
  205.             PmgSetShortFileName((BOOL) is_short);
  206.             if (PmgIsEmptySlot(g_ext_melody_idx) == MMI_FALSE)
  207.             {
  208.                 err = PmgReplaceExtMelodyBySlotPathFileName(filepath, g_ext_melody_idx);
  209.             }
  210.             else
  211.             {
  212.                 err = PmgAddExtMelodyBySlotPathFileName(filepath, g_ext_melody_idx);
  213.             }
  214.         }
  215.         switch (err)
  216.         {
  217.             case PMG_ADDFILE_ERR_SUCCESS:
  218.                 DisplayPopup(
  219.                     (PU8) GetString(STR_GLOBAL_DONE),
  220.                     IMG_GLOBAL_ACTIVATED,
  221.                     1,
  222.                     UI_POPUP_NOTIFYDURATION_TIME,
  223.                     SUCCESS_TONE);
  224.                 break;
  225.             case PMG_ADDFILE_ERR_STR_TOO_LONG:
  226.             case PMG_ADDFILE_ERR_STRFILE_TOO_LONG:
  227.             case PMG_ADDFILE_ERR_STRPATH_TOO_LONG:
  228.                 DisplayPopup(
  229.                     (PU8) GetString(STR_PROFILES_RING_TONE_SETUP_NAMETOOLONG),
  230.                     IMG_GLOBAL_UNFINISHED,
  231.                     1,
  232.                     UI_POPUP_NOTIFYDURATION_TIME,
  233.                     WARNING_TONE);
  234.                 break;
  235.             case PMG_ADDFILE_ERR_SLOT_FULL:
  236.                 DisplayPopup(
  237.                     (PU8) GetString(STR_PROFILES_RING_TONE_SETUP_LISTFULL),
  238.                     IMG_GLOBAL_UNFINISHED,
  239.                     1,
  240.                     UI_POPUP_NOTIFYDURATION_TIME,
  241.                     WARNING_TONE);
  242.                 break;
  243.             case PMG_ADDFILE_ERR_FILE_TOO_LARGE:
  244.                 DisplayPopup(
  245.                     (PU8) GetString(STR_PROFILES_RING_TONE_SETUP_FILETOOLARGE),
  246.                     IMG_GLOBAL_UNFINISHED,
  247.                     1,
  248.                     UI_POPUP_NOTIFYDURATION_TIME,
  249.                     WARNING_TONE);
  250.                 break;
  251.             case PMG_ADDFILE_ERR_DUPLICATED:
  252.                 DisplayPopup(
  253.                     (PU8) GetString(STR_PROFILES_RING_TONE_SETUP_DUPLICATED),
  254.                     IMG_GLOBAL_UNFINISHED,
  255.                     1,
  256.                     UI_POPUP_NOTIFYDURATION_TIME,
  257.                     WARNING_TONE);
  258.                 break;
  259.             default:
  260.                 DisplayPopup(
  261.                     (PU8) GetString(STR_GLOBAL_UNFINISHED),
  262.                     IMG_GLOBAL_UNFINISHED,
  263.                     1,
  264.                     UI_POPUP_NOTIFYDURATION_TIME,
  265.                     WARNING_TONE);
  266.                 break;
  267.         }
  268.         DeleteUptoScrID(SCR_ID_ALM_TONE_SETUP_EXT_MELODY);
  269.         DeleteScreenIfPresent(SCR_ID_ALM_TONE_SETUP_EXT_MELODY);
  270.     }
  271.     else
  272.     {
  273.         /* DisplayPopup((PU8)GetString(STR_GLOBAL_EMPTY), 
  274.            IMG_GLOBAL_EMPTY, 1,UI_POPUP_NOTIFYDURATION_TIME,WARNING_TONE); */
  275.         GoBackToHistory(SCR_ID_ALM_TONE_SETUP_EXT_MELODY);
  276.     }
  277. }
  278. /*****************************************************************************
  279.  * FUNCTION
  280.  *  mmi_alm_tone_setup_delete_ext_melody
  281.  * DESCRIPTION
  282.  *  When the external file is deleted, Profile will call the function to update ring tone id.
  283.  * PARAMETERS
  284.  *  ToneId      [IN]        
  285.  * RETURNS
  286.  *  void
  287.  *****************************************************************************/
  288. void mmi_alm_tone_setup_delete_ext_melody(U16 ToneId)
  289. {
  290.     /*----------------------------------------------------------------*/
  291.     /* Local Variables                                                */
  292.     /*----------------------------------------------------------------*/
  293.     U16 i;
  294.     BOOL dirty_flag = FALSE;
  295.     /*----------------------------------------------------------------*/
  296.     /* Code Body                                                      */
  297.     /*----------------------------------------------------------------*/
  298.     /* Check if external melody ID is deleted */
  299.     for (i = 0; i < NUM_OF_ALM; i++)
  300.     {
  301.         /* If the external ID saved in the alarm NVRAM */
  302.         if ((g_alm_cntx.AlmList[i].AudioOption == ALM_AUDIO_OPTIONS_TONE) &&
  303.             (g_alm_cntx.AlmList[i].AudioOptionValue == ToneId))
  304.         {
  305.             g_alm_cntx.AlmList[i].AudioOptionValue = (U16) (gstartMidiId + 1);
  306.             dirty_flag = TRUE;
  307.         }
  308.         /* If current highlight on the alarm */
  309.         if ((g_alm_cntx.CurrHiliteAlarm == i) &&
  310.             (g_alm_cntx.CurrHiliteAudioOption == ALM_AUDIO_OPTIONS_TONE) &&
  311.             (g_alm_cntx.CurrHiliteAudioOptionValue == ToneId))
  312.         {
  313.             g_alm_cntx.CurrHiliteAudioOptionValue = (U16) (gstartMidiId + 1);
  314.         }
  315.     }
  316.     /* Write result back to NVRAM */
  317.     if (dirty_flag)
  318.     {
  319.         AlmWriteToNvram();
  320.     }
  321. }
  322. #endif /* __MMI_PROFILE_EXTMELODY_SUPPORT__ */ 
  323. /*****************************************************************************
  324.  * FUNCTION
  325.  *  mmi_alm_tone_setup_hilite_hdlr
  326.  * DESCRIPTION
  327.  *  Highlight handler for the tone list screen
  328.  * PARAMETERS
  329.  *  index       [IN]        
  330.  * RETURNS
  331.  *  void
  332.  *****************************************************************************/
  333. void mmi_alm_tone_setup_hilite_hdlr(S32 index)
  334. {
  335.     /*----------------------------------------------------------------*/
  336.     /* Local Variables                                                */
  337.     /*----------------------------------------------------------------*/
  338.     U16 tempval1 = 0;
  339.     U16 tempval2 = gtotalRingId;
  340.     S32 data;
  341.     BOOL play_it = TRUE;
  342.     /*----------------------------------------------------------------*/
  343.     /* Code Body                                                      */
  344.     /*----------------------------------------------------------------*/
  345.     g_alm_tone_index = (U16) index;
  346.     StopToneAudio();
  347.     if ((g_alm_tone_index >= tempval1) && (g_alm_tone_index < tempval2))
  348.     {
  349.         gcurrentaudioId = g_alm_tone_index + gstartRingId;
  350.     }
  351.     tempval1 = tempval2;
  352.     tempval2 = gtotalMidiId + gtotalRingId;
  353.     if ((g_alm_tone_index >= tempval1) && (g_alm_tone_index < tempval2))
  354.     {
  355.         gcurrentaudioId = g_alm_tone_index + gstartMidiId - gtotalRingId;
  356.     }
  357. #if defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  358.     tempval1 = tempval2;
  359.     tempval2 = gtotalMidiId + gtotalRingId + MAXIMUM_EXT_MELODY_NUM;
  360.     if ((g_alm_tone_index >= tempval1) && (g_alm_tone_index < tempval2))
  361.     {
  362.         data = g_alm_tone_index - (gtotalMidiId + gtotalRingId);
  363.         gcurrentaudioId = PMG_EXT_MELODY_BEGIN + (U16) data;
  364.     }
  365. #endif /* defined(__MMI_PROFILE_EXTMELODY_SUPPORT__) */ 
  366. #if defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__)
  367.     if (g_alm_tone_index == tempval2)
  368.     {
  369.         DYNAUDIOINFO *download_theme_tones;
  370.         if (GetThemeV2TonesInfo(&download_theme_tones) != 0 && mmi_tm_get_current_theme_ringtone())
  371.         {
  372.             gcurrentaudioId = (U16) download_theme_tones[0].AudioId;
  373.             if (AudioFileDeletedFromFmgr(gcurrentaudioId))
  374.             {
  375.                 play_it = FALSE;
  376.             }
  377.         }
  378.         else
  379.         {
  380.             ASSERT(0);
  381.         }
  382.     }
  383. #endif /* defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__) */ 
  384.     if (play_it)
  385.     {
  386.         StartTimer(TIMER_PROFILES_TONE_PLAY, 1000, PlayToneAudio);
  387.     }
  388. }
  389. #endif /* __MMI_ALM_CUSTOMIZE_TONE__ */ 
  390. /*****************************************************************************
  391.  * FUNCTION
  392.  *  mmi_alm_entry_aud_opt_fmrdo
  393.  * DESCRIPTION
  394.  *  The entry function for the screen displaying options for fmradio audio option.
  395.  * PARAMETERS
  396.  *  void
  397.  * RETURNS
  398.  *  void
  399.  *****************************************************************************/
  400. void mmi_alm_entry_aud_opt_fmrdo(void)
  401. {
  402.     /*----------------------------------------------------------------*/
  403.     /* Local Variables                                                */
  404.     /*----------------------------------------------------------------*/
  405.     U8 *gui_buffer;
  406.     U16 item_count;
  407.     U16 item_texts[10];
  408.     U8 *item_popups[10];
  409.     S32 i;
  410.     U16 item_icons[] = {IMG_GLOBAL_L1, IMG_GLOBAL_L2};
  411.     /*----------------------------------------------------------------*/
  412.     /* Code Body                                                      */
  413.     /*----------------------------------------------------------------*/
  414.     EntryNewScreen(SCR_ID_ALM_AUDIO_OPT_FMRADIO, NULL, mmi_alm_entry_aud_opt_fmrdo, NULL);
  415.     gui_buffer = GetCurrGuiBuffer(SCR_ID_ALM_AUDIO_OPT_FMRADIO);
  416.     item_count = GetNumOfChild(MENU_ID_ALM_AUDIO_OPT_FMRADIO);
  417.     GetSequenceStringIds(MENU_ID_ALM_AUDIO_OPT_FMRADIO, item_texts);
  418.     SetParentHandler(MENU_ID_ALM_AUDIO_OPT_FMRADIO);
  419.     RegisterHighlightHandler(mmi_alm_aud_opt_fmrdo_highlight_hdlr);
  420.     for (i = 0; i < item_count; i++)
  421.     {
  422.         item_popups[i] = NULL;
  423.     }
  424.     ShowCategory52Screen(
  425.         STR_GLOBAL_OPTIONS,
  426.         0 /* MAIN_MENU_TITLE_MULTIMEDIA_ICON */ ,
  427.         STR_GLOBAL_OK,
  428.         0,
  429.         STR_GLOBAL_BACK,
  430.         0,
  431.         item_count,
  432.         item_texts,
  433.         item_icons,
  434.         (U8 **) item_popups,
  435.         0,
  436.         0,
  437.         gui_buffer);
  438.     /* Set the right & left arrow key handlers. */
  439.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  440.     /* Set the LSK and RSK handlers. */
  441.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  442. }
  443. /*****************************************************************************
  444.  * FUNCTION
  445.  *  mmi_alm_aud_opt_fmrdo_highlight_hdlr
  446.  * DESCRIPTION
  447.  *  Highlight handler of Alarm Audio Options FM Radio options screen.
  448.  * PARAMETERS
  449.  *  index       [IN]        Index of inline selection
  450.  * RETURNS
  451.  *  void
  452.  *****************************************************************************/
  453. void mmi_alm_aud_opt_fmrdo_highlight_hdlr(S32 index)
  454. {
  455.     /*----------------------------------------------------------------*/
  456.     /* Local Variables                                                */
  457.     /*----------------------------------------------------------------*/
  458.     /*----------------------------------------------------------------*/
  459.     /* Code Body                                                      */
  460.     /*----------------------------------------------------------------*/
  461.     if (index == 0)
  462.     {
  463.         SetLeftSoftkeyFunction(mmi_alm_entry_aud_opt_fmrdo_channel_list, KEY_EVENT_UP);
  464.         SetKeyHandler(mmi_alm_entry_aud_opt_fmrdo_channel_list, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  465.     }
  466.     else if (index == 1)
  467.     {
  468.         SetLeftSoftkeyFunction(mmi_alm_entry_fmrdo_manual_input, KEY_EVENT_UP);
  469.         SetKeyHandler(mmi_alm_entry_fmrdo_manual_input, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  470.     }
  471. }
  472. /*****************************************************************************
  473.  * FUNCTION
  474.  *  mmi_alm_entry_aud_opt_fmrdo_channel_list
  475.  * DESCRIPTION
  476.  *  The entry function for the screen displaying the FM channels.
  477.  * PARAMETERS
  478.  *  void
  479.  * RETURNS
  480.  *  void
  481.  *****************************************************************************/
  482. void mmi_alm_entry_aud_opt_fmrdo_channel_list(void)
  483. {
  484.     /*----------------------------------------------------------------*/
  485.     /* Local Variables                                                */
  486.     /*----------------------------------------------------------------*/
  487.     U8 *gui_buffer;
  488.     /*----------------------------------------------------------------*/
  489.     /* Code Body                                                      */
  490.     /*----------------------------------------------------------------*/
  491.     EntryNewScreen(SCR_ID_ALM_AUDIO_OPT_FMRADIO_CHANNEL_LIST, NULL, mmi_alm_entry_aud_opt_fmrdo_channel_list, NULL);
  492.     /* register highlight handler */
  493.     RegisterHighlightHandler(mmi_alm_aud_opt_fmrdo_channel_list_highlight_hdlr);
  494.     gui_buffer = GetCurrGuiBuffer(SCR_ID_ALM_AUDIO_OPT_FMRADIO_CHANNEL_LIST);
  495.     if (gui_buffer == NULL)
  496.     {
  497.         if (g_alm_cntx.CurrHiliteAudioOptionValue > 0)
  498.         {
  499.             g_alm_aud_opt_fmrdo_channel_index = g_alm_cntx.CurrHiliteAudioOptionValue - 1;
  500.         }
  501.         else
  502.         {
  503.             g_alm_aud_opt_fmrdo_channel_index = 0;
  504.         }
  505.     }
  506.     ShowCategory184Screen(
  507.         STR_ID_ALM_AUDIO_OPTIONS_FMRADIO_CHANNELLIST,
  508.         0,
  509.         0,
  510.         0,
  511.         STR_GLOBAL_BACK,
  512.         IMG_GLOBAL_BACK,
  513.         FM_RADIO_CHANNEL_NUM,
  514.         mmi_fmrdo_channel_list_item,
  515.         mmi_fmrdo_channel_list_item_hint,
  516.         g_alm_aud_opt_fmrdo_channel_index,
  517.         gui_buffer);
  518.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  519.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  520. }
  521. /*****************************************************************************
  522.  * FUNCTION
  523.  *  mmi_alm_aud_opt_fmrdo_channel_list_highlight_hdlr
  524.  * DESCRIPTION
  525.  *  Highlight handler for the FM Channels Screen.
  526.  * PARAMETERS
  527.  *  index       [IN]        Index of inline selection
  528.  * RETURNS
  529.  *  void
  530.  *****************************************************************************/
  531. void mmi_alm_aud_opt_fmrdo_channel_list_highlight_hdlr(S32 index)
  532. {
  533.     /*----------------------------------------------------------------*/
  534.     /* Local Variables                                                */
  535.     /*----------------------------------------------------------------*/
  536.     /*----------------------------------------------------------------*/
  537.     /* Code Body                                                      */
  538.     /*----------------------------------------------------------------*/
  539.     g_alm_aud_opt_fmrdo_channel_index = index;
  540.     if (g_fmrdo.channel_list.freq[g_alm_aud_opt_fmrdo_channel_index] == 0)
  541.     {
  542.         ClearKeyHandler(KEY_LSK, KEY_EVENT_UP);
  543.         ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  544.         ChangeLeftSoftkey(0, 0);
  545.     }
  546.     else
  547.     {
  548.         ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  549.         SetLeftSoftkeyFunction(mmi_alm_entry_aud_opt_fmrdo_channel_options, KEY_EVENT_UP);
  550.         SetKeyHandler(mmi_alm_entry_aud_opt_fmrdo_channel_options, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  551.     }
  552. }
  553. /*****************************************************************************
  554.  * FUNCTION
  555.  *  mmi_alm_entry_aud_opt_fmrdo_channel_options
  556.  * DESCRIPTION
  557.  *  The entry function for the channel options screen
  558.  * PARAMETERS
  559.  *  void
  560.  * RETURNS
  561.  *  void
  562.  *****************************************************************************/
  563. void mmi_alm_entry_aud_opt_fmrdo_channel_options(void)
  564. {
  565.     /*----------------------------------------------------------------*/
  566.     /* Local Variables                                                */
  567.     /*----------------------------------------------------------------*/
  568.     U8 *gui_buffer_p;
  569.     U16 item_texts[] = {STR_GLOBAL_SELECT, STR_ID_ALM_AUDIO_OPT_FMRDO_OPT_PREV};
  570.     U16 item_icons[] = {IMG_GLOBAL_L1, IMG_GLOBAL_L2};
  571.     U8 *item_popups[] = {NULL, NULL};
  572.     /*----------------------------------------------------------------*/
  573.     /* Code Body                                                      */
  574.     /*----------------------------------------------------------------*/
  575.     EntryNewScreen(SCR_ID_ALM_AUDIO_OPT_FMRDO_CHANNEL_OPT, NULL, mmi_alm_entry_aud_opt_fmrdo_channel_options, NULL);
  576.     gui_buffer_p = GetCurrGuiBuffer(SCR_ID_ALM_AUDIO_OPT_FMRDO_CHANNEL_OPT);
  577.     RegisterHighlightHandler(mmi_alm_fmrdo_channel_opt_highlight_hdlr);
  578.     ShowCategory52Screen(
  579.         STR_GLOBAL_OPTIONS,
  580.         0,
  581.         STR_GLOBAL_OK,
  582.         0,
  583.         STR_GLOBAL_BACK,
  584.         0,
  585.         2,
  586.         item_texts,
  587.         item_icons,
  588.         (U8 **) item_popups,
  589.         0,
  590.         0,
  591.         gui_buffer_p);
  592.     SetLeftSoftkeyFunction(mmi_alm_aud_opt_fmrdo_channel_opt_lsk_hdlr, KEY_EVENT_UP);
  593.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  594.     /* Set Key handlers */
  595.     SetKeyHandler(mmi_alm_aud_opt_fmrdo_channel_opt_lsk_hdlr, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  596.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  597. }
  598. /*****************************************************************************
  599.  * FUNCTION
  600.  *  mmi_alm_fmrdo_channel_opt_highlight_hdlr
  601.  * DESCRIPTION
  602.  *  Highlight handler for the FM Radio channel options screen
  603.  * PARAMETERS
  604.  *  index       [IN]        
  605.  * RETURNS
  606.  *  void
  607.  *****************************************************************************/
  608. void mmi_alm_fmrdo_channel_opt_highlight_hdlr(S32 index)
  609. {
  610.     /*----------------------------------------------------------------*/
  611.     /* Local Variables                                                */
  612.     /*----------------------------------------------------------------*/
  613.     U16 item_texts[] = {STR_GLOBAL_SELECT, STR_ID_ALM_AUDIO_OPT_FMRDO_OPT_PREV};
  614.     /*----------------------------------------------------------------*/
  615.     /* Code Body                                                      */
  616.     /*----------------------------------------------------------------*/
  617.     g_alm_aud_opt_fmrdo_channel_opt_index = item_texts[index];
  618. }
  619. /*****************************************************************************
  620.  * FUNCTION
  621.  *  mmi_alm_aud_opt_fmrdo_channel_opt_lsk_hdlr
  622.  * DESCRIPTION
  623.  *  LSK function for the FM Radio channel options screen
  624.  * PARAMETERS
  625.  *  void
  626.  * RETURNS
  627.  *  void
  628.  *****************************************************************************/
  629. void mmi_alm_aud_opt_fmrdo_channel_opt_lsk_hdlr(void)
  630. {
  631.     /*----------------------------------------------------------------*/
  632.     /* Local Variables                                                */
  633.     /*----------------------------------------------------------------*/
  634.     /*----------------------------------------------------------------*/
  635.     /* Code Body                                                      */
  636.     /*----------------------------------------------------------------*/
  637.     switch (g_alm_aud_opt_fmrdo_channel_opt_index)
  638.     {
  639.         case STR_GLOBAL_SELECT: /* for selecting a particular FM channel for alarm. */
  640.             g_alm_cntx.CurrHiliteAudioOption = ALM_AUDIO_OPTIONS_FMRADIO_CHANNEL;
  641.             g_alm_cntx.CurrHiliteAudioOptionValue = g_alm_aud_opt_fmrdo_channel_index + 1;
  642.             g_alm_aud_opt_selected = TRUE;
  643.             DisplayPopup(
  644.                 (U8*) GetString(STR_GLOBAL_DONE),
  645.                 IMG_GLOBAL_ACTIVATED,
  646.                 1,
  647.                 UI_POPUP_NOTIFYDURATION_TIME,
  648.                 SUCCESS_TONE);
  649.             DeleteUptoScrID(SCR_ID_ALM_EDITOR);
  650.             break;
  651.         case STR_ID_ALM_AUDIO_OPT_FMRDO_OPT_PREV:
  652.             g_alm_fmrdo_prev_freq = g_fmrdo.channel_list.freq[g_alm_aud_opt_fmrdo_channel_index];
  653.     #ifdef __MMI_FM_RADIO_BIND_EARPHONE__
  654.             if (!isEarphonePlugged)
  655.             {
  656.                 DisplayPopup(
  657.                     (U8*) GetString(STR_ID_ALM_FMRDO_PLEASE_PLUG_IN_EARPHONE),
  658.                     IMG_GLOBAL_WARNING,
  659.                     1,
  660.                     UI_POPUP_NOTIFYDURATION_TIME_2000,
  661.                     WARNING_TONE);
  662.             }
  663.             else
  664.     #endif /* __MMI_FM_RADIO_BIND_EARPHONE__ */ 
  665.                 mmi_alm_entry_fmrdo_prev_channel();
  666.             break;
  667.     }
  668. }
  669. /*****************************************************************************
  670.  * FUNCTION
  671.  *  mmi_alm_entry_fmrdo_manual_input
  672.  * DESCRIPTION
  673.  *  The entry function for the manual input screen
  674.  * PARAMETERS
  675.  *  void
  676.  * RETURNS
  677.  *  void
  678.  *****************************************************************************/
  679. void mmi_alm_entry_fmrdo_manual_input(void)
  680. {
  681.     /*----------------------------------------------------------------*/
  682.     /* Local Variables                                                */
  683.     /*----------------------------------------------------------------*/
  684.     U8 *guiBuffer;
  685.     U8 *inputBuffer;
  686.     U16 inputBufferSize;
  687.     /*----------------------------------------------------------------*/
  688.     /* Code Body                                                      */
  689.     /*----------------------------------------------------------------*/
  690.     EntryNewScreen(SCR_ID_ALM_FMRDO_MANUAL_INPUT, mmi_alm_exit_fmrdo_manual_input, NULL, NULL);
  691.     InitializeCategory57Screen();
  692.     guiBuffer = GetCurrGuiBuffer(SCR_ID_ALM_FMRDO_MANUAL_INPUT);
  693.     inputBuffer = GetCurrNInputBuffer(SCR_ID_ALM_FMRDO_MANUAL_INPUT, &inputBufferSize);
  694.     RegisterHighlightHandler(mmi_alm_fmrdo_manual_input_highlight_hdlr);
  695.     if (guiBuffer == NULL)
  696.     {
  697.         if (g_alm_cntx.CurrHiliteAudioOption != ALM_AUDIO_OPTIONS_FMRADIO_MANUAL)
  698.         {
  699.             memset(channel_manual_input_buffer, 0, 2);
  700.         }
  701.         else
  702.         {
  703.             kal_wsprintf(
  704.                 channel_manual_input_buffer,
  705.                 "%d.%d",
  706.                 g_alm_cntx.CurrHiliteAudioOptionValue / 10,
  707.                 g_alm_cntx.CurrHiliteAudioOptionValue % 10);
  708.         }
  709.     }
  710.     SetInlineItemActivation(&wgui_inline_items[0], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  711.     SetInlineItemTextEdit(
  712.         &wgui_inline_items[0],
  713.         (U8*) channel_manual_input_buffer,
  714.         MAX_MANUAL_INPUT_LEN,
  715.         INPUT_TYPE_DECIMAL_NUMERIC);
  716.     LeftJustifyInlineItem(&wgui_inline_items[0]);
  717.     SetInlineItemFullWidth(&wgui_inline_items[0]);
  718.     EnableInlineItemBoundary(&wgui_inline_items[0]);
  719.     DisableCategory57ScreenDone();
  720.     /* show category screen */
  721.     ShowCategory57Screen(
  722.         STR_ID_ALM_AUDIO_OPTIONS_FMRADIO_MAN_INPUT,
  723.         MAIN_MENU_TITLE_MULTIMEDIA_ICON,    /* title text and icon */
  724.         STR_GLOBAL_OPTIONS,
  725.         IMG_GLOBAL_OPTIONS,                 /* LSK text and icon */
  726.         STR_GLOBAL_BACK,
  727.         IMG_GLOBAL_BACK,                    /* RSK text and icon */
  728.         1,
  729.         0,
  730.         wgui_inline_items,
  731.         0,
  732.         guiBuffer);
  733.     SetCategory57LeftSoftkeyFunction(mmi_alm_fmrdo_manual_input_options);
  734.     SetCategory57RightSoftkeyFunctions(GoBackHistory, GoBackHistory);
  735. }
  736. /*****************************************************************************
  737.  * FUNCTION
  738.  *  mmi_alm_exit_fmrdo_manual_input
  739.  * DESCRIPTION
  740.  *  The exit function for the manual input screen
  741.  * PARAMETERS
  742.  *  void
  743.  * RETURNS
  744.  *  void
  745.  *****************************************************************************/
  746. void mmi_alm_exit_fmrdo_manual_input(void)
  747. {
  748.     /*----------------------------------------------------------------*/
  749.     /* Local Variables                                                */
  750.     /*----------------------------------------------------------------*/
  751.     history h;
  752.     U16 inputBufferSize;
  753.     /*----------------------------------------------------------------*/
  754.     /* Code Body                                                      */
  755.     /*----------------------------------------------------------------*/
  756.     CloseCategory57Screen();
  757.     h.scrnID = SCR_ID_ALM_FMRDO_MANUAL_INPUT;
  758.     h.entryFuncPtr = mmi_alm_entry_fmrdo_manual_input;
  759.     GetCategoryHistory(h.guiBuffer);
  760.     inputBufferSize = (U16) GetCategory57DataSize();
  761.     GetCategory57Data((U8*) h.inputBuffer);
  762.     AddNHistory(h, inputBufferSize);
  763. }
  764. /*****************************************************************************
  765.  * FUNCTION
  766.  *  mmi_alm_fmrdo_manual_input_highlight_hdlr
  767.  * DESCRIPTION
  768.  *  The highlight handler function for the manual input screen
  769.  * PARAMETERS
  770.  *  index       [IN]        
  771.  * RETURNS
  772.  *  void
  773.  *****************************************************************************/
  774. void mmi_alm_fmrdo_manual_input_highlight_hdlr(S32 index)
  775. {
  776.     /*----------------------------------------------------------------*/
  777.     /* Local Variables                                                */
  778.     /*----------------------------------------------------------------*/
  779.     /*----------------------------------------------------------------*/
  780.     /* Code Body                                                      */
  781.     /*----------------------------------------------------------------*/
  782. }
  783. /*****************************************************************************
  784.  * FUNCTION
  785.  *  mmi_alm_fmrdo_manual_input_options
  786.  * DESCRIPTION
  787.  *  The LSK function for manual input screen
  788.  * PARAMETERS
  789.  *  void
  790.  * RETURNS
  791.  *  void
  792.  *****************************************************************************/
  793. void mmi_alm_fmrdo_manual_input_options()
  794. {   /* calculate frequency number */
  795.     /*----------------------------------------------------------------*/
  796.     /* Local Variables                                                */
  797.     /*----------------------------------------------------------------*/
  798.     U16 freq = mmi_fmrdo_get_freq_from_str(channel_manual_input_buffer);
  799.     /*----------------------------------------------------------------*/
  800.     /* Code Body                                                      */
  801.     /*----------------------------------------------------------------*/
  802.     /* check frequency input */
  803.     if (freq == 0xffff) /* invalid decimal digit */
  804.     {
  805.         DisplayPopup(
  806.             (PU8) GetString(STR_ID_FMRDO_VALID_FM_DECIMAL),
  807.             IMG_GLOBAL_WARNING,
  808.             1,
  809.             UI_POPUP_NOTIFYDURATION_TIME_2000,
  810.             (U8) WARNING_TONE);
  811.     }
  812.     else if (freq < MIN_FM_FREQUENCY || freq > MAX_FM_FREQUENCY)        /* warning invalid frequency */
  813.     {
  814.         DisplayPopup(
  815.             (PU8) GetString(STR_ID_ALM_FMRDO_VALID_FM_BANDWIDTH),
  816.             IMG_GLOBAL_WARNING,
  817.             1,
  818.             UI_POPUP_NOTIFYDURATION_TIME_2000,
  819.             (U8) WARNING_TONE);
  820.     }
  821.     else
  822.     {
  823.         mmi_alm_entry_fmrdo_manual_input_options();
  824.     }
  825. }
  826. /*****************************************************************************
  827.  * FUNCTION
  828.  *  mmi_alm_entry_fmrdo_manual_input_options
  829.  * DESCRIPTION
  830.  *  Entry function for the manual input options screen
  831.  * PARAMETERS
  832.  *  void
  833.  * RETURNS
  834.  *  void
  835.  *****************************************************************************/
  836. void mmi_alm_entry_fmrdo_manual_input_options(void)
  837. {
  838.     /*----------------------------------------------------------------*/
  839.     /* Local Variables                                                */
  840.     /*----------------------------------------------------------------*/
  841.     U8 *gui_buffer_p;
  842.     U16 item_texts[] = {STR_GLOBAL_DONE, STR_ID_ALM_AUDIO_OPT_FMRDO_OPT_PREV};
  843.     U16 item_icons[] = {IMG_GLOBAL_L1, IMG_GLOBAL_L2};
  844.     U8 *item_popups[] = {NULL, NULL};
  845.     /*----------------------------------------------------------------*/
  846.     /* Code Body                                                      */
  847.     /*----------------------------------------------------------------*/
  848.     EntryNewScreen(SCR_ID_ALM_FMRDO_MANUAL_INPUT_OPT, NULL, mmi_alm_entry_fmrdo_manual_input_options, NULL);
  849.     gui_buffer_p = GetCurrGuiBuffer(SCR_ID_ALM_FMRDO_MANUAL_INPUT_OPT);
  850.     RegisterHighlightHandler(mmi_alm_fmrdo_manual_input_opt_highlight_hdlr);
  851.     ShowCategory52Screen(
  852.         STR_GLOBAL_OPTIONS,
  853.         0,
  854.         STR_GLOBAL_OK,
  855.         0,
  856.         STR_GLOBAL_BACK,
  857.         0,
  858.         2,
  859.         item_texts,
  860.         item_icons,
  861.         (U8 **) item_popups,
  862.         0,
  863.         0,
  864.         gui_buffer_p);
  865.     SetLeftSoftkeyFunction(mmi_alm_fmrdo_manual_input_opt_lsk_hdlr, KEY_EVENT_UP);
  866.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  867. }
  868. /*****************************************************************************
  869.  * FUNCTION
  870.  *  mmi_alm_fmrdo_manual_input_opt_lsk_hdlr
  871.  * DESCRIPTION
  872.  *  LSK handler for the manual input options screen
  873.  * PARAMETERS
  874.  *  void
  875.  *  index(?)        [IN]        Index of inline selection
  876.  * RETURNS
  877.  *  void
  878.  *****************************************************************************/
  879. void mmi_alm_fmrdo_manual_input_opt_lsk_hdlr(void)
  880. {
  881.     /*----------------------------------------------------------------*/
  882.     /* Local Variables                                                */
  883.     /*----------------------------------------------------------------*/
  884.     U16 freq = mmi_fmrdo_get_freq_from_str(channel_manual_input_buffer);
  885.     /*----------------------------------------------------------------*/
  886.     /* Code Body                                                      */
  887.     /*----------------------------------------------------------------*/
  888.     switch (g_alm_fmrdo_man_inp_opt_index)
  889.     {
  890.         case STR_GLOBAL_DONE:
  891.             g_alm_cntx.CurrHiliteAudioOptionValue = freq;
  892.             g_alm_cntx.CurrHiliteAudioOption = ALM_AUDIO_OPTIONS_FMRADIO_MANUAL;
  893.             g_alm_aud_opt_selected = TRUE;
  894.             GoBackToHistory(SCR_ID_ALM_EDITOR);
  895.             break;
  896.         case STR_ID_ALM_AUDIO_OPT_FMRDO_OPT_PREV:
  897.             g_alm_fmrdo_prev_freq = freq;
  898.     #ifdef __MMI_FM_RADIO_BIND_EARPHONE__
  899.             if (!isEarphonePlugged)
  900.             {
  901.                 /* DisplayPopupCallBack( (PU8)GetString( STR_ID_ALM_FMRDO_PLEASE_PLUG_IN_EARPHONE ), IMG_GLOBAL_WARNING, 1, 2000, (U8)WARNING_TONE,mmi_alm_entry_fmrdo_prev_channel ); */
  902.                 DisplayPopup(
  903.                     (U8*) GetString(STR_ID_ALM_FMRDO_PLEASE_PLUG_IN_EARPHONE),
  904.                     IMG_GLOBAL_WARNING,
  905.                     1,
  906.                     UI_POPUP_NOTIFYDURATION_TIME_2000,
  907.                     WARNING_TONE);
  908.             }
  909.             else
  910.     #endif /* __MMI_FM_RADIO_BIND_EARPHONE__ */ 
  911.                 mmi_alm_entry_fmrdo_prev_channel();
  912.             break;
  913.     }
  914. }
  915. /*****************************************************************************
  916.  * FUNCTION
  917.  *  mmi_alm_entry_fmrdo_prev_channel
  918.  * DESCRIPTION
  919.  *  Entry function for the preview screen
  920.  * PARAMETERS
  921.  *  void
  922.  *  index(?)        [IN]        Index of inline selection
  923.  * RETURNS
  924.  *  void
  925.  *****************************************************************************/
  926. void mmi_alm_entry_fmrdo_prev_channel(void)
  927. {
  928.     /*----------------------------------------------------------------*/
  929.     /* Local Variables                                                */
  930.     /*----------------------------------------------------------------*/
  931.     U16 str[32];
  932.     U8 vol;
  933.     /*----------------------------------------------------------------*/
  934.     /* Code Body                                                      */
  935.     /*----------------------------------------------------------------*/
  936.     kal_wsprintf(str, "FM %d.%d", g_alm_fmrdo_prev_freq / 10, g_alm_fmrdo_prev_freq % 10);
  937.     /* mdi function calls */
  938.     vol = mmi_fmrdo_get_volume();
  939.     mdi_audio_stop_fmr();
  940.     mdi_audio_set_volume(AUD_VOLUME_FMR, vol);
  941.     mdi_fmr_power_on_with_path(MDI_DEVICE_SPEAKER2, NULL);
  942.     mdi_fmr_set_freq(g_alm_fmrdo_prev_freq);
  943.     EntryNewScreen(SCR_ID_ALM_FMRDO_PREV, mmi_alm_exit_fmrdo_prev_channel, NULL, NULL);
  944.     /* clear End key */
  945.     ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  946.     ClearKeyHandler(KEY_END, KEY_LONG_PRESS);
  947.     /* Show searching screen */
  948.     ShowCategory66Screen(
  949.         STR_ID_ALM_AUDIO_OPT_FMRDO_OPT_PREV,
  950.         0,
  951.         0,
  952.         0,
  953.         STR_GLOBAL_BACK,
  954.         0,
  955.         (U8*) str,
  956.         IMG_GLOBAL_PROGRESS,
  957.         NULL);
  958.     /* Set RSK to abort searching */
  959.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  960.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  961. }
  962. /*****************************************************************************
  963.  * FUNCTION
  964.  *  mmi_alm_exit_fmrdo_prev_channel
  965.  * DESCRIPTION
  966.  *  The interface for calling the mdi function for stopping the FM Radio.
  967.  * PARAMETERS
  968.  *  void
  969.  * RETURNS
  970.  *  void
  971.  *****************************************************************************/
  972. void mmi_alm_exit_fmrdo_prev_channel(void)
  973. {
  974.     /*----------------------------------------------------------------*/
  975.     /* Local Variables                                                */
  976.     /*----------------------------------------------------------------*/
  977.     /*----------------------------------------------------------------*/
  978.     /* Code Body                                                      */
  979.     /*----------------------------------------------------------------*/
  980.     mdi_audio_stop_fmr();
  981. }
  982. /*****************************************************************************
  983.  * FUNCTION
  984.  *  mmi_alm_fmrdo_manual_input_opt_highlight_hdlr
  985.  * DESCRIPTION
  986.  *  Highlight handler for the manual input options screen
  987.  * PARAMETERS
  988.  *  index       [IN]        Index of inline selection
  989.  * RETURNS
  990.  *  void
  991.  *****************************************************************************/
  992. void mmi_alm_fmrdo_manual_input_opt_highlight_hdlr(S32 index)
  993. {
  994.     /*----------------------------------------------------------------*/
  995.     /* Local Variables                                                */
  996.     /*----------------------------------------------------------------*/
  997.     U16 item_texts[] = {STR_GLOBAL_DONE, STR_ID_ALM_AUDIO_OPT_FMRDO_OPT_PREV};
  998.     /*----------------------------------------------------------------*/
  999.     /* Code Body                                                      */
  1000.     /*----------------------------------------------------------------*/
  1001.     g_alm_fmrdo_man_inp_opt_index = item_texts[index];
  1002. }
  1003. /*****************************************************************************
  1004.  * FUNCTION
  1005.  *  HighlightAlmInlineAudioOptions
  1006.  * DESCRIPTION
  1007.  *  Highlight handler of Alarm Audio Options inline selection item in editor screen.
  1008.  * PARAMETERS
  1009.  *  index       [IN]        Index of inline selection
  1010.  * RETURNS
  1011.  *  void
  1012.  *****************************************************************************/
  1013. void HighlightAlmInlineAudioOptions(S32 index)
  1014. {
  1015. #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__)
  1016.     /*----------------------------------------------------------------*/
  1017.     /* Local Variables                                                */
  1018.     /*----------------------------------------------------------------*/
  1019.     DYNAUDIOINFO *download_theme_tones = NULL;
  1020.     /*----------------------------------------------------------------*/
  1021.     /* Code Body                                                      */
  1022.     /*----------------------------------------------------------------*/
  1023.     if (mmi_tm_get_current_theme_ringtone())
  1024.     {
  1025.         GetThemeV2TonesInfo(&download_theme_tones);
  1026.     }
  1027. #endif /* defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__) */ 
  1028.     /* If selection item changed */
  1029.     if (!((g_alm_cntx.CurrHiliteAudioOption && index) || (!g_alm_cntx.CurrHiliteAudioOption && !index)))
  1030.     {
  1031.         g_alm_cntx.CurrHiliteAudioOptionValue = 0;
  1032.         Category57ChangeItemText(g_alm_aud_opt_curselitem_inline_index, (U8*) GetString(STR_GLOBAL_EMPTY_LIST));
  1033.     #ifndef __MMI_ALM_CUSTOMIZE_TONE__
  1034.         if (!index)
  1035.         {
  1036.             U16 sel_tone = gcurrentprofile.toneSetup.alarmTone;
  1037.             U8 tone_index;
  1038.             g_alm_cntx.CurrHiliteAudioOptionValue = gcurrentprofile.toneSetup.alarmTone;
  1039.             if ((sel_tone >= gstartRingId) && (sel_tone <= (gstartRingId + gtotalRingId - 1)))
  1040.             {
  1041.                 tone_index = sel_tone - gstartRingId;
  1042.                 Category57ChangeItemText(
  1043.                     g_alm_aud_opt_curselitem_inline_index,
  1044.                     (U8*) GetString((U16) (STR_PROFILES_RING_1 + tone_index)));
  1045.             }
  1046.             else if ((sel_tone) >= gstartMidiId && (sel_tone) <= (gstartMidiId + gtotalMidiId - 1))
  1047.             {
  1048.                 tone_index = (sel_tone - (gstartMidiId) + gtotalRingId);
  1049.                 Category57ChangeItemText(
  1050.                     g_alm_aud_opt_curselitem_inline_index,
  1051.                     (U8*) GetString((U16) (STR_PROFILES_RING_1 + tone_index)));
  1052.             }
  1053.         #if defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  1054.             else if (sel_tone >= PMG_EXT_MELODY_BEGIN && sel_tone <= PMG_EXT_MELODY_END)
  1055.             {
  1056.                 DYNEXTMELODYINFO *ExtMelodyInfo;
  1057.                 tone_index = sel_tone - PMG_EXT_MELODY_BEGIN;
  1058.                 PmgGetExtMelodyInfo(&ExtMelodyInfo);
  1059.                 if (IS_EXTMELODY_SHORTNAME(ExtMelodyInfo->info[tone_index].filepath) &&
  1060.                     g_alm_ext_melody_short_name_ptr != NULL)
  1061.                 {
  1062.                     mmi_chset_mixed_text_to_ucs2_str(
  1063.                         g_alm_ext_melody_short_name_ptr,
  1064.                         (FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH,
  1065.                         (U8*) ExtMelodyInfo->info[tone_index].filename,
  1066.                         g_chset_text_encoding);
  1067.                     Category57ChangeItemText(g_alm_aud_opt_curselitem_inline_index, g_alm_ext_melody_short_name_ptr);                    
  1068.                 }
  1069.                 else
  1070.                 {
  1071.                     Category57ChangeItemText(g_alm_aud_opt_curselitem_inline_index,(ExtMelodyInfo->info[tone_index]).filename);
  1072.                 }
  1073.             }
  1074.         #endif /* defined(__MMI_PROFILE_EXTMELODY_SUPPORT__) */ 
  1075.         #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__)
  1076.             else if (download_theme_tones != NULL && sel_tone == download_theme_tones[0].AudioId)
  1077.             {
  1078.                 Category57ChangeItemText(
  1079.                     g_alm_aud_opt_curselitem_inline_index,
  1080.                     (U8*) GetString(STR_PROFILES_CURR_THEME));
  1081.             }
  1082.         #endif /* defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__) */ 
  1083.         }
  1084.     #endif /* __MMI_ALM_CUSTOMIZE_TONE__ */ 
  1085.     }
  1086.     else    /* if the user has selected the same audio option which is the CurrHiliteAudioOption */
  1087.     {
  1088.         if (g_alm_cntx.CurrHiliteAudioOption == ALM_AUDIO_OPTIONS_FMRADIO_CHANNEL)
  1089.         {
  1090.             U16 index = g_alm_cntx.CurrHiliteAudioOptionValue - 1;
  1091.             if (g_fmrdo.channel_list.freq[index] < MIN_FM_FREQUENCY ||
  1092.                 g_fmrdo.channel_list.freq[index] > MAX_FM_FREQUENCY)
  1093.             {
  1094.                 Category57ChangeItemText(
  1095.                     g_alm_aud_opt_curselitem_inline_index,
  1096.                     (U8*) GetString((U16) (STR_GLOBAL_EMPTY_LIST)));
  1097.             }
  1098.             else
  1099.             {
  1100.                 Category57ChangeItemText(g_alm_aud_opt_curselitem_inline_index, (U8*) g_alm_audio_options_curselitem);
  1101.             }
  1102.         }
  1103.         else if (g_alm_cntx.CurrHiliteAudioOption == ALM_AUDIO_OPTIONS_FMRADIO_MANUAL)
  1104.         {
  1105.             if (g_alm_cntx.CurrHiliteAudioOptionValue < MIN_FM_FREQUENCY ||
  1106.                 g_alm_cntx.CurrHiliteAudioOptionValue > MAX_FM_FREQUENCY)
  1107.             {
  1108.                 Category57ChangeItemText(
  1109.                     g_alm_aud_opt_curselitem_inline_index,
  1110.                     (U8*) GetString((U16) (STR_GLOBAL_EMPTY_LIST)));
  1111.             }
  1112.             else
  1113.             {
  1114.                 Category57ChangeItemText(g_alm_aud_opt_curselitem_inline_index, (U8*) g_alm_audio_options_curselitem);
  1115.             }
  1116.         }
  1117.         else
  1118.         {
  1119.         #ifdef __MMI_ALM_CUSTOMIZE_TONE__
  1120.             U16 sel_tone = g_alm_cntx.CurrHiliteAudioOptionValue;
  1121.         #else 
  1122.             U16 sel_tone = gcurrentprofile.toneSetup.alarmTone;
  1123.         #endif 
  1124.             U8 tone_index;
  1125.             if ((sel_tone >= gstartRingId) && (sel_tone <= (gstartRingId + gtotalRingId - 1)))
  1126.             {
  1127.                 tone_index = sel_tone - gstartRingId;
  1128.                 Category57ChangeItemText(
  1129.                     g_alm_aud_opt_curselitem_inline_index,
  1130.                     (U8*) GetString((U16) (STR_PROFILES_RING_1 + tone_index)));
  1131.             }
  1132.             else if ((sel_tone >= gstartMidiId) && (sel_tone <= (gstartMidiId + gtotalMidiId - 1)))
  1133.             {
  1134.                 tone_index = (sel_tone - gstartMidiId + gtotalRingId);
  1135.                 Category57ChangeItemText(
  1136.                     g_alm_aud_opt_curselitem_inline_index,
  1137.                     (U8*) GetString((U16) (STR_PROFILES_RING_1 + tone_index)));
  1138.             }
  1139.         #if defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  1140.             else if (sel_tone >= PMG_EXT_MELODY_BEGIN && sel_tone <= PMG_EXT_MELODY_END)
  1141.             {
  1142.                 DYNEXTMELODYINFO *ExtMelodyInfo;
  1143.                 tone_index = sel_tone - PMG_EXT_MELODY_BEGIN;
  1144.                 PmgGetExtMelodyInfo(&ExtMelodyInfo);
  1145.                 if (IS_EXTMELODY_SHORTNAME(ExtMelodyInfo->info[tone_index].filepath) &&
  1146.                     g_alm_ext_melody_short_name_ptr != NULL)
  1147.                 {
  1148.                     mmi_chset_mixed_text_to_ucs2_str(
  1149.                         g_alm_ext_melody_short_name_ptr,
  1150.                         (FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH,
  1151.                         (U8*) ExtMelodyInfo->info[tone_index].filename,
  1152.                         g_chset_text_encoding);
  1153.                     Category57ChangeItemText(g_alm_aud_opt_curselitem_inline_index, g_alm_ext_melody_short_name_ptr);                    
  1154.                 }
  1155.                 else
  1156.                 {
  1157.                     Category57ChangeItemText(g_alm_aud_opt_curselitem_inline_index,(ExtMelodyInfo->info[tone_index]).filename);
  1158.                 }
  1159.             }
  1160.         #endif /* defined(__MMI_PROFILE_EXTMELODY_SUPPORT__) */ 
  1161.         #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__)
  1162.             else if (download_theme_tones != NULL && sel_tone == download_theme_tones[0].AudioId)
  1163.             {
  1164.                 Category57ChangeItemText(
  1165.                     g_alm_aud_opt_curselitem_inline_index,
  1166.                     (U8*) GetString(STR_PROFILES_CURR_THEME));
  1167.             }
  1168.         #endif /* defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__) */ 
  1169.             else
  1170.             {
  1171.                 g_alm_cntx.CurrHiliteAudioOptionValue = 0;
  1172.                 Category57ChangeItemText(
  1173.                     g_alm_aud_opt_curselitem_inline_index,
  1174.                     (U8*) GetString((U16) (STR_GLOBAL_EMPTY_LIST)));
  1175.             }
  1176.         }
  1177.     }
  1178.     RedrawCategory57Screen();
  1179. }
  1180. /*****************************************************************************
  1181.  * FUNCTION
  1182.  *  mmi_alm_aud_fmrdo_init_channe_list
  1183.  * DESCRIPTION
  1184.  *  This function is to check if the channel in FM radio initialized.
  1185.  * PARAMETERS
  1186.  *  void
  1187.  * RETURNS
  1188.  *  void
  1189.  *****************************************************************************/
  1190. void mmi_alm_aud_fmrdo_init_channe_list(void)
  1191. {
  1192.     /*----------------------------------------------------------------*/
  1193.     /* Local Variables                                                */
  1194.     /*----------------------------------------------------------------*/
  1195.     S16 error;
  1196.     /*----------------------------------------------------------------*/
  1197.     /* Code Body                                                      */
  1198.     /*----------------------------------------------------------------*/
  1199.     if (!g_fmrdo.is_ready && !g_alm_fmrdo_read_channel_name)
  1200.     {
  1201.         ReadRecord(NVRAM_EF_FM_RADIO_LID, 1, (void*)&g_fmrdo.channel_list, NVRAM_EF_FM_RADIO_SIZE, &error);
  1202.         if(g_fmrdo.channel_list.name[0][0] == 0xFFFF)
  1203.         {
  1204.             memset(&g_fmrdo.channel_list, 0, sizeof(mmi_fmrdo_channel_list_struct));
  1205.         }
  1206.         g_alm_fmrdo_read_channel_name = TRUE;
  1207.     }
  1208. }
  1209. /*****************************************************************************
  1210.  * FUNCTION
  1211.  *  mmi_alm_aud_fmrdo_play_alarm
  1212.  * DESCRIPTION
  1213.  *  This function is to play the FM radio when alarm expired.
  1214.  * PARAMETERS
  1215.  *  alarm_index     [IN]        
  1216.  *  volume          [IN]        
  1217.  * RETURNS
  1218.  *  void
  1219.  *****************************************************************************/
  1220. void mmi_alm_aud_fmrdo_play_alarm(U8 alarm_index, U8 volume)
  1221. {
  1222.     /*----------------------------------------------------------------*/
  1223.     /* Local Variables                                                */
  1224.     /*----------------------------------------------------------------*/
  1225.     U16 freq = 0;
  1226.     /*----------------------------------------------------------------*/
  1227.     /* Code Body                                                      */
  1228.     /*----------------------------------------------------------------*/
  1229.     /* check if FM Radio freqency set */
  1230.     if (g_alm_cntx.AlmList[alarm_index].AudioOption == ALM_AUDIO_OPTIONS_FMRADIO_CHANNEL)
  1231.     {
  1232.         mmi_alm_aud_fmrdo_init_channe_list();
  1233.         if ((g_alm_cntx.AlmList[alarm_index].AudioOptionValue > 0) &&
  1234.             (g_alm_cntx.AlmList[alarm_index].AudioOptionValue <= FM_RADIO_CHANNEL_NUM))
  1235.         {
  1236.             freq = g_fmrdo.channel_list.freq[g_alm_cntx.AlmList[alarm_index].AudioOptionValue - 1];
  1237.         }
  1238.     }
  1239.     else if (g_alm_cntx.AlmList[alarm_index].AudioOption == ALM_AUDIO_OPTIONS_FMRADIO_MANUAL)
  1240.     {
  1241.         freq = g_alm_cntx.AlmList[alarm_index].AudioOptionValue;
  1242.     }
  1243.     if ((freq >= MIN_FM_FREQUENCY) && (freq <= MAX_FM_FREQUENCY))
  1244.     {
  1245.         mdi_audio_stop_fmr();
  1246.         mdi_audio_set_volume(MDI_VOLUME_FMR, volume);
  1247.         mdi_fmr_power_on_with_path(MDI_DEVICE_SPEAKER_BOTH, NULL);
  1248.         mdi_fmr_set_freq(freq);
  1249.     }
  1250.     /* Play default ring tone and restore alarm to default value */
  1251.     else
  1252.     {
  1253.         g_alm_cntx.AlmList[alarm_index].AudioOption = ALM_AUDIO_OPTIONS_TONE;
  1254.         g_alm_cntx.AlmList[alarm_index].AudioOptionValue = (U16) (gstartMidiId + 1);
  1255.         AlmWriteToNvram();
  1256.         playRequestedTone(ALARM_TONE);
  1257.     }
  1258. }
  1259. #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ 
  1260. /*****************************************************************************
  1261.  * FUNCTION
  1262.  *  AlmIsInlineEditorChanged
  1263.  * DESCRIPTION
  1264.  *  To check if alarm is changed in inline editor screen.
  1265.  * PARAMETERS
  1266.  *  index       [IN]        Index of inline selection
  1267.  * RETURNS
  1268.  *  TURE if alarm is changed; otherwise, FLASE.
  1269.  *****************************************************************************/
  1270. BOOL AlmIsInlineEditorChanged(S32 index)
  1271. {
  1272.     /*----------------------------------------------------------------*/
  1273.     /* Local Variables                                                */
  1274.     /*----------------------------------------------------------------*/
  1275.     U8 tmpHour = (g_alm_cntx.HourBuf[0] - '0') * 10 + (g_alm_cntx.HourBuf[ENCODING_LENGTH] - '0');
  1276.     U8 tmpMin = (g_alm_cntx.MinBuf[0] - '0') * 10 + (g_alm_cntx.MinBuf[ENCODING_LENGTH] - '0');
  1277.     /*----------------------------------------------------------------*/
  1278.     /* Code Body                                                      */
  1279.     /*----------------------------------------------------------------*/
  1280.     if (
  1281. #ifdef __MMI_ALM_CUST_VOLUME__
  1282.            (g_alm_cntx.AlmList[index].Volume != g_alm_cntx.CurrHiliteVol) ||
  1283. #endif 
  1284.            (g_alm_cntx.AlmList[index].State != g_alm_cntx.CurrHiliteState) ||
  1285.            (g_alm_cntx.AlmList[index].Freq != (U8) g_alm_cntx.CurrHiliteFreq) ||
  1286.            (g_alm_cntx.AlmList[index].Hour != tmpHour) || (g_alm_cntx.AlmList[index].Min != tmpMin))
  1287.     {
  1288.         return TRUE;
  1289.     }
  1290. #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1291.     else if ((g_alm_cntx.AlmList[index].AudioOption != g_alm_cntx.CurrHiliteAudioOption))
  1292.     {
  1293.         return TRUE;
  1294.     }
  1295.     else if (g_alm_cntx.AlmList[index].AudioOptionValue != g_alm_cntx.CurrHiliteAudioOptionValue)
  1296.     {
  1297.         return TRUE;
  1298.     }
  1299. #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ 
  1300.     else if (g_alm_freq_set[g_alm_cntx.AlmList[index].Freq] == ALM_FREQ_DAYS)
  1301.     {
  1302.         return TRUE;
  1303.     }
  1304. #ifdef __MMI_ALM_SNOOZE_SETTING__
  1305.     else if (g_alm_cntx.AlmList[index].SnoozeInterval != (U8) g_alm_cntx.CurrHilightSnoozeInterval)
  1306.     {
  1307.         return TRUE;
  1308.     }
  1309. #endif /* __MMI_ALM_SNOOZE_SETTING__ */ 
  1310. #ifdef __MMI_ALM_ALERT_TYPE__
  1311.     else if (g_alm_cntx.AlmList[index].AlertType != (U8) g_alm_cntx.CurrHilightAlertType)
  1312.     {
  1313.         return TRUE;
  1314.     }
  1315. #endif /* __MMI_ALM_ALERT_TYPE__ */ 
  1316.     else
  1317.     {
  1318.         return FALSE;
  1319.     }
  1320. }
  1321. /*****************************************************************************
  1322.  * FUNCTION
  1323.  *  AlmInlineEditHighlightHdlr
  1324.  * DESCRIPTION
  1325.  *  Alarm editor highlight handler
  1326.  * PARAMETERS
  1327.  *  index       [IN]        
  1328.  * RETURNS
  1329.  *  void
  1330.  *****************************************************************************/
  1331. void AlmInlineEditHighlightHdlr(S32 index)
  1332. {
  1333. #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1334.     /*----------------------------------------------------------------*/
  1335.     /* Local Variables                                                */
  1336.     /*----------------------------------------------------------------*/
  1337.     /*----------------------------------------------------------------*/
  1338.     /* Code Body                                                      */
  1339.     /*----------------------------------------------------------------*/
  1340.     if (index == g_alm_aud_opt_curselitem_inline_index)
  1341.     {
  1342.         ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  1343.         if (g_alm_audio_option_previndex == ALM_AUDIO_OPTIONS_TONE)
  1344.         {
  1345.         #ifdef __MMI_ALM_CUSTOMIZE_TONE__
  1346.             SetLeftSoftkeyFunction(mmi_alm_entry_aud_opt_tone, KEY_EVENT_UP);
  1347.         #else /* __MMI_ALM_CUSTOMIZE_TONE__ */ 
  1348.             ChangeLeftSoftkey(0, 0);
  1349.             ClearKeyHandler(KEY_LSK, KEY_EVENT_UP);
  1350.         #endif /* __MMI_ALM_CUSTOMIZE_TONE__ */ 
  1351.         }
  1352.         else
  1353.         {
  1354.             SetLeftSoftkeyFunction(mmi_alm_entry_aud_opt_fmrdo, KEY_EVENT_UP);
  1355.         }
  1356.     }
  1357. #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ 
  1358. }
  1359. /*****************************************************************************
  1360.  * FUNCTION
  1361.  *  EntryAlmEditScreen
  1362.  * DESCRIPTION
  1363.  *  Display inline editor screen of alarm.
  1364.  * PARAMETERS
  1365.  *  void
  1366.  * RETURNS
  1367.  *  void
  1368.  *****************************************************************************/
  1369. void EntryAlmEditScreen(void)
  1370. {
  1371.     /*----------------------------------------------------------------*/
  1372.     /* Local Variables                                                */
  1373.     /*----------------------------------------------------------------*/
  1374.     U8 *guiBuffer;
  1375.     U8 *inputBuffer;        /* added for inline edit history */
  1376.     U16 inputBufferSize;    /* added for inline edit history */
  1377.     U8 nMenuItems;
  1378.     U16 alarm_icon_list[] = {IMG_STATUS, IMG_TIME, IMG_REPEAT, 0, 0
  1379.     #ifdef __MMI_ALM_CUST_VOLUME__
  1380.             , ALARM_VOLUME_IMAGEID, 0
  1381.     #endif 
  1382.     #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1383.             , IMG_ALM_AUD_OPT, 0, 0
  1384.     #endif 
  1385.     #ifdef __MMI_ALM_SNOOZE_SETTING__
  1386.             , ALARMS_SET_SNOOZE_PERIOD_IMAGEID, 0
  1387.     #endif 
  1388.     #ifdef __MMI_ALM_ALERT_TYPE__
  1389.             , ALARMS_SET_ALERT_TYPE_IMAGEID, 0
  1390.     #endif 
  1391.     };
  1392.     /*----------------------------------------------------------------*/
  1393.     /* Code Body                                                      */
  1394.     /*----------------------------------------------------------------*/
  1395.     nMenuItems = sizeof(alarm_icon_list) / sizeof(U16);
  1396.     EntryNewScreen(SCR_ID_ALM_EDITOR, ExitAlmEditScreen, NULL, NULL);
  1397.     guiBuffer = GetCurrGuiBuffer(SCR_ID_ALM_EDITOR);
  1398.     InitializeCategory57Screen();
  1399.     RegisterHighlightHandler(AlmInlineEditHighlightHdlr);
  1400.     /* Use screen base memory to display short name of external melody*/
  1401. #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  1402.     g_alm_ext_melody_short_name_ptr = 
  1403.         (U8*) mmi_frm_scrmem_alloc((FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH);
  1404. #endif /* defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_PROFILE_EXTMELODY_SUPPORT__) */
  1405.     AlmFillInlineEditStruct();
  1406.     inputBuffer = GetCurrNInputBuffer(SCR_ID_ALM_EDITOR, &inputBufferSize);     /* added for inline edit history */
  1407.     if (inputBuffer != NULL)
  1408.     {
  1409.         SetCategory57Data(wgui_inline_items, nMenuItems, inputBuffer);
  1410.     }
  1411.     
  1412. #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1413.     if(guiBuffer == NULL)
  1414.     {
  1415.         g_alm_aud_opt_selected = FALSE;
  1416.     }
  1417.     else if (g_alm_aud_opt_selected)
  1418.     {
  1419.         SetInlineDoneFlag(guiBuffer);
  1420.     }
  1421. #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ 
  1422.     ShowCategory57Screen(
  1423.         ALARM_EDIT_TITLE_STRINGID,
  1424.         GetRootTitleIcon(ORGANIZER_ALARM_MENU),
  1425.         ALARM_STR_DONE,
  1426.         IMG_GLOBAL_OK,
  1427.         STR_GLOBAL_BACK,
  1428.         IMG_GLOBAL_BACK,
  1429.         nMenuItems,
  1430.         alarm_icon_list,
  1431.         wgui_inline_items,
  1432.         /* currItemAlarmEdit */ 0,
  1433.         guiBuffer);
  1434.     SetCategory57RightSoftkeyFunctions(EntryAlmSaveConfirmation, GoBackHistory);
  1435. }
  1436. /*****************************************************************************
  1437.  * FUNCTION
  1438.  *  ExitAlmEditScreen
  1439.  * DESCRIPTION
  1440.  *  Exit function for inline editor screen of alarm.
  1441.  * PARAMETERS
  1442.  *  void
  1443.  * RETURNS
  1444.  *  void
  1445.  *****************************************************************************/
  1446. void ExitAlmEditScreen(void)
  1447. {
  1448.     /*----------------------------------------------------------------*/
  1449.     /* Local Variables                                                */
  1450.     /*----------------------------------------------------------------*/
  1451.     history Scr;
  1452.     S16 nHistory = 0;
  1453.     U16 inputBufferSize;    /* added for inline edit history */
  1454.     /*----------------------------------------------------------------*/
  1455.     /* Code Body                                                      */
  1456.     /*----------------------------------------------------------------*/
  1457.     Scr.scrnID = SCR_ID_ALM_EDITOR;
  1458.     CloseCategory57Screen();
  1459.     Scr.entryFuncPtr = EntryAlmEditScreen;
  1460.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
  1461.     GetCategory57History(Scr.guiBuffer);
  1462.     inputBufferSize = (U16) GetCategory57DataSize();    /* added for inline edit history */
  1463.     GetCategory57Data((U8*) Scr.inputBuffer);           /* added for inline edit history */
  1464.     AddNHistory(Scr, inputBufferSize);                  /* added for inline edit history */
  1465.     /* Free screen memory*/
  1466. #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  1467.     mmi_frm_scrmem_free((void*)g_alm_ext_melody_short_name_ptr);
  1468.     g_alm_ext_melody_short_name_ptr = NULL;
  1469. #endif /*defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)*/
  1470. }
  1471. /*****************************************************************************
  1472.  * FUNCTION
  1473.  *  AlmTimeEditorCallBack
  1474.  * DESCRIPTION
  1475.  *  Callback function for inline time editor.
  1476.  * PARAMETERS
  1477.  *  string_buffer       [IN/OUT]        Buffer to store the result of time
  1478.  *  hours_buffer        [IN]            Buffer to store hour string
  1479.  *  min_buffer          [IN]            Buffer to store minute string
  1480.  *  AM_PM_flag          [IN]            Flag to indicate the time format of time string
  1481.  * RETURNS
  1482.  *  void
  1483.  *****************************************************************************/
  1484. void AlmTimeEditorCallBack(U8 *string_buffer, U8 *hours_buffer, U8 *min_buffer, U8 *AM_PM_flag)
  1485. {
  1486.     /*----------------------------------------------------------------*/
  1487.     /* Local Variables                                                */
  1488.     /*----------------------------------------------------------------*/
  1489.     /*----------------------------------------------------------------*/
  1490.     /* Code Body                                                      */
  1491.     /*----------------------------------------------------------------*/
  1492.     pfnUnicodeStrcpy((S8*) string_buffer, (S8*) hours_buffer);
  1493.     pfnUnicodeStrcat((S8*) string_buffer, (S8*) ":");
  1494.     pfnUnicodeStrcat((S8*) string_buffer, (S8*) min_buffer);
  1495. }
  1496. /*****************************************************************************
  1497.  * FUNCTION
  1498.  *  AlmFillInlineEditStruct
  1499.  * DESCRIPTION
  1500.  *  Initialize inline structure of input screen.
  1501.  * PARAMETERS
  1502.  *  void
  1503.  * RETURNS
  1504.  *  void
  1505.  *****************************************************************************/
  1506. void AlmFillInlineEditStruct()
  1507. {
  1508.     /*----------------------------------------------------------------*/
  1509.     /* Local Variables                                                */
  1510.     /*----------------------------------------------------------------*/
  1511.     S8 inline_item_index = 0, j;
  1512. #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  1513.     DYNEXTMELODYINFO *ExtMelodyInfo;
  1514. #endif 
  1515. #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__)
  1516.     DYNAUDIOINFO *download_theme_tones = NULL;
  1517.     /*----------------------------------------------------------------*/
  1518.     /* Code Body                                                      */
  1519.     /*----------------------------------------------------------------*/
  1520.     if (mmi_tm_get_current_theme_ringtone())
  1521.     {
  1522.         GetThemeV2TonesInfo(&download_theme_tones);
  1523.     }
  1524. #endif /* defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__) */ 
  1525. #ifdef __MMI_ALM_CUST_VOLUME__
  1526.     gAlmVolumeList[0] = (S8*) gAlmVolumeString[0];
  1527.     gAlmVolumeList[1] = (S8*) gAlmVolumeString[1];
  1528.     gAlmVolumeList[2] = (S8*) gAlmVolumeString[2];
  1529.     gAlmVolumeList[3] = (S8*) gAlmVolumeString[3];
  1530.     gAlmVolumeList[4] = (S8*) gAlmVolumeString[4];
  1531.     gAlmVolumeList[5] = (S8*) gAlmVolumeString[5];
  1532.     gAlmVolumeList[6] = (S8*) gAlmVolumeString[6];
  1533. #endif /* __MMI_ALM_CUST_VOLUME__ */ 
  1534. #ifdef __MMI_ALM_SNOOZE_SETTING__
  1535.     gAlmSettingSnooze[0] = GetString((U16) STR_ID_ALM_DEFAULT);
  1536.     gAlmSettingSnooze[1] = GetString((U16) STR_GLOBAL_1);
  1537.     gAlmSettingSnooze[2] = GetString((U16) STR_GLOBAL_2);
  1538.     gAlmSettingSnooze[3] = GetString((U16) STR_GLOBAL_3);
  1539.     gAlmSettingSnooze[4] = GetString((U16) STR_GLOBAL_4);
  1540.     gAlmSettingSnooze[5] = GetString((U16) STR_GLOBAL_5);
  1541.     gAlmSettingSnooze[6] = GetString((U16) STR_GLOBAL_6);
  1542.     gAlmSettingSnooze[7] = GetString((U16) STR_GLOBAL_7);
  1543.     gAlmSettingSnooze[8] = GetString((U16) STR_GLOBAL_8);
  1544.     gAlmSettingSnooze[9] = GetString((U16) STR_GLOBAL_9);
  1545.     gAlmSettingSnooze[10] = GetString((U16) STR_GLOBAL_10);
  1546. #endif /* __MMI_ALM_SNOOZE_SETTING__ */ 
  1547. #ifdef __MMI_ALM_ALERT_TYPE__
  1548.     gAlmSettingAlertType[ALM_ALERT_VIBRATION_AND_RING] = GetString((U16) STR_VIBRATION_AND_RING);
  1549.     gAlmSettingAlertType[ALM_ALERT_RING] = GetString((U16) STR_RING);
  1550.     gAlmSettingAlertType[ALM_ALERT_VIBRATION] = GetString((U16) STR_VIBRATION_ONLY);
  1551. #endif /* __MMI_ALM_ALERT_TYPE__ */ 
  1552.     for (j = 0; j < ALARM_FREQ_NUM; j++)
  1553.     {
  1554.         gAlmFreqList[j] = GetString((U16) (g_alm_freq_set[j] + ALARM_REPEAT_OFF_INDEX));
  1555.     }
  1556.     /* ON/OFF */
  1557.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1558.     SetInlineItemSelect(
  1559.         &(wgui_inline_items[inline_item_index]),
  1560.         NUM_STATE_FOR_ALM,
  1561.         (U8 **) gAlmOnOffString,
  1562.         &g_alm_cntx.CurrHiliteState /* (gAlmCurrHiliteState[g_alm_cntx.CurrHiliteAlarm]) */ );
  1563.     DisableInlineItemHighlight(&(wgui_inline_items[inline_item_index]));
  1564.     /* time */
  1565.     inline_item_index++;
  1566.     SetInlineItemActivation(
  1567.         &(wgui_inline_items[inline_item_index]),
  1568.         INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  1569.         KEY_EVENT_UP);
  1570.     SetInlineItemTime(
  1571.         &(wgui_inline_items[inline_item_index]),
  1572.         (U8*) g_alm_cntx.HourBuf,
  1573.         (U8*) g_alm_cntx.MinBuf,
  1574.         NULL,
  1575.         AlmTimeEditorCallBack);
  1576.     DisableInlineItemHighlight(&(wgui_inline_items[inline_item_index]));
  1577.     /* repeat caption */
  1578.     inline_item_index++;
  1579.     SetInlineItemCaption(&(wgui_inline_items[inline_item_index]), (U8*) GetString(ALARM_REPEAT_STRING));
  1580.     /* repeat */
  1581.     inline_item_index++;
  1582.     SetInlineItemSelect(&(wgui_inline_items[inline_item_index]), ALARM_FREQ_NUM, (U8 **) gAlmFreqList, &g_alm_cntx.CurrHiliteFreq);     /* -2 forweekdays and monthly */
  1583.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1584.     RegisterInlineSelectHighlightHandler(&wgui_inline_items[inline_item_index], HighlightAlmInlineRepeat);
  1585.     /* day of week */
  1586.     if (g_alm_freq_set[g_alm_cntx.CurrHiliteFreq] != ALM_FREQ_DAYS)     /* not Days */
  1587.     {
  1588.         memset(gAlmDaysStates, 0, 7);
  1589.     }
  1590.     inline_item_index++;
  1591.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1592.     SetInlineItemDOWSelect(&(wgui_inline_items[inline_item_index]), inline_item_index, gAlmDaysStates);
  1593.     /* day of week */
  1594.     if (g_alm_freq_set[g_alm_cntx.CurrHiliteFreq] != ALM_FREQ_DAYS)     /* not Days */
  1595.     {
  1596.         DisableInlineItem(&wgui_inline_items[inline_item_index], 4);    /* multi select days */
  1597.     }
  1598. #ifdef __MMI_ALM_CUST_VOLUME__
  1599.     /* volume */
  1600.     inline_item_index++;
  1601.     SetInlineItemCaption(&(wgui_inline_items[inline_item_index]), (U8*) GetString(ALARMS_VOLUME));
  1602.     inline_item_index++;
  1603.     SetInlineItemSelect(&(wgui_inline_items[inline_item_index]), (LEVEL7 + 1), (U8 **) gAlmVolumeList, &g_alm_cntx.CurrHiliteVol);      /* -2 forweekdays and monthly */
  1604.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1605. #endif /* __MMI_ALM_CUST_VOLUME__ */ 
  1606.     /* Customize Ring Tone and FM alarm */
  1607. #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1608.     /* Ring Tone Caption */
  1609.     inline_item_index++;
  1610.     SetInlineItemCaption(&(wgui_inline_items[inline_item_index]), (U8*) GetString(STR_ID_ALM_AUDIO_OPTIONS));
  1611.     g_alm_audio_option_previndex =
  1612.         (g_alm_cntx.CurrHiliteAudioOption >
  1613.          ALM_AUDIO_OPTIONS_TONE) ? ALM_AUDIO_OPTIONS_FMRADIO_CHANNEL : ALM_AUDIO_OPTIONS_TONE;
  1614.     inline_item_index++;
  1615.     /* Ring Tone Inline Selectt */
  1616.     SetInlineItemSelect(
  1617.         &(wgui_inline_items[inline_item_index]),
  1618.         NUM_AUDIO_OPTIONS,
  1619.         (U8 **) g_alm_audio_options_string,
  1620.         &g_alm_audio_option_previndex);
  1621.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1622.     RegisterInlineSelectHighlightHandler(&wgui_inline_items[inline_item_index], HighlightAlmInlineAudioOptions);
  1623.     inline_item_index++;
  1624.     g_alm_aud_opt_curselitem_inline_index = inline_item_index;
  1625.     if (g_alm_cntx.CurrHiliteAudioOption == ALM_AUDIO_OPTIONS_FMRADIO_CHANNEL)
  1626.     {
  1627.         if ((g_alm_cntx.CurrHiliteAudioOptionValue > 0) &&
  1628.             (g_alm_cntx.CurrHiliteAudioOptionValue <= FM_RADIO_CHANNEL_NUM))
  1629.         {
  1630.             U8 list_index = g_alm_cntx.CurrHiliteAudioOptionValue - 1;
  1631.             if (pfnUnicodeStrlen((S8*) g_fmrdo.channel_list.name[list_index]))
  1632.             {
  1633.                 pfnUnicodeStrcpy((S8*) g_alm_audio_options_curselitem, (S8*) g_fmrdo.channel_list.name[list_index]);
  1634.             }
  1635.             else
  1636.             {
  1637.                 kal_wsprintf(
  1638.                     g_alm_audio_options_curselitem,
  1639.                     "FM %d.%d",
  1640.                     g_fmrdo.channel_list.freq[list_index] / 10,
  1641.                     g_fmrdo.channel_list.freq[list_index] % 10);
  1642.             }
  1643.         }
  1644.         else
  1645.         {
  1646.             pfnUnicodeStrcpy((S8*) g_alm_audio_options_curselitem, GetString(STR_GLOBAL_EMPTY_LIST));
  1647.         }
  1648.         SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1649.         SetInlineItemDisplayOnly(&(wgui_inline_items[inline_item_index]), (U8*) g_alm_audio_options_curselitem);
  1650.     }
  1651.     else if (g_alm_cntx.CurrHiliteAudioOption == ALM_AUDIO_OPTIONS_FMRADIO_MANUAL)
  1652.     {
  1653.         if (g_alm_cntx.CurrHiliteAudioOptionValue > 0)
  1654.         {
  1655.             kal_wsprintf(
  1656.                 g_alm_audio_options_curselitem,
  1657.                 "FM %d.%d",
  1658.                 g_alm_cntx.CurrHiliteAudioOptionValue / 10,
  1659.                 g_alm_cntx.CurrHiliteAudioOptionValue % 10);
  1660.         }
  1661.         else
  1662.         {
  1663.             pfnUnicodeStrcpy((S8*) g_alm_audio_options_curselitem, GetString(STR_GLOBAL_EMPTY_LIST));
  1664.         }
  1665.         SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1666.         SetInlineItemDisplayOnly(&(wgui_inline_items[inline_item_index]), (U8*) g_alm_audio_options_curselitem);
  1667.     }
  1668.     else
  1669.     {
  1670.     #ifdef __MMI_ALM_CUSTOMIZE_TONE__
  1671.         U16 sel_tone = g_alm_cntx.CurrHiliteAudioOptionValue;
  1672.     #else 
  1673.         U16 sel_tone = gcurrentprofile.toneSetup.alarmTone;
  1674.     #endif 
  1675.         U8 tone_index;
  1676.         SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1677.         /* Ring Tone as Alarm */
  1678.         if ((sel_tone >= gstartRingId) && (sel_tone <= (gstartRingId + gtotalRingId - 1)))
  1679.         {
  1680.             tone_index = sel_tone - gstartRingId;
  1681.             SetInlineItemDisplayOnly(
  1682.                 &(wgui_inline_items[inline_item_index]),
  1683.                 (U8*) GetString((U16) (STR_PROFILES_RING_1 + tone_index)));
  1684.         }
  1685.         /* Midi Tone as Alarm */
  1686.         else if ((sel_tone >= gstartMidiId) && (sel_tone <= (gstartMidiId + gtotalMidiId - 1)))
  1687.         {
  1688.             tone_index = (sel_tone - gstartMidiId + gtotalRingId);
  1689.             SetInlineItemDisplayOnly(
  1690.                 &(wgui_inline_items[inline_item_index]),
  1691.                 (U8*) GetString((U16) (STR_PROFILES_RING_1 + tone_index)));
  1692.         }
  1693.         /* External Resource as Alarm */
  1694.     #if defined(__MMI_PROFILE_EXTMELODY_SUPPORT__)
  1695.         else if (sel_tone >= PMG_EXT_MELODY_BEGIN && sel_tone <= PMG_EXT_MELODY_END)
  1696.         {
  1697.             tone_index = sel_tone - PMG_EXT_MELODY_BEGIN;
  1698.             PmgGetExtMelodyInfo(&ExtMelodyInfo);
  1699.             if (IS_EXTMELODY_SHORTNAME(ExtMelodyInfo->info[tone_index].filepath) &&
  1700.                 g_alm_ext_melody_short_name_ptr != NULL)
  1701.             {
  1702.                 mmi_chset_mixed_text_to_ucs2_str(
  1703.                     g_alm_ext_melody_short_name_ptr,
  1704.                     (FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH,
  1705.                     (U8*) ExtMelodyInfo->info[tone_index].filename,
  1706.                     g_chset_text_encoding);
  1707.                 SetInlineItemDisplayOnly(&(wgui_inline_items[inline_item_index]),g_alm_ext_melody_short_name_ptr);
  1708.             }
  1709.             else
  1710.             {
  1711.                 SetInlineItemDisplayOnly(&(wgui_inline_items[inline_item_index]),(ExtMelodyInfo->info[tone_index]).filename);
  1712.             }
  1713.         }
  1714.     #endif /* defined(__MMI_PROFILE_EXTMELODY_SUPPORT__) */ 
  1715.     #if defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__)
  1716.         else if (download_theme_tones != NULL && sel_tone == download_theme_tones[0].AudioId)
  1717.         {
  1718.             pfnUnicodeStrcpy((S8*) g_alm_audio_options_curselitem, GetString(STR_PROFILES_CURR_THEME));
  1719.             SetInlineItemDisplayOnly(&(wgui_inline_items[inline_item_index]), (U8*) g_alm_audio_options_curselitem);
  1720.         }
  1721.     #endif /* defined(__MMI_ALM_AUDIO_OPTIONS__) && defined(__MMI_DOWNLOADABLE_THEMES_SUPPORT__) */ 
  1722.         /* Ring tone range incorrect or not initialized */
  1723.         else
  1724.         {
  1725.             pfnUnicodeStrcpy((S8*) g_alm_audio_options_curselitem, GetString(STR_GLOBAL_EMPTY_LIST));
  1726.             SetInlineItemDisplayOnly(&(wgui_inline_items[inline_item_index]), (U8*) g_alm_audio_options_curselitem);
  1727.         }
  1728.     }
  1729. #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ // #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1730. #ifdef __MMI_ALM_SNOOZE_SETTING__
  1731.     inline_item_index++;
  1732.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1733.     SetInlineItemCaption(
  1734.         &(wgui_inline_items[inline_item_index]),
  1735.         (U8*) GetString((U16) ALARMS_SETTING_SNOOZE_INTERVAL));
  1736.     inline_item_index++;
  1737.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1738.     SetInlineItemSelect(
  1739.         &(wgui_inline_items[inline_item_index]),
  1740.         (S32) ALM_SNOOZE_INTERVAL_SETTING_NUM,
  1741.         (U8 **) gAlmSettingSnooze,
  1742.         &(g_alm_cntx.CurrHilightSnoozeInterval));
  1743.     /* RegisterInlineSelectHighlightHandler(&wgui_inline_items[SNOOZE_INTERVAL],mmi_hightlight_snooze_selection); */
  1744. #endif /* __MMI_ALM_SNOOZE_SETTING__ */ 
  1745. #ifdef __MMI_ALM_ALERT_TYPE__
  1746.     inline_item_index++;
  1747.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1748.     SetInlineItemCaption(&(wgui_inline_items[inline_item_index]), (U8*) GetString((U16) STR_MT_CALL_ALERT_TYPE));
  1749.     inline_item_index++;
  1750.     SetInlineItemActivation(&(wgui_inline_items[inline_item_index]), INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1751.     SetInlineItemSelect(
  1752.         &(wgui_inline_items[inline_item_index]),
  1753.         (S32) ALM_ALERT_TYPE_SETTING_NUM,
  1754.         (U8 **) gAlmSettingAlertType,
  1755.         &(g_alm_cntx.CurrHilightAlertType));
  1756. #endif /* __MMI_ALM_ALERT_TYPE__ */ 
  1757. }
  1758. /*****************************************************************************
  1759.  * FUNCTION
  1760.  *  AlmSaveInlineEdit
  1761.  * DESCRIPTION
  1762.  *  Save alarm to nvram and set/cancel alarm to driver accordingly.
  1763.  * PARAMETERS
  1764.  *  void
  1765.  * RETURNS
  1766.  *  void
  1767.  *****************************************************************************/
  1768. void AlmSaveInlineEdit(void)
  1769. {
  1770.     /*----------------------------------------------------------------*/
  1771.     /* Local Variables                                                */
  1772.     /*----------------------------------------------------------------*/
  1773.     /*----------------------------------------------------------------*/
  1774.     /* Code Body                                                      */
  1775.     /*----------------------------------------------------------------*/
  1776.     if (AlmIsInlineEditorChanged(g_alm_cntx.CurrHiliteAlarm))
  1777.     {
  1778.         S32 i, j;
  1779.         i = g_alm_cntx.CurrHiliteAlarm;
  1780.         g_alm_cntx.AlmList[i].Freq = (U8) g_alm_cntx.CurrHiliteFreq;
  1781.         g_alm_cntx.AlmList[i].Days = 0;
  1782.         if (g_alm_freq_set[g_alm_cntx.AlmList[i].Freq] == ALM_FREQ_DAYS)
  1783.         {
  1784.             for (j = 0; j < NUM_DAYS; j++)
  1785.             {
  1786.                 g_alm_cntx.AlmList[i].Days |= (gAlmDaysStates[j] << j);
  1787.             }
  1788.             if (g_alm_cntx.AlmList[i].Days == 0)
  1789.             {
  1790.                 g_alm_cntx.AlmList[i].Freq = mmi_alm_get_freq_order(ALARM_FREQ_NUM, g_alm_freq_set, ALM_FREQ_ONCE);
  1791.             }
  1792.         }
  1793.         g_alm_cntx.AlmList[i].State = (U8) g_alm_cntx.CurrHiliteState;
  1794.         g_alm_cntx.AlmList[i].Hour = (g_alm_cntx.HourBuf[0] - '0') * 10 + (g_alm_cntx.HourBuf[ENCODING_LENGTH] - '0');
  1795.         g_alm_cntx.AlmList[i].Min = (g_alm_cntx.MinBuf[0] - '0') * 10 + (g_alm_cntx.MinBuf[ENCODING_LENGTH] - '0');
  1796.         g_alm_cntx.AlmList[i].Snooze = 0;
  1797.     #ifdef __MMI_ALM_CUST_VOLUME__
  1798.         g_alm_cntx.AlmList[i].Volume = (U8) g_alm_cntx.CurrHiliteVol;
  1799.     #endif 
  1800.         /* Alarm Audio Setting */
  1801.     #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1802.         if (g_alm_cntx.CurrHiliteAudioOptionValue != 0)
  1803.         {
  1804.             g_alm_cntx.AlmList[i].AudioOption = (U8) g_alm_cntx.CurrHiliteAudioOption;
  1805.             g_alm_cntx.AlmList[i].AudioOptionValue = g_alm_cntx.CurrHiliteAudioOptionValue;
  1806.         }
  1807.         else    /* Should not enter here because it already check before save */
  1808.         {
  1809.             g_alm_cntx.AlmList[i].AudioOption = ALM_AUDIO_OPTIONS_TONE;
  1810.         #ifdef __MMI_ALM_CUSTOMIZE_TONE__
  1811.             g_alm_cntx.AlmList[i].AudioOptionValue = (U16) (gstartMidiId + 1);
  1812.         #else 
  1813.             g_alm_cntx.AlmList[i].AudioOptionValue = gcurrentprofile.toneSetup.alarmTone;
  1814.         #endif 
  1815.         }
  1816.     #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ 
  1817.     #ifdef __MMI_ALM_SNOOZE_SETTING__
  1818.         g_alm_cntx.AlmList[i].SnoozeInterval = (U8) g_alm_cntx.CurrHilightSnoozeInterval;
  1819.     #endif 
  1820.     #ifdef __MMI_ALM_ALERT_TYPE__
  1821.         g_alm_cntx.AlmList[i].AlertType = (U8) g_alm_cntx.CurrHilightAlertType;
  1822.     #endif 
  1823.         AlmWriteToNvram();
  1824.         if (g_alm_cntx.CurrHiliteState == SET_STATE)
  1825.         {
  1826.             AlmSetAlarm((U8) (i + ALM_ALM_START));
  1827.             AlmActivateIndicator();
  1828.         }
  1829.         else
  1830.         {
  1831.             AlmCancelAlarm((U8) (i + ALM_ALM_START));
  1832.             if (!(AlmIsAnyAlarmActivated()))
  1833.             {
  1834.                 AlmDeactivateIndicator();
  1835.             }
  1836.         }
  1837.     }
  1838. #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1839.     if ((g_alm_cntx.AlmList[g_alm_cntx.CurrHiliteAlarm].AudioOption == ALM_AUDIO_OPTIONS_FMRADIO_CHANNEL) ||
  1840.         (g_alm_cntx.AlmList[g_alm_cntx.CurrHiliteAlarm].AudioOption == ALM_AUDIO_OPTIONS_FMRADIO_MANUAL))
  1841.     {
  1842.         DisplayConfirm(
  1843.             STR_GLOBAL_OK,
  1844.             IMG_GLOBAL_OK,
  1845.             0,
  1846.             0,
  1847.             get_string(STR_ID_ALM_FMRDO_HEADFONE_REMINDER),
  1848.             0,
  1849.             WARNING_TONE);
  1850.         SetLeftSoftkeyFunction(mmi_alm_display_popup, KEY_EVENT_UP);
  1851.     }
  1852.     else
  1853. #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ 
  1854.     {
  1855.         DisplayPopup(
  1856.             (U8*) GetString(STR_GLOBAL_DONE),
  1857.             IMG_GLOBAL_ACTIVATED,
  1858.             1,
  1859.             UI_POPUP_NOTIFYDURATION_TIME,
  1860.             SUCCESS_TONE);
  1861.         DeleteUptoScrID(SCR_ID_ALM_LIST);
  1862.     }
  1863. }
  1864. #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1865. /*****************************************************************************
  1866.  * FUNCTION
  1867.  *  mmi_alm_display_popup
  1868.  * DESCRIPTION
  1869.  *  
  1870.  * PARAMETERS
  1871.  *  void
  1872.  * RETURNS
  1873.  *  void
  1874.  *****************************************************************************/
  1875. void mmi_alm_display_popup(void)
  1876. {
  1877.     /*----------------------------------------------------------------*/
  1878.     /* Local Variables                                                */
  1879.     /*----------------------------------------------------------------*/
  1880.     /*----------------------------------------------------------------*/
  1881.     /* Code Body                                                      */
  1882.     /*----------------------------------------------------------------*/
  1883.     DisplayPopup(
  1884.         (U8*) GetString(STR_GLOBAL_DONE),
  1885.         IMG_GLOBAL_ACTIVATED,
  1886.         1,
  1887.         UI_POPUP_NOTIFYDURATION_TIME,
  1888.         SUCCESS_TONE);
  1889.     DeleteUptoScrID(SCR_ID_ALM_LIST);
  1890. }
  1891. #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ 
  1892. /*****************************************************************************
  1893.  * FUNCTION
  1894.  *  AlmCancelAlarmFromAT
  1895.  * DESCRIPTION
  1896.  *  Handler to cancel alarm from AT command.
  1897.  * PARAMETERS
  1898.  *  index       [IN]        
  1899.  * RETURNS
  1900.  *  void
  1901.  *****************************************************************************/
  1902. void AlmCancelAlarmFromAT(U8 index)
  1903. {
  1904.     /*----------------------------------------------------------------*/
  1905.     /* Local Variables                                                */
  1906.     /*----------------------------------------------------------------*/
  1907.     /*----------------------------------------------------------------*/
  1908.     /* Code Body                                                      */
  1909.     /*----------------------------------------------------------------*/
  1910.     if (g_alm_cntx.AlmList[index].State == 1)   /* alarm is currently on */
  1911.     {
  1912.         AlmCancelAlarm((U8) (index + ALM_ALM_START));
  1913.     }
  1914.     if (g_alm_frm_cntx.CurrAlmIndex == (U8) (index + ALM_ALM_START))
  1915.     {
  1916.         AlmStopHandler();
  1917.     }
  1918.     memset(&g_alm_cntx.AlmList[index], 0, sizeof(alm_nvram_struct));
  1919.     AlmWriteToNvram();
  1920.     if (!(AlmIsAnyAlarmActivated()))
  1921.     {
  1922.         AlmDeactivateIndicator();
  1923.     }
  1924. }
  1925. /*****************************************************************************
  1926.  * FUNCTION
  1927.  *  AlmSetAlarmFromAT
  1928.  * DESCRIPTION
  1929.  *  Handler to process alarm request from AT command
  1930.  * PARAMETERS
  1931.  *  index           [IN]        
  1932.  *  mytime          [IN]        
  1933.  *  weekdays        [IN]        
  1934.  * RETURNS
  1935.  *  void
  1936.  *****************************************************************************/
  1937. void AlmSetAlarmFromAT(U8 index, MYTIME mytime, U8 weekdays)
  1938. {
  1939.     /*----------------------------------------------------------------*/
  1940.     /* Local Variables                                                */
  1941.     /*----------------------------------------------------------------*/
  1942.     /*----------------------------------------------------------------*/
  1943.     /* Code Body                                                      */
  1944.     /*----------------------------------------------------------------*/
  1945.     g_alm_cntx.AlmList[index].Hour = mytime.nHour;
  1946.     g_alm_cntx.AlmList[index].Min = mytime.nMin;
  1947.     g_alm_cntx.AlmList[index].Snooze = 0;
  1948.     g_alm_cntx.AlmList[index].State = 1;
  1949.     if (weekdays == 0)
  1950.     {
  1951.         g_alm_cntx.AlmList[index].Freq = mmi_alm_get_freq_order(ALARM_FREQ_NUM, g_alm_freq_set, ALM_FREQ_ONCE);
  1952.     }
  1953.     else if (weekdays == 0x7F)
  1954.     {
  1955.         g_alm_cntx.AlmList[index].Freq = mmi_alm_get_freq_order(ALARM_FREQ_NUM, g_alm_freq_set, ALM_FREQ_EVERYDAY);
  1956.     }
  1957.     else
  1958.     {
  1959.         g_alm_cntx.AlmList[index].Freq = mmi_alm_get_freq_order(ALARM_FREQ_NUM, g_alm_freq_set, ALM_FREQ_DAYS);
  1960.         g_alm_cntx.AlmList[index].Days = weekdays;
  1961.     }
  1962.     #ifdef __MMI_ALM_AUDIO_OPTIONS__
  1963.         g_alm_cntx.AlmList[index].AudioOption = ALM_AUDIO_OPTIONS_TONE;
  1964.         g_alm_cntx.AlmList[index].AudioOptionValue = gcurrentprofile.toneSetup.alarmTone;
  1965.     #endif /* __MMI_ALM_AUDIO_OPTIONS__ */ 
  1966.     AlmWriteToNvram();
  1967.     AlmSetAlarm((U8) (index + ALM_ALM_START));
  1968.     AlmActivateIndicator();
  1969. }
  1970. /*****************************************************************************
  1971.  * FUNCTION
  1972.  *  AlmQueryAlarmFromAT
  1973.  * DESCRIPTION
  1974.  *  Handler to process query alarm request from AT command
  1975.  * PARAMETERS
  1976.  *  void
  1977.  * RETURNS
  1978.  *  void
  1979.  *****************************************************************************/
  1980. void AlmQueryAlarmFromAT(void)
  1981. {
  1982. #ifdef MMI_ON_HARDWARE_P
  1983.     /*----------------------------------------------------------------*/
  1984.     /* Local Variables                                                */
  1985.     /*----------------------------------------------------------------*/
  1986.     mmi_at_alarm_query_res_req_struct *rsp;
  1987.     MYQUEUE Message;
  1988.     S32 i, j;
  1989.     MYTIME almTime;
  1990.     /*----------------------------------------------------------------*/
  1991.     /* Code Body                                                      */
  1992.     /*----------------------------------------------------------------*/
  1993.     Message.oslSrcId = MOD_MMI;
  1994.     Message.oslDestId = MOD_L4C;
  1995.     Message.oslMsgId = MSG_ID_MMI_AT_ALARM_QUERY_RES_REQ;
  1996.     rsp = (mmi_at_alarm_query_res_req_struct*) OslConstructDataPtr(sizeof(mmi_at_alarm_query_res_req_struct));
  1997.     rsp->totalAlarm = NUM_OF_ALM;
  1998.     rsp->alarmList = NULL;
  1999.     rsp->activeAlarm = 0;
  2000.     for (i = 0; i < NUM_OF_ALM; i++)
  2001.         if (g_alm_cntx.AlmList[i].State == SET_STATE)
  2002.         {
  2003.             rsp->activeAlarm++;
  2004.         }
  2005.     if (rsp->activeAlarm)
  2006.     {
  2007.         rsp->alarmList = (mmi_at_alarm_info_struct*)
  2008.             OslConstructDataPtr(sizeof(mmi_at_alarm_info_struct) * rsp->activeAlarm);
  2009.         for (i = 0, j = 0; i < NUM_OF_ALM; i++)
  2010.         {
  2011.             if (g_alm_cntx.AlmList[i].State == SET_STATE)
  2012.             {
  2013.                 rsp->alarmList[j].alarm_index = i;
  2014.                 almTime = AlmGetAlarmTime((kal_uint8) (i + ALM_ALM_START));
  2015.                 rsp->alarmList[j].date_time.rtc_year = almTime.nYear - YEARFORMATE;
  2016.                 rsp->alarmList[j].date_time.rtc_wday = almTime.DayIndex;
  2017.                 rsp->alarmList[j].date_time.rtc_mon = almTime.nMonth;
  2018.                 rsp->alarmList[j].date_time.rtc_day = almTime.nDay;
  2019.                 rsp->alarmList[j].date_time.rtc_hour = almTime.nHour;
  2020.                 rsp->alarmList[j].date_time.rtc_min = almTime.nMin;
  2021.                 rsp->alarmList[j].date_time.rtc_sec = almTime.nSec;
  2022.                 if (g_alm_freq_set[g_alm_cntx.AlmList[i].Freq] == ALM_FREQ_ONCE)
  2023.                 {
  2024.                     rsp->alarmList[j].recurr = 0;
  2025.                 }
  2026.                 else if (g_alm_freq_set[g_alm_cntx.AlmList[i].Freq] == ALM_FREQ_EVERYDAY)
  2027.                 {
  2028.                     rsp->alarmList[j].recurr = ALM_ALL_DAYS;
  2029.                 }
  2030.                 else
  2031.                 {
  2032.                     rsp->alarmList[j].recurr = g_alm_cntx.AlmList[i].Days;
  2033.                 }
  2034.                 j++;
  2035.             }
  2036.         }
  2037.     }
  2038.     Message.oslDataPtr = (oslParaType*) rsp;
  2039.     Message.oslPeerBuffPtr = NULL;
  2040.     OslMsgSendExtQueue(&Message);
  2041. #endif /* MMI_ON_HARDWARE_P */ 
  2042. }
  2043. #endif /* _MMI_ALARM_C */ // #ifndef _MMI_ALARM_C