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>
21 #include "svc_viewlog.h"
28 * PROTOTYPES _________________________________________________________________
32 void Problems_OnInitDialog (HWND hDlg
, LPIDENT lpi
);
33 void Problems_OnRefresh (HWND hDlg
, LPIDENT lpi
);
34 void Problems_OnRedraw (HWND hDlg
, LPIDENT lpi
);
35 void Problems_OnRemedy (HWND hDlg
, LPIDENT lpi
);
39 * ROUTINES ___________________________________________________________________
43 BOOL CALLBACK
Problems_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
45 if (AfsAppLib_HandleHelp (IDD_SVR_PROBLEMS
, hDlg
, msg
, wp
, lp
))
48 if (msg
== WM_INITDIALOG
)
49 SetWindowLongPtr (hDlg
, DWLP_USER
, ((LPPROPSHEETPAGE
)lp
)->lParam
);
51 LPIDENT lpi
= (LPIDENT
)GetWindowLongPtr (hDlg
, DWLP_USER
);
56 NotifyMe (WHEN_OBJECT_CHANGES
, lpi
, hDlg
, 0);
57 Problems_OnInitDialog (hDlg
, lpi
);
58 Problems_OnRefresh (hDlg
, lpi
);
61 case WM_NOTIFY_FROM_DISPATCH
:
62 Problems_OnRefresh (hDlg
, lpi
);
63 Delete ((LPNOTIFYSTRUCT
)lp
);
67 DontNotifyMeEver (hDlg
);
73 case IDC_PROBLEM_REMEDY
:
74 Problems_OnRemedy (hDlg
, lpi
);
79 case WM_CTLCOLORSTATIC
:
80 if ((HWND
)lp
== GetDlgItem (hDlg
, IDC_PROBLEM_TEXT
))
82 SetBkColor ((HDC
)wp
, GetSysColor (COLOR_WINDOW
));
83 return CreateSolidBrush (GetSysColor (COLOR_WINDOW
))?TRUE
:FALSE
;
90 posOld
= GetScrollPos (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SB_CTL
);
119 memset (&si
, 0x00, sizeof(si
));
120 si
.cbSize
= sizeof(si
);
121 si
.fMask
= SIF_RANGE
;
122 GetScrollInfo (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SB_CTL
, &si
);
123 posNew
= limit (0, posNew
, si
.nMax
);
125 if (posNew
!= posOld
)
127 SetScrollPos (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SB_CTL
, posNew
, (LOWORD(wp
) == SB_THUMBTRACK
) ? FALSE
: TRUE
);
128 Problems_OnRedraw (hDlg
, lpi
);
137 void Problems_OnInitDialog (HWND hDlg
, LPIDENT lpi
)
139 TCHAR szText
[ cchRESOURCE
];
140 GetDlgItemText (hDlg
, IDC_PROBLEM_TITLE
, szText
, cchRESOURCE
);
142 LPTSTR pszTitle
= NULL
;
144 if (lpi
->fIsServer())
146 TCHAR szServer
[ cchNAME
];
147 lpi
->GetServerName (szServer
);
148 pszTitle
= FormatString (szText
, TEXT("%s"), szServer
);
150 else if (lpi
->fIsService())
152 TCHAR szServer
[ cchNAME
];
153 TCHAR szService
[ cchNAME
];
154 lpi
->GetServerName (szServer
);
155 lpi
->GetServiceName (szService
);
156 pszTitle
= FormatString (szText
, TEXT("%s%s"), szServer
, szService
);
158 else if (lpi
->fIsAggregate())
160 TCHAR szServer
[ cchNAME
];
161 TCHAR szAggregate
[ cchNAME
];
162 lpi
->GetServerName (szServer
);
163 lpi
->GetAggregateName (szAggregate
);
164 pszTitle
= FormatString (szText
, TEXT("%s%s"), szServer
, szAggregate
);
166 else if (lpi
->fIsFileset())
168 TCHAR szServer
[ cchNAME
];
169 TCHAR szAggregate
[ cchNAME
];
170 TCHAR szFileset
[ cchNAME
];
171 lpi
->GetServerName (szServer
);
172 lpi
->GetAggregateName (szAggregate
);
173 lpi
->GetFilesetName (szFileset
);
174 pszTitle
= FormatString (szText
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
177 if (pszTitle
== NULL
)
178 SetDlgItemText (hDlg
, IDC_PROBLEM_TITLE
, TEXT(""));
181 SetDlgItemText (hDlg
, IDC_PROBLEM_TITLE
, pszTitle
);
182 FreeString (pszTitle
);
185 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SW_HIDE
);
186 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_HEADER
), SW_HIDE
);
187 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_REMEDY
), SW_HIDE
);
188 SetDlgItemText (hDlg
, IDC_PROBLEM_TEXT
, TEXT(""));
192 void Problems_OnRefresh (HWND hDlg
, LPIDENT lpi
)
194 size_t nAlerts
= Alert_GetCount (lpi
);
196 LPTSTR pszText
= FormatString (IDS_PROBLEM_BOX
, TEXT("%lu"), nAlerts
);
197 SetDlgItemText (hDlg
, IDC_PROBLEM_BOX
, pszText
);
198 FreeString (pszText
);
203 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SW_HIDE
);
204 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_HEADER
), SW_HIDE
);
205 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_REMEDY
), SW_HIDE
);
207 TCHAR szText
[ cchRESOURCE
];
208 if (lpi
->fIsServer())
209 GetString (szText
, IDS_SERVER_NO_PROBLEMS
);
210 else if (lpi
->fIsService())
211 GetString (szText
, IDS_SERVICE_NO_PROBLEMS
);
212 else if (lpi
->fIsAggregate())
213 GetString (szText
, IDS_AGGREGATE_NO_PROBLEMS
);
214 else if (lpi
->fIsFileset())
215 GetString (szText
, IDS_FILESET_NO_PROBLEMS
);
217 wsprintf (szText
, TEXT("UNEXPECTED CONDITION in problems.cpp"));
219 SetDlgItemText (hDlg
, IDC_PROBLEM_TEXT
, szText
);
223 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SW_HIDE
);
224 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_HEADER
), SW_HIDE
);
225 Problems_OnRedraw (hDlg
, lpi
);
228 default: // two or more
229 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SW_SHOW
);
230 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_HEADER
), SW_SHOW
);
233 si
.cbSize
= sizeof(si
);
234 si
.fMask
= SIF_RANGE
| SIF_POS
| SIF_PAGE
;
236 si
.nMax
= (int)(nAlerts
-1);
241 SetScrollInfo (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SB_CTL
, &si
, TRUE
);
242 Problems_OnRedraw (hDlg
, lpi
);
248 void Problems_OnRedraw (HWND hDlg
, LPIDENT lpi
)
252 if (IsWindowVisible (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
)))
254 iAlert
= GetScrollPos (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SB_CTL
);
257 TCHAR szText
[ cchRESOURCE
];
258 wsprintf (szText
, TEXT("%lu:"), 1+iAlert
);
259 SetWindowText (GetDlgItem (hDlg
, IDC_PROBLEM_HEADER
), szText
);
261 LPTSTR pszText1
= Alert_GetDescription (lpi
, iAlert
, TRUE
);
262 LPTSTR pszText2
= Alert_GetRemedy (lpi
, iAlert
);
263 LPTSTR pszText3
= Alert_GetButton (lpi
, iAlert
);
265 LPTSTR pszProblem
= FormatString (TEXT("%1\n\n%2"), TEXT("%s%s"),
266 (pszText1
) ? pszText1
: TEXT(""),
267 (pszText2
) ? pszText2
: TEXT(""));
268 SetWindowText (GetDlgItem (hDlg
, IDC_PROBLEM_TEXT
), pszProblem
);
269 FreeString (pszProblem
);
271 if (pszText3
== NULL
)
272 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_REMEDY
), SW_HIDE
);
275 SetWindowText (GetDlgItem (hDlg
, IDC_PROBLEM_REMEDY
), pszText3
);
276 ShowWindow (GetDlgItem (hDlg
, IDC_PROBLEM_REMEDY
), SW_SHOW
);
279 FreeString (pszText3
);
280 FreeString (pszText2
);
281 FreeString (pszText1
);
285 void Problems_OnRemedy (HWND hDlg
, LPIDENT lpi
)
287 int iAlert
= GetScrollPos (GetDlgItem (hDlg
, IDC_PROBLEM_SCROLL
), SB_CTL
);
289 LPIDENT lpiTarget
= Alert_GetIdent (lpi
, iAlert
);
290 ALERT alert
= Alert_GetAlert (lpi
, iAlert
);
295 if (lpiTarget
&& lpiTarget
->fIsCell())
297 StartTask (taskREFRESH
, NULL
, lpiTarget
);
301 StartTask (taskREFRESH
, NULL
, lpiTarget
->GetServer());
306 if (lpiTarget
&& lpiTarget
->fIsFileset())
308 size_t nAlerts
= Alert_GetCount (lpiTarget
);
309 Filesets_ShowProperties (lpiTarget
, nAlerts
, TRUE
);
311 else if (lpiTarget
&& lpiTarget
->fIsAggregate())
313 size_t nAlerts
= Alert_GetCount (lpiTarget
);
314 Aggregates_ShowProperties (lpiTarget
, nAlerts
, TRUE
);
318 case alertNO_VLDBENT
:
319 // No button in this case
323 // No button in this case
327 Services_ShowServiceLog (lpiTarget
);
335 // No button in this case
338 case alertSTATE_NO_VNODE
:
339 case alertSTATE_NO_SERVICE
:
340 case alertSTATE_OFFLINE
:
341 // No button in these cases
352 void ParseFilesetName (LPIDENT lpiSearch
, LPTSTR pszBase
, LPTSTR pszEnding
)
354 TCHAR szFileset
[ cchNAME
];
355 lpiSearch
->GetFilesetName (szFileset
);
358 if ((pszDot
= (LPTSTR
)lstrrchr (szFileset
, TEXT('.'))) != NULL
)
360 if ( lstrcmpi (pszDot
, cszENDING_CLONE
) &&
361 lstrcmpi (pszDot
, cszENDING_REPLICA
) )
369 lstrcpy (pszBase
, szFileset
);
372 else // (pszDot != NULL)
374 lstrcpy (pszBase
, szFileset
);
375 lstrcpy (pszEnding
, pszDot
);
376 pszBase
[ pszEnding
- szFileset
] = TEXT('\0');