findlanabyname-20040228
[openafs.git] / src / WINNT / client_exp / make_symbolic_link_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 "make_symbolic_link_dlg.h"
18 #include "gui2fs.h"
19 #include "msgs.h"
20 #define MAXSIZE 2048 /* most I'll get back from PIOCTL */
21
22 #ifdef _DEBUG
23 #define new DEBUG_NEW
24 #undef THIS_FILE
25 static char THIS_FILE[] = __FILE__;
26 #endif
27
28 /////////////////////////////////////////////////////////////////////////////
29 // CMakeMountPointDlg dialog
30
31
32 CMakeSymbolicLinkDlg::CMakeSymbolicLinkDlg(CWnd* pParent /*=NULL*/)
33         : CDialog()
34 {
35         InitModalIndirect (TaLocale_GetDialogResource (CMakeSymbolicLinkDlg::IDD), pParent);
36
37         //{{AFX_DATA_INIT(CMakeSymbolicLinkDlg)
38         m_strName = _T("");
39         m_strDir = _T("");
40         //}}AFX_DATA_INIT
41 }
42
43
44 void CMakeSymbolicLinkDlg::DoDataExchange(CDataExchange* pDX)
45 {
46         CDialog::DoDataExchange(pDX);
47         //{{AFX_DATA_MAP(CMakeSymbolicLinkDlg)
48         DDX_Control(pDX, IDOK, m_OK);
49         DDX_Control(pDX, IDC_NAME, m_Name);
50         DDX_Control(pDX, IDC_DIR, m_Dir);
51         DDX_Text(pDX, IDC_NAME, m_strName);
52         DDV_MaxChars(pDX, m_strName, 63);
53         DDX_Text(pDX, IDC_DIR, m_strDir);
54         DDV_MaxChars(pDX, m_strDir, 63);
55         //}}AFX_DATA_MAP
56 }
57
58
59 BEGIN_MESSAGE_MAP(CMakeSymbolicLinkDlg, CDialog)
60         //{{AFX_MSG_MAP(CMakeSymbolicLinkDlg)
61         //}}AFX_MSG_MAP
62 END_MESSAGE_MAP()
63
64 /////////////////////////////////////////////////////////////////////////////
65 // CMakeSymbolicLinkDlg message handlers
66
67 void CMakeSymbolicLinkDlg::OnOK() 
68 {
69         char space[64];
70         UINT code;
71         int i;
72         UpdateData(TRUE);
73         CString strName;
74         CString strDir;
75         m_Name.GetWindowText(strName);
76         m_Dir.GetWindowText(strDir);
77     if (!IsPathInAfs(m_sBase)) {
78                 MessageBeep((UINT)-1);
79                 strDir+=" - Path is not in AFS directory";
80                 AfxMessageBox(strDir,MB_OK);
81                 return;
82         } 
83         if (m_sBase.GetLength()>MAX_PATH-2)
84         {
85                 MessageBeep((UINT)-1);
86                 ShowMessageBox(IDS_CURRENT_DIRECTORY_PATH_TOO_LONG,MB_OK,IDS_CURRENT_DIRECTORY_PATH_TOO_LONG);
87         }
88         if (!SetCurrentDirectory(m_sBase))
89         {
90                 MessageBeep((UINT)-1);
91                 ShowMessageBox(IDS_UNABLE_TO_SET_CURRENT_DIRECTORY,MB_OK,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
92                 return;
93         }
94         if ((code=MakeSymbolicLink(strName,strDir))!=0){
95                 MessageBeep((UINT)-1);
96                 ShowMessageBox(IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,MB_OK,IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,code);
97                 return;
98         }
99         CDialog::OnOK();
100 }
101 /*
102 void CMakeSymbolicLinkDlg::OnChangeName() 
103 {
104         CString strName;
105         m_Name.GetWindowText(strName);
106         if (strName.GetLength() > 63) {
107                 MessageBeep((UINT)-1);
108                 m_Name.SetWindowText(m_strName);
109         } else
110                 m_strName = strName;
111         CheckEnableOk();
112 }
113
114 void CMakeSymbolicLinkDlg::OnChangeDir() 
115 {
116         m_Dir.GetWindowText(m_strDir);
117     if (!IsPathInAfs(m_strDir)) {
118                 MessageBeep((UINT)-1);
119                 m_Dir.SetWindowText(m_strDir);
120         }
121         CheckEnableOk();
122 }
123 */
124 void CMakeSymbolicLinkDlg::CheckEnableOk()
125 {
126         BOOL bEnable = FALSE;
127         
128         if ((m_strName.GetLength() > 0) && (m_strDir.GetLength() > 0))
129                 bEnable = TRUE;
130
131         m_OK.EnableWindow(bEnable);
132 }
133
134 BOOL CMakeSymbolicLinkDlg::OnInitDialog() 
135 {
136         CDialog::OnInitDialog();
137         
138 //      m_Dir.SetWindowText(m_strDir);
139 //      m_Name.SetWindowText(m_strName);
140         UpdateData(FALSE);
141
142         return TRUE;  // return TRUE unless you set the focus to a control
143                       // EXCEPTION: OCX Property Pages should return FALSE
144 }