📄 vcdemo_prodlg.cpp
字号:
UpdateControls();
}
void CVcDemo_proDlg::OnBtnCancelTransfer()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
m_Va.CancelTransfer(DlgTranSet.m_sCancelTransfer );
UpdateControls();
}
void CVcDemo_proDlg::OnBtnBlindTransfer()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
CString num;
m_edtNumToTransfer.GetWindowText(num);
m_Va.BlindTransfer( num,DlgTranSet.m_sHookFlash );
UpdateControls();
}
void CVcDemo_proDlg::OnBtnHold()
{
// TODO: Add your control notification handler code here
m_Va.Hold(DlgTranSet.m_sHold );
}
void CVcDemo_proDlg::OnBtnUnhold()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
m_Va.Unhold(DlgTranSet.m_sUnhold );
}
void CVcDemo_proDlg::OnBtnSwapHold()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
m_Va.SwapHold(DlgTranSet.m_sSwapHold );
}
void CVcDemo_proDlg::OnBtnGenerateDigits()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
CString digits;
m_edtDigitsToGenerate.GetWindowText(digits);
m_Va.GenerateDigits(digits);
}
void CVcDemo_proDlg::OnCallStatusAngel(long LineIndex, long EventID, long Param1, LPCTSTR Param2)
{
// TODO: Add your control notification handler code here
CString s;CString msg;CString sLineIndex;
switch(EventID)
{
//Status events For outgoing calls
case CALLSTATUS_DIALWELLDONE : ShowMsg("Dial well done");break;
case CALLSTATUS_NO_SOUND_AFTER_DIALING : ShowMsg(" No response after dialing.");break;
case CALLSTATUS_RINGBACK :
s.Format("The %d RingBack on line %d",Param1,LineIndex);
ShowMsg(s); break;
case CALLSTATUS_BUSY : ShowMsg("Busy!"); break;
case CALLSTATUS_VOICE_PROMPT_DETECTED :
s.Format("Voice Prompt Detected. The Prompt ID is d%, Descripton:%S",Param1,Param2);
ShowMsg(s); break;
case CALLSTATUS_FAX_TONE : ShowMsg("Fax Tone Detected!"); break;
case CALLSTATUS_CALL_REJECTED : ShowMsg("Call rejected");break;
case CALLSTATUS_CONNECTED :
ShowMsg("Connected!");
switch (Param1)
{
case 0: msg="Connected after dialing."; break;
case 1:msg="Connected after answering."; break;
case 2:msg="Connected after transfering.";break;
case 3:msg="Connected after completing transfer."; break;
case 4:msg="Connected after cancelling transfer."; break;
}
sLineIndex.Format("%d",LineIndex);
msg="Line " + sLineIndex+" "+msg;
ShowMsg(msg);
break;
case CALLSTATUS_WAIT_CONNECTION_TIMEOUT : ShowMsg("Timeout while waiting for connection!");break;
case CALLSTATUS_MONITOR_CALL_STATUS_TIMEOUT : ShowMsg("Timeout while monitoring call status!");break;
case CALLSTATUS_VOICE_PROMPT_TRAINED : ShowMsg("Voice Prompt Trained, the information of the voice prompt has been recorded in knowledge.inf");break;
//Status events for Incoming calls
case CALLSTATUS_RINGING :
s.Format("The %d ring...", Param1);ShowMsg(s);
break;
case CALLSTATUS_CALLERID:
s="CallerID:";
s=s+Param2; ShowMsg(s); break;
case CALLSTATUS_CALLINFO:
long dwOffset;
LINECALLINFO *pCallInfo;
pCallInfo=( LINECALLINFO *)Param1;
dwOffset=pCallInfo->dwCallerIDOffset;
long dwSize;
dwSize=pCallInfo->dwCallerIDSize;
long neededSize;
neededSize= pCallInfo->dwNeededSize;
char *lpszCallerID;
if (dwSize>0)
{
lpszCallerID=new char[dwSize+10];
memccpy(lpszCallerID,(BYTE*)pCallInfo+dwOffset,NULL,dwSize);
delete []lpszCallerID;
}
break;
//Others
case CALLSTATUS_DISCONNECTED : ShowMsg("Disconnected!"); break;
case CALLSTATUS_BLINDTRANSFER_DONE : ShowMsg("Blind Transfer done"); break;
}
UpdateControls();
}
void CVcDemo_proDlg::OnFaxStatusAngel(long LineIndex, short StatusID, long ErrorID, LPCTSTR StatusDescription)
{
// TODO: Add your control notification handler code here
CString sErr;
switch(StatusID)
{case FAX_STATUS_DIALING :
case FAX_STATUS_CONNECTED :
case FAX_STATUS_NEGOTIATING :
case FAX_STATUS_BEGIN_SEND_PAGE :
case FAX_STATUS_PAGE_SENT :
case FAX_STATUS_ALL_PAGES_SENT :
case FAX_STATUS_ANSWERING :
case FAX_STATUS_BEGIN_RECEIVE_PAGE :
case FAX_STATUS_PAGE_RECEIVED :
case FAX_STATUS_ALL_PAGES_RECEIVED :
ShowMsg(StatusDescription);break;
case FAX_STATUS_FINISHED : ShowMsg("Fax success."); m_btnCancelFax.EnableWindow(false); break;
case FAX_STATUS_ERROR:
sErr.Format("A error occured during the fax.The Error Code is %d,the Error Description is:",ErrorID);
sErr+=StatusDescription;
ShowMsg(sErr);
m_btnCancelFax.EnableWindow(false);
default:
ShowMsg(StatusDescription);
}
UpdateControls();
// TODO: Add your control notification handler code here
}
void CVcDemo_proDlg::OnCkAnalyzeRingbackTone()
{
// TODO: Add your control notification handler code here
m_ckRecordRingBackToneToFile.EnableWindow(m_ckAnalyzeRingBackTone.GetCheck());
m_edtWaveFileToRecordRingBackTone.EnableWindow(m_ckAnalyzeRingBackTone.GetCheck());
if(!m_ckAnalyzeRingBackTone.GetCheck())
m_ckRecordRingBackToneToFile.SetCheck(false);
}
void CVcDemo_proDlg::OnBtnSimulateCallProgress()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
CString fileName;
m_edtWaveFileToRecordRingBackTone.GetWindowText(fileName);
m_Va.OpenWaveFile(fileName.GetBuffer(30));
if(m_Va.GetErrorNumber()) ShowMsg(m_Va.GetErrorDescribe());
m_Va.StartPlaying(3,false);
UpdateControls();
}
void CVcDemo_proDlg::OnChangeEdtWaveFileToRecordRingbackTone()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
CString fileName; FILE * hFile;
m_edtWaveFileToRecordRingBackTone.GetWindowText(fileName);
if(hFile=fopen(fileName.GetBuffer(30),"r"))
{ fclose(hFile);
m_btnSimulateOutgoingCallProgress.EnableWindow(true);
}
else m_btnSimulateOutgoingCallProgress.EnableWindow(false);
// TODO: Add your control notification handler code here
}
void CVcDemo_proDlg::OnBtnBufferSetting()
{
m_Va.SetCurrentLineIndex(CurLineIndex);
char bufSize[10];
//DlgBufferSet.DoModal();
if(!DlgBufferSet.m_hWnd)
DlgBufferSet.Create(IDD_DLG_BUFFER_SETTING);
DlgBufferSet.ShowWindow(0);
ltoa(m_Va.GetPlayBufferSize(),bufSize,10);
DlgBufferSet.m_edtPlayBufferSize.SetWindowText(bufSize);
ltoa(m_Va.GetRecordBufferSize(),bufSize,10);
DlgBufferSet.m_edtRecordBufferSize.SetWindowText(bufSize);
DlgBufferSet.ShowWindow(4);
}
void CVcDemo_proDlg::OnBtnSpeech()
{
if(!IsWindow(DlgSpeech.m_hWnd))
DlgSpeech.Create(IDD_DLG_SPEECH);
DlgSpeech.ShowWindow(4);
/*
DlgSpeech.ShowWindow(0);
m_Va.TtsInitialize();
for(int i=0; i<m_Va.GetTtsEngineCount();i++)
{ m_Va.TtsSetCurEngine(i);
DlgSpeech.m_cmbTtsEngines.AddString( m_Va.GetTtsEngineName());
}
m_Va.SrInitialize();
for( i=0; i<m_Va.GetSrEngineCount();i++)
{ m_Va.SrSetCurEngine(i);
DlgSpeech.m_cmbSrEngines.AddString( m_Va.GetSrEngineName());
}
DlgSpeech.m_ckCC.SetCheck(true);
DlgSpeech.UpdateGrammar();*/
}
void CVcDemo_proDlg::OnSrEventAngel(long LineIndex, long EventID, LPCTSTR EventString)
{
// TODO: Add your control notification handler code here
CString msg,sEventString;
sEventString=EventString;
switch( EventID)
{ case SPEI_RECOGNITION:
msg= "You've said: " + sEventString; break;
case SPEI_FALSE_RECOGNITION:
msg= "I can not recognize what you said"; break;
case SPEI_HYPOTHESIS:
msg= "Hypothetic words:" + sEventString; break;
case SPEI_PHRASE_START:
msg= "Phase Started"; break;
case SPEI_INTERFERENCE:
msg= "Interface event:" + sEventString; break;
case SPEI_SOUND_START :
msg= "Sound Started"; break;
case SPEI_SOUND_END:
msg= "Sound Ended"; break;
default:
msg.Format( "Event ID: d%, description:s%", EventID,sEventString);
break;
}
DlgSpeech.ShowMsg(msg);
}
void CVcDemo_proDlg::OnTtsEventAngel(long LineIndex, long EventID, long Param1, long Param2)
{if(!DlgSpeech.m_hWnd) return;
switch(EventID)
{ case SPEI_END_INPUT_STREAM:
DlgSpeech.m_btnSpeak.SetWindowText("Speak");
break;
case SPEI_WORD_BOUNDARY:
DlgSpeech.m_edtTextToSpeak.SetSel( Param1 ,Param1+Param2);
DlgSpeech.m_edtTextToSpeak.SetFocus();
break;
}
}
void CVcDemo_proDlg::OnBtnTrainVoicePrompt()
{
DlgPromptTrain.DoModal();
if(DlgPromptTrain.m_ID<=0)
MessageBox("Prompt ID should bigger then 0.");
m_Va.SetCurrentLineIndex(CurLineIndex);
UpdateData(true);
CString WaveFileToRecordRingBackTone;
if(m_ckRecordRingBackToneToFile.GetCheck())
m_edtWaveFileToRecordRingBackTone.GetWindowText(WaveFileToRecordRingBackTone);
else WaveFileToRecordRingBackTone="";
m_Va.VoicePromptTrain(m_TelNum, DlgPromptTrain.m_ID ,DlgPromptTrain.m_Description,WaveFileToRecordRingBackTone );
UpdateControls();
}
void CVcDemo_proDlg::UpdateControls()
{ m_Va.SetCurrentLineIndex(CurLineIndex);
long linetype=m_Va.GetLineType(), st= m_Va.GetLineStatus(),action=m_Va.GetCurrentActions(),curcall= m_Va.GetCurrentCall();
CString sNumber;
m_edtTelnum.GetWindowText(sNumber);
m_btnDial.EnableWindow((st== LINE_STATUS_IDLE && sNumber!=""));
m_btnTrainVoicePrompt.EnableWindow((st== LINE_STATUS_IDLE&& sNumber!=""));
m_btnAnswer.EnableWindow((st== LINE_STATUS_RINGING));
m_btnDrop.EnableWindow((st== LINE_STATUS_CONNECTED||st== LINE_STATUS_DIALING));
m_btnSimulateOutgoingCallProgress.EnableWindow((st== LINE_STATUS_IDLE));
m_edtNumToTransfer.GetWindowText(sNumber);
m_btnStartTransfer.EnableWindow((st== LINE_STATUS_CONNECTED&&curcall==CURRENT_CALL_ORIGINAL&& sNumber!=""));
m_btnCancelTransfer.EnableWindow((st== LINE_STATUS_CONNECTED&&curcall==CURRENT_CALL_CONSULTATION));
m_btnCompleteTransfer.EnableWindow((st== LINE_STATUS_CONNECTED&&curcall==CURRENT_CALL_CONSULTATION));
m_btnBlindTransfer.EnableWindow((st== LINE_STATUS_CONNECTED&&curcall==CURRENT_CALL_ORIGINAL&& sNumber!=""));
m_btnHold.EnableWindow((st== LINE_STATUS_CONNECTED));
m_btnUnHold.EnableWindow((st== LINE_STATUS_CONNECTED));
m_btnSwapHold.EnableWindow( (st== LINE_STATUS_CONNECTED));
m_ckSpeakerphone.EnableWindow( (st== LINE_STATUS_CONNECTED));
m_ckMonitorDigit.EnableWindow( (st== LINE_STATUS_CONNECTED));
m_ckMonitorSilence.EnableWindow( st== LINE_STATUS_CONNECTED&& !(action&ACTION_PLAY));
m_btnGenerateDigits.EnableWindow( (st== LINE_STATUS_CONNECTED));
m_btnGatherDigits.EnableWindow( (st== LINE_STATUS_CONNECTED));
bool bSoundable;
bSoundable= (linetype==LINE_TYPE_SOUND_CARD||st== LINE_STATUS_CONNECTED);
m_btnPlay.EnableWindow((bSoundable && !(action&ACTION_PLAY) && !(action&ACTION_RECORD)));
m_btnRecord.EnableWindow((bSoundable && !(action&ACTION_PLAY) && !(action&ACTION_RECORD)));
m_btnStop.EnableWindow((bSoundable &&( action&ACTION_PLAY || action&ACTION_RECORD)));
m_btnSpeech.EnableWindow(bSoundable);
m_edtFaxNum.GetWindowText(sNumber);
CString sFaxDoc;
m_edtFaxDoc.GetWindowText(sFaxDoc);
m_btnSendFax.EnableWindow(linetype==LINE_TYPE_VOICE_MODEM && !(action&ACTION_SEND_FAX) && !(action&ACTION_RECEIVE_FAX) && sFaxDoc!="" &&( sNumber!="" ||st==LINE_STATUS_CONNECTED));
m_btnReceiveFax.EnableWindow(linetype==LINE_TYPE_VOICE_MODEM &&!(action&ACTION_SEND_FAX) && !(action&ACTION_RECEIVE_FAX)&& (st==LINE_STATUS_CONNECTED||st==LINE_STATUS_RINGING));
m_btnCancelFax.EnableWindow(linetype==LINE_TYPE_VOICE_MODEM &&((action&ACTION_SEND_FAX) || (action&ACTION_RECEIVE_FAX)));
}
void CVcDemo_proDlg::OnChangeEdtNumTransfer()
{
UpdateControls();
}
void CVcDemo_proDlg::OnBrowse()
{
// TODO: Add your control notification handler code here
char prePath[201];
GetCurrentDirectory(200, prePath);
m_dlg.SetFileName("");
m_dlg.SetFilter("All documents(*.Tif *.doc *.xls)|*.Tif; *.doc; *.xls;|Tif Documents(*.tif)|*.tif|Word Documents(*.Doc)|*.Doc|Excel Documents(*.xls)|*.xls|");
m_dlg.ShowOpen();
if(m_dlg.GetFileName()!="")
m_edtFaxDoc.SetWindowText(m_dlg.GetFileName());
m_dlg.SetFileName("");
SetCurrentDirectory( prePath);
}
void CVcDemo_proDlg::OnChangeEdtFaxNum()
{
UpdateControls();
}
void CVcDemo_proDlg::OnChangeEdtFaxDoc()
{
CString file;
m_edtFaxDoc.GetWindowText(file);
if (file.Find(".doc")!=-1||file.Find(".xls")!=-1)
m_ckECM.EnableWindow(true);
else
m_ckECM.EnableWindow(false);
UpdateControls();
}
BOOL CVcDemo_proDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
m_Va.ShutDown();
m_Va.SaveVoicePromptLibrary("VoicePrompts.inf");
return CDialog::DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -