Leaked source code of windows server 2003
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.

267 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. feedinfo.h
  5. Abstract:
  6. Defines the CFeed class that maintains all properties about a feed.
  7. Author:
  8. Magnus Hedlund (MagnusH) --
  9. Revision History:
  10. --*/
  11. #ifndef _FEEDINFO_INCLUDED_
  12. #define _FEEDINFO_INCLUDED_
  13. // Dependencies
  14. #include "cmultisz.h"
  15. #include "metakey.h"
  16. typedef struct _NNTP_FEED_INFO NNTP_FEED_INFO, * LPNNTP_FEED_INFO;
  17. typedef DWORD FEED_TYPE;
  18. //
  19. // Forward declarations:
  20. //
  21. class CFeed;
  22. class CFeedPair;
  23. class CFeedPairList;
  24. NNTP_FEED_SERVER_TYPE FeedTypeToEnum ( FEED_TYPE ft );
  25. void EnumToFeedType ( NNTP_FEED_SERVER_TYPE type, FEED_TYPE & ftMask );
  26. //$-------------------------------------------------------------------
  27. //
  28. // Class:
  29. // CFeed
  30. //
  31. // Description:
  32. //
  33. //--------------------------------------------------------------------
  34. class CFeed
  35. {
  36. friend class CFeedPair;
  37. friend class CFeedPairList;
  38. public:
  39. //
  40. // Creating CFeed objects:
  41. //
  42. static HRESULT CreateFeed ( CFeed ** ppNewFeed );
  43. static HRESULT CreateFeedFromFeedInfo ( LPNNTP_FEED_INFO pFeedInfo, CFeed ** ppNewFeed );
  44. static HRESULT CreateFeedFromINntpOneWayFeed ( INntpOneWayFeed * pFeed, CFeed ** ppNewFeed );
  45. CFeed ( );
  46. ~CFeed ( );
  47. void Destroy ();
  48. const CFeed & operator= ( const CFeed & feed );
  49. inline const CFeed & operator= ( const NNTP_FEED_INFO & feed ) {
  50. FromFeedInfo ( &feed );
  51. return *this;
  52. }
  53. //
  54. // Conversion routines:
  55. //
  56. HRESULT ToFeedInfo ( LPNNTP_FEED_INFO pFeedInfo );
  57. HRESULT FromFeedInfo ( const NNTP_FEED_INFO * pFeedInfo );
  58. HRESULT ToINntpOneWayFeed ( INntpOneWayFeed ** ppFeed );
  59. HRESULT FromINntpOneWayFeed ( INntpOneWayFeed * pFeed );
  60. //
  61. // Communicating changes to the service:
  62. //
  63. HRESULT Add ( LPCWSTR strServer, DWORD dwInstance, CMetabaseKey* pMK );
  64. HRESULT Remove ( LPCWSTR strServer, DWORD dwInstance, CMetabaseKey* pMK );
  65. HRESULT Set ( LPCWSTR strServer, DWORD dwInstance, CMetabaseKey* pMK );
  66. HRESULT SetPairId ( LPCWSTR strServer, DWORD dwInstance, DWORD dwPairId, CMetabaseKey* pMK );
  67. // Feed Properties:
  68. public:
  69. DWORD m_dwFeedId;
  70. DWORD m_dwPairFeedId;
  71. FEED_TYPE m_FeedType;
  72. BOOL m_fAllowControlMessages;
  73. DWORD m_dwAuthenticationType;
  74. DWORD m_dwConcurrentSessions;
  75. BOOL m_fCreateAutomatically;
  76. BOOL m_fEnabled;
  77. CMultiSz m_mszDistributions;
  78. DWORD m_dwFeedInterval;
  79. DATE m_datePullNews;
  80. DWORD m_dwMaxConnectionAttempts;
  81. CMultiSz m_mszNewsgroups;
  82. DWORD m_dwSecurityType;
  83. DWORD m_dwOutgoingPort;
  84. CComBSTR m_strUucpName;
  85. CComBSTR m_strAccountName;
  86. CComBSTR m_strPassword;
  87. CComBSTR m_strTempDirectory;
  88. //
  89. // CFeedPair sets these:
  90. //
  91. NNTP_FEED_SERVER_TYPE m_EnumType;
  92. CComBSTR m_strRemoteServer;
  93. //
  94. // Routines to help property gets/puts:
  95. //
  96. HRESULT get_FeedAction ( NNTP_FEED_ACTION * feedaction );
  97. HRESULT put_FeedAction ( NNTP_FEED_ACTION feedaction );
  98. BOOL CheckValid () const;
  99. private:
  100. #ifdef DEBUG
  101. void AssertValid ( ) const;
  102. #else
  103. inline void AssertValid ( ) const { }
  104. #endif
  105. private:
  106. HRESULT TranslateFeedError ( DWORD dwErrorCode, DWORD dwParmErr = 0 );
  107. HRESULT CheckConfirm( DWORD dwFeedId,
  108. DWORD dwInstanceId,
  109. CMetabaseKey* pMK,
  110. PDWORD pdwErr,
  111. PDWORD pdwErrMask );
  112. // Don't call the copy constructor:
  113. CFeed ( const CFeed & );
  114. };
  115. //$-------------------------------------------------------------------
  116. //
  117. // Class:
  118. // CFeedPair
  119. //
  120. // Description:
  121. //
  122. //--------------------------------------------------------------------
  123. class CFeedPair
  124. {
  125. friend class CNntpFeed;
  126. friend class CFeedPairList;
  127. public:
  128. CFeedPair();
  129. ~CFeedPair();
  130. static HRESULT CreateFeedPair (
  131. CFeedPair ** ppNewFeedPair,
  132. BSTR strRemoteServer,
  133. NNTP_FEED_SERVER_TYPE type
  134. );
  135. void Destroy ();
  136. HRESULT AddFeed ( CFeed * pFeed );
  137. BOOL ContainsFeedId ( DWORD dwFeedId );
  138. // Routines to help property gets/puts:
  139. HRESULT get_FeedType ( NNTP_FEED_SERVER_TYPE * feedtype );
  140. HRESULT put_FeedType ( NNTP_FEED_SERVER_TYPE feedtype );
  141. // CFeedPair <-> OLE INntpFeedPair:
  142. HRESULT ToINntpFeed ( INntpFeed ** ppFeed );
  143. HRESULT FromINntpFeed ( INntpFeed * pFeed );
  144. // Talking with the Server:
  145. HRESULT AddToServer ( LPCWSTR strServer, DWORD dwInstance, CMetabaseKey* pMK );
  146. HRESULT SetToServer ( LPCWSTR strServer, DWORD dwInstance, INntpFeed * pFeed, CMetabaseKey* pMK );
  147. HRESULT RemoveFromServer ( LPCWSTR strServer, DWORD dwInstance, CMetabaseKey* pMK );
  148. private:
  149. HRESULT AddIndividualFeed ( LPCWSTR strServer, DWORD dwInstance, CFeed * pFeed, CMetabaseKey* pMK );
  150. HRESULT SetIndividualFeed ( LPCWSTR strServer, DWORD dwInstance, CFeed * pFeed, CMetabaseKey* pMK );
  151. HRESULT SetPairIds (
  152. LPCWSTR strServer,
  153. DWORD dwInstance,
  154. CFeed * pFeed1,
  155. CFeed * pFeed2,
  156. CMetabaseKey* pMK
  157. );
  158. HRESULT UndoFeedAction (
  159. LPCWSTR strServer,
  160. DWORD dwInstance,
  161. CFeed * pNewFeed,
  162. CFeed * pOldFeed ,
  163. CMetabaseKey* pMK
  164. );
  165. CComBSTR m_strRemoteServer;
  166. NNTP_FEED_SERVER_TYPE m_type;
  167. CFeed * m_pInbound;
  168. CFeed * m_pOutbound;
  169. CFeedPair * m_pNext; // Used by CFeedPairList
  170. private:
  171. #ifdef DEBUG
  172. void AssertValid ( ) const;
  173. #else
  174. inline void AssertValid ( ) const { }
  175. #endif
  176. };
  177. //$-------------------------------------------------------------------
  178. //
  179. // Class:
  180. // CFeedPairList
  181. //
  182. // Description:
  183. //
  184. //--------------------------------------------------------------------
  185. class CFeedPairList
  186. {
  187. public:
  188. CFeedPairList ( );
  189. ~CFeedPairList ( );
  190. //
  191. // List interface:
  192. //
  193. DWORD GetCount ( ) const;
  194. void Empty ( );
  195. CFeedPair * Item ( DWORD index );
  196. void Add ( CFeedPair * pPair );
  197. void Remove ( CFeedPair * pPair );
  198. CFeedPair * Find ( DWORD dwFeedId );
  199. DWORD GetPairIndex ( CFeedPair * pPair ) const;
  200. private:
  201. #ifdef DEBUG
  202. void AssertValid ( ) const;
  203. #else
  204. inline void AssertValid ( ) const { }
  205. #endif
  206. private:
  207. DWORD m_cCount;
  208. CFeedPair * m_pHead;
  209. CFeedPair * m_pTail;
  210. };
  211. #endif // _FEEDINFO_INCLUDED_