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.

472 lines
16 KiB

  1. #ifndef _GCC_CONTROLLER_
  2. #define _GCC_CONTROLLER_
  3. /*
  4. * gcontrol.h
  5. *
  6. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  7. *
  8. * Abstract:
  9. * It is the responsibility of the controller to create and destroy many
  10. * of the other objects in the system at run-time. There is should only
  11. * be one controller in existence at a time per GCC provider. The
  12. * controller is constructed during system initialization, and not
  13. * destroyed until the provider is shut down. The controller's primary
  14. * responsibility is to maintain five "layers" of objects in the system at
  15. * run-time. These include the Application Interface, the SAPs (the
  16. * Control SAP as well as the Application SAPs), the Conference objects,
  17. * the MCSUser object (which is actualy created by the conference object),
  18. * and the MCS Interface. It also "plugs" together objects in adjacent
  19. * layers by informing a newly created object of the identity of those
  20. * objects with which it must communicate. The newly created object can
  21. * then register itself with the appropriate objects in the layers above
  22. * and below. The controller plays a small role in the passing of
  23. * information during a conference (this is handled by the objects it
  24. * creates).
  25. *
  26. * It is worth noting that the controller is the primary recipient of
  27. * owner callbacks in the GCC system. Most of the objects in its "object
  28. * stack" are capable of issuing owner callbacks to the controller for
  29. * various events and requests.
  30. *
  31. * The controller is not completely portable. Since the nature of
  32. * application and MCS interfaces will vary from platform to platform, the
  33. * interface objects that must be created will also vary. It is necessary
  34. * for the controller to know which objects to create and destroy during
  35. * initialization and cleanup. Other than this, however, the rest of the
  36. * code in the controller class should port cleanly.
  37. *
  38. * The constructor performs all activity required to prepare GCC for use.
  39. * It creates an instance of the Memory Manager class (and possibly a
  40. * Message Memory Manager class in certain environments), which will be
  41. * used for memory handling by other objects in the system. It creates the
  42. * GccAppInterface objects that will be used to communicate with all user
  43. * applications (including the node controller). It creates the MCS
  44. * Interface object that will be used to communicate with MCS. GCC relies
  45. * on an owner callback from a GccAppInterface object to give it a
  46. * heartbeat. It is during this heartbeat that the controller does all of
  47. * its work at run-time.
  48. *
  49. * The destructor essentially does the opposite of what the constructor
  50. * does (as you might expect). It destroys all objects that are "owned"
  51. * by the controller, cleanly shutting everything down.
  52. *
  53. * As mentioned above, the controller is the primary recipient of owner
  54. * callbacks in the GCC system. To accomplish this it overrides the
  55. * Owner-Callback member function. It can then pass its "this" pointer to
  56. * objects that it creates, allowing them to issue owner callbacks when
  57. * necessary. Everything the controller does at run-time is in response
  58. * to these owner callbacks.
  59. *
  60. * The controller is the prime recipient of connect provider indications
  61. * from MCS. Many of the messages that are passed between GCC and the
  62. * GccAppInterface before a conference is established involve the
  63. * controller. These include ConferenceCreateIndication,
  64. * ConferenceInviteIndication, etc. Also, the controller object is
  65. * exclusively responsible for handling conference queries since it
  66. * maintains a complete list of all the conferences that exist in the
  67. * system.
  68. *
  69. * Portable:
  70. * Not Completely (80 % portable)
  71. * Member functions which aren't portable:
  72. * - GCCControl()
  73. * - ~GCCControl()
  74. * - EventLoop()
  75. * - PollCommDevices()
  76. * - CreateApplicationSap()
  77. *
  78. * Protected Instance Variables:
  79. * None.
  80. *
  81. * Caveats:
  82. * None.
  83. *
  84. * Author:
  85. * blp
  86. */
  87. #include "sap.h"
  88. #include "csap.h"
  89. #include "appsap.h"
  90. #include "conf.h"
  91. #include "pktcoder.h"
  92. #include "privlist.h"
  93. #include "mcsdllif.h"
  94. #include "t120app.h"
  95. // #include "gccncif.h"
  96. extern CRITICAL_SECTION g_csGCCProvider;
  97. /*
  98. ** These are the message bases used by the controller object. Any
  99. ** owner callback message received from an object that the controller
  100. ** created must have a message base added to it before it is received
  101. ** at the controller.
  102. */
  103. #define MCS_INTERFACE_MESSAGE_BASE 300 // Leave room for status
  104. enum
  105. {
  106. GCTRL_REBUILD_CONF_POLL_LIST = GCTRLMSG_BASE + 1,
  107. };
  108. // permit to enroll callback list
  109. class CApplet;
  110. class CAppletList : public CList
  111. {
  112. DEFINE_CLIST(CAppletList, CApplet*)
  113. };
  114. /*
  115. ** The conference information structure is used to temporarily store
  116. ** information needed to create a conference while waiting for a
  117. ** conference create response.
  118. */
  119. typedef struct PENDING_CREATE_CONF
  120. {
  121. // a destructor to this data structure
  122. PENDING_CREATE_CONF(void);
  123. ~PENDING_CREATE_CONF(void);
  124. LPSTR pszConfNumericName;
  125. LPWSTR pwszConfTextName;
  126. BOOL password_in_the_clear;
  127. BOOL conference_is_locked;
  128. BOOL conference_is_listed;
  129. BOOL conference_is_conductible;
  130. GCCTerminationMethod termination_method;
  131. PPrivilegeListData conduct_privilege_list;
  132. PPrivilegeListData conduct_mode_privilege_list;
  133. PPrivilegeListData non_conduct_privilege_list;
  134. LPWSTR pwszConfDescription;
  135. ConnectionHandle connection_handle;
  136. UserID parent_node_id;
  137. UserID top_node_id;
  138. TagNumber tag_number;
  139. }
  140. PENDING_CREATE_CONF;
  141. /*
  142. ** This defines the template for the list that keeps track of information
  143. ** associated with a conference that is waiting for a response on a
  144. ** create conference indication.
  145. */
  146. class CPendingCreateConfList2 : public CList2
  147. {
  148. DEFINE_CLIST2(CPendingCreateConfList2, PENDING_CREATE_CONF*, GCCConfID)
  149. };
  150. /*
  151. ** The join information structure is used to temporarily store
  152. ** information needed to join a conference after the join response is
  153. ** issued.
  154. */
  155. typedef struct PENDING_JOIN_CONF
  156. {
  157. PENDING_JOIN_CONF(void);
  158. ~PENDING_JOIN_CONF(void);
  159. CPassword *convener_password;
  160. CPassword *password_challenge;
  161. LPWSTR pwszCallerID;
  162. BOOL numeric_name_present;
  163. GCCConfID nConfID;
  164. }
  165. PENDING_JOIN_CONF;
  166. /*
  167. ** This defines the template for the list that keeps track of information
  168. ** associated with an outstanding join request.
  169. */
  170. class CPendingJoinConfList2 : public CList2
  171. {
  172. DEFINE_CLIST2_(CPendingJoinConfList2, PENDING_JOIN_CONF*, ConnectionHandle)
  173. };
  174. // Holds the list of outstanding query request
  175. class CPendingQueryConfList2 : public CList2
  176. {
  177. DEFINE_CLIST2_(CPendingQueryConfList2, GCCConfID, ConnectionHandle)
  178. };
  179. extern HANDLE g_hevGCCOutgoingPDU;
  180. class GCCController : public CRefCount
  181. {
  182. public:
  183. GCCController(PGCCError);
  184. ~GCCController(void);
  185. void RegisterAppSap(CAppSap *);
  186. void UnRegisterAppSap(CAppSap *);
  187. void RegisterApplet(CApplet *);
  188. void UnregisterApplet(CApplet *);
  189. CConf *GetConfObject(GCCConfID nConfID) { return m_ConfList2.Find(nConfID); }
  190. // Functions initiated from the node controller
  191. GCCError ConfCreateRequest(CONF_CREATE_REQUEST *, GCCConfID *);
  192. void WndMsgHandler ( UINT uMsg );
  193. BOOL FlushOutgoingPDU ( void );
  194. void SetEventToFlushOutgoingPDU ( void ) { ::SetEvent(g_hevGCCOutgoingPDU); }
  195. // Functions initiated from Control SAP
  196. GCCError ConfCreateResponse(PConfCreateResponseInfo);
  197. GCCError ConfQueryRequest(PConfQueryRequestInfo);
  198. GCCError ConfQueryResponse(PConfQueryResponseInfo);
  199. GCCError ConfJoinRequest(PConfJoinRequestInfo, GCCConfID *);
  200. GCCError ConfJoinIndResponse(PConfJoinResponseInfo);
  201. GCCError ConfInviteResponse(PConfInviteResponseInfo);
  202. GCCError FailConfJoinIndResponse(GCCConfID, ConnectionHandle);
  203. GCCError FailConfJoinIndResponse(PConfJoinResponseInfo);
  204. void RemoveConfJoinInfo(ConnectionHandle hConn);
  205. // Functions initiated from Conference object
  206. GCCError ProcessConfEstablished(GCCConfID);
  207. GCCError ProcessConfTerminated(GCCConfID, GCCReason);
  208. // Functions initiated from the MCS Interface
  209. GCCError ProcessConnectProviderIndication(PConnectProviderIndication);
  210. GCCError ProcessConferenceCreateRequest(PConferenceCreateRequest, PConnectProviderIndication);
  211. GCCError ProcessConferenceQueryRequest(PConferenceQueryRequest, PConnectProviderIndication);
  212. GCCError ProcessConferenceJoinRequest(PConferenceJoinRequest, PConnectProviderIndication);
  213. GCCError ProcessConferenceInviteRequest(PConferenceInviteRequest, PConnectProviderIndication);
  214. GCCError ProcessConnectProviderConfirm(PConnectProviderConfirm);
  215. GCCError ProcessConferenceQueryResponse(PConferenceQueryResponse, PConnectProviderConfirm);
  216. GCCError ProcessDisconnectProviderIndication(ConnectionHandle);
  217. void CancelConfQueryRequest(ConnectionHandle);
  218. private:
  219. /*
  220. ** Routines called from the Owner-Callback function
  221. */
  222. // Miscelaneous support functions
  223. GCCConfID AllocateConferenceID();
  224. GCCConfID AllocateQueryID();
  225. GCCConfID GetConferenceIDFromName(
  226. PGCCConferenceName conference_name,
  227. GCCNumericString conference_modifier);
  228. void RebuildConfPollList ( void );
  229. void PostMsgToRebuildConfPollList ( void );
  230. private:
  231. CPendingCreateConfList2 m_PendingCreateConfList2;
  232. CPendingJoinConfList2 m_PendingJoinConfList2;
  233. CPendingQueryConfList2 m_PendingQueryConfList2;
  234. CConfList m_ConfDeleteList;
  235. CConfList2 m_ConfList2;
  236. CAppSapList m_AppSapList;
  237. BOOL m_fConfListChangePending;
  238. GCCConfID m_ConfIDCounter;
  239. GCCConfID m_QueryIDCounter;
  240. BOOL m_fControllerIsExiting;
  241. DWORD m_dwControllerWaitTimeout;
  242. DWORD m_dwControllerEventMask;
  243. // These list are used only for iterating. Whenever a conference or
  244. // application SAP object is deleted (or created in the case of an
  245. // application SAP) it is added to the dictionary list first and
  246. // a flag is set which forces the Polled list to get recreated at the
  247. // top of the next heartbeat.
  248. CConfList m_ConfPollList;
  249. // T120 Applet list
  250. CAppletList m_AppletList;
  251. };
  252. extern GCCController *g_pGCCController;
  253. /*
  254. * GCCController (PGCCError gcc_error)
  255. *
  256. * Public member function of Conference
  257. *
  258. * Function Description
  259. * This is the Windows 32 Bit version of the GCC controller constructor. It
  260. * is responsible for initializing all the instance variables used by this
  261. * class. It is also responsible for creating the memory manager, the
  262. * packet coder, the Node Controller application interface, the Shared
  263. * memory interface used to communicate with enrolled applications, the
  264. * Node Controller SAP and the MCS Interface. It also sets up the
  265. * g_csGCCProvider that protects the core of GCC in the multi-threaded
  266. * Win32 environment. It also sets up a number of Windows Event objects
  267. * used to signal the GCC thread when various events happen at the
  268. * interfaces. The last thing it does before returning if no errors have
  269. * occured is launch the GCC thread. Fatal errors are returned from this
  270. * constructor in the return value.
  271. *
  272. * Formal Parameters:
  273. * gcc_error - (o) Errors that occur are returned here.
  274. *
  275. * Return Value
  276. * None.
  277. *
  278. * Side Effects
  279. * This constructor launches the GCC thread if no errors occur.
  280. *
  281. * Caveats
  282. * This constructor is very specific to the Win32 environment. When
  283. * porting GCC to other platforms, this constructor will have to be
  284. * rewritten for the proper platform.
  285. */
  286. /*
  287. * GCCController( USHORT timer_duration,
  288. * PGCCError gcc_error)
  289. *
  290. * Public member function of Conference
  291. *
  292. * Function Description
  293. * This is the Windows 16 Bit version of the GCC controller constructor. It
  294. * is responsible for initializing all the instance variables used by this
  295. * class. It is also responsible for creating the memory manager, the
  296. * packet coder, the Node Controller application interface, the Shared
  297. * memory interface used to communicate with enrolled applications, the
  298. * Node Controller SAP and the MCS Interface. It also sets up the
  299. * internal Windows timer if a timer_interval other than zero is specified.
  300. * Fatal errors are returned from this constructor in the return value.
  301. *
  302. * Formal Parameters:
  303. * timer_duration - (i) Timer interval in miliseconds that the
  304. * heartbeat will trigger at.
  305. * instance_handle - (i) This is the windows instance handle used to
  306. * set up the Windows timer.
  307. * gcc_error - (o) Errors that occur are returned here.
  308. *
  309. * Return Value
  310. * None.
  311. *
  312. * Side Effects
  313. * None.
  314. *
  315. * Caveats
  316. * This constructor is very specific to the Win16 environment. When
  317. * porting GCC to other platforms, this constructor will have to be
  318. * rewritten for the proper platform.
  319. */
  320. /*
  321. * ~GCCController();
  322. *
  323. * Public member function of Conference
  324. *
  325. * Function Description
  326. * This is the Controller destructor. All platform specific cleanup that
  327. * occurs is included in this destructor but is "macro'd" out in
  328. * environments where the cleanup is not necessary (things like
  329. * critical sections, and Windows timers). Deleting the controller
  330. * essentially shuts down GCC. Deleting all the active conferences, SAPs,
  331. * and interfaces along with all the GCC support modules (memory manager,
  332. * packet coder, etc.).
  333. *
  334. * Formal Parameters:
  335. * None.
  336. *
  337. * Return Value
  338. * None.
  339. *
  340. * Side Effects
  341. * None.
  342. *
  343. * Caveats
  344. * This destructor includes platform specific code. It may be necessary
  345. * to include some platform specific code here when porting GCC to
  346. * other platforms. Macros should be used to isolate this code
  347. * where ever possible.
  348. */
  349. /*
  350. * ULONG Owner-Callback ( UINT message,
  351. * LPVOID parameter1,
  352. * ULONG parameter2);
  353. *
  354. * Public member function of Conference
  355. *
  356. * Function Description
  357. * This function overides the base class function and is used to
  358. * receive all owner callback information from the objects the
  359. * the controller creates.
  360. *
  361. * Formal Parameters:
  362. * message - (i) Message number including base offset.
  363. * parameter1 - (i) void pointer of message data.
  364. * parameter2 - (i) Long holding message data.
  365. *
  366. * Return Value
  367. * GCC_NO_ERROR - No error occured.
  368. * GCC_ALLOCATION_FAILURE - Resource error occured.
  369. * GCC_INVALID_CONFERENCE_NAME - Invalid conference name passed in.
  370. * GCC_FAILURE_CREATING_DOMAIN - Failure creating domain.
  371. * GCC_BAD_NETWORK_ADDRESS - Bad network address passed in.
  372. * GCC_BAD_NETWORK_ADDRESS_TYPE - Bad network address type passed in.
  373. * GCC_CONFERENCE_ALREADY_EXISTS - Conference specified already exists.
  374. * GCC_INVALID_TRANSPORT - Cannot find specified transport.
  375. * GCC_INVALID_ADDRESS_PREFIX - Bad transport address passed in.
  376. * GCC_INVALID_TRANSPORT_ADDRESS - Bad transport address
  377. * GCC_BAD_SESSION_KEY - Enrolling with invalid session key.
  378. * GCC_INVALID_PASSWORD - Invalid password passed in.
  379. * GCC_BAD_USER_DATA - Invalid user data passed in.
  380. * GCC_INVALID_JOIN_RESPONSE_TAG - No match found for join response tag
  381. * GCC_NO_SUCH_APPLICATION - Invalid SAP handle passed in.
  382. * GCC_CONFERENCE_NOT_ESTABLISHED - Request failed because conference
  383. * was not established.
  384. * GCC_BAD_CAPABILITY_ID - Invalid capability ID passed in.
  385. * GCC_NO_SUCH_APPLICATION - Bad SAP handle passed in.
  386. * GCC_DOMAIN_PARAMETERS_UNACCEPTABLE - Domain parameters were
  387. * unacceptable for this connection.
  388. *
  389. * Side Effects
  390. * None.
  391. *
  392. * Caveats
  393. * None.
  394. */
  395. /*
  396. * void EventLoop();
  397. *
  398. * Public member function of Conference
  399. *
  400. * Function Description
  401. * This routine is only used for the 32 bit windows platform. It gets
  402. * called whenever an event occurs in this environment. These include
  403. * timer events as well as PDU and message events
  404. *
  405. * Formal Parameters:
  406. * None.
  407. *
  408. * Return Value
  409. * None.
  410. *
  411. * Side Effects
  412. * None.
  413. *
  414. * Caveats
  415. * None.
  416. */
  417. #endif // _GCC_CONTROLLER_