📄 atrkfaxdlg.cpp
字号:
}
else
{
if( SsmFaxStartSend(i, m_FaxCh[i].szSendPathFile) == -1 ) //start sending fax file
{
SsmGetLastErrMsg(m_FaxCh[i].pChErrMsg);
m_FaxCh[i].Step = FAX_IDLE;
}
else
m_FaxCh[i].Step = FAX_CHECK_END;
}
}
else if(m_bHowFile == 1)
{
strcpy(m_szSendMultiPath, m_strRecordFile.GetBuffer(m_strRecordFile.GetLength()));
memset(m_szSendMultiFile, 0, sizeof(m_szSendMultiFile));
for(int jj = 0; jj< m_nSCTNumber; jj++)
{
if(m_szSendMultiFile[0] != 0)
strcat(m_szSendMultiFile, ";");
strcat(m_szSendMultiFile, ffSCT[jj].szFileName);
}
if(SsmFaxSendMultiFile(i, m_szSendMultiPath, m_szSendMultiFile) == -1)
{
SsmGetLastErrMsg(m_FaxCh[i].pChErrMsg);
m_FaxCh[i].Step = FAX_IDLE;
}
else
m_FaxCh[i].Step = FAX_CHECK_END;
}
else if(m_bHowFile == 2)
{
PFAX_FILE_SCT pSCT;
pSCT = ffSCT;
if(SsmFaxSendMultiFileEx(i, pSCT, m_nSCTNumber) == -1)
{
SsmGetLastErrMsg(m_FaxCh[i].pChErrMsg);
m_FaxCh[i].Step = FAX_IDLE;
}
else
m_FaxCh[i].Step = FAX_CHECK_END;
}
}
else // receive a fax file
{
if(m_nTabShow == 0)
{
strcpy(m_FaxCh[i].szRecPathFile,m_firstDlg.m_strRecPath.GetBuffer(m_firstDlg.m_strRecPath.GetLength()));
strcat(m_FaxCh[i].szRecPathFile,"\\");
if(m_bMultiFax)
{
strTemp.Format("%s",m_firstDlg.m_strRecFile);
strTemp.TrimRight();
str = strTemp.Right(5);
m = str.GetLength();
n = str.Find('.');
str.Format("%d",i);
n = strTemp.GetLength() - m + n;
for(int jj=0;jj<str.GetLength();jj++)
strTemp.Insert(n+jj,str[jj]);
strcat(m_FaxCh[i].szRecPathFile,strTemp.GetBuffer(strTemp.GetLength()));
}
else
strcat(m_FaxCh[i].szRecPathFile,m_firstDlg.m_strRecFile.GetBuffer(m_firstDlg.m_strRecFile.GetLength()));
//myCreateFileName(m_FaxCh[i].fnRcvFaxFile,
}
else if(m_nTabShow == 2)
{
strcpy(m_FaxCh[i].szRecPathFile, m_thirdDlg.m_strRecPath.GetBuffer(m_thirdDlg.m_strRecPath.GetLength()));
strcat(m_FaxCh[i].szRecPathFile,"\\");
if(m_bMultiFax)
{
strTemp.Format("%s",m_thirdDlg.m_strRecFile);
strTemp.TrimRight();
str = strTemp.Right(5);
m = str.GetLength();
n = str.Find('.');
str.Format("%d",i);
n = strTemp.GetLength() - m + n;
for(int jj=0;jj<str.GetLength();jj++)
strTemp.Insert(n+jj,str[jj]);
strcat(m_FaxCh[i].szRecPathFile,strTemp.GetBuffer(strTemp.GetLength()));
}
else
strcat(m_FaxCh[i].szRecPathFile,m_thirdDlg.m_strRecFile.GetBuffer(m_thirdDlg.m_strRecFile.GetLength()));
//myCreateFileName(m_FaxCh[i].fnRcvFaxFile,
}
if( SsmFaxStartReceive(i, m_FaxCh[i].szRecPathFile) == -1 ) //start receiving fax file
{
SsmGetLastErrMsg(m_FaxCh[i].pChErrMsg);
m_FaxCh[i].Step = FAX_IDLE;
}
else
m_FaxCh[i].Step = FAX_CHECK_END;
}
break;
case FAX_CHECK_END:
_itoa(SsmFaxGetPages(i), m_FaxCh[i].Page, 10);
SsmFaxGetID(i, m_FaxCh[i].GetID);
if( m_FaxCh[i].OffLine ) // remote hangup
{
SsmFaxStop(i);
m_FaxCh[i].Step = FAX_CHECK_STOP;
}
else
{
m_FaxCh[i].ucCheckEnd = SsmFaxCheckEnd(i);
switch( m_FaxCh[i].ucCheckEnd )
{
case 1 :
WriteLog("successful fax send");
m_FaxCh[i].Step = FAX_CHECK_STOP;
break;
case 2 :
if(SsmFaxGetPages(i) > 0 || SsmFaxGetSendBytes(i) >0)
{
WriteLog("fax send: failed operation at page phrase ");
// m_FaxCh[i].Step = FAX_CHECK_STOP;
}
else
{
if(m_FaxCh[i].Fax_Answered == 1)
{
WriteLog("fas send: failed operation at handshaking phrase ");;
}
else if(m_FaxCh[i].Fax_Answered == 0)
{
WriteLog("fax send: timeout because remote end did not press 'start' key ");
}
}
m_FaxCh[i].Step = FAX_CHECK_STOP;
break;
case 0 :
switch( SsmGetToneAnalyzeResult(m_FaxCh[i].nTrunkch) )
{
case 2 :
strcpy(m_FaxCh[i].pChErrMsg , "busy tone");
SsmFaxStop(i);
m_FaxCh[i].Step = FAX_CHECK_STOP;
break;
case 8 :
m_FaxCh[i].Fax_Answered = 1;
break;
default :
break;
}
break;
case 3 :
switch( SsmGetToneAnalyzeResult(m_FaxCh[i].nTrunkch) )
{
case 2 :
strcpy(m_FaxCh[i].pChErrMsg , "OK");
SsmFaxStop(i);
m_FaxCh[i].Step = FAX_CHECK_STOP;
default :
break;
}
break;
case -1 :
SsmGetLastErrMsg( m_FaxCh[i].pChErrMsg );
m_FaxCh[i].Step = FAX_IDLE;
break;
}
}
break;
case FAX_CHECK_STOP:
m_FaxCh[i].Step = FAX_IDLE;
break;
}
}
}
void CAtrkFaxDlg::myUpdateChInfoList()
{
char newstat[250], oldstat[250];
char statemsg[100];
int nListIndex = 0;
for(int i=0; i<m_nTotalCh; i++)
{
if( SsmGetChType(i) != FAX_CH
&& SsmGetChType(i) != SOFTFAX_CH) continue;
if(m_AutoFaxMode == 0) strcpy(newstat,"ordinary");
else strcpy(newstat,"fine");
m_FaxChList.GetItemText( nListIndex, 1, oldstat, 29 );
if(strcmp(newstat,oldstat) != 0)
m_FaxChList.SetItemText( nListIndex, 1, newstat );
switch( m_FaxCh[i].Step )
{
case FAX_IDLE: strcpy(newstat, "idle"); break;
case FAX_START: strcpy(newstat, "start fax"); break;
case FAX_CHECK_STOP: strcpy(newstat, "stop fax"); break;
case FAX_CHECK_END:
if(m_FaxCh[i].Direction == 0) strcpy(newstat, "sending:");
else strcpy(newstat, "receiving:");
if( SsmFaxGetChStateMsg(i , statemsg) != -1) strcat( newstat,statemsg);
break;
}
m_FaxChList.GetItemText(nListIndex, 2, oldstat, 29);
if(strcmp(newstat,oldstat) != 0)
m_FaxChList.SetItemText( nListIndex, 2, newstat);
m_FaxChList.GetItemText(nListIndex, 3, oldstat, 29);
if(strcmp(m_FaxCh[i].Page,oldstat) != 0)
m_FaxChList.SetItemText( nListIndex, 3, m_FaxCh[i].Page);
m_FaxChList.GetItemText(nListIndex, 4, oldstat, 50);
if(strcmp(m_FaxCh[i].GetID,oldstat) != 0)
m_FaxChList.SetItemText(nListIndex, 4, m_FaxCh[i].GetID);
if(m_FaxCh[i].Step != FAX_IDLE)
{
if(m_FaxCh[i].Direction ==0)
{
if(m_FaxCh[i].Mode == 0)
strcpy(newstat, m_FaxCh[i].szSendPathFile);
else if(m_FaxCh[i].Mode == 1)
strcpy(newstat , m_strManSendFaxFile);
}
else
strcpy(newstat,m_FaxCh[i].szRecPathFile);
m_FaxChList.GetItemText( nListIndex, 5, oldstat, 250 ); //display phone number
if(strcmp(newstat,oldstat) != 0)
m_FaxChList.SetItemText( nListIndex, 5, newstat );
}
m_FaxChList.GetItemText( nListIndex, 6, oldstat, 60 ); //display phone number
if(strcmp(m_FaxCh[i].pChErrMsg,oldstat) != 0)
m_FaxChList.SetItemText( nListIndex, 6, m_FaxCh[i].pChErrMsg );
m_FaxChList.GetItemText( nListIndex, 7, oldstat, 60 ); //display phone number
sprintf(newstat,"%d",m_FaxCh[i].ucCheckEnd);
if(strcmp(newstat,oldstat) != 0)
m_FaxChList.SetItemText( nListIndex, 7, newstat );
nListIndex++;
}
}
void CAtrkFaxDlg::myUpDateATrunkChListCtrl()
{
char newstat[250], oldstat[100];
int nListIndex = 0;
for(int i=0; i<m_nTotalCh; i++)
{
if( !m_ATrkCh[i].EnCalled ) continue;
switch(SsmGetChState(i))
{
case -1: wsprintf(newstat,"-1"); break;
case S_CALL_STANDBY: wsprintf(newstat,"idle"); break;
case S_CALL_PICKUPED: wsprintf(newstat,"offhook"); break;
case S_CALL_RINGING: wsprintf(newstat,"ringing"); break;
case S_CALL_TALKING: wsprintf(newstat,"talking"); break;
case S_CALL_ANALOG_WAITDIALTONE: wsprintf(newstat,"WtDT"); break;
case S_CALL_ANALOG_TXPHONUM: wsprintf(newstat,"Dl.."); break;
case S_CALL_ANALOG_WAITDIALRESULT: wsprintf(newstat,"WtDl"); break;
case S_CALL_PENDING: wsprintf(newstat,"pending"); break;
case S_CALL_OFFLINE: wsprintf(newstat,"offline"); break;
case S_CALL_WAIT_REMOTE_PICKUP: wsprintf(newstat,"ringback"); break;
case S_CALL_UNAVAILABLE: wsprintf(newstat,"unavailable"); break;
case S_CALL_LOCKED: wsprintf(newstat,"call locked"); break;
case S_CALL_LocalBlock: wsprintf(newstat,"local blocked"); break;
case S_CALL_RemoteBlock: wsprintf(newstat,"remote blocked"); break;
case S_CALL_Ss1InWaitPhoNum : wsprintf(newstat,"wait calledid"); break;
case S_CALL_Ss1InWaitFwdStop : wsprintf(newstat,"wait forward signal to be stopped"); break;
case S_CALL_Ss1InWaitCallerID: wsprintf(newstat,"receive callerid"); break;
case S_CALL_Ss1InWaitKD : wsprintf(newstat,"receive KD"); break;
case S_CALL_Ss1InWaitKDStop : wsprintf(newstat,"wait KD to be stopped"); break;
case S_CALL_SS1_SAYIDLE : wsprintf(newstat,"send free indication"); break;
case S_CALL_SS1WaitIdleCAS : wsprintf(newstat,"wait free indication"); break;
case S_CALL_SS1PhoNumHoldup : wsprintf(newstat,"S_CALL_SS1PhoNumHoldup"); break;
case S_CALL_Ss1InWaitStopSendA3p: wsprintf(newstat,"S_CALL_Ss1InWaitStopSendA3p"); break;
case S_CALL_Ss1OutWaitBwdAck : wsprintf(newstat,"wait backward seizure ack"); break;
case S_CALL_Ss1OutTxPhoNum : wsprintf(newstat,"send calledid"); break;
case S_CALL_Ss1OutWaitAppendPhoNum: wsprintf(newstat,"incomplete phone number"); break;
case S_CALL_Ss1OutTxCallerID : wsprintf(newstat,"send callerid"); break;
case S_CALL_Ss1OutWaitKB : wsprintf(newstat,"wait KB"); break;
case S_FAX_ROUND : wsprintf(newstat,"in state transition"); break;
case S_FAX_PhaseA : wsprintf(newstat,"call setup"); break;
case S_FAX_PhaseB : wsprintf(newstat,"premessage processing"); break;
case S_FAX_SendDCS : wsprintf(newstat,"send DCS"); break;
case S_FAX_Train : wsprintf(newstat,"transport training "); break;
case S_FAX_PhaseC : wsprintf(newstat,"message transport"); break;
case S_FAX_PhaseD : wsprintf(newstat,"post-message processing"); break;
case S_FAX_NextPage: wsprintf(newstat,"transport nex page"); break;
case S_FAX_AllSent : wsprintf(newstat,"transport complete"); break;
case S_FAX_PhaseE : wsprintf(newstat,"call release"); break;
case S_FAX_Reset : wsprintf(newstat,"reset modem"); break;
case S_FAX_Init : wsprintf(newstat,"initialize modem"); break;
case S_FAX_RcvDCS : wsprintf(newstat,"receive DCS"); break;
case S_FAX_SendFTT : wsprintf(newstat,"send FTT"); break;
case S_FAX_SendCFR : wsprintf(newstat,"send CFR"); break;
case S_TUP_WaitPcmReset: wsprintf(newstat,"circuit reset"); break;
case S_TUP_WaitSAM: wsprintf(newstat,"wait SAM"); break;
case S_TUP_WaitGSM: wsprintf(newstat,"wait GSM"); break;
case S_TUP_WaitCLF: wsprintf(newstat,"wait CLF"); break;
case S_TUP_WaitPrefix: wsprintf(newstat,"receive prefix"); break;
case S_TUP_WaitDialAnswer: wsprintf(newstat,"wait answer"); break;
case S_TUP_WaitRLG: wsprintf(newstat,"wait RLG"); break;
case S_ISDN_OUT_WAIT_NET_RESPONSE: wsprintf(newstat, "wait network response"); break;
case S_ISDN_OUT_PLS_APPEND_NO: wsprintf(newstat, "wait phone append"); break;
case S_ISDN_IN_CHK_CALL_IN: wsprintf(newstat, "inbound call detected"); break;
case S_ISDN_IN_RCVING_NO: wsprintf(newstat,"receiving number"); break;
case S_ISDN_IN_WAIT_TALK: wsprintf(newstat, "ready for talking"); break;
case S_ISDN_OUT_WAIT_ALERT: wsprintf(newstat, "wait alert signal"); break;
case S_ISDN_CALL_BEGIN: wsprintf(newstat, "call begin"); break;
case S_ISDN_WAIT_HUANGUP: wsprintf(newstat, "wait release"); break;
case S_CALL_SENDRING: wsprintf(newstat, "send ringing"); break;
default: wsprintf(newstat,"S=%d",i); break;
}
m_TrkChList.GetItemText( nListIndex, 1, oldstat, 29 ) ;
if(strcmp(newstat, oldstat) != 0)
m_TrkChList.SetItemText( nListIndex, 1, newstat);
switch( m_ATrkCh[i].Step )
{
case TRK_IDLE: strcpy(newstat, "idle"); break ;
case TRK_WAIT_CONNECT: strcpy(newstat, "wait conn"); break ;
case TRK_PLAY_SELECT: strcpy(newstat, "paly prompt 1"); break ;
case TRK_CHECK_PLAY_SELECT: strcpy(newstat, "play prompt 1"); break ;
case TRK_CHECK_PLAY_START: strcpy(newstat, "play prompt 2"); break ;
case TRK_CHECK_FAX_PROCESS: strcpy(newstat, "talking..."); break ;
case TRK_HANGUP: strcpy(newstat, "onhook"); break ;
case TRK_CHECK_AUTODIAL: strcpy(newstat, "dialing"); break ;
case TRK_PLAY_MANUAL_HINT: strcpy(newstat, "play prompt"); break ;
case TRK_CHECK_MANUAL_PLAY_START: strcpy(newstat, "check whehter playback is complete"); break ;
case TRK_MANUAL_FAX_START: strcpy(newstat, "start fax"); break ;
default: strcpy(newstat, "undefined"); break ;
}
m_TrkChList.GetItemText( nListIndex, 2, oldstat, 29 ) ;
if(strcmp(newstat, oldstat) != 0)
m_TrkChList.SetItemText( nListIndex, 2, newstat);
strcpy(newstat,"");
SsmGetDtmfStr( i , newstat);
m_TrkChList.GetItemText( nListIndex, 3, oldstat, 29 );
if(strcmp(newstat, oldstat) != 0)
m_TrkChList.SetItemText( nListIndex, 3, newstat);
m_TrkChList.GetItemText( nListIndex, 4, oldstat, 60 ); //display error messages occured
if(strcmp(m_ATrkCh[i].pChErrMsg, oldstat) != 0)
m_TrkChList.SetItemText( nListIndex, 4, m_ATrkCh[i].pChErrMsg );
nListIndex++;
}
}
void CAtrkFaxDlg::OnDestroy()
{
CDialog::OnDestroy();
SsmFreeIndexData(1);
SsmFreeIndexData(2);
SsmCloseCti();
}
void CAtrkFaxDlg::OnTimer(UINT nIDEvent)
{
myScanATrunkCh(); //trunk channel processing
myScanFaxCh(); //fax channel processing
myUpDateATrunkChListCtrl(); //trunk channel information display
myUpdateChInfoList(); //fax channel information display
CDialog::OnTimer(nIDEvent);
}
void CAtrkFaxDlg::OnAppend()
{
CString str,str2;
str.Format("nothing!\n");
for( int i=0;i< m_nTotalCh;i++)
{
if( SsmGetChType(i) != FAX_CH
&& SsmGetChType(i) != SOFTFAX_CH) continue;
if( SsmFaxAppendSend(i,m_fnAppendFaxFile)==0 )
{
str2.Format("%d# channel append!\n",i);
str += str2;
}
}
MessageBox(str);
}
void CAtrkFaxDlg::OnSelfn()
{
}
void CAtrkFaxDlg::OnCheckStartPage()
{
}
void CAtrkFaxDlg::OnButtonStopFax()
{
CString str;
int n,m;
m_cmbFaxCh.GetWindowText(str);
if(str.IsEmpty())
{
MessageBox("set fax channel"," Warning",MB_OK);
return;
}
else
n = atoi(str);
m = SsmFaxStop(n);
if(m ==-1)
{
str.Format("fail to stop fax on channel %d",n);
MessageBox(str,"Fail",MB_OK);
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -