1 /* Copyright 2000, International Business Machines Corporation and others.
4 This software has been released under the terms of the IBM Public
5 License. For details, see the LICENSE file in the top-level source
6 directory or online at http://www.openafs.org/dl/license10.html
8 // Change.cpp : implementation file
12 #include "WinAfsLoad.h"
13 #include "WinAfsLoadDlg.h"
19 static char THIS_FILE[] = __FILE__;
22 /////////////////////////////////////////////////////////////////////////////
26 CChange::CChange(BOOL change,CWnd* pParent /*=NULL*/)
27 : CDialog(CChange::IDD, pParent)
29 //{{AFX_DATA_INIT(CChange)
31 m_sDescription = _T("");
35 m_pParent=(CWinAfsLoadDlg *)pParent;
39 void CChange::DoDataExchange(CDataExchange* pDX)
41 CDialog::DoDataExchange(pDX);
42 //{{AFX_DATA_MAP(CChange)
43 DDX_Control(pDX, IDC_DESCRIPTION, m_cShare);
44 DDX_Control(pDX, IDC_PERSISTENT, m_cAuto);
45 DDX_Control(pDX, IDC_PATH, m_cPath);
46 DDX_Control(pDX, IDC_DRIVE, m_cDrive);
47 DDX_Text(pDX, IDC_PATH, m_sPath);
48 DDV_MaxChars(pDX, m_sPath, 512);
49 DDX_Text(pDX, IDC_DESCRIPTION, m_sDescription);
50 DDV_MaxChars(pDX, m_sDescription, 12);
51 DDX_Check(pDX, IDC_PERSISTENT, m_bAuto);
56 BEGIN_MESSAGE_MAP(CChange, CDialog)
57 //{{AFX_MSG_MAP(CChange)
59 ON_BN_CLICKED(IDC_HELPMAIN, OnHelpmain)
63 /////////////////////////////////////////////////////////////////////////////
64 // CChange message handlers
68 // TODO: Add extra validation here
69 m_cDrive.GetLBText(m_cDrive.GetCurSel(),m_sDrive);
70 m_sDrive=m_sDrive.Left(2);
72 if (IsValidSubmountName(m_sPath))
75 if (IsValidShareName(m_sDescription))
80 MessageBox("Incorrect Share name","AFS Warning",MB_OK|MB_ICONWARNING);
84 MessageBox("Incorrect Path name","AFS Warning",MB_OK|MB_ICONWARNING);
88 void CChange::OnCancel()
90 // TODO: Add extra cleanup here
91 m_sDrive=m_sPath=m_sDescription="";
95 BOOL CChange::OnInitDialog()
97 CDialog::OnInitDialog();
99 // TODO: Add extra initialization here
100 CWnd *win=GetDlgItem(IDOK);
104 win->SetWindowText("Accept Change");
105 SetWindowText("AFS Change Item");
108 win->SetWindowText("Add Item");
109 SetWindowText("AFS Add Item");
113 TCHAR szDrive[] = TEXT("*: ");
114 wsprintf(szDrive,"%2s ",m_sDrive);
115 if (m_cDrive.FindString(0,szDrive)!=CB_ERR)
116 m_cDrive.SetCurSel(m_cDrive.FindString(0,szDrive));
119 m_cDrive.SetCurSel(m_cDrive.FindString(0,szDrive));
121 if (stricmp(m_sDescription,"all")) return TRUE;
122 m_cPath.ModifyStyle(0,WS_DISABLED);
123 m_cShare.ModifyStyle(0,WS_DISABLED);
124 m_cAuto.ModifyStyle(0,WS_DISABLED);
125 return TRUE; // return TRUE unless you set the focus to a control
126 // EXCEPTION: OCX Property Pages should return FALSE
129 VOID CChange::ListDrive()
131 m_pParent->BuildDriveList();
132 POSITION pos=m_pParent->m_Drivelist.GetHeadPosition();
135 m_cDrive.InsertString(-1,m_pParent->m_Drivelist.GetNext(pos));
139 BOOL CChange::IsValidShareName(LPCTSTR pszShare)
143 if (stricmp(pszShare,"")==0)
144 return FALSE; //disallow adding a share name of ""
145 for ( ; *pszShare; ++pszShare)
147 if (!isprint(*pszShare))
149 if (*pszShare == TEXT(' '))
151 if (*pszShare == TEXT('\t'))
158 BOOL CChange::IsValidSubmountName (LPCTSTR pszSubmount)
162 if (stricmp(pszSubmount,"all")==0)
163 return FALSE; //disallow adding a share name of "all"
164 for ( ; *pszSubmount; ++pszSubmount)
166 if (!isprint(*pszSubmount))
168 if (*pszSubmount == TEXT(' '))
170 if (*pszSubmount == TEXT('\t'))
178 BOOL CChange::OnHelpInfo(HELPINFO* pHelpInfo)
180 // TODO: Add your message handler code here and/or call default
182 ::WinHelp(m_hWnd,CWINAFSLOADAPP->m_pszHelpFilePath,HELP_CONTEXT,(m_bChange)?IDH_CHANGE:IDH_ADD);
184 // return CDialog::OnHelpInfo(pHelpInfo);
187 void CChange::OnHelpmain()
189 // TODO: Add your control notification handler code here
190 ::WinHelp(m_hWnd,CWINAFSLOADAPP->m_pszHelpFilePath,HELP_CONTEXT,(m_bChange)?IDH_CHANGE:IDH_ADD);