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.

117 lines
4.2 KiB

  1. /*****************************************************************************\
  2. * MODULE: prnsec.h
  3. *
  4. * PURPOSE: Declaration of the security class that determines the required
  5. * security settings for a com class. Interacts with the security
  6. * manager to determine the zone that we are running under.
  7. *
  8. * Copyright (C) 1999 Microsoft Corporation
  9. *
  10. * History:
  11. *
  12. * 09/2/99 mlawrenc Declaration of security templates
  13. *
  14. \*****************************************************************************/
  15. #ifndef __PRNSEC_H_
  16. #define __PRNSEC_H_
  17. #include "stdafx.h"
  18. #include "urlmon.h"
  19. class ATL_NO_VTABLE COlePrnSecurity {
  20. /*++
  21. Class Description
  22. This is the class that we we use for a mix in in all the printer classes that require
  23. zone based security. It also automatically loads any string resources it needs.
  24. --*/
  25. public:
  26. // Enumeration, Security Messages, these messages must correspond to the resource order
  27. // given from START_SECURITY_DIALOGUE_RES
  28. enum SecurityMessage {
  29. StartMessages = 0,
  30. AddWebPrinterConnection = 0,
  31. AddPrinterConnection,
  32. DeletePrinterConnection,
  33. EndMessages
  34. };
  35. static BOOL InitStrings(void);
  36. static void DeallocStrings(void);
  37. static HRESULT PromptUser( SecurityMessage, LPTSTR );
  38. inline BOOL DisplayUIonDisallow(BOOL); // Set to FALSE if we don't want IE to pop
  39. // up UI on disallow or Query
  40. virtual ~COlePrnSecurity();
  41. protected:
  42. // Protected Methods
  43. COlePrnSecurity(IUnknown *&iSite, DWORD &dwSafety);
  44. HRESULT GetActionPolicy(DWORD dwAction, DWORD &dwPolicy);
  45. // Find out if the action is allowed
  46. private:
  47. // Private Methods
  48. HRESULT SetSecurityManager(void);
  49. static LPTSTR LoadResString(UINT uResId);
  50. static const DWORD dwMaxResBuf;
  51. // Private Data Members
  52. IUnknown* &m_iSite; // The site under which we are located
  53. DWORD &m_dwSafetyFlags; // The safety set for the site
  54. BOOL m_bDisplayUIonDisallow; // Should we ask for UI when Policy is Disallow? Default TRUE
  55. IInternetHostSecurityManager *m_iSecurity; // Use this to get the security information of
  56. // the site we are running under
  57. static LPTSTR m_MsgStrings[EndMessages*2];
  58. };
  59. template<class T>
  60. class ATL_NO_VTABLE COlePrnSecComControl : public CComControl<T>,
  61. public IObjectSafetyImpl<T>,
  62. public COlePrnSecurity {
  63. /*++
  64. Class Description
  65. A class which wishes to use the security control just needs to derive from this.
  66. Used to to illiminate having to templatise COlePrnSecurity
  67. --*/
  68. public:
  69. COlePrnSecComControl() : COlePrnSecurity(*(IUnknown **)&m_spClientSite, m_dwSafety) {}
  70. };
  71. template<class T>
  72. class ATL_NO_VTABLE COlePrnSecObject : public IObjectWithSiteImpl<T>,
  73. public IObjectSafetyImpl<T>,
  74. public COlePrnSecurity
  75. /*++
  76. Class Description
  77. A class which wishes to use the security control just needs to derive from this.
  78. This is for classes that are not OleObjects (i.e. do not have IOleObjectImpl<T> in
  79. their inheritance. IE can use the lighter weight IObjectWithSite interface for
  80. these objects
  81. --*/
  82. {
  83. public:
  84. COlePrnSecObject() : COlePrnSecurity(*(IUnknown **)&m_spUnkSite, m_dwSafety) {}
  85. };
  86. ////////////////////////////////////////////////////////////////////////////////
  87. // INLINE METHODS
  88. ////////////////////////////////////////////////////////////////////////////////
  89. inline BOOL COlePrnSecurity::DisplayUIonDisallow(BOOL bNewSetting) {
  90. BOOL bOldSetting = m_bDisplayUIonDisallow;
  91. m_bDisplayUIonDisallow = bNewSetting;
  92. return bOldSetting;
  93. }
  94. #endif // __PRNSEC_H_
  95. /*******************************************************************************
  96. ** End of File (prnsec.h)
  97. *******************************************************************************/