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

📄 callctrl.cpp

📁 windows mobile RIL软件
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    // Parse "<prefix>"
    if (!ParseRspPrefix(szRsp, szRsp)) {
        hr = E_FAIL;
        goto Error;
    }

    // Clear callstate structure for a clean slate
    memset(g_rgfCallStates, 0x00, sizeof(g_rgfCallStates));

    // Parse "+CLCC: "
    while (MatchStringBeginning(szRsp, "+CLCC: ", szRsp)) {
        if (nUsed == nAllocated) {
            if (!AllocateOrReallocateStorage((BYTE**)&rgrci, sizeof(RILCALLINFO), nUsed, &nAllocated, CALLCTRL_ALLOC_NUMBER)) {
                hr = E_OUTOFMEMORY;
                goto Error;
            }
        }

		nNoCalls ++;

        memset(&rgrci[nUsed], 0x00, sizeof(RILCALLINFO));
        rgrci[nUsed].cbSize = sizeof(RILCALLINFO);
        rgrci[nUsed].raAddress.cbSize = sizeof(RILADDRESS);

        // Parse "<id>"
        if (!ParseUInt(szRsp, TRUE, nValue, szRsp)) {
            goto Continue;
        }
        rgrci[nUsed].dwID = nValue;
        rgrci[nUsed].dwParams |= RIL_PARAM_CI_ID;

        // Track the call
        DEBUGCHK((0 <= nValue) && (nValue < ARRAY_LENGTH(rgfNewCallsInProgress))); // Otherwise, it may be necessary to increase RIL_MAX_TRACKED_CALL_ID
        if ((0 <= nValue) && (nValue < ARRAY_LENGTH(rgfNewCallsInProgress))) {
            rgfNewCallsInProgress[nValue] = TRUE;
        }

        // Parse ",<direction>"
        if (!MatchStringBeginning(szRsp, ",", szRsp) ||
            !ParseUIntAndVerifyAbove(szRsp, TRUE, 2, nValue, szRsp)) {
            goto Continue;
        }
        rgrci[nUsed].dwDirection = (nValue ? RIL_CALLDIR_INCOMING : RIL_CALLDIR_OUTGOING);
        rgrci[nUsed].dwParams |= RIL_PARAM_CI_DIRECTION;

        // Parse ",<status>"
        if (!MatchStringBeginning(szRsp, ",", szRsp) ||
            !ParseUIntAndVerifyAbove(szRsp, TRUE, NUM_CALLSTATS, nValue, szRsp)) {
            goto Continue;
        }
        rgrci[nUsed].dwStatus = g_rgdwCallStats[nValue];
        rgrci[nUsed].dwParams |= RIL_PARAM_CI_STATUS;

#ifdef PHILIP_DRIVER
// Alan Luo For Test	disabled by viking wang
	//if there is no other call exist. it's the first incoming call
	//if(0 == nUsed)
	{
		if(RIL_CALLSTAT_WAITING == rgrci[nUsed].dwStatus)
			rgrci[nUsed].dwStatus = RIL_CALLSTAT_INCOMING;	
	}
// End Test
#endif
        switch (g_rgdwCallStats[nValue])
        {
        case RIL_CALLSTAT_INCOMING:
        case RIL_CALLSTAT_WAITING:
            bIncomingCall = TRUE;
        }

        // Parse ",<type>"
        if (!MatchStringBeginning(szRsp, ",", szRsp) ||
            !ParseUIntAndVerifyAbove(szRsp, TRUE, NUM_CALLTYPES, nValue, szRsp)) {
            goto Continue;
        }
        rgrci[nUsed].dwType = g_rgdwCallTypes[nValue];
        rgrci[nUsed].dwParams |= RIL_PARAM_CI_TYPE;

        // Parse ",<multiparty>"
        if (!MatchStringBeginning(szRsp, ",", szRsp) ||
            !ParseUIntAndVerifyAbove(szRsp, TRUE, 2, nValue, szRsp)) {
            goto Continue;
        }
        rgrci[nUsed].dwMultiparty = (nValue ? RIL_CALL_MULTIPARTY : RIL_CALL_SINGLEPARTY);
		//viking wang:I  think there is some problem here.
		//rgrci[nUsed].dwParams |= RIL_PARAM_CI_TYPE;
	
#ifdef PHILIP_DRIVER
//     Alan Luo : Test according to Ryan code 
	 rgrci[nUsed].dwParams |= RIL_PARAM_CI_MULTIPARTY;
#else
        rgrci[nUsed].dwParams |= RIL_PARAM_CI_TYPE;
#endif

        // Parse ","
        if (MatchStringBeginning(szRsp, ",", szRsp)) {
            // Parse "<address>,<type>"
            if (ParseString(szRsp, szAddress, MAXLENGTH_ADDRESS, szRsp)) {
                if (!MatchStringBeginning(szRsp, ",", szRsp)                 ||
                    !ParseUIntAndVerifyAbove(szRsp, FALSE, 0x100, nValue, szRsp)  ||
                    !StringToRILAddress(szAddress, (BYTE)nValue, rgrci[nUsed].raAddress)) {
                    goto Continue;
                }
                rgrci[nUsed].dwParams |= RIL_PARAM_CI_ADDRESS;
            }
            else {
                // If we couldn't parse an address, then it might be empty,
                // meaning the ID is blocked. Since the address parameter
                // is present, make sure the type also exists before continuing.
                if (!MatchStringBeginning(szRsp, ",", szRsp)                 ||
                    !ParseUIntAndVerifyAbove(szRsp, FALSE, 0x100, nValue, szRsp)) {
                    goto Continue;
                }
            }

            // Parse ","
            if (MatchStringBeginning(szRsp, ",", szRsp)) {
                // Parse "<description>"
                if (!ParseQuotedEncodedString(ENCODING_TECHARSET, szRsp, rgrci[nUsed].wszDescription, rgrci[nUsed].wszDescription + MAXLENGTH_DESCRIPTION)) {
                    goto Continue;
                }
                rgrci[nUsed].dwParams |= RIL_PARAM_CI_DESCRIPTION;
            }
#ifdef EMP_DRIVER
            // Parse ",<priority>" (0-4)
            if (!MatchStringBeginning(szRsp, ",", szRsp) ||
                !ParseUIntAndVerifyAbove(szRsp, TRUE, 5, nValue, szRsp)) {
                goto Continue;
            }
#endif
        }

        // copy the current call info into our global array
        //g_rgfCallStates[rgrci[nUsed].dwID] = rgrci[nUsed];
		//modified by viking wang
		memcpy(&g_rgfCallStates[rgrci[nUsed].dwID], &rgrci[nUsed], sizeof(RILCALLINFO)); 
        // do external calltype progessing for this call
        if (g_rfExternalCalltypeDetermination)
        {
            // get the calltype and associate it with the call id
            SetCalltypeFromCallInfo(&rgrci[nUsed]);
        }

        // Increment the array index
        nUsed++;

Continue:
        // Find "<postfix>"
        bSuccess = ParseRspPostfix(szRsp, szRsp);

        // Note: WaveCom euro radios forget to include the <cr><lf> between +CLCC lines,
        // so for wavecom don't worry if we don't find these characters
#if !defined(WAVECOM_DRIVER) && !defined(PHILIP_DRIVER)
        if (!bSuccess)
        {
            hr = E_FAIL;
            goto Error;
        }
#endif


    }

//added by viking wang
#if 0
    {
        BOOL bDoBroadcast = FALSE;

        EnterCriticalSection(&g_CallInfoSection);

        //if ((UINT)g_iNrCallInfo != nUsed) 
		{
            g_iNrCallInfo = nUsed;
            if (g_iNrCallInfo > 0) {
                bDoBroadcast = TRUE;
                //if (AllocateOrReallocateStorage((BYTE**)&rgrci, sizeof(RILCALLINFO), 0, &nAllocated, max(CALLCTRL_ALLOC_NUMBER,g_iNrCallInfo))) {
                //    if (g_iNrCallInfo > (INT)nAllocated) {
                //        hr = E_OUTOFMEMORY;
                //        LeaveCriticalSection(&g_CallInfoSection);
                //        goto Error;
                //    }
                    memcpy(g_CallInfo, rgrci, g_iNrCallInfo * sizeof(RILCALLINFO));
                //}
            }
        }
        LeaveCriticalSection(&g_CallInfoSection);

        //if (bDoBroadcast)
           // BroadcastRealBlobNotification(RIL_NOTIFY_CALLSTATECHANGED, NULL, 0);
    }
#endif
//end adding by viking wang

	//DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : ParseGetCallList : sizeof(rgfNewCallsInProgress) = %d \r\n"), sizeof(rgfNewCallsInProgress)));

    // Now that we've succeeded parsing the notification, record the new call states
    //C_ASSERT(sizeof(g_rgfCallsInProgress) == sizeof(rgfNewCallsInProgress));
    CopyMemory(g_rgfCallsInProgress, rgfNewCallsInProgress, sizeof(g_rgfCallsInProgress));

    // clean up externally determined calltypes, if necessary
    if (g_rfExternalCalltypeDetermination)
    {
        UINT uiRilCall = 0;
        while(uiRilCall < RIL_MAX_TRACKED_CALL_ID)
        {
            if (FALSE == rgfNewCallsInProgress[uiRilCall])
            {
                // no current call with this id, make sure that the calltype tracking data is erased
                g_rgfCalltypeChecked[uiRilCall] = FALSE;
                g_rgctCalltype[uiRilCall] = RIL_CALLTYPE_UNKNOWN;
                //  Was this a ringing call?
                EnterCriticalSection(&g_csRingingCallData);
                if ((TRUE == g_rcdRingingCallData.fCallIdValid) && (uiRilCall == g_rcdRingingCallData.dwCallId))
                {
                    g_rcdRingingCallData.fCallIdValid = FALSE;
                    g_rcdRingingCallData.dwCallId = RIL_MAX_TRACKED_CALL_ID;
                    g_rcdRingingCallData.dwCalltype = RIL_CALLTYPE_UNKNOWN;
                    g_rcdRingingCallData.fCalltypeValid = FALSE;
                    DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : ParseGetCallList : Ringing Call TypeValid = %d, type = %d, IdValid = %d, Id = %d, \r\n"), 
                        g_rcdRingingCallData.fCalltypeValid, g_rcdRingingCallData.dwCalltype,g_rcdRingingCallData.fCallIdValid,g_rcdRingingCallData.dwCallId));
                }
                LeaveCriticalSection(&g_csRingingCallData);
            }
            uiRilCall++;
        }
    }

    SetBacklightIncomingCall(bIncomingCall);

	if(0 == nNoCalls)
	{
		//RHADeactivateVoicePath(pDevice);
	}
	
    pBlob = (void*)rgrci;
    cbBlob = nUsed * sizeof(RILCALLINFO);

Error:

//#if defined(PHILIP_DRIVER)
#if 0
    if( (nUsed == 0) && (fInCall == TRUE) )
    {
        fInCall = FALSE;

        //signal audio driver that no call are active

        if(RILDrv_OpenMyWav())
	
        {
            if (!DeviceIoControl (g_hWavDev, IOCTL_GSM_CALL_INACTIVE, 0, 0, NULL, 0, &dwRet, NULL))
                NKDbgPrintfW(TEXT("RilDrv: signal audio driver that no call are active FAILURE\r\n"));
            else
            {
                //NKDbgPrintfW(TEXT("RilDrv: signal audio driver that no call are active SUCCESS\r\n"));
            }
        }
    }
    /* Calls to IOCTL_GSM_CALL_ACTIVE are handled at the point of dialing and answering. The call here
       comes too late to meet the setup sequence.
        1. Both EAC modem port and GSM voiceband IF are off without voice calls. 
        2. GSM detects a call signal and notifies RIL driver the call progress information. 
        3. RIL driver parses GSM call progress notification and finds it is a %CPI notification. 
        4. RIL driver notifies audio driver that a call is coming. 
        5. Audio driver turns on the EAC modem port. 
        6. Device ring tone rings. 
        7. User accepts the call by pressing the accept button in the device. 
        8. RIL driver sends a ATA command to GSM. 
        9. GSM turns on voiceband IF.
    */ 
    else if( (nUsed == 1) && (fInCall == FALSE) )
    {
        fInCall = TRUE;
    }
#else
    if( nUsed == 0 )
    {
        // Indicate call is inactive to audio driver.
        IndicateCallActivityToAudioSubsystem(FALSE, FALSE);
    }
#endif  // 

    if (FAILED(hr)) {
        FreeBlob(rgrci);
    }
    return hr;
}


//
//
//
HRESULT RILDrv_GetCallList(DWORD dwParam)
{
    FUNCTION_TRACE(RILDrv_GetCallList);
    HRESULT hr = S_OK;
    CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
    if (!pHandle) {
        hr = E_FAIL;
        goto Error;
    }

#ifdef RIL_RADIO_RESILIENCE
    if (ShouldSpoofCommand())
    {
        // If the radio was reset recently, just return no calls.  Otherwise this may get
        // queued up after all the init commands, and take a long time to execute, only
        // to find out that there are no calls.  This is bad, since we want to handle
        // the RIL_NOTIFY_DISCONNECT that is sent up during reset so the UI can be
        // updated quickly
        hr = pHandle->GetDevice()->GetNextCmdID();
        pHandle->Notify(RIL_RESULT_OK, hr, NULL, 0);
    }
    else
#endif // RIL_RADIO_RESILIENCE        
    {
        if (!QueueCmd(pHandle, "AT+CLCC\r", CMDOPT_NONE, APIID_GETCALLLIST, ParseGetCallList, NULL, hr)) {
            hr = E_FAIL;
            goto Error;
        }
    }
Error:
    return hr;
}


//
//
//
HRESULT RILDrv_ManageCalls(DWORD dwParam, DWORD dwCommand, DWORD dwID)
{
    FUNCTION_TRACE(RILDrv_ManageCalls);
    CNotificationData* pnd = NULL;
    BOOL fNeedNotification = TRUE;
    char szCmd[MAX_PATH];
    DWORD dwOpt = CMDOPT_NONE;
    HRESULT hr = S_OK;
    CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
    if (!pHandle) {
        hr = E_FAIL;
        goto Error;
    }
	
  	RILRetailTrace((TEXT("RilDrv:+RILDrv_ManageCalls()\r\n")));
    switch (dwCommand)
    {
        case RIL_CALLCMD_RELEASEHELD:
			RILRetailTrace((TEXT("RilDrv:RILDrv_ManageCalls::Release held calls\r\n")));
#ifdef OEM2_DRIVER
            (void)strncpyz(szCmd, "AT+CHLD=7\r", MAX_PATH);
#else
            (void)strncpyz(szCmd, "AT+CHLD=0\r", MAX_PATH);
#endif
            dwOpt |= CMDOPT_HANGUP;  // Necessary when attempting to end a single outgoing call
            break;

        case RIL_CALLCMD_RELEASEACTIVE_ACCEPTHELD:
			RILRetailTrace((TEXT("RilDrv:RILDrv_ManageCalls::Release Active and accept others\r\n")));
            (void)strncpyz(szCmd, "AT+CHLD=1\r", MAX_PATH);
            break;

        case RIL_CALLCMD_RELEASECALL:
            if (dwID==0)
            {
            	RILRetailTrace((TEXT("RilDrv:RILDrv_ManageCalls::Release specific call dwId=0\r\n")));
        
                // Id of 0 is a magic value which says to release a call being dialed while
                // another call is on hold.
                // This activates code in HangupThreadProc to force it to send AT\r to the modem
                // to try to abort a call being dialed.
#if defined (WAVECOM_DRIVER) || defined (PHILIP_DRIVER)
                // H1 on wavecom will hang up calls in the alerting state.
                (void)strncpyz(szCmd, "ATH1\r", MAX_PATH);
                dwOpt = CMDOPT_HANGUP;
#else
                // We don't need to send a command to the modem because 
                // HangupThreadProc's AT\r will cancel the dial.
                (void)strncpyz(szCmd, "AT\r", MAX_PATH);
                dwOpt = CMDOPT_HANGUP | CMDOPT_NOOP;
#endif
            }
            else if (9 == dwID)
            {
                // This is a special-case to enable us to pass FTA case GSM 51.010 31.4.4.2 which requires
                // a way to end all calls in one operation (i.e., "19<SEND>")
                (void)strncpyz(szCmd, "ATH\r", MAX_PATH);
            }
            else if (8 == dwID)
            {
                // This is a special-case to enable us to pass FTA case GSM 51.010 31.4.4.1.2.4 which requires
                // a way to end a held conference call in one operation (i.e., "18<SEND>")
                (void)strncpyz(szCmd, "at+chld=11\rAT\rat+chld=12\r", MAX_PATH);
            }
            else
            {
                DEBUGCHK((0 <= dwID) && (dwID < ARRAY_LENGTH(g_rgfCallsInProgress)));  // Otherwise, if may be necessary to increase MAX_TRACKED_CALLS
                if ((0 <= dwID) && (dwID < ARRAY_LENGTH(g_rgfCallsInProgress)) && g_rgfCallsInProgress[dwID])
                {
                	RILRetailTrace((TEXT("RilDrv:RILDrv_ManageCalls::Release specific call Id=%d\r\n"),dwID));
        
#ifdef OEM1_DRIVER

⌨️ 快捷键说明

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