Standardize License information
[openafs.git] / src / WINNT / client_exp / copy_acl_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 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include "stdafx.h"
16 #include "afs_shl_ext.h"
17 #include "copy_acl_dlg.h"
18 #include "io.h"
19 #include "msgs.h"
20
21 #ifdef _DEBUG
22 #define new DEBUG_NEW
23 #undef THIS_FILE
24 static char THIS_FILE[] = __FILE__;
25 #endif
26
27 /////////////////////////////////////////////////////////////////////////////
28 // CCopyAclDlg dialog
29
30
31 CCopyAclDlg::CCopyAclDlg(CWnd* pParent /*=NULL*/)
32         : CDialog()
33 {
34         InitModalIndirect (TaLocale_GetDialogResource (CCopyAclDlg::IDD), pParent);
35
36         //{{AFX_DATA_INIT(CCopyAclDlg)
37                 // NOTE: the ClassWizard will add member initialization here
38         //}}AFX_DATA_INIT
39
40         m_bClear = FALSE;
41 }
42
43
44 void CCopyAclDlg::DoDataExchange(CDataExchange* pDX)
45 {
46         CDialog::DoDataExchange(pDX);
47         //{{AFX_DATA_MAP(CCopyAclDlg)
48         DDX_Control(pDX, IDOK, m_Ok);
49         DDX_Control(pDX, IDC_FROM_DIR, m_FromDir);
50         DDX_Control(pDX, IDC_TO_DIR, m_ToDir);
51         DDX_Control(pDX, IDC_CLEAR, m_Clear);
52         //}}AFX_DATA_MAP
53 }
54
55
56 BEGIN_MESSAGE_MAP(CCopyAclDlg, CDialog)
57         //{{AFX_MSG_MAP(CCopyAclDlg)
58         ON_EN_CHANGE(IDC_TO_DIR, OnChangeToDir)
59         ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
60         ON_BN_CLICKED(IDHELP, OnHelp)
61         //}}AFX_MSG_MAP
62 END_MESSAGE_MAP()
63
64 /////////////////////////////////////////////////////////////////////////////
65 // CCopyAclDlg message handlers
66
67 void CCopyAclDlg::OnOK() 
68 {
69         m_bClear = m_Clear.GetCheck() == 1;
70         m_ToDir.GetWindowText(m_strToDir);
71         
72         if (access(m_strToDir, 0) == -1) {
73                 ShowMessageBox(IDS_DIR_DOES_NOT_EXIST_ERROR, MB_ICONEXCLAMATION, IDS_DIR_DOES_NOT_EXIST_ERROR, m_strToDir);
74                 return;
75         }
76
77         CDialog::OnOK();
78 }
79
80 BOOL CCopyAclDlg::OnInitDialog() 
81 {
82         CDialog::OnInitDialog();
83
84         m_FromDir.SetWindowText(m_strFromDir);
85         
86         return TRUE;  // return TRUE unless you set the focus to a control
87                       // EXCEPTION: OCX Property Pages should return FALSE
88 }
89
90 void CCopyAclDlg::OnChangeToDir() 
91 {
92         m_ToDir.GetWindowText(m_strToDir);
93         
94         BOOL bEnable = m_strToDir.GetLength() > 0;
95         m_Ok.EnableWindow(bEnable);
96 }
97
98 void CCopyAclDlg::OnBrowse() 
99 {
100         CFileDialog dlg(TRUE, 0, "*.*", OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY, 0, 0);
101
102         if (dlg.DoModal() == IDCANCEL)
103                 return;
104
105         CString strPath = dlg.GetPathName();
106         
107         // Remove file name (last component of path)
108         int nFirstSlash = strPath.Find('\\');
109         int nLastSlash = strPath.ReverseFind('\\');
110         if (nFirstSlash != nLastSlash)
111                 strPath = strPath.Left(nLastSlash);
112         else
113                 strPath = strPath.Left(nFirstSlash + 1);
114
115         m_ToDir.SetWindowText(strPath);
116 }
117
118 void CCopyAclDlg::OnHelp() 
119 {
120         ShowHelp(m_hWnd, COPY_ACL_HELP_ID);
121 }
122