📄 pbxdlg.cpp
字号:
switch(ChInfo[nCh].nStatus)
{
case USER_GET_1STDTMF:
//close T1
if(SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmStopTimer");
}
nToneType = 0;
nToneChResult = SsmChkSendTone(nCh,&nToneType);
if(nToneChResult != -1)
{
if(nToneChResult == 1)
{
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_GET_1STDTMF", "SsmStopSendTone");
}
}
}
else
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_GET_1STDTMF", "SsmChkSendTone");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
break;
case USER_DIALOUT:
//detect whether it is dialing or not
nToneType = 0;
nToneChResult = SsmChkSendTone(nCh,&nToneType);
if(nToneChResult != -1)
{
if(nToneChResult == 1)
{
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_DIALOUT", "SsmStopSendTone");
}
}
}
else
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_DIALOUT", "SsmChkSendTone");
}
//send E_TK_RELEASE
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
SendMessage(WM_USER+E_TK_RELEASE, ChInfo[nCh].nLinkToCh, nCh);
//close TX
if(SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_DIALOUT", "SsmStopTimer");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_DIALOUT", "SsmSendTone");
}
break;
case USER_F_GET_DTMF:
//close T4
if(SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmStopTimer");
}
nToneType = 0;
nToneChResult = SsmChkSendTone(nCh,&nToneType);
if(nToneChResult != -1)
{
if(nToneChResult == 1)
{
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmStopSendTone");
}
}
}
else
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmChkSendTone");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_F_OPERATE;
break;
default:
//close TX
if(SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "default", "SsmStopTimer");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "default", "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
break;
}
break;
/*+++++++++define station channel message +++++++++*/
case E_US_SEIZURE:
if(USER_IDLE == ChInfo[nCh].nStatus)
{
ChInfo[nCh].nStatus = USER_LOCAL_RING;
//send E_US_SEIZURE_ACK_IDLE
SendMessage(WM_USER+E_US_SEIZURE_ACK_IDLE, lParam, nCh);
//send ringing tone
if(SsmStartRing(nCh) == -1)
{
ShowErrMsg("E_US_SEIZURE", "USER_IDLE", "SsmStartRing");
}
ChInfo[nCh].nLinkToCh = lParam;
//retrieve CallerId
if(ChInfo[ChInfo[nCh].nLinkToCh].nChType == 0)
{
if(SsmGetCallerId(ChInfo[nCh].nLinkToCh, ChInfo[nCh].szCallerId) == -1)
{
ShowErrMsg("E_US_SEIZURE", "USER_IDLE", "SsmGetCallerId");
}
}
else
{
strcpy(ChInfo[nCh].szCallerId, ChInfo[ChInfo[nCh].nLinkToCh].CUserNum);
}
}
else
{
//send E_US_SEIZURE_ACK_BUSY
SendMessage(WM_USER+E_US_SEIZURE_ACK_BUSY, lParam, nCh);
}
break;
case E_US_SEIZURE_ACK_IDLE: //it is detected that station channel is seizured successfully
switch(ChInfo[nCh].nStatus)
{
case USER_REQ_USER:
//play ringback tone
if(SsmSendTone(nCh, 2) == -1)
{
ShowErrMsg("E_US_SEIZURE_ACK_IDLE", "USER_REQ_USER", "SsmSendTone");
}
//retrieve CalledId
strcpy(ChInfo[nCh].szCalleeId, ChInfo[nCh].szPhoneNumBuf);
ChInfo[nCh].nLinkToCh = lParam;
ChInfo[nCh].nStatus = USER_RING_BACK;
break;
case USER_F_REQ_USER: // extension in call transfer is seized successfully
//play ringback tone
if(SsmSendTone(nCh, 2) == -1)
{
ShowErrMsg("E_US_SEIZURE_ACK_IDLE", "USER_F_REQ_USER", "SsmSendTone");
}
//retrieve CalledId
strcpy(ChInfo[nCh].szCalleeId, ChInfo[nCh].szPhoneNumBuf);
ChInfo[nCh].nLinkToCh = lParam;
ChInfo[nCh].nStatus = USER_F_RING_BACK;
break;
default:
break;
}
break;
case E_US_SEIZURE_ACK_BUSY: //failed to seize designatedstation channel
switch(ChInfo[nCh].nStatus)
{
case USER_REQ_USER:
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_US_SEIZURE_ACK_IDLE", "USER_REQ_USER", "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
break;
case USER_F_REQ_USER:
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_US_SEIZURE_ACK_IDLE", "USER_F_REQ_USER", "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_F_OPERATE;
break;
default:
break;
}
break;
case E_US_PICKUP:
//Called party go off-hook
switch(ChInfo[nCh].nStatus)
{
case USER_RING_BACK:
//stop sending of rinback tone
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_US_PICKUP", "USER_RING_BACK", "SsmStopSendTone");
}
//build bus connection
if(SsmTalkWith(nCh, ChInfo[nCh].nLinkToCh) == -1)
{
ShowErrMsg("E_US_PICKUP", "USER_RING_BACK", "SsmTalkWith");
}
ChInfo[nCh].nStatus = USER_TALKING;
break;
case USER_F_RING_BACK:
//stop sending of ringback tone
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_US_PICKUP", "USER_F_RING_BACK", "SsmStopSendTone");
}
//build bus connection between ch1 and ch2
if(SsmTalkWith(nCh, ChInfo[nCh].nLinkToCh) == -1)
{
ShowErrMsg("E_US_PICKUP", "USER_F_RING_BACK", "SsmTalkWith");
}
ChInfo[nCh].nStatus = USER_F_TALKING;
break;
}
break;
case E_US_RELEASE:
//stop ringing
if(SsmStopRing(nCh) == -1)
{
ShowErrMsg("E_US_RELEASE", NULL, "SsmStopRing");
}
ChInfo[nCh].nLinkToCh = -1;
ChInfo[nCh].bPressFlag = FALSE;
ChInfo[nCh].nStatus = USER_IDLE;
memset(ChInfo[nCh].szCallerId, '\0', sizeof(char)*NUM_LENGTH); //clear CalledId
break;
case F_US_SEIZURE:
if(USER_IDLE == ChInfo[nCh].nStatus)
{
//send ringing
if(SsmStartRing(nCh) == -1)
{
ShowErrMsg("F_US_SEIZURE", "USER_IDLE", "SsmStartRing");
}
ChInfo[nCh].nStatus = USER_LOCAL_RING;
ChInfo[nCh].nLinkToCh = lParam;
ChInfo[nCh].bPressFlag = TRUE;
strcpy(ChInfo[nCh].szCallerId, ChInfo[ChInfo[nCh].nLinkToCh].CUserNum);
//send E_US_SEIZURE_ACK_IDLE
SendMessage(WM_USER+E_US_SEIZURE_ACK_IDLE, lParam, nCh);
}
else
{
//send E_US_SEIZURE_ACK_BUSY
SendMessage(WM_USER+E_US_SEIZURE_ACK_BUSY, lParam, nCh);
}
break;
/*+++++++++define analog trunk channel message +++++++++*/
case E_TK_SEIZURE_TK_ACK_IDLE: //trunk channel is seized successfully
//send dial tone
if(SsmSendTone(nCh, 0) == -1)
{
ShowErrMsg("E_TK_SEIZURE_TK_ACK_IDLE", NULL, "SsmSendTone");
}
//start T3:18 seconds
if( (ChInfo[nCh].nTimer = SsmStartTimer(18000, 1)) == -1)
{
ShowErrMsg("E_TK_SEIZURE_TK_ACK_IDLE", NULL, "SsmStartTimer");
}
ChInfo[nCh].nLinkToCh =lParam;
ChInfo[nCh].nStatus = USER_DIALOUT;
break;
case E_TK_SEIZURE_TK_ACK_BUSY: //failed to seize designated trunk channel
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_TK_SEIZURE_TK_ACK_BUSY", NULL, "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
break;
case E_TK_DIAL_OK:
//close T3
if(SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_TK_DIAL_OK", NULL, "SsmStopTimer");
}
//play ringback tone
if(SsmSendTone(nCh, 2) == -1)
{
ShowErrMsg("E_TK_DIAL_OK", NULL, "SsmSendTone");
}
//retrieve CalledId
if (SsmGetDtmfStr(nCh,ChInfo[nCh].szCalleeId) == -1)
{
ShowErrMsg("E_TK_DIAL_OK", NULL, "SsmGetDtmfStr");
}
ChInfo[nCh].nStatus = USER_WAIT_REMOTE_PICKUP;
break;
case E_TK_DIAL_FAIL:
//detect whether dial tone is present
nToneType = 0;
nToneChResult = SsmChkSendTone(nCh,&nToneType);
if(nToneChResult != -1)
{
if(nToneChResult == 1)
{
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_TK_DIAL_FAIL", NULL, "SsmStopSendTone");
}
}
}
else
{
ShowErrMsg("E_TK_DIAL_FAIL", NULL, "SsmChkSendTone");
}
//close T3
if(SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_TK_DIAL_FAIL", NULL, "SsmStopTimer");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_TK_DIAL_FAIL", NULL, "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
break;
case E_TK_REMOTE_NOANSWER: //trunk channel does not answer
//stop sending of ringback tone
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_TK_REMOTE_NOANSWER", NULL, "SsmStopSendTone");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_TK_REMOTE_NOANSWER", NULL, "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
break;
case E_TK_REMOTE_PICKUP: //remote end go off-hook
switch(ChInfo[nCh].nStatus)
{
case USER_DIALOUT:
//close T3
if(SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_TK_REMOTE_PICKUP", "USER_DIALOUT", "SsmStopTimer");
}
//build bus connection between station and trunk channel
if(SsmTalkWith(nCh, ChInfo[nCh].nLinkToCh) == -1)
{
ShowErrMsg("E_TK_REMOTE_PICKUP", "USER_DIALOUT", "SsmTalkWith");
}
ChInfo[nCh].nStatus = USER_TALKING;
break;
case USER_WAIT_REMOTE_PICKUP:
//stop sending of ringback tone
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_TK_REMOTE_NOANSWER", NULL, "SsmStopSendTone");
}
//build bus connection
if(SsmTalkWith(nCh, ChInfo[nCh].nLinkToCh) == -1)
{
ShowErrMsg("E_TK_REMOTE_PICKUP", "USER_WAIT_REMOTE_PICKUP", "SsmTalkWith");
}
ChInfo[nCh].nStatus = USER_TALKING;
break;
default:
break;
}
//retrieve CalledId
if (SsmGetDtmfStr(nCh,ChInfo[nCh].szCalleeId) == -1)
{
ShowErrMsg("E_TK_DIAL_OK", NULL, "SsmGetDtmfStr");
}
break;
/*+++++++++define public message +++++++++*/
case E_MSG_RELEASE:
switch(ChInfo[nCh].nStatus)
{
case USER_TALKING:
//play howler tone
if(SsmSendTone(nCh, 3) == -1)
{
ShowErrMsg("E_MSG_RELEASE", "USER_TALKING", "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
break;
case USER_F_WAIT_TALK:
//stop playback of background music
nPlayResult = SsmCheckPlay(nCh);
if(nPlayResult != -1)
{
if(nPlayResult == 0)
{
if(SsmStopPlayFile(nCh) == -1)
{
ShowErrMsg("E_MSG_RELEASE", "USER_F_TALKING", "SsmStopPlayFile");
}
}
}
else
{
ShowErrMsg("E_MSG_RELEASE", "USER_F_TALKING", "SsmCheckPlay");
}
//call transfer failed and send howler tone to original calling party
if(SsmSendTone(nCh, 3) == -1)
{
ShowErrMsg("E_MSG_RELEASE", "USER_F_TALKING", "SsmSendTone");
}
ChInfo[nCh].nStatus = USER_WAIT_HANGUP;
break;
case USER_F_TALKING:
//play howler tone
if(SsmSendTone(nCh, 3) == -1)
{
ShowErrMsg("E_MSG_RELEASE", "USER_F_TALKING", "SsmSendTone");
}
ChInfo[nCh].nLinkToCh = -1;
ChInfo[nCh].nStatus = USER_F_OPERATE;
break;
default:
break;
}
break;
case E_MSG_FLASH:
GetCurrentDirectory(MAX_PATH, szVoicePath);
strcat(szVoicePath, "\\bgmusic.wav");
//play background music
if(SsmPlayFile(nCh, szVoicePath, -1, 0, 0xffffffff) == -1)
{
ShowErrMsg("E_MSG_FLASH", NULL, "SsmPlayFile");
}
ChInfo[nCh].nStatus = USER_F_WAIT_TALK;
break;
case E_MSG_CONNECT:
ChInfo[nCh].nLinkToCh = lParam;
//stop playback of background music
nPlayResult = SsmCheckPlay(nCh);
if(nPlayResult != -1)
{
if(nPlayResult == 0)
{
if(SsmStopPlayFile(nCh) == -1)
{
ShowErrMsg("E_MSG_CONNECT", NULL, "SsmStopPlayFile");
}
}
}
else
{
ShowErrMsg("E_MSG_CONNECT", NULL, "SsmCheckPlay");
}
ChInfo[nCh].nStatus = USER_TALKING;
break;
case E_MSG_HANGUP:
ChInfo[nCh].bSubmiteChHookFlag = TRUE; //origial calling party go on-hook
break;
default:
break;
}
}
void CPbxDlg::TrunkProc(UINT event, WPARAM wParam, LPARAM lParam)
{
int nCh; //trunk channel number
DWORD dwDtmfLen; // lenght of DTMF received
UCHAR dwDtmfNum; // DTMF received
char szVoicePath[MAX_PATH]; //sound file path
DWORD nChState; //current statt of trunk channel
int nPlayResult; //return value of function SsmCheckPlay()
nCh = wParam;
switch(event)
{
/*+++++++++driver message +++++++++*/
case E_CHG_ChState:
nChState = lParam & 0xffff;
switch(ChInfo[nCh].nStatus)
{
case TRUNK_IDLE:
if(nChState == S_CALL_RINGING)
{
//go off-hook
if(SsmPickup(nCh) == -1)
{
ShowErrMsg("E_CHG_ChState", "TRUNK_IDLE", "SsmPickup");
}
//retrieve CallerId
if(SsmGetCallerId(nCh, ChInfo[nCh].szCallerId) == -1)
{
ShowErrMsg("E_CHG_ChState", "TRUNK_IDLE", "SsmGetDtmfStr");
}
ChInfo[nCh].nStatus = TRUNK_WAIT_ACTUAL_PICKUP;
ChInfo[nCh].nLinkToCh = -1; //added by lgr for SC-243 2007.11.14
}
break;
case TRUNK_WAIT_ACTUAL_PICKUP:
if(nChState == S_CALL_TALKING) //play welcome
{
GetCurrentDirectory(MAX_PATH, szVoicePath);
strcat(szVoicePath, "\\Select.pcm");
//play welcome
if(SsmPlayFile(nCh, szVoicePath, -1, 0, 0xffffffff) == -1)
{
ShowErrMsg("E_CHG_ChState", "TRUNK_WAIT_ACTUAL_PICKUP", "SsmPlayFile");
}
//set DTMF-STOP-PLAY switch
if(SsmSetDtmfStopPlay(nCh, 1) == -1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -