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

📄 dtp_event_vcdlg.cpp

📁 三汇CTI示例程序源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	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);
		}
		//CDisplay 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++;		
	}
}


LRESULT CDTP_Event_VCDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	int nCic;
	int nCh;
	char cNewDtmf;
	int nEventCode;
	int nNewState;

	//Adopt windows message mechanism
	//	   windows message code:event code + 0x7000(WM_USER)
	if(message > WM_USER)  
	{		
		nEventCode = message - WM_USER;	

		//Event notifying the state change of the monitored circuit
		if(nEventCode == E_CHG_SpyState)	
		{
			nCic = wParam;
	 		nNewState = (int)lParam & 0xFFFF;
			if(nCic >= 0 && nCic < MAX_CIC)
			{
				switch(nNewState)
				{
				//Idle state
				case S_SPY_STANDBY:
					{
						if(CicState[nCic].nCicState == CIRCUIT_TALKING)
						{	
							//Call the function with circuit number as its parameter
							if(m_nCallFnMode == 0)				
							{
								//stop recording
								if(SpyStopRecToFile(nCic) == -1)
									MessageBox("Fail to call SpyStopRecToFile");
							}
							//Call the function with channel number as its parameter
							else
							{
								if(CicState[nCic].wRecDirection == CALL_IN_RECORD)
								{
									if(SsmStopRecToFile(CicState[nCic].nCallInCh) == -1)
										MessageBox("Fail to call SsmStopRecToFile");
								}
								else if(CicState[nCic].wRecDirection == CALL_OUT_RECORD)
								{
									if(SsmStopRecToFile(CicState[nCic].nCallOutCh) == -1)
										MessageBox("Fail to call SsmStopRecToFile");
								}
								else
								{
									if(SsmSetRecMixer(CicState[nCic].nCallInCh, FALSE, 0) == -1)//Turn off the record mixer
										MessageBox("Fail to call SsmSetRecMixer");
									if(SsmStopLinkFrom(CicState[nCic].nCallOutCh, CicState[nCic].nCallInCh) == -1)//Cut off the bus connect from outgoing channel to incoming channel
										MessageBox("Fail to call SsmStopLinkFrom");
									if(SsmStopRecToFile(CicState[nCic].nCallInCh) == -1)		//Stop recording
										MessageBox("Fail to call SsmStopRecToFile");
								}
							}
						}
						CicState[nCic].nCicState = CIRCUIT_IDLE;
						CicState[nCic].nCallInIndex = 0;
						CicState[nCic].nCallOutIndex = 0;
						memset(CicState[nCic].szCallInDtmf, 0, sizeof(char)*100);
						memset(CicState[nCic].szCallOutDtmf, 0, sizeof(char)*100);
					}
					break;
				//Receiving phone number
				case S_SPY_RCVPHONUM:
					{
						if(CicState[nCic].nCicState == CIRCUIT_IDLE)
						{
							CicState[nCic].nCicState = CIRCUIT_RCV_PHONUM;
						}
					}
					break;			
				//Ringing
				case S_SPY_RINGING:
					{
						CicState[nCic].nCicState = CIRCUIT_RINGING;
						memset(CicState[nCic].szCallerId, 0, sizeof(char)*20);
						memset(CicState[nCic].szCalleeId, 0, sizeof(char)*20);
						if(SpyGetCallerId(nCic, CicState[nCic].szCallerId) == -1)//Get calling party number
							MessageBox("Fail to call SpyGetCallerId");
						if(SpyGetCalleeId(nCic, CicState[nCic].szCalleeId) == -1)//Get called party number
							MessageBox("Fail to call SpyGetCalleeId");
					}
					break;			
				//Talking
				case S_SPY_TALKING:
					{
						if(CicState[nCic].nCicState == CIRCUIT_RCV_PHONUM)
						{
							memset(CicState[nCic].szCallerId, 0, sizeof(char)*20);
							memset(CicState[nCic].szCalleeId, 0, sizeof(char)*20);
							if(SpyGetCallerId(nCic, CicState[nCic].szCallerId) == -1)
								MessageBox("Fail to call SpyGetCallerId");
							if(SpyGetCalleeId(nCic, CicState[nCic].szCalleeId) == -1)
								MessageBox("Fail to call SpyGetCalleeId");
						}
						if((CicState[nCic].nCallInCh = SpyGetCallInCh(nCic)) == -1)	//Get the number of incoming channel
							MessageBox("Fail to call SpyGetCallInCh");
						if((CicState[nCic].nCallOutCh = SpyGetCallOutCh(nCic)) == -1)//Get the number of outgoing channel
							MessageBox("Fail to call SpyGetCallOutCh");
						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(m_nCallFnMode == 0)	//Call the function with circuit number as its parameter
						{
							if(SpyRecToFile(nCic, CicState[nCic].wRecDirection, szTemp, -1, 0L, -1, -1, 0) == -1)
								MessageBox("Fail to call SpyRecToFile");
						}
						else if(m_nCallFnMode == 1)		//Call the function with channel number as its parameter
						{
							if(CicState[nCic].wRecDirection == CALL_IN_RECORD)
							{
								if(SsmRecToFile(CicState[nCic].nCallInCh, szTemp, -1, 0L, -1, -1, 0) == -1)
									MessageBox("Fail to call SsmRecToFile");
							}
							else if(CicState[nCic].wRecDirection == CALL_OUT_RECORD)
							{
								if(SsmRecToFile(CicState[nCic].nCallOutCh, szTemp, -1, 0L, -1, -1, 0) == -1)
									MessageBox("Fail to call SsmRecToFile");
							}
							else
							{
								if(SsmLinkFrom(CicState[nCic].nCallOutCh, CicState[nCic].nCallInCh) == -1)  //Connect the bus from outgoing channel to incoming channel
									MessageBox("Fail to call SsmLinkFrom");
								if(SsmSetRecMixer(CicState[nCic].nCallInCh, TRUE, 0) == -1)		//Turn on the record mixer
									MessageBox("Fail to call SsmSetRecMixer");
								if(SsmRecToFile(CicState[nCic].nCallInCh, szTemp, -1, 0L, -1, -1, 0) == -1)//Recording
									MessageBox("Fail to call SsmRecToFile");
							}
						}
					}
					break;
				default:
					break;
				}
			}		
		}
		//Event generated by the driver when DTMF is received
		else if(nEventCode == E_CHG_RcvDTMF)
		{
			nCh = wParam;
			//Switching from channel number to circuit number
 			if((nCic = SpyChToCic(nCh)) == -1)
			{
				MessageBox("Fail to call SpyChToCic");
			}
			if(nCic != -1)
			{
				if(CicState[nCic].nCicState == CIRCUIT_TALKING)
				{
					cNewDtmf = (char)(0xFFFF & lParam);	//Newly received DTMF
					if(nCh == CicState[nCic].nCallInCh)
					{
						CicState[nCic].szCallInDtmf[CicState[nCic].nCallInIndex] = cNewDtmf;
						CicState[nCic].nCallInIndex++;
					}
					else if(nCh == CicState[nCic].nCallOutCh)
					{
						CicState[nCic].szCallOutDtmf[CicState[nCic].nCallOutIndex] = cNewDtmf;
						CicState[nCic].nCallOutIndex++; 
					}
				}
			}
		}
		
		UpdateCircuitListCtrl();
	}

	return CDialog::WindowProc(message, wParam, lParam);
}
//Incoming call recording
void CDTP_Event_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;
}
//Outgoing call recording
void CDTP_Event_VCDlg::OnRadioCallOut() 
{
	// 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;	
}
//Mix-record
void CDTP_Event_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;		
}


void CDTP_Event_VCDlg::OnSelchangeComboCic() 
{
	// 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_Event_VCDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
	//Close board driver
	if(SsmCloseCti() == -1)
		MessageBox("Fail to call SsmCloseCti");
}


void CDTP_Event_VCDlg::OnRadioCircuit() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);	
}


void CDTP_Event_VCDlg::OnRadioCh() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
}

⌨️ 快捷键说明

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