Leaked source code of windows server 2003
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.

2353 lines
62 KiB

  1. /*++
  2. Copyright (c) 1994-2001 Microsoft Corporation
  3. Module Name :
  4. app_sheet.cpp
  5. Abstract:
  6. Application property sheet implementation
  7. Author:
  8. Sergei Antonov (sergeia)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #include "stdafx.h"
  14. #include "common.h"
  15. #include "resource.h"
  16. #include "inetmgrapp.h"
  17. #include "inetprop.h"
  18. #include "shts.h"
  19. #include "w3sht.h"
  20. #include "app_sheet.h"
  21. #include <algorithm>
  22. // Defaults and ranges for properties
  23. #define SESSION_TIMEOUT_MIN 1
  24. #define SESSION_TIMEOUT_MAX 2000000000
  25. #define SCRIPT_TIMEOUT_MIN 1
  26. #define SCRIPT_TIMEOUT_MAX 2000000000
  27. #define SCRIPT_ENG_MIN 0
  28. #define SCRIPT_ENG_MAX 2000000000
  29. #define WINHELP_NUMBER_BASE 0x20000
  30. extern CInetmgrApp theApp;
  31. HRESULT
  32. AppConfigSheet(CIISMBNode * pNode,CIISMBNode * pNodeParent, LPCTSTR metapath, CWnd * pParent)
  33. {
  34. if (pNode == NULL)
  35. {
  36. return E_POINTER;
  37. }
  38. CError err;
  39. do
  40. {
  41. CAppPropSheet * pSheet = new CAppPropSheet(
  42. pNode->QueryAuthInfo(),
  43. metapath,
  44. pParent,
  45. (LPARAM)pNode,
  46. (LPARAM)pNodeParent,
  47. NULL
  48. );
  49. CString caption;
  50. caption.LoadString(IDS_APPSHEET_TITLE);
  51. pSheet->SetTitle(caption);
  52. // Hide Apply button for modal dialog
  53. pSheet->m_psh.dwFlags |= PSH_NOAPPLYNOW;
  54. BOOL fCompatMode = FALSE;
  55. BOOL bShowCache = FALSE;
  56. if (pSheet->QueryMajorVersion() >= 6)
  57. {
  58. CError err;
  59. CString svc, inst;
  60. CMetabasePath::GetServicePath(metapath, svc, NULL);
  61. CMetaKey mk(pSheet->QueryAuthInfo(), svc, METADATA_PERMISSION_READ);
  62. err = mk.QueryResult();
  63. if (err.Succeeded())
  64. {
  65. err = mk.QueryValue(MD_GLOBAL_STANDARD_APP_MODE_ENABLED, fCompatMode);
  66. }
  67. }
  68. else
  69. {
  70. fCompatMode = TRUE;
  71. }
  72. if (fCompatMode)
  73. {
  74. if (CMetabasePath::IsMasterInstance(metapath))
  75. {
  76. bShowCache = TRUE;
  77. }
  78. else
  79. {
  80. CMetaKey mk(pSheet->QueryAuthInfo(), metapath, METADATA_PERMISSION_READ);
  81. err = mk.QueryResult();
  82. DWORD isol = 0;
  83. if (err.Succeeded())
  84. {
  85. err = mk.QueryValue(MD_APP_ISOLATED, isol);
  86. }
  87. bShowCache = isol == eAppRunOutProcIsolated;
  88. }
  89. }
  90. else
  91. {
  92. bShowCache = CMetabasePath::IsMasterInstance(metapath);
  93. }
  94. CPropertyPage * pPage;
  95. if (pSheet->QueryMajorVersion() < 6)
  96. {
  97. pPage = new CAppMappingPage_iis5(pSheet);
  98. }
  99. else
  100. {
  101. pPage = new CAppMappingPage(pSheet);
  102. }
  103. if (pPage == NULL)
  104. {
  105. err = ERROR_NOT_ENOUGH_MEMORY;
  106. break;
  107. }
  108. pSheet->AddPage(pPage);
  109. pPage = new CAspMainPage(pSheet);
  110. if (pPage == NULL)
  111. {
  112. err = ERROR_NOT_ENOUGH_MEMORY;
  113. break;
  114. }
  115. pSheet->AddPage(pPage);
  116. pPage = new CAspDebug(pSheet);
  117. if (pPage == NULL)
  118. {
  119. err = ERROR_NOT_ENOUGH_MEMORY;
  120. break;
  121. }
  122. pSheet->AddPage(pPage);
  123. if (bShowCache)
  124. {
  125. if (pSheet->QueryMajorVersion() == 5 && pSheet->QueryMinorVersion() == 0)
  126. {
  127. pPage = new CAppCache_iis5(pSheet);
  128. }
  129. else
  130. {
  131. pPage = new CAppCache(pSheet);
  132. }
  133. if (pPage == NULL)
  134. {
  135. err = ERROR_NOT_ENOUGH_MEMORY;
  136. break;
  137. }
  138. pSheet->AddPage(pPage);
  139. }
  140. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  141. err = pSheet->DoModal() == IDOK ? S_OK : S_FALSE;
  142. // pSheet->Release();
  143. } while (FALSE);
  144. return err;
  145. }
  146. _Mapping::_Mapping(const CString& buf)
  147. {
  148. int len = buf.GetLength();
  149. int pos = buf.Find(_T(','));
  150. ASSERT(pos != -1);
  151. ext = buf.Left(pos);
  152. int pos1 = buf.Find(_T(','), ++pos);
  153. ASSERT(pos1 != -1);
  154. path = buf.Mid(pos, pos1 - pos);
  155. pos = pos1;
  156. pos1 = buf.Find(_T(','), ++pos);
  157. if (pos1 == -1)
  158. {
  159. flags = StrToInt(buf.Right(len - pos));
  160. }
  161. else
  162. {
  163. flags = StrToInt(buf.Mid(pos, pos1 - pos));
  164. verbs = buf.Right(len - pos1 - 1);
  165. }
  166. }
  167. LPCTSTR
  168. _Mapping::ToString(CString& buf) const
  169. {
  170. TCHAR num[12];
  171. buf = ext;
  172. buf += _T(",");
  173. buf += path;
  174. buf += _T(",");
  175. wsprintf(num, _T("%u"), flags);
  176. buf += num;
  177. if (!verbs.IsEmpty())
  178. {
  179. buf += _T(",");
  180. buf += verbs;
  181. }
  182. return buf;
  183. }
  184. void
  185. CApplicationProps::LoadInitialMappings(CStringListEx& list)
  186. {
  187. m_initData.assign(list.GetCount(), CString(_T("")));
  188. CString buf;
  189. POSITION p = list.GetHeadPosition();
  190. while (p != NULL)
  191. {
  192. buf = list.GetNext(p);
  193. m_initData.push_back(buf);
  194. }
  195. }
  196. inline bool eq_nocase(CString& str1, CString& str2)
  197. {
  198. return str1.CompareNoCase(str2) == 0;
  199. }
  200. struct less_nocase : public std::less<CString>
  201. {
  202. bool operator()(const CString& str1, const CString& str2) const
  203. {
  204. return StrCmpI(str1, str2) < 0;
  205. }
  206. };
  207. BOOL
  208. CApplicationProps::InitialDataChanged(CStringListEx& list)
  209. {
  210. std::vector<CString> newData;
  211. newData.assign(list.GetCount(), CString(_T("")));
  212. POSITION pos = list.GetHeadPosition();
  213. while (pos != NULL)
  214. {
  215. CString data = list.GetNext(pos);
  216. newData.push_back(data);
  217. }
  218. std::sort(m_initData.begin(), m_initData.end(), less_nocase());
  219. std::sort(newData.begin(), newData.end(), less_nocase());
  220. return !std::equal(newData.begin(), newData.end(), m_initData.begin(), eq_nocase);
  221. }
  222. CApplicationProps::CApplicationProps(
  223. CComAuthInfo * pAuthInfo, LPCTSTR meta_path, BOOL fInherit
  224. )
  225. : CMetaProperties(pAuthInfo, meta_path)
  226. {
  227. m_fInherit = fInherit;
  228. }
  229. CApplicationProps::CApplicationProps(
  230. CMetaInterface * pInterface, LPCTSTR meta_path, BOOL fInherit
  231. )
  232. : CMetaProperties(pInterface, meta_path)
  233. {
  234. m_fInherit = fInherit;
  235. }
  236. CApplicationProps::CApplicationProps(
  237. CMetaKey * pKey, LPCTSTR meta_path, BOOL fInherit
  238. )
  239. : CMetaProperties(pKey, meta_path)
  240. {
  241. m_fInherit = fInherit;
  242. }
  243. #define CACHE_SIZE_UNDEFINED 0xfffffffe
  244. void
  245. CApplicationProps::ParseFields()
  246. {
  247. HRESULT hr = S_OK;
  248. MP_DWORD asp_scriptfilecachesize = CACHE_SIZE_UNDEFINED;
  249. m_AspMaxDiskTemplateCacheFiles = 0;
  250. BEGIN_PARSE_META_RECORDS(m_dwNumEntries, m_pbMDData)
  251. HANDLE_META_RECORD(MD_APP_ISOLATED, m_AppIsolated)
  252. HANDLE_META_RECORD(MD_ASP_ALLOWSESSIONSTATE, m_EnableSession)
  253. HANDLE_META_RECORD(MD_ASP_BUFFERINGON, m_EnableBuffering)
  254. HANDLE_META_RECORD(MD_ASP_ENABLEPARENTPATHS, m_EnableParents)
  255. HANDLE_META_RECORD(MD_ASP_SESSIONTIMEOUT, m_SessionTimeout)
  256. HANDLE_META_RECORD(MD_ASP_SCRIPTTIMEOUT, m_ScriptTimeout)
  257. HANDLE_META_RECORD(MD_ASP_SCRIPTLANGUAGE, m_Languages)
  258. HANDLE_META_RECORD(MD_ASP_SERVICE_FLAGS, m_AspServiceFlag)
  259. HANDLE_META_RECORD(MD_ASP_SERVICE_SXS_NAME, m_AspSxsName)
  260. HANDLE_META_RECORD(MD_CACHE_EXTENSIONS, m_CacheISAPI)
  261. HANDLE_INHERITED_META_RECORD(MD_SCRIPT_MAPS, m_strlMappings, m_fMappingsInherited)
  262. HANDLE_META_RECORD(MD_ASP_ENABLESERVERDEBUG, m_ServerDebug)
  263. HANDLE_META_RECORD(MD_ASP_ENABLECLIENTDEBUG, m_ClientDebug)
  264. HANDLE_META_RECORD(MD_ASP_SCRIPTERRORSSENTTOBROWSER, m_SendAspError)
  265. HANDLE_META_RECORD(MD_ASP_SCRIPTERRORMESSAGE, m_DefaultError)
  266. HANDLE_META_RECORD(MD_ASP_SCRIPTENGINECACHEMAX, m_ScriptEngCacheMax)
  267. HANDLE_META_RECORD(MD_ASP_SCRIPTFILECACHESIZE, asp_scriptfilecachesize)
  268. HANDLE_META_RECORD(MD_ASP_DISKTEMPLATECACHEDIRECTORY, m_DiskCacheDir)
  269. HANDLE_META_RECORD(MD_ASP_MAXDISKTEMPLATECACHEFILES, m_AspMaxDiskTemplateCacheFiles)
  270. END_PARSE_META_RECORDS
  271. LoadVersion();
  272. LoadInitialMappings(MP_V(m_strlMappings));
  273. do
  274. {
  275. m_NoCache = m_UnlimCache = m_LimCache = FALSE;
  276. if (MajorVersion() == 5 && MinorVersion() == 0)
  277. {
  278. m_AspScriptFileCacheSize = asp_scriptfilecachesize == CACHE_SIZE_UNDEFINED ?
  279. 0 : asp_scriptfilecachesize;
  280. if (m_AspScriptFileCacheSize == 0)
  281. {
  282. m_NoCache = TRUE;
  283. }
  284. else if (m_AspScriptFileCacheSize == 0xFFFFFFFF)
  285. {
  286. m_UnlimCache = TRUE;
  287. }
  288. else
  289. {
  290. m_LimCache = TRUE;
  291. }
  292. }
  293. else
  294. {
  295. if (MP_V(m_DiskCacheDir).IsEmpty())
  296. {
  297. m_DiskCacheDir = _T("%windir%\\system32\\inetsrv\\ASP Compiled Templates");
  298. }
  299. m_AspScriptFileCacheSize = asp_scriptfilecachesize;
  300. m_LimCacheMemSize = 120;
  301. m_LimCacheDiskSize = 1000;
  302. if (m_AspMaxDiskTemplateCacheFiles == 0
  303. && m_AspScriptFileCacheSize == 0)
  304. {
  305. m_NoCache = TRUE;
  306. }
  307. else if (m_AspScriptFileCacheSize == -1)
  308. {
  309. m_UnlimCache = TRUE;
  310. }
  311. else if (m_AspMaxDiskTemplateCacheFiles == -1)
  312. {
  313. m_LimCache = TRUE;
  314. m_LimDiskCache = FALSE;
  315. m_LimCacheMemSize = m_AspScriptFileCacheSize;
  316. }
  317. else
  318. {
  319. m_LimCache = TRUE;
  320. m_LimDiskCache = TRUE;
  321. m_LimCacheMemSize = m_AspScriptFileCacheSize;
  322. m_LimCacheDiskSize = m_AspMaxDiskTemplateCacheFiles;
  323. }
  324. }
  325. } while (FALSE);
  326. }
  327. HRESULT
  328. CApplicationProps::WriteDirtyProps()
  329. {
  330. CError err;
  331. BEGIN_META_WRITE()
  332. META_WRITE(MD_ASP_ALLOWSESSIONSTATE, m_EnableSession)
  333. META_WRITE(MD_ASP_BUFFERINGON, m_EnableBuffering)
  334. META_WRITE(MD_ASP_ENABLEPARENTPATHS, m_EnableParents)
  335. META_WRITE(MD_ASP_SESSIONTIMEOUT, m_SessionTimeout)
  336. META_WRITE(MD_ASP_SCRIPTTIMEOUT, m_ScriptTimeout)
  337. META_WRITE(MD_ASP_SCRIPTLANGUAGE, m_Languages)
  338. META_WRITE(MD_ASP_ENABLESERVERDEBUG, m_ServerDebug)
  339. META_WRITE(MD_ASP_ENABLECLIENTDEBUG, m_ClientDebug)
  340. META_WRITE(MD_ASP_SCRIPTERRORSSENTTOBROWSER, m_SendAspError)
  341. META_WRITE(MD_ASP_SCRIPTERRORMESSAGE, m_DefaultError)
  342. META_WRITE(MD_CACHE_EXTENSIONS, m_CacheISAPI)
  343. META_WRITE(MD_ASP_SCRIPTENGINECACHEMAX, m_ScriptEngCacheMax)
  344. if (MajorVersion() == 5 && MinorVersion() == 0)
  345. {
  346. if (m_NoCache)
  347. {
  348. m_AspScriptFileCacheSize = 0;
  349. }
  350. else if (m_UnlimCache)
  351. {
  352. m_AspScriptFileCacheSize = -1;
  353. }
  354. META_WRITE(MD_ASP_SCRIPTFILECACHESIZE, m_AspScriptFileCacheSize)
  355. }
  356. else
  357. {
  358. META_WRITE(MD_ASP_DISKTEMPLATECACHEDIRECTORY, m_DiskCacheDir)
  359. if (m_NoCache)
  360. {
  361. m_AspScriptFileCacheSize = 0;
  362. m_AspMaxDiskTemplateCacheFiles = 0;
  363. }
  364. else if (m_UnlimCache)
  365. {
  366. m_AspScriptFileCacheSize = -1;
  367. }
  368. else if (m_LimCache)
  369. {
  370. m_AspScriptFileCacheSize = m_LimCacheMemSize;
  371. if (m_LimDiskCache)
  372. {
  373. m_AspMaxDiskTemplateCacheFiles = m_LimCacheDiskSize;
  374. }
  375. else
  376. {
  377. m_AspMaxDiskTemplateCacheFiles = -1;
  378. }
  379. }
  380. else
  381. {
  382. ASSERT(FALSE);
  383. }
  384. META_WRITE(MD_ASP_MAXDISKTEMPLATECACHEFILES, m_AspMaxDiskTemplateCacheFiles)
  385. META_WRITE(MD_ASP_SCRIPTFILECACHESIZE, m_AspScriptFileCacheSize)
  386. }
  387. if (MajorVersion() >= 6)
  388. {
  389. META_WRITE(MD_ASP_SERVICE_FLAGS, m_AspServiceFlag)
  390. META_WRITE(MD_ASP_SERVICE_SXS_NAME, m_AspSxsName)
  391. }
  392. // Process mappings
  393. if (MP_V(m_strlMappings).IsEmpty())
  394. {
  395. // User must be wants to inherit scriptmaps from the parent
  396. if (!m_fMappingsInherited)
  397. {
  398. FlagPropertyForDeletion(MD_SCRIPT_MAPS);
  399. }
  400. }
  401. else if ( MP_V(m_strlMappings).GetCount() != m_initData.size()
  402. || InitialDataChanged(MP_V(m_strlMappings))
  403. )
  404. {
  405. META_WRITE(MD_SCRIPT_MAPS, m_strlMappings)
  406. m_fMappingsInherited = FALSE;
  407. }
  408. END_META_WRITE(err);
  409. m_Dirty = err.Succeeded();
  410. return err;
  411. }
  412. HRESULT
  413. CApplicationProps::LoadVersion()
  414. {
  415. CString info;
  416. CMetabasePath::GetServiceInfoPath(_T(""), info);
  417. CServerCapabilities sc(this, info);
  418. HRESULT hr = sc.LoadData();
  419. if (SUCCEEDED(hr))
  420. {
  421. DWORD dwVersion = sc.QueryMajorVersion();
  422. if (dwVersion)
  423. {
  424. m_dwVersion = dwVersion | (sc.QueryMinorVersion() << SIZE_IN_BITS(WORD));
  425. }
  426. }
  427. return hr;
  428. }
  429. /////////////////////////////////////////////////////////////////////////////////////////////////////
  430. IMPLEMENT_DYNAMIC(CAppPropSheet, CInetPropertySheet)
  431. CAppPropSheet::CAppPropSheet(
  432. CComAuthInfo * pAuthInfo,
  433. LPCTSTR lpszMetaPath,
  434. CWnd * pParentWnd,
  435. LPARAM lParam,
  436. LPARAM lParamParent,
  437. UINT iSelectPage
  438. )
  439. : CInetPropertySheet(
  440. pAuthInfo, lpszMetaPath, pParentWnd, lParam, lParamParent, iSelectPage),
  441. m_pprops(NULL)
  442. {
  443. }
  444. CAppPropSheet::~CAppPropSheet()
  445. {
  446. FreeConfigurationParameters();
  447. }
  448. HRESULT
  449. CAppPropSheet::LoadConfigurationParameters()
  450. {
  451. //
  452. // Load base properties
  453. //
  454. CError err;
  455. if (m_pprops == NULL)
  456. {
  457. //
  458. // First call -- load values
  459. //
  460. m_pprops = new CApplicationProps(QueryAuthInfo(), QueryMetaPath());
  461. if (!m_pprops)
  462. {
  463. TRACEEOLID("LoadConfigurationParameters: OOM");
  464. err = ERROR_NOT_ENOUGH_MEMORY;
  465. return err;
  466. }
  467. err = m_pprops->LoadData();
  468. }
  469. return err;
  470. }
  471. void
  472. CAppPropSheet::FreeConfigurationParameters()
  473. {
  474. CInetPropertySheet::FreeConfigurationParameters();
  475. delete m_pprops;
  476. }
  477. BEGIN_MESSAGE_MAP(CAppPropSheet, CInetPropertySheet)
  478. //{{AFX_MSG_MAP(CAppPoolSheet)
  479. //}}AFX_MSG_MAP
  480. END_MESSAGE_MAP()
  481. /////////////////////////////////////////////////////////////////
  482. IMPLEMENT_DYNCREATE(CAspMainPage, CInetPropertyPage)
  483. CAspMainPage::CAspMainPage(CInetPropertySheet * pSheet)
  484. : CInetPropertyPage(CAspMainPage::IDD, pSheet)
  485. {
  486. #if 0
  487. // hack to have new struct size with old MFC and new NT 5.0 headers
  488. ZeroMemory(&m_psp_ex, sizeof(PROPSHEETPAGE));
  489. memcpy(&m_psp_ex, &m_psp, m_psp.dwSize);
  490. m_psp_ex.dwSize = sizeof(PROPSHEETPAGE);
  491. #endif
  492. }
  493. CAspMainPage::~CAspMainPage()
  494. {
  495. m_AspEnableSxs = FALSE;
  496. }
  497. /* virtual */
  498. HRESULT
  499. CAspMainPage::FetchLoadedValues()
  500. {
  501. CError err;
  502. BEGIN_META_INST_READ(CAppPropSheet)
  503. FETCH_INST_DATA_FROM_SHEET(m_EnableSession);
  504. FETCH_INST_DATA_FROM_SHEET(m_EnableBuffering);
  505. FETCH_INST_DATA_FROM_SHEET(m_EnableParents);
  506. FETCH_INST_DATA_FROM_SHEET(m_SessionTimeout);
  507. FETCH_INST_DATA_FROM_SHEET(m_ScriptTimeout);
  508. FETCH_INST_DATA_FROM_SHEET(m_Languages);
  509. FETCH_INST_DATA_FROM_SHEET(m_AspServiceFlag);
  510. FETCH_INST_DATA_FROM_SHEET(m_AspSxsName);
  511. END_META_INST_READ(err)
  512. if (GetSheet()->QueryMajorVersion() >= 6)
  513. {
  514. m_AspEnableSxs = 0 != (m_AspServiceFlag & 2);
  515. }
  516. return err;
  517. }
  518. /* virtual */
  519. HRESULT
  520. CAspMainPage::SaveInfo()
  521. {
  522. ASSERT(IsDirty());
  523. CError err;
  524. if (m_AspEnableSxs)
  525. m_AspServiceFlag |= 2;
  526. else
  527. m_AspServiceFlag &= ~2;
  528. BEGIN_META_INST_WRITE(CAppPropSheet)
  529. STORE_INST_DATA_ON_SHEET(m_EnableSession)
  530. STORE_INST_DATA_ON_SHEET(m_EnableBuffering)
  531. STORE_INST_DATA_ON_SHEET(m_EnableParents)
  532. STORE_INST_DATA_ON_SHEET(m_SessionTimeout)
  533. STORE_INST_DATA_ON_SHEET(m_ScriptTimeout)
  534. STORE_INST_DATA_ON_SHEET(m_Languages)
  535. if (GetSheet()->QueryMajorVersion() >= 6)
  536. {
  537. STORE_INST_DATA_ON_SHEET(m_AspServiceFlag)
  538. STORE_INST_DATA_ON_SHEET(m_AspSxsName)
  539. }
  540. END_META_INST_WRITE(err)
  541. return err;
  542. }
  543. void
  544. CAspMainPage::DoDataExchange(CDataExchange * pDX)
  545. {
  546. CInetPropertyPage::DoDataExchange(pDX);
  547. //{{AFX_DATA_MAP(CAspMainPage)
  548. DDX_Check(pDX, IDC_ENABLE_SESSION, m_EnableSession);
  549. DDX_Check(pDX, IDC_ENABLE_BUFFERING, m_EnableBuffering);
  550. DDX_Check(pDX, IDC_ENABLE_PARENTS, m_EnableParents);
  551. // This Needs to come before DDX_Text which will try to put text big number into small number
  552. DDV_MinMaxBalloon(pDX, IDC_SESSION_TIMEOUT, SESSION_TIMEOUT_MIN, SESSION_TIMEOUT_MAX);
  553. DDX_TextBalloon(pDX, IDC_SESSION_TIMEOUT, m_SessionTimeout);
  554. // This Needs to come before DDX_Text which will try to put text big number into small number
  555. DDV_MinMaxBalloon(pDX, IDC_SCRIPT_TIMEOUT, SCRIPT_TIMEOUT_MIN, SCRIPT_TIMEOUT_MAX);
  556. DDX_TextBalloon(pDX, IDC_SCRIPT_TIMEOUT, m_ScriptTimeout);
  557. DDX_Text(pDX, IDC_LANGUAGES, m_Languages);
  558. DDX_Check(pDX, IDC_ENABLE_SXS, m_AspEnableSxs);
  559. DDX_Control(pDX, IDC_LANGUAGES, m_LanguagesCtrl);
  560. //}}AFX_DATA_MAP
  561. DDX_Text(pDX, IDC_MANIFEST, m_AspSxsName);
  562. if (pDX->m_bSaveAndValidate)
  563. {
  564. if (m_AspEnableSxs)
  565. {
  566. DDV_MinMaxChars(pDX, m_AspSxsName, 0, MAX_PATH);
  567. if ( !PathIsValid(m_AspSxsName,FALSE)
  568. || !PathIsFileSpec(m_AspSxsName)
  569. || m_AspSxsName.FindOneOf(_T(" *?/\\<>:|\"")) != -1
  570. )
  571. {
  572. DDV_ShowBalloonAndFail(pDX, IDS_INVALID_MANIFEST_NAME);
  573. }
  574. }
  575. }
  576. }
  577. //////////////////////////////////////////////////////
  578. BEGIN_MESSAGE_MAP(CAspMainPage, CInetPropertyPage)
  579. //{{AFX_MSG_MAP(CAspMainPage)
  580. ON_BN_CLICKED(IDC_ENABLE_SESSION, OnItemChanged)
  581. ON_BN_CLICKED(IDC_ENABLE_SXS, OnSxs)
  582. //}}AFX_MSG_MAP
  583. END_MESSAGE_MAP()
  584. BOOL
  585. CAspMainPage::OnInitDialog()
  586. {
  587. UDACCEL toAcc[3] = {{1, 1}, {3, 5}, {6, 10}};
  588. CInetPropertyPage::OnInitDialog();
  589. ASSERT(NULL != GetDlgItem(IDC_TIMEOUT_SPIN));
  590. SendDlgItemMessage(IDC_TIMEOUT_SPIN,UDM_SETRANGE32, SESSION_TIMEOUT_MIN, SESSION_TIMEOUT_MAX);
  591. SendDlgItemMessage(IDC_TIMEOUT_SPIN, UDM_SETPOS32, 0, m_SessionTimeout);
  592. SendDlgItemMessage(IDC_TIMEOUT_SPIN, UDM_SETACCEL, 3, (LPARAM)toAcc);
  593. ASSERT(NULL != GetDlgItem(IDC_ASPTIMEOUT_SPIN));
  594. SendDlgItemMessage(IDC_ASPTIMEOUT_SPIN, UDM_SETRANGE32, SCRIPT_TIMEOUT_MIN, SCRIPT_TIMEOUT_MAX);
  595. SendDlgItemMessage(IDC_ASPTIMEOUT_SPIN, UDM_SETPOS32, 0, m_ScriptTimeout);
  596. SendDlgItemMessage(IDC_ASPTIMEOUT_SPIN, UDM_SETACCEL, 3, (LPARAM)toAcc);
  597. GetDlgItem(IDC_ENABLE_SXS)->EnableWindow(GetSheet()->QueryMajorVersion() >= 6);
  598. SetControlsState();
  599. OnItemChanged();
  600. return FALSE;
  601. }
  602. void
  603. CAspMainPage::OnItemChanged()
  604. {
  605. BOOL bEnable = SendDlgItemMessage(IDC_ENABLE_SESSION, BM_GETCHECK, 0, 0);
  606. ::EnableWindow(CONTROL_HWND(IDC_SESSION_TIMEOUT), bEnable);
  607. ::EnableWindow(CONTROL_HWND(IDC_TIMEOUT_SPIN), bEnable);
  608. SetModified(TRUE);
  609. }
  610. void
  611. CAspMainPage::OnSxs()
  612. {
  613. m_AspEnableSxs = !m_AspEnableSxs;
  614. SetControlsState();
  615. SetModified(TRUE);
  616. }
  617. void
  618. CAspMainPage::SetControlsState()
  619. {
  620. GetDlgItem(IDC_MANIFEST_STATIC)->EnableWindow(m_AspEnableSxs);
  621. GetDlgItem(IDC_MANIFEST)->EnableWindow(m_AspEnableSxs);
  622. }
  623. /////////////////////////////////////////////////////////////////////////////
  624. #define EXT_WIDTH 58
  625. #define PATH_WIDTH 204
  626. #define EXCLUSIONS_WIDTH 72
  627. static int CALLBACK SortCallback(LPARAM lp1, LPARAM lp2, LPARAM parSort)
  628. {
  629. Mapping * pm1 = (Mapping *)lp1;
  630. ATLASSERT(pm1 != NULL);
  631. Mapping * pm2 = (Mapping *)lp2;
  632. ATLASSERT(pm2 != NULL);
  633. short order = (short)HIWORD(parSort) > 0 ? 1 : -1;
  634. int col = (int)LOWORD(parSort);
  635. int res = 0;
  636. switch (col)
  637. {
  638. case 0:
  639. res = pm1->ext.CompareNoCase(pm2->ext);
  640. break;
  641. case 1:
  642. res = pm1->path.CompareNoCase(pm2->path);
  643. break;
  644. case 2:
  645. res = pm1->verbs.CompareNoCase(pm2->verbs);
  646. break;
  647. }
  648. return order * res;
  649. }
  650. BOOL SortMappings(CListCtrl& list, int col, int order)
  651. {
  652. return list.SortItems(SortCallback, MAKELPARAM((WORD)col, (WORD)order));
  653. }
  654. CAppMappingPageBase::CAppMappingPageBase(DWORD id, CInetPropertySheet * pSheet)
  655. : CInetPropertyPage(id, pSheet)
  656. {
  657. }
  658. CAppMappingPageBase::~CAppMappingPageBase()
  659. {
  660. }
  661. HRESULT
  662. CAppMappingPageBase::FetchLoadedValues()
  663. {
  664. CError err;
  665. BEGIN_META_INST_READ(CAppPropSheet)
  666. FETCH_INST_DATA_FROM_SHEET(m_CacheISAPI);
  667. FETCH_INST_DATA_FROM_SHEET(m_strlMappings);
  668. END_META_INST_READ(err)
  669. return err;
  670. }
  671. HRESULT
  672. CAppMappingPageBase::SaveInfo()
  673. {
  674. ASSERT(IsDirty());
  675. CError err;
  676. BEGIN_META_INST_WRITE(CAppPropSheet)
  677. STORE_INST_DATA_ON_SHEET(m_CacheISAPI)
  678. STORE_INST_DATA_ON_SHEET(m_strlMappings)
  679. END_META_INST_WRITE(err)
  680. return err;
  681. }
  682. void
  683. CAppMappingPageBase::RemoveSelected(CListCtrl& lst)
  684. {
  685. int sel = -1;
  686. int count = lst.GetItemCount();
  687. for (int i = 0; i < count;)
  688. {
  689. // We are scanning list looking for selected item, when found we are deleting it,
  690. // decrementing count and do not advance index, because now index points
  691. // to next item. It should work for any combination of selections in
  692. // multiselection list
  693. UINT state = lst.GetItemState(i, LVIS_SELECTED);
  694. if ((state & LVIS_SELECTED) != 0)
  695. {
  696. Mapping * p = (Mapping *)lst.GetItemData(i);
  697. delete p;
  698. if (sel == -1)
  699. {
  700. sel = i;
  701. }
  702. lst.DeleteItem(i);
  703. count--;
  704. continue;
  705. }
  706. i++;
  707. }
  708. count = lst.GetItemCount();
  709. if (sel == count)
  710. {
  711. sel--;
  712. }
  713. lst.SetItemState(sel, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  714. }
  715. void
  716. CAppMappingPageBase::SetControlsState()
  717. {
  718. int sel_count = m_list.GetSelectedCount();
  719. ::EnableWindow(CONTROL_HWND(IDC_EDIT), sel_count == 1);
  720. ::EnableWindow(CONTROL_HWND(IDC_REMOVE), sel_count > 0);
  721. }
  722. void
  723. CAppMappingPageBase::DoDataExchange(CDataExchange * pDX)
  724. {
  725. CInetPropertyPage::DoDataExchange(pDX);
  726. //{{AFX_DATA_MAP(CAppMappingPageBase)
  727. DDX_Check(pDX, IDC_CACHE_ISAPI, m_CacheISAPI);
  728. DDX_Control(pDX, IDC_LIST, m_list);
  729. //}}AFX_DATA_MAP
  730. if (pDX->m_bSaveAndValidate)
  731. {
  732. int count = m_list.GetItemCount();
  733. m_strlMappings.RemoveAll();
  734. for (int i = 0; i < count; i++)
  735. {
  736. Mapping * p = (Mapping *)m_list.GetItemData(i);
  737. CString buf;
  738. p->ToString(buf);
  739. m_strlMappings.AddTail(buf);
  740. }
  741. }
  742. }
  743. BEGIN_MESSAGE_MAP(CAppMappingPageBase, CInetPropertyPage)
  744. //{{AFX_MSG_MAP(CAppMappingPageBase)
  745. ON_BN_CLICKED(IDC_ADD, OnAdd)
  746. ON_BN_CLICKED(IDC_EDIT, OnEdit)
  747. ON_BN_CLICKED(IDC_REMOVE, OnRemove)
  748. ON_BN_CLICKED(IDC_CACHE_ISAPI, OnDlgItemChanged)
  749. //}}AFX_MSG_MAP
  750. END_MESSAGE_MAP()
  751. BOOL
  752. CAppMappingPageBase::OnInitDialog()
  753. {
  754. CInetPropertyPage::OnInitDialog();
  755. DWORD dwStyle = m_list.GetExtendedStyle();
  756. m_list.SetExtendedStyle(
  757. dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_LABELTIP);
  758. CString str;
  759. str.LoadString(IDS_EXTENSION);
  760. m_list.InsertColumn(COL_EXTENSION, str, LVCFMT_LEFT, EXT_WIDTH, 0);
  761. str.LoadString(IDS_EXECUTABLE_PATH);
  762. m_list.InsertColumn(COL_PATH, str, LVCFMT_LEFT, PATH_WIDTH, 1);
  763. str.LoadString(IDS_VERBS);
  764. m_list.InsertColumn(COL_EXCLUSIONS, str, LVCFMT_LEFT, EXCLUSIONS_WIDTH, 2);
  765. CString all_verbs;
  766. all_verbs.LoadString(IDS_ALL);
  767. POSITION pos = m_strlMappings.GetHeadPosition();
  768. int idx = 0;
  769. while (pos != NULL)
  770. {
  771. str = m_strlMappings.GetNext(pos);
  772. Mapping * p = new Mapping(str);
  773. if (p == NULL)
  774. break;
  775. if (StrCmp(p->ext, _T("*")) != 0 || GetSheet()->QueryMajorVersion() < 6)
  776. {
  777. VERIFY(-1 != m_list.InsertItem(idx, p->ext));
  778. VERIFY(m_list.SetItemData(idx, (LPARAM)p));
  779. VERIFY(m_list.SetItemText(idx, COL_PATH, p->path));
  780. VERIFY(m_list.SetItemText(idx, COL_EXCLUSIONS,
  781. p->verbs.IsEmpty() ? all_verbs : p->verbs));
  782. idx++;
  783. }
  784. else
  785. {
  786. delete p;
  787. }
  788. }
  789. CString remainder;
  790. CMetabasePath::GetRootPath(QueryMetaPath(), str, &remainder);
  791. ::EnableWindow(CONTROL_HWND(IDC_CACHE_ISAPI), remainder.IsEmpty());
  792. int count = m_list.GetItemCount();
  793. m_sortCol = 0;
  794. m_sortOrder = 1;
  795. if (count > 0)
  796. {
  797. SortMappings(m_list, m_sortCol, m_sortOrder);
  798. m_list.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  799. }
  800. SetControlsState();
  801. return FALSE;
  802. }
  803. BOOL
  804. CAppMappingPageBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  805. {
  806. ASSERT(pResult != NULL);
  807. NMHDR* pNMHDR = (NMHDR*)lParam;
  808. // We are looking only for events from the listview control here.
  809. // This is the only way to catch notification, MFC screens
  810. // all this stuff out.
  811. if (pNMHDR->idFrom == IDC_LIST)
  812. {
  813. BOOL processed = FALSE;
  814. switch (pNMHDR->code)
  815. {
  816. case NM_DBLCLK:
  817. processed = OnDblClickList(pNMHDR, pResult);
  818. break;
  819. case LVN_ITEMCHANGED:
  820. processed = OnItemChanged(pNMHDR, pResult);
  821. break;
  822. case LVN_KEYDOWN:
  823. processed = OnKeyDown(pNMHDR, pResult);
  824. break;
  825. case LVN_COLUMNCLICK:
  826. processed = OnColumnClick(pNMHDR, pResult);
  827. break;
  828. default:
  829. break;
  830. }
  831. if (processed)
  832. return TRUE;
  833. }
  834. return CInetPropertyPage::OnNotify(wParam, lParam, pResult);
  835. }
  836. void
  837. CAppMappingPageBase::OnAdd()
  838. {
  839. CEditMap dlg(this);
  840. dlg.m_new = TRUE;
  841. dlg.m_flags = MD_SCRIPTMAPFLAG_SCRIPT | MD_SCRIPTMAPFLAG_CHECK_PATH_INFO;
  842. dlg.m_pMaps = &m_list;
  843. dlg.m_bIsLocal = GetSheet()->IsLocal();
  844. dlg.m_has_global_interceptor = GetSheet()->QueryMajorVersion() >= 6;
  845. if (dlg.DoModal() == IDOK)
  846. {
  847. CString all_verbs;
  848. VERIFY(all_verbs.LoadString(IDS_ALL));
  849. Mapping * pmap = new Mapping;
  850. pmap->ext = dlg.m_ext;
  851. pmap->path = dlg.m_exec;
  852. pmap->verbs = dlg.m_verbs;
  853. pmap->flags = dlg.m_flags;
  854. int count = m_list.GetItemCount();
  855. VERIFY(-1 != m_list.InsertItem(count, pmap->ext));
  856. VERIFY(m_list.SetItemData(count, (LPARAM)pmap));
  857. VERIFY(m_list.SetItemText(count, COL_PATH, pmap->path));
  858. VERIFY(m_list.SetItemText(count, COL_EXCLUSIONS,
  859. dlg.m_verbs[0] == 0 ? all_verbs : dlg.m_verbs));
  860. // Now unselect all items and select the new one
  861. for (int i = 0; i < count; i++)
  862. {
  863. m_list.SetItemState(i, 0, LVIS_SELECTED | LVIS_FOCUSED);
  864. }
  865. m_list.SetItemState(count, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  866. SetModified(TRUE);
  867. SetControlsState();
  868. SortMappings(m_list, m_sortCol, m_sortOrder);
  869. }
  870. }
  871. void
  872. CAppMappingPageBase::OnEdit()
  873. {
  874. int idx = m_list.GetNextItem(-1, LVNI_SELECTED);
  875. if (LB_ERR != idx)
  876. {
  877. CEditMap dlg(this);
  878. dlg.m_new = FALSE;
  879. dlg.m_pMaps = &m_list;
  880. dlg.m_bIsLocal = GetSheet()->IsLocal();
  881. dlg.m_has_global_interceptor = GetSheet()->QueryMajorVersion() >= 6;
  882. Mapping * pmap = (Mapping *)m_list.GetItemData(idx);
  883. ASSERT(pmap != NULL);
  884. dlg.m_ext = pmap->ext;
  885. dlg.m_exec = pmap->path;
  886. dlg.m_verbs = pmap->verbs;
  887. dlg.m_flags = pmap->flags;
  888. if (dlg.DoModal() == IDOK)
  889. {
  890. CString all_verbs;
  891. all_verbs.LoadString(IDS_ALL);
  892. pmap->ext = dlg.m_ext;
  893. pmap->path = dlg.m_exec;
  894. pmap->verbs = dlg.m_verbs;
  895. pmap->flags = dlg.m_flags;
  896. VERIFY(m_list.SetItemData(idx, (LPARAM)pmap));
  897. VERIFY(m_list.SetItemText(idx, COL_PATH, pmap->path));
  898. VERIFY(m_list.SetItemText(idx, COL_EXCLUSIONS,
  899. dlg.m_verbs[0] == 0 ? all_verbs : dlg.m_verbs));
  900. SetModified(TRUE);
  901. SetControlsState();
  902. SortMappings(m_list, m_sortCol, m_sortOrder);
  903. }
  904. }
  905. }
  906. void
  907. CAppMappingPageBase::OnRemove()
  908. {
  909. if (IDYES == AfxMessageBox(IDS_CONFIRM_REMOVE_MAP, MB_YESNO))
  910. {
  911. RemoveSelected(m_list);
  912. SetModified(TRUE);
  913. SetControlsState();
  914. ::SetFocus(CONTROL_HWND(m_list.GetItemCount() <= 0 ? IDC_ADD : IDC_REMOVE));
  915. }
  916. }
  917. BOOL
  918. CAppMappingPageBase::OnDblClickList(NMHDR* pNMHDR, LRESULT* pResult)
  919. {
  920. if (m_list.GetItemCount() > 0)
  921. {
  922. OnEdit();
  923. }
  924. *pResult = TRUE;
  925. return *pResult;
  926. }
  927. BOOL
  928. CAppMappingPageBase::OnItemChanged(NMHDR* pNMHDR, LRESULT* pResult)
  929. {
  930. SetControlsState();
  931. SetModified(TRUE);
  932. *pResult = TRUE;
  933. return *pResult;
  934. }
  935. void
  936. CAppMappingPageBase::OnDlgItemChanged()
  937. {
  938. SetControlsState();
  939. SetModified(TRUE);
  940. }
  941. BOOL
  942. CAppMappingPageBase::OnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
  943. {
  944. NMLVKEYDOWN * pKD = (NMLVKEYDOWN *)pNMHDR;
  945. if (pKD->wVKey == VK_DELETE)
  946. {
  947. if (::IsWindowEnabled(CONTROL_HWND(IDC_REMOVE)))
  948. {
  949. OnRemove();
  950. *pResult = TRUE;
  951. }
  952. }
  953. else if (pKD->wVKey == VK_INSERT)
  954. {
  955. OnAdd();
  956. *pResult = TRUE;
  957. }
  958. else if (pKD->wVKey == VK_RETURN)
  959. {
  960. short state = GetKeyState(VK_MENU);
  961. if ((0x8000 & state) != 0)
  962. {
  963. if (::IsWindowEnabled(CONTROL_HWND(IDC_EDIT)))
  964. {
  965. OnEdit();
  966. *pResult = TRUE;
  967. }
  968. }
  969. }
  970. else
  971. {
  972. *pResult = FALSE;
  973. }
  974. return *pResult;
  975. }
  976. BOOL
  977. CAppMappingPageBase::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult)
  978. {
  979. LPNMLISTVIEW plv = (LPNMLISTVIEW)pNMHDR;
  980. if (m_sortCol == plv->iSubItem)
  981. {
  982. m_sortOrder = -m_sortOrder;
  983. }
  984. else
  985. {
  986. m_sortCol = plv->iSubItem;
  987. }
  988. SortMappings(m_list, m_sortCol, m_sortOrder);
  989. *pResult = FALSE;
  990. return *pResult;
  991. }
  992. /////////////////////////////////////////////////////
  993. BOOL
  994. CEditMapBase::OnInitDialog()
  995. {
  996. m_file_exists = ((m_flags & MD_SCRIPTMAPFLAG_CHECK_PATH_INFO) != 0);
  997. CDialog::OnInitDialog();
  998. m_exec_init = m_exec;
  999. ::EnableWindow(CONTROL_HWND(IDC_BUTTON_BROWSE), m_bIsLocal);
  1000. return FALSE;
  1001. }
  1002. static int
  1003. ExtractPath(LPCTSTR cmd_line, CString& path)
  1004. {
  1005. int rc = 0;
  1006. LPTSTR pbuf = (LPTSTR)_alloca(sizeof(TCHAR) * lstrlen(cmd_line) + sizeof(TCHAR));
  1007. if (pbuf != NULL)
  1008. {
  1009. LPTSTR start = pbuf;
  1010. _tcscpy(pbuf, cmd_line);
  1011. if (*pbuf == _T('"'))
  1012. {
  1013. LPTSTR end = StrChr(++start, _T('"'));
  1014. if (end == NULL)
  1015. {
  1016. // Wrong format, closing quotation mark is not set
  1017. rc = IDS_ERR_PATH_NO_CLOSING_QUOTE;
  1018. // Return part of the path up to first space
  1019. PathRemoveArgs(pbuf);
  1020. }
  1021. else
  1022. {
  1023. ++end;
  1024. *end = 0;
  1025. PathUnquoteSpaces(pbuf);
  1026. start = pbuf;
  1027. }
  1028. }
  1029. else
  1030. {
  1031. PathRemoveArgs(pbuf);
  1032. }
  1033. if (rc == 0)
  1034. {
  1035. path = pbuf;
  1036. }
  1037. }
  1038. return rc;
  1039. }
  1040. void
  1041. CEditMapBase::DoDataExchange(CDataExchange * pDX)
  1042. {
  1043. BOOL bHasSpaces = FALSE;
  1044. DDX_Text(pDX, IDC_EXECUTABLE, m_exec);
  1045. if (pDX->m_bSaveAndValidate)
  1046. {
  1047. int rc = 0;
  1048. CString path, csPathMunged;
  1049. // check if entered path contains spaces...
  1050. bHasSpaces = (_tcschr(m_exec, _T(' ')) != NULL);
  1051. if (bHasSpaces)
  1052. {
  1053. //
  1054. // This could either be:
  1055. // 1. c:\program files\myfile.exe
  1056. // 2. c:\program files\myfile.exe %1
  1057. // 3. c:\program files\myfilethatdoesntexist.exe
  1058. // 4. c:\program files\myfilethatdoesntexist.exe %1
  1059. // if it has spaces then we have to require that it
  1060. // contain quotation marks
  1061. if (_tcschr(m_exec, _T('"')) != NULL)
  1062. {
  1063. // we found a quote!
  1064. // proceed
  1065. }
  1066. else
  1067. {
  1068. // contains spaces but no quotes, show the error msg and bail!
  1069. DDV_ShowBalloonAndFail(pDX, IDS_ERR_PATH_HAS_SPACES_REQUIRE_QUOTES);
  1070. }
  1071. }
  1072. rc = ExtractPath(m_exec, path);
  1073. if (rc != 0)
  1074. {
  1075. DDV_ShowBalloonAndFail(pDX, rc);
  1076. }
  1077. if (m_exec.CompareNoCase(m_exec_init) != 0
  1078. && m_star_maps && m_pMaps != NULL)
  1079. {
  1080. LVFINDINFO fi;
  1081. fi.flags = LVFI_STRING;
  1082. fi.vkDirection = VK_DOWN;
  1083. fi.psz = m_exec;
  1084. int idx = m_pMaps->FindItem(&fi, -1);
  1085. if (idx != -1)
  1086. {
  1087. DDV_ShowBalloonAndFail(pDX, IDS_ERR_USEDPATH);
  1088. }
  1089. }
  1090. csPathMunged = path;
  1091. #ifdef SUPPORT_SLASH_SLASH_QUESTIONMARK_SLASH_TYPE_PATHS
  1092. GetSpecialPathRealPath(0,path,csPathMunged);
  1093. #endif
  1094. DDV_FilePath(pDX, csPathMunged, m_bIsLocal);
  1095. if (PathIsUNC(csPathMunged))
  1096. {
  1097. DDV_ShowBalloonAndFail(pDX, IDS_ERR_NOUNC);
  1098. }
  1099. if (m_bIsLocal)
  1100. {
  1101. if (PathIsNetworkPath(csPathMunged))
  1102. {
  1103. DDV_ShowBalloonAndFail(pDX, IDS_ERR_NOREMOTE);
  1104. }
  1105. if (PathIsDirectory(csPathMunged))
  1106. {
  1107. DDV_ShowBalloonAndFail(pDX, IDS_ERR_FILENOTEXISTS);
  1108. }
  1109. }
  1110. }
  1111. DDX_Check(pDX, IDC_FILE_EXISTS, m_file_exists);
  1112. if (pDX->m_bSaveAndValidate)
  1113. {
  1114. if (m_file_exists)
  1115. {
  1116. m_flags |= MD_SCRIPTMAPFLAG_CHECK_PATH_INFO;
  1117. }
  1118. else
  1119. {
  1120. m_flags &= ~MD_SCRIPTMAPFLAG_CHECK_PATH_INFO;
  1121. }
  1122. }
  1123. }
  1124. BOOL
  1125. CEditMapBase::SetControlsState()
  1126. {
  1127. BOOL bRes = ::GetWindowTextLength(CONTROL_HWND(IDC_EXECUTABLE)) > 0;
  1128. ::EnableWindow(CONTROL_HWND(IDOK), bRes);
  1129. return bRes;
  1130. }
  1131. BEGIN_MESSAGE_MAP(CEditMapBase, CDialog)
  1132. //{{AFX_MSG_MAP(CEditMapBase)
  1133. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  1134. ON_EN_CHANGE(IDC_EXECUTABLE, OnExecutableChanged)
  1135. //}}AFX_MSG_MAP
  1136. END_MESSAGE_MAP()
  1137. void
  1138. CEditMapBase::OnButtonBrowse()
  1139. {
  1140. ASSERT(m_bIsLocal);
  1141. CString mask((LPCTSTR) m_IDS_BROWSE_BUTTON_MASK);
  1142. //#if 0
  1143. TCHAR buf[MAX_PATH];
  1144. _tcscpy(buf, _T(""));
  1145. for (int i = 0; i < mask.GetLength(); i++)
  1146. {
  1147. if (mask.GetAt(i) == _T('|'))
  1148. mask.SetAt(i, 0);
  1149. }
  1150. OPENFILENAME ofn = {0};
  1151. ZeroMemory(&ofn, sizeof(OPENFILENAME));
  1152. ofn.lStructSize = sizeof(OPENFILENAME);
  1153. //ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
  1154. ofn.hwndOwner = m_hWnd;
  1155. ofn.lpstrFilter = mask;
  1156. ofn.lpstrFile = buf;
  1157. //ofn.lpstrInitialDir = buf2;
  1158. ofn.nMaxFile = MAX_PATH;
  1159. ofn.Flags |=
  1160. OFN_DONTADDTORECENT
  1161. |OFN_HIDEREADONLY
  1162. |OFN_ENABLESIZING
  1163. |OFN_EXPLORER
  1164. |OFN_FILEMUSTEXIST
  1165. |OFN_NONETWORKBUTTON;
  1166. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  1167. if (GetOpenFileName(&ofn))
  1168. {
  1169. ::SetWindowText(CONTROL_HWND(IDC_EXECUTABLE), ofn.lpstrFile);
  1170. OnExecutableChanged();
  1171. }
  1172. else
  1173. {
  1174. // Failure
  1175. if (CommDlgExtendedError() != 0)
  1176. {
  1177. DebugTrace(_T("GetOpenFileName failed, 0x%08lx\n"),CommDlgExtendedError());
  1178. }
  1179. }
  1180. #if 0
  1181. //#else
  1182. CFileDialog dlgBrowse(
  1183. TRUE,
  1184. NULL,
  1185. NULL,
  1186. OFN_HIDEREADONLY,
  1187. mask,
  1188. this
  1189. );
  1190. // Disable hook to get Windows 2000 style dialog
  1191. dlgBrowse.m_ofn.Flags &= ~(OFN_ENABLEHOOK);
  1192. dlgBrowse.m_ofn.Flags |= OFN_DONTADDTORECENT|OFN_FILEMUSTEXIST;
  1193. INT_PTR rc = dlgBrowse.DoModal();
  1194. if (rc == IDOK)
  1195. {
  1196. ::SetWindowText(CONTROL_HWND(IDC_EXECUTABLE), dlgBrowse.GetPathName());
  1197. OnExecutableChanged();
  1198. }
  1199. else if (rc == IDCANCEL)
  1200. {
  1201. DWORD err = CommDlgExtendedError();
  1202. }
  1203. #endif
  1204. }
  1205. void
  1206. CEditMapBase::OnExecutableChanged()
  1207. {
  1208. SetControlsState();
  1209. }
  1210. ///===================
  1211. BOOL
  1212. CEditMap::OnInitDialog()
  1213. {
  1214. m_verbs_index = m_verbs.IsEmpty() ? 0 : 1;
  1215. m_script_engine = ((m_flags & MD_SCRIPTMAPFLAG_SCRIPT) != 0);
  1216. CEditMapBase::OnInitDialog();
  1217. SetControlsState();
  1218. return FALSE;
  1219. }
  1220. void
  1221. CEditMap::DoDataExchange(CDataExchange * pDX)
  1222. {
  1223. CEditMapBase::DoDataExchange(pDX);
  1224. DDX_Text(pDX, IDC_EXTENSION, m_ext);
  1225. if (pDX->m_bSaveAndValidate && m_new)
  1226. {
  1227. CString ext = m_ext;
  1228. ext.TrimLeft();
  1229. ext.TrimRight();
  1230. if (0 == ext.Compare(_T(".")))
  1231. {
  1232. DDV_ShowBalloonAndFail(pDX, IDS_ERR_BADEXT);
  1233. }
  1234. if (0 == ext.GetLength())
  1235. {
  1236. DDV_ShowBalloonAndFail(pDX, IDS_ERR_BADEXT);
  1237. }
  1238. if (ext.ReverseFind(_T('.')) > 0)
  1239. {
  1240. DDV_ShowBalloonAndFail(pDX, IDS_ERR_BADEXT);
  1241. }
  1242. size_t n, len = ext.GetLength();
  1243. if ((n = _tcscspn(ext, _T(",\"| /\\:?<>"))) < len)
  1244. {
  1245. DDV_ShowBalloonAndFail(pDX, IDS_ERR_BADEXT);
  1246. }
  1247. if (m_has_global_interceptor)
  1248. {
  1249. if (ext.GetAt(0) == _T('*') || ext.Compare(_T(".*")) == 0)
  1250. {
  1251. // Change it later to more explicit message
  1252. DDV_ShowBalloonAndFail(pDX, IDS_ERR_BADEXT);
  1253. }
  1254. else if (ext.Find(_T('*')) != -1)
  1255. {
  1256. DDV_ShowBalloonAndFail(pDX, IDS_ERR_BADEXT);
  1257. }
  1258. }
  1259. else if (ext.Find(_T('*')) != -1)
  1260. {
  1261. DDV_ShowBalloonAndFail(pDX, IDS_ERR_BADEXT);
  1262. }
  1263. if (ext.GetAt(0) == _T('*'))
  1264. ext = ext.Left(1);
  1265. else if (ext.Compare(_T(".*")) == 0)
  1266. ext = _T("*");
  1267. else if (ext.GetAt(0) != _T('.'))
  1268. ext = _T('.') + ext;
  1269. if (ext.GetAt(0) != _T('.') && ext.Find(_T('*')) > 1)
  1270. {
  1271. DDV_ShowBalloonAndFail(pDX, IDS_ERR_BADEXT);
  1272. }
  1273. LVFINDINFO fi;
  1274. fi.flags = LVFI_STRING;
  1275. fi.vkDirection = VK_DOWN;
  1276. fi.psz = ext;
  1277. if (m_pMaps->FindItem(&fi) != -1)
  1278. {
  1279. DDV_ShowBalloonAndFail(pDX, IDS_ERR_USEDEXT);
  1280. }
  1281. m_ext = ext;
  1282. }
  1283. DDX_Radio(pDX, IDC_ALL_VERBS, m_verbs_index);
  1284. DDX_Text(pDX, IDC_VERBS, m_verbs);
  1285. if (pDX->m_bSaveAndValidate)
  1286. {
  1287. if (m_verbs_index > 0)
  1288. {
  1289. DDV_MinMaxChars(pDX, m_verbs, 1, MAX_PATH);
  1290. }
  1291. else
  1292. {
  1293. m_verbs.Empty();
  1294. }
  1295. }
  1296. DDX_Check(pDX, IDC_SCRIPT_ENGINE, m_script_engine);
  1297. if (pDX->m_bSaveAndValidate)
  1298. {
  1299. if (m_script_engine)
  1300. m_flags |= MD_SCRIPTMAPFLAG_SCRIPT;
  1301. else
  1302. m_flags &= ~MD_SCRIPTMAPFLAG_SCRIPT;
  1303. }
  1304. }
  1305. BOOL
  1306. CEditMap::SetControlsState()
  1307. {
  1308. BOOL bRes = CEditMapBase::SetControlsState();
  1309. BOOL lim_verbs = ((CButton*)GetDlgItem(IDC_LIMIT_VERBS))->GetCheck() == BST_CHECKED;
  1310. ::EnableWindow(CONTROL_HWND(IDC_VERBS), lim_verbs);
  1311. ::EnableWindow(CONTROL_HWND(IDC_EXTENSION), m_new);
  1312. if (bRes)
  1313. {
  1314. bRes = GetDlgItem(IDC_EXTENSION)->GetWindowTextLength() > 0;
  1315. if (lim_verbs)
  1316. {
  1317. bRes = GetDlgItem(IDC_VERBS)->GetWindowTextLength() > 0;
  1318. }
  1319. ::EnableWindow(CONTROL_HWND(IDOK), bRes);
  1320. }
  1321. return bRes;
  1322. }
  1323. BEGIN_MESSAGE_MAP(CEditMap, CEditMapBase)
  1324. //{{AFX_MSG_MAP(CEditMapBase)
  1325. ON_EN_CHANGE(IDC_EXTENSION, OnExtChanged)
  1326. ON_BN_CLICKED(IDC_HELPBTN, OnHelp)
  1327. ON_BN_CLICKED(IDC_ALL_VERBS, OnVerbs)
  1328. ON_BN_CLICKED(IDC_LIMIT_VERBS, OnVerbs)
  1329. ON_EN_CHANGE(IDC_VERBS, OnVerbsChanged)
  1330. //}}AFX_MSG_MAP
  1331. END_MESSAGE_MAP()
  1332. void
  1333. CEditMap::OnExtChanged()
  1334. {
  1335. SetControlsState();
  1336. }
  1337. void
  1338. CEditMap::OnVerbs()
  1339. {
  1340. SetControlsState();
  1341. }
  1342. void
  1343. CEditMap::OnVerbsChanged()
  1344. {
  1345. SetControlsState();
  1346. }
  1347. void
  1348. CEditMap::OnHelp()
  1349. {
  1350. ::WinHelp(m_hWnd, theApp.m_pszHelpFilePath, HELP_CONTEXT, CEditMap::IDD + WINHELP_NUMBER_BASE);
  1351. }
  1352. BEGIN_MESSAGE_MAP(CEditStarMap, CEditMapBase)
  1353. ON_BN_CLICKED(IDC_HELPBTN, OnHelp)
  1354. END_MESSAGE_MAP()
  1355. void
  1356. CEditStarMap::OnHelp()
  1357. {
  1358. ::WinHelp(m_hWnd, theApp.m_pszHelpFilePath, HELP_CONTEXT, CEditStarMap::IDD + WINHELP_NUMBER_BASE);
  1359. }
  1360. ///=====================
  1361. BOOL
  1362. CAppMappingPage::OnInitDialog()
  1363. {
  1364. BOOL bres = CAppMappingPageBase::OnInitDialog();
  1365. DWORD dwStyle = m_list_exe.GetExtendedStyle();
  1366. m_list_exe.SetExtendedStyle(
  1367. dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
  1368. RECT rc;
  1369. m_list_exe.GetClientRect(&rc);
  1370. CString buf;
  1371. buf.LoadString(IDS_EXECUTABLE_PATH);
  1372. VERIFY(-1 != m_list_exe.InsertColumn(0, buf, LVCFMT_LEFT, rc.right - rc.left));
  1373. POSITION pos = m_strlMappings.GetHeadPosition();
  1374. int idx = 0;
  1375. while (pos != NULL)
  1376. {
  1377. buf = m_strlMappings.GetNext(pos);
  1378. Mapping * p = new Mapping(buf);
  1379. if (p == NULL)
  1380. break;
  1381. if (StrCmp(p->ext, _T("*")) == 0)
  1382. {
  1383. VERIFY(-1 != m_list_exe.InsertItem(idx, p->path));
  1384. VERIFY(m_list_exe.SetItemData(idx, (LPARAM)p));
  1385. idx++;
  1386. }
  1387. else
  1388. {
  1389. delete p;
  1390. }
  1391. }
  1392. if (idx > 0)
  1393. {
  1394. m_list_exe.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  1395. }
  1396. SetControlsState();
  1397. return bres;
  1398. }
  1399. void
  1400. CAppMappingPage::DoDataExchange(CDataExchange * pDX)
  1401. {
  1402. CAppMappingPageBase::DoDataExchange(pDX);
  1403. //{{AFX_DATA_MAP(CAppMappingPageBase)
  1404. DDX_Check(pDX, IDC_CACHE_ISAPI, m_CacheISAPI);
  1405. DDX_Control(pDX, IDC_LIST_EXE, m_list_exe);
  1406. //}}AFX_DATA_MAP
  1407. if (pDX->m_bSaveAndValidate)
  1408. {
  1409. int count = m_list_exe.GetItemCount();
  1410. for (int i = 0; i < count; i++)
  1411. {
  1412. Mapping * p = (Mapping *)m_list_exe.GetItemData(i);
  1413. CString buf;
  1414. p->ToString(buf);
  1415. m_strlMappings.AddTail(buf);
  1416. }
  1417. }
  1418. }
  1419. void
  1420. CAppMappingPage::SetControlsState()
  1421. {
  1422. CAppMappingPageBase::SetControlsState();
  1423. int count = m_list_exe.GetItemCount();
  1424. int sel_count = m_list_exe.GetSelectedCount();
  1425. int sel = m_list_exe.GetNextItem(-1, LVNI_SELECTED);
  1426. BOOL bEnableUp = sel > 0 && sel_count == 1;
  1427. BOOL bEnableDown = sel >= 0 && sel_count == 1 && sel < count - 1;
  1428. ::EnableWindow(CONTROL_HWND(IDC_EDIT_EXE), sel_count == 1);
  1429. ::EnableWindow(CONTROL_HWND(IDC_REMOVE_EXE), sel_count > 0);
  1430. ::EnableWindow(CONTROL_HWND(IDC_MOVE_UP), bEnableUp);
  1431. ::EnableWindow(CONTROL_HWND(IDC_MOVE_DOWN), bEnableDown);
  1432. }
  1433. void
  1434. CAppMappingPage::MoveItem(CListCtrl& lst, int from, int to)
  1435. {
  1436. Mapping * pFrom = (Mapping *)lst.GetItemData(from);
  1437. Mapping * pTo = (Mapping *)lst.GetItemData(to);
  1438. lst.SetItemText(from, 0, pTo->path);
  1439. lst.SetItemData(from, (DWORD_PTR)pTo);
  1440. lst.SetItemState(from, 0, LVIS_SELECTED | LVIS_FOCUSED);
  1441. lst.SetItemText(to, 0, pFrom->path);
  1442. lst.SetItemData(to, (DWORD_PTR)pFrom);
  1443. lst.SetItemState(to, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  1444. }
  1445. BOOL
  1446. CAppMappingPage::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  1447. {
  1448. ASSERT(pResult != NULL);
  1449. NMHDR* pNMHDR = (NMHDR*)lParam;
  1450. // We are looking only for events from the starmaps listview control here.
  1451. // This is the only way to catch notification, MFC screens
  1452. // all this stuff out.
  1453. if (pNMHDR->idFrom == IDC_LIST_EXE)
  1454. {
  1455. BOOL processed = FALSE;
  1456. switch (pNMHDR->code)
  1457. {
  1458. case NM_DBLCLK:
  1459. processed = OnDblClickListExe(pNMHDR, pResult);
  1460. break;
  1461. case LVN_ITEMCHANGED:
  1462. processed = OnItemChangedExe(pNMHDR, pResult);
  1463. break;
  1464. case LVN_KEYDOWN:
  1465. processed = OnKeyDownExe(pNMHDR, pResult);
  1466. break;
  1467. default:
  1468. break;
  1469. }
  1470. if (processed)
  1471. return TRUE;
  1472. }
  1473. return CAppMappingPageBase::OnNotify(wParam, lParam, pResult);
  1474. }
  1475. BEGIN_MESSAGE_MAP(CAppMappingPage, CAppMappingPageBase)
  1476. ON_BN_CLICKED(IDC_INSERT, OnInsert)
  1477. ON_BN_CLICKED(IDC_EDIT_EXE, OnEditExe)
  1478. ON_BN_CLICKED(IDC_REMOVE_EXE, OnRemoveExe)
  1479. ON_BN_CLICKED(IDC_MOVE_UP, OnMoveUp)
  1480. ON_BN_CLICKED(IDC_MOVE_DOWN, OnMoveDown)
  1481. END_MESSAGE_MAP()
  1482. void
  1483. CAppMappingPage::OnInsert()
  1484. {
  1485. CEditStarMap dlg(this);
  1486. dlg.m_new = TRUE;
  1487. dlg.m_flags = MD_SCRIPTMAPFLAG_CHECK_PATH_INFO;
  1488. dlg.m_pMaps = &m_list_exe;
  1489. dlg.m_bIsLocal = GetSheet()->IsLocal();
  1490. if (dlg.DoModal() == IDOK)
  1491. {
  1492. CString all_verbs;
  1493. VERIFY(all_verbs.LoadString(IDS_ALL));
  1494. Mapping * pmap = new Mapping;
  1495. pmap->ext = _T("*");
  1496. pmap->path = dlg.m_exec;
  1497. pmap->verbs = all_verbs;
  1498. pmap->flags = dlg.m_flags;
  1499. int count = m_list_exe.GetItemCount();
  1500. VERIFY(-1 != m_list_exe.InsertItem(count, pmap->path));
  1501. m_list_exe.SetItemData(count, (DWORD_PTR)pmap);
  1502. // Now unselect all items and select the new one
  1503. for (int i = 0; i < count; i++)
  1504. {
  1505. m_list_exe.SetItemState(i, 0, LVIS_SELECTED | LVIS_FOCUSED);
  1506. }
  1507. m_list_exe.SetItemState(count, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  1508. SetModified(TRUE);
  1509. SetControlsState();
  1510. }
  1511. }
  1512. void
  1513. CAppMappingPage::OnRemoveExe()
  1514. {
  1515. if (IDYES == AfxMessageBox(IDS_CONFIRM_REMOVE_MAP, MB_YESNO))
  1516. {
  1517. RemoveSelected(m_list_exe);
  1518. SetModified(TRUE);
  1519. SetControlsState();
  1520. ::SetFocus(CONTROL_HWND(m_list_exe.GetItemCount() <= 0 ? IDC_INSERT : IDC_REMOVE_EXE));
  1521. }
  1522. }
  1523. void
  1524. CAppMappingPage::OnEditExe()
  1525. {
  1526. int idx = m_list_exe.GetNextItem(-1, LVNI_SELECTED);
  1527. if (idx != -1)
  1528. {
  1529. CEditStarMap dlg(this);
  1530. dlg.m_new = FALSE;
  1531. dlg.m_pMaps = &m_list_exe;
  1532. dlg.m_bIsLocal = GetSheet()->IsLocal();
  1533. Mapping * p = (Mapping *)m_list_exe.GetItemData(idx);
  1534. ASSERT(p != NULL);
  1535. dlg.m_exec = p->path;
  1536. dlg.m_flags = p->flags;
  1537. if (dlg.DoModal() == IDOK)
  1538. {
  1539. p->path = dlg.m_exec;
  1540. p->flags = dlg.m_flags;
  1541. VERIFY(m_list_exe.SetItemText(idx, 0, dlg.m_exec));
  1542. SetModified(TRUE);
  1543. }
  1544. }
  1545. }
  1546. void
  1547. CAppMappingPage::OnMoveUp()
  1548. {
  1549. int from = m_list_exe.GetNextItem(-1, LVNI_SELECTED);
  1550. MoveItem(m_list_exe, from, from - 1);
  1551. SetControlsState();
  1552. SetModified(TRUE);
  1553. ::SetFocus(CONTROL_HWND(
  1554. ::IsWindowEnabled(CONTROL_HWND(IDC_MOVE_UP)) ? IDC_MOVE_UP : IDC_MOVE_DOWN));
  1555. }
  1556. void
  1557. CAppMappingPage::OnMoveDown()
  1558. {
  1559. int from = m_list_exe.GetNextItem(-1, LVNI_SELECTED);
  1560. MoveItem(m_list_exe, from, from + 1);
  1561. SetControlsState();
  1562. SetModified(TRUE);
  1563. ::SetFocus(CONTROL_HWND(
  1564. ::IsWindowEnabled(CONTROL_HWND(IDC_MOVE_DOWN)) ? IDC_MOVE_DOWN : IDC_MOVE_UP));
  1565. }
  1566. BOOL
  1567. CAppMappingPage::OnDblClickListExe(NMHDR* pNMHDR, LRESULT* pResult)
  1568. {
  1569. if (m_list_exe.GetItemCount() > 0)
  1570. {
  1571. OnEditExe();
  1572. }
  1573. *pResult = TRUE;
  1574. return *pResult;
  1575. }
  1576. BOOL
  1577. CAppMappingPage::OnItemChangedExe(NMHDR* pNMHDR, LRESULT* pResult)
  1578. {
  1579. SetControlsState();
  1580. *pResult = TRUE;
  1581. return *pResult;
  1582. }
  1583. BOOL
  1584. CAppMappingPage::OnKeyDownExe(NMHDR* pNMHDR, LRESULT* pResult)
  1585. {
  1586. NMLVKEYDOWN * pKD = (NMLVKEYDOWN *)pNMHDR;
  1587. if (pKD->wVKey == VK_DOWN)
  1588. {
  1589. short state = GetKeyState(VK_CONTROL);
  1590. if ((0x8000 & state) != 0)
  1591. {
  1592. if (::IsWindowEnabled(CONTROL_HWND(IDC_MOVE_DOWN)))
  1593. {
  1594. OnMoveDown();
  1595. *pResult = TRUE;
  1596. }
  1597. }
  1598. }
  1599. else if (pKD->wVKey == VK_UP)
  1600. {
  1601. short state = GetKeyState(VK_CONTROL);
  1602. if ((0x8000 & state) != 0)
  1603. {
  1604. if (::IsWindowEnabled(CONTROL_HWND(IDC_MOVE_UP)))
  1605. {
  1606. OnMoveUp();
  1607. *pResult = TRUE;
  1608. }
  1609. }
  1610. }
  1611. else if (pKD->wVKey == VK_DELETE)
  1612. {
  1613. if (::IsWindowEnabled(CONTROL_HWND(IDC_REMOVE_EXE)))
  1614. {
  1615. OnRemoveExe();
  1616. *pResult = TRUE;
  1617. }
  1618. }
  1619. else if (pKD->wVKey == VK_INSERT)
  1620. {
  1621. OnInsert();
  1622. *pResult = TRUE;
  1623. }
  1624. else if (pKD->wVKey == VK_RETURN)
  1625. {
  1626. short state = GetKeyState(VK_MENU);
  1627. if ((0x8000 & state) != 0)
  1628. {
  1629. if (::IsWindowEnabled(CONTROL_HWND(IDC_EDIT_EXE)))
  1630. {
  1631. OnEditExe();
  1632. *pResult = TRUE;
  1633. }
  1634. }
  1635. }
  1636. else
  1637. {
  1638. *pResult = FALSE;
  1639. }
  1640. return *pResult;
  1641. }
  1642. //////////////////////////
  1643. BEGIN_MESSAGE_MAP(CAppMappingPage_iis5, CAppMappingPageBase)
  1644. END_MESSAGE_MAP()
  1645. //////////////////////////
  1646. CAppCacheBase::CAppCacheBase(DWORD id, CInetPropertySheet * pSheet)
  1647. : CInetPropertyPage(id, pSheet)
  1648. {
  1649. }
  1650. CAppCacheBase::~CAppCacheBase()
  1651. {
  1652. }
  1653. BOOL
  1654. CAppCacheBase::OnInitDialog()
  1655. {
  1656. UDACCEL toAcc[3] = {{1, 1}, {3, 5}, {6, 10}};
  1657. CInetPropertyPage::OnInitDialog();
  1658. SETUP_SPIN(m_ScriptEngCacheMaxSpin, 0, 2000000000, m_ScriptEngCacheMax);
  1659. return FALSE;
  1660. }
  1661. void
  1662. CAppCacheBase::DoDataExchange(CDataExchange * pDX)
  1663. {
  1664. CInetPropertyPage::DoDataExchange(pDX);
  1665. //{{AFX_DATA_MAP(CAppCache)
  1666. if (pDX->m_bSaveAndValidate)
  1667. {
  1668. // This Needs to come before DDX_Text which will try to put text big number into small number
  1669. DDV_MinMaxBalloon(pDX, IDC_ENGINES, SCRIPT_ENG_MIN, SCRIPT_ENG_MAX);
  1670. }
  1671. DDX_TextBalloon(pDX, IDC_ENGINES, m_ScriptEngCacheMax);
  1672. DDX_Control(pDX, IDC_ENG_CACHED_SPIN, m_ScriptEngCacheMaxSpin);
  1673. //}}AFX_DATA_MAP
  1674. }
  1675. BEGIN_MESSAGE_MAP(CAppCacheBase, CInetPropertyPage)
  1676. ON_EN_CHANGE(IDC_ENGINES, OnItemChanged)
  1677. END_MESSAGE_MAP()
  1678. void
  1679. CAppCacheBase::SetControlsState()
  1680. {
  1681. ((CButton *)GetDlgItem(IDC_NO_CACHE))->SetCheck(m_NoCache ? BST_CHECKED : BST_UNCHECKED);
  1682. ((CButton *)GetDlgItem(IDC_UNLIMITED_CACHE))->SetCheck(m_UnlimCache ? BST_CHECKED : BST_UNCHECKED);
  1683. ((CButton *)GetDlgItem(IDC_LIMITED_CACHE))->SetCheck(m_LimCache ? BST_CHECKED : BST_UNCHECKED);
  1684. }
  1685. void
  1686. CAppCacheBase::OnItemChanged()
  1687. {
  1688. SetControlsState();
  1689. SetModified(TRUE);
  1690. }
  1691. ///////////////////////////////////////////
  1692. CAppCache::CAppCache(CInetPropertySheet * pSheet) : CAppCacheBase(CAppCache::IDD, pSheet)
  1693. {
  1694. }
  1695. CAppCache::~CAppCache()
  1696. {
  1697. }
  1698. HRESULT
  1699. CAppCache::FetchLoadedValues()
  1700. {
  1701. CError err;
  1702. BEGIN_META_INST_READ(CAppPropSheet)
  1703. FETCH_INST_DATA_FROM_SHEET(m_ScriptEngCacheMax);
  1704. FETCH_INST_DATA_FROM_SHEET(m_NoCache);
  1705. FETCH_INST_DATA_FROM_SHEET(m_LimCache);
  1706. FETCH_INST_DATA_FROM_SHEET(m_UnlimCache);
  1707. FETCH_INST_DATA_FROM_SHEET(m_LimDiskCache);
  1708. FETCH_INST_DATA_FROM_SHEET(m_LimCacheMemSize);
  1709. FETCH_INST_DATA_FROM_SHEET(m_LimCacheDiskSize);
  1710. FETCH_INST_DATA_FROM_SHEET(m_DiskCacheDir);
  1711. END_META_INST_READ(err)
  1712. return err;
  1713. }
  1714. HRESULT
  1715. CAppCache::SaveInfo()
  1716. {
  1717. ASSERT(IsDirty());
  1718. CError err;
  1719. BEGIN_META_INST_WRITE(CAppPropSheet)
  1720. STORE_INST_DATA_ON_SHEET(m_ScriptEngCacheMax)
  1721. STORE_INST_DATA_ON_SHEET(m_NoCache);
  1722. STORE_INST_DATA_ON_SHEET(m_LimCache);
  1723. STORE_INST_DATA_ON_SHEET(m_UnlimCache);
  1724. STORE_INST_DATA_ON_SHEET(m_LimDiskCache);
  1725. STORE_INST_DATA_ON_SHEET(m_LimCacheMemSize);
  1726. STORE_INST_DATA_ON_SHEET(m_LimCacheDiskSize);
  1727. STORE_INST_DATA_ON_SHEET(m_DiskCacheDir);
  1728. END_META_INST_WRITE(err)
  1729. return err;
  1730. }
  1731. void
  1732. CAppCache::DoDataExchange(CDataExchange * pDX)
  1733. {
  1734. CAppCacheBase::DoDataExchange(pDX);
  1735. if (pDX->m_bSaveAndValidate)
  1736. {
  1737. // This Needs to come before DDX_Text which will try to put text big number into small number
  1738. DDV_MinMaxBalloon(pDX, IDC_CACHE_SIZE_EDIT, 0, 2000000000);
  1739. }
  1740. DDX_TextBalloon(pDX, IDC_CACHE_SIZE_EDIT, m_LimCacheMemSize);
  1741. if (pDX->m_bSaveAndValidate)
  1742. {
  1743. // This Needs to come before DDX_Text which will try to put text big number into small number
  1744. DDV_MinMaxBalloon(pDX, IDC_DISK_UNLIM_EDIT, 0, 2000000000);
  1745. }
  1746. DDX_TextBalloon(pDX, IDC_DISK_UNLIM_EDIT, m_LimCacheDiskSize);
  1747. DDX_Text(pDX, IDC_CACHE_PATH, m_DiskCacheDir);
  1748. DDV_FolderPath(pDX, m_DiskCacheDir, GetSheet()->IsLocal());
  1749. DDX_Control(pDX, IDC_CACHE_SIZE_SPIN, m_LimCacheMemSizeSpin);
  1750. DDX_Control(pDX, IDC_DISK_UNLIM_SPIN, m_LimCacheDiskSizeSpin);
  1751. }
  1752. void
  1753. CAppCache::SetControlsState()
  1754. {
  1755. CAppCacheBase::SetControlsState();
  1756. // Edit control left to limited cache button
  1757. ::EnableWindow(CONTROL_HWND(IDC_CACHE_SIZE_EDIT), m_LimCache);
  1758. ::EnableWindow(CONTROL_HWND(IDC_CACHE_SIZE_SPIN), m_LimCache);
  1759. // Two radio buttons under limited cache button
  1760. ::EnableWindow(CONTROL_HWND(IDC_CACHE_UNLIMITED_DISK), m_LimCache);
  1761. ::EnableWindow(CONTROL_HWND(IDC_CACHE_LIMITED_DISK), m_LimCache);
  1762. // Edit control for limited disk cache button
  1763. ::EnableWindow(CONTROL_HWND(IDC_DISK_UNLIM_EDIT), m_LimCache && m_LimDiskCache);
  1764. ::EnableWindow(CONTROL_HWND(IDC_DISK_UNLIM_SPIN), m_LimCache && m_LimDiskCache);
  1765. }
  1766. BOOL
  1767. CAppCache::OnInitDialog()
  1768. {
  1769. UDACCEL toAcc[3] = {{1, 1}, {3, 5}, {6, 10}};
  1770. CAppCacheBase::OnInitDialog();
  1771. ((CButton *)GetDlgItem(IDC_CACHE_UNLIMITED_DISK))->SetCheck(!m_LimDiskCache ? BST_CHECKED : BST_UNCHECKED);
  1772. ((CButton *)GetDlgItem(IDC_CACHE_LIMITED_DISK))->SetCheck(m_LimDiskCache ? BST_CHECKED : BST_UNCHECKED);
  1773. ::EnableWindow(CONTROL_HWND(IDC_BROWSE), GetSheet()->IsLocal());
  1774. SETUP_SPIN(m_LimCacheMemSizeSpin, 0, 2000000000, m_LimCacheMemSize);
  1775. SETUP_SPIN(m_LimCacheDiskSizeSpin, 0, 2000000000, m_LimCacheDiskSize);
  1776. SetControlsState();
  1777. #ifdef SUPPORT_SLASH_SLASH_QUESTIONMARK_SLASH_TYPE_PATHS
  1778. LimitInputPath(CONTROL_HWND(IDC_CACHE_PATH),TRUE);
  1779. #else
  1780. LimitInputPath(CONTROL_HWND(IDC_CACHE_PATH),FALSE);
  1781. #endif
  1782. return FALSE;
  1783. }
  1784. BEGIN_MESSAGE_MAP(CAppCache, CAppCacheBase)
  1785. ON_BN_CLICKED(IDC_NO_CACHE, OnNoCache)
  1786. ON_BN_CLICKED(IDC_UNLIMITED_CACHE, OnUnlimitedCache)
  1787. ON_BN_CLICKED(IDC_LIMITED_CACHE, OnLimitedCache)
  1788. ON_BN_CLICKED(IDC_CACHE_UNLIMITED_DISK, OnUnlimitedDiskCache)
  1789. ON_BN_CLICKED(IDC_CACHE_LIMITED_DISK, OnLimitedDiskCache)
  1790. ON_EN_CHANGE(IDC_CACHE_PATH, OnItemChanged)
  1791. ON_EN_CHANGE(IDC_DISK_UNLIM_EDIT, OnItemChanged)
  1792. ON_EN_CHANGE(IDC_CACHE_SIZE_EDIT, OnItemChanged)
  1793. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  1794. END_MESSAGE_MAP()
  1795. //void
  1796. //CAppCache::OnItemChanged()
  1797. //{
  1798. // SetControlsState();
  1799. // SetModified(TRUE);
  1800. //}
  1801. //
  1802. void
  1803. CAppCache::OnNoCache()
  1804. {
  1805. m_NoCache = TRUE;
  1806. m_UnlimCache = FALSE;
  1807. m_LimCache = FALSE;
  1808. SetControlsState();
  1809. SetModified(TRUE);
  1810. }
  1811. void
  1812. CAppCache::OnUnlimitedCache()
  1813. {
  1814. m_NoCache = FALSE;
  1815. m_UnlimCache = TRUE;
  1816. m_LimCache = FALSE;
  1817. SetControlsState();
  1818. SetModified(TRUE);
  1819. }
  1820. void
  1821. CAppCache::OnLimitedCache()
  1822. {
  1823. m_NoCache = FALSE;
  1824. m_UnlimCache = FALSE;
  1825. m_LimCache = TRUE;
  1826. SetControlsState();
  1827. SetModified(TRUE);
  1828. }
  1829. void
  1830. CAppCache::OnLimitedDiskCache()
  1831. {
  1832. m_LimDiskCache = TRUE;
  1833. SetControlsState();
  1834. SetModified(TRUE);
  1835. }
  1836. void
  1837. CAppCache::OnUnlimitedDiskCache()
  1838. {
  1839. m_LimDiskCache = FALSE;
  1840. SetControlsState();
  1841. SetModified(TRUE);
  1842. }
  1843. static int CALLBACK
  1844. FileChooserCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
  1845. {
  1846. CAppCache * pThis = (CAppCache *)lpData;
  1847. ASSERT(pThis != NULL);
  1848. return pThis->BrowseForFolderCallback(hwnd, uMsg, lParam);
  1849. }
  1850. int
  1851. CAppCache::BrowseForFolderCallback(HWND hwnd, UINT uMsg, LPARAM lParam)
  1852. {
  1853. switch (uMsg)
  1854. {
  1855. case BFFM_INITIALIZED:
  1856. ASSERT(m_pPathTemp != NULL);
  1857. if (::PathIsNetworkPath(m_pPathTemp))
  1858. return 0;
  1859. while (!::PathIsDirectory(m_pPathTemp))
  1860. {
  1861. if (0 == ::PathRemoveFileSpec(m_pPathTemp) && !::PathIsRoot(m_pPathTemp))
  1862. {
  1863. return 0;
  1864. }
  1865. DWORD attr = GetFileAttributes(m_pPathTemp);
  1866. if ((attr & FILE_ATTRIBUTE_READONLY) == 0)
  1867. break;
  1868. }
  1869. ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)m_pPathTemp);
  1870. break;
  1871. case BFFM_SELCHANGED:
  1872. {
  1873. LPITEMIDLIST pidl = (LPITEMIDLIST)lParam;
  1874. TCHAR path[MAX_PATH];
  1875. if (SHGetPathFromIDList(pidl, path))
  1876. {
  1877. ::SendMessage(hwnd, BFFM_ENABLEOK, 0, !PathIsNetworkPath(path));
  1878. }
  1879. }
  1880. break;
  1881. case BFFM_VALIDATEFAILED:
  1882. break;
  1883. }
  1884. return 0;
  1885. }
  1886. void
  1887. CAppCache::OnBrowse()
  1888. {
  1889. BOOL bRes = FALSE;
  1890. HRESULT hr;
  1891. CString str;
  1892. GetDlgItem(IDC_CACHE_PATH)->GetWindowText(str);
  1893. if (SUCCEEDED(hr = CoInitialize(NULL)))
  1894. {
  1895. LPITEMIDLIST pidl = NULL;
  1896. if (SUCCEEDED(SHGetFolderLocation(NULL, CSIDL_DRIVES, NULL, 0, &pidl)))
  1897. {
  1898. LPITEMIDLIST pidList = NULL;
  1899. BROWSEINFO bi;
  1900. TCHAR buf[MAX_PATH] = {0};
  1901. ZeroMemory(&bi, sizeof(bi));
  1902. int drive = PathGetDriveNumber(str);
  1903. if (GetDriveType(PathBuildRoot(buf, drive)) == DRIVE_FIXED)
  1904. {
  1905. StrCpy(buf, str);
  1906. }
  1907. bi.hwndOwner = m_hWnd;
  1908. bi.pidlRoot = pidl;
  1909. bi.pszDisplayName = m_pPathTemp = buf;
  1910. bi.ulFlags |= BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
  1911. bi.lpfn = FileChooserCallback;
  1912. bi.lParam = (LPARAM)this;
  1913. pidList = SHBrowseForFolder(&bi);
  1914. if ( pidList != NULL
  1915. && SHGetPathFromIDList(pidList, buf)
  1916. )
  1917. {
  1918. str = buf;
  1919. bRes = TRUE;
  1920. }
  1921. IMalloc * pMalloc;
  1922. VERIFY(SUCCEEDED(SHGetMalloc(&pMalloc)));
  1923. if (pidl != NULL)
  1924. pMalloc->Free(pidl);
  1925. pMalloc->Release();
  1926. }
  1927. CoUninitialize();
  1928. }
  1929. if (bRes)
  1930. {
  1931. GetDlgItem(IDC_CACHE_PATH)->SetWindowText(str);
  1932. SetModified(TRUE);
  1933. SetControlsState();
  1934. }
  1935. }
  1936. ////////////////////////////////////////////
  1937. CAppCache_iis5::CAppCache_iis5(CInetPropertySheet * pSheet) : CAppCacheBase(CAppCache_iis5::IDD, pSheet)
  1938. {
  1939. }
  1940. CAppCache_iis5::~CAppCache_iis5()
  1941. {
  1942. }
  1943. HRESULT
  1944. CAppCache_iis5::FetchLoadedValues()
  1945. {
  1946. CError err;
  1947. BEGIN_META_INST_READ(CAppPropSheet)
  1948. FETCH_INST_DATA_FROM_SHEET(m_ScriptEngCacheMax);
  1949. FETCH_INST_DATA_FROM_SHEET(m_NoCache);
  1950. FETCH_INST_DATA_FROM_SHEET(m_LimCache);
  1951. FETCH_INST_DATA_FROM_SHEET(m_UnlimCache);
  1952. FETCH_INST_DATA_FROM_SHEET(m_AspScriptFileCacheSize);
  1953. END_META_INST_READ(err)
  1954. return err;
  1955. }
  1956. HRESULT
  1957. CAppCache_iis5::SaveInfo()
  1958. {
  1959. ASSERT(IsDirty());
  1960. CError err;
  1961. BEGIN_META_INST_WRITE(CAppPropSheet)
  1962. STORE_INST_DATA_ON_SHEET(m_ScriptEngCacheMax)
  1963. STORE_INST_DATA_ON_SHEET(m_NoCache);
  1964. STORE_INST_DATA_ON_SHEET(m_LimCache);
  1965. STORE_INST_DATA_ON_SHEET(m_UnlimCache);
  1966. STORE_INST_DATA_ON_SHEET(m_AspScriptFileCacheSize);
  1967. END_META_INST_WRITE(err)
  1968. return err;
  1969. }
  1970. void
  1971. CAppCache_iis5::DoDataExchange(CDataExchange * pDX)
  1972. {
  1973. CAppCacheBase::DoDataExchange(pDX);
  1974. if (m_LimCache)
  1975. {
  1976. // This Needs to come before DDX_Text which will try to put text big number into small number
  1977. DDV_MinMaxBalloon(pDX, IDC_CACHE_SIZE_EDIT, 0, 2000000000);
  1978. DDX_TextBalloon(pDX, IDC_CACHE_SIZE_EDIT, m_AspScriptFileCacheSize);
  1979. }
  1980. DDX_Control(pDX, IDC_CACHE_SIZE_SPIN, m_AspScriptFileCacheSizeSpin);
  1981. }
  1982. void
  1983. CAppCache_iis5::SetControlsState()
  1984. {
  1985. CAppCacheBase::SetControlsState();
  1986. // Edit control left to limited cache button
  1987. ::EnableWindow(CONTROL_HWND(IDC_CACHE_SIZE_EDIT), m_LimCache);
  1988. ::EnableWindow(CONTROL_HWND(IDC_CACHE_SIZE_SPIN), m_LimCache);
  1989. }
  1990. BOOL
  1991. CAppCache_iis5::OnInitDialog()
  1992. {
  1993. UDACCEL toAcc[3] = {{1, 1}, {3, 5}, {6, 10}};
  1994. CAppCacheBase::OnInitDialog();
  1995. if (!m_LimCache)
  1996. {
  1997. SetDlgItemInt(IDC_CACHE_SIZE_EDIT, 250, FALSE);
  1998. }
  1999. SETUP_SPIN(m_AspScriptFileCacheSizeSpin, 0, 2000000000, m_AspScriptFileCacheSize);
  2000. SetControlsState();
  2001. return FALSE;
  2002. }
  2003. BEGIN_MESSAGE_MAP(CAppCache_iis5, CAppCacheBase)
  2004. ON_BN_CLICKED(IDC_NO_CACHE, OnNoCache)
  2005. ON_BN_CLICKED(IDC_UNLIMITED_CACHE, OnUnlimitedCache)
  2006. ON_BN_CLICKED(IDC_LIMITED_CACHE, OnLimitedCache)
  2007. ON_EN_CHANGE(IDC_CACHE_SIZE_EDIT, OnItemChanged)
  2008. END_MESSAGE_MAP()
  2009. void
  2010. CAppCache_iis5::OnItemChanged()
  2011. {
  2012. SetControlsState();
  2013. SetModified(TRUE);
  2014. }
  2015. void
  2016. CAppCache_iis5::OnNoCache()
  2017. {
  2018. m_NoCache = TRUE;
  2019. m_UnlimCache = FALSE;
  2020. m_LimCache = FALSE;
  2021. SetControlsState();
  2022. SetModified(TRUE);
  2023. }
  2024. void
  2025. CAppCache_iis5::OnUnlimitedCache()
  2026. {
  2027. m_NoCache = FALSE;
  2028. m_UnlimCache = TRUE;
  2029. m_LimCache = FALSE;
  2030. SetControlsState();
  2031. SetModified(TRUE);
  2032. }
  2033. void
  2034. CAppCache_iis5::OnLimitedCache()
  2035. {
  2036. m_NoCache = FALSE;
  2037. m_UnlimCache = FALSE;
  2038. m_LimCache = TRUE;
  2039. SetControlsState();
  2040. SetModified(TRUE);
  2041. }
  2042. ////////////////////////////////////////////////////
  2043. IMPLEMENT_DYNCREATE(CAspDebug, CInetPropertyPage)
  2044. CAspDebug::CAspDebug(CInetPropertySheet * pSheet)
  2045. : CInetPropertyPage(CAspDebug::IDD, pSheet)
  2046. {
  2047. #if 0
  2048. // hack to have new struct size with old MFC and new NT 5.0 headers
  2049. ZeroMemory(&m_psp_ex, sizeof(PROPSHEETPAGE));
  2050. memcpy(&m_psp_ex, &m_psp, m_psp.dwSize);
  2051. m_psp_ex.dwSize = sizeof(PROPSHEETPAGE);
  2052. #endif
  2053. }
  2054. CAspDebug::~CAspDebug()
  2055. {
  2056. }
  2057. HRESULT
  2058. CAspDebug::FetchLoadedValues()
  2059. {
  2060. CError err;
  2061. BEGIN_META_INST_READ(CAppPropSheet)
  2062. FETCH_INST_DATA_FROM_SHEET(m_ServerDebug);
  2063. FETCH_INST_DATA_FROM_SHEET(m_ClientDebug);
  2064. FETCH_INST_DATA_FROM_SHEET(m_SendAspError);
  2065. FETCH_INST_DATA_FROM_SHEET(m_DefaultError);
  2066. END_META_INST_READ(err)
  2067. return err;
  2068. }
  2069. /* virtual */
  2070. HRESULT
  2071. CAspDebug::SaveInfo()
  2072. {
  2073. ASSERT(IsDirty());
  2074. CError err;
  2075. BEGIN_META_INST_WRITE(CAppPropSheet)
  2076. STORE_INST_DATA_ON_SHEET(m_ServerDebug);
  2077. STORE_INST_DATA_ON_SHEET(m_ClientDebug);
  2078. STORE_INST_DATA_ON_SHEET(m_SendAspError);
  2079. STORE_INST_DATA_ON_SHEET(m_DefaultError);
  2080. END_META_INST_WRITE(err)
  2081. return err;
  2082. }
  2083. void
  2084. CAspDebug::DoDataExchange(CDataExchange * pDX)
  2085. {
  2086. CInetPropertyPage::DoDataExchange(pDX);
  2087. //{{AFX_DATA_MAP(CAspMainPage)
  2088. DDX_Check(pDX, IDC_SERVER_DEBUG, m_ServerDebug);
  2089. DDX_Check(pDX, IDC_CLIENT_DEBUG, m_ClientDebug);
  2090. DDX_Text(pDX, IDC_DEFAULT_ERROR, m_DefaultError);
  2091. //}}AFX_DATA_MAP
  2092. }
  2093. //////////////////////////////////////////////////////
  2094. BEGIN_MESSAGE_MAP(CAspDebug, CInetPropertyPage)
  2095. //{{AFX_MSG_MAP(CAspDebug)
  2096. ON_BN_CLICKED(IDC_SERVER_DEBUG, OnItemChanged)
  2097. ON_BN_CLICKED(IDC_CLIENT_DEBUG, OnItemChanged)
  2098. ON_BN_CLICKED(IDC_SEND_DETAILED_ERROR, OnChangedError)
  2099. ON_BN_CLICKED(IDC_SEND_DEF_ERROR, OnChangedError)
  2100. ON_EN_CHANGE(IDC_DEFAULT_ERROR, OnItemChanged)
  2101. //}}AFX_MSG_MAP
  2102. END_MESSAGE_MAP()
  2103. BOOL
  2104. CAspDebug::OnInitDialog()
  2105. {
  2106. CInetPropertyPage::OnInitDialog();
  2107. ((CButton *)GetDlgItem(
  2108. m_SendAspError ? IDC_SEND_DETAILED_ERROR : IDC_SEND_DEF_ERROR))->SetCheck(BST_CHECKED);
  2109. ::EnableWindow(CONTROL_HWND(IDC_DEFAULT_ERROR), !m_SendAspError);
  2110. return FALSE;
  2111. }
  2112. void
  2113. CAspDebug::OnItemChanged()
  2114. {
  2115. SetModified(TRUE);
  2116. }
  2117. void
  2118. CAspDebug::OnChangedError()
  2119. {
  2120. m_SendAspError = ((CButton *)GetDlgItem(IDC_SEND_DETAILED_ERROR))->GetCheck() == BST_CHECKED;
  2121. ::EnableWindow(CONTROL_HWND(IDC_DEFAULT_ERROR), !m_SendAspError);
  2122. SetModified(TRUE);
  2123. }