2 * Copyright 2000, International Business Machines Corporation and others.
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
14 #include <afs/param.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
)
44 if ((hCurrent
= PropCache_Search (pcSVR_EXECUTE
, NULL
)) != NULL
)
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
))
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
)
75 PropCache_Add (pcSVR_EXECUTE
, NULL
, hDlg
);
76 Server_Execute_OnInitDialog (hDlg
, lpp
);
81 if ((ptp
= (LPTASKPACKET
)lp
) != NULL
)
83 if (ptp
->idTask
== taskSVR_ENUM_TO_COMBOBOX
)
84 Server_Execute_OnEndTask_InitDialog (hDlg
, ptp
, lpp
);
93 Server_Execute_OnOK (hDlg
);
103 Server_Execute_EnableOK (hDlg
);
110 SetWindowLongPtr (hDlg
, DWLP_USER
, 0);
111 PropCache_Delete (pcSVR_EXECUTE
, NULL
);
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
;
150 TCHAR szCommand
[ MAX_PATH
];
151 GetDlgItemText (hDlg
, IDC_COMMAND
, szCommand
, MAX_PATH
);
152 if (szCommand
[0] == TEXT('\0'))
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
);