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.

145 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. objsf.h
  5. Abstract:
  6. Definitions for CMdhcpObjectSafety class.
  7. --*/
  8. #ifndef _MDHCP_OBJECT_SAFETY_
  9. #define _MDHCP_OBJECT_SAFETY_
  10. #define IDD_TAPI_SECURITY_DIALOG 500
  11. #define IDC_SECURITY_WARNING_TEXT 502
  12. #define IDC_DONOT_PROMPT_IN_THE_FUTURE 503
  13. #define ID_YES 505
  14. #define ID_NO 506
  15. #define ID_YES_DONT_ASK_AGAIN 557
  16. #define IDS_MADCAP_SEC_PROMPT 92
  17. #include <PromptedObjectSafety.h>
  18. #include <ScrpScrtDlg.h>
  19. #include <ObjectWithSite.h>
  20. static const TCHAR gszCookieName[] = _T("Mdhcp");
  21. //
  22. // this will pop a message box asking if we want to enable object safety
  23. //
  24. class CMdhcpObjectSafety :
  25. public CPromptedObjectSafety,
  26. public CObjectWithSite
  27. {
  28. public:
  29. //
  30. // call CObjectWithSite's constructor and pass in the cookie name
  31. //
  32. CMdhcpObjectSafety()
  33. :CObjectWithSite(gszCookieName)
  34. {
  35. }
  36. //
  37. // implementing CPromptedObjectSafety's pure virtual method
  38. // if the page is not in the safe list, and this is the first
  39. // time we are asking, prompt the user. act accordingly.
  40. // if the user chooses, mark the page safe for scripting (persistently)
  41. //
  42. virtual BOOL Ask()
  43. {
  44. //
  45. // if the object does not have a site pointer, we should not consider
  46. // it to be safe. Do not display the prompt.
  47. //
  48. if ( !HaveSite() )
  49. {
  50. return FALSE;
  51. }
  52. EnValidation enCurrentValidation = GetValidation();
  53. //
  54. // if the page has not been validated, try to validate it.
  55. //
  56. if (UNVALIDATED == enCurrentValidation)
  57. {
  58. if( IsIntranet())
  59. {
  60. Validate(VALIDATED_SAFE);
  61. enCurrentValidation = GetValidation();
  62. return TRUE;
  63. }
  64. CScriptSecurityDialog *pDialog = new CScriptSecurityDialog;
  65. //
  66. // if succeeded displaying the dialog
  67. // validate the page based on user's input
  68. //
  69. if ( NULL != pDialog )
  70. {
  71. switch (pDialog->DoModalWithText(IDS_MADCAP_SEC_PROMPT))
  72. {
  73. case ID_YES:
  74. Validate(VALIDATED_SAFE);
  75. break;
  76. case ID_NO:
  77. Validate(VALIDATED_UNSAFE);
  78. break;
  79. case ID_YES_DONT_ASK_AGAIN:
  80. Validate(VALIDATED_SAFE_PERMANENT);
  81. break;
  82. default:
  83. break;
  84. }
  85. delete pDialog;
  86. //
  87. // get the new validation.
  88. //
  89. enCurrentValidation = GetValidation();
  90. } // if (NULL != pDialog)
  91. }
  92. //
  93. // by now we either got the validation data or validation did not change
  94. //
  95. // return true if the page is validated as safe
  96. //
  97. return (VALIDATED_SAFE == enCurrentValidation) ;
  98. }
  99. };
  100. #endif // _MDHCP_OBJECT_SAFETY_