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>
22 #include "svr_window.h"
24 #include "svc_startstop.h"
27 #include "set_general.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
);
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
];
82 if (!AfsAppLib_CrackCredentials (g
.hCreds
, szCell
, szUser
, &stExpire
))
84 GetString (szUser
, IDS_NO_AFS_ID
);
85 SetDlgItemText (g
.hMain
, IDC_AFS_ID
, szUser
);
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
);
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
))
110 // Fix up the image lists for the Servers window
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;
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
);
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
148 for (LPSERVER lpServer
= lpCell
->ServerFindFirst (&hEnum
, pdr
->lpiNotify
, FALSE
); lpServer
; lpServer
= lpCell
->ServerFindNext (&hEnum
))
150 Display_Servers_Internal_AddServer (pdr
, lpServer
);
155 pdr
->actOnDone
|= ACT_UNCOVER
;
162 void Display_Servers_Internal_Clean (LPDISPLAYREQUEST pdr
)
164 if (pdr
->lpiNotify
) // else, we already emptied the list
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
)
178 if (lpServer
->GetIdentifier() == pdr
->lpiNotify
)
179 status
= pdr
->status
;
183 lpServer
->GetStatus (&ss
, FALSE
, &status
);
186 if ((lpsp
= (LPSERVER_PREF
)lpServer
->GetUserParam()) != NULL
)
187 memcpy (&lpsp
->ssLast
, &ss
, sizeof(SERVERSTATUS
));
190 ICONVIEW ivSvr
= Display_GetServerIconView();
194 LPTSTR pszCol1
= FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer
->GetIdentifier(), svrcolNAME
), status
);
196 Display_InsertItem (pdr
->hList
,
199 (LPARAM
)lpServer
->GetIdentifier(),
200 imageSERVER
, imageSERVER_ALERT
, ivSvr
);
202 FreeString (pszCol1
);
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
,
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
))
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()))
240 // Fix up the image lists for the Services window
243 FastList_GetImageLists (pdr
->hList
, &hiSmall
, NULL
);
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.
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
;
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
);
274 if (pdr
->lpiToSelect
)
275 FL_SetSelectedByData (pdr
->hList
, (LPARAM
)pdr
->lpiToSelect
);
281 void Display_Services_Internal_Clean (LPDISPLAYREQUEST pdr
)
283 if (pdr
->lpiNotify
) // else, we already emptied the list
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
)
297 if (lpServer
->GetIdentifier() == pdr
->lpiNotify
)
298 status
= pdr
->status
;
300 lpServer
->GetStatus (&ss
, FALSE
, &status
);
302 LPTSTR pszServerText
= NULL
;
303 int iStatusImage
= imageSERVER
;
304 BOOL fContinue
= TRUE
;
308 pszServerText
= FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Server_GetColumnText (lpServer
->GetIdentifier(), svrcolNAME
), status
);
309 iStatusImage
= imageSERVER_ALERT
;
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
;
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
);
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
);
335 FreeString (pszServerText
);
339 // Update icons for all appropriate services
341 LPIDENT lpiSearch
= (pdr
->lpiNotify
&& pdr
->lpiNotify
->fIsService()) ? (pdr
->lpiNotify
) : NULL
;
344 for (LPSERVICE lpService
= lpServer
->ServiceFindFirst (&hEnum
, lpiSearch
, FALSE
); lpService
; lpService
= lpServer
->ServiceFindNext (&hEnum
))
346 Display_Services_Internal_AddService (pdr
, lpService
, hServer
);
353 void Display_Services_Internal_AddService (LPDISPLAYREQUEST pdr
, LPSERVICE lpService
, HLISTITEM hServer
)
358 if (lpService
->GetIdentifier() == pdr
->lpiNotify
)
359 status
= pdr
->status
;
361 lpService
->GetStatus (&ss
, FALSE
, &status
);
363 BOOL fShowServerName
= !Server_GetServer (pdr
->hChild
);
367 LPTSTR pszCol1
= FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Services_GetColumnText (lpService
->GetIdentifier(), svccolNAME
, fShowServerName
), status
);
369 Display_InsertItem (pdr
->hList
,
372 (LPARAM
)lpService
->GetIdentifier(),
373 imageSERVICE
, imageSERVICE_ALERT
, gr
.ivSvc
);
375 FreeString (pszCol1
);
379 TCHAR szName
[ cchRESOURCE
];
380 lpService
->GetName (szName
);
382 BOOL fIsBOS
= !lstrcmpi (szName
, TEXT("BOS"));
385 if ((lpsp
= (LPSERVICE_PREF
)lpService
->GetUserParam()) != NULL
)
386 memcpy (&lpsp
->ssLast
, &ss
, sizeof(SERVICESTATUS
));
388 int iTypeImage
= imageSERVICE
;
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
;
398 iStatusImage
= imageBOSSERVICE
;
400 Display_InsertItem (pdr
->hList
,
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
))
422 TCHAR szClassName
[ cchRESOURCE
];
423 if (GetClassName (pdr
->hList
, szClassName
, cchRESOURCE
))
425 if (!lstrcmp (szClassName
, WC_FASTLIST
))
429 // First off, can we totally ignore this request?
431 if (pdr
->lpiServer
&& pdr
->lpiNotify
&& (pdr
->lpiServer
!= pdr
->lpiNotify
->GetServer()))
434 // Fix up the image lists for the Aggregates window
439 FastList_GetImageLists (pdr
->hList
, &hiSmall
, NULL
);
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.
450 if (g
.lpiCell
&& (lpCell
= g
.lpiCell
->OpenCell()))
452 LPIDENT lpiSelectedNow
;
454 lpiSelectedNow
= (LPIDENT
)FL_StartChange (pdr
->hList
, (pdr
->lpiNotify
) ? FALSE
: TRUE
);
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
;
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
);
479 if (pdr
->lpiToSelect
)
482 FL_SetSelectedByData (pdr
->hList
, (LPARAM
)pdr
->lpiToSelect
);
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);
499 void Display_Aggregates_Internal_Clean (LPDISPLAYREQUEST pdr
)
501 if (pdr
->lpiNotify
) // else, we already emptied the list
506 if ((hItem
= FastList_FindItem (pdr
->hList
, (LPARAM
)(pdr
->lpiNotify
))) != NULL
)
507 FastList_RemoveItem (pdr
->hList
, hItem
);
511 size_t iMax
= SendMessage (pdr
->hList
, CB_GETCOUNT
, 0, 0);
513 for (UINT iItem
= 0; iItem
< iMax
; )
515 BOOL fDelete
= FALSE
;
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
)
525 // delete the entry if it's the server of a TBD aggregate
527 if (lpiItem
== pdr
->lpiNotify
->GetServer())
530 // delete the entry if it's an aggregate on the TBD server
532 if (lpiItem
->GetServer() == pdr
->lpiNotify
)
540 SendMessage (pdr
->hList
, CB_DELETESTRING
, iItem
, 0);
549 void Display_Aggregates_Internal_AddServer (LPDISPLAYREQUEST pdr
, LPSERVER lpServer
)
554 if (lpServer
->GetIdentifier() == pdr
->lpiNotify
)
555 status
= pdr
->status
;
557 lpServer
->GetStatus (&ss
, FALSE
, &status
);
559 HLISTITEM hServer
= NULL
;
562 LPTSTR pszServerText
= NULL
;
563 int iStatusImage
= imageSERVER
;
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
);
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
);
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
;
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
)
616 if (lpAggregate
->GetIdentifier() == pdr
->lpiNotify
)
617 status
= pdr
->status
;
619 lpAggregate
->GetStatus (&as
, FALSE
, &status
);
621 BOOL fShowServerName
= !Server_GetServer (pdr
->hChild
);
625 LPTSTR pszCol1
= FormatString (TEXT("%1 - %2"), TEXT("%s%e"), Aggregates_GetColumnText (lpAggregate
->GetIdentifier(), aggcolNAME
, fShowServerName
), status
);
629 Display_InsertItem (pdr
->hList
, hServer
, pszCol1
,
630 (LPARAM
)lpAggregate
->GetIdentifier(),
631 imageAGGREGATE
, imageAGGREGATE_ALERT
, gr
.ivAgg
);
635 CB_AddItem (pdr
->hList
, pszCol1
, (LPARAM
)lpAggregate
->GetIdentifier());
638 FreeString (pszCol1
);
642 LPAGGREGATE_PREF lpap
;
643 if ((lpap
= (LPAGGREGATE_PREF
)lpAggregate
->GetUserParam()) != NULL
)
645 memcpy (&lpap
->asLast
, &as
, sizeof(AGGREGATESTATUS
));
646 lpAggregate
->GetDevice (lpap
->szDevice
);
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
);
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
))
682 TCHAR szClassName
[ cchRESOURCE
];
683 if (GetClassName (pdr
->hList
, szClassName
, cchRESOURCE
))
685 if (!lstrcmp (szClassName
, WC_FASTLIST
))
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()))
696 // Fix up the image lists for the Filesets window
701 FastList_GetImageLists (pdr
->hList
, &hiSmall
, NULL
);
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.
712 if (g
.lpiCell
&& (lpCell
= g
.lpiCell
->OpenCell()))
714 pdr
->actOnDone
= ACT_ENDCHANGE
;
716 // Remove any to-be-replaced old services
718 LPIDENT lpiSelectedNow
;
720 lpiSelectedNow
= (LPIDENT
)FL_StartChange (pdr
->hList
, (pdr
->lpiNotify
) ? FALSE
: TRUE
);
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
;
729 hCell
= Display_Filesets_Internal_AddCell (pdr
, lpCell
);
731 // Update all appropriate fileset entries
733 LPIDENT lpiRefresh
= (pdr
->lpiNotify
) ? pdr
->lpiNotify
: pdr
->lpiServer
;
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
);
743 if (pdr
->lpiToSelect
)
746 FL_SetSelectedByData (pdr
->hList
, (LPARAM
)pdr
->lpiToSelect
);
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);
763 void Display_Filesets_Internal_Clean (LPDISPLAYREQUEST pdr
)
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
;
784 if ((lpiItem
= (LPIDENT
)CB_GetData (pdr
->hList
, iItem
)) != NULL
)
786 if (lpiItem
->GetServer() == pdr
->lpiNotify
)
788 if (lpiItem
->GetAggregate() == pdr
->lpiNotify
)
790 if (lpiItem
== pdr
->lpiNotify
)
798 SendMessage (pdr
->hList
, CB_DELETESTRING
, iItem
, 0);
807 HLISTITEM
Display_Filesets_Internal_AddCell (LPDISPLAYREQUEST pdr
, LPCELL lpCell
)
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
);
828 void Display_Filesets_Internal_AddServer (LPDISPLAYREQUEST pdr
, LPSERVER lpServer
, HLISTITEM hCell
)
833 if (lpServer
->GetIdentifier() == pdr
->lpiNotify
)
834 status
= pdr
->status
;
836 lpServer
->GetStatus (&ss
, FALSE
, &status
);
838 HLISTITEM hServer
= NULL
;
841 LPTSTR pszServerText
= NULL
;
842 int iStatusImage
= imageSERVER
;
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
);
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
);
871 FreeString (pszServerText
);
876 // Update filesets on all appropriate aggregates
878 LPIDENT lpiSearch
= (pdr
->lpiNotify
&& !pdr
->lpiNotify
->fIsServer()) ? (pdr
->lpiNotify
->GetAggregate()) : pdr
->lpiAggregate
;
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
)
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
)
906 if (lpAggregate
->GetIdentifier() == pdr
->lpiNotify
)
907 status
= pdr
->status
;
909 lpAggregate
->GetStatus (&as
, FALSE
, &status
);
911 HLISTITEM hAggregate
= NULL
;
914 LPTSTR pszAggregateText
= NULL
;
915 int iStatusImage
= imageAGGREGATE
;
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
);
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
);
949 // Update all appropriate filesets from this aggregate
951 LPIDENT lpiSearch
= (pdr
->lpiNotify
&& pdr
->lpiNotify
->fIsFileset()) ? (pdr
->lpiNotify
) : NULL
;
954 for (LPFILESET lpFileset
= lpAggregate
->FilesetFindFirst (&hEnum
, lpiSearch
, FALSE
); lpFileset
; lpFileset
= lpAggregate
->FilesetFindNext (&hEnum
))
956 Display_Filesets_Internal_AddFileset (pdr
, lpFileset
, hAggregate
);
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
)
979 if (lpFileset
->GetIdentifier() == pdr
->lpiNotify
)
980 status
= pdr
->status
;
982 lpFileset
->GetStatus (&fs
, FALSE
, &status
);
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
);
1001 TCHAR szName
[ cchNAME
];
1002 lpFileset
->GetName (szName
);
1003 CB_AddItem (pdr
->hList
, szName
, (LPARAM
)lpFileset
->GetIdentifier());
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
))
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
);
1050 if ((lpCell
= lpiRW
->OpenCell()) != NULL
)
1053 for (LPSERVER lpServer
= lpCell
->ServerFindFirst (&heServer
); lpServer
; lpServer
= lpCell
->ServerFindNext (&heServer
))
1056 for (LPAGGREGATE lpAggregate
= lpServer
->AggregateFindFirst (&heAggregate
); lpAggregate
; lpAggregate
= lpServer
->AggregateFindNext (&heAggregate
))
1059 for (LPFILESET lpFileset
= lpAggregate
->FilesetFindFirst (&heFileset
); lpFileset
; lpFileset
= lpAggregate
->FilesetFindNext (&heFileset
))
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());
1080 lpAggregate
->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
)
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
;
1119 *piImage0
= (iStatusImage
== IMAGE_NOIMAGE
) ? IMAGE_BLANKIMAGE
: iStatusImage
;
1120 *piImage1
= IMAGE_NOIMAGE
;
1121 dwFlags
|= PIF_ALWAYSSHOWICON
;
1125 *piImage0
= (iStatusImage
== IMAGE_NOIMAGE
) ? IMAGE_BLANKIMAGE
: iStatusImage
;
1126 *piImage1
= IMAGE_NOIMAGE
;
1130 *piImage0
= iTypeImage
;
1131 *piImage1
= iStatusImage
;
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
;
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
);