VoIPInterface.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:18k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * VoIPInterface.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * Coding Template header file
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include "MMI_features.h"
- #ifdef __MMI_VOIP__
- #include "stdC.h"
- #include "L4Dr1.h"
- #include "DebugInitDef.h"
- #include "mmi_trc.h" /* debug info */
- #include "GlobalMenuItems.h"
- #include "GlobalScrEnum.h"
- #include "CustMenuRes.h"
- #include "CustDataRes.h"
- #include "ProtocolEvents.h"
- #include "CommonScreens.h"
- #include "SettingProfile.h"
- #include "EventsGprot.h"
- #include "wgui_categories_popup.h"
- #include "wgui_categories_inputs.h"
- #include "wgui_categories_util.h"
- #include "NVRAMEnum.h"
- #include "NVRAMProt.h"
- #include "NVRAMType.h"
- #include "custom_nvram_editor_data_item.h"
- #include "custom_data_account.h"
- #include "CallManagementGprot.h"
- #include "CallManagementStruct.h"
- #include "CallsGprots.h"
- #include "KeyBrd.h"
- #if defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__)
- #include "NetworkSetupDefs.h"
- #endif
- #include "PhoneBookGprot.h"
- #include "PhoneBookTypes.h"
- #include "VoIPDef.h"
- #include "VoIPGProt.h"
- #include "VoIPProt.h"
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_app_get_register_state
- * DESCRIPTION
- * Get VoIP register state. Mainly for preferred mode.
- * PARAMETERS
- * void
- * RETURNS
- * VoIP register state, either MMI_VOIP_DEREG_STATE, MMI_VOIP_PROCESS_STATE, or MMI_VOIP_REG_STATE.
- *****************************************************************************/
- mmi_voip_reg_state_enum mmi_voip_app_get_register_state(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_voip_cntx_p->reg_state_info;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_app_make_call
- * DESCRIPTION
- * Make a VoIP call to the given URI. Mainly for phonebook and call history.
- * PARAMETERS
- * unicodeUri [IN] Destination uri in unicode string
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_voip_app_make_call(U8 *unicodeUri)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 uriLen = 0;
- BOOL fromPhb = FALSE, fromLog = FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #if defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__)
- if (mmi_netset_get_active_preferred_mode() == 0) /* preferred mode = GSM only */
- {
- DisplayPopup(
- (U8*)GetString(STR_GLOBAL_UNFINISHED),
- IMG_GLOBAL_UNFINISHED,
- 1,
- UI_POPUP_NOTIFYDURATION_TIME,
- (U8)ERROR_TONE);
- mmi_phb_call_set_dial_from_list(MMI_PHB_NONE); /* reset dial from phonebook flag */
- CHISTSetDialFromCallLogFlag(0); /* reset dial from call history flag */
- return;
- }
- #endif /* defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__) */
- uriLen = (VOIP_URI_LEN > pfnUnicodeStrlen((S8*)unicodeUri)) ?
- (pfnUnicodeStrlen((S8*)unicodeUri)) : (VOIP_URI_LEN - 1);
- memset(g_voip_cntx_p->call_misc_info.dispUri, 0, (VOIP_URI_LEN * ENCODING_LENGTH));
- pfnUnicodeStrncpy((S8*)g_voip_cntx_p->call_misc_info.dispUri, (S8*)unicodeUri, uriLen);
- fromPhb = mmi_voip_set_outgoing_origin_app(MMI_VOIP_PHB);
- fromLog = mmi_voip_set_outgoing_origin_app(MMI_VOIP_HISTORY);
- /* cannot dial from phonebook and dial from call log simultaneously */
- MMI_ASSERT(!(fromPhb == TRUE && fromLog == TRUE));
- mmi_voip_pre_dial();
- mmi_phb_call_set_dial_from_list(MMI_PHB_NONE); /* reset dial from phonebook flag */
- CHISTSetDialFromCallLogFlag(0); /* reset dial from call history flag */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_app_total_call
- * DESCRIPTION
- * Total number of voip calls, including outgoing call, incoming call,
- * active call, held call, etc.
- * PARAMETERS
- * void
- * RETURNS
- * 0 means voip not in-call, !0 means voip in-call.
- *****************************************************************************/
- S32 mmi_voip_app_total_call(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_voip_cntx_p->call_list_info.numTotal;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_app_set_conn_flag
- * DESCRIPTION
- * Set the flag before disconnecting the other type of call.
- * After disconnecting successfully, connect the given type of call.
- * Mainly for the interaction of GSM and VoIP.
- * PARAMETERS
- * needConn [IN] Need to connect what type of call
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_voip_app_set_conn_flag(mmi_voip_call_conn_enum needConn)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_voip_cntx_p->call_list_info.needConn = needConn;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_app_get_conn_flag
- * DESCRIPTION
- * Get the flag before connecting call so that we know what type of call that needs to connect.
- * Mainly for the interaction of GSM and VoIP.
- * PARAMETERS
- * void
- * RETURNS
- * MMI_VOIP_CALL_CONN_NONE means no need to connect call;
- * MMI_VOIP_CALL_CONN_GSM means to connect gsm call;
- * MMI_VOIP_CALL_CONN_VOIP means to connect voip call.
- *****************************************************************************/
- mmi_voip_call_conn_enum mmi_voip_app_get_conn_flag(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_voip_cntx_p->call_list_info.needConn;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_entry_headsetkey
- * DESCRIPTION
- * Handle headset key after receiving GPIO detection. Mainly for GPIO.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_voip_entry_headsetkey(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* incoming call exists, headset key is to answer it */
- if (mmi_voip_get_incoming_call_id() != -1)
- {
- PRINT_INFORMATION(("n[mmi_voip_entry_headsetkey] Answer Incoming Calln"));
- mmi_voip_entry_answer_call();
- }
- /* outgoing call exists, headset key is to abort it */
- else if (mmi_voip_get_outgoing_call_id() != -1)
- {
- PRINT_INFORMATION(("n[mmi_voip_entry_headsetkey] Abort Outgoing Calln"));
- mmi_voip_entry_abort_call();
- }
- /* in call, headset key is to release current highlight tab call */
- else if (g_voip_cntx_p->call_list_info.numTotal > 0)
- {
- PRINT_INFORMATION(("n[mmi_voip_entry_headsetkey] Release Highlight Tab Calln"));
- mmi_voip_entry_in_call_endkey();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_need_msg_waiting_ind
- * DESCRIPTION
- * Display message waiting screen in idle screen or not. Mainly for idle screen.
- * PARAMETERS
- * void
- * RETURNS
- * TRUE means need to show message waiting screen in idle;
- * FALSE means need not to show message waiting screen in idle.
- *****************************************************************************/
- BOOL mmi_voip_need_msg_waiting_ind(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_voip_cntx_p->msg_waiting_info.isDisp;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_entry_msg_waiting_ind
- * DESCRIPTION
- * Message waiting screen in idle screen. Mainly for idle screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_voip_entry_msg_waiting_ind(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 lskStr = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(g_voip_cntx_p->msg_waiting_info.mwiStr, 0, MMI_VOIP_MAX_STRING_LEN);
- mmi_voip_get_mwi_string((U8*)g_voip_cntx_p->msg_waiting_info.mwiStr);
- if (mmi_voip_is_keypad_lock_state() == FALSE)
- {
- EntryNewScreen(SCR_ID_VOIP_MSG_WAITING, NULL, mmi_voip_entry_msg_waiting_ind, NULL);
- if ((g_voip_cntx_p->msg_waiting_info.mwiType == STR_ID_VOIP_VOICE_MESSAGE) &&
- (!strlen((S8*) g_voip_cntx_p->msg_waiting_info.mwiAcct)))
- {
- lskStr = STR_ID_VOIP_DIAL;
- memset(g_voip_cntx_p->call_misc_info.dispUri, 0, VOIP_URI_LEN);
- AnsiiNToUnicodeString(
- (S8*) g_voip_cntx_p->call_misc_info.dispUri,
- (S8*) g_voip_cntx_p->msg_waiting_info.mwiAcct,
- VOIP_URI_LEN);
- }
- else
- {
- lskStr = 0;
- }
- ShowCategory141Screen(
- g_voip_cntx_p->msg_waiting_info.mwiType,
- GetRootTitleIcon(MENU_ID_VOIP_MAIN),
- lskStr,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- (U8*)g_voip_cntx_p->msg_waiting_info.mwiStr,
- IMG_ID_VOIP_MSG_WAITING,
- NULL);
- if (lskStr)
- {
- SetLeftSoftkeyFunction(mmi_voip_pre_dial, KEY_EVENT_UP);
- }
- SetRightSoftkeyFunction(mmi_voip_go_back_to_idle, KEY_EVENT_UP);
- SetKeyHandler(mmi_voip_go_back_to_idle, KEY_END, KEY_EVENT_DOWN);
- }
- else /* keypad lock */
- {
- ShowCategory141Screen(
- g_voip_cntx_p->msg_waiting_info.mwiType,
- GetRootTitleIcon(MENU_ID_VOIP_MAIN),
- g_keylock_context.KeyLockLSKStringID,
- g_keylock_context.KeyLockLSKIconID,
- g_keylock_context.KeyLockRSKStringID,
- g_keylock_context.KeyLockRSKIconID,
- (U8*)g_voip_cntx_p->msg_waiting_info.mwiStr,
- IMG_ID_VOIP_MSG_WAITING,
- NULL);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_go_back_to_idle
- * DESCRIPTION
- * Handle RSK and END key in message waiting screen. Mainly for idle screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_voip_go_back_to_idle(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_voip_cntx_p->msg_waiting_info.isDisp = FALSE;
- DisplayIdleScreen();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_voip_entry_msg_waiting_popup
- * DESCRIPTION
- * Message waiting popup in other application.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_voip_entry_msg_waiting_popup(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 strId = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_POPUP_SCREEN, NULL, NULL, NULL);
- strId = g_voip_cntx_p->msg_waiting_info.mwiType;
- ShowCategory65Screen((U8*) GetString(strId), IMG_GLOBAL_OK, NULL);
- SetGroupKeyHandler(NULL, (U16*) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_DOWN);
- SetGroupKeyHandler(GoBackHistory, (U16*) PresentAllKeys, TOTAL_KEYS, KEY_EVENT_UP);
- }
- #endif /* __MMI_VOIP__ */