Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

491 lines
14 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1997 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // Iis.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CIISVirtualRootParamsPage class.
  10. //
  11. // Author:
  12. // Pete Benoit (v-pbenoi) October 16, 1996
  13. // David Potter (davidp) October 17, 1996
  14. //
  15. // Revision History:
  16. //
  17. // Notes:
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include <inetinfo.h>
  22. #include "IISClEx3.h"
  23. #include "Iis.h"
  24. #include "ExtObj.h"
  25. #include "DDxDDv.h"
  26. #include "HelpData.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CIISVirtualRootParamsPage property page
  34. /////////////////////////////////////////////////////////////////////////////
  35. IMPLEMENT_DYNCREATE(CIISVirtualRootParamsPage, CBasePropertyPage)
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Message Maps
  38. BEGIN_MESSAGE_MAP(CIISVirtualRootParamsPage, CBasePropertyPage)
  39. //{{AFX_MSG_MAP(CIISVirtualRootParamsPage)
  40. ON_BN_CLICKED(IDC_PP_IIS_FTP, OnChangeServiceType)
  41. ON_BN_CLICKED(IDC_PP_IIS_GOPHER, OnChangeServiceType)
  42. ON_BN_CLICKED(IDC_PP_IIS_WWW, OnChangeServiceType)
  43. #ifdef _ACCOUNT_AND_PASSWORD
  44. ON_EN_CHANGE(IDC_PP_IIS_DIRECTORY, OnChangeDirectory)
  45. #endif // _ACCOUNT_AND_PASSWORD
  46. ON_EN_CHANGE(IDC_PP_IIS_ALIAS, OnChangeRequiredField)
  47. //}}AFX_MSG_MAP
  48. // TODO: Modify the following lines to represent the data displayed on this page.
  49. #ifdef _ACCOUNT_AND_PASSWORD
  50. ON_EN_CHANGE(IDC_PP_IIS_ACCOUNTNAME, CBasePropertyPage::OnChangeCtrl)
  51. ON_EN_CHANGE(IDC_PP_IIS_PASSWORD, CBasePropertyPage::OnChangeCtrl)
  52. #endif /// _ACCOUNT_AND_PASSWORD
  53. ON_BN_CLICKED(IDC_PP_IIS_READ_ACCESS, CBasePropertyPage::OnChangeCtrl)
  54. ON_BN_CLICKED(IDC_PP_IIS_WRITE_ACCESS, CBasePropertyPage::OnChangeCtrl)
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. //++
  58. //
  59. // CIISVirtualRootParamsPage::CIISVirtualRootParamsPage
  60. //
  61. // Routine Description:
  62. // Default constructor.
  63. //
  64. // Arguments:
  65. // None.
  66. //
  67. // Return Value:
  68. // None.
  69. //
  70. //--
  71. /////////////////////////////////////////////////////////////////////////////
  72. CIISVirtualRootParamsPage::CIISVirtualRootParamsPage(void)
  73. : CBasePropertyPage(g_aHelpIDs_IDD_PP_IIS_PARAMETERS, g_aHelpIDs_IDD_WIZ_IIS_PARAMETERS)
  74. {
  75. // TODO: Modify the following lines to represent the data displayed on this page.
  76. //{{AFX_DATA_INIT(CIISVirtualRootParamsPage)
  77. m_strDirectory = _T("");
  78. m_strAlias = _T("");
  79. m_bRead = FALSE;
  80. m_bWrite = FALSE;
  81. m_nServerType = -1;
  82. #ifdef _ACCOUNT_AND_PASSWORD
  83. m_strAccountName = _T("");
  84. m_strPassword = _T("");
  85. #endif // _ACCOUNT_AND_PASSWORD
  86. //}}AFX_DATA_INIT
  87. // Setup the property array.
  88. {
  89. m_rgProps[epropServiceName].Set(REGPARAM_IIS_SERVICE_NAME, m_strServiceName, m_strPrevServiceName);
  90. m_rgProps[epropDirectory].Set(REGPARAM_IIS_DIRECTORY, m_strDirectory, m_strPrevDirectory);
  91. m_rgProps[epropAlias].Set(REGPARAM_IIS_ALIAS, m_strAlias, m_strPrevAlias);
  92. #ifdef _ACCOUNT_AND_PASSWORD
  93. m_rgProps[epropAccoutName].Set(REGPARAM_IIS_ACCOUNTNAME, m_strAccountName, m_strPrevAccountName);
  94. m_rgProps[epropPassword].Set(REGPARAM_IIS_PASSWORD, m_strPassword, m_strPrevPassword);
  95. #endif // _ACCOUNT_AND_PASSWORD
  96. m_rgProps[epropAccessMask].Set(REGPARAM_IIS_ACCESSMASK, m_dwAccessMask, m_dwPrevAccessMask);
  97. } // Setup the property array
  98. m_iddPropertyPage = IDD_PP_IIS_PARAMETERS;
  99. m_iddWizardPage = IDD_WIZ_IIS_PARAMETERS;
  100. } //*** CIISVirtualRootParamsPage::CIISVirtualRootParamsPage()
  101. /////////////////////////////////////////////////////////////////////////////
  102. //++
  103. //
  104. // CIISVirtualRootParamsPage::DoDataExchange
  105. //
  106. // Routine Description:
  107. // Do data exchange between the dialog and the class.
  108. //
  109. // Arguments:
  110. // pDX [IN OUT] Data exchange object
  111. //
  112. // Return Value:
  113. // None.
  114. //
  115. //--
  116. /////////////////////////////////////////////////////////////////////////////
  117. void CIISVirtualRootParamsPage::DoDataExchange(CDataExchange * pDX)
  118. {
  119. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  120. if (!pDX->m_bSaveAndValidate)
  121. {
  122. // Set the service type.
  123. if (m_strServiceName.CompareNoCase(IIS_SVC_NAME_FTP) == 0)
  124. m_nServerType = 0;
  125. else if (m_strServiceName.CompareNoCase(IIS_SVC_NAME_GOPHER) == 0)
  126. m_nServerType = 1;
  127. else if (m_strServiceName.CompareNoCase(IIS_SVC_NAME_WWW) == 0)
  128. m_nServerType = 2;
  129. else
  130. m_nServerType = -1;
  131. // Set the access variables.
  132. if (m_dwAccessMask & VROOT_MASK_READ)
  133. m_bRead = TRUE;
  134. else
  135. m_bRead = FALSE;
  136. if (m_dwAccessMask & (VROOT_MASK_WRITE | VROOT_MASK_EXECUTE))
  137. m_bWrite = TRUE;
  138. else
  139. m_bWrite = FALSE;
  140. } // if: setting data to dialog
  141. // TODO: Modify the following lines to represent the data displayed on this page.
  142. //{{AFX_DATA_MAP(CIISVirtualRootParamsPage)
  143. DDX_Control(pDX, IDC_PP_IIS_WRITE_ACCESS, m_ckbWrite);
  144. DDX_Control(pDX, IDC_PP_IIS_READ_ACCESS, m_ckbRead);
  145. DDX_Control(pDX, IDC_PP_IIS_ACCESS_GROUP, m_groupAccess);
  146. #ifdef _ACCOUNT_AND_PASSWORD
  147. DDX_Control(pDX, IDC_PP_IIS_PASSWORD, m_editPassword);
  148. DDX_Control(pDX, IDC_PP_IIS_PASSWORD_LABEL, m_staticPassword);
  149. DDX_Control(pDX, IDC_PP_IIS_ACCOUNTNAME, m_editAccountName);
  150. DDX_Control(pDX, IDC_PP_IIS_ACCOUNTNAME_LABEL, m_staticAccountName);
  151. DDX_Control(pDX, IDC_PP_IIS_ACCT_INFO_GROUP, m_groupAccountInfo);
  152. #endif // _ACCOUNT_AND_PASSWORD
  153. DDX_Control(pDX, IDC_PP_IIS_ALIAS, m_editAlias);
  154. DDX_Control(pDX, IDC_PP_IIS_DIRECTORY, m_editDirectory);
  155. DDX_Control(pDX, IDC_PP_IIS_WWW, m_rbWWW);
  156. DDX_Control(pDX, IDC_PP_IIS_GOPHER, m_rbGOPHER);
  157. DDX_Control(pDX, IDC_PP_IIS_FTP, m_rbFTP);
  158. DDX_Radio(pDX, IDC_PP_IIS_FTP, m_nServerType);
  159. DDX_Text(pDX, IDC_PP_IIS_DIRECTORY, m_strDirectory);
  160. DDX_Text(pDX, IDC_PP_IIS_ALIAS, m_strAlias);
  161. #ifdef _ACCOUNT_AND_PASSWORD
  162. DDX_Text(pDX, IDC_PP_IIS_ACCOUNTNAME, m_strAccountName);
  163. DDX_Text(pDX, IDC_PP_IIS_PASSWORD, m_strPassword);
  164. #endif // _ACCOUNT_AND_PASSWORD
  165. DDX_Check(pDX, IDC_PP_IIS_READ_ACCESS, m_bRead);
  166. DDX_Check(pDX, IDC_PP_IIS_WRITE_ACCESS, m_bWrite);
  167. //}}AFX_DATA_MAP
  168. if (pDX->m_bSaveAndValidate)
  169. {
  170. if (!BBackPressed())
  171. {
  172. DDV_MaxChars(pDX, m_strDirectory, MAX_PATH);
  173. DDV_MaxChars(pDX, m_strAlias, MAX_PATH);
  174. DDV_RequiredText(pDX, IDC_PP_IIS_DIRECTORY, IDC_PP_IIS_DIRECTORY_LABEL, m_strDirectory);
  175. DDV_RequiredText(pDX, IDC_PP_IIS_ALIAS, IDC_PP_IIS_ALIAS_LABEL, m_strAlias);
  176. } // if: Back button not pressed
  177. // Save the type.
  178. if (m_nServerType == 0)
  179. m_strServiceName = IIS_SVC_NAME_FTP;
  180. else if (m_nServerType == 1)
  181. m_strServiceName = IIS_SVC_NAME_GOPHER;
  182. else if (m_nServerType == 2)
  183. m_strServiceName = IIS_SVC_NAME_WWW;
  184. else
  185. {
  186. CString strMsg;
  187. strMsg.LoadString(IDS_INVALID_IIS_SERVICE_TYPE);
  188. AfxMessageBox(strMsg, MB_OK | MB_ICONSTOP);
  189. strMsg.Empty();
  190. pDX->PrepareCtrl(IDC_PP_IIS_FTP); // do this just to set the control for Fail().
  191. pDX->Fail();
  192. } // else: no service type set
  193. // Save the access mask values.
  194. m_dwAccessMask = 0;
  195. if (m_bRead)
  196. m_dwAccessMask |= VROOT_MASK_READ;
  197. if (m_bWrite)
  198. {
  199. if (m_nServerType == 2) // WWW
  200. m_dwAccessMask |= VROOT_MASK_EXECUTE;
  201. else if (m_nServerType == 0) // FTP
  202. m_dwAccessMask |= VROOT_MASK_WRITE;
  203. } // if: Write/Execute button pressed
  204. // If the alias isn't prefixed with a slash, supply it.
  205. if (m_strAlias[0] != _T('/'))
  206. {
  207. CString strTempAlias;
  208. try
  209. {
  210. strTempAlias = _T('/') + m_strAlias;
  211. m_strAlias = strTempAlias;
  212. } // try
  213. catch (CException * pe)
  214. {
  215. pe->ReportError();
  216. pe->Delete();
  217. strTempAlias.Empty();
  218. pDX->PrepareCtrl(IDC_PP_IIS_ALIAS); // do this just to set the control for Fail().
  219. pDX->Fail();
  220. } // catch: CException
  221. } // if: alias not prefixed with slash
  222. } // if: saving data from dialog
  223. CBasePropertyPage::DoDataExchange(pDX);
  224. } //*** CIISVirtualRootParamsPage::DoDataExchange()
  225. /////////////////////////////////////////////////////////////////////////////
  226. //++
  227. //
  228. // CIISVirtualRootParamsPage::OnInitDialog
  229. //
  230. // Routine Description:
  231. // Handler for the WM_INITDIALOG message.
  232. //
  233. // Arguments:
  234. // None.
  235. //
  236. // Return Value:
  237. // TRUE We need the focus to be set for us.
  238. // FALSE We already set the focus to the proper control.
  239. //
  240. //--
  241. /////////////////////////////////////////////////////////////////////////////
  242. BOOL CIISVirtualRootParamsPage::OnInitDialog(void)
  243. {
  244. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  245. if (BWizard())
  246. {
  247. try
  248. {
  249. m_strServiceName = IIS_SVC_NAME_WWW;
  250. m_dwAccessMask = VROOT_MASK_READ;
  251. } // try
  252. catch (CMemoryException * pme)
  253. {
  254. pme->ReportError();
  255. pme->Delete();
  256. } // catch: CMemoryException
  257. } // if: creating a new resource
  258. CBasePropertyPage::OnInitDialog();
  259. // Set limits on the edit controls.
  260. m_editDirectory.SetLimitText(MAX_PATH);
  261. m_editAlias.SetLimitText(MAX_PATH);
  262. #ifdef _ACCOUNT_AND_PASSWORD
  263. m_staticPassword.EnableWindow(FALSE);
  264. m_editPassword.EnableWindow(FALSE);
  265. #endif // _ACCOUNT_AND_PASSWORD
  266. OnChangeServiceType();
  267. #ifdef _ACCOUNT_AND_PASSWORD
  268. OnChangeDirectory();
  269. #endif // _ACCOUNT_AND_PASSWORD
  270. return TRUE; // return TRUE unless you set the focus to a control
  271. // EXCEPTION: OCX Property Pages should return FALSE
  272. } //*** CIISVirtualRootParamsPage::OnInitDialog()
  273. /////////////////////////////////////////////////////////////////////////////
  274. //++
  275. //
  276. // CIISVirtualRootParamsPage::OnSetActive
  277. //
  278. // Routine Description:
  279. // Handler for the PSN_SETACTIVE message.
  280. //
  281. // Arguments:
  282. // None.
  283. //
  284. // Return Value:
  285. // TRUE Page successfully initialized.
  286. // FALSE Page not initialized.
  287. //
  288. //--
  289. /////////////////////////////////////////////////////////////////////////////
  290. BOOL CIISVirtualRootParamsPage::OnSetActive(void)
  291. {
  292. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  293. // Enable/disable the Next/Finish button.
  294. if (BWizard())
  295. {
  296. if ((m_editDirectory.GetWindowTextLength() == 0)
  297. || (m_editAlias.GetWindowTextLength() == 0))
  298. EnableNext(FALSE);
  299. else
  300. EnableNext(TRUE);
  301. } // if: in the wizard
  302. return CBasePropertyPage::OnSetActive();
  303. } //*** CIISVirtualRootParamsPage::OnSetActive()
  304. /////////////////////////////////////////////////////////////////////////////
  305. //++
  306. //
  307. // CIISVirtualRootParamsPage::OnChangeServiceType
  308. //
  309. // Routine Description:
  310. // Handler for the BN_CLICKED message on one of the service type radio
  311. // buttons.
  312. //
  313. // Arguments:
  314. // None.
  315. //
  316. // Return Value:
  317. // None.
  318. //
  319. //--
  320. /////////////////////////////////////////////////////////////////////////////
  321. void CIISVirtualRootParamsPage::OnChangeServiceType(void)
  322. {
  323. int nCmdShowAccess;
  324. IDS idsWriteLabel = 0;
  325. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  326. OnChangeCtrl();
  327. if (m_rbFTP.GetCheck() == BST_CHECKED)
  328. {
  329. nCmdShowAccess = SW_SHOW;
  330. idsWriteLabel = IDS_WRITE;
  331. } // if: FTP service
  332. else if (m_rbGOPHER.GetCheck() == BST_CHECKED)
  333. {
  334. nCmdShowAccess = SW_HIDE;
  335. } // else if: GOPHER service
  336. else if (m_rbWWW.GetCheck() == BST_CHECKED)
  337. {
  338. nCmdShowAccess = SW_SHOW;
  339. idsWriteLabel = IDS_EXECUTE;
  340. } // else if: WWW service
  341. else
  342. {
  343. nCmdShowAccess = SW_HIDE;
  344. } // else: unknown service
  345. // Set the access checkbox labels.
  346. if (idsWriteLabel != 0)
  347. {
  348. CString strWriteLabel;
  349. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  350. strWriteLabel.LoadString(idsWriteLabel);
  351. m_ckbWrite.SetWindowText(strWriteLabel);
  352. } // if: write label needs to be set
  353. // Hide the Access group if this is for a GOPHER Virtual Root.
  354. m_groupAccess.ShowWindow(nCmdShowAccess);
  355. m_ckbRead.ShowWindow(nCmdShowAccess);
  356. m_ckbWrite.ShowWindow(nCmdShowAccess);
  357. } //*** CIISVirtualRootParamsPage::OnChangeServiceType()
  358. /////////////////////////////////////////////////////////////////////////////
  359. //++
  360. //
  361. // CIISVirtualRootParamsPage::OnChangeDirectory
  362. //
  363. // Routine Description:
  364. // Handler for the EN_CHANGE message on the Directory edit control.
  365. //
  366. // Arguments:
  367. // None.
  368. //
  369. // Return Value:
  370. // None.
  371. //
  372. //--
  373. /////////////////////////////////////////////////////////////////////////////
  374. #ifdef _ACCOUNT_AND_PASSWORD
  375. void CIISVirtualRootParamsPage::OnChangeDirectory(void)
  376. {
  377. BOOL bEnable = FALSE;
  378. CString strDirectory;
  379. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  380. OnChangeCtrl();
  381. // If the edit control begins with a \\name\, enable the account info
  382. // group. Otherwise disable it.
  383. m_editDirectory.GetWindowText(strDirectory);
  384. if ((strDirectory.GetLength() >= 4)
  385. && (strDirectory[0] == _T('\\'))
  386. && (strDirectory[1] == _T('\\'))
  387. && (strDirectory[2] != _T('\\')))
  388. {
  389. CString strRight;
  390. strRight = strDirectory.Right(strDirectory.GetLength() - 3);
  391. if (strRight.Find(_T('\\')) >= 0)
  392. bEnable = TRUE;
  393. } // if: directory begins with a double backslash + non-backslash
  394. // Enable or disable the account info group.
  395. m_groupAccountInfo.EnableWindow(bEnable);
  396. m_staticAccountName.EnableWindow(bEnable);
  397. m_editAccountName.EnableWindow(bEnable);
  398. // m_staticPassword.EnableWindow(bEnable);
  399. // m_editPassword.EnableWindow(bEnable);
  400. if (BWizard())
  401. {
  402. if ((m_strDirectory.GetLength() == 0)
  403. || (m_editAlias.GetWindowTextLength() == 0))
  404. EnableNext(FALSE);
  405. else
  406. EnableNext(TRUE);
  407. } // if: in a wizard
  408. } //*** CIISVirtualRootParamsPage::OnChangeDirectory()
  409. #endif // _ACCOUNT_AND_PASSWORD
  410. /////////////////////////////////////////////////////////////////////////////
  411. //++
  412. //
  413. // CIISVirtualRootParamsPage::OnChangeRequiredField
  414. //
  415. // Routine Description:
  416. // Handler for the EN_CHANGE message on the Share name or Path edit
  417. // controls.
  418. //
  419. // Arguments:
  420. // None.
  421. //
  422. // Return Value:
  423. // None.
  424. //
  425. //--
  426. /////////////////////////////////////////////////////////////////////////////
  427. void CIISVirtualRootParamsPage::OnChangeRequiredField(void)
  428. {
  429. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  430. OnChangeCtrl();
  431. if (BWizard())
  432. {
  433. if ((m_editDirectory.GetWindowTextLength() == 0)
  434. || (m_editAlias.GetWindowTextLength() == 0))
  435. EnableNext(FALSE);
  436. else
  437. EnableNext(TRUE);
  438. } // if: in a wizard
  439. } //*** CIISVirtualRootParamsPage::OnChangeRequiredField()