forked from bigmacd/trapreceiver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigureTrapData.cpp
More file actions
158 lines (145 loc) · 4.13 KB
/
ConfigureTrapData.cpp
File metadata and controls
158 lines (145 loc) · 4.13 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
#include "stdafx.h"
#include "traprcvr.h"
#include "ConfigureTrapData.h"
#include "EnvVarsDlg.h"
#include "CmdLineDlg.h"
#include "Registry.h"
IMPLEMENT_DYNCREATE(ConfigureTrapData, CPropertyPage)
ConfigureTrapData::ConfigureTrapData(CWnd* pParent /*=NULL*/)
:CPropertyPage(ConfigureTrapData::IDD)
{
//{{AFX_DATA_INIT(ConfigureTrapData)
mCommandLine = FALSE;
mEnvVars = FALSE;
//}}AFX_DATA_INIT
}
void
ConfigureTrapData::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ConfigureTrapData)
DDX_Control(pDX, IDC_BUTTONSPECIFYVARIABLES, mVariables);
DDX_Control(pDX, IDC_BUTTONSPECIFYPARAMETERS, mParms);
DDX_Check(pDX, IDC_CHECKPASSASCOMMANDLINEPARAMETERS, mCommandLine);
DDX_Check(pDX, IDC_CHECKSETASENVIRONMENTVARIABLES, mEnvVars);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ConfigureTrapData, CPropertyPage)
//{{AFX_MSG_MAP(ConfigureTrapData)
ON_BN_CLICKED(IDC_CHECKPASSASCOMMANDLINEPARAMETERS, OnCheckPassAsCommandLineParameters)
ON_BN_CLICKED(IDC_CHECKSETASENVIRONMENTVARIABLES, OnCheckSetAsEnvironmentVariables)
ON_BN_CLICKED(IDC_BUTTONSPECIFYPARAMETERS, OnButtonSpecifyParameters)
ON_BN_CLICKED(IDC_BUTTONSPECIFYVARIABLES, OnButtonSpecifyVariables)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void
ConfigureTrapData::OnCheckPassAsCommandLineParameters()
{
UpdateData(TRUE);
mParms.EnableWindow(mCommandLine);
Registry r;
r.includeCmdLine(mCommandLine);
SetModified(TRUE);
}
void
ConfigureTrapData::OnCheckSetAsEnvironmentVariables()
{
UpdateData(TRUE);
mVariables.EnableWindow(mEnvVars);
Registry r;
r.includeEnvironment(mEnvVars);
SetModified(TRUE);
}
void
ConfigureTrapData::OnButtonSpecifyParameters()
{
CmdLineDlg dlg;
int result = dlg.DoModal();
if (result == IDOK)
{
SetModified(TRUE);
Registry r;
r.includeCmdCommunity(dlg.mCommunity);
r.includeCmdIpAddress(dlg.mIpAddress);
r.includeCmdRealIpAddress(dlg.mRealIpAddress);
r.includeCmdGenericType(dlg.mGenericType);
r.includeCmdSpecificType(dlg.mSpecificType);
r.includeCmdSenderOID(dlg.mSenderOID);
r.includeCmdVbData(dlg.mVbData);
r.includeCmdVbOID(dlg.mVbOID);
if (dlg.mCommunity)
r.cmdCommunity(dlg.mCommunityString);
if (dlg.mGenericType)
r.cmdGenericType(dlg.mGenericTypeString);
if (dlg.mIpAddress)
r.cmdIpAddress(dlg.mIpAddressString);
if (dlg.mRealIpAddress)
r.cmdRealIpAddress(dlg.mRealIpAddressString);
if (dlg.mSenderOID)
r.cmdSenderOID(dlg.mSenderOIDString);
if (dlg.mSpecificType)
r.cmdSpecificType(dlg.mSpecificTypeString);
if (dlg.mVbData)
r.cmdVbData(dlg.mVbDataString);
if (dlg.mVbOID)
r.cmdVbOID(dlg.mVbOIDString);
}
}
void
ConfigureTrapData::OnButtonSpecifyVariables()
{
EnvVarsDlg dlg;
int result = dlg.DoModal();
if (result == IDOK)
{
SetModified(TRUE);
Registry r;
r.includeEnvCommunity(dlg.mCommunity);
r.includeEnvIpAddress(dlg.mIpAddress);
r.includeEnvRealIpAddress(dlg.mRealIpAddress);
r.includeEnvGenericType(dlg.mGenericType);
r.includeEnvSpecificType(dlg.mSpecificType);
r.includeEnvSenderOID(dlg.mSenderOID);
r.includeEnvVbData(dlg.mVbData);
r.includeEnvVbOID(dlg.mVbOID);
if (dlg.mCommunity)
r.envCommunity(dlg.mCommunityString);
if (dlg.mGenericType)
r.envGenericType(dlg.mGenericTypeString);
if (dlg.mIpAddress)
r.envIpAddress(dlg.mIpAddressString);
if (dlg.mRealIpAddress)
r.envRealIpAddress(dlg.mRealIpAddressString);
if (dlg.mSenderOID)
r.envSenderOID(dlg.mSenderOIDString);
if (dlg.mSpecificType)
r.envSpecificType(dlg.mSpecificTypeString);
if (dlg.mVbData)
r.envVbData(dlg.mVbDataString);
if (dlg.mVbOID)
r.envVbOID(dlg.mVbOIDString);
}
}
BOOL
ConfigureTrapData::OnInitDialog()
{
CPropertyPage::OnInitDialog();
Registry r;
try
{
mCommandLine = r.includeCmdLine();
mParms.EnableWindow(mCommandLine);
mEnvVars = r.includeEnvironment();
mVariables.EnableWindow(mEnvVars);
}
catch(int x)
{
if (x == 0)
{
r.includeCmdLine(FALSE);
r.includeEnvironment(FALSE);
}
}
UpdateData(FALSE);
return TRUE;
}