Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrcfg / info_page.cpp
blobf418c3fef5932ce850ecb2aa78c25a586932d4c3
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
34 * PROTOTYPES _________________________________________________________________
37 static void OnInitDialog(HWND hwndDlg);
38 static void CheckEnableButtons();
39 static BOOL SavePageInfo();
40 static void ShowPageInfo();
41 static void IsFirstServer(BOOL bIs = TRUE);
45 * EXPORTED FUNCTIONS _________________________________________________________________
50 * Dialog Procs _________________________________________________________________
53 BOOL CALLBACK InfoPageDlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp)
55 if (WizStep_Common_DlgProc (hRHS, msg, wp, lp))
56 return FALSE;
58 switch (msg) {
59 case WM_INITDIALOG:
60 OnInitDialog(hRHS);
61 break;
63 case WM_COMMAND:
64 switch (LOWORD(wp)) {
65 case IDNEXT:
66 if (SavePageInfo())
67 g_pWiz->SetState (sidSTEP_THREE);
68 break;
70 case IDBACK:
71 if (SavePageInfo())
72 g_pWiz->SetState (sidSTEP_ONE);
73 break;
75 case IDC_FIRST_SERVER:
76 IsFirstServer();
77 break;
79 case IDC_JOIN_EXISTING_CELL:
80 IsFirstServer(FALSE);
81 break;
83 case IDC_CELL_NAME:
84 case IDC_SERVER_PW:
85 case IDC_VERIFY_PW:
86 if (HIWORD(wp) == EN_CHANGE)
87 CheckEnableButtons();
88 break;
91 break;
94 return FALSE;
98 * STATIC FUNCTIONS ________________________________________________________________________
103 * Event Handler Functions _________________________________________________________________
106 static void OnInitDialog(HWND hwndDlg)
108 hDlg = hwndDlg;
110 g_pWiz->EnableButtons(BACK_BUTTON);
112 ShowPageInfo();
114 if (g_CfgData.bFirstServer)
115 IsFirstServer();
117 g_pWiz->SetDefaultControl(IDC_CELL_NAME);
122 * Utility Functions _________________________________________________________________
125 static void CheckEnableButtons()
127 BOOL bDisable = FALSE;
129 TCHAR szCellName[cchRESOURCE];
130 TCHAR szPW[cchRESOURCE];
131 TCHAR szVerifyPW[cchRESOURCE];
133 bDisable = lstrlen(GetWndText(hDlg, IDC_CELL_NAME, szCellName)) == 0;
135 GetWndText(hDlg, IDC_SERVER_PW, szPW);
136 GetWndText(hDlg, IDC_VERIFY_PW, szVerifyPW);
138 if (IsButtonChecked(hDlg, IDC_FIRST_SERVER))
139 bDisable |= !lstrlen(szPW) || !lstrlen(szVerifyPW) || lstrcmp(szPW, szVerifyPW);
141 if (bDisable)
142 g_pWiz->EnableButtons(BACK_BUTTON);
143 else
144 g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
147 static BOOL SavePageInfo()
149 TCHAR szText[cchRESOURCE];
151 GetWndText(hDlg, IDC_CELL_NAME, szText);
152 if (lstrlen(szText) > MAX_CELL_NAME_LEN) {
153 MsgBox(hDlg, IDS_CELL_NAME_LEN_ERROR, GetAppTitleID(), MB_ICONSTOP | MB_OK);
154 return FALSE;
157 lstrcpy(g_CfgData.szCellName, szText);
158 lstrncpy(g_CfgData.szServerPW, GetWndText(hDlg, IDC_SERVER_PW, szText), MAX_SERVER_PW_LEN);
159 g_CfgData.bFirstServer = IsButtonChecked(hDlg, IDC_FIRST_SERVER);
161 return TRUE;
164 static void ShowPageInfo()
166 SetWndText(hDlg, IDC_CELL_NAME, g_CfgData.szCellName);
167 SetWndText(hDlg, IDC_SERVER_PW, g_CfgData.szServerPW);
168 SetWndText(hDlg, IDC_VERIFY_PW, g_CfgData.szServerPW);
170 if (g_CfgData.bFirstServer)
171 SetCheck(hDlg, IDC_FIRST_SERVER);
172 else
173 SetCheck(hDlg, IDC_JOIN_EXISTING_CELL);
176 static void IsFirstServer(BOOL bIs)
178 ENABLE_STATE es;
180 if (bIs)
181 es = ES_ENABLE;
182 else
183 es = ES_DISABLE;
185 SetEnable(hDlg, IDC_PRINCIPAL_LABEL, es);
186 SetEnable(hDlg, IDC_PRINCIPAL, es);
188 SetEnable(hDlg, IDC_SERVER_PW_FRAME, es);
189 SetEnable(hDlg, IDC_SERVER_PW_LABEL, es);
190 SetEnable(hDlg, IDC_SERVER_PW_PROMPT, es);
191 SetEnable(hDlg, IDC_SERVER_PW, es);
192 SetEnable(hDlg, IDC_VERIFY_PW_LABEL, es);
193 SetEnable(hDlg, IDC_VERIFY_PW, es);
195 CheckEnableButtons();