-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMtrFirewallPage.cpp
127 lines (111 loc) · 3.13 KB
/
MtrFirewallPage.cpp
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
/******************************************************************************
** (C) Chris Oldwood
**
** MODULE: MTRFIREWALLPAGE.CPP
** COMPONENT: The Application
** DESCRIPTION: CMtrFirewallPage class definition.
**
*******************************************************************************
*/
#include "Common.hpp"
#include "MtrFirewallPage.hpp"
#include "MasterQueryOpts.hpp"
/******************************************************************************
** Method: Default constructor.
**
** Description: .
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
CMtrFirewallPage::CMtrFirewallPage(CMasterQueryOpts& oConfig)
: CPropertyPage(IDD_MASTER_FIREWALL)
, m_oConfig(oConfig)
, m_ebFirstPort(false, 5)
, m_ebLastPort(false, 5)
{
DEFINE_CTRL_TABLE
CTRL(IDC_MASTER_PORTS, &m_ckFirewall)
CTRL(IDC_FIRST_PORT, &m_ebFirstPort)
CTRL(IDC_LAST_PORT, &m_ebLastPort)
END_CTRL_TABLE
DEFINE_CTRLMSG_TABLE
CMD_CTRLMSG(IDC_MASTER_PORTS, BN_CLICKED, &CMtrFirewallPage::OnClickFirewall)
END_CTRLMSG_TABLE
}
/******************************************************************************
** Method: OnInitDialog()
**
** Description: Initialise the dialog.
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
void CMtrFirewallPage::OnInitDialog()
{
// Initialise controls.
m_ckFirewall.Check(m_oConfig.m_bFirewall);
m_ebFirstPort.IntValue(m_oConfig.m_nFirstPort);
m_ebLastPort.IntValue(m_oConfig.m_nLastPort);
OnClickFirewall();
}
/******************************************************************************
** Method: OnValidate()
**
** Description: Validate the settings.
**
** Parameters: None.
**
** Returns: true or false.
**
*******************************************************************************
*/
bool CMtrFirewallPage::OnValidate()
{
if ( (m_ebFirstPort.TextLength() == 0) || (m_ebFirstPort.IntValue() > 65535) )
{
AlertMsg(TXT("Please enter a valid 'from' IP port number (0 - 65535)."));
m_ebFirstPort.Focus();
return false;
}
if ( (m_ebLastPort.TextLength() == 0) || (m_ebLastPort.IntValue() > 65535) )
{
AlertMsg(TXT("Please enter a valid 'to' IP port number (0 - 65535)."));
m_ebLastPort.Focus();
return false;
}
if (m_ebLastPort.IntValue() < m_ebFirstPort.IntValue())
{
AlertMsg(TXT("The second port number should be greater than the first."));
m_ebLastPort.Focus();
return false;
}
// Get new settings.
m_oConfig.m_bFirewall = m_ckFirewall.IsChecked();
m_oConfig.m_nFirstPort = m_ebFirstPort.IntValue();
m_oConfig.m_nLastPort = m_ebLastPort.IntValue();
return true;
}
/******************************************************************************
** Method: OnClickFirewall()
**
** Description: Enable/Disable the firewall port range edit boxes.
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
void CMtrFirewallPage::OnClickFirewall()
{
bool bFirewall = m_ckFirewall.IsChecked();
m_ebFirstPort.Enable(bFirewall);
m_ebLastPort.Enable(bFirewall);
}