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.

569 lines
13 KiB

  1. #include "precomp.h"
  2. // Net Meeting SDK includes
  3. #include "NmManager.h"
  4. #include "NmConference.h"
  5. #include "NmCall.h"
  6. #include "NmSharableApp.h"
  7. #include "NmChannelAppShare.h"
  8. #include "SDKWindow.h"
  9. CSDKWindow* CSDKWindow::ms_pSDKWnd = NULL;
  10. int CSDKWindow::ms_NumUnlocks = 0;
  11. /////////////////////////////////////////////////////////////////////////////////
  12. // Construction / destruction / initialization
  13. /////////////////////////////////////////////////////////////////////////////////
  14. //static
  15. HRESULT CSDKWindow::InitSDK()
  16. {
  17. DBGENTRY(CSDKWindow::InitSDK);
  18. HRESULT hr = S_OK;
  19. ASSERT(NULL == ms_pSDKWnd);
  20. ms_pSDKWnd = new CSDKWindow();
  21. if(ms_pSDKWnd)
  22. {
  23. // Create the window
  24. RECT rc;
  25. ms_pSDKWnd->Create(NULL, rc, NULL, WS_POPUP);
  26. if(!ms_pSDKWnd->IsWindow())
  27. {
  28. hr = HRESULT_FROM_WIN32(GetLastError());
  29. }
  30. }
  31. else
  32. {
  33. hr = E_OUTOFMEMORY;
  34. }
  35. DBGEXIT_HR(CSDKWindow::InitSDK,hr);
  36. return hr;
  37. }
  38. //static
  39. void CSDKWindow::CleanupSDK()
  40. {
  41. if(ms_pSDKWnd && ms_pSDKWnd->IsWindow())
  42. {
  43. ms_pSDKWnd->DestroyWindow();
  44. }
  45. delete ms_pSDKWnd;
  46. }
  47. //static
  48. HRESULT CSDKWindow::PostDelayModuleUnlock()
  49. {
  50. if(ms_pSDKWnd)
  51. {
  52. if(!ms_pSDKWnd->SetTimer(DELAY_UNLOAD_TIMER, DELAY_UNLOAD_INTERVAL))
  53. {
  54. return HRESULT_FROM_WIN32(GetLastError());
  55. }
  56. ++ms_NumUnlocks;
  57. return S_OK;
  58. }
  59. return E_FAIL;
  60. }
  61. /////////////////////////////////////////////////////////////////////////////////
  62. // INmManagerNotify Posting functions
  63. /////////////////////////////////////////////////////////////////////////////////
  64. //static
  65. HRESULT CSDKWindow::PostConferenceCreated(CNmManagerObj* pMgr, INmConference* pInternalNmConference)
  66. {
  67. DBGENTRY(CSDKWindow::PostConferenceCreated);
  68. HRESULT hr = S_OK;
  69. ASSERT(ms_pSDKWnd);
  70. ASSERT(pMgr);
  71. pMgr->AddRef();
  72. if(pInternalNmConference)
  73. {
  74. pInternalNmConference->AddRef();
  75. }
  76. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_CREATED, reinterpret_cast<WPARAM>(pMgr), reinterpret_cast<LPARAM>(pInternalNmConference));
  77. DBGEXIT_HR(CSDKWindow::PostConferenceCreated,hr);
  78. return hr;
  79. }
  80. //static
  81. HRESULT CSDKWindow::PostCallCreated(CNmManagerObj* pMgr, INmCall* pInternalNmCall)
  82. {
  83. DBGENTRY(CSDKWindow::PostCallCreated);
  84. HRESULT hr = S_OK;
  85. ASSERT(ms_pSDKWnd);
  86. ASSERT(pMgr);
  87. pMgr->AddRef();
  88. if(pInternalNmCall)
  89. {
  90. pInternalNmCall->AddRef();
  91. }
  92. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CALL_CREATED, reinterpret_cast<WPARAM>(pMgr), reinterpret_cast<LPARAM>(pInternalNmCall));
  93. DBGEXIT_HR(CSDKWindow::PostCallCreated,hr);
  94. return hr;
  95. }
  96. //static
  97. HRESULT CSDKWindow::PostManagerNmUI(CNmManagerObj* pMgr, CONFN uNotify)
  98. {
  99. DBGENTRY(CSDKWindow::PostManagerNmUI);
  100. HRESULT hr = S_OK;
  101. ASSERT(ms_pSDKWnd);
  102. ASSERT(pMgr);
  103. pMgr->AddRef();
  104. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_MANAGER_NMUI, reinterpret_cast<WPARAM>(pMgr), uNotify);
  105. DBGEXIT_HR(CSDKWindow::PostManagerNmUI,hr);
  106. return hr;
  107. }
  108. /////////////////////////////////////////////////////////////////////////////////
  109. // INmConferenceNotify Posting functions
  110. /////////////////////////////////////////////////////////////////////////////////
  111. HRESULT CSDKWindow::PostConferenceNmUI(CNmConferenceObj* pConf, CONFN uNotify)
  112. {
  113. DBGENTRY(CSDKWindow::PostConferenceNmUI);
  114. HRESULT hr = S_OK;
  115. ASSERT(ms_pSDKWnd);
  116. ASSERT(pConf);
  117. pConf->AddRef();
  118. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_NMUI, reinterpret_cast<WPARAM>(pConf), uNotify);
  119. DBGEXIT_HR(CSDKWindow::PostConferenceNmUI,hr);
  120. return hr;
  121. }
  122. //static
  123. HRESULT CSDKWindow::PostConferenceStateChanged(CNmConferenceObj* pConference, NM_CONFERENCE_STATE uState)
  124. {
  125. DBGENTRY(CSDKWindow::PostConferenceStateChanged);
  126. HRESULT hr = S_OK;
  127. ASSERT(ms_pSDKWnd);
  128. ASSERT(pConference);
  129. pConference->AddRef();
  130. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_STATE_CHANGED, reinterpret_cast<WPARAM>(pConference), uState);
  131. DBGEXIT_HR(CSDKWindow::PostConferenceStateChanged,hr);
  132. return hr;
  133. }
  134. //static
  135. HRESULT CSDKWindow::PostConferenceMemberChanged(CNmConferenceObj* pConf, NM_MEMBER_NOTIFY uNotify, INmMember *pMember)
  136. {
  137. DBGENTRY(CSDKWindow::PostConferenceMemberChanged);
  138. HRESULT hr = S_OK;
  139. ASSERT(ms_pSDKWnd);
  140. ASSERT(pConf);
  141. pConf->AddRef();
  142. if(pMember)
  143. {
  144. pMember->AddRef();
  145. }
  146. ConferenceMemberChanged *pParams = new ConferenceMemberChanged;
  147. pParams->uNotify = uNotify;
  148. pParams->pMember = pMember;
  149. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_MEMBER_CHANGED, reinterpret_cast<WPARAM>(pConf), reinterpret_cast<LPARAM>(pParams));
  150. DBGEXIT_HR(CSDKWindow::PostConferenceMemberChanged,hr);
  151. return hr;
  152. }
  153. //static
  154. HRESULT CSDKWindow::PostConferenceChannelChanged(CNmConferenceObj* pConf, NM_CHANNEL_NOTIFY uNotify, INmChannel *pChannel)
  155. {
  156. DBGENTRY(CSDKWindow::PostConferenceChannelChanged);
  157. HRESULT hr = S_OK;
  158. ASSERT(ms_pSDKWnd);
  159. ASSERT(pConf);
  160. pConf->AddRef();
  161. if(pChannel)
  162. {
  163. pChannel->AddRef();
  164. }
  165. ConferenceChannelChanged *pParams = new ConferenceChannelChanged;
  166. pParams->uNotify = uNotify;
  167. pParams->pChannel = pChannel;
  168. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_CHANNEL_CHANGED, reinterpret_cast<WPARAM>(pConf), reinterpret_cast<LPARAM>(pParams));
  169. DBGEXIT_HR(CSDKWindow::PostConferenceChannelChanged,hr);
  170. return hr;
  171. }
  172. //static
  173. HRESULT CSDKWindow::PostStateChanged(CNmChannelAppShareObj* pAppShareChan, NM_SHAPP_STATE uNotify, INmSharableApp *pApp)
  174. {
  175. HRESULT hr = S_OK;
  176. ASSERT(ms_pSDKWnd);
  177. ASSERT(pAppShareChan);
  178. ASSERT(pApp);
  179. pAppShareChan->AddRef();
  180. pApp->AddRef();
  181. StateChanged* pParams = new StateChanged;
  182. pParams->uNotify = uNotify;
  183. pParams->pApp = pApp;
  184. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_STATE_CHANGED, reinterpret_cast<WPARAM>(pAppShareChan), reinterpret_cast<LPARAM>(pParams));
  185. return hr;
  186. }
  187. /////////////////////////////////////////////////////////////////////////////////
  188. // INmCallNotify Posting functions
  189. /////////////////////////////////////////////////////////////////////////////////
  190. //static
  191. HRESULT CSDKWindow::PostCallStateChanged(CNmCallObj* pCall, NM_CALL_STATE uState)
  192. {
  193. DBGENTRY(CSDKWindow::PostCallStateChanged);
  194. HRESULT hr = S_OK;
  195. ASSERT(ms_pSDKWnd);
  196. ASSERT(pCall);
  197. pCall->AddRef();
  198. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CALL_STATE_CHANGED, reinterpret_cast<WPARAM>(pCall), uState);
  199. DBGEXIT_HR(CSDKWindow::PostCallStateChanged,hr);
  200. return hr;
  201. }
  202. //static
  203. HRESULT CSDKWindow::PostCallNmUi(CNmCallObj* pCall, CONFN uNotify)
  204. {
  205. DBGENTRY(CSDKWindow::PostCallNmUi);
  206. HRESULT hr = S_OK;
  207. ASSERT(ms_pSDKWnd);
  208. ASSERT(pCall);
  209. pCall->AddRef();
  210. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_NMUI, reinterpret_cast<WPARAM>(pCall), uNotify);
  211. DBGEXIT_HR(CSDKWindow::PostCallNmUi,hr);
  212. return hr;
  213. }
  214. //static
  215. HRESULT CSDKWindow::PostFailed(CNmCallObj* pCall, ULONG uError)
  216. {
  217. DBGENTRY(CSDKWindow::PostFailed);
  218. HRESULT hr = S_OK;
  219. ASSERT(ms_pSDKWnd);
  220. ASSERT(pCall);
  221. pCall->AddRef();
  222. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_FAILED, reinterpret_cast<WPARAM>(pCall), uError);
  223. DBGEXIT_HR(CSDKWindow::PostFailed,hr);
  224. return hr;
  225. }
  226. //static
  227. HRESULT CSDKWindow::PostAccepted(CNmCallObj* pCall, INmConference* pConference)
  228. {
  229. DBGENTRY(CSDKWindow::PostAccepted);
  230. HRESULT hr = S_OK;
  231. ASSERT(ms_pSDKWnd);
  232. ASSERT(pCall);
  233. pCall->AddRef();
  234. if(pConference)
  235. {
  236. pConference->AddRef();
  237. }
  238. ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_ACCEPTED, reinterpret_cast<WPARAM>(pCall), reinterpret_cast<LPARAM>(pConference));
  239. DBGEXIT_HR(CSDKWindow::PostAccepted,hr);
  240. return hr;
  241. }
  242. /////////////////////////////////////////////////////////////////////////////////
  243. // INmManagerNotify message handling functions
  244. /////////////////////////////////////////////////////////////////////////////////
  245. LRESULT CSDKWindow::_OnMsgConferenceCreated(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  246. {
  247. DBGENTRY(CSDKWindow::_OnMsgConferenceCreated);
  248. CNmManagerObj* pMgr = reinterpret_cast<CNmManagerObj*>(wParam);
  249. INmConference* pInternalConf = reinterpret_cast<INmConference*>(lParam);
  250. pMgr->Fire_ConferenceCreated(pInternalConf);
  251. pMgr->Release();
  252. if(pInternalConf)
  253. {
  254. pInternalConf->Release();
  255. }
  256. DBGEXIT(CSDKWindow::_OnMsgConferenceCreated);
  257. return 0;
  258. }
  259. LRESULT CSDKWindow::_OnMsgManagerNmUI(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  260. {
  261. DBGENTRY(CSDKWindow::_OnMsgManagerNmUI);
  262. CNmManagerObj* pMgr = reinterpret_cast<CNmManagerObj*>(wParam);
  263. CONFN uNotify = static_cast<CONFN>(lParam);
  264. pMgr->Fire_NmUI(uNotify);
  265. pMgr->Release();
  266. DBGEXIT(CSDKWindow::_OnMsgManagerNmUI);
  267. return 0;
  268. }
  269. LRESULT CSDKWindow::_OnMsgCallCreated(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  270. {
  271. DBGENTRY(CSDKWindow::_OnMsgCallCreated);
  272. CNmManagerObj* pMgr = reinterpret_cast<CNmManagerObj*>(wParam);
  273. INmCall* pInternalCall = reinterpret_cast<INmCall*>(lParam);
  274. pMgr->Fire_CallCreated(pInternalCall);
  275. pMgr->Release();
  276. if(pInternalCall)
  277. {
  278. pInternalCall->Release();
  279. }
  280. DBGEXIT(CSDKWindow::_OnMsgCallCreated);
  281. return 0;
  282. }
  283. /////////////////////////////////////////////////////////////////////////////////
  284. // INmConferenceNotify message handling functions
  285. /////////////////////////////////////////////////////////////////////////////////
  286. LRESULT CSDKWindow::_OnMsgConferenceNmUI(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  287. {
  288. DBGENTRY(CSDKWindow::_OnMsgConferenceNmUI);
  289. CNmConferenceObj* pConf = reinterpret_cast<CNmConferenceObj*>(wParam);
  290. CONFN uNotify = static_cast<CONFN>(lParam);
  291. pConf->Fire_NmUI(uNotify);
  292. pConf->Release();
  293. DBGEXIT(CSDKWindow::_OnMsgConferenceNmUI);
  294. return 0;
  295. }
  296. LRESULT CSDKWindow::_OnMsgConferenceStateChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  297. {
  298. DBGENTRY(CSDKWindow::_OnMsgConferenceStateChanged);
  299. CNmConferenceObj* pConference = reinterpret_cast<CNmConferenceObj*>(wParam);
  300. NM_CONFERENCE_STATE uState = static_cast<NM_CONFERENCE_STATE>(lParam);
  301. pConference->Fire_StateChanged(uState);
  302. pConference->Release();
  303. DBGEXIT(CSDKWindow::_OnMsgConferenceStateChanged);
  304. return 0;
  305. }
  306. LRESULT CSDKWindow::_OnMsgConferenceMemberChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  307. {
  308. DBGENTRY(CSDKWindow::_OnMsgConferenceMemberChanged);
  309. CNmConferenceObj* pConf = reinterpret_cast<CNmConferenceObj*>(wParam);
  310. ConferenceMemberChanged* pParams = reinterpret_cast<ConferenceMemberChanged*>(lParam);
  311. pConf->Fire_MemberChanged(pParams->uNotify, pParams->pMember);
  312. pConf->Release();
  313. if(pParams->pMember)
  314. {
  315. pParams->pMember->Release();
  316. }
  317. delete pParams;
  318. DBGEXIT(CSDKWindow::_OnMsgConferenceMemberChanged);
  319. return 0;
  320. }
  321. LRESULT CSDKWindow::_OnMsgConferenceChannelChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  322. {
  323. DBGENTRY(CSDKWindow::_OnMsgConferenceChannelChanged);
  324. CNmConferenceObj* pConf = reinterpret_cast<CNmConferenceObj*>(wParam);
  325. ConferenceChannelChanged* pParams = reinterpret_cast<ConferenceChannelChanged*>(lParam);
  326. pConf->Fire_ChannelChanged(pParams->uNotify, pParams->pChannel);
  327. pConf->Release();
  328. if(pParams->pChannel)
  329. {
  330. pParams->pChannel->Release();
  331. }
  332. delete pParams;
  333. DBGEXIT(CSDKWindow::_OnMsgConferenceChannelChanged);
  334. return 0;
  335. }
  336. LRESULT CSDKWindow::_OnStateChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandlede)
  337. {
  338. CNmChannelAppShareObj* pAppShareChan = reinterpret_cast<CNmChannelAppShareObj*>(wParam);
  339. StateChanged* pParams = reinterpret_cast<StateChanged*>(lParam);
  340. pAppShareChan->Fire_StateChanged(pParams->uNotify, pParams->pApp);
  341. pAppShareChan->Release();
  342. pParams->pApp->Release();
  343. delete pParams;
  344. return 0;
  345. }
  346. /////////////////////////////////////////////////////////////////////////////////
  347. // INmCallNotify message handling functions
  348. /////////////////////////////////////////////////////////////////////////////////
  349. LRESULT CSDKWindow::_OnMsgCallStateChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  350. {
  351. DBGENTRY(CSDKWindow::_OnMsgCallStateChanged);
  352. CNmCallObj* pCall = reinterpret_cast<CNmCallObj*>(wParam);
  353. NM_CALL_STATE uState = static_cast<NM_CALL_STATE>(lParam);
  354. pCall->Fire_StateChanged(uState);
  355. pCall->Release();
  356. DBGEXIT(CSDKWindow::_OnMsgCallStateChanged);
  357. return 0;
  358. }
  359. LRESULT CSDKWindow::_OnMsgCallNmUI(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  360. {
  361. DBGENTRY(CSDKWindow::_OnCallMsgNmUI);
  362. CNmCallObj* pCall = reinterpret_cast<CNmCallObj*>(wParam);
  363. CONFN uNotify = static_cast<CONFN>(lParam);
  364. pCall->Fire_NmUI(uNotify);
  365. pCall->Release();
  366. DBGEXIT(CSDKWindow::_OnMsgCallNmUI);
  367. return 0;
  368. }
  369. LRESULT CSDKWindow::_OnMsgFailed(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  370. {
  371. DBGENTRY(CSDKWindow::_OnMsgFailed);
  372. CNmCallObj* pCall = reinterpret_cast<CNmCallObj*>(wParam);
  373. ULONG uError = (ULONG)lParam;
  374. pCall->Fire_Failed(uError);
  375. pCall->Release();
  376. DBGEXIT(CSDKWindow::_OnMsgFailed);
  377. return 0;
  378. }
  379. LRESULT CSDKWindow::_OnMsgAccepted(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  380. {
  381. DBGENTRY(CSDKWindow::_OnMsgAccepted);
  382. CNmCallObj* pCall = reinterpret_cast<CNmCallObj*>(wParam);
  383. INmConference* pConf = reinterpret_cast<INmConference*>(lParam);
  384. pCall->Fire_Accepted(pConf);
  385. pCall->Release();
  386. if(pConf)
  387. {
  388. pConf->Release();
  389. }
  390. DBGEXIT(CSDKWindow::_OnMsgAccepted);
  391. return 0;
  392. }
  393. LRESULT CSDKWindow::_OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  394. {
  395. if(DELAY_UNLOAD_TIMER == wParam)
  396. {
  397. if(ms_NumUnlocks)
  398. {
  399. --ms_NumUnlocks;
  400. _Module.Unlock();
  401. }
  402. if(!ms_NumUnlocks)
  403. {
  404. KillTimer(DELAY_UNLOAD_TIMER);
  405. }
  406. }
  407. return 0;
  408. }