ident-cleanup-20030619
[openafs.git] / src / WINNT / afssvrcfg / replicatition_page.cpp
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;
28
29
30 /*
31  * PROTOTYPES _________________________________________________________________
32  *
33  */
34 static void OnInitDialog(HWND hwndDlg);
35 static void ShowStatusMsg(UINT nMsgID);
36
37
38 /*
39  * EXPORTED FUNCTIONS _________________________________________________________________
40  *
41  */
42
43 /*
44  * Dialog Proc _________________________________________________________________
45  *
46  */
47 BOOL CALLBACK ReplicationPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
48 {
49         if (WizStep_Common_DlgProc (hwndDlg, msg, wp, lp))
50                 return FALSE;
51
52         switch (msg) {
53                 case WM_INITDIALOG:
54                  OnInitDialog(hwndDlg);
55                      break;
56
57                 case WM_COMMAND:
58                         switch (LOWORD(wp)) {
59                                 case IDNEXT:
60                                         g_pWiz->SetState(sidSTEP_ELEVEN);
61                                         break;
62
63                                 case IDBACK:
64                                    g_pWiz->SetState(sidSTEP_NINE);
65                                    break;
66
67                                 case IDC_DONT_REPLICATE:
68                                         g_CfgData.configRep = CS_DONT_CONFIGURE;
69                                         break;
70
71                                 case IDC_REPLICATE:
72                                         g_CfgData.configRep = CS_CONFIGURE;
73                                         break;
74                         }
75                 break;
76
77         }
78
79         return FALSE;
80 }
81
82
83
84 /*
85  * STATIC FUNCTIONS _________________________________________________________________
86  *
87  */
88
89 /*
90  * Event Handler Functions _________________________________________________________________
91  *
92  */
93 static void OnInitDialog(HWND hwndDlg)
94 {
95         hDlg = hwndDlg;
96
97         g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
98         g_pWiz->SetButtonText(IDNEXT, IDS_NEXT);
99         g_pWiz->SetDefaultControl(IDNEXT);
100
101         if (g_CfgData.bFirstServer) {
102                 ShowStatusMsg(IDS_MUST_REPLICATE);
103                 g_CfgData.configRep = CS_CONFIGURE;
104                 return;
105         }
106
107         if (g_CfgData.configRep == CS_ALREADY_CONFIGURED) {
108                 ShowStatusMsg(IDS_ALREADY_REPLICATED);
109         return;
110         }
111
112         // If the replication of the root volumes could not be determined, we'll
113         // ask the user if they want to create them if they don't already exist.
114         if (!g_CfgData.bRootVolumesReplicationKnown) {
115                 SetWndText(hDlg, IDC_REPLICATE_QUESTION, IDS_REP_ROOT_VOLUMES_IF_NECESSARY_PROMPT);
116         g_CfgData.configRep = CS_CONFIGURE;
117                 SetCheck(hDlg, IDC_REPLICATE);
118         return;
119         }
120
121         // Should this step be disabled?  Yes, if this machine does
122         // not have a root.afs volume.
123         if (!ConfiguredOrConfiguring(g_CfgData.configRootVolumes)) {
124                 ShowStatusMsg(IDS_ROOT_AFS_DOESNT_EXIST);
125                 EnableStep(g_CfgData.configRep, FALSE);
126                 return;
127         }
128
129         // Must do this in case it was disabled on the last run through
130         EnableStep(g_CfgData.configRep);
131
132         if (g_CfgData.configRep == CS_DONT_CONFIGURE)
133                 SetCheck(hDlg, IDC_DONT_REPLICATE);
134         else if (g_CfgData.configRep == CS_CONFIGURE)
135                 SetCheck(hDlg, IDC_REPLICATE);
136 }
137
138
139 /*
140  * Utility Functions _________________________________________________________________
141  *
142  */
143 static void ShowStatusMsg(UINT nMsgID)
144 {
145         TCHAR szMsg[cchRESOURCE];
146
147         GetString(szMsg, nMsgID);
148
149         ShowWnd(hDlg, IDC_REPLICATE_QUESTION, FALSE);
150         ShowWnd(hDlg, IDC_REPLICATE, FALSE);
151         ShowWnd(hDlg, IDC_DONT_REPLICATE, FALSE);
152
153         ShowWnd(hDlg, IDC_CANT_REPLICATE_MSG);
154         SetWndText(hDlg, IDC_CANT_REPLICATE_MSG, szMsg);
155 }
156