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.

366 lines
9.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: msgflter.cxx
  7. //
  8. // Contents: class for intellignet modal loop uses in sychronous binding
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 8-21-96 JohannP (Johann Posch) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include <trans.h>
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Method: CModalLoop::CModalLoop
  21. //
  22. // Synopsis:
  23. //
  24. // Arguments: [phr] --
  25. //
  26. // Returns:
  27. //
  28. // History: 8-21-96 JohannP (Johann Posch) Created
  29. //
  30. // Notes:
  31. //
  32. //----------------------------------------------------------------------------
  33. CModalLoop::CModalLoop(HRESULT *phr)
  34. {
  35. DEBUG_ENTER((DBG_TRANS,
  36. None,
  37. "CModalLoop::CModalLoop",
  38. "this=%#x, %#x",
  39. this, phr
  40. ));
  41. UrlMkAssert((phr));
  42. // BUGBUG 3384: message filter is bogus. Disable for now.
  43. // *phr = CoRegisterMessageFilter(this, &_pMsgFlter);
  44. _pMsgFlter = NULL;
  45. *phr = 0x80000000;
  46. DEBUG_LEAVE(0);
  47. }
  48. //+---------------------------------------------------------------------------
  49. //
  50. // Method: CModalLoop::~CModalLoop
  51. //
  52. // Synopsis:
  53. //
  54. // Arguments: (none)
  55. //
  56. // Returns:
  57. //
  58. // History: 8-21-96 JohannP (Johann Posch) Created
  59. //
  60. // Notes:
  61. //
  62. //----------------------------------------------------------------------------
  63. CModalLoop::~CModalLoop()
  64. {
  65. DEBUG_ENTER((DBG_TRANS,
  66. None,
  67. "CModalLoop::~CModalLoop",
  68. "this=%#x",
  69. this
  70. ));
  71. IMessageFilter *pthis;
  72. if (_pMsgFlter)
  73. {
  74. HRESULT hr = CoRegisterMessageFilter(_pMsgFlter, &pthis);
  75. // we should get back our messagefilter we installed
  76. // in ctor
  77. TransAssert(( (hr == NOERROR) && (this == pthis) ));
  78. _pMsgFlter->Release();
  79. }
  80. DEBUG_LEAVE(0);
  81. }
  82. //+---------------------------------------------------------------------------
  83. //
  84. // Method: CModalLoop::QueryInterface
  85. //
  86. // Synopsis:
  87. //
  88. // Arguments: [riid] --
  89. // [ppv] --
  90. //
  91. // Returns:
  92. //
  93. // History: 8-21-96 JohannP (Johann Posch) Created
  94. //
  95. // Notes:
  96. //
  97. //----------------------------------------------------------------------------
  98. STDMETHODIMP CModalLoop::QueryInterface( REFIID riid, void **ppv )
  99. {
  100. DEBUG_ENTER((DBG_TRANS,
  101. Hresult,
  102. "CModalLoop::IUnknown::QueryInterface",
  103. "this=%#x, %#x, %#x",
  104. this, &riid, ppv
  105. ));
  106. HRESULT hr = NOERROR;
  107. UrlMkDebugOut((DEB_BINDING, "%p _IN CModalLoop::QueryInterface (%lx, %p)\n", this, riid, ppv));
  108. if ( IsEqualIID(riid, IID_IUnknown)
  109. || IsEqualIID(riid, IID_IMessageFilter) )
  110. {
  111. *ppv = (void FAR *)(IMessageFilter *)this;
  112. AddRef();
  113. }
  114. else
  115. {
  116. *ppv = NULL;
  117. hr = E_NOINTERFACE;
  118. }
  119. UrlMkDebugOut((DEB_BINDING, "%p OUT CModalLoop::QueryInterface (%lx)[%p]\n", this, hr, *ppv));
  120. DEBUG_LEAVE(hr);
  121. return hr;
  122. }
  123. //+---------------------------------------------------------------------------
  124. //
  125. // Method: CModalLoop::AddRef
  126. //
  127. // Synopsis:
  128. //
  129. // Arguments: [void] --
  130. //
  131. // Returns:
  132. //
  133. // History: 11-11-95 JohannP (Johann Posch) Created
  134. //
  135. // Notes:
  136. //
  137. //----------------------------------------------------------------------------
  138. STDMETHODIMP_(ULONG) CModalLoop::AddRef( void )
  139. {
  140. DEBUG_ENTER((DBG_TRANS,
  141. Dword,
  142. "CModalLoop::IUnknown::AddRef",
  143. "this=%#x",
  144. this
  145. ));
  146. UrlMkDebugOut((DEB_BINDING, "%p _IN CModalLoop::AddRef\n", this));
  147. LONG lRet = ++_CRefs;
  148. UrlMkDebugOut((DEB_BINDING, "%p OUT CModalLoop::AddRef (%ld)\n", this, lRet));
  149. DEBUG_LEAVE(lRet);
  150. return lRet;
  151. }
  152. //+---------------------------------------------------------------------------
  153. //
  154. // Method: CModalLoop::Release
  155. //
  156. // Synopsis:
  157. //
  158. // Arguments: [void] --
  159. //
  160. // Returns:
  161. //
  162. // History: 11-11-95 JohannP (Johann Posch) Created
  163. //
  164. // Notes:
  165. //
  166. //----------------------------------------------------------------------------
  167. STDMETHODIMP_(ULONG) CModalLoop::Release( void )
  168. {
  169. DEBUG_ENTER((DBG_TRANS,
  170. Dword,
  171. "CModalLoop::IUnknown::Release",
  172. "this=%#x",
  173. this
  174. ));
  175. UrlMkDebugOut((DEB_BINDING, "%p _IN CModalLoop::Release\n", this));
  176. LONG lRet = --_CRefs;
  177. if (_CRefs == 0)
  178. {
  179. delete this;
  180. }
  181. UrlMkDebugOut((DEB_BINDING, "%p OUT CModalLoop::Release (%ld)\n", this, lRet));
  182. DEBUG_LEAVE(lRet);
  183. return lRet;
  184. }
  185. //+---------------------------------------------------------------------------
  186. //
  187. // Function: HandleInComingCall
  188. //
  189. // Synopsis:
  190. //
  191. // Arguments: [DWORD] --
  192. //
  193. // Returns:
  194. //
  195. // History: 8-21-96 JohannP (Johann Posch) Created
  196. //
  197. // Notes:
  198. //
  199. //----------------------------------------------------------------------------
  200. STDMETHODIMP_(DWORD) CModalLoop::HandleInComingCall(DWORD dwCallType,HTASK htaskCaller,DWORD dwTickCount,LPINTERFACEINFO lpInterfaceInfo)
  201. {
  202. DEBUG_ENTER((DBG_TRANS,
  203. Dword,
  204. "CModalLoop::HandleInComingCall",
  205. "this=%#x, %#x, %#x, %#x, %#x",
  206. this, dwCallType, htaskCaller, dwTickCount, lpInterfaceInfo
  207. ));
  208. DWORD dwRet = 0;
  209. UrlMkDebugOut((DEB_BINDING, "%p _IN CModalLoop::HandleInComingCall \n", this));
  210. if (_pMsgFlter)
  211. {
  212. dwRet = _pMsgFlter->HandleInComingCall(dwCallType, htaskCaller, dwTickCount, lpInterfaceInfo);
  213. }
  214. UrlMkDebugOut((DEB_BINDING, "%p OUT CModalLoop::HandleInComingCall (dwRet:%lx)\n", this, dwRet));
  215. DEBUG_LEAVE(dwRet);
  216. return dwRet;
  217. }
  218. //+---------------------------------------------------------------------------
  219. //
  220. // Function: RetryRejectedCall
  221. //
  222. // Synopsis:
  223. //
  224. // Arguments: [DWORD] --
  225. //
  226. // Returns:
  227. //
  228. // History: 8-21-96 JohannP (Johann Posch) Created
  229. //
  230. // Notes:
  231. //
  232. //----------------------------------------------------------------------------
  233. STDMETHODIMP_(DWORD) CModalLoop::RetryRejectedCall(HTASK htaskCallee,DWORD dwTickCount,DWORD dwRejectType)
  234. {
  235. DEBUG_ENTER((DBG_TRANS,
  236. Dword,
  237. "CModalLoop::RetryRejectedCall",
  238. "this=%#x, %#x, %#x, %#x",
  239. this, htaskCallee, dwTickCount, dwRejectType
  240. ));
  241. DWORD dwRet = 0;
  242. UrlMkDebugOut((DEB_BINDING, "%p _IN CModalLoop::RetryRejectedCall \n", this));
  243. if (_pMsgFlter)
  244. {
  245. dwRet = _pMsgFlter->RetryRejectedCall( htaskCallee, dwTickCount, dwRejectType);
  246. }
  247. UrlMkDebugOut((DEB_BINDING, "%p OUT CModalLoop::RetryRejectedCall (dwRet:%lx)\n", this, dwRet));
  248. DEBUG_LEAVE(dwRet);
  249. return dwRet;
  250. }
  251. //+---------------------------------------------------------------------------
  252. //
  253. // Function: MessagePending
  254. //
  255. // Synopsis:
  256. //
  257. // Arguments: [DWORD] --
  258. //
  259. // Returns:
  260. //
  261. // History: 8-21-96 JohannP (Johann Posch) Created
  262. //
  263. // Notes:
  264. //
  265. //----------------------------------------------------------------------------
  266. STDMETHODIMP_(DWORD) CModalLoop::MessagePending(HTASK htaskCallee,DWORD dwTickCount,DWORD dwPendingType)
  267. {
  268. DEBUG_ENTER((DBG_TRANS,
  269. Dword,
  270. "CModalLoop::MessagePending",
  271. "this=%#x, %#x, %#x, %#x",
  272. this, htaskCallee, dwTickCount, dwPendingType
  273. ));
  274. DWORD dwRet = 0;
  275. UrlMkDebugOut((DEB_BINDING, "%p _IN CModalLoop::MessagePending \n", this));
  276. if (_pMsgFlter)
  277. {
  278. dwRet = _pMsgFlter->MessagePending( htaskCallee, dwTickCount, dwPendingType);
  279. }
  280. UrlMkDebugOut((DEB_BINDING, "%p OUT CModalLoop::MessagePending (dwRet:%lx)\n", this, dwRet));
  281. DEBUG_LEAVE(dwRet);
  282. return dwRet;
  283. }
  284. //+---------------------------------------------------------------------------
  285. //
  286. // Method: CModalLoop::HandlePendingMessage
  287. //
  288. // Synopsis:
  289. //
  290. // Arguments: [dwPendingType] --
  291. // [dwPendingRecursion] --
  292. // [dwReserved] --
  293. //
  294. // Returns:
  295. //
  296. // History: 8-21-96 JohannP (Johann Posch) Created
  297. //
  298. // Notes:
  299. //
  300. //----------------------------------------------------------------------------
  301. HRESULT CModalLoop::HandlePendingMessage(DWORD dwPendingType, DWORD dwPendingRecursion, DWORD dwReserved)
  302. {
  303. DEBUG_ENTER((DBG_TRANS,
  304. Dword,
  305. "CModalLoop::HandlePendingMessage",
  306. "this=%#x, %#x, %#x, %#x",
  307. this, dwPendingType, dwPendingRecursion, dwReserved
  308. ));
  309. HRESULT hr = NOERROR;
  310. DWORD dwRet = 0;
  311. HTASK htaskCallee = 0;
  312. DWORD dwTickCount = 0;
  313. UrlMkDebugOut((DEB_BINDING, "%p _IN CModalLoop::HandlePendingMessage \n", this));
  314. if (_pMsgFlter)
  315. {
  316. dwRet = _pMsgFlter->MessagePending( htaskCallee, dwTickCount, dwPendingType);
  317. }
  318. UrlMkDebugOut((DEB_BINDING, "%p OUT CModalLoop::HandlePendingMessage (dwRet:%lx)\n", this, dwRet));
  319. DEBUG_LEAVE(dwRet);
  320. return dwRet;
  321. }