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.

312 lines
6.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FaxOutboundRoutingGroup.cpp
  5. Abstract:
  6. Implementation of CFaxOutboundRoutingGroup class.
  7. Author:
  8. Iv Garber (IvG) Jun, 2000
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "FaxComEx.h"
  13. #include "FaxOutboundRoutingGroup.h"
  14. #include "FaxDeviceIds.h"
  15. //
  16. //========================= GET DEVICE IDS ========================================
  17. //
  18. STDMETHODIMP
  19. CFaxOutboundRoutingGroup::get_DeviceIds(
  20. /*[out, retval]*/ IFaxDeviceIds **pFaxDeviceIds
  21. )
  22. /*++
  23. Routine name : CFaxOutboundRoutingGroup::get_DeviceIds
  24. Routine description:
  25. Returns DeviceIds Collection owned by the Group
  26. Author:
  27. Iv Garber (IvG), Jun, 2000
  28. Arguments:
  29. pFaxDeviceIds [out] - the Collection to Return
  30. Return Value:
  31. Standard HRESULT code
  32. --*/
  33. {
  34. HRESULT hr = S_OK;
  35. DBG_ENTER(_T("CFaxOutboundRoutingGroup::get_DeviceIds"), hr);
  36. //
  37. // Check that Ptr we have got -- is OK
  38. //
  39. if (IsBadWritePtr(pFaxDeviceIds, sizeof(IFaxDeviceIds*)))
  40. {
  41. hr = E_POINTER;
  42. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr(pFaxDeviceIds, sizeof(IFaxDeviceIds *))"), hr);
  43. AtlReportError(CLSID_FaxOutboundRoutingGroup, GetErrorMsgId(hr), IID_IFaxOutboundRoutingGroup, hr);
  44. return hr;
  45. }
  46. //
  47. // Return the m_pDeviceIds Collection Object
  48. //
  49. hr = m_pDeviceIds.CopyTo(pFaxDeviceIds);
  50. if (FAILED(hr))
  51. {
  52. hr = E_FAIL;
  53. CALL_FAIL(GENERAL_ERR, _T("CComPtr.CopyTo(pFaxDeviceIds)"), hr);
  54. AtlReportError(CLSID_FaxOutboundRoutingGroup, GetErrorMsgId(hr), IID_IFaxOutboundRoutingGroup, hr);
  55. return hr;
  56. }
  57. return hr;
  58. }
  59. //
  60. //========================= INIT ========================================
  61. //
  62. STDMETHODIMP
  63. CFaxOutboundRoutingGroup::Init(
  64. /*[in]*/ FAX_OUTBOUND_ROUTING_GROUP *pInfo,
  65. /*[in]*/ IFaxServerInner *pServer
  66. )
  67. /*++
  68. Routine name : CFaxOutboundRoutingGroup::Init
  69. Routine description:
  70. Initialize the Group Object with given Data.
  71. Author:
  72. Iv Garber (IvG), Jun, 2000
  73. Arguments:
  74. pInfo [in] - Data of the Group
  75. pServer [in] - Ptr to the Server
  76. Return Value:
  77. Standard HRESULT code
  78. --*/
  79. {
  80. HRESULT hr = S_OK;
  81. DBG_ENTER(_T("CFaxOutboundRoutingGroup::Init"), hr);
  82. m_Status = FAX_GROUP_STATUS_ENUM(pInfo->Status);
  83. m_bstrName = pInfo->lpctstrGroupName;
  84. if (pInfo->lpctstrGroupName && !m_bstrName)
  85. {
  86. //
  87. // not enough memory
  88. //
  89. hr = E_OUTOFMEMORY;
  90. AtlReportError(CLSID_FaxOutboundRoutingGroup, IDS_ERROR_OUTOFMEMORY, IID_IFaxOutboundRoutingGroup, hr);
  91. CALL_FAIL(MEM_ERR, _T("CComBSTR::operator=()"), hr);
  92. return hr;
  93. }
  94. //
  95. // Create Device Ids Collection
  96. //
  97. CComObject<CFaxDeviceIds> *pClass = NULL;
  98. hr = CComObject<CFaxDeviceIds>::CreateInstance(&pClass);
  99. if (FAILED(hr) || (!pClass))
  100. {
  101. if (!pClass)
  102. {
  103. hr = E_OUTOFMEMORY;
  104. CALL_FAIL(MEM_ERR, _T("CComObject<CFaxDeviceIds>::CreateInstance(&pClass)"), hr);
  105. }
  106. else
  107. {
  108. CALL_FAIL(GENERAL_ERR, _T("CComObject<CFaxDeviceIds>::CreateInstance(&pClass)"), hr);
  109. }
  110. AtlReportError(CLSID_FaxOutboundRoutingGroup, IDS_ERROR_OUTOFMEMORY, IID_IFaxOutboundRoutingGroup, hr);
  111. return hr;
  112. }
  113. //
  114. // Init the DeviceIds Collection
  115. //
  116. hr = pClass->Init(pInfo->lpdwDevices, pInfo->dwNumDevices, m_bstrName, pServer);
  117. if (FAILED(hr))
  118. {
  119. CALL_FAIL(GENERAL_ERR, _T("pClass->Init(pInfo->lpdwDevices, pInfo->dwNumDevices, m_bstrName, pServer)"), hr);
  120. AtlReportError(CLSID_FaxOutboundRoutingGroup, IDS_ERROR_OUTOFMEMORY, IID_IFaxOutboundRoutingGroup, hr);
  121. delete pClass;
  122. return hr;
  123. }
  124. //
  125. // Get Interface from the pClass.
  126. // This will make AddRef() on the Interface.
  127. // This is the Collection's AddRef, which is freed at Collection's Dtor.
  128. //
  129. hr = pClass->QueryInterface(&m_pDeviceIds);
  130. if (FAILED(hr) || (!m_pDeviceIds))
  131. {
  132. if (!m_pDeviceIds)
  133. {
  134. hr = E_FAIL;
  135. }
  136. CALL_FAIL(GENERAL_ERR, _T("pClass->QueryInterface(&m_pDeviceIds)"), hr);
  137. AtlReportError(CLSID_FaxOutboundRoutingGroup, IDS_ERROR_OUTOFMEMORY, IID_IFaxOutboundRoutingGroup, hr);
  138. delete pClass;
  139. return hr;
  140. }
  141. return hr;
  142. }
  143. //
  144. //========================= GET STATUS ========================================
  145. //
  146. STDMETHODIMP
  147. CFaxOutboundRoutingGroup::get_Status(
  148. /*[out, retval]*/ FAX_GROUP_STATUS_ENUM *pStatus
  149. )
  150. /*++
  151. Routine name : CFaxOutboundRoutingGroup::get_Status
  152. Routine description:
  153. Return the Status of the Group
  154. Author:
  155. Iv Garber (IvG), Jun, 2000
  156. Arguments:
  157. pStatus [out] - the return value
  158. Return Value:
  159. Standard HRESULT code
  160. --*/
  161. {
  162. HRESULT hr = S_OK;
  163. DBG_ENTER (_T("CFaxOutboundRoutingGroup::get_Status"), hr);
  164. //
  165. // Check that we have got good Ptr
  166. //
  167. if (::IsBadWritePtr(pStatus, sizeof(FAX_GROUP_STATUS_ENUM)))
  168. {
  169. hr = E_POINTER;
  170. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr(pStatus, sizeof(FAX_GROUP_STATUS_ENUM))"), hr);
  171. AtlReportError(CLSID_FaxOutboundRoutingGroup, GetErrorMsgId(hr), IID_IFaxOutboundRoutingGroup, hr);
  172. return hr;
  173. }
  174. *pStatus = m_Status;
  175. return hr;
  176. }
  177. //
  178. //========================= GET NAME ========================================
  179. //
  180. STDMETHODIMP
  181. CFaxOutboundRoutingGroup::get_Name(
  182. BSTR *pbstrName
  183. )
  184. /*++
  185. Routine name : CFaxOutboundRoutingGroup::get_Name
  186. Routine description:
  187. Return Name of the OR Group
  188. Author:
  189. Iv Garber (IvG), Jun, 2000
  190. Arguments:
  191. pbstrName [out] - Ptr to put the Name
  192. Return Value:
  193. Standard HRESULT code
  194. --*/
  195. {
  196. HRESULT hr = S_OK;
  197. DBG_ENTER (TEXT("CFaxOutboundRoutingGroup::get_Name"), hr);
  198. hr = GetBstr(pbstrName, m_bstrName);
  199. if (FAILED(hr))
  200. {
  201. AtlReportError(CLSID_FaxOutboundRoutingGroup, GetErrorMsgId(hr), IID_IFaxOutboundRoutingGroup, hr);
  202. return hr;
  203. }
  204. return hr;
  205. }
  206. //
  207. //===================== SUPPORT ERROR INFO ======================================
  208. //
  209. STDMETHODIMP
  210. CFaxOutboundRoutingGroup::InterfaceSupportsErrorInfo(
  211. REFIID riid
  212. )
  213. /*++
  214. Routine name : CFaxOutboundRoutingGroup::InterfaceSupportsErrorInfo
  215. Routine description:
  216. ATL's implementation of the ISupportErrorInfo Interface.
  217. Author:
  218. Iv Garber (IvG), Jun, 2000
  219. Arguments:
  220. riid [in] - Reference to the Interface
  221. Return Value:
  222. Standard HRESULT code
  223. --*/
  224. {
  225. static const IID* arr[] =
  226. {
  227. &IID_IFaxOutboundRoutingGroup
  228. };
  229. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  230. {
  231. if (InlineIsEqualGUID(*arr[i],riid))
  232. return S_OK;
  233. }
  234. return S_FALSE;
  235. }