windows-aklog-cleanup-20080321
[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 <afs/param.h>
15 #include <afs/stds.h>
16 }
17
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"
55
56
57 /*
58  * PROTOTYPES _________________________________________________________________
59  *
60  */
61
62 void Command_OnProperties (LPIDENT lpi);
63 void Command_OnIconView (HWND hDialog, BOOL fServerView, CHILDTAB iTab, int cmd);
64
65
66 /*
67  * ROUTINES ___________________________________________________________________
68  *
69  */
70
71 void StartContextCommand (HWND hDialog,
72                           LPIDENT lpiRepresentedByWindow,
73                           LPIDENT lpiChosenByClick,
74                           int cmd)
75 {
76    CHILDTAB iTab = Server_GetDisplayedTab (hDialog);
77    LPIDENT lpi = (lpiChosenByClick) ? lpiChosenByClick : lpiRepresentedByWindow;
78
79    if (lpi && lpi->fIsCell())
80       lpi = NULL;
81
82    switch (cmd)
83       {
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;
94
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;
100
101       case M_VIEW_ONEICON:
102       case M_VIEW_TWOICONS:
103       case M_VIEW_STATUS:
104          Command_OnIconView (hDialog, FALSE, iTab, cmd);
105          break;
106
107       case M_PROPERTIES:
108          if (lpi)
109             Command_OnProperties (lpi);
110          break;
111
112       case M_SUBSET:
113          ShowSubsetsDialog();
114          break;
115
116       case M_REFRESHALL:
117          if (g.lpiCell)
118             StartTask (taskREFRESH, NULL, g.lpiCell);
119          break;
120
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;
127
128       case M_SYNCVLDB:
129          if (lpi)
130             Server_SyncVLDB (lpi);
131          break;
132
133       case M_SALVAGE:
134          if (lpi)
135             Server_Salvage (lpi);
136          break;
137
138       case M_SET_CREATE:
139          Filesets_Create (lpi);
140          break;
141
142       case M_SET_REPLICATION:
143          if (lpi && lpi->fIsFileset())
144             Filesets_ShowReplication (Server_GetWindowForChild (hDialog), lpi);
145          break;
146
147       case M_SET_DELETE:
148          if (lpi && lpi->fIsFileset())
149             Filesets_Delete (lpi);
150          break;
151
152       case M_SET_CLONE:
153          Filesets_Clone (lpi);
154          break;
155
156       case M_SET_DUMP:
157          if (lpi && lpi->fIsFileset())
158             Filesets_Dump (lpi);
159          break;
160
161       case M_SET_RESTORE:
162          Filesets_Restore (lpi);
163          break;
164
165       case M_SET_RELEASE:
166          if (lpi && lpi->fIsFileset())
167             Filesets_Release (lpi);
168          break;
169
170       case M_SET_MOVETO:
171          if (lpi && lpi->fIsFileset())
172             Filesets_ShowMoveTo (lpi, NULL);
173          break;
174
175       case M_SET_SETQUOTA:
176          if (lpi && lpi->fIsFileset())
177             Filesets_SetQuota (lpi);
178          break;
179
180       case M_SET_LOCK:
181          if (lpi && lpi->fIsFileset())
182             StartTask (taskSET_LOCK, NULL, lpi);
183          break;
184
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;
191
192       case M_SET_RENAME:
193          if (lpi && lpi->fIsFileset())
194             Filesets_ShowRename (lpi);
195          break;
196
197       case M_SVR_OPEN:
198          if (lpi && lpi->fIsServer())
199             StartTask (taskSVR_GETWINDOWPOS, g.hMain, lpi);
200          break;
201
202       case M_SVR_CLOSE:
203          if (lpi && lpi->fIsServer())
204             Server_Close (lpi);
205          break;
206
207       case M_SVR_CLOSEALL:
208          Server_CloseAll (TRUE);
209          break;
210
211       case M_SVR_SECURITY:
212          Server_Security (lpi);
213          break;
214
215       case M_SVR_HOSTS:
216          Server_Hosts (lpi);
217          break;
218
219       case M_SVR_INSTALL:
220          Server_Install (lpi);
221          break;
222
223       case M_SVR_UNINSTALL:
224          Server_Uninstall (lpi);
225          break;
226
227       case M_SVR_PRUNE:
228          Server_Prune (lpi);
229          break;
230
231       case M_SVR_GETDATES:
232          Server_GetDates (lpi);
233          break;
234
235       case M_EXECUTE:
236          Server_Execute (lpi);
237          break;
238
239       case M_VIEWLOG:
240          if (lpi && lpi->fIsService())
241             Services_ShowServiceLog (lpi);
242          else
243             Services_ShowServerLog (lpi);
244          break;
245
246       case M_SVR_MONITOR:
247          if (lpi && lpi->fIsServer())
248             StartTask (taskSVR_MONITOR_ONOFF, NULL, lpi);
249          break;
250
251       case M_SVC_CREATE:
252          if (!lpi)
253             Services_Create (NULL);
254          else
255             Services_Create (lpi->GetServer());
256          break;
257
258       case M_SVC_DELETE:
259          if (lpi && lpi->fIsService())
260             Services_Delete (lpi);
261          break;
262
263       case M_SVC_START:
264          if (lpi && lpi->fIsService())
265             Services_Start (lpi);
266          break;
267
268       case M_SVC_STOP:
269          if (lpi && lpi->fIsService())
270             Services_Stop (lpi);
271          break;
272
273       case M_SVC_RESTART:
274          if (lpi && lpi->fIsService())
275             Services_Restart (lpi);
276          break;
277
278       case M_CELL_OPEN:
279          OpenCellDialog();
280          break;
281
282       case M_CREDENTIALS:
283          NewCredsDialog();
284          break;
285
286       case M_OPTIONS:
287          ShowOptionsDialog();
288          break;
289
290       case M_HELP:
291          WinHelp (g.hMain, cszHELPFILENAME, HELP_FINDER, 0);
292          break;
293
294       case M_HELP_FIND:
295          Help_FindCommand();
296          break;
297
298       case M_HELP_XLATE:
299          Help_FindError();
300          break;
301
302       case M_ABOUT:
303          Help_About();
304          break;
305       }
306 }
307
308
309 void Command_OnProperties (LPIDENT lpi)
310 {
311    if (lpi)
312       {
313       size_t nAlerts = Alert_GetCount (lpi);
314
315       if (lpi->fIsServer())
316          {
317          Server_ShowProperties (lpi, nAlerts);
318          }
319       else if (lpi->fIsService())
320          {
321          Services_ShowProperties (lpi, nAlerts);
322          }
323       else if (lpi->fIsAggregate())
324          {
325          Aggregates_ShowProperties (lpi, nAlerts);
326          }
327       else if (lpi->fIsFileset())
328          {
329          Filesets_ShowProperties (lpi, nAlerts);
330          }
331       }
332 }
333
334
335 void Command_OnIconView (HWND hDialog, BOOL fServerView, CHILDTAB iTab, int cmd)
336 {
337    ICONVIEW *piv = NULL;
338
339    if (fServerView)
340       {
341       piv = &gr.ivSvr;
342       }
343    else if (iTab == tabAGGREGATES)
344       {
345       piv = &gr.ivAgg;
346       }
347    else if (iTab == tabSERVICES)
348       {
349       piv = &gr.ivSvc;
350       }
351    else if (iTab == tabFILESETS)
352       {
353       piv = &gr.ivSet;
354       }
355
356    ICONVIEW iv;
357    switch (cmd)
358       {
359       case M_SVR_VIEW_TWOICONS:
360       case M_VIEW_TWOICONS:
361          iv = ivTWOICONS;
362          break;
363
364       case M_SVR_VIEW_STATUS:
365       case M_VIEW_STATUS:
366          iv = ivSTATUS;
367          break;
368
369       case M_SVR_VIEW_ONEICON:
370       case M_VIEW_ONEICON:
371       default:
372          iv = ivONEICON;
373          break;
374       }
375
376    if (piv)
377       {
378       UpdateDisplay_SetIconView (FALSE, hDialog, piv, iv);
379       }
380
381    if (fServerView)
382       Main_SetServerViewMenus();
383 }
384