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.

316 lines
9.5 KiB

  1. // approcpg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include <iadmw.h>
  5. #include "cnfgprts.h"
  6. #include "wrapmb.h"
  7. #include "metatool.h"
  8. #include <iiscnfg.h>
  9. #include "approcpg.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. enum
  16. {
  17. SCRIPTCHACHE_NONE = 0,
  18. SCRIPTCHACHE_ALL,
  19. SCRIPTCHACHE_SOME
  20. };
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CAppProcPage dialog
  23. IMPLEMENT_DYNCREATE(CAppProcPage, CPropertyPage)
  24. //---------------------------------------------------------------------------
  25. CAppProcPage::CAppProcPage() : CPropertyPage(CAppProcPage::IDD),
  26. m_fInitialized( FALSE )
  27. {
  28. //{{AFX_DATA_INIT(CAppProcPage)
  29. m_dw_cache_size = 0;
  30. m_bool_write_fail_parent = FALSE;
  31. m_dw_engine_cache_max = 0;
  32. m_int_scriptcache = -1;
  33. m_dw_cgiseconds = 0;
  34. m_bool_catch_exceptions = FALSE;
  35. //}}AFX_DATA_INIT
  36. }
  37. //---------------------------------------------------------------------------
  38. void CAppProcPage::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CAppProcPage)
  42. DDX_Control(pDX, IDC_EDT_CACHE_SIZE, m_cedit_cache_size);
  43. DDX_Text(pDX, IDC_EDT_CACHE_SIZE, m_dw_cache_size);
  44. DDV_MinMaxDWord(pDX, m_dw_cache_size, 0, 4095);
  45. DDX_Check(pDX, IDC_CHK_WRITE_FAIL_TO_LOG, m_bool_write_fail_parent);
  46. DDX_Text(pDX, IDC_EDT_NUM_ENGINES, m_dw_engine_cache_max);
  47. DDX_Radio(pDX, IDC_RDO_CACHE_NONE, m_int_scriptcache);
  48. DDX_Text(pDX, IDC_CGI_SECONDS, m_dw_cgiseconds);
  49. DDX_Check(pDX, IDC_CHK_EXCEPTION_CATCH, m_bool_catch_exceptions);
  50. //}}AFX_DATA_MAP
  51. }
  52. //---------------------------------------------------------------------------
  53. BEGIN_MESSAGE_MAP(CAppProcPage, CDialog)
  54. //{{AFX_MSG_MAP(CAppProcPage)
  55. ON_BN_CLICKED(IDC_RDO_CACHE_ALL, OnRdoCacheAll)
  56. ON_BN_CLICKED(IDC_RDO_CACHE_SIZE, OnRdoCacheSize)
  57. ON_EN_CHANGE(IDC_EDT_CACHE_SIZE, OnChangeEdtCacheSize)
  58. ON_BN_CLICKED(IDC_CHK_WRITE_FAIL_TO_LOG, OnChkWriteFailToLog)
  59. ON_EN_CHANGE(IDC_EDT_NUM_ENGINES, OnChangeEdtNumEngines)
  60. ON_BN_CLICKED(IDC_RDO_CACHE_NONE, OnRdoCacheNone)
  61. ON_EN_CHANGE(IDC_CGI_SECONDS, OnChangeCgiSeconds)
  62. ON_BN_CLICKED(IDC_CHK_EXCEPTION_CATCH, OnChkExceptionCatch)
  63. //}}AFX_MSG_MAP
  64. ON_COMMAND(ID_HELP_FINDER, DoHelp)
  65. ON_COMMAND(ID_HELP, DoHelp)
  66. ON_COMMAND(ID_CONTEXT_HELP, DoHelp)
  67. ON_COMMAND(ID_DEFAULT_HELP, DoHelp)
  68. END_MESSAGE_MAP()
  69. //---------------------------------------------------------------------------
  70. void CAppProcPage::DoHelp()
  71. {
  72. // go to the appropriate helpmapping
  73. // if ( m_fInProcGlobal )
  74. // WinHelp( HIDD_APPMAPS_IN_PROC_GLOBAL );
  75. // else
  76. WinHelp( HIDD_APPMAPS_OUT_OF_PROC );
  77. }
  78. //---------------------------------------------------------------------------
  79. void CAppProcPage::EnableItems()
  80. {
  81. UpdateData( TRUE );
  82. if ( m_int_scriptcache == SCRIPTCHACHE_SOME )
  83. {
  84. m_cedit_cache_size.EnableWindow( TRUE );
  85. }
  86. else
  87. {
  88. m_cedit_cache_size.EnableWindow( FALSE );
  89. }
  90. }
  91. //---------------------------------------------------------------------------
  92. void CAppProcPage::Init()
  93. {
  94. UpdateData( TRUE );
  95. DWORD dw;
  96. // we will just be pulling stuff out of the metabase here
  97. // prepare the metabase wrapper
  98. CWrapMetaBase mbWrap;
  99. if ( !mbWrap.FInit(m_pMB) ) return;
  100. // open the target
  101. if ( mbWrap.Open( m_szMeta, METADATA_PERMISSION_READ ) )
  102. {
  103. // CGI Timeout
  104. m_dw_cgiseconds = 0;
  105. if ( mbWrap.GetDword( _T(""), MD_SCRIPT_TIMEOUT, IIS_MD_UT_FILE, &dw, METADATA_INHERIT ) )
  106. {
  107. m_dw_cgiseconds = dw;
  108. }
  109. else
  110. m_dw_cgiseconds = 900;
  111. // script file cache
  112. m_dw_cache_size = 0xFFFFFFFF;
  113. if ( mbWrap.GetDword( _T(""), MD_ASP_SCRIPTFILECACHESIZE, IIS_MD_UT_WAM, &dw, METADATA_INHERIT ) )
  114. {
  115. if ( dw == 0 )
  116. {
  117. m_int_scriptcache = SCRIPTCHACHE_NONE;
  118. m_dw_cache_size = 1000;
  119. }
  120. else if ( dw != 0xFFFFFFFF )
  121. {
  122. m_int_scriptcache = SCRIPTCHACHE_SOME;
  123. m_dw_cache_size = dw;
  124. }
  125. }
  126. // if the cache size is -1 (0xFFFFFFFF)
  127. if ( m_dw_cache_size == 0xFFFFFFFF )
  128. {
  129. m_int_scriptcache = SCRIPTCHACHE_ALL;
  130. m_dw_cache_size = 1000;
  131. }
  132. // read the write errors flag
  133. if ( mbWrap.GetDword( _T(""), MD_ASP_LOGERRORREQUESTS, IIS_MD_UT_WAM, &dw, METADATA_INHERIT ) )
  134. m_bool_write_fail_parent = dw;
  135. else
  136. m_bool_write_fail_parent = TRUE; // default
  137. // read the max engine cache
  138. if ( mbWrap.GetDword( _T(""), MD_ASP_SCRIPTENGINECACHEMAX, IIS_MD_UT_WAM, &dw, METADATA_INHERIT ) )
  139. m_dw_engine_cache_max = dw;
  140. else
  141. m_dw_engine_cache_max = 30; // default
  142. // get the exception catching
  143. if ( mbWrap.GetDword( _T(""), MD_ASP_EXCEPTIONCATCHENABLE, IIS_MD_UT_WAM, &dw, METADATA_INHERIT ) )
  144. m_bool_catch_exceptions = dw;
  145. else
  146. m_bool_catch_exceptions = 0;
  147. // close the metabase
  148. mbWrap.Close();
  149. }
  150. // set the data into place
  151. UpdateData( FALSE );
  152. // enable the approprieate items
  153. EnableItems();
  154. }
  155. //----------------------------------------------------------------
  156. // blow away the parameters
  157. void CAppProcPage::BlowAwayParameters()
  158. {
  159. // prepare the metabase wrapper
  160. CWrapMetaBase mbWrap;
  161. if ( !mbWrap.FInit(m_pMB) ) return;
  162. // open the target
  163. if ( mbWrap.Open( m_szMeta, METADATA_PERMISSION_WRITE ) )
  164. {
  165. mbWrap.DeleteData( _T(""), MD_SCRIPT_TIMEOUT, DWORD_METADATA );
  166. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTFILECACHESIZE, DWORD_METADATA );
  167. mbWrap.DeleteData( _T(""), MD_ASP_LOGERRORREQUESTS, DWORD_METADATA );
  168. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTENGINECACHEMAX, DWORD_METADATA );
  169. mbWrap.DeleteData( _T(""), MD_ASP_EXCEPTIONCATCHENABLE, DWORD_METADATA );
  170. /*
  171. mbWrap.DeleteData( _T(""), MD_SCRIPT_TIMEOUT, IIS_MD_UT_FILE, DWORD_METADATA );
  172. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTFILECACHESIZE, IIS_MD_UT_WAM, DWORD_METADATA );
  173. mbWrap.DeleteData( _T(""), MD_ASP_LOGERRORREQUESTS, IIS_MD_UT_WAM, DWORD_METADATA );
  174. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTENGINECACHEMAX, IIS_MD_UT_WAM, DWORD_METADATA );
  175. mbWrap.DeleteData( _T(""), MD_ASP_EXCEPTIONCATCHENABLE, IIS_MD_UT_WAM, DWORD_METADATA );
  176. */
  177. // close the metabase
  178. mbWrap.Close();
  179. }
  180. }
  181. /////////////////////////////////////////////////////////////////////////////
  182. // CAppProcPage message handlers
  183. //----------------------------------------------------------------
  184. BOOL CAppProcPage::OnSetActive()
  185. {
  186. // if this is the first time, init the parameters
  187. if ( !m_fInitialized )
  188. {
  189. Init();
  190. m_fInitialized = TRUE;
  191. }
  192. return CPropertyPage::OnSetActive();
  193. }
  194. //----------------------------------------------------------------
  195. BOOL CAppProcPage::OnApply()
  196. {
  197. DWORD dwCache = 0; // local cache reference
  198. BOOL f;
  199. UpdateData( TRUE );
  200. // set the correct cache size
  201. switch( m_int_scriptcache )
  202. {
  203. case SCRIPTCHACHE_NONE:
  204. dwCache = 0;
  205. break;
  206. case SCRIPTCHACHE_ALL:
  207. dwCache = 0xFFFFFFFF;
  208. break;
  209. case SCRIPTCHACHE_SOME:
  210. dwCache = m_dw_cache_size;
  211. break;
  212. };
  213. // exception catching
  214. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_EXCEPTIONCATCHENABLE,
  215. IIS_MD_UT_WAM, m_bool_catch_exceptions, TRUE );
  216. // cgi timeout
  217. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_SCRIPT_TIMEOUT,
  218. IIS_MD_UT_FILE, m_dw_cgiseconds, TRUE );
  219. // script file size
  220. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_SCRIPTFILECACHESIZE,
  221. IIS_MD_UT_WAM, dwCache, TRUE );
  222. // write errors
  223. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_LOGERRORREQUESTS,
  224. IIS_MD_UT_WAM, m_bool_write_fail_parent, TRUE );
  225. // max engine cache
  226. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_SCRIPTENGINECACHEMAX,
  227. IIS_MD_UT_WAM, m_dw_engine_cache_max, TRUE );
  228. SetModified( FALSE );
  229. return CPropertyPage::OnApply();
  230. }
  231. //----------------------------------------------------------------
  232. void CAppProcPage::OnRdoCacheNone()
  233. {
  234. EnableItems();
  235. SetModified();
  236. }
  237. //----------------------------------------------------------------
  238. void CAppProcPage::OnRdoCacheAll()
  239. {
  240. EnableItems();
  241. SetModified();
  242. }
  243. //----------------------------------------------------------------
  244. void CAppProcPage::OnRdoCacheSize()
  245. {
  246. EnableItems();
  247. SetModified();
  248. }
  249. //----------------------------------------------------------------
  250. void CAppProcPage::OnChangeEdtCacheSize()
  251. {
  252. SetModified();
  253. }
  254. //----------------------------------------------------------------
  255. void CAppProcPage::OnChkWriteFailToLog()
  256. {
  257. SetModified();
  258. }
  259. //----------------------------------------------------------------
  260. void CAppProcPage::OnChangeEdtNumEngines()
  261. {
  262. SetModified();
  263. }
  264. //----------------------------------------------------------------
  265. void CAppProcPage::OnChangeCgiSeconds()
  266. {
  267. SetModified();
  268. }
  269. //----------------------------------------------------------------
  270. void CAppProcPage::OnChkExceptionCatch()
  271. {
  272. SetModified();
  273. }