Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrcfg / sys_control_page.cpp
blobfaaaa4faf72f988ba38cb47b7adc903dd2502b31
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
11 * INCLUDES _________________________________________________________________
14 #include <winsock2.h>
15 #include <ws2tcpip.h>
17 extern "C" {
18 #include <afs/param.h>
19 #include <afs/stds.h>
22 #include "afscfg.h"
23 #include "resource.h"
27 * DEFINITIONS _________________________________________________________________
30 static HWND hDlg = 0;
31 extern int nOptionButtonSeparationHeight; // Comes from backup_server_page.cpp
35 * PROTOTYPES _________________________________________________________________
38 static void OnInitDialog(HWND hwndDlg);
39 static void CantConfig(UINT nMsgID);
40 static void EnableSysControlMachine(BOOL bEnable);
41 static void ShowSysControlMachine(TCHAR *pszSysControlMachine);
42 static void CheckEnableNextButton();
46 * EXPORTED FUNCTIONS _________________________________________________________________
51 * Dialog Proc _________________________________________________________________
54 BOOL CALLBACK SysControlPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
56 if (WizStep_Common_DlgProc (hwndDlg, msg, wp, lp))
57 return FALSE;
59 switch (msg) {
60 case WM_INITDIALOG:
61 OnInitDialog(hwndDlg);
62 break;
64 case WM_COMMAND:
65 switch (LOWORD(wp)) {
66 case IDNEXT:
67 g_pWiz->SetState(sidSTEP_TWELVE);
68 break;
70 case IDBACK:
71 g_pWiz->SetState(sidSTEP_TEN);
72 break;
74 case IDC_SYS_CONTROL_SERVER:
75 g_CfgData.configSCS = CS_CONFIGURE;
76 g_CfgData.configSCC = CS_DONT_CONFIGURE;
77 EnableSysControlMachine(FALSE);
78 break;
80 case IDC_SYS_CONTROL_CLIENT:
81 g_CfgData.configSCS = CS_DONT_CONFIGURE;
82 g_CfgData.configSCC = CS_CONFIGURE;
83 EnableSysControlMachine(TRUE);
84 SetFocus(GetDlgItem(hDlg, IDC_SYS_CONTROL_MACHINE));
85 break;
87 case IDC_DONT_CONFIGURE:
88 g_CfgData.configSCS = CS_DONT_CONFIGURE;
89 g_CfgData.configSCC = CS_DONT_CONFIGURE;
90 EnableSysControlMachine(FALSE);
91 break;
93 case IDC_SYS_CONTROL_MACHINE:
94 if (HIWORD(wp) == EN_CHANGE)
95 CheckEnableNextButton();
96 break;
98 break;
101 return FALSE;
105 * STATIC FUNCTIONS _________________________________________________________________
110 * Event Handler Functions _________________________________________________________________
113 static void OnInitDialog(HWND hwndDlg)
115 hDlg = hwndDlg;
117 g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
118 g_pWiz->SetButtonText(IDNEXT, IDS_NEXT);
119 g_pWiz->SetDefaultControl(IDNEXT);
121 if (g_CfgData.configSCS == CS_ALREADY_CONFIGURED) {
122 CantConfig(IDS_ALREADY_A_SYS_CONTROL_SERVER);
123 return;
124 } else if (g_CfgData.configSCC == CS_ALREADY_CONFIGURED) {
125 CantConfig(IDS_ALREADY_A_SYS_CONTROL_CLIENT);
126 return;
129 // Should this step be disabled? Yes, if this machine
130 // is not configured as a database or file server.
131 if (!ConfiguredOrConfiguring(g_CfgData.configFS) && !ConfiguredOrConfiguring(g_CfgData.configDB)) {
132 CantConfig(IDS_SC_NOT_A_DB_OR_FS_SERVER);
133 EnableStep(g_CfgData.configSCS, FALSE);
134 EnableStep(g_CfgData.configSCC, FALSE);
135 return;
138 // Do this in case they were disabled on the last run through
139 EnableStep(g_CfgData.configSCS);
140 EnableStep(g_CfgData.configSCC);
142 // If this is the first server, then it can't be a SCC
143 if (g_CfgData.bFirstServer) {
144 // Disable the SCC step
145 EnableStep(g_CfgData.configSCC, FALSE);
147 // Hide the SCC controls
148 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT_DESC, FALSE);
149 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT, FALSE);
150 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, FALSE);
151 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE, FALSE);
153 // Move remaining controls to fill the holes left from
154 // hiding the SCC controls
156 // Get position of the "Do not configure" option button; we will position
157 // the other controls relative to this one
158 RECT rectDNC;
159 GetWindowRect(GetDlgItem(hDlg, IDC_DONT_CONFIGURE), &rectDNC);
161 // Get position of the SCS option button
162 RECT rectSCS;
163 GetWindowRect(GetDlgItem(hDlg, IDC_SYS_CONTROL_SERVER), &rectSCS);
165 // Calc offset between the two
166 int nOffset = rectDNC.top - rectSCS.top;
168 // Separate the two option controls
169 nOffset -= nOptionButtonSeparationHeight;
171 // Move the controls
172 MoveWnd(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, 0, nOffset);
173 MoveWnd(hDlg, IDC_SYS_CONTROL_SERVER, 0, nOffset);
175 SetWndText(hDlg, IDC_TITLE, IDS_CONFIG_SCS);
176 SetWndText(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, IDS_SYS_CONTROL_SERVER_ONLY_MSG);
177 SetWndText(hDlg, IDC_DONT_CONFIGURE, IDS_DONT_CONFIG_SYS_CONTROL_SERVER_MSG);
180 if (g_CfgData.configSCS == CS_CONFIGURE)
181 SetCheck(hDlg, IDC_SYS_CONTROL_SERVER);
182 else if (g_CfgData.configSCC == CS_CONFIGURE) {
183 SetCheck(hDlg, IDC_SYS_CONTROL_CLIENT);
184 EnableSysControlMachine(TRUE);
185 } else
186 SetCheck(hDlg, IDC_DONT_CONFIGURE);
190 * Utility Functions _________________________________________________________________
193 static void CantConfig(UINT nMsgID)
195 TCHAR szMsg[cchRESOURCE];
197 GetString(szMsg, nMsgID);
199 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, FALSE);
200 ShowWnd(hDlg, IDC_SYS_CONTROL_SERVER, FALSE);
201 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT, FALSE);
202 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, FALSE);
203 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE, FALSE);
204 ShowWnd(hDlg, IDC_DONT_CONFIGURE, FALSE);
206 ShowWnd(hDlg, IDC_CANT_CONFIG_MSG);
207 SetWndText(hDlg, IDC_CANT_CONFIG_MSG, szMsg);
210 static void EnableSysControlMachine(BOOL bEnable)
212 EnableWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, bEnable);
213 EnableWnd(hDlg, IDC_SYS_CONTROL_MACHINE, bEnable);
215 if (bEnable)
216 ShowSysControlMachine(g_CfgData.szSysControlMachine);
217 else
218 ShowSysControlMachine(TEXT(""));
220 CheckEnableNextButton();
223 static void ShowSysControlMachine(TCHAR *pszSysControlMachine)
225 SetWndText(hDlg, IDC_SYS_CONTROL_MACHINE, pszSysControlMachine);
228 static void CheckEnableNextButton()
230 BOOL bEnable = TRUE;
232 if (IsButtonChecked(hDlg, IDC_SYS_CONTROL_CLIENT)) {
233 GetWndText(hDlg, IDC_SYS_CONTROL_MACHINE, g_CfgData.szSysControlMachine, MAX_MACHINE_NAME_LEN);
235 if (lstrlen(g_CfgData.szSysControlMachine) == 0)
236 bEnable = FALSE;
239 if (bEnable)
240 g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
241 else
242 g_pWiz->EnableButtons(BACK_BUTTON);