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