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.

227 lines
5.7 KiB

  1. // domain.h : Declaration of the CSmtpAdminDomain
  2. #include "resource.h" // main symbols
  3. #include "smtptype.h"
  4. #include "smtpapi.h"
  5. #include "cmultisz.h"
  6. #include "metafact.h"
  7. #include "smtpadm.h"
  8. #include "listmacr.h"
  9. struct DomainEntry
  10. {
  11. TCHAR m_strDomainName[256]; // current domain's name
  12. DWORD m_dwActionType;
  13. TCHAR m_strActionString[256];
  14. BOOL m_fAllowEtrn;
  15. DWORD m_dwDomainId;
  16. LIST_ENTRY list;
  17. BOOL FromString( LPCTSTR lpDomainString );
  18. BOOL ToString( LPTSTR lpDomainString ); // big enough to hold the entry
  19. DomainEntry()
  20. {
  21. ZeroMemory( m_strDomainName, sizeof(m_strDomainName) );
  22. ZeroMemory( m_strActionString, sizeof(m_strActionString) );
  23. m_dwActionType = SMTP_DELIVER;
  24. m_fAllowEtrn = FALSE;
  25. m_dwDomainId = (DWORD)-1;
  26. InitializeListHead( &list );
  27. }
  28. };
  29. /////////////////////////////////////////////////////////////////////////////
  30. // smtpadm
  31. class CSmtpAdminDomain :
  32. public ISmtpAdminDomain,
  33. public IPrivateUnknown,
  34. public IPrivateDispatch,
  35. public IADsExtension,
  36. public INonDelegatingUnknown,
  37. public ISupportErrorInfo,
  38. public CComObjectRoot,
  39. public CComCoClass<CSmtpAdminDomain,&CLSID_CSmtpAdminDomain>
  40. {
  41. public:
  42. CSmtpAdminDomain();
  43. virtual ~CSmtpAdminDomain();
  44. BEGIN_COM_MAP(CSmtpAdminDomain)
  45. COM_INTERFACE_ENTRY(IDispatch)
  46. COM_INTERFACE_ENTRY(IADs)
  47. COM_INTERFACE_ENTRY(ISmtpAdminDomain)
  48. COM_INTERFACE_ENTRY(IADsExtension)
  49. COM_INTERFACE_ENTRY(IPrivateUnknown)
  50. COM_INTERFACE_ENTRY(IPrivateDispatch)
  51. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  52. END_COM_MAP()
  53. //DECLARE_NOT_AGGREGATABLE(CSmtpAdminDomain)
  54. // Remove the comment from the line above if you don't want your object to
  55. // support aggregation. The default is to support it
  56. DECLARE_REGISTRY(CSmtpAdminDomain, _T("Smtpadm.Domain.1"), _T("Smtpadm.Domain"), IDS_SMTPADMIN_DOMAIN_DESC, THREADFLAGS_BOTH)
  57. // ISupportsErrorInfo
  58. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  59. //
  60. // This declares methods for the following:
  61. // IADsExtension
  62. // IUnknown
  63. // IDispatch
  64. // IPrivateUnknown
  65. // IPrivateDispatch
  66. //
  67. #define THIS_LIBID LIBID_SMTPADMLib
  68. #define THIS_IID IID_ISmtpAdminDomain
  69. #include "adsimp.inl"
  70. #undef THIS_LIBID
  71. #undef THIS_IID
  72. // ISmtpAdminDomain
  73. public:
  74. //////////////////////////////////////////////////////////////////////
  75. // Properties:
  76. //////////////////////////////////////////////////////////////////////
  77. //
  78. // IADs methods:
  79. //
  80. DECLARE_IADS_METHODS()
  81. // Which service to configure:
  82. STDMETHODIMP get_Server ( BSTR * pstrServer );
  83. STDMETHODIMP put_Server ( BSTR strServer );
  84. STDMETHODIMP get_ServiceInstance ( long * plServiceInstance );
  85. STDMETHODIMP put_ServiceInstance ( long lServiceInstance );
  86. // enumeration
  87. STDMETHODIMP get_Count ( long* plCount );
  88. // Domain Properties:
  89. STDMETHODIMP get_DomainName ( BSTR * pstrDomainName );
  90. STDMETHODIMP put_DomainName ( BSTR strDomainName );
  91. STDMETHODIMP get_ActionType ( long * plActionType );
  92. STDMETHODIMP put_ActionType ( long lActionType );
  93. // drop IsDefault!!
  94. STDMETHODIMP get_IsDefault ( BOOL * pfIsDefault );
  95. STDMETHODIMP put_IsDefault ( BOOL fIsDefault );
  96. STDMETHODIMP get_IsLocal ( BOOL * pfIsLocal );
  97. STDMETHODIMP put_IsLocal ( BOOL fIsLocal );
  98. // if local
  99. STDMETHODIMP get_LDAPServer ( BSTR * pstrLDAPServer );
  100. STDMETHODIMP put_LDAPServer ( BSTR strLDAPServer );
  101. STDMETHODIMP get_Account ( BSTR * pstrAccount );
  102. STDMETHODIMP put_Account ( BSTR strAccount );
  103. STDMETHODIMP get_Password ( BSTR * pstrPassword );
  104. STDMETHODIMP put_Password ( BSTR strPassword );
  105. STDMETHODIMP get_LDAPContainer ( BSTR * pstrLDAPContainer );
  106. STDMETHODIMP put_LDAPContainer ( BSTR strLDAPContainer );
  107. // if remote
  108. STDMETHODIMP get_UseSSL ( BOOL * pfUseSSL );
  109. STDMETHODIMP put_UseSSL ( BOOL fUseSSL );
  110. STDMETHODIMP get_EnableETRN ( BOOL * pfEnableETRN );
  111. STDMETHODIMP put_EnableETRN ( BOOL fEnableETRN );
  112. STDMETHODIMP get_DropDir ( BSTR * pstrDropDir );
  113. STDMETHODIMP put_DropDir ( BSTR strDropDir );
  114. STDMETHODIMP get_RoutingDomain ( BSTR * pstrRoutingDomain );
  115. STDMETHODIMP put_RoutingDomain ( BSTR strRoutingDomain );
  116. //////////////////////////////////////////////////////////////////////
  117. // Methods:
  118. //////////////////////////////////////////////////////////////////////
  119. STDMETHODIMP Default ( );
  120. STDMETHODIMP Add ( );
  121. STDMETHODIMP Remove ( );
  122. STDMETHODIMP Get ( );
  123. STDMETHODIMP Set ( );
  124. STDMETHODIMP Enumerate ( );
  125. STDMETHODIMP GetNth ( long lIndex );
  126. STDMETHODIMP GetDefaultDomain ( );
  127. STDMETHODIMP SetAsDefaultDomain ( );
  128. //////////////////////////////////////////////////////////////////////
  129. // Data:
  130. //////////////////////////////////////////////////////////////////////
  131. private:
  132. CIADsImpl m_iadsImpl;
  133. long m_lCount;
  134. // metabase key values, these shouldn't be changed before Set()
  135. CMultiSz m_mszDomainRouting;
  136. CComBSTR m_strDefaultDomain;
  137. CComBSTR m_strDropDir;
  138. // current domain's property
  139. CComBSTR m_strDomainName; // current domain's name
  140. DWORD m_dwActionType;
  141. CComBSTR m_strActionString;
  142. BOOL m_fAllowEtrn;
  143. DWORD m_dwDomainId;
  144. // if local
  145. CComBSTR m_strLDAPServer;
  146. CComBSTR m_strAccount;
  147. CComBSTR m_strPassword;
  148. CComBSTR m_strLDAPContainer;
  149. // Metabase:
  150. CMetabaseFactory m_mbFactory;
  151. // add a list of domains
  152. LIST_ENTRY m_list;
  153. DWORD m_dwMaxDomainId;
  154. BOOL m_fEnumerated;
  155. // DWORD m_dwCurrentIndex; // optimization
  156. DomainEntry* m_pCurrentDomainEntry;
  157. DomainEntry* m_pDefaultDomainEntry;
  158. // private method
  159. HRESULT SaveData();
  160. BOOL LoadDomainProperty(DomainEntry* pDomainEntry);
  161. DomainEntry* FindDomainEntry( LPCWSTR lpName );
  162. BOOL ConstructListFromMetabaseValues();
  163. BOOL ParseListToMetabaseValues(); // called by SaveData()
  164. HRESULT GetFromMetabase();
  165. HRESULT SaveToMetabase();
  166. void EmptyList();
  167. };