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.

174 lines
4.5 KiB

  1. // binding.h : Declaration of the CServerBinding & CServerBindings classes.
  2. #include "resource.h" // main symbols
  3. //
  4. // Dependencies:
  5. //
  6. class CMultiSz;
  7. //
  8. // A simple binding class:
  9. //
  10. class CBinding
  11. {
  12. public:
  13. CBinding () :
  14. m_dwTcpPort ( 0 ),
  15. m_dwSslPort ( 0 )
  16. { }
  17. CComBSTR m_strIpAddress;
  18. long m_dwTcpPort;
  19. long m_dwSslPort;
  20. HRESULT SetProperties ( BSTR strIpAddress, long dwTcpPort, long dwSslPort );
  21. inline HRESULT SetProperties ( const CBinding & binding )
  22. {
  23. return SetProperties (
  24. binding.m_strIpAddress,
  25. binding.m_dwTcpPort,
  26. binding.m_dwSslPort
  27. );
  28. }
  29. private:
  30. // Don't call this:
  31. const CBinding & operator= ( const CBinding & );
  32. };
  33. /////////////////////////////////////////////////////////////////////////////
  34. // The Binding Object
  35. class CServerBinding :
  36. public CComDualImpl<IServerBinding, &IID_IServerBinding, &LIBID_SMTPADMLib>,
  37. public ISupportErrorInfo,
  38. public CComObjectRoot
  39. {
  40. friend class CServerBindings;
  41. //friend class CVirtualServer;
  42. public:
  43. CServerBinding();
  44. virtual ~CServerBinding ();
  45. BEGIN_COM_MAP(CServerBinding)
  46. COM_INTERFACE_ENTRY(IDispatch)
  47. COM_INTERFACE_ENTRY(IServerBinding)
  48. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  49. END_COM_MAP()
  50. //DECLARE_NOT_AGGREGATABLE(CServerBinding)
  51. // Remove the comment from the line above if you don't want your object to
  52. // support aggregation. The default is to support it
  53. // ISupportsErrorInfo
  54. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  55. // IServerBinding
  56. public:
  57. //////////////////////////////////////////////////////////////////////
  58. // Properties:
  59. //////////////////////////////////////////////////////////////////////
  60. STDMETHODIMP get_IpAddress ( BSTR * pstrIpAddress );
  61. STDMETHODIMP put_IpAddress ( BSTR strIpAddress );
  62. STDMETHODIMP get_TcpPort ( long * pdwTcpPort );
  63. STDMETHODIMP put_TcpPort ( long dwTcpPort );
  64. STDMETHODIMP get_SslPort ( long * plSslPort );
  65. STDMETHODIMP put_SslPort ( long lSslPort );
  66. //////////////////////////////////////////////////////////////////////
  67. // Data:
  68. //////////////////////////////////////////////////////////////////////
  69. private:
  70. inline HRESULT SetProperties ( const CBinding & binding )
  71. {
  72. return m_binding.SetProperties ( binding );
  73. }
  74. // Property variables:
  75. CBinding m_binding;
  76. };
  77. /////////////////////////////////////////////////////////////////////////////
  78. // The Bindings Object
  79. class CServerBindings :
  80. public CComDualImpl<IServerBindings, &IID_IServerBindings, &LIBID_SMTPADMLib>,
  81. public ISupportErrorInfo,
  82. public CComObjectRoot
  83. {
  84. friend class CServerBinding;
  85. //friend class CVirtualServer;
  86. public:
  87. CServerBindings();
  88. virtual ~CServerBindings ();
  89. BEGIN_COM_MAP(CServerBindings)
  90. COM_INTERFACE_ENTRY(IDispatch)
  91. COM_INTERFACE_ENTRY(IServerBindings)
  92. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  93. END_COM_MAP()
  94. //DECLARE_NOT_AGGREGATABLE(CServerBindings)
  95. // Remove the comment from the line above if you don't want your object to
  96. // support aggregation. The default is to support it
  97. // ISupportsErrorInfo
  98. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  99. // IServerBindings
  100. public:
  101. //////////////////////////////////////////////////////////////////////
  102. // Properties:
  103. //////////////////////////////////////////////////////////////////////
  104. STDMETHODIMP get_Count ( long * pdwCount );
  105. //////////////////////////////////////////////////////////////////////
  106. // Methods:
  107. //////////////////////////////////////////////////////////////////////
  108. STDMETHODIMP Item ( long index, IServerBinding ** ppBinding );
  109. STDMETHODIMP ItemDispatch ( long index, IDispatch ** ppBinding );
  110. STDMETHODIMP Add ( BSTR strIpAddress, long dwTcpPort, long dwSslPort );
  111. STDMETHODIMP ChangeBinding ( long index, IServerBinding * pBinding );
  112. STDMETHODIMP ChangeBindingDispatch ( long index, IDispatch * pBinding );
  113. STDMETHODIMP Remove ( long index );
  114. STDMETHODIMP Clear ( );
  115. //////////////////////////////////////////////////////////////////////
  116. // Data:
  117. //////////////////////////////////////////////////////////////////////
  118. private:
  119. // Property variables:
  120. long m_dwCount;
  121. CBinding * m_rgBindings;
  122. };
  123. //////////////////////////////////////////////////////////////////////
  124. //
  125. // Useful routines to go from IServerBindings to
  126. // Metabase data types.
  127. //
  128. //////////////////////////////////////////////////////////////////////
  129. HRESULT
  130. MDBindingsToIBindings (
  131. CMultiSz * pmszBindings,
  132. BOOL fTcpBindings,
  133. IServerBindings * pBindings
  134. );
  135. HRESULT IBindingsToMDBindings (
  136. IServerBindings * pBindings,
  137. BOOL fTcpBindings,
  138. CMultiSz * pmszBindings
  139. );