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.

189 lines
3.7 KiB

  1. // File: confman.cpp
  2. //
  3. // Conference Manager
  4. #include "precomp.h"
  5. #include "conf.h"
  6. #include "confroom.h"
  7. #include "confman.h"
  8. #include "cr.h" // for CreateConfRoom
  9. #include "call.h" // for OnUICallCreated
  10. CConfMan * CConfMan::m_pConfMan = NULL; // There is only one of these
  11. static const UINT g_cuShutdownMsgTimeout = 0x7FFFFFFF; // milliseconds
  12. /* C C O N F M A N */
  13. /*-------------------------------------------------------------------------
  14. %%Function: CConfMan
  15. -------------------------------------------------------------------------*/
  16. CConfMan::CConfMan(INmManager2 *pManager) :
  17. RefCount(NULL),
  18. m_pManager(pManager)
  19. {
  20. m_pConfMan = this;
  21. ASSERT(NULL != m_pManager);
  22. NmAdvise(m_pManager, (INmManagerNotify*)this, IID_INmManagerNotify, &m_dwCookie);
  23. m_pManager->AddRef();
  24. DbgMsg(iZONE_OBJECTS, "Obj: %08X created CConfMan", this);
  25. }
  26. CConfMan::~CConfMan()
  27. {
  28. ASSERT(NULL == m_pManager);
  29. m_pConfMan = NULL;
  30. DbgMsg(iZONE_OBJECTS, "Obj: %08X destroyed CConfMan", this);
  31. }
  32. BOOL CConfMan::FCreate(INmManager2 *pManager)
  33. {
  34. if (NULL != m_pConfMan)
  35. return FALSE; // already created
  36. m_pConfMan = new CConfMan(pManager);
  37. if (NULL == m_pConfMan)
  38. return FALSE;
  39. return TRUE;
  40. }
  41. VOID CConfMan::Destroy(void)
  42. {
  43. if (NULL == m_pConfMan)
  44. return;
  45. m_pConfMan->CleanUp();
  46. // we should only have one more lock on this object
  47. m_pConfMan->Release();
  48. // so this will be cleared in the destructor
  49. ASSERT(NULL == m_pConfMan);
  50. }
  51. VOID CConfMan::CleanUp(void)
  52. {
  53. if (NULL != m_pManager)
  54. {
  55. NmUnadvise(m_pManager, IID_INmManagerNotify, m_dwCookie);
  56. CConfRoom* pcr = ::GetConfRoom();
  57. if (NULL != pcr)
  58. {
  59. pcr->CleanUp();
  60. }
  61. m_pManager->Release();
  62. m_pManager = NULL;
  63. }
  64. }
  65. /* G E T N M M A N A G E R */
  66. /*-------------------------------------------------------------------------
  67. %%Function: GetNmManager
  68. -------------------------------------------------------------------------*/
  69. INmManager2 * CConfMan::GetNmManager()
  70. {
  71. if (NULL == m_pConfMan)
  72. return NULL;
  73. INmManager2 * pManager = m_pConfMan->GetINmManager();
  74. if (NULL != pManager)
  75. {
  76. pManager->AddRef();
  77. }
  78. return pManager;
  79. }
  80. //////////////////////////////////////////////////////////////////////////
  81. // IUnknown
  82. STDMETHODIMP_(ULONG) CConfMan::AddRef(void)
  83. {
  84. return RefCount::AddRef();
  85. }
  86. STDMETHODIMP_(ULONG) CConfMan::Release(void)
  87. {
  88. return RefCount::Release();
  89. }
  90. STDMETHODIMP CConfMan::QueryInterface(REFIID riid, PVOID *ppv)
  91. {
  92. HRESULT hr = S_OK;
  93. if ((riid == IID_INmManagerNotify) || (riid == IID_IUnknown))
  94. {
  95. *ppv = (INmManagerNotify *)this;
  96. ApiDebugMsg(("CConfMan::QueryInterface()"));
  97. }
  98. else
  99. {
  100. hr = E_NOINTERFACE;
  101. *ppv = NULL;
  102. ApiDebugMsg(("CConfMan::QueryInterface(): Called on unknown interface."));
  103. }
  104. if (S_OK == hr)
  105. {
  106. AddRef();
  107. }
  108. return hr;
  109. }
  110. //////////////////////////////////////////////////////////////////////////
  111. // INmManagerNotify
  112. STDMETHODIMP CConfMan::NmUI(CONFN uNotify)
  113. {
  114. return S_OK;
  115. }
  116. STDMETHODIMP CConfMan::ConferenceCreated(INmConference *pConference)
  117. {
  118. CConfRoom * m_pConfRoom = ::GetConfRoom();
  119. ASSERT(NULL != m_pConfRoom);
  120. if(_Module.IsUIActive())
  121. {
  122. m_pConfRoom->BringToFront();
  123. }
  124. return m_pConfRoom->OnConferenceCreated(pConference);
  125. }
  126. STDMETHODIMP CConfMan::CallCreated(INmCall *pCall)
  127. {
  128. OnUICallCreated(pCall);
  129. return S_OK;
  130. }
  131. VOID CConfMan::AllowAV(BOOL fAllowAV)
  132. {
  133. CConfMan * pConfMan = CConfMan::GetInstance();
  134. if (NULL == pConfMan)
  135. return;
  136. INmManager2 * pManager = pConfMan->GetINmManager();
  137. if (NULL == pManager)
  138. return;
  139. pManager->AllowH323(fAllowAV);
  140. }