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>
19 #include "svr_window.h"
21 #include "svc_startstop.h"
24 #include "set_general.h"
29 * PROTOTYPES _________________________________________________________________
33 void Display_Servers_Internal_Clean (LPDISPLAYREQUEST pdr);
34 void Display_Servers_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
36 void Display_Services_Internal_Clean (LPDISPLAYREQUEST pdr);
37 void Display_Services_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
38 void Display_Services_Internal_AddService (LPDISPLAYREQUEST pdr, LPSERVICE lpService, HLISTITEM hServer);
40 void Display_Aggregates_Internal_Clean (LPDISPLAYREQUEST pdr);
41 void Display_Aggregates_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer);
42 void Display_Aggregates_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer);
44 void Display_Filesets_Internal_Clean (LPDISPLAYREQUEST pdr);
45 HLISTITEM Display_Filesets_Internal_AddCell (LPDISPLAYREQUEST pdr, LPCELL lpCell);
46 void Display_Filesets_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer, HLISTITEM hCell);
47 void Display_Filesets_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer);
48 void Display_Filesets_Internal_AddFileset (LPDISPLAYREQUEST pdr, LPFILESET lpFileset, HLISTITEM hAggregate);
50 #define PIF_ALWAYSSHOWICON 0x00000001
51 #define PIF_ONLYONEICON 0x00000002
52 #define PIF_TREEVIEW_ONLY 0x00000004
53 #define PIF_DISALLOW_COLLAPSE 0x00000008
54 void Display_PickImages (int *piFirstImage, int *piSecondImage, int iTypeImage, int iStatusImage, ICONVIEW iv, DWORD dwPickImageFlags = 0);
55 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);
59 * CELL _______________________________________________________________________
63 void Display_Cell_Internal (LPDISPLAYREQUEST pdr)
65 // Update the "Current Cell:" field on g.hMain
67 TCHAR szCell[ cchNAME ];
68 if (g.lpiCell == NULL)
69 GetString (szCell, IDS_NO_CELL_SELECTED);
71 g.lpiCell->GetCellName (szCell);
73 SetDlgItemText (g.hMain, IDC_CELL, szCell);
75 // Update the "AFS Identity:" field on g.hMain
77 TCHAR szUser[ cchNAME ];
79 if (!AfsAppLib_CrackCredentials (g.hCreds, szCell, szUser, &stExpire))
81 GetString (szUser, IDS_NO_AFS_ID);
82 SetDlgItemText (g.hMain, IDC_AFS_ID, szUser);
86 int ids = (AfsAppLib_IsTimeInFuture (&stExpire)) ? IDS_AFS_ID_WILLEXP : IDS_AFS_ID_DIDEXP;
87 LPTSTR pszText = FormatString (ids, TEXT("%s%t"), szUser, &stExpire);
88 SetDlgItemText (g.hMain, IDC_AFS_ID, pszText);
95 * SERVERS ____________________________________________________________________
99 void Display_Servers_Internal (LPDISPLAYREQUEST pdr)
101 pdr->hList = GetDlgItem (g.hMain, IDC_SERVERS);
102 pdr->lpvi = (gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr;
104 if (!IsWindow (pdr->hList))
107 // Fix up the image lists for the Servers window
111 FastList_GetImageLists (pdr->hList, &hiSmall, &hiLarge);
112 if (!hiSmall || !hiLarge)
114 hiSmall = AfsAppLib_CreateImageList (FALSE);
115 hiLarge = AfsAppLib_CreateImageList (TRUE);
116 FastList_SetImageLists (pdr->hList, hiSmall, hiLarge);
119 // Add an entry in the Servers list for each server in the cell.
121 // LPIDENT lpiSelStart = (LPIDENT)FL_GetSelectedData (pdr->hList);
122 // BOOL fRefresh = FALSE;
125 if (!g.lpiCell || !(lpCell = g.lpiCell->OpenCell()))
127 LPTSTR pszCover = FormatString (IDS_ERROR_REFRESH_CELLSERVERS_NOCELL);
128 AfsAppLib_CoverWindow (pdr->hList, pszCover);
129 FreeString (pszCover);
135 pdr->lpiToSelect = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
136 pdr->actOnDone = ACT_ENDCHANGE | ACT_SELPREVIEW;
138 // Remove any to-be-replaced old servers
140 Display_Servers_Internal_Clean (pdr);
142 // Add a server entry for each server as appropriate
145 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, pdr->lpiNotify, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
147 Display_Servers_Internal_AddServer (pdr, lpServer);
152 pdr->actOnDone |= ACT_UNCOVER;
159 void Display_Servers_Internal_Clean (LPDISPLAYREQUEST pdr)
161 if (pdr->lpiNotify) // else, we already emptied the list
164 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
165 FastList_RemoveItem (pdr->hList, hItem);
170 void Display_Servers_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
175 if (lpServer->GetIdentifier() == pdr->lpiNotify)
176 status = pdr->status;
180 lpServer->GetStatus (&ss, FALSE, &status);
183 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
184 memcpy (&lpsp->ssLast, &ss, sizeof(SERVERSTATUS));
187 ICONVIEW ivSvr = Display_GetServerIconView();
191 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
193 Display_InsertItem (pdr->hList,
196 (LPARAM)lpServer->GetIdentifier(),
197 imageSERVER, imageSERVER_ALERT, ivSvr);
199 FreeString (pszCol1);
203 int iStatusImage = IMAGE_NOIMAGE;
204 if (!lpServer->fIsMonitored())
205 iStatusImage = imageSERVER_UNMON;
206 else if (Server_GetAlertCount (lpServer))
207 iStatusImage = imageSERVER_ALERT;
209 Display_InsertItem (pdr->hList,
212 (LPARAM)lpServer->GetIdentifier(),
213 imageSERVER, iStatusImage, ivSvr);
219 * SERVICES ___________________________________________________________________
223 void Display_Services_Internal (LPDISPLAYREQUEST pdr)
225 pdr->hList = GetDlgItem (pdr->hChild, IDC_SVC_LIST);
226 pdr->lpvi = &gr.viewSvc;
228 if (!IsWindow (pdr->hList))
231 // First off, can we totally ignore this request?
233 LPIDENT lpiWindow = Server_GetServerForChild (pdr->hChild);
234 if (lpiWindow && pdr->lpiNotify && (lpiWindow != pdr->lpiNotify->GetServer()))
237 // Fix up the image lists for the Services window
240 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
243 hiSmall = AfsAppLib_CreateImageList (FALSE);
244 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
247 // Add either all services, or one server's services, or one service.
250 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
252 pdr->lpiToSelect = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
253 pdr->actOnDone = ACT_ENDCHANGE;
255 // Remove any to-be-replaced old services
257 Display_Services_Internal_Clean (pdr);
259 // Update all appropriate service entries
261 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : lpiWindow;
264 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
266 if (lpServer->fIsMonitored())
267 Display_Services_Internal_AddServer (pdr, lpServer);
271 if (pdr->lpiToSelect)
272 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
278 void Display_Services_Internal_Clean (LPDISPLAYREQUEST pdr)
280 if (pdr->lpiNotify) // else, we already emptied the list
283 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
284 FastList_RemoveItem (pdr->hList, hItem);
289 void Display_Services_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
294 if (lpServer->GetIdentifier() == pdr->lpiNotify)
295 status = pdr->status;
297 lpServer->GetStatus (&ss, FALSE, &status);
299 LPTSTR pszServerText = NULL;
300 int iStatusImage = imageSERVER;
301 BOOL fContinue = TRUE;
305 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
306 iStatusImage = imageSERVER_ALERT;
309 else if (Server_GetAlertCount (lpServer))
311 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
312 iStatusImage = imageSERVER_ALERT;
316 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
318 hServer = Display_InsertItem (pdr->hList, NULL, pszServerText,
319 (LPARAM)lpServer->GetIdentifier(),
320 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
324 int iImage1, iImage2;
325 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
326 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
327 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
328 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
332 FreeString (pszServerText);
336 // Update icons for all appropriate services
338 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsService()) ? (pdr->lpiNotify) : NULL;
341 for (LPSERVICE lpService = lpServer->ServiceFindFirst (&hEnum, lpiSearch, FALSE); lpService; lpService = lpServer->ServiceFindNext (&hEnum))
343 Display_Services_Internal_AddService (pdr, lpService, hServer);
350 void Display_Services_Internal_AddService (LPDISPLAYREQUEST pdr, LPSERVICE lpService, HLISTITEM hServer)
355 if (lpService->GetIdentifier() == pdr->lpiNotify)
356 status = pdr->status;
358 lpService->GetStatus (&ss, FALSE, &status);
360 BOOL fShowServerName = !Server_GetServer (pdr->hChild);
364 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Services_GetColumnText (lpService->GetIdentifier(), svccolNAME, fShowServerName), status);
366 Display_InsertItem (pdr->hList,
369 (LPARAM)lpService->GetIdentifier(),
370 imageSERVICE, imageSERVICE_ALERT, gr.ivSvc);
372 FreeString (pszCol1);
376 TCHAR szName[ cchRESOURCE ];
377 lpService->GetName (szName);
379 BOOL fIsBOS = !lstrcmpi (szName, TEXT("BOS"));
382 if ((lpsp = (LPSERVICE_PREF)lpService->GetUserParam()) != NULL)
383 memcpy (&lpsp->ssLast, &ss, sizeof(SERVICESTATUS));
385 int iTypeImage = imageSERVICE;
387 iTypeImage = imageBOSSERVICE;
389 int iStatusImage = IMAGE_NOIMAGE;
390 if (Services_GetAlertCount (lpService))
391 iStatusImage = imageSERVICE_ALERT;
392 else if (!Services_fRunning (lpService))
393 iStatusImage = imageSERVICE_STOPPED;
395 iStatusImage = imageBOSSERVICE;
397 Display_InsertItem (pdr->hList,
400 (LPARAM)lpService->GetIdentifier(),
401 iTypeImage, iStatusImage, gr.ivSvc);
407 * AGGREGATES _________________________________________________________________
411 void Display_Aggregates_Internal (LPDISPLAYREQUEST pdr)
413 if (pdr->lpvi == NULL)
414 pdr->lpvi = &gr.viewAgg;
416 if (!IsWindow (pdr->hList))
419 TCHAR szClassName[ cchRESOURCE ];
420 if (GetClassName (pdr->hList, szClassName, cchRESOURCE))
422 if (!lstrcmp (szClassName, WC_FASTLIST))
426 // First off, can we totally ignore this request?
428 if (pdr->lpiServer && pdr->lpiNotify && (pdr->lpiServer != pdr->lpiNotify->GetServer()))
431 // Fix up the image lists for the Aggregates window
436 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
439 hiSmall = AfsAppLib_CreateImageList (FALSE);
440 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
444 // Add either all aggregates, or one server's aggregates, or one aggregate.
447 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
449 LPIDENT lpiSelectedNow;
451 lpiSelectedNow = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
453 lpiSelectedNow = (LPIDENT)CB_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
455 if (!pdr->lpiToSelect)
456 pdr->lpiToSelect = lpiSelectedNow;
458 pdr->actOnDone = ACT_ENDCHANGE;
460 // Remove any to-be-replaced old services
462 Display_Aggregates_Internal_Clean (pdr);
464 // Update all appropriate aggregate entries
466 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : pdr->lpiServer;
469 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
471 if (lpServer->fIsMonitored())
472 Display_Aggregates_Internal_AddServer (pdr, lpServer);
476 if (pdr->lpiToSelect)
479 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
481 CB_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
483 if (!pdr->fList) // combobox? then always pick *something*...
485 if (!CB_GetSelectedData (pdr->hList))
487 pdr->lpiToSelect = (LPIDENT)CB_GetData (pdr->hList, 0);
496 void Display_Aggregates_Internal_Clean (LPDISPLAYREQUEST pdr)
498 if (pdr->lpiNotify) // else, we already emptied the list
503 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)(pdr->lpiNotify))) != NULL)
504 FastList_RemoveItem (pdr->hList, hItem);
508 size_t iMax = SendMessage (pdr->hList, CB_GETCOUNT, 0, 0);
510 for (size_t iItem = 0; iItem < iMax; )
512 BOOL fDelete = FALSE;
515 if ((lpiItem = (LPIDENT)CB_GetData (pdr->hList, iItem)) != NULL)
517 // delete the entry if it's the TBD server or aggregate
519 if (lpiItem == pdr->lpiNotify)
522 // delete the entry if it's the server of a TBD aggregate
524 if (lpiItem == pdr->lpiNotify->GetServer())
527 // delete the entry if it's an aggregate on the TBD server
529 if (lpiItem->GetServer() == pdr->lpiNotify)
537 SendMessage (pdr->hList, CB_DELETESTRING, iItem, 0);
546 void Display_Aggregates_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer)
551 if (lpServer->GetIdentifier() == pdr->lpiNotify)
552 status = pdr->status;
554 lpServer->GetStatus (&ss, FALSE, &status);
556 HLISTITEM hServer = NULL;
559 LPTSTR pszServerText = NULL;
560 int iStatusImage = imageSERVER;
564 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
565 iStatusImage = imageSERVER_ALERT;
567 else if (Server_GetAlertCount (lpServer))
569 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
570 iStatusImage = imageSERVER_ALERT;
573 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
575 hServer = Display_InsertItem (pdr->hList, NULL, pszServerText,
576 (LPARAM)lpServer->GetIdentifier(),
577 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
581 int iImage1, iImage2;
582 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
583 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
584 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
585 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
589 FreeString (pszServerText);
592 if ((hServer || !pdr->fList) && !status)
594 // Update icons for all appropriate aggregates
596 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsAggregate()) ? (pdr->lpiNotify) : NULL;
599 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum, lpiSearch, FALSE); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
601 Display_Aggregates_Internal_AddAggregate (pdr, lpAggregate, hServer);
602 lpAggregate->Close();
608 void Display_Aggregates_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer)
613 if (lpAggregate->GetIdentifier() == pdr->lpiNotify)
614 status = pdr->status;
616 lpAggregate->GetStatus (&as, FALSE, &status);
618 BOOL fShowServerName = !Server_GetServer (pdr->hChild);
622 LPTSTR pszCol1 = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME, fShowServerName), status);
626 Display_InsertItem (pdr->hList, hServer, pszCol1,
627 (LPARAM)lpAggregate->GetIdentifier(),
628 imageAGGREGATE, imageAGGREGATE_ALERT, gr.ivAgg);
632 CB_AddItem (pdr->hList, pszCol1, (LPARAM)lpAggregate->GetIdentifier());
635 FreeString (pszCol1);
639 LPAGGREGATE_PREF lpap;
640 if ((lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) != NULL)
642 memcpy (&lpap->asLast, &as, sizeof(AGGREGATESTATUS));
643 lpAggregate->GetDevice (lpap->szDevice);
648 int iStatusImage = IMAGE_NOIMAGE;
649 if (Aggregates_GetAlertCount (lpAggregate))
650 iStatusImage = imageAGGREGATE_ALERT;
652 Display_InsertItem (pdr->hList, hServer, NULL,
653 (LPARAM)lpAggregate->GetIdentifier(),
654 imageAGGREGATE, iStatusImage, gr.ivAgg);
658 TCHAR szName[ cchNAME ];
659 lpAggregate->GetIdentifier()->GetAggregateName (szName);
660 CB_AddItem (pdr->hList, szName, (LPARAM)lpAggregate->GetIdentifier());
667 * FILESETS ___________________________________________________________________
671 void Display_Filesets_Internal (LPDISPLAYREQUEST pdr)
673 if (pdr->hList == NULL)
674 pdr->hList = GetDlgItem (pdr->hChild, IDC_SET_LIST);
676 if (!IsWindow (pdr->hList))
679 TCHAR szClassName[ cchRESOURCE ];
680 if (GetClassName (pdr->hList, szClassName, cchRESOURCE))
682 if (!lstrcmp (szClassName, WC_FASTLIST))
686 pdr->lpvi = (pdr->fList) ? &gr.viewSet : NULL;
688 // First off, can we totally ignore this request?
690 if (pdr->lpiServer && pdr->lpiNotify && (pdr->lpiServer != pdr->lpiNotify->GetServer()))
693 // Fix up the image lists for the Filesets window
698 FastList_GetImageLists (pdr->hList, &hiSmall, NULL);
701 hiSmall = AfsAppLib_CreateImageList (FALSE);
702 FastList_SetImageLists (pdr->hList, hiSmall, NULL);
706 // Add either all filesets, or one server's filesets, or one fileset.
709 if (g.lpiCell && (lpCell = g.lpiCell->OpenCell()))
711 pdr->actOnDone = ACT_ENDCHANGE;
713 // Remove any to-be-replaced old services
715 LPIDENT lpiSelectedNow;
717 lpiSelectedNow = (LPIDENT)FL_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
719 lpiSelectedNow = (LPIDENT)CB_StartChange (pdr->hList, (pdr->lpiNotify) ? FALSE : TRUE);
720 Display_Filesets_Internal_Clean (pdr);
722 if (! pdr->lpiToSelect)
723 pdr->lpiToSelect = lpiSelectedNow;
726 hCell = Display_Filesets_Internal_AddCell (pdr, lpCell);
728 // Update all appropriate fileset entries
730 LPIDENT lpiRefresh = (pdr->lpiNotify) ? pdr->lpiNotify : pdr->lpiServer;
733 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, lpiRefresh, FALSE); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
735 if (lpServer->fIsMonitored())
736 Display_Filesets_Internal_AddServer (pdr, lpServer, hCell);
740 if (pdr->lpiToSelect)
743 FL_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
745 CB_SetSelectedByData (pdr->hList, (LPARAM)pdr->lpiToSelect);
747 if (!pdr->fList) // combobox? then always pick *something*...
749 if (!CB_GetSelectedData (pdr->hList))
751 pdr->lpiToSelect = (LPIDENT)CB_GetData (pdr->hList, 0);
760 void Display_Filesets_Internal_Clean (LPDISPLAYREQUEST pdr)
767 if ((hItem = FastList_FindItem (pdr->hList, (LPARAM)pdr->lpiNotify)) != NULL)
769 FastList_RemoveItem (pdr->hList, hItem);
772 else // Must be a combobox
774 size_t iMax = SendMessage (pdr->hList, CB_GETCOUNT, 0, 0);
776 for (size_t iItem = 0; iItem < iMax; )
778 BOOL fDelete = FALSE;
781 if ((lpiItem = (LPIDENT)CB_GetData (pdr->hList, iItem)) != NULL)
783 if (lpiItem->GetServer() == pdr->lpiNotify)
785 if (lpiItem->GetAggregate() == pdr->lpiNotify)
787 if (lpiItem == pdr->lpiNotify)
795 SendMessage (pdr->hList, CB_DELETESTRING, iItem, 0);
804 HLISTITEM Display_Filesets_Internal_AddCell (LPDISPLAYREQUEST pdr, LPCELL lpCell)
810 if ((hCell = FastList_FindItem (pdr->hList, (LPARAM)lpCell->GetIdentifier())) == NULL)
812 TCHAR szName[ cchNAME ];
813 lpCell->GetName (szName);
815 hCell = Display_InsertItem (pdr->hList, NULL, szName,
816 (LPARAM)lpCell->GetIdentifier(),
817 imageCELL, IMAGE_NOIMAGE, gr.ivSet,
818 PIF_ALWAYSSHOWICON | PIF_ONLYONEICON | PIF_TREEVIEW_ONLY | PIF_DISALLOW_COLLAPSE);
825 void Display_Filesets_Internal_AddServer (LPDISPLAYREQUEST pdr, LPSERVER lpServer, HLISTITEM hCell)
830 if (lpServer->GetIdentifier() == pdr->lpiNotify)
831 status = pdr->status;
833 lpServer->GetStatus (&ss, FALSE, &status);
835 HLISTITEM hServer = NULL;
838 LPTSTR pszServerText = NULL;
839 int iStatusImage = imageSERVER;
843 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), status);
844 iStatusImage = imageSERVER_ALERT;
846 else if (Server_GetAlertCount (lpServer))
848 pszServerText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Server_GetColumnText (lpServer->GetIdentifier(), svrcolNAME), Server_GetColumnText (lpServer->GetIdentifier(), svrcolSTATUS));
849 iStatusImage = imageSERVER_ALERT;
852 if ((hServer = FastList_FindItem (pdr->hList, (LPARAM)(lpServer->GetIdentifier()))) == NULL)
854 hServer = Display_InsertItem (pdr->hList, hCell, pszServerText,
855 (LPARAM)lpServer->GetIdentifier(),
856 imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
860 int iImage1, iImage2;
861 Display_PickImages (&iImage1, &iImage2, imageSERVER, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
862 FastList_SetItemFirstImage (pdr->hList, hServer, iImage1);
863 FastList_SetItemSecondImage (pdr->hList, hServer, iImage2);
864 FastList_SetItemText (pdr->hList, hServer, 0, pszServerText);
868 FreeString (pszServerText);
873 // Update filesets on all appropriate aggregates
875 LPIDENT lpiSearch = (pdr->lpiNotify && !pdr->lpiNotify->fIsServer()) ? (pdr->lpiNotify->GetAggregate()) : pdr->lpiAggregate;
878 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum, lpiSearch, FALSE); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
880 Display_Filesets_Internal_AddAggregate (pdr, lpAggregate, hServer);
881 lpAggregate->Close();
884 if (pdr->fList && hServer)
889 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
890 fExpand = lpsp->fExpandTree;
892 FastList_SetExpanded (pdr->hList, hServer, fExpand);
898 void Display_Filesets_Internal_AddAggregate (LPDISPLAYREQUEST pdr, LPAGGREGATE lpAggregate, HLISTITEM hServer)
903 if (lpAggregate->GetIdentifier() == pdr->lpiNotify)
904 status = pdr->status;
906 lpAggregate->GetStatus (&as, FALSE, &status);
908 HLISTITEM hAggregate = NULL;
911 LPTSTR pszAggregateText = NULL;
912 int iStatusImage = imageAGGREGATE;
916 pszAggregateText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME, FALSE), status);
917 iStatusImage = imageAGGREGATE_ALERT;
919 else if (Aggregates_GetAlertCount (lpAggregate))
921 pszAggregateText = FormatString (TEXT("%1 - %2"), TEXT("%s%s"), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolNAME), Aggregates_GetColumnText (lpAggregate->GetIdentifier(), aggcolSTATUS));
922 iStatusImage = imageAGGREGATE_ALERT;
925 if ((hAggregate = FastList_FindItem (pdr->hList, (LPARAM)lpAggregate->GetIdentifier())) == NULL)
927 hAggregate = Display_InsertItem (pdr->hList, hServer, pszAggregateText,
928 (LPARAM)lpAggregate->GetIdentifier(),
929 imageAGGREGATE, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
933 int iImage1, iImage2;
934 Display_PickImages (&iImage1, &iImage2, imageAGGREGATE, iStatusImage, gr.ivSet, PIF_ALWAYSSHOWICON | PIF_TREEVIEW_ONLY);
935 FastList_SetItemFirstImage (pdr->hList, hAggregate, iImage1);
936 FastList_SetItemSecondImage (pdr->hList, hAggregate, iImage2);
937 FastList_SetItemText (pdr->hList, hAggregate, 0, pszAggregateText);
940 if (pszAggregateText)
941 FreeString (pszAggregateText);
946 // Update all appropriate filesets from this aggregate
948 LPIDENT lpiSearch = (pdr->lpiNotify && pdr->lpiNotify->fIsFileset()) ? (pdr->lpiNotify) : NULL;
951 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum, lpiSearch, FALSE); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
953 Display_Filesets_Internal_AddFileset (pdr, lpFileset, hAggregate);
957 if (pdr->fList && hAggregate)
959 BOOL fExpand = (hServer == NULL) ? TRUE : FALSE;
961 LPAGGREGATE_PREF lpap;
962 if ((lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) != NULL)
963 fExpand = lpap->fExpandTree;
965 FastList_SetExpanded (pdr->hList, hAggregate, fExpand);
971 void Display_Filesets_Internal_AddFileset (LPDISPLAYREQUEST pdr, LPFILESET lpFileset, HLISTITEM hAggregate)
976 if (lpFileset->GetIdentifier() == pdr->lpiNotify)
977 status = pdr->status;
979 lpFileset->GetStatus (&fs, FALSE, &status);
985 LPTSTR pszFilesetText = FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Filesets_GetColumnText (lpFileset->GetIdentifier(), setcolNAME), status);
987 Display_InsertItem (pdr->hList, hAggregate, pszFilesetText,
988 (LPARAM)lpFileset->GetIdentifier(),
989 imageFILESET, imageFILESET_ALERT, gr.ivSet);
991 FreeString (pszFilesetText);
998 TCHAR szName[ cchNAME ];
999 lpFileset->GetName (szName);
1000 CB_AddItem (pdr->hList, szName, (LPARAM)lpFileset->GetIdentifier());
1004 LPFILESET_PREF lpfp;
1005 if ((lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) != NULL)
1007 memcpy (&lpfp->fsLast, &fs, sizeof(FILESETSTATUS));
1008 lpfp->lpiRW = lpFileset->GetReadWriteIdentifier();
1011 int iStatusImage = IMAGE_NOIMAGE;
1012 if (Filesets_GetAlertCount (lpFileset))
1013 iStatusImage = imageFILESET_ALERT;
1014 else if (Filesets_fIsLocked (&fs))
1015 iStatusImage = imageFILESET_LOCKED;
1017 Display_InsertItem (pdr->hList, hAggregate, NULL,
1018 (LPARAM)lpFileset->GetIdentifier(),
1019 imageFILESET, iStatusImage, gr.ivSet);
1026 * REPLICAS ___________________________________________________________________
1028 * (lpiNotify is the RW for which to list all replicas)
1032 void Display_Replicas_Internal (LPDISPLAYREQUEST pdr)
1034 if (!IsWindow (pdr->hList))
1037 pdr->lpvi = &gr.viewRep;
1038 pdr->actOnDone = ACT_ENDCHANGE;
1040 LPIDENT lpiRW = pdr->lpiNotify;
1041 VOLUMEID vidReadWrite;
1042 lpiRW->GetFilesetID (&vidReadWrite);
1044 FL_StartChange (pdr->hList, TRUE);
1047 if ((lpCell = lpiRW->OpenCell()) != NULL)
1050 for (LPSERVER lpServer = lpCell->ServerFindFirst (&heServer); lpServer; lpServer = lpCell->ServerFindNext (&heServer))
1053 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&heAggregate); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&heAggregate))
1056 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&heFileset); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&heFileset))
1059 if (lpFileset->GetStatus (&fs))
1061 if ( (fs.Type == ftREPLICA) &&
1062 (!memcmp (&vidReadWrite, &fs.idReadWrite, sizeof(VOLUMEID))) )
1064 LPFILESET_PREF lpfp;
1065 if ((lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) != NULL)
1067 memcpy (&lpfp->fsLast, &fs, sizeof(FILESETSTATUS));
1068 lpfp->lpiRW = lpiRW;
1071 Display_InsertItem (pdr->hList, NULL, NULL,
1072 (LPARAM)lpFileset->GetIdentifier());
1077 lpAggregate->Close();
1087 * SERVER WINDOWS _____________________________________________________________
1091 void Display_ServerWindow_Internal (LPDISPLAYREQUEST pdr)
1093 Server_SelectServer (pdr->hChild, pdr->lpiServer, TRUE); // redraw svr window
1098 * ICON SELECTION _____________________________________________________________
1102 void Display_PickImages (int *piImage0, int *piImage1, int iTypeImage, int iStatusImage, ICONVIEW iv, DWORD dwFlags)
1107 *piImage0 = iTypeImage;
1108 *piImage1 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1109 if (*piImage1 == *piImage0)
1110 *piImage1 = IMAGE_BLANKIMAGE;
1111 if (dwFlags & PIF_ONLYONEICON)
1112 *piImage1 = IMAGE_NOIMAGE;
1116 *piImage0 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1117 *piImage1 = IMAGE_NOIMAGE;
1118 dwFlags |= PIF_ALWAYSSHOWICON;
1122 *piImage0 = (iStatusImage == IMAGE_NOIMAGE) ? IMAGE_BLANKIMAGE : iStatusImage;
1123 *piImage1 = IMAGE_NOIMAGE;
1127 *piImage0 = iTypeImage;
1128 *piImage1 = iStatusImage;
1132 if ((dwFlags & PIF_ALWAYSSHOWICON) && ((*piImage0 == IMAGE_NOIMAGE) || (*piImage0 == IMAGE_BLANKIMAGE)))
1134 *piImage0 = iTypeImage;
1139 HLISTITEM Display_InsertItem (HWND hList, HLISTITEM hParent, LPTSTR pszText, LPARAM lp, int iImage0, int iImage1, ICONVIEW iv, DWORD dwPickImageFlags)
1141 FASTLISTADDITEM flai;
1142 memset (&flai, 0x00, sizeof(flai));
1143 flai.hParent = hParent;
1144 flai.pszText = pszText;
1146 Display_PickImages (&flai.iFirstImage, &flai.iSecondImage, iImage0, iImage1, iv, dwPickImageFlags);
1148 if (dwPickImageFlags & PIF_TREEVIEW_ONLY)
1149 flai.dwFlags |= FLIF_TREEVIEW_ONLY;
1151 if (dwPickImageFlags & PIF_DISALLOW_COLLAPSE)
1152 flai.dwFlags |= FLIF_DISALLOW_COLLAPSE;
1154 return FastList_AddItem (hList, &flai);