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.

401 lines
6.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FaxRecipient.cpp
  5. Abstract:
  6. Implementation of Fax Recipient Interface
  7. Author:
  8. Iv Garber (IvG) Apr, 2000
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "FaxComEx.h"
  13. #include "FaxRecipient.h"
  14. #include "..\..\inc\FaxUIConstants.h"
  15. //
  16. //===================== GET RECIPIENT PROFILE =====================================
  17. //
  18. STDMETHODIMP
  19. CFaxRecipient::GetRecipientProfile(
  20. FAX_PERSONAL_PROFILE *pRecipientProfile
  21. )
  22. /*++
  23. Routine name : CFaxRecipient::GetRecipientProfile
  24. Routine description:
  25. Fills the pRecipientProfile with the data of the object.
  26. Author:
  27. Iv Garber (IvG), May, 2000
  28. Arguments:
  29. pRecipientProfile [out] - the FAX_PERSONAL_PROFILE struct to fill
  30. Return Value:
  31. Standard HRESULT code
  32. --*/
  33. {
  34. HRESULT hr = S_OK;
  35. DBG_ENTER (TEXT("CFaxRecipient::GetRecipientProfile"), hr);
  36. if (::IsBadWritePtr(pRecipientProfile, sizeof(FAX_PERSONAL_PROFILE)))
  37. {
  38. //
  39. // Bad Return OR Interface Pointer
  40. //
  41. hr = E_POINTER;
  42. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr()"), hr);
  43. return hr;
  44. }
  45. ZeroMemory(pRecipientProfile, sizeof(FAX_PERSONAL_PROFILE));
  46. pRecipientProfile->dwSizeOfStruct = sizeof(FAX_PERSONAL_PROFILE);
  47. pRecipientProfile->lptstrName = m_bstrName;
  48. pRecipientProfile->lptstrFaxNumber = m_bstrFaxNumber;
  49. return hr;
  50. }
  51. //
  52. //============== PUT RECIPIENT PROFILE ============================================
  53. //
  54. STDMETHODIMP
  55. CFaxRecipient::PutRecipientProfile(
  56. FAX_PERSONAL_PROFILE *pRecipientProfile
  57. )
  58. /*++
  59. Routine name : CFaxRecipient::PutRecipientProfile
  60. Routine description:
  61. Receives FAX_PERSONAL_PROFILE structure and fills the Recipient's fields.
  62. Author:
  63. Iv Garber (IvG), May, 2000
  64. Arguments:
  65. pRecipientProfile [in] - the data to put into the object's variables
  66. Return Value:
  67. Standard HRESULT code
  68. --*/
  69. {
  70. HRESULT hr = S_OK;
  71. DBG_ENTER (_T("CFaxRecipient::PutRecipientProfile"), hr);
  72. m_bstrFaxNumber = pRecipientProfile->lptstrFaxNumber;
  73. m_bstrName = pRecipientProfile->lptstrName;
  74. if ((pRecipientProfile->lptstrFaxNumber && !m_bstrFaxNumber) ||
  75. (pRecipientProfile->lptstrName && !m_bstrName))
  76. {
  77. //
  78. // Not enough memory
  79. //
  80. hr = E_OUTOFMEMORY;
  81. CALL_FAIL(MEM_ERR, _T("CComBSTR::operator=()"), hr);
  82. }
  83. return hr;
  84. }
  85. //
  86. //==================== INTERFACE SUPPORT ERROR INFO =====================
  87. //
  88. STDMETHODIMP
  89. CFaxRecipient::InterfaceSupportsErrorInfo (
  90. REFIID riid
  91. )
  92. /*++
  93. Routine name : CFaxRecipient::InterfaceSupportsErrorInfo
  94. Routine description:
  95. ATL's implementation of Support Error Info
  96. Author:
  97. Iv Garber (IvG), Apr, 2000
  98. Arguments:
  99. riid [in] - Interface ID
  100. Return Value:
  101. Standard HRESULT code
  102. --*/
  103. {
  104. static const IID* arr[] =
  105. {
  106. &IID_IFaxRecipient
  107. };
  108. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  109. {
  110. if (InlineIsEqualGUID(*arr[i],riid))
  111. return S_OK;
  112. }
  113. return S_FALSE;
  114. }
  115. //
  116. //==================== CREATE ========================================
  117. //
  118. HRESULT
  119. CFaxRecipient::Create (
  120. IFaxRecipient **ppRecipient
  121. )
  122. /*++
  123. Routine name : CFaxRecipient::Create
  124. Routine description:
  125. Static function to create the Fax Recipient Instance
  126. Author:
  127. Iv Garber (IvG), Apr, 2000
  128. Arguments:
  129. ppRecipient [out] -- the new Fax Recipient Instance
  130. Return Value:
  131. Standard HRESULT code
  132. --*/
  133. {
  134. CComObject<CFaxRecipient> *pClass;
  135. HRESULT hr = S_OK;
  136. DBG_ENTER (TEXT("CFaxRecipient::Create"), hr);
  137. hr = CComObject<CFaxRecipient>::CreateInstance(&pClass);
  138. if (FAILED(hr))
  139. {
  140. //
  141. // Failed to create Instance
  142. //
  143. CALL_FAIL(GENERAL_ERR, _T("CComObject<CFaxRecipient>::CreateInstance()"), hr);
  144. return hr;
  145. }
  146. hr = pClass->QueryInterface(__uuidof(IFaxRecipient), (void **) ppRecipient);
  147. if (FAILED(hr))
  148. {
  149. //
  150. // Failed to Query Recipient Interface
  151. //
  152. CALL_FAIL(GENERAL_ERR, _T("QueryInterface()"), hr);
  153. return hr;
  154. }
  155. return hr;
  156. }
  157. //
  158. //==================== FAX NUMBER ========================================
  159. //
  160. STDMETHODIMP
  161. CFaxRecipient::get_FaxNumber(
  162. BSTR *pbstrFaxNumber
  163. )
  164. /*++
  165. Routine name : CFaxRecipient::get_FaxNumber
  166. Routine description:
  167. return FaxNumber
  168. Author:
  169. Iv Garber (IvG), Apr, 2000
  170. Arguments:
  171. pbstrFaxNumber [out] - the FaxNumber
  172. Return Value:
  173. Standard HRESULT code
  174. --*/
  175. {
  176. HRESULT hr = S_OK;
  177. DBG_ENTER (TEXT("CFaxRecipient::get_FaxNumber"), hr);
  178. hr = GetBstr(pbstrFaxNumber, m_bstrFaxNumber);
  179. if (FAILED(hr))
  180. {
  181. AtlReportError(CLSID_FaxRecipient, GetErrorMsgId(hr), IID_IFaxRecipient, hr);
  182. return hr;
  183. }
  184. return hr;
  185. }
  186. STDMETHODIMP
  187. CFaxRecipient::put_FaxNumber (
  188. BSTR bstrFaxNumber
  189. )
  190. /*++
  191. Routine name : CFaxRecipient::put_FaxNumber
  192. Routine description:
  193. Set FaxNumber
  194. Author:
  195. Iv Garber (IvG), Apr, 2000
  196. Arguments:
  197. bstrFaxNumber [in] - new Fax Number
  198. Return Value:
  199. Standard HRESULT code
  200. --*/
  201. {
  202. HRESULT hr = S_OK;
  203. DBG_ENTER (_T("CFaxRecipient::put_FaxNumber"), hr, _T("%s"), bstrFaxNumber);
  204. m_bstrFaxNumber = bstrFaxNumber;
  205. if (!m_bstrFaxNumber && bstrFaxNumber)
  206. {
  207. //
  208. // Not enough memory
  209. //
  210. hr = E_OUTOFMEMORY;
  211. AtlReportError(CLSID_FaxRecipient, IDS_ERROR_OUTOFMEMORY, IID_IFaxRecipient, hr);
  212. CALL_FAIL(MEM_ERR, _T("CComBSTR::operator="), hr);
  213. return hr;
  214. }
  215. return hr;
  216. }
  217. //
  218. //==================== NAME ========================================
  219. //
  220. STDMETHODIMP
  221. CFaxRecipient::get_Name(
  222. BSTR *pbstrName
  223. )
  224. /*++
  225. Routine name : CFaxRecipient::get_Name
  226. Routine description:
  227. return Name
  228. Author:
  229. Iv Garber (IvG), Apr, 2000
  230. Arguments:
  231. pbstrName [out] - the Name
  232. Return Value:
  233. Standard HRESULT code
  234. --*/
  235. {
  236. HRESULT hr = S_OK;
  237. DBG_ENTER (_T("CFaxRecipient::get_Name"), hr);
  238. hr = GetBstr(pbstrName, m_bstrName);
  239. if (FAILED(hr))
  240. {
  241. AtlReportError(CLSID_FaxRecipient, GetErrorMsgId(hr), IID_IFaxRecipient, hr);
  242. return hr;
  243. }
  244. return hr;
  245. }
  246. STDMETHODIMP
  247. CFaxRecipient::put_Name (
  248. BSTR bstrName
  249. )
  250. /*++
  251. Routine name : CFaxRecipient::put_Name
  252. Routine description:
  253. Set Name
  254. Author:
  255. Iv Garber (IvG), Apr, 2000
  256. Arguments:
  257. bstrName [in] - new Name
  258. Return Value:
  259. Standard HRESULT code
  260. --*/
  261. {
  262. HRESULT hr = S_OK;
  263. DBG_ENTER (_T("CFaxRecipient::put_Name"), hr, _T("%s"), bstrName);
  264. m_bstrName = bstrName;
  265. if (!m_bstrName && bstrName)
  266. {
  267. //
  268. // Not enough memory
  269. //
  270. hr = E_OUTOFMEMORY;
  271. AtlReportError(CLSID_FaxRecipient, IDS_ERROR_OUTOFMEMORY, IID_IFaxRecipient, hr);
  272. CALL_FAIL(MEM_ERR, _T("CComBSTR::operator="), hr);
  273. return hr;
  274. }
  275. return hr;
  276. }