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.

176 lines
5.7 KiB

  1. //
  2. // Dependencies
  3. //
  4. class ADDRESS_CHECK;
  5. class CTcpAccess;
  6. class CTcpAccessExceptions;
  7. class CTcpAccessException;
  8. class CMetabaseKey;
  9. /////////////////////////////////////////////////////////////////////////////
  10. // The TcpAccess Object
  11. class CTcpAccess :
  12. public CComDualImpl<ITcpAccess, &IID_ITcpAccess, &LIBID_SMTPADMLib>,
  13. public ISupportErrorInfo,
  14. public CComObjectRoot
  15. {
  16. public:
  17. CTcpAccess();
  18. virtual ~CTcpAccess ();
  19. BEGIN_COM_MAP(CTcpAccess)
  20. COM_INTERFACE_ENTRY(IDispatch)
  21. COM_INTERFACE_ENTRY(ITcpAccess)
  22. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  23. END_COM_MAP()
  24. //DECLARE_NOT_AGGREGATABLE(CTcpAccess)
  25. // Remove the comment from the line above if you don't want your object to
  26. // support aggregation. The default is to support it
  27. // ISupportsErrorInfo
  28. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  29. // DECLARE_REGISTRY(CTcpAccess, _T("Smtpadm.TcpAccess.1"), _T("Smtpadm.TcpAccess"), IDS_TCPACCESS_DESC, THREADFLAGS_BOTH)
  30. // Private admin object interface:
  31. public:
  32. HRESULT GetFromMetabase ( CMetabaseKey * pMB );
  33. HRESULT SendToMetabase ( CMetabaseKey * pMB );
  34. // ITcpAccess
  35. public:
  36. //////////////////////////////////////////////////////////////////////
  37. // Properties:
  38. //////////////////////////////////////////////////////////////////////
  39. STDMETHODIMP get_GrantedList ( ITcpAccessExceptions ** ppGrantedList );
  40. STDMETHODIMP get_DeniedList ( ITcpAccessExceptions ** ppDeniedList );
  41. /*
  42. STDMETHODIMP put_GrantedList ( ITcpAccessExceptions * pGrantedList );
  43. STDMETHODIMP put_DeniedList ( ITcpAccessExceptions * pDeniedList );
  44. */
  45. //////////////////////////////////////////////////////////////////////
  46. // Data:
  47. //////////////////////////////////////////////////////////////////////
  48. private:
  49. CComObject<CTcpAccessExceptions> * m_pGrantList;
  50. CComObject<CTcpAccessExceptions> * m_pDenyList;
  51. HRESULT GetAddressCheckFromMetabase ( CMetabaseKey * pMB, ADDRESS_CHECK * pAC );
  52. };
  53. /////////////////////////////////////////////////////////////////////////////
  54. // The TcpAccessExceptions Object
  55. class CTcpAccessExceptions :
  56. public CComDualImpl<ITcpAccessExceptions, &IID_ITcpAccessExceptions, &LIBID_SMTPADMLib>,
  57. public ISupportErrorInfo,
  58. public CComObjectRoot
  59. {
  60. public:
  61. CTcpAccessExceptions();
  62. virtual ~CTcpAccessExceptions ();
  63. BEGIN_COM_MAP(CTcpAccessExceptions)
  64. COM_INTERFACE_ENTRY(IDispatch)
  65. COM_INTERFACE_ENTRY(ITcpAccessExceptions)
  66. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  67. END_COM_MAP()
  68. //DECLARE_NOT_AGGREGATABLE(CTcpAccessExceptions)
  69. // Remove the comment from the line above if you don't want your object to
  70. // support aggregation. The default is to support it
  71. // ISupportsErrorInfo
  72. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  73. // DECLARE_REGISTRY(CTcpAccessExceptions, _T("Smtpadm.TcpAccessExceptions.1"), _T("Smtpadm.TcpAccessExceptions"), IDS_TCPACCESSEXCEPTIONS_DESC, THREADFLAGS_BOTH)
  74. //
  75. // Private admin object interface:
  76. //
  77. HRESULT FromAddressCheck ( ADDRESS_CHECK * pAC, BOOL fGrant );
  78. HRESULT ToAddressCheck ( ADDRESS_CHECK * pAC, BOOL fGrant );
  79. // ITcpAccessExceptions
  80. public:
  81. //////////////////////////////////////////////////////////////////////
  82. // Properties:
  83. //////////////////////////////////////////////////////////////////////
  84. STDMETHODIMP get_Count ( long * pcCount );
  85. STDMETHODIMP AddDnsName ( BSTR strDnsName );
  86. STDMETHODIMP AddIpAddress( long lIpAddress, long lIpMask );
  87. STDMETHODIMP Item ( long index, ITcpAccessException ** ppAccessException );
  88. STDMETHODIMP Remove ( long index );
  89. STDMETHODIMP FindDnsIndex( BSTR strDnsName, long * pIndex );
  90. STDMETHODIMP FindIpIndex ( long lIpAddress, long lIpMask, long * pIndex );
  91. STDMETHODIMP Clear ( );
  92. //////////////////////////////////////////////////////////////////////
  93. // Data:
  94. //////////////////////////////////////////////////////////////////////
  95. private:
  96. long m_cCount;
  97. CComPtr<ITcpAccessException> * m_rgItems;
  98. HRESULT AddItem ( ITcpAccessException * pNew );
  99. };
  100. class CTcpAccessException :
  101. public CComDualImpl<ITcpAccessException, &IID_ITcpAccessException, &LIBID_SMTPADMLib>,
  102. public ISupportErrorInfo,
  103. public CComObjectRoot
  104. {
  105. public:
  106. CTcpAccessException();
  107. virtual ~CTcpAccessException ();
  108. static HRESULT CreateNew ( LPWSTR strDnsName, ITcpAccessException ** ppNew );
  109. static HRESULT CreateNew ( DWORD dwIpAddress, DWORD dwIpMask, ITcpAccessException ** ppNew );
  110. BEGIN_COM_MAP(CTcpAccessException)
  111. COM_INTERFACE_ENTRY(IDispatch)
  112. COM_INTERFACE_ENTRY(ITcpAccessException)
  113. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  114. END_COM_MAP()
  115. //DECLARE_NOT_AGGREGATABLE(CTcpAccessException)
  116. // Remove the comment from the line above if you don't want your object to
  117. // support aggregation. The default is to support it
  118. // ISupportsErrorInfo
  119. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  120. // DECLARE_REGISTRY(CTcpAccessException, _T("Smtpadm.TcpAccessException.1"), _T("Smtpadm.TcpAccessException"), IDS_TCPACCESSEXCEPTION_DESC, THREADFLAGS_BOTH)
  121. // ITcpAccessException
  122. public:
  123. //////////////////////////////////////////////////////////////////////
  124. // Properties:
  125. //////////////////////////////////////////////////////////////////////
  126. STDMETHODIMP get_IsDnsName ( BOOL * pfIsDnsName );
  127. STDMETHODIMP get_IsIpAddress ( BOOL * pfIsIpAddress );
  128. STDMETHODIMP get_DnsName ( BSTR * pstrDnsName );
  129. STDMETHODIMP put_DnsName ( BSTR strDnsName );
  130. STDMETHODIMP get_IpAddress ( long * plIpAddress );
  131. STDMETHODIMP put_IpAddress ( long lIpAddress );
  132. STDMETHODIMP get_IpMask ( long * plIpMask );
  133. STDMETHODIMP put_IpMask ( long lIpMask );
  134. //////////////////////////////////////////////////////////////////////
  135. // Data:
  136. //////////////////////////////////////////////////////////////////////
  137. private:
  138. CComBSTR m_strDnsName;
  139. DWORD m_dwIpAddress;
  140. DWORD m_dwIpMask;
  141. BOOL m_fIsDnsName;
  142. BOOL m_fIsIpAddress;
  143. };