📄 fax_polling_vcdlg.cpp
字号:
{
if(SsmTalkWith(nCh, m_TrkCh[nCh].nToFaxCh) == -1)
WriteLog("Fail to call SsmTalkWith");
if(*m_TrkCh[nCh].szDtmfChose == '1')
{
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nDirection = C_SEND_FAX; //send
FaxProc(E_MSG_SEND_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
// SendMessage(WM_USER+E_MSG_SEND_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
}
else
{
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nDirection = C_RECEIVE_FAX;//receive
FaxProc(E_MSG_RCV_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
// SendMessage(WM_USER+E_MSG_RCV_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
}
m_TrkCh[nCh].nStep = TRK_FAXING;
}
}
break;
//Chinese: 传真通道变为空闲事件
//English: event generated by the driver when the fax channel state turns to be idle
case E_MSG_FAX_IDLE:
{
if(SsmStopTalkWith(nCh, m_TrkCh[nCh].nToFaxCh) == -1)
WriteLog("Fail to call SsmStopTalkWith");
Hangup(nCh);
}
break;
//Chinese: 自动拨号有进展
//English: event generated by the driver when the task of auto-dialing progresses
case E_PROC_AutoDial:
{
i = lParam;
if(m_TrkCh[nCh].nStep == TRK_DIALING)
{
switch(i)
{
case DIAL_NO_DIALTONE:
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strcpy(m_TrkCh[nCh].szChErrMsg, "无拨号音");
else
strcpy(m_TrkCh[nCh].szChErrMsg, "No dial tone");
WriteLog(m_TrkCh[nCh].szChErrMsg);
Hangup(nCh);
break;
case DIAL_BUSYTONE:
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strcpy(m_TrkCh[nCh].szChErrMsg, "忙音");
else
strcpy(m_TrkCh[nCh].szChErrMsg, "Busy tone");
WriteLog(m_TrkCh[nCh].szChErrMsg);
Hangup(nCh);
break;
case DIAL_ECHO_NOVOICE:
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strcpy(m_TrkCh[nCh].szChErrMsg, "回铃后无声");
else
strcpy(m_TrkCh[nCh].szChErrMsg, "Silent after ringback tone");
WriteLog(m_TrkCh[nCh].szChErrMsg);
Hangup(nCh);
break;
case DIAL_NOVOICE:
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strcpy(m_TrkCh[nCh].szChErrMsg, "拨号后无声");
else
strcpy(m_TrkCh[nCh].szChErrMsg, "Silent after dial tone");
WriteLog(m_TrkCh[nCh].szChErrMsg);
Hangup(nCh);
break;
case DIAL_VOICEF1:
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strcpy(m_TrkCh[nCh].szChErrMsg, "对端传真机摘机,并处于发送状态");
else
strcpy(m_TrkCh[nCh].szChErrMsg, "The receiver's fax machine answers and it is in transmitting process");
WriteLog(m_TrkCh[nCh].szChErrMsg);
Hangup(nCh);
break;
case DIAL_NOANSWER:
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strcpy(m_TrkCh[nCh].szChErrMsg, "没人接听");
else
strcpy(m_TrkCh[nCh].szChErrMsg, "Nobody answers");
WriteLog(m_TrkCh[nCh].szChErrMsg);
Hangup(nCh);
break;
//Chinese: 对方已摘机(检测到话音)
//English: called party picked up (voice detected)
case DIAL_VOICE:
if(!m_TrkCh[nCh].nAutoOrNot) //send automatically
{
if(SsmTalkWith(nCh, m_TrkCh[nCh].nToFaxCh) == -1)
WriteLog("Fail to call SsmTalkWith");
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nAnswered = 0;
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nDirection = C_SEND_FAX; //send
m_TrkCh[nCh].nStep = TRK_FAXING;
FaxProc(E_MSG_SEND_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
// SendMessage(WM_USER+E_MSG_SEND_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
}
else //manual
{
//Chinese: 打开通道的抢拨开关
//English: turn on 'DTMF_stop_play' switch
if(SsmSetDtmfStopPlay(nCh, 1) == -1)
WriteLog("Fail to call SsmSetDtmfStopPlay");
if(SsmPlayIndexString(nCh, "1") == -1) //play voice 1
WriteLog("Fail to call SsmPlayIndexString");
if(SsmClearRxDtmfBuf(nCh) == -1) //clear DTMF buffer
WriteLog("Fail to call SsmClearRxDtmfBuf");
if((m_TrkCh[nCh].nTimer = SsmStartTimer(15000, 1)) == -1)
WriteLog("Fail to call SsmStartTimer");
m_TrkCh[nCh].nStep = TRK_PLAY_VOC1;
}
break;
//F2 tone detected
case DIAL_VOICEF2:
if(SsmTalkWith(nCh, m_TrkCh[nCh].nToFaxCh) == -1)
WriteLog("Fail to call SsmTalkWith");
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nAnswered = 1;
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nDirection = C_SEND_FAX; //send
m_TrkCh[i].nStep = TRK_FAXING;
FaxProc(E_MSG_SEND_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
// SendMessage(WM_USER+E_MSG_SEND_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
break;
case DIAL_INVALID_PHONUM:
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strcpy(m_TrkCh[nCh].szChErrMsg, "空号");
else
strcpy(m_TrkCh[nCh].szChErrMsg, "empty phone number");
WriteLog(m_TrkCh[nCh].szChErrMsg);
Hangup(nCh);
break;
default :
break;
}//end of switch
}//end of if
}
break;
//Chinese: 指示有传真任务之事件
//English: event generated by us when faxing task is available
case E_MSG_HAVETASK:
{
if((SsmPickup(nCh)) == -1) //pick up
{
MessageBox("SsmPickup Fail", "Fail", MB_OK);
WriteLog("Fail to call SsmPickup");
}
sprintf(szRecFile, "channel%d.pcm", nCh);
if(m_TrkCh[nCh].bRecord)
{
if(SsmRecToFile(nCh, szRecFile, -1, 0, -1, -1, 0) == -1) //record
WriteLog("Fail to call SsmRecToFile");
//Chinese: 打开录音混音器
//English: turn on record mixer
if(SsmSetRecMixer(nCh, 1, 0) == -1)
WriteLog("Fail to call SsmSetRecMixer");
}
if(SsmAutoDial(nCh, m_TrkCh[nCh].szCallNo) == -1) //auto-dialing failed
{
SsmGetLastErrMsg(m_TrkCh[nCh].szChErrMsg);
WriteLog(m_TrkCh[nCh].szChErrMsg);
Hangup(nCh);
}
else
{
m_TrkCh[nCh].nCallFlag = 1;
m_TrkCh[nCh].nStep = TRK_DIALING;
}
}
break;
}//end of switch of event
}
void CFax_Polling_VCDlg::FaxProc(UINT event, WPARAM wParam, LPARAM lParam)
{
int i; //Channel ID
int m, n;
CString strTemp, str;
char szTemp[128];
sprintf(szTemp,"new event %d,wparam %d,lparam %d",event,wParam,lParam);
OutputDebugString(szTemp);
i = wParam;
switch(event)
{
//Chinese: 开始传真任务之事件
//English: event indicating the start of faxing
case E_MSG_SEND_FAX:
{
if(m_FaxCh[i].nStep == FAX_IDLE)
{
if(m_TrkCh[m_FaxCh[i].nTrunkCh].nCallFlag == 0) //inbound call
{
m_FaxCh[i].nHowFile = m_SecondDlg.m_nHowFile;
if(m_FaxCh[i].nHowFile == 0) //single file
{
strcpy(m_FaxCh[i].szSendFile, m_SecondDlg.m_strSendFile.GetBuffer(m_SecondDlg.m_strSendFile.GetLength()));
m_SecondDlg.m_strSendFile.ReleaseBuffer();
m_FaxCh[i].nStartPage = m_SecondDlg.nStartPage;
m_FaxCh[i].nEndPage = m_SecondDlg.nEndPage;
}
else if(m_FaxCh[i].nHowFile == 1) //multi-file
{
strcpy(m_FaxCh[i].szSendPath, m_SecondDlg.m_strSendPath.GetBuffer(m_SecondDlg.m_strSendPath.GetLength()));
m_SecondDlg.m_strSendPath.ReleaseBuffer();
m_FaxCh[i].nSCTNumber = m_SecondDlg.nSCTNumber;
for(int jj = 0; jj < m_FaxCh[i].nSCTNumber; jj++)
{
*((m_FaxCh[i].pffSCT)+jj) = m_SecondDlg.ffSCT[jj];
}
}
else if(m_FaxCh[i].nHowFile == 2) //multi-file(page number is optional)
{
m_FaxCh[i].nSCTNumber = m_SecondDlg.nSCTNumber;
for(int jj = 0; jj < m_FaxCh[i].nSCTNumber; jj++)
{
*((m_FaxCh[i].pffSCT)+jj) = m_SecondDlg.ffSCT[jj];
}
}
} //end of nCallFlag
m_TrkCh[m_FaxCh[i].nTrunkCh].nCallFlag = -1;
if(m_FaxCh[i].nHowFile == 0) //single file
{
//Chinese: 未设置页码
//English: page number is not set
if(m_FaxCh[i].nStartPage == 1 && m_FaxCh[i].nEndPage == -1)
{
if(SsmFaxStartSend(i, m_FaxCh[i].szSendFile) == -1) //send
{
SsmGetLastErrMsg(m_FaxCh[i].szChErrMsg);
WriteLog(m_FaxCh[i].szChErrMsg);
m_FaxCh[i].nStep = FAX_IDLE;
strcpy(m_FaxCh[i].szRcvPathFile, "");
strcpy(m_FaxCh[i].szSendFile, "");
strcpy(m_FaxCh[i].szSendPath, "");
TrunkProc(E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
// SendMessage(WM_USER+E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
}
else
{
m_FaxCh[i].nStep = FAX_CHECK_END;
}
}
//Chinese: 设置了页码
//English: page number is set
else
{
if(SsmFaxStartSend(i, m_FaxCh[i].szSendFile) == -1) //send
{
SsmGetLastErrMsg(m_FaxCh[i].szChErrMsg);
m_FaxCh[i].nStep = FAX_IDLE;
strcpy(m_FaxCh[i].szRcvPathFile, "");
strcpy(m_FaxCh[i].szSendFile, "");
strcpy(m_FaxCh[i].szSendPath, "");
TrunkProc(E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
// SendMessage(WM_USER+E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
}
else
m_FaxCh[i].nStep = FAX_CHECK_END;
}
}
else if(m_FaxCh[i].nHowFile == 1) //multi-file
{
for(int jj = 0; jj < m_FaxCh[i].nSCTNumber; jj++)
{
if(m_FaxCh[i].szSendFile[0] != 0)
strcat(m_FaxCh[i].szSendFile, ";");
strcat(m_FaxCh[i].szSendFile, ((m_FaxCh[i].pffSCT)+jj)->szFileName);
}
if(SsmFaxSendMultiFile(i, m_FaxCh[i].szSendPath, m_FaxCh[i].szSendFile) == -1) //发送传真
{
SsmGetLastErrMsg(m_FaxCh[i].szChErrMsg);
m_FaxCh[i].nStep = FAX_IDLE;
strcpy(m_FaxCh[i].szRcvPathFile, "");
strcpy(m_FaxCh[i].szSendFile, "");
strcpy(m_FaxCh[i].szSendPath, "");
TrunkProc(E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
// SendMessage(WM_USER+E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
}
else
m_FaxCh[i].nStep = FAX_CHECK_END;
}
else if(m_FaxCh[i].nHowFile == 2) //multi-file(page number is optional)
{
for(int jj = 0; jj < m_FaxCh[i].nSCTNumber; jj++)
{
if(m_FaxCh[i].szSendFile[0] != 0)
strcat(m_FaxCh[i].szSendFile, ";");
strcat(m_FaxCh[i].szSendFile, ((m_FaxCh[i].pffSCT)+jj)->szFileName);
}
PFAX_FILE_SCT pSCT;
pSCT = m_FaxCh[i].pffSCT;
if(SsmFaxSendMultiFileEx(i, pSCT, m_FaxCh[i].nSCTNumber) == -1) //send
{
SsmGetLastErrMsg(m_FaxCh[i].szChErrMsg);
WriteLog(m_FaxCh[i].szChErrMsg);
m_FaxCh[i].nStep = FAX_IDLE;
strcpy(m_FaxCh[i].szRcvPathFile, "");
strcpy(m_FaxCh[i].szSendFile, "");
strcpy(m_FaxCh[i].szSendPath, "");
TrunkProc(E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
// SendMessage(WM_USER+E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
}
else
m_FaxCh[i].nStep = FAX_CHECK_END;
}
}
}
break;
case E_MSG_RCV_FAX:
{
if(m_FaxCh[i].nStep == FAX_IDLE)
{
strcpy(m_FaxCh[i].szRcvPathFile, m_FirstDlg.m_strRcvPath.GetBuffer(m_FirstDlg.m_strRcvPath.GetLength()));
m_FirstDlg.m_strRcvPath.ReleaseBuffer();
strcat(m_FaxCh[i].szRcvPathFile, "\\");
//Chinese: 文件名+通道号
//English: fax file name + channel ID
strTemp.Format("%s", m_FirstDlg.m_strRcvFile);
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].szRcvPathFile, strTemp.GetBuffer(strTemp.GetLength()));
strTemp.ReleaseBuffer();
if(SsmFaxStartReceive(i, m_FaxCh[i].szRcvPathFile) == -1) //receive
{
SsmGetLastErrMsg(m_FaxCh[i].szChErrMsg);
WriteLog(m_FaxCh[i].szChErrMsg);
m_FaxCh[i].nStep = FAX_IDLE;
strcpy(m_FaxCh[i].szRcvPathFile, "");
strcpy(m_FaxCh[i].szSendFile, "");
strcpy(m_FaxCh[i].szSendPath, "");
TrunkProc(E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
// SendMessage(WM_USER+E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
}
else
{
m_FaxCh[i].nStep = FAX_CHECK_END;
}
}
}
break;
case E_PROC_FaxEnd:
{
if(m_FaxCh[i].nStep == FAX_CHECK_END)
{
m_FaxCh[i].nCheckEnd = lParam;
switch(m_FaxCh[i].nCheckEnd)
{
case 1 :
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
WriteLog("传真成功");
else
WriteLog("Succeed in faxing");
m_FaxCh[i].nStep = FAX_IDLE;
strcpy(m_FaxCh[i].szRcvPathFile, "");
strcpy(m_FaxCh[i].szSendFile, "");
strcpy(m_FaxCh[i].szSendPath, "");
TrunkProc(E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
// SendMessage(WM_USER+E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
break;
case 2 :
if(SsmFaxGetPages(i) > 0 || SsmFaxGetSendBytes(i) > 0)
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
WriteLog("传真失败 : 传真在页面阶段失败");
else
WriteLog("Failed to fax : failure in page phase");
}
else
{
if(m_FaxCh[i].nAnswered == 1)
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
WriteLog("传真失败 : 传真在握手阶段失败");
else
WriteLog("Failed to fax : failure in handshake phase");
}
else if(m_FaxCh[i].nAnswered == 0)
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
WriteLog("传真失败 : 对方未按\"开始\"键,发送超时");
else
WriteLog("Failed to fax : the receiver doesn't press key 'start' or time out when waiting for key 'start'");
}
}
m_FaxCh[i].nStep = FAX_IDLE;
strcpy(m_FaxCh[i].szRcvPathFile, "");
strcpy(m_FaxCh[i].szSendFile, "");
st
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -