~ubuntu-branches/ubuntu/gutsy/openafs/gutsy

« back to all changes in this revision

Viewing changes to src/WINNT/afssvrcfg/info2_page.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2004-01-10 16:37:33 UTC
  • Revision ID: james.westby@ubuntu.com-20040110163733-jvr0n1uahshlb1uu
Tags: upstream-1.2.11
ImportĀ upstreamĀ versionĀ 1.2.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2000, International Business Machines Corporation and others.
 
3
 * All Rights Reserved.
 
4
 * 
 
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
 */
 
9
 
 
10
/*
 
11
 * INCLUDES _________________________________________________________________
 
12
 *
 
13
 */
 
14
extern "C" {
 
15
#include <afs/param.h>
 
16
#include <afs/stds.h>
 
17
}
 
18
 
 
19
#include "afscfg.h"
 
20
#include "resource.h"
 
21
 
 
22
 
 
23
/*
 
24
 * DEFINITIONS _________________________________________________________________
 
25
 *
 
26
 */
 
27
static HWND hDlg = 0;                           // HWND for this page's dialog
 
28
 
 
29
#define FIRST_SERVER_STEP               sidSTEP_THREE
 
30
#define NOT_FIRST_SERVER_STEP   sidSTEP_FOUR
 
31
 
 
32
#define MIN_AFS_UID             1
 
33
#define MAX_AFS_UID             UD_MAXVAL
 
34
 
 
35
 
 
36
/*
 
37
 * PROTOTYPES _________________________________________________________________
 
38
 *
 
39
 */
 
40
static void OnInitDialog(HWND hwndDlg);
 
41
static void CheckEnableButtons();
 
42
static void SavePageInfo();
 
43
static void ShowPageInfo();
 
44
static void UseNextUid(BOOL bUseNext);
 
45
 
 
46
 
 
47
/*
 
48
 * EXPORTED FUNCTIONS _________________________________________________________________
 
49
 *
 
50
 */
 
51
 
 
52
/*
 
53
 * Dialog Procs _________________________________________________________________
 
54
 *
 
55
 */
 
56
BOOL CALLBACK InfoPage2DlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp)
 
57
{
 
58
    if (WizStep_Common_DlgProc (hRHS, msg, wp, lp))
 
59
        return FALSE;
 
60
 
 
61
        switch (msg) {
 
62
                case WM_INITDIALOG:
 
63
                        OnInitDialog(hRHS);
 
64
                        break;
 
65
 
 
66
                case WM_COMMAND:
 
67
                        switch (LOWORD(wp)) {
 
68
                                case IDC_WIZARD:
 
69
                                        if (HIWORD(wp) == wcIS_STATE_DISABLED) {
 
70
                                                int nState = g_pWiz->GetState();
 
71
                                                
 
72
                                                // Disable step 3 if we are not the first server
 
73
                                                if (nState == sidSTEP_THREE)
 
74
                                                        return !g_CfgData.bFirstServer;
 
75
 
 
76
                                                // Disable step 4 if we are the first server
 
77
                                                if (nState == sidSTEP_FOUR)
 
78
                                                        return g_CfgData.bFirstServer;
 
79
                                        }
 
80
                                        break;
 
81
 
 
82
                                case IDNEXT:
 
83
                                        SavePageInfo();
 
84
                                        g_pWiz->SetState (sidSTEP_FIVE);
 
85
                                        break;
 
86
 
 
87
                                case IDBACK:
 
88
                                        SavePageInfo();
 
89
                                        g_pWiz->SetState (sidSTEP_TWO);
 
90
                                        break;
 
91
 
 
92
                                case IDC_USE_NEXT_UID:
 
93
                                        UseNextUid(TRUE);
 
94
                                        CheckEnableButtons();
 
95
                                        break;
 
96
 
 
97
                                case IDC_USE_THIS_UID:
 
98
                                        UseNextUid(FALSE);
 
99
                                        CheckEnableButtons();
 
100
                                        break;
 
101
 
 
102
                                case IDC_ADMIN_NAME:
 
103
                                case IDC_ADMIN_PW:
 
104
                                case IDC_VERIFY_ADMIN_PW:
 
105
                                case IDC_HOSTNAME:
 
106
                                        if (HIWORD(wp) == EN_CHANGE)
 
107
                                                CheckEnableButtons();
 
108
                                        break;
 
109
 
 
110
                        }
 
111
                break;
 
112
    }
 
113
 
 
114
    return FALSE;
 
115
}
 
116
 
 
117
/*
 
118
 * STATIC FUNCTIONS _________________________________________________________________
 
119
 *
 
120
 */
 
121
 
 
122
/*
 
123
 * Event Handler Functions _________________________________________________________________
 
124
 *
 
125
 */
 
126
static void OnInitDialog(HWND hwndDlg)
 
127
{
 
128
        hDlg = hwndDlg;
 
129
 
 
130
        g_pWiz->EnableButtons(BACK_BUTTON);
 
131
 
 
132
        SetUpDownRange(hDlg, IDC_AFS_UID_SPINNER, MIN_AFS_UID, MAX_AFS_UID);
 
133
 
 
134
        ShowPageInfo();
 
135
 
 
136
        g_pWiz->SetDefaultControl(IDC_ADMIN_NAME);
 
137
}
 
138
 
 
139
 
 
140
/*
 
141
 * Utility Functions _________________________________________________________________
 
142
 *
 
143
 */
 
144
static void CheckEnableButtons()
 
145
{
 
146
        BOOL bDisable = FALSE;
 
147
 
 
148
        TCHAR szDummy[cchRESOURCE];
 
149
        TCHAR szPW[cchRESOURCE];
 
150
        TCHAR szVerifyPW[cchRESOURCE];
 
151
 
 
152
        bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_NAME, szDummy)) == 0;
 
153
 
 
154
        bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_PW, szPW)) == 0;
 
155
 
 
156
        if (IsWindowEnabled(GetDlgItem(hDlg, IDC_VERIFY_ADMIN_PW))) {
 
157
                GetWndText(hDlg, IDC_VERIFY_ADMIN_PW, szVerifyPW);
 
158
                bDisable |= !lstrlen(szVerifyPW) || lstrcmp(szPW, szVerifyPW);
 
159
        }
 
160
 
 
161
        if (IsWindowEnabled(GetDlgItem(hDlg, IDC_ADMIN_UID)))
 
162
                bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_UID, szDummy)) == 0;
 
163
 
 
164
        if (IsWindowEnabled(GetDlgItem(hDlg, IDC_HOSTNAME)))
 
165
                bDisable |= lstrlen(GetWndText(hDlg, IDC_HOSTNAME, szDummy)) == 0;
 
166
 
 
167
        if (bDisable)
 
168
                g_pWiz->EnableButtons(BACK_BUTTON);
 
169
        else
 
170
                g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
 
171
}
 
172
 
 
173
static void SavePageInfo()
 
174
{
 
175
        TCHAR szText[cchRESOURCE];
 
176
        
 
177
        lstrncpy(g_CfgData.szAdminName, GetWndText(hDlg, IDC_ADMIN_NAME, szText), MAX_ADMIN_NAME_LEN);
 
178
        lstrncpy(g_CfgData.szAdminPW, GetWndText(hDlg, IDC_ADMIN_PW, szText), MAX_ADMIN_PW_LEN);
 
179
 
 
180
        if (g_pWiz->GetState() == FIRST_SERVER_STEP) {
 
181
                g_CfgData.bUseNextUid = IsButtonChecked(hDlg, IDC_USE_NEXT_UID);
 
182
                if (!g_CfgData.bUseNextUid)
 
183
                        lstrncpy(g_CfgData.szAdminUID, GetWndText(hDlg, IDC_ADMIN_UID, szText), MAX_UID_LEN);
 
184
        }
 
185
 
 
186
        if (g_pWiz->GetState() == NOT_FIRST_SERVER_STEP)
 
187
                lstrncpy(g_CfgData.szCellServDbHostname, GetWndText(hDlg, IDC_HOSTNAME, szText), MAX_MACHINE_NAME_LEN);
 
188
}
 
189
 
 
190
static void ShowPageInfo()
 
191
{
 
192
        SetWndText(hDlg, IDC_ADMIN_NAME, g_CfgData.szAdminName);
 
193
        SetWndText(hDlg, IDC_ADMIN_PW, g_CfgData.szAdminPW);
 
194
        SetWndText(hDlg, IDC_VERIFY_ADMIN_PW, g_CfgData.szAdminPW);
 
195
        SetWndText(hDlg, IDC_HOSTNAME, g_CfgData.szCellServDbHostname);
 
196
 
 
197
        if (g_pWiz->GetState() == FIRST_SERVER_STEP) {
 
198
                if (g_CfgData.bUseNextUid)
 
199
                        SetCheck(hDlg, IDC_USE_NEXT_UID);
 
200
                else
 
201
                        SetCheck(hDlg, IDC_USE_THIS_UID);
 
202
                UseNextUid(g_CfgData.bUseNextUid);
 
203
                SetWndText(hDlg, IDC_ADMIN_UID, g_CfgData.szAdminUID);
 
204
        }
 
205
}
 
206
 
 
207
static void UseNextUid(BOOL bUseNext)
 
208
{
 
209
        ENABLE_STATE es = bUseNext ? ES_DISABLE : ES_ENABLE;
 
210
        
 
211
        SetEnable(hDlg, IDC_ADMIN_UID, es);
 
212
        SetEnable(hDlg, IDC_AFS_UID_SPINNER, es);
 
213
}
 
214