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 <afsconfig.h>
15 #include <afs/param.h>
23 #include "svr_window.h"
25 #include "svc_startstop.h"
28 #include "set_general.h"
33 * PROTOTYPES _________________________________________________________________
37 void Display_Servers_Internal_Clean (LPDISPLAYREQUEST pdr);
38 void Display_Servers_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
40 void Display_Services_Internal_Clean (LPDISPLAYREQUEST pdr);
41 void Display_Services_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
42 void Display_Services_Internal_AddService (LPDISPLAYREQUEST pdr, LPSERVICE lpService, HLISTITEM hServer);
44 void Display_Aggregates_Internal_Clean (LPDISPLAYREQUEST pdr);
45 void Display_Aggregates_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
46 void Display_Aggregates_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer);
48 void Display_Filesets_Internal_Clean (LPDISPLAYREQUEST pdr);
49 HLISTITEM Display_Filesets_Internal_AddCell (LPDISPLAYREQUEST pdr, LPCELL lpCell);
50 void Display_Filesets_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer, HLISTITEM hCell);
51 void Display_Filesets_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer);
52 void Display_Filesets_Internal_AddFileset (LPDISPLAYREQUEST pdr, LPFILESET lpFileset, HLISTITEM hAggregate);
54 #define PIF_ALWAYSSHOWICON 0x00000001
55 #define PIF_ONLYONEICON 0x00000002
56 #define PIF_TREEVIEW_ONLY 0x00000004
57 #define PIF_DISALLOW_COLLAPSE 0x00000008
58 void Display_PickImages (int *piFirstImage, int *piSecondImage, int iTypeImage, int iStatusImage, ICONVIEW iv, DWORD dwPickImageFlags = 0);
59 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);
63 * CELL _______________________________________________________________________
67 void Display_Cell_Internal (LPDISPLAYREQUEST pdr)
69 // Update the "Current Cell:" field on g.hMain
71 TCHAR szCell[ cchNAME ];
72 if (g.lpiCell == NULL)
73 GetString (szCell, IDS_NO_CELL_SELECTED);
75 g.lpiCell->GetCellName (szCell);
77 SetDlgItemText (g.hMain, IDC_CELL, szCell);
79 // Update the "AFS Identity:" field on g.hMain
81 TCHAR szUser[ cchNAME ];
83 if (!AfsAppLib_CrackCredentials (g.hCreds, szCell, szUser, &stExpire))
85 GetString (szUser, IDS_NO_AFS_ID);
86 SetDlgItemText (g.hMain, IDC_AFS_ID, szUser);
90 int ids = (AfsAppLib_IsTimeInFuture (&stExpire)) ? IDS_AFS_ID_WILLEXP : IDS_AFS_ID_DIDEXP;
91 LPTSTR pszText = FormatString (ids, TEXT("%s%t"), szUser, &stExpire);
92 SetDlgItemText (g.hMain, IDC_AFS_ID, pszText);
99 * SERVERS ____________________________________________________________________
103 void Display_Servers_Internal (LPDISPLAYREQUEST pdr)
105 pdr->hList = GetDlgItem (g.hMain, IDC_SERVERS);
106 pdr->lpvi = (gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr;
108 if (!IsWindow (pdr->hList))
111 // Fix up the image lists for the Servers window
115 FastList_GetImageLists (pdr->hList, &hiSmall, &hiLarge);
116 if (!hiSmall || !hiLarge)
118 hiSmall = AfsAppLib_CreateImageList (FALSE);
119 hiLarge = AfsAppLib_CreateImageList (TRUE);
120 FastList_SetImageLists (pdr->hList, hiSmall, hiLarge);
123 // Add an entry in the Servers list for each server in the cell.
125 // LPIDENT lpiSelStart = (LPIDENT)FL_GetSelectedData (pdr->hList);
126 // BOOL fRefresh = FALSE;
129 if (!g.lpiCell || !(lpCell = g.lpiCell->OpenCell()))
131 LPTSTR pszCover = FormatString (IDS_ERROR_REFRESH_CELLSERVERS_NOCELL);
132 AfsAppLib_CoverWindow (pdr->hList, pszCover);
133 FreeString (pszCover);
139 pdr->lpiToSelect = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
140 pdr->actOnDone = ACT_ENDCHANGE | ACT_SELPREVIEW;
142 // Remove any to-be-replaced old servers
144 Display_Servers_Internal_Clean (pdr);
146 // Add a server entry for each server as appropriate
149 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, pdr->lpiNotify, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
151 Display_Servers_Internal_AddServer (pdr, lpServer);
156 pdr->actOnDone |= ACT_UNCOVER;
163 void Display_Servers_Internal_Clean (LPDISPLAYREQUEST pdr)
165 if (pdr->lpiNotify) // else, we already emptied the list
168 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
169 FastList_RemoveItem (pdr->hList, hItem);
174 void Display_Servers_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
179 if (lpServer->GetIdentifier() == pdr->lpiNotify)
180 status = pdr->status;
184 lpServer->GetStatus (&ss, FALSE, &status);
187 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
188 memcpy (&lpsp->ssLast, &ss, sizeof(SERVERSTATUS));
191 ICONVIEW ivSvr = Display_GetServerIconView();
195 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
197 Display_InsertItem (pdr->hList,
200 (LPARAM)lpServer->GetIdentifier(),
201 imageSERVER, imageSERVER_ALERT, ivSvr);
203 FreeString (pszCol1);
207 int iStatusImage = IMAGE_NOIMAGE;
208 if (!lpServer->fIsMonitored())
209 iStatusImage = imageSERVER_UNMON;
210 else if (Server_GetAlertCount (lpServer))
211 iStatusImage = imageSERVER_ALERT;
213 Display_InsertItem (pdr->hList,
216 (LPARAM)lpServer->GetIdentifier(),
217 imageSERVER, iStatusImage, ivSvr);
223 * SERVICES ___________________________________________________________________
227 void Display_Services_Internal (LPDISPLAYREQUEST pdr)
229 pdr->hList = GetDlgItem (pdr->hChild, IDC_SVC_LIST);
230 pdr->lpvi = &gr.viewSvc;
232 if (!IsWindow (pdr->hList))
235 // First off, can we totally ignore this request?
237 LPIDENT lpiWindow = Server_GetServerForChild (pdr->hChild);
238 if (lpiWindow && pdr->lpiNotify && (lpiWindow != pdr->lpiNotify->GetServer()))
241 // Fix up the image lists for the Services window
244 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
247 hiSmall = AfsAppLib_CreateImageList (FALSE);
248 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
251 // Add either all services, or one server's services, or one service.
254 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
256 pdr->lpiToSelect = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
257 pdr->actOnDone = ACT_ENDCHANGE;
259 // Remove any to-be-replaced old services
261 Display_Services_Internal_Clean (pdr);
263 // Update all appropriate service entries
265 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : lpiWindow;
268 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
270 if (lpServer->fIsMonitored())
271 Display_Services_Internal_AddServer (pdr, lpServer);
275 if (pdr->lpiToSelect)
276 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
282 void Display_Services_Internal_Clean (LPDISPLAYREQUEST pdr)
284 if (pdr->lpiNotify) // else, we already emptied the list
287 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
288 FastList_RemoveItem (pdr->hList, hItem);
293 void Display_Services_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
298 if (lpServer->GetIdentifier() == pdr->lpiNotify)
299 status = pdr->status;
301 lpServer->GetStatus (&ss, FALSE, &status);
303 LPTSTR pszServerText = NULL;
304 int iStatusImage = imageSERVER;
305 BOOL fContinue = TRUE;
309 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
310 iStatusImage = imageSERVER_ALERT;
313 else if (Server_GetAlertCount (lpServer))
315 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
316 iStatusImage = imageSERVER_ALERT;
320 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
322 hServer = Display_InsertItem (pdr->hList, NULL, pszServerText,
323 (LPARAM)lpServer->GetIdentifier(),
324 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
328 int iImage1, iImage2;
329 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
330 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
331 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
332 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
336 FreeString (pszServerText);
340 // Update icons for all appropriate services
342 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsService()) ? (pdr->lpiNotify) : NULL;
345 for (LPSERVICE lpService = lpServer->ServiceFindFirst (&hEnum, lpiSearch, FALSE); lpService; lpService = lpServer->ServiceFindNext (&hEnum))
347 Display_Services_Internal_AddService (pdr, lpService, hServer);
354 void Display_Services_Internal_AddService (LPDISPLAYREQUEST pdr, LPSERVICE lpService, HLISTITEM hServer)
359 if (lpService->GetIdentifier() == pdr->lpiNotify)
360 status = pdr->status;
362 lpService->GetStatus (&ss, FALSE, &status);
364 BOOL fShowServerName = !Server_GetServer (pdr->hChild);
368 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Services_GetColumnText (lpService->GetIdentifier(), svccolNAME, fShowServerName), status);
370 Display_InsertItem (pdr->hList,
373 (LPARAM)lpService->GetIdentifier(),
374 imageSERVICE, imageSERVICE_ALERT, gr.ivSvc);
376 FreeString (pszCol1);
380 TCHAR szName[ cchRESOURCE ];
381 lpService->GetName (szName);
383 BOOL fIsBOS = !lstrcmpi (szName, TEXT("BOS"));
386 if ((lpsp = (LPSERVICE_PREF)lpService->GetUserParam()) != NULL)
387 memcpy (&lpsp->ssLast, &ss, sizeof(SERVICESTATUS));
389 int iTypeImage = imageSERVICE;
391 iTypeImage = imageBOSSERVICE;
393 int iStatusImage = IMAGE_NOIMAGE;
394 if (Services_GetAlertCount (lpService))
395 iStatusImage = imageSERVICE_ALERT;
396 else if (!Services_fRunning (lpService))
397 iStatusImage = imageSERVICE_STOPPED;
399 iStatusImage = imageBOSSERVICE;
401 Display_InsertItem (pdr->hList,
404 (LPARAM)lpService->GetIdentifier(),
405 iTypeImage, iStatusImage, gr.ivSvc);
411 * AGGREGATES _________________________________________________________________
415 void Display_Aggregates_Internal (LPDISPLAYREQUEST pdr)
417 if (pdr->lpvi == NULL)
418 pdr->lpvi = &gr.viewAgg;
420 if (!IsWindow (pdr->hList))
423 TCHAR szClassName[ cchRESOURCE ];
424 if (GetClassName (pdr->hList, szClassName, cchRESOURCE))
426 if (!lstrcmp (szClassName, WC_FASTLIST))
430 // First off, can we totally ignore this request?
432 if (pdr->lpiServer && pdr->lpiNotify && (pdr->lpiServer != pdr->lpiNotify->GetServer()))
435 // Fix up the image lists for the Aggregates window
440 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
443 hiSmall = AfsAppLib_CreateImageList (FALSE);
444 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
448 // Add either all aggregates, or one server's aggregates, or one aggregate.
451 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
453 LPIDENT lpiSelectedNow;
455 lpiSelectedNow = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
457 lpiSelectedNow = (LPIDENT)CB_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
459 if (!pdr->lpiToSelect)
460 pdr->lpiToSelect = lpiSelectedNow;
462 pdr->actOnDone = ACT_ENDCHANGE;
464 // Remove any to-be-replaced old services
466 Display_Aggregates_Internal_Clean (pdr);
468 // Update all appropriate aggregate entries
470 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : pdr->lpiServer;
473 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
475 if (lpServer->fIsMonitored())
476 Display_Aggregates_Internal_AddServer (pdr, lpServer);
480 if (pdr->lpiToSelect)
483 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
485 CB_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
487 if (!pdr->fList) // combobox? then always pick *something*...
489 if (!CB_GetSelectedData (pdr->hList))
491 pdr->lpiToSelect = (LPIDENT)CB_GetData (pdr->hList, 0);
500 void Display_Aggregates_Internal_Clean (LPDISPLAYREQUEST pdr)
502 if (pdr->lpiNotify) // else, we already emptied the list
507 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
508 FastList_RemoveItem (pdr->hList, hItem);
512 size_t iMax = SendMessage (pdr->hList, CB_GETCOUNT, 0, 0);
514 for (UINT iItem = 0; iItem < iMax; )
516 BOOL fDelete = FALSE;
519 if ((lpiItem = (LPIDENT)CB_GetData (pdr->hList, iItem)) != NULL)
521 // delete the entry if it's the TBD server or aggregate
523 if (lpiItem == pdr->lpiNotify)
526 // delete the entry if it's the server of a TBD aggregate
528 if (lpiItem == pdr->lpiNotify->GetServer())
531 // delete the entry if it's an aggregate on the TBD server
533 if (lpiItem->GetServer() == pdr->lpiNotify)
541 SendMessage (pdr->hList, CB_DELETESTRING, iItem, 0);
550 void Display_Aggregates_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
555 if (lpServer->GetIdentifier() == pdr->lpiNotify)
556 status = pdr->status;
558 lpServer->GetStatus (&ss, FALSE, &status);
560 HLISTITEM hServer = NULL;
563 LPTSTR pszServerText = NULL;
564 int iStatusImage = imageSERVER;
568 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
569 iStatusImage = imageSERVER_ALERT;
571 else if (Server_GetAlertCount (lpServer))
573 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
574 iStatusImage = imageSERVER_ALERT;
577 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
579 hServer = Display_InsertItem (pdr->hList, NULL, pszServerText,
580 (LPARAM)lpServer->GetIdentifier(),
581 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
585 int iImage1, iImage2;
586 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
587 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
588 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
589 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
593 FreeString (pszServerText);
596 if ((hServer || !pdr->fList) && !status)
598 // Update icons for all appropriate aggregates
600 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsAggregate()) ? (pdr->lpiNotify) : NULL;
603 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum, lpiSearch, FALSE); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
605 Display_Aggregates_Internal_AddAggregate (pdr, lpAggregate, hServer);
606 lpAggregate->Close();
612 void Display_Aggregates_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer)
617 if (lpAggregate->GetIdentifier() == pdr->lpiNotify)
618 status = pdr->status;
620 lpAggregate->GetStatus (&as, FALSE, &status);
622 BOOL fShowServerName = !Server_GetServer (pdr->hChild);
626 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME, fShowServerName), status);
630 Display_InsertItem (pdr->hList, hServer, pszCol1,
631 (LPARAM)lpAggregate->GetIdentifier(),
632 imageAGGREGATE, imageAGGREGATE_ALERT, gr.ivAgg);
636 CB_AddItem (pdr->hList, pszCol1, (LPARAM)lpAggregate->GetIdentifier());
639 FreeString (pszCol1);
643 LPAGGREGATE_PREF lpap;
644 if ((lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) != NULL)
646 memcpy (&lpap->asLast, &as, sizeof(AGGREGATESTATUS));
647 lpAggregate->GetDevice (lpap->szDevice);
652 int iStatusImage = IMAGE_NOIMAGE;
653 if (Aggregates_GetAlertCount (lpAggregate))
654 iStatusImage = imageAGGREGATE_ALERT;
656 Display_InsertItem (pdr->hList, hServer, NULL,
657 (LPARAM)lpAggregate->GetIdentifier(),
658 imageAGGREGATE, iStatusImage, gr.ivAgg);
662 TCHAR szName[ cchNAME ];
663 lpAggregate->GetIdentifier()->GetAggregateName (szName);
664 CB_AddItem (pdr->hList, szName, (LPARAM)lpAggregate->GetIdentifier());
671 * FILESETS ___________________________________________________________________
675 void Display_Filesets_Internal (LPDISPLAYREQUEST pdr)
677 if (pdr->hList == NULL)
678 pdr->hList = GetDlgItem (pdr->hChild, IDC_SET_LIST);
680 if (!IsWindow (pdr->hList))
683 TCHAR szClassName[ cchRESOURCE ];
684 if (GetClassName (pdr->hList, szClassName, cchRESOURCE))
686 if (!lstrcmp (szClassName, WC_FASTLIST))
690 pdr->lpvi = (pdr->fList) ? &gr.viewSet : NULL;
692 // First off, can we totally ignore this request?
694 if (pdr->lpiServer && pdr->lpiNotify && (pdr->lpiServer != pdr->lpiNotify->GetServer()))
697 // Fix up the image lists for the Filesets window
702 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
705 hiSmall = AfsAppLib_CreateImageList (FALSE);
706 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
710 // Add either all filesets, or one server's filesets, or one fileset.
713 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
715 pdr->actOnDone = ACT_ENDCHANGE;
717 // Remove any to-be-replaced old services
719 LPIDENT lpiSelectedNow;
721 lpiSelectedNow = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
723 lpiSelectedNow = (LPIDENT)CB_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
724 Display_Filesets_Internal_Clean (pdr);
726 if (! pdr->lpiToSelect)
727 pdr->lpiToSelect = lpiSelectedNow;
730 hCell = Display_Filesets_Internal_AddCell (pdr, lpCell);
732 // Update all appropriate fileset entries
734 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : pdr->lpiServer;
737 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
739 if (lpServer->fIsMonitored())
740 Display_Filesets_Internal_AddServer (pdr, lpServer, hCell);
744 if (pdr->lpiToSelect)
747 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
749 CB_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
751 if (!pdr->fList) // combobox? then always pick *something*...
753 if (!CB_GetSelectedData (pdr->hList))
755 pdr->lpiToSelect = (LPIDENT)CB_GetData (pdr->hList, 0);
764 void Display_Filesets_Internal_Clean (LPDISPLAYREQUEST pdr)
771 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)pdr->lpiNotify)) != NULL)
773 FastList_RemoveItem (pdr->hList, hItem);
776 else // Must be a combobox
778 size_t iMax = SendMessage (pdr->hList, CB_GETCOUNT, 0, 0);
780 for (UINT iItem = 0; iItem < iMax; )
782 BOOL fDelete = FALSE;
785 if ((lpiItem = (LPIDENT)CB_GetData (pdr->hList, iItem)) != NULL)
787 if (lpiItem->GetServer() == pdr->lpiNotify)
789 if (lpiItem->GetAggregate() == pdr->lpiNotify)
791 if (lpiItem == pdr->lpiNotify)
799 SendMessage (pdr->hList, CB_DELETESTRING, iItem, 0);
808 HLISTITEM Display_Filesets_Internal_AddCell (LPDISPLAYREQUEST pdr, LPCELL lpCell)
814 if ((hCell = FastList_FindItem (pdr->hList, (LPARAM)lpCell->GetIdentifier())) == NULL)
816 TCHAR szName[ cchNAME ];
817 lpCell->GetName (szName);
819 hCell = Display_InsertItem (pdr->hList, NULL, szName,
820 (LPARAM)lpCell->GetIdentifier(),
821 imageCELL, IMAGE_NOIMAGE, gr.ivSet,
822 PIF_ALWAYSSHOWICON | PIF_ONLYONEICON | PIF_TREEVIEW_ONLY | PIF_DISALLOW_COLLAPSE);
829 void Display_Filesets_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer, HLISTITEM hCell)
834 if (lpServer->GetIdentifier() == pdr->lpiNotify)
835 status = pdr->status;
837 lpServer->GetStatus (&ss, FALSE, &status);
839 HLISTITEM hServer = NULL;
842 LPTSTR pszServerText = NULL;
843 int iStatusImage = imageSERVER;
847 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
848 iStatusImage = imageSERVER_ALERT;
850 else if (Server_GetAlertCount (lpServer))
852 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
853 iStatusImage = imageSERVER_ALERT;
856 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
858 hServer = Display_InsertItem (pdr->hList, hCell, pszServerText,
859 (LPARAM)lpServer->GetIdentifier(),
860 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
864 int iImage1, iImage2;
865 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
866 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
867 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
868 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
872 FreeString (pszServerText);
877 // Update filesets on all appropriate aggregates
879 LPIDENT lpiSearch = (pdr->lpiNotify && !pdr->lpiNotify->fIsServer()) ? (pdr->lpiNotify->GetAggregate()) : pdr->lpiAggregate;
882 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum, lpiSearch, FALSE); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
884 Display_Filesets_Internal_AddAggregate (pdr, lpAggregate, hServer);
885 lpAggregate->Close();
888 if (pdr->fList && hServer)
893 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
894 fExpand = lpsp->fExpandTree;
896 FastList_SetExpanded (pdr->hList, hServer, fExpand);
902 void Display_Filesets_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer)
907 if (lpAggregate->GetIdentifier() == pdr->lpiNotify)
908 status = pdr->status;
910 lpAggregate->GetStatus (&as, FALSE, &status);
912 HLISTITEM hAggregate = NULL;
915 LPTSTR pszAggregateText = NULL;
916 int iStatusImage = imageAGGREGATE;
920 pszAggregateText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME, FALSE), status);
921 iStatusImage = imageAGGREGATE_ALERT;
923 else if (Aggregates_GetAlertCount (lpAggregate))
925 pszAggregateText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolSTATUS));
926 iStatusImage = imageAGGREGATE_ALERT;
929 if ((hAggregate = FastList_FindItem (pdr->hList, (LPARAM)lpAggregate->GetIdentifier())) == NULL)
931 hAggregate = Display_InsertItem (pdr->hList, hServer, pszAggregateText,
932 (LPARAM)lpAggregate->GetIdentifier(),
933 imageAGGREGATE, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
937 int iImage1, iImage2;
938 Display_PickImages (&iImage1, &iImage2, imageAGGREGATE, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
939 FastList_SetItemFirstImage (pdr->hList, hAggregate, iImage1);
940 FastList_SetItemSecondImage (pdr->hList, hAggregate, iImage2);
941 FastList_SetItemText (pdr->hList, hAggregate, 0, pszAggregateText);
944 if (pszAggregateText)
945 FreeString (pszAggregateText);
950 // Update all appropriate filesets from this aggregate
952 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsFileset()) ? (pdr->lpiNotify) : NULL;
955 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum, lpiSearch, FALSE); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
957 Display_Filesets_Internal_AddFileset (pdr, lpFileset, hAggregate);
961 if (pdr->fList && hAggregate)
963 BOOL fExpand = (hServer == NULL) ? TRUE : FALSE;
965 LPAGGREGATE_PREF lpap;
966 if ((lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) != NULL)
967 fExpand = lpap->fExpandTree;
969 FastList_SetExpanded (pdr->hList, hAggregate, fExpand);
975 void Display_Filesets_Internal_AddFileset (LPDISPLAYREQUEST pdr, LPFILESET lpFileset, HLISTITEM hAggregate)
980 if (lpFileset->GetIdentifier() == pdr->lpiNotify)
981 status = pdr->status;
983 lpFileset->GetStatus (&fs, FALSE, &status);
989 LPTSTR pszFilesetText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Filesets_GetColumnText (lpFileset->GetIdentifier(), setcolNAME), status);
991 Display_InsertItem (pdr->hList, hAggregate, pszFilesetText,
992 (LPARAM)lpFileset->GetIdentifier(),
993 imageFILESET, imageFILESET_ALERT, gr.ivSet);
995 FreeString (pszFilesetText);
1002 TCHAR szName[ cchNAME ];
1003 lpFileset->GetName (szName);
1004 CB_AddItem (pdr->hList, szName, (LPARAM)lpFileset->GetIdentifier());
1008 LPFILESET_PREF lpfp;
1009 if ((lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) != NULL)
1011 memcpy (&lpfp->fsLast, &fs, sizeof(FILESETSTATUS));
1012 lpfp->lpiRW = lpFileset->GetReadWriteIdentifier();
1015 int iStatusImage = IMAGE_NOIMAGE;
1016 if (Filesets_GetAlertCount (lpFileset))
1017 iStatusImage = imageFILESET_ALERT;
1018 else if (Filesets_fIsLocked (&fs))
1019 iStatusImage = imageFILESET_LOCKED;
1021 Display_InsertItem (pdr->hList, hAggregate, NULL,
1022 (LPARAM)lpFileset->GetIdentifier(),
1023 imageFILESET, iStatusImage, gr.ivSet);
1030 * REPLICAS ___________________________________________________________________
1032 * (lpiNotify is the RW for which to list all replicas)
1036 void Display_Replicas_Internal (LPDISPLAYREQUEST pdr)
1038 if (!IsWindow (pdr->hList))
1041 pdr->lpvi = &gr.viewRep;
1042 pdr->actOnDone = ACT_ENDCHANGE;
1044 LPIDENT lpiRW = pdr->lpiNotify;
1045 VOLUMEID vidReadWrite;
1046 lpiRW->GetFilesetID (&vidReadWrite);
1048 FL_StartChange (pdr->hList, TRUE);
1051 if ((lpCell = lpiRW->OpenCell()) != NULL)
1054 for (LPSERVER lpServer = lpCell->ServerFindFirst (&heServer); lpServer; lpServer = lpCell->ServerFindNext (&heServer))
1057 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&heAggregate); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&heAggregate))
1060 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&heFileset); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&heFileset))
1063 if (lpFileset->GetStatus (&fs))
1065 if ( (fs.Type == ftREPLICA) &&
1066 (!memcmp (&vidReadWrite, &fs.idReadWrite, sizeof(VOLUMEID))) )
1068 LPFILESET_PREF lpfp;
1069 if ((lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) != NULL)
1071 memcpy (&lpfp->fsLast, &fs, sizeof(FILESETSTATUS));
1072 lpfp->lpiRW = lpiRW;
1075 Display_InsertItem (pdr->hList, NULL, NULL,
1076 (LPARAM)lpFileset->GetIdentifier());
1081 lpAggregate->Close();
1091 * SERVER WINDOWS _____________________________________________________________
1095 void Display_ServerWindow_Internal (LPDISPLAYREQUEST pdr)
1097 Server_SelectServer (pdr->hChild, pdr->lpiServer, TRUE); // redraw svr window
1102 * ICON SELECTION _____________________________________________________________
1106 void Display_PickImages (int *piImage0, int *piImage1, int iTypeImage, int iStatusImage, ICONVIEW iv, DWORD dwFlags)
1111 *piImage0 = iTypeImage;
1112 *piImage1 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1113 if (*piImage1 == *piImage0)
1114 *piImage1 = IMAGE_BLANKIMAGE;
1115 if (dwFlags & PIF_ONLYONEICON)
1116 *piImage1 = IMAGE_NOIMAGE;
1120 *piImage0 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1121 *piImage1 = IMAGE_NOIMAGE;
1122 dwFlags |= PIF_ALWAYSSHOWICON;
1126 *piImage0 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1127 *piImage1 = IMAGE_NOIMAGE;
1131 *piImage0 = iTypeImage;
1132 *piImage1 = iStatusImage;
1136 if ((dwFlags & PIF_ALWAYSSHOWICON) && ((*piImage0 == IMAGE_NOIMAGE) || (*piImage0 == IMAGE_BLANKIMAGE)))
1138 *piImage0 = iTypeImage;
1143 HLISTITEM Display_InsertItem (HWND hList, HLISTITEM hParent, LPTSTR pszText, LPARAM lp, int iImage0, int iImage1, ICONVIEW iv, DWORD dwPickImageFlags)
1145 FASTLISTADDITEM flai;
1146 memset (&flai, 0x00, sizeof(flai));
1147 flai.hParent = hParent;
1148 flai.pszText = pszText;
1150 Display_PickImages (&flai.iFirstImage, &flai.iSecondImage, iImage0, iImage1, iv, dwPickImageFlags);
1152 if (dwPickImageFlags & PIF_TREEVIEW_ONLY)
1153 flai.dwFlags |= FLIF_TREEVIEW_ONLY;
1155 if (dwPickImageFlags & PIF_DISALLOW_COLLAPSE)
1156 flai.dwFlags |= FLIF_DISALLOW_COLLAPSE;
1158 return FastList_AddItem (hList, &flai);