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

📄 response.cpp

📁 手机RILGSM实现的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1999  Microsoft Corporation

Module Name:

response.cpp

Abstract:


Notes:


--*/

//--------------------------------------------------------------------------------------------------
//    Revision History
//    Date                    Author                    Activity ID                        Activity Headline
//    ------------      ------------        ----------------           -----------------------
//   2006-11-28      weizhenjin              CEDB200032402              add '#' at the end of TP-OA to indicate GSM1 msg                                                   
//   2007-03-30      XieFei                    CEDB200049615         Merge crowsbow code to cynthia850
//   2007-05-16      dongqiang		   CEDB200054889   	     modify for USSD notify 
//  2007-05-22       fengguisen             CEDB200055583        add new code for cc of Cynthia850
//  2007-07-18       xiangming              WM600010395          add the G/E icon function
//   2007-08-17      sunrenhong            WM600013373          modified * for status
//   2007-09-13      qinxuetao               WM600011136          In conference call, one end can't receive voice.
//   2007-10-10      sunrenhong            WM600019169           delete check audio list for new audio interface,and arrang id for reject call
//  2007-10-19      sunrenhong             WM600019595           modified CCSU parase fuction
//  2007-10-22      Cuiguoqing              WM600020011       write some codes for modify ring tone on cynthia850_ver2.04.
//  2007-11-07      qinxuetao                WM600021934       fix CMUT issues
//  2007-11-09      sunrenhong             WM600022168           reset the second state when call relase
//  2007-11-13      Cuiguoqing               WM600022632          reset the the last bit of phonebook register table for alternating master card. 
//  2007-11-13      sunrenhong      WM600022706    add the interface for reject call history
//  2007-11-16      sunrenhong      WM600023253      add CPI setup declaration for last call dialing
//  2007-11-26      xiangming       WM600023874      modify the unregisterd-gprs SIM card connecting to the GPRS
//  2007-12-05      zhangjianchao   WM600024307      modify CGACT 0\r+CME ERROR\r+CGEV:ME DEACT string parse process
//  2007-12-06        Cuiguoqing       WM600025007          Modify for offering a IMEI and IMSI api Interface on ver2.13.
//  2007-12-06      zhangjianchao    WM600025309     we can only ignore CME error when there exist "ME DEACT" in the at string
//  2007-12-14      zhongchuren         WM600025529    fixed the issue about Power off when Attach GPRS.
//  2007-12-25       Cuiguoqing       WM600025698      Modify for getting IMEI and IMSI but doesn't affect TI protocol stack.
//  2007-12-28       sunrenhong       WM600027478     add cmcc fetion message
//  2008-01-15       Cuiguoqing       WM600029093      Modify for getting  IMSI but doesn't affect TI protocol stack again in ver3.0.
//  2008-01-15       sunruiyang      WM600029279      add DM push message parser
//  2008-01-29       qinxuetao       WM600030160      Fix SMS and SIMPB ready notification problem 
//  2008-02-22      zhongchuren    WM600031915          display Spn name in idle
//  2008-02-26      zhongchuren    WM600032146          fixed the diaplay issue.
//  2008-03-27      Chenjianjun     WM600034160          Add firewall function for Cynthia850
//  2008-04-01      Chenjianjun     WM600034869          Modify firewall's codes,in order to avoid the problem of call status screen.
//  2008-04-03      Chenjianjun     WM600034888          We set rejecting call from card2,it play card2's ring if there is a call from card1.
//  2008-04-03      Chenjianjun     WM600034986          The SMS firewall function is enabled,but it reject MMS.
//  2008-04-07      Chenjianjun     WM600035145          The number of historical record is wrong in Firewall.
//  2008-04-09      Chenjianjun     WM600035336          When selecting "reject SIM card1" or "reject SIM card2",we could give a outcoming call.
//--------------------------------------------------------------------------------------------------


#include "precomp.h"
#ifdef RIL_LAST_ERROR
#include "ccoreutl.h"
#endif
#include "rilproxyExt_ioctl.h"

#define ARCMSG_S_OK                                         0x00000000L
#define ARCMSG_E_INVALID_PARAMETER          0x00000001L
#define ARCMSG_E_INSUFFICIENT_BUFFER       0x00000002L
#define ARCMSG_E_UNSUPPORT_FORMAT          0x00000003L
#define ARCMSG_E_UNKNOWN                            0x00000004L

#define STKINIT_TI    TEXT("SIMToolkitITI/SetSTKReady/INITSTK")
CRITICAL_SECTION g_csDeactCringLock;
bool g_fCringRcvd = FALSE;
DWORD g_LastCringRcvd = 0;

extern BOOL g_rfExternalCalltypeDetermination;
extern RILCALLTYPECALLBACK g_rlpfExternalCalltypeFunction;

extern RILCALLINFO g_rgfCallStates[RIL_MAX_TRACKED_CALL_ID];
extern BOOL g_rgfCallsInProgress[RIL_MAX_TRACKED_CALL_ID];

extern BOOL g_rgfCalltypeChecked[RIL_MAX_TRACKED_CALL_ID];
extern DWORD g_rgctCalltype[RIL_MAX_TRACKED_CALL_ID];
extern BOOL  g_rgfTCHAssigned[RIL_MAX_TRACKED_CALL_ID]; 
extern CALLCTRL_CID g_stDriver1CIDMap[CALLCTRL_MAX_CID] ;//call id array for local driver

extern DIALEDCALLDATA g_rcdDialedCallData;
extern CRITICAL_SECTION g_csDialedCallData;

BOOL g_bChangedPrimaryCard = FALSE;// we need reset card2 to be master card when cancel card1 pin and input card2 pin correctly  powerup.
extern DWORD g_dwCREGFlag;
RINGINGCALLDATA g_rcdRingingCallData;
extern CRITICAL_SECTION g_csRingingCallData;

BOOL g_dwCPIStatus=FALSE;

BOOL g_bCurrentGprsAttachStatus = FALSE; //add for the issue about unregisterd-gprs SIM card connecting to the GPRS
//xiangming add for the G/E icon function at 070718
BOOL  g_fNetworkSystemChanged = FALSE;
BOOL  g_fNetworkGprsAttachState = FALSE;
DWORD g_bNetworkSystemType=RIL_SYSTEMTYPE_GSM;

BOOL g_bMEDEACTafterNOCARRIER = FALSE;

extern DWORD g_isflymode;
BOOL g_NotifyMEDeact = FALSE;

DWORD g_bNetworkSystemStatus=RIL_REGSTAT_UNKNOWN;
BOOL  g_bNotifyNWDeact=FALSE;
#define RIL_GPRS_REGSTAT_LIMITED      0x00000006  //  6 limited service (cell might be overloaded) [GPRS suspend]
#define RIL_GPRS_REGSTAT_GSMCALL      0x00000007  //  7 GSM call active [GPRS suspend]
#define RIL_GPRS_REGSTAT_NOCELL       0x00000008  //  8 no cell available [GPRS suspend]
#define RIL_GPRS_REGSTAT_NEXTATTEMPT  0x00000009  //  9 next attempt to update MS [GPRS suspend]
DWORD g_dwCGREGReportGPRSStatus = 0x00000000;
DWORD g_dwCREGReportNetworkStatus = RIL_SYSTEMTYPE_NONE;
BOOL  g_bNotifyMEDeact = FALSE; 
//xiangming add for the G/E icon function at 070718 end

WAITINGCALLDATA g_rcdWaitingCallData;
#ifdef OFFER_IMEI_IMSI
//added by cuiguoqing for getting IMSI correctly.
BOOL g_bFirstGetIMSI = TRUE;
extern BOOL g_bRadioOff;
#endif
//added by wuguangliang 2006/4/10
extern HANDLE  g_hGetRegistrationEvent;
extern BOOL      g_bNetworkHelperRunning ;
BOOL g_bSetPhoneNumberTone = FALSE;

//BOOL g_bIncomingCallBlockRunning =FALSE;
//extern CRITICAL_SECTION g_csIncomingcallBlock;
extern CRITICAL_SECTION g_csManualSearchNetwork;
extern BOOL g_bStackAllReady ;
extern BOOL    ISInCALLProgress();
extern BOOL IsPrimaryCard(void);
extern DWORD g_dwEquipmentState;
typedef  LONG (*MMSPORT_GETTRANSID)(LPVOID lpMsgData, LONG lMsgDataLen, LPVOID lpTransID, LPLONG lpTransIDLen);

#ifdef DCD_MESSAGE_FTR

#ifdef DCDPUSH_EXPORTS
#define DCDPUSH_API __declspec(dllexport)
#else
#define DCDPUSH_API __declspec(dllimport)
#endif

extern DCDPUSH_API int nDCDPush;
DCDPUSH_API int fnDCDPush(void);
DCDPUSH_API int dcdPushParser(IN	const unsigned char *pPushData, IN const int nPushLength, OUT unsigned char **pURL, OUT   int *nURLLength);
#endif

#ifdef DCD_MESSAGE_FTR
//DCD push callback
typedef DCDPUSH_API int (*DCDPUSH_PARSER)(IN const unsigned char	*pPushData, IN const int nPushLength, OUT unsigned char **pURL, OUT int *nURLLength);

#define DCD_PUSH 1
#define OTHER_PUSH 0
#define ERROR_PUSH -1
#endif

BOOL DetermineRingingCalltype(DWORD * pdwCallType);

#ifdef FIREWALL
BOOL bWhetherInBackList = FALSE;
BOOL CheckCallwhetherInBackList(const char* szAddress,int nType);
BOOL CheckSMSwhetherInBackList(RILMESSAGE SmsMessage);
typedef  DWORD (*FIREWALLSERVICECHECK)(UINT nNetType, const PWCHAR pwszNumber,int nType);
typedef  DWORD (*FIREWALLSMSCHECK)(UINT nNetType, const PWCHAR pwszNumber, const PWCHAR pwszSMSContent);
FIREWALLSERVICECHECK pfnFireWallServiceCheck = NULL;
FIREWALLSMSCHECK pfnFireWallSMSServiceCheck = NULL;
HMODULE hFireWallDll = NULL;
#endif
/****************************************************************************/
/*** start of helper ATCmd **************************************************/

class CPHSStatus : public ATCmd
{
public:
    CPHSStatus( DWORD dwAddress )
    {
        m_dwAddress = dwAddress;
        memset( &m_rsrs, 0, sizeof(m_rsrs) );
        m_rsrs.dwSize = sizeof(m_rsrs);
    }
    virtual ~CPHSStatus()
    {
    }
    HRESULT Read()
    {
        HRESULT hr = E_FAIL;

        char *szCmd = NULL;
        char buf[128];

        /* based on misc.cpp:RILDrv_GetSimRecordStatus() */
        /* simplied for use in the CPHS context */

        _snprintfz( buf, ARRAY_LENGTH(buf), "AT+CRSM=%u,%u,%u,%u,%u",
#ifdef OEM1_DRIVER
                    192,
#else
                    242,
#endif
                    m_dwAddress, 0, 0, 15 );

        BOOL fOk = ComposeCmdWithByteArray( buf, NULL, 0, "\r", szCmd );
        if ( fOk )
        {
            hr = Execute( szCmd );
        }
        else
        {
            hr = E_OUTOFMEMORY;
        }

        if ( szCmd != NULL )
        {
            delete[] szCmd;
            szCmd = NULL;
        }

        return hr;
    }
    RILSIMRECORDSTATUS GetStatus() const
    {
        return m_rsrs;
    }
    virtual void Dump() const
    {
#ifdef DEBUG
        _tprintf(TEXT("---RILSIMRECORDSTATUS[0x%04x]----------"), m_dwAddress);
        ATCmd::Dump();
        _tprintf(TEXT("cbSize       [%u]"), m_rsrs.cbSize);
        _tprintf(TEXT("dwParams     [%u]"), m_rsrs.dwParams);
        if ( m_rsrs.dwParams & RIL_PARAM_SRS_RECORDTYPE )
        {
            _tprintf(TEXT("dwRecordType [%u]"), m_rsrs.dwRecordType);
        }
        if ( m_rsrs.dwParams & RIL_PARAM_SRS_ITEMCOUNT )
        {
            _tprintf(TEXT("dwItemCount  [%u]"), m_rsrs.dwItemCount);
        }
        if ( m_rsrs.dwParams & RIL_PARAM_SRS_SIZE )
        {
            _tprintf(TEXT("dwSize       [%u]"), m_rsrs.dwSize);
        }
        _tprintf(TEXT("---RILSIMRECORDSTATUS[0x%04x]----------"), m_dwAddress);
#endif
    }
protected:
    virtual HRESULT Parse( LPCSTR szRsp )
    {
        void *pBlob = NULL;
        UINT cbBlob = 0;

        HRESULT hr = ParseGetSimRecordStatus( szRsp, pBlob, cbBlob );
        if ( SUCCEEDED( hr ) && pBlob != NULL && cbBlob == sizeof(m_rsrs) )
        {
            memcpy( &m_rsrs, pBlob, sizeof(m_rsrs) );
        }

        if ( pBlob != NULL )
        {
            FreeBlob( pBlob );
            pBlob = NULL;
        }

        return hr;
    }
private:
    DWORD m_dwAddress;
    RILSIMRECORDSTATUS m_rsrs;
};

class CPHSRecord : public ATCmd
{
public:
    enum
    {
        READ_BINARY = 176,
        READ_RECORD = 178
    };
    enum
    {
        ABSOLUTE_MODE = 4
    };

    CPHSRecord(
        DWORD dwAddress,
        DWORD dwSize,
        DWORD dwCmd,
        DWORD dwIndex)
    {
        m_dwAddress = dwAddress;
        m_dwSize = dwSize;
        m_dwCmd = dwCmd;
        m_dwIndex = dwIndex;
        m_prsr = NULL;
    }

    CPHSRecord(
        DWORD dwAddress,
        DWORD dwSize)
    {
        m_dwAddress = dwAddress;
        m_dwSize = dwSize;
        m_dwCmd = READ_BINARY;
        m_dwIndex = 0;
        m_prsr = NULL;
    }

    virtual ~CPHSRecord()
    {
        if ( m_prsr != NULL )
        {
            FreeBlob( m_prsr );
            m_prsr = NULL;
        }
    }
    HRESULT Read()
    {
        HRESULT hr = E_FAIL;

#ifdef WAVECOM_DRIVER
        /* WaveCom hardware doesnt support AT+CRSM */
        hr = E_NOTIMPL;
#else
        char *szCmd = NULL;
        char buf[128];
        DWORD dwMode = 0;

        /* based on misc.cpp:RILDrv_SendRestrictedSimCmd() */
        /* based on simrecrd.cpp:ReadRecord() */
        /* simplied for use in the CPHS context */

        if (READ_RECORD == m_dwCmd)
        {
            dwMode = ABSOLUTE_MODE;
        }
        _snprintfz( buf, ARRAY_LENGTH(buf), "AT+CRSM=%u,%u,%u,%u,%u",
                    m_dwCmd, m_dwAddress, m_dwIndex, dwMode, m_dwSize );

        BOOL fOk = ComposeCmdWithByteArray( buf, NULL, 0, "\r", szCmd );
        if ( fOk )
        {
            hr = Execute( szCmd );
        }
        else
        {
            hr = E_OUTOFMEMORY;
        }

        if ( szCmd != NULL )
        {
            delete[] szCmd;
            szCmd = NULL;
        }
#endif

        return hr;
    }
    RILSIMRESPONSE GetResponse() const
    {
        RILSIMRESPONSE rsr;
        memset( &rsr, 0, sizeof(rsr) );
        if ( m_prsr != NULL )
        {
            memcpy( &rsr, m_prsr, sizeof(rsr) );
        }
        return rsr;
    }
    BOOL GetRecord( __out_ecount(cbData) BYTE *pData, DWORD& cbData ) const
    {
        BOOL fOk = FALSE;
        if ( m_prsr != NULL && pData != NULL && cbData > 0 )
        {
            int totalsize = (int)m_prsr->cbSize;
            int responsesize = (int)sizeof(RILSIMRESPONSE);
            int recordsize = ( totalsize - responsesize );
            if ( totalsize > 0 && recordsize > 0 && cbData >= (DWORD)recordsize )
            {
                BYTE *pPtr = (BYTE*)m_prsr;

                memset( pData, 0, cbData );

                memcpy( pData, pPtr+responsesize, recordsize );
                cbData = (DWORD)recordsize;

                fOk = TRUE;
            }
        }
        return fOk;
    }

⌨️ 快捷键说明

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