manual map layout can be saved and restored
[public/netxms.git] / src / server / tools / nxconfig / PollCfgPage.cpp
1 // PollCfgPage.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "nxconfig.h"
6 #include "PollCfgPage.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CPollCfgPage property page
16
17 IMPLEMENT_DYNCREATE(CPollCfgPage, CPropertyPage)
18
19 CPollCfgPage::CPollCfgPage() : CPropertyPage(CPollCfgPage::IDD)
20 {
21 //{{AFX_DATA_INIT(CPollCfgPage)
22 // NOTE: the ClassWizard will add member initialization here
23 //}}AFX_DATA_INIT
24 }
25
26 CPollCfgPage::~CPollCfgPage()
27 {
28 }
29
30 void CPollCfgPage::DoDataExchange(CDataExchange* pDX)
31 {
32 CPropertyPage::DoDataExchange(pDX);
33 //{{AFX_DATA_MAP(CPollCfgPage)
34 // NOTE: the ClassWizard will add DDX and DDV calls here
35 //}}AFX_DATA_MAP
36 }
37
38
39 BEGIN_MESSAGE_MAP(CPollCfgPage, CPropertyPage)
40 //{{AFX_MSG_MAP(CPollCfgPage)
41 ON_BN_CLICKED(IDC_CHECK_RUN_DISCOVERY, OnCheckRunDiscovery)
42 //}}AFX_MSG_MAP
43 END_MESSAGE_MAP()
44
45 /////////////////////////////////////////////////////////////////////////////
46 // CPollCfgPage message handlers
47
48 //
49 // Handler for "Back" button
50 //
51
52 LRESULT CPollCfgPage::OnWizardBack()
53 {
54 WIZARD_CFG_INFO *pc = &((CConfigWizard *)GetParent())->m_cfg;
55
56 return !_tcsicmp(pc->m_szDBDriver, _T("odbc.ddr")) ? IDD_ODBC : IDD_SELECT_DB;
57 }
58
59
60 //
61 // WM_INITDIALOG message handler
62 //
63
64 BOOL CPollCfgPage::OnInitDialog()
65 {
66 TCHAR szBuffer[32];
67 WIZARD_CFG_INFO *pc = &((CConfigWizard *)GetParent())->m_cfg;
68
69 CPropertyPage::OnInitDialog();
70
71 // Discovery
72 _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwDiscoveryPI);
73 SetDlgItemText(IDC_EDIT_INT_DP, szBuffer);
74 SendDlgItemMessage(IDC_CHECK_RUN_DISCOVERY, BM_SETCHECK, pc->m_bRunAutoDiscovery);
75 EnableDlgItem(this, IDC_STATIC_DI, pc->m_bRunAutoDiscovery);
76 EnableDlgItem(this, IDC_STATIC_SEC, pc->m_bRunAutoDiscovery);
77 EnableDlgItem(this, IDC_EDIT_INT_DP, pc->m_bRunAutoDiscovery);
78
79 // Status poll
80 _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwNumStatusPollers);
81 SetDlgItemText(IDC_EDIT_NUM_SP, szBuffer);
82 _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwStatusPI);
83 SetDlgItemText(IDC_EDIT_INT_SP, szBuffer);
84
85 // Configuration poll
86 _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwNumConfigPollers);
87 SetDlgItemText(IDC_EDIT_NUM_CP, szBuffer);
88 _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwConfigurationPI);
89 SetDlgItemText(IDC_EDIT_INT_CP, szBuffer);
90
91 return TRUE;
92 }
93
94
95 //
96 // Handler for "Run autodiscovery" check box
97 //
98
99 void CPollCfgPage::OnCheckRunDiscovery()
100 {
101 WIZARD_CFG_INFO *pc = &((CConfigWizard *)GetParent())->m_cfg;
102
103 pc->m_bRunAutoDiscovery = (SendDlgItemMessage(IDC_CHECK_RUN_DISCOVERY, BM_GETCHECK) == BST_CHECKED);
104 EnableDlgItem(this, IDC_STATIC_DI, pc->m_bRunAutoDiscovery);
105 EnableDlgItem(this, IDC_STATIC_SEC, pc->m_bRunAutoDiscovery);
106 EnableDlgItem(this, IDC_EDIT_INT_DP, pc->m_bRunAutoDiscovery);
107 }
108
109
110 //
111 // Handler for "Next" button
112 //
113
114 LRESULT CPollCfgPage::OnWizardNext()
115 {
116 WIZARD_CFG_INFO *pc = &((CConfigWizard *)GetParent())->m_cfg;
117
118 // Discovery poll
119 if (!GetEditBoxValueULong(this, IDC_EDIT_INT_DP, &pc->m_dwDiscoveryPI, 5))
120 {
121 MessageBox(_T("Invalid value entered as discovery polling interval"),
122 _T("Warning"), MB_OK | MB_ICONEXCLAMATION);
123 GetDlgItem(IDC_EDIT_INT_DP)->SetFocus();
124 return -1;
125 }
126
127 // Status poll
128 if (!GetEditBoxValueULong(this, IDC_EDIT_NUM_SP, &pc->m_dwNumStatusPollers, 1, 100000))
129 {
130 MessageBox(_T("Invalid value entered as number of status pollers"),
131 _T("Warning"), MB_OK | MB_ICONEXCLAMATION);
132 GetDlgItem(IDC_EDIT_NUM_SP)->SetFocus();
133 return -1;
134 }
135 if (!GetEditBoxValueULong(this, IDC_EDIT_INT_SP, &pc->m_dwStatusPI, 5))
136 {
137 MessageBox(_T("Invalid value entered as status polling interval"),
138 _T("Warning"), MB_OK | MB_ICONEXCLAMATION);
139 GetDlgItem(IDC_EDIT_INT_SP)->SetFocus();
140 return -1;
141 }
142
143 // Configuration poll
144 if (!GetEditBoxValueULong(this, IDC_EDIT_NUM_CP, &pc->m_dwNumConfigPollers, 1, 1000))
145 {
146 MessageBox(_T("Invalid value entered as number of configuration pollers"),
147 _T("Warning"), MB_OK | MB_ICONEXCLAMATION);
148 GetDlgItem(IDC_EDIT_NUM_CP)->SetFocus();
149 return -1;
150 }
151 if (!GetEditBoxValueULong(this, IDC_EDIT_INT_CP, &pc->m_dwConfigurationPI, 30))
152 {
153 MessageBox(_T("Invalid value entered as configuration polling interval"),
154 _T("Warning"), MB_OK | MB_ICONEXCLAMATION);
155 GetDlgItem(IDC_EDIT_INT_CP)->SetFocus();
156 return -1;
157 }
158
159 return CPropertyPage::OnWizardNext();
160 }