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

📄 callctrl.cpp

📁 windows mobile RIL软件
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                    (void)_snprintfz(szCmd, MAX_PATH, "AT%%CHLD=7%u\r", dwID);
#else
                    (void)_snprintfz(szCmd, MAX_PATH, "AT+CHLD=1%u\r", dwID);
#endif
#if defined (WAVECOM_DRIVER) || defined (PHILIP_DRIVER)
                    // We need special case for data calls. We assume that
                    // the data call is always line 1.
                    // When a data call is released, we need to make sure that
                    // RIL gets out of data mode appropriately.
                    if (1 == dwID)
                    {
                        dwOpt |= CMDOPT_HANGUP;
                    }
#endif
                }
                else
                {
                    // Special case for FTA case GSM 51.010 31.9.1.1.16 which requires us to send the command as USSD
                    // if there isn't an active call associated with this ID
                    (void)_snprintfz(szCmd, MAX_PATH, "AT+CUSD=1,\"1%u\",15\r", dwID);
                    dwOpt |= CMDOPT_SUPPRESSLOGGING;
                    fNeedNotification = FALSE;
                }
            }
              break;

        case RIL_CALLCMD_HOLDACTIVE_ACCEPTHELD:
#ifdef OEM2_DRIVER
            (void)strncpyz(szCmd, "AT+CHLD=6\r", MAX_PATH);
#else
            (void)strncpyz(szCmd, "AT+CHLD=2\r", MAX_PATH);
#endif
            break;

        case RIL_CALLCMD_HOLDALLBUTONE:
            DEBUGCHK((0 <= dwID) && (dwID < ARRAY_LENGTH(g_rgfCallsInProgress)));  // Otherwise, it may be necessary to increase MAX_TRACKED_CALLS
            if ((0 <= dwID) && (dwID < ARRAY_LENGTH(g_rgfCallsInProgress)) && g_rgfCallsInProgress[dwID])
            {
                (void)_snprintfz(szCmd, MAX_PATH, "AT+CHLD=2%u\r", dwID);
            }
            else
            {
                // Special case for FTA case GSM 51.010 31.9.1.1.16 which requires us to send the command as USSD
                // if there isn't an active call associated with this ID
                dwOpt |= CMDOPT_SUPPRESSLOGGING;
                (void)_snprintfz(szCmd, MAX_PATH, "AT+CUSD=1,\"2%u\",15\r", dwID);
            }

            fNeedNotification = FALSE;
            break;

        case RIL_CALLCMD_ADDHELDTOCONF:
            (void)strncpyz(szCmd, "AT+CHLD=3\r", MAX_PATH);
            fNeedNotification = FALSE;
            break;

        case RIL_CALLCMD_ADDHELDTOCONF_DISCONNECT:
            (void)strncpyz(szCmd, "AT+CHLD=4\r", MAX_PATH);
            break;

        case RIL_CALLCMD_INVOKECCBS:
#ifdef EMP_DRIVER
            hr = E_NOTIMPL;
            goto Error;
#else
            (void)strncpyz(szCmd, "AT+CHLD=5\r", MAX_PATH);
            fNeedNotification = FALSE;
#endif
            break;

        default:
            // The proxy code should never let us get here
            DEBUGCHK(FALSE);
    }

    if (fNeedNotification) {
        pnd = new CNotificationData;
        if (pnd && !pnd->InitFromRealBlob(RIL_NOTIFY_CALLSTATECHANGED, NULL, 0)) {
            delete pnd;
            pnd = NULL;
        }
    }

    if (!QueueCmd(pHandle, szCmd, dwOpt, APIID_MANAGECALLS, NULL, pnd, hr)) {
        hr = E_FAIL;
        goto Error;
    }
    pnd = NULL;
RILRetailTrace((TEXT("-RilDrv:RILDrv_ManageCalls\r\n")));
Error:
    return hr;
}


//
//
//
HRESULT RILDrv_TransferCall(DWORD dwParam, const RILADDRESS* lpAddress, const RILSUBADDRESS* lpSubAddress)
{
    FUNCTION_TRACE(RILDrv_TransferCall);

	RILRetailTrace((TEXT("RilDrv:+RILDrv_TransferCall()\r\n")));
#if !defined(WAVECOM_DRIVER) && !defined(EMP_DRIVER) && !defined(PHILIP_DRIVER) 
    // HW-SPECIFIC: WaveCom and EMP hardware don't support AT+CTFR

    BYTE bTypeOfAddress;
    BYTE bType;
    char szAddress[MAXLENGTH_ADDRESS];
    char szSubAddress[MAXLENGTH_SUBADDR];
    char szCmd[CALLCTRL_CMDBUF_LENGTH];
    LPSTR szWalk = szCmd;
    HRESULT hrSubAddress;
    HRESULT hr = S_OK;
    CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
    if (!pHandle || !lpAddress) {
        hr = E_FAIL;
        goto Error;
    }

    // Determine address and type-of-address byte
    hr = RILAddressToString(*lpAddress, szAddress, MAXLENGTH_ADDRESS, bTypeOfAddress);
    if (FAILED(hr)) {
        goto Error;
    }
    (void)_snprintfz(szWalk, CALLCTRL_CMDBUF_LENGTH - (szWalk - szCmd), "AT+CTFR=\"%s\",%u", szAddress, bTypeOfAddress);
    szWalk = strchr(szWalk, '\0');  // NO_TYPO: 27
    DEBUGCHK(NULL != szWalk);

    if (lpSubAddress) {
        hrSubAddress = RILSubAddressToString(*lpSubAddress, szSubAddress, MAXLENGTH_SUBADDR, bType);
        if (SUCCEEDED(hrSubAddress)) {
            (void)_snprintfz(szWalk, CALLCTRL_CMDBUF_LENGTH - (szWalk - szCmd), ",\"%s\",%u", szSubAddress, bType);
            szWalk = strchr(szWalk, '\0');  // NO_TYPO: 27
            DEBUGCHK(NULL != szWalk);
        }
    }
    (void)strncpyz(szWalk, "\r", CALLCTRL_CMDBUF_LENGTH - (szWalk - szCmd));  // NO_TYPO: 30

    if (!QueueCmd(pHandle, szCmd, CMDOPT_NONE, APIID_TRANSFERCALL, NULL, NULL, hr)) {
        hr = E_FAIL;
        goto Error;
    }

Error:
#else  // WAVECOM_DRIVER && EMP_DRIVER

    HRESULT hr = E_NOTIMPL;
#endif // WAVECOM_DRIVER && EMP_DRIVER

    return hr;
}


//
//
//
static HRESULT ParseGetLineStatusRsp(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
    FUNCTION_TRACE(ParseGetLineStatusRsp);
    UINT nValue;
    DWORD* pdwLineStatus = NULL;
    HRESULT hr = S_OK;

    pBlob = NULL;
    cbBlob = 0;

    pdwLineStatus = (DWORD*)AllocBlob(sizeof(DWORD));
    if (!pdwLineStatus) {
        hr = E_OUTOFMEMORY;
        goto Error;
    }
    memset(pdwLineStatus, 0x00, sizeof(DWORD));

    // Parse "<prefix>+CPAS: <line_status><postfix>"
    if (!ParseRspPrefix(szRsp, szRsp)                                  ||
        !MatchStringBeginning(szRsp, "+CPAS: ", szRsp)                 ||
        !ParseUIntAndVerifyAbove(szRsp, TRUE, NUM_LINESTATS, nValue, szRsp) ||
        !ParseRspPostfix(szRsp, szRsp)) {
        hr = E_FAIL;
        goto Error;
    }
    *pdwLineStatus = g_rgdwLineStats[nValue];

	///////////added by viking wang for receiving waiting call///////////////////
	 if(g_fCallWaiting && *pdwLineStatus == RIL_LINESTAT_RINGING)
	 	*pdwLineStatus = RIL_LINESTAT_CALLINPROGRESS;
	////////////end by test /////////////////////////

    SetBacklightIncomingCall(RIL_LINESTAT_RINGING == g_rgdwLineStats[nValue]);

    pBlob = (void*)pdwLineStatus;
    cbBlob = sizeof(DWORD);

Error:
    if (FAILED(hr)) {
        FreeBlob(pdwLineStatus);
    }
    return hr;
}


//
//
//
HRESULT RILDrv_GetLineStatus(DWORD dwParam)
{
    FUNCTION_TRACE(RILDrv_GetLineStatus);
    HRESULT hr = S_OK;
    CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
    if (!pHandle) {
        hr = E_FAIL;
        goto Error;
    }
DEBUGMSG(ZONE_ERROR, (TEXT("+RILDrv : RILDrv_GetLineStatus \r\n")));
#ifdef RIL_RADIO_RESILIENCE
    if (ShouldSpoofCommand())
    {
        // If the radio was reset recently, just return idle line status.  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        
        DWORD* pdwLineStatus = (DWORD*)AllocBlob(sizeof(DWORD));
        if (!pdwLineStatus) {
            hr = E_OUTOFMEMORY;
            goto Error;
        }
        hr = pHandle->GetDevice()->GetNextCmdID();
        *pdwLineStatus = RIL_LINESTAT_READY;
        pHandle->Notify(RIL_RESULT_OK, hr, pdwLineStatus, sizeof(DWORD));
    }
    else
#endif // RIL_RADIO_RESILIENCE
    {    	
        if (!QueueCmd(pHandle, "AT+CPAS\r", CMDOPT_NONE, APIID_GETLINESTATUS, ParseGetLineStatusRsp, NULL, hr)) {
            hr = E_FAIL;
            goto Error;
        }
    }
Error:
    return hr;
}

//
//
//
HRESULT RILDrv_SetCurrentAddressId(DWORD dwParam, DWORD dwAddressId)
{
    FUNCTION_TRACE(RILDrv_SetCurrentAddressId);
	DEBUGMSG(ZONE_ERROR, (TEXT("+RILDrv : RILDrv_SetCurrentAddressId \r\n")));
#if defined(OEM1_DRIVER) || defined(EMP_DRIVER)
    HRESULT hr = S_OK;
    char szCmd[MAX_PATH];
    CNotificationData* pnd = NULL;
    CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
    if (!pHandle) {
        hr = E_FAIL;
        goto Error;
    }

#ifdef EMP_DRIVER
    // EMP only supports 1 for <line>
    if (1 != dwAddressId)
    {
        hr = E_NOTIMPL;
        goto Error;
    }
#endif

    pnd = new CNotificationData;
    if (pnd && !pnd->InitFromDWORDBlob(RIL_NOTIFY_CURRENTLINECHANGED, dwAddressId)) {
        delete pnd;
        pnd = NULL;
    }

#ifdef EMP_DRIVER
    (void)_snprintfz(szCmd, MAX_PATH, "AT*ELIN=%u\r", dwAddressId);
#else
    (void)_snprintfz(szCmd, MAX_PATH, "AT%%ALS=%u\r", dwAddressId);
#endif
    if (!QueueCmd(pHandle, szCmd, CMDOPT_NONE, APIID_SETCURRENTADDRESSID, NULL, pnd, hr)) {
        hr = E_FAIL;
        goto Error;
    }

Error:
#else
    HRESULT hr = E_NOTIMPL;
#endif
    return hr;
}

//
//
//
static HRESULT ParseGetCurrentAddressId(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
    FUNCTION_TRACE(ParseGetCurrentAddressId);
    UINT nValue;
    DWORD* pdwAddressId = NULL;
    HRESULT hr = S_OK;

    pBlob = NULL;
    cbBlob = 0;

    pdwAddressId = (DWORD*)AllocBlob(sizeof(DWORD));
    if (!pdwAddressId) {
        hr = E_OUTOFMEMORY;
        goto Error;
    }
    *pdwAddressId = 0;

    // Parse "<prefix>%ALS: <addressID><postfix>"
    // On EMP platform the response is "<prefix>*ELIN: <addressID><postfix>"
    if (!ParseRspPrefix(szRsp, szRsp)                   ||
#ifdef EMP_DRIVER
        !MatchStringBeginning(szRsp, "*ELIN: ", szRsp)   ||
#else
        !MatchStringBeginning(szRsp, "%ALS: ", szRsp)   ||
#endif
        !ParseUInt(szRsp, TRUE, nValue, szRsp)          ||
        !ParseRspPostfix(szRsp, szRsp)) {
        hr = E_FAIL;
        goto Error;
    }
    *pdwAddressId = nValue;

    pBlob = (void*)pdwAddressId;
    cbBlob = sizeof(DWORD);

Error:
    if (FAILED(hr)) {
        FreeBlob(pdwAddressId);
    }
    return hr;
}

//
//
//
HRESULT RILDrv_GetCurrentAddressId(DWORD dwParam)
{
    FUNCTION_TRACE(RILDrv_GetCurrentAddressId);
	DEBUGMSG(ZONE_ERROR, (TEXT("+RILDrv : RILDrv_GetCurrentAddressId \r\n")));
#if defined(OEM1_DRIVER) || defined(EMP_DRIVER)
    HRESULT hr = S_OK;
    CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
    if (!pHandle) {
        hr = E_FAIL;
        goto Error;
    }

#ifdef EMP_DRIVER
    if (!QueueCmd(pHandle, "AT*ELIN?\r", CMDOPT_NONE, APIID_GETCURRENTADDRESSID, ParseGetCurrentAddressId, NULL, hr)) {
#else
    if (!QueueCmd(pHandle, "AT%ALS?\r", CMDOPT_NONE, APIID_GETCURRENTADDRESSID, ParseGetCurrentAddressId, NULL, hr)) {
#endif
        hr = E_FAIL;
        goto Error;
    }

Error:
#else
    HRESULT hr = E_NOTIMPL;
#endif
    return hr;
}

#ifdef PHILIP_DRIVER

BOOL RILDrv_OpenMyWav(void)
{
	BOOL bOK = FALSE;
	if((g_hWavDev == NULL) || (g_hWavDev == INVALID_HANDLE_VALUE))
	{
	    g_hWavDev = CreateFile(TEXT("WAV1:"),
	        GENERIC_READ | GENERIC_WRITE,
	        0, NULL,
	        OPEN_EXISTING,
	        0, NULL);	

	    if (g_hWavDev == INVALID_HANDLE_VALUE)
	    {
	        NKDbgPrintfW(TEXT("failed to open WavDev driver\r\n"));
	    }
		else
		{
			bOK = TRUE;
		}
	}
	else
	{
		NKDbgPrintfW(TEXT("WavDev driver already open\r\n"));
		bOK = TRUE;
	}
	
	return bOK;
}
#endif

⌨️ 快捷键说明

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