Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrmgr / dispguts.cpp
blobdff0a4a5f274ccaf4e472ed727c088d39257e0c6
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 "display.h"
20 #include "dispguts.h"
21 #include "svr_col.h"
22 #include "svr_window.h"
23 #include "svc_col.h"
24 #include "svc_startstop.h"
25 #include "agg_col.h"
26 #include "set_col.h"
27 #include "set_general.h"
28 #include "creds.h"
32 * PROTOTYPES _________________________________________________________________
36 void Display_Servers_Internal_Clean (LPDISPLAYREQUEST pdr);
37 void Display_Servers_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
39 void Display_Services_Internal_Clean (LPDISPLAYREQUEST pdr);
40 void Display_Services_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
41 void Display_Services_Internal_AddService (LPDISPLAYREQUEST pdr, LPSERVICE lpService, HLISTITEM hServer);
43 void Display_Aggregates_Internal_Clean (LPDISPLAYREQUEST pdr);
44 void Display_Aggregates_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
45 void Display_Aggregates_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer);
47 void Display_Filesets_Internal_Clean (LPDISPLAYREQUEST pdr);
48 HLISTITEM Display_Filesets_Internal_AddCell (LPDISPLAYREQUEST pdr, LPCELL lpCell);
49 void Display_Filesets_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer, HLISTITEM hCell);
50 void Display_Filesets_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer);
51 void Display_Filesets_Internal_AddFileset (LPDISPLAYREQUEST pdr, LPFILESET lpFileset, HLISTITEM hAggregate);
53 #define PIF_ALWAYSSHOWICON 0x00000001
54 #define PIF_ONLYONEICON 0x00000002
55 #define PIF_TREEVIEW_ONLY 0x00000004
56 #define PIF_DISALLOW_COLLAPSE 0x00000008
57 void Display_PickImages (int *piFirstImage, int *piSecondImage, int iTypeImage, int iStatusImage, ICONVIEW iv, DWORD dwPickImageFlags = 0);
58 HLISTITEM Display_InsertItem (HWND hList, HLISTITEM hParent, LPTSTR pszText, LPARAM lp, int iImage0 = IMAGE_NOIMAGE, int iImage1 = IMAGE_NOIMAGE, ICONVIEW iv = (ICONVIEW)-1, DWORD dwPickImageFlags = 0);
62 * CELL _______________________________________________________________________
66 void Display_Cell_Internal (LPDISPLAYREQUEST pdr)
68 // Update the "Current Cell:" field on g.hMain
70 TCHAR szCell[ cchNAME ];
71 if (g.lpiCell == NULL)
72 GetString (szCell, IDS_NO_CELL_SELECTED);
73 else
74 g.lpiCell->GetCellName (szCell);
76 SetDlgItemText (g.hMain, IDC_CELL, szCell);
78 // Update the "AFS Identity:" field on g.hMain
80 TCHAR szUser[ cchNAME ];
81 SYSTEMTIME stExpire;
82 if (!AfsAppLib_CrackCredentials (g.hCreds, szCell, szUser, &stExpire))
84 GetString (szUser, IDS_NO_AFS_ID);
85 SetDlgItemText (g.hMain, IDC_AFS_ID, szUser);
87 else
89 int ids = (AfsAppLib_IsTimeInFuture (&stExpire)) ? IDS_AFS_ID_WILLEXP : IDS_AFS_ID_DIDEXP;
90 LPTSTR pszText = FormatString (ids, TEXT("%s%t"), szUser, &stExpire);
91 SetDlgItemText (g.hMain, IDC_AFS_ID, pszText);
92 FreeString (pszText);
98 * SERVERS ____________________________________________________________________
102 void Display_Servers_Internal (LPDISPLAYREQUEST pdr)
104 pdr->hList = GetDlgItem (g.hMain, IDC_SERVERS);
105 pdr->lpvi = (gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr;
107 if (!IsWindow (pdr->hList))
108 return;
110 // Fix up the image lists for the Servers window
112 HIMAGELIST hiSmall;
113 HIMAGELIST hiLarge;
114 FastList_GetImageLists (pdr->hList, &hiSmall, &hiLarge);
115 if (!hiSmall || !hiLarge)
117 hiSmall = AfsAppLib_CreateImageList (FALSE);
118 hiLarge = AfsAppLib_CreateImageList (TRUE);
119 FastList_SetImageLists (pdr->hList, hiSmall, hiLarge);
122 // Add an entry in the Servers list for each server in the cell.
124 // LPIDENT lpiSelStart = (LPIDENT)FL_GetSelectedData (pdr->hList);
125 // BOOL fRefresh = FALSE;
127 LPCELL lpCell;
128 if (!g.lpiCell || !(lpCell = g.lpiCell->OpenCell()))
130 LPTSTR pszCover = FormatString (IDS_ERROR_REFRESH_CELLSERVERS_NOCELL);
131 AfsAppLib_CoverWindow (pdr->hList, pszCover);
132 FreeString (pszCover);
134 else
136 BOOL rc = TRUE;
138 pdr->lpiToSelect = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
139 pdr->actOnDone = ACT_ENDCHANGE | ACT_SELPREVIEW;
141 // Remove any to-be-replaced old servers
143 Display_Servers_Internal_Clean (pdr);
145 // Add a server entry for each server as appropriate
147 HENUM hEnum;
148 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, pdr->lpiNotify, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
150 Display_Servers_Internal_AddServer (pdr, lpServer);
151 lpServer->Close();
154 if (rc)
155 pdr->actOnDone |= ACT_UNCOVER;
157 lpCell->Close();
162 void Display_Servers_Internal_Clean (LPDISPLAYREQUEST pdr)
164 if (pdr->lpiNotify) // else, we already emptied the list
166 HLISTITEM hItem;
167 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
168 FastList_RemoveItem (pdr->hList, hItem);
173 void Display_Servers_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
175 ULONG status = 0;
176 SERVERSTATUS ss;
178 if (lpServer->GetIdentifier() == pdr->lpiNotify)
179 status = pdr->status;
181 if (!status)
183 lpServer->GetStatus (&ss, FALSE, &status);
185 LPSERVER_PREF lpsp;
186 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
187 memcpy (&lpsp->ssLast, &ss, sizeof(SERVERSTATUS));
190 ICONVIEW ivSvr = Display_GetServerIconView();
192 if (status != 0)
194 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
196 Display_InsertItem (pdr->hList,
197 NULL,
198 pszCol1,
199 (LPARAM)lpServer->GetIdentifier(),
200 imageSERVER, imageSERVER_ALERT, ivSvr);
202 FreeString (pszCol1);
204 else
206 int iStatusImage = IMAGE_NOIMAGE;
207 if (!lpServer->fIsMonitored())
208 iStatusImage = imageSERVER_UNMON;
209 else if (Server_GetAlertCount (lpServer))
210 iStatusImage = imageSERVER_ALERT;
212 Display_InsertItem (pdr->hList,
213 NULL,
214 NULL,
215 (LPARAM)lpServer->GetIdentifier(),
216 imageSERVER, iStatusImage, ivSvr);
222 * SERVICES ___________________________________________________________________
226 void Display_Services_Internal (LPDISPLAYREQUEST pdr)
228 pdr->hList = GetDlgItem (pdr->hChild, IDC_SVC_LIST);
229 pdr->lpvi = &gr.viewSvc;
231 if (!IsWindow (pdr->hList))
232 return;
234 // First off, can we totally ignore this request?
236 LPIDENT lpiWindow = Server_GetServerForChild (pdr->hChild);
237 if (lpiWindow && pdr->lpiNotify && (lpiWindow != pdr->lpiNotify->GetServer()))
238 return;
240 // Fix up the image lists for the Services window
242 HIMAGELIST hiSmall;
243 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
244 if (!hiSmall)
246 hiSmall = AfsAppLib_CreateImageList (FALSE);
247 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
250 // Add either all services, or one server's services, or one service.
252 LPCELL lpCell;
253 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
255 pdr->lpiToSelect = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
256 pdr->actOnDone = ACT_ENDCHANGE;
258 // Remove any to-be-replaced old services
260 Display_Services_Internal_Clean (pdr);
262 // Update all appropriate service entries
264 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : lpiWindow;
266 HENUM hEnum;
267 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
269 if (lpServer->fIsMonitored())
270 Display_Services_Internal_AddServer (pdr, lpServer);
271 lpServer->Close();
274 if (pdr->lpiToSelect)
275 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
276 lpCell->Close();
281 void Display_Services_Internal_Clean (LPDISPLAYREQUEST pdr)
283 if (pdr->lpiNotify) // else, we already emptied the list
285 HLISTITEM hItem;
286 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
287 FastList_RemoveItem (pdr->hList, hItem);
292 void Display_Services_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
294 ULONG status = 0;
295 SERVERSTATUS ss;
297 if (lpServer->GetIdentifier() == pdr->lpiNotify)
298 status = pdr->status;
299 if (!status)
300 lpServer->GetStatus (&ss, FALSE, &status);
302 LPTSTR pszServerText = NULL;
303 int iStatusImage = imageSERVER;
304 BOOL fContinue = TRUE;
306 if (status != 0)
308 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
309 iStatusImage = imageSERVER_ALERT;
310 fContinue = FALSE;
312 else if (Server_GetAlertCount (lpServer))
314 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
315 iStatusImage = imageSERVER_ALERT;
318 HLISTITEM hServer;
319 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
321 hServer = Display_InsertItem (pdr->hList, NULL, pszServerText,
322 (LPARAM)lpServer->GetIdentifier(),
323 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
325 else
327 int iImage1, iImage2;
328 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
329 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
330 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
331 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
334 if (pszServerText)
335 FreeString (pszServerText);
337 if (fContinue)
339 // Update icons for all appropriate services
341 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsService()) ? (pdr->lpiNotify) : NULL;
343 HENUM hEnum;
344 for (LPSERVICE lpService = lpServer->ServiceFindFirst (&hEnum, lpiSearch, FALSE); lpService; lpService = lpServer->ServiceFindNext (&hEnum))
346 Display_Services_Internal_AddService (pdr, lpService, hServer);
347 lpService->Close();
353 void Display_Services_Internal_AddService (LPDISPLAYREQUEST pdr, LPSERVICE lpService, HLISTITEM hServer)
355 ULONG status = 0;
356 SERVICESTATUS ss;
358 if (lpService->GetIdentifier() == pdr->lpiNotify)
359 status = pdr->status;
360 if (!status)
361 lpService->GetStatus (&ss, FALSE, &status);
363 BOOL fShowServerName = !Server_GetServer (pdr->hChild);
365 if (status != 0)
367 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Services_GetColumnText (lpService->GetIdentifier(), svccolNAME, fShowServerName), status);
369 Display_InsertItem (pdr->hList,
370 hServer,
371 pszCol1,
372 (LPARAM)lpService->GetIdentifier(),
373 imageSERVICE, imageSERVICE_ALERT, gr.ivSvc);
375 FreeString (pszCol1);
377 else
379 TCHAR szName[ cchRESOURCE ];
380 lpService->GetName (szName);
382 BOOL fIsBOS = !lstrcmpi (szName, TEXT("BOS"));
384 LPSERVICE_PREF lpsp;
385 if ((lpsp = (LPSERVICE_PREF)lpService->GetUserParam()) != NULL)
386 memcpy (&lpsp->ssLast, &ss, sizeof(SERVICESTATUS));
388 int iTypeImage = imageSERVICE;
389 if (fIsBOS)
390 iTypeImage = imageBOSSERVICE;
392 int iStatusImage = IMAGE_NOIMAGE;
393 if (Services_GetAlertCount (lpService))
394 iStatusImage = imageSERVICE_ALERT;
395 else if (!Services_fRunning (lpService))
396 iStatusImage = imageSERVICE_STOPPED;
397 else if (fIsBOS)
398 iStatusImage = imageBOSSERVICE;
400 Display_InsertItem (pdr->hList,
401 hServer,
402 NULL,
403 (LPARAM)lpService->GetIdentifier(),
404 iTypeImage, iStatusImage, gr.ivSvc);
410 * AGGREGATES _________________________________________________________________
414 void Display_Aggregates_Internal (LPDISPLAYREQUEST pdr)
416 if (pdr->lpvi == NULL)
417 pdr->lpvi = &gr.viewAgg;
419 if (!IsWindow (pdr->hList))
420 return;
422 TCHAR szClassName[ cchRESOURCE ];
423 if (GetClassName (pdr->hList, szClassName, cchRESOURCE))
425 if (!lstrcmp (szClassName, WC_FASTLIST))
426 pdr->fList = TRUE;
429 // First off, can we totally ignore this request?
431 if (pdr->lpiServer && pdr->lpiNotify && (pdr->lpiServer != pdr->lpiNotify->GetServer()))
432 return;
434 // Fix up the image lists for the Aggregates window
436 if (pdr->fList)
438 HIMAGELIST hiSmall;
439 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
440 if (!hiSmall)
442 hiSmall = AfsAppLib_CreateImageList (FALSE);
443 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
447 // Add either all aggregates, or one server's aggregates, or one aggregate.
449 LPCELL lpCell;
450 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
452 LPIDENT lpiSelectedNow;
453 if (pdr->fList)
454 lpiSelectedNow = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
455 else
456 lpiSelectedNow = (LPIDENT)CB_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
458 if (!pdr->lpiToSelect)
459 pdr->lpiToSelect = lpiSelectedNow;
461 pdr->actOnDone = ACT_ENDCHANGE;
463 // Remove any to-be-replaced old services
465 Display_Aggregates_Internal_Clean (pdr);
467 // Update all appropriate aggregate entries
469 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : pdr->lpiServer;
471 HENUM hEnum;
472 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
474 if (lpServer->fIsMonitored())
475 Display_Aggregates_Internal_AddServer (pdr, lpServer);
476 lpServer->Close();
479 if (pdr->lpiToSelect)
481 if (pdr->fList)
482 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
483 else
484 CB_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
486 if (!pdr->fList) // combobox? then always pick *something*...
488 if (!CB_GetSelectedData (pdr->hList))
490 pdr->lpiToSelect = (LPIDENT)CB_GetData (pdr->hList, 0);
494 lpCell->Close();
499 void Display_Aggregates_Internal_Clean (LPDISPLAYREQUEST pdr)
501 if (pdr->lpiNotify) // else, we already emptied the list
503 if (pdr->fList)
505 HLISTITEM hItem;
506 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
507 FastList_RemoveItem (pdr->hList, hItem);
509 else
511 size_t iMax = SendMessage (pdr->hList, CB_GETCOUNT, 0, 0);
513 for (UINT iItem = 0; iItem < iMax; )
515 BOOL fDelete = FALSE;
517 LPIDENT lpiItem;
518 if ((lpiItem = (LPIDENT)CB_GetData (pdr->hList, iItem)) != NULL)
520 // delete the entry if it's the TBD server or aggregate
522 if (lpiItem == pdr->lpiNotify)
523 fDelete = TRUE;
525 // delete the entry if it's the server of a TBD aggregate
527 if (lpiItem == pdr->lpiNotify->GetServer())
528 fDelete = TRUE;
530 // delete the entry if it's an aggregate on the TBD server
532 if (lpiItem->GetServer() == pdr->lpiNotify)
533 fDelete = TRUE;
536 if (!fDelete)
537 ++iItem;
538 else
540 SendMessage (pdr->hList, CB_DELETESTRING, iItem, 0);
541 --iMax;
549 void Display_Aggregates_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
551 ULONG status = 0;
552 SERVERSTATUS ss;
554 if (lpServer->GetIdentifier() == pdr->lpiNotify)
555 status = pdr->status;
556 if (!status)
557 lpServer->GetStatus (&ss, FALSE, &status);
559 HLISTITEM hServer = NULL;
560 if (pdr->fList)
562 LPTSTR pszServerText = NULL;
563 int iStatusImage = imageSERVER;
565 if (status != 0)
567 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
568 iStatusImage = imageSERVER_ALERT;
570 else if (Server_GetAlertCount (lpServer))
572 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
573 iStatusImage = imageSERVER_ALERT;
576 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
578 hServer = Display_InsertItem (pdr->hList, NULL, pszServerText,
579 (LPARAM)lpServer->GetIdentifier(),
580 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
582 else
584 int iImage1, iImage2;
585 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
586 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
587 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
588 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
591 if (pszServerText)
592 FreeString (pszServerText);
595 if ((hServer || !pdr->fList) && !status)
597 // Update icons for all appropriate aggregates
599 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsAggregate()) ? (pdr->lpiNotify) : NULL;
601 HENUM hEnum;
602 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum, lpiSearch, FALSE); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
604 Display_Aggregates_Internal_AddAggregate (pdr, lpAggregate, hServer);
605 lpAggregate->Close();
611 void Display_Aggregates_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer)
613 ULONG status = 0;
614 AGGREGATESTATUS as;
616 if (lpAggregate->GetIdentifier() == pdr->lpiNotify)
617 status = pdr->status;
618 if (!status)
619 lpAggregate->GetStatus (&as, FALSE, &status);
621 BOOL fShowServerName = !Server_GetServer (pdr->hChild);
623 if (status != 0)
625 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME, fShowServerName), status);
627 if (pdr->fList)
629 Display_InsertItem (pdr->hList, hServer, pszCol1,
630 (LPARAM)lpAggregate->GetIdentifier(),
631 imageAGGREGATE, imageAGGREGATE_ALERT, gr.ivAgg);
633 else
635 CB_AddItem (pdr->hList, pszCol1, (LPARAM)lpAggregate->GetIdentifier());
638 FreeString (pszCol1);
640 else
642 LPAGGREGATE_PREF lpap;
643 if ((lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) != NULL)
645 memcpy (&lpap->asLast, &as, sizeof(AGGREGATESTATUS));
646 lpAggregate->GetDevice (lpap->szDevice);
649 if (pdr->fList)
651 int iStatusImage = IMAGE_NOIMAGE;
652 if (Aggregates_GetAlertCount (lpAggregate))
653 iStatusImage = imageAGGREGATE_ALERT;
655 Display_InsertItem (pdr->hList, hServer, NULL,
656 (LPARAM)lpAggregate->GetIdentifier(),
657 imageAGGREGATE, iStatusImage, gr.ivAgg);
659 else
661 TCHAR szName[ cchNAME ];
662 lpAggregate->GetIdentifier()->GetAggregateName (szName);
663 CB_AddItem (pdr->hList, szName, (LPARAM)lpAggregate->GetIdentifier());
670 * FILESETS ___________________________________________________________________
674 void Display_Filesets_Internal (LPDISPLAYREQUEST pdr)
676 if (pdr->hList == NULL)
677 pdr->hList = GetDlgItem (pdr->hChild, IDC_SET_LIST);
679 if (!IsWindow (pdr->hList))
680 return;
682 TCHAR szClassName[ cchRESOURCE ];
683 if (GetClassName (pdr->hList, szClassName, cchRESOURCE))
685 if (!lstrcmp (szClassName, WC_FASTLIST))
686 pdr->fList = TRUE;
689 pdr->lpvi = (pdr->fList) ? &gr.viewSet : NULL;
691 // First off, can we totally ignore this request?
693 if (pdr->lpiServer && pdr->lpiNotify && (pdr->lpiServer != pdr->lpiNotify->GetServer()))
694 return;
696 // Fix up the image lists for the Filesets window
698 if (pdr->fList)
700 HIMAGELIST hiSmall;
701 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
702 if (!hiSmall)
704 hiSmall = AfsAppLib_CreateImageList (FALSE);
705 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
709 // Add either all filesets, or one server's filesets, or one fileset.
711 LPCELL lpCell;
712 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
714 pdr->actOnDone = ACT_ENDCHANGE;
716 // Remove any to-be-replaced old services
718 LPIDENT lpiSelectedNow;
719 if (pdr->fList)
720 lpiSelectedNow = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
721 else
722 lpiSelectedNow = (LPIDENT)CB_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
723 Display_Filesets_Internal_Clean (pdr);
725 if (! pdr->lpiToSelect)
726 pdr->lpiToSelect = lpiSelectedNow;
728 HLISTITEM hCell;
729 hCell = Display_Filesets_Internal_AddCell (pdr, lpCell);
731 // Update all appropriate fileset entries
733 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : pdr->lpiServer;
735 HENUM hEnum;
736 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
738 if (lpServer->fIsMonitored())
739 Display_Filesets_Internal_AddServer (pdr, lpServer, hCell);
740 lpServer->Close();
743 if (pdr->lpiToSelect)
745 if (pdr->fList)
746 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
747 else
748 CB_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
750 if (!pdr->fList) // combobox? then always pick *something*...
752 if (!CB_GetSelectedData (pdr->hList))
754 pdr->lpiToSelect = (LPIDENT)CB_GetData (pdr->hList, 0);
758 lpCell->Close();
763 void Display_Filesets_Internal_Clean (LPDISPLAYREQUEST pdr)
765 if (pdr->lpiNotify)
767 if (pdr->fList)
769 HLISTITEM hItem;
770 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)pdr->lpiNotify)) != NULL)
772 FastList_RemoveItem (pdr->hList, hItem);
775 else // Must be a combobox
777 size_t iMax = SendMessage (pdr->hList, CB_GETCOUNT, 0, 0);
779 for (UINT iItem = 0; iItem < iMax; )
781 BOOL fDelete = FALSE;
783 LPIDENT lpiItem;
784 if ((lpiItem = (LPIDENT)CB_GetData (pdr->hList, iItem)) != NULL)
786 if (lpiItem->GetServer() == pdr->lpiNotify)
787 fDelete = TRUE;
788 if (lpiItem->GetAggregate() == pdr->lpiNotify)
789 fDelete = TRUE;
790 if (lpiItem == pdr->lpiNotify)
791 fDelete = TRUE;
794 if (!fDelete)
795 ++iItem;
796 else
798 SendMessage (pdr->hList, CB_DELETESTRING, iItem, 0);
799 --iMax;
807 HLISTITEM Display_Filesets_Internal_AddCell (LPDISPLAYREQUEST pdr, LPCELL lpCell)
809 if (!pdr->fList)
810 return NULL;
812 HLISTITEM hCell;
813 if ((hCell = FastList_FindItem (pdr->hList, (LPARAM)lpCell->GetIdentifier())) == NULL)
815 TCHAR szName[ cchNAME ];
816 lpCell->GetName (szName);
818 hCell = Display_InsertItem (pdr->hList, NULL, szName,
819 (LPARAM)lpCell->GetIdentifier(),
820 imageCELL, IMAGE_NOIMAGE, gr.ivSet,
821 PIF_ALWAYSSHOWICON | PIF_ONLYONEICON | PIF_TREEVIEW_ONLY | PIF_DISALLOW_COLLAPSE);
824 return hCell;
828 void Display_Filesets_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer, HLISTITEM hCell)
830 ULONG status = 0;
831 SERVERSTATUS ss;
833 if (lpServer->GetIdentifier() == pdr->lpiNotify)
834 status = pdr->status;
835 if (!status)
836 lpServer->GetStatus (&ss, FALSE, &status);
838 HLISTITEM hServer = NULL;
839 if (pdr->fList)
841 LPTSTR pszServerText = NULL;
842 int iStatusImage = imageSERVER;
844 if (status != 0)
846 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
847 iStatusImage = imageSERVER_ALERT;
849 else if (Server_GetAlertCount (lpServer))
851 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
852 iStatusImage = imageSERVER_ALERT;
855 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
857 hServer = Display_InsertItem (pdr->hList, hCell, pszServerText,
858 (LPARAM)lpServer->GetIdentifier(),
859 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
861 else
863 int iImage1, iImage2;
864 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
865 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
866 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
867 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
870 if (pszServerText)
871 FreeString (pszServerText);
874 if (status == 0)
876 // Update filesets on all appropriate aggregates
878 LPIDENT lpiSearch = (pdr->lpiNotify && !pdr->lpiNotify->fIsServer()) ? (pdr->lpiNotify->GetAggregate()) : pdr->lpiAggregate;
880 HENUM hEnum;
881 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum, lpiSearch, FALSE); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
883 Display_Filesets_Internal_AddAggregate (pdr, lpAggregate, hServer);
884 lpAggregate->Close();
887 if (pdr->fList && hServer)
889 BOOL fExpand = TRUE;
891 LPSERVER_PREF lpsp;
892 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
893 fExpand = lpsp->fExpandTree;
895 FastList_SetExpanded (pdr->hList, hServer, fExpand);
901 void Display_Filesets_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer)
903 ULONG status = 0;
904 AGGREGATESTATUS as;
906 if (lpAggregate->GetIdentifier() == pdr->lpiNotify)
907 status = pdr->status;
908 if (!status)
909 lpAggregate->GetStatus (&as, FALSE, &status);
911 HLISTITEM hAggregate = NULL;
912 if (pdr->fList)
914 LPTSTR pszAggregateText = NULL;
915 int iStatusImage = imageAGGREGATE;
917 if (status != 0)
919 pszAggregateText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME, FALSE), status);
920 iStatusImage = imageAGGREGATE_ALERT;
922 else if (Aggregates_GetAlertCount (lpAggregate))
924 pszAggregateText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolSTATUS));
925 iStatusImage = imageAGGREGATE_ALERT;
928 if ((hAggregate = FastList_FindItem (pdr->hList, (LPARAM)lpAggregate->GetIdentifier())) == NULL)
930 hAggregate = Display_InsertItem (pdr->hList, hServer, pszAggregateText,
931 (LPARAM)lpAggregate->GetIdentifier(),
932 imageAGGREGATE, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
934 else
936 int iImage1, iImage2;
937 Display_PickImages (&iImage1, &iImage2, imageAGGREGATE, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
938 FastList_SetItemFirstImage (pdr->hList, hAggregate, iImage1);
939 FastList_SetItemSecondImage (pdr->hList, hAggregate, iImage2);
940 FastList_SetItemText (pdr->hList, hAggregate, 0, pszAggregateText);
943 if (pszAggregateText)
944 FreeString (pszAggregateText);
947 if (status == 0)
949 // Update all appropriate filesets from this aggregate
951 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsFileset()) ? (pdr->lpiNotify) : NULL;
953 HENUM hEnum;
954 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum, lpiSearch, FALSE); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
956 Display_Filesets_Internal_AddFileset (pdr, lpFileset, hAggregate);
957 lpFileset->Close();
960 if (pdr->fList && hAggregate)
962 BOOL fExpand = (hServer == NULL) ? TRUE : FALSE;
964 LPAGGREGATE_PREF lpap;
965 if ((lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) != NULL)
966 fExpand = lpap->fExpandTree;
968 FastList_SetExpanded (pdr->hList, hAggregate, fExpand);
974 void Display_Filesets_Internal_AddFileset (LPDISPLAYREQUEST pdr, LPFILESET lpFileset, HLISTITEM hAggregate)
976 ULONG status = 0;
977 FILESETSTATUS fs;
979 if (lpFileset->GetIdentifier() == pdr->lpiNotify)
980 status = pdr->status;
981 if (!status)
982 lpFileset->GetStatus (&fs, FALSE, &status);
984 if (status != 0)
986 if (pdr->fList)
988 LPTSTR pszFilesetText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Filesets_GetColumnText (lpFileset->GetIdentifier(), setcolNAME), status);
990 Display_InsertItem (pdr->hList, hAggregate, pszFilesetText,
991 (LPARAM)lpFileset->GetIdentifier(),
992 imageFILESET, imageFILESET_ALERT, gr.ivSet);
994 FreeString (pszFilesetText);
997 else
999 if (!pdr->fList)
1001 TCHAR szName[ cchNAME ];
1002 lpFileset->GetName (szName);
1003 CB_AddItem (pdr->hList, szName, (LPARAM)lpFileset->GetIdentifier());
1005 else
1007 LPFILESET_PREF lpfp;
1008 if ((lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) != NULL)
1010 memcpy (&lpfp->fsLast, &fs, sizeof(FILESETSTATUS));
1011 lpfp->lpiRW = lpFileset->GetReadWriteIdentifier();
1014 int iStatusImage = IMAGE_NOIMAGE;
1015 if (Filesets_GetAlertCount (lpFileset))
1016 iStatusImage = imageFILESET_ALERT;
1017 else if (Filesets_fIsLocked (&fs))
1018 iStatusImage = imageFILESET_LOCKED;
1020 Display_InsertItem (pdr->hList, hAggregate, NULL,
1021 (LPARAM)lpFileset->GetIdentifier(),
1022 imageFILESET, iStatusImage, gr.ivSet);
1029 * REPLICAS ___________________________________________________________________
1031 * (lpiNotify is the RW for which to list all replicas)
1035 void Display_Replicas_Internal (LPDISPLAYREQUEST pdr)
1037 if (!IsWindow (pdr->hList))
1038 return;
1040 pdr->lpvi = &gr.viewRep;
1041 pdr->actOnDone = ACT_ENDCHANGE;
1043 LPIDENT lpiRW = pdr->lpiNotify;
1044 VOLUMEID vidReadWrite;
1045 lpiRW->GetFilesetID (&vidReadWrite);
1047 FL_StartChange (pdr->hList, TRUE);
1049 LPCELL lpCell;
1050 if ((lpCell = lpiRW->OpenCell()) != NULL)
1052 HENUM heServer;
1053 for (LPSERVER lpServer = lpCell->ServerFindFirst (&heServer); lpServer; lpServer = lpCell->ServerFindNext (&heServer))
1055 HENUM heAggregate;
1056 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&heAggregate); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&heAggregate))
1058 HENUM heFileset;
1059 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&heFileset); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&heFileset))
1061 FILESETSTATUS fs;
1062 if (lpFileset->GetStatus (&fs))
1064 if ( (fs.Type == ftREPLICA) &&
1065 (!memcmp (&vidReadWrite, &fs.idReadWrite, sizeof(VOLUMEID))) )
1067 LPFILESET_PREF lpfp;
1068 if ((lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) != NULL)
1070 memcpy (&lpfp->fsLast, &fs, sizeof(FILESETSTATUS));
1071 lpfp->lpiRW = lpiRW;
1074 Display_InsertItem (pdr->hList, NULL, NULL,
1075 (LPARAM)lpFileset->GetIdentifier());
1078 lpFileset->Close();
1080 lpAggregate->Close();
1082 lpServer->Close();
1084 lpCell->Close();
1090 * SERVER WINDOWS _____________________________________________________________
1094 void Display_ServerWindow_Internal (LPDISPLAYREQUEST pdr)
1096 Server_SelectServer (pdr->hChild, pdr->lpiServer, TRUE); // redraw svr window
1101 * ICON SELECTION _____________________________________________________________
1105 void Display_PickImages (int *piImage0, int *piImage1, int iTypeImage, int iStatusImage, ICONVIEW iv, DWORD dwFlags)
1107 switch (iv)
1109 case ivTWOICONS:
1110 *piImage0 = iTypeImage;
1111 *piImage1 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1112 if (*piImage1 == *piImage0)
1113 *piImage1 = IMAGE_BLANKIMAGE;
1114 if (dwFlags & PIF_ONLYONEICON)
1115 *piImage1 = IMAGE_NOIMAGE;
1116 break;
1118 case ivONEICON:
1119 *piImage0 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1120 *piImage1 = IMAGE_NOIMAGE;
1121 dwFlags |= PIF_ALWAYSSHOWICON;
1122 break;
1124 case ivSTATUS:
1125 *piImage0 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1126 *piImage1 = IMAGE_NOIMAGE;
1127 break;
1129 default:
1130 *piImage0 = iTypeImage;
1131 *piImage1 = iStatusImage;
1132 return;
1135 if ((dwFlags & PIF_ALWAYSSHOWICON) && ((*piImage0 == IMAGE_NOIMAGE) || (*piImage0 == IMAGE_BLANKIMAGE)))
1137 *piImage0 = iTypeImage;
1142 HLISTITEM Display_InsertItem (HWND hList, HLISTITEM hParent, LPTSTR pszText, LPARAM lp, int iImage0, int iImage1, ICONVIEW iv, DWORD dwPickImageFlags)
1144 FASTLISTADDITEM flai;
1145 memset (&flai, 0x00, sizeof(flai));
1146 flai.hParent = hParent;
1147 flai.pszText = pszText;
1148 flai.lParam = lp;
1149 Display_PickImages (&flai.iFirstImage, &flai.iSecondImage, iImage0, iImage1, iv, dwPickImageFlags);
1151 if (dwPickImageFlags & PIF_TREEVIEW_ONLY)
1152 flai.dwFlags |= FLIF_TREEVIEW_ONLY;
1154 if (dwPickImageFlags & PIF_DISALLOW_COLLAPSE)
1155 flai.dwFlags |= FLIF_DISALLOW_COLLAPSE;
1157 return FastList_AddItem (hList, &flai);