rx: Remove RX_CALL_BUSY
[openafs.git] / src / WINNT / client_exp / add_acl_entry_dlg.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 #include "stdafx.h"
11 #include <winsock2.h>
12 #include <ws2tcpip.h>
13
14 extern "C" {
15 #include <afs/param.h>
16 #include <afs/stds.h>
17 }
18
19 #include "afs_shl_ext.h"
20 #include "add_acl_entry_dlg.h"
21 #include "set_afs_acl.h"
22 #include "msgs.h"
23
24 #ifdef _DEBUG
25 #define new DEBUG_NEW
26 #undef THIS_FILE
27 static char THIS_FILE[] = __FILE__;
28 #endif
29
30 /////////////////////////////////////////////////////////////////////////////
31 // CAddAclEntryDlg dialog
32
33
34 CAddAclEntryDlg::CAddAclEntryDlg(CWnd* pParent /*=NULL*/)
35         : CDialog()
36 {
37         InitModalIndirect (TaLocale_GetDialogResource (CAddAclEntryDlg::IDD), pParent);
38
39         //{{AFX_DATA_INIT(CAddAclEntryDlg)
40         //}}AFX_DATA_INIT
41
42         m_pAclSetDlg = 0;
43 }
44
45
46 void CAddAclEntryDlg::DoDataExchange(CDataExchange* pDX)
47 {
48         CDialog::DoDataExchange(pDX);
49         //{{AFX_DATA_MAP(CAddAclEntryDlg)
50         DDX_Control(pDX, IDOK, m_Ok);
51         DDX_Control(pDX, IDC_NAME, m_Name);
52         DDX_Control(pDX, IDC_ADD_NORMAL_ENTRY, m_NormalEntry);
53         DDX_Control(pDX, IDC_LOOKUP2, m_LookupPerm);
54         DDX_Control(pDX, IDC_LOCK2, m_LockPerm);
55         DDX_Control(pDX, IDC_WRITE, m_WritePerm);
56         DDX_Control(pDX, IDC_ADMINISTER, m_AdminPerm);
57         DDX_Control(pDX, IDC_READ, m_ReadPerm);
58         DDX_Control(pDX, IDC_INSERT, m_InsertPerm);
59         DDX_Control(pDX, IDC_DELETE, m_DeletePerm);
60         //}}AFX_DATA_MAP
61 }
62
63
64 BEGIN_MESSAGE_MAP(CAddAclEntryDlg, CDialog)
65         //{{AFX_MSG_MAP(CAddAclEntryDlg)
66         ON_BN_CLICKED(IDC_ADD_NEGATIVE_ENTRY, OnAddNegativeEntry)
67         ON_BN_CLICKED(IDC_ADD_NORMAL_ENTRY, OnAddNormalEntry)
68         ON_EN_CHANGE(IDC_NAME, OnChangeName)
69         ON_BN_CLICKED(IDHELP, OnHelp)
70         //}}AFX_MSG_MAP
71 END_MESSAGE_MAP()
72
73 /////////////////////////////////////////////////////////////////////////////
74 // CAddAclEntryDlg message handlers
75
76 void CAddAclEntryDlg::OnAddNegativeEntry()
77 {
78         m_bNormal = FALSE;
79 }
80
81 void CAddAclEntryDlg::OnAddNormalEntry()
82 {
83         m_bNormal = TRUE;
84 }
85
86 BOOL CAddAclEntryDlg::OnInitDialog()
87 {
88         CDialog::OnInitDialog();
89
90         m_NormalEntry.SetCheck(CHECKED);
91         m_Ok.EnableWindow(FALSE);
92
93         m_Name.SetFocus();
94
95         m_bNormal = TRUE;
96
97         return TRUE;  // return TRUE unless you set the focus to a control
98                       // EXCEPTION: OCX Property Pages should return FALSE
99 }
100
101 CString CAddAclEntryDlg::MakePermString()
102 {
103         CString str;
104
105         if (m_ReadPerm.GetCheck() == CHECKED)
106                 str += "r";
107         if (m_LookupPerm.GetCheck() == CHECKED)
108                 str += "l";
109         if (m_InsertPerm.GetCheck() == CHECKED)
110                 str += "i";
111         if (m_DeletePerm.GetCheck() == CHECKED)
112                 str += "d";
113         if (m_WritePerm.GetCheck() == CHECKED)
114                 str += "w";
115         if (m_LockPerm.GetCheck() == CHECKED)
116                 str += "k";
117         if (m_AdminPerm.GetCheck() == CHECKED)
118                 str += "a";
119
120         return str;
121 }
122
123 void CAddAclEntryDlg::OnOK()
124 {
125         m_Rights = MakePermString();
126         m_Name.GetWindowText(m_strName);
127
128         if (m_pAclSetDlg->IsNameInUse(m_bNormal, m_strName)) {
129                 ShowMessageBox(IDS_ACL_ENTRY_NAME_IN_USE, MB_ICONEXCLAMATION, IDS_ACL_ENTRY_NAME_IN_USE);
130                 return;
131         }
132
133         CDialog::OnOK();
134 }
135
136 void CAddAclEntryDlg::OnChangeName()
137 {
138         m_Name.GetWindowText(m_strName);
139
140         if (m_strName.GetLength() > 0)
141                 m_Ok.EnableWindow(TRUE);
142 }
143
144 void CAddAclEntryDlg::OnHelp()
145 {
146         ShowHelp(m_hWnd, ADD_ACL_ENTRY_HELP_ID);
147 }
148