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.

374 lines
9.4 KiB

  1. #include "precomp.h"
  2. #include "fsdiag.h"
  3. DEBUG_FILEZONE(ZONE_T120_CONF_ROSTER);
  4. /*
  5. * crostmgr.cpp
  6. *
  7. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  8. *
  9. * Abstract:
  10. * This is the implementation file for the Conference Roster
  11. * Manager Class.
  12. *
  13. * SEE THE INTERFACE FILE FOR A MORE DETAILED EXPLANATION OF THIS CLASS
  14. *
  15. * Private Instance Variable:
  16. * m_pGlobalConfRoster
  17. * A pointer to the global conference roster.
  18. * m_pLocalConfRoster
  19. * A pointer to the local conference roster.
  20. * m_fTopProvider
  21. * Flag indicating if this is a Top Provider node.
  22. * m_pMcsUserObject
  23. * Pointer to the MCS user object associated with this conference.
  24. * m_pConf
  25. * Pointer to object that will receive all the owner callbacks.
  26. *
  27. * Caveats:
  28. * None
  29. *
  30. * Author:
  31. * blp
  32. */
  33. #include "crostmsg.h"
  34. #include "crostmgr.h"
  35. #include "conf.h"
  36. /*
  37. * CConfRosterMgr ()
  38. *
  39. * Public Function Description
  40. * This is the conference roster constructor. It is responsible for
  41. * initializing all the instance variables used by this class.
  42. */
  43. CConfRosterMgr::CConfRosterMgr(
  44. PMCSUser user_object,
  45. CConf *pConf,
  46. BOOL top_provider,
  47. PGCCError rc)
  48. :
  49. CRefCount(MAKE_STAMP_ID('C','R','M','r')),
  50. m_fTopProvider(top_provider),
  51. m_pMcsUserObject(user_object),
  52. m_pLocalConfRoster(NULL),
  53. m_pGlobalConfRoster(NULL),
  54. m_pConf(pConf)
  55. {
  56. BOOL maintain_pdu_buffer;
  57. DebugEntry(CConfRosterMgr::CConfRosterMgr);
  58. *rc = GCC_NO_ERROR;
  59. // Here we determine if the roster needs to maintain PDU data
  60. maintain_pdu_buffer = m_fTopProvider;
  61. // Create the global conference roster.
  62. DBG_SAVE_FILE_LINE
  63. m_pGlobalConfRoster = new CConfRoster( m_pMcsUserObject->GetTopNodeID(),
  64. m_pMcsUserObject->GetParentNodeID(),
  65. m_pMcsUserObject->GetMyNodeID(),
  66. m_fTopProvider,
  67. FALSE, // Is not Local
  68. maintain_pdu_buffer);
  69. if (m_pGlobalConfRoster != NULL)
  70. {
  71. if (m_fTopProvider == FALSE)
  72. {
  73. // Create the local conference roster.
  74. DBG_SAVE_FILE_LINE
  75. m_pLocalConfRoster = new CConfRoster(
  76. m_pMcsUserObject->GetTopNodeID(),
  77. m_pMcsUserObject->GetParentNodeID(),
  78. m_pMcsUserObject->GetMyNodeID(),
  79. m_fTopProvider,
  80. TRUE, // Is Local
  81. TRUE // Maintain PDU buffer
  82. );
  83. if (m_pLocalConfRoster == NULL)
  84. *rc = GCC_ALLOCATION_FAILURE;
  85. }
  86. }
  87. else
  88. *rc = GCC_ALLOCATION_FAILURE;
  89. DebugExitVOID(CConfRosterMgr::CConfRosterMgr);
  90. }
  91. /*
  92. * ~CConfRosterMgr ()
  93. *
  94. * Public Function Description
  95. * This is the conference roster destructor. It is responsible for
  96. * freeing up all memory allocated by this class.
  97. */
  98. CConfRosterMgr::~CConfRosterMgr(void)
  99. {
  100. if (NULL != m_pGlobalConfRoster)
  101. {
  102. m_pGlobalConfRoster->Release();
  103. }
  104. if (NULL != m_pLocalConfRoster)
  105. {
  106. m_pLocalConfRoster->Release();
  107. }
  108. }
  109. /*
  110. * GCCError AddNodeRecord ()
  111. *
  112. * Public Function Description
  113. * This routine is used to add a new record to the conference roster.
  114. * This class makes the decision about which roster the new record goes
  115. * into (global or local).
  116. */
  117. GCCError CConfRosterMgr::AddNodeRecord(PGCCNodeRecord node_record)
  118. {
  119. GCCError rc = GCC_NO_ERROR;
  120. CConfRoster *conference_roster;
  121. DebugEntry(CConfRosterMgr::AddNodeRecord);
  122. /*
  123. ** First determinate the right conference roster. For non Top Providers
  124. ** the global roster will be updated when the refresh comes back in.
  125. */
  126. conference_roster = m_fTopProvider ? m_pGlobalConfRoster : m_pLocalConfRoster;
  127. // Add the top providers conference record to the roster.
  128. rc = conference_roster->AddRecord(node_record,
  129. m_pMcsUserObject->GetMyNodeID());
  130. DebugExitINT(CConfRosterMgr::AddNodeRecord, rc);
  131. return rc;
  132. }
  133. /*
  134. * GCCError UpdateNodeRecord ()
  135. *
  136. * Public Function Description
  137. * This routine is used to replace a record in the conference roster with
  138. * a new record. This class makes the decision about which roster the new
  139. * record affects (global or local).
  140. */
  141. GCCError CConfRosterMgr::UpdateNodeRecord(PGCCNodeRecord node_record)
  142. {
  143. GCCError rc = GCC_NO_ERROR;
  144. CConfRoster *conference_roster;
  145. DebugEntry(CConfRosterMgr::UpdateNodeRecord);
  146. /*
  147. ** First determinate the right conference roster. For non Top Providers
  148. ** the global roster will be updated when the refresh comes back in.
  149. */
  150. conference_roster = m_fTopProvider ? m_pGlobalConfRoster : m_pLocalConfRoster;
  151. rc = conference_roster->ReplaceRecord(node_record, m_pMcsUserObject->GetMyNodeID());
  152. DebugExitINT(CConfRosterMgr::UpdateNodeRecord, rc);
  153. return rc;
  154. }
  155. /*
  156. * GCCError RemoveUserReference ()
  157. *
  158. * Public Function Description
  159. * This routine removes the record associated with the specified node
  160. * id.
  161. */
  162. GCCError CConfRosterMgr::RemoveUserReference(UserID deteched_node_id)
  163. {
  164. GCCError rc = GCC_NO_ERROR;
  165. CConfRoster *conference_roster;
  166. DebugEntry(CConfRosterMgr::RemoveUserReference);
  167. /*
  168. ** First determinate the right conference roster. For non Top Providers
  169. ** the global roster will be updated when the refresh comes back in.
  170. */
  171. conference_roster = m_fTopProvider ? m_pGlobalConfRoster : m_pLocalConfRoster;
  172. rc = conference_roster->RemoveUserReference (deteched_node_id);
  173. DebugExitINT(CConfRosterMgr::RemoveUserReference, rc);
  174. return rc;
  175. }
  176. /*
  177. * GCCError RosterUpdateIndication ()
  178. *
  179. * Public Function Description
  180. * This routine is responsible for processing the decoded PDU data.
  181. * It essentially passes the PDU on along to the appropriate roster.
  182. */
  183. GCCError CConfRosterMgr::RosterUpdateIndication(
  184. PGCCPDU roster_update,
  185. UserID sender_id)
  186. {
  187. GCCError rc = GCC_NO_ERROR;
  188. CConfRoster *conference_roster;
  189. DebugEntry(CConfRosterMgr::RosterUpdateIndication);
  190. /*
  191. ** Determine if this update came from the Top Provider or a node
  192. ** below this node. This dictates which conference roster will
  193. ** process the PDU.
  194. */
  195. conference_roster = (m_fTopProvider || (sender_id == m_pMcsUserObject->GetTopNodeID())) ?
  196. m_pGlobalConfRoster :
  197. m_pLocalConfRoster;
  198. rc = conference_roster->ProcessRosterUpdateIndicationPDU (
  199. &roster_update->u.indication.u.roster_update_indication.
  200. node_information,
  201. sender_id);
  202. DebugExitINT(CConfRosterMgr::RosterUpdateIndication, rc);
  203. return rc;
  204. }
  205. /*
  206. * GCCError FlushRosterUpdateIndication ()
  207. *
  208. * Public Function Description
  209. * This routine is used to access any PDU data that might currently be
  210. * queued inside the conference roster. It also is responsible for
  211. * flushing a roster update message if necessary.
  212. */
  213. GCCError CConfRosterMgr::FlushRosterUpdateIndication(PNodeInformation node_information)
  214. {
  215. GCCError rc = GCC_NO_ERROR;
  216. CConfRoster *conference_roster;
  217. CConfRosterMsg *roster_message;
  218. DebugEntry(CConfRosterMgr::FlushRosterUpdateIndication);
  219. // First determine the conference roster that is affected.
  220. conference_roster = m_fTopProvider ? m_pGlobalConfRoster : m_pLocalConfRoster;
  221. // Now add the node information to the PDU structure.
  222. conference_roster->FlushRosterUpdateIndicationPDU (node_information);
  223. /*
  224. ** Next we must deliver any roster update messages that need to be
  225. ** delivered.
  226. */
  227. if (m_pGlobalConfRoster->HasRosterChanged ())
  228. {
  229. DBG_SAVE_FILE_LINE
  230. roster_message = new CConfRosterMsg(m_pGlobalConfRoster);
  231. if (roster_message != NULL)
  232. {
  233. m_pConf->ConfRosterReportIndication(roster_message);
  234. roster_message->Release();
  235. }
  236. else
  237. {
  238. ERROR_OUT(("CConfRosterMgr::FlushRosterUpdateIndication: can't create CConfRosterMsg"));
  239. rc = GCC_ALLOCATION_FAILURE;
  240. }
  241. }
  242. /*
  243. ** Now perform the necessary cleanup which includes resetting the
  244. ** conference rosters to their neutral state.
  245. */
  246. m_pGlobalConfRoster->ResetConferenceRoster ();
  247. if (m_fTopProvider == FALSE)
  248. m_pLocalConfRoster->ResetConferenceRoster ();
  249. DebugExitINT(CConfRosterMgr::FlushRosterUpdateIndication, rc);
  250. return rc;
  251. }
  252. /*
  253. * GCCError GetFullRosterRefreshPDU ()
  254. *
  255. * Public Function Description
  256. * This routine is used to access a full conference roster refresh.
  257. */
  258. GCCError CConfRosterMgr::GetFullRosterRefreshPDU(PNodeInformation node_information)
  259. {
  260. GCCError rc;
  261. DebugEntry(CConfRosterMgr::GetFullRosterRefreshPDU);
  262. if (m_fTopProvider)
  263. {
  264. // Call on the global roster to build a full refresh PDU.
  265. rc = m_pGlobalConfRoster->BuildFullRefreshPDU ();
  266. if (rc == GCC_NO_ERROR)
  267. {
  268. /*
  269. ** Now flush the full refresh PDU. Note that this will also
  270. ** deliver any queued roster update messages to the local
  271. ** SAPs that may be queued.
  272. */
  273. rc = FlushRosterUpdateIndication (node_information);
  274. }
  275. }
  276. else
  277. rc = GCC_INVALID_PARAMETER;
  278. DebugExitINT(CConfRosterMgr::GetFullRosterRefreshPDU, rc);
  279. return rc;
  280. }
  281. /*
  282. * BOOL Contains ()
  283. *
  284. * Public Function Description
  285. * This routine is used to determine if the specified record exists in
  286. * the conference roster.
  287. */
  288. /*
  289. * CConfRoster *GetConferenceRosterPointer ()
  290. *
  291. * Public Function Description
  292. * This routine is used to access a pointer to the conference roster
  293. * managed by this conference roster manager. The global roster
  294. * is always returned by this routine.
  295. */
  296. /*
  297. * USHORT GetNumberOfConferenceRecords ()
  298. *
  299. * Public Function Description
  300. * This routine returns the total number of conference roster records
  301. * contained in the global conference roster record list.
  302. */
  303. BOOL CConfRosterMgr::
  304. IsThisNodeParticipant ( GCCNodeID nid )
  305. {
  306. return ((NULL != m_pGlobalConfRoster) ?
  307. m_pGlobalConfRoster->Contains(nid) :
  308. FALSE);
  309. }