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.

289 lines
7.5 KiB

  1. #ifndef _T120_APPLET_SAP_
  2. #define _T120_APPLET_SAP_
  3. /*
  4. * include files
  5. */
  6. #include "it120app.h"
  7. #include "appsap.h"
  8. class CApplet;
  9. typedef enum
  10. {
  11. APPSESS_INITIALIZED,
  12. APPSESS_ATTACH_USER_REQ,
  13. APPSESS_ATTACH_USER_CON,
  14. APPSESS_JOIN_MY_CHANNEL_REQ,
  15. APPSESS_JOIN_MY_CHANNEL_CON,
  16. APPSESS_JOIN_STATIC_CHANNEL_REQ,
  17. APPSESS_JOIN_STATIC_CHANNEL_CON, // may go back to APPSESS_JOIN_STATIC_CHANNEL_REQ
  18. APPSESS_INACTIVELY_ENROLL_REQ,
  19. APPSESS_INACTIVELY_ENROLL_CON,
  20. APPSESS_RESOURCE_REQ,
  21. APPSESS_RESOURCE_CON, // may go back to APPSESS_RESOURCE_REQ
  22. APPSESS_ACTIVELY_ENROLL_REQ,
  23. APPSESS_ACTIVELY_ENROLL_CON,
  24. APPSESS_JOINED,
  25. APPSESS_LEAVING,
  26. APPSESS_LEFT,
  27. }
  28. APPLET_SESSION_STATE;
  29. typedef enum
  30. {
  31. NONE_CHOSEN,
  32. ERROR_CHOSEN,
  33. RESULT_CHOSEN,
  34. }
  35. SESSION_ERROR_TYPE;
  36. typedef enum
  37. {
  38. DCJS_INITIALIZED,
  39. DCJS_RETRIEVE_ENTRY_REQ,
  40. DCJS_RETRIEVE_ENTRY_CON,
  41. DCJS_EXISTING_CHANNEL_JOIN_REQ,
  42. DCJS_EXISTING_CHANNEL_JOIN_CON,
  43. DCJS_NEW_CHANNEL_JOIN_REQ,
  44. DCJS_NEW_CHANNEL_JOIN_CON,
  45. DCJS_REGISTER_CHANNEL_REQ,
  46. DCJS_REGISTER_CHANNEL_CON,
  47. }
  48. DYNCHNL_JOIN_STATE;
  49. class CAppletSession : public IT120AppletSession, public CRefCount
  50. {
  51. friend class CApplet;
  52. friend void CALLBACK MCS_SapCallback(UINT, LPARAM, LPVOID);
  53. friend void CALLBACK GCC_SapCallback(GCCAppSapMsg *);
  54. public:
  55. CAppletSession(CApplet *, T120ConfID);
  56. ~CAppletSession(void);
  57. /* exit the conference */
  58. STDMETHOD_(void, ReleaseInterface) (THIS);
  59. STDMETHOD_(void, Advise) (THIS_
  60. IN LPFN_APPLET_SESSION_CB pfnCallback,
  61. IN LPVOID pAppletContext,
  62. IN LPVOID pSessionContext);
  63. STDMETHOD_(void, Unadvise) (THIS);
  64. /* basic info */
  65. STDMETHOD_(T120ConfID, GetConfID) (THIS) { return m_nConfID; }
  66. STDMETHOD_(BOOL, IsThisNodeTopProvider) (THIS);
  67. STDMETHOD_(T120NodeID, GetTopProvider) (THIS);
  68. /* join/leave */
  69. STDMETHOD_(T120Error, Join) (THIS_
  70. IN T120JoinSessionRequest *);
  71. STDMETHOD_(void, Leave) (THIS);
  72. /* send data */
  73. STDMETHOD_(T120Error, AllocateSendDataBuffer) (THIS_
  74. IN ULONG,
  75. OUT void **);
  76. STDMETHOD_(void, FreeSendDataBuffer) (THIS_
  77. IN void *);
  78. STDMETHOD_(T120Error, SendData) (THIS_
  79. IN DataRequestType,
  80. IN T120ChannelID,
  81. IN T120Priority,
  82. IN LPBYTE,
  83. IN ULONG,
  84. IN SendDataFlags);
  85. /* ------ ADVANCED METHODS ---- */
  86. STDMETHOD_(T120Error, InvokeApplet) (THIS_
  87. IN GCCAppProtEntityList *,
  88. IN GCCSimpleNodeList *,
  89. OUT T120RequestTag *);
  90. STDMETHOD_(T120Error, InquireRoster) (THIS_
  91. IN GCCSessionKey *);
  92. /* ------ registry services ------ */
  93. STDMETHOD_(T120Error, RegistryRequest) (THIS_
  94. IN T120RegistryRequest *);
  95. /* ------ channel services ------ */
  96. STDMETHOD_(T120Error, ChannelRequest) (THIS_
  97. IN T120ChannelRequest *);
  98. /* ------ token services ------ */
  99. STDMETHOD_(T120Error, TokenRequest) (THIS_
  100. IN T120TokenRequest *);
  101. protected:
  102. void GCCCallback(T120AppletSessionMsg *);
  103. void MCSCallback(T120AppletSessionMsg *);
  104. BOOL IsJoining(void);
  105. //
  106. // handy functions for the join process
  107. //
  108. void SetTempMsg(T120AppletSessionMsg *pMsg) { m_pTempMsg = pMsg; }
  109. void ClearTempMsg(void) { m_pTempMsg = NULL; }
  110. void HandleAttachUserConfirm(void);
  111. void HandleJoinChannelConfirm(void);
  112. void HandleEnrollConfirm(void);
  113. void HandleRegisterChannelConfirm(void);
  114. void HandleRetrieveEntryConfirm(void);
  115. void HandleTokenGrabConfirm(void);
  116. private:
  117. void ClearError(void) { m_eErrorType = NONE_CHOSEN; }
  118. void SetError(T120Error err) { m_eErrorType = ERROR_CHOSEN; m_Error.eError = err; }
  119. void SetError(T120Result res) { m_eErrorType = RESULT_CHOSEN; m_Error.eResult = res; }
  120. void SetState(APPLET_SESSION_STATE eState);
  121. APPLET_SESSION_STATE GetState(void) { return m_eState; }
  122. void SendMCSMessage(T120AppletSessionMsg *);
  123. void SendCallbackMessage(T120AppletSessionMsg *);
  124. T120Error DoEnroll(BOOL fEnroll, BOOL fEnrollActively = FALSE);
  125. void DoJoinStaticChannels(void);
  126. void DoResourceRequests(void);
  127. void DoJoinDynamicChannels(BOOL fInitState);
  128. void DoJoined(void);
  129. void DoGrabTokenRequest(void);
  130. void AbortJoin(void);
  131. void SendJoinResult(T120Result eResult = T120_RESULT_SUCCESSFUL, T120Error eErrorCode = T120_NO_ERROR);
  132. void FreeJoinRequest(BOOL fZeroOut);
  133. private:
  134. // remmember the context
  135. LPVOID m_pAppletContext;
  136. LPVOID m_pSessionContext;
  137. LPFN_APPLET_SESSION_CB m_pfnCallback;
  138. // parent applet object
  139. CApplet *m_pApplet;
  140. // tentative sap pointers
  141. IMCSSap *m_pMCSAppletSAP;
  142. // information about myself
  143. T120ConfID m_nConfID;
  144. T120UserID m_uidMyself;
  145. T120SessionID m_sidMyself;
  146. T120EntityID m_eidMyself;
  147. T120NodeID m_nidMyself;
  148. // join state
  149. APPLET_SESSION_STATE m_eState;
  150. ULONG m_nArrayIndex;
  151. // error handling
  152. SESSION_ERROR_TYPE m_eErrorType;
  153. union
  154. {
  155. T120Error eError;
  156. T120Result eResult;
  157. } m_Error;
  158. // join conference request copy
  159. T120JoinSessionRequest m_JoinRequest; // valid during join session
  160. BOOL m_fMCSFreeDataIndBuffer;
  161. // dynamic channels join state
  162. BOOL m_fFirstRoster;
  163. DYNCHNL_JOIN_STATE m_eDynamicChannelJoinState;
  164. T120AppletSessionMsg *m_pTempMsg;
  165. };
  166. class CSessionList : public CList
  167. {
  168. DEFINE_CLIST(CSessionList, CAppletSession*)
  169. CAppletSession *FindByConfID(T120ConfID);
  170. };
  171. class CApplet : public IT120Applet, public CRefCount
  172. {
  173. friend void CALLBACK GCC_SapCallback(GCCAppSapMsg *);
  174. public:
  175. CApplet(T120Error *);
  176. ~CApplet(void);
  177. STDMETHOD_(void, ReleaseInterface) (THIS);
  178. STDMETHOD_(void, Advise) (THIS_
  179. IN LPFN_APPLET_CB pfnCallback,
  180. IN LPVOID pAppletContext);
  181. STDMETHOD_(void, Unadvise) (THIS);
  182. /* ------ Auto Join ------ */
  183. STDMETHOD_(T120Error, RegisterAutoJoin) (THIS_
  184. IN T120JoinSessionRequest *);
  185. STDMETHOD_(void, UnregisterAutoJoin) (THIS);
  186. /* ------ Session ------ */
  187. STDMETHOD_(T120Error, CreateSession) (THIS_
  188. OUT IT120AppletSession **,
  189. IN T120ConfID);
  190. void SendCallbackMessage(T120AppletMsg *pMsg);
  191. IGCCAppSap *GetAppSap(void) { return m_pAppSap; }
  192. void RegisterSession(CAppletSession *p) { m_SessionList.Append(p); }
  193. void UnregisterSession(CAppletSession *p) { m_SessionList.Remove(p); }
  194. CAppletSession *FindSessionByConfID(T120ConfID nConfID) { return m_SessionList.FindByConfID(nConfID); }
  195. protected:
  196. void GCCCallback(T120AppletSessionMsg *);
  197. void HandleAutoJoin(T120ConfID);
  198. private:
  199. LPFN_APPLET_CB m_pfnCallback;
  200. LPVOID m_pAppletContext;
  201. IGCCAppSap *m_pAppSap;
  202. CSessionList m_SessionList;
  203. // for auto join
  204. T120JoinSessionRequest *m_pAutoJoinReq;
  205. CAppletSession *m_pAutoAppletSession;
  206. };
  207. #endif // _T120_APPLET_SAP_