Windows: AFSVolSync creationDate based readonly volume versioning
[openafs.git] / src / WINNT / afssvrcfg / root_afs_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 #include <winsock2.h>
15 #include <ws2tcpip.h>
16
17 extern "C" {
18 #include <afs/param.h>
19 #include <afs/stds.h>
20 }
21
22 #include "afscfg.h"
23 #include "resource.h"
24
25
26 /*
27  * DEFINITIONS _________________________________________________________________
28  *
29  */
30 static HWND hDlg = 0;
31
32
33 /*
34  * PROTOTYPES _________________________________________________________________
35  *
36  */
37 static void OnInitDialog(HWND hwndDlg);
38 static void ShowStatusMsg(UINT nMsgID);
39
40
41 /*
42  * EXPORTED FUNCTIONS __________________________________________________________
43  *
44  */
45
46 /*
47  * Dialog Proc _________________________________________________________________
48  *
49  */
50 BOOL CALLBACK RootAfsPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
51 {
52     if (WizStep_Common_DlgProc (hwndDlg, msg, wp, lp))
53         return FALSE;
54
55     switch (msg) {
56     case WM_INITDIALOG:
57         OnInitDialog(hwndDlg);
58         break;
59
60     case WM_COMMAND:
61         switch (LOWORD(wp)) {
62         case IDNEXT:
63             g_pWiz->SetState(sidSTEP_TEN);
64             break;
65
66         case IDBACK:
67             g_pWiz->SetState(sidSTEP_EIGHT);
68             break;
69
70         case IDC_DONT_CREATE_ROOT_VOLUMES:
71             g_CfgData.configRootVolumes = CS_DONT_CONFIGURE;
72             break;
73
74         case IDC_CREATE_ROOT_VOLUMES:
75             g_CfgData.configRootVolumes = CS_CONFIGURE;
76             break;
77         }       
78         break;
79
80     }
81
82     return FALSE;
83 }       
84
85
86
87 /*
88  * STATIC FUNCTIONS _________________________________________________________________
89  *
90  */
91
92 /*
93  * Event Handler Functions _________________________________________________________________
94  *
95  */
96 static void OnInitDialog(HWND hwndDlg)
97 {
98     hDlg = hwndDlg;
99
100     g_pWiz->EnableButtons(BACK_BUTTON | NEXT_BUTTON);
101     g_pWiz->SetButtonText(IDNEXT, IDS_NEXT);
102     g_pWiz->SetDefaultControl(IDNEXT);
103
104     if (g_CfgData.bFirstServer) {
105         ShowStatusMsg(IDS_MUST_CREATE_ROOT_AFS);
106         g_CfgData.configRootVolumes = CS_CONFIGURE;
107         return;
108     }
109
110     if (g_CfgData.configRootVolumes == CS_ALREADY_CONFIGURED) {
111         ShowStatusMsg(IDS_ROOT_AFS_ALREADY_EXISTS);
112         return;
113     }
114
115     // If the existence of the root volumes could not be determined, we'll
116     // ask the user if they want to create them if they don't already exist.
117     if (!g_CfgData.bRootVolumesExistanceKnown) {
118         SetWndText(hDlg, IDC_ROOT_AFS_QUESTION, IDS_CREATE_ROOT_VOLUMES_IF_NECESSARY_PROMPT);
119         SetCheck(hDlg, IDC_CREATE_ROOT_VOLUMES);
120         g_CfgData.configRootVolumes = CS_CONFIGURE;
121         return;
122     }
123
124     // Should this step be disabled?  Yes, if this machine does
125     // not have a partition to make root.afs on.
126     if (!ConfiguredOrConfiguring(g_CfgData.configPartition)) {
127         ShowStatusMsg(IDS_NO_PARTITION_EXISTS);
128         EnableStep(g_CfgData.configRootVolumes, FALSE);
129         return;
130     }
131
132     // If root.afs exists already but root.cell does not exist, then 
133     // the wizard cannot make root.cell and must disable this option.  
134     // However, since the root volumes don't both exist, we will leave 
135     // this option enabled, and only disable the yes check box.
136     // TODO:  We should handle this better in a future version where we can
137     // add new messages.  The message catalog is frozen for this version
138     // so we have to handle this case without adding new messages.
139     if (g_CfgData.bRootAfsExists && !g_CfgData.bRootCellExists) {
140         EnableWnd(hDlg, IDC_CREATE_ROOT_VOLUMES, FALSE);
141         SetCheck(hDlg, IDC_DONT_CREATE_ROOT_VOLUMES);
142         g_CfgData.configRootVolumes = CS_DONT_CONFIGURE;
143         return;
144     }
145
146     // Must do this in case it was disabled on the last run through
147     EnableStep(g_CfgData.configRootVolumes);
148
149     if (g_CfgData.configRootVolumes == CS_DONT_CONFIGURE)
150         SetCheck(hDlg, IDC_DONT_CREATE_ROOT_VOLUMES);
151     else
152         SetCheck(hDlg, IDC_CREATE_ROOT_VOLUMES);
153 }       
154
155
156 /*
157  * Utility Functions _________________________________________________________________
158  *
159  */
160 static void ShowStatusMsg(UINT nMsgID)
161 {
162     TCHAR szMsg[cchRESOURCE];
163
164     GetString(szMsg, nMsgID);
165
166     // Hide the controls that are at the same position as the message
167     ShowWnd(hDlg, IDC_ROOT_AFS_QUESTION, FALSE);
168     ShowWnd(hDlg, IDC_CREATE_ROOT_VOLUMES, FALSE);
169     ShowWnd(hDlg, IDC_DONT_CREATE_ROOT_VOLUMES, FALSE);
170         
171     SetWndText(hDlg, IDC_ROOT_AFS_MSG, szMsg);
172     ShowWnd(hDlg, IDC_ROOT_AFS_MSG);
173 }
174