Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrmgr / command.cpp
blob0a018bb2f57d938002648941838f763e8f64a7cd
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 */
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
13 extern "C" {
14 #include <afs/param.h>
15 #include <afs/stds.h>
18 #include "svrmgr.h"
19 #include "command.h"
20 #include "columns.h"
21 #include "subset.h"
22 #include "creds.h"
23 #include "task.h"
24 #include "helpfunc.h"
25 #include "options.h"
26 #include "display.h"
27 #include "svr_window.h"
28 #include "svr_security.h"
29 #include "svr_syncvldb.h"
30 #include "svr_salvage.h"
31 #include "svc_create.h"
32 #include "svc_delete.h"
33 #include "svc_startstop.h"
34 #include "svc_viewlog.h"
35 #include "svr_prop.h"
36 #include "svr_install.h"
37 #include "svr_uninstall.h"
38 #include "svr_prune.h"
39 #include "svr_getdates.h"
40 #include "svr_execute.h"
41 #include "svr_hosts.h"
42 #include "svc_prop.h"
43 #include "agg_prop.h"
44 #include "set_prop.h"
45 #include "set_repprop.h"
46 #include "set_create.h"
47 #include "set_delete.h"
48 #include "set_move.h"
49 #include "set_quota.h"
50 #include "set_rename.h"
51 #include "set_release.h"
52 #include "set_clone.h"
53 #include "set_dump.h"
54 #include "set_restore.h"
58 * PROTOTYPES _________________________________________________________________
62 void Command_OnProperties (LPIDENT lpi);
63 void Command_OnIconView (HWND hDialog, BOOL fServerView, CHILDTAB iTab, int cmd);
67 * ROUTINES ___________________________________________________________________
71 void StartContextCommand (HWND hDialog,
72 LPIDENT lpiRepresentedByWindow,
73 LPIDENT lpiChosenByClick,
74 int cmd)
76 CHILDTAB iTab = Server_GetDisplayedTab (hDialog);
77 LPIDENT lpi = (lpiChosenByClick) ? lpiChosenByClick : lpiRepresentedByWindow;
79 if (lpi && lpi->fIsCell())
80 lpi = NULL;
82 switch (cmd)
84 case M_COLUMNS:
85 if (iTab == tabSERVICES)
86 ShowColumnsDialog (hDialog, &gr.viewSvc);
87 else if (iTab == tabAGGREGATES)
88 ShowColumnsDialog (hDialog, &gr.viewAgg);
89 else if (iTab == tabFILESETS)
90 ShowColumnsDialog (hDialog, &gr.viewSet);
91 else
92 ShowColumnsDialog (hDialog, NULL);
93 break;
95 case M_SVR_VIEW_ONEICON:
96 case M_SVR_VIEW_TWOICONS:
97 case M_SVR_VIEW_STATUS:
98 Command_OnIconView (hDialog, TRUE, iTab, cmd);
99 break;
101 case M_VIEW_ONEICON:
102 case M_VIEW_TWOICONS:
103 case M_VIEW_STATUS:
104 Command_OnIconView (hDialog, FALSE, iTab, cmd);
105 break;
107 case M_PROPERTIES:
108 if (lpi)
109 Command_OnProperties (lpi);
110 break;
112 case M_SUBSET:
113 ShowSubsetsDialog();
114 break;
116 case M_REFRESHALL:
117 if (g.lpiCell)
118 StartTask (taskREFRESH, NULL, g.lpiCell);
119 break;
121 case M_REFRESH:
122 if (lpi)
123 StartTask (taskREFRESH, NULL, lpi);
124 else if (g.lpiCell)
125 StartTask (taskREFRESH, NULL, g.lpiCell);
126 break;
128 case M_SYNCVLDB:
129 if (lpi)
130 Server_SyncVLDB (lpi);
131 break;
133 case M_SALVAGE:
134 if (lpi)
135 Server_Salvage (lpi);
136 break;
138 case M_SET_CREATE:
139 Filesets_Create (lpi);
140 break;
142 case M_SET_REPLICATION:
143 if (lpi && lpi->fIsFileset())
144 Filesets_ShowReplication (Server_GetWindowForChild (hDialog), lpi);
145 break;
147 case M_SET_DELETE:
148 if (lpi && lpi->fIsFileset())
149 Filesets_Delete (lpi);
150 break;
152 case M_SET_CLONE:
153 Filesets_Clone (lpi);
154 break;
156 case M_SET_DUMP:
157 if (lpi && lpi->fIsFileset())
158 Filesets_Dump (lpi);
159 break;
161 case M_SET_RESTORE:
162 Filesets_Restore (lpi);
163 break;
165 case M_SET_RELEASE:
166 if (lpi && lpi->fIsFileset())
167 Filesets_Release (lpi);
168 break;
170 case M_SET_MOVETO:
171 if (lpi && lpi->fIsFileset())
172 Filesets_ShowMoveTo (lpi, NULL);
173 break;
175 case M_SET_SETQUOTA:
176 if (lpi && lpi->fIsFileset())
177 Filesets_SetQuota (lpi);
178 break;
180 case M_SET_LOCK:
181 if (lpi && lpi->fIsFileset())
182 StartTask (taskSET_LOCK, NULL, lpi);
183 break;
185 case M_SET_UNLOCK:
186 if (lpi && !lpi->fIsService())
187 StartTask (taskSET_UNLOCK, NULL, lpi);
188 else if (!lpi && g.lpiCell)
189 StartTask (taskSET_UNLOCK, NULL, g.lpiCell);
190 break;
192 case M_SET_RENAME:
193 if (lpi && lpi->fIsFileset())
194 Filesets_ShowRename (lpi);
195 break;
197 case M_SVR_OPEN:
198 if (lpi && lpi->fIsServer())
199 StartTask (taskSVR_GETWINDOWPOS, g.hMain, lpi);
200 break;
202 case M_SVR_CLOSE:
203 if (lpi && lpi->fIsServer())
204 Server_Close (lpi);
205 break;
207 case M_SVR_CLOSEALL:
208 Server_CloseAll (TRUE);
209 break;
211 case M_SVR_SECURITY:
212 Server_Security (lpi);
213 break;
215 case M_SVR_HOSTS:
216 Server_Hosts (lpi);
217 break;
219 case M_SVR_INSTALL:
220 Server_Install (lpi);
221 break;
223 case M_SVR_UNINSTALL:
224 Server_Uninstall (lpi);
225 break;
227 case M_SVR_PRUNE:
228 Server_Prune (lpi);
229 break;
231 case M_SVR_GETDATES:
232 Server_GetDates (lpi);
233 break;
235 case M_EXECUTE:
236 Server_Execute (lpi);
237 break;
239 case M_VIEWLOG:
240 if (lpi && lpi->fIsService())
241 Services_ShowServiceLog (lpi);
242 else
243 Services_ShowServerLog (lpi);
244 break;
246 case M_SVR_MONITOR:
247 if (lpi && lpi->fIsServer())
248 StartTask (taskSVR_MONITOR_ONOFF, NULL, lpi);
249 break;
251 case M_SVC_CREATE:
252 if (!lpi)
253 Services_Create (NULL);
254 else
255 Services_Create (lpi->GetServer());
256 break;
258 case M_SVC_DELETE:
259 if (lpi && lpi->fIsService())
260 Services_Delete (lpi);
261 break;
263 case M_SVC_START:
264 if (lpi && lpi->fIsService())
265 Services_Start (lpi);
266 break;
268 case M_SVC_STOP:
269 if (lpi && lpi->fIsService())
270 Services_Stop (lpi);
271 break;
273 case M_SVC_RESTART:
274 if (lpi && lpi->fIsService())
275 Services_Restart (lpi);
276 break;
278 case M_CELL_OPEN:
279 OpenCellDialog();
280 break;
282 case M_CREDENTIALS:
283 NewCredsDialog();
284 break;
286 case M_OPTIONS:
287 ShowOptionsDialog();
288 break;
290 case M_HELP:
291 WinHelp (g.hMain, cszHELPFILENAME, HELP_FINDER, 0);
292 break;
294 case M_HELP_FIND:
295 Help_FindCommand();
296 break;
298 case M_HELP_XLATE:
299 Help_FindError();
300 break;
302 case M_ABOUT:
303 Help_About();
304 break;
309 void Command_OnProperties (LPIDENT lpi)
311 if (lpi)
313 size_t nAlerts = Alert_GetCount (lpi);
315 if (lpi->fIsServer())
317 Server_ShowProperties (lpi, nAlerts);
319 else if (lpi->fIsService())
321 Services_ShowProperties (lpi, nAlerts);
323 else if (lpi->fIsAggregate())
325 Aggregates_ShowProperties (lpi, nAlerts);
327 else if (lpi->fIsFileset())
329 Filesets_ShowProperties (lpi, nAlerts);
335 void Command_OnIconView (HWND hDialog, BOOL fServerView, CHILDTAB iTab, int cmd)
337 ICONVIEW *piv = NULL;
339 if (fServerView)
341 piv = &gr.ivSvr;
343 else if (iTab == tabAGGREGATES)
345 piv = &gr.ivAgg;
347 else if (iTab == tabSERVICES)
349 piv = &gr.ivSvc;
351 else if (iTab == tabFILESETS)
353 piv = &gr.ivSet;
356 ICONVIEW iv;
357 switch (cmd)
359 case M_SVR_VIEW_TWOICONS:
360 case M_VIEW_TWOICONS:
361 iv = ivTWOICONS;
362 break;
364 case M_SVR_VIEW_STATUS:
365 case M_VIEW_STATUS:
366 iv = ivSTATUS;
367 break;
369 case M_SVR_VIEW_ONEICON:
370 case M_VIEW_ONEICON:
371 default:
372 iv = ivONEICON;
373 break;
376 if (piv)
378 UpdateDisplay_SetIconView (FALSE, hDialog, piv, iv);
381 if (fServerView)
382 Main_SetServerViewMenus();