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.

271 lines
7.3 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: msgrefadm.cpp
  5. //
  6. // Description:
  7. // Implements CAsyncAdminMsgRefQueue class
  8. //
  9. // Author: Mike Swafford (MikeSwa)
  10. //
  11. // History:
  12. // 12/7/2000 - MikeSwa Created
  13. //
  14. // Copyright (C) 2000 Microsoft Corporation
  15. //
  16. //-----------------------------------------------------------------------------
  17. #include "aqprecmp.h"
  18. #include "msgrefadm.h"
  19. #include "asyncadm.inl"
  20. //---[ CAsyncAdminMsgRefQueue::HrDeleteMsgFromQueueNDR ]-----------------------
  21. //
  22. //
  23. // Description:
  24. // Wraps call to NDR MsgRef
  25. // Parameters:
  26. // *pIUnknown - IUnkown of Msgref
  27. // Returns:
  28. // S_OK on success
  29. // History:
  30. // 12/7/2000 - MikeSwa Created
  31. //
  32. //-----------------------------------------------------------------------------
  33. HRESULT CAsyncAdminMsgRefQueue::HrDeleteMsgFromQueueNDR(
  34. IUnknown *pIUnknownMsg)
  35. {
  36. TraceFunctEnterEx((LPARAM) this, "CAsyncAdminMsgRefQueue::HrDeleteMsgFromQueueNDR");
  37. HRESULT hr = S_OK;
  38. CMsgRef *pmsgref = NULL;
  39. _ASSERT(pIUnknownMsg);
  40. hr = pIUnknownMsg->QueryInterface(IID_CMsgRef, (void **) &pmsgref);
  41. _ASSERT(SUCCEEDED(hr) && "IUnknownMsg Must be a CMsgRef!!");
  42. if (FAILED(hr))
  43. {
  44. ErrorTrace((LPARAM) this, "QI for MsgRef failed with hr 0x%08X", hr);
  45. goto Exit;
  46. }
  47. //
  48. // Attempt to NDR message
  49. //
  50. hr = pmsgref->HrQueueAdminNDRMessage(NULL);
  51. Exit:
  52. if (pmsgref)
  53. pmsgref->Release();
  54. TraceFunctLeave();
  55. return hr;
  56. }
  57. //---[ CAsyncAdminMsgRefQueue::HrDeleteMsgFromQueueSilent ]--------------------
  58. //
  59. //
  60. // Description:
  61. // Wrapper function to silently delete a message from a queue
  62. // Parameters:
  63. // *pIUnknown - IUnkown of Msgref
  64. // Returns:
  65. // S_OK on success
  66. // History:
  67. // 12/7/2000 - MikeSwa Created
  68. //
  69. //-----------------------------------------------------------------------------
  70. HRESULT CAsyncAdminMsgRefQueue::HrDeleteMsgFromQueueSilent(
  71. IUnknown *pIUnknownMsg)
  72. {
  73. TraceFunctEnterEx((LPARAM) this, "CAsyncAdminMsgRefQueue::HrDeleteMsgFromQueueSilent");
  74. HRESULT hr = S_OK;
  75. CMsgRef *pmsgref = NULL;
  76. _ASSERT(pIUnknownMsg);
  77. hr = pIUnknownMsg->QueryInterface(IID_CMsgRef, (void **) &pmsgref);
  78. _ASSERT(SUCCEEDED(hr) && "IUnknownMsg Must be a CMsgRef!!");
  79. if (FAILED(hr))
  80. {
  81. ErrorTrace((LPARAM) this, "QI for MsgRef failed with hr 0x%08X", hr);
  82. goto Exit;
  83. }
  84. //
  85. // Attempt to remove the message from the queue
  86. //
  87. hr = pmsgref->HrRemoveMessageFromQueue(NULL);
  88. Exit:
  89. if (pmsgref)
  90. pmsgref->Release();
  91. TraceFunctLeave();
  92. return hr;
  93. }
  94. //---[ CAsyncAdminMsgRefQueue::HrFreezeMsg ]-----------------------------------
  95. //
  96. //
  97. // Description:
  98. // Wrapper to freeze a pmsgref
  99. // Parameters:
  100. // *pIUnknown - IUnkown of Msgref
  101. // Returns:
  102. // S_OK on success
  103. // History:
  104. // 12/7/2000 - MikeSwa Created
  105. //
  106. //-----------------------------------------------------------------------------
  107. HRESULT CAsyncAdminMsgRefQueue::HrFreezeMsg(IUnknown *pIUnknownMsg)
  108. {
  109. TraceFunctEnterEx((LPARAM) this, "CAsyncAdminMsgRefQueue::HrFreezeMsg");
  110. HRESULT hr = S_OK;
  111. CMsgRef *pmsgref = NULL;
  112. _ASSERT(pIUnknownMsg);
  113. hr = pIUnknownMsg->QueryInterface(IID_CMsgRef, (void **) &pmsgref);
  114. _ASSERT(SUCCEEDED(hr) && "IUnknownMsg Must be a CMsgRef!!");
  115. if (FAILED(hr))
  116. {
  117. ErrorTrace((LPARAM) this, "QI for MsgRef failed with hr 0x%08X", hr);
  118. goto Exit;
  119. }
  120. //
  121. // Attempt to freeze the message
  122. //
  123. pmsgref->GlobalFreezeMessage();
  124. Exit:
  125. if (pmsgref)
  126. pmsgref->Release();
  127. TraceFunctLeave();
  128. return hr;
  129. }
  130. //---[ CAsyncAdminMsgRefQueue::HrThawMsg ]-------------------------------------
  131. //
  132. //
  133. // Description:
  134. // Wrapper function to thaw a message
  135. // Parameters:
  136. // *pIUnknown - IUnkown of Msgref
  137. // Returns:
  138. // S_OK on success
  139. // History:
  140. // 12/7/2000 - MikeSwa Created
  141. //
  142. //-----------------------------------------------------------------------------
  143. HRESULT CAsyncAdminMsgRefQueue::HrThawMsg(IUnknown *pIUnknownMsg)
  144. {
  145. TraceFunctEnterEx((LPARAM) this, "AsyncAdminMsgRefQueue::HrThawMsg");
  146. HRESULT hr = S_OK;
  147. CMsgRef *pmsgref = NULL;
  148. _ASSERT(pIUnknownMsg);
  149. hr = pIUnknownMsg->QueryInterface(IID_CMsgRef, (void **) &pmsgref);
  150. _ASSERT(SUCCEEDED(hr) && "IUnknownMsg Must be a CMsgRef!!");
  151. if (FAILED(hr))
  152. {
  153. ErrorTrace((LPARAM) this, "QI for MsgRef failed with hr 0x%08X", hr);
  154. goto Exit;
  155. }
  156. //
  157. // Attempt to thaw message
  158. //
  159. pmsgref->GlobalThawMessage();
  160. Exit:
  161. if (pmsgref)
  162. pmsgref->Release();
  163. TraceFunctLeave();
  164. return hr;
  165. }
  166. //---[ CAsyncAdminMsgRefQueue::HrGetStatsForMsg ]------------------------------
  167. //
  168. //
  169. // Description:
  170. // Wrapper function to fill in the CAQStats struct for a message
  171. // Parameters:
  172. // *pIUnknown - IUnkown of Msgref
  173. // *paqstats - Ptr to aqstats struction to fill in.
  174. // Returns:
  175. // S_OK on success
  176. // History:
  177. // 12/7/2000 - MikeSwa Created
  178. //
  179. //-----------------------------------------------------------------------------
  180. HRESULT CAsyncAdminMsgRefQueue::HrGetStatsForMsg(
  181. IUnknown *pIUnknownMsg,
  182. CAQStats *paqstats)
  183. {
  184. TraceFunctEnterEx((LPARAM) this, "CAsyncAdminMsgRefQueue::HrGetStatsForMsg");
  185. HRESULT hr = S_OK;
  186. CMsgRef *pmsgref = NULL;
  187. _ASSERT(pIUnknownMsg);
  188. _ASSERT(paqstats);
  189. hr = pIUnknownMsg->QueryInterface(IID_CMsgRef, (void **) &pmsgref);
  190. _ASSERT(SUCCEEDED(hr) && "IUnknownMsg Must be a CMsgRef!!");
  191. if (FAILED(hr))
  192. {
  193. ErrorTrace((LPARAM) this, "QI for MsgRef failed with hr 0x%08X", hr);
  194. goto Exit;
  195. }
  196. //
  197. // Attempt to get stats from MsgRef
  198. //
  199. pmsgref->GetStatsForMsg(paqstats);
  200. Exit:
  201. if (pmsgref)
  202. pmsgref->Release();
  203. TraceFunctLeave();
  204. return hr;
  205. }
  206. //---[ CAsyncAdminMsgRefQueue::HrInternalQuerySupportedActions ]---------------
  207. //
  208. //
  209. // Description:
  210. // Returns the actions and filters that this implementation supports
  211. // Parameters:
  212. // pdwSupportedActions - QAPI MsgActions that this queue suppprts
  213. // pdwSupportedFilterFlags - QAPI filter flags that this queue supports
  214. // Returns:
  215. // S_OK on success
  216. // History:
  217. // 12/12/2000 - MikeSwa Created
  218. //
  219. //-----------------------------------------------------------------------------
  220. HRESULT CAsyncAdminMsgRefQueue::HrInternalQuerySupportedActions(
  221. DWORD *pdwSupportedActions,
  222. DWORD *pdwSupportedFilterFlags)
  223. {
  224. TraceFunctEnterEx((LPARAM) this, "CAsyncAdminMsgRefQueue::HrInternalQuerySupportedActions");
  225. HRESULT hr = S_OK;
  226. //
  227. // This queue implementation supports all of the default flags.
  228. //
  229. hr = QueryDefaultSupportedActions(pdwSupportedActions, pdwSupportedFilterFlags);
  230. return hr;
  231. }