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

📄 tapiwavedrivertestdlg.cpp

📁 AVAYA IPO 430系列交换机Wavedriver的demo程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	BOOL bHeld = FALSE;
	BOOL bPending = FALSE;
	TAPILine *pLine = m_TAPIConnection.GetTapiLine();
	if (pLine)
	{
		bActive = !!(pLine->m_hConnectedCall);
		bWaiting = !!(pLine->m_hWaitingCall);
		bHeld = !!(pLine->m_hHeldCall);
		bPending = !!(pLine->m_hPendingCall);
	}

	CWnd *pWnd = NULL;
	pWnd = GetDlgItem(IDC_BUTTON_MAKECALL);
	if (pWnd)
		pWnd->EnableWindow(!bActive && !bPending);
	pWnd = GetDlgItem(IDC_BUTTON_HANGUP);
	if (pWnd)
		pWnd->EnableWindow(bActive || bWaiting);
	pWnd = GetDlgItem(IDC_BUTTON_ANSWER);
	if (pWnd)
		pWnd->EnableWindow(bPending);


	// Ensure evrthing is stopped.
	if (!bActive)
	{
		this->OnButtonStop();
	}

	// Enable only the appropriate buttons
//	m_CtlConferenceCall.EnableWindow(bActive && bHeld);
//	m_CtlAnswerCall.EnableWindow(bPending);
//	m_CtlCancelCall.EnableWindow(bActive || bWaiting);
//	m_CtlHoldCall.EnableWindow(bActive);
//	m_CtlMakeCall.EnableWindow(!bActive && !bPending);
//	m_CtlRetrieveCall.EnableWindow(bHeld);
//	m_CtlTransferCall.EnableWindow(bActive);
}


//*************************************************************************
// Setup initial extension for dialing
void CTAPIWaveDriverTestDlg::SetExtensionField()
{
	UpdateData(TRUE); // In case the user has typed something in an edit box
	TAPILine *pTAPILine = m_TAPIConnection.GetTapiLine();
	if (pTAPILine)
		m_ebCallText = 	pTAPILine->GetDefaultExt();

	UpdateData(FALSE); // Update the text box
}

//*************************************************************************
// CtDialStringSink events
void CTAPIWaveDriverTestDlg::OnDialDone()
{
 	m_BrowseButton.EnableWindow(TRUE);
	m_SendButton.EnableWindow(TRUE);
	m_SendButton.SetFocus();
	m_RecordButton.EnableWindow(TRUE);
	m_StopButton.EnableWindow(FALSE);
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnWaveInData()
{
    m_bufcount++;
	if (m_bRecording)
	{
        CString info;
        info.Format("Input buffer filled %d",m_bufcount);
        AddText(info); 
		// Append data
	//	m_Wave.Record(m_WaveDeviceID, RECORD_DURATION);
		m_Wave.ContinueRecord(RECORD_DURATION);
		m_Wave.Append();
	}
	else
	{
        CString info;
        info.Format("Input buffer filled %d (no longer recording)",m_bufcount);
        AddText(info); 

        m_Wave.SwitchInputBuffer();
		m_Wave.Append();

		// Save data.
		// Pick a random path name
		char    szPath[MAX_PATH+1];
		GetTempPath(MAX_PATH, szPath);
		GetTempFileName(szPath, "wav", 0, m_strWaveFile.GetBuffer(MAX_PATH));
		m_strWaveFile.ReleaseBuffer();
		UpdateData(FALSE);

		// Save the file
		BeginWaitCursor();
		m_Wave.Save(m_strWaveFile);
		m_Wave.Load(m_strWaveFile);
		EndWaitCursor();

		// Enable the play/record buttons
 		m_BrowseButton.EnableWindow(TRUE);
		m_SendButton.EnableWindow(TRUE);
		m_RecordButton.EnableWindow(TRUE);
		m_RecordButton.SetFocus();
		m_StopButton.EnableWindow(FALSE);
	}
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnWaveOutDone()
{
 	m_BrowseButton.EnableWindow(TRUE);
	m_SendButton.EnableWindow(TRUE);
	m_SendButton.SetFocus();
    m_RecordButton.EnableWindow(TRUE);
    m_StopButton.EnableWindow(FALSE);
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnWaveOutOpen()
{
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnDialError()
{
 	m_BrowseButton.EnableWindow(TRUE);
	m_SendButton.EnableWindow(TRUE);
	m_SendButton.SetFocus();
    m_RecordButton.EnableWindow(TRUE);
    m_StopButton.EnableWindow(FALSE);
    MessageBox("Error playing DTMF Tones");
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonSendWAV() 
{
	TAPILine *pTAPILine = m_TAPIConnection.GetTapiLine();
	if (pTAPILine)
	{
		BeginWaitCursor();
		if( m_Wave.Play(pTAPILine->m_waveOutId) )
		{
			EndWaitCursor();
			m_BrowseButton.EnableWindow(FALSE);
			m_SendButton.EnableWindow(FALSE);
			m_RecordButton.EnableWindow(FALSE);
			m_StopButton.EnableWindow(TRUE);
		}	
		else
			EndWaitCursor();
	}

}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonBrowseWAV() 
{
    char*   pszFilter = "Wave Files (*.wav)|*.wav|All Files (*.*)|*.*||";
	CFileDialog dlg(TRUE, "wav", 0, OFN_FILEMUSTEXIST, pszFilter, this);
	
    if( dlg.DoModal() == IDOK )
    {
        m_strWaveFile = dlg.GetPathName();
        m_Wave.Load(m_strWaveFile);
        UpdateData(FALSE);
 		m_BrowseButton.EnableWindow(TRUE);
		m_SendButton.EnableWindow(TRUE);
    }
	
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonStop() 
{
	m_bRecording = false;
	m_Wave.Stop();
    m_DTMF.Cancel();
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonRecord() 
{
    m_bufcount = 0;
	TAPILine *pTAPILine = m_TAPIConnection.GetTapiLine();
	if (pTAPILine)
	{
		BeginWaitCursor();

		if( m_Wave.Record(pTAPILine->m_waveOutId, RECORD_DURATION) )
		{
			//if( m_Wave.Play(pTAPILine->m_waveOutId) )
			//{
			//}	
			EndWaitCursor();
			m_BrowseButton.EnableWindow(FALSE);
			m_SendButton.EnableWindow(FALSE);
			m_RecordButton.EnableWindow(FALSE);
			m_StopButton.EnableWindow(TRUE);

			CString sMsg;
			sMsg.Format("Recording...");
			SetDlgItemText(IDC_EDIT_WAVEFILE, sMsg);

			m_bRecording = true;
		}
		else
			EndWaitCursor();
	}
}


//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonTones() 
{
	TAPILine *pTAPILine = m_TAPIConnection.GetTapiLine();
	if (pTAPILine)
	{
		UpdateData(TRUE);
		m_DTMF = m_strDialTones;
    
		if( m_DTMF.Dial(pTAPILine->m_waveOutId, 500, 1000) )
		{
			m_BrowseButton.EnableWindow(FALSE);
			m_SendButton.EnableWindow(FALSE);
			m_RecordButton.EnableWindow(FALSE);
			m_StopButton.EnableWindow(TRUE);
		}
	}

}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

/*lineGenerateTone
lineMonitorDigits
lineMonitorTone*/

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonTest1() 
{
	TAPILine *pTAPILine = m_TAPIConnection.GetTapiLine();
	if (pTAPILine)
	{
		if (pTAPILine->m_hConnectedCall)
		{
			lineGenerateTone(pTAPILine->m_hConnectedCall, 
						LINETONEMODE_BEEP, 1000, 0 , 0);
		}
	}

	
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonMonitortone() 
{
	TAPILine *pTAPILine = m_TAPIConnection.GetTapiLine();
	if (pTAPILine)
	{
		if (pTAPILine->m_hConnectedCall)
		{	
			LINEMONITORTONE tones[1];
			tones[0].dwAppSpecific  = TEST_FOR_SILENCE;
			tones[0].dwDuration = 3000;
			tones[0].dwFrequency1 = 0;
			tones[0].dwFrequency2 = 0;
			tones[0].dwFrequency3 = 0;
			lineMonitorTones(pTAPILine->m_hConnectedCall, 
						tones, 1);
		}
	}
	
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonGendigits() 
{
	// This only works on owned calls ie outgoing???
	TAPILine *pTAPILine = m_TAPIConnection.GetTapiLine();
	if (pTAPILine)
	{
		if (pTAPILine->m_hConnectedCall)
		{	
			char digits[] = {'1','2','3' ,0};
			CString str = "123";
	//		lineGenerateDigits(pTAPILine->m_hConnectedCall, LINEDIGITMODE_DTMF,
	//					digits, 1000);
			lineGenerateDigits(pTAPILine->m_hConnectedCall, LINEDIGITMODE_DTMF,
						str, 1000);
		}
	}
	
	
}

//*************************************************************************
void CTAPIWaveDriverTestDlg::OnButtonMondigits() 
{
	TAPILine *pTAPILine = m_TAPIConnection.GetTapiLine();
	if (pTAPILine)
	{
		if (pTAPILine->m_hConnectedCall)
		{	
			if (!m_bDigitMonitoringOn)
			{
				m_MonitorDigits.SetWindowText("Stop monitoring digits");
				lineMonitorDigits(pTAPILine->m_hConnectedCall, LINEDIGITMODE_DTMF);
			}
			else
			{
				m_MonitorDigits.SetWindowText("Start monitoring digits");
				lineMonitorDigits(pTAPILine->m_hConnectedCall, 0);
			}

			m_bDigitMonitoringOn = !m_bDigitMonitoringOn;
		}
	}
	
}


void CTAPIWaveDriverTestDlg::OnButtonSelectline() 
{
	UpdateData(TRUE); // Get data from edit box
	// Select the TAPI line	
	//
	// Find the extension in the array of lines, and select the line
	DWORD extension = atoi(m_strLine);
	for (unsigned int i = 0; i < m_TAPIConnection.m_NumDevs; i++)
	{
		if (m_TAPIConnection.m_pLines[i] != NULL)
		{
			if (m_TAPIConnection.m_pLines[i]->m_extension == extension)
			{
				m_TAPIConnection.SetTapiLine(i);
				break;
			}
		}
	}

}

void CTAPIWaveDriverTestDlg::OnClear() 
{
	// Clear the display window
	m_InfoTextBox.Empty();
	UpdateData(FALSE);	
}

⌨️ 快捷键说明

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