40d0fb091b964cf1b659fb2ac9fcdda079a80de6
[openafs.git] / src / WINNT / afssvrmgr / svr_col.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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  */
9
10 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include "svrmgr.h"
16 #include "svr_col.h"
17
18
19 /*
20  * SERVER-VIEW COLUMNS ________________________________________________________
21  *
22  */
23
24 void Server_SetDefaultView_Horz (LPVIEWINFO lpviHorz)
25 {
26    lpviHorz->lvsView = FLS_VIEW_LIST;
27    lpviHorz->nColsAvail = nSERVERCOLUMNS;
28
29    for (size_t iCol = 0; iCol < nSERVERCOLUMNS; ++iCol)
30       {
31       lpviHorz->cxColumns[ iCol ]  = SERVERCOLUMNS[ iCol ].cxWidth;
32       lpviHorz->idsColumns[ iCol ] = SERVERCOLUMNS[ iCol ].idsColumn;
33       }
34
35    lpviHorz->iSort = svrcolNAME;
36
37    lpviHorz->nColsShown = 3;
38    lpviHorz->aColumns[0] = (int)svrcolNAME;
39    lpviHorz->aColumns[1] = (int)svrcolADDRESS;
40    lpviHorz->aColumns[2] = (int)svrcolSTATUS;
41 }
42
43
44 void Server_SetDefaultView_Vert (LPVIEWINFO lpviVert)
45 {
46    lpviVert->lvsView = FLS_VIEW_LARGE;
47    lpviVert->nColsAvail = nSERVERCOLUMNS;
48
49    for (size_t iCol = 0; iCol < nSERVERCOLUMNS; ++iCol)
50       {
51       lpviVert->cxColumns[ iCol ]  = SERVERCOLUMNS[ iCol ].cxWidth;
52       lpviVert->idsColumns[ iCol ] = SERVERCOLUMNS[ iCol ].idsColumn;
53       }
54
55    lpviVert->iSort = svrcolNAME;
56
57    lpviVert->nColsShown = 3;
58    lpviVert->aColumns[0] = (int)svrcolNAME;
59    lpviVert->aColumns[1] = (int)svrcolADDRESS;
60    lpviVert->aColumns[2] = (int)svrcolSTATUS;
61 }
62
63
64 /*
65  * ROUTINES ___________________________________________________________________
66  *
67  */
68
69 size_t Server_GetAlertCount (LPSERVER lpServer)
70 {
71    return Alert_GetCount (lpServer->GetIdentifier());
72 }
73
74
75 LPTSTR Server_GetColumnText (LPIDENT lpi, SERVERCOLUMN svrcol)
76 {
77    static TCHAR aszBuffer[ nSERVERCOLUMNS ][ cchRESOURCE ];
78    static size_t iBufferNext = 0;
79    LPTSTR pszBuffer = aszBuffer[ iBufferNext++ ];
80    if (iBufferNext == nSERVERCOLUMNS)
81       iBufferNext = 0;
82    *pszBuffer = TEXT('\0');
83
84    LPSERVERSTATUS lpss = NULL;
85    LPSERVER_PREF lpsp;
86    if ((lpsp = (LPSERVER_PREF)lpi->GetUserParam()) != NULL)
87       {
88       lpss = &lpsp->ssLast;
89       }
90
91    switch (svrcol)
92       {
93       case svrcolNAME:
94          lpi->GetServerName (pszBuffer);
95          break;
96
97       case svrcolADDRESS:
98          if (lpss)
99             FormatSockAddr (pszBuffer, TEXT("%a"), &lpss->aAddresses[0]);
100          break;
101
102       case svrcolSTATUS:
103          {
104          LPTSTR pszDesc;
105          if ((pszDesc = Alert_GetQuickDescription (lpi)) == NULL)
106             GetString (pszBuffer, IDS_STATUS_NOALERTS);
107          else
108             {
109             lstrcpy (pszBuffer, pszDesc);
110             FreeString (pszDesc);
111             }
112          }
113          break;
114       }
115
116    return pszBuffer;
117 }
118