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.

255 lines
7.9 KiB

  1. // AspDbgPg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include <iadmw.h>
  5. #include "cnfgprts.h"
  6. #include "AspDbgPg.h"
  7. #include "wrapmb.h"
  8. #include "metatool.h"
  9. #include <iiscnfg.h>
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CAppAspDebugPage property page
  17. IMPLEMENT_DYNCREATE(CAppAspDebugPage, CPropertyPage)
  18. //---------------------------------------------------------------------------
  19. CAppAspDebugPage::CAppAspDebugPage() : CPropertyPage(CAppAspDebugPage::IDD),
  20. m_fInitialized( FALSE )
  21. {
  22. //{{AFX_DATA_INIT(CAppAspDebugPage)
  23. m_sz_error = _T("");
  24. m_bool_client_debug = FALSE;
  25. m_bool_server_debug = FALSE;
  26. m_int_SendError = -1;
  27. //}}AFX_DATA_INIT
  28. }
  29. //---------------------------------------------------------------------------
  30. CAppAspDebugPage::~CAppAspDebugPage()
  31. {
  32. }
  33. //---------------------------------------------------------------------------
  34. void CAppAspDebugPage::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CPropertyPage::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CAppAspDebugPage)
  38. DDX_Control(pDX, IDC_DEFAULT_ERROR, m_cedit_error);
  39. DDX_Text(pDX, IDC_DEFAULT_ERROR, m_sz_error);
  40. DDX_Check(pDX, IDC_CHK_CLIENT_DEBUG, m_bool_client_debug);
  41. DDX_Check(pDX, IDC_CHK_SERVER_DEBUG, m_bool_server_debug);
  42. DDX_Radio(pDX, IDC_RDO_SEND_DETAILED_ERROR, m_int_SendError);
  43. //}}AFX_DATA_MAP
  44. }
  45. //---------------------------------------------------------------------------
  46. BEGIN_MESSAGE_MAP(CAppAspDebugPage, CPropertyPage)
  47. //{{AFX_MSG_MAP(CAppAspDebugPage)
  48. ON_BN_CLICKED(IDC_RDO_SEND_DEF_ERROR, OnRdoSendDefError)
  49. ON_BN_CLICKED(IDC_RDO_SEND_DETAILED_ERROR, OnRdoSendDetailedError)
  50. ON_EN_CHANGE(IDC_DEFAULT_ERROR, OnChangeDefaultError)
  51. ON_BN_CLICKED(IDC_CHK_CLIENT_DEBUG, OnChkClientDebug)
  52. ON_BN_CLICKED(IDC_CHK_SERVER_DEBUG, OnChkServerDebug)
  53. //}}AFX_MSG_MAP
  54. ON_COMMAND(ID_HELP_FINDER, DoHelp)
  55. ON_COMMAND(ID_HELP, DoHelp)
  56. ON_COMMAND(ID_CONTEXT_HELP, DoHelp)
  57. ON_COMMAND(ID_DEFAULT_HELP, DoHelp)
  58. END_MESSAGE_MAP()
  59. //---------------------------------------------------------------------------
  60. void CAppAspDebugPage::DoHelp()
  61. {
  62. WinHelp( HIDD_APPMAPS_ASP_DEBUG );
  63. }
  64. //---------------------------------------------------------------------------
  65. void CAppAspDebugPage::Init()
  66. {
  67. UpdateData( TRUE );
  68. DWORD dw;
  69. WCHAR* pstr;
  70. // we will just be pulling stuff out of the metabase here
  71. // prepare the metabase wrapper
  72. CWrapMetaBase mbWrap;
  73. if ( !mbWrap.FInit(m_pMB) ) return;
  74. // open the target
  75. if ( mbWrap.Open( m_szMeta, METADATA_PERMISSION_READ ) )
  76. {
  77. // first the server debug
  78. if ( mbWrap.GetDword( _T(""), MD_ASP_ENABLESERVERDEBUG, ASP_MD_UT_APP, &dw, METADATA_INHERIT ) )
  79. {
  80. m_bool_server_debug = dw;
  81. }
  82. else
  83. m_bool_server_debug = 0;
  84. // then the client debug
  85. if ( mbWrap.GetDword( _T(""), MD_ASP_ENABLECLIENTDEBUG, ASP_MD_UT_APP, &dw, METADATA_INHERIT ) )
  86. {
  87. m_bool_client_debug = dw;
  88. }
  89. else
  90. m_bool_client_debug = 0;
  91. // now the truncate size
  92. m_int_SendError = 1;
  93. if ( mbWrap.GetDword( _T(""), MD_ASP_SCRIPTERRORSSENTTOBROWSER, ASP_MD_UT_APP, &dw, METADATA_INHERIT ) )
  94. {
  95. if ( dw == 1 )
  96. m_int_SendError = 0;
  97. }
  98. // default error string
  99. pstr = (WCHAR*)mbWrap.GetData( _T(""), MD_ASP_SCRIPTERRORMESSAGE, ASP_MD_UT_APP, STRING_METADATA, &dw, METADATA_INHERIT );
  100. if ( pstr )
  101. {
  102. m_sz_error = pstr;
  103. // free it
  104. mbWrap.FreeWrapData( (PVOID)pstr );
  105. }
  106. else
  107. {
  108. // load a default string
  109. m_sz_error.LoadString( IDS_APP_DEFAULT_ERROR );
  110. }
  111. // close the metabase
  112. mbWrap.Close();
  113. }
  114. // set the data into place
  115. UpdateData( FALSE );
  116. // enable the approprieate items
  117. EnableItems();
  118. }
  119. //---------------------------------------------------------------------------
  120. void CAppAspDebugPage::EnableItems()
  121. {
  122. UpdateData( TRUE );
  123. if ( m_int_SendError == 1 )
  124. {
  125. m_cedit_error.EnableWindow( TRUE );
  126. }
  127. else
  128. {
  129. m_cedit_error.EnableWindow( FALSE );
  130. }
  131. }
  132. //----------------------------------------------------------------
  133. // blow away the parameters
  134. void CAppAspDebugPage::BlowAwayParameters()
  135. {
  136. // prepare the metabase wrapper
  137. CWrapMetaBase mbWrap;
  138. if ( !mbWrap.FInit(m_pMB) ) return;
  139. // open the target
  140. if ( mbWrap.Open( m_szMeta, METADATA_PERMISSION_WRITE ) )
  141. {
  142. mbWrap.DeleteData( _T(""), MD_ASP_ENABLESERVERDEBUG, DWORD_METADATA );
  143. mbWrap.DeleteData( _T(""), MD_ASP_ENABLECLIENTDEBUG, DWORD_METADATA );
  144. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTERRORSSENTTOBROWSER, DWORD_METADATA );
  145. mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTERRORMESSAGE, STRING_METADATA );
  146. // mbWrap.DeleteData( _T(""), MD_ASP_ENABLESERVERDEBUG, ASP_MD_UT_APP, DWORD_METADATA );
  147. // mbWrap.DeleteData( _T(""), MD_ASP_ENABLECLIENTDEBUG, ASP_MD_UT_APP, DWORD_METADATA );
  148. // mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTERRORSSENTTOBROWSER, ASP_MD_UT_APP, DWORD_METADATA );
  149. // mbWrap.DeleteData( _T(""), MD_ASP_SCRIPTERRORMESSAGE, ASP_MD_UT_APP, STRING_METADATA );
  150. // close the metabase
  151. mbWrap.Close();
  152. }
  153. }
  154. /////////////////////////////////////////////////////////////////////////////
  155. // CAppAspDebugPage message handlers
  156. //---------------------------------------------------------------------------
  157. BOOL CAppAspDebugPage::OnApply()
  158. {
  159. // build the save flags first
  160. BOOL f;
  161. UpdateData( TRUE );
  162. // prepare the metabase wrapper
  163. CWrapMetaBase mbWrap;
  164. if ( !mbWrap.FInit(m_pMB) ) return FALSE;
  165. // server side debug
  166. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_ENABLESERVERDEBUG,
  167. ASP_MD_UT_APP, m_bool_server_debug, TRUE );
  168. // client side debug
  169. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_ENABLECLIENTDEBUG,
  170. ASP_MD_UT_APP, m_bool_client_debug, TRUE );
  171. // errors sent to browser
  172. if ( m_int_SendError )
  173. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_SCRIPTERRORSSENTTOBROWSER,
  174. ASP_MD_UT_APP, 0, TRUE );
  175. else
  176. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_SCRIPTERRORSSENTTOBROWSER,
  177. ASP_MD_UT_APP, 1, TRUE );
  178. // error message string to browser
  179. f = SetMetaString( m_pMB, m_szServer, m_szMeta, _T(""), MD_ASP_SCRIPTERRORMESSAGE,
  180. ASP_MD_UT_APP, m_sz_error, TRUE);
  181. return CPropertyPage::OnApply();
  182. }
  183. //---------------------------------------------------------------------------
  184. BOOL CAppAspDebugPage::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. void CAppAspDebugPage::OnRdoSendDefError()
  196. {
  197. EnableItems();
  198. SetModified();
  199. }
  200. //---------------------------------------------------------------------------
  201. void CAppAspDebugPage::OnRdoSendDetailedError()
  202. {
  203. EnableItems();
  204. SetModified();
  205. }
  206. //---------------------------------------------------------------------------
  207. void CAppAspDebugPage::OnChangeDefaultError()
  208. {
  209. SetModified();
  210. }
  211. //---------------------------------------------------------------------------
  212. void CAppAspDebugPage::OnChkClientDebug()
  213. {
  214. SetModified();
  215. }
  216. //---------------------------------------------------------------------------
  217. void CAppAspDebugPage::OnChkServerDebug()
  218. {
  219. SetModified();
  220. }