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 _________________________________________________________________
15 #include <afs/param.h>
24 * DEFINITIONS _________________________________________________________________
28 extern int nOptionButtonSeparationHeight; // Comes from backup_server_page.cpp
32 * PROTOTYPES _________________________________________________________________
35 static void OnInitDialog(HWND hwndDlg);
36 static void CantConfig(UINT nMsgID);
37 static void EnableSysControlMachine(BOOL bEnable);
38 static void ShowSysControlMachine(TCHAR *pszSysControlMachine);
39 static void CheckEnableNextButton();
43 * EXPORTED FUNCTIONS _________________________________________________________________
48 * Dialog Proc _________________________________________________________________
51 BOOL CALLBACK SysControlPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
53 if (WizStep_Common_DlgProc (hwndDlg, msg, wp, lp))
58 OnInitDialog(hwndDlg);
64 g_pWiz->SetState(sidSTEP_TWELVE);
68 g_pWiz->SetState(sidSTEP_TEN);
71 case IDC_SYS_CONTROL_SERVER:
72 g_CfgData.configSCS = CS_CONFIGURE;
73 g_CfgData.configSCC = CS_DONT_CONFIGURE;
74 EnableSysControlMachine(FALSE);
77 case IDC_SYS_CONTROL_CLIENT:
78 g_CfgData.configSCS = CS_DONT_CONFIGURE;
79 g_CfgData.configSCC = CS_CONFIGURE;
80 EnableSysControlMachine(TRUE);
81 SetFocus(GetDlgItem(hDlg, IDC_SYS_CONTROL_MACHINE));
84 case IDC_DONT_CONFIGURE:
85 g_CfgData.configSCS = CS_DONT_CONFIGURE;
86 g_CfgData.configSCC = CS_DONT_CONFIGURE;
87 EnableSysControlMachine(FALSE);
90 case IDC_SYS_CONTROL_MACHINE:
91 if (HIWORD(wp) == EN_CHANGE)
92 CheckEnableNextButton();
103 * STATIC FUNCTIONS _________________________________________________________________
108 * Event Handler Functions _________________________________________________________________
111 static void OnInitDialog(HWND hwndDlg)
115 g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
116 g_pWiz->SetButtonText(IDNEXT, IDS_NEXT);
117 g_pWiz->SetDefaultControl(IDNEXT);
119 if (g_CfgData.configSCS == CS_ALREADY_CONFIGURED) {
120 CantConfig(IDS_ALREADY_A_SYS_CONTROL_SERVER);
122 } else if (g_CfgData.configSCC == CS_ALREADY_CONFIGURED) {
123 CantConfig(IDS_ALREADY_A_SYS_CONTROL_CLIENT);
127 // Should this step be disabled? Yes, if this machine
128 // is not configured as a database or file server.
129 if (!ConfiguredOrConfiguring(g_CfgData.configFS) && !ConfiguredOrConfiguring(g_CfgData.configDB)) {
130 CantConfig(IDS_SC_NOT_A_DB_OR_FS_SERVER);
131 EnableStep(g_CfgData.configSCS, FALSE);
132 EnableStep(g_CfgData.configSCC, FALSE);
136 // Do this in case they were disabled on the last run through
137 EnableStep(g_CfgData.configSCS);
138 EnableStep(g_CfgData.configSCC);
140 // If this is the first server, then it can't be a SCC
141 if (g_CfgData.bFirstServer) {
142 // Disable the SCC step
143 EnableStep(g_CfgData.configSCC, FALSE);
145 // Hide the SCC controls
146 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT_DESC, FALSE);
147 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT, FALSE);
148 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, FALSE);
149 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE, FALSE);
151 // Move remaining controls to fill the holes left from
152 // hiding the SCC controls
154 // Get position of the "Do not configure" option button; we will position
155 // the other controls relative to this one
157 GetWindowRect(GetDlgItem(hDlg, IDC_DONT_CONFIGURE), &rectDNC);
159 // Get position of the SCS option button
161 GetWindowRect(GetDlgItem(hDlg, IDC_SYS_CONTROL_SERVER), &rectSCS);
163 // Calc offset between the two
164 int nOffset = rectDNC.top - rectSCS.top;
166 // Separate the two option controls
167 nOffset -= nOptionButtonSeparationHeight;
170 MoveWnd(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, 0, nOffset);
171 MoveWnd(hDlg, IDC_SYS_CONTROL_SERVER, 0, nOffset);
173 SetWndText(hDlg, IDC_TITLE, IDS_CONFIG_SCS);
174 SetWndText(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, IDS_SYS_CONTROL_SERVER_ONLY_MSG);
175 SetWndText(hDlg, IDC_DONT_CONFIGURE, IDS_DONT_CONFIG_SYS_CONTROL_SERVER_MSG);
178 if (g_CfgData.configSCS == CS_CONFIGURE)
179 SetCheck(hDlg, IDC_SYS_CONTROL_SERVER);
180 else if (g_CfgData.configSCC == CS_CONFIGURE) {
181 SetCheck(hDlg, IDC_SYS_CONTROL_CLIENT);
182 EnableSysControlMachine(TRUE);
184 SetCheck(hDlg, IDC_DONT_CONFIGURE);
188 * Utility Functions _________________________________________________________________
191 static void CantConfig(UINT nMsgID)
193 TCHAR szMsg[cchRESOURCE];
195 GetString(szMsg, nMsgID);
197 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_QUESTION, FALSE);
198 ShowWnd(hDlg, IDC_SYS_CONTROL_SERVER, FALSE);
199 ShowWnd(hDlg, IDC_SYS_CONTROL_CLIENT, FALSE);
200 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, FALSE);
201 ShowWnd(hDlg, IDC_SYS_CONTROL_MACHINE, FALSE);
202 ShowWnd(hDlg, IDC_DONT_CONFIGURE, FALSE);
204 ShowWnd(hDlg, IDC_CANT_CONFIG_MSG);
205 SetWndText(hDlg, IDC_CANT_CONFIG_MSG, szMsg);
208 static void EnableSysControlMachine(BOOL bEnable)
210 EnableWnd(hDlg, IDC_SYS_CONTROL_MACHINE_LABEL, bEnable);
211 EnableWnd(hDlg, IDC_SYS_CONTROL_MACHINE, bEnable);
214 ShowSysControlMachine(g_CfgData.szSysControlMachine);
216 ShowSysControlMachine(TEXT(""));
218 CheckEnableNextButton();
221 static void ShowSysControlMachine(TCHAR *pszSysControlMachine)
223 SetWndText(hDlg, IDC_SYS_CONTROL_MACHINE, pszSysControlMachine);
226 static void CheckEnableNextButton()
230 if (IsButtonChecked(hDlg, IDC_SYS_CONTROL_CLIENT)) {
231 GetWndText(hDlg, IDC_SYS_CONTROL_MACHINE, g_CfgData.szSysControlMachine, MAX_MACHINE_NAME_LEN);
233 if (lstrlen(g_CfgData.szSysControlMachine) == 0)
238 g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
240 g_pWiz->EnableButtons(BACK_BUTTON);