- Search string now assumed with * at the ends in object browser
[public/netxms.git] / src / console / win32 / NodePropsGeneral.cpp
1 // NodePropsGeneral.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "nxcon.h"
6 #include "NodePropsGeneral.h"
7 #include <nxsnmp.h>
8
9 #ifdef _DEBUG
10 #define new DEBUG_NEW
11 #undef THIS_FILE
12 static char THIS_FILE[] = __FILE__;
13 #endif
14
15
16 //
17 // Static data
18 //
19
20 char *m_pszAuthStrings[] = { "None", "Shared Secred (Plain Text)",
21 "Shared Secred (MD5 Hash)", "Shared Secred (SHA1 Hash)" };
22
23 /////////////////////////////////////////////////////////////////////////////
24 // CNodePropsGeneral property page
25
26 IMPLEMENT_DYNCREATE(CNodePropsGeneral, CPropertyPage)
27
28 CNodePropsGeneral::CNodePropsGeneral() : CPropertyPage(CNodePropsGeneral::IDD)
29 {
30 //{{AFX_DATA_INIT(CNodePropsGeneral)
31 m_dwObjectId = 0;
32 m_strName = _T("");
33 m_strOID = _T("");
34 m_iAgentPort = 0;
35 m_strPrimaryIp = _T("");
36 m_strSecret = _T("");
37 m_strCommunity = _T("");
38 m_iAuthType = -1;
39 m_iSNMPVersion = -1;
40 //}}AFX_DATA_INIT
41 }
42
43 CNodePropsGeneral::~CNodePropsGeneral()
44 {
45 }
46
47 void CNodePropsGeneral::DoDataExchange(CDataExchange* pDX)
48 {
49 CPropertyPage::DoDataExchange(pDX);
50 //{{AFX_DATA_MAP(CNodePropsGeneral)
51 DDX_Control(pDX, IDC_COMBO_AUTH, m_wndAuthList);
52 DDX_Text(pDX, IDC_EDIT_ID, m_dwObjectId);
53 DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
54 DDV_MaxChars(pDX, m_strName, 63);
55 DDX_Text(pDX, IDC_EDIT_OID, m_strOID);
56 DDX_Text(pDX, IDC_EDIT_PORT, m_iAgentPort);
57 DDV_MinMaxInt(pDX, m_iAgentPort, 1, 65535);
58 DDX_Text(pDX, IDC_EDIT_PRIMARY_IP, m_strPrimaryIp);
59 DDX_Text(pDX, IDC_EDIT_SECRET, m_strSecret);
60 DDV_MaxChars(pDX, m_strSecret, 63);
61 DDX_Text(pDX, IDC_EDIT_COMMUNITY, m_strCommunity);
62 DDV_MaxChars(pDX, m_strCommunity, 63);
63 DDX_CBIndex(pDX, IDC_COMBO_AUTH, m_iAuthType);
64 DDX_Radio(pDX, IDC_RADIO_VERSION1, m_iSNMPVersion);
65 //}}AFX_DATA_MAP
66 }
67
68
69 BEGIN_MESSAGE_MAP(CNodePropsGeneral, CPropertyPage)
70 //{{AFX_MSG_MAP(CNodePropsGeneral)
71 ON_EN_CHANGE(IDC_EDIT_NAME, OnChangeEditName)
72 ON_EN_CHANGE(IDC_EDIT_SECRET, OnChangeEditSecret)
73 ON_EN_CHANGE(IDC_EDIT_PORT, OnChangeEditPort)
74 ON_EN_CHANGE(IDC_EDIT_COMMUNITY, OnChangeEditCommunity)
75 ON_CBN_SELCHANGE(IDC_COMBO_AUTH, OnSelchangeComboAuth)
76 ON_BN_CLICKED(IDC_RADIO_VERSION_2C, OnRadioVersion2c)
77 ON_BN_CLICKED(IDC_RADIO_VERSION1, OnRadioVersion1)
78 ON_BN_CLICKED(IDC_SELECT_IP, OnSelectIp)
79 //}}AFX_MSG_MAP
80 END_MESSAGE_MAP()
81
82 /////////////////////////////////////////////////////////////////////////////
83 // CNodePropsGeneral message handlers
84
85 BOOL CNodePropsGeneral::OnInitDialog()
86 {
87 int i;
88
89 CPropertyPage::OnInitDialog();
90
91 m_pUpdate = ((CObjectPropSheet *)GetParent())->GetUpdateStruct();
92
93 // Initialize dropdown lists
94 for(i = 0; i < 4; i++)
95 m_wndAuthList.AddString(m_pszAuthStrings[i]);
96 m_wndAuthList.SelectString(-1, m_pszAuthStrings[m_iAuthType]);
97
98 return TRUE;
99 }
100
101
102 //
103 // Handlers for changed controls
104 //
105
106 void CNodePropsGeneral::OnChangeEditName()
107 {
108 m_pUpdate->dwFlags |= OBJ_UPDATE_NAME;
109 SetModified();
110 }
111
112 void CNodePropsGeneral::OnChangeEditSecret()
113 {
114 m_pUpdate->dwFlags |= OBJ_UPDATE_AGENT_SECRET;
115 SetModified();
116 }
117
118 void CNodePropsGeneral::OnChangeEditPort()
119 {
120 m_pUpdate->dwFlags |= OBJ_UPDATE_AGENT_PORT;
121 SetModified();
122 }
123
124 void CNodePropsGeneral::OnChangeEditCommunity()
125 {
126 m_pUpdate->dwFlags |= OBJ_UPDATE_SNMP_COMMUNITY;
127 SetModified();
128 }
129
130 void CNodePropsGeneral::OnSelchangeComboAuth()
131 {
132 m_pUpdate->dwFlags |= OBJ_UPDATE_AGENT_AUTH;
133 SetModified();
134 }
135
136 void CNodePropsGeneral::OnRadioVersion2c()
137 {
138 m_pUpdate->dwFlags |= OBJ_UPDATE_SNMP_VERSION;
139 SetModified();
140 }
141
142 void CNodePropsGeneral::OnRadioVersion1()
143 {
144 m_pUpdate->dwFlags |= OBJ_UPDATE_SNMP_VERSION;
145 SetModified();
146 }
147
148
149 //
150 // Handler for PSN_OK message
151 //
152
153 void CNodePropsGeneral::OnOK()
154 {
155 char szBuffer[256];
156 int i;
157
158 CPropertyPage::OnOK();
159
160 // Set fields in update structure
161 m_pUpdate->pszName = (char *)((LPCTSTR)m_strName);
162 m_pUpdate->iAgentPort = m_iAgentPort;
163 m_pUpdate->pszCommunity = (char *)((LPCTSTR)m_strCommunity);
164 m_pUpdate->pszSecret = (char *)((LPCTSTR)m_strSecret);
165 m_pUpdate->wSNMPVersion = (m_iSNMPVersion == 0) ? SNMP_VERSION_1 : SNMP_VERSION_2C;
166
167 // Authentication type
168 m_wndAuthList.GetWindowText(szBuffer, 255);
169 for(i = 0; i < 4; i++)
170 if (!strcmp(szBuffer, m_pszAuthStrings[i]))
171 {
172 m_pUpdate->iAuthType = i;
173 break;
174 }
175 }
176
177
178 //
179 // Select primary IP address for node
180 //
181
182 void CNodePropsGeneral::OnSelectIp()
183 {
184 }