📄 fax_event_vcdlg.cpp
字号:
}
break;
// 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");
// 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_Event_VCDlg::FaxProc(UINT event, WPARAM wParam, LPARAM lParam)
{
int i; //Channel ID
int m, n;
CString strTemp, str;
i = wParam;
switch(event)
{
// 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_szSendPathFile);
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_szSendPath);
for(int jj = 0; jj < m_SecondDlg.m_arrSendFiles.GetSize(); jj++)
{
if(m_FaxCh[i].szSendFile[0] != 0)
strcat(m_FaxCh[i].szSendFile, ";");
strcat(m_FaxCh[i].szSendFile, m_SecondDlg.m_arrSendFiles[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
{
// 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);
TrunkProc(E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
}
else
{
m_FaxCh[i].nStep = FAX_CHECK_END;
}
}
// page number is set
else
{
if(SsmFaxStartSendEx(i, m_FaxCh[i].szSendFile, m_FaxCh[i].nStartPage, m_FaxCh[i].nEndPage) == -1) //send
{
SsmGetLastErrMsg(m_FaxCh[i].szChErrMsg);
TrunkProc(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
{
if(SsmFaxSendMultiFile(i, m_FaxCh[i].szSendPath, m_FaxCh[i].szSendFile) == -1)
{
SsmGetLastErrMsg(m_FaxCh[i].szChErrMsg);
TrunkProc(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);
TrunkProc(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);
if (m_FirstDlg.m_strRcvFile.GetLength())
strcat(m_FaxCh[i].szRcvPathFile, "\\");
// 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);
if(SsmFaxStartReceive(i, m_FaxCh[i].szRcvPathFile) == -1) //receive
{
SsmGetLastErrMsg(m_FaxCh[i].szChErrMsg);
WriteLog(m_FaxCh[i].szChErrMsg);
TrunkProc(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");
TrunkProc(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(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
WriteLog("传真失败 : 传真在握手阶段失败");
else
WriteLog("Failed to fax : failure in handshake phase");
}
TrunkProc(E_MSG_FAX_IDLE, m_FaxCh[i].nTrunkCh, i);
break;
}//end of switch
}
}
break;
case E_CHG_FaxPages:
{
_itoa(lParam, m_FaxCh[i].szPage, 10);
}
break;
// event indicating the hangup of the remote fax machine
case E_MSG_OFFLINE:
{
if(m_FaxCh[i].nStep == FAX_CHECK_END)
{
if(SsmFaxStop(i) == -1)
WriteLog("Fail to call SsmFaxStop");
m_FaxCh[i].nStep = FAX_IDLE;
strcpy(m_FaxCh[i].szRcvPathFile, "");
strcpy(m_FaxCh[i].szSendFile, "");
strcpy(m_FaxCh[i].szSendPath, "");
}
}
break;
}//end of switch of event
}
void CFax_Event_VCDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
// scan task queue
UpdateFaxChListCtrl();
UpdateTrunkChListCtrl();
CDialog::OnTimer(nIDEvent);
}
void CFax_Event_VCDlg::Hangup(int nChannel)
{
int nCh = nChannel;
int nFaxCh = m_TrkCh[nCh].nToFaxCh;
if(SsmHangup(nCh) == -1) //remote hangup
WriteLog("Fail to call SsmHangup");
if(SsmStopRecToFile(nCh) == -1) //stop recording
WriteLog("Fail to call SsmStopRecToFile");
m_TrkCh[nCh].nStep = TRK_IDLE;
strcpy(m_TrkCh[nCh].szCallerId, "");
m_TrkCh[nCh].bInUse = FALSE;
m_TrkCh[nCh].nIndex = 0;
m_TrkCh[nCh].szDtmf[0] = 0;
m_TrkCh[nCh].szDtmfChose = 0;
if (nFaxCh != -1)
{
m_TrkCh[nCh].nToFaxCh = -1;
m_FaxCh[nFaxCh].bInUse = FALSE;
m_FaxCh[nFaxCh].nStep = FAX_IDLE;
strcpy(m_FaxCh[nFaxCh].szRcvPathFile, "");
strcpy(m_FaxCh[nFaxCh].szSendFile, "");
strcpy(m_FaxCh[nFaxCh].szSendPath, "");
m_FaxCh[nFaxCh].nHowFile = -1;
m_FaxCh[nFaxCh].nSCTNumber = 0;
m_FaxCh[nFaxCh].nTrunkCh = -1;
}
}
void CFax_Event_VCDlg::SendFax(int nTrunkCh, int nFaxCh)
{
// faxing task available
if(nTrunkCh == -1 && (nTrunkCh = FindAnIdleTrunkCh()) != -1
|| nTrunkCh != -1 && m_TrkCh[nTrunkCh].bInUse == FALSE && m_TrkCh[nTrunkCh].nStep == TRK_IDLE)
{
// scan next task if idle fax channel is unavailable
if((nFaxCh == -1) && ((nFaxCh = FindAnIdleFaxCh()) == -1)
|| (nFaxCh != -1) && ((m_FaxCh[nFaxCh].nStep != FAX_IDLE) || (m_FaxCh[nFaxCh].bInUse == TRUE)))
{
MessageBox("Connot find idle fax channel");
}
// begin the task if idle fax channel is available
else
{
m_TrkCh[nTrunkCh].nLineState = SsmGetChState(nTrunkCh);
if(m_TrkCh[nTrunkCh].nLineState == -1)
WriteLog("Fail to call SsmGetChState");
else if(m_TrkCh[nTrunkCh].nLineState != S_CALL_STANDBY)
{
MessageBox("Connot find idle fax channel");
return;
}
//m_TrkCh[nTrunkCh].bLinked = TRUE;
m_TrkCh[nTrunkCh].bInUse = TRUE;
m_FaxCh[nFaxCh].bInUse = TRUE;
m_TrkCh[nTrunkCh].nToFaxCh = nFaxCh;
m_FaxCh[nFaxCh].nTrunkCh = nTrunkCh;
m_FaxCh[nFaxCh].nHowFile = m_SecondDlg.m_nHowFile;
strcpy(m_TrkCh[nTrunkCh].szCallNo, m_SecondDlg.m_strCallNo);
if(m_FaxCh[nFaxCh].nHowFile == 0) //single file
{
m_FaxCh[nFaxCh].nStartPage = m_SecondDlg.nStartPage;
m_FaxCh[nFaxCh].nEndPage = m_SecondDlg.nEndPage;
strcpy(m_FaxCh[nFaxCh].szSendFile, m_SecondDlg.m_szSendPathFile);
}
if(m_FaxCh[nFaxCh].nHowFile == 1) //multi-file
{
strcpy(m_FaxCh[nFaxCh].szSendPath, m_SecondDlg.m_szSendPath);
for(int jj = 0; jj < m_SecondDlg.m_arrSendFiles.GetSize(); jj++)
{
if(m_FaxCh[nFaxCh].szSendFile[0] != 0)
strcat(m_FaxCh[nFaxCh].szSendFile, ";");
strcat(m_FaxCh[nFaxCh].szSendFile, m_SecondDlg.m_arrSendFiles[jj]);
}
}
if(m_FaxCh[nFaxCh].nHowFile == 2) //multi-file(page number is optional)
{
m_FaxCh[nFaxCh].nSCTNumber = m_SecondDlg.nSCTNumber;
for(int jj = 0; jj < m_FaxCh[nFaxCh].nSCTNumber; jj++)
{
m_FaxCh[nFaxCh].pffSCT[jj] = m_SecondDlg.ffSCT[jj];
}
}
SendMessage(WM_USER+E_MSG_HAVETASK, nTrunkCh, nFaxCh);
}
}
}
void CFax_Event_VCDlg::InitLab()
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
{
//Chinese
strLab[0].Format("传真速率");
strLab[1].Format("传真追加与终止");
strLab[2].Format("传真通道");
strLab[3].Format("浏览");
strLab[4].Format("收发传真方式");
strLab[5].Format("中继通道");
strLab[6].Format("自动收发传真");
strLab[7].Format("提示收发传真");
strLab[8].Format("录音设置");
strLab[9].Format("中继通道");
strLab[10].Format("录音");
strLab[11].Format("传真ID设置");
strLab[12].Format("传真通道");
strLab[13].Format("设置ID号");
}
else
{ //English
strLab[0].Format("Faxing speed");
strLab[1].Format("Fax appending/stopping");
strLab[2].Format("FaxCh ID");
strLab[3].Format("Browse");
strLab[4].Format("Fax receiving/transmitting mode");
strLab[5].Format("TrunkCh ID");
strLab[6].Format("Automatic");
strLab[7].Format("Manual");
strLab[8].Format("Recording Setting");
strLab[9].Format("TrunkCh ID");
strLab[10].Format("Record");
strLab[11].Format("Fax ID Setting");
strLab[12].Format("FaxCh ID");
strLab[13].Format("ID setting");
}
SetWinTextLab(this, IDC_STATIC_FAXSPEED, strLab[0]);
SetWinTextLab(this, IDC_STATIC_APPEND_STOP, strLab[1]);
SetWinTextLab(this, IDC_STATIC_FAXCH, strLab[2]);
SetWinTextLab(this, IDC_BUTTON_APPEND_FILE, strLab[3]);
SetWinTextLab(this, IDC_STATIC_FAX_MODE, strLab[4]);
SetWinTextLab(this, IDC_STATIC_TRUNKCH, strLab[5]);
SetWinTextLab(this, IDC_RADIO_AUTO, strLab[6]);
SetWinTextLab(this, IDC_RADIO_MANUAL, strLab[7]);
SetWinTextLab(this, IDC_STATIC_RECORD, strLab[8]);
SetWinTextLab(this, IDC_STATIC_TRUNKCH_ID, strLab[9]);
SetWinTextLab(this, IDC_CHECK_RECORD, strLab[10]);
SetWinTextLab(this, IDC_STATIC_FAX_ID, strLab[11]);
SetWinTextLab(this, IDC_STATIC_FAXCH_ID, strLab[12]);
SetWinTextLab(this, IDC_STATIC_SETID, strLab[13]);
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
InitLabAbout();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAboutDlg::InitLabAbout()
{
CString strLabAbout[10];
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
{
//Chinese
strLabAbout[0].Format("Fax_Event_VC 2.0 版");
strLabAbout[1].Format("版权所有 (C) 2006");
strLabAbout[2].Format("确定");
}
else
{
//English
strLabAbout[0].Format("Fax_Event_VC V2.0");
strLabAbout[1].Format("Copyright (c) 2006 All right reserved");
strLabAbout[2].Format("OK");
}
SetWinTextLab(this, IDC_STATIC_EDITION, strLabAbout[0]);
SetWinTextLab(this, IDC_STATIC_COPYRIGHT, strLabAbout[1]);
SetWinTextLab(this, IDOK, strLabAbout[2]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -