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.

228 lines
7.6 KiB

  1. // File: ichnldat.h
  2. //
  3. #ifndef _ICHNLDAT_H_
  4. #define _ICHNLDAT_H_
  5. #include "pfnt120.h"
  6. typedef enum _scState { /* State of data channel */
  7. SCS_UNINITIALIZED = 0, // Nothing is valid
  8. SCS_CREATESAP, // Creating m_gcc_pIAppSap
  9. SCS_ATTACH, // Attaching
  10. SCS_ENROLL, // Enrolling in a conference
  11. SCS_JOIN_PRIVATE, // Join the private channel
  12. SCS_REGRETRIEVE, // Checking the registry
  13. SCS_REGRETRIEVE_NEW, // new channel must be created
  14. SCS_REGRETRIEVE_EXISTS, // channel already exists
  15. SCS_JOIN_NEW, // Creating a new MCS channel
  16. SCS_REGCHANNEL, // Registering the MCS channel
  17. SCS_JOIN_OLD, // Joining an existing channel
  18. SCS_REGPRIVATE, // Register the private channel
  19. SCS_CONNECTED, // m_mcs_channel_id is valid
  20. SCS_TERMINATING, // shutting down
  21. SCS_JOIN_STATIC_CHANNEL // Join a static channel
  22. } SCSTATE;
  23. // An application key consists of an MS Object ID + guid identifier + guid + node id
  24. #define cbKeyApp (4 + 1 + sizeof(GUID) + sizeof(DWORD))
  25. #define MAX_CHECKID_COUNT 80 // Maximum number of times to ask for channel Id
  26. typedef struct _tagUcid {
  27. DWORD dwUserId; // Node ID
  28. ChannelID channelId; // Private channel ID
  29. UserID sender_id_public;
  30. UserID sender_id_private;
  31. } UCID;
  32. // CNmMemberId
  33. class CNmMemberId
  34. {
  35. private:
  36. UINT m_cCheckId; // non-zero means checking the ID
  37. ChannelID m_channelId; // Private channel ID
  38. UserID m_sender_id_public;
  39. UserID m_sender_id_private;
  40. CNmMember *m_pMember;
  41. public:
  42. CNmMemberId(CNmMember *pMember, UCID *pucid);
  43. ChannelID GetChannelId(void) {return m_channelId;}
  44. ChannelID SenderId(void) {return m_sender_id_public;}
  45. VOID UpdateRosterInfo(UCID * pucid);
  46. BOOL FSenderId(UserID id) {return ((id == m_sender_id_public) || (id == m_sender_id_private));}
  47. UINT GetCheckIdCount(void) {return m_cCheckId;}
  48. VOID SetCheckIdCount(UINT c) {m_cCheckId = c;}
  49. CNmMember *GetMember(void) {return m_pMember;}
  50. };
  51. // INmChannelData
  52. //
  53. class CNmChannelData : public INmChannelData2,
  54. public DllRefCount, public CConnectionPointContainer
  55. {
  56. private:
  57. GUID m_guid; // SetGuid/GetGuid
  58. BOOL m_fClosed; // TRUE when CloseConnection is called
  59. BOOL m_fActive; // TRUE when data channel is active
  60. DWORD m_dwUserIdLocal; // Data channel needs to know local user id
  61. CConfObject * m_pConference; // Helpful to get member list
  62. ULONG m_cMember; // Number of members in this channel
  63. COBLIST * m_pListMemberId; // Member id list
  64. COBLIST * m_pListMember; // Member list
  65. PGCCEnrollRequest m_pGCCER; // Enroll request from enrolling app
  66. public:
  67. CNmChannelData(CConfObject * pConference, REFGUID rguid, PGCCEnrollRequest pER = NULL);
  68. ~CNmChannelData();
  69. // Internal functions
  70. GUID * PGuid(void) {return &m_guid;}
  71. VOID UpdatePeer(CNmMember * pMember, UCID *pucid, BOOL fAdd);
  72. VOID UpdateRoster(UCID * rgPeer, int cPeer, BOOL fAdd, BOOL fRemove);
  73. VOID UpdateMemberChannelId(DWORD dwUserId, ChannelID channelId);
  74. HRESULT OpenConnection(void);
  75. HRESULT CloseConnection(void);
  76. ULONG IsEmpty() {return 0 == m_cMember;}
  77. COBLIST * GetMemberList() {return m_pListMember;}
  78. VOID AddMember(CNmMember * pMember);
  79. VOID RemoveMember(CNmMember * pMember);
  80. CNmMemberId *GetMemberId(CNmMember *pMember);
  81. CNmMemberId *GetMemberId(DWORD dwUserId);
  82. VOID UpdateRosterInfo(CNmMember *pMember, UCID * pucid);
  83. ChannelID GetChannelId(CNmMember *pMember);
  84. CNmMember *PMemberFromSenderId(UserID id);
  85. CConfObject * PConference() {return m_pConference;}
  86. DWORD GetLocalId() {return m_dwUserIdLocal;}
  87. // INmChannelData methods
  88. HRESULT STDMETHODCALLTYPE GetGuid(GUID *pguid);
  89. HRESULT STDMETHODCALLTYPE SendData(INmMember *pMember, ULONG uSize, LPBYTE pb, ULONG uOptions);
  90. HRESULT STDMETHODCALLTYPE RegistryAllocateHandle(ULONG numberOfHandlesRequested);
  91. // INmChannel methods
  92. HRESULT STDMETHODCALLTYPE IsSameAs(INmChannel *pChannel);
  93. HRESULT STDMETHODCALLTYPE IsActive(void);
  94. HRESULT STDMETHODCALLTYPE SetActive(BOOL fActive);
  95. HRESULT STDMETHODCALLTYPE GetConference(INmConference **ppConference);
  96. HRESULT STDMETHODCALLTYPE GetInterface(IID *piid);
  97. HRESULT STDMETHODCALLTYPE GetNmch(ULONG *puCh);
  98. HRESULT STDMETHODCALLTYPE EnumMember(IEnumNmMember **ppEnum);
  99. HRESULT STDMETHODCALLTYPE GetMemberCount(ULONG * puCount);
  100. // IUnknown methods
  101. ULONG STDMETHODCALLTYPE AddRef(void);
  102. ULONG STDMETHODCALLTYPE Release(void);
  103. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
  104. /////////////////////////////////////////////////////////////
  105. // class CT120Channel
  106. private:
  107. DWORD DoJoin(SCSTATE scs);
  108. DWORD DoJoinStatic(ChannelID staticChannel);
  109. DWORD DoCreateSap(void);
  110. DWORD DoEnroll(void);
  111. DWORD DoJoinPrivate(void);
  112. DWORD DoAttach(void);
  113. DWORD DoRegRetrieve(void);
  114. DWORD DoRegChannel(void);
  115. DWORD DoJoinNew(void);
  116. DWORD DoJoinOld(void);
  117. DWORD DoRegPrivate(void);
  118. VOID OnEntryConfirmRemote(GCCAppSapMsg * pMsg);
  119. VOID OnEntryConfirmLocal(GCCAppSapMsg * pMsg);
  120. public:
  121. // Methods:
  122. VOID InitCT120Channel(DWORD dwUserId);
  123. GUID * m_pGuid;
  124. CNmChannelData * m_pChannel;
  125. DWORD m_dwUserId;
  126. BYTE m_keyApp[cbKeyApp];
  127. BYTE m_keyChannel[cbKeyApp];
  128. SCSTATE m_scs; // Current state
  129. GCCConferenceID m_gcc_conference_id;
  130. IGCCAppSap *m_gcc_pIAppSap;
  131. GCCSessionKey m_gcc_session_key;
  132. GCCRegistryKey m_gcc_registry_key;
  133. GCCRegistryItem m_gcc_registry_item;
  134. GCCRegistryKey m_registry_key_Private;
  135. GCCRegistryItem m_registry_item_Private;
  136. ChannelID m_mcs_channel_id; // public channel ID
  137. PIMCSSap m_pmcs_sap;
  138. UserID m_gcc_node_id;
  139. // m_mcs_sender_id is the result of MCS_ATTACH_USER_CONFIRM.
  140. // It is also the "sender_id" in MCS_SEND_DATA_INDICATION
  141. UserID m_mcs_sender_id;
  142. // Properties:
  143. BOOL FConnected(void) {return (SCS_CONNECTED == m_scs);}
  144. ChannelID GetMcsChannelId() {return m_mcs_channel_id;}
  145. ChannelID SenderChannelId() {return m_mcs_sender_id;}
  146. VOID CloseChannel(VOID);
  147. HRESULT HrSendData(ChannelID channelId, DWORD dwUserId, LPVOID lpv, DWORD cb, DWORD opt);
  148. VOID UpdateScState(SCSTATE scs, DWORD dwErr);
  149. VOID ProcessEntryConfirm(GCCAppSapMsg * pMsg);
  150. BOOL UpdateRoster(GCCAppSapMsg * pMsg);
  151. VOID RemovePeer(UINT iPeer);
  152. VOID RequestChannelId(DWORD dwUserId);
  153. VOID NotifyChannelConnected(void);
  154. VOID ProcessHandleConfirm(GCCAppSapMsg * pMsg);
  155. };
  156. DECLARE_STANDARD_TYPES(CNmChannelData);
  157. void CALLBACK NmGccMsgHandler(GCCAppSapMsg * pMsg);
  158. void CALLBACK NmMcsMsgHandler(unsigned int uMsg, LPARAM lParam, PVOID pv);
  159. // list management
  160. POSITION AddNode(PVOID pv, COBLIST **ppList);
  161. PVOID RemoveNodePos(POSITION * pPos, COBLIST *pList);
  162. VOID RemoveNode(PVOID pv, COBLIST * pList);
  163. // Data Notification Structure
  164. typedef struct {
  165. INmMember * pMember;
  166. LPBYTE pb;
  167. ULONG cb;
  168. ULONG dwFlags;
  169. } NMN_DATA_XFER;
  170. // Global Routines
  171. VOID FreeMemberIdList(COBLIST ** ppList);
  172. HRESULT OnNmDataSent(IUnknown *pConferenceNotify, void *pv, REFIID riid);
  173. HRESULT OnNmDataReceived(IUnknown *pConferenceNotify, void *pv, REFIID riid);
  174. HRESULT OnAllocateHandleConfirm(IUnknown *pConferenceNotify, void *pv, REFIID riid);
  175. #endif // _ICHNLDAT_H_