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
11 #include <afs/param.h>
16 #include "svc_create.h"
17 #include "svc_general.h"
18 #include "propcache.h"
22 * PROTOTYPES _________________________________________________________________
26 BOOL CALLBACK Services_Create_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
28 void Services_Create_OnInitDialog (HWND hDlg, LPIDENT lpi);
29 void Services_Create_OnType (HWND hDlg);
30 void Services_Create_OnApply (HWND hDlg);
31 void Services_Create_EnableOK (HWND hDlg);
35 * ROUTINES ___________________________________________________________________
39 void Services_Create (LPIDENT lpiServer)
43 if ((hCurrent = PropCache_Search (pcSVC_CREATE, NULL)) != NULL)
49 LPPROPSHEET psh = PropSheet_Create (IDS_SVC_ADD_TITLE, FALSE);
50 psh->sh.dwFlags |= PSH_NOAPPLYNOW;
52 PropSheet_AddTab (psh, IDS_SVC_ADD_TAB, IDD_SVC_CREATE, (DLGPROC)Services_Create_DlgProc, (LPARAM)lpiServer, TRUE);
53 PropSheet_ShowModeless (psh);
58 BOOL CALLBACK Services_Create_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
60 if (AfsAppLib_HandleHelp (IDD_SVC_CREATE, hDlg, msg, wp, lp))
65 case WM_INITDIALOG_SHEET:
66 PropCache_Add (pcSVC_CREATE, NULL, hDlg);
69 case WM_DESTROY_SHEET:
70 PropCache_Delete (hDlg);
74 Services_Create_OnInitDialog (hDlg, (LPIDENT)( ((LPPROPSHEETPAGE)lp)->lParam ));
81 Services_Create_OnApply (hDlg);
85 TCHAR szService[ cchNAME ];
86 GetDlgItemText (hDlg, IDC_SVC_NAME, szService, cchNAME);
88 TCHAR szLogFile[ MAX_PATH ];
89 Services_GuessLogName (szLogFile, szService);
90 if (szLogFile[0] != TEXT('\0'))
91 SetDlgItemText (hDlg, IDC_SVC_LOGFILE, szLogFile);
93 Services_Create_EnableOK (hDlg);
97 Services_Create_EnableOK (hDlg);
100 case IDC_SVC_TYPE_SIMPLE:
101 case IDC_SVC_TYPE_CRON:
102 Services_Create_OnType (hDlg);
112 void Services_Create_OnInitDialog (HWND hDlg, LPIDENT lpi)
114 CheckDlgButton (hDlg, IDC_SVC_TYPE_SIMPLE, TRUE);
115 CheckDlgButton (hDlg, IDC_SVC_RUNNOW, TRUE);
117 LPSVR_ENUM_TO_COMBOBOX_PACKET lpp = New (SVR_ENUM_TO_COMBOBOX_PACKET);
118 lpp->hCombo = GetDlgItem (hDlg, IDC_SVC_SERVER);
119 lpp->lpiSelect = lpi;
120 StartTask (taskSVR_ENUM_TO_COMBOBOX, hDlg, lpp);
122 HWND hName = GetDlgItem (hDlg, IDC_SVC_NAME);
123 CB_StartChange (hName, TRUE);
124 CB_AddItem (hName, TEXT("buserver"), 0);
125 CB_AddItem (hName, TEXT("fileserver"), 0);
126 CB_AddItem (hName, TEXT("kaserver"), 0);
127 CB_AddItem (hName, TEXT("ptserver"), 0);
128 CB_AddItem (hName, TEXT("salvager"), 0);
129 CB_AddItem (hName, TEXT("upclient"), 0);
130 CB_AddItem (hName, TEXT("upserver"), 0);
131 CB_AddItem (hName, TEXT("vlserver"), 0);
132 CB_AddItem (hName, TEXT("volserver"), 0);
133 CB_EndChange (hName, 0);
135 Services_Create_EnableOK (hDlg);
136 Services_Create_OnType (hDlg);
140 void Services_Create_OnType (HWND hDlg)
143 if (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_FS))
144 type = SERVICETYPE_FS;
145 else if (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_CRON))
146 type = SERVICETYPE_CRON;
147 else // (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_SIMPLE))
148 type = SERVICETYPE_SIMPLE;
150 EnableWindow (GetDlgItem (hDlg, IDC_SVC_RUNNOW), (type == SERVICETYPE_SIMPLE));
151 EnableWindow (GetDlgItem (hDlg, IDC_SVC_RUNDAY), (type == SERVICETYPE_CRON));
152 EnableWindow (GetDlgItem (hDlg, IDC_SVC_RUNTIME), (type == SERVICETYPE_CRON));
154 HWND hDay = GetDlgItem (hDlg, IDC_SVC_RUNDAY);
155 CB_StartChange (hDay, TRUE);
156 CB_AddItem (hDay, IDS_RECUR_DAILY, -1);
157 CB_AddItem (hDay, IDS_RECUR_SUNDAY, 0);
158 CB_AddItem (hDay, IDS_RECUR_MONDAY, 1);
159 CB_AddItem (hDay, IDS_RECUR_TUESDAY, 2);
160 CB_AddItem (hDay, IDS_RECUR_WEDNESDAY, 3);
161 CB_AddItem (hDay, IDS_RECUR_THURSDAY, 4);
162 CB_AddItem (hDay, IDS_RECUR_FRIDAY, 5);
163 CB_AddItem (hDay, IDS_RECUR_SATURDAY, 6);
164 CB_EndChange (hDay, -1);
168 void Services_Create_OnApply (HWND hDlg)
170 LPSVC_CREATE_PARAMS lpp = New (SVC_CREATE_PARAMS);
171 lpp->lpiServer = (LPIDENT)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SVC_SERVER));
172 GetDlgItemText (hDlg, IDC_SVC_NAME, lpp->szService, cchNAME);
173 GetDlgItemText (hDlg, IDC_SVC_COMMAND, lpp->szCommand, cchNAME);
174 GetDlgItemText (hDlg, IDC_SVC_PARAMS, lpp->szParams, cchNAME);
175 GetDlgItemText (hDlg, IDC_SVC_LOGFILE, lpp->szLogFile, cchNAME);
176 GetDlgItemText (hDlg, IDC_SVC_NOTIFIER, lpp->szNotifier, cchNAME);
178 if (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_FS))
179 lpp->type = SERVICETYPE_FS;
180 else if (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_CRON))
181 lpp->type = SERVICETYPE_CRON;
182 else // (IsDlgButtonChecked (hDlg, IDC_SVC_TYPE_SIMPLE))
183 lpp->type = SERVICETYPE_SIMPLE;
185 if (lpp->type == SERVICETYPE_SIMPLE)
187 lpp->fRunNow = IsDlgButtonChecked (hDlg, IDC_SVC_RUNNOW);
189 else if (lpp->type == SERVICETYPE_CRON)
191 TI_GetTime (GetDlgItem (hDlg, IDC_SVC_RUNTIME), &lpp->stIfCron);
192 lpp->stIfCron.wDayOfWeek = (WORD)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SVC_RUNDAY));
193 // wDayOfWeek: -1==daily, 0==sunday etc
196 StartTask (taskSVC_CREATE, NULL, lpp);
200 void Services_Create_EnableOK (HWND hDlg)
204 if (!IsWindowEnabled (GetDlgItem (hDlg, IDC_SVC_SERVER)))
209 TCHAR szText[ cchRESOURCE ];
210 GetDlgItemText (hDlg, IDC_SVC_NAME, szText, cchRESOURCE);
211 if (szText[0] == TEXT('\0'))
217 TCHAR szText[ cchRESOURCE ];
218 GetDlgItemText (hDlg, IDC_SVC_COMMAND, szText, cchRESOURCE);
219 if (szText[0] == TEXT('\0'))
223 EnableWindow (GetDlgItem (GetParent(hDlg), IDOK), fEnable);