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 "svc_create.h"
20 #include "svc_general.h"
21 #include "propcache.h"
25 * PROTOTYPES _________________________________________________________________
29 BOOL CALLBACK Services_Create_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
31 void Services_Create_OnInitDialog (HWND hDlg, LPIDENT lpi);
32 void Services_Create_OnType (HWND hDlg);
33 void Services_Create_OnApply (HWND hDlg);
34 void Services_Create_EnableOK (HWND hDlg);
38 * ROUTINES ___________________________________________________________________
42 void Services_Create (LPIDENT lpiServer)
46 if ((hCurrent = PropCache_Search (pcSVC_CREATE, NULL)) != NULL)
52 LPPROPSHEET psh = PropSheet_Create (IDS_SVC_ADD_TITLE, FALSE);
53 psh->sh.dwFlags |= PSH_NOAPPLYNOW;
55 PropSheet_AddTab (psh, IDS_SVC_ADD_TAB, IDD_SVC_CREATE, (DLGPROC)Services_Create_DlgProc, (LPARAM)lpiServer, TRUE);
56 PropSheet_ShowModeless (psh);
61 BOOL CALLBACK Services_Create_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
63 if (AfsAppLib_HandleHelp (IDD_SVC_CREATE, hDlg, msg, wp, lp))
68 case WM_INITDIALOG_SHEET:
69 PropCache_Add (pcSVC_CREATE, NULL, hDlg);
72 case WM_DESTROY_SHEET:
73 PropCache_Delete (hDlg);
77 Services_Create_OnInitDialog (hDlg, (LPIDENT)( ((LPPROPSHEETPAGE)lp)->lParam ));
84 Services_Create_OnApply (hDlg);
88 TCHAR szService[ cchNAME ];
89 GetDlgItemText (hDlg, IDC_SVC_NAME, szService, cchNAME);
91 TCHAR szLogFile[ MAX_PATH ];
92 Services_GuessLogName (szLogFile, szService);
93 if (szLogFile[0] != TEXT('\0'))
94 SetDlgItemText (hDlg, IDC_SVC_LOGFILE, szLogFile);
96 Services_Create_EnableOK (hDlg);
100 Services_Create_EnableOK (hDlg);
103 case IDC_SVC_TYPE_SIMPLE:
104 case IDC_SVC_TYPE_CRON:
105 Services_Create_OnType (hDlg);
115 void Services_Create_OnInitDialog (HWND hDlg, LPIDENT lpi)
117 CheckDlgButton (hDlg, IDC_SVC_TYPE_SIMPLE, TRUE);
118 CheckDlgButton (hDlg, IDC_SVC_RUNNOW, TRUE);
120 LPSVR_ENUM_TO_COMBOBOX_PACKET lpp = New (SVR_ENUM_TO_COMBOBOX_PACKET);
121 lpp->hCombo = GetDlgItem (hDlg, IDC_SVC_SERVER);
122 lpp->lpiSelect = lpi;
123 StartTask (taskSVR_ENUM_TO_COMBOBOX, hDlg, lpp);
125 HWND hName = GetDlgItem (hDlg, IDC_SVC_NAME);
126 CB_StartChange (hName, TRUE);
127 CB_AddItem (hName, TEXT("buserver"), 0);
128 CB_AddItem (hName, TEXT("fileserver"), 0);
129 CB_AddItem (hName, TEXT("kaserver"), 0);
130 CB_AddItem (hName, TEXT("ptserver"), 0);
131 CB_AddItem (hName, TEXT("salvager"), 0);
132 CB_AddItem (hName, TEXT("upclient"), 0);
133 CB_AddItem (hName, TEXT("upserver"), 0);
134 CB_AddItem (hName, TEXT("vlserver"), 0);
135 CB_AddItem (hName, TEXT("volserver"), 0);
136 CB_EndChange (hName, 0);
138 Services_Create_EnableOK (hDlg);
139 Services_Create_OnType (hDlg);
143 void Services_Create_OnType (HWND hDlg)
146 if (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_FS))
147 type = SERVICETYPE_FS;
148 else if (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_CRON))
149 type = SERVICETYPE_CRON;
150 else // (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_SIMPLE))
151 type = SERVICETYPE_SIMPLE;
153 EnableWindow (GetDlgItem (hDlg, IDC_SVC_RUNNOW), (type == SERVICETYPE_SIMPLE));
154 EnableWindow (GetDlgItem (hDlg, IDC_SVC_RUNDAY), (type == SERVICETYPE_CRON));
155 EnableWindow (GetDlgItem (hDlg, IDC_SVC_RUNTIME), (type == SERVICETYPE_CRON));
157 HWND hDay = GetDlgItem (hDlg, IDC_SVC_RUNDAY);
158 CB_StartChange (hDay, TRUE);
159 CB_AddItem (hDay, IDS_RECUR_DAILY, -1);
160 CB_AddItem (hDay, IDS_RECUR_SUNDAY, 0);
161 CB_AddItem (hDay, IDS_RECUR_MONDAY, 1);
162 CB_AddItem (hDay, IDS_RECUR_TUESDAY, 2);
163 CB_AddItem (hDay, IDS_RECUR_WEDNESDAY, 3);
164 CB_AddItem (hDay, IDS_RECUR_THURSDAY, 4);
165 CB_AddItem (hDay, IDS_RECUR_FRIDAY, 5);
166 CB_AddItem (hDay, IDS_RECUR_SATURDAY, 6);
167 CB_EndChange (hDay, -1);
171 void Services_Create_OnApply (HWND hDlg)
173 LPSVC_CREATE_PARAMS lpp = New (SVC_CREATE_PARAMS);
174 lpp->lpiServer = (LPIDENT)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SVC_SERVER));
175 GetDlgItemText (hDlg, IDC_SVC_NAME, lpp->szService, cchNAME);
176 GetDlgItemText (hDlg, IDC_SVC_COMMAND, lpp->szCommand, cchNAME);
177 GetDlgItemText (hDlg, IDC_SVC_PARAMS, lpp->szParams, cchNAME);
178 GetDlgItemText (hDlg, IDC_SVC_LOGFILE, lpp->szLogFile, cchNAME);
179 GetDlgItemText (hDlg, IDC_SVC_NOTIFIER, lpp->szNotifier, cchNAME);
181 if (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_FS))
182 lpp->type = SERVICETYPE_FS;
183 else if (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_CRON))
184 lpp->type = SERVICETYPE_CRON;
185 else // (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_SIMPLE))
186 lpp->type = SERVICETYPE_SIMPLE;
188 if (lpp->type == SERVICETYPE_SIMPLE)
190 lpp->fRunNow = IsDlgButtonChecked (hDlg, IDC_SVC_RUNNOW);
192 else if (lpp->type == SERVICETYPE_CRON)
194 TI_GetTime (GetDlgItem (hDlg, IDC_SVC_RUNTIME), &lpp->stIfCron);
195 lpp->stIfCron.wDayOfWeek = (WORD)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SVC_RUNDAY));
196 // wDayOfWeek: -1==daily, 0==sunday etc
199 StartTask (taskSVC_CREATE, NULL, lpp);
203 void Services_Create_EnableOK (HWND hDlg)
207 if (!IsWindowEnabled (GetDlgItem (hDlg, IDC_SVC_SERVER)))
212 TCHAR szText[ cchRESOURCE ];
213 GetDlgItemText (hDlg, IDC_SVC_NAME, szText, cchRESOURCE);
214 if (szText[0] == TEXT('\0'))
220 TCHAR szText[ cchRESOURCE ];
221 GetDlgItemText (hDlg, IDC_SVC_COMMAND, szText, cchRESOURCE);
222 if (szText[0] == TEXT('\0'))
226 EnableWindow (GetDlgItem (GetParent(hDlg), IDOK), fEnable);