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.

1667 lines
42 KiB

  1. #include "precomp.h"
  2. DEBUG_FILEZONE(ZONE_T120_SAP);
  3. /*
  4. * appsap.cpp
  5. *
  6. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  7. *
  8. * Abstract:
  9. *
  10. * Protected Instance Variables:
  11. * None.
  12. *
  13. * Caveats:
  14. * None.
  15. *
  16. * Author:
  17. * blp
  18. */
  19. #include "appsap.h"
  20. #include "conf.h"
  21. #include "gcontrol.h"
  22. GCCError WINAPI GCC_CreateAppSap(IGCCAppSap **ppIAppSap, LPVOID pUserData, LPFN_APP_SAP_CB pfnCallback)
  23. {
  24. GCCError rc;
  25. if (NULL != ppIAppSap && NULL != pfnCallback)
  26. {
  27. if (NULL != g_pGCCController)
  28. {
  29. DBG_SAVE_FILE_LINE
  30. if (NULL != (*ppIAppSap = (IGCCAppSap *) new CAppSap(pUserData, pfnCallback, &rc)))
  31. {
  32. if (GCC_NO_ERROR != rc)
  33. {
  34. (*ppIAppSap)->ReleaseInterface(); // free the interface in case of error
  35. }
  36. }
  37. else
  38. {
  39. ERROR_OUT(("GCC_CreateAppSap: can't create IAppSap."));
  40. rc = GCC_ALLOCATION_FAILURE;
  41. }
  42. }
  43. else
  44. {
  45. WARNING_OUT(("GCC_CreateAppSap: GCC Provider is not initialized."));
  46. rc = GCC_NOT_INITIALIZED;
  47. }
  48. }
  49. else
  50. {
  51. ERROR_OUT(("GCC_CreateAppSap: either or both pointers are null"));
  52. rc = GCC_INVALID_PARAMETER;
  53. }
  54. return rc;
  55. }
  56. /*
  57. * Macros defining the number of handles which may be allocated.
  58. */
  59. #define MINIMUM_NUMBER_OF_ALLOCATED_HANDLES 1
  60. #define MAXIMUM_NUMBER_OF_ALLOCATED_HANDLES 1024
  61. /*
  62. * CAppSap()
  63. *
  64. * Public Function Description:
  65. * This is the constructor for the CAppSap class. It initializes instance
  66. * variables and registers with the new application.
  67. */
  68. CAppSap::
  69. CAppSap
  70. (
  71. LPVOID pAppData,
  72. LPFN_APP_SAP_CB pfnCallback,
  73. PGCCError pRetCode
  74. )
  75. :
  76. CBaseSap(MAKE_STAMP_ID('A','S','a','p')),
  77. m_pAppData(pAppData),
  78. m_pfnCallback(pfnCallback)
  79. {
  80. ASSERT(NULL != pfnCallback);
  81. ASSERT(NULL != g_pGCCController);
  82. //
  83. // We just created a window in the constructor of CBaseSap.
  84. // Double check the window is created successfully.
  85. //
  86. if (NULL != m_hwndNotify)
  87. {
  88. //
  89. // Make sure the gcc provider does not go away randomly.
  90. //
  91. ::EnterCriticalSection(&g_csGCCProvider);
  92. g_pGCCController->AddRef();
  93. g_pGCCController->RegisterAppSap(this);
  94. ::LeaveCriticalSection(&g_csGCCProvider);
  95. *pRetCode = GCC_NO_ERROR;
  96. }
  97. else
  98. {
  99. ERROR_OUT(("CAppSap::CAppSap: can't create window, win32_err=%u", ::GetLastError()));
  100. *pRetCode = GCC_ALLOCATION_FAILURE;
  101. }
  102. }
  103. /*
  104. * ~AppSap ()
  105. *
  106. * Public Function Description:
  107. * This is the destructor for the CAppSap class. It is called when the
  108. * controller marks the CAppSap to be deleted. This occurs when either
  109. * the CAppSap asks to be deleted due to an "unregister request"
  110. * issued from the client application, or when there is an error
  111. * condition in the CAppSap.
  112. */
  113. CAppSap::
  114. ~CAppSap ( void )
  115. {
  116. //
  117. // LONCHANC: This Release() must be outside of the GCC critical section
  118. // because the GCC Controller can delete this critical section in
  119. // its destructor.
  120. //
  121. g_pGCCController->Release();
  122. }
  123. void CAppSap::
  124. ReleaseInterface ( void )
  125. {
  126. ASSERT(NULL != g_pGCCController);
  127. //
  128. // It is ok for the gcc provider to go away now.
  129. //
  130. ::EnterCriticalSection(&g_csGCCProvider);
  131. g_pGCCController->UnRegisterAppSap(this);
  132. ::LeaveCriticalSection(&g_csGCCProvider);
  133. //
  134. // Reset the app related data
  135. //
  136. m_pAppData = NULL;
  137. m_pfnCallback = NULL;
  138. //
  139. // Remove any message in the queue.
  140. //
  141. PurgeMessageQueue();
  142. //
  143. // Release this object now.
  144. //
  145. Release();
  146. }
  147. void CAppSap::
  148. PostAppSapMsg ( GCCAppSapMsgEx *pAppSapMsgEx )
  149. {
  150. ASSERT(NULL != m_hwndNotify);
  151. ::PostMessage(m_hwndNotify,
  152. ASAPMSG_BASE + (UINT) pAppSapMsgEx->Msg.eMsgType,
  153. (WPARAM) pAppSapMsgEx,
  154. (LPARAM) this);
  155. }
  156. /*
  157. * AppEnroll()
  158. *
  159. * Public Function Description:
  160. * This routine is called when an application wants to enroll in a
  161. * conference. The controller is notified of the enrollment request.
  162. */
  163. GCCError CAppSap::
  164. AppEnroll
  165. (
  166. GCCConfID nConfID,
  167. GCCEnrollRequest *pReq,
  168. GCCRequestTag *pnReqTag
  169. )
  170. {
  171. GCCError rc;
  172. CConf *pConf;
  173. DebugEntry(CAppSap::AppEnroll);
  174. // sanity check
  175. if (NULL == pReq || NULL == pnReqTag)
  176. {
  177. rc = GCC_INVALID_PARAMETER;
  178. goto MyExit;
  179. }
  180. TRACE_OUT_EX(ZONE_T120_APP_ROSTER,
  181. ("CAppSap::AppEnroll: confID=%u, enrolled?=%u, active?=%u\r\n",
  182. (UINT) nConfID, (UINT) pReq->fEnroll, (UINT) pReq->fEnrollActively));
  183. // create the request id
  184. *pnReqTag = GenerateRequestTag();
  185. // find the corresponding conference
  186. if (NULL == (pConf = g_pGCCController->GetConfObject(nConfID)))
  187. {
  188. rc = GCC_INVALID_CONFERENCE;
  189. goto MyExit;
  190. }
  191. // check to make sure that the application has a valid uid and
  192. // session key if it is enrolling.
  193. if (pReq->fEnroll)
  194. {
  195. if (pReq->fEnrollActively)
  196. {
  197. if (pReq->nUserID < MINIMUM_USER_ID_VALUE)
  198. {
  199. rc = GCC_INVALID_MCS_USER_ID;
  200. goto MyExit;
  201. }
  202. }
  203. else if (pReq->nUserID < MINIMUM_USER_ID_VALUE)
  204. {
  205. // we must make sure that this is zero if it is invalid and
  206. // the user is enrolling inactively.
  207. pReq->nUserID = GCC_INVALID_UID;
  208. }
  209. if (NULL == pReq->pSessionKey)
  210. {
  211. rc = GCC_BAD_SESSION_KEY;
  212. goto MyExit;
  213. }
  214. }
  215. ::EnterCriticalSection(&g_csGCCProvider);
  216. rc = pConf->AppEnrollRequest(this, pReq, *pnReqTag);
  217. ::LeaveCriticalSection(&g_csGCCProvider);
  218. MyExit:
  219. DebugExitINT(CAppSap::AppEnroll, rc);
  220. return rc;
  221. }
  222. GCCError CAppSap::
  223. AppInvoke
  224. (
  225. GCCConfID nConfID,
  226. GCCAppProtEntityList *pApeList,
  227. GCCSimpleNodeList *pNodeList,
  228. GCCRequestTag *pnReqTag
  229. )
  230. {
  231. return CBaseSap::AppInvoke(nConfID, pApeList, pNodeList, pnReqTag);
  232. }
  233. GCCError CAppSap::
  234. AppRosterInquire
  235. (
  236. GCCConfID nConfID,
  237. GCCSessionKey *pSessionKey,
  238. GCCAppSapMsg **ppMsg
  239. )
  240. {
  241. return CBaseSap::AppRosterInquire(nConfID, pSessionKey, (GCCAppSapMsgEx **) ppMsg);
  242. }
  243. BOOL CAppSap::
  244. IsThisNodeTopProvider ( GCCConfID nConfID )
  245. {
  246. return CBaseSap::IsThisNodeTopProvider(nConfID);
  247. }
  248. GCCNodeID CAppSap::
  249. GetTopProvider ( GCCConfID nConfID )
  250. {
  251. return CBaseSap::GetTopProvider(nConfID);
  252. }
  253. GCCError CAppSap::
  254. ConfRosterInquire(GCCConfID nConfID, GCCAppSapMsg **ppMsg)
  255. {
  256. return CBaseSap::ConfRosterInquire(nConfID, (GCCAppSapMsgEx **) ppMsg);
  257. }
  258. GCCError CAppSap::
  259. ConductorInquire ( GCCConfID nConfID )
  260. {
  261. return CBaseSap::ConductorInquire(nConfID);
  262. }
  263. /*
  264. * RegisterChannel()
  265. *
  266. * Public Function Description:
  267. * This routine is called when an application wishes to register a
  268. * channel. The call is routed to the appropriate conference object.
  269. */
  270. GCCError CAppSap::
  271. RegisterChannel
  272. (
  273. GCCConfID nConfID,
  274. GCCRegistryKey *pRegKey,
  275. ChannelID nChnlID
  276. )
  277. {
  278. GCCError rc;
  279. CConf *pConf;
  280. DebugEntry(CAppSap::RegisterChannel);
  281. if (NULL == pRegKey)
  282. {
  283. rc = GCC_INVALID_PARAMETER;
  284. goto MyExit;
  285. }
  286. /*
  287. ** If the desired conference exists, call it in order to register the
  288. ** channel. Report an error if the desired conference does not exist.
  289. */
  290. if (NULL == (pConf = g_pGCCController->GetConfObject(nConfID)))
  291. {
  292. WARNING_OUT(("CAppSap::RegisterChannel: invalid conf id=%u", (UINT) nConfID));
  293. rc = GCC_INVALID_CONFERENCE;
  294. goto MyExit;
  295. }
  296. ::EnterCriticalSection(&g_csGCCProvider);
  297. rc = (nChnlID != 0) ? pConf->RegistryRegisterChannelRequest(pRegKey, nChnlID, this) :
  298. GCC_INVALID_CHANNEL;
  299. ::LeaveCriticalSection(&g_csGCCProvider);
  300. if (GCC_NO_ERROR != rc)
  301. {
  302. ERROR_OUT(("CAppSap::RegisterChannel: can't register channel, rc=%u", (UINT) rc));
  303. // goto MyExit;
  304. }
  305. MyExit:
  306. DebugExitINT(CAppSap::RegisterChannel, rc);
  307. return rc;
  308. }
  309. /*
  310. * RegistryAssignToken()
  311. *
  312. * Public Function Description:
  313. * This routine is called when an application wishes to assign a
  314. * token. The call is routed to the appropriate conference object.
  315. */
  316. GCCError CAppSap::
  317. RegistryAssignToken
  318. (
  319. GCCConfID nConfID,
  320. GCCRegistryKey *pRegKey
  321. )
  322. {
  323. GCCError rc;
  324. CConf *pConf;
  325. DebugEntry(CAppSap::RegistryAssignToken);
  326. if (NULL == pRegKey)
  327. {
  328. rc = GCC_INVALID_PARAMETER;
  329. goto MyExit;
  330. }
  331. /*
  332. ** If the desired conference exists, call it in order to assign the
  333. ** token. Report an error if the desired conference does not exist.
  334. */
  335. if (NULL == (pConf = g_pGCCController->GetConfObject(nConfID)))
  336. {
  337. WARNING_OUT(("CAppSap::RegistryAssignToken: invalid conf id=%u", (UINT) nConfID));
  338. rc = GCC_INVALID_CONFERENCE;
  339. goto MyExit;
  340. }
  341. ::EnterCriticalSection(&g_csGCCProvider);
  342. rc = pConf->RegistryAssignTokenRequest(pRegKey, this);
  343. ::LeaveCriticalSection(&g_csGCCProvider);
  344. if (GCC_NO_ERROR != rc)
  345. {
  346. ERROR_OUT(("CAppSap::RegistryAssignToken: can't assign token, rc=%u", (UINT) rc));
  347. // goto MyExit;
  348. }
  349. MyExit:
  350. DebugExitINT(CAppSap::RegistryAssignToken, rc);
  351. return rc;
  352. }
  353. /*
  354. * RegistrySetParameter()
  355. *
  356. * Public Function Description:
  357. * This routine is called when an application wishes to set a
  358. * parameter. The call is routed to the appropriate conference object.
  359. */
  360. GCCError CAppSap::
  361. RegistrySetParameter
  362. (
  363. GCCConfID nConfID,
  364. GCCRegistryKey *pRegKey,
  365. LPOSTR poszParameter,
  366. GCCModificationRights eRights
  367. )
  368. {
  369. GCCError rc;
  370. CConf *pConf;
  371. DebugEntry(CAppSap::RegistrySetParameter);
  372. if (NULL == pRegKey || NULL == poszParameter)
  373. {
  374. rc = GCC_INVALID_PARAMETER;
  375. goto MyExit;
  376. }
  377. /*
  378. ** If the desired conference exists, call it in order to set the
  379. ** parameter. Report an error if the desired conference does not exist.
  380. */
  381. if (NULL == (pConf = g_pGCCController->GetConfObject(nConfID)))
  382. {
  383. WARNING_OUT(("CAppSap::RegistrySetParameter: invalid conf id=%u", (UINT) nConfID));
  384. rc = GCC_INVALID_CONFERENCE;
  385. goto MyExit;
  386. }
  387. switch (eRights)
  388. {
  389. case GCC_OWNER_RIGHTS:
  390. case GCC_SESSION_RIGHTS:
  391. case GCC_PUBLIC_RIGHTS:
  392. case GCC_NO_MODIFICATION_RIGHTS_SPECIFIED:
  393. ::EnterCriticalSection(&g_csGCCProvider);
  394. rc = pConf->RegistrySetParameterRequest(pRegKey, poszParameter, eRights, this);
  395. ::LeaveCriticalSection(&g_csGCCProvider);
  396. if (GCC_NO_ERROR != rc)
  397. {
  398. ERROR_OUT(("CAppSap::RegistrySetParameter: can't set param, rc=%u", (UINT) rc));
  399. // goto MyExit;
  400. }
  401. break;
  402. default:
  403. rc = GCC_INVALID_MODIFICATION_RIGHTS;
  404. break;
  405. }
  406. MyExit:
  407. DebugExitINT(CAppSap::RegistrySetParameter, rc);
  408. return rc;
  409. }
  410. /*
  411. * RegistryRetrieveEntry()
  412. *
  413. * Public Function Description:
  414. * This routine is called when an application wishes to retrieve a registry
  415. * entry. The call is routed to the appropriate conference object.
  416. */
  417. GCCError CAppSap::
  418. RegistryRetrieveEntry
  419. (
  420. GCCConfID nConfID,
  421. GCCRegistryKey *pRegKey
  422. )
  423. {
  424. GCCError rc;
  425. CConf *pConf;
  426. DebugEntry(CAppSap::RegistryRetrieveEntry);
  427. if (NULL == pRegKey)
  428. {
  429. rc = GCC_INVALID_PARAMETER;
  430. goto MyExit;
  431. }
  432. /*
  433. ** If the desired conference exists, call it in order to retrieve the
  434. ** registry entry. Report an error if the desired conference does not
  435. ** exist.
  436. */
  437. if (NULL == (pConf = g_pGCCController->GetConfObject(nConfID)))
  438. {
  439. WARNING_OUT(("CAppSap::RegistryRetrieveEntry: invalid conf id=%u", (UINT) nConfID));
  440. rc = GCC_INVALID_CONFERENCE;
  441. goto MyExit;
  442. }
  443. ::EnterCriticalSection(&g_csGCCProvider);
  444. rc = pConf->RegistryRetrieveEntryRequest(pRegKey, this);
  445. ::LeaveCriticalSection(&g_csGCCProvider);
  446. if (GCC_NO_ERROR != rc)
  447. {
  448. ERROR_OUT(("CAppSap::RegistryRetrieveEntry: can't retrieve entry, rc=%u", (UINT) rc));
  449. // goto MyExit;
  450. }
  451. MyExit:
  452. DebugExitINT(CAppSap::RegistryRetrieveEntry, rc);
  453. return rc;
  454. }
  455. /*
  456. * RegistryDeleteEntry()
  457. *
  458. * Public Function Description:
  459. * This routine is called when an application wishes to delete a registry
  460. * entry. The call is routed to the appropriate conference object.
  461. */
  462. GCCError CAppSap::
  463. RegistryDeleteEntry
  464. (
  465. GCCConfID nConfID,
  466. GCCRegistryKey *pRegKey
  467. )
  468. {
  469. GCCError rc;
  470. CConf *pConf;
  471. DebugEntry(IAppSap::RegistryDeleteEntry);
  472. if (NULL == pRegKey)
  473. {
  474. ERROR_OUT(("CAppSap::RegistryDeleteEntry: null pRegKey"));
  475. rc = GCC_INVALID_PARAMETER;
  476. goto MyExit;
  477. }
  478. /*
  479. ** If the desired conference exists, call it in order to delete the
  480. ** desired registry entry. Report an error if the desired conference does
  481. ** not exist.
  482. */
  483. if (NULL == (pConf = g_pGCCController->GetConfObject(nConfID)))
  484. {
  485. TRACE_OUT(("CAppSap::RegistryDeleteEntry: invalid conf id=%u", (UINT) nConfID));
  486. rc = GCC_INVALID_CONFERENCE;
  487. goto MyExit;
  488. }
  489. ::EnterCriticalSection(&g_csGCCProvider);
  490. rc = pConf->RegistryDeleteEntryRequest(pRegKey, this);
  491. ::LeaveCriticalSection(&g_csGCCProvider);
  492. if (GCC_NO_ERROR != rc)
  493. {
  494. WARNING_OUT(("CAppSap::RegistryDeleteEntry: can't delete entry, rc=%u", (UINT) rc));
  495. // goto MyExit;
  496. }
  497. MyExit:
  498. DebugExitINT(CAppSap::RegistryDeleteEntry, rc);
  499. return rc;
  500. }
  501. /*
  502. * RegistryMonitor()
  503. *
  504. * Public Function Description:
  505. * This routine is called when an application wishes to monitor a
  506. * particular registry entry. The call is routed to the appropriate
  507. * conference object.
  508. */
  509. GCCError CAppSap::
  510. RegistryMonitor
  511. (
  512. GCCConfID nConfID,
  513. BOOL fEnalbeDelivery,
  514. GCCRegistryKey *pRegKey
  515. )
  516. {
  517. GCCError rc;
  518. CConf *pConf;
  519. DebugEntry(IAppSap::RegistryMonitor);
  520. if (NULL == pRegKey)
  521. {
  522. rc = GCC_INVALID_PARAMETER;
  523. goto MyExit;
  524. }
  525. /*
  526. ** If the desired conference exists, call it in order to monitor the
  527. ** appropriate registry entry. Report an error if the desired conference
  528. ** does not exist.
  529. */
  530. if (NULL == (pConf = g_pGCCController->GetConfObject(nConfID)))
  531. {
  532. WARNING_OUT(("CAppSap::RegistryMonitor: invalid conf id=%u", (UINT) nConfID));
  533. rc = GCC_INVALID_CONFERENCE;
  534. goto MyExit;
  535. }
  536. ::EnterCriticalSection(&g_csGCCProvider);
  537. rc = pConf->RegistryMonitorRequest(fEnalbeDelivery, pRegKey, this);
  538. ::LeaveCriticalSection(&g_csGCCProvider);
  539. if (GCC_NO_ERROR != rc)
  540. {
  541. ERROR_OUT(("CAppSap::RegistryMonitor: can't monitor the registry, rc=%u", (UINT) rc));
  542. // goto MyExit;
  543. }
  544. MyExit:
  545. DebugExitINT(CAppSap::RegistryMonitor, rc);
  546. return rc;
  547. }
  548. /*
  549. * RegistryAllocateHandle()
  550. *
  551. * Public Function Description:
  552. * This routine is called when an application wishes to allocate one or
  553. * more handles. The call is routed to the appropriate conference object.
  554. */
  555. GCCError CAppSap::
  556. RegistryAllocateHandle
  557. (
  558. GCCConfID nConfID,
  559. ULONG cHandles
  560. )
  561. {
  562. GCCError rc;
  563. CConf *pConf;
  564. DebugEntry(CAppSap::RegistryAllocateHandle);
  565. /*
  566. ** If the desired conference exists, call it in order to allocate the
  567. ** handle(s). Report an error if the desired conference does not exist or
  568. ** if the number of handles wishing to be allocated is not within the
  569. ** allowable range.
  570. */
  571. if (NULL == (pConf = g_pGCCController->GetConfObject(nConfID)))
  572. {
  573. WARNING_OUT(("CAppSap::RegistryAllocateHandle: invalid conf id=%u", (UINT) nConfID));
  574. rc = GCC_INVALID_CONFERENCE;
  575. goto MyExit;
  576. }
  577. ::EnterCriticalSection(&g_csGCCProvider);
  578. rc = ((cHandles >= MINIMUM_NUMBER_OF_ALLOCATED_HANDLES) &&
  579. (cHandles <= MAXIMUM_NUMBER_OF_ALLOCATED_HANDLES)) ?
  580. pConf->RegistryAllocateHandleRequest(cHandles, this) :
  581. GCC_BAD_NUMBER_OF_HANDLES;
  582. ::LeaveCriticalSection(&g_csGCCProvider);
  583. if (GCC_NO_ERROR != rc)
  584. {
  585. ERROR_OUT(("CAppSap::RegistryAllocateHandle: can't allocate handles, cHandles=%u, rc=%u", (UINT) cHandles, (UINT) rc));
  586. // goto MyExit;
  587. }
  588. MyExit:
  589. DebugExitINT(CAppSap::RegistryAllocateHandle, rc);
  590. return rc;
  591. }
  592. /*
  593. * The following routines are all Command Target Calls
  594. */
  595. /*
  596. * PermissionToEnrollIndication ()
  597. *
  598. * Public Function Description:
  599. * This routine is called by the Controller when it wishes to send an
  600. * indication to the user application notifying it of a "permission to
  601. * enroll" event. This does not mean that permission to enroll is
  602. * necessarily granted to the application.
  603. */
  604. GCCError CAppSap::
  605. PermissionToEnrollIndication
  606. (
  607. GCCConfID nConfID,
  608. BOOL fGranted
  609. )
  610. {
  611. GCCError rc;
  612. DebugEntry(CAppSap: PermissionToEnrollIndication);
  613. TRACE_OUT_EX(ZONE_T120_APP_ROSTER, ("CAppSap::PermissionToEnrollIndication: "
  614. "confID=%u, granted?=%u\r\n",
  615. (UINT) nConfID, (UINT) fGranted));
  616. DBG_SAVE_FILE_LINE
  617. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_PERMIT_TO_ENROLL_INDICATION);
  618. if (NULL != pMsgEx)
  619. {
  620. pMsgEx->Msg.nConfID = nConfID;
  621. pMsgEx->Msg.AppPermissionToEnrollInd.nConfID = nConfID;
  622. pMsgEx->Msg.AppPermissionToEnrollInd.fPermissionGranted = fGranted;
  623. PostAppSapMsg(pMsgEx);
  624. rc = GCC_NO_ERROR;
  625. }
  626. else
  627. {
  628. ERROR_OUT(("CAppSap: PermissionToEnrollIndication: can't create GCCAppSapMsgEx"));
  629. rc = GCC_ALLOCATION_FAILURE;
  630. }
  631. DebugExitINT(CAppSap: PermissionToEnrollIndication, rc);
  632. return rc;
  633. }
  634. /*
  635. * AppEnrollConfirm ()
  636. *
  637. * Public Function Description:
  638. * This routine is called by the CConf object when it wishes
  639. * to send an enrollment confirmation to the user application.
  640. */
  641. GCCError CAppSap::
  642. AppEnrollConfirm ( GCCAppEnrollConfirm *pConfirm )
  643. {
  644. GCCError rc;
  645. DebugEntry(CAppSap::AppEnrollConfirm);
  646. DBG_SAVE_FILE_LINE
  647. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_ENROLL_CONFIRM);
  648. if (NULL != pMsgEx)
  649. {
  650. pMsgEx->Msg.nConfID = pConfirm->nConfID;
  651. pMsgEx->Msg.AppEnrollConfirm = *pConfirm;
  652. PostAppSapMsg(pMsgEx);
  653. rc = GCC_NO_ERROR;
  654. }
  655. else
  656. {
  657. ERROR_OUT(("CAppSap::AppEnrollConfirm: can't create GCCAppSapMsgEx"));
  658. rc = GCC_ALLOCATION_FAILURE;
  659. }
  660. DebugExitINT(CAppSap: AppEnrollConfirm, rc);
  661. return rc;
  662. }
  663. /*
  664. * RegistryConfirm ()
  665. *
  666. * Public Function Description:
  667. * This command target routine is called by the CConf object when it
  668. * wishes to send an registry confirmation to the user application.
  669. */
  670. GCCError CAppSap::
  671. RegistryConfirm
  672. (
  673. GCCConfID nConfID,
  674. GCCMessageType eMsgType,
  675. CRegKeyContainer *pRegKey,
  676. CRegItem *pRegItem,
  677. GCCModificationRights eRights,
  678. GCCNodeID nidOwner,
  679. GCCEntityID eidOwner,
  680. BOOL fDeliveryEnabled,
  681. GCCResult nResult
  682. )
  683. {
  684. GCCError rc;
  685. DebugEntry(CAppSap::RegistryConfirm);
  686. DBG_SAVE_FILE_LINE
  687. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(eMsgType);
  688. if (NULL == pMsgEx)
  689. {
  690. ERROR_OUT(("CAppSap::RegistryConfirm: can't create GCCAppSapMsgEx"));
  691. rc = GCC_ALLOCATION_FAILURE;
  692. goto MyExit;
  693. }
  694. pMsgEx->Msg.nConfID = nConfID;
  695. if (NULL != pRegKey)
  696. {
  697. rc = pRegKey->CreateRegistryKeyData(&(pMsgEx->Msg.RegistryConfirm.pRegKey));
  698. if (GCC_NO_ERROR != rc)
  699. {
  700. ERROR_OUT(("CAppSap::RegistryConfirm: can't get registry key data, rc=%u", (UINT) rc));
  701. goto MyExit;
  702. }
  703. }
  704. if (NULL != pRegItem)
  705. {
  706. rc = pRegItem->CreateRegistryItemData(&(pMsgEx->Msg.RegistryConfirm.pRegItem));
  707. if (GCC_NO_ERROR != rc)
  708. {
  709. ERROR_OUT(("CAppSap::RegistryConfirm: can't get registry item data, rc=%u", (UINT) rc));
  710. goto MyExit;
  711. }
  712. }
  713. if (GCC_INVALID_NID != nidOwner)
  714. {
  715. pMsgEx->Msg.RegistryConfirm.EntryOwner.entry_is_owned = TRUE;
  716. pMsgEx->Msg.RegistryConfirm.EntryOwner.owner_node_id = nidOwner;
  717. pMsgEx->Msg.RegistryConfirm.EntryOwner.owner_entity_id = eidOwner;
  718. }
  719. pMsgEx->Msg.RegistryConfirm.nConfID = nConfID;
  720. pMsgEx->Msg.RegistryConfirm.eRights = eRights;
  721. pMsgEx->Msg.RegistryConfirm.nResult = nResult;
  722. pMsgEx->Msg.RegistryConfirm.fDeliveryEnabled = fDeliveryEnabled; // for monitor only
  723. PostAppSapMsg(pMsgEx);
  724. rc = GCC_NO_ERROR;
  725. MyExit:
  726. if (GCC_NO_ERROR != rc)
  727. {
  728. delete pMsgEx;
  729. }
  730. DebugExitINT(CAppSap::RegistryConfirm, rc);
  731. return rc;
  732. }
  733. /*
  734. * RegistryMonitorIndication()
  735. *
  736. * Public Function Description
  737. * This command target routine is called by the CConf object when it
  738. * wishes to send a Registry monitor indication to the user application.
  739. */
  740. /*
  741. * RegistryAllocateHandleConfirm()
  742. *
  743. * Public Function Description:
  744. * This command target routine is called by the CConf object when it
  745. * wishes to send a handle allocation confirmation to the user application.
  746. */
  747. GCCError CAppSap::
  748. RegistryAllocateHandleConfirm
  749. (
  750. GCCConfID nConfID,
  751. ULONG cHandles,
  752. ULONG nFirstHandle,
  753. GCCResult nResult
  754. )
  755. {
  756. GCCError rc;
  757. DebugEntry(CAppSap::RegistryAllocateHandleConfirm);
  758. DBG_SAVE_FILE_LINE
  759. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_ALLOCATE_HANDLE_CONFIRM);
  760. if (NULL != pMsgEx)
  761. {
  762. pMsgEx->Msg.nConfID = nConfID;
  763. pMsgEx->Msg.RegAllocHandleConfirm.nConfID = nConfID;
  764. pMsgEx->Msg.RegAllocHandleConfirm.cHandles = cHandles;
  765. pMsgEx->Msg.RegAllocHandleConfirm.nFirstHandle = nFirstHandle;
  766. pMsgEx->Msg.RegAllocHandleConfirm.nResult = nResult;
  767. PostAppSapMsg(pMsgEx);
  768. rc = GCC_NO_ERROR;
  769. }
  770. else
  771. {
  772. ERROR_OUT(("CAppSap::RegistryAllocateHandleConfirm: can't create GCCAppSapMsgEx"));
  773. rc = GCC_ALLOCATION_FAILURE;
  774. }
  775. DebugExitINT(CAppSap::RegistryAllocateHandleConfirm, rc);
  776. return rc;
  777. }
  778. void CAppSapList::
  779. DeleteList ( void )
  780. {
  781. CAppSap *pAppSap;
  782. while (NULL != (pAppSap = Get()))
  783. {
  784. pAppSap->Release();
  785. }
  786. }
  787. void CAppSapEidList2::
  788. DeleteList ( void )
  789. {
  790. CAppSap *pAppSap;
  791. while (NULL != (pAppSap = Get()))
  792. {
  793. pAppSap->Release();
  794. }
  795. }
  796. /*
  797. * ConfRosterInquireConfirm()
  798. *
  799. * Public Function Description
  800. * This routine is called in order to return a requested conference
  801. * roster to an application or the node controller.
  802. */
  803. GCCError CAppSap::
  804. ConfRosterInquireConfirm
  805. (
  806. GCCConfID nConfID,
  807. PGCCConferenceName pConfName,
  808. LPSTR pszConfModifier,
  809. LPWSTR pwszConfDescriptor,
  810. CConfRoster *pConfRoster,
  811. GCCResult nResult,
  812. GCCAppSapMsgEx **ppMsgExToRet
  813. )
  814. {
  815. GCCError rc;
  816. BOOL fLock = FALSE;
  817. UINT cbDataSize;
  818. DebugEntry(CAppSap::ConfRosterInquireConfirm);
  819. DBG_SAVE_FILE_LINE
  820. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_ROSTER_INQUIRE_CONFIRM);
  821. if (NULL == pMsgEx)
  822. {
  823. ERROR_OUT(("CAppSap::ConfRosterInquireConfirm: can't create GCCAppSapMsgEx"));
  824. rc = GCC_ALLOCATION_FAILURE;
  825. goto MyExit;
  826. }
  827. pMsgEx->Msg.nConfID = nConfID;
  828. pMsgEx->Msg.ConfRosterInquireConfirm.nConfID = nConfID;
  829. pMsgEx->Msg.ConfRosterInquireConfirm.nResult = nResult;
  830. pMsgEx->Msg.ConfRosterInquireConfirm.ConfName.numeric_string = ::My_strdupA(pConfName->numeric_string);
  831. pMsgEx->Msg.ConfRosterInquireConfirm.ConfName.text_string = ::My_strdupW(pConfName->text_string);
  832. pMsgEx->Msg.ConfRosterInquireConfirm.pszConfModifier = ::My_strdupA(pszConfModifier);
  833. pMsgEx->Msg.ConfRosterInquireConfirm.pwszConfDescriptor = ::My_strdupW(pwszConfDescriptor);
  834. /*
  835. * Lock the data for the conference roster. The lock call will
  836. * return the length of the data to be serialized for the roster so
  837. * add that length to the total memory block size and allocate the
  838. * memory block.
  839. */
  840. fLock = TRUE;
  841. cbDataSize = pConfRoster->LockConferenceRoster();
  842. if (0 != cbDataSize)
  843. {
  844. DBG_SAVE_FILE_LINE
  845. pMsgEx->Msg.ConfRosterInquireConfirm.pConfRoster = (PGCCConfRoster) new char[cbDataSize];
  846. if (NULL == pMsgEx->Msg.ConfRosterInquireConfirm.pConfRoster)
  847. {
  848. ERROR_OUT(("CAppSap::ConfRosterInquireConfirm: can't create conf roster buffer"));
  849. rc = GCC_ALLOCATION_FAILURE;
  850. goto MyExit;
  851. }
  852. /*
  853. * Retrieve the conference roster data from the roster object.
  854. * The roster object will serialize any referenced data into
  855. * the memory block passed in to the "Get" call.
  856. */
  857. pConfRoster->GetConfRoster(&(pMsgEx->Msg.ConfRosterInquireConfirm.pConfRoster),
  858. (LPBYTE) pMsgEx->Msg.ConfRosterInquireConfirm.pConfRoster);
  859. }
  860. if (NULL != ppMsgExToRet)
  861. {
  862. *ppMsgExToRet = pMsgEx;
  863. }
  864. else
  865. {
  866. PostAppSapMsg(pMsgEx);
  867. }
  868. rc = GCC_NO_ERROR;
  869. MyExit:
  870. if (fLock)
  871. {
  872. pConfRoster->UnLockConferenceRoster();
  873. }
  874. if (GCC_NO_ERROR != rc)
  875. {
  876. delete pMsgEx;
  877. }
  878. DebugExitINT(CAppSap::ConfRosterInquireConfirm, rc);
  879. return rc;
  880. }
  881. /*
  882. * AppRosterInquireConfirm()
  883. *
  884. * Public Function Description
  885. * This routine is called in order to return a requested list of
  886. * application rosters to an application or the node controller.
  887. */
  888. GCCError CAppSap::
  889. AppRosterInquireConfirm
  890. (
  891. GCCConfID nConfID,
  892. CAppRosterMsg *pAppRosterMsg,
  893. GCCResult nResult,
  894. GCCAppSapMsgEx **ppMsgEx
  895. )
  896. {
  897. GCCError rc;
  898. DebugEntry(CAppSap::AppRosterInquireConfirm);
  899. DBG_SAVE_FILE_LINE
  900. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_APP_ROSTER_INQUIRE_CONFIRM);
  901. if (NULL == pMsgEx)
  902. {
  903. ERROR_OUT(("CAppSap::AppRosterInquireConfirm: can't create GCCAppSapMsgEx"));
  904. rc = GCC_ALLOCATION_FAILURE;
  905. goto MyExit;
  906. }
  907. pMsgEx->Msg.nConfID = nConfID;
  908. /*
  909. * Lock the data for the roster message and retrieve the data.
  910. */
  911. rc = pAppRosterMsg->LockApplicationRosterMessage();
  912. if (GCC_NO_ERROR != rc)
  913. {
  914. ERROR_OUT(("CAppSap::AppRosterInquireConfirm: can't lock app roster message, rc=%u", (UINT) rc));
  915. goto MyExit;
  916. }
  917. rc = pAppRosterMsg->GetAppRosterMsg((LPBYTE *) &(pMsgEx->Msg.AppRosterInquireConfirm.apAppRosters),
  918. &(pMsgEx->Msg.AppRosterInquireConfirm.cRosters));
  919. if (GCC_NO_ERROR != rc)
  920. {
  921. ERROR_OUT(("CAppSap::AppRosterInquireConfirm: can't get app roster message, rc=%u", (UINT) rc));
  922. pAppRosterMsg->UnLockApplicationRosterMessage();
  923. goto MyExit;
  924. }
  925. // fill in the roster information
  926. pMsgEx->Msg.AppRosterInquireConfirm.pReserved = (LPVOID) pAppRosterMsg;
  927. pMsgEx->Msg.AppRosterInquireConfirm.nConfID = nConfID;
  928. pMsgEx->Msg.AppRosterInquireConfirm.nResult = nResult;
  929. if (NULL != ppMsgEx)
  930. {
  931. *ppMsgEx = pMsgEx;
  932. }
  933. else
  934. {
  935. PostAppSapMsg(pMsgEx);
  936. }
  937. rc = GCC_NO_ERROR;
  938. MyExit:
  939. if (GCC_NO_ERROR != rc)
  940. {
  941. delete pMsgEx;
  942. }
  943. DebugExitINT(CAppSap::AppRosterInquireConfirm, rc);
  944. return rc;
  945. }
  946. void CAppSap::
  947. FreeAppSapMsg ( GCCAppSapMsg *pMsg )
  948. {
  949. GCCAppSapMsgEx *pMsgEx = (GCCAppSapMsgEx *) pMsg;
  950. ASSERT((LPVOID) pMsgEx == (LPVOID) pMsg);
  951. delete pMsgEx;
  952. }
  953. /*
  954. * AppInvokeConfirm ()
  955. *
  956. * Public Function Description
  957. * This routine is called in order to confirm a call requesting application
  958. * invocation.
  959. */
  960. GCCError CAppSap::
  961. AppInvokeConfirm
  962. (
  963. GCCConfID nConfID,
  964. CInvokeSpecifierListContainer *pInvokeList,
  965. GCCResult nResult,
  966. GCCRequestTag nReqTag
  967. )
  968. {
  969. GCCError rc;
  970. DebugEntry(CAppSap::AppInvokeConfirm);
  971. DBG_SAVE_FILE_LINE
  972. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_APPLICATION_INVOKE_CONFIRM);
  973. if (NULL != pMsgEx)
  974. {
  975. pMsgEx->Msg.nConfID = nConfID;
  976. pMsgEx->Msg.AppInvokeConfirm.nConfID = nConfID;
  977. pMsgEx->Msg.AppInvokeConfirm.nResult = nResult;
  978. pMsgEx->Msg.AppInvokeConfirm.nReqTag = nReqTag;
  979. PostAppSapMsg(pMsgEx);
  980. rc = GCC_NO_ERROR;
  981. }
  982. else
  983. {
  984. ERROR_OUT(("CAppSap::AppInvokeConfirm: can't create GCCAppSapMsgEx"));
  985. rc = GCC_ALLOCATION_FAILURE;
  986. }
  987. DebugExitINT(CAppSap::AppInvokeConfirm, rc);
  988. return rc;
  989. }
  990. /*
  991. * AppInvokeIndication()
  992. *
  993. * Public Function Description
  994. * This routine is called in order to send an indication to an application
  995. * or node controller that a request for application invocation has been
  996. * made.
  997. */
  998. GCCError CAppSap::
  999. AppInvokeIndication
  1000. (
  1001. GCCConfID nConfID,
  1002. CInvokeSpecifierListContainer *pInvokeList,
  1003. GCCNodeID nidInvoker
  1004. )
  1005. {
  1006. GCCError rc;
  1007. UINT cbDataSize;
  1008. BOOL fLock = FALSE;
  1009. DebugEntry(CAppSap::AppInvokeIndication);
  1010. DBG_SAVE_FILE_LINE
  1011. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_APPLICATION_INVOKE_INDICATION);
  1012. if (NULL == pMsgEx)
  1013. {
  1014. ERROR_OUT(("CAppSap::AppInvokeIndication: can't create GCCAppSapMsgEx"));
  1015. rc = GCC_ALLOCATION_FAILURE;
  1016. goto MyExit;
  1017. }
  1018. pMsgEx->Msg.nConfID = nConfID;
  1019. fLock = TRUE;
  1020. cbDataSize = pInvokeList->LockApplicationInvokeSpecifierList();
  1021. if (0 != cbDataSize)
  1022. {
  1023. DBG_SAVE_FILE_LINE
  1024. pMsgEx->Msg.AppInvokeInd.ApeList.apApes = (PGCCAppProtocolEntity *) new char[cbDataSize];
  1025. if (NULL == pMsgEx->Msg.AppInvokeInd.ApeList.apApes)
  1026. {
  1027. ERROR_OUT(("CAppSap::AppInvokeIndication: can't create ape list"));
  1028. rc = GCC_ALLOCATION_FAILURE;
  1029. goto MyExit;
  1030. }
  1031. pInvokeList->GetApplicationInvokeSpecifierList(
  1032. &(pMsgEx->Msg.AppInvokeInd.ApeList.cApes),
  1033. (LPBYTE) pMsgEx->Msg.AppInvokeInd.ApeList.apApes);
  1034. }
  1035. pMsgEx->Msg.AppInvokeInd.nConfID = nConfID;
  1036. pMsgEx->Msg.AppInvokeInd.nidInvoker = nidInvoker;
  1037. PostAppSapMsg(pMsgEx);
  1038. rc = GCC_NO_ERROR;
  1039. MyExit:
  1040. if (fLock)
  1041. {
  1042. pInvokeList->UnLockApplicationInvokeSpecifierList();
  1043. }
  1044. if (GCC_NO_ERROR != rc)
  1045. {
  1046. delete pMsgEx;
  1047. }
  1048. DebugExitINT(CAppSap::AppInvokeIndication, rc);
  1049. return rc;
  1050. }
  1051. /*
  1052. * AppRosterReportIndication ()
  1053. *
  1054. * Public Function Description
  1055. * This routine is called in order to indicate to applications and the
  1056. * node controller that the list of application rosters has been updated.
  1057. */
  1058. GCCError CAppSap::
  1059. AppRosterReportIndication
  1060. (
  1061. GCCConfID nConfID,
  1062. CAppRosterMsg *pAppRosterMsg
  1063. )
  1064. {
  1065. GCCError rc;
  1066. DebugEntry(CAppSap::AppRosterReportIndication);
  1067. DBG_SAVE_FILE_LINE
  1068. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_APP_ROSTER_REPORT_INDICATION);
  1069. if (NULL == pMsgEx)
  1070. {
  1071. ERROR_OUT(("CAppSap::AppRosterReportIndication: can't create GCCAppSapMsgEx"));
  1072. rc = GCC_ALLOCATION_FAILURE;
  1073. goto MyExit;
  1074. }
  1075. pMsgEx->Msg.nConfID = nConfID;
  1076. /*
  1077. * Lock the data for the roster message and retrieve the data.
  1078. */
  1079. rc = pAppRosterMsg->LockApplicationRosterMessage();
  1080. if (GCC_NO_ERROR != rc)
  1081. {
  1082. ERROR_OUT(("CAppSap::AppRosterReportIndication: can't lock app roster message, rc=%u", (UINT) rc));
  1083. goto MyExit;
  1084. }
  1085. rc = pAppRosterMsg->GetAppRosterMsg((LPBYTE *) &(pMsgEx->Msg.AppRosterReportInd.apAppRosters),
  1086. &(pMsgEx->Msg.AppRosterReportInd.cRosters));
  1087. if (GCC_NO_ERROR != rc)
  1088. {
  1089. ERROR_OUT(("CAppSap::AppRosterReportIndication: can't get app roster message, rc=%u", (UINT) rc));
  1090. pAppRosterMsg->UnLockApplicationRosterMessage();
  1091. goto MyExit;
  1092. }
  1093. // fill in the roster information
  1094. pMsgEx->Msg.AppRosterReportInd.pReserved = (LPVOID) pAppRosterMsg;
  1095. pMsgEx->Msg.AppRosterReportInd.nConfID = nConfID;
  1096. PostAppSapMsg(pMsgEx);
  1097. rc = GCC_NO_ERROR;
  1098. MyExit:
  1099. if (GCC_NO_ERROR != rc)
  1100. {
  1101. delete pMsgEx;
  1102. }
  1103. DebugExitINT(CAppSap::AppRosterReportIndication, rc);
  1104. return rc;
  1105. }
  1106. /*
  1107. * ConductorInquireConfirm ()
  1108. *
  1109. * Public Function Description
  1110. * This routine is called in order to return conductorship information
  1111. * which has been requested.
  1112. *
  1113. */
  1114. GCCError CAppSap::
  1115. ConductorInquireConfirm
  1116. (
  1117. GCCNodeID nidConductor,
  1118. GCCResult nResult,
  1119. BOOL fGranted,
  1120. BOOL fConducted,
  1121. GCCConfID nConfID
  1122. )
  1123. {
  1124. GCCError rc;
  1125. DebugEntry(CAppSap::ConductorInquireConfirm);
  1126. DBG_SAVE_FILE_LINE
  1127. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_CONDUCT_INQUIRE_CONFIRM);
  1128. if (NULL != pMsgEx)
  1129. {
  1130. pMsgEx->Msg.nConfID = nConfID;
  1131. pMsgEx->Msg.ConductorInquireConfirm.nConfID = nConfID;
  1132. pMsgEx->Msg.ConductorInquireConfirm.fConducted = fConducted;
  1133. pMsgEx->Msg.ConductorInquireConfirm.nidConductor = nidConductor;
  1134. pMsgEx->Msg.ConductorInquireConfirm.fGranted = fGranted;
  1135. pMsgEx->Msg.ConductorInquireConfirm.nResult = nResult;
  1136. PostAppSapMsg(pMsgEx);
  1137. rc = GCC_NO_ERROR;
  1138. }
  1139. else
  1140. {
  1141. ERROR_OUT(("CAppSap::ConductorInquireConfirm: can't create GCCAppSapMsgEx"));
  1142. rc = GCC_ALLOCATION_FAILURE;
  1143. }
  1144. DebugExitINT(CAppSap::ConductorInquireConfirm, rc);
  1145. return rc;
  1146. }
  1147. /*
  1148. * ConductorPermitGrantIndication ()
  1149. *
  1150. * Public Function Description
  1151. * This routine is called in order to send an indication to an application
  1152. * or node controller that a request for permission from the conductor
  1153. * has been made.
  1154. */
  1155. GCCError CAppSap::
  1156. ConductorPermitGrantIndication
  1157. (
  1158. GCCConfID nConfID,
  1159. UINT cGranted,
  1160. GCCNodeID *aGranted,
  1161. UINT cWaiting,
  1162. GCCNodeID *aWaiting,
  1163. BOOL fThisNodeIsGranted
  1164. )
  1165. {
  1166. GCCError rc;
  1167. UINT cbDataSize = 0;
  1168. DebugEntry(CAppSap::ConductorPermitGrantIndication);
  1169. cbDataSize = (0 != cGranted || 0 != cWaiting) ?
  1170. (ROUNDTOBOUNDARY(sizeof(GCCNodeID)) * cGranted) +
  1171. (ROUNDTOBOUNDARY(sizeof(GCCNodeID)) * cWaiting) :
  1172. 0;
  1173. DBG_SAVE_FILE_LINE
  1174. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_CONDUCT_GRANT_INDICATION);
  1175. if (NULL != pMsgEx)
  1176. {
  1177. pMsgEx->Msg.nConfID = nConfID;
  1178. if (cbDataSize > 0)
  1179. {
  1180. DBG_SAVE_FILE_LINE
  1181. pMsgEx->Msg.ConductorPermitGrantInd.pReserved = (LPVOID) new char[cbDataSize];
  1182. if (NULL == pMsgEx->Msg.ConductorPermitGrantInd.pReserved)
  1183. {
  1184. ERROR_OUT(("CAppSap::ConductorPermitGrantIndication: can't allocate buffer, cbDataSize=%u", (UINT) cbDataSize));
  1185. goto MyExit;
  1186. }
  1187. }
  1188. pMsgEx->Msg.ConductorPermitGrantInd.nConfID = nConfID;
  1189. pMsgEx->Msg.ConductorPermitGrantInd.Granted.cNodes = cGranted;
  1190. if (0 != cGranted)
  1191. {
  1192. pMsgEx->Msg.ConductorPermitGrantInd.Granted.aNodeIDs =
  1193. (GCCNodeID *) pMsgEx->Msg.ConductorPermitGrantInd.pReserved;
  1194. ::CopyMemory(pMsgEx->Msg.ConductorPermitGrantInd.Granted.aNodeIDs,
  1195. aGranted,
  1196. sizeof(GCCNodeID) * cGranted);
  1197. }
  1198. pMsgEx->Msg.ConductorPermitGrantInd.Waiting.cNodes = cWaiting;
  1199. if (0 != cWaiting)
  1200. {
  1201. pMsgEx->Msg.ConductorPermitGrantInd.Waiting.aNodeIDs =
  1202. (GCCNodeID *) ((LPBYTE) pMsgEx->Msg.ConductorPermitGrantInd.pReserved +
  1203. (ROUNDTOBOUNDARY(sizeof(GCCNodeID)) * cGranted));
  1204. ::CopyMemory(pMsgEx->Msg.ConductorPermitGrantInd.Waiting.aNodeIDs,
  1205. aWaiting,
  1206. sizeof(GCCNodeID) * cWaiting);
  1207. }
  1208. pMsgEx->Msg.ConductorPermitGrantInd.fThisNodeIsGranted = fThisNodeIsGranted;
  1209. PostAppSapMsg(pMsgEx);
  1210. rc = GCC_NO_ERROR;
  1211. }
  1212. else
  1213. {
  1214. ERROR_OUT(("CAppSap::ConductorPermitGrantIndication: can't create GCCAppSapMsgEx"));
  1215. rc = GCC_ALLOCATION_FAILURE;
  1216. }
  1217. MyExit:
  1218. if (GCC_NO_ERROR != rc)
  1219. {
  1220. delete pMsgEx;
  1221. }
  1222. DebugExitINT(CAppSap::ConductorPermitGrantIndication, rc);
  1223. return rc;
  1224. }
  1225. /*
  1226. * ConductorAssignIndication ()
  1227. *
  1228. * Public Function Description
  1229. * This routine is called in order to send an indication to an application
  1230. * or node controller that a request has been made to assign conductorship.
  1231. */
  1232. GCCError CAppSap::
  1233. ConductorAssignIndication
  1234. (
  1235. GCCNodeID nidConductor,
  1236. GCCConfID nConfID
  1237. )
  1238. {
  1239. GCCError rc;
  1240. DebugEntry(CAppSap::ConductorAssignIndication);
  1241. DBG_SAVE_FILE_LINE
  1242. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_CONDUCT_ASSIGN_INDICATION);
  1243. if (NULL != pMsgEx)
  1244. {
  1245. pMsgEx->Msg.nConfID = nConfID;
  1246. pMsgEx->Msg.ConductorAssignInd.nConfID = nConfID;
  1247. pMsgEx->Msg.ConductorAssignInd.nidConductor = nidConductor;
  1248. PostAppSapMsg(pMsgEx);
  1249. rc = GCC_NO_ERROR;
  1250. }
  1251. else
  1252. {
  1253. ERROR_OUT(("CAppSap::ConductorPermitGrantIndication: can't create GCCAppSapMsgEx"));
  1254. rc = GCC_ALLOCATION_FAILURE;
  1255. }
  1256. DebugExitINT(CAppSap::ConductorAssignIndication, rc);
  1257. return rc;
  1258. }
  1259. /*
  1260. * ConductorReleaseIndication ()
  1261. *
  1262. * Public Function Description
  1263. * This routine is called in order to send an indication to an application
  1264. * or node controller that a request for releasing conductorship has been
  1265. * made.
  1266. */
  1267. GCCError CAppSap::
  1268. ConductorReleaseIndication ( GCCConfID nConfID )
  1269. {
  1270. GCCError rc;
  1271. DebugEntry(CAppSap::ConductorReleaseIndication);
  1272. DBG_SAVE_FILE_LINE
  1273. GCCAppSapMsgEx *pMsgEx = new GCCAppSapMsgEx(GCC_CONDUCT_RELEASE_INDICATION);
  1274. if (NULL != pMsgEx)
  1275. {
  1276. pMsgEx->Msg.nConfID = nConfID;
  1277. pMsgEx->Msg.ConductorReleaseInd.nConfID = nConfID;
  1278. PostAppSapMsg(pMsgEx);
  1279. rc = GCC_NO_ERROR;
  1280. }
  1281. else
  1282. {
  1283. ERROR_OUT(("CAppSap::ConductorReleaseIndication: can't create GCCAppSapMsgEx"));
  1284. rc = GCC_ALLOCATION_FAILURE;
  1285. }
  1286. DebugExitINT(CAppSap::ConductorReleaseIndication, rc);
  1287. return rc;
  1288. }
  1289. void CAppSap::
  1290. NotifyProc ( GCCAppSapMsgEx *pAppSapMsgEx )
  1291. {
  1292. if (NULL != m_pfnCallback)
  1293. {
  1294. pAppSapMsgEx->Msg.pAppData = m_pAppData;
  1295. (*m_pfnCallback)(&(pAppSapMsgEx->Msg));
  1296. }
  1297. delete pAppSapMsgEx;
  1298. }
  1299. //
  1300. // The following is for GCCAppSapMsgEx structure
  1301. //
  1302. GCCAppSapMsgEx::
  1303. GCCAppSapMsgEx ( GCCMessageType eMsgType )
  1304. {
  1305. ::ZeroMemory(&Msg, sizeof(Msg));
  1306. Msg.eMsgType = eMsgType;
  1307. }
  1308. GCCAppSapMsgEx::
  1309. ~GCCAppSapMsgEx ( void )
  1310. {
  1311. switch (Msg.eMsgType)
  1312. {
  1313. //
  1314. // Application Roster related callbacks
  1315. //
  1316. case GCC_PERMIT_TO_ENROLL_INDICATION:
  1317. case GCC_ENROLL_CONFIRM:
  1318. case GCC_APPLICATION_INVOKE_CONFIRM:
  1319. //
  1320. // No need to free anything
  1321. //
  1322. break;
  1323. case GCC_APP_ROSTER_REPORT_INDICATION:
  1324. if (NULL != Msg.AppRosterReportInd.pReserved)
  1325. {
  1326. //
  1327. // App roster report is also sent to control sap.
  1328. //
  1329. ::EnterCriticalSection(&g_csGCCProvider);
  1330. ((CAppRosterMsg *) Msg.AppRosterReportInd.pReserved)->UnLockApplicationRosterMessage();
  1331. ::LeaveCriticalSection(&g_csGCCProvider);
  1332. }
  1333. break;
  1334. case GCC_APP_ROSTER_INQUIRE_CONFIRM:
  1335. if (NULL != Msg.AppRosterInquireConfirm.pReserved)
  1336. {
  1337. ((CAppRosterMsg *) Msg.AppRosterInquireConfirm.pReserved)->UnLockApplicationRosterMessage();
  1338. }
  1339. break;
  1340. case GCC_APPLICATION_INVOKE_INDICATION:
  1341. delete Msg.AppInvokeInd.ApeList.apApes;
  1342. break;
  1343. //
  1344. // Conference Roster related callbacks
  1345. //
  1346. case GCC_ROSTER_INQUIRE_CONFIRM:
  1347. delete Msg.ConfRosterInquireConfirm.ConfName.numeric_string;
  1348. delete Msg.ConfRosterInquireConfirm.ConfName.text_string;
  1349. delete Msg.ConfRosterInquireConfirm.pszConfModifier;
  1350. delete Msg.ConfRosterInquireConfirm.pwszConfDescriptor;
  1351. delete Msg.ConfRosterInquireConfirm.pConfRoster;
  1352. break;
  1353. //
  1354. // Application Registry related callbacks
  1355. //
  1356. case GCC_REGISTER_CHANNEL_CONFIRM:
  1357. case GCC_ASSIGN_TOKEN_CONFIRM:
  1358. case GCC_RETRIEVE_ENTRY_CONFIRM:
  1359. case GCC_DELETE_ENTRY_CONFIRM:
  1360. case GCC_SET_PARAMETER_CONFIRM:
  1361. case GCC_MONITOR_INDICATION:
  1362. case GCC_MONITOR_CONFIRM:
  1363. delete Msg.RegistryConfirm.pRegKey;
  1364. delete Msg.RegistryConfirm.pRegItem;
  1365. break;
  1366. case GCC_ALLOCATE_HANDLE_CONFIRM:
  1367. //
  1368. // No need to free anything
  1369. //
  1370. break;
  1371. //
  1372. // Conductorship related callbacks
  1373. //
  1374. case GCC_CONDUCT_ASSIGN_INDICATION:
  1375. case GCC_CONDUCT_RELEASE_INDICATION:
  1376. case GCC_CONDUCT_INQUIRE_CONFIRM:
  1377. //
  1378. // No need to free anything
  1379. //
  1380. break;
  1381. case GCC_CONDUCT_GRANT_INDICATION:
  1382. delete Msg.ConductorPermitGrantInd.pReserved;
  1383. break;
  1384. default:
  1385. ERROR_OUT(("GCCAppSapMsgEx::~GCCAppSapMsgEx: unknown msg type=%u", (UINT) Msg.eMsgType));
  1386. break;
  1387. }
  1388. }
  1389. void CAppSap::
  1390. PurgeMessageQueue(void)
  1391. {
  1392. MSG msg;
  1393. /*
  1394. * This loop calls PeekMessage to go through all the messages in the thread's
  1395. * queue that were posted by the main MCS thread. It removes these
  1396. * messages and frees the resources that they consume.
  1397. */
  1398. while (PeekMessage(&msg, m_hwndNotify, ASAPMSG_BASE, ASAPMSG_BASE + MSG_RANGE, PM_REMOVE))
  1399. {
  1400. if (msg.message == WM_QUIT)
  1401. {
  1402. // Repost the quit
  1403. PostQuitMessage(0);
  1404. break;
  1405. }
  1406. ASSERT(this == (CAppSap *) msg.lParam);
  1407. delete (GCCAppSapMsgEx *) msg.wParam;
  1408. }
  1409. // Destroy the window; we do not need it anymore
  1410. if (NULL != m_hwndNotify)
  1411. {
  1412. ::DestroyWindow(m_hwndNotify);
  1413. m_hwndNotify = NULL;
  1414. }
  1415. }