2 * Copyright 2000, International Business Machines Corporation and others.
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
11 * INCLUDES _________________________________________________________________
18 #include <afsconfig.h>
19 #include <afs/param.h>
29 * DEFINITIONS _________________________________________________________________
33 extern int nOptionButtonSeparationHeight; // Comes from backup_server_page.cpp
37 * PROTOTYPES _________________________________________________________________
40 static void OnInitDialog(HWND hwndDlg);
41 static void CantConfig(UINT nMsgID);
42 static void EnableSysControlMachine(BOOL bEnable);
43 static void ShowSysControlMachine(TCHAR *pszSysControlMachine);
44 static void CheckEnableNextButton();
48 * EXPORTED FUNCTIONS _________________________________________________________________
53 * Dialog Proc _________________________________________________________________
56 BOOL CALLBACK SysControlPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
58 if (WizStep_Common_DlgProc (hwndDlg, msg, wp, lp))
63 OnInitDialog(hwndDlg);
69 g_pWiz->SetState(sidSTEP_TWELVE);
73 g_pWiz->SetState(sidSTEP_TEN);
76 case IDC_SYS_CONTROL_SERVER:
77 g_CfgData.configSCS = CS_CONFIGURE;
78 g_CfgData.configSCC = CS_DONT_CONFIGURE;
79 EnableSysControlMachine(FALSE);
82 case IDC_SYS_CONTROL_CLIENT:
83 g_CfgData.configSCS = CS_DONT_CONFIGURE;
84 g_CfgData.configSCC = CS_CONFIGURE;
85 EnableSysControlMachine(TRUE);
86 SetFocus(GetDlgItem(hDlg, IDC_SYS_CONTROL_MACHINE));
89 case IDC_DONT_CONFIGURE:
90 g_CfgData.configSCS = CS_DONT_CONFIGURE;
91 g_CfgData.configSCC = CS_DONT_CONFIGURE;
92 EnableSysControlMachine(FALSE);
95 case IDC_SYS_CONTROL_MACHINE:
96 if (HIWORD(wp) == EN_CHANGE)
97 CheckEnableNextButton();
107 * STATIC FUNCTIONS _________________________________________________________________
112 * Event Handler Functions _________________________________________________________________
115 static void OnInitDialog(HWND hwndDlg)
119 g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
120 g_pWiz->SetButtonText(IDNEXT, IDS_NEXT);
121 g_pWiz->SetDefaultControl(IDNEXT);
123 if (g_CfgData.configSCS == CS_ALREADY_CONFIGURED) {
124 CantConfig(IDS_ALREADY_A_SYS_CONTROL_SERVER);
126 } else if (g_CfgData.configSCC == CS_ALREADY_CONFIGURED) {
127 CantConfig(IDS_ALREADY_A_SYS_CONTROL_CLIENT);
131 // Should this step be disabled? Yes, if this machine
132 // is not configured as a database or file server.
133 if (!ConfiguredOrConfiguring(g_CfgData.configFS) && !ConfiguredOrConfiguring(g_CfgData.configDB)) {
134 CantConfig(IDS_SC_NOT_A_DB_OR_FS_SERVER);
135 EnableStep(g_CfgData.configSCS, FALSE);
136 EnableStep(g_CfgData.configSCC, FALSE);
140 // Do this in case they were disabled on the last run through
141 EnableStep(g_CfgData.configSCS);
142 EnableStep(g_CfgData.configSCC);
144 // If this is the first server, then it can't be a SCC
145 if (g_CfgData.bFirstServer) {
146 // Disable the SCC step
147 EnableStep(g_CfgData.configSCC, FALSE);
149 // Hide the SCC controls
150 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT_DESC, FALSE);
151 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT, FALSE);
152 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, FALSE);
153 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE, FALSE);
155 // Move remaining controls to fill the holes left from
156 // hiding the SCC controls
158 // Get position of the "Do not configure" option button; we will position
159 // the other controls relative to this one
161 GetWindowRect(GetDlgItem(hDlg, IDC_DONT_CONFIGURE), &rectDNC);
163 // Get position of the SCS option button
165 GetWindowRect(GetDlgItem(hDlg, IDC_SYS_CONTROL_SERVER), &rectSCS);
167 // Calc offset between the two
168 int nOffset = rectDNC.top - rectSCS.top;
170 // Separate the two option controls
171 nOffset -= nOptionButtonSeparationHeight;
174 MoveWnd(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, 0, nOffset);
175 MoveWnd(hDlg, IDC_SYS_CONTROL_SERVER, 0, nOffset);
177 SetWndText(hDlg, IDC_TITLE, IDS_CONFIG_SCS);
178 SetWndText(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, IDS_SYS_CONTROL_SERVER_ONLY_MSG);
179 SetWndText(hDlg, IDC_DONT_CONFIGURE, IDS_DONT_CONFIG_SYS_CONTROL_SERVER_MSG);
182 if (g_CfgData.configSCS == CS_CONFIGURE)
183 SetCheck(hDlg, IDC_SYS_CONTROL_SERVER);
184 else if (g_CfgData.configSCC == CS_CONFIGURE) {
185 SetCheck(hDlg, IDC_SYS_CONTROL_CLIENT);
186 EnableSysControlMachine(TRUE);
188 SetCheck(hDlg, IDC_DONT_CONFIGURE);
192 * Utility Functions _________________________________________________________________
195 static void CantConfig(UINT nMsgID)
197 TCHAR szMsg[cchRESOURCE];
199 GetString(szMsg, nMsgID);
201 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, FALSE);
202 ShowWnd(hDlg, IDC_SYS_CONTROL_SERVER, FALSE);
203 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT, FALSE);
204 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, FALSE);
205 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE, FALSE);
206 ShowWnd(hDlg, IDC_DONT_CONFIGURE, FALSE);
208 ShowWnd(hDlg, IDC_CANT_CONFIG_MSG);
209 SetWndText(hDlg, IDC_CANT_CONFIG_MSG, szMsg);
212 static void EnableSysControlMachine(BOOL bEnable)
214 EnableWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, bEnable);
215 EnableWnd(hDlg, IDC_SYS_CONTROL_MACHINE, bEnable);
218 ShowSysControlMachine(g_CfgData.szSysControlMachine);
220 ShowSysControlMachine(TEXT(""));
222 CheckEnableNextButton();
225 static void ShowSysControlMachine(TCHAR *pszSysControlMachine)
227 SetWndText(hDlg, IDC_SYS_CONTROL_MACHINE, pszSysControlMachine);
230 static void CheckEnableNextButton()
234 if (IsButtonChecked(hDlg, IDC_SYS_CONTROL_CLIENT)) {
235 GetWndText(hDlg, IDC_SYS_CONTROL_MACHINE, g_CfgData.szSysControlMachine, MAX_MACHINE_NAME_LEN);
237 if (lstrlen(g_CfgData.szSysControlMachine) == 0)
242 g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
244 g_pWiz->EnableButtons(BACK_BUTTON);