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