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.

303 lines
10 KiB

  1. // AspMnPg.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 "AspMnPg.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. #define SIZE_MBYTE 1048576
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CAppAspMainPage property page
  18. IMPLEMENT_DYNCREATE(CAppAspMainPage, CPropertyPage)
  19. //---------------------------------------------------------------------------
  20. CAppAspMainPage::CAppAspMainPage() : CPropertyPage(CAppAspMainPage::IDD),
  21. m_fInitialized( FALSE )
  22. {
  23. //{{AFX_DATA_INIT(CAppAspMainPage)
  24. m_dw_session_timeout = 0;
  25. m_bool_enable_session = FALSE;
  26. m_bool_enable_parents = FALSE;
  27. m_bool_enable_buffering = FALSE;
  28. m_sz_default_language = _T("");
  29. m_dw_script_timeout = 1;
  30. //}}AFX_DATA_INIT
  31. }
  32. //---------------------------------------------------------------------------
  33. CAppAspMainPage::~CAppAspMainPage()
  34. {
  35. }
  36. //---------------------------------------------------------------------------
  37. void CAppAspMainPage::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CPropertyPage::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CAppAspMainPage)
  41. DDX_Control(pDX, IDC_LANG_TITLE, m_cstatic_lang_title);
  42. DDX_Control(pDX, IDC_SESSION_UNITS, m_cstatic_session_units);
  43. DDX_Control(pDX, IDC_SESSION_TITLE, m_cstatic_session_title);
  44. DDX_Control(pDX, IDC_EDT_SESSION_TIMEOUT, m_cedit_session_timeout);
  45. DDX_Text(pDX, IDC_EDT_SESSION_TIMEOUT, m_dw_session_timeout);
  46. DDX_Text(pDX, IDC_EDT_SCRIPT_TIMEOUT, m_dw_script_timeout);
  47. DDV_MinMaxDWord(pDX, m_dw_script_timeout, 1, 2147483647);
  48. DDX_Check(pDX, IDC_CHK_ENABLE_BUFFERING, m_bool_enable_buffering);
  49. DDX_Check(pDX, IDC_CHK_ENABLE_SESSION, m_bool_enable_session);
  50. DDX_Check(pDX, IDC_CHK_ENABLE_PARENTS, m_bool_enable_parents);
  51. DDX_Text(pDX, IDC_EDT_LANGUAGES, m_sz_default_language);
  52. //}}AFX_DATA_MAP
  53. }
  54. //---------------------------------------------------------------------------
  55. BEGIN_MESSAGE_MAP(CAppAspMainPage, CPropertyPage)
  56. //{{AFX_MSG_MAP(CAppAspMainPage)
  57. ON_EN_CHANGE(IDC_EDT_SESSION_TIMEOUT, OnChangeEdtSessionTimeout)
  58. ON_BN_CLICKED(IDC_CHK_ENABLE_SESSION, OnChkEnableSession)
  59. ON_BN_CLICKED(IDC_CHK_ENABLE_PARENTS, OnChkEnableParents)
  60. ON_BN_CLICKED(IDC_CHK_POOL_ODBC, OnChkPoolOdbc)
  61. ON_BN_CLICKED(IDC_CHK_ENABLE_BUFFERING, OnChkEnableBuffering)
  62. ON_CBN_SELCHANGE(IDC_CMBO_LANGUAGES, OnSelchangeCmboLanguages)
  63. ON_EN_CHANGE(IDC_EDT_LANGUAGES, OnChangeEdtLanguages)
  64. ON_EN_CHANGE(IDC_EDT_SCRIPT_TIMEOUT, OnChangeEdtScriptTimeout)
  65. //}}AFX_MSG_MAP
  66. ON_COMMAND(ID_HELP_FINDER, DoHelp)
  67. ON_COMMAND(ID_HELP, DoHelp)
  68. ON_COMMAND(ID_CONTEXT_HELP, DoHelp)
  69. ON_COMMAND(ID_DEFAULT_HELP, DoHelp)
  70. END_MESSAGE_MAP()
  71. //---------------------------------------------------------------------------
  72. void CAppAspMainPage::DoHelp()
  73. {
  74. WinHelp( HIDD_APPMAPS_ASP_MAIN );
  75. }
  76. //---------------------------------------------------------------------------
  77. void CAppAspMainPage::EnableItems()
  78. {
  79. UpdateData( TRUE );
  80. if ( m_bool_enable_session )
  81. {
  82. m_cstatic_session_units.EnableWindow( TRUE );
  83. m_cstatic_session_title.EnableWindow( TRUE );
  84. m_cedit_session_timeout.EnableWindow( TRUE );
  85. }
  86. else
  87. {
  88. m_cstatic_session_units.EnableWindow( FALSE );
  89. m_cstatic_session_title.EnableWindow( FALSE );
  90. m_cedit_session_timeout.EnableWindow( FALSE );
  91. }
  92. }
  93. //---------------------------------------------------------------------------
  94. void CAppAspMainPage::Init()
  95. {
  96. UpdateData( TRUE );
  97. DWORD dw;
  98. // we will just be pulling stuff out of the metabase here
  99. // prepare the metabase wrapper
  100. CWrapMetaBase mbWrap;
  101. if ( !mbWrap.FInit(m_pMB) ) return;
  102. // open the target
  103. if ( mbWrap.Open( m_szMeta, METADATA_PERMISSION_READ ) )
  104. {
  105. // read the enable buffering flag
  106. if ( mbWrap.GetDword( _T(""), MD_ASP_BUFFERINGON, ASP_MD_UT_APP, &dw, METADATA_INHERIT ) )
  107. m_bool_enable_buffering = dw;
  108. else
  109. m_bool_enable_buffering = FALSE; // default
  110. // read the session state information
  111. if ( mbWrap.GetDword( _T(""), MD_ASP_ALLOWSESSIONSTATE, ASP_MD_UT_APP, &dw, METADATA_INHERIT ) )
  112. m_bool_enable_session = dw;
  113. else
  114. m_bool_enable_session = TRUE; // default
  115. // read the script timeout
  116. if ( mbWrap.GetDword( _T(""), MD_ASP_SCRIPTTIMEOUT, ASP_MD_UT_APP, &dw, METADATA_INHERIT ) )
  117. m_dw_script_timeout = dw;
  118. else
  119. m_dw_script_timeout = 90; // default
  120. // read the session timeout information
  121. if ( mbWrap.GetDword( _T(""), MD_ASP_SESSIONTIMEOUT, ASP_MD_UT_APP, &dw, METADATA_INHERIT ) )
  122. m_dw_session_timeout = dw;
  123. else
  124. m_dw_session_timeout = 20; // default
  125. // read the enable parent paths flag
  126. if ( mbWrap.GetDword( _T(""), MD_ASP_ENABLEPARENTPATHS, ASP_MD_UT_APP, &dw, METADATA_INHERIT ) )
  127. m_bool_enable_parents = dw;
  128. else
  129. m_bool_enable_parents = TRUE; // default
  130. // now get the currently selected language and choose it in the combo box
  131. WCHAR* pstr = (WCHAR*)mbWrap.GetData( _T(""), MD_ASP_SCRIPTLANGUAGE, ASP_MD_UT_APP, STRING_METADATA, &dw, METADATA_INHERIT );
  132. if ( pstr )
  133. {
  134. m_sz_default_language = pstr;
  135. mbWrap.FreeWrapData( (PVOID)pstr );
  136. }
  137. // close the metabase
  138. mbWrap.Close();
  139. }
  140. // set the data into place
  141. UpdateData( FALSE );
  142. // enable the approprieate items
  143. EnableItems();
  144. }
  145. //----------------------------------------------------------------
  146. // blow away the parameters
  147. void CAppAspMainPage::BlowAwayParameters()
  148. {
  149. // prepare the metabase wrapper
  150. CWrapMetaBase mbWrap;
  151. if ( !mbWrap.FInit(m_pMB) ) return;
  152. // open the target
  153. if ( mbWrap.Open( m_szMeta, METADATA_PERMISSION_WRITE ) )
  154. {
  155. mbWrap.DeleteData( _T(""), MD_ASP_BUFFERINGON, DWORD_METADATA );
  156. mbWrap.DeleteData( _T(""), MD_ASP_ALLOWSESSIONSTATE, DWORD_METADATA );
  157. mbWrap.DeleteData( _T(""), MD_ASP_SESSIONTIMEOUT, DWORD_METADATA );
  158. mbWrap.DeleteData( _T(""), MD_ASP_ENABLEPARENTPATHS, DWORD_METADATA );
  159. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTLANGUAGE, STRING_METADATA );
  160. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTTIMEOUT, DWORD_METADATA );
  161. /*
  162. mbWrap.DeleteData( _T(""), MD_ASP_BUFFERINGON, ASP_MD_UT_APP, DWORD_METADATA );
  163. mbWrap.DeleteData( _T(""), MD_ASP_ALLOWSESSIONSTATE, ASP_MD_UT_APP, DWORD_METADATA );
  164. mbWrap.DeleteData( _T(""), MD_ASP_SESSIONTIMEOUT, ASP_MD_UT_APP, DWORD_METADATA );
  165. mbWrap.DeleteData( _T(""), MD_ASP_ENABLEPARENTPATHS, ASP_MD_UT_APP, DWORD_METADATA );
  166. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTLANGUAGE, ASP_MD_UT_APP, STRING_METADATA );
  167. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTTIMEOUT, ASP_MD_UT_APP, DWORD_METADATA );
  168. */
  169. // close the metabase
  170. mbWrap.Close();
  171. }
  172. }
  173. /////////////////////////////////////////////////////////////////////////////
  174. // CAppAspMainPage message handlers
  175. //----------------------------------------------------------------
  176. BOOL CAppAspMainPage::OnSetActive()
  177. {
  178. // if this is the first time, init the parameters
  179. if ( !m_fInitialized )
  180. {
  181. Init();
  182. m_fInitialized = TRUE;
  183. }
  184. return CPropertyPage::OnSetActive();
  185. }
  186. //----------------------------------------------------------------
  187. BOOL CAppAspMainPage::OnApply()
  188. {
  189. DWORD dwCache = 0; // local cache reference
  190. BOOL f;
  191. UpdateData( TRUE );
  192. // clean up the script string
  193. m_sz_default_language.TrimLeft();
  194. m_sz_default_language.TrimRight();
  195. // prepare the metabase wrapper
  196. CWrapMetaBase mbWrap;
  197. if ( !mbWrap.FInit(m_pMB) ) return FALSE;
  198. // session state
  199. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_ALLOWSESSIONSTATE,
  200. ASP_MD_UT_APP, m_bool_enable_session, TRUE );
  201. // session timeout
  202. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_SESSIONTIMEOUT,
  203. ASP_MD_UT_APP, m_dw_session_timeout, TRUE );
  204. // enable parent paths
  205. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_ENABLEPARENTPATHS,
  206. ASP_MD_UT_APP, m_bool_enable_parents, TRUE );
  207. // enable buffering
  208. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_BUFFERINGON,
  209. ASP_MD_UT_APP, m_bool_enable_buffering, TRUE );
  210. // script timeout
  211. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_SCRIPTTIMEOUT,
  212. ASP_MD_UT_APP, m_dw_script_timeout, TRUE );
  213. // script language
  214. f = SetMetaString( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_SCRIPTLANGUAGE,
  215. ASP_MD_UT_APP, m_sz_default_language, TRUE );
  216. SetModified( FALSE );
  217. return CPropertyPage::OnApply();
  218. }
  219. //----------------------------------------------------------------
  220. void CAppAspMainPage::OnChangeEdtSessionTimeout()
  221. {
  222. SetModified();
  223. }
  224. //----------------------------------------------------------------
  225. void CAppAspMainPage::OnChkEnableSession()
  226. {
  227. EnableItems();
  228. SetModified();
  229. }
  230. //----------------------------------------------------------------
  231. void CAppAspMainPage::OnChkEnableParents()
  232. {
  233. SetModified();
  234. }
  235. //----------------------------------------------------------------
  236. void CAppAspMainPage::OnChkPoolOdbc()
  237. {
  238. SetModified();
  239. }
  240. //----------------------------------------------------------------
  241. void CAppAspMainPage::OnChkEnableBuffering()
  242. {
  243. SetModified();
  244. }
  245. //----------------------------------------------------------------
  246. void CAppAspMainPage::OnSelchangeCmboLanguages()
  247. {
  248. SetModified();
  249. }
  250. //----------------------------------------------------------------
  251. void CAppAspMainPage::OnChangeEdtLanguages()
  252. {
  253. SetModified();
  254. }
  255. //----------------------------------------------------------------
  256. void CAppAspMainPage::OnChangeEdtScriptTimeout()
  257. {
  258. SetModified();
  259. }