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