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.

246 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FaxActivity.cpp
  5. Abstract:
  6. Implementation of CFaxActivity Class.
  7. Author:
  8. Iv Garber (IvG) Jun, 2000
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "FaxComEx.h"
  13. #include "FaxActivity.h"
  14. //
  15. //========================= QUEUED MESSAGES =============================
  16. //
  17. STDMETHODIMP
  18. CFaxActivity::get_QueuedMessages(
  19. long *plQueuedMessages
  20. )
  21. {
  22. HRESULT hr = S_OK;
  23. DBG_ENTER(_T("CFaxActivity::get_QueuedMessages"), hr);
  24. hr = GetNumberOfMessages(mtQUEUED, plQueuedMessages);
  25. return hr;
  26. }
  27. //
  28. //========================= OUTGOING MESSAGES =============================
  29. //
  30. STDMETHODIMP
  31. CFaxActivity::get_OutgoingMessages(
  32. long *plOutgoingMessages
  33. )
  34. {
  35. HRESULT hr = S_OK;
  36. DBG_ENTER(_T("CFaxActivity::get_OutgoingMessages"), hr);
  37. hr = GetNumberOfMessages(mtOUTGOING, plOutgoingMessages);
  38. return hr;
  39. }
  40. //
  41. //========================= ROUTING MESSAGES =============================
  42. //
  43. STDMETHODIMP
  44. CFaxActivity::get_RoutingMessages(
  45. long *plRoutingMessages
  46. )
  47. {
  48. HRESULT hr = S_OK;
  49. DBG_ENTER(_T("CFaxActivity::get_RoutingMessages"), hr);
  50. hr = GetNumberOfMessages(mtROUTING, plRoutingMessages);
  51. return hr;
  52. }
  53. //
  54. //========================= INCOMING MESSAGES =============================
  55. //
  56. STDMETHODIMP
  57. CFaxActivity::get_IncomingMessages(
  58. long *plIncomingMessages
  59. )
  60. {
  61. HRESULT hr = S_OK;
  62. DBG_ENTER(_T("CFaxActivity::get_IncomingMessages"), hr);
  63. hr = GetNumberOfMessages(mtINCOMING, plIncomingMessages);
  64. return hr;
  65. }
  66. //
  67. //=================== GET NUMBER OF MESSAGES ===================================
  68. //
  69. STDMETHODIMP
  70. CFaxActivity::GetNumberOfMessages(
  71. MSG_TYPE msgType,
  72. long * plNumber
  73. )
  74. {
  75. HRESULT hr = S_OK;
  76. DBG_ENTER(_T("CFaxActivity::GetNumberOfMessages"), hr);
  77. //
  78. // check that we have got good ptr
  79. //
  80. if (::IsBadWritePtr(plNumber, sizeof(long)))
  81. {
  82. hr = E_POINTER;
  83. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr(plNumber, sizeof(long))"), hr);
  84. AtlReportError(CLSID_FaxActivity,
  85. IDS_ERROR_INVALID_ARGUMENT,
  86. IID_IFaxActivity,
  87. hr);
  88. return hr;
  89. }
  90. //
  91. // Bring data from Server in the first time
  92. //
  93. if (!m_bInited)
  94. {
  95. hr = Refresh();
  96. if (FAILED(hr))
  97. {
  98. return hr;
  99. }
  100. }
  101. switch(msgType)
  102. {
  103. case mtINCOMING:
  104. *plNumber = m_ServerActivity.dwIncomingMessages;
  105. break;
  106. case mtROUTING:
  107. *plNumber = m_ServerActivity.dwRoutingMessages;
  108. break;
  109. case mtOUTGOING:
  110. *plNumber = m_ServerActivity.dwOutgoingMessages;
  111. break;
  112. case mtQUEUED:
  113. *plNumber = m_ServerActivity.dwQueuedMessages;
  114. break;
  115. default:
  116. //
  117. // ASSERT(FALSE)
  118. //
  119. ATLASSERT(msgType == mtQUEUED);
  120. break;
  121. }
  122. return hr;
  123. }
  124. //
  125. //========================= REFRESH ============================================
  126. //
  127. STDMETHODIMP
  128. CFaxActivity::Refresh()
  129. /*++
  130. Routine name : CFaxActivity::Refresh
  131. Routine description:
  132. Refresh the contents of the object : bring new data from the Server.
  133. Author:
  134. Iv Garber (IvG), Jun, 2000
  135. Arguments:
  136. Return Value:
  137. Standard HRESULT code
  138. --*/
  139. {
  140. HRESULT hr = S_OK;
  141. DBG_ENTER(_T("CFaxActivity::Refresh"), hr);
  142. //
  143. // Get Fax Server Handle
  144. //
  145. HANDLE hFaxHandle = NULL;
  146. hr = GetFaxHandle(&hFaxHandle);
  147. if (FAILED(hr))
  148. {
  149. AtlReportError(CLSID_FaxActivity,
  150. GetErrorMsgId(hr),
  151. IID_IFaxActivity,
  152. hr);
  153. return hr;
  154. }
  155. //
  156. // Ask from Server new Activity data
  157. //
  158. if (!FaxGetServerActivity(hFaxHandle, &m_ServerActivity))
  159. {
  160. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  161. AtlReportError(CLSID_FaxActivity,
  162. GetErrorMsgId(hr),
  163. IID_IFaxActivity,
  164. hr);
  165. CALL_FAIL(GENERAL_ERR, _T("FaxGetServerActivity(hFaxHandle, &ServerActivity)"), hr);
  166. return hr;
  167. }
  168. m_bInited = true;
  169. return hr;
  170. }
  171. //
  172. //======================= SUPPORT ERROR INFO ==================================
  173. //
  174. STDMETHODIMP
  175. CFaxActivity::InterfaceSupportsErrorInfo(
  176. REFIID riid
  177. )
  178. /*++
  179. Routine name : CFaxActivity::InterfaceSupportsErrorInfo
  180. Routine description:
  181. ATL's implementation of Support Error Info.
  182. Author:
  183. Iv Garber (IvG), Jun, 2000
  184. Arguments:
  185. riid [in] - reference to the ifc to check.
  186. Return Value:
  187. Standard HRESULT code
  188. --*/
  189. {
  190. static const IID* arr[] =
  191. {
  192. &IID_IFaxActivity
  193. };
  194. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  195. {
  196. if (InlineIsEqualGUID(*arr[i],riid))
  197. return S_OK;
  198. }
  199. return S_FALSE;
  200. }