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.

628 lines
19 KiB

  1. /*
  2. * crost.h
  3. *
  4. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * Instances of this class represent a single Conference Roster's
  8. * information base. It encapsulates all the functionality required to
  9. * maintain the information base which includes the ability to add new
  10. * roster records, delete records and update records. It has the ability
  11. * to convert its internal information base into a list of conference
  12. * records that can be used in a GCC_ROSTER_UPDATE_INDICATION callback. It
  13. * is also responsible for converting its internal information base into
  14. * Conference Roster Update PDUs. Basically, this class is responsible
  15. * for all operations that require direct access to the records contained
  16. * in a Conference Roster.
  17. *
  18. * The Conference Roster class incorporates Rogue Wave list to hold the
  19. * roster record information. Using iterators throughout the class makes
  20. * it easy to quickly convert the information contained in the list into
  21. * either a PDU or into a list of record pointers (for roster update
  22. * indications back to the node controller).
  23. *
  24. * A Conference Roster object has the ability to serialize its roster data
  25. * into a single contiguous memory block when it is required to send a
  26. * message to the application interface. This serialization process is
  27. * managed externally by the CConfRosterMsg class through calls to
  28. * LockConferenceRoster(), UnLockConferenceRoster() and
  29. * GetConfRoster(). When a conference roster is to be serialized, a
  30. * call is made to LockConferenceRoster() which causes the CConfRoster
  31. * object to increment an internal lock count and returns the number of
  32. * bytes required to hold the complete roster update. The Conference
  33. * Roster is then serialized into memory through a call to
  34. * GetConfRoster(). The CConfRoster is then unlocked to allow
  35. * it to be deleted when the free flag gets set through the
  36. * FreeConferenceRoster() function. In the current implementation of GCC,
  37. * FreeConferenceRoster() is not used since the CConfRosterMsg
  38. * maintains the data used to deliver the message (see a more detailed
  39. * description of the lock, free and unlock mechanism in the section
  40. * describing the data containers).
  41. *
  42. * The Conference Roster object also is responsible for maintaining
  43. * internal PDU data which is updated whenever a change occurs to its
  44. * internal information base. This PDU can be affected by both local
  45. * request or by processing incoming PDUs. Higher level objects access
  46. * this PDU data by calling the Conference Roster's flush routine which in
  47. * turn causes the PDU to be freed on any subsequent request that affects
  48. * the rosters internal information base.
  49. *
  50. * Caveats:
  51. * None.
  52. *
  53. * Author:
  54. * blp
  55. */
  56. #ifndef _CONFERENCE_ROSTER_
  57. #define _CONFERENCE_ROSTER_
  58. #include "netaddr.h"
  59. #include "userdata.h"
  60. #include "clists.h"
  61. /*
  62. ** These enumerations define the different ways the a conference roster list
  63. ** can be updated. It is used externally to inform a conference roster object
  64. ** what to of send data PDU to build.
  65. */
  66. typedef enum
  67. {
  68. ADD_RECORD,
  69. DELETE_RECORD,
  70. REPLACE_RECORD,
  71. FULL_REFRESH
  72. }
  73. CONF_ROSTER_UPDATE_TYPE;
  74. /*
  75. ** This list is used to keep track of the conference participants. It is
  76. ** a list of rogue wave pointers to Unicode Strings.
  77. */
  78. class CParticipantNameList : public CList
  79. {
  80. DEFINE_CLIST(CParticipantNameList, LPWSTR)
  81. void DeleteList(void);
  82. };
  83. /*
  84. ** This is the structure used to maintain the conference roster information
  85. ** internally. Optional paramters use a NULL pointer to indicate that the
  86. ** parameter is not in use.
  87. */
  88. typedef struct CONF_RECORD
  89. {
  90. CONF_RECORD(void);
  91. ~CONF_RECORD(void);
  92. UserID superior_node;
  93. NodeType node_type;
  94. NodeProperties node_properties;
  95. LPWSTR pwszNodeName;
  96. CParticipantNameList *participant_name_list;
  97. LPWSTR pwszSiteInfo;
  98. CNetAddrListContainer *network_address_list;
  99. LPOSTR poszAltNodeID;
  100. CUserDataListContainer *user_data_list;
  101. }
  102. CONF_RECORD;
  103. /*
  104. ** This list is used to hold the pointers to the actual conference record for
  105. ** each node in the conference. The list is indexed by the Node ID associated
  106. ** with the record.
  107. */
  108. class CConfRecordList2 : public CList2
  109. {
  110. DEFINE_CLIST2_(CConfRecordList2, CONF_RECORD*, UserID)
  111. void CleanList(void);
  112. };
  113. class CConfRoster : public CRefCount
  114. {
  115. public:
  116. CConfRoster(UserID uidTopProvider, UserID uidSuperiorNode, UserID uidMime,
  117. BOOL is_top_provider, BOOL is_local_roster, BOOL maintain_pdu_buffer);
  118. ~CConfRoster(void);
  119. /*
  120. * Utilities that operate on roster update PDU strucutures.
  121. */
  122. void FlushRosterUpdateIndicationPDU(PNodeInformation);
  123. GCCError BuildFullRefreshPDU(void);
  124. GCCError ProcessRosterUpdateIndicationPDU(PNodeInformation, UserID uidSender);
  125. /*
  126. * Utilities used to generate a roster update message.
  127. */
  128. UINT LockConferenceRoster(void);
  129. void UnLockConferenceRoster(void);
  130. UINT GetConfRoster(PGCCConferenceRoster *, LPBYTE memory_pointer);
  131. /*
  132. ** Utilities that operate directly on the conference roster objects
  133. ** internal databease.
  134. */
  135. GCCError AddRecord(PGCCNodeRecord, UserID);
  136. GCCError ReplaceRecord(PGCCNodeRecord, UserID);
  137. GCCError RemoveUserReference(UserID);
  138. /*
  139. ** Miscelaneous utilities.
  140. */
  141. void ResetConferenceRoster(void);
  142. UINT GetNumberOfNodeRecords(void) { return m_RecordList2.GetCount(); }
  143. BOOL Contains(UserID uidConf) { return m_RecordList2.Find(uidConf) ? TRUE : FALSE; }
  144. BOOL HasRosterChanged(void) { return m_fRosterChanged; }
  145. private:
  146. /*
  147. * Utilities used to create a roster update indication PDU.
  148. */
  149. GCCError BuildRosterUpdateIndicationPDU(CONF_ROSTER_UPDATE_TYPE, UserID);
  150. GCCError BuildSetOfRefreshesPDU(void);
  151. GCCError BuildSetOfUpdatesPDU(UserID, CONF_ROSTER_UPDATE_TYPE);
  152. GCCError BuildParticipantsListPDU(UserID, PParticipantsList *);
  153. /*
  154. * Utilities used to Free a roster update indication PDU.
  155. */
  156. void FreeRosterUpdateIndicationPDU(void);
  157. void FreeSetOfRefreshesPDU(void);
  158. void FreeSetOfUpdatesPDU(void);
  159. void FreeParticipantsListPDU(PParticipantsList);
  160. void CleanUpdateRecordPDU(PSetOfNodeRecordUpdates);
  161. /*
  162. * Utilities used to Process roster update indications.
  163. */
  164. GCCError ProcessSetOfRefreshesPDU(PSetOfNodeRecordRefreshes);
  165. GCCError ProcessSetOfUpdatesPDU(PSetOfNodeRecordUpdates);
  166. GCCError ProcessParticipantsListPDU(PParticipantsList, CONF_RECORD *);
  167. /*
  168. * Utilities used to operate on conference roster reports.
  169. */
  170. void ClearRecordList(void);
  171. void GetNodeTypeAndProperties (
  172. NodeType pdu_node_type,
  173. NodeProperties pdu_node_properties,
  174. PGCCNodeType node_type,
  175. PGCCNodeProperties node_properties);
  176. void GetPDUNodeTypeAndProperties (
  177. GCCNodeType node_type,
  178. GCCNodeProperties node_properties,
  179. PNodeType pdu_node_type,
  180. PNodeProperties pdu_node_properties);
  181. GCCError DeleteRecord(UserID node_id);
  182. GCCError GetNodeSubTree(UserID, CUidList *);
  183. private:
  184. BOOL m_fNodesAdded;
  185. BOOL m_fNodesRemoved;
  186. BOOL m_fRosterChanged;
  187. BOOL m_fTopProvider;
  188. BOOL m_fLocalRoster;
  189. BOOL m_fMaintainPduBuffer;
  190. BOOL m_fPduFlushed;
  191. UserID m_uidTopProvider;
  192. UserID m_uidSuperiorNode;
  193. UserID m_uidMyNodeID;
  194. UINT m_nInstanceNumber;
  195. UINT m_cbDataMemorySize;
  196. NodeInformation m_NodeInformation;
  197. CConfRecordList2 m_RecordList2;
  198. PSetOfNodeRecordUpdates m_pNodeRecordUpdateSet;
  199. };
  200. #endif
  201. /*
  202. * CConfRoster( UserID top_provider_id,
  203. * UserID superior_node,
  204. * BOOL is_top_provider,
  205. * BOOL is_local_roster,
  206. * BOOL maintain_pdu_buffer,
  207. *
  208. * Public Function Description
  209. * This is the conference roster constructor. It is responsible for
  210. * initializing all the instance variables used by this class.
  211. *
  212. * Formal Parameters:
  213. * top_provider_id - (i) The Node ID of the Top Provider
  214. * superior_node - (i) The Node ID of the node that is the parent
  215. * to this one. Zero for the top provider.
  216. * is_top_provider - (i) Indicates if this is the top provider node.
  217. * is_local_roster - (i) Indicates if this roster is a local one.
  218. * maintain_pdu_buffer - (i) Indicates if this roster should maintain
  219. * a PDU buffer.
  220. *
  221. *
  222. * Return Value
  223. * None.
  224. *
  225. * Side Effects
  226. * None.
  227. *
  228. * Caveats
  229. * None.
  230. */
  231. /*
  232. * ~CConfRoster ()
  233. *
  234. * Public Function Description
  235. * This is the conference roster destructor. It is responsible for
  236. * freeing up all the internal memory used by this class.
  237. *
  238. * Formal Parameters:
  239. * None.
  240. *
  241. * Return Value
  242. * None.
  243. *
  244. * Side Effects
  245. * None.
  246. *
  247. * Caveats
  248. * None.
  249. */
  250. /*
  251. * void FlushRosterUpdateIndicationPDU (
  252. * PNodeInformation node_information)
  253. *
  254. * Public Function Description
  255. * This routine is used to access any PDU data that might currently be
  256. * queued inside the conference roster. PDU data is queued whenever
  257. * a request is made to the conference roster that affects its
  258. * internal information base.
  259. *
  260. * Formal Parameters:
  261. * node_information - (o) Pointer to the PDU buffer to fill in.
  262. *
  263. * Return Value
  264. * None.
  265. *
  266. * Side Effects
  267. * None.
  268. *
  269. * Caveats
  270. * The PDU data returned by this routine is automatically freed the next
  271. * time a request is made to this roster object that affects its internal
  272. * databease.
  273. */
  274. /*
  275. * GCCError BuildFullRefreshPDU (void)
  276. *
  277. * Public Function Description
  278. * This routine is responsible for generating a full conference roster
  279. * refresh PDU.
  280. *
  281. * Formal Parameters:
  282. * None.
  283. *
  284. * Return Value
  285. * GCC_NO_ERROR - No error occured.
  286. * GCC_ALLOCATION_FAILURE - A resource error occured.
  287. *
  288. * Side Effects
  289. * None.
  290. *
  291. * Caveats
  292. * None.
  293. */
  294. /*
  295. * GCCError ProcessRosterUpdateIndicationPDU (
  296. * PNodeInformation node_information)
  297. *
  298. * Public Function Description
  299. * This routine is responsible for processing the decoded PDU data.
  300. * It essentially changes the conference roster objects internal database
  301. * based on the information in the structure.
  302. *
  303. * Formal Parameters:
  304. * node_information - (i) This is a pointer to a structure that
  305. * holds the decoded PDU data.
  306. *
  307. * Return Value
  308. * GCC_NO_ERROR - No error occured.
  309. * GCC_ALLOCATION_FAILURE - A resource error occured.
  310. *
  311. * Side Effects
  312. * None.
  313. *
  314. * Caveats
  315. * None.
  316. */
  317. /*
  318. * UINT LockConferenceRoster()
  319. *
  320. * Public Function Description:
  321. * This routine is used to "lock" the "API" data for this object. This
  322. * results in the lock count for this object being incremented. When the
  323. * lock count transitions from 0 to 1, a calculation is made to determine
  324. * how much memory will be needed to hold any "API" data which will
  325. * be referenced by, but not held in, the GCCConferenceRoster structure
  326. * which is filled in on a call to GetConfRoster. This is the
  327. * value returned by this routine in order to allow the calling object to
  328. * allocate that amount of memory in preparation for the call to
  329. * GetConfRoster.
  330. *
  331. * Formal Parameters:
  332. * None.
  333. *
  334. * Return Value:
  335. * The amount of memory, if any, which will be needed to hold "API" data
  336. * which is referenced by, but not held in, the GCCConferenceRoster
  337. * structure provided as an output parameter to the GetConfRoster
  338. * call.
  339. *
  340. * Side Effects:
  341. * The internal lock count is incremented.
  342. *
  343. * Caveats:
  344. * The internal lock count is used in conjuction with an internal "free"
  345. * flag as a mechanism for ensuring that this object remains in existance
  346. * until all interested parties are through with it. The object remains
  347. * valid (unless explicity deleted) until the lock count is zero and the
  348. * "free" flag is set through a call to FreeConferenceRoster. This allows
  349. * other objects to lock this object and be sure that it remains valid
  350. * until they call UnLock which will decrement the internal lock count. A
  351. * typical usage scenerio for this object would be: A CConfRoster
  352. * object is constructed and then passed off to any interested parties
  353. * through a function call. On return from the function call, the
  354. * FreeConferenceRoster call is made which will set the internal "free"
  355. * flag. If no other parties have locked the object with a Lock call,
  356. * then the CConfRoster object will automatically delete itself when
  357. * the FreeConferenceRoster call is made. If, however, any number of
  358. * other parties has locked the object, it will remain in existence until
  359. * each of them has unlocked the object through a call to UnLock.
  360. */
  361. /*
  362. * void UnLockConferenceRoster ();
  363. *
  364. * Public Function Description:
  365. * This routine is used to "unlock" the "API" data for this object. This
  366. * results in the lock count for this object being decremented. When the
  367. * lock count transitions from 1 to 0, a check is made to determine
  368. * whether the object has been freed through a call to
  369. * FreeConferenceRoster. If so, the object will automatically delete
  370. * itself.
  371. *
  372. * Formal Parameters:
  373. * None.
  374. *
  375. * Return Value:
  376. * None.
  377. *
  378. * Side Effects:
  379. * The internal lock count is decremented.
  380. *
  381. * Caveats:
  382. * It is the responsibility of any party which locks an CConfRoster
  383. * object by calling Lock to also unlock the object with a call to UnLock.
  384. * If the party calling UnLock did not construct the CConfRoster
  385. * object, it should assume the object to be invalid thereafter.
  386. */
  387. /*
  388. * UINT GetConfRoster(
  389. * PGCCConferenceRoster FAR * conference_roster,
  390. * LPSTR memory_pointer);
  391. *
  392. * Public Function Description:
  393. * This routine is used to retrieve the conference roster data from
  394. * the CConfRoster object in the "API" form of a GCCConferenceRoster.
  395. *
  396. * Formal Parameters:
  397. * conference_roster (o) The GCCConferenceRoster structure to fill in.
  398. * memory_pointer (o) The memory used to hold any data referenced by,
  399. * but not held in, the output structure.
  400. *
  401. * Return Value:
  402. * The amount of data, if any, written into the bulk memory block provided.
  403. *
  404. * Side Effects:
  405. * None.
  406. *
  407. * Caveats:
  408. * None.
  409. */
  410. /*
  411. * GCCError AddRecord( PGCCNodeRecord conference_record,
  412. * UserID node_id)
  413. *
  414. * Public Function Description:
  415. * This routine is used to add a single nodes conference record to the
  416. * conference roster object's internal list of records.
  417. *
  418. * Formal Parameters:
  419. * conference_record (i) Pointer to the "API" record structure to add.
  420. * node_id (i) Node ID associated with record being added.
  421. *
  422. * Return Value:
  423. * GCC_NO_ERROR - No error occured.
  424. * GCC_ALLOCATION_FAILURE - A resource error occured.
  425. * GCC_INVALID_PARAMETER - Invalid parameter passed in.
  426. * GCC_BAD_NETWORK_ADDRESS - Invalid network address passed in.
  427. * GCC_BAD_NETWORK_ADDRESS_TYPE - Bad "choice" field for address
  428. * GCC_BAD_USER_DATA - The user data passed in contained
  429. * an invalid object key.
  430. *
  431. * Side Effects:
  432. * None.
  433. *
  434. * Caveats:
  435. * None.
  436. */
  437. /*
  438. * GCCError RemoveRecord(UserID node_id)
  439. *
  440. * Public Function Description:
  441. * This routine is used to remove a single nodes conference record from the
  442. * conference roster object's internal list of records.
  443. *
  444. * Formal Parameters:
  445. * node_id (i) Node ID of record to be removed.
  446. *
  447. * Return Value:
  448. * GCC_NO_ERROR - No error occured.
  449. * GCC_INVALID_PARAMETER - Invalid parameter passed in.
  450. *
  451. * Side Effects:
  452. * None.
  453. *
  454. * Caveats:
  455. * None.
  456. */
  457. /*
  458. * GCCError ReplaceRecord( PGCCNodeRecord conference_record,
  459. * UserID node_id)
  460. *
  461. * Public Function Description:
  462. * This routine is used to replace a single nodes conference record in the
  463. * conference roster object's internal list of records.
  464. *
  465. * Formal Parameters:
  466. * conference_record (i) Conference record to use as the replacement.
  467. * node_id (i) Node ID of record to be replaced.
  468. *
  469. * Return Value:
  470. * GCC_NO_ERROR - No error occured.
  471. * GCC_ALLOCATION_FAILURE - A resource error occured.
  472. * GCC_INVALID_PARAMETER - Invalid parameter passed in.
  473. * GCC_BAD_NETWORK_ADDRESS - Invalid network address passed in.
  474. * GCC_BAD_NETWORK_ADDRESS_TYPE - Bad "choice" field for address
  475. * GCC_BAD_USER_DATA - The user data passed in contained
  476. *
  477. * Side Effects:
  478. * None.
  479. *
  480. * Caveats:
  481. * None.
  482. */
  483. /*
  484. * GCCError RemoveUserReference (
  485. * UserID detached_node)
  486. *
  487. * Public Function Description:
  488. * This routine removes the record associated with the specified node
  489. * id.
  490. *
  491. * Formal Parameters:
  492. * detached_node (i) Node reference to remove.
  493. *
  494. * Return Value:
  495. * GCC_NO_ERROR - No error occured.
  496. * GCC_INVALID_PARAMETER - No records associated with this node
  497. *
  498. * Side Effects:
  499. * None.
  500. *
  501. * Caveats:
  502. * None.
  503. */
  504. /*
  505. * BOOL Contains( UserID conference_node_id )
  506. *
  507. * Public Function Description:
  508. * This routine is used to determine if the specified record exists in
  509. * the conference roster.
  510. *
  511. * Formal Parameters:
  512. * conference_node_id (i) Node ID of record to check for
  513. *
  514. * Return Value:
  515. * TRUE - If the record is contained in the conference roster.
  516. * FALSE - If the record is not contained in the conference roster.
  517. *
  518. * Side Effects:
  519. * None.
  520. *
  521. * Caveats:
  522. * None.
  523. */
  524. /*
  525. * USHORT GetNumberOfNodeRecords ();
  526. *
  527. * Public Function Description:
  528. * This routine returns the total number of conference roster records
  529. * contained in the objects conference roster record list.
  530. *
  531. * Formal Parameters:
  532. * None.
  533. *
  534. * Return Value:
  535. * The number of records in the conference roster list.
  536. *
  537. * Side Effects:
  538. * None.
  539. *
  540. * Caveats:
  541. * None.
  542. */
  543. /*
  544. * void ResetConferenceRoster ()
  545. *
  546. * Public Function Description:
  547. * This routine takes care of resetting all the internal flags that are
  548. * used to convey the current state of the conference roster. Should be
  549. * called after the roster is flushed and any roster update messages have
  550. * been delivered (after a change to the roster occurs).
  551. *
  552. * Formal Parameters:
  553. * None.
  554. *
  555. * Return Value:
  556. * None.
  557. *
  558. * Side Effects:
  559. * None.
  560. *
  561. * Caveats:
  562. * None.
  563. */
  564. /*
  565. * BOOL HasRosterChanged ();
  566. *
  567. * Public Function Description:
  568. * This routine informs the caller if the roster has changed since the
  569. * last time it was reset.
  570. *
  571. * Formal Parameters:
  572. * None.
  573. *
  574. * Return Value:
  575. * TRUE - If roster has changed
  576. * FALSE - If roster has not changed
  577. *
  578. * Side Effects:
  579. * None.
  580. *
  581. * Caveats:
  582. * None.
  583. */