summaryrefslogtreecommitdiffabout
path: root/T42AnnounceDlg.cpp
Unidiff
Diffstat (limited to 'T42AnnounceDlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--T42AnnounceDlg.cpp144
1 files changed, 144 insertions, 0 deletions
diff --git a/T42AnnounceDlg.cpp b/T42AnnounceDlg.cpp
new file mode 100644
index 0000000..874a898
--- a/dev/null
+++ b/T42AnnounceDlg.cpp
@@ -0,0 +1,144 @@
1// T42AnnounceDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "T42.h"
6#include "T42AnnounceDlg.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// T42AnnounceDlg dialog
16
17
18T42AnnounceDlg::T42AnnounceDlg(TalkCtlMessage& rq,CWnd* pParent /*=NULL*/)
19 : CDialog(T42AnnounceDlg::IDD, pParent), m_RQ(rq)
20{
21 //{{AFX_DATA_INIT(T42AnnounceDlg)
22 m_Callee = _T("");
23 m_Caller = _T("");
24 m_TTY = _T("");
25 //}}AFX_DATA_INIT
26 m_Callee = rq.m_RName;
27 m_Caller = rq.m_LName;
28 m_Caller+= '@';
29 m_Caller+= inet_ntoa(((sockaddr_in*)&rq.m_Addr)->sin_addr);
30 m_TTY = rq.m_RTTY;
31 m_asyncRequest=NULL;
32 m_timeOut = 30;
33 m_ipCaller = m_Caller;
34 m_bLooped=FALSE;
35}
36
37
38void T42AnnounceDlg::DoDataExchange(CDataExchange* pDX)
39{
40 CDialog::DoDataExchange(pDX);
41 //{{AFX_DATA_MAP(T42AnnounceDlg)
42 DDX_Control(pDX, IDC_CALLEE, m_CalleeCtl);
43 DDX_Control(pDX, IDC_TTY, m_TTYCtl);
44 DDX_Control(pDX, IDOK, m_YesCtl);
45 DDX_Control(pDX, IDCANCEL, m_NotMeCtl);
46 DDX_Control(pDX, IDC_SECRETARY, m_SecretaryCtl);
47 DDX_Control(pDX, IDC_CALLER, m_CallerCtl);
48 DDX_Text(pDX, IDC_CALLEE, m_Callee);
49 DDX_Text(pDX, IDC_CALLER, m_Caller);
50 DDX_Text(pDX, IDC_TTY, m_TTY);
51 //}}AFX_DATA_MAP
52}
53
54
55BEGIN_MESSAGE_MAP(T42AnnounceDlg, CDialog)
56 //{{AFX_MSG_MAP(T42AnnounceDlg)
57 ON_MESSAGE(WM_SOURCERESOLVED, OnSourceResolved)
58 ON_WM_DESTROY()
59 ON_WM_TIMER()
60 ON_BN_CLICKED(IDC_SECRETARY, OnSecretary)
61 //}}AFX_MSG_MAP
62END_MESSAGE_MAP()
63
64/////////////////////////////////////////////////////////////////////////////
65// T42AnnounceDlg message handlers
66
67BOOL T42AnnounceDlg::OnInitDialog()
68{
69 CDialog::OnInitDialog();
70
71 m_asyncRequest = WSAAsyncGetHostByAddr(m_hWnd,WM_SOURCERESOLVED,
72 (CHAR*)&((sockaddr_in*)&m_RQ.m_Addr)->sin_addr,
73 4,AF_INET,
74 m_ResolveBuffer,sizeof(m_ResolveBuffer)
75 );
76
77CT42App* app = (CT42App*)AfxGetApp();
78 ASSERT(app);
79 m_bLooped = app->StartSound(app->m_sndT42Prompt,app->m_bT42PromptLoop);
80 SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
81 SetTimer(timerTimeout,m_timeOut*1000,NULL);
82CFont* f = GetFont();
83LOGFONT lf;
84 if(f->GetLogFont(&lf)){
85 if(lf.lfWeight)
86 lf.lfWeight = 1000-lf.lfWeight;
87 else
88 lf.lfWeight = 700;
89 if(m_Font.CreateFontIndirect(&lf)){
90 m_CalleeCtl.SetFont(&m_Font);
91 m_CallerCtl.SetFont(&m_Font);
92 m_TTYCtl.SetFont(&m_Font);
93 }
94 }
95 return TRUE; // return TRUE unless you set the focus to a control
96 // EXCEPTION: OCX Property Pages should return FALSE
97}
98
99LRESULT T42AnnounceDlg::OnSourceResolved(WPARAM,LPARAM lP)
100{
101 if(WSAGETASYNCERROR(lP)){
102 TRACE1("Failed to resolve callee's host: %ld\n",WSAGETASYNCERROR(lP));
103 return -1;
104 }
105hostent* he = (hostent*)m_ResolveBuffer;
106 m_Caller = m_RQ.m_LName;
107 m_Caller+= '@';
108 m_Caller+= he->h_name;
109 m_CallerCtl.SetWindowText(m_Caller);
110 m_asyncRequest=NULL;
111 return 0;
112}
113
114void T42AnnounceDlg::OnDestroy()
115{
116 if(m_bLooped){
117 CT42App* app = (CT42App*)AfxGetApp();
118 ASSERT(app);
119 app->StopSound(app->m_sndT42Prompt);
120 }
121 m_bLooped=FALSE;
122 if(m_asyncRequest){
123 WSACancelAsyncRequest(m_asyncRequest);
124 m_asyncRequest=NULL;
125 }
126 CDialog::OnDestroy();
127}
128
129void T42AnnounceDlg::OnTimer(UINT nIDEvent)
130{
131 if(nIDEvent==timerTimeout){
132 KillTimer(timerTimeout);
133 UpdateData(TRUE);
134 // *** OnPromptTimeout?
135 EndDialog(IDC_SECRETARY);
136 }else
137 CDialog::OnTimer(nIDEvent);
138}
139
140void T42AnnounceDlg::OnSecretary()
141{
142 UpdateData(TRUE);
143 EndDialog(IDC_SECRETARY);
144}