Standardize License information
[openafs.git] / src / WINNT / client_exp / add_submount_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 "add_submount_dlg.h"
17 #include "submount_info.h"
18 #include "help.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 // CAddSubmtDlg dialog
29
30
31 CAddSubmtDlg::CAddSubmtDlg(CWnd* pParent /*=NULL*/)
32         : CDialog()
33 {
34         InitModalIndirect (TaLocale_GetDialogResource (CAddSubmtDlg::IDD), pParent);
35
36         //{{AFX_DATA_INIT(CAddSubmtDlg)
37         m_strShareName = _T("");
38         m_strPathName = _T("");
39         //}}AFX_DATA_INIT
40
41         m_bAdd = TRUE;
42         m_bSave = FALSE;
43 }
44
45
46 void CAddSubmtDlg::DoDataExchange(CDataExchange* pDX)
47 {
48         CDialog::DoDataExchange(pDX);
49         //{{AFX_DATA_MAP(CAddSubmtDlg)
50         DDX_Control(pDX, IDOK, m_Ok);
51         DDX_Text(pDX, IDC_SHARE_NAME, m_strShareName);
52         DDX_Text(pDX, IDC_PATH_NAME, m_strPathName);
53         //}}AFX_DATA_MAP
54 }
55
56
57 BEGIN_MESSAGE_MAP(CAddSubmtDlg, CDialog)
58         //{{AFX_MSG_MAP(CAddSubmtDlg)
59         ON_EN_CHANGE(IDC_SHARE_NAME, OnChangeShareName)
60         ON_EN_CHANGE(IDC_PATH_NAME, OnChangePathName)
61         ON_BN_CLICKED(IDHELP, OnHelp)
62         //}}AFX_MSG_MAP
63 END_MESSAGE_MAP()
64
65 /////////////////////////////////////////////////////////////////////////////
66 // CAddSubmtDlg message handlers
67
68 BOOL CAddSubmtDlg::OnInitDialog() 
69 {
70         CDialog::OnInitDialog();
71         
72         if (!m_bAdd) {
73                 SetWindowText(GetMessageString(IDS_EDIT_PATH_NAME));
74                 ((CEdit *)GetDlgItem(IDC_SHARE_NAME))->EnableWindow(FALSE);
75         }
76
77         return TRUE;  // return TRUE unless you set the focus to a control
78                       // EXCEPTION: OCX Property Pages should return FALSE
79 }
80
81 void CAddSubmtDlg::CheckEnableOk()
82 {
83         UpdateData(TRUE);
84
85         m_Ok.EnableWindow(!m_strShareName.IsEmpty() && !m_strPathName.IsEmpty());
86 }
87
88 void CAddSubmtDlg::OnChangeShareName() 
89 {
90         CheckEnableOk();
91 }
92
93 void CAddSubmtDlg::OnChangePathName() 
94 {
95         CheckEnableOk();
96 }
97
98 void CAddSubmtDlg::OnOK()
99 {
100         UpdateData(TRUE);
101
102         m_bSave = TRUE;
103
104         CDialog::OnOK();
105 }
106
107 void CAddSubmtDlg::SetSubmtInfo(CSubmountInfo *pInfo)
108 {
109         ASSERT_VALID(pInfo);
110         
111         m_strShareName = pInfo->GetShareName();
112         m_strPathName = pInfo->GetPathName();
113 }
114
115 CSubmountInfo *CAddSubmtDlg::GetSubmtInfo()
116 {
117         if (!m_bSave)
118                 return 0;
119         
120         SUBMT_INFO_STATUS status;
121
122         if (m_bAdd)
123                 status = SIS_ADDED;
124         else
125                 status = SIS_CHANGED;
126         
127         return new CSubmountInfo(m_strShareName, m_strPathName, status);
128 }
129
130 void CAddSubmtDlg::OnHelp() 
131 {
132         ShowHelp(m_hWnd, (m_bAdd ? ADD_SUBMT_HELP_ID : EDIT_PATH_NAME_HELP_ID));
133 }
134