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

📄 callstructuremanagement.c

📁 MTK手机平台的MMI部分的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
 * DESCRIPTION
 *  Wrapper to reinitialize all non Idle calls structure
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void PurgeAllCalls(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 count;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* search all non-idle calls and reset them */
    for (count = 0; count < MAX_CALLS; count++)
    {
        if (cm_p->state_info.AllCalls[count].curr_state != CM_IDLE_STATE)
        {
            SetCallState((CM_CALL_HANDLE) count, CM_IDLE_STATE, FALSE);
        }
    }
}


/*****************************************************************************
 * FUNCTION
 *  SetIncomingCallStateActive
 * DESCRIPTION
 *  Function sets the state of incoming call to active
 * PARAMETERS
 *  void
 *  MYTIME(?)       [IN]        *time time strucutre to initialize
 * RETURNS
 *  void
 *****************************************************************************/
void SetIncomingCallStateActive(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U8 count;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (count = 0; count < MAX_CALLS; count++)
    {
        /* handle race condition:  
           when user answer incoming call and drop call very fast, it's possible that the answer 
           response comes later than the drop request and the call state will become 
           disconnecting, not incoming */
        if (cm_p->state_info.AllCalls[count].curr_state == CM_INCOMING_STATE ||
            (cm_p->state_info.AllCalls[count].curr_state == CM_DISCONNECTING_STATE &&
             cm_p->state_info.AllCalls[count].prev_state == CM_INCOMING_STATE))
        {
            SetCallState((CM_CALL_HANDLE) cm_p->state_info.AllCalls[count].call_handle, CM_ACTIVE_STATE, TRUE);
        }
    }
}


/*****************************************************************************
 * FUNCTION
 *  AddNewCallInfo
 * DESCRIPTION
 *  Each New Incoming or outging call is stored
 *  In the calls array with this function
 * PARAMETERS
 *  Number                  [IN]        Of the call
 *  currentstate            [IN]        Current state of call wether incoming/outgoing
 *  prevstate               [IN]        Previous state of the call
 *  MOflag                  [IN]        Whether call is coming or outgoing
 *  currentCallHandle       [IN]        Call handle of the call
 *  callType                [IN]        
 *  pBname(?)               [IN]        Name of the caller
 * RETURNS
 *  void
 *****************************************************************************/
void AddNewCallInfo(
        PU8 Number,
        CALL_STATE currentstate,
        CALL_STATE prevstate,
        CALL_DIR MOflag,
        CM_CALL_HANDLE currentCallHandle,
        U8 callType)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 index;
    PHB_CM_INTERFACE phb_data;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    index = GetFirstFreeIndex();
    PRINT_INFORMATION(("*** AddNewCallInfo index=%d\n", index));

    memset(&gPhoneNumberStruct, 0, sizeof(gPhoneNumberStruct));
    memset(&cm_p->state_info.AllCalls[index], 0, sizeof(CALL_INFO));
    gPhoneNumberStruct.pictureId = IMG_PHB_DEFAULT;

    SetPreviousCallWAP(FALSE);

    cm_p->state_info.AllCalls[index].call_handle = currentCallHandle;
    cm_p->state_info.AllCalls[index].curr_state = currentstate;
    cm_p->state_info.AllCalls[index].prev_state = prevstate;
    cm_p->state_info.AllCalls[index].status_flag = 0;
    cm_p->state_info.AllCalls[index].orgination_flag = MOflag;
    cm_p->state_info.AllCalls[index].call_type = callType;

#ifdef __MMI_CH_QUICK_END__
    /* init quick end time */
    cm_p->alert_info.QuickEndTime = CHISTGetQuickEndTime();
#endif /* __MMI_CH_QUICK_END__ */ 

    if (Number[0] != '\0')
    {
        /* number existed, search phonebook if necessary */
        pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].number, (PS8) Number);
        pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].num, (PS8) Number);

        if (CM_CALL_MT == MOflag)
        {
            /* MO call needs to wait till dial_ind to search phonebook for name
               because number might be changed by SAT */
            phb_data = mmi_phb_call_get_data_for_call_mgnt(Number, FALSE);
            pfnUnicodeStrcpy((PS8)phb_data.number, (PS8)Number);
            SetCMPhoneBookStruct(&phb_data);
            cm_p->state_info.AllCalls[index].name_dcs = gPhoneNumberStruct.name_dcs;
            pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].pBname, (PS8) gPhoneNumberStruct.name);
            if (!(gPhoneNumberStruct.number[0] == 0 && gPhoneNumberStruct.number[1] == 0))
            {
                pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].number, (PS8) gPhoneNumberStruct.number);
            }

            if (MOflag == CM_CALL_MT)
            {
                CMSetupAlertForMT();
            }
        #ifdef __MMI_INCOMING_CALL_VIDEO__
            /* waiting call and ccbs invoke can't use video for display */
            if (GetTotalCallCount() > 0 || GetCCBSFlag() == TRUE)
            {
                gPhoneNumberStruct.videoId = 0;
            }
        #endif /* __MMI_INCOMING_CALL_VIDEO__ */ 

        #ifdef __MMI_CM_BLACK_LIST__
		//KP Jerry modify on 2007-4-25 start
        #if defined(__MMI_CM_BLACK_LIST__) && !defined(__MMI_CM_WHITE_LIST__)
            if (IsBlackListNum(Number) == TRUE)
        #elif defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
            if (Call_GetNumFromFirewallList_InvailFlag(Number))
        #endif
		//KP Jerry modify on 2007-4-25 end
            {
                cm_p->state_info.AllCalls[index].block_flag = TRUE;
            }
            else
            {
                cm_p->state_info.AllCalls[index].block_flag = FALSE;
            }
        #endif /* __MMI_CM_BLACK_LIST__ */ 
            /* memcpy((PS8)cm_p->state_info.AllCalls[index].pbNumber,(PS8)gPhoneNumberStruct.number,sizeof(cm_p->state_info.AllCalls[index].pbNumber)); */
        }
        else if (MOflag == CM_CALL_MO_STK)
        {
            PS8 tmpName;
            U8 dcs;

            tmpName = (PS8) SATGetCallDisplay(&dcs);
            if (tmpName != NULL)
            {
                cm_p->state_info.AllCalls[index].name_dcs = dcs;
                pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].pBname, tmpName);
            }
            else
            {
                /* if SAT didn't provide name, search phonebook name for SAT call */
                phb_data = mmi_phb_call_get_data_for_call_mgnt(Number, FALSE);
                SetCMPhoneBookStruct(&phb_data);
                cm_p->state_info.AllCalls[index].name_dcs = gPhoneNumberStruct.name_dcs;
                pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].pBname, (PS8) gPhoneNumberStruct.name);
                if (!(gPhoneNumberStruct.number[0] == 0 && gPhoneNumberStruct.number[1] == 0))
                {
                    pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].number, (PS8) gPhoneNumberStruct.number);
                }
            }
        }
        else if (CHISTGetDialFromCallLogFlag() != 0)
        {
            LOG_CALL hilite_item;

            /* dial from call log should directly use name in call log,
               no need to search phonebook */
            CHISTGetCallLogName(&hilite_item);

            cm_p->state_info.AllCalls[index].name_dcs = hilite_item.nameDCS;
            pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].pBname, (PS8) hilite_item.pbName);
            /* memcpy((PS8)cm_p->state_info.AllCalls[index].pbNumber,(PS8)cm_p->state_info.AllCalls[index].number,sizeof(cm_p->state_info.AllCalls[index].pbNumber)); */
        }
    }
    else
    {
        pfnUnicodeStrcpy((PS8) cm_p->state_info.AllCalls[index].pBname, (PS8) GetString(STR_UNKNOWN_CALLER));
        cm_p->state_info.AllCalls[index].name_dcs = MMI_PHB_UCS2;
    }

    cm_p->state_info.TotalCallCount++;
    mmi_frm_kbd_set_tone_state(MMI_KEY_VOL_TONE_DISABLED);
}


/*****************************************************************************
 * FUNCTION
 *  SetCallState
 * DESCRIPTION
 *  Sets the call state of a particular call
 *  
 *  This function updates all those variables which are
 *  required for managing the calls like number of hold calls
 *  number of active calls etc.
 * PARAMETERS
 *  nCallHandle     [IN]        // Handle for call structure for which flag is to be set
 *  state           [IN]        // State to set
 *  bIsHandle       [IN]        // If the n/w has supplied a handle
 * RETURNS
 *  void
 *****************************************************************************/
void SetCallState(CM_CALL_HANDLE nCallHandle, CALL_STATE state, pBOOL bIsHandle)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 index;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (bIsHandle)
    {
        index = GetMMIStructIndexof(nCallHandle);
    }
    else
    {
        index = nCallHandle;
    }
    /* Start by Julia: Drop call refinement */
    if (cm_p->state_info.AllCalls[index].curr_state != CM_DISCONNECTING_STATE)
        /* End by Julia */
    {
        cm_p->state_info.AllCalls[index].prev_state = cm_p->state_info.AllCalls[index].curr_state;
    }
    cm_p->state_info.AllCalls[index].curr_state = state;

    MMI_TRACE((MMI_TRACE_G5_CM, MMI_CM_INFO_SetCallState, state, cm_p->state_info.AllCalls[index].call_handle));

    if (cm_p->state_info.AllCalls[index].curr_state == CM_ACTIVE_STATE)
    {
        /* one call becomes active: incoming, outoing, hold -> active */
        cm_p->state_info.NumofActivecalls++;
        if (cm_p->state_info.AllCalls[index].prev_state == CM_INCOMING_STATE)
        {
            DeleteScreenIfPresent(ITEMSCR_INCOMING_CALL);
        #if defined(__MMI_BG_SOUND_EFFECT__)
            mmi_bgsnd_mt_play_sound();
        #endif 
        }
        if (cm_p->state_info.AllCalls[index].prev_state == CM_HOLD_STATE)
        {
            cm_p->state_info.NumofHeldcalls--;
        }
    #if defined(__MMI_BG_SOUND_EFFECT__)
        if (cm_p->state_info.AllCalls[index].prev_state == CM_OUTGOING_STATE &&
            (cm_p->state_info.AllCalls[index].call_type == CSMCC_VOICE_CALL ||
             cm_p->state_info.AllCalls[index].call_type == CSMCC_AUX_VOICE_CALL))
        {
            mmi_bgsnd_mo_play_sound();
        }
    #endif /* defined(__MMI_BG_SOUND_EFFECT__) */ 
    }

    if (cm_p->state_info.AllCalls[index].curr_state == CM_HOLD_STATE)
    {
        /* one call becomes hold: active -> hold */
        cm_p->state_info.NumofHeldcalls++;
        if (cm_p->state_info.AllCalls[index].prev_state == CM_ACTIVE_STATE)
        {
            cm_p->state_info.NumofActivecalls--;
        }
    }

    if (cm_p->state_info.AllCalls[index].curr_state == CM_IDLE_STATE)
    {
        if (cm_p->state_info.AllCalls[index].prev_state == CM_ACTIVE_STATE)
        {
            /* one active call ends */
            cm_p->state_info.NumofActivecalls--;
            if (GetWapCallPresent())
            {
                /* there can be only one active call when wap call present,
                   => the active call is wap call */
                SetWapCallPresent(FALSE);
                SetPreviousCallWAP(TRUE);
            }
        }
        if (cm_p->state_info.AllCalls[index].prev_state == CM_HOLD_STATE)
        {
            /* one hold call ends */
            cm_p->state_info.NumofHeldcalls--;
        }

        if (cm_p->state_info.AllCalls[index].prev_state == CM_OUTGOING_STATE)
        {
            if (GetTotalCallCount() > 1)
            {
                SyncCallList();
            }
            SetSpeechFlag(FALSE);
            /* one outgoing call ends */
            SetCallEndedBeforeConnFlag(TRUE);
            /* where to log call? */
            DeleteScreenIfPresent(SCR1001_CM_OUTGOINGCALLSCREEN);
        }
        if (cm_p->state_info.AllCalls[index].prev_state == CM_INCOMING_STATE)
        {
            /* MT call drop when WAP call present, can resume audio */
            if (GetWapCallPresent())
            {
        #ifdef __MMI_CM_BLACK_LIST__
            	if(GetBlackIncomingFlag() == FALSE)
            	{
        #endif /* __MMI_CM_BLACK_LIST__ */ 
                mdi_audio_resume_background_play();
        #ifdef __MMI_CM_BLACK_LIST__
                }
        #endif /* __MMI_CM_BLACK_LIST__ */
            }
            if (GetTotalCallCount() > 1)
            {
                SyncCallList();
            }
        #ifdef __MMI_CM_BLACK_LIST__
            /* do not log the number that has been blocked */
		//KP Jerry modify on 2007-4-25 start
        #if defined(__MMI_CM_BLACK_LIST__) && !defined(__MMI_CM_WHITE_LIST__)
            if (GetBlackListMode() == TRUE && cm_p->state_info.AllCalls[index].block_flag == TRUE)
        #elif defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
            if (cm_p->state_info.AllCalls[index].block_flag == TRUE)
		#endif
		//KP Jerry modify on 2007-4-25 end
            {
				if (GetTotalCallCount() > 1)  /*Now, it is able to resume audio.   by Mick*/
				{
					SetBlackIncomingFlag(FALSE);
				}
                ResetCallInfo(index, FALSE);
                cm_p->state_info.TotalCallCount--;
                AdjustHistoryForCM();
                return;
            }
            else
        #endif /* __MMI_CM_BLACK_LIST__ */ 
            {
                /* one incoming call ends */
                GetEndTimeAndNotifyCallMissed();
                DeleteScreenIfPresent(ITEMSCR_INCOMING_CALL);
            }
        }
        /* incoming call exist after call end => it was a waiting call */
        if (GetIncomingCallHandle() != -1 && 
        	cm_p->state_info.AllCalls[index].prev_state != CM_OUTGOING_STATE)
        {
            SetCallWaitFlag(TRUE);
        }

        ResetCallInfo(index, FALSE);
        cm_p->state_info.TotalCallCount--;

    #ifdef __MMI_BT_PROFILE__
    #ifdef __MMI_VOIP__
        /* no gsm and no voip call, or only data call exists */
        if (((GetTotalCallCount() == 0) && (mmi_voip_app_total_call() == 0)) ||
            ((GetTotalCallCount() > 0) && (GetActiveCallType() != CSMCC_VOICE_CALL) && (GetActiveCallType() != CSMCC_AUX_VOICE_CALL)))
        {
            PRINT_INFORMATION(("\n[SetCallState] SCO Ends\n"));
            mmi_profiles_bt_call_end_callback();
        }
    #else
        /* following cases shall callback API for bluetooth outband ring, mmi_profiles_bt_call_end_callback. */
        /* 1. only one incoming call */
        if ((GetTotalCallCount() == 1 && GetCurrentState() == CM_INCOMING_STATE))
        {
            mmi_profiles_bt_call_end_callback();
        }
        /* 2. no any voice call */
        else if ((GetTotalCallCount() == 0) ||
                 (GetTotalCallCount() > 0 &&

⌨️ 快捷键说明

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