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.

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