Windows: remove trailing whitespace
[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 #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 "make_symbolic_link_dlg.h"
21 #include "gui2fs.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 // CMakeMountPointDlg dialog
32
33
34 CMakeSymbolicLinkDlg::CMakeSymbolicLinkDlg(CWnd* pParent /*=NULL*/)
35         : CDialog()
36 {
37         InitModalIndirect (TaLocale_GetDialogResource (CMakeSymbolicLinkDlg::IDD), pParent);
38
39         //{{AFX_DATA_INIT(CMakeSymbolicLinkDlg)
40         m_strName = _T("");
41         m_strDir = _T("");
42         //}}AFX_DATA_INIT
43 }
44
45
46 void CMakeSymbolicLinkDlg::DoDataExchange(CDataExchange* pDX)
47 {
48         CDialog::DoDataExchange(pDX);
49         //{{AFX_DATA_MAP(CMakeSymbolicLinkDlg)
50         DDX_Control(pDX, IDOK, m_OK);
51         DDX_Control(pDX, IDC_NAME, m_Name);
52         DDX_Control(pDX, IDC_DIR, m_Dir);
53         DDX_Text(pDX, IDC_NAME, m_strName);
54         DDV_MaxChars(pDX, m_strName, 63);
55         DDX_Text(pDX, IDC_DIR, m_strDir);
56         DDV_MaxChars(pDX, m_strDir, 255);
57         //}}AFX_DATA_MAP
58 }
59
60
61 BEGIN_MESSAGE_MAP(CMakeSymbolicLinkDlg, CDialog)
62         //{{AFX_MSG_MAP(CMakeSymbolicLinkDlg)
63         //}}AFX_MSG_MAP
64 END_MESSAGE_MAP()
65
66 /////////////////////////////////////////////////////////////////////////////
67 // CMakeSymbolicLinkDlg message handlers
68
69 void CMakeSymbolicLinkDlg::OnOK()
70 {
71     UINT code;
72     UpdateData(TRUE);
73     CString strName;
74     CString strTarget;
75     m_Name.GetWindowText(strName);
76     m_Dir.GetWindowText(strTarget);
77     if (!IsPathInAfs(m_sBase)) {
78         MessageBeep((UINT)-1);
79         strTarget+=" - Path is not in AFS directory";
80         AfxMessageBox(strTarget,MB_ICONERROR);
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_ICONERROR,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_ICONERROR,IDS_UNABLE_TO_SET_CURRENT_DIRECTORY);
92         return;
93     }
94     if ((code=MakeSymbolicLink(strName,strTarget))!=0){
95         MessageBeep((UINT)-1);
96         ShowMessageBox(IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,MB_ICONERROR,IDS_UNABLE_TO_CREATE_SYMBOLIC_LINK,GetAfsError(code, strName));
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 }