📄 outgoingcallhelper.c
字号:
#ifdef __MMI_VOIP__
#include "VoIPGProt.h"
#endif
#if defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__)
#include "NetworkSetupDefs.h"
#endif
#if defined(__MMI_BG_SOUND_EFFECT__)
#include "BGSoundGProt.h"
#endif
#ifdef __MMI_BT_PROFILE__
#include "mdi_datatype.h"
#include "mdi_audio.h"
void mmi_profiles_bt_call_start_callback(void);
#endif /* __MMI_BT_PROFILE__ */
#if defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT)
#include "ddl.h"
#include "jcutils.h"
#include "jcerror.h"
#include "jdd_tapi.h"
#endif
static CM_CALL_HANDLE gMyhandle;
/* static U16 curKeyCode, curKeyType; */
static pBOOL gCheckDialIndEndOutgoing = FALSE;
S8 DTMFPadCallBuffer[MAX_DIGITS_USSD];
S8 UnicodeDTMFPadCallBuffer[MAX_DIGITS_USSD * ENCODING_LENGTH];
PU8 gCallDeflectNumber;
extern U16 gtmpOutgoingIndex;
extern void SSCHandleIMEI(void);
const U16 CMIdleScreenDigits[MAX_CM_SCREEN_DIGITS] =
{
KEY_0, KEY_1, KEY_2, KEY_3,
KEY_4, KEY_5, KEY_6, KEY_7,
KEY_8, KEY_9, KEY_STAR,
KEY_POUND
};
/*****************************************************************************
* FUNCTION
* MakeCallEx
* DESCRIPTION
* Wrapper which checks to see if the call to be made is
* O/G or USSD
*
* This function is exported to others applications
* PARAMETERS
* strNumber [IN]
* pre_check [IN]
* Number(?) [IN] Which needs to be sent to network
* RETURNS
* void
*****************************************************************************/
void MakeCallEx(PS8 strNumber, BOOL pre_check)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* check low battery */
if (!CHECK_MO_ALLOW())
{
ChgrPlayLowBatTone();
BatteryIndicationPopup(STR_LOW_BATTERY_MT_PROHIBIT);
return;
}
#ifdef __MMI_VOIP__
/* cannot dial gsm call when voip call exists */
if (mmi_voip_app_total_call() != 0)
{
ShowCallManagementErrorMessage(ERR_REQ_FACILITY_UNAVAIL);
return;
}
#endif /* __MMI_VOIP__ */
if (IS_LOW_BATTERY())
{
ChgrPlayLowBatTone();
if (g_charbat_context.LowBatteryTxProhibitFlag)
{
SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_TALK_DURCNT_PROHIBIT);
}
else
{
SET_LOW_BATTERY_ALARM_THRESHOLD(LBAT_TALK_DURCNT_NORMAL);
}
}
SetNoSave();
if (!GetDialedDigitCalledFlag())
{
ClearDtmfBuf();
FillDtmfBuff((PU8) strNumber);
}
else
{
SetDialedDigitCalledFlag(FALSE);
}
if (!pre_check)
{
if (NULL == strNumber)
{
SetCallDeflectFlag(FALSE);
ShowCallManagementErrorMessage(ERR_INVALID_NUMBER_FORMAT);
return;
}
else if (0 == *strNumber)
{
SetCallDeflectFlag(FALSE);
ShowCallManagementErrorMessage(ERR_INVALID_NUMBER_FORMAT);
return;
}
if (!CheckValidEmergencyNo1(strNumber))
{
if (UCS2StrFirstPositionSearch(strNumber) == FALSE)
{
SetCallDeflectFlag(FALSE);
ShowCallManagementErrorMessage(ERR_INVALID_NUMBER_FORMAT);
return;
}
if (UCS2StrNoFirstPositionSearch(strNumber, 'p') == FALSE)
{
SetCallDeflectFlag(FALSE);
ShowCallManagementErrorMessage(ERR_INVALID_NUMBER_FORMAT);
return;
}
if (UCS2StrNoFirstPositionSearch(strNumber, 'w') == FALSE)
{
SetCallDeflectFlag(FALSE);
ShowCallManagementErrorMessage(ERR_INVALID_NUMBER_FORMAT);
return;
}
}
}
CheckShortCutOrCall();
}
/*****************************************************************************
* FUNCTION
* MakeCall
* DESCRIPTION
* Check if the background sound is turn on
*
* This function is exported to others applications
* PARAMETERS
* strNumber [IN]
* Number(?) [IN] Which needs to be sent to network
* RETURNS
* void
*****************************************************************************/
void MakeCall(PS8 strNumber)
{
#if defined(__MMI_BG_SOUND_EFFECT__)
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 scr_id;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
#if defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__)
if (mmi_netset_get_active_preferred_mode() == 1 /*&& ref_prefer_mode == MMI_TRUE*/)
{
/* preferred mode = WLAN only */
DisplayPopup(
(PU8)GetString(STR_GLOBAL_UNFINISHED),
IMG_GLOBAL_UNFINISHED,
1,
CS_NOTIFYDURATION,
(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__) */
/* Don't enter background sound in the call setup screen */
scr_id = GetActiveScreenId();
SetNoSave();
/* Do check in advance to avoid some screen problem. */
if (!(scr_id >= SCR_ID_CALLSET_BARRING_MAIN && scr_id <= SCR_SETTING_BLACK_LIST_NUM) &&
(strNumber != NULL) &&
(*strNumber != 0) &&
( ( CheckValidEmergencyNo1(strNumber) ) ||
(UCS2StrFirstPositionSearch(strNumber) == TRUE) &&
(UCS2StrNoFirstPositionSearch(strNumber, 'p') == TRUE) &&
(UCS2StrNoFirstPositionSearch(strNumber, 'w') == TRUE) ) &&
(CHECK_MO_ALLOW()) &&
(mmi_bgsnd_mo_call_check_last_char(strNumber, '#') == MMI_FALSE)) /* Not SS string */
{
/* Already check the number correctness, no need to check in MakeCallEx() again */
if (mmi_bgsnd_mo_call_use_effect(strNumber) == FALSE)
{
MakeCallEx(strNumber, TRUE);
}
}
else
{
/* Check number correctness fail, let it check again and popup error message in the MakeCallEx() */
#if defined(__MMI_WLAN_FEATURES__) && defined(__MMI_VOIP__)
if (mmi_netset_get_active_preferred_mode() == 1 /*&& ref_prefer_mode == MMI_TRUE*/)
{
/* preferred mode = WLAN only */
DisplayPopup(
(PU8) GetString(STR_GLOBAL_UNFINISHED),
IMG_GLOBAL_UNFINISHED,
1,
CS_NOTIFYDURATION,
(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__) */
MakeCallEx(strNumber, FALSE);
}
#else /* defined(__MMI_BG_SOUND_EFFECT__) */
MakeCallEx(strNumber, FALSE);
#endif /* defined(__MMI_BG_SOUND_EFFECT__) */
}
/*****************************************************************************
* FUNCTION
* CheckShortCutOrCall
* DESCRIPTION
* Helper function to check if the key is shortcut or not
* if not it makes a call
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void CheckShortCutOrCall(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
PU8 dtmfBuf;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
SetNoSave();
dtmfBuf = GetDtmfBuffer();
if (GetCallDeflectFlag() == FALSE)
{
if (IsStandardGsmSS(dtmfBuf))
{
return;
}
}
if (GetCallDeflectFlag() == TRUE)
{
PRINT_INFORMATION(("XXX Call Deflection\n"));
SetCallDeflectFlag(FALSE);
OutgoingProcessCMEvent(CM_KB_CALL_DEFLECT_REQ, dtmfBuf);
/* return; */
}
else if (IsSimControlProcedure(dtmfBuf) == TRUE)
{
PRINT_INFORMATION(("XXX Sim Specifc Control\n"));
return;
}
else if (IsManufactuerSpecific(dtmfBuf) == TRUE)
{
PRINT_INFORMATION(("XXX Manufacture Specific Control \n"));
return;
}
else if (isHashString(dtmfBuf))
{
MakeMyCall((PS8) dtmfBuf);
}
else if (isShortString(dtmfBuf))
{
MakeMyCall((PS8) dtmfBuf);
}
else /* if (AllowMoreCalls()) */
{
MakeMyCall((PS8) dtmfBuf);
}
/* else
{
ShowCallManagementErrorMessage(ERR_CSMCC_CMD_NOT_ALLOW);
} */
ClearDtmfBuf();
}
/*****************************************************************************
* FUNCTION
* MakeMyCall
* DESCRIPTION
* Helper function to make a outgoingcall of a given number.
*
* This converts the number to OUTGOING_CALL structure which is necessary for State m/c.
* PARAMETERS
* strNumber [IN]
* Number(?) [IN] Which needs to make the outgoing call.
* RETURNS
* void
*****************************************************************************/
void MakeMyCall(PS8 strNumber)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
OUTGOING_CALL outCall;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
memset(&outCall, 0, sizeof(OUTGOING_CALL));
if ((strlen((void*)strNumber) * ENCODING_LENGTH) > MAX_CM_NUMBER)
{
PRINT_INFORMATION(("XXX Number too long XXX \n"));
ShowCallManagementErrorMessage(ERR_INVALID_NUMBER_FORMAT);
return;
}
pfnUnicodeStrcpy((void*)outCall.Number, (void*)UnicodeDTMFPadCallBuffer);
MakeOutgoingcall(outCall);
}
/*****************************************************************************
* FUNCTION
* MakeOutgoingcall
* DESCRIPTION
* Helper function to generate Keybrd Event CM_KB_OUTGOINGCALL with the OUTGOING_CALL structure.
*
* This invokes the function to process the CM_KB_OUTGOINGCALL event in the state m/c.
* PARAMETERS
* MsgStruct [IN]
* structure(?) [IN] Contains the calling number and name if present corresponding to that number.
* RETURNS
* void
*****************************************************************************/
void MakeOutgoingcall(OUTGOING_CALL MsgStruct)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
OutgoingProcessCMEvent(CM_KB_OUTGOINGCALL, &MsgStruct);
}
/*****************************************************************************
* FUNCTION
* IsStandardGsmSS
* DESCRIPTION
* Helper function for interpreting user code
* PARAMETERS
* dtmfBuf [IN]
* true(?) [OUT] Or false on the basis of interepretaion of SS
* buffer(?) [IN] For interpretation
* RETURNS
* pBOOL
*****************************************************************************/
pBOOL IsStandardGsmSS(PU8 dtmfBuf)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
PU8 tmpBuf = dtmfBuf;
CM_CALL_HANDLE callVal;
S32 bufLen;
pBOOL valid = FALSE;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (GetTotalCallCount() == 0)
{
return FALSE;
}
/* second digit must be NULL, *, or 0~9 */
if ((*(tmpBuf + 1) == 0) || (*(tmpBuf + 1) == '*') || ((*(tmpBuf + 1) >= '0') && (*(tmpBuf + 1) <= '9')))
{
valid = TRUE;
}
if (valid == TRUE)
{
switch (*tmpBuf)
{
case '0':
if ('\0' == *(tmpBuf + 1))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -