📄 callcontrol.c
字号:
tCcUaMsg.hdr.dwChannel = dwChannel;
dwIdx = eFirstcall;
tCcUaMsg.hdr.dwCcIdx = dwIdx;
tCcUaMsg.hdr.dwUaIdx = mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].dwUaIdx;
if ( eType == eBillStart ) {
// 话单开始
tCcUaMsg.hdr.eMsgType = eReportBillStart;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tBillStart );
ttCur = time(0);
ttTm = localtime( &ttCur );
mtFxxAttrib[dwChannel].dwBillSn = ttTm->tm_mday * 1000000 + ttTm->tm_hour * 10000 + ttTm->tm_min * 100 + ttTm->tm_sec;
tCcUaMsg.u.tBillStart.dwBillSn = mtFxxAttrib[dwChannel].dwBillSn;
tCcUaMsg.u.tBillStart.dwCallee = m_tModuleInfo.port.dwTelno[dwChannel];
if ( mtFxxAttrib[dwChannel].eFxoCallType == eFxoCallout ) {
if ( mtFxxAttrib[dwChannel].dwPayFxsNumber ) {
tCcUaMsg.u.tBillStart.dwCaller = mtFxxAttrib[dwChannel].dwPayFxsNumber;
} else {
tCcUaMsg.u.tBillStart.dwCaller = mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCaller;
}
} else {
tCcUaMsg.u.tBillStart.dwCaller = atoi(mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.cDispName);
}
tCcUaMsg.u.tBillStart.dwLastCaller = tCcUaMsg.u.tBillStart.dwCaller;
tCcUaMsg.u.tBillStart.mchCallNumber[0] = 0;
} else {
if ( mtFxxAttrib[dwChannel].dwBillSn == 0 ) {
ttCur = time(0);
ttTm = localtime( &ttCur );
mtFxxAttrib[dwChannel].dwBillSn
= ttTm->tm_mday * 1000000 + ttTm->tm_hour * 10000 + ttTm->tm_min * 100 + ttTm->tm_sec;
}
// 话单结束
if ( mtFxxAttrib[dwChannel].eFxoCallType == eFxoCallout &&
mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].dwReceiveNumber == 0 ) {
// no dialnumber
return;
}
tCcUaMsg.hdr.eMsgType = eReportBillEnd;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tBillEnd );
tCcUaMsg.u.tBillEnd.dwBillSn = mtFxxAttrib[dwChannel].dwBillSn;
tCcUaMsg.u.tBillEnd.dwCallee = m_tModuleInfo.port.dwTelno[dwChannel];
if ( mtFxxAttrib[dwChannel].eFxoCallType == eFxoCallout ) {
tCcUaMsg.u.tBillEnd.dwLastCaller = mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCaller;
if ( mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCaller == m_tModuleInfo.port.dwTelno[dwChannel] ) {
tCcUaMsg.u.tBillEnd.dwLastCaller = mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCallee;
}
memcpy( tCcUaMsg.u.tBillEnd.mchCallNumber, mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].mchReceiveNumber,
MAX_TELNO_LEN );
for( dwTmp = 0; dwTmp < mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].dwReceiveNumber; dwTmp ++ ) {
tCcUaMsg.u.tBillEnd.mchCallNumber[dwTmp] += '0';
}
if ( tCcUaMsg.u.tBillEnd.mchCallNumber[0] == '9' ) {
for( dwTmp = MAX_SHORT_DTMF_SAVED; dwTmp < mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].dwReceiveNumber; dwTmp ++ ) {
tCcUaMsg.u.tBillEnd.mchCallNumber[dwTmp] = 0;
}
}
tCcUaMsg.u.tBillEnd.mchCallNumber[mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].dwReceiveNumber] = 0;
} else {
if ( mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCallee == m_tModuleInfo.port.dwTelno[dwChannel] ) {
tCcUaMsg.u.tBillEnd.dwLastCaller = mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCaller;
} else {
tCcUaMsg.u.tBillEnd.dwLastCaller=atoi(mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.cDispName);
tCcUaMsg.u.tBillEnd.dwLastCaller = mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCallee;
}
if(mtFxxAttrib[dwChannel].eFxoCallType == eFxoCallout ) //shangfeng0711
memcpy( tCcUaMsg.u.tBillEnd.mchCallNumber, mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.cDispName,
MAX_TELNO_LEN );
else //shangfeng0711
//itoa(mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCallee, tCcUaMsg.u.tBillEnd.mchCallNumber, 10); //shangfeng0711
sprintf(tCcUaMsg.u.tBillEnd.mchCallNumber,"%d",mtFxxAttrib[dwChannel].mtCallInfo[dwIdx].tSetup.dwCallee);//shangfeng 0711
}
}
vSendMsgToUA( &tCcUaMsg );
}
void CCallControl::vReportCCStatus( DWORD dwChannel )
{
tCC_UA_MSG tCcUaMsg;
tCcUaMsg.hdr.eMsgType = eReportStatus;
tCcUaMsg.hdr.dwCcIdx = 0;
tCcUaMsg.hdr.dwUaIdx = 0;
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.hdr.length = sizeof(tCcUaMsg.hdr) + sizeof(tCcUaMsg.u.tReport);
tCcUaMsg.u.tReport.dwModuleNumber = m_tModuleInfo.general.iModuleIndex;
tCcUaMsg.u.tReport.dwLineType = gmiLineType[dwChannel];
tCcUaMsg.u.tReport.dwChannel = m_tModuleInfo.port.dwTelno[dwChannel];
//printf("vReportCCStatus,%d\n",m_tModuleInfo.general.iModuleIndex);
switch( meChannelStatus[dwChannel] ) {
case eFxx_null:
tCcUaMsg.u.tReport.dwPortStatus = 4; // busy
tCcUaMsg.u.tReport.dwAcdBusyMark = eAcdSetBusy;
break;
case eFxs_idle:
tCcUaMsg.u.tReport.dwPortStatus = 0; // idle
if ( mtFxxAttrib[dwChannel].eAcdStatus == eAcdSetBusy ) {
tCcUaMsg.u.tReport.dwAcdBusyMark = eAcdSetBusy;
} else {
tCcUaMsg.u.tReport.dwAcdBusyMark = mtFxxAttrib[dwChannel].eAcdStatus;
}
break;
case eFxs_waitdial:
case eFxs_waitonhook:
case eFxs_playing:
case eFxs_dialing:
case eFxs_connecting:
case eFxs_calling:
case eFxs_waitconnect:
case eFxs_disconnect:
case eFxs_replace:
case eFxs_followme:
case eFxs_waitcmdans:
tCcUaMsg.u.tReport.dwPortStatus = 4; // busy
if ( mtFxxAttrib[dwChannel].eAcdStatus == eAcdSetBusy ) {
tCcUaMsg.u.tReport.dwAcdBusyMark = eAcdSetBusy;
} else {
tCcUaMsg.u.tReport.dwAcdBusyMark = mtFxxAttrib[dwChannel].eAcdStatus;
}
break;
case eFxs_ringing:
tCcUaMsg.u.tReport.dwPortStatus = 2; // ring
if ( mtFxxAttrib[dwChannel].eAcdStatus == eAcdSetBusy ) {
tCcUaMsg.u.tReport.dwAcdBusyMark = eAcdSetBusy;
} else {
tCcUaMsg.u.tReport.dwAcdBusyMark = mtFxxAttrib[dwChannel].eAcdStatus;
}
break;
case eFxs_talking:
if ( mtFxxAttrib[dwChannel].eAcdStatus == eAcdSetBusy ) {
tCcUaMsg.u.tReport.dwAcdBusyMark = eAcdSetBusy;
} else {
tCcUaMsg.u.tReport.dwAcdBusyMark = mtFxxAttrib[dwChannel].eAcdStatus;
}
tCcUaMsg.u.tReport.dwPortStatus = 4; // busy
if ( mtFxxAttrib[dwChannel].e2ndCallStatus == e2ndCallNull &&
m_tModuleInfo.port.isCallWait[dwChannel] ) {
tCcUaMsg.u.tReport.dwPortStatus = 1; // talk
}
if ( mtFxxAttrib[dwChannel].e2ndCallStatus == e2ndCallRing ) {
tCcUaMsg.u.tReport.dwPortStatus = 3; // talk_ring
}
break;
case eFxo_idle:
if ( mtFxxAttrib[dwChannel].mtCallInfo[0].dwDirectCall ) {
tCcUaMsg.u.tReport.dwPortStatus = 4; // busy
} else {
tCcUaMsg.u.tReport.dwPortStatus = 0; // idle
}
tCcUaMsg.u.tReport.dwAcdBusyMark = eAcdIdle;
break;
case eFxo_play:
case eFxo_calling:
case eFxo_disconnect:
case eFxo_connecting:
case eFxo_waitconnect:
case eFxo_talking:
case eFxo_waitdial:
case eFxo_dialing:
case eFxo_end:
case eFxo_getpasswd:
case eFxo_getnumber:
case eFxo_waitinfo:
tCcUaMsg.u.tReport.dwPortStatus = 4; // busy
tCcUaMsg.u.tReport.dwAcdBusyMark = eAcdIdle;
break;
default:
tCcUaMsg.u.tReport.dwPortStatus = 4; // busy
tCcUaMsg.u.tReport.dwAcdBusyMark = eAcdIdle;
break;
}
if ( memcmp( &(tCcUaMsg.u.tReport), &m_mtReportStatus[dwChannel], sizeof(tReportStatus) ) ) {
m_mdwReportSame[dwChannel] = 0;
vSendMsgToUA( &tCcUaMsg );
m_mtReportStatus[dwChannel] = tCcUaMsg.u.tReport;
} else {
m_mdwReportSame[dwChannel] ++;
if ( m_mdwReportSame[dwChannel] < 2 ) {
vSendMsgToUA( &tCcUaMsg );
}
}
vSetTimer( dwChannel, eT101, mdwTimeoutLength[eT101] );
}
void CCallControl::vCodeFunc( DWORD dwChannel )
{
tCC_UA_MSG tCcUaMsg;
DWORD dwTmp;
switch( mtFxxAttrib[dwChannel].eCurrentFuncCode ) {
case eFuncForwardEnable: // 设置无条件前转
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eForwardMsg;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tForward );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tForward.dwType = 1;
tCcUaMsg.u.tForward.dwForwardNumber = mtFxxAttrib[dwChannel].dwForwardNumber;
tCcUaMsg.u.tForward.dwChannel = dwChannel;
tCcUaMsg.u.tForward.dwModuleNumber = m_tModuleInfo.general.iModuleIndex;
tCcUaMsg.hdr.dwCcIdx = 0;
tCcUaMsg.hdr.dwUaIdx = 0;
vSendMsgToUA( &tCcUaMsg );
vPlayVoiceFile( dwChannel, eForwardSetOk );
mtFxxAttrib[dwChannel].dwPlayMode = 1;
m_tModuleInfo.port.dwForwardTel[dwChannel] = mtFxxAttrib[dwChannel].dwForwardNumber;
m_tModuleInfo.port.dwDelayTime[dwChannel] = 0;
vChangeCCStatus( dwChannel, eFxs_playing );
break;
case eFuncForwardDisable: // 取消无条件前转
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eForwardMsg;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tForward );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tForward.dwType = 0;
tCcUaMsg.u.tForward.dwModuleNumber = m_tModuleInfo.general.iModuleIndex;
tCcUaMsg.u.tForward.dwChannel = dwChannel;
tCcUaMsg.hdr.dwCcIdx = 0;
tCcUaMsg.hdr.dwUaIdx = 0;
vSendMsgToUA( &tCcUaMsg );
vPlayVoiceFile( dwChannel, eForwardClearOk );
mtFxxAttrib[dwChannel].dwPlayMode = 1;
m_tModuleInfo.port.dwForwardTel[dwChannel] = 0;
vChangeCCStatus( dwChannel, eFxs_playing );
break;
case eFuncDelayForwardEnable: // 设置延时前转
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eDelayForwardMsg;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tDelayForward );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tDelayForward.dwType = 1;
tCcUaMsg.u.tDelayForward.dwForwardNumber = mtFxxAttrib[dwChannel].dwForwardNumber;
tCcUaMsg.u.tDelayForward.dwChannel = dwChannel;
tCcUaMsg.u.tDelayForward.dwModuleNumber = m_tModuleInfo.general.iModuleIndex;
tCcUaMsg.u.tDelayForward.dwTimelength = mtFxxAttrib[dwChannel].dwDelayForwardTimeout;
tCcUaMsg.hdr.dwCcIdx = 0;
tCcUaMsg.hdr.dwUaIdx = 0;
vSendMsgToUA( &tCcUaMsg );
vPlayVoiceFile( dwChannel, eDelayForwardSetOk );
mtFxxAttrib[dwChannel].dwPlayMode = 1;
m_tModuleInfo.port.dwDelayTime[dwChannel] = mtFxxAttrib[dwChannel].dwDelayForwardTimeout;
m_tModuleInfo.port.dwForwardTel[dwChannel] = mtFxxAttrib[dwChannel].dwForwardNumber;
vChangeCCStatus( dwChannel, eFxs_playing );
break;
case eFuncDelayForwardDisable: // 取消延时前转
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eDelayForwardMsg;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tDelayForward );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tDelayForward.dwType = 0;
tCcUaMsg.u.tDelayForward.dwForwardNumber = 0;
tCcUaMsg.u.tDelayForward.dwChannel = dwChannel;
tCcUaMsg.u.tDelayForward.dwModuleNumber = m_tModuleInfo.general.iModuleIndex;
tCcUaMsg.u.tDelayForward.dwTimelength = 0;
tCcUaMsg.hdr.dwCcIdx = 0;
tCcUaMsg.hdr.dwUaIdx = 0;
vSendMsgToUA( &tCcUaMsg );
vPlayVoiceFile( dwChannel, eDelayForwardClearOk );
mtFxxAttrib[dwChannel].dwPlayMode = 1;
m_tModuleInfo.port.dwDelayTime[dwChannel] = 0;
m_tModuleInfo.port.dwForwardTel[dwChannel] = 0;
vChangeCCStatus( dwChannel, eFxs_playing );
break;
case eFuncFollowmeEnable: // 设置跟我来功能
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eFollowme;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tFollowme );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tFollowme.eType = eF_Set;
tCcUaMsg.u.tFollowme.iDestinationNumber = m_tModuleInfo.port.dwTelno[dwChannel];
tCcUaMsg.u.tFollowme.iSourceNumber = mtFxxAttrib[dwChannel].dwFollowmeNumberSave;
tCcUaMsg.u.tFollowme.iPassword = mtFxxAttrib[dwChannel].dwFollowmePassword;
tCcUaMsg.u.tFollowme.dwModuleNumber = m_tModuleInfo.general.iModuleIndex;
vSendMsgToUA( &tCcUaMsg );
vSetTimer( dwChannel, eT109, mdwTimeoutLength[eT109] );
vChangeCCStatus( dwChannel, eFxs_followme );
break;
case eFuncFollowmeDisable: // 取消跟我来功能
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eFollowme;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tFollowme );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tFollowme.eType = eF_Clear;
tCcUaMsg.u.tFollowme.iDestinationNumber = m_tModuleInfo.port.dwTelno[dwChannel];
tCcUaMsg.u.tFollowme.iSourceNumber = mtFxxAttrib[dwChannel].dwFollowmeNumberSave;
tCcUaMsg.u.tFollowme.iPassword = mtFxxAttrib[dwChannel].dwFollowmePassword;
tCcUaMsg.u.tFollowme.dwModuleNumber = m_tModuleInfo.general.iModuleIndex;
vSendMsgToUA( &tCcUaMsg );
vSetTimer( dwChannel, eT118, mdwTimeoutLength[eT118] );
vChangeCCStatus( dwChannel, eFxs_followme );
break;
case eFuncCallWaitingEnable: // 设置呼叫等待功能
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eCallWaitingCommand;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tCallWaiting );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tCallWaiting.dwChannel = dwChannel;
tCcUaMsg.u.tCallWaiting.dwType = 1;
vSendMsgToUA( &tCcUaMsg );
vPlayVoiceFile( dwChannel, eCallWaitingSet );
mtFxxAttrib[dwChannel].dwPlayMode = 1;
m_tModuleInfo.port.isCallWait[dwChannel] = TRUE;
vChangeCCStatus( dwChannel, eFxs_playing );
break;
case eFuncCallWaitingDisable: // 取消呼叫等待功能
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eCallWaitingCommand;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tCallWaiting );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tCallWaiting.dwChannel = dwChannel;
tCcUaMsg.u.tCallWaiting.dwType = 0;
vSendMsgToUA( &tCcUaMsg );
vPlayVoiceFile( dwChannel, eCallWaitingClr );
mtFxxAttrib[dwChannel].dwPlayMode = 1;
m_tModuleInfo.port.isCallWait[dwChannel] = FALSE;
vChangeCCStatus( dwChannel, eFxs_playing );
break;
case eFuncAcdSetBusyEnable: // ACD置忙
mtFxxAttrib[dwChannel].eAcdStatus = eAcdSetBusy;
vPlayVoiceFile( dwChannel, eAcdBusySet );
mtFxxAttrib[dwChannel].dwPlayMode = 1;
vChangeCCStatus( dwChannel, eFxs_playing );
break;
case eFuncAcdSetBusyDisable: // 取消ACD置忙
mtFxxAttrib[dwChannel].eAcdStatus = eAcdIdle;
vPlayVoiceFile( dwChannel, eAcdBusyClr );
mtFxxAttrib[dwChannel].dwPlayMode = 1;
vChangeCCStatus( dwChannel, eFxs_playing );
break;
case eFuncReplace: // 代接
memset( (char *)&tCcUaMsg, 0, sizeof(tCcUaMsg) );
tCcUaMsg.hdr.eMsgType = eReplace;
tCcUaMsg.hdr.length = sizeof( tCcUaMsg.hdr ) + sizeof( tCcUaMsg.u.tReplace );
tCcUaMsg.hdr.dwChannel = dwChannel;
tCcUaMsg.u.tReplace.iChannelNumber = m_tModuleInfo.port.dwTelno[dwChannel];
tCcUaMsg.hdr.dwCcIdx = 0;
tCcUaMsg.hdr.dwUaIdx = 0;
vSendMsgToUA( &tCcUaMsg );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -