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.

292 lines
6.9 KiB

  1. //
  2. // evsink.cpp: event sink class
  3. //
  4. #include "stdafx.h"
  5. #define TRC_GROUP TRC_GROUP_UI
  6. #define TRC_FILE "evsink"
  7. #include <atrcapi.h>
  8. #include "evsink.h"
  9. #include "contwnd.h"
  10. CEventSink::CEventSink(CContainerWnd* pContainerWnd) :
  11. _pContainerWnd(pContainerWnd)
  12. {
  13. _cRef = 0;
  14. }
  15. CEventSink::~CEventSink()
  16. {
  17. }
  18. STDMETHODIMP CEventSink::QueryInterface( REFIID riid, void ** ppv )
  19. {
  20. DC_BEGIN_FN("QueryInterface");
  21. TRC_ASSERT(ppv,(TB,_T("ppv is null")));
  22. *ppv = NULL;
  23. if (IID_IUnknown == riid || IID_IDispatch == riid || DIID_IMsTscAxEvents == riid)
  24. *ppv = this;
  25. if (NULL != *ppv)
  26. {
  27. ((LPUNKNOWN)*ppv)->AddRef();
  28. return NOERROR;
  29. }
  30. DC_END_FN();
  31. return ResultFromScode(E_NOINTERFACE);
  32. }
  33. STDMETHODIMP_(ULONG) CEventSink::AddRef(void)
  34. {
  35. return InterlockedIncrement(&_cRef);
  36. }
  37. STDMETHODIMP_(ULONG) CEventSink::Release(void)
  38. {
  39. if (0L != InterlockedDecrement(&_cRef))
  40. return _cRef;
  41. delete this;
  42. return 0L;
  43. }
  44. STDMETHODIMP CEventSink::GetTypeInfoCount(UINT *pctInfo)
  45. {
  46. *pctInfo = 0;
  47. return NOERROR;
  48. }
  49. STDMETHODIMP CEventSink::GetTypeInfo(UINT itInfo, LCID lcid, ITypeInfo **ppTypeInfo)
  50. {
  51. DC_BEGIN_FN("GetTypeInfo");
  52. TRC_ABORT((TB,_T("GetTypeInfo should not get called")));
  53. *ppTypeInfo = NULL;
  54. DC_END_FN();
  55. return E_NOTIMPL;
  56. }
  57. STDMETHODIMP CEventSink::GetIDsOfNames(REFIID riid, OLECHAR **rgwzNames,
  58. UINT cNames, LCID lcid, DISPID *rgDispID)
  59. {
  60. DC_BEGIN_FN("GetIDsOfNames");
  61. TRC_ABORT((TB,_T("GetIDsOfNames should not get called")));
  62. DC_END_FN();
  63. return E_NOTIMPL;
  64. }
  65. STDMETHODIMP CEventSink::Invoke(DISPID dispidMember, REFIID riid,
  66. LCID lcid, WORD /*wFlags*/,
  67. DISPPARAMS* pdispparams, VARIANT* pvarResult,
  68. EXCEPINFO* /*pexcepinfo*/, UINT* /*puArgErr*/)
  69. {
  70. HRESULT hr = E_NOTIMPL;
  71. switch (dispidMember)
  72. {
  73. case DISPID_CONNECTED:
  74. hr = OnConnected();
  75. break;
  76. case DISPID_DISCONNECTED:
  77. hr = OnDisconnected(pdispparams->rgvarg->lVal);
  78. break;
  79. case DISPID_LOGINCOMPLETE:
  80. hr = OnLoginComplete();
  81. break;
  82. case DISPID_REQUESTGOFULLSCREEN:
  83. hr = OnRequestEnterFullScreen();
  84. break;
  85. case DISPID_REQUESTLEAVEFULLSCREEN:
  86. hr = OnRequestLeaveFullScreen();
  87. break;
  88. case DISPID_FATALERROR:
  89. hr = OnFatalError(pdispparams->rgvarg->lVal);
  90. break;
  91. case DISPID_WARNING:
  92. hr = OnWarning(pdispparams->rgvarg->lVal);
  93. break;
  94. case DISPID_REMOTEDESKTOPSIZECHANGE:
  95. hr = OnRemoteDesktopSizeChange(pdispparams->rgvarg[1].lVal,
  96. pdispparams->rgvarg[0].lVal);
  97. break;
  98. case DISPID_REQUESTCONTAINERMINIMIZE:
  99. hr = OnRequestContainerMinimize();
  100. break;
  101. case DISPID_CONFIRMCLOSE:
  102. hr = OnConfirmClose( pdispparams->rgvarg[0].pboolVal );
  103. break;
  104. }
  105. return hr;
  106. }
  107. HRESULT __stdcall CEventSink::OnConnected()
  108. {
  109. DC_BEGIN_FN("OnConnected");
  110. TRC_NRM((TB,_T("CEventSink::OnConnected\n")));
  111. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  112. if (_pContainerWnd)
  113. {
  114. _pContainerWnd->OnConnected();
  115. }
  116. DC_END_FN();
  117. return S_OK;
  118. }
  119. HRESULT __stdcall CEventSink::OnLoginComplete()
  120. {
  121. DC_BEGIN_FN("OnConnected");
  122. TRC_NRM((TB,_T("CEventSink::OnConnected\n")));
  123. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  124. if (_pContainerWnd)
  125. {
  126. _pContainerWnd->OnLoginComplete();
  127. }
  128. DC_END_FN();
  129. return S_OK;
  130. }
  131. HRESULT __stdcall CEventSink::OnDisconnected(long disconReason)
  132. {
  133. DC_BEGIN_FN("OnDisonnected");
  134. TRC_NRM((TB,_T("CEventSink::OnDisonnected\n")));
  135. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  136. if (_pContainerWnd)
  137. {
  138. _pContainerWnd->OnDisconnected(disconReason);
  139. }
  140. DC_END_FN();
  141. return S_OK;
  142. }
  143. HRESULT __stdcall CEventSink::OnRequestEnterFullScreen()
  144. {
  145. DC_BEGIN_FN("OnEnterFullScreen");
  146. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  147. if (_pContainerWnd)
  148. {
  149. _pContainerWnd->OnEnterFullScreen();
  150. }
  151. DC_END_FN();
  152. return S_OK;
  153. }
  154. HRESULT __stdcall CEventSink::OnRequestLeaveFullScreen()
  155. {
  156. DC_BEGIN_FN("OnLeaveFullScreen");
  157. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  158. if (_pContainerWnd)
  159. {
  160. _pContainerWnd->OnLeaveFullScreen();
  161. }
  162. DC_END_FN();
  163. return S_OK;
  164. }
  165. HRESULT __stdcall CEventSink::OnFatalError(long errorCode)
  166. {
  167. DC_BEGIN_FN("OnFatalError");
  168. TRC_NRM((TB,_T("CEventSink::OnFatalError\n")));
  169. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  170. if (_pContainerWnd)
  171. {
  172. _pContainerWnd->OnFatalError(errorCode);
  173. }
  174. DC_END_FN();
  175. return S_OK;
  176. }
  177. HRESULT __stdcall CEventSink::OnWarning(long warnCode)
  178. {
  179. DC_BEGIN_FN("OnFatalError");
  180. TRC_NRM((TB,_T("CEventSink::OnFatalError\n")));
  181. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  182. if (_pContainerWnd)
  183. {
  184. _pContainerWnd->OnWarning(warnCode);
  185. }
  186. DC_END_FN();
  187. return S_OK;
  188. }
  189. HRESULT __stdcall CEventSink::OnRemoteDesktopSizeChange(long width, long height)
  190. {
  191. DC_BEGIN_FN("OnFatalError");
  192. TRC_NRM((TB,_T("CEventSink::OnFatalError\n")));
  193. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  194. if (_pContainerWnd)
  195. {
  196. _pContainerWnd->OnRemoteDesktopSizeNotify(width,height);
  197. }
  198. DC_END_FN();
  199. return S_OK;
  200. }
  201. //
  202. // Just minimize the container window
  203. //
  204. HRESULT __stdcall CEventSink::OnRequestContainerMinimize()
  205. {
  206. DC_BEGIN_FN("OnRequestContainerMinimize");
  207. TRC_NRM((TB,_T("CEventSink::OnFatalError\n")));
  208. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  209. if (_pContainerWnd)
  210. {
  211. _pContainerWnd->OnRequestMinimize();
  212. }
  213. DC_END_FN();
  214. return S_OK;
  215. }
  216. HRESULT __stdcall CEventSink::OnConfirmClose(VARIANT_BOOL* pvbConfirmClose)
  217. {
  218. BOOL fConfirmClose;
  219. HRESULT hr = E_FAIL;
  220. DC_BEGIN_FN("OnConfirmClose");
  221. TRC_NRM((TB,_T("CEventSink::OnConfirmClose\n")));
  222. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  223. if(pvbConfirmClose)
  224. {
  225. if (_pContainerWnd)
  226. {
  227. hr = _pContainerWnd->OnConfirmClose( &fConfirmClose );
  228. if (SUCCEEDED(hr))
  229. {
  230. *pvbConfirmClose = fConfirmClose ? VARIANT_TRUE :
  231. VARIANT_FALSE;
  232. }
  233. }
  234. }
  235. else
  236. {
  237. return E_INVALIDARG;
  238. }
  239. DC_END_FN();
  240. return hr;
  241. }