📄 dtp_poll_vcdlg.cpp
字号:
for(int i = 0; i < nMaxCic; i++)
{
//Display the state of the monitored circuit
switch(CicState[i].nCicState)
{
case CIRCUIT_IDLE: strcpy(szNewStat, "Idle"); break;
case CIRCUIT_RCV_PHONUM: strcpy(szNewStat, "Receiving Phone number"); break;
case CIRCUIT_RINGING: strcpy(szNewStat, "Ringing"); break;
case CIRCUIT_TALKING: strcpy(szNewStat, "Talking"); break;
}
m_CicList.GetItemText(nIndex, 1, szOldStat, 10);
if(strcmp(szOldStat, szNewStat) != 0)
{
m_CicList.SetItemText(nIndex, 1, szNewStat);
}
//Display calling party number
m_CicList.GetItemText(nIndex, 2, szOldStat, 20);
if(strcmp(szOldStat, CicState[i].szCallerId) != 0)
{
m_CicList.SetItemText(nIndex, 2, CicState[i].szCallerId);
}
//Display called party number
m_CicList.GetItemText(nIndex, 3, szOldStat, 20);
if(strcmp(szOldStat, CicState[i].szCalleeId) != 0)
{
m_CicList.SetItemText(nIndex, 3, CicState[i].szCalleeId);
}
//Display incoming channel and received DTMFs in the channel
sprintf(szNewStat, "%d:%s", CicState[i].nCallInCh, CicState[i].szCallInDtmf);
m_CicList.GetItemText(nIndex, 4, szOldStat, 99);
if(strcmp(szOldStat, szNewStat) != 0)
{
m_CicList.SetItemText(nIndex, 4, szNewStat);
}
//Display outgoing channel and received DTMFs in the channel
sprintf(szNewStat, "%d:%s", CicState[i].nCallOutCh, CicState[i].szCallOutDtmf);
m_CicList.GetItemText(nIndex, 5, szOldStat, 99);
if(strcmp(szOldStat, szNewStat) != 0)
{
m_CicList.SetItemText(nIndex, 5, szNewStat);
}
nIndex++;
}
}
DWORD CDTP_Poll_VCDlg::PollProc(LPVOID pParam)
{
// TODO: Add your specialized code here and/or call the base class
int nCic;
int nCh;
char cNewDtmf;
int nNewState;
DWORD wParam;
DWORD lParam;
MESSAGE_INFO EventBuffer;
CDTP_Poll_VCDlg *PDlg =(CDTP_Poll_VCDlg*)pParam;
//ENG: Adopt Event Poll
while(1)
{
Sleep(10);
if(SsmWaitForEvent(50,&EventBuffer)==0)
{
wParam = EventBuffer.nReference;
lParam = EventBuffer.dwParam;
//Event notifying the state change of the monitored circuit
if(EventBuffer.wEventCode == E_CHG_SpyState)
{
nCic = wParam;
nNewState = (int)lParam & 0xFFFF;
if(nCic >= 0 && nCic < MAX_CIC)
{
switch(nNewState)
{
//Idle state
case S_SPY_STANDBY:
{
if(PDlg->CicState[nCic].nCicState == CIRCUIT_TALKING)
{
//Call the function with circuit number as its parameter
if(PDlg->m_nCallFnMode == 0)
{
//stop recording
if(SpyStopRecToFile(nCic) == -1)
PDlg->MessageBox("Fail to call SpyStopRecToFile");
}
//Call the function with channel number as its parameter
else
{
if(PDlg->CicState[nCic].wRecDirection == CALL_IN_RECORD)
{
if(SsmStopRecToFile(PDlg->CicState[nCic].nCallInCh) == -1)
PDlg->MessageBox("Fail to call SsmStopRecToFile");
}
else if(PDlg->CicState[nCic].wRecDirection == CALL_OUT_RECORD)
{
if(SsmStopRecToFile(PDlg->CicState[nCic].nCallOutCh) == -1)
PDlg->MessageBox("Fail to call SsmStopRecToFile");
}
else
{
if(SsmSetRecMixer(PDlg->CicState[nCic].nCallInCh, FALSE, 0) == -1)//Turn off the record mixer
PDlg->MessageBox("Fail to call SsmSetRecMixer");
if(SsmStopLinkFrom(PDlg->CicState[nCic].nCallOutCh, PDlg->CicState[nCic].nCallInCh) == -1)//Cut off the bus connect from outgoing channel to incoming channel
PDlg->MessageBox("Fail to call SsmStopLinkFrom");
if(SsmStopRecToFile(PDlg->CicState[nCic].nCallInCh) == -1) //Stop recording
PDlg->MessageBox("Fail to call SsmStopRecToFile");
}
}
}
PDlg->CicState[nCic].nCicState = CIRCUIT_IDLE;
PDlg->CicState[nCic].nCallInIndex = 0;
PDlg->CicState[nCic].nCallOutIndex = 0;
memset(PDlg->CicState[nCic].szCallInDtmf, 0, sizeof(char)*100);
memset(PDlg->CicState[nCic].szCallOutDtmf, 0, sizeof(char)*100);
}
break;
//Receiving phone number
case S_SPY_RCVPHONUM:
{
if(PDlg->CicState[nCic].nCicState == CIRCUIT_IDLE)
{
PDlg->CicState[nCic].nCicState = CIRCUIT_RCV_PHONUM;
}
}
break;
//Ringing
case S_SPY_RINGING:
{
PDlg->CicState[nCic].nCicState = CIRCUIT_RINGING;
memset(PDlg->CicState[nCic].szCallerId, 0, sizeof(char)*20);
memset(PDlg->CicState[nCic].szCalleeId, 0, sizeof(char)*20);
if(SpyGetCallerId(nCic, PDlg->CicState[nCic].szCallerId) == -1)//Get calling party number
PDlg->MessageBox("Fail to call SpyGetCallerId");
if(SpyGetCalleeId(nCic, PDlg->CicState[nCic].szCalleeId) == -1)//Get called party number
PDlg->MessageBox("Fail to call SpyGetCalleeId");
}
break;
//Talking
case S_SPY_TALKING:
{
if(PDlg->CicState[nCic].nCicState == CIRCUIT_RCV_PHONUM)
{
memset(PDlg->CicState[nCic].szCallerId, 0, sizeof(char)*20);
memset(PDlg->CicState[nCic].szCalleeId, 0, sizeof(char)*20);
if(SpyGetCallerId(nCic, PDlg->CicState[nCic].szCallerId) == -1)
PDlg->MessageBox("Fail to call SpyGetCallerId");
if(SpyGetCalleeId(nCic, PDlg->CicState[nCic].szCalleeId) == -1)
PDlg->MessageBox("Fail to call SpyGetCalleeId");
}
if((PDlg->CicState[nCic].nCallInCh = SpyGetCallInCh(nCic)) == -1) //Get the number of incoming channel
PDlg->MessageBox("Fail to call SpyGetCallInCh");
if((PDlg->CicState[nCic].nCallOutCh = SpyGetCallOutCh(nCic)) == -1)//Get the number of outgoing channel
PDlg->MessageBox("Fail to call SpyGetCallOutCh");
PDlg->CicState[nCic].nCicState = CIRCUIT_TALKING;
//Start recording
//Record file name + Monitored circuit number + Time(hour-minute-second)
CString strRecFile;
SYSTEMTIME st;
char szTemp[50];
GetLocalTime(&st);
strRecFile.Format("Rec%d-%d-%d-%d.wav", nCic, st.wHour, st.wMinute, st.wSecond);
strcpy(szTemp, strRecFile.GetBuffer(strRecFile.GetLength()));
strRecFile.ReleaseBuffer();
if(PDlg->m_nCallFnMode == 0) //Call the function with circuit number as its parameter
{
if(SpyRecToFile(nCic, PDlg->CicState[nCic].wRecDirection, szTemp, -1, 0L, -1, -1, 0) == -1)
PDlg->MessageBox("Fail to call SpyRecToFile");
}
else //Call the function with channel number as its parameter
{
if(PDlg->CicState[nCic].wRecDirection == CALL_IN_RECORD)
{
if(SsmRecToFile(PDlg->CicState[nCic].nCallInCh, szTemp, -1, 0L, -1, -1, 0) == -1)
PDlg->MessageBox("Fail to call SsmRecToFile");
}
else if(PDlg->CicState[nCic].wRecDirection == CALL_OUT_RECORD)
{
if(SsmRecToFile(PDlg->CicState[nCic].nCallOutCh, szTemp, -1, 0L, -1, -1, 0) == -1)
PDlg->MessageBox("Fail to call SsmRecToFile");
}
else
{
if(SsmLinkFrom(PDlg->CicState[nCic].nCallOutCh, PDlg->CicState[nCic].nCallInCh) == -1) //Connect the bus from outgoing channel to incoming channel
PDlg->MessageBox("Fail to call SsmLinkFrom");
if(SsmSetRecMixer(PDlg->CicState[nCic].nCallInCh, TRUE, 0) == -1) //Turn on the record mixer
PDlg->MessageBox("Fail to call SsmSetRecMixer");
if(SsmRecToFile(PDlg->CicState[nCic].nCallInCh, szTemp, -1, 0L, -1, -1, 0) == -1)//Recording
PDlg->MessageBox("Fail to call SsmRecToFile");
}
}
}
break;
default:
break;
}
}
}
//Event generated by the driver when DTMF is received
else if(EventBuffer.wEventCode == E_CHG_RcvDTMF)
{
nCh = wParam;
//Switching from channel number to circuit number
if((nCic = SpyChToCic(nCh)) == -1)
{
PDlg->MessageBox("Fail to call SpyChToCic");
}
if(nCic != -1)
{
if(PDlg->CicState[nCic].nCicState == CIRCUIT_TALKING)
{
cNewDtmf = (char)(0xFFFF & lParam); //Newly received DTMF
if(nCh == PDlg->CicState[nCic].nCallInCh)
{
PDlg->CicState[nCic].szCallInDtmf[PDlg->CicState[nCic].nCallInIndex] = cNewDtmf;
PDlg->CicState[nCic].nCallInIndex++;
}
else if(nCh == PDlg->CicState[nCic].nCallOutCh)
{
PDlg->CicState[nCic].szCallOutDtmf[PDlg->CicState[nCic].nCallOutIndex] = cNewDtmf;
PDlg->CicState[nCic].nCallOutIndex++;
}
}
}
}
}
PDlg->UpdateCircuitListCtrl();
}
return 0;
}
void CDTP_Poll_VCDlg::OnDestroy()
{
TerminateThread(hThread, 1);
SsmCloseCti();
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
//void CDTP_Poll_VCDlg::OnBUTTONStart()
//{
// TODO: Add your control notification handler code here
// hThread=::CreateThread(NULL,0,PollProc,this,0,NULL); //CREATE_SUSPENDED,NULL);
//}
void CDTP_Poll_VCDlg::OnRadioCircuit()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CDTP_Poll_VCDlg::OnRadioCh()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CDTP_Poll_VCDlg::OnEditchangeComboCic()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
int nCurLine;
char sz[100];
m_cmbCic.GetLBText(m_cmbCic.GetCurSel(), sz);
nCurLine = atoi(sz);
switch(CicState[nCurLine].wRecDirection)
{
case CALL_IN_RECORD: m_nRecFormat = 0; break;
case CALL_OUT_RECORD: m_nRecFormat = 1; break;
case MIX_RECORD: m_nRecFormat = 2; break;
}
UpdateData(FALSE);
}
void CDTP_Poll_VCDlg::OnRadioCallIn()
{
// TODO: Add your control notification handler code here
int nCurLine;
char sz[100];
UpdateData(TRUE);
m_cmbCic.GetLBText(m_cmbCic.GetCurSel(), sz);
nCurLine = atoi(sz);
CicState[nCurLine].wRecDirection = CALL_IN_RECORD;
}
void CDTP_Poll_VCDlg::OnRadioCallOut()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
int nCurLine;
char sz[100];
UpdateData(TRUE);
m_cmbCic.GetLBText(m_cmbCic.GetCurSel(), sz);
nCurLine = atoi(sz);
CicState[nCurLine].wRecDirection = CALL_OUT_RECORD;
}
void CDTP_Poll_VCDlg::OnRadioMix()
{
// TODO: Add your control notification handler code here
int nCurLine;
char sz[100];
UpdateData(TRUE);
m_cmbCic.GetLBText(m_cmbCic.GetCurSel(), sz);
nCurLine = atoi(sz);
CicState[nCurLine].wRecDirection = MIX_RECORD;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -