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.

222 lines
7.0 KiB

  1. // File: ichnldat.h
  2. //
  3. #ifndef _ICHNLDAT_H_
  4. #define _ICHNLDAT_H_
  5. typedef enum _scState { /* State of data channel */
  6. SCS_UNINITIALIZED = 0, // Nothing is valid
  7. SCS_CREATESAP, // Creating m_gcc_pIAppSap
  8. SCS_ATTACH, // Attaching
  9. SCS_ENROLL, // Enrolling in a conference
  10. SCS_JOIN_PRIVATE, // Join the private channel
  11. SCS_REGRETRIEVE, // Checking the registry
  12. SCS_REGRETRIEVE_NEW, // new channel must be created
  13. SCS_REGRETRIEVE_EXISTS, // channel already exists
  14. SCS_JOIN_NEW, // Creating a new MCS channel
  15. SCS_REGCHANNEL, // Registering the MCS channel
  16. SCS_JOIN_OLD, // Joining an existing channel
  17. SCS_REGPRIVATE, // Register the private channel
  18. SCS_CONNECTED, // m_mcs_channel_id is valid
  19. SCS_TERMINATING, // shutting down
  20. SCS_JOIN_STATIC_CHANNEL // Join a static channel
  21. } SCSTATE;
  22. // An application key consists of an MS Object ID + guid identifier + guid + node id
  23. #define cbKeyApp (4 + 1 + sizeof(GUID) + sizeof(DWORD))
  24. #define MAX_CHECKID_COUNT 80 // Maximum number of times to ask for channel Id
  25. typedef struct _tagUcid {
  26. DWORD dwUserId; // Node ID
  27. ChannelID channelId; // Private channel ID
  28. UserID sender_id_public;
  29. UserID sender_id_private;
  30. } UCID;
  31. // CNmMemberId
  32. class CNmMemberId
  33. {
  34. private:
  35. UINT m_cCheckId; // non-zero means checking the ID
  36. ChannelID m_channelId; // Private channel ID
  37. UserID m_sender_id_public;
  38. UserID m_sender_id_private;
  39. CNmMember *m_pMember;
  40. public:
  41. CNmMemberId(CNmMember *pMember, UCID *pucid);
  42. ChannelID GetChannelId(void) {return m_channelId;}
  43. ChannelID SenderId(void) {return m_sender_id_public;}
  44. VOID UpdateRosterInfo(UCID * pucid);
  45. BOOL FSenderId(UserID id) {return ((id == m_sender_id_public) || (id == m_sender_id_private));}
  46. UINT GetCheckIdCount(void) {return m_cCheckId;}
  47. VOID SetCheckIdCount(UINT c) {m_cCheckId = c;}
  48. CNmMember *GetMember(void) {return m_pMember;}
  49. };
  50. // INmChannelData
  51. //
  52. class CNmChannelData : public INmChannelData,
  53. public RefCount,
  54. 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);
  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. STDMETHODIMP IsActive(void);
  89. STDMETHODIMP SetActive(BOOL fActive);
  90. STDMETHODIMP GetConference(INmConference **ppConference);
  91. STDMETHODIMP EnumMember(IEnumNmMember **ppEnum);
  92. STDMETHODIMP GetMemberCount(ULONG * puCount); STDMETHODIMP GetGuid(GUID *pguid);
  93. STDMETHODIMP SendData(INmMember *pMember, ULONG uSize, LPBYTE pb, ULONG uOptions);
  94. STDMETHODIMP RegistryAllocateHandle(ULONG numberOfHandlesRequested);
  95. // IUnknown methods
  96. ULONG STDMETHODCALLTYPE AddRef(void);
  97. ULONG STDMETHODCALLTYPE Release(void);
  98. STDMETHODIMP QueryInterface(REFIID riid, PVOID *ppvObj);
  99. /////////////////////////////////////////////////////////////
  100. // class CT120Channel
  101. private:
  102. DWORD DoJoin(SCSTATE scs);
  103. DWORD DoJoinStatic(ChannelID staticChannel);
  104. DWORD DoCreateSap(void);
  105. DWORD DoEnroll(void);
  106. DWORD DoJoinPrivate(void);
  107. DWORD DoAttach(void);
  108. DWORD DoRegRetrieve(void);
  109. DWORD DoRegChannel(void);
  110. DWORD DoJoinNew(void);
  111. DWORD DoJoinOld(void);
  112. DWORD DoRegPrivate(void);
  113. VOID OnEntryConfirmRemote(GCCAppSapMsg * pMsg);
  114. VOID OnEntryConfirmLocal(GCCAppSapMsg * pMsg);
  115. public:
  116. // Methods:
  117. VOID InitCT120Channel(DWORD dwUserId);
  118. GUID * m_pGuid;
  119. CNmChannelData * m_pChannel;
  120. DWORD m_dwUserId;
  121. BYTE m_keyApp[cbKeyApp];
  122. BYTE m_keyChannel[cbKeyApp];
  123. SCSTATE m_scs; // Current state
  124. GCCConferenceID m_gcc_conference_id;
  125. IGCCAppSap *m_gcc_pIAppSap;
  126. GCCSessionKey m_gcc_session_key;
  127. GCCRegistryKey m_gcc_registry_key;
  128. GCCRegistryItem m_gcc_registry_item;
  129. GCCRegistryKey m_registry_key_Private;
  130. GCCRegistryItem m_registry_item_Private;
  131. ChannelID m_mcs_channel_id; // public channel ID
  132. PIMCSSap m_pmcs_sap;
  133. UserID m_gcc_node_id;
  134. // m_mcs_sender_id is the result of MCS_ATTACH_USER_CONFIRM.
  135. // It is also the "sender_id" in MCS_SEND_DATA_INDICATION
  136. UserID m_mcs_sender_id;
  137. // Properties:
  138. BOOL FConnected(void) {return (SCS_CONNECTED == m_scs);}
  139. ChannelID GetMcsChannelId() {return m_mcs_channel_id;}
  140. ChannelID SenderChannelId() {return m_mcs_sender_id;}
  141. VOID CloseChannel(VOID);
  142. HRESULT HrSendData(ChannelID channelId, DWORD dwUserId, LPVOID lpv, DWORD cb, ULONG opt);
  143. VOID UpdateScState(SCSTATE scs, DWORD dwErr);
  144. VOID ProcessEntryConfirm(GCCAppSapMsg * pMsg);
  145. BOOL UpdateRoster(GCCAppSapMsg * pMsg);
  146. VOID RemovePeer(UINT iPeer);
  147. VOID RequestChannelId(DWORD dwUserId);
  148. VOID NotifyChannelConnected(void);
  149. VOID ProcessHandleConfirm(GCCAppSapMsg * pMsg);
  150. };
  151. DECLARE_STANDARD_TYPES(CNmChannelData);
  152. void CALLBACK NmGccMsgHandler(GCCAppSapMsg * pMsg);
  153. void CALLBACK NmMcsMsgHandler(unsigned int uMsg, LPARAM lParam, PVOID pv);
  154. // list management
  155. POSITION AddNode(PVOID pv, COBLIST **ppList);
  156. PVOID RemoveNodePos(POSITION * pPos, COBLIST *pList);
  157. VOID RemoveNode(PVOID pv, COBLIST * pList);
  158. // Data Notification Structure
  159. typedef struct {
  160. INmMember * pMember;
  161. LPBYTE pb;
  162. ULONG cb;
  163. ULONG dwFlags;
  164. } NMN_DATA_XFER;
  165. // Global Routines
  166. VOID FreeMemberIdList(COBLIST ** ppList);
  167. HRESULT OnNmDataSent(IUnknown *pConferenceNotify, void *pv, REFIID riid);
  168. HRESULT OnNmDataReceived(IUnknown *pConferenceNotify, void *pv, REFIID riid);
  169. HRESULT OnAllocateHandleConfirm(IUnknown *pConferenceNotify, void *pv, REFIID riid);
  170. #endif // _ICHNLDAT_H_