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.

485 lines
7.6 KiB

  1. // File: asui.cpp
  2. #include "precomp.h"
  3. #include "resource.h"
  4. #include "popupmsg.h"
  5. #include "cr.h"
  6. #include "dshowdlg.h"
  7. #include <help_ids.h>
  8. #include "confroom.h"
  9. #include "confman.h"
  10. #include "particip.h"
  11. #include "menuutil.h"
  12. #include <nmremote.h>
  13. #include "NmManager.h"
  14. //
  15. // AppSharing part of confroom
  16. //
  17. //
  18. // IAppSharingNotify METHODS
  19. //
  20. STDMETHODIMP CConfRoom::OnReadyToShare(BOOL fReady)
  21. {
  22. ASSERT(m_pAS);
  23. //
  24. // 2.x SDK: CHANGE AS CHANNEL STATE
  25. //
  26. CNmManagerObj::AppSharingChannelActiveStateChanged(fReady != FALSE);
  27. return S_OK;
  28. }
  29. STDMETHODIMP CConfRoom::OnShareStarted(void)
  30. {
  31. ASSERT(m_pAS);
  32. return S_OK;
  33. }
  34. STDMETHODIMP CConfRoom::OnSharingStarted(void)
  35. {
  36. ASSERT(m_pAS);
  37. CNmManagerObj::AppSharingChannelChanged();
  38. return S_OK;
  39. }
  40. STDMETHODIMP CConfRoom::OnShareEnded(void)
  41. {
  42. ASSERT(m_pAS);
  43. CNmManagerObj::AppSharingChannelChanged();
  44. return S_OK;
  45. }
  46. STDMETHODIMP CConfRoom::OnPersonJoined(IAS_GCC_ID gccMemberID)
  47. {
  48. ASSERT(m_pAS);
  49. //
  50. // 2.x SDK -- ADD PERSON TO AS CHANNEL MEMBER LIST
  51. //
  52. CNmManagerObj::ASMemberChanged(gccMemberID);
  53. return S_OK;
  54. }
  55. STDMETHODIMP CConfRoom::OnPersonLeft(IAS_GCC_ID gccMemberID)
  56. {
  57. ASSERT(m_pAS);
  58. //
  59. // 2.x SDK -- REMOVE PERSON FROM AS CHANNEL MEMBER LIST
  60. //
  61. CNmManagerObj::ASMemberChanged(gccMemberID);
  62. return S_OK;
  63. }
  64. STDMETHODIMP CConfRoom::OnStartInControl(IAS_GCC_ID gccMemberID)
  65. {
  66. ASSERT(m_pAS);
  67. //
  68. // 2.x SDK -- CHANGE MEMBER STATES
  69. // * Change remote (gccMemberID) to VIEWING
  70. // * Change local to IN CONTROL
  71. //
  72. CNmManagerObj::ASLocalMemberChanged();
  73. CNmManagerObj::ASMemberChanged(gccMemberID);
  74. CNmManagerObj::AppSharingChannelChanged();
  75. return S_OK;
  76. }
  77. STDMETHODIMP CConfRoom::OnStopInControl(IAS_GCC_ID gccMemberID)
  78. {
  79. ASSERT(m_pAS);
  80. //
  81. // 2.x SDK -- CHANGE MEMBER STATES
  82. // * Change remote (gccMemberID) to DETACHED
  83. // * Change local to DETACHED
  84. //
  85. CNmManagerObj::ASLocalMemberChanged();
  86. CNmManagerObj::ASMemberChanged(gccMemberID);
  87. CNmManagerObj::AppSharingChannelChanged();
  88. return S_OK;
  89. }
  90. STDMETHODIMP CConfRoom::OnPausedInControl(IAS_GCC_ID gccMemberID)
  91. {
  92. //
  93. // New for 3.0
  94. // 3.0 SDK -- Change member state?
  95. //
  96. return S_OK;
  97. }
  98. STDMETHODIMP CConfRoom::OnUnpausedInControl(IAS_GCC_ID gccMemberID)
  99. {
  100. //
  101. // New for 3.0
  102. // 3.0 SDK -- Change member state?
  103. //
  104. return(S_OK);
  105. }
  106. STDMETHODIMP CConfRoom::OnControllable(BOOL fControllable)
  107. {
  108. ASSERT(m_pAS);
  109. //
  110. // 2.x SDK -- CHANGE LOCAL STATE?
  111. //
  112. CNmManagerObj::ASLocalMemberChanged();
  113. CNmManagerObj::AppSharingChannelChanged();
  114. return S_OK;
  115. }
  116. STDMETHODIMP CConfRoom::OnStartControlled(IAS_GCC_ID gccMemberID)
  117. {
  118. ASSERT(m_pAS);
  119. //
  120. // 2.x SDK -- CHANGE MEMBER STATES
  121. // * Change local to VIEWING
  122. // * Change remote (gccMemberID) to IN CONTROL
  123. //
  124. CNmManagerObj::ASLocalMemberChanged();
  125. CNmManagerObj::ASMemberChanged(gccMemberID);
  126. CNmManagerObj::AppSharingChannelChanged();
  127. return S_OK;
  128. }
  129. STDMETHODIMP CConfRoom::OnStopControlled(IAS_GCC_ID gccMemberID)
  130. {
  131. ASSERT(m_pAS);
  132. //
  133. // 2.x SDK -- CHANGE MEMBER STATES
  134. // * Change local to DETACHED
  135. // * Change remote to DETACHED
  136. //
  137. CNmManagerObj::ASLocalMemberChanged();
  138. CNmManagerObj::ASMemberChanged(gccMemberID);
  139. CNmManagerObj::AppSharingChannelChanged();
  140. return S_OK;
  141. }
  142. STDMETHODIMP CConfRoom::OnPausedControlled(IAS_GCC_ID gccMemberID)
  143. {
  144. ASSERT(m_pAS);
  145. return(S_OK);
  146. }
  147. STDMETHODIMP CConfRoom::OnUnpausedControlled(IAS_GCC_ID gccMemberID)
  148. {
  149. ASSERT(m_pAS);
  150. return(S_OK);
  151. }
  152. //
  153. // RevokeControl()
  154. //
  155. HRESULT CConfRoom::RevokeControl(UINT gccID)
  156. {
  157. if (!m_pAS)
  158. return E_FAIL;
  159. return m_pAS->RevokeControl(gccID);
  160. }
  161. //
  162. // AllowControl()
  163. //
  164. HRESULT CConfRoom::AllowControl(BOOL fAllow)
  165. {
  166. if (!m_pAS)
  167. return(E_FAIL);
  168. return(m_pAS->AllowControl(fAllow));
  169. }
  170. //
  171. // GiveControl()
  172. //
  173. HRESULT CConfRoom::GiveControl(UINT gccID)
  174. {
  175. if (!m_pAS)
  176. return(E_FAIL);
  177. return(m_pAS->GiveControl(gccID));
  178. }
  179. //
  180. // CancelGiveControl()
  181. //
  182. HRESULT CConfRoom::CancelGiveControl(UINT gccID)
  183. {
  184. if (!m_pAS)
  185. return(E_FAIL);
  186. return(m_pAS->CancelGiveControl(gccID));
  187. }
  188. BOOL CConfRoom::FIsSharingAvailable(void)
  189. {
  190. if (!m_pAS)
  191. return FALSE;
  192. return(m_pAS->IsSharingAvailable());
  193. }
  194. /* F C A N S H A R E */
  195. /*-------------------------------------------------------------------------
  196. %%Function: FCanShare
  197. -------------------------------------------------------------------------*/
  198. BOOL CConfRoom::FCanShare(void)
  199. {
  200. if (!m_pAS)
  201. return FALSE;
  202. return (m_pAS->CanShareNow());
  203. }
  204. //
  205. // FInShare()
  206. //
  207. BOOL CConfRoom::FInShare(void)
  208. {
  209. if (!m_pAS)
  210. return FALSE;
  211. return (m_pAS->IsInShare());
  212. }
  213. BOOL CConfRoom::FIsSharing(void)
  214. {
  215. if (!m_pAS)
  216. return FALSE;
  217. return (m_pAS->IsSharing());
  218. }
  219. //
  220. // FIsControllable()
  221. //
  222. BOOL CConfRoom::FIsControllable(void)
  223. {
  224. if (!m_pAS)
  225. return FALSE;
  226. return (m_pAS->IsControllable());
  227. }
  228. //
  229. // GetPersonShareStatus()
  230. //
  231. HRESULT CConfRoom::GetPersonShareStatus(UINT gccID, IAS_PERSON_STATUS * pStatus)
  232. {
  233. if (!m_pAS)
  234. return E_FAIL;
  235. ZeroMemory(pStatus, sizeof(*pStatus));
  236. pStatus->cbSize = sizeof(*pStatus);
  237. return(m_pAS->GetPersonStatus(gccID, pStatus));
  238. }
  239. HRESULT CConfRoom::CmdShare(HWND hwnd)
  240. {
  241. HRESULT hr = E_FAIL;
  242. DebugEntry(CConfRoom::CmdShare);
  243. if (m_pAS)
  244. {
  245. hr = m_pAS->Share(hwnd, IAS_SHARE_DEFAULT);
  246. if (SUCCEEDED(hr))
  247. {
  248. CNmManagerObj::SharableAppStateChanged(hwnd, NM_SHAPP_SHARED);
  249. }
  250. }
  251. DebugExitHRESULT(CConfRoom::CmdShare, hr);
  252. return hr;
  253. }
  254. HRESULT CConfRoom::CmdUnshare(HWND hwnd)
  255. {
  256. HRESULT hr = E_FAIL;
  257. DebugEntry(CConfRoom::CmdUnshare);
  258. if (m_pAS)
  259. {
  260. hr = m_pAS->Unshare(hwnd);
  261. if (SUCCEEDED(hr))
  262. {
  263. CNmManagerObj::SharableAppStateChanged(hwnd, NM_SHAPP_NOT_SHARED);
  264. }
  265. }
  266. DebugExitHRESULT(CConfRoom::CmdUnshare, hr);
  267. return hr;
  268. }
  269. BOOL CConfRoom::FIsWindowShareable(HWND hwnd)
  270. {
  271. if (!m_pAS)
  272. return(FALSE);
  273. return(m_pAS->IsWindowShareable(hwnd));
  274. }
  275. BOOL CConfRoom::FIsWindowShared(HWND hwnd)
  276. {
  277. if (!m_pAS)
  278. return(FALSE);
  279. return(m_pAS->IsWindowShared(hwnd));
  280. }
  281. HRESULT CConfRoom::GetShareableApps(IAS_HWND_ARRAY ** pList)
  282. {
  283. if (!m_pAS)
  284. return E_FAIL;
  285. return m_pAS->GetShareableApps(pList);
  286. }
  287. HRESULT CConfRoom::FreeShareableApps(IAS_HWND_ARRAY * pList)
  288. {
  289. if (!m_pAS)
  290. return E_FAIL;
  291. return m_pAS->FreeShareableApps(pList);
  292. }
  293. void CConfRoom::LaunchHostUI(void)
  294. {
  295. if (m_pAS)
  296. {
  297. m_pAS->LaunchHostUI();
  298. }
  299. }
  300. HRESULT GetShareState(ULONG ulGCCId, NM_SHARE_STATE *puState)
  301. {
  302. HRESULT hr = E_UNEXPECTED;
  303. ASSERT(puState);
  304. *puState = NM_SHARE_UNKNOWN;
  305. CConfRoom *p = ::GetConfRoom();
  306. if(p)
  307. {
  308. IAS_PERSON_STATUS s;
  309. hr = p->GetPersonShareStatus(ulGCCId, &s);
  310. if(SUCCEEDED(hr))
  311. {
  312. //
  313. // There's no share at all as far as we know, or this person isn't participating
  314. //
  315. if (!s.InShare)
  316. {
  317. *puState = NM_SHARE_UNKNOWN;
  318. return hr;
  319. }
  320. //
  321. // This person is in control of another
  322. //
  323. if ((s.InControlOf) || (s.Controllable && !s.ControlledBy))
  324. {
  325. *puState = NM_SHARE_IN_CONTROL;
  326. return hr;
  327. }
  328. //
  329. // This person can be (and maybe is) controlled by another
  330. //
  331. if (s.Controllable)
  332. {
  333. *puState = NM_SHARE_COLLABORATING;
  334. return hr;
  335. }
  336. *puState = NM_SHARE_WORKING_ALONE;
  337. }
  338. }
  339. return hr;
  340. }