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.

559 lines
10 KiB

  1. /*++
  2. Copyright (c) 1994-2001 Microsoft Corporation
  3. Module Name :
  4. machsht.cpp
  5. Abstract:
  6. IIS Machine Property sheet classes
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager (cluster edition)
  12. Revision History:
  13. --*/
  14. #include "stdafx.h"
  15. #include "common.h"
  16. #include "inetprop.h"
  17. #include "InetMgrApp.h"
  18. #include "shts.h"
  19. #include "ftpsht.h"
  20. //
  21. // Help IDs. Home directory gets substituted.
  22. //
  23. #define HIDD_FTP_DIRECTORY_PROPERTIES (IDD_FTP_DIRECTORY_PROPERTIES + 0x20000)
  24. #define HIDD_FTP_HOME_DIRECTORY_PROPERTIES (HIDD_FTP_DIRECTORY_PROPERTIES + 0x20000)
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char BASED_CODE THIS_FILE[] = __FILE__;
  28. #endif
  29. #define new DEBUG_NEW
  30. CFTPInstanceProps::CFTPInstanceProps(
  31. IN CComAuthInfo * pAuthInfo,
  32. IN LPCTSTR lpszMDPath
  33. )
  34. /*++
  35. Routine Description:
  36. Constructor for FTP instance properties
  37. Arguments:
  38. CComAuthInfo * pAuthInfo : COM Authentication info
  39. LPCTSTR lpszMDPath : MD Path
  40. Return Value:
  41. N/A
  42. --*/
  43. : CInstanceProps(pAuthInfo, lpszMDPath, 21U),
  44. m_nMaxConnections((LONG)0L),
  45. m_nConnectionTimeOut((LONG)0L),
  46. m_dwLogType(MD_LOG_TYPE_DISABLED),
  47. /**/
  48. m_strUserName(),
  49. m_strPassword(),
  50. m_fAllowAnonymous(FALSE),
  51. m_fOnlyAnonymous(FALSE),
  52. m_fPasswordSync(TRUE),
  53. m_acl(),
  54. /**/
  55. m_strExitMessage(),
  56. m_strMaxConMsg(),
  57. m_strlWelcome(),
  58. m_strlBanner(),
  59. /**/
  60. m_fDosDirOutput(TRUE),
  61. /**/
  62. m_dwDownlevelInstance(1)
  63. {
  64. //
  65. // Fetch everything
  66. //
  67. m_dwMDUserType = ALL_METADATA;
  68. m_dwMDDataType = ALL_METADATA;
  69. }
  70. /* virtual */
  71. void
  72. CFTPInstanceProps::ParseFields()
  73. /*++
  74. Routine Description:
  75. Break into fields.
  76. Arguments:
  77. None.
  78. Return Value:
  79. None.
  80. --*/
  81. {
  82. //
  83. // Fetch base properties
  84. //
  85. CInstanceProps::ParseFields();
  86. BEGIN_PARSE_META_RECORDS(m_dwNumEntries, m_pbMDData)
  87. //
  88. // Service Page
  89. //
  90. HANDLE_META_RECORD(MD_MAX_CONNECTIONS, m_nMaxConnections)
  91. HANDLE_META_RECORD(MD_CONNECTION_TIMEOUT, m_nConnectionTimeOut)
  92. HANDLE_META_RECORD(MD_LOG_TYPE, m_dwLogType)
  93. //
  94. // Accounts Page
  95. //
  96. HANDLE_META_RECORD(MD_ANONYMOUS_USER_NAME, m_strUserName)
  97. HANDLE_META_RECORD(MD_ANONYMOUS_PWD, m_strPassword)
  98. HANDLE_META_RECORD(MD_ANONYMOUS_ONLY, m_fOnlyAnonymous)
  99. HANDLE_META_RECORD(MD_ALLOW_ANONYMOUS, m_fAllowAnonymous)
  100. HANDLE_META_RECORD(MD_ANONYMOUS_USE_SUBAUTH, m_fPasswordSync)
  101. HANDLE_META_RECORD(MD_ADMIN_ACL, m_acl)
  102. //
  103. // Message Page
  104. //
  105. HANDLE_META_RECORD(MD_EXIT_MESSAGE, m_strExitMessage)
  106. HANDLE_META_RECORD(MD_MAX_CLIENTS_MESSAGE, m_strMaxConMsg)
  107. HANDLE_META_RECORD(MD_GREETING_MESSAGE, m_strlWelcome)
  108. HANDLE_META_RECORD(MD_BANNER_MESSAGE, m_strlBanner)
  109. //
  110. // Directory Properties Page
  111. //
  112. HANDLE_META_RECORD(MD_MSDOS_DIR_OUTPUT, m_fDosDirOutput);
  113. //
  114. // Default Site
  115. //
  116. HANDLE_META_RECORD(MD_DOWNLEVEL_ADMIN_INSTANCE, m_dwDownlevelInstance)
  117. HANDLE_META_RECORD(MD_MAX_BANDWIDTH, m_dwMaxBandwidth)
  118. END_PARSE_META_RECORDS
  119. }
  120. /* virtual */
  121. HRESULT
  122. CFTPInstanceProps::WriteDirtyProps()
  123. /*++
  124. Routine Description:
  125. Write the dirty properties to the metabase
  126. Arguments:
  127. None
  128. Return Value:
  129. HRESULT
  130. --*/
  131. {
  132. CError err(CInstanceProps::WriteDirtyProps());
  133. if (err.Failed())
  134. {
  135. return err;
  136. }
  137. BEGIN_META_WRITE()
  138. //
  139. // Service Page
  140. //
  141. META_WRITE(MD_MAX_CONNECTIONS, m_nMaxConnections)
  142. META_WRITE(MD_CONNECTION_TIMEOUT, m_nConnectionTimeOut)
  143. META_WRITE(MD_LOG_TYPE, m_dwLogType)
  144. //
  145. // Accounts Page
  146. //
  147. META_WRITE(MD_ANONYMOUS_USER_NAME, m_strUserName)
  148. META_WRITE(MD_ANONYMOUS_PWD, m_strPassword)
  149. META_WRITE(MD_ANONYMOUS_ONLY, m_fOnlyAnonymous)
  150. META_WRITE(MD_ALLOW_ANONYMOUS, m_fAllowAnonymous)
  151. META_WRITE(MD_ANONYMOUS_USE_SUBAUTH, m_fPasswordSync)
  152. META_WRITE(MD_ADMIN_ACL, m_acl)
  153. //
  154. // Message Page
  155. //
  156. META_WRITE(MD_EXIT_MESSAGE, m_strExitMessage)
  157. META_WRITE(MD_MAX_CLIENTS_MESSAGE, m_strMaxConMsg)
  158. META_WRITE(MD_GREETING_MESSAGE, m_strlWelcome)
  159. META_WRITE(MD_BANNER_MESSAGE, m_strlBanner)
  160. //
  161. // Directory Properties Page
  162. //
  163. META_WRITE(MD_MSDOS_DIR_OUTPUT, m_fDosDirOutput);
  164. //
  165. // Default Site
  166. //
  167. META_WRITE(MD_DOWNLEVEL_ADMIN_INSTANCE, m_dwDownlevelInstance)
  168. META_WRITE(MD_MAX_BANDWIDTH, m_dwMaxBandwidth)
  169. END_META_WRITE(err);
  170. return err;
  171. }
  172. CFTPDirProps::CFTPDirProps(
  173. IN CComAuthInfo * pAuthInfo,
  174. IN LPCTSTR lpszMDPath
  175. )
  176. /*++
  177. Routine Description:
  178. FTP Directory properties object
  179. Arguments:
  180. CComAuthInfo * pAuthInfo : COM Authentication info
  181. LPCTSTR lpszMDPath : MD Path
  182. Return Value:
  183. N/A.
  184. --*/
  185. : CChildNodeProps(
  186. pAuthInfo,
  187. lpszMDPath,
  188. WITH_INHERITANCE,
  189. FALSE // Complete information
  190. ),
  191. /**/
  192. m_fDontLog(FALSE),
  193. m_ipl()
  194. {
  195. //
  196. // Fetch everything
  197. //
  198. m_dwMDUserType = ALL_METADATA;
  199. m_dwMDDataType = ALL_METADATA;
  200. }
  201. /* virtual */
  202. void
  203. CFTPDirProps::ParseFields()
  204. /*++
  205. Routine Description:
  206. Break into fields.
  207. Arguments:
  208. None.
  209. Return Value:
  210. None.
  211. --*/
  212. {
  213. //
  214. // Fetch base properties
  215. //
  216. CChildNodeProps::ParseFields();
  217. BEGIN_PARSE_META_RECORDS(m_dwNumEntries, m_pbMDData)
  218. HANDLE_META_RECORD(MD_VR_USERNAME, m_strUserName)
  219. HANDLE_META_RECORD(MD_VR_PASSWORD, m_strPassword)
  220. HANDLE_META_RECORD(MD_DONT_LOG, m_fDontLog);
  221. HANDLE_META_RECORD(MD_IP_SEC, m_ipl);
  222. END_PARSE_META_RECORDS
  223. }
  224. /* virtual */
  225. HRESULT
  226. CFTPDirProps::WriteDirtyProps()
  227. /*++
  228. Routine Description:
  229. Write the dirty properties to the metabase
  230. Arguments:
  231. None
  232. Return Value:
  233. HRESULT
  234. --*/
  235. {
  236. CError err(CChildNodeProps::WriteDirtyProps());
  237. if (err.Failed())
  238. {
  239. return err;
  240. }
  241. //
  242. // CODEWORK: Consider DDX/DDV like methods which do both
  243. // ParseFields and WriteDirtyProps in a single method. Must
  244. // take care not to write data which should only be read, not
  245. // written
  246. //
  247. BEGIN_META_WRITE()
  248. META_WRITE(MD_VR_USERNAME, m_strUserName)
  249. META_WRITE(MD_VR_PASSWORD, m_strPassword)
  250. META_WRITE(MD_DONT_LOG, m_fDontLog);
  251. META_WRITE(MD_IP_SEC, m_ipl);
  252. END_META_WRITE(err);
  253. return err;
  254. }
  255. //
  256. // FTP Property Sheet Implementation
  257. //
  258. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  259. CFtpSheet::CFtpSheet(
  260. CComAuthInfo * pAuthInfo,
  261. LPCTSTR lpszMetaPath,
  262. CWnd * pParentWnd,
  263. LPARAM lParam,
  264. LONG_PTR handle,
  265. UINT iSelectPage
  266. )
  267. /*++
  268. Routine Description:
  269. FTP Property sheet constructor
  270. Arguments:
  271. CComAuthInfo * pAuthInfo : Authentication information
  272. LPCTSTR lpszMetPath : Metabase path
  273. CWnd * pParentWnd : Optional parent window
  274. LPARAM lParam : MMC Console parameter
  275. LONG_PTR handle : MMC Console handle
  276. UINT iSelectPage : Initial page to be selected
  277. Return Value:
  278. N/A
  279. --*/
  280. : CInetPropertySheet(
  281. pAuthInfo,
  282. lpszMetaPath,
  283. pParentWnd,
  284. lParam,
  285. handle,
  286. iSelectPage
  287. ),
  288. m_ppropInst(NULL),
  289. m_ppropDir(NULL)
  290. {
  291. }
  292. CFtpSheet::~CFtpSheet()
  293. /*++
  294. Routine Description:
  295. FTP Sheet destructor
  296. Arguments:
  297. N/A
  298. Return Value:
  299. N/A
  300. --*/
  301. {
  302. FreeConfigurationParameters();
  303. }
  304. void
  305. CFtpSheet::WinHelp(
  306. IN DWORD dwData,
  307. IN UINT nCmd
  308. )
  309. /*++
  310. Routine Description:
  311. FTP Property sheet help handler
  312. Arguments:
  313. DWORD dwData : WinHelp data (dialog ID)
  314. UINT nCmd : WinHelp command
  315. Return Value:
  316. None
  317. Notes:
  318. Replace the dialog ID if this is the directory tab. We have
  319. different help depending on virtual directory, home, file, directory.
  320. --*/
  321. {
  322. ASSERT(m_ppropDir != NULL);
  323. if (::lstrcmpi(m_ppropDir->QueryAlias(), g_cszRoot) == 0
  324. && dwData == HIDD_FTP_DIRECTORY_PROPERTIES)
  325. {
  326. //
  327. // It's a home virtual directory -- change the ID
  328. //
  329. dwData = HIDD_FTP_HOME_DIRECTORY_PROPERTIES;
  330. }
  331. CInetPropertySheet::WinHelp(dwData, nCmd);
  332. }
  333. /* virtual */
  334. HRESULT
  335. CFtpSheet::LoadConfigurationParameters()
  336. /*++
  337. Routine Description:
  338. Load configuration parameters information
  339. Arguments:
  340. None
  341. Return Value:
  342. HRESULT
  343. --*/
  344. {
  345. //
  346. // Load base properties
  347. //
  348. CError err(CInetPropertySheet::LoadConfigurationParameters());
  349. if (err.Failed())
  350. {
  351. return err;
  352. }
  353. if (m_ppropInst == NULL)
  354. {
  355. //
  356. // First call -- load values
  357. //
  358. ASSERT(m_ppropDir == NULL);
  359. m_ppropInst = new CFTPInstanceProps(QueryAuthInfo(), QueryInstancePath());
  360. m_ppropDir = new CFTPDirProps(QueryAuthInfo(), QueryDirectoryPath());
  361. if (!m_ppropInst || !m_ppropDir)
  362. {
  363. TRACEEOLID("LoadConfigurationParameters: OOM");
  364. SAFE_DELETE(m_ppropDir);
  365. SAFE_DELETE(m_ppropInst);
  366. err = ERROR_NOT_ENOUGH_MEMORY;
  367. return err;
  368. }
  369. err = m_ppropInst->LoadData();
  370. if (err.Succeeded())
  371. {
  372. err = m_ppropDir->LoadData();
  373. }
  374. }
  375. return err;
  376. }
  377. /* virtual */
  378. void
  379. CFtpSheet::FreeConfigurationParameters()
  380. /*++
  381. Routine Description:
  382. Clean up configuration data
  383. Arguments:
  384. None
  385. Return Value:
  386. None
  387. --*/
  388. {
  389. //
  390. // Base class
  391. //
  392. CInetPropertySheet::FreeConfigurationParameters();
  393. ASSERT(m_ppropInst != NULL);
  394. ASSERT(m_ppropDir != NULL);
  395. SAFE_DELETE(m_ppropInst);
  396. SAFE_DELETE(m_ppropDir);
  397. }
  398. //
  399. // Message Map
  400. //
  401. BEGIN_MESSAGE_MAP(CFtpSheet, CInetPropertySheet)
  402. //{{AFX_MSG_MAP(CInetPropertySheet)
  403. //}}AFX_MSG_MAP
  404. END_MESSAGE_MAP()