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.

310 lines
5.4 KiB

  1. #include "precomp.h"
  2. #include "confroom.h"
  3. // NetMeeting SDK stuff
  4. #include "SDKInternal.h"
  5. #include "NmConference.h"
  6. #include "NmMember.h"
  7. /////////////////////////////////////////////////////////////////////////
  8. // Construction and Destruction
  9. /////////////////////////////////////////////////////////////////////////
  10. CNmMemberObj::CNmMemberObj(): m_bIsSelf(false)
  11. {
  12. DBGENTRY(CNmMemberObj::CNmMemberObj);
  13. DBGEXIT(CNmMemberObj::CNmMemberObj);
  14. }
  15. CNmMemberObj::~CNmMemberObj()
  16. {
  17. DBGENTRY(CNmMemberObj::~CNmMemberObj);
  18. DBGEXIT(CNmMemberObj::~CNmMemberObj);
  19. }
  20. //static
  21. HRESULT CNmMemberObj::CreateInstance(CNmConferenceObj* pConfObj, INmMember* pInternalINmMember, INmMember** ppMember)
  22. {
  23. DBGENTRY(CNmMemberObj::CreateInstance);
  24. HRESULT hr = S_OK;
  25. CComObject<CNmMemberObj>* p = NULL;
  26. p = new CComObject<CNmMemberObj>(NULL);
  27. if (p != NULL)
  28. {
  29. if(SUCCEEDED(hr))
  30. {
  31. CNmMemberObj* pThis = static_cast<CNmMemberObj*>(p);
  32. pThis->m_spInternalINmMember = pInternalINmMember;
  33. pThis->m_pConferenceObj = pConfObj;
  34. pThis->m_bIsSelf = (pInternalINmMember && (S_OK == pInternalINmMember->IsSelf()));
  35. if(pThis != NULL)
  36. {
  37. pThis->SetVoid(NULL);
  38. // We do this so that we don't accidentally Release out of memory
  39. ++pThis->m_dwRef;
  40. hr = pThis->FinalConstruct();
  41. --pThis->m_dwRef;
  42. if(hr == S_OK)
  43. hr = pThis->QueryInterface(IID_INmMember, reinterpret_cast<void**>(ppMember));
  44. if(FAILED(hr))
  45. {
  46. delete pThis;
  47. }
  48. }
  49. else
  50. {
  51. hr = E_UNEXPECTED;
  52. }
  53. }
  54. }
  55. else
  56. {
  57. hr = E_OUTOFMEMORY;
  58. }
  59. DBGEXIT_HR(CNmMemberObj::CreateInstance,hr);
  60. return hr;
  61. }
  62. /////////////////////////////////////////////////////////////////////////
  63. // INmMember methods
  64. /////////////////////////////////////////////////////////////////////////
  65. STDMETHODIMP CNmMemberObj::GetName(BSTR *pbstrName)
  66. {
  67. DBGENTRY(CNmMemberObj::GetName);
  68. HRESULT hr = S_OK;
  69. if(m_spInternalINmMember)
  70. {
  71. hr = m_spInternalINmMember->GetName(pbstrName);
  72. }
  73. else
  74. {
  75. hr = E_UNEXPECTED;
  76. }
  77. DBGEXIT_HR(CNmMemberObj::GetName,hr);
  78. return hr;
  79. }
  80. STDMETHODIMP CNmMemberObj::GetID(ULONG * puID)
  81. {
  82. DBGENTRY(CNmMemberObj::GetID);
  83. HRESULT hr = S_OK;
  84. if(m_spInternalINmMember)
  85. {
  86. hr = m_spInternalINmMember->GetID(puID);
  87. }
  88. else
  89. {
  90. hr = E_UNEXPECTED;
  91. }
  92. DBGEXIT_HR(CNmMemberObj::GetID,hr);
  93. return hr;
  94. }
  95. STDMETHODIMP CNmMemberObj::GetNmVersion(ULONG *puVersion)
  96. {
  97. DBGENTRY(CNmMemberObj::GetNmVersion);
  98. HRESULT hr = S_OK;
  99. if(m_spInternalINmMember)
  100. {
  101. m_spInternalINmMember->GetNmVersion(puVersion);
  102. }
  103. else
  104. {
  105. hr = E_UNEXPECTED;
  106. }
  107. DBGEXIT_HR(CNmMemberObj::GetNmVersion,hr);
  108. return hr;
  109. }
  110. STDMETHODIMP CNmMemberObj::GetAddr(BSTR *pbstrAddr, NM_ADDR_TYPE *puType)
  111. {
  112. DBGENTRY(CNmMemberObj::GetAddr);
  113. HRESULT hr = S_OK;
  114. if(m_spInternalINmMember)
  115. {
  116. hr = m_spInternalINmMember->GetAddr(pbstrAddr, puType);
  117. }
  118. else
  119. {
  120. hr = E_UNEXPECTED;
  121. }
  122. DBGEXIT_HR(CNmMemberObj::GetAddr,hr);
  123. return hr;
  124. }
  125. STDMETHODIMP CNmMemberObj::GetUserData(REFGUID rguid, BYTE **ppb, ULONG *pcb)
  126. {
  127. DBGENTRY(CNmMemberObj::GetUserData);
  128. HRESULT hr = S_OK;
  129. if(m_spInternalINmMember)
  130. {
  131. m_spInternalINmMember->GetUserData(rguid, ppb, pcb);
  132. }
  133. else
  134. {
  135. hr = E_UNEXPECTED;
  136. }
  137. DBGEXIT_HR(CNmMemberObj::GetUserData,hr);
  138. return hr;
  139. }
  140. STDMETHODIMP CNmMemberObj::GetConference(INmConference **ppConference)
  141. {
  142. DBGENTRY(CNmMemberObj::GetConference);
  143. HRESULT hr = S_OK;
  144. if(ppConference)
  145. {
  146. hr = E_FAIL;
  147. if(m_pConferenceObj)
  148. {
  149. IUnknown * pUnk = m_pConferenceObj->GetUnknown();
  150. if(SUCCEEDED(pUnk->QueryInterface(IID_INmConference, reinterpret_cast<void**>(ppConference))))
  151. {
  152. hr = S_OK;
  153. }
  154. }
  155. }
  156. else
  157. {
  158. hr = E_POINTER;
  159. }
  160. DBGEXIT_HR(CNmMemberObj::GetConference,hr);
  161. return hr;
  162. }
  163. STDMETHODIMP CNmMemberObj::GetNmchCaps(ULONG *puchCaps)
  164. {
  165. DBGENTRY(CNmMemberObj::GetNmchCaps);
  166. HRESULT hr = S_OK;
  167. if(m_spInternalINmMember)
  168. {
  169. hr = m_spInternalINmMember->GetNmchCaps(puchCaps);
  170. }
  171. else
  172. {
  173. hr = E_UNEXPECTED;
  174. }
  175. DBGEXIT_HR(CNmMemberObj::GetNmchCaps,hr);
  176. return hr;
  177. }
  178. STDMETHODIMP CNmMemberObj::GetShareState(NM_SHARE_STATE *puState)
  179. {
  180. DBGENTRY(CNmMemberObj::GetShareState);
  181. HRESULT hr = E_POINTER;
  182. if(puState)
  183. {
  184. ULONG ulGCCId;
  185. hr = GetID(&ulGCCId);
  186. if(SUCCEEDED(hr))
  187. {
  188. hr = ::GetShareState(ulGCCId, puState);
  189. }
  190. }
  191. DBGEXIT_HR(CNmMemberObj::GetShareState,hr);
  192. return hr;
  193. }
  194. STDMETHODIMP CNmMemberObj::IsSelf(void)
  195. {
  196. DBGENTRY(CNmMemberObj::IsSelf);
  197. HRESULT hr = S_OK;
  198. hr = m_bIsSelf ? S_OK : S_FALSE;
  199. DBGEXIT_HR(CNmMemberObj::IsSelf,hr);
  200. return hr;
  201. }
  202. STDMETHODIMP CNmMemberObj::IsMCU(void)
  203. {
  204. DBGENTRY(CNmMemberObj::IsMCU);
  205. HRESULT hr = S_OK;
  206. if(m_spInternalINmMember)
  207. {
  208. hr = m_spInternalINmMember->IsMCU();
  209. }
  210. else
  211. {
  212. hr = E_UNEXPECTED;
  213. }
  214. DBGEXIT_HR(CNmMemberObj::IsMCU,hr);
  215. return hr;
  216. }
  217. STDMETHODIMP CNmMemberObj::Eject(void)
  218. {
  219. DBGENTRY(CNmMemberObj::Eject);
  220. HRESULT hr = S_OK;
  221. if(m_spInternalINmMember)
  222. {
  223. hr = m_spInternalINmMember->Eject();
  224. }
  225. else
  226. {
  227. hr = E_UNEXPECTED;
  228. }
  229. DBGEXIT_HR(CNmMemberObj::Eject,hr);
  230. return hr;
  231. }
  232. /////////////////////////////////////////////////////////////////////////
  233. // IInternalMemberObj methods
  234. /////////////////////////////////////////////////////////////////////////
  235. STDMETHODIMP CNmMemberObj::GetInternalINmMember(INmMember** ppMember)
  236. {
  237. DBGENTRY(CNmMemberObj::GetInternalINmMember);
  238. HRESULT hr = S_OK;
  239. ASSERT(ppMember);
  240. *ppMember = m_spInternalINmMember;
  241. (*ppMember)->AddRef();
  242. DBGEXIT_HR(CNmMemberObj::GetInternalINmMember,hr);
  243. return hr;
  244. }