forked from bigmacd/trapreceiver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrEmailAdd.cpp
More file actions
172 lines (155 loc) · 3.28 KB
/
TrEmailAdd.cpp
File metadata and controls
172 lines (155 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include "stdafx.h"
#include "TrEmailAdd.h"
#include "Registry.h"
#include "SmtpAuthDlg.h"
TrEmailAdd::TrEmailAdd(CWnd* pParent)
:CDialog(TrEmailAdd::IDD, pParent),
mInChangeMode(FALSE)
{
//{{AFX_DATA_INIT(TrEmailAdd)
mFrom = _T("");
mHost = _T("");
mMessage = _T("");
mPort = 25;
mSubject = _T("");
mTo = _T("");
mUser = _T("");
mJuniper = _T("");
mAuthNeeded = FALSE;
usessl = FALSE;
//}}AFX_DATA_INIT
}
TrEmailAdd::TrEmailAdd(CString host,
CString to,
CString from,
int port,
CString subject,
CString message,
BOOL needAuth,
CString user,
CString juniper,
BOOL inUsessl)
:CDialog(TrEmailAdd::IDD, NULL),
mInChangeMode(TRUE),
mHost(host),
mTo(to),
mFrom(from),
mPort(port),
mSubject(subject),
mMessage(message),
mAuthNeeded(needAuth),
mUser(user),
mJuniper(juniper),
usessl(inUsessl)
{
}
void TrEmailAdd::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(TrEmailAdd)
DDX_Control(pDX, IDC_BUTTONSETAUTH, mAuthButton);
DDX_Control(pDX, IDOK, mAddUpdateButton);
DDX_Text(pDX, IDC_EDITFROM, mFrom);
DDV_MaxChars(pDX, mFrom, 60);
DDX_Text(pDX, IDC_EDITSMTPSERVER, mHost);
DDV_MaxChars(pDX, mHost, 30);
DDX_Text(pDX, IDC_EDITMESSAGE, mMessage);
DDV_MaxChars(pDX, mMessage, 512);
DDX_Text(pDX, IDC_EDITSMTPPORT, mPort);
DDV_MinMaxInt(pDX, mPort, 0, 65535);
DDX_Text(pDX, IDC_EDITSUBJECT, mSubject);
DDV_MaxChars(pDX, mSubject, 255);
DDX_Text(pDX, IDC_EDITTO, mTo);
DDV_MaxChars(pDX, mTo, 60);
DDX_Check(pDX, IDC_CHECKAUTHREQUIRED, mAuthNeeded);
DDX_Check(pDX, IDC_CHECKSSLREQUIRED, usessl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(TrEmailAdd, CDialog)
//{{AFX_MSG_MAP(TrEmailAdd)
ON_BN_CLICKED(IDC_BUTTONSETAUTH, OnButtonSetAuth)
ON_BN_CLICKED(IDC_CHECKAUTHREQUIRED, OnCheckAuthRequired)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL
TrEmailAdd::OnInitDialog()
{
CDialog::OnInitDialog();
if (mInChangeMode)
mAddUpdateButton.SetWindowText("Update");
else
mAddUpdateButton.SetWindowText("Add");
mAuthButton.EnableWindow(mAuthNeeded);
return TRUE;
}
void
TrEmailAdd::OnCancel()
{
CDialog::OnCancel();
}
void
TrEmailAdd::OnOK()
{
UpdateData(TRUE);
if (mHost.GetLength() == 0)
{
AfxMessageBox("Incorrect host specified",
MB_OK | MB_ICONEXCLAMATION);
return;
}
else
if (mTo.GetLength() == 0)
{
AfxMessageBox("No recepient specified",
MB_OK | MB_ICONEXCLAMATION);
return;
}
else
{
if (!mInChangeMode)
{
int dummy;
try
{
Registry registry("Email");
if (registry.find(mHost,
mFrom,
mTo,
mSubject,
dummy))
{
AfxMessageBox("Duplicate Entry",
MB_OK | MB_ICONEXCLAMATION);
return;
}
}
catch(...)
{
}
}
}
CDialog::OnOK();
}
void
TrEmailAdd::OnButtonSetAuth()
{
int result = IDCANCEL;
SmtpAuthDlg* dlg;
if (mInChangeMode)
dlg = new SmtpAuthDlg(mUser, mJuniper);
else
dlg = new SmtpAuthDlg;
result = dlg->DoModal();
if (result == IDOK)
{
mUser = dlg->User();
mJuniper = dlg->Password();
}
delete dlg;
}
void
TrEmailAdd::OnCheckAuthRequired()
{
UpdateData(TRUE);
mAuthButton.EnableWindow(mAuthNeeded);
}