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