⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 callstructuremanagement.c

📁 MTK手机平台的MMI部分的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:

   REMARKS     : nil

   AUTHOR      : Ashish

   DATE     : Nov 8,02

**************************************************************/
#include "stdC.h"
#include "MMI_features.h"
#include "L4Dr.h"
#include "L4Dr1.h"
#include "PixtelDataTypes.h"
#include "GlobalConstants.h"
#include "DebugInitDef.h"
#include "MMI_trc.h"
#include "TimerEvents.h"

#include "WrapperGprot.h"
#include "mdi_datatype.h"
#include "mdi_audio.h"
#include "KeyBrd.h"
#include "DateTimeGProt.h"
#include "PhoneBookDef.h"
#include "PhoneBookTypes.h"
#include "PhoneBookGProt.h"
#include "IdleAppDef.h"
#include "SettingGprots.h"
#include "SATGProts.h"
#include "ManageCallMain.h"
#include "SimDetectionGProt.h"
#include "ProfileGprots.h"
#include "CSP.h"

#ifdef __CTM_SUPPORT__
#include "TextPhoneDef.h"
#include "TextPhoneProt.h"
#endif /* __CTM_SUPPORT__ */ 
#ifdef __MMI_VOIP__
#include "VoIPGProt.h"
#endif
#include "CallmanagementIdDef.h"
#include "CallManagementStruct.h"
#include "CallStructureManagementProt.h"
#include "CallManagementGprot.h"
#include "CommonStubsProt.h"
#include "RedialHelperGProt.h"
#include "PsCallHelperDef.h"
#include "mmiapi_struct.h"
#include "PsCallHelperGprot.h"
#include "IncomingCallManagementProt.h"
#include "OutgoingCallManagementProt.h"
#include "CallsGProts.h"
#if defined(__MMI_BG_SOUND_EFFECT__)
#include "BGSoundGProt.h"
#endif

static cm_context_struct g_CallManagement_cntxt;
cm_context_struct *cm_p = &g_CallManagement_cntxt;

//static CALL_STATE gCurrentState = CM_IDLE_STATE; //to manage the current state
//static CALL_STATE gPrevState = CM_IDLE_STATE; //to manage the previous state
//static CALL_INFO gAllCalls[MAX_CALLS];
//static CALL_INFO gCallStructureForCallLog;

static CM_CALL_HANDLE gCallHandleForStartTimeUpdate;
static MYTIME gTimeStructForEndedCallStartTime;
MYTIME gTimeStructForCallDuration;

static MMI_ANSWERING_MODE gCMAnsMode;
static PHB_CM_INTERFACE gPhoneNumberStruct;
static CHLD_REQ_ACTION gChldReqSent;

//static U16 gNumofActivecalls=0;               //to store the num of active calls.
//static U16 gNumOfHoldCalls=0;         //to store the num of hold calls.
//static U16 gTotalCallCount=0;         //to store the total calls.

static U16 gCallEndCause = 0;
static U32 gCtrTime;
U32 gSumACMValue = 0;

#ifdef __MMI_CM_BLACK_LIST__
static pBOOL gBlackIncomingFlag = FALSE; /* If the incoming call is in black list*/
#endif
static pBOOL gClearKeyFlag = TRUE;
static pBOOL gIsCCCall = TRUE;
static pBOOL gCallAbortRequested = FALSE;   /* To determine whether abort call has been called once */
static pBOOL gDropRequestFlag = FALSE;
static pBOOL gCallAbortReqSentFlag = FALSE;
static pBOOL gCallEndedBeforeConnFlag = FALSE;
static pBOOL gIncomingCallDroppedFlag = FALSE;
static pBOOL gMissedCallFlag = FALSE;
static pBOOL gCallWaitFlag = FALSE;
static pBOOL gCcbsFlag = FALSE;
static pBOOL gCcbsFlagActivated = FALSE;
static pBOOL gWait2RingCallFlag = FALSE;
static pBOOL gNoTwiceRingFlag = FALSE;
static U8 gErrorToneFlag = 0;
static pBOOL gAutoAnswerFlag = FALSE;

/* Start by Julia: Drop call refinement */
static pBOOL gAutoReleaseFlag = FALSE;

/* End by Julia */
static pBOOL gCallDeflectFlag = FALSE;
static pBOOL gShowAOC = FALSE;
static pBOOL gDTMFKeyUpFlag = TRUE;
static pBOOL gCMScrnFlag = TRUE;
static pBOOL gGetTimeBeforeActive = FALSE;

static pBOOL gWapCallPresent = FALSE;
static pBOOL gPreviousWapCall = FALSE;

static pBOOL gPriority = FALSE;
static pBOOL gDialedDigitCalledFlag = FALSE;
static pBOOL gSATScrnSavedFlag = FALSE;

static pBOOL gSyncFromAT = FALSE;

#ifdef __IP_NUMBER__
static pBOOL gTempUseIPNum = FALSE;
#endif 

extern U16 gtmpOutgoingIndex;
extern U8 isCSPPresent;

/* extern U8 isIdleScreenReached; */


/*****************************************************************************
 * FUNCTION
 *  InitCallManagement
 * DESCRIPTION
 *  To Initialize the Call Management Application
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void InitCallManagement(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    InitIncomingCall();
    InitOutGoingCall();
    memset (cm_p, 0, sizeof(cm_context_struct));
    ResetGlobalValues();

#ifdef __CTM_SUPPORT__
    mmi_init_ctm_call();
#endif 
}


/*****************************************************************************
 * FUNCTION
 *  ReinitalizeCallManagement
 * DESCRIPTION
 *  To Re-Initialize the Call Management Application
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void ReinitalizeCallManagement(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (cm_p->alert_info.IsCTRStart == TRUE);
    StopTimer(CM_CTR_TIMER);

    ResetGlobalValues();
    ReinitalizeIncomingCall();
    ReinitializeOutgoingCall();
    SetCurrentState(CM_IDLE_STATE);
    SetPreviousState(CM_IDLE_STATE);
}


/*****************************************************************************
 * FUNCTION
 *  ResetGlobalValues
 * DESCRIPTION
 *  This function resets the state of all the internal
 *  call variables. This is to be called at time of exit
 *  from CM application
 * PARAMETERS
 *  void
 *  Index(?)        [OUT]       To the location where the call can be stored
 * RETURNS
 *  Index(?)
 *****************************************************************************/
void ResetGlobalValues(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    CALL_INFO temp;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    memset(&cm_p->alert_info, 0, sizeof(cm_alert_struct));
    memset(&cm_p->redial_info, 0, sizeof(cm_redial_struct));

    /* do not reset history info, notify SS might not finish when get out of CM */

    /* keep call info for call log */
    memcpy(&temp, &cm_p->state_info.CallStructureForCallLog, sizeof(CALL_INFO));
    memset(&cm_p->state_info, 0, sizeof(cm_state_struct));
    memcpy(&cm_p->state_info.CallStructureForCallLog, &temp, sizeof(CALL_INFO));

    cm_p->alert_info.DTMF = TRUE;
    cm_p->history_info.IsSave = FALSE;
    //gNumofActivecalls=0;
    //gNumOfHoldCalls=0;
    //gTotalCallCount=0;
    //gCurrentState = CM_IDLE_STATE;
    //gPrevState = CM_IDLE_STATE;
    gSumACMValue = 0;
    InitCallInfo();
    SetShowAOC(FALSE);
}


/*****************************************************************************
 * FUNCTION
 *  DeInitCM
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void DeInitCM(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (isInCall())
    {
        HangupAllCalls();
    }
    if (GetCurrentAttempt() > 0)
    {
        ResetRedialAndGoBack();
    }
}


/*****************************************************************************
 * FUNCTION
 *  InitCallInfo
 * DESCRIPTION
 *  Initializes the Call structres array
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void InitCallInfo(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 index;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (index = 0; index < MAX_CALLS; index++)
    {
        memset(&cm_p->state_info.AllCalls[index], 0, sizeof(CALL_INFO));
        cm_p->state_info.AllCalls[index].call_handle = -1;
    }

    cm_p->state_info.NumofActivecalls = 0;
    cm_p->state_info.NumofHeldcalls = 0;
    cm_p->state_info.TotalCallCount = 0;
}


/*****************************************************************************
 * FUNCTION
 *  ResetCallInfo
 * DESCRIPTION
 *  Helper function to reset a particular call structure
 * PARAMETERS
 *  nCallHandle     [IN]        // Handle for call structure to reset
 *  bIsHandle       [IN]        // If the n/w has supplied a handle
 * RETURNS
 *  void
 *****************************************************************************/
void ResetCallInfo(CM_CALL_HANDLE nCallHandle, pBOOL bIsHandle)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 index;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (bIsHandle)
    {
        index = GetMMIStructIndexof(nCallHandle);
    }
    else
    {
        index = nCallHandle;
    }

    memset(&cm_p->state_info.AllCalls[index], 0, sizeof(CALL_INFO));
    cm_p->state_info.AllCalls[index].call_handle = -1;
}


/*****************************************************************************
 * FUNCTION
 *  PurgeOutgoingCallsStructure
 * DESCRIPTION
 *  Wrapper to reinitialize all outgoing calls structure
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void PurgeOutgoingCallsStructure(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 count;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (count = 0; count < MAX_CALLS; count++)
    {
        /* Start by Julia: Drop call refinement - add CM_DISCONNECTING_STATE condition */
        if (cm_p->state_info.AllCalls[count].curr_state == CM_OUTGOING_STATE ||
            (cm_p->state_info.AllCalls[count].prev_state == CM_OUTGOING_STATE &&
             cm_p->state_info.AllCalls[count].curr_state == CM_DISCONNECTING_STATE))
            /* End by Julia */
        {
            SetCallState((CM_CALL_HANDLE) count, CM_IDLE_STATE, FALSE);
        }
    }
}


/*****************************************************************************
 * FUNCTION
 *  PurgeIncomingCallStructure
 * DESCRIPTION
 *  Wrapper to reinitialize incoming call structure
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void PurgeIncomingCallStructure(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 count;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (count = 0; count < MAX_CALLS; count++)
    {
        /* Start by Julia: Drop call refinement - add CM_DISCONNECTING_STATE condition */
        if (cm_p->state_info.AllCalls[count].curr_state == CM_INCOMING_STATE ||
            (cm_p->state_info.AllCalls[count].prev_state == CM_INCOMING_STATE &&
             cm_p->state_info.AllCalls[count].curr_state == CM_DISCONNECTING_STATE))
            /* End by Julia */
        {
            SetCallState((CM_CALL_HANDLE) count, CM_IDLE_STATE, FALSE);
        }
    }
}


/*****************************************************************************
 * FUNCTION
 *  PurgeAllCalls

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -