#include "precomp.h" // Net Meeting SDK includes #include "NmManager.h" #include "NmConference.h" #include "NmCall.h" #include "NmSharableApp.h" #include "NmChannelAppShare.h" #include "SDKWindow.h" CSDKWindow* CSDKWindow::ms_pSDKWnd = NULL; int CSDKWindow::ms_NumUnlocks = 0; ///////////////////////////////////////////////////////////////////////////////// // Construction / destruction / initialization ///////////////////////////////////////////////////////////////////////////////// //static HRESULT CSDKWindow::InitSDK() { DBGENTRY(CSDKWindow::InitSDK); HRESULT hr = S_OK; ASSERT(NULL == ms_pSDKWnd); ms_pSDKWnd = new CSDKWindow(); if(ms_pSDKWnd) { // Create the window RECT rc; ms_pSDKWnd->Create(NULL, rc, NULL, WS_POPUP); if(!ms_pSDKWnd->IsWindow()) { hr = HRESULT_FROM_WIN32(GetLastError()); } } else { hr = E_OUTOFMEMORY; } DBGEXIT_HR(CSDKWindow::InitSDK,hr); return hr; } //static void CSDKWindow::CleanupSDK() { if(ms_pSDKWnd && ms_pSDKWnd->IsWindow()) { ms_pSDKWnd->DestroyWindow(); } delete ms_pSDKWnd; } //static HRESULT CSDKWindow::PostDelayModuleUnlock() { if(ms_pSDKWnd) { if(!ms_pSDKWnd->SetTimer(DELAY_UNLOAD_TIMER, DELAY_UNLOAD_INTERVAL)) { return HRESULT_FROM_WIN32(GetLastError()); } ++ms_NumUnlocks; return S_OK; } return E_FAIL; } ///////////////////////////////////////////////////////////////////////////////// // INmManagerNotify Posting functions ///////////////////////////////////////////////////////////////////////////////// //static HRESULT CSDKWindow::PostConferenceCreated(CNmManagerObj* pMgr, INmConference* pInternalNmConference) { DBGENTRY(CSDKWindow::PostConferenceCreated); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pMgr); pMgr->AddRef(); if(pInternalNmConference) { pInternalNmConference->AddRef(); } ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_CREATED, reinterpret_cast(pMgr), reinterpret_cast(pInternalNmConference)); DBGEXIT_HR(CSDKWindow::PostConferenceCreated,hr); return hr; } //static HRESULT CSDKWindow::PostCallCreated(CNmManagerObj* pMgr, INmCall* pInternalNmCall) { DBGENTRY(CSDKWindow::PostCallCreated); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pMgr); pMgr->AddRef(); if(pInternalNmCall) { pInternalNmCall->AddRef(); } ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CALL_CREATED, reinterpret_cast(pMgr), reinterpret_cast(pInternalNmCall)); DBGEXIT_HR(CSDKWindow::PostCallCreated,hr); return hr; } //static HRESULT CSDKWindow::PostManagerNmUI(CNmManagerObj* pMgr, CONFN uNotify) { DBGENTRY(CSDKWindow::PostManagerNmUI); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pMgr); pMgr->AddRef(); ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_MANAGER_NMUI, reinterpret_cast(pMgr), uNotify); DBGEXIT_HR(CSDKWindow::PostManagerNmUI,hr); return hr; } ///////////////////////////////////////////////////////////////////////////////// // INmConferenceNotify Posting functions ///////////////////////////////////////////////////////////////////////////////// HRESULT CSDKWindow::PostConferenceNmUI(CNmConferenceObj* pConf, CONFN uNotify) { DBGENTRY(CSDKWindow::PostConferenceNmUI); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pConf); pConf->AddRef(); ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_NMUI, reinterpret_cast(pConf), uNotify); DBGEXIT_HR(CSDKWindow::PostConferenceNmUI,hr); return hr; } //static HRESULT CSDKWindow::PostConferenceStateChanged(CNmConferenceObj* pConference, NM_CONFERENCE_STATE uState) { DBGENTRY(CSDKWindow::PostConferenceStateChanged); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pConference); pConference->AddRef(); ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_STATE_CHANGED, reinterpret_cast(pConference), uState); DBGEXIT_HR(CSDKWindow::PostConferenceStateChanged,hr); return hr; } //static HRESULT CSDKWindow::PostConferenceMemberChanged(CNmConferenceObj* pConf, NM_MEMBER_NOTIFY uNotify, INmMember *pMember) { DBGENTRY(CSDKWindow::PostConferenceMemberChanged); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pConf); pConf->AddRef(); if(pMember) { pMember->AddRef(); } ConferenceMemberChanged *pParams = new ConferenceMemberChanged; pParams->uNotify = uNotify; pParams->pMember = pMember; ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_MEMBER_CHANGED, reinterpret_cast(pConf), reinterpret_cast(pParams)); DBGEXIT_HR(CSDKWindow::PostConferenceMemberChanged,hr); return hr; } //static HRESULT CSDKWindow::PostConferenceChannelChanged(CNmConferenceObj* pConf, NM_CHANNEL_NOTIFY uNotify, INmChannel *pChannel) { DBGENTRY(CSDKWindow::PostConferenceChannelChanged); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pConf); pConf->AddRef(); if(pChannel) { pChannel->AddRef(); } ConferenceChannelChanged *pParams = new ConferenceChannelChanged; pParams->uNotify = uNotify; pParams->pChannel = pChannel; ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CONFERENCE_CHANNEL_CHANGED, reinterpret_cast(pConf), reinterpret_cast(pParams)); DBGEXIT_HR(CSDKWindow::PostConferenceChannelChanged,hr); return hr; } //static HRESULT CSDKWindow::PostStateChanged(CNmChannelAppShareObj* pAppShareChan, NM_SHAPP_STATE uNotify, INmSharableApp *pApp) { HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pAppShareChan); ASSERT(pApp); pAppShareChan->AddRef(); pApp->AddRef(); StateChanged* pParams = new StateChanged; pParams->uNotify = uNotify; pParams->pApp = pApp; ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_STATE_CHANGED, reinterpret_cast(pAppShareChan), reinterpret_cast(pParams)); return hr; } ///////////////////////////////////////////////////////////////////////////////// // INmCallNotify Posting functions ///////////////////////////////////////////////////////////////////////////////// //static HRESULT CSDKWindow::PostCallStateChanged(CNmCallObj* pCall, NM_CALL_STATE uState) { DBGENTRY(CSDKWindow::PostCallStateChanged); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pCall); pCall->AddRef(); ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_CALL_STATE_CHANGED, reinterpret_cast(pCall), uState); DBGEXIT_HR(CSDKWindow::PostCallStateChanged,hr); return hr; } //static HRESULT CSDKWindow::PostCallNmUi(CNmCallObj* pCall, CONFN uNotify) { DBGENTRY(CSDKWindow::PostCallNmUi); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pCall); pCall->AddRef(); ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_NMUI, reinterpret_cast(pCall), uNotify); DBGEXIT_HR(CSDKWindow::PostCallNmUi,hr); return hr; } //static HRESULT CSDKWindow::PostFailed(CNmCallObj* pCall, ULONG uError) { DBGENTRY(CSDKWindow::PostFailed); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pCall); pCall->AddRef(); ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_FAILED, reinterpret_cast(pCall), uError); DBGEXIT_HR(CSDKWindow::PostFailed,hr); return hr; } //static HRESULT CSDKWindow::PostAccepted(CNmCallObj* pCall, INmConference* pConference) { DBGENTRY(CSDKWindow::PostAccepted); HRESULT hr = S_OK; ASSERT(ms_pSDKWnd); ASSERT(pCall); pCall->AddRef(); if(pConference) { pConference->AddRef(); } ms_pSDKWnd->PostMessage(WM_APP_NOTIFY_ACCEPTED, reinterpret_cast(pCall), reinterpret_cast(pConference)); DBGEXIT_HR(CSDKWindow::PostAccepted,hr); return hr; } ///////////////////////////////////////////////////////////////////////////////// // INmManagerNotify message handling functions ///////////////////////////////////////////////////////////////////////////////// LRESULT CSDKWindow::_OnMsgConferenceCreated(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgConferenceCreated); CNmManagerObj* pMgr = reinterpret_cast(wParam); INmConference* pInternalConf = reinterpret_cast(lParam); pMgr->Fire_ConferenceCreated(pInternalConf); pMgr->Release(); if(pInternalConf) { pInternalConf->Release(); } DBGEXIT(CSDKWindow::_OnMsgConferenceCreated); return 0; } LRESULT CSDKWindow::_OnMsgManagerNmUI(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgManagerNmUI); CNmManagerObj* pMgr = reinterpret_cast(wParam); CONFN uNotify = static_cast(lParam); pMgr->Fire_NmUI(uNotify); pMgr->Release(); DBGEXIT(CSDKWindow::_OnMsgManagerNmUI); return 0; } LRESULT CSDKWindow::_OnMsgCallCreated(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgCallCreated); CNmManagerObj* pMgr = reinterpret_cast(wParam); INmCall* pInternalCall = reinterpret_cast(lParam); pMgr->Fire_CallCreated(pInternalCall); pMgr->Release(); if(pInternalCall) { pInternalCall->Release(); } DBGEXIT(CSDKWindow::_OnMsgCallCreated); return 0; } ///////////////////////////////////////////////////////////////////////////////// // INmConferenceNotify message handling functions ///////////////////////////////////////////////////////////////////////////////// LRESULT CSDKWindow::_OnMsgConferenceNmUI(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgConferenceNmUI); CNmConferenceObj* pConf = reinterpret_cast(wParam); CONFN uNotify = static_cast(lParam); pConf->Fire_NmUI(uNotify); pConf->Release(); DBGEXIT(CSDKWindow::_OnMsgConferenceNmUI); return 0; } LRESULT CSDKWindow::_OnMsgConferenceStateChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgConferenceStateChanged); CNmConferenceObj* pConference = reinterpret_cast(wParam); NM_CONFERENCE_STATE uState = static_cast(lParam); pConference->Fire_StateChanged(uState); pConference->Release(); DBGEXIT(CSDKWindow::_OnMsgConferenceStateChanged); return 0; } LRESULT CSDKWindow::_OnMsgConferenceMemberChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgConferenceMemberChanged); CNmConferenceObj* pConf = reinterpret_cast(wParam); ConferenceMemberChanged* pParams = reinterpret_cast(lParam); pConf->Fire_MemberChanged(pParams->uNotify, pParams->pMember); pConf->Release(); if(pParams->pMember) { pParams->pMember->Release(); } delete pParams; DBGEXIT(CSDKWindow::_OnMsgConferenceMemberChanged); return 0; } LRESULT CSDKWindow::_OnMsgConferenceChannelChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgConferenceChannelChanged); CNmConferenceObj* pConf = reinterpret_cast(wParam); ConferenceChannelChanged* pParams = reinterpret_cast(lParam); pConf->Fire_ChannelChanged(pParams->uNotify, pParams->pChannel); pConf->Release(); if(pParams->pChannel) { pParams->pChannel->Release(); } delete pParams; DBGEXIT(CSDKWindow::_OnMsgConferenceChannelChanged); return 0; } LRESULT CSDKWindow::_OnStateChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandlede) { CNmChannelAppShareObj* pAppShareChan = reinterpret_cast(wParam); StateChanged* pParams = reinterpret_cast(lParam); pAppShareChan->Fire_StateChanged(pParams->uNotify, pParams->pApp); pAppShareChan->Release(); pParams->pApp->Release(); delete pParams; return 0; } ///////////////////////////////////////////////////////////////////////////////// // INmCallNotify message handling functions ///////////////////////////////////////////////////////////////////////////////// LRESULT CSDKWindow::_OnMsgCallStateChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgCallStateChanged); CNmCallObj* pCall = reinterpret_cast(wParam); NM_CALL_STATE uState = static_cast(lParam); pCall->Fire_StateChanged(uState); pCall->Release(); DBGEXIT(CSDKWindow::_OnMsgCallStateChanged); return 0; } LRESULT CSDKWindow::_OnMsgCallNmUI(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnCallMsgNmUI); CNmCallObj* pCall = reinterpret_cast(wParam); CONFN uNotify = static_cast(lParam); pCall->Fire_NmUI(uNotify); pCall->Release(); DBGEXIT(CSDKWindow::_OnMsgCallNmUI); return 0; } LRESULT CSDKWindow::_OnMsgFailed(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgFailed); CNmCallObj* pCall = reinterpret_cast(wParam); ULONG uError = (ULONG)lParam; pCall->Fire_Failed(uError); pCall->Release(); DBGEXIT(CSDKWindow::_OnMsgFailed); return 0; } LRESULT CSDKWindow::_OnMsgAccepted(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { DBGENTRY(CSDKWindow::_OnMsgAccepted); CNmCallObj* pCall = reinterpret_cast(wParam); INmConference* pConf = reinterpret_cast(lParam); pCall->Fire_Accepted(pConf); pCall->Release(); if(pConf) { pConf->Release(); } DBGEXIT(CSDKWindow::_OnMsgAccepted); return 0; } LRESULT CSDKWindow::_OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if(DELAY_UNLOAD_TIMER == wParam) { if(ms_NumUnlocks) { --ms_NumUnlocks; _Module.Unlock(); } if(!ms_NumUnlocks) { KillTimer(DELAY_UNLOAD_TIMER); } } return 0; }