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.

2239 lines
45 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. vdir.cpp
  5. Abstract:
  6. WWW Directory Properties Page
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "w3scfg.h"
  18. #include "vdir.h"
  19. #include "dirbrows.h"
  20. #include <lmcons.h>
  21. #include <atlbase.h>
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. /****************************************************************************
  28. ** **
  29. ** WARNING: What a hairy mess this dialog and this code have become. **
  30. ** The tale grew in the telling as it were, but at some point **
  31. ** it ought to be rewritten. Currently, I would be very **
  32. ** wary of touching anything in here if I were you, because this **
  33. ** dialog exists in many configurations: file, directory, **
  34. ** virtual directory, home directory, master properties, local **
  35. ** path, redirected path, UNC path, downlevel, plus combinations **
  36. ** of the aforementioned. Whatever you touch will likely affect **
  37. ** all these configurations. **
  38. ** **
  39. ** 2/1/1998 - RonaldM **
  40. ** **
  41. ****************************************************************************/
  42. //
  43. // Directory Properties Page
  44. //
  45. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  46. LPCTSTR
  47. CvtPathToDosStyle(
  48. IN OUT CString & strPath
  49. )
  50. {
  51. //
  52. // Get a pointer to the string data without increasing the buffer
  53. //
  54. for (LPTSTR lp = strPath.GetBuffer(1); *lp; ++lp)
  55. {
  56. if (*lp == _T('/'))
  57. {
  58. *lp = _T('\\');
  59. }
  60. }
  61. strPath.ReleaseBuffer();
  62. return strPath;
  63. }
  64. IMPLEMENT_DYNCREATE(CW3DirectoryPage, CInetPropertyPage)
  65. CW3DirectoryPage::CW3DirectoryPage(
  66. IN CInetPropertySheet * pSheet,
  67. IN BOOL fHome,
  68. IN DWORD dwAttributes
  69. )
  70. /*++
  71. Routine Description:
  72. Constructor for directory property page
  73. Arguments:
  74. CInetPropertySheet * pSheet : Sheet pointer
  75. BOOL fHome : TRUE if this is a home directory
  76. DWORD dwAttributes : Attributes of the directory/file/vroot
  77. Return Value:
  78. N/A
  79. --*/
  80. : CInetPropertyPage(CW3DirectoryPage::IDD, pSheet,
  81. fHome ? IDS_TAB_HOME_DIRECTORY
  82. : IS_VROOT(dwAttributes)
  83. ? IDS_TAB_VIRTUAL_DIRECTORY
  84. : IS_DIR(dwAttributes)
  85. ? IDS_TAB_DIR
  86. : IDS_TAB_FILE),
  87. //
  88. // Assign the range of bits in m_dwAccessPermissions that
  89. // we manage. This is important, because another page
  90. // manages other bits, and we don't want to mess up
  91. // the master value bits when our changes collide (it
  92. // will mark the original bits as dirty, because we're not
  93. // notified when the change is made...
  94. //
  95. m_dwBitRangePermissions(MD_ACCESS_EXECUTE |
  96. MD_ACCESS_SCRIPT |
  97. MD_ACCESS_WRITE |
  98. MD_ACCESS_SOURCE |
  99. MD_ACCESS_READ),
  100. m_dwBitRangeDirBrowsing(MD_DIRBROW_ENABLED),
  101. m_fHome(fHome),
  102. m_fRecordChanges(FALSE),
  103. m_strMetaRoot(),
  104. m_dwAttributes(dwAttributes),
  105. m_pApplication(NULL),
  106. m_fOriginallyUNC(FALSE)
  107. {
  108. #if 0 // Keep Class-wizard happy
  109. //{{AFX_DATA_INIT(CW3DirectoryPage)
  110. m_nPathType = RADIO_DIRECTORY;
  111. m_nPermissions = -1;
  112. m_fBrowsingAllowed = FALSE;
  113. m_fRead = FALSE;
  114. m_fWrite = FALSE;
  115. m_fAuthor = FALSE;
  116. m_fLogAccess = FALSE;
  117. m_strPath = _T("");
  118. m_strRedirectPath = _T("");
  119. m_strAppFriendlyName = _T("");
  120. m_fIndex = FALSE;
  121. m_strDefaultDocument = _T("");
  122. //}}AFX_DATA_INIT
  123. #endif // 0
  124. VERIFY(m_strPrompt[RADIO_DIRECTORY].LoadString(IDS_PROMPT_DIR));
  125. VERIFY(m_strPrompt[RADIO_NETDIRECTORY].LoadString(IDS_PROMPT_UNC));
  126. VERIFY(m_strPrompt[RADIO_REDIRECT].LoadString(IDS_PROMPT_REDIRECT));
  127. VERIFY(m_strRemove.LoadString(IDS_BUTTON_REMOVE));
  128. VERIFY(m_strCreate.LoadString(IDS_BUTTON_CREATE));
  129. VERIFY(m_strEnable.LoadString(IDS_BUTTON_ENABLE));
  130. VERIFY(m_strDisable.LoadString(IDS_BUTTON_DISABLE));
  131. VERIFY(m_strWebFmt.LoadString(IDS_APPROOT_FMT));
  132. VERIFY(m_strWebMaster.LoadString(IDS_WEB_MASTER));
  133. }
  134. CW3DirectoryPage::~CW3DirectoryPage()
  135. /*++
  136. Routine Description:
  137. Destructor
  138. Arguments:
  139. N/A
  140. Return Value:
  141. N/A
  142. --*/
  143. {
  144. SAFE_DELETE(m_pApplication);
  145. }
  146. void
  147. CW3DirectoryPage::MakeDisplayAlias()
  148. /*++
  149. Routine Description:
  150. Build display version of the metabase alias;
  151. Arguments:
  152. None
  153. Return Value:
  154. None
  155. --*/
  156. {
  157. CString strPath(((CW3Sheet *)GetSheet())->QueryParent());
  158. strPath += _T("/");
  159. strPath += m_strAlias;
  160. m_strDisplayAlias = strPath.Mid(::lstrlen(g_cszRoot));
  161. CvtPathToDosStyle(m_strDisplayAlias);
  162. }
  163. void
  164. CW3DirectoryPage::DoDataExchange(
  165. IN CDataExchange * pDX
  166. )
  167. /*++
  168. Routine Description:
  169. Initialise/Store control Data
  170. Arguments:
  171. CDataExchange * pDX : DDX/DDV struct
  172. Return Value:
  173. None.
  174. --*/
  175. {
  176. CInetPropertyPage::DoDataExchange(pDX);
  177. //{{AFX_DATA_MAP(CW3DirectoryPage)
  178. DDX_Radio(pDX, IDC_RADIO_DIR, m_nPathType);
  179. DDX_CBIndex(pDX, IDC_COMBO_PERMISSIONS, m_nPermissions);
  180. DDX_Check(pDX, IDC_CHECK_DIRECTORY_BROWSING_ALLOWED, m_fBrowsingAllowed);
  181. DDX_Check(pDX, IDC_CHECK_READ, m_fRead);
  182. DDX_Check(pDX, IDC_CHECK_WRITE, m_fWrite);
  183. DDX_Check(pDX, IDC_CHECK_AUTHOR, m_fAuthor);
  184. DDX_Check(pDX, IDC_CHECK_LOG_ACCESS, m_fLogAccess);
  185. DDX_Check(pDX, IDC_CHECK_INDEX, m_fIndexed);
  186. DDX_Text(pDX, IDC_EDIT_ALIAS, m_strDisplayAlias);
  187. DDX_Text(pDX, IDC_EDIT_APPLICATION, m_strAppFriendlyName);
  188. DDV_MinMaxChars(pDX, m_strAppFriendlyName, 0, MAX_PATH); /// ?
  189. DDX_Control(pDX, IDC_EDIT_PATH, m_edit_Path);
  190. DDX_Control(pDX, IDC_EDIT_ALIAS, m_edit_DisplayAlias);
  191. DDX_Control(pDX, IDC_EDIT_REDIRECT, m_edit_Redirect);
  192. DDX_Control(pDX, IDC_EDIT_APPLICATION, m_edit_AppFriendlyName);
  193. DDX_Control(pDX, IDC_STATIC_APP_PROMPT, m_static_AppPrompt);
  194. DDX_Control(pDX, IDC_STATIC_PATH_PROMPT, m_static_PathPrompt);
  195. DDX_Control(pDX, IDC_STATIC_STARTING_POINT, m_static_StartingPoint);
  196. DDX_Control(pDX, IDC_STATIC_PROTECTIOn, m_static_ProtectionPrompt);
  197. DDX_Control(pDX, IDC_STATIC_PERMISSIONS, m_static_PermissionsPrompt);
  198. DDX_Control(pDX, IDC_BUTTON_UNLOAD_APP, m_button_Unload);
  199. DDX_Control(pDX, IDC_BUTTON_CREATE_REMOVE_APP, m_button_CreateRemove);
  200. DDX_Control(pDX, IDC_BUTTON_BROWSE, m_button_Browse);
  201. DDX_Control(pDX, IDC_BUTTON_CONNECT_AS, m_button_ConnectAs);
  202. DDX_Control(pDX, IDC_DUMMY_CONFIGURATION, m_button_Configuration);
  203. DDX_Control(pDX, IDC_RADIO_DIR, m_radio_Dir);
  204. DDX_Control(pDX, IDC_CHECK_AUTHOR, m_check_Author);
  205. DDX_Control(pDX, IDC_CHECK_CHILD, m_check_Child);
  206. DDX_Control(pDX, IDC_CHECK_DIRECTORY_BROWSING_ALLOWED, m_check_DirBrowse);
  207. DDX_Control(pDX, IDC_CHECK_INDEX, m_check_Index);
  208. DDX_Control(pDX, IDC_CHECK_WRITE, m_check_Write);
  209. DDX_Control(pDX, IDC_CHECK_READ, m_check_Read);
  210. DDX_Control(pDX, IDC_COMBO_PERMISSIONS, m_combo_Permissions);
  211. DDX_Control(pDX, IDC_COMBO_PROCESS, m_combo_Process);
  212. //}}AFX_DATA_MAP
  213. DDX_Control(pDX, IDC_RADIO_UNC, m_radio_Unc);
  214. DDX_Control(pDX, IDC_RADIO_REDIRECT, m_radio_Redirect);
  215. DDX_Check(pDX, IDC_CHECK_CHILD, m_fChild);
  216. DDX_Check(pDX, IDC_CHECK_EXACT, m_fExact);
  217. DDX_Check(pDX, IDC_CHECK_PERMANENT, m_fPermanent);
  218. if (pDX->m_bSaveAndValidate)
  219. {
  220. //
  221. // Make sure all field names are correct
  222. //
  223. if (m_nPathType == RADIO_NETDIRECTORY)
  224. {
  225. DDX_Text(pDX, IDC_EDIT_PATH, m_strPath);
  226. m_strPath.TrimLeft();
  227. DDV_MinMaxChars(pDX, m_strPath, 0, MAX_PATH);
  228. if (!IsUNCName(m_strPath))
  229. {
  230. ::AfxMessageBox(IDS_BAD_UNC_PATH);
  231. pDX->Fail();
  232. }
  233. m_strRedirectPath.Empty();
  234. /*
  235. ISSUE: Don't need username/password?
  236. if (m_strUserName.IsEmpty())
  237. {
  238. ::AfxMessageBox(IDS_ERR_NO_USERNAME);
  239. if (!BrowseUser())
  240. {
  241. pDX->Fail();
  242. }
  243. }
  244. */
  245. }
  246. else if (m_nPathType == RADIO_REDIRECT)
  247. {
  248. DDX_Text(pDX, IDC_EDIT_REDIRECT, m_strRedirectPath);
  249. m_strRedirectPath.TrimLeft();
  250. DDV_MinMaxChars(pDX, m_strRedirectPath, 0, 2 * MAX_PATH);
  251. if (!IsRelURLPath(m_strRedirectPath)
  252. && !IsWildcardedRedirectPath(m_strRedirectPath)
  253. && !IsURLName(m_strRedirectPath))
  254. {
  255. ::AfxMessageBox(IDS_BAD_URL_PATH);
  256. pDX->Fail();
  257. }
  258. }
  259. else // Local directory
  260. {
  261. ASSERT(m_nPathType == RADIO_DIRECTORY);
  262. m_strRedirectPath.Empty();
  263. if (IsVroot())
  264. {
  265. DDX_Text(pDX, IDC_EDIT_PATH, m_strPath);
  266. m_strPath.TrimLeft();
  267. if (!IsMasterInstance())
  268. {
  269. DDV_MinMaxChars(pDX, m_strPath, 1, MAX_PATH);
  270. }
  271. else
  272. {
  273. if (m_strPath.IsEmpty())
  274. {
  275. //
  276. // No additional validation necc. on master
  277. // instance.
  278. //
  279. return;
  280. }
  281. }
  282. if (!IsFullyQualifiedPath(m_strPath) && !IsDevicePath(m_strPath))
  283. {
  284. ::AfxMessageBox(IDS_ERR_INVALID_PATH);
  285. pDX->Fail();
  286. }
  287. if (IsLocal())
  288. {
  289. DWORD dwAttr = GetFileAttributes(m_strPath);
  290. if (dwAttr == 0xffffffff ||
  291. (dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0)
  292. {
  293. ::AfxMessageBox(IDS_ERR_PATH_NOT_FOUND);
  294. pDX->Fail();
  295. }
  296. }
  297. }
  298. }
  299. }
  300. else
  301. {
  302. DDX_Text(pDX, IDC_EDIT_REDIRECT, m_strRedirectPath);
  303. DDX_Text(pDX, IDC_EDIT_PATH, m_strPath);
  304. DDV_MinMaxChars(pDX, m_strPath, 0, MAX_PATH);
  305. if (!IsMasterInstance() && IS_VROOT(m_dwAttributes))
  306. {
  307. DDV_MinMaxChars(pDX, m_strPath, 1, MAX_PATH);
  308. }
  309. }
  310. }
  311. //
  312. // Message Map
  313. //
  314. BEGIN_MESSAGE_MAP(CW3DirectoryPage, CInetPropertyPage)
  315. //{{AFX_MSG_MAP(CW3DirectoryPage)
  316. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  317. ON_BN_CLICKED(IDC_BUTTON_CONNECT_AS, OnButtonConnectAs)
  318. ON_BN_CLICKED(IDC_BUTTON_CREATE_REMOVE_APP, OnButtonCreateRemoveApp)
  319. ON_BN_CLICKED(IDC_BUTTON_UNLOAD_APP, OnButtonUnloadApp)
  320. ON_BN_CLICKED(IDC_DUMMY_CONFIGURATION, OnButtonConfiguration)
  321. ON_BN_CLICKED(IDC_CHECK_READ, OnCheckRead)
  322. ON_BN_CLICKED(IDC_CHECK_WRITE, OnCheckWrite)
  323. ON_BN_CLICKED(IDC_CHECK_AUTHOR, OnCheckAuthor)
  324. ON_BN_CLICKED(IDC_RADIO_DIR, OnRadioDir)
  325. ON_BN_CLICKED(IDC_RADIO_REDIRECT, OnRadioRedirect)
  326. ON_BN_CLICKED(IDC_RADIO_UNC, OnRadioUnc)
  327. ON_CBN_SELCHANGE(IDC_COMBO_PERMISSIONS, OnSelchangeComboPermissions)
  328. ON_CBN_SELCHANGE(IDC_COMBO_PROCESS, OnSelchangeComboProcess)
  329. //}}AFX_MSG_MAP
  330. ON_EN_CHANGE(IDC_EDIT_PATH, OnItemChanged)
  331. ON_EN_CHANGE(IDC_EDIT_REDIRECT, OnItemChanged)
  332. ON_EN_CHANGE(IDC_EDIT_APPLICATION, OnItemChanged)
  333. ON_BN_CLICKED(IDC_CHECK_DIRECTORY_BROWSING_ALLOWED, OnItemChanged)
  334. ON_BN_CLICKED(IDC_CHECK_LOG_ACCESS, OnItemChanged)
  335. ON_BN_CLICKED(IDC_CHECK_SCRIPT, OnItemChanged)
  336. ON_BN_CLICKED(IDC_CHECK_CHILD, OnItemChanged)
  337. ON_BN_CLICKED(IDC_CHECK_EXACT, OnItemChanged)
  338. ON_BN_CLICKED(IDC_CHECK_PERMANENT, OnItemChanged)
  339. ON_BN_CLICKED(IDC_CHECK_INDEX, OnItemChanged)
  340. END_MESSAGE_MAP()
  341. void
  342. CW3DirectoryPage::RefreshAppState()
  343. /*++
  344. Routine Description:
  345. Refresh app state parameters
  346. Arguments:
  347. None
  348. Return Value:
  349. None
  350. --*/
  351. {
  352. ASSERT(m_pApplication != NULL);
  353. CError err(m_pApplication->RefreshAppState());
  354. if (err.Failed())
  355. {
  356. m_dwAppState = APPSTATUS_NOTDEFINED;
  357. if (err.Win32Error() == ERROR_PATH_NOT_FOUND)
  358. {
  359. //
  360. // Ignore this error, it really just means the path
  361. // doesn't exist in the metabase, which is true for most
  362. // file and directory properties, and not an error
  363. // condition.
  364. //
  365. err.Reset();
  366. }
  367. }
  368. else
  369. {
  370. m_dwAppState = m_pApplication->QueryAppState();
  371. }
  372. if (err.Succeeded())
  373. {
  374. //
  375. // Get metabase information
  376. //
  377. m_strAppRoot = m_pApplication->m_strAppRoot;
  378. m_dwAppProtection = m_pApplication->m_dwProcessProtection;
  379. m_strAppFriendlyName = m_pApplication->m_strFriendlyName;
  380. m_fIsAppRoot = m_strMetaRoot.CompareNoCase(
  381. CMetaKey::CleanMetaPath(m_strAppRoot)) == 0;
  382. }
  383. else
  384. {
  385. //
  386. // Display error information
  387. //
  388. err.MessageBoxFormat(IDS_ERR_APP, MB_OK, NO_HELP_CONTEXT);
  389. }
  390. }
  391. CString &
  392. CW3DirectoryPage::FriendlyAppRoot(
  393. IN LPCTSTR lpAppRoot,
  394. OUT CString & strFriendly
  395. )
  396. /*++
  397. Routine Description:
  398. Convert the metabase app root path to a friendly display name
  399. format.
  400. Arguments:
  401. LPCTSTR lpAppRoot : App root
  402. CString & strFriendly : Output friendly app root format
  403. Return Value:
  404. Reference to the output string
  405. Notes:
  406. App root must have been cleaned from WAM format priort
  407. to calling this function (see first ASSERT below
  408. --*/
  409. {
  410. //
  411. // Make sure we cleaned up WAM format
  412. //
  413. ASSERT(*lpAppRoot != _T('/'));
  414. CString strAppRoot(lpAppRoot);
  415. TRACEEOLID("Unfriendly app root: " << strAppRoot);
  416. //
  417. // Break into fields
  418. //
  419. strFriendly.Empty();
  420. LPCTSTR lp = _tcschr(lpAppRoot, _T('/')); // lm
  421. if (lp != NULL)
  422. {
  423. lp = _tcschr(++lp, _T('/')); // w3svc
  424. if (lp == NULL)
  425. {
  426. //
  427. // Master Instance
  428. //
  429. strFriendly = m_strWebMaster;
  430. return strFriendly;
  431. }
  432. DWORD dwInstance = _ttol(++lp);
  433. lp = _tcschr(lp, _T('/')); // Instance #
  434. if (lp != NULL)
  435. {
  436. lp = _tcschr(++lp, _T('/')); // Skip "ROOT"
  437. }
  438. CInstanceProps prop(QueryServerName(), g_cszSvc, dwInstance);
  439. HRESULT hr = prop.LoadData();
  440. if (SUCCEEDED(hr))
  441. {
  442. CString strName;
  443. strFriendly.Format(
  444. m_strWebFmt,
  445. prop.GetDisplayText(strName, SERVICE_SHORT_NAME)
  446. );
  447. if (lp != NULL)
  448. {
  449. //
  450. // Add rest of dir path
  451. //
  452. strFriendly += lp;
  453. }
  454. //
  455. // Now change forward slashes in the path to backward slashes
  456. //
  457. CvtPathToDosStyle(strFriendly);
  458. return strFriendly;
  459. }
  460. };
  461. //
  462. // Bogus
  463. //
  464. VERIFY(strFriendly.LoadString(IDS_APPROOT_UNKNOWN));
  465. return strFriendly;
  466. }
  467. int
  468. CW3DirectoryPage::SetComboSelectionFromAppState(
  469. IN DWORD dwAppState
  470. )
  471. /*++
  472. Routine Description:
  473. Set the protection combo box current selection from the
  474. app state DWORD
  475. Arguments:
  476. DWORD dwAppState : Application State
  477. Return Value:
  478. Combo selection ID
  479. --*/
  480. {
  481. int nSel = -1;
  482. switch(dwAppState)
  483. {
  484. case CWamInterface::APP_INPROC:
  485. nSel = m_nSelInProc;
  486. break;
  487. case CWamInterface::APP_POOLEDPROC:
  488. ASSERT(m_pApplication->SupportsPooledProc());
  489. nSel = m_nSelPooledProc;
  490. break;
  491. case CWamInterface::APP_OUTOFPROC:
  492. nSel = m_nSelOutOfProc;
  493. break;
  494. default:
  495. ASSERT("Bogus app protection level");
  496. }
  497. ASSERT(nSel >= 0);
  498. m_combo_Process.SetCurSel(nSel);
  499. return nSel;
  500. }
  501. DWORD
  502. CW3DirectoryPage::GetAppStateFromComboSelection() const
  503. /*++
  504. Routine Description:
  505. Get the app state DWORD that coresponds to the current combo
  506. box list selection
  507. Arguments:
  508. None
  509. Return Value:
  510. App state DWORD or 0xffffffff;
  511. --*/
  512. {
  513. int nSel = m_combo_Process.GetCurSel();
  514. if (nSel == m_nSelOutOfProc)
  515. {
  516. return CWamInterface::APP_OUTOFPROC;
  517. }
  518. if (nSel == m_nSelPooledProc)
  519. {
  520. ASSERT(m_pApplication->SupportsPooledProc());
  521. return CWamInterface::APP_POOLEDPROC;
  522. }
  523. if (nSel == m_nSelInProc)
  524. {
  525. return CWamInterface::APP_INPROC;
  526. }
  527. ASSERT(FALSE && "Invalid application state");
  528. return 0xffffffff;
  529. }
  530. void
  531. CW3DirectoryPage::SetApplicationState()
  532. /*++
  533. Routine Description:
  534. Set application control state
  535. Arguments:
  536. None
  537. Return Value:
  538. None
  539. --*/
  540. {
  541. //
  542. // SetWindowText causes a dirty marker
  543. //
  544. BOOL fOld = m_fRecordChanges;
  545. m_fRecordChanges = FALSE;
  546. m_fParentEnabled = !m_strAppRoot.IsEmpty();
  547. m_fAppEnabled = FALSE;
  548. if (m_pApplication != NULL)
  549. {
  550. m_pApplication->RefreshAppState();
  551. m_fAppEnabled = m_fIsAppRoot && m_pApplication->IsEnabledApplication();
  552. }
  553. m_button_CreateRemove.EnableWindow(
  554. !IsMasterInstance()
  555. && HasAdminAccess()
  556. );
  557. m_button_CreateRemove.SetWindowText(m_fAppEnabled
  558. ? m_strRemove
  559. : m_strCreate
  560. );
  561. m_static_ProtectionPrompt.EnableWindow(
  562. m_fAppEnabled
  563. && !IsMasterInstance()
  564. && HasAdminAccess()
  565. );
  566. //
  567. // Set selection in combo box to match current app state
  568. //
  569. SetComboSelectionFromAppState(m_dwAppProtection);
  570. m_combo_Process.EnableWindow(
  571. m_fAppEnabled
  572. && !IsMasterInstance()
  573. && HasAdminAccess()
  574. );
  575. m_static_PermissionsPrompt.EnableWindow(HasAdminAccess());
  576. m_combo_Permissions.EnableWindow(HasAdminAccess());
  577. m_static_AppPrompt.EnableWindow(m_fIsAppRoot && HasAdminAccess());
  578. m_edit_AppFriendlyName.EnableWindow(m_fIsAppRoot && HasAdminAccess());
  579. m_button_Configuration.EnableWindow(m_fAppEnabled);
  580. //
  581. // Write out the verbose starting point.
  582. //
  583. CString str;
  584. FitPathToControl(
  585. m_static_StartingPoint,
  586. FriendlyAppRoot(m_strAppRoot, str)
  587. );
  588. m_edit_AppFriendlyName.SetWindowText(m_strAppFriendlyName);
  589. m_button_Unload.EnableWindow(m_dwAppState == APPSTATUS_RUNNING);
  590. //
  591. // Restore (see note on top)
  592. //
  593. m_fRecordChanges = fOld;
  594. }
  595. void
  596. CW3DirectoryPage::ChangeTypeTo(
  597. IN int nNewType
  598. )
  599. /*++
  600. Routine Description
  601. Change the directory type
  602. Arguments:
  603. int nNewType : New radio value
  604. Return Value:
  605. None
  606. --*/
  607. {
  608. int nOldType = m_nPathType;
  609. m_nPathType = nNewType;
  610. if (nOldType == m_nPathType)
  611. {
  612. //
  613. // No change
  614. //
  615. return;
  616. }
  617. OnItemChanged();
  618. SetStateByType();
  619. int nID = -1;
  620. CEdit * pPath = NULL;
  621. LPCTSTR lpKeepPath = NULL;
  622. switch(m_nPathType)
  623. {
  624. case RADIO_DIRECTORY:
  625. if (IsVroot())
  626. {
  627. if (IsFullyQualifiedPath(m_strPath) || IsDevicePath(m_strPath))
  628. {
  629. //
  630. // The old path info is acceptable, propose it
  631. // as a default
  632. //
  633. lpKeepPath = m_strPath;
  634. }
  635. nID = IDS_DIRECTORY_MASK;
  636. pPath = &m_edit_Path;
  637. }
  638. break;
  639. case RADIO_NETDIRECTORY:
  640. if (IsVroot())
  641. {
  642. if (IsUNCName(m_strPath))
  643. {
  644. //
  645. // The old path info is acceptable, propose it
  646. // as a default
  647. //
  648. lpKeepPath = m_strPath;
  649. }
  650. nID = IDS_UNC_MASK;
  651. pPath = &m_edit_Path;
  652. }
  653. break;
  654. case RADIO_REDIRECT:
  655. if (!m_strRedirectPath.IsEmpty())
  656. {
  657. //
  658. // The old path info is acceptable, propose it
  659. // as a default
  660. //
  661. lpKeepPath = m_strRedirectPath;
  662. }
  663. nID = IDS_REDIRECT_MASK;
  664. pPath = &m_edit_Redirect;
  665. break;
  666. default:
  667. ASSERT(FALSE);
  668. return;
  669. }
  670. //
  671. // Load mask resource, and display
  672. // this in the directory
  673. //
  674. if (pPath != NULL)
  675. {
  676. if (lpKeepPath != NULL)
  677. {
  678. pPath->SetWindowText(lpKeepPath);
  679. }
  680. else
  681. {
  682. CString str;
  683. VERIFY(str.LoadString(nID));
  684. pPath->SetWindowText(str);
  685. }
  686. pPath->SetSel(0,-1);
  687. pPath->SetFocus();
  688. }
  689. }
  690. void
  691. CW3DirectoryPage::ShowControl(
  692. IN CWnd * pWnd,
  693. IN BOOL fShow
  694. )
  695. /*++
  696. Routine Description:
  697. Show/hide the given control
  698. Arguments:
  699. CWnd * pWnd : Window control
  700. BOOL fShow : TRUE to show, FALSE to hide
  701. Return Value:
  702. None
  703. --*/
  704. {
  705. ASSERT(pWnd != NULL);
  706. /*
  707. if (pWnd)
  708. {
  709. pWnd->ShowWindow(fShow ? SW_SHOW : SW_HIDE);
  710. }
  711. */
  712. ActivateControl(*pWnd, fShow);
  713. }
  714. int
  715. CW3DirectoryPage::AddStringToComboBox(
  716. IN CComboBox & combo,
  717. IN UINT nID
  718. )
  719. /*++
  720. Routine Description:
  721. Add a string referred to by resource ID to the combobox
  722. Arguments:
  723. CComboBox & combo : Combo box
  724. UINT nID : Resource ID
  725. Return Value:
  726. Index of the string added
  727. --*/
  728. {
  729. CString str;
  730. VERIFY(str.LoadString(nID));
  731. return combo.AddString(str);
  732. }
  733. void
  734. CW3DirectoryPage::SetStateByType()
  735. /*++
  736. Routine Description:
  737. Set the state of the dialog by the path type currently selected
  738. Arguments:
  739. None
  740. Return Value:
  741. None
  742. --*/
  743. {
  744. BOOL fShowDirFlags;
  745. BOOL fShowLargeDirGroup;
  746. BOOL fShowRedirectFlags;
  747. BOOL fShowApp;
  748. BOOL fShowIndex;
  749. BOOL fShowDirBrowse;
  750. BOOL fShowDAV;
  751. BOOL fEnableChild;
  752. BOOL fEnableBrowse;
  753. switch(m_nPathType)
  754. {
  755. case RADIO_DIRECTORY:
  756. ShowControl(&m_button_ConnectAs, FALSE);
  757. ShowControl(&m_button_Browse, IsVroot());
  758. ShowControl(&m_edit_Path, IsVroot());
  759. ShowControl(&m_edit_DisplayAlias, !IsVroot());
  760. ShowControl(&m_edit_Redirect, FALSE);
  761. fShowDirFlags = TRUE;
  762. fShowLargeDirGroup = !IsFile();
  763. fShowRedirectFlags = FALSE;
  764. fShowApp = !IsFile();
  765. fShowIndex = !IsFile();
  766. fShowDirBrowse = !IsFile();
  767. fShowDAV = TRUE;
  768. fEnableChild = FALSE;
  769. fEnableBrowse = IsLocal() && !IsMasterInstance() && HasAdminAccess();
  770. break;
  771. case RADIO_NETDIRECTORY:
  772. ShowControl(&m_button_ConnectAs, TRUE);
  773. ShowControl(&m_button_Browse, FALSE);
  774. ShowControl(&m_edit_Path, TRUE);
  775. ShowControl(&m_edit_DisplayAlias, FALSE);
  776. ShowControl(&m_edit_Redirect, FALSE);
  777. fShowDirFlags = TRUE;
  778. fShowLargeDirGroup = TRUE;
  779. fShowRedirectFlags = FALSE;
  780. fShowApp = TRUE;
  781. fShowIndex = TRUE;
  782. fShowDirBrowse = TRUE;
  783. fShowDAV = TRUE;
  784. fEnableChild = FALSE;
  785. fEnableBrowse = FALSE;
  786. break;
  787. case RADIO_REDIRECT:
  788. ShowControl(&m_button_ConnectAs, FALSE);
  789. ShowControl(&m_button_Browse, FALSE);
  790. ShowControl(&m_edit_Path, FALSE);
  791. ShowControl(&m_edit_DisplayAlias, FALSE);
  792. ShowControl(&m_edit_Redirect, TRUE);
  793. fShowDirFlags = FALSE;
  794. fShowRedirectFlags = TRUE;
  795. fShowApp = FALSE;
  796. fShowDAV = FALSE;
  797. fShowIndex = FALSE;
  798. fShowDirBrowse = FALSE;
  799. fEnableChild = !IsFile();
  800. fEnableBrowse = FALSE;
  801. break;
  802. default:
  803. ASSERT(FALSE && "Invalid Selection");
  804. return;
  805. }
  806. UINT nID;
  807. for (nID = IDC_DIR_FLAGS_FIRST; nID <= IDC_DIR_FLAGS_LAST; ++nID)
  808. {
  809. ShowControl(GetDlgItem(nID), fShowDirFlags);
  810. }
  811. ShowControl(GetDlgItem(IDC_STATIC_DIRFLAGS_LARGE),
  812. fShowDirFlags && fShowLargeDirGroup);
  813. ShowControl(GetDlgItem(IDC_STATIC_DIRFLAGS_SMALL),
  814. fShowDirFlags && !fShowLargeDirGroup);
  815. for (nID = IDC_REDIRECT_FLAGS_FIRST; nID <= IDC_REDIRECT_FLAGS_LAST; ++nID)
  816. {
  817. ShowControl(nID, fShowRedirectFlags);
  818. }
  819. for (nID = IDC_APPLICATIONS_FIRST; nID <= IDC_APPLICATIONS_LAST; ++nID)
  820. {
  821. ShowControl(nID, fShowApp);
  822. }
  823. ShowControl(&m_check_Author, fShowDAV);
  824. ShowControl(&m_check_DirBrowse, fShowDirBrowse);
  825. ShowControl(&m_check_Index, fShowIndex);
  826. //
  827. // Enable/Disable must come after the showcontrols
  828. //
  829. m_button_Browse.EnableWindow(fEnableBrowse);
  830. m_check_Child.EnableWindow(fEnableChild);
  831. m_static_PathPrompt.SetWindowText(m_strPrompt[m_nPathType]);
  832. SetApplicationState();
  833. }
  834. void
  835. CW3DirectoryPage::SaveAuthoringState()
  836. /*++
  837. Routine Description:
  838. Save authoring state
  839. Arguments:
  840. None
  841. Return Value:
  842. None
  843. --*/
  844. {
  845. /*
  846. if (m_check_Write.m_hWnd)
  847. {
  848. //
  849. // Controls initialized -- store live data
  850. //
  851. m_fOriginalWrite = m_check_Write.GetCheck() > 0;
  852. m_fOriginalRead = m_check_Read.GetCheck() > 0;
  853. }
  854. else
  855. {
  856. //
  857. // Controls not yet initialized, store original data
  858. //
  859. m_fOriginalWrite = m_fWrite;
  860. m_fOriginalRead = m_fRead;
  861. }
  862. */
  863. }
  864. void
  865. CW3DirectoryPage::RestoreAuthoringState()
  866. /*++
  867. Routine Description:
  868. Restore the authoring state
  869. Arguments:
  870. None
  871. Return Value:
  872. None
  873. --*/
  874. {
  875. /*
  876. m_fWrite = m_fOriginalWrite;
  877. m_fRead = m_fOriginalRead;
  878. */
  879. }
  880. void
  881. CW3DirectoryPage::SetAuthoringState(
  882. BOOL fAlterReadAndWrite
  883. )
  884. /*++
  885. Routine Description:
  886. Set authoring state
  887. Arguments:
  888. None
  889. Return Value:
  890. None
  891. --*/
  892. {
  893. /*
  894. if (fAlterReadAndWrite)
  895. {
  896. if (m_fAuthor)
  897. {
  898. //
  899. // Remember previous setting to undo
  900. // this thing.
  901. //
  902. SaveAuthoringState();
  903. m_fRead = m_fWrite = TRUE;
  904. }
  905. else
  906. {
  907. //
  908. // Restore previous defaults
  909. //
  910. RestoreAuthoringState();
  911. }
  912. m_check_Read.SetCheck(m_fRead);
  913. m_check_Write.SetCheck(m_fWrite);
  914. }
  915. */
  916. m_check_Author.EnableWindow(
  917. (m_fRead || m_fWrite) &&
  918. HasAdminAccess() &&
  919. HasDAV()
  920. );
  921. //m_check_Read.EnableWindow(!m_fAuthor && HasAdminAccess());
  922. //m_check_Write.EnableWindow(!m_fAuthor && HasAdminAccess());
  923. m_check_Read.EnableWindow(HasAdminAccess());
  924. m_check_Write.EnableWindow(HasAdminAccess());
  925. }
  926. void
  927. CW3DirectoryPage::SetPathType()
  928. /*++
  929. Routine Description:
  930. Set path type from given path
  931. Arguments:
  932. None
  933. Return Value:
  934. None
  935. --*/
  936. {
  937. if (!m_strRedirectPath.IsEmpty())
  938. {
  939. m_nPathType = RADIO_REDIRECT;
  940. m_radio_Dir.SetCheck(0);
  941. m_radio_Unc.SetCheck(0);
  942. m_radio_Redirect.SetCheck(1);
  943. }
  944. else if (!IsVroot())
  945. {
  946. m_nPathType = RADIO_DIRECTORY;
  947. m_radio_Redirect.SetCheck(0);
  948. m_radio_Unc.SetCheck(0);
  949. m_radio_Dir.SetCheck(1);
  950. }
  951. else
  952. {
  953. m_radio_Redirect.SetCheck(0);
  954. SetPathType(m_strPath);
  955. }
  956. m_static_PathPrompt.SetWindowText(m_strPrompt[m_nPathType]);
  957. }
  958. void
  959. CW3DirectoryPage::SetPathType(
  960. IN LPCTSTR lpstrPath
  961. )
  962. /*++
  963. Routine Description:
  964. Set path type from given path
  965. Arguments:
  966. LPCTSTR lpstrPath : Path string
  967. Return Value:
  968. None
  969. --*/
  970. {
  971. if (::IsUNCName(lpstrPath))
  972. {
  973. m_nPathType = RADIO_NETDIRECTORY;
  974. m_radio_Dir.SetCheck(0);
  975. m_radio_Unc.SetCheck(1);
  976. }
  977. else
  978. {
  979. m_nPathType = RADIO_DIRECTORY;
  980. m_radio_Unc.SetCheck(0);
  981. m_radio_Dir.SetCheck(1);
  982. }
  983. }
  984. BOOL
  985. CW3DirectoryPage::BrowseUser()
  986. /*++
  987. Routine Description:
  988. Browse for username/password
  989. Arguments:
  990. None
  991. Return Value:
  992. TRUE if one was selected, FALSE otherwise.
  993. --*/
  994. {
  995. CUserAccountDlg dlg(
  996. QueryServerName(),
  997. m_strUserName,
  998. m_strPassword,
  999. this
  1000. );
  1001. if (dlg.DoModal() == IDOK)
  1002. {
  1003. m_strUserName = dlg.m_strUserName;
  1004. m_strPassword = dlg.m_strPassword;
  1005. OnItemChanged();
  1006. return TRUE;
  1007. }
  1008. return FALSE;
  1009. }
  1010. //
  1011. // Message Handlers
  1012. //
  1013. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1014. void
  1015. CW3DirectoryPage::OnItemChanged()
  1016. /*++
  1017. Routine Description:
  1018. Handle change in data on the item
  1019. Arguments:
  1020. None
  1021. Return Value:
  1022. None
  1023. --*/
  1024. {
  1025. if (m_fRecordChanges)
  1026. {
  1027. SetModified(TRUE);
  1028. }
  1029. }
  1030. void
  1031. CW3DirectoryPage::OnButtonBrowse()
  1032. /*++
  1033. Routine Description:
  1034. "Browse" button handler
  1035. Arguments:
  1036. None
  1037. Return Value:
  1038. None
  1039. --*/
  1040. {
  1041. ASSERT(IsLocal());
  1042. CString str;
  1043. m_edit_Path.GetWindowText(str);
  1044. CDirBrowseDlg dlgBrowse(this, str);
  1045. if (dlgBrowse.DoModal() == IDOK)
  1046. {
  1047. m_edit_Path.SetWindowText(dlgBrowse.GetFullPath(m_strPath));
  1048. SetPathType();
  1049. OnItemChanged();
  1050. }
  1051. }
  1052. BOOL
  1053. CW3DirectoryPage::OnSetActive()
  1054. /*++
  1055. Routine Description:
  1056. Page has become active. Dismiss if we're in an inconsistent state
  1057. Arguments:
  1058. None
  1059. Return Value:
  1060. TRUE to proceed, FALSE to dismiss.
  1061. --*/
  1062. {
  1063. if (m_pApplication == NULL)
  1064. {
  1065. return FALSE;
  1066. }
  1067. return CInetPropertyPage::OnSetActive();
  1068. }
  1069. BOOL
  1070. CW3DirectoryPage::OnInitDialog()
  1071. /*++
  1072. Routine Description:
  1073. WM_INITDIALOG handler. Initialize the dialog.
  1074. Arguments:
  1075. None.
  1076. Return Value:
  1077. TRUE if no focus is to be set automatically, FALSE if the focus
  1078. is already set.
  1079. --*/
  1080. {
  1081. CInetPropertyPage::OnInitDialog();
  1082. //
  1083. // Dynamically create a hidden app config OCX.
  1084. //
  1085. CRect rc(0, 0, 0, 0);
  1086. CString str;
  1087. VERIFY(str.LoadString(
  1088. IsVroot() ? IDS_RADIO_VDIR :
  1089. IsDir() ? IDS_RADIO_DIR : IDS_RADIO_FILE));
  1090. m_radio_Dir.SetWindowText(str);
  1091. //
  1092. // Fill permissions combo box.
  1093. //
  1094. for (UINT n = IDS_PERMISSIONS_NONE; n <= IDS_PERMISSIONS_EXECUTE; ++n)
  1095. {
  1096. AddStringToComboBox(m_combo_Permissions, n);
  1097. }
  1098. m_combo_Permissions.SetCurSel(m_nPermissions);
  1099. //
  1100. // And process combo box (low, medium and high)
  1101. //
  1102. m_nSelInProc = AddStringToComboBox(m_combo_Process, IDS_COMBO_INPROC);
  1103. if (m_pApplication->SupportsPooledProc())
  1104. {
  1105. m_nSelPooledProc = AddStringToComboBox(
  1106. m_combo_Process,
  1107. IDS_COMBO_POOLEDPROC
  1108. );
  1109. }
  1110. else
  1111. {
  1112. m_nSelPooledProc = -1; // N/A
  1113. }
  1114. m_nSelOutOfProc = AddStringToComboBox(m_combo_Process, IDS_COMBO_OUTPROC);
  1115. //
  1116. // Selection will be set later...
  1117. //
  1118. SetPathType();
  1119. SetStateByType();
  1120. SetAuthoringState(FALSE);
  1121. TRACEEOLID(m_strMetaRoot);
  1122. //
  1123. // Some items not available on master instance, or if no admin
  1124. // access exists
  1125. //
  1126. BOOL fOkToDIR = TRUE;
  1127. BOOL fOkToUNC = TRUE;
  1128. if (!HasAdminAccess() && IsVroot())
  1129. {
  1130. //
  1131. // If not an admin, operator cannot change
  1132. // the path, he can only cancel a redirect
  1133. // by going back to the path it had before.
  1134. //
  1135. fOkToDIR = IsFullyQualifiedPath(m_strPath) || IsDevicePath(m_strPath);
  1136. fOkToUNC = IsUNCName(m_strPath);
  1137. }
  1138. GetDlgItem(IDC_STATIC_PATH_TYPE)->EnableWindow(!IsMasterInstance());
  1139. GetDlgItem(IDC_RADIO_DIR)->EnableWindow(!IsMasterInstance() && fOkToDIR);
  1140. GetDlgItem(IDC_RADIO_UNC)->EnableWindow(
  1141. IsVroot()
  1142. && !IsMasterInstance()
  1143. && fOkToUNC
  1144. );
  1145. GetDlgItem(IDC_RADIO_REDIRECT)->EnableWindow(!IsMasterInstance());
  1146. GetDlgItem(IDC_STATIC_PATH_PROMPT)->EnableWindow(!IsMasterInstance());
  1147. GetDlgItem(IDC_EDIT_PATH)->EnableWindow(
  1148. !IsMasterInstance()
  1149. && HasAdminAccess()
  1150. );
  1151. GetDlgItem(IDC_BUTTON_EDIT_PATH_TYPE)->EnableWindow(!IsMasterInstance());
  1152. //SetApplicationState();
  1153. //
  1154. // Store the original value of fUNC of reference later
  1155. // when saving out --BoydM
  1156. //
  1157. m_fOriginallyUNC = (m_nPathType == RADIO_NETDIRECTORY);
  1158. //
  1159. // All changes from here on out need to be reflected.
  1160. //
  1161. m_fRecordChanges = TRUE;
  1162. return TRUE;
  1163. }
  1164. /* virtual */
  1165. HRESULT
  1166. CW3DirectoryPage::FetchLoadedValues()
  1167. /*++
  1168. Routine Description:
  1169. Move configuration data from sheet to dialog controls
  1170. Arguments:
  1171. None
  1172. Return Value:
  1173. HRESULT
  1174. --*/
  1175. {
  1176. CError err;
  1177. m_strMetaRoot = QueryMetaPath();
  1178. BEGIN_META_DIR_READ(CW3Sheet)
  1179. //
  1180. // Use m_ notation because the message crackers require it
  1181. //
  1182. BOOL m_fDontLog;
  1183. FETCH_DIR_DATA_FROM_SHEET(m_strAlias);
  1184. FETCH_DIR_DATA_FROM_SHEET(m_strUserName);
  1185. FETCH_DIR_DATA_FROM_SHEET(m_strPassword);
  1186. FETCH_DIR_DATA_FROM_SHEET(m_strPath);
  1187. FETCH_DIR_DATA_FROM_SHEET(m_strRedirectPath);
  1188. FETCH_DIR_DATA_FROM_SHEET(m_dwAccessPerms);
  1189. FETCH_DIR_DATA_FROM_SHEET(m_dwDirBrowsing);
  1190. FETCH_DIR_DATA_FROM_SHEET(m_fDontLog);
  1191. FETCH_DIR_DATA_FROM_SHEET(m_fIndexed);
  1192. FETCH_DIR_DATA_FROM_SHEET(m_fExact);
  1193. FETCH_DIR_DATA_FROM_SHEET(m_fChild);
  1194. FETCH_DIR_DATA_FROM_SHEET(m_fPermanent);
  1195. m_fBrowsingAllowed = IS_FLAG_SET(m_dwDirBrowsing, MD_DIRBROW_ENABLED);
  1196. m_fRead = IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_READ);
  1197. m_fWrite = IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_WRITE);
  1198. m_fAuthor = IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_SOURCE);
  1199. m_fLogAccess = !m_fDontLog;
  1200. SaveAuthoringState();
  1201. if (!m_fIsAppRoot)
  1202. {
  1203. m_dwAppState = APPSTATUS_NOTDEFINED;
  1204. }
  1205. MakeDisplayAlias();
  1206. END_META_DIR_READ(err)
  1207. m_nPermissions = IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_EXECUTE)
  1208. ? COMBO_EXECUTE
  1209. : IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_SCRIPT)
  1210. ? COMBO_SCRIPT
  1211. : COMBO_NONE;
  1212. //
  1213. // Make sure we were passed the right home directory
  1214. // flag
  1215. //
  1216. ASSERT((m_fHome && !::lstrcmp(m_strAlias, g_cszRoot))
  1217. || (!m_fHome && ::lstrcmp(m_strAlias, g_cszRoot)));
  1218. TRACEEOLID(QueryMetaPath());
  1219. BeginWaitCursor();
  1220. m_pApplication = new CIISApplication(QueryServerName(), QueryMetaPath());
  1221. err = m_pApplication != NULL
  1222. ? m_pApplication->QueryResult()
  1223. : ERROR_NOT_ENOUGH_MEMORY;
  1224. if (err.Win32Error() == ERROR_PATH_NOT_FOUND)
  1225. {
  1226. //
  1227. // No app information; that's ok in cases of file system directories
  1228. // that don't exist in the metabase yet.
  1229. //
  1230. err.Reset();
  1231. }
  1232. EndWaitCursor();
  1233. if (err.Succeeded())
  1234. {
  1235. //
  1236. // CODEWORK: RefreshAppState should be split up into two
  1237. // different methods: one that fetches the data, and one
  1238. // that moves the data to the UI controls on this page.
  1239. //
  1240. RefreshAppState();
  1241. }
  1242. return err;
  1243. }
  1244. /* virtual */
  1245. HRESULT
  1246. CW3DirectoryPage::SaveInfo()
  1247. /*++
  1248. Routine Description:
  1249. Save the information on this property page
  1250. Arguments:
  1251. None
  1252. Return Value:
  1253. Error return code
  1254. --*/
  1255. {
  1256. ASSERT(IsDirty());
  1257. TRACEEOLID("Saving W3 virtual directory page now...");
  1258. CError err;
  1259. SET_FLAG_IF(m_fBrowsingAllowed, m_dwDirBrowsing, MD_DIRBROW_ENABLED);
  1260. SET_FLAG_IF(m_fRead, m_dwAccessPerms, MD_ACCESS_READ);
  1261. SET_FLAG_IF(m_fWrite, m_dwAccessPerms, MD_ACCESS_WRITE);
  1262. SET_FLAG_IF(m_fAuthor, m_dwAccessPerms, MD_ACCESS_SOURCE);
  1263. SET_FLAG_IF(
  1264. (m_nPermissions == COMBO_EXECUTE),
  1265. m_dwAccessPerms,
  1266. MD_ACCESS_EXECUTE
  1267. );
  1268. //
  1269. // script is set on EXECUTE as well "Execute (including script)"
  1270. //
  1271. SET_FLAG_IF(((m_nPermissions == COMBO_SCRIPT) || (m_nPermissions == COMBO_EXECUTE)),
  1272. m_dwAccessPerms, MD_ACCESS_SCRIPT);
  1273. BOOL m_fDontLog = !m_fLogAccess;
  1274. BOOL fUNC = (m_nPathType == RADIO_NETDIRECTORY);
  1275. ASSERT(!fUNC || IsVroot());
  1276. DWORD dwAppProtection = GetAppStateFromComboSelection();
  1277. if (dwAppProtection != m_dwAppProtection && m_fAppEnabled)
  1278. {
  1279. //
  1280. // Isolation state has changed; recreate the application
  1281. //
  1282. CError err2(m_pApplication->RefreshAppState());
  1283. if (err2.Succeeded())
  1284. {
  1285. err2 = m_pApplication->Create(
  1286. m_strAppFriendlyName,
  1287. dwAppProtection
  1288. );
  1289. //
  1290. // Remember the new state, so we don't do this again
  1291. // the next time the guy hits "apply"
  1292. //
  1293. if (err2.Succeeded())
  1294. {
  1295. m_dwAppProtection = dwAppProtection;
  1296. }
  1297. }
  1298. err2.MessageBoxOnFailure();
  1299. }
  1300. BOOL fUserNameWritten = FALSE;
  1301. BeginWaitCursor();
  1302. BEGIN_META_DIR_WRITE(CW3Sheet)
  1303. INIT_DIR_DATA_MASK(m_dwAccessPerms, m_dwBitRangePermissions)
  1304. INIT_DIR_DATA_MASK(m_dwDirBrowsing, m_dwBitRangeDirBrowsing)
  1305. if (fUNC)
  1306. {
  1307. // Fix for 380353 -- sergeia
  1308. // When user want to change password only the above construction doesn't work
  1309. // because flag will be false -- user name is the same and not written!
  1310. // STORE_DIR_DATA_ON_SHEET_REMEMBER(m_strUserName, fUserNameWritten)
  1311. // if (fUserNameWritten)
  1312. // {
  1313. STORE_DIR_DATA_ON_SHEET(m_strUserName);
  1314. STORE_DIR_DATA_ON_SHEET(m_strPassword);
  1315. // }
  1316. // endoffix
  1317. }
  1318. else
  1319. {
  1320. if (m_fOriginallyUNC)
  1321. {
  1322. FLAG_DIR_DATA_FOR_DELETION(MD_VR_USERNAME)
  1323. FLAG_DIR_DATA_FOR_DELETION(MD_VR_PASSWORD)
  1324. }
  1325. }
  1326. STORE_DIR_DATA_ON_SHEET(m_strPath)
  1327. STORE_DIR_DATA_ON_SHEET(m_fDontLog)
  1328. STORE_DIR_DATA_ON_SHEET(m_fIndexed)
  1329. STORE_DIR_DATA_ON_SHEET(m_fChild);
  1330. STORE_DIR_DATA_ON_SHEET(m_fExact);
  1331. STORE_DIR_DATA_ON_SHEET(m_fPermanent);
  1332. //
  1333. // CODEWORK: Not an elegant solution
  1334. //
  1335. pSheet->GetDirectoryProperties().MarkRedirAsInherit(!m_fChild);
  1336. STORE_DIR_DATA_ON_SHEET(m_strRedirectPath)
  1337. STORE_DIR_DATA_ON_SHEET(m_dwAccessPerms)
  1338. STORE_DIR_DATA_ON_SHEET(m_dwDirBrowsing)
  1339. END_META_DIR_WRITE(err)
  1340. if (err.Succeeded() && m_pApplication->IsEnabledApplication())
  1341. {
  1342. err = m_pApplication->WriteFriendlyName(m_strAppFriendlyName);
  1343. }
  1344. if (err.Succeeded())
  1345. {
  1346. //
  1347. // Save Defaults
  1348. //
  1349. SaveAuthoringState();
  1350. }
  1351. EndWaitCursor();
  1352. return err;
  1353. }
  1354. BOOL
  1355. CW3DirectoryPage::CheckWriteAndExecWarning()
  1356. /*++
  1357. Routine Description:
  1358. Warn if both 'exec' and 'write' permissions are set.
  1359. Arguments:
  1360. None
  1361. Return Value:
  1362. TRUE to proceed anyway.
  1363. -*/
  1364. {
  1365. if (m_nPermissions == COMBO_EXECUTE && m_fWrite)
  1366. {
  1367. if (::AfxMessageBox(
  1368. IDS_WRN_WRITE_EXEC,
  1369. MB_YESNO | MB_DEFBUTTON2
  1370. ) != IDYES)
  1371. {
  1372. return FALSE;
  1373. }
  1374. }
  1375. OnItemChanged();
  1376. return TRUE;
  1377. }
  1378. void
  1379. CW3DirectoryPage::OnCheckRead()
  1380. /*++
  1381. Routine Description:
  1382. handle 'read' checkbox
  1383. Arguments:
  1384. None
  1385. Return Value:
  1386. None
  1387. --*/
  1388. {
  1389. m_fRead = !m_fRead;
  1390. SetAuthoringState(FALSE);
  1391. OnItemChanged();
  1392. }
  1393. void
  1394. CW3DirectoryPage::OnCheckWrite()
  1395. /*++
  1396. Routine Description:
  1397. handle 'write' checkbox
  1398. Arguments:
  1399. None
  1400. Return Value:
  1401. None
  1402. --*/
  1403. {
  1404. m_fWrite = !m_fWrite;
  1405. if (!CheckWriteAndExecWarning())
  1406. {
  1407. //
  1408. // Undo
  1409. //
  1410. m_fWrite = FALSE;
  1411. m_check_Write.SetCheck(m_fWrite);
  1412. }
  1413. else
  1414. {
  1415. SetAuthoringState(FALSE);
  1416. OnItemChanged();
  1417. }
  1418. }
  1419. void
  1420. CW3DirectoryPage::OnCheckAuthor()
  1421. /*++
  1422. Routine Description:
  1423. 'Author' checkbox handler
  1424. Arguments:
  1425. None
  1426. Return Value:
  1427. None
  1428. --*/
  1429. {
  1430. m_fAuthor = !m_fAuthor;
  1431. SetAuthoringState(TRUE);
  1432. if (!CheckWriteAndExecWarning())
  1433. {
  1434. //
  1435. // Undo -- set script instead
  1436. //
  1437. m_combo_Permissions.SetCurSel(m_nPermissions = COMBO_SCRIPT);
  1438. }
  1439. OnItemChanged();
  1440. }
  1441. void
  1442. CW3DirectoryPage::OnSelchangeComboPermissions()
  1443. /*++
  1444. Routine Description:
  1445. Permissions combo box selection change handler
  1446. Arguments:
  1447. None
  1448. Return Value:
  1449. None
  1450. --*/
  1451. {
  1452. m_nPermissions = m_combo_Permissions.GetCurSel();
  1453. ASSERT(m_nPermissions >= COMBO_NONE && m_nPermissions <= COMBO_EXECUTE);
  1454. if (!CheckWriteAndExecWarning())
  1455. {
  1456. //
  1457. // Undo -- set script instead
  1458. //
  1459. m_combo_Permissions.SetCurSel(m_nPermissions = COMBO_SCRIPT);
  1460. }
  1461. OnItemChanged();
  1462. }
  1463. void
  1464. CW3DirectoryPage::OnButtonConnectAs()
  1465. /*++
  1466. Routine Description:
  1467. Handle 'connect as' button.
  1468. Arguments:
  1469. None
  1470. Return Value:
  1471. None
  1472. --*/
  1473. {
  1474. BrowseUser();
  1475. }
  1476. void
  1477. CW3DirectoryPage::OnRadioDir()
  1478. /*++
  1479. Routine Description:
  1480. 'Directory' radio button handler
  1481. Arguments:
  1482. None
  1483. Return Value:
  1484. None
  1485. --*/
  1486. {
  1487. ChangeTypeTo(RADIO_DIRECTORY);
  1488. }
  1489. void
  1490. CW3DirectoryPage::OnRadioUnc()
  1491. /*++
  1492. Routine Description:
  1493. 'Network path' radio button handler
  1494. Arguments:
  1495. None
  1496. Return Value:
  1497. None
  1498. --*/
  1499. {
  1500. ChangeTypeTo(RADIO_NETDIRECTORY);
  1501. }
  1502. void
  1503. CW3DirectoryPage::OnRadioRedirect()
  1504. /*++
  1505. Routine Description:
  1506. 'Redirect' radio button handler
  1507. Arguments:
  1508. None
  1509. Return Value:
  1510. None
  1511. --*/
  1512. {
  1513. ChangeTypeTo(RADIO_REDIRECT);
  1514. }
  1515. void
  1516. CW3DirectoryPage::OnButtonCreateRemoveApp()
  1517. /*++
  1518. Routine Description:
  1519. Create/Remove button handler
  1520. Arguments:
  1521. None
  1522. Return Value:
  1523. None
  1524. --*/
  1525. {
  1526. BeginWaitCursor();
  1527. CError err(m_pApplication->RefreshAppState());
  1528. if (m_fAppEnabled)
  1529. {
  1530. //
  1531. // App currently exists -- delete it
  1532. //
  1533. err = m_pApplication->Delete();
  1534. }
  1535. else
  1536. {
  1537. //
  1538. // Create new app in-proc
  1539. //
  1540. CString strAppName;
  1541. if (m_fHome)
  1542. {
  1543. //
  1544. // Use default name for application name
  1545. //
  1546. VERIFY(strAppName.LoadString(IDS_DEF_APP));
  1547. }
  1548. else
  1549. {
  1550. //
  1551. // Use name of the virtual directory for the
  1552. // application name
  1553. //
  1554. strAppName = m_strAlias;
  1555. }
  1556. //
  1557. // Attempt to create a pooled-proc by default; failing
  1558. // that if it's not supported, create it in proc
  1559. //
  1560. DWORD dwAppProtState = m_pApplication->SupportsPooledProc()
  1561. ? CWamInterface::APP_POOLEDPROC
  1562. : CWamInterface::APP_INPROC;
  1563. err = m_pApplication->Create(strAppName, dwAppProtState);
  1564. }
  1565. if (err.Succeeded())
  1566. {
  1567. RefreshAppState();
  1568. NotifyMMC();
  1569. }
  1570. //
  1571. // Move app data to the controls
  1572. //
  1573. UpdateData(FALSE);
  1574. EndWaitCursor();
  1575. err.MessageBoxOnFailure();
  1576. SetApplicationState();
  1577. }
  1578. void
  1579. CW3DirectoryPage::OnButtonUnloadApp()
  1580. /*++
  1581. Routine Description:
  1582. 'Unload' button handler
  1583. Arguments:
  1584. None
  1585. Return Value:
  1586. None
  1587. --*/
  1588. {
  1589. ASSERT(m_dwAppState == APPSTATUS_RUNNING);
  1590. BeginWaitCursor();
  1591. CError err(m_pApplication->RefreshAppState());
  1592. if (err.Succeeded())
  1593. {
  1594. if (m_dwAppProtection == CWamInterface::APP_POOLEDPROC)
  1595. {
  1596. //
  1597. // Warn that everything in its process will get unloaded
  1598. //
  1599. if (!NoYesMessageBox(IDS_WRN_UNLOAD_POOP))
  1600. {
  1601. //
  1602. // Chickened out
  1603. //
  1604. return;
  1605. }
  1606. }
  1607. err = m_pApplication->Unload();
  1608. }
  1609. err.MessageBoxOnFailure();
  1610. RefreshAppState();
  1611. EndWaitCursor();
  1612. //
  1613. // Ensure that an enabled button will have focus.
  1614. //
  1615. m_button_CreateRemove.SetFocus();
  1616. SetApplicationState();
  1617. }
  1618. #include "..\AppConfig\AppConfig.h"
  1619. void
  1620. CW3DirectoryPage::OnButtonConfiguration()
  1621. /*++
  1622. Routine Description:
  1623. Pass on "configuration" button click to the ocx.
  1624. Arguments:
  1625. None
  1626. Return Value:
  1627. None
  1628. --*/
  1629. {
  1630. IIISAppConfig * pAppConfig = NULL;
  1631. CLSID clsID;
  1632. HRESULT hr;
  1633. if ( SUCCEEDED(hr = CLSIDFromProgID(OLESTR("AppConfig.IISAppConfig"), &clsID))
  1634. && SUCCEEDED(hr = ::CoCreateInstance(clsID,
  1635. NULL,
  1636. CLSCTX_ALL,
  1637. __uuidof(IIISAppConfig),
  1638. (void **)&pAppConfig)))
  1639. {
  1640. pAppConfig->put_ComputerName((LPTSTR)(LPCTSTR)GetServerName());
  1641. pAppConfig->put_MetaPath((LPTSTR)QueryMetaPath());
  1642. pAppConfig->put_UserName((LPTSTR)(LPCTSTR)m_strUserName);
  1643. pAppConfig->put_UserPassword((LPTSTR)(LPCTSTR)m_strPassword);
  1644. pAppConfig->Run();
  1645. }
  1646. }
  1647. void
  1648. CW3DirectoryPage::OnSelchangeComboProcess()
  1649. /*++
  1650. Routine Description:
  1651. Handle change in process protection UI
  1652. Arguments:
  1653. None
  1654. Return Value:
  1655. None
  1656. --*/
  1657. {
  1658. OnItemChanged();
  1659. }