Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrmgr / svr_execute.cpp
blobb8e9a7f5924b98913b4fcbd7143484e9604fd094
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 "svr_execute.h"
20 #include "propcache.h"
23 * PROTOTYPES _________________________________________________________________
27 BOOL WINAPI Server_Execute_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
29 void Server_Execute_OnInitDialog (HWND hDlg, LPSVR_EXECUTE_PARAMS lpp);
30 void Server_Execute_OnEndTask_InitDialog (HWND hDlg, LPTASKPACKET ptp, LPSVR_EXECUTE_PARAMS lpp);
31 void Server_Execute_EnableOK (HWND hDlg);
32 void Server_Execute_OnOK (HWND hDlg);
36 * ROUTINES ___________________________________________________________________
40 void Server_Execute (LPIDENT lpiServer)
42 HWND hCurrent;
44 if ((hCurrent = PropCache_Search (pcSVR_EXECUTE, NULL)) != NULL)
46 SetFocus (hCurrent);
48 else
50 LPSVR_EXECUTE_PARAMS lpp = New (SVR_EXECUTE_PARAMS);
51 lpp->lpiServer = lpiServer;
52 lpp->szCommand[0] = TEXT('\0');
54 HWND hDlg = ModelessDialogParam (IDD_SVR_EXECUTE, NULL, (DLGPROC)Server_Execute_DlgProc, (LPARAM)lpp);
55 ShowWindow (hDlg, SW_SHOW);
60 BOOL WINAPI Server_Execute_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
62 if (AfsAppLib_HandleHelp (IDD_SVR_EXECUTE, hDlg, msg, wp, lp))
63 return TRUE;
65 LPSVR_EXECUTE_PARAMS lpp;
67 if (msg == WM_INITDIALOG)
68 SetWindowLongPtr (hDlg, DWLP_USER, lp);
70 if ((lpp = (LPSVR_EXECUTE_PARAMS)GetWindowLongPtr(hDlg,DWLP_USER)) != NULL)
72 switch (msg)
74 case WM_INITDIALOG:
75 PropCache_Add (pcSVR_EXECUTE, NULL, hDlg);
76 Server_Execute_OnInitDialog (hDlg, lpp);
77 break;
79 case WM_ENDTASK:
80 LPTASKPACKET ptp;
81 if ((ptp = (LPTASKPACKET)lp) != NULL)
83 if (ptp->idTask == taskSVR_ENUM_TO_COMBOBOX)
84 Server_Execute_OnEndTask_InitDialog (hDlg, ptp, lpp);
85 FreeTaskPacket (ptp);
87 break;
89 case WM_COMMAND:
90 switch (LOWORD(wp))
92 case IDOK:
93 Server_Execute_OnOK (hDlg);
94 DestroyWindow (hDlg);
95 break;
97 case IDCANCEL:
98 DestroyWindow (hDlg);
99 break;
101 case IDC_SERVER:
102 case IDC_COMMAND:
103 Server_Execute_EnableOK (hDlg);
104 break;
106 break;
108 case WM_DESTROY:
109 Delete (lpp);
110 SetWindowLongPtr (hDlg, DWLP_USER, 0);
111 PropCache_Delete (pcSVR_EXECUTE, NULL);
112 break;
116 return FALSE;
120 void Server_Execute_OnInitDialog (HWND hDlg, LPSVR_EXECUTE_PARAMS lpp)
122 LPSVR_ENUM_TO_COMBOBOX_PACKET lppEnum = New (SVR_ENUM_TO_COMBOBOX_PACKET);
123 lppEnum->hCombo = GetDlgItem (hDlg, IDC_SERVER);
124 lppEnum->lpiSelect = lpp->lpiServer;
125 StartTask (taskSVR_ENUM_TO_COMBOBOX, hDlg, lppEnum);
127 EnableWindow (GetDlgItem (hDlg, IDC_SERVER), FALSE);
128 EnableWindow (GetDlgItem (hDlg, IDOK), FALSE);
132 void Server_Execute_OnEndTask_InitDialog (HWND hDlg, LPTASKPACKET ptp, LPSVR_EXECUTE_PARAMS lpp)
134 EnableWindow (GetDlgItem (hDlg, IDC_SERVER), TRUE);
135 Server_Execute_EnableOK (hDlg);
139 void Server_Execute_EnableOK (HWND hDlg)
141 LPIDENT lpiServer = NULL;
143 if (IsWindowEnabled (GetDlgItem (hDlg, IDC_SERVER)))
144 lpiServer = (LPIDENT)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SERVER));
146 BOOL fEnable = (lpiServer != NULL) ? TRUE : FALSE;
148 if (fEnable)
150 TCHAR szCommand[ MAX_PATH ];
151 GetDlgItemText (hDlg, IDC_COMMAND, szCommand, MAX_PATH);
152 if (szCommand[0] == TEXT('\0'))
153 fEnable = FALSE;
156 EnableWindow (GetDlgItem (hDlg, IDOK), fEnable);
160 void Server_Execute_OnOK (HWND hDlg)
162 LPSVR_EXECUTE_PARAMS lpp = New (SVR_EXECUTE_PARAMS);
163 lpp->lpiServer = (LPIDENT)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SERVER));
164 GetDlgItemText (hDlg, IDC_COMMAND, lpp->szCommand, MAX_PATH);
166 StartTask (taskSVR_EXECUTE, NULL, lpp);