TAPICaseView.cpp
上传用户:fstfhk1234
上传日期:2007-06-12
资源大小:67k
文件大小:12k
- // TAPICaseView.cpp : implementation of the CTAPICaseView class
- //
- #include "stdafx.h"
- #include "TAPICase.h"
- #include "global.h"
- #include "TAPI.h"
- #include "TAPILine.h"
- #include "TAPICaseDoc.h"
- #include "TAPICaseView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern CTAPILine* myTAPILine;//引用外部变量
- /////////////////////////////////////////////////////////////////////////////
- // CTAPICaseView
- IMPLEMENT_DYNCREATE(CTAPICaseView, CFormView)
- BEGIN_MESSAGE_MAP(CTAPICaseView, CFormView)
- //{{AFX_MSG_MAP(CTAPICaseView)
- ON_BN_CLICKED(IDC_DIAL, OnDial)
- ON_BN_CLICKED(IDC_DISCONNECTED, OnDisconnected)
- ON_BN_CLICKED(IDC_LINECONFIGURE, OnLineconfigure)
- ON_BN_CLICKED(IDC_DIALPROPERTY, OnDialproperty)
- ON_CBN_SELCHANGE(IDC_LINE, OnSelchangeLine)
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CTAPICaseView construction/destruction
- CTAPICaseView::CTAPICaseView()
- : CFormView(CTAPICaseView::IDD)
- {
- //{{AFX_DATA_INIT(CTAPICaseView)
- m_strLine = _T("");
- m_strPhoneNumber = _T("1111111");
- //}}AFX_DATA_INIT
- // TODO: add construction code here
- }
- CTAPICaseView::~CTAPICaseView()
- {
- }
- void CTAPICaseView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CTAPICaseView)
- DDX_Control(pDX, IDC_PROGRESS, m_ctrlProgress);
- DDX_Control(pDX, IDC_DIALICON, m_ctrlIcon);
- DDX_Control(pDX, IDC_DIAL, m_ctrlDial);
- DDX_Control(pDX, IDC_DISCONNECTED, m_ctrlDisconnect);
- DDX_Control(pDX, IDC_LINE, m_ctrlLine);
- DDX_Control(pDX, IDC_LIST1, m_ctrlListBox);
- DDX_CBString(pDX, IDC_LINE, m_strLine);
- DDX_Text(pDX, IDC_PHONENUMBER, m_strPhoneNumber);
- //}}AFX_DATA_MAP
- }
- BOOL CTAPICaseView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CFormView::PreCreateWindow(cs);
- }
- //对线路进行初始化
- void CTAPICaseView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
- GetParentFrame()->RecalcLayout();
- ResizeParentToFit();
- DWORD line;
- BOOL bSuccess;
- char strItem[100];
- //开始时候,挂断按钮无效
- m_ctrlDisconnect.EnableWindow(FALSE);
- myTAPILine = new CTAPILine;
- //将要协商的版本:1.3到3.0
- myTAPILine->SetLowAPI(0x00010003);
- myTAPILine->SetHighAPI(0x00030000);
-
- //在列表框中设置返回信息
- m_ctrlListBox.AddString(_T("TAPI版本协商"));
-
- //为每条线路进行初始化和协商
- bSuccess = myTAPILine->Create();
- //如果成功,列出所有的有效地TAPI线路
- if(bSuccess)
- {
- for(line = 0; line < myTAPILine->GetNumLines(); line++)
- {
- myTAPILine->SetCurrentLineID(line);
- if(myTAPILine->GetNegoAPIVersion())
- {
- sprintf(strItem, "%d", line);
- m_ctrlLine.AddString((const char*)strItem);
- }
- }
- //设置当前的选择为第一条线路
- m_ctrlLine.SetCurSel(0);
- OnSelchangeLine();
- }
- else
- {
- //返回用户信息,但不支持TAPI 2.1
- m_ctrlListBox.ResetContent();
- m_ctrlListBox.AddString(myTAPILine->ErrorString(myTAPILine->GetLasterror()));
-
-
- m_ctrlListBox.AddString("试探TaPI1.3 - 1.4");
- myTAPILine->SetLowAPI(0x00010003);
- myTAPILine->SetHighAPI(0x00010004);
- bSuccess = myTAPILine->Create();
- if(bSuccess)
- {
- for(line = 0; line < myTAPILine->GetNumLines(); line++)
- {
- myTAPILine->SetCurrentLineID(line);
- if(myTAPILine->GetNegoAPIVersion())
- {
- sprintf(strItem, "%d", line);
- m_ctrlLine.AddString((const char*)strItem);
- }
- }
- OnSelchangeLine();
- }
- else
- m_ctrlListBox.AddString("致命的错误, TAPI版本协商失败");
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CTAPICaseView printing
- BOOL CTAPICaseView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CTAPICaseView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CTAPICaseView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- void CTAPICaseView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
- {
- // TODO: add customized printing code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CTAPICaseView diagnostics
- #ifdef _DEBUG
- void CTAPICaseView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void CTAPICaseView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- CTAPICaseDoc* CTAPICaseView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTAPICaseDoc)));
- return (CTAPICaseDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CTAPICaseView message handlers
- //"拨号"按钮的响应函数
- void CTAPICaseView::OnDial()
- {
- // TODO: Add your control notification handler code here
- BOOL bSuccess;
- CString strTemp;
- UpdateData(TRUE);
- m_ctrlDial.EnableWindow(FALSE);
- m_ctrlProgress.ResetContent();
-
- //提示用户进度
- strTemp.Format("打开线路: #%dn", myTAPILine->GetCurrentLineID());
- m_ctrlProgress.AddString(strTemp);
- UpdateData(FALSE);
- bSuccess = myTAPILine->OpenLine();
- if(!bSuccess)
- {
- strTemp = "TAPI错误n" + myTAPILine->ErrorString(myTAPILine->GetLasterror());
- ::MessageBox(NULL, strTemp, "错误提示", MB_OK);
- m_ctrlDial.EnableWindow(TRUE);
- return;
- }
-
- strTemp.Format("正准备呼叫: %sn", m_strPhoneNumber);
- m_ctrlProgress.AddString(strTemp);
- UpdateData(FALSE);
- //调用呼叫函数进行呼叫
- bSuccess = myTAPILine->MakeCallAsynch(m_strPhoneNumber);
- if(!bSuccess)
- {
- myTAPILine->CloseLine();
- strTemp = "TAPI错误n" + myTAPILine->ErrorString(myTAPILine->GetLasterror());
- ::MessageBox(NULL, strTemp, "错误提示", MB_OK);
- m_ctrlDial.EnableWindow(TRUE);
- return;
- }
- }
- //"挂断"按钮的响应函数
- void CTAPICaseView::OnDisconnected()
- {
- // TODO: Add your control notification handler code here
- BOOL bSuccess;
- m_ctrlProgress.ResetContent();
- m_ctrlProgress.AddString("请求挂断呼叫");
- bSuccess = myTAPILine->DropCallAsynch();
- if(!bSuccess)
- {
- ::MessageBox(NULL, myTAPILine->ErrorString(myTAPILine->GetLasterror()), "错误提示", MB_OK);
- }
- }
- //"线路配置"按钮的响应函数
- void CTAPICaseView::OnLineconfigure()
- {
- // TODO: Add your control notification handler code here
- BOOL bSuccess;
- bSuccess = myTAPILine->ConfigDialog(NULL);
- if(!bSuccess)
- ::MessageBox(NULL, myTAPILine->ErrorString(myTAPILine->GetLasterror()), "错误提示", MB_OK);
- }
- //"拨号属性"按钮的响应函数
- void CTAPICaseView::OnDialproperty()
- {
- // TODO: Add your control notification handler code here
- BOOL bSuccess;
- UpdateData(TRUE);
- bSuccess = myTAPILine->DialoingPropertiesDialog(NULL, m_strPhoneNumber);
- if(!bSuccess)
- ::MessageBox(NULL, myTAPILine->ErrorString(myTAPILine->GetLasterror()), "错误提示", MB_OK);
- }
- //"线路"组合框焦点改变的响应函数
- void CTAPICaseView::OnSelchangeLine()
- {
- // TODO: Add your control notification handler code here
- //清空信息框
- //int i;
- char buffer[100];
- CString strTemp;
- m_ctrlListBox.ResetContent();
- UpdateData(TRUE);
-
- sprintf(buffer, "%d", m_ctrlLine.GetCurSel());
- m_strLine = (const char*)buffer;
- if( m_strLine != "")
- {
- //类的信息转换为当前的线路
- myTAPILine->SetCurrentLineID(atol(m_strLine));
-
- //在列表框中显示当前线路的信息
- strTemp.Format("TAPI线路: #%d", myTAPILine->GetCurrentLineID());
- m_ctrlListBox.AddString(strTemp);
- strTemp.Format("TAPI线路名称: %s", myTAPILine->GetLineName());
- m_ctrlListBox.AddString(strTemp);
- strTemp.Format("TAPI服务提供商名称: %s", myTAPILine->GetProviderInfo());
- m_ctrlListBox.AddString(strTemp);
- strTemp.Format("TAPI转换信息: %s", myTAPILine->GetSwitchInfo());
- m_ctrlListBox.AddString(strTemp);
- strTemp.Format("固定的线路标识: %d", myTAPILine->GetPermanentLineID());
- m_ctrlListBox.AddString(strTemp);
- switch(myTAPILine->GetStringFormat())
- {
- case STRINGFORMAT_ASCII:
- m_ctrlListBox.AddString("字符串格式: STRINGFORMAT_ASCII");
- break;
- case STRINGFORMAT_DBCS:
- m_ctrlListBox.AddString("字符串格式: STRINGFORMAT_DBCS");
- break;
- case STRINGFORMAT_UNICODE:
- m_ctrlListBox.AddString("字符串格式: STRINGFORMAT_UNICODe");
- break;
- case STRINGFORMAT_BINARY:
- m_ctrlListBox.AddString("字符串格式: STRINGFORMAT_BINARY");
- break;
- }
-
- strTemp.Format("与本线路相关联的地址数目: %d", myTAPILine->GetNumAddress());
- m_ctrlListBox.AddString(strTemp);
-
- strTemp.Format("最大数据传输率: %d", myTAPILine->GetmaxDataRate());
- m_ctrlListBox.AddString(strTemp);
- m_ctrlListBox.AddString("支持的载荷模式:");
-
- if(LINEBEARERMODE_VOICE & myTAPILine->GetBearerModes())
- m_ctrlListBox.AddString("tLINEBEARERMODE_VOICE");
- if(LINEBEARERMODE_SPEECH & myTAPILine->GetBearerModes())
- m_ctrlListBox.AddString("tLINEBEARERMODE_SPEECH");
- if(LINEBEARERMODE_DATA & myTAPILine->GetBearerModes())
- m_ctrlListBox.AddString("tLINEBEARERMODE_DATA");
- if(LINEBEARERMODE_ALTSPEECHDATA & myTAPILine->GetBearerModes())
- m_ctrlListBox.AddString("tLINEBEARERMODE_ALTSPEECHDATA");
- if(LINEBEARERMODE_MULTIUSE & myTAPILine->GetBearerModes())
- m_ctrlListBox.AddString("tLINEBEARERMODE_MULTIUSE");
- if(LINEBEARERMODE_NONCALLSIGNALING & myTAPILine->GetBearerModes())
- m_ctrlListBox.AddString("tLINEBEARERMODE_NONCALLSIGNALING");
-
- m_ctrlListBox.AddString("支持的地址模式");
-
- if(LINEADDRESSMODE_ADDRESSID & myTAPILine->GetAddressModes())
- m_ctrlListBox.AddString("tLINEADDRESSMODE_ADDRESSID");
- if(LINEADDRESSMODE_DIALABLEADDR & myTAPILine->GetAddressModes())
- m_ctrlListBox.AddString("tLINEADDRESSMODE_DIALABLEADDR");
- m_ctrlListBox.AddString("支持的媒体形式");
- if(LINEMEDIAMODE_ADSI & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_ADSI");
- if(LINEMEDIAMODE_AUTOMATEDVOICE & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_AUTOMATEDVOICE");
- if(LINEMEDIAMODE_DATAMODEM & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_DATAMODEM");
- if(LINEMEDIAMODE_DIGITALDATA & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_DITAIGALDATA");
- if(LINEMEDIAMODE_G3FAX & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_G3FAX");
- if(LINEMEDIAMODE_G4FAX & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_G4FAX");
- if(LINEMEDIAMODE_INTERACTIVEVOICE & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_INTERACTIVEVOICE");
- if(LINEMEDIAMODE_MIXED & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_MIXED");
- if(LINEMEDIAMODE_TDD & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_TDD");
- if(LINEMEDIAMODE_TELETEX & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_TELETEX");
- if(LINEMEDIAMODE_UNKNOWN & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_UNKNOWN");
-
- if(LINEMEDIAMODE_VIDEOTEX & myTAPILine->GetMediaModes())
- m_ctrlListBox.AddString("tLINEMEDIAMODE_VIDEOTEX");
- if(myTAPILine->GetGenerateToneMaxNumFreq() == 0)
- m_ctrlListBox.AddString("是否支持Line Tone Generation: 否");
- else
- {
- m_ctrlListBox.AddString("是否支持Line Tone Generation: 是");
- if(LINETONEMODE_BEEP & myTAPILine->GetGenerateToneModes())
- m_ctrlListBox.AddString("tLINETONEMODE_BEEP");
- if(LINETONEMODE_BILLING & myTAPILine->GetGenerateToneModes())
- m_ctrlListBox.AddString("tLINETONEMODE_BILLING");
- if(LINETONEMODE_BUSY & myTAPILine->GetGenerateToneModes())
- m_ctrlListBox.AddString("tLINETONEMODE_BUSY");
- if(LINETONEMODE_CUSTOM & myTAPILine->GetGenerateToneModes())
- m_ctrlListBox.AddString("tLINETONEMODE_CUSTOM");
- if(LINETONEMODE_RINGBACK & myTAPILine->GetGenerateToneModes())
- m_ctrlListBox.AddString("tLINETONEMODE_RINGBACK");
- }
- strTemp.Format("线路终端数目: %d", myTAPILine->GetNumTerminals());
- m_ctrlListBox.AddString(strTemp);
- }
- else
- m_ctrlListBox.AddString("没有有效的TAPI线路选中");
-
- //是否支持语音呼叫
- if(myTAPILine->GetLineSupportsVoice())
- m_ctrlDial.EnableWindow(TRUE);
- else
- m_ctrlDial.EnableWindow(FALSE);
- //绘制线路图标
- HICON hIcon;
- LONG rc;
- rc = lineGetIcon(myTAPILine->GetCurrentLineID(), "", &hIcon);
- if(hIcon != NULL)
- m_ctrlIcon.SetIcon(hIcon);
- }