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

📄 response_older.cpp

📁 windows mobile RIL软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        rcbNewLength = szResponse2 - m_szData;
        m_fUnrecognized = TRUE;
        return TRUE;
    }

    // Didn't find a partial response (or at least we're not sure it was a partial response)
    return FALSE;
}

//
//
//
BOOL CResponse::ParseOKOrError(const BOOL fOK, UINT& rcbNewLength)
{
    FUNCTION_TRACE(CResponse::ParseOKOrError);
    LPSTR szPointer = m_szData;
    LPCSTR szCode = (fOK ? "0\r" : "4\r");
    HRESULT hrError;
    BOOL fRet;

#ifdef OEM1_DRIVER
    // Necessary change to make battery driver calls work on this hardware
    if( strstr( szPointer, "ADC" ) )
    {
        char* pch;

        pch = strstr( szPointer, "\n4\r" );
        if( pch )
        {
            *(pch+1) = 0x30;
        }
    }
#endif // OEM1_DRIVER

    while (1)
    {
        // First search in the beginning of the response
        fRet = MatchStringBeginning(szPointer, szCode, szPointer);
        if (fRet && '\n' != *szPointer)
        {
            // We found "<code><CR>" not followed by <LF> in the beginning of the response
            break;
        }
        else
        {
            // Now search elsewhere in the response
            fRet = MatchStringAnywhere(szPointer, szCode, szPointer);
            if (!fRet)
            {
                // We didn't find "<code><CR>"
                break;
            }
            else if ('\n' != *szPointer &&
                     ('\n' == *(szPointer - 3) || '\r' == *(szPointer - 3)))
            {
                // We found "<code><CR>" not followed by <LF> and preceded by <LF> or <CR>
                break;
            }
        }
    }

    if (!fRet)
    {
        // If we couldn't find the numeric OK or ERROR, try looking for verbose responses
        fRet = MatchStringAnywhere(m_szData, (fOK ? "\r\nOK\r\n" : "\r\nERROR\r\n"), szPointer);
    }

    if (!fRet && fOK)
    {
        // If that didn't succeed either, see if we got an SMS intermediary prompt
        // we'll treat this as an OK for now, but this will cause the command thread
        // to send down the second part of the command which will be the SMS PDU
#ifdef OEM1_DRIVER
        fRet = MatchStringBeginning(m_szData, "> \r", szPointer);
#else
        fRet = MatchStringBeginning(m_szData, "\r\n> ", szPointer);
#endif
    }

    if (fRet)
    {
        m_fUnsolicited = FALSE;
        m_dwCode = (fOK ? RIL_RESULT_OK : RIL_RESULT_ERROR);
        rcbNewLength = szPointer - m_szData;

        if (!fOK)
        {
            // For error responses, we have additional info -- error code
            hrError = E_FAIL;
            if (!SetBlob((void*)&hrError, sizeof(HRESULT)))
            {
                fRet = FALSE;
                goto Error;
            }
        }
    }

    Error:
    return fRet;
}

//
//  This function gets a remotely determined calltype based on information in a RILREMOTEPARTYINFO
//  structure
//
DWORD GetCalltypeFromRemotePartyInfo(RILREMOTEPARTYINFO*prrpi)
{
    DWORD dwLocalCalltype = RIL_CALLTYPE_UNKNOWN;
    if (NULL != g_rlpfExternalCalltypeFunction)
    {
        DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : GetCalltypeFromRemotePartyInfo : Making Calltype Callback.\r\n")));
        dwLocalCalltype = g_rlpfExternalCalltypeFunction(prrpi);
        DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : GetCalltypeFromRemotePartyInfo : Calltype Received = %d\r\n"), dwLocalCalltype));
        //  validate calltype
        if ((dwLocalCalltype < RIL_CALLTYPE_UNKNOWN) ||
            (dwLocalCalltype > RIL_CALLTYPE_LAST))
        {
            dwLocalCalltype = RIL_CALLTYPE_UNKNOWN;
        }
        DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : GetCalltypeFromRemotePartyInfo : Calltype Returned = %d\r\n"), dwLocalCalltype));
    }
    else
    {
        DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : GetCalltypeFromRemotePartyInfo : g_rlpfExternalCalltypeFunction is NULL.\r\n")));
    }
    return dwLocalCalltype;
}

//
//  This function sets a remotely determined calltype based on information in a RILCALLINFO
//  structure.  It first checks for previously validated data from previous calls to this function.  It then
//  looks for valid data from a RILDrv_Dial call.  If these two fail, it calls GetCalltypeFromRemotePartyInfo.
//  This data is then used to update the necessary calltype and call state structures.
//
VOID SetCalltypeFromCallInfo(RILCALLINFO *prci)
{
    DWORD dwLocalCalltype = RIL_CALLTYPE_UNKNOWN;
    BOOL fFoundDialedCalltype = FALSE;

    DEBUGCHK((0 <= prci->dwID) && (prci->dwID < ARRAY_LENGTH(g_rgfCalltypeChecked)));  // Otherwise, it may be necessary to increase MAX_TRACKED_CALLS

    if (g_rgfCalltypeChecked[prci->dwID] != TRUE)
    {
        EnterCriticalSection(&g_csDialedCallData);
        // need to see if the calltype has been set up through a dial command
        if (TRUE == g_rcdDialedCallData.fValid)
        {
            //  check the address
            if (!wcsncmp(g_rcdDialedCallData.wszAddress,prci->raAddress.wszAddress,MAXLENGTH_ADDRESS))
            {
                // The address matches, so this is the call associated with the dial in progress.
                dwLocalCalltype = g_rcdDialedCallData.dwCalltype;
                //  invalidate the cache data
                g_rcdDialedCallData.fValid= FALSE;
                fFoundDialedCalltype = TRUE;
                DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : SetCalltypeFromCallInfo : Using g_rcdDialedCallData.dwCalltype = %d\r\n"), dwLocalCalltype));
            }
        }
        LeaveCriticalSection(&g_csDialedCallData);
        if (FALSE == fFoundDialedCalltype)
        {
            //  Haven't got a calltype yet, need to see if a calltype has been set up through a call waiting notification
            if (TRUE == g_rcdWaitingCallData.fValid)
            {
                //  check the address
                if (!wcsncmp(g_rcdWaitingCallData.wszAddress,prci->raAddress.wszAddress,MAXLENGTH_ADDRESS))
                {
                    // The address matches, so this is the call associated with the call waiting call
                    dwLocalCalltype = g_rcdWaitingCallData.dwCalltype;
                    //  invalidate the cache data
                    g_rcdWaitingCallData.fValid = FALSE;
                }
            }
            else
            {
                RILREMOTEPARTYINFO rrpi; memset(&rrpi, 0, sizeof(RILREMOTEPARTYINFO));
                rrpi.cbSize = sizeof(RILREMOTEPARTYINFO);
                rrpi.raAddress = prci->raAddress;
                rrpi.dwValidity = RIL_REMOTEPARTYINFO_VALID;
                // rrpi validity set correctly by memset above
                rrpi.dwParams = RIL_PARAM_RPI_ADDRESS | RIL_PARAM_RPI_VALIDITY;
                //  Haven't got a calltype yet, so query the remote function
                dwLocalCalltype = GetCalltypeFromRemotePartyInfo(&rrpi);
            }
        }

        if (RIL_CALLTYPE_UNKNOWN != dwLocalCalltype)
        {
            //  Only override the original calltype if the determined calltype is not unknown
            prci->dwType = dwLocalCalltype;
        }
        g_rgctCalltype[prci->dwID] = prci->dwType;
        g_rgfCalltypeChecked[prci->dwID] = TRUE;
        DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : SetCalltypeFromCallInfo : External Calltype = %d, Final Calltype = %d, Call ID = %d.\r\n"), dwLocalCalltype, g_rgctCalltype[prci->dwID], prci->dwID));

        EnterCriticalSection(&g_csRingingCallData);
        if (TRUE == g_rcdRingingCallData.fDelayRingNotification)
        {
            // call is ringing but calltype was undetermined - now it is
            g_rcdRingingCallData.dwCalltype = g_rgctCalltype[prci->dwID];
            g_rcdRingingCallData.fCalltypeValid = TRUE;
            g_rcdRingingCallData.fDelayRingNotification = FALSE;
            g_rcdRingingCallData.fForceRingNotification = TRUE;
            g_rcdRingingCallData.fCallIdValid = TRUE;
            g_rcdRingingCallData.dwCallId = prci->dwID;
            DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : SetCalltypeFromCallInfo : Setting g_rcdRingingCallData.fForceRingNotification.\r\n")));
        }
        DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : SetCalltypeFromCallInfo : Ringing Call TypeValid = %d, type = %d, IdValid = %d, Id = %d, Delay = %d, Force = %d\r\n"),
            g_rcdRingingCallData.fCalltypeValid, g_rcdRingingCallData.dwCalltype,g_rcdRingingCallData.fCallIdValid,g_rcdRingingCallData.dwCallId,g_rcdRingingCallData.fDelayRingNotification,g_rcdRingingCallData.fForceRingNotification));
        LeaveCriticalSection(&g_csRingingCallData);
    }
    else
    {
        DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : SetCalltypeFromCallInfo : Previously calculated Calltype = %d, Call ID = %d.\r\n"), g_rgctCalltype[prci->dwID], prci->dwID));
        prci->dwType = g_rgctCalltype[prci->dwID];
    }
}

//
//
//
BOOL CResponse::ParseNotification(UINT& rcbNewLength, BOOL fDataOnNotificationPort)
{
    FUNCTION_TRACE(CResponse::ParseNotification);
    UINT nCode;
    LPSTR szPointer = m_szData + m_nOffset;
    BOOL fExpectCRLF = TRUE;
    BOOL fSuppressLogging = FALSE;
#ifdef RIL_WATSON_REPORT
    BOOL fErrorNotification = false;
    LPSTR szData = m_szData;
#endif // RIL_WATSON_REPORT
    BOOL fRet = FALSE;

    // Parse "<prefix>"
    if (!ParseRspPrefix(szPointer, szPointer))
    {
        goto Error;
    }
    if (MatchStringBeginning(szPointer, "+++", szPointer) &&
        ParseUInt(szPointer, FALSE, nCode, szPointer)     &&
        3 == nCode)
    {
        // Special case for "+++" followed by 3(NO CARRIER)
        m_fUnsolicited = FALSE;
        m_dwCode = RIL_RESULT_NOCARRIER;
        fExpectCRLF = FALSE;
    }
#ifdef PHILIP_DRIVER

//Alan Luo : fix GPRS issue

    else if (MatchStringBeginning(szPointer, "CONNECT", szPointer))
    {
        if (!ParseV25Response(16))
        {
            goto Error;
        }
        fExpectCRLF = FALSE;
    }
//end

#endif
#ifdef OEM1_DRIVER

    else if (MatchStringBeginning(szPointer, "CONNECT 9600", szPointer))
    {
        if (!ParseV25Response(15))
        {
            goto Error;
        }
        fExpectCRLF = FALSE;
    }
    else if (MatchStringAnywhere(szPointer, "AT-Command Interpreter ready", szPointer))
    {
        m_fUnsolicited = FALSE;
#ifdef OEM1_CSQ_NOTIFICATION
        g_fSignalQualityReceived = FALSE;
#endif    // OEM1_CSQ_NOTIFICATION

#ifdef RIL_RADIO_RESILIENCE
        // If this isn't the initial message sent on boot, then it is a radio reset
        if (g_fInitedFirstTime)
        {
            SignalCriticalError(RILLOG_EVENT_GENERALREINIT, __LINE__, __FILE__);
            MakeError(RIL_E_RADIOREBOOTED);
        }
#endif // RIL_RADIO_RESILIENCE
    }
#endif // OEM1_DRIVER
#ifdef OEM2_DRIVER
    else if (MatchStringAnywhere(szPointer, "+CCRASHED 0", szPointer))
    {
        m_fUnsolicited = FALSE;
        g_fSignalQualityReceived = FALSE;

#ifdef RIL_RADIO_RESILIENCE
        // This indicates a radio reboot
        SignalCriticalError(RILLOG_EVENT_GENERALREINIT, __LINE__, __FILE__);
        MakeError(RIL_E_RADIOREBOOTED);
#endif // RIL_RADIO_RESILIENCE
    }
    else if (MatchStringAnywhere(szPointer, "+CCRASHED 2", szPointer))
    {
        m_fUnsolicited = FALSE;
        g_fSignalQualityReceived = FALSE;

#ifdef RIL_RADIO_RESILIENCE
        // This indicates a radio reboot failure
        SignalCriticalError(RILLOG_EVENT_GENERALREINIT, __LINE__, __FILE__);
        MakeError(RIL_E_RADIOREBOOTED);
#endif // RIL_RADIO_RESILIENCE
        NKDbgPrintfW(TEXT("RILDrv : E : Radio has crashed - Cold Boot required.\r\n"));
        DebugBreak();
    }
#endif // OEM2_DRIVER
    else if (ParseUInt(szPointer, FALSE, nCode, szPointer))
    {
        // Classic V.25ter numeric response (except for 0(OK) and 4(ERROR))
        if (!ParseV25Response(nCode))
        {
            goto Error;
        }
        fExpectCRLF = FALSE;
    }
#ifdef OEM1_DRIVER
    else if (MatchStringBeginning(szPointer, "%CPI: ", szPointer))
    {
        if (!ParseCallProgressInformation(szPointer))
        {
            goto Error;
        }
    }
#endif // OEM1_DRIVER
#ifdef EMP_DRIVER
    else if (MatchStringBeginning(szPointer, "*ECAV: ", szPointer))
    {
        if (!ParseCallProgressInformation(szPointer))
        {
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "*EREG: ", szPointer))
    {
        // EMP specific roaming notification with access type indication
        if (!ParseExtRegistrationStatus(szPointer))
        {
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "+CIEV:", szPointer))
    {
        // Parse signal strength notification
        if (!ParseIndicatorEvent(szPointer))
        {
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "*STKI:", szPointer))
    {
        // Unhandled SIM Toolkit command notification
        if (!ParseSIMToolkitCmdOrRsp(szPointer, RIL_NOTIFY_SIMTOOLKITCMD))
        {
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "*STKN:", szPointer))
    {
        // Unhandled SIM Toolkit command or response notification
        if (!ParseSIMToolkitCmdOrRsp(szPointer, RIL_NOTIFY_SIMTOOLKITEVENT))
        {
            goto Error;
        }
    }
#endif // EMP_DRIVER
    else if (MatchStringBeginning(szPointer, "+CREG: ", szPointer))
    {
        if (!ParseRegistrationStatus(szPointer,RIL_NOTIFY_REGSTATUSCHANGED))
        {
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "+CGREG: ", szPointer))
    {
        if (!ParseRegistrationStatus(szPointer,RIL_NOTIFY_GPRSREGSTATUSCHANGED))
        {
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "+CR: ", szPointer))
    {
        // Connection service notification
        if (!ParseServiceInfo(szPointer))
        {
            goto Error;
        }
    }
    else if (MatchStringBeginning(szPointer, "+CLIP: ", szPointer))
    {
        // Caller ID notification
        if (!ParseRemotePartyInfo(szPointer, TRUE))
        {
            goto Error;
        }
    }
    //Alan Luo: Move here,because get CRING first
    else if (MatchStringBeginning(szPointer, "+CRING: ", szPointer))

⌨️ 快捷键说明

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