rx: Remove RX_CALL_BUSY
[openafs.git] / src / WINNT / client_exp / PropVolume.cpp
1 // PropFile.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "PropVolume.h"
6 #include <shlwapi.h>
7
8 extern "C" {
9 #include <afs/param.h>
10 #include <afs/stds.h>
11 }
12
13 #include "WINNT\talocale.h"
14 #include "afs_shl_ext.h"
15 #include "gui2fs.h"
16 #include "msgs.h"
17
18
19 BOOL CPropVolume::PropPageProc( HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam )
20 {
21     switch(uMessage)
22     {
23     case WM_INITDIALOG:
24         {
25             CPropVolume * sheetpage = (CPropVolume*) ((LPPROPSHEETPAGE) lParam)->lParam;
26             SetWindowLongPtr (hwnd, GWLP_USERDATA, (LONG_PTR) sheetpage);
27             sheetpage->SetHwnd(hwnd);
28             AfxSetResourceHandle(m_hInst);
29
30             BOOL bFollow = (filenames.GetCount() == 1 && m_bIsMountpoint);
31
32             if(filenames.GetCount() >= 1) {
33                 CString sText;
34
35                 SetDlgItemText(hwnd, IDC_PROP_VOLUMENAME, filenames.GetAt(0));
36                 sText = GetCellName(filenames.GetAt(0), bFollow);
37                 SetDlgItemText(hwnd, IDC_PROP_CELL, sText);
38                 sText = GetServer(filenames.GetAt(0), bFollow);
39                 SetDlgItemText(hwnd, IDC_PROP_FILESERVER, sText);
40
41                 TCHAR buf[100];
42                 CVolInfo volInfo;
43
44                 if (GetVolumeInfo(filenames.GetAt(0), volInfo, bFollow)) {
45                     SetDlgItemText(hwnd, IDC_PROP_VOLUMENAME, volInfo.m_strName);
46
47                     SetDlgItemText(hwnd, IDC_PROP_VOLUME_STATUS, volInfo.m_strAvail);
48
49                     sText.Format(_T("%u"), volInfo.m_nID);
50                     SetDlgItemText(hwnd, IDC_PROP_VID, sText);
51
52                     if (volInfo.m_nQuota == 0) {
53                         SetDlgItemText(hwnd, IDC_QUOTA_MAX, _T("unlimited"));
54                         SetDlgItemText(hwnd, IDC_QUOTA_PERCENT, _T("0.00%"));
55                     } else {
56                         StrFormatByteSize64(volInfo.m_nQuota*1024, buf, 100);
57                         SetDlgItemText(hwnd, IDC_QUOTA_MAX, buf);
58
59                         sText.Format(_T("%.2f%%"), ((double)volInfo.m_nUsed / (double)volInfo.m_nQuota) * 100);
60                         SetDlgItemText(hwnd, IDC_QUOTA_PERCENT, sText);
61                     }
62
63                     StrFormatByteSize64(volInfo.m_nUsed*1024, buf, 100);
64                     SetDlgItemText(hwnd, IDC_QUOTA_USED, buf);
65
66                     StrFormatByteSize64(volInfo.m_nPartSize*1024, buf, 100);
67                     SetDlgItemText(hwnd, IDC_PARTITION_SIZE, buf);
68                     StrFormatByteSize64(volInfo.m_nPartFree*1024, buf, 100);
69                     SetDlgItemText(hwnd, IDC_PARTITION_FREE, buf);
70
71                     sText.Format(_T("%.2f%%"), ((double)volInfo.m_nPartFree / (double)volInfo.m_nPartSize) * 100);
72                     SetDlgItemText(hwnd, IDC_PARTITION_PERCENT, sText);
73                 }
74                 else
75                 {
76                     SetDlgItemText(hwnd, IDC_PROP_VOLUMENAME, volInfo.m_strErrorMsg);
77                 }
78
79                 // "where is" info
80                 CStringArray servers;
81                 GetServers(filenames.GetAt(0), servers, bFollow);
82                 int tabstops[1] = {118};
83                 SendDlgItemMessage(hwnd, IDC_SERVERS, LB_SETTABSTOPS, 1, (LPARAM)&tabstops);
84                 for (int i=0;i<servers.GetCount();++i){
85                     SendDlgItemMessage(m_hwnd, IDC_SERVERS, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)servers.GetAt(i));
86                 }
87             }
88             return TRUE;
89         }
90         break;
91     case WM_NOTIFY:
92         {
93             LPNMHDR point = (LPNMHDR)lParam;
94             int code = point->code;
95             BOOL bRet = FALSE;
96             switch (code)
97             {
98             case PSN_APPLY:
99                 {
100                     // Return PSNRET_NOERROR to allow the sheet to close if the user clicked OK.
101                     SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, PSNRET_NOERROR);
102                 }
103                 break;
104             }
105             SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, FALSE);
106             return bRet;
107         }
108         break;
109     case WM_COMMAND:
110         switch (HIWORD(wParam))
111         {
112         case BN_CLICKED:
113             switch (LOWORD(wParam))
114             {
115             case IDC_FLUSH:
116                 FlushVolume(filenames);
117                 return TRUE;
118             }
119             break;
120         }
121         break;
122     }
123
124     return FALSE;
125 }