windows-misc-20050102
[openafs.git] / src / WINNT / afsusrmgr / mch_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 "TaAfsUsrMgr.h"
16 #include "mch_col.h"
17
18
19 /*
20  * USER-VIEW COLUMNS __________________________________________________________
21  *
22  */
23
24 void Machine_SetDefaultView (LPVIEWINFO lpvi, ICONVIEW *piv)
25 {
26    lpvi->lvsView = FLS_VIEW_SMALL;
27    lpvi->nColsAvail = nMACHINECOLUMNS;
28
29    for (size_t iCol = 0; iCol < nMACHINECOLUMNS; ++iCol)
30       {
31       lpvi->cxColumns[ iCol ]  = MACHINECOLUMNS[ iCol ].cxWidth;
32       lpvi->idsColumns[ iCol ] = MACHINECOLUMNS[ iCol ].idsColumn;
33       }
34
35    lpvi->iSort = mchcolNAME;
36
37    lpvi->nColsShown = 2;
38    lpvi->aColumns[0] = (int)mchcolNAME;
39    lpvi->aColumns[1] = (int)mchcolUID;
40
41    *piv = ivSTATUS;
42 }
43
44
45 void Machine_GetColumn (ASID idObject, MACHINECOLUMN iCol, LPTSTR pszText, LPSYSTEMTIME pstDate, LONG *pcsec, COLUMNTYPE *pcType)
46 {
47    if (pszText)
48       *pszText = TEXT('\0');
49    if (pstDate)
50       memset (pstDate, 0x00, sizeof(SYSTEMTIME));
51    if (pcsec)
52       *pcsec = 0;
53    if (pcType)
54       *pcType = ctALPHABETIC;
55
56    ASOBJPROP Properties;
57    if (asc_ObjectPropertiesGet_Fast (g.idClient, g.idCell, idObject, &Properties))
58       {
59       switch (iCol)
60          {
61          case mchcolNAME:
62             if (pcType)
63                *pcType = ctALPHABETIC;
64             if (pszText)
65                lstrcpy (pszText, Properties.szName);
66             break;
67
68          case mchcolCGROUPMAX:
69             if (pcType)
70                *pcType = ctNUMERIC;
71             if (Properties.u.UserProperties.fHavePtsInfo)
72                {
73                if (pszText)
74                   wsprintf (pszText, TEXT("%ld"), Properties.u.UserProperties.PTSINFO.cgroupCreationQuota);
75                }
76             break;
77
78          case mchcolUID:
79             if (pcType)
80                *pcType = ctNUMERIC;
81             if (Properties.u.UserProperties.fHavePtsInfo)
82                {
83                if (pszText)
84                   wsprintf (pszText, TEXT("%ld"), Properties.u.UserProperties.PTSINFO.uidName);
85                }
86             break;
87
88          case mchcolOWNER:
89             if (pcType)
90                *pcType = ctALPHABETIC;
91             if (Properties.u.UserProperties.fHavePtsInfo)
92                {
93                if (pszText)
94                   {
95                   if (Properties.u.UserProperties.PTSINFO.szOwner[0])
96                      wsprintf (pszText, TEXT("%s (%ld)"), Properties.u.UserProperties.PTSINFO.szOwner, Properties.u.UserProperties.PTSINFO.uidOwner);
97                   else
98                      wsprintf (pszText, TEXT("%ld"), Properties.u.UserProperties.PTSINFO.uidOwner);
99                   }
100                }
101             break;
102
103          case mchcolCREATOR:
104             if (pcType)
105                *pcType = ctALPHABETIC;
106             if (Properties.u.UserProperties.fHavePtsInfo)
107                {
108                if (pszText)
109                   {
110                   if (Properties.u.UserProperties.PTSINFO.szCreator[0])
111                      wsprintf (pszText, TEXT("%s (%ld)"), Properties.u.UserProperties.PTSINFO.szCreator, Properties.u.UserProperties.PTSINFO.uidCreator);
112                   else
113                      wsprintf (pszText, TEXT("%ld"), Properties.u.UserProperties.PTSINFO.uidCreator);
114                   }
115                }
116             break;
117          }
118       }
119 }
120