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 <afs/param.h>
27 * DEFINITIONS _________________________________________________________________
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
))
61 OnInitDialog(hwndDlg
);
67 g_pWiz
->SetState(sidSTEP_TWELVE
);
71 g_pWiz
->SetState(sidSTEP_TEN
);
74 case IDC_SYS_CONTROL_SERVER
:
75 g_CfgData
.configSCS
= CS_CONFIGURE
;
76 g_CfgData
.configSCC
= CS_DONT_CONFIGURE
;
77 EnableSysControlMachine(FALSE
);
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
));
87 case IDC_DONT_CONFIGURE
:
88 g_CfgData
.configSCS
= CS_DONT_CONFIGURE
;
89 g_CfgData
.configSCC
= CS_DONT_CONFIGURE
;
90 EnableSysControlMachine(FALSE
);
93 case IDC_SYS_CONTROL_MACHINE
:
94 if (HIWORD(wp
) == EN_CHANGE
)
95 CheckEnableNextButton();
105 * STATIC FUNCTIONS _________________________________________________________________
110 * Event Handler Functions _________________________________________________________________
113 static void OnInitDialog(HWND 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
);
124 } else if (g_CfgData
.configSCC
== CS_ALREADY_CONFIGURED
) {
125 CantConfig(IDS_ALREADY_A_SYS_CONTROL_CLIENT
);
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
);
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
159 GetWindowRect(GetDlgItem(hDlg
, IDC_DONT_CONFIGURE
), &rectDNC
);
161 // Get position of the SCS option button
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
;
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
);
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
);
216 ShowSysControlMachine(g_CfgData
.szSysControlMachine
);
218 ShowSysControlMachine(TEXT(""));
220 CheckEnableNextButton();
223 static void ShowSysControlMachine(TCHAR
*pszSysControlMachine
)
225 SetWndText(hDlg
, IDC_SYS_CONTROL_MACHINE
, pszSysControlMachine
);
228 static void CheckEnableNextButton()
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)
240 g_pWiz
->EnableButtons(BACK_BUTTON
| NEXT_BUTTON
);
242 g_pWiz
->EnableButtons(BACK_BUTTON
);