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 _________________________________________________________________
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
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
))
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
;
87 g_pWiz
->SetState (sidSTEP_FIVE
);
92 g_pWiz
->SetState (sidSTEP_TWO
);
95 case IDC_USE_NEXT_UID
:
100 case IDC_USE_THIS_UID
:
102 CheckEnableButtons();
107 case IDC_VERIFY_ADMIN_PW
:
109 if (HIWORD(wp
) == EN_CHANGE
)
110 CheckEnableButtons();
121 * STATIC FUNCTIONS _________________________________________________________________
126 * Event Handler Functions _________________________________________________________________
129 static void OnInitDialog(HWND hwndDlg
)
133 g_pWiz
->EnableButtons(BACK_BUTTON
);
135 SetUpDownRange(hDlg
, IDC_AFS_UID_SPINNER
, MIN_AFS_UID
, MAX_AFS_UID
);
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;
171 g_pWiz
->EnableButtons(BACK_BUTTON
);
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
);
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
);