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.

261 lines
8.4 KiB

  1. /***************************************************************************/
  2. /** Microsoft Windows **/
  3. /** Copyright(c) Microsoft Corp., 1995-1996 **/
  4. /***************************************************************************/
  5. /****************************************************************************
  6. events.hpp
  7. Nov. 95 LenS
  8. Event handler infrastructure.
  9. CSequentialEventList assumes that all activity occurs on a single thread.
  10. It is the responsibility of the users to do the sychronization and thread
  11. context switches for this to happen.
  12. ****************************************************************************/
  13. #ifndef EVENTS_INC
  14. #define EVENTS_INC
  15. // #include <nmutil.h>
  16. // #include <referenc.h>
  17. #include <inodecnt.h>
  18. #include "ernccons.h"
  19. #include "cuserdta.hpp"
  20. class DCRNCConference;
  21. class CLogicalConnection;
  22. #define QUERY_IND_WORK_OWNER ((LPVOID) 1)
  23. class CWorkItem
  24. {
  25. friend class CSequentialWorkList;
  26. public:
  27. CWorkItem(LPVOID pOwner) : m_pOwner(pOwner) { }
  28. virtual CWorkItem::~CWorkItem(void) = 0;
  29. virtual void DoWork(void) = 0;
  30. BOOL IsOwnedBy(LPVOID pOwner) { return (pOwner == m_pOwner);};
  31. protected:
  32. LPVOID m_pOwner;
  33. };
  34. // Invited by a remote node.
  35. class CInviteIndWork : public CWorkItem
  36. {
  37. public:
  38. CInviteIndWork(PCONFERENCE pConference,
  39. LPCWSTR wszCallerID,
  40. PT120PRODUCTVERSION pRequestorVersion,
  41. GCCUserData **_ppUserData,
  42. UINT _nUserData,
  43. CLogicalConnection * _pConEntry);
  44. ~CInviteIndWork(void);
  45. void DoWork(void);
  46. LPWSTR GetCallerID(void) {return m_pwszCallerID;};
  47. private:
  48. PCONFERENCE m_pConf;
  49. LPWSTR m_pwszCallerID;
  50. T120PRODUCTVERSION m_RequestorVersion;
  51. PT120PRODUCTVERSION m_pRequestorVersion;
  52. PUSERDATAINFO m_pUserDataList;
  53. UINT m_nUserData;
  54. BOOL m_fSecure;
  55. };
  56. // joined by a remote node
  57. class CJoinIndWork : public CWorkItem
  58. {
  59. public:
  60. CJoinIndWork(GCCResponseTag Tag,
  61. PCONFERENCE pConference,
  62. LPCWSTR wszCallerID,
  63. CLogicalConnection *pConEntry,
  64. PT120PRODUCTVERSION pRequestorVersion,
  65. UINT _nUserData,
  66. GCCUserData **_ppUserData,
  67. HRESULT *pRetCode);
  68. ~CJoinIndWork(void);
  69. BOOL AddUserData(UINT nUserData, GCCUserData ** ppUserData);
  70. void DoWork(void);
  71. HRESULT Respond(GCCResult Result);
  72. PCONFERENCE GetConference(void) { return m_pConf; };
  73. LPWSTR GetCallerID(void) { return m_pwszCallerID; };
  74. CLogicalConnection *GetConEntry(void) { return m_pConEntry; };
  75. private:
  76. GCCResponseTag m_nResponseTag;
  77. PCONFERENCE m_pConf;
  78. LPWSTR m_pwszCallerID;
  79. CLogicalConnection *m_pConEntry;
  80. T120PRODUCTVERSION m_RequestorVersion;
  81. PT120PRODUCTVERSION m_pRequestorVersion;
  82. PUSERDATAINFO m_pUserDataList;
  83. GCCUserData **m_ppUserData;
  84. UINT m_nUserData;
  85. };
  86. class CQueryRemoteWork : public CWorkItem
  87. {
  88. public:
  89. CQueryRemoteWork(LPVOID pContext, GCCAsymmetryType, LPCSTR pcszNodeAddr, BOOL fSecure, HRESULT *);
  90. ~CQueryRemoteWork(void);
  91. void DoWork(void);
  92. void HandleQueryConfirmation(QueryConfirmMessage * pQueryMessage);
  93. void SyncQueryRemoteResult(void);
  94. void AsyncQueryRemoteResult(void);
  95. int GenerateRand(void);
  96. void SetHr(HRESULT hr) { m_hr = hr; }
  97. BOOL IsInUnknownQueryRequest(void) { return m_fInUnknownQueryRequest; }
  98. ConnectionHandle GetConnectionHandle(void) { return m_hGCCConnHandle; }
  99. void GetAsymIndicator ( GCCAsymmetryIndicator *pIndicator )
  100. {
  101. pIndicator->asymmetry_type = m_LocalAsymIndicator.asymmetry_type;
  102. pIndicator->random_number = m_LocalAsymIndicator.random_number;
  103. }
  104. private:
  105. ConnectionHandle m_hGCCConnHandle;
  106. GCCAsymmetryType m_eAsymType;
  107. LPSTR m_pszAddress;
  108. LPWSTR *m_apConfNames;
  109. HRESULT m_hr;
  110. BOOL m_fRemoteIsMCU;
  111. PT120PRODUCTVERSION m_pVersion;
  112. T120PRODUCTVERSION m_Version;
  113. GCCAsymmetryIndicator m_LocalAsymIndicator;
  114. BOOL m_fInUnknownQueryRequest;
  115. int m_nRandSeed;
  116. BOOL m_fSecure;
  117. LPWSTR *m_apConfDescriptors;
  118. };
  119. // The CSequentialWorkList class is used to process a series
  120. // of asynchronous requests one at a time.
  121. // The user subclasses CWorkItem and puts the CWorkItem object into
  122. // the list by calling CSequentialWorkList::Add().
  123. // When it is its turn to be processed (i.e. there are no pending requests),
  124. // CWorkItem::Handle() is called. When the asynchonous work is done,
  125. // the user calls CSequentialWorkList::Remove which takes the CWorkItem
  126. // object out of the list, destroys it and calls CWorkItem::Handle() for
  127. // the next CWorkItem in the list (if any).
  128. class CSequentialWorkList : public CList
  129. {
  130. DEFINE_CLIST(CSequentialWorkList, CWorkItem*)
  131. public:
  132. ~CSequentialWorkList(void)
  133. {
  134. // Don't want to destroy an event list with pending events.
  135. // Codework: build I/O rundown into a generic event list,
  136. // and subclass.
  137. ASSERT(IsEmpty());
  138. }
  139. void AddWorkItem(CWorkItem * pWorkItem);
  140. void RemoveWorkItem(CWorkItem * pWorkItem);
  141. void PurgeListEntriesByOwner(DCRNCConference *pOwner);
  142. void DeleteList(void);
  143. };
  144. #define DEFINE_SEQ_WORK_LIST(_NewClass_,_PtrItemType_) \
  145. public: \
  146. _NewClass_(UINT cMaxItems = CLIST_DEFAULT_MAX_ITEMS) : CSequentialWorkList(cMaxItems) { ASSERT(sizeof(_PtrItemType_) == sizeof(CWorkItem*)); } \
  147. _NewClass_(_NewClass_ *pSrc) : CSequentialWorkList((CSequentialWorkList *) pSrc) { ASSERT(sizeof(_PtrItemType_) == sizeof(CWorkItem*)); } \
  148. _NewClass_(_NewClass_ &Src) : CSequentialWorkList((CSequentialWorkList *) &Src) { ASSERT(sizeof(_PtrItemType_) == sizeof(CWorkItem*)); } \
  149. BOOL Append(_PtrItemType_ pData) { return CSequentialWorkList::Append((CWorkItem*) pData); } \
  150. BOOL Prepend(_PtrItemType_ pData) { return CSequentialWorkList::Prepend((CWorkItem*) pData); } \
  151. BOOL Remove(_PtrItemType_ pData) { return CSequentialWorkList::Remove((CWorkItem*) pData); } \
  152. BOOL Find(_PtrItemType_ pData) { return CSequentialWorkList::Find((CWorkItem*) pData); } \
  153. _PtrItemType_ Get(void) { return (_PtrItemType_) CSequentialWorkList::Get(); } \
  154. _PtrItemType_ PeekHead(void) { return (_PtrItemType_) CSequentialWorkList::PeekHead(); } \
  155. _PtrItemType_ Iterate(void) { return (_PtrItemType_) CSequentialWorkList::Iterate(); }
  156. class CInviteIndWorkList : public CSequentialWorkList
  157. {
  158. DEFINE_SEQ_WORK_LIST(CInviteIndWorkList, CInviteIndWork*)
  159. public:
  160. void AddWorkItem(CInviteIndWork * pWorkItem)
  161. {
  162. CSequentialWorkList::AddWorkItem(pWorkItem);
  163. }
  164. void RemoveWorkItem(CInviteIndWork * pWorkItem)
  165. {
  166. CSequentialWorkList::RemoveWorkItem(pWorkItem);
  167. }
  168. };
  169. class CJoinIndWorkList : public CSequentialWorkList
  170. {
  171. DEFINE_SEQ_WORK_LIST(CJoinIndWorkList, CJoinIndWork*)
  172. public:
  173. void AddWorkItem(CJoinIndWork * pWorkItem)
  174. {
  175. CSequentialWorkList::AddWorkItem(pWorkItem);
  176. }
  177. void RemoveWorkItem(CJoinIndWork * pWorkItem)
  178. {
  179. CSequentialWorkList::RemoveWorkItem(pWorkItem);
  180. }
  181. };
  182. class CQueryRemoteWorkList : public CSequentialWorkList
  183. {
  184. DEFINE_SEQ_WORK_LIST(CQueryRemoteWorkList, CQueryRemoteWork*)
  185. public:
  186. void AddWorkItem(CQueryRemoteWork * pWorkItem)
  187. {
  188. CSequentialWorkList::AddWorkItem(pWorkItem);
  189. }
  190. void RemoveWorkItem(CQueryRemoteWork * pWorkItem)
  191. {
  192. CSequentialWorkList::RemoveWorkItem(pWorkItem);
  193. }
  194. HRESULT Cancel ( LPVOID pCallerContext );
  195. };
  196. extern CQueryRemoteWorkList *g_pQueryRemoteList;
  197. #endif /* ndef EVENTS_INC */