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.

388 lines
7.6 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
  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 "machsht.h"
  20. #include "mime.h"
  21. #include <iisver.h>
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26. #define new DEBUG_NEW
  27. //
  28. // CIISMachineSheet class
  29. //
  30. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  31. CIISMachineSheet::CIISMachineSheet(
  32. CComAuthInfo * pAuthInfo,
  33. LPCTSTR lpszMetaPath,
  34. CWnd * pParentWnd,
  35. LPARAM lParam,
  36. LPARAM lParamParent,
  37. UINT iSelectPage
  38. )
  39. /*++
  40. Routine Description:
  41. IIS Machine Property sheet constructor
  42. Arguments:
  43. CComAuthInfo * pAuthInfo : Authentication information
  44. LPCTSTR lpszMetPath : Metabase path
  45. CWnd * pParentWnd : Optional parent window
  46. LPARAM lParam : MMC Console parameter
  47. UINT iSelectPage : Initial page to be selected
  48. Return Value:
  49. N/A
  50. --*/
  51. : CInetPropertySheet(
  52. pAuthInfo,
  53. lpszMetaPath,
  54. pParentWnd,
  55. lParam,
  56. lParamParent,
  57. iSelectPage
  58. ),
  59. m_ppropMachine(NULL)
  60. {
  61. }
  62. CIISMachineSheet::~CIISMachineSheet()
  63. {
  64. FreeConfigurationParameters();
  65. }
  66. /* virtual */
  67. HRESULT
  68. CIISMachineSheet::LoadConfigurationParameters()
  69. /*++
  70. Routine Description:
  71. Load configuration parameters information
  72. Arguments:
  73. None
  74. Return Value:
  75. HRESULT
  76. --*/
  77. {
  78. //
  79. // Load base values
  80. //
  81. CError err(CInetPropertySheet::LoadConfigurationParameters());
  82. if (err.Failed())
  83. {
  84. return err;
  85. }
  86. ASSERT(m_ppropMachine == NULL);
  87. m_ppropMachine = new CMachineProps(QueryAuthInfo());
  88. if (!m_ppropMachine)
  89. {
  90. err = ERROR_NOT_ENOUGH_MEMORY;
  91. return err;
  92. }
  93. err = m_ppropMachine->LoadData();
  94. if (err.Failed())
  95. {
  96. return err;
  97. }
  98. return err;
  99. }
  100. /* virtual */
  101. void
  102. CIISMachineSheet::FreeConfigurationParameters()
  103. {
  104. //
  105. // Free Base values
  106. //
  107. CInetPropertySheet::FreeConfigurationParameters();
  108. ASSERT_PTR(m_ppropMachine);
  109. SAFE_DELETE(m_ppropMachine);
  110. }
  111. //
  112. // Message Map
  113. //
  114. BEGIN_MESSAGE_MAP(CIISMachineSheet, CInetPropertySheet)
  115. //{{AFX_MSG_MAP(CInetPropertySheet)
  116. //}}AFX_MSG_MAP
  117. END_MESSAGE_MAP()
  118. IMPLEMENT_DYNCREATE(CIISMachinePage, CInetPropertyPage)
  119. CIISMachinePage::CIISMachinePage(
  120. CIISMachineSheet * pSheet
  121. )
  122. : CInetPropertyPage(CIISMachinePage::IDD, pSheet),
  123. m_ppropMimeTypes(NULL)
  124. {
  125. }
  126. CIISMachinePage::~CIISMachinePage()
  127. {
  128. }
  129. void
  130. CIISMachinePage::DoDataExchange(
  131. CDataExchange * pDX
  132. )
  133. {
  134. CInetPropertyPage::DoDataExchange(pDX);
  135. //{{AFX_DATA_MAP(CIISMachinePage)
  136. DDX_Control(pDX, IDC_ENABLE_MB_EDIT, m_EnableMetabaseEdit);
  137. DDX_Check(pDX, IDC_ENABLE_MB_EDIT, m_fEnableMetabaseEdit);
  138. DDX_Control(pDX, IDC_WEBLOG_UTF8, m_UTF8Web);
  139. DDX_Check(pDX, IDC_WEBLOG_UTF8, m_fUTF8Web);
  140. //}}AFX_DATA_MAP
  141. }
  142. //
  143. // Message Map
  144. //
  145. BEGIN_MESSAGE_MAP(CIISMachinePage, CInetPropertyPage)
  146. //{{AFX_MSG_MAP(CIISMachinePage)
  147. ON_BN_CLICKED(IDC_ENABLE_MB_EDIT, OnCheckEnableEdit)
  148. ON_BN_CLICKED(IDC_WEBLOG_UTF8, OnCheckUTF8)
  149. ON_BN_CLICKED(IDC_BUTTON_FILE_TYPES, OnButtonFileTypes)
  150. //}}AFX_MSG_MAP
  151. END_MESSAGE_MAP()
  152. //
  153. // Message Handlers
  154. //
  155. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  156. /* virtual */
  157. HRESULT
  158. CIISMachinePage::FetchLoadedValues()
  159. /*++
  160. Routine Description:
  161. Move configuration data from sheet to dialog controls
  162. Arguments:
  163. None
  164. Return Value:
  165. HRESULT
  166. --*/
  167. {
  168. CError err;
  169. BEGIN_META_MACHINE_READ(CIISMachineSheet)
  170. FETCH_MACHINE_DATA_FROM_SHEET(m_fEnableMetabaseEdit)
  171. FETCH_MACHINE_DATA_FROM_SHEET(m_fUTF8Web)
  172. END_META_MACHINE_READ(err);
  173. m_fUTF8Web_Init = m_fUTF8Web;
  174. CMetabasePath mime_path(FALSE, QueryMetaPath(), SZ_MBN_MIMEMAP);
  175. m_ppropMimeTypes = new CMimeTypes(
  176. QueryAuthInfo(),
  177. mime_path
  178. );
  179. if (m_ppropMimeTypes)
  180. {
  181. err = m_ppropMimeTypes->LoadData();
  182. if (err.Succeeded())
  183. {
  184. m_strlMimeTypes = m_ppropMimeTypes->m_strlMimeTypes;
  185. }
  186. }
  187. else
  188. {
  189. err = ERROR_NOT_ENOUGH_MEMORY;
  190. }
  191. return err;
  192. }
  193. /* virtual */
  194. HRESULT
  195. CIISMachinePage::SaveInfo()
  196. /*++
  197. Routine Description:
  198. Save the information on this property page.
  199. --*/
  200. {
  201. ASSERT(IsDirty());
  202. CError err;
  203. BeginWaitCursor();
  204. BEGIN_META_MACHINE_WRITE(CIISMachineSheet)
  205. STORE_MACHINE_DATA_ON_SHEET(m_fEnableMetabaseEdit)
  206. STORE_MACHINE_DATA_ON_SHEET(m_fUTF8Web)
  207. END_META_MACHINE_WRITE(err);
  208. if (m_fUTF8Web_Init != m_fUTF8Web)
  209. {
  210. GetSheet()->SetRestartRequired(TRUE, PROP_CHANGE_NO_UPDATE);
  211. m_fUTF8Web_Init = m_fUTF8Web;
  212. }
  213. if (err.Succeeded() && m_ppropMimeTypes)
  214. {
  215. m_ppropMimeTypes->m_strlMimeTypes = m_strlMimeTypes;
  216. err = m_ppropMimeTypes->WriteDirtyProps();
  217. }
  218. EndWaitCursor();
  219. return err;
  220. }
  221. BOOL
  222. CIISMachinePage::OnInitDialog()
  223. {
  224. CInetPropertyPage::OnInitDialog();
  225. CError err;
  226. CIISMBNode * pMachine = (CIISMBNode *)GetSheet()->GetParameter();
  227. ASSERT(pMachine != NULL);
  228. if (pMachine)
  229. {
  230. err = CheckForMetabaseAccess(METADATA_PERMISSION_READ,pMachine,TRUE);
  231. if (err.Succeeded())
  232. {
  233. if ( GetSheet()->QueryMajorVersion() < VER_IISMAJORVERSION
  234. || GetSheet()->QueryMinorVersion() < VER_IISMINORVERSION
  235. )
  236. {
  237. m_EnableMetabaseEdit.EnableWindow(FALSE);
  238. m_UTF8Web.EnableWindow(FALSE);
  239. }
  240. else
  241. {
  242. BOOL bWeb = FALSE;
  243. IConsoleNameSpace2 * pConsoleNameSpace = (IConsoleNameSpace2 *)pMachine->GetConsoleNameSpace();
  244. if (!pMachine->IsExpanded())
  245. {
  246. err = pConsoleNameSpace->Expand(pMachine->QueryScopeItem());
  247. }
  248. HSCOPEITEM child = NULL;
  249. MMC_COOKIE cookie = 0;
  250. err = pConsoleNameSpace->GetChildItem(pMachine->QueryScopeItem(), (MMC_COOKIE *) &child, &cookie);
  251. while (err.Succeeded())
  252. {
  253. CIISService * pService = (CIISService *)cookie;
  254. ASSERT(pService != NULL);
  255. if (0 == _tcsicmp(pService->GetNodeName(), SZ_MBN_WEB))
  256. {
  257. bWeb = TRUE;
  258. }
  259. err = pConsoleNameSpace->GetNextItem(child, &child, (MMC_COOKIE *) &cookie);
  260. }
  261. m_UTF8Web.EnableWindow(bWeb);
  262. }
  263. return TRUE;
  264. }
  265. else
  266. {
  267. return FALSE;
  268. }
  269. }
  270. else
  271. {
  272. return FALSE;
  273. }
  274. }
  275. void
  276. CIISMachinePage::OnCheckEnableEdit()
  277. {
  278. SetModified(TRUE);
  279. }
  280. void
  281. CIISMachinePage::OnCheckUTF8()
  282. {
  283. SetModified(TRUE);
  284. }
  285. void
  286. CIISMachinePage::OnButtonFileTypes()
  287. /*++
  288. Routine Description:
  289. 'file types' button handler
  290. Arguments:
  291. None
  292. Return Value:
  293. None
  294. --*/
  295. {
  296. CMimeDlg dlg(m_strlMimeTypes, this);
  297. if (dlg.DoModal() == IDOK)
  298. {
  299. SetModified(TRUE);
  300. }
  301. }