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.

288 lines
8.1 KiB

  1. // vroots.h : Declaration of the CNntpVirtualRoot & CNntpVirtualRoots classes.
  2. #ifndef _VROOTS_INCLUDED_
  3. #define _VROOTS_INCLUDED_
  4. //
  5. // Dependencies:
  6. //
  7. #include "nntptype.h"
  8. #include "nntpapi.h"
  9. #include "metafact.h"
  10. class CMetabaseKey;
  11. //
  12. // A simple VRoot class:
  13. //
  14. class CVRoot
  15. {
  16. public:
  17. CVRoot ();
  18. CComBSTR m_strNewsgroupSubtree;
  19. CComBSTR m_strDirectory;
  20. DWORD m_dwWin32Error;
  21. DWORD m_bvAccess;
  22. DWORD m_bvSslAccess;
  23. BOOL m_fLogAccess;
  24. BOOL m_fIndexContent;
  25. CComBSTR m_strUNCUsername;
  26. CComBSTR m_strUNCPassword;
  27. CComBSTR m_strDriverProgId;
  28. CComBSTR m_strGroupPropFile;
  29. CComBSTR m_strMdbGuid;
  30. DWORD m_dwUseAccount;
  31. BOOL m_fDoExpire;
  32. BOOL m_fOwnModerator;
  33. HRESULT SetProperties ( INntpVirtualRoot * pVirtualRoot );
  34. inline HRESULT SetProperties ( const CVRoot & VRoot )
  35. {
  36. return SetProperties (
  37. VRoot.m_strNewsgroupSubtree,
  38. VRoot.m_strDirectory,
  39. VRoot.m_dwWin32Error,
  40. VRoot.m_bvAccess,
  41. VRoot.m_bvSslAccess,
  42. VRoot.m_fLogAccess,
  43. VRoot.m_fIndexContent,
  44. VRoot.m_strUNCUsername,
  45. VRoot.m_strUNCPassword,
  46. VRoot.m_strDriverProgId,
  47. VRoot.m_strGroupPropFile,
  48. VRoot.m_dwUseAccount,
  49. VRoot.m_fDoExpire,
  50. VRoot.m_fOwnModerator,
  51. VRoot.m_strMdbGuid
  52. );
  53. }
  54. HRESULT GetFromMetabase ( CMetabaseKey * pMB, LPCWSTR wszKey, DWORD dwInstanceId, LPWSTR wszVRootPath );
  55. HRESULT SendToMetabase ( CMetabaseKey * pMB, LPCWSTR wszKey );
  56. private:
  57. HRESULT SetProperties (
  58. BSTR strNewsgroupSubtree,
  59. BSTR strDirectory,
  60. DWORD dwWin32Error,
  61. DWORD bvAccess,
  62. DWORD bvSslAccess,
  63. BOOL fLogAcccess,
  64. BOOL fIndexContent,
  65. BSTR strUNCUsername,
  66. BSTR strUNCPassword,
  67. BSTR strDriverProgId,
  68. BSTR strGroupPropFile,
  69. DWORD dwUseAccount,
  70. BOOL fDoExpire,
  71. BOOL fOwnModerator,
  72. BSTR strMdbGuid
  73. );
  74. // Don't call this:
  75. const CVRoot & operator= ( const CVRoot & );
  76. };
  77. /////////////////////////////////////////////////////////////////////////////
  78. // The VRoot Object
  79. class CNntpVirtualRoot :
  80. public CComDualImpl<INntpVirtualRoot, &IID_INntpVirtualRoot, &LIBID_NNTPADMLib>,
  81. public ISupportErrorInfo,
  82. public CComObjectRoot,
  83. public CComCoClass<CNntpVirtualRoot,&CLSID_CNntpVirtualRoot>
  84. {
  85. friend class CNntpVirtualRoots;
  86. friend class CNntpVirtualServer;
  87. public:
  88. CNntpVirtualRoot();
  89. virtual ~CNntpVirtualRoot ();
  90. BEGIN_COM_MAP(CNntpVirtualRoot)
  91. COM_INTERFACE_ENTRY(IDispatch)
  92. COM_INTERFACE_ENTRY(INntpVirtualRoot)
  93. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  94. END_COM_MAP()
  95. //DECLARE_NOT_AGGREGATABLE(CNntpVirtualRoot)
  96. // Remove the comment from the line above if you don't want your object to
  97. // support aggregation. The default is to support it
  98. // ISupportsErrorInfo
  99. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  100. DECLARE_REGISTRY(CNntpVirtualRoot, _T("Nntpadm.VirtualRoot.1"), _T("Nntpadm.VirtualRoot"), IDS_NNTPVIRTUALROOT_DESC, THREADFLAGS_BOTH)
  101. // INntpVirtualRoot
  102. public:
  103. //////////////////////////////////////////////////////////////////////
  104. // Properties:
  105. //////////////////////////////////////////////////////////////////////
  106. STDMETHODIMP get_NewsgroupSubtree ( BSTR * pstrNewsgroupSubtree );
  107. STDMETHODIMP put_NewsgroupSubtree ( BSTR strNewsgroupSubtree );
  108. STDMETHODIMP get_Directory ( BSTR * pstrDirectory );
  109. STDMETHODIMP put_Directory ( BSTR strDirectory );
  110. STDMETHODIMP get_Win32Error ( long * plWin32Error );
  111. STDMETHODIMP get_AllowPosting ( BOOL * pfAllowPosting );
  112. STDMETHODIMP put_AllowPosting ( BOOL fAllowPosting );
  113. STDMETHODIMP get_RestrictGroupVisibility ( BOOL * pfRestrictGroupVisibility );
  114. STDMETHODIMP put_RestrictGroupVisibility ( BOOL fRestrictGroupVisibility );
  115. STDMETHODIMP get_LogAccess ( BOOL * pfLogAccess );
  116. STDMETHODIMP put_LogAccess ( BOOL fLogAccess );
  117. STDMETHODIMP get_IndexContent ( BOOL * pfIndexContent );
  118. STDMETHODIMP put_IndexContent ( BOOL fIndexContent );
  119. STDMETHODIMP get_RequireSsl ( BOOL * pfRequireSsl );
  120. STDMETHODIMP put_RequireSsl ( BOOL fRequireSsl );
  121. STDMETHODIMP get_Require128BitSsl ( BOOL * pfRequire128BitSsl );
  122. STDMETHODIMP put_Require128BitSsl ( BOOL fRequire128BitSsl );
  123. STDMETHODIMP get_UNCUsername ( BSTR * pstrUNCUsername );
  124. STDMETHODIMP put_UNCUsername ( BSTR strUNCUsername );
  125. STDMETHODIMP get_UNCPassword ( BSTR * pstrUNCPassword );
  126. STDMETHODIMP put_UNCPassword ( BSTR strUNCPassword );
  127. STDMETHODIMP get_DriverProgId( BSTR *pstrDriverProgId );
  128. STDMETHODIMP put_DriverProgId( BSTR strDriverProgId );
  129. STDMETHODIMP get_GroupPropFile( BSTR *pstrGRoupPropFile );
  130. STDMETHODIMP put_GroupPropFile( BSTR strGroupPropFile );
  131. STDMETHODIMP get_MdbGuid( BSTR *pstrMdbGuid );
  132. STDMETHODIMP put_MdbGuid( BSTR strMdbGuid );
  133. STDMETHODIMP get_UseAccount( DWORD *pdwUseAccount );
  134. STDMETHODIMP put_UseAccount( DWORD dwUseAccount );
  135. STDMETHODIMP get_OwnExpire( BOOL *fOwnExpire );
  136. STDMETHODIMP put_OwnExpire( BOOL fOwnExpire );
  137. STDMETHODIMP get_OwnModerator( BOOL *fOwnModerator );
  138. STDMETHODIMP put_OwnModerator( BOOL fOwnModerator );
  139. //////////////////////////////////////////////////////////////////////
  140. // Data:
  141. //////////////////////////////////////////////////////////////////////
  142. private:
  143. /*
  144. inline HRESULT SetProperties ( BSTR strNewsgroupSubtree, BSTR strDirectory )
  145. {
  146. return m_vroot.SetProperties ( strNewsgroupSubtree, strDirectory );
  147. }
  148. */
  149. inline HRESULT SetProperties ( const CVRoot & VRoot )
  150. {
  151. return m_vroot.SetProperties ( VRoot );
  152. }
  153. // Property variables:
  154. CVRoot m_vroot;
  155. };
  156. /////////////////////////////////////////////////////////////////////////////
  157. // The VRoots Object
  158. typedef HRESULT (* VROOT_ITERATOR) (
  159. CMetabaseKey * pMB,
  160. LPCWSTR wszPath,
  161. LPARAM lParam
  162. );
  163. class CNntpVirtualRoots :
  164. public CComDualImpl<INntpVirtualRoots, &IID_INntpVirtualRoots, &LIBID_NNTPADMLib>,
  165. public ISupportErrorInfo,
  166. public CComObjectRoot
  167. {
  168. friend class CNntpVirtualRoot;
  169. friend class CNntpVirtualServer;
  170. public:
  171. CNntpVirtualRoots();
  172. virtual ~CNntpVirtualRoots ();
  173. BEGIN_COM_MAP(CNntpVirtualRoots)
  174. COM_INTERFACE_ENTRY(IDispatch)
  175. COM_INTERFACE_ENTRY(INntpVirtualRoots)
  176. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  177. END_COM_MAP()
  178. //DECLARE_NOT_AGGREGATABLE(CNntpVirtualRoots)
  179. // Remove the comment from the line above if you don't want your object to
  180. // support aggregation. The default is to support it
  181. // ISupportsErrorInfo
  182. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  183. // INntpVirtualRoots
  184. public:
  185. //////////////////////////////////////////////////////////////////////
  186. // Properties:
  187. //////////////////////////////////////////////////////////////////////
  188. STDMETHODIMP get_Server ( BSTR * pstrServer );
  189. STDMETHODIMP put_Server ( BSTR strServer );
  190. STDMETHODIMP get_ServiceInstance ( long * plServiceInstance );
  191. STDMETHODIMP put_ServiceInstance ( long lServiceInstance );
  192. STDMETHODIMP get_Count ( long * pdwCount );
  193. //////////////////////////////////////////////////////////////////////
  194. // Methods:
  195. //////////////////////////////////////////////////////////////////////
  196. STDMETHODIMP Enumerate ( );
  197. STDMETHODIMP Item ( long index, INntpVirtualRoot ** ppVRoot );
  198. STDMETHODIMP ItemDispatch ( long index, IDispatch ** ppVRoot );
  199. STDMETHODIMP Add ( INntpVirtualRoot * pVRoot );
  200. STDMETHODIMP AddDispatch ( IDispatch * pVRoot );
  201. STDMETHODIMP Set ( long index, INntpVirtualRoot * pVRoot );
  202. STDMETHODIMP SetDispatch ( long index, IDispatch * pVRoot );
  203. STDMETHODIMP Remove ( long index );
  204. STDMETHODIMP Find ( BSTR strNewsgroupSubtree, long * pIndex );
  205. private:
  206. HRESULT Init ( BSTR strServer, DWORD dwServiceInstance );
  207. //////////////////////////////////////////////////////////////////////
  208. // Data:
  209. //////////////////////////////////////////////////////////////////////
  210. private:
  211. // Property variables:
  212. long m_dwCount;
  213. CVRoot * m_rgVRoots;
  214. // Which service are we talking to:
  215. CComBSTR m_strServer;
  216. DWORD m_dwServiceInstance;
  217. // Metabase values:
  218. CMetabaseFactory m_mbFactory;
  219. HRESULT GetVRootsFromMetabase ( IMSAdminBase * pMetabase );
  220. static HRESULT IterateOverVroots (
  221. CMetabaseKey * pMB,
  222. VROOT_ITERATOR fpIterator,
  223. LPARAM lParam,
  224. LPCWSTR wszPath = _T("")
  225. );
  226. void GetMDVRootPath ( LPWSTR wszPath );
  227. void GetVRootName ( LPWSTR wszDisplayName, LPWSTR wszPathName );
  228. };
  229. #endif // _VROOTS_INCLUDED_