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

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.  *  VoIPInterface.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.  *------------------------------------------------------------------------------
  88.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  89.  *============================================================================
  90.  ****************************************************************************/
  91. #include "MMI_features.h"
  92. #ifdef __MMI_VOIP__
  93. #include "stdC.h"
  94. #include "L4Dr1.h"
  95. #include "DebugInitDef.h"
  96. #include "mmi_trc.h"    /* debug info */
  97. #include "GlobalMenuItems.h"
  98. #include "GlobalScrEnum.h"
  99. #include "CustMenuRes.h"
  100. #include "CustDataRes.h"
  101. #include "ProtocolEvents.h"
  102. #include "CommonScreens.h"
  103. #include "SettingProfile.h"
  104. #include "EventsGprot.h"
  105. #include "wgui_categories_popup.h"
  106. #include "wgui_categories_inputs.h"
  107. #include "wgui_categories_util.h"
  108. #include "NVRAMEnum.h"
  109. #include "NVRAMProt.h"
  110. #include "NVRAMType.h"
  111. #include "custom_nvram_editor_data_item.h"
  112. #include "custom_data_account.h"
  113. #include "CallManagementGprot.h"
  114. #include "CallManagementStruct.h"
  115. #include "CallsGprots.h"
  116. #include "KeyBrd.h"
  117. #if defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__)
  118. #include "NetworkSetupDefs.h"
  119. #endif
  120. #include "PhoneBookGprot.h"
  121. #include "PhoneBookTypes.h"
  122. #include "VoIPDef.h"
  123. #include "VoIPGProt.h"
  124. #include "VoIPProt.h"
  125. /*****************************************************************************
  126.  * FUNCTION
  127.  *  mmi_voip_app_get_register_state
  128.  * DESCRIPTION
  129.  *  Get VoIP register state. Mainly for preferred mode.
  130.  * PARAMETERS
  131.  *  void
  132.  * RETURNS
  133.  *  VoIP register state, either MMI_VOIP_DEREG_STATE, MMI_VOIP_PROCESS_STATE, or MMI_VOIP_REG_STATE.
  134.  *****************************************************************************/
  135. mmi_voip_reg_state_enum mmi_voip_app_get_register_state(void)
  136. {
  137.     /*----------------------------------------------------------------*/
  138.     /* Local Variables                                                */
  139.     /*----------------------------------------------------------------*/
  140.     /*----------------------------------------------------------------*/
  141.     /* Code Body                                                      */
  142.     /*----------------------------------------------------------------*/
  143.     return g_voip_cntx_p->reg_state_info;
  144. }
  145. /*****************************************************************************
  146.  * FUNCTION
  147.  *  mmi_voip_app_make_call
  148.  * DESCRIPTION
  149.  *  Make a VoIP call to the given URI. Mainly for phonebook and call history.
  150.  * PARAMETERS
  151.  *  unicodeUri      [IN]        Destination uri in unicode string
  152.  * RETURNS
  153.  *  void
  154.  *****************************************************************************/
  155. void mmi_voip_app_make_call(U8 *unicodeUri)
  156. {
  157.     /*----------------------------------------------------------------*/
  158.     /* Local Variables                                                */
  159.     /*----------------------------------------------------------------*/
  160.     S32 uriLen = 0;
  161.     BOOL fromPhb = FALSE, fromLog = FALSE;
  162.     /*----------------------------------------------------------------*/
  163.     /* Code Body                                                      */
  164.     /*----------------------------------------------------------------*/
  165. #if defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__)
  166.     if (mmi_netset_get_active_preferred_mode() == 0) /* preferred mode = GSM only */
  167.     {
  168.         DisplayPopup(
  169.             (U8*)GetString(STR_GLOBAL_UNFINISHED),
  170.             IMG_GLOBAL_UNFINISHED,
  171.             1,
  172.             UI_POPUP_NOTIFYDURATION_TIME,
  173.             (U8)ERROR_TONE);
  174.         mmi_phb_call_set_dial_from_list(MMI_PHB_NONE);  /* reset dial from phonebook flag */
  175.         CHISTSetDialFromCallLogFlag(0);                 /* reset dial from call history flag */
  176.         return;
  177.     }
  178. #endif /* defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__) */
  179.     uriLen = (VOIP_URI_LEN > pfnUnicodeStrlen((S8*)unicodeUri)) ?
  180.         (pfnUnicodeStrlen((S8*)unicodeUri)) : (VOIP_URI_LEN - 1);
  181.     
  182.     memset(g_voip_cntx_p->call_misc_info.dispUri, 0, (VOIP_URI_LEN * ENCODING_LENGTH));
  183.     pfnUnicodeStrncpy((S8*)g_voip_cntx_p->call_misc_info.dispUri, (S8*)unicodeUri, uriLen);
  184.     
  185.     fromPhb = mmi_voip_set_outgoing_origin_app(MMI_VOIP_PHB);
  186.     fromLog = mmi_voip_set_outgoing_origin_app(MMI_VOIP_HISTORY);
  187.     /* cannot dial from phonebook and dial from call log simultaneously */
  188.     MMI_ASSERT(!(fromPhb == TRUE && fromLog == TRUE));
  189.     
  190.     mmi_voip_pre_dial();
  191.     mmi_phb_call_set_dial_from_list(MMI_PHB_NONE);  /* reset dial from phonebook flag */
  192.     CHISTSetDialFromCallLogFlag(0);                 /* reset dial from call history flag */
  193. }
  194. /*****************************************************************************
  195.  * FUNCTION
  196.  *  mmi_voip_app_total_call
  197.  * DESCRIPTION
  198.  *  Total number of voip calls, including outgoing call, incoming call,
  199.  *  active call, held call, etc.
  200.  * PARAMETERS
  201.  *  void
  202.  * RETURNS
  203.  *  0 means voip not in-call, !0 means voip in-call.
  204.  *****************************************************************************/
  205. S32 mmi_voip_app_total_call(void)
  206. {
  207.     /*----------------------------------------------------------------*/
  208.     /* Local Variables                                                */
  209.     /*----------------------------------------------------------------*/
  210.     /*----------------------------------------------------------------*/
  211.     /* Code Body                                                      */
  212.     /*----------------------------------------------------------------*/
  213.     return g_voip_cntx_p->call_list_info.numTotal;
  214. }
  215. /*****************************************************************************
  216.  * FUNCTION
  217.  *  mmi_voip_app_set_conn_flag
  218.  * DESCRIPTION
  219.  *  Set the flag before disconnecting the other type of call.
  220.  *  After disconnecting successfully, connect the given type of call.
  221.  *  Mainly for the interaction of GSM and VoIP.
  222.  * PARAMETERS
  223.  *  needConn        [IN]        Need to connect what type of call
  224.  * RETURNS
  225.  *  void
  226.  *****************************************************************************/
  227. void mmi_voip_app_set_conn_flag(mmi_voip_call_conn_enum needConn)
  228. {
  229.     /*----------------------------------------------------------------*/
  230.     /* Local Variables                                                */
  231.     /*----------------------------------------------------------------*/
  232.     /*----------------------------------------------------------------*/
  233.     /* Code Body                                                      */
  234.     /*----------------------------------------------------------------*/
  235.     g_voip_cntx_p->call_list_info.needConn = needConn;
  236. }
  237. /*****************************************************************************
  238.  * FUNCTION
  239.  *  mmi_voip_app_get_conn_flag
  240.  * DESCRIPTION
  241.  *  Get the flag before connecting call so that we know what type of call that needs to connect.
  242.  *  Mainly for the interaction of GSM and VoIP.
  243.  * PARAMETERS
  244.  *  void
  245.  * RETURNS
  246.  *  MMI_VOIP_CALL_CONN_NONE means no need to connect call;
  247.  *  MMI_VOIP_CALL_CONN_GSM means to connect gsm call;
  248.  *  MMI_VOIP_CALL_CONN_VOIP means to connect voip call.
  249.  *****************************************************************************/
  250. mmi_voip_call_conn_enum mmi_voip_app_get_conn_flag(void)
  251. {
  252.     /*----------------------------------------------------------------*/
  253.     /* Local Variables                                                */
  254.     /*----------------------------------------------------------------*/
  255.     /*----------------------------------------------------------------*/
  256.     /* Code Body                                                      */
  257.     /*----------------------------------------------------------------*/
  258.     return g_voip_cntx_p->call_list_info.needConn;
  259. }
  260. /*****************************************************************************
  261.  * FUNCTION
  262.  *  mmi_voip_entry_headsetkey
  263.  * DESCRIPTION
  264.  *  Handle headset key after receiving GPIO detection. Mainly for GPIO.
  265.  * PARAMETERS
  266.  *  void
  267.  * RETURNS
  268.  *  void
  269.  *****************************************************************************/
  270. void mmi_voip_entry_headsetkey(void)
  271. {
  272.     /*----------------------------------------------------------------*/
  273.     /* Local Variables                                                */
  274.     /*----------------------------------------------------------------*/
  275.     /*----------------------------------------------------------------*/
  276.     /* Code Body                                                      */
  277.     /*----------------------------------------------------------------*/
  278.     /* incoming call exists, headset key is to answer it */
  279.     if (mmi_voip_get_incoming_call_id() != -1)
  280.     {
  281.         PRINT_INFORMATION(("n[mmi_voip_entry_headsetkey] Answer Incoming Calln"));
  282.         mmi_voip_entry_answer_call();
  283.     }
  284.     /* outgoing call exists, headset key is to abort it */
  285.     else if (mmi_voip_get_outgoing_call_id() != -1)
  286.     {
  287.         PRINT_INFORMATION(("n[mmi_voip_entry_headsetkey] Abort Outgoing Calln"));
  288.         mmi_voip_entry_abort_call();
  289.     }
  290.     /* in call, headset key is to release current highlight tab call */
  291.     else if (g_voip_cntx_p->call_list_info.numTotal > 0)
  292.     {
  293.         PRINT_INFORMATION(("n[mmi_voip_entry_headsetkey] Release Highlight Tab Calln"));
  294.         mmi_voip_entry_in_call_endkey();
  295.     }
  296. }
  297. /*****************************************************************************
  298.  * FUNCTION
  299.  *  mmi_voip_need_msg_waiting_ind
  300.  * DESCRIPTION
  301.  *  Display message waiting screen in idle screen or not. Mainly for idle screen.
  302.  * PARAMETERS
  303.  *  void
  304.  * RETURNS
  305.  *  TRUE means need to show message waiting screen in idle;
  306.  *  FALSE means need not to show message waiting screen in idle.
  307.  *****************************************************************************/
  308. BOOL mmi_voip_need_msg_waiting_ind(void)
  309. {
  310.     /*----------------------------------------------------------------*/
  311.     /* Local Variables                                                */
  312.     /*----------------------------------------------------------------*/
  313.     /*----------------------------------------------------------------*/
  314.     /* Code Body                                                      */
  315.     /*----------------------------------------------------------------*/
  316.     return g_voip_cntx_p->msg_waiting_info.isDisp;
  317. }
  318. /*****************************************************************************
  319.  * FUNCTION
  320.  *  mmi_voip_entry_msg_waiting_ind
  321.  * DESCRIPTION
  322.  *  Message waiting screen in idle screen. Mainly for idle screen.
  323.  * PARAMETERS
  324.  *  void
  325.  * RETURNS
  326.  *  void
  327.  *****************************************************************************/
  328. void mmi_voip_entry_msg_waiting_ind(void)
  329. {
  330.     /*----------------------------------------------------------------*/
  331.     /* Local Variables                                                */
  332.     /*----------------------------------------------------------------*/
  333.     U16 lskStr = 0;
  334.     /*----------------------------------------------------------------*/
  335.     /* Code Body                                                      */
  336.     /*----------------------------------------------------------------*/
  337.     memset(g_voip_cntx_p->msg_waiting_info.mwiStr, 0, MMI_VOIP_MAX_STRING_LEN);
  338.     mmi_voip_get_mwi_string((U8*)g_voip_cntx_p->msg_waiting_info.mwiStr);
  339.     if (mmi_voip_is_keypad_lock_state() == FALSE)
  340.     {
  341.         EntryNewScreen(SCR_ID_VOIP_MSG_WAITING, NULL, mmi_voip_entry_msg_waiting_ind, NULL);
  342.         if ((g_voip_cntx_p->msg_waiting_info.mwiType == STR_ID_VOIP_VOICE_MESSAGE) &&
  343.             (!strlen((S8*) g_voip_cntx_p->msg_waiting_info.mwiAcct)))
  344.         {
  345.             lskStr = STR_ID_VOIP_DIAL;
  346.             memset(g_voip_cntx_p->call_misc_info.dispUri, 0, VOIP_URI_LEN);
  347.             AnsiiNToUnicodeString(
  348.                 (S8*) g_voip_cntx_p->call_misc_info.dispUri,
  349.                 (S8*) g_voip_cntx_p->msg_waiting_info.mwiAcct,
  350.                 VOIP_URI_LEN);
  351.         }
  352.         else
  353.         {
  354.             lskStr = 0;
  355.         }
  356.         ShowCategory141Screen(
  357.             g_voip_cntx_p->msg_waiting_info.mwiType,
  358.             GetRootTitleIcon(MENU_ID_VOIP_MAIN),
  359.             lskStr,
  360.             IMG_GLOBAL_OK,
  361.             STR_GLOBAL_BACK,
  362.             IMG_GLOBAL_BACK,
  363.             (U8*)g_voip_cntx_p->msg_waiting_info.mwiStr,
  364.             IMG_ID_VOIP_MSG_WAITING,
  365.             NULL);
  366.         if (lskStr)
  367.         {
  368.             SetLeftSoftkeyFunction(mmi_voip_pre_dial, KEY_EVENT_UP);
  369.         }
  370.         SetRightSoftkeyFunction(mmi_voip_go_back_to_idle, KEY_EVENT_UP);
  371.         SetKeyHandler(mmi_voip_go_back_to_idle, KEY_END, KEY_EVENT_DOWN);
  372.     }
  373.     else    /* keypad lock */
  374.     {
  375.         ShowCategory141Screen(
  376.             g_voip_cntx_p->msg_waiting_info.mwiType,
  377.             GetRootTitleIcon(MENU_ID_VOIP_MAIN),
  378.             g_keylock_context.KeyLockLSKStringID,
  379.             g_keylock_context.KeyLockLSKIconID,
  380.             g_keylock_context.KeyLockRSKStringID,
  381.             g_keylock_context.KeyLockRSKIconID,
  382.             (U8*)g_voip_cntx_p->msg_waiting_info.mwiStr,
  383.             IMG_ID_VOIP_MSG_WAITING,
  384.             NULL);
  385.     }
  386. }
  387. /*****************************************************************************
  388.  * FUNCTION
  389.  *  mmi_voip_go_back_to_idle
  390.  * DESCRIPTION
  391.  *  Handle RSK and END key in message waiting screen. Mainly for idle screen.
  392.  * PARAMETERS
  393.  *  void
  394.  * RETURNS
  395.  *  void
  396.  *****************************************************************************/
  397. void mmi_voip_go_back_to_idle(void)
  398. {
  399.     /*----------------------------------------------------------------*/
  400.     /* Local Variables                                                */
  401.     /*----------------------------------------------------------------*/
  402.     /*----------------------------------------------------------------*/
  403.     /* Code Body                                                      */
  404.     /*----------------------------------------------------------------*/
  405.     g_voip_cntx_p->msg_waiting_info.isDisp = FALSE;
  406.     DisplayIdleScreen();
  407. }
  408. /*****************************************************************************
  409.  * FUNCTION
  410.  *  mmi_voip_entry_msg_waiting_popup
  411.  * DESCRIPTION
  412.  *  Message waiting popup in other application.
  413.  * PARAMETERS
  414.  *  void
  415.  * RETURNS
  416.  *  void
  417.  *****************************************************************************/
  418. void mmi_voip_entry_msg_waiting_popup(void)
  419. {
  420.     /*----------------------------------------------------------------*/
  421.     /* Local Variables                                                */
  422.     /*----------------------------------------------------------------*/
  423.     U16 strId = 0;
  424.     /*----------------------------------------------------------------*/
  425.     /* Code Body                                                      */
  426.     /*----------------------------------------------------------------*/
  427.     EntryNewScreen(SCR_POPUP_SCREEN, NULL, NULL, NULL);
  428.     strId = g_voip_cntx_p->msg_waiting_info.mwiType;
  429.     ShowCategory65Screen((U8*) GetString(strId), IMG_GLOBAL_OK, NULL);
  430.     SetGroupKeyHandler(NULL, (U16*) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_DOWN);
  431.     SetGroupKeyHandler(GoBackHistory, (U16*) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_UP);
  432. }
  433. #endif /* __MMI_VOIP__ */