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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *  VoIPMain.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *  MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  Coding Template header file
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  *------------------------------------------------------------------------------
  116.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  117.  *============================================================================
  118.  ****************************************************************************/
  119. #include "MMI_features.h"
  120. #ifdef __MMI_VOIP__
  121. #include "stdC.h"
  122. #include "L4Dr1.h"
  123. #include "DebugInitDef.h"
  124. #include "mmi_trc.h"    /* debug info */
  125. #include "GlobalMenuItems.h"
  126. #include "GlobalScrEnum.h"
  127. #include "CustMenuRes.h"
  128. #include "CustDataRes.h"
  129. #include "ProtocolEvents.h"
  130. #include "CommonScreens.h"
  131. #include "SettingProfile.h"
  132. #include "EventsGprot.h"
  133. #include "wgui_categories_popup.h"
  134. #include "wgui_categories_inputs.h"
  135. #include "wgui_categories_util.h"
  136. #include "NVRAMEnum.h"
  137. #include "NVRAMProt.h"
  138. #include "NVRAMType.h"
  139. #include "custom_nvram_editor_data_item.h"
  140. #include "custom_data_account.h"
  141. #include "CallManagementGprot.h"
  142. #include "VoIPDef.h"
  143. #include "VoIPGProt.h"
  144. #include "VoIPProt.h"
  145. extern U32 voip_custom_get_max_call_num(void);
  146. mmi_voip_cntx_struct g_voip_cntx;
  147. mmi_voip_cntx_struct *g_voip_cntx_p = &g_voip_cntx;
  148. /*****************************************************************************
  149.  * FUNCTION
  150.  *  mmi_voip_init
  151.  * DESCRIPTION
  152.  *  Initialize VoIP application.
  153.  * PARAMETERS
  154.  *  void
  155.  * RETURNS
  156.  *  void
  157.  *****************************************************************************/
  158. void mmi_voip_init(void)
  159. {
  160.     /*----------------------------------------------------------------*/
  161.     /* Local Variables                                                */
  162.     /*----------------------------------------------------------------*/
  163.     S32 profIndex = 0;
  164.     /*----------------------------------------------------------------*/
  165.     /* Code Body                                                      */
  166.     /*----------------------------------------------------------------*/
  167.     mmi_voip_init_context();
  168.     mmi_voip_init_highlight_hdlr();
  169.     mmi_voip_init_protocol_hdlr();
  170.     profIndex = g_voip_cntx_p->prof_setting_info.actprofIndex;
  171.     if ((profIndex != -1) && (g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].comm_info.autoLogin == 1)) /* auto login */
  172.     {
  173.         mmi_voip_register_req(); /* send request to voip cc in the background */
  174.         /* in case the first time register is not success, deregister_ind will not be received */
  175.     #ifdef __MMI_WLAN_FEATURES__
  176.         mmi_wlan_add_event_notify_hdlr(mmi_voip_wlan_state_callback);
  177.     #endif
  178.     }
  179. }
  180. /*****************************************************************************
  181.  * FUNCTION
  182.  *  mmi_voip_deinit
  183.  * DESCRIPTION
  184.  *  Deinitialize VoIP application.
  185.  * PARAMETERS
  186.  *  void
  187.  * RETURNS
  188.  *  void
  189.  *****************************************************************************/
  190. void mmi_voip_deinit(void)
  191. {
  192.     /*----------------------------------------------------------------*/
  193.     /* Local Variables                                                */
  194.     /*----------------------------------------------------------------*/
  195.     /*----------------------------------------------------------------*/
  196.     /* Code Body                                                      */
  197.     /*----------------------------------------------------------------*/
  198.     if (g_voip_cntx_p->reg_state_info == MMI_VOIP_REG_STATE)
  199.     {
  200.         mmi_voip_deregister_req();
  201.     }    
  202. }
  203. #ifdef __MMI_WLAN_FEATURES__
  204. /*****************************************************************************
  205.  * FUNCTION
  206.  *  mmi_voip_wlan_state_callback
  207.  * DESCRIPTION
  208.  *  Callback function of wlan state for VoIP auto login feature.
  209.  * PARAMETERS
  210.  *  state           [IN]            Wlan state, either DTCNT_BEARER_STATE_INACTIVE, 
  211.  *                                  DTCNT_BEARER_STATE_INITIALIZED or DTCNT_BEARER_STATE_CONNECTED
  212.  * RETURNS
  213.  *  void
  214.  *****************************************************************************/
  215. void mmi_voip_wlan_state_callback(U16 state)
  216. {
  217.     /*----------------------------------------------------------------*/
  218.     /* Local Variables                                                */
  219.     /*----------------------------------------------------------------*/
  220.     S32 profIndex = 0;
  221.     /*----------------------------------------------------------------*/
  222.     /* Code Body                                                      */
  223.     /*----------------------------------------------------------------*/
  224.     if ((state == DTCNT_BEARER_STATE_CONNECTED) && 
  225.         (g_voip_cntx_p->reg_state_info == MMI_VOIP_DEREG_STATE)) /* wlan is connected but voip is deregistered */
  226.     {
  227.         profIndex = g_voip_cntx_p->prof_setting_info.actprofIndex;
  228.         if ((profIndex != -1) && (g_voip_cntx_p->prof_setting_info.saved_prof[profIndex].comm_info.autoLogin == 1)) /* auto login */
  229.         {
  230.             mmi_voip_register_req(); /* send request to voip cc in the background */
  231.         }
  232.     }
  233. }
  234. #endif /* __MMI_WLAN_FEATURES__ */
  235. /*****************************************************************************
  236.  * FUNCTION
  237.  *  mmi_voip_init_context
  238.  * DESCRIPTION
  239.  *  Initialize all global context.
  240.  * PARAMETERS
  241.  *  void
  242.  * RETURNS
  243.  *  void
  244.  *****************************************************************************/
  245. void mmi_voip_init_context(void)
  246. {
  247.     /*----------------------------------------------------------------*/
  248.     /* Local Variables                                                */
  249.     /*----------------------------------------------------------------*/
  250.     /*----------------------------------------------------------------*/
  251.     /* Code Body                                                      */
  252.     /*----------------------------------------------------------------*/
  253.     mmi_voip_init_setting_context();
  254.     mmi_voip_init_call_context();
  255. }
  256. /*****************************************************************************
  257.  * FUNCTION
  258.  *  mmi_voip_init_setting_context
  259.  * DESCRIPTION
  260.  *  Initialize setting related global context.
  261.  * PARAMETERS
  262.  *  void
  263.  * RETURNS
  264.  *  void
  265.  *****************************************************************************/
  266. void mmi_voip_init_setting_context(void)
  267. {
  268.     /*----------------------------------------------------------------*/
  269.     /* Local Variables                                                */
  270.     /*----------------------------------------------------------------*/
  271.     S32 i = 0;
  272.     /*----------------------------------------------------------------*/
  273.     /* Code Body                                                      */
  274.     /*----------------------------------------------------------------*/
  275.     g_voip_cntx_p->reg_state_info = MMI_VOIP_DEREG_STATE;
  276.     memset(&g_voip_cntx_p->prof_setting_info, 0, sizeof(mmi_voip_prof_setting_struct));
  277.     g_voip_cntx_p->prof_setting_info.actprofIndex = -1;
  278.     memset(&g_voip_cntx_p->call_setting_info, 0, sizeof(mmi_voip_call_setting_struct));
  279.     g_voip_cntx_p->call_setting_info.numCodec = MMI_VOIP_MAX_CODEC_NUM;
  280.     for (i = 0; i < MMI_VOIP_MAX_PROFILE_NUM; i++)
  281.     {
  282.         mmi_voip_load_profile(i);
  283.     }
  284.     mmi_voip_load_profile_active_index();
  285.     mmi_voip_load_setting();
  286. }
  287. /*****************************************************************************
  288.  * FUNCTION
  289.  *  mmi_voip_init_call_context
  290.  * DESCRIPTION
  291.  *  Initialize call related global context.
  292.  * PARAMETERS
  293.  *  void
  294.  * RETURNS
  295.  *  void
  296.  *****************************************************************************/
  297. void mmi_voip_init_call_context(void)
  298. {
  299.     /*----------------------------------------------------------------*/
  300.     /* Local Variables                                                */
  301.     /*----------------------------------------------------------------*/
  302.     S32 i = 0, j = 0;
  303.     /*----------------------------------------------------------------*/
  304.     /* Code Body                                                      */
  305.     /*----------------------------------------------------------------*/
  306.     memset(&g_voip_cntx_p->call_list_info, 0, sizeof(mmi_voip_call_list_struct));
  307.     g_voip_cntx_p->call_list_info.maxnumCall = voip_custom_get_max_call_num();
  308.     g_voip_cntx_p->call_list_info.processCId = -1;
  309.     g_voip_cntx_p->call_list_info.processDId = -1;
  310.     g_voip_cntx_p->call_list_info.bkrejCId = -1;
  311.     g_voip_cntx_p->call_list_info.bkrejDId = -1;
  312.     for (i = 0; i < MMI_VOIP_MAX_NUM_CALL; i++)
  313.     {
  314.         g_voip_cntx_p->call_list_info.call_info[i].callId = -1;
  315.         for (j = 0; j < VOIP_MAX_NUM_DIALOG; j++)
  316.         {
  317.             g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].dialogId = -1;
  318.             g_voip_cntx_p->call_list_info.call_info[i].dialog_info[j].rtpHandle = -1;
  319.         }
  320.     }
  321.     for (i = 0; i < MMI_VOIP_MAX_HELD_CALL; i++)
  322.     {
  323.         g_voip_cntx_p->call_list_info.held_call_info[i].callId = -1;
  324.     }
  325.     memset(&g_voip_cntx_p->call_redial_info, 0, sizeof(mmi_voip_call_redial_struct));
  326.     g_voip_cntx_p->call_redial_info.maxAttempt = 3;
  327.     memset(&g_voip_cntx_p->call_misc_info, 0, sizeof(mmi_voip_call_misc_struct));
  328.     g_voip_cntx_p->call_misc_info.isDtmf = TRUE;
  329.     memset(&g_voip_cntx_p->call_originapp_info, 0, sizeof(mmi_voip_call_originapp_struct));
  330.     
  331.     memset(&g_voip_cntx_p->call_log_info, 0, sizeof(mmi_voip_call_log_struct));
  332. }
  333. /*****************************************************************************
  334.  * FUNCTION
  335.  *  mmi_voip_init_highlight_hdlr
  336.  * DESCRIPTION
  337.  *  Initialize all highlight handlers.
  338.  * PARAMETERS
  339.  *  void
  340.  * RETURNS
  341.  *  void
  342.  *****************************************************************************/
  343. void mmi_voip_init_highlight_hdlr(void)
  344. {
  345.     /*----------------------------------------------------------------*/
  346.     /* Local Variables                                                */
  347.     /*----------------------------------------------------------------*/
  348.     /*----------------------------------------------------------------*/
  349.     /* Code Body                                                      */
  350.     /*----------------------------------------------------------------*/
  351.     mmi_voip_init_setting_highlight_hdlr();
  352.     mmi_voip_init_setting_hint_hdlr();
  353.     mmi_voip_init_call_highlight_hdlr();
  354.     mmi_voip_init_call_hint_hdlr();
  355. }
  356. /*****************************************************************************
  357.  * FUNCTION
  358.  *  mmi_voip_init_setting_highlight_hdlr
  359.  * DESCRIPTION
  360.  *  Initialize setting related highlight handlers.
  361.  * PARAMETERS
  362.  *  void
  363.  * RETURNS
  364.  *  void
  365.  *****************************************************************************/
  366. void mmi_voip_init_setting_highlight_hdlr(void)
  367. {
  368.     /*----------------------------------------------------------------*/
  369.     /* Local Variables                                                */
  370.     /*----------------------------------------------------------------*/
  371.     /*----------------------------------------------------------------*/
  372.     /* Code Body                                                      */
  373.     /*----------------------------------------------------------------*/
  374.     SetHiliteHandler(MENU_ID_VOIP_MAIN, mmi_voip_highlight_main_menu);
  375.     SetHiliteHandler(MENU_ID_VOIP_STATUS, mmi_voip_highlight_status);
  376.     SetHiliteHandler(MENU_ID_VOIP_SUMMARY, mmi_voip_highlight_summary);
  377.     SetHiliteHandler(MENU_ID_VOIP_PROF_SETTING, mmi_voip_highlight_prof_setting);
  378.     SetHiliteHandler(MENU_ID_VOIP_PROF_SETTING_OPTION_ACTIVATE, mmi_voip_highlight_prof_setting_option_activate);
  379.     SetHiliteHandler(MENU_ID_VOIP_PROF_SETTING_OPTION_EDIT, mmi_voip_highlight_prof_setting_option_edit);
  380.     SetHiliteHandler(MENU_ID_VOIP_PROF_EDIT_COMMON, mmi_voip_highlight_prof_edit_common);
  381.     SetHiliteHandler(MENU_ID_VOIP_PROF_EDIT_ACCOUNT, mmi_voip_highlight_prof_edit_account);
  382.     SetHiliteHandler(MENU_ID_VOIP_PROF_EDIT_OUTBOUND, mmi_voip_highlight_prof_edit_outbound);
  383.     SetHiliteHandler(MENU_ID_VOIP_PROF_EDIT_REGISTER, mmi_voip_highlight_prof_edit_register);
  384.     SetHiliteHandler(MENU_ID_VOIP_PROF_EDIT_NAT, mmi_voip_highlight_prof_edit_nat);
  385.     SetHiliteHandler(MENU_ID_VOIP_FULL_EDITOR_DONE, mmi_voip_highlight_done);
  386.     SetHiliteHandler(MENU_ID_VOIP_FULL_EDITOR_INPUT_METHOD, mmi_voip_highlight_input_method_in_menu);
  387.     SetHiliteHandler(MENU_ID_VOIP_CALL_SETTING, mmi_voip_highlight_call_setting);
  388.     SetHiliteHandler(MENU_ID_VOIP_SETTING_AUTO_ANSWER, mmi_voip_highlight_auto_answer);
  389.     SetHiliteHandler(MENU_ID_VOIP_SETTING_AUTO_REJECT, mmi_voip_highlight_auto_reject);
  390.     SetHiliteHandler(MENU_ID_VOIP_SETTING_AUTO_REDIAL, mmi_voip_highlight_auto_redial);
  391.     SetHiliteHandler(MENU_ID_VOIP_SETTING_HIDE_CALLER_ID, mmi_voip_highlight_hide_caller_id);
  392.     SetHiliteHandler(MENU_ID_VOIP_SETTING_DTMF, mmi_voip_highlight_dtmf_in_menu);
  393.     SetHiliteHandler(MENU_ID_VOIP_SETTING_COMFORT_NOISE, mmi_voip_highlight_comfort_noise);
  394.     SetHiliteHandler(MENU_ID_VOIP_SETTING_SET_CODEC_ORDER, mmi_voip_highlight_set_codec_order);
  395.     SetHiliteHandler(MENU_ID_VOIP_CALL_EDITOR, mmi_voip_highlight_new_call);
  396.     SetHiliteHandler(MENU_ID_VOIP_CALL_EDITOR_DIAL, mmi_voip_highlight_dial);
  397.     SetHiliteHandler(MENU_ID_VOIP_CALL_EDITOR_SAVE_PHONEBOOK, mmi_voip_highlight_save_phonebook);
  398.     SetHiliteHandler(MENU_ID_VOIP_CALL_EDITOR_INPUT_METHOD, mmi_voip_highlight_input_method_in_call);
  399.     SetHiliteHandler(MENU_ID_VOIP_CALL_EDITOR_SOS, mmi_voip_highlight_sos);
  400. #ifdef SIP_CONFORMANCE_TEST
  401.     SetHiliteHandler(MENU_ID_VOIP_OPTION_QUERY, mmi_voip_highlight_option_query);
  402. #endif
  403. }
  404. /*****************************************************************************
  405.  * FUNCTION
  406.  *  mmi_voip_init_setting_hint_hdlr
  407.  * DESCRIPTION
  408.  *  Initialize setting related hint handlers.
  409.  * PARAMETERS
  410.  *  void
  411.  * RETURNS
  412.  *  void
  413.  *****************************************************************************/
  414. void mmi_voip_init_setting_hint_hdlr(void)
  415. {
  416.     /*----------------------------------------------------------------*/
  417.     /* Local Variables                                                */
  418.     /*----------------------------------------------------------------*/
  419.     /*----------------------------------------------------------------*/
  420.     /* Code Body                                                      */
  421.     /*----------------------------------------------------------------*/
  422.     SetHintHandler(MENU_ID_VOIP_SETTING_AUTO_ANSWER, mmi_voip_hint_auto_answer);
  423.     SetHintHandler(MENU_ID_VOIP_SETTING_AUTO_REJECT, mmi_voip_hint_auto_reject);
  424.     SetHintHandler(MENU_ID_VOIP_SETTING_AUTO_REDIAL, mmi_voip_hint_auto_redial);
  425.     SetHintHandler(MENU_ID_VOIP_SETTING_HIDE_CALLER_ID, mmi_voip_hint_hide_caller_id);
  426.     SetHintHandler(MENU_ID_VOIP_SETTING_DTMF, mmi_voip_hint_dtmf_in_menu);
  427.     SetHintHandler(MENU_ID_VOIP_SETTING_COMFORT_NOISE, mmi_voip_hint_comfort_noise);
  428. }
  429. /*****************************************************************************
  430.  * FUNCTION
  431.  *  mmi_voip_init_call_highlight_hdlr
  432.  * DESCRIPTION
  433.  *  Initialize call related highlight handlers.
  434.  * PARAMETERS
  435.  *  void
  436.  * RETURNS
  437.  *  void
  438.  *****************************************************************************/
  439. void mmi_voip_init_call_highlight_hdlr(void)
  440. {
  441.     /*----------------------------------------------------------------*/
  442.     /* Local Variables                                                */
  443.     /*----------------------------------------------------------------*/
  444.     /*----------------------------------------------------------------*/
  445.     /* Code Body                                                      */
  446.     /*----------------------------------------------------------------*/
  447.     SetHiliteHandler(MENU_ID_VOIP_HOLD_SINGLE, mmi_voip_highlight_hold_single);
  448.     SetHiliteHandler(MENU_ID_VOIP_HOLD_CONFERENCE, mmi_voip_highlight_hold_conference);
  449.     SetHiliteHandler(MENU_ID_VOIP_RETRIEVE_SINGLE, mmi_voip_highlight_retrieve_single);
  450.     SetHiliteHandler(MENU_ID_VOIP_RETRIEVE_CONFERENCE, mmi_voip_highlight_retrieve_conference);
  451.     SetHiliteHandler(MENU_ID_VOIP_SWAP, mmi_voip_highlight_swap);
  452.     SetHiliteHandler(MENU_ID_VOIP_CONFERENCE, mmi_voip_highlight_conference);
  453.     SetHiliteHandler(MENU_ID_VOIP_SPLIT, mmi_voip_highlight_split);
  454.     SetHiliteHandler(MENU_ID_VOIP_END_SINGLE, mmi_voip_highlight_end_single);
  455.     SetHiliteHandler(MENU_ID_VOIP_END_CONFERENCE, mmi_voip_highlight_end_conference);
  456.     SetHiliteHandler(MENU_ID_VOIP_END_ALL, mmi_voip_highlight_end_all);
  457.     SetHiliteHandler(MENU_ID_VOIP_TRANSFER, mmi_voip_highlight_transfer);
  458.     SetHiliteHandler(MENU_ID_VOIP_PHONEBOOK, mmi_voip_highlight_phonebook);
  459.     SetHiliteHandler(MENU_ID_VOIP_MUTE, mmi_voip_highlight_mute);
  460.     SetHiliteHandler(MENU_ID_VOIP_DTMF, mmi_voip_highlight_dtmf_in_call);
  461. }
  462. /*****************************************************************************
  463.  * FUNCTION
  464.  *  mmi_voip_init_call_hint_hdlr
  465.  * DESCRIPTION
  466.  *  Initialize call related hint handlers.
  467.  * PARAMETERS
  468.  *  void
  469.  * RETURNS
  470.  *  void
  471.  *****************************************************************************/
  472. void mmi_voip_init_call_hint_hdlr(void)
  473. {
  474.     /*----------------------------------------------------------------*/
  475.     /* Local Variables                                                */
  476.     /*----------------------------------------------------------------*/
  477.     /*----------------------------------------------------------------*/
  478.     /* Code Body                                                      */
  479.     /*----------------------------------------------------------------*/
  480.     SetHintHandler(MENU_ID_VOIP_MUTE, mmi_voip_hint_mute);
  481.     SetHintHandler(MENU_ID_VOIP_DTMF, mmi_voip_hint_dtmf_in_call);
  482. }
  483. /*****************************************************************************
  484.  * FUNCTION
  485.  *  mmi_voip_init_protocol_hdlr
  486.  * DESCRIPTION
  487.  *  Initialize all protocol handlers.
  488.  * PARAMETERS
  489.  *  void
  490.  * RETURNS
  491.  *  void
  492.  *****************************************************************************/
  493. void mmi_voip_init_protocol_hdlr(void)
  494. {
  495.     /*----------------------------------------------------------------*/
  496.     /* Local Variables                                                */
  497.     /*----------------------------------------------------------------*/
  498.     /*----------------------------------------------------------------*/
  499.     /* Code Body                                                      */
  500.     /*----------------------------------------------------------------*/
  501.     SetProtocolEventHandler(mmi_voip_register_rsp, MSG_ID_MMI_VOIP_REGISTER_RSP);
  502.     SetProtocolEventHandler(mmi_voip_deregister_rsp, MSG_ID_MMI_VOIP_DEREGISTER_RSP);
  503.     SetProtocolEventHandler(mmi_voip_deregister_ind, MSG_ID_MMI_VOIP_DEREGISTER_IND);
  504.     SetProtocolEventHandler(mmi_voip_setting_rsp, MSG_ID_MMI_VOIP_SETTING_RSP);
  505.     SetProtocolEventHandler(mmi_voip_progressing_ind, MSG_ID_MMI_VOIP_PROGRESSING_IND);
  506.     SetProtocolEventHandler(mmi_voip_call_ring_ind, MSG_ID_MMI_VOIP_CALL_RING_IND);
  507.     SetProtocolEventHandler(mmi_voip_call_end_ind, MSG_ID_MMI_VOIP_CALL_END_IND);
  508.     SetProtocolEventHandler(mmi_voip_call_state_ind, MSG_ID_MMI_VOIP_CALL_STATE_IND);
  509.     SetProtocolEventHandler(mmi_voip_dispatch_call_act_rsp, MSG_ID_MMI_VOIP_CALL_ACT_RSP);
  510.     SetProtocolEventHandler(mmi_voip_msg_waiting_ind, MSG_ID_MMI_VOIP_WAITING_MSG_IND);
  511.     SetProtocolEventHandler(mmi_voip_at_call_ctrl_approve_ind, MSG_ID_MMI_VOIP_AT_CALL_CTRL_APPROVE_IND);
  512. }
  513. /*****************************************************************************
  514.  * FUNCTION
  515.  *  mmi_voip_load_profile
  516.  * DESCRIPTION
  517.  *  Load profile data with specific index from NVRAM to
  518.  *  g_voip_cntx_p->prof_setting_info.saved_prof[index].
  519.  * PARAMETERS
  520.  *  profIndex       [IN]        Index of intended to load profile
  521.  * RETURNS
  522.  *  TRUE means load success; FALSE means load fail.
  523.  *****************************************************************************/
  524. BOOL mmi_voip_load_profile(S32 profIndex)
  525. {
  526.     /*----------------------------------------------------------------*/
  527.     /* Local Variables                                                */
  528.     /*----------------------------------------------------------------*/
  529.     S32 result;
  530.     S16 error;
  531.     /*----------------------------------------------------------------*/
  532.     /* Code Body                                                      */
  533.     /*----------------------------------------------------------------*/
  534.     if ((profIndex < 0) || (profIndex >= MMI_VOIP_MAX_PROFILE_NUM))
  535.     {
  536.         return FALSE;
  537.     }
  538.     result = ReadRecord(
  539.                 NVRAM_EF_VOIP_PROF_LID,
  540.                 (U16) (profIndex + 1),
  541.                 g_voip_cntx_p->prof_setting_info.saved_prof + profIndex,
  542.                 sizeof(mmi_voip_prof_struct),
  543.                 &error);
  544.     if (result < 0)
  545.     {
  546.         return FALSE;
  547.     }
  548.     return TRUE;
  549. }
  550. /*****************************************************************************
  551.  * FUNCTION
  552.  *  mmi_voip_save_profile
  553.  * DESCRIPTION
  554.  *  Save g_voip_cntx_p->prof_setting_info.saved_prof[index] to NVRAM
  555.  *  with profile data with specific index.
  556.  * PARAMETERS
  557.  *  profIndex       [IN]        Index of intended to save profile
  558.  * RETURNS
  559.  *  TRUE means save success; FALSE means save fail.
  560.  *****************************************************************************/
  561. BOOL mmi_voip_save_profile(S32 profIndex)
  562. {
  563.     /*----------------------------------------------------------------*/
  564.     /* Local Variables                                                */
  565.     /*----------------------------------------------------------------*/
  566.     S32 result;
  567.     S16 error;
  568.     /*----------------------------------------------------------------*/
  569.     /* Code Body                                                      */
  570.     /*----------------------------------------------------------------*/
  571.     if ((profIndex < 0) || (profIndex >= MMI_VOIP_MAX_PROFILE_NUM))
  572.     {
  573.         return FALSE;
  574.     }
  575.     result = WriteRecord(
  576.                 NVRAM_EF_VOIP_PROF_LID,
  577.                 (U16) (profIndex + 1),
  578.                 g_voip_cntx_p->prof_setting_info.saved_prof + profIndex,
  579.                 sizeof(mmi_voip_prof_struct),
  580.                 &error);
  581.     if (result < 0)
  582.     {
  583.         return FALSE;
  584.     }
  585.     return TRUE;
  586. }
  587. /*****************************************************************************
  588.  * FUNCTION
  589.  *  mmi_voip_load_profile_active_index
  590.  * DESCRIPTION
  591.  *  Load activate profile index from NVRAM.
  592.  * PARAMETERS
  593.  *  void
  594.  * RETURNS
  595.  *  void
  596.  *****************************************************************************/
  597. void mmi_voip_load_profile_active_index(void)
  598. {
  599.     /*----------------------------------------------------------------*/
  600.     /* Local Variables                                                */
  601.     /*----------------------------------------------------------------*/
  602.     S16 error;
  603.     U8 data;
  604.     /*----------------------------------------------------------------*/
  605.     /* Code Body                                                      */
  606.     /*----------------------------------------------------------------*/
  607.     ReadValue(NVRAM_VOIP_PROF_ACTIVATED, &data, DS_BYTE, &error);
  608.     if (data == 0xFF)
  609.     {
  610.         data = 0;
  611.         WriteValue(NVRAM_VOIP_PROF_ACTIVATED, &data, DS_BYTE, &error);
  612.         g_voip_cntx_p->prof_setting_info.actprofIndex = -1;
  613.     }
  614.     else
  615.     {
  616.         g_voip_cntx_p->prof_setting_info.actprofIndex = data - 1;
  617.     }
  618. }
  619. /*****************************************************************************
  620.  * FUNCTION
  621.  *  mmi_voip_save_profile_active_index
  622.  * DESCRIPTION
  623.  *  Save activate profile index to NVRAM.
  624.  * PARAMETERS
  625.  *  void
  626.  * RETURNS
  627.  *  void
  628.  *****************************************************************************/
  629. void mmi_voip_save_profile_active_index(void)
  630. {
  631.     /*----------------------------------------------------------------*/
  632.     /* Local Variables                                                */
  633.     /*----------------------------------------------------------------*/
  634.     S16 error;
  635.     U8 data;
  636.     /*----------------------------------------------------------------*/
  637.     /* Code Body                                                      */
  638.     /*----------------------------------------------------------------*/
  639.     data = g_voip_cntx_p->prof_setting_info.actprofIndex + 1;
  640.     WriteValue(NVRAM_VOIP_PROF_ACTIVATED, &data, DS_BYTE, &error);
  641. }
  642. /*****************************************************************************
  643.  * FUNCTION
  644.  *  mmi_voip_load_setting
  645.  * DESCRIPTION
  646.  *  Load call setting data from NVRAM to
  647.  *  g_voip_cntx_p->call_setting_info.saved_setting.
  648.  * PARAMETERS
  649.  *  void
  650.  * RETURNS
  651.  *  TRUE means load success; FALSE means load fail.
  652.  *****************************************************************************/
  653. BOOL mmi_voip_load_setting(void)
  654. {
  655.     /*----------------------------------------------------------------*/
  656.     /* Local Variables                                                */
  657.     /*----------------------------------------------------------------*/
  658.     S32 result, i = 0;
  659.     S16 error;
  660.     /*----------------------------------------------------------------*/
  661.     /* Code Body                                                      */
  662.     /*----------------------------------------------------------------*/
  663.     result = ReadRecord(
  664.                 NVRAM_EF_VOIP_SETTING_LID,
  665.                 1,
  666.                 &g_voip_cntx_p->call_setting_info.saved_setting,
  667.                 sizeof(mmi_voip_setting_struct),
  668.                 &error);
  669.     if (result < 0)
  670.     {
  671.         return FALSE;
  672.     }
  673.     /* check if codec order string empty */
  674.     for (i = 0; i < MMI_VOIP_MAX_CODEC_NUM; i++)
  675.     {
  676.         if (!strlen((S8*)g_voip_cntx_p->call_setting_info.saved_setting.codecOrder[i]))
  677.         {
  678.             UnicodeToAnsii(
  679.                 (S8*)g_voip_cntx_p->call_setting_info.saved_setting.codecOrder[i], 
  680.                 (S8*)GetString(STR_ID_VOIP_SETTING_CODEC2 + i));
  681.             MMI_ASSERT(g_voip_cntx_p->call_setting_info.saved_setting.codecOrder[i][MMI_VOIP_MAX_CODEC_NAME_LEN - 1] == '');
  682.         }
  683.     }
  684.     /* set g_voip_cntx_p->call_setting_info.codecEnum */
  685.     mmi_voip_update_setting_codec_cache_to_disp();
  686.     return TRUE;
  687. }
  688. /*****************************************************************************
  689.  * FUNCTION
  690.  *  mmi_voip_save_setting
  691.  * DESCRIPTION
  692.  *  Save g_voip_cntx_p->call_setting_info.saved_setting to NVRAM
  693.  *  with call setting data.
  694.  * PARAMETERS
  695.  *  void
  696.  * RETURNS
  697.  *  TRUE means save success; FALSE means save fail.
  698.  *****************************************************************************/
  699. BOOL mmi_voip_save_setting(void)
  700. {
  701.     /*----------------------------------------------------------------*/
  702.     /* Local Variables                                                */
  703.     /*----------------------------------------------------------------*/
  704.     S32 result;
  705.     S16 error;
  706.     /*----------------------------------------------------------------*/
  707.     /* Code Body                                                      */
  708.     /*----------------------------------------------------------------*/
  709.     result = WriteRecord(
  710.                 NVRAM_EF_VOIP_SETTING_LID,
  711.                 1,
  712.                 &g_voip_cntx_p->call_setting_info.saved_setting,
  713.                 sizeof(mmi_voip_setting_struct),
  714.                 &error);
  715.     if (result < 0)
  716.     {
  717.         return FALSE;
  718.     }
  719.     return TRUE;
  720. }
  721. #endif /* __MMI_VOIP__ */