Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrcfg / info2_page.cpp
blob61ce364eaf697da971e3d5d783fe79ecf85763f6
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; // HWND for this page's dialog
32 #define FIRST_SERVER_STEP sidSTEP_THREE
33 #define NOT_FIRST_SERVER_STEP sidSTEP_FOUR
35 #define MIN_AFS_UID 1
36 #define MAX_AFS_UID UD_MAXVAL
40 * PROTOTYPES _________________________________________________________________
43 static void OnInitDialog(HWND hwndDlg);
44 static void CheckEnableButtons();
45 static void SavePageInfo();
46 static void ShowPageInfo();
47 static void UseNextUid(BOOL bUseNext);
51 * EXPORTED FUNCTIONS _________________________________________________________________
56 * Dialog Procs _________________________________________________________________
59 BOOL CALLBACK InfoPage2DlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp)
61 if (WizStep_Common_DlgProc (hRHS, msg, wp, lp))
62 return FALSE;
64 switch (msg) {
65 case WM_INITDIALOG:
66 OnInitDialog(hRHS);
67 break;
69 case WM_COMMAND:
70 switch (LOWORD(wp)) {
71 case IDC_WIZARD:
72 if (HIWORD(wp) == wcIS_STATE_DISABLED) {
73 int nState = g_pWiz->GetState();
75 // Disable step 3 if we are not the first server
76 if (nState == sidSTEP_THREE)
77 return !g_CfgData.bFirstServer;
79 // Disable step 4 if we are the first server
80 if (nState == sidSTEP_FOUR)
81 return g_CfgData.bFirstServer;
83 break;
85 case IDNEXT:
86 SavePageInfo();
87 g_pWiz->SetState (sidSTEP_FIVE);
88 break;
90 case IDBACK:
91 SavePageInfo();
92 g_pWiz->SetState (sidSTEP_TWO);
93 break;
95 case IDC_USE_NEXT_UID:
96 UseNextUid(TRUE);
97 CheckEnableButtons();
98 break;
100 case IDC_USE_THIS_UID:
101 UseNextUid(FALSE);
102 CheckEnableButtons();
103 break;
105 case IDC_ADMIN_NAME:
106 case IDC_ADMIN_PW:
107 case IDC_VERIFY_ADMIN_PW:
108 case IDC_HOSTNAME:
109 if (HIWORD(wp) == EN_CHANGE)
110 CheckEnableButtons();
111 break;
114 break;
117 return FALSE;
121 * STATIC FUNCTIONS _________________________________________________________________
126 * Event Handler Functions _________________________________________________________________
129 static void OnInitDialog(HWND hwndDlg)
131 hDlg = hwndDlg;
133 g_pWiz->EnableButtons(BACK_BUTTON);
135 SetUpDownRange(hDlg, IDC_AFS_UID_SPINNER, MIN_AFS_UID, MAX_AFS_UID);
137 ShowPageInfo();
139 g_pWiz->SetDefaultControl(IDC_ADMIN_NAME);
144 * Utility Functions _________________________________________________________________
147 static void CheckEnableButtons()
149 BOOL bDisable = FALSE;
151 TCHAR szDummy[cchRESOURCE];
152 TCHAR szPW[cchRESOURCE];
153 TCHAR szVerifyPW[cchRESOURCE];
155 bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_NAME, szDummy)) == 0;
157 bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_PW, szPW)) == 0;
159 if (IsWindowEnabled(GetDlgItem(hDlg, IDC_VERIFY_ADMIN_PW))) {
160 GetWndText(hDlg, IDC_VERIFY_ADMIN_PW, szVerifyPW);
161 bDisable |= !lstrlen(szVerifyPW) || lstrcmp(szPW, szVerifyPW);
164 if (IsWindowEnabled(GetDlgItem(hDlg, IDC_ADMIN_UID)))
165 bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_UID, szDummy)) == 0;
167 if (IsWindowEnabled(GetDlgItem(hDlg, IDC_HOSTNAME)))
168 bDisable |= lstrlen(GetWndText(hDlg, IDC_HOSTNAME, szDummy)) == 0;
170 if (bDisable)
171 g_pWiz->EnableButtons(BACK_BUTTON);
172 else
173 g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
176 static void SavePageInfo()
178 TCHAR szText[cchRESOURCE];
180 lstrncpy(g_CfgData.szAdminName, GetWndText(hDlg, IDC_ADMIN_NAME, szText), MAX_ADMIN_NAME_LEN);
181 lstrncpy(g_CfgData.szAdminPW, GetWndText(hDlg, IDC_ADMIN_PW, szText), MAX_ADMIN_PW_LEN);
183 if (g_pWiz->GetState() == FIRST_SERVER_STEP) {
184 g_CfgData.bUseNextUid = IsButtonChecked(hDlg, IDC_USE_NEXT_UID);
185 if (!g_CfgData.bUseNextUid)
186 lstrncpy(g_CfgData.szAdminUID, GetWndText(hDlg, IDC_ADMIN_UID, szText), MAX_UID_LEN);
189 if (g_pWiz->GetState() == NOT_FIRST_SERVER_STEP)
190 lstrncpy(g_CfgData.szCellServDbHostname, GetWndText(hDlg, IDC_HOSTNAME, szText), MAX_MACHINE_NAME_LEN);
193 static void ShowPageInfo()
195 SetWndText(hDlg, IDC_ADMIN_NAME, g_CfgData.szAdminName);
196 SetWndText(hDlg, IDC_ADMIN_PW, g_CfgData.szAdminPW);
197 SetWndText(hDlg, IDC_VERIFY_ADMIN_PW, g_CfgData.szAdminPW);
198 SetWndText(hDlg, IDC_HOSTNAME, g_CfgData.szCellServDbHostname);
200 if (g_pWiz->GetState() == FIRST_SERVER_STEP) {
201 if (g_CfgData.bUseNextUid)
202 SetCheck(hDlg, IDC_USE_NEXT_UID);
203 else
204 SetCheck(hDlg, IDC_USE_THIS_UID);
205 UseNextUid(g_CfgData.bUseNextUid);
206 SetWndText(hDlg, IDC_ADMIN_UID, g_CfgData.szAdminUID);
210 static void UseNextUid(BOOL bUseNext)
212 ENABLE_STATE es = bUseNext ? ES_DISABLE : ES_ENABLE;
214 SetEnable(hDlg, IDC_ADMIN_UID, es);
215 SetEnable(hDlg, IDC_AFS_UID_SPINNER, es);