📄 dialog001.cpp
字号:
// Dialog001.cpp : implementation file
//
#include "stdafx.h"
#include "KevinApp002_RilTest.h"
#include "Dialog001.h"
DWORD gRilCmdID_Dial;
DWORD gRilCmdID_Hangup;
DWORD gRilCmdID_Answer;
void CDialog001::ResultProc(
DWORD dwCode, // @parm result code
HRESULT hrCmdID, // @parm ID returned by the command that originated this response
const void* lpData, // @parm data associated with the notification
DWORD cbData // @parm size of the strcuture pointed to lpData
)
{
NKDbgPrintfW(TEXT("RilResultCallBackFunc dwCode=%x,lpData=%x,cbData=%x,hrCmdID=%x\n"), dwCode,lpData,cbData,hrCmdID);
if(hrCmdID == gRilCmdID_Dial)
{
}
else if(hrCmdID == gRilCmdID_Hangup)
{
}
else if(hrCmdID == gRilCmdID_Answer)
{
}
#if 0
switch ( dwCode )
{
case RIL_RESULT_OK:
{
RILCALLINFO *pCallInfo = ((RILCALLINFO *)lpData); // must call RIL_GetCallList
if(pCallInfo && pCallInfo->dwDirection == RIL_CALLDIR_OUTGOING)// To make an outbound voice call
{
NKDbgPrintfW(TEXT("Number: %s\n"), pCallInfo->raAddress.wszAddress);
}
break;
}
}
#endif
}
void CDialog001::NotifyProc(
DWORD dwCode, // @parm notification code
const void* lpData, // @parm data associated with the notification
DWORD cbData // @parm size of the strcuture pointed to lpData
)
{
NKDbgPrintfW(TEXT("RilNotifyCallBackFunc dwCode=%x,lpData=%x,cbData=%x\n"), dwCode,lpData,cbData);
switch(dwCode)
{
case RIL_NOTIFY_RING: //receive an inbound voice call
{
LPRILRINGINFO ringInfo = (LPRILRINGINFO) lpData;
m_Str_DisplayDialNum=_T("Incoming:");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
break;
}
case RIL_NOTIFY_DISCONNECT:
{
break;
}
case RIL_NOTIFY_CONNECT: // To make an outbound voice call
{
LPRILCONNECTINFO connectInfo = (LPRILCONNECTINFO)lpData;
//RIL_GetCallList( g_hRil );
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("...");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
break;
}
case RIL_NOTIFY_CALLERID: //receive an inbound voice call
{
RILREMOTEPARTYINFO *rpi = (RILREMOTEPARTYINFO *)lpData;
NKDbgPrintfW(TEXT("Number: %s\n"), rpi->raAddress.wszAddress );
//m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T(rpi->raAddress.wszAddress);
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("05925390795");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
break;
}
default:
break;
}
}
// CDialog001 dialog
IMPLEMENT_DYNAMIC(CDialog001, CDialog)
CDialog001::CDialog001(CWnd* pParent /*=NULL*/)
: CDialog(CDialog001::IDD, pParent)
, m_Str_DisplayDialNum(_T(""))
{
HRESULT hResult;
g_hRil = NULL;
hResult=RIL_Initialize(
1, // @parm index of the RIL port to use (e.g., 1 for RIL1:)
RilResultCallBackFunc, // @parm function result callback
RilNotifyCallBackFunc, // @parm notification callback
RIL_NCLASS_ALL, // @parm classes of notifications to be enabled for this client
(DWORD)this, // @parm custom parameter passed to result and notififcation callbacks
&g_hRil // @parm returned handle to RIL instance
);
if(hResult == S_OK)
{
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Initialize return S_Ok=%x \r\n"),hResult);
}
else if(hResult == S_FALSE)
{
hResult = GetLastError();
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Initialize return S_FALSE=%x \r\n"),hResult);
}
else
{
hResult = GetLastError();
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Initialize return E_XXX=%x \r\n"),hResult);
}
}
CDialog001::~CDialog001()
{
}
void CDialog001::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDialog001, CDialog)
ON_BN_CLICKED(IDC_BUTTON4, &CDialog001::OnBnClickedButton4)
ON_BN_CLICKED(IDC_BUTTON5, &CDialog001::OnBnClickedButton5)
ON_BN_CLICKED(IDC_BUTTON6, &CDialog001::OnBnClickedButton6)
ON_BN_CLICKED(IDC_BUTTON7, &CDialog001::OnBnClickedButton7)
ON_BN_CLICKED(IDC_BUTTON8, &CDialog001::OnBnClickedButton8)
ON_BN_CLICKED(IDC_BUTTON9, &CDialog001::OnBnClickedButton9)
ON_BN_CLICKED(IDC_BUTTON10, &CDialog001::OnBnClickedButton10)
ON_BN_CLICKED(IDC_BUTTON11, &CDialog001::OnBnClickedButton11)
ON_BN_CLICKED(IDC_BUTTON12, &CDialog001::OnBnClickedButton12)
ON_BN_CLICKED(IDC_BUTTON13, &CDialog001::OnBnClickedButton13)
ON_BN_CLICKED(IDC_BUTTON14, &CDialog001::OnBnClickedButton14)
ON_BN_CLICKED(IDC_BUTTON15, &CDialog001::OnBnClickedButton15)
ON_BN_CLICKED(IDC_BUTTON1, &CDialog001::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &CDialog001::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON3, &CDialog001::OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON16, &CDialog001::OnBnClickedButton16)
ON_BN_CLICKED(IDC_BUTTON17, &CDialog001::OnBnClickedButton17)
ON_BN_CLICKED(IDC_BUTTON18, &CDialog001::OnBnClickedButton18)
END_MESSAGE_MAP()
// CDialog001 message handlers
void CDialog001::OnBnClickedButton4()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("1");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton5()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("2");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton6()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("3");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton7()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("4");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton8()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("5");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton9()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("6");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton10()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("7");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton11()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("8");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton12()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("9");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton13()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("*");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton14()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("0");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton15()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=m_Str_DisplayDialNum+_T("#");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
HRESULT hResult;
DWORD len;
len = m_Str_DisplayDialNum.GetLength();
char *pDialNum = new char[len];
for(DWORD i=0;i<len;i++)
pDialNum[i] = (char)m_Str_DisplayDialNum.GetAt(i);
hResult = RIL_Dial(
g_hRil, // @parm handle to RIL instance returned by <f RIL_Initialize>
pDialNum, // @parm address to dial (no longer than <def MAXLENGTH_ADDRESS> chars)
RIL_CALLTYPE_VOICE, // @parm type of the call to establish (<def RIL_CALLTYPE_> constant)
RIL_DIALOPT_NONE // @parm dialing options (any combination of <def RIL_DIALOPT_> constants)
);
if(hResult >= 0)
{
gRilCmdID_Dial = (DWORD)hResult;
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Dial return Ok=%x \r\n"),hResult);
}
else
{
gRilCmdID_Dial = (-1);
hResult = GetLastError();
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Dial return FALSE=%x \r\n"),hResult);
}
delete[] pDialNum;
}
void CDialog001::OnBnClickedButton2()
{
// TODO: Add your control notification handler code here
HRESULT hResult;
hResult = RIL_Hangup(
g_hRil // @parm handle to RIL instance returned by <f RIL_Initialize>
);
if(hResult >= 0)
{
gRilCmdID_Hangup = (DWORD)hResult;
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Hangup return Ok=%x \r\n"),hResult);
}
else
{
gRilCmdID_Hangup = (-1);
hResult = GetLastError();
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Hangup return FALSE=%x \r\n"),hResult);
}
}
void CDialog001::OnBnClickedButton3()
{
// TODO: Add your control notification handler code here
m_Str_DisplayDialNum=_T("");
UpdateData(FALSE);
SetDlgItemText(IDC_EDIT1,m_Str_DisplayDialNum);
}
void CDialog001::OnBnClickedButton16()
{
// TODO: Add your control notification handler code here
HRESULT hResult;
hResult = RIL_Answer(
g_hRil // @parm handle to RIL instance returned by <f RIL_Initialize>
);
if(hResult >= 0)
{
gRilCmdID_Answer= (DWORD)hResult;
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Answer return Ok=%x \r\n"),hResult);
}
else
{
gRilCmdID_Answer = (-1);
hResult = GetLastError();
NKDbgPrintfW(TEXT("===========Kevin Debug RIL_Answer return FALSE=%x \r\n"),hResult);
}
}
void CDialog001::OnBnClickedButton17()
{
// TODO: Add your control notification handler code here
}
void CDialog001::OnBnClickedButton18()
{
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -