📄 gatestat.c
字号:
}
gateUpdate(pCamelSession,GATE_WAIT_PROMPTPASSWD_CMPLT);
break;
//用户中途突然挂机
case DE_LCOFF:
case DE_TONEON:
case DIGITAL_ONHOOK:
Session[channel].waitOnHook = FALSE;
gateTRACE(channel,(Session[channel].LogFile,"PSTN Disconnect on channel %d\n",
channel));
/* Unlisten both sides */
if(lpNetTsc->fIsInbound != TRUE) {
gateUnRoute(channel);
}
lpTsc->fBusy=FALSE;
user_onhook(channel); //用户挂机处理函数
break;
case DX_ONHOOK:
gateUpdate(pCamelSession,GATE_WAIT_CALL);
break;
default:
gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x) on channel %d in Gate_Wait_For_Welcome_cmplt\n",
gateEventStr(event),event,channel));
break;
}//end of switch event
return(DM3SUCCESS);
}// end of function gateWaitForGetUsernameCmplt
/*****FUNCTION***************************************************
* NAME : gateWaitForPromptPasswdCmplt
* DESCRIPTION : 等待播放提示输入密码语音完成,接收用户按键输入
* add by xuzq 98.6.10
* INPUT : LPDM3NetTSC lpNetTsc - pointer to NetTsc structure
* LONG event - the recieved event
* void *pEvtData - the data recieved
* OUTPUT : None
* RETURNS : Success or fail
* CAUTIONS : None.
****************************************************************/
USHORT gateWaitForPromptPasswdCmplt(LPDM3NetTSC lpNetTsc,
LONG event,
void *pEvtData)
{
BOOL rBool;
LPDM3TSC lpTsc;
GateSession *pCamelSession;
USHORT channel;
pCamelSession = (GateSession *)(lpNetTsc->lpUserInfo);
channel = pCamelSession->sessionNumber;
lpTsc = NETTSC_GET_DM3TSC(lpNetTsc);
switch(event) {
case TM_EOD: //播放完毕
case TM_MAXDTMF: //用户按键
if (dx_fileclose(handle[channel]) == -1) {
/* process error */
gateTRACE(channel,(Session[channel].LogFile,"Error in closing VOX file in channel %d on Gate_wait_for_welcome_cmplt state\n",
channel));
}
if (getdigs(channel,10)==-1){ //出错
gateTRACE(channel,(Session[channel].LogFile,"Error in getting digitals in channel %d on Gate_wait_for_Offhook state\n",
channel));
gateExit(GET_DIGITALS_ERROR,channel);
return(DM3FAIL);
}
gateUpdate(pCamelSession,GATE_WAIT_GETPASSWD_CMPLT);
break;
//用户中途突然挂机
case DE_LCOFF:
case DE_TONEON:
case DIGITAL_ONHOOK:
Session[channel].waitOnHook = FALSE;
gateTRACE(channel,(Session[channel].LogFile,"PSTN Disconnect on channel %d\n",
channel));
/* Unlisten both sides */
if(lpNetTsc->fIsInbound != TRUE) {
gateUnRoute(channel);
}
lpTsc->fBusy=FALSE;
user_onhook(channel); //用户挂机处理函数
break;
case DX_ONHOOK:
gateUpdate(pCamelSession,GATE_WAIT_CALL);
break;
default:
gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x) on channel %d in Gate_Wait_For_Welcome_cmplt\n",
gateEventStr(event),event,channel));
break;
}//end of switch event!
return(DM3SUCCESS);
}// end of function gateWaitForPromptPasswdCmplt
/*****FUNCTION***************************************************
* NAME : gateWaitForGetPasswdCmplt
* DESCRIPTION : 等待获取用户密码按键完成
* 保存用户按键,用户验证;并用语音提示结果:
* 验证成功,提示输入对方电话号码——phonenum.vox,转入状态7
* 验证失败,提示重新输入用户名——again.vox,转入状态8
* add by xuzq 98.6.10
* INPUT : LPDM3NetTSC lpNetTsc - pointer to NetTsc structure
* LONG event - the recieved event
* void *pEvtData - the data recieved
* OUTPUT : None
* RETURNS : Success or fail
* CAUTIONS : None.
****************************************************************/
USHORT gateWaitForGetPasswdCmplt(LPDM3NetTSC lpNetTsc,
LONG event,
void *pEvtData)
{
BOOL rBool;
LPDM3TSC lpTsc;
GateSession *pCamelSession;
USHORT channel;
pCamelSession = (GateSession *)(lpNetTsc->lpUserInfo);
channel = pCamelSession->sessionNumber;
lpTsc = NETTSC_GET_DM3TSC(lpNetTsc);
switch(event) {
case TM_DIGIT: //按键结束。以“#”终止
if (strlen(digp[channel].dg_value)>NUM_PASSWORD) { //用户名超长
if ((handle[channel] = dx_fileopen("vox\\again.vox", O_RDONLY|O_BINARY)) == -1) {
//出错
gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getpasswd_cmplt state\n",
channel));
gateExit(OPEN_VOXFILE_ERROR,channel);
return(DM3FAIL);
}
gateUpdate(pCamelSession,GATE_WAIT_NOTMATCH_CMPLT);
if (play(channel,handle[channel])==-1) { //播放文件出错
gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getusername_cmplt state\n",
channel));
gateExit(PLAY_VOXFILE_ERROR,channel);
return(DM3FAIL);
}
break;
}
strcpy(password[channel],digp[channel].dg_value);
//用户验证
if (check(username[channel],password[channel])==1){ //身份验证成功
//记录用户信息,以备存入数据库中!
strcpy(uta[channel].user_id,username[channel]);
if ((handle[channel] = dx_fileopen("vox\\phonenum.vox", O_RDONLY|O_BINARY)) == -1) {
//出错
gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getpasswd_cmplt state\n",
channel));
gateExit(OPEN_VOXFILE_ERROR,channel);
return(DM3FAIL);
}
gateUpdate(pCamelSession,GATE_WAIT_PROMPTPHONENUM_CMPLT);
}
else{//验证失败或用户名不存在!
if ((handle[channel] = dx_fileopen("vox\\again.vox", O_RDONLY|O_BINARY)) == -1) {
//出错
gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getpasswd_cmplt state\n",
channel));
gateExit(OPEN_VOXFILE_ERROR,channel);
return(DM3FAIL);
}
gateUpdate(pCamelSession,GATE_WAIT_NOTMATCH_CMPLT);
} //验证结束
if (play(channel,handle[channel])==-1) { //播放文件出错
gateTRACE(channel,(Session[channel].LogFile,"Error in openning VOX file in channel %d on Gate_wait_for_getpasswd_cmplt state\n",
channel));
gateExit(PLAY_VOXFILE_ERROR,channel);
return(DM3FAIL);
}//播放语音文件操作结束
break;
//用户中途突然挂机
case DE_LCOFF:
case DE_TONEON:
case DIGITAL_ONHOOK:
Session[channel].waitOnHook = FALSE;
gateTRACE(channel,(Session[channel].LogFile,"PSTN Disconnect on channel %d\n",
channel));
/* Unlisten both sides */
if(lpNetTsc->fIsInbound != TRUE) {
gateUnRoute(channel);
}
lpTsc->fBusy=FALSE;
user_onhook(channel); //用户挂机处理函数
break;
case DX_ONHOOK:
gateUpdate(pCamelSession,GATE_WAIT_CALL);
break;
default:
gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x) on channel %d in Gate_Wait_For_Welcome_cmplt\n",
gateEventStr(event),event,channel));
break;
}//end of switch event
return(DM3SUCCESS);
}// end of function gateWaitForGetPasswdCmplt
/*****FUNCTION***************************************************
* NAME : gateWaitForPromptPhonenumCmplt
* DESCRIPTION : 用户验证成功,等待播放提示输入目的电话号码语音完成
* add by xuzq 98.6.10
* INPUT : LPDM3NetTSC lpNetTsc - pointer to NetTsc structure
* LONG event - the recieved event
* void *pEvtData - the data recieved
* OUTPUT : None
* RETURNS : Success or fail
* CAUTIONS : None.
****************************************************************/
USHORT gateWaitForPromptPhonenumCmplt(LPDM3NetTSC lpNetTsc,
LONG event,
void *pEvtData)
{
BOOL rBool;
LPDM3TSC lpTsc;
GateSession *pCamelSession;
USHORT channel;
pCamelSession = (GateSession *)(lpNetTsc->lpUserInfo);
channel = pCamelSession->sessionNumber;
lpTsc = NETTSC_GET_DM3TSC(lpNetTsc);
switch(event) {
case TM_EOD : //播放完毕或用户按键
case TM_MAXDTMF:
if (dx_fileclose(handle[channel]) == -1) {
/* process error */
gateTRACE(channel,(Session[channel].LogFile,"Error in closing VOX file in channel %d on Gate_wait_for_promptphonenum_cmplt state\n",
channel));
}
if (getdigs(channel,10)==-1){
//出错
gateTRACE(channel,(Session[channel].LogFile,"Error in getting digitals in channel %d on Gate_wait_for_promptphonenum_cmplt state\n",
channel));
gateExit(GET_DIGITALS_ERROR,channel);
return(DM3FAIL);
}
gateUpdate(pCamelSession,GATE_WAIT_GETPHONENUM_CMPLT);
break;
//用户中途突然挂机
case DE_LCOFF:
case DE_TONEON:
case DIGITAL_ONHOOK:
Session[channel].waitOnHook = FALSE;
gateTRACE(channel,(Session[channel].LogFile,"PSTN Disconnect on channel %d\n",
channel));
/* Unlisten both sides */
if(lpNetTsc->fIsInbound != TRUE) {
gateUnRoute(channel);
}
lpTsc->fBusy=FALSE;
user_onhook(channel); //用户挂机处理函数
break;
case DX_ONHOOK:
gateUpdate(pCamelSession,GATE_WAIT_CALL);
break;
default:
gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x) on channel %d in Gate_Wait_For_PromptPhonenum_Cmplt\n",
gateEventStr(event),event,channel));
break;
}//end of switch event
return(DM3SUCCESS);
}// end of function gateWaitForPromptPhonenumCmplt
/*****FUNCTION***************************************************
* NAME : gateWaitForNotmatchCmplt
* DESCRIPTION : 用户验证失败,等待播放提示重新输入用户名语音完成
* add by xuzq 98.6.10
* INPUT : LPDM3NetTSC lpNetTsc - pointer to NetTsc structure
* LONG event - the recieved event
* void *pEvtData - the data recieved
* OUTPUT : None
* RETURNS : Success or fail
* CAUTIONS : None.
****************************************************************/
USHORT gateWaitForNotmatchCmplt(LPDM3NetTSC lpNetTsc,
LONG event,
void *pEvtData)
{
BOOL rBool;
LPDM3TSC lpTsc;
GateSession *pCamelSession;
USHORT channel;
pCamelSession = (GateSession *)(lpNetTsc->lpUserInfo);
channel = pCamelSession->sessionNumber;
lpTsc = NETTSC_GET_DM3TSC(lpNetTsc);
switch(event) {
case TM_EOD : //播放完毕或用户按键
case TM_MAXDTMF:
if (dx_fileclose(handle[channel]) == -1) {
/* process error */
gateTRACE(channel,(Session[channel].LogFile,"Error in closing VOX file in channel %d on Gate_wait_for_Notmatch_Cmplt state\n",
channel));
}
if (getdigs(channel,10)==-1){
//出错
gateTRACE(channel,(Session[channel].LogFile,"Error in getting digitals in channel %d on Gate_wait_for_Notmatch_Cmplt state\n",
channel));
gateExit(GET_DIGITALS_ERROR,channel);
return(DM3FAIL);
}
gateUpdate(pCamelSession,GATE_WAIT_GETUSERNAME_CMPLT);
break;
//不明消息、或用户中途突然挂机
default:
gateTRACE(channel,(Session[channel].LogFile,"\tUnexpected event %s (0x%x) on channel %d in Gate_Wait_For_Notmatch_Cmplt\n",
gateEventStr(event),event,channel));
case DE_LCOFF:
c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -