⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atrkfaxdlg.cpp

📁 基于板卡的传真发送接收群发语音留言等的演示程序。
💻 CPP
📖 第 1 页 / 共 4 页
字号:
				{
					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("发送传真成功");
					m_FaxCh[i].Step = FAX_CHECK_STOP;
					break;
				case 2 :
					if(SsmFaxGetPages(i) > 0 || SsmFaxGetSendBytes(i) >0)
					{
						WriteLog("发送传真失败 : 传真在页面阶段失败");
						m_FaxCh[i].Step = FAX_CHECK_STOP;
					}
					else
					{
						if(m_FaxCh[i].Fax_Answered == 1)
						{
							WriteLog("发送传真失败 : 传真在握手阶段失败");;
						}
						else if(m_FaxCh[i].Fax_Answered == 0)
						{
							WriteLog("发送传真失败 : 对方未按\"开始\"键,发送超时");
						}
					}
					break;
				case 0 :
					switch( SsmGetToneAnalyzeResult(m_FaxCh[i].nTrunkch) )
					{
					case 2 :
						strcpy(m_FaxCh[i].pChErrMsg , "忙音");
						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,"普通");
		else                   strcpy(newstat,"精细");
		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, "空闲");			break;
		case FAX_START:					strcpy(newstat, "开始传真");		break;
		case FAX_CHECK_STOP:			strcpy(newstat, "停止传真");		break;
		case FAX_CHECK_END:
			if(m_FaxCh[i].Direction == 0) strcpy(newstat, "正在发送:");
			else                        strcpy(newstat, "正在接收:");

			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,"空闲");		break;
		case S_CALL_PICKUPED:				wsprintf(newstat,"摘机");		break;
		case S_CALL_RINGING:				wsprintf(newstat,"振铃");		break;
		case S_CALL_TALKING:				wsprintf(newstat,"通话");		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,"挂起");		break;
		case S_CALL_OFFLINE:				wsprintf(newstat,"断线");		break;
		case S_CALL_WAIT_REMOTE_PICKUP:		wsprintf(newstat,"回铃");		break;
		case S_CALL_UNAVAILABLE:			wsprintf(newstat,"不可用");		break;
		case S_CALL_LOCKED:					wsprintf(newstat,"呼出保留");	break;

		case S_CALL_LocalBlock:				wsprintf(newstat,"本地闭塞");	break;
		case S_CALL_RemoteBlock:			wsprintf(newstat,"对端闭塞");	break;

		case S_CALL_Ss1InWaitPhoNum  :			wsprintf(newstat,"接收被叫");	break;
		case S_CALL_Ss1InWaitFwdStop :			wsprintf(newstat,"等待前向");	break;
		case S_CALL_Ss1InWaitCallerID:			wsprintf(newstat,"接收主叫");	break;
		case S_CALL_Ss1InWaitKD      :			wsprintf(newstat,"接收KD");	break;
		case S_CALL_Ss1InWaitKDStop  :			wsprintf(newstat,"等KD停发");	break;
		case S_CALL_SS1_SAYIDLE      :			wsprintf(newstat,"发送示闲");	break;
		case S_CALL_SS1WaitIdleCAS   :			wsprintf(newstat,"等待示闲");	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,"等待后向占用证实信令”");	break;
		case S_CALL_Ss1OutTxPhoNum        :	wsprintf(newstat,"发送被叫");	break;
		case S_CALL_Ss1OutWaitAppendPhoNum:	wsprintf(newstat,"号码不足");	break;
		case S_CALL_Ss1OutTxCallerID      :	wsprintf(newstat,"发送主叫");	break;
		case S_CALL_Ss1OutWaitKB          :	wsprintf(newstat,"等待KB");	break;

		case S_FAX_ROUND   :	wsprintf(newstat,"状态转移过程中");	break;
		case S_FAX_PhaseA  :	wsprintf(newstat,"呼叫建立");	break;
		case S_FAX_PhaseB  :	wsprintf(newstat,"报文前处理");	break;
		case S_FAX_SendDCS :	wsprintf(newstat,"发送DCS信号");	break;
		case S_FAX_Train   :	wsprintf(newstat,"传输训练");	break;
		case S_FAX_PhaseC  :	wsprintf(newstat,"报文传输");	break;
		case S_FAX_PhaseD  :	wsprintf(newstat,"报文后处理");	break;
		case S_FAX_NextPage:	wsprintf(newstat,"传输下页");	break;
		case S_FAX_AllSent :	wsprintf(newstat,"传输结束");	break;
		case S_FAX_PhaseE  :	wsprintf(newstat,"呼叫释放");	break;
		case S_FAX_Reset   :	wsprintf(newstat,"复位猫");	break;
		case S_FAX_Init    :	wsprintf(newstat,"初始化猫");	break;
		case S_FAX_RcvDCS  :	wsprintf(newstat,"接收DCS");	break;
		case S_FAX_SendFTT :	wsprintf(newstat,"发送训练失败信号FTT");	break;
		case S_FAX_SendCFR :	wsprintf(newstat,"发送证实信号CFR");	break;

		case S_TUP_WaitPcmReset:			wsprintf(newstat,"电路复原");	break;
		case S_TUP_WaitSAM:					wsprintf(newstat,"等待SAM");	break;
		case S_TUP_WaitGSM:					wsprintf(newstat,"等待GSM");	break;
		case S_TUP_WaitCLF:					wsprintf(newstat,"等待CLF");	break;
		case S_TUP_WaitPrefix:				wsprintf(newstat,"接收局号");	break;
		case S_TUP_WaitDialAnswer:			wsprintf(newstat,"等待应答");	break;
		case S_TUP_WaitRLG:					wsprintf(newstat,"等待RLG");	break;

		case S_ISDN_OUT_WAIT_NET_RESPONSE:	wsprintf(newstat, "等待网络响应"); break;
		case S_ISDN_OUT_PLS_APPEND_NO:		wsprintf(newstat, "等待追加号码"); break;
		case S_ISDN_IN_CHK_CALL_IN:			wsprintf(newstat, "检测到呼入");	break;
		case S_ISDN_IN_RCVING_NO:			wsprintf(newstat,"正在接收号码");	break;
		case S_ISDN_IN_WAIT_TALK:			wsprintf(newstat, "准备进入通话");	break;
		case S_ISDN_OUT_WAIT_ALERT:			wsprintf(newstat, "等待提醒信号");	break;
		case S_ISDN_CALL_BEGIN:				wsprintf(newstat, "呼叫起始");		break;
		case S_ISDN_WAIT_HUANGUP:			wsprintf(newstat, "等待释放");		break;

		case S_CALL_SENDRING:				wsprintf(newstat, "发送振铃");		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, "空闲");		break ;
		case TRK_WAIT_CONNECT:		    strcpy(newstat,	"等待连接");	break ;
		case TRK_PLAY_SELECT:			strcpy(newstat, "播放提示语1");	break ;
		case TRK_CHECK_PLAY_SELECT:		strcpy(newstat, "播放提示语1");	break ;
		case TRK_CHECK_PLAY_START:		strcpy(newstat, "播放提示语2");	break ;
		case TRK_CHECK_FAX_PROCESS:		strcpy(newstat, "通话...");		break ;
		case TRK_HANGUP:				strcpy(newstat, "挂机");		break ;
		case TRK_CHECK_AUTODIAL:		strcpy(newstat, "正在拨号");		break ;	
		case TRK_PLAY_MANUAL_HINT:		strcpy(newstat, "播放提示语");		break ;	
		case TRK_CHECK_MANUAL_PLAY_START: strcpy(newstat, "检测播放音是否结束");		break ; 
		case TRK_MANUAL_FAX_START:		strcpy(newstat, "传真开始");		break ;	
		default:						strcpy(newstat, "未定义");		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();			//处理外线通道
	myScanFaxCh();				//处理传真通道

	myUpDateATrunkChListCtrl();	//处理外线通道显示
	myUpdateChInfoList();		//处理传真通道显示

	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() 
{
/*	CFileDialog cf(1, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Fax File(*.fax)|*.fax|Tif File(*.tif)|*.tif|Tiff File(*.tiff)|*.tiff|All File(*.*)|*.*|",NULL);
	char path[200];
	strcpy(path,m_szCurPath);
	strcat(path,"\\FaxFile");
	cf.m_ofn.lpstrInitialDir = path;
	if(cf.DoModal() == IDOK)
	{
		strcpy(m_fnAppendFaxFile, cf.GetFileName());
		SetDlgItemText(IDC_APPENDFN,m_fnAppendFaxFile);
		strcpy(m_fnAppendFaxFile, cf.GetPathName());
	}*/
}

void CAtrkFaxDlg::OnCheckStartPage() 
{
	/*UpdateData();
	CWnd *p=GetDlgItem(IDC_EDIT_START_PAGE);
	p->EnableWindow(m_bStartPage);
	p=GetDlgItem(IDC_EDIT_END_PAGE);
	p->EnableWindow(m_bStartPage);*/
}

/*void CAtrkFaxDlg::GetStartPage()
{
	CString str ;
	GetDlgItemText(IDC_EDIT_START_PAGE,str);
	str.TrimLeft();
	str.TrimRight();
	if (str.IsEmpty())
		m_nStartPage = 0;
	else
		m_nStartPage = atoi(str); 
	
	GetDlgItemText(IDC_EDIT_END_PAGE,str);
	str.TrimLeft();
	str.TrimRight();
	if (str.IsEmpty())
		m_nEndPage = 0;
	else
		m_nEndPage = atoi(str); 
}
*/

void CAtrkFaxDlg::OnButtonStopFax() 
{
	CString str;
	int n,m;
	m_cmbFaxCh.GetWindowText(str);
	if(str.IsEmpty())
	{
		MessageBox("设置传真通道号"," 注意",MB_OK);
		return;
	}
	else
		n = atoi(str);
	m = SsmFaxStop(n);
	if(m ==-1)
	{
		str.Format("通道%d传真停止失败",n);
		MessageBox(str,"失败",MB_OK);
	}
	else
	{	
		str.Format("通道%d传真支持成功",n);
		MessageBox(str,"成功",MB_OK);
	}
	//SsmPickup(2);
	//SsmPickup(3);
}


void CAtrkFaxDlg::OnButton1() 
{
/*	CString str;
	static int		n = 0;
	UpdateData();
	m_cmbCurCh.GetWindowText(str);
	if(str.IsEmpty())
	{
		MessageBox("请选择通道","注意",MB_OK);
		return;
	}
	n = atoi(str);
	if(m_strRecordFile.IsEmpty())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -