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.

1886 lines
42 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FaxJobInner.h
  5. Abstract:
  6. Implementation of Fax Job Inner Class :
  7. Base Class for Inbound and Outbound Job Classes.
  8. Author:
  9. Iv Garber (IvG) May, 2000
  10. Revision History:
  11. --*/
  12. #ifndef __FAXJOBINNER_H_
  13. #define __FAXJOBINNER_H_
  14. #include "FaxJobStatus.h"
  15. #include "FaxSender.h"
  16. //
  17. //===================== FAX JOB INNER CLASS ===============================
  18. //
  19. template<class T, const IID* piid, const CLSID* pcid>
  20. class CFaxJobInner :
  21. public IDispatchImpl<T, piid, &LIBID_FAXCOMEXLib>,
  22. public CFaxInitInnerAddRef
  23. {
  24. public:
  25. CFaxJobInner() : CFaxInitInnerAddRef(_T("FAX JOB INNER"))
  26. {
  27. m_pSender = NULL;
  28. m_pRecipient = NULL;
  29. };
  30. ~CFaxJobInner()
  31. {
  32. if (m_pSender)
  33. {
  34. m_pSender->Release();
  35. }
  36. if (m_pRecipient)
  37. {
  38. m_pRecipient->Release();
  39. }
  40. };
  41. STDMETHOD(Init)(PFAX_JOB_ENTRY_EX pFaxJob, IFaxServerInner *pServer);
  42. // common for both Jobs
  43. STDMETHOD(Cancel)();
  44. STDMETHOD(Refresh)();
  45. STDMETHOD(CopyTiff)(BSTR bstrTiffPath);
  46. STDMETHOD(get_Id)(/*[out, retval]*/ BSTR *pbstrId);
  47. STDMETHOD(get_Size)(/*[out, retval]*/ long *plSize);
  48. STDMETHOD(get_CSID)(/*[out, retval]*/ BSTR *pbstrCSID);
  49. STDMETHOD(get_TSID)(/*[out, retval]*/ BSTR *pbstrTSID);
  50. STDMETHOD(get_Retries)(/*[out, retval]*/ long *plRetries);
  51. STDMETHOD(get_DeviceId)(/*[out, retval]*/ long *plDeviceId);
  52. STDMETHOD(get_CurrentPage)(/*[out, retval]*/ long *plCurrentPage);
  53. STDMETHOD(get_Status)(/*[out, retval]*/ FAX_JOB_STATUS_ENUM *pStatus);
  54. STDMETHOD(get_ExtendedStatus)(/*[out, retval]*/ BSTR *pbstrExtendedStatus);
  55. STDMETHOD(get_TransmissionEnd)(/*[out, retval]*/ DATE *pdateTransmissionEnd);
  56. STDMETHOD(get_TransmissionStart)(/*[out, retval]*/ DATE *pdateTransmissionStart);
  57. STDMETHOD(get_ExtendedStatusCode)(FAX_JOB_EXTENDED_STATUS_ENUM *pExtendedStatusCode);
  58. STDMETHOD(get_AvailableOperations)(/*[out, retval]*/ FAX_JOB_OPERATIONS_ENUM *pAvailableOperations);
  59. // specific for Outbound Job
  60. STDMETHOD(Pause)();
  61. STDMETHOD(Resume)();
  62. STDMETHOD(Restart)();
  63. STDMETHOD(get_Sender)(IFaxSender **ppFaxSender);
  64. STDMETHOD(get_Pages)(/*[out, retval]*/ long *plPages);
  65. STDMETHOD(get_Recipient)(IFaxRecipient **ppFaxRecipient);
  66. STDMETHOD(get_Subject)(/*[out, retval]*/ BSTR *pbstrSubject);
  67. STDMETHOD(get_ReceiptType)(FAX_RECEIPT_TYPE_ENUM *pReceiptType);
  68. STDMETHOD(get_DocumentName)(/*[out, retval]*/ BSTR *pbstrDocumentName);
  69. STDMETHOD(get_SubmissionId)(/*[out, retval] */BSTR *pbstrSubmissionId);
  70. STDMETHOD(get_OriginalScheduledTime)(DATE *pdateOriginalScheduledTime);
  71. STDMETHOD(get_ScheduledTime)(/*[out, retval]*/ DATE *pdateScheduledTime);
  72. STDMETHOD(get_SubmissionTime)(/*[out, retval]*/ DATE *pdateSubmissionTime);
  73. STDMETHOD(get_Priority)(/*[out, retval]*/ FAX_PRIORITY_TYPE_ENUM *pPriority);
  74. STDMETHOD(get_GroupBroadcastReceipts)(VARIANT_BOOL *pbGroupBroadcastReceipts);
  75. // specific for Inbound Job
  76. STDMETHOD(get_CallerId)(/*[out, retval]*/ BSTR *pbstrCallerId);
  77. STDMETHOD(get_JobType)(/*[out, retval]*/ FAX_JOB_TYPE_ENUM *pJobType);
  78. STDMETHOD(get_RoutingInformation)(/*[out, retval]*/ BSTR *pbstrRoutingInformation);
  79. private:
  80. DWORDLONG m_dwlMessageId;
  81. DWORDLONG m_dwlBroadcastId;
  82. DWORD m_dwReceiptType;
  83. CComBSTR m_bstrSubject;
  84. CComBSTR m_bstrDocumentName;
  85. SYSTEMTIME m_tmOriginalScheduleTime;
  86. SYSTEMTIME m_tmSubmissionTime;
  87. FAX_PRIORITY_TYPE_ENUM m_Priority;
  88. CComObject<CFaxJobStatus> m_JobStatus;
  89. CComObject<CFaxSender> *m_pSender;
  90. CComObject<CFaxRecipient> *m_pRecipient;
  91. STDMETHOD(UpdateJob)(FAX_ENUM_JOB_COMMANDS cmdToPerform);
  92. };
  93. //
  94. //====================== GET JOB TYPE ===============================
  95. //
  96. template<class T, const IID* piid, const CLSID* pcid>
  97. STDMETHODIMP
  98. CFaxJobInner<T, piid, pcid>::get_JobType(
  99. FAX_JOB_TYPE_ENUM *pJobType
  100. )
  101. /*++
  102. Routine name : CFaxJobInner::get_JobType
  103. Routine description:
  104. Return the Type of the Job
  105. Author:
  106. Iv Garber (IvG), Jul, 2000
  107. Arguments:
  108. pJobType [out] - Return Value of Job Type
  109. Return Value:
  110. Standard HRESULT code
  111. --*/
  112. {
  113. HRESULT hr = S_OK;
  114. DBG_ENTER (TEXT("CFaxJobInner::get_JobType"), hr);
  115. hr = m_JobStatus.get_JobType(pJobType);
  116. return hr;
  117. }
  118. //
  119. //==================== INIT ===================================================
  120. //
  121. template<class T, const IID* piid, const CLSID* pcid>
  122. STDMETHODIMP
  123. CFaxJobInner<T, piid, pcid>::Init(
  124. PFAX_JOB_ENTRY_EX pFaxJob,
  125. IFaxServerInner* pFaxServerInner
  126. )
  127. /*++
  128. Routine name : CFaxJobInner::Init
  129. Routine description:
  130. Initialize the JobInner Class : store Job Information and Ptr to Server
  131. Author:
  132. Iv Garber (IvG), May, 2000
  133. Arguments:
  134. pFaxJob [in] - Job Info
  135. pFaxServerInner [in] - Ptr to Server
  136. Return Value:
  137. Standard HRESULT code
  138. --*/
  139. {
  140. HRESULT hr = S_OK;
  141. DBG_ENTER (TEXT("CFaxJobInner::Init"), hr);
  142. ATLASSERT(pFaxJob->pStatus);
  143. //
  144. // Store the given structure
  145. //
  146. m_dwlMessageId = pFaxJob->dwlMessageId;
  147. m_dwlBroadcastId = pFaxJob->dwlBroadcastId;
  148. m_dwReceiptType = pFaxJob->dwDeliveryReportType;
  149. m_Priority = FAX_PRIORITY_TYPE_ENUM(pFaxJob->Priority);
  150. m_tmOriginalScheduleTime = pFaxJob->tmOriginalScheduleTime;
  151. m_tmSubmissionTime = pFaxJob->tmSubmissionTime;
  152. m_bstrSubject = pFaxJob->lpctstrSubject;
  153. m_bstrDocumentName = pFaxJob->lpctstrDocumentName;
  154. if ( (pFaxJob->lpctstrSubject && !m_bstrSubject) ||
  155. (pFaxJob->lpctstrDocumentName && !m_bstrDocumentName) )
  156. {
  157. //
  158. // Not enough memory to copy the TSID into CComBSTR
  159. //
  160. hr = E_OUTOFMEMORY;
  161. AtlReportError(*pcid, IDS_ERROR_OUTOFMEMORY, *piid, hr);
  162. CALL_FAIL(MEM_ERR, _T("CComBSTR::operator=()"), hr);
  163. return hr;
  164. }
  165. //
  166. // Create Status Object
  167. //
  168. hr = m_JobStatus.Init(pFaxJob->pStatus);
  169. if (FAILED(hr))
  170. {
  171. AtlReportError(*pcid, IDS_ERROR_OUTOFMEMORY, *piid, hr);
  172. CALL_FAIL(MEM_ERR, _T("m_JobStatus.Init"), hr);
  173. return hr;
  174. }
  175. //
  176. // When called from Refresh(), no need to set pFaxServerInner
  177. //
  178. if (pFaxServerInner)
  179. {
  180. hr = CFaxInitInnerAddRef::Init(pFaxServerInner);
  181. }
  182. return hr;
  183. }
  184. //
  185. //====================== GET ID ================================================
  186. //
  187. template<class T, const IID* piid, const CLSID *pcid>
  188. STDMETHODIMP
  189. CFaxJobInner<T, piid, pcid>::get_Id(
  190. BSTR *pbstrId
  191. )
  192. /*++
  193. Routine name : CFaxJobInner::get_Id
  194. Routine description:
  195. Return Unique ID of the Message
  196. Author:
  197. Iv Garber (IvG), May, 2000
  198. Arguments:
  199. pbstrId [out] - pointer to the place to put the ID
  200. Return Value:
  201. Standard HRESULT code
  202. --*/
  203. {
  204. HRESULT hr = S_OK;
  205. DBG_ENTER (TEXT("CFaxJobInner::get_Id"), hr);
  206. //
  207. // Check that we can write to the given pointer
  208. //
  209. if (::IsBadWritePtr(pbstrId, sizeof(BSTR)))
  210. {
  211. //
  212. // got bad pointer
  213. //
  214. hr = E_POINTER;
  215. AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr);
  216. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr()"), hr);
  217. return hr;
  218. }
  219. //
  220. // Translate m_dwlMessageId into BSTR
  221. //
  222. TCHAR tcBuffer[25];
  223. BSTR bstrTemp;
  224. ::_i64tot(m_dwlMessageId, tcBuffer, 16);
  225. bstrTemp = ::SysAllocString(tcBuffer);
  226. if (!bstrTemp)
  227. {
  228. //
  229. // Not enough memory
  230. //
  231. hr = E_OUTOFMEMORY;
  232. AtlReportError(*pcid, IDS_ERROR_OUTOFMEMORY, *piid, hr);
  233. CALL_FAIL(MEM_ERR, _T("SysAllocString()"), hr);
  234. return hr;
  235. }
  236. *pbstrId = bstrTemp;
  237. return hr;
  238. }
  239. //
  240. //====================== GET SIZE ================================================
  241. //
  242. template<class T, const IID* piid, const CLSID *pcid>
  243. STDMETHODIMP
  244. CFaxJobInner<T, piid, pcid>::get_Size(
  245. long *plSize
  246. )
  247. /*++
  248. Routine name : CFaxJobInner::get_Size
  249. Routine description:
  250. Return Size ( in bytes ) of Fax Job's TIFF File
  251. Author:
  252. Iv Garber (IvG), May, 2000
  253. Arguments:
  254. plSize [out] - Pointer to the place to put Size
  255. Return Value:
  256. Standard HRESULT code
  257. --*/
  258. {
  259. HRESULT hr = S_OK;
  260. DBG_ENTER (TEXT("CFaxJobInner::get_Size"), hr);
  261. hr = m_JobStatus.get_Size(plSize);
  262. return hr;
  263. }
  264. //
  265. //====================== GET CURRENT PAGE =============================================
  266. //
  267. template<class T, const IID* piid, const CLSID *pcid>
  268. STDMETHODIMP
  269. CFaxJobInner<T, piid, pcid>::get_CurrentPage(
  270. long *plCurrentPage
  271. )
  272. /*++
  273. Routine name : CFaxJobInner::get_CurrentPage
  274. Routine description:
  275. Current Page number being received / sent
  276. Author:
  277. Iv Garber (IvG), May, 2000
  278. Arguments:
  279. plCurrentPage [out] - Pointer to the place to put the Current Page Number
  280. Return Value:
  281. Standard HRESULT code
  282. --*/
  283. {
  284. HRESULT hr = S_OK;
  285. DBG_ENTER (TEXT("CFaxJobInner::get_CurrentPage"), hr);
  286. hr = m_JobStatus.get_CurrentPage(plCurrentPage);
  287. return hr;
  288. }
  289. //
  290. //====================== GET DEVICE ID =============================================
  291. //
  292. template<class T, const IID* piid, const CLSID *pcid>
  293. STDMETHODIMP
  294. CFaxJobInner<T, piid, pcid>::get_DeviceId(
  295. long *plDeviceId
  296. )
  297. /*++
  298. Routine name : CFaxJobInner::get_DeviceId
  299. Routine description:
  300. The Device Id by which the Job is being sent / received.
  301. Author:
  302. Iv Garber (IvG), May, 2000
  303. Arguments:
  304. plDeviceId [out] - Pointer to the place to put the Device Id
  305. Return Value:
  306. Standard HRESULT code
  307. --*/
  308. {
  309. HRESULT hr = S_OK;
  310. DBG_ENTER (TEXT("CFaxJobInner::get_DeviceId"), hr);
  311. hr = m_JobStatus.get_DeviceId(plDeviceId);
  312. return hr;
  313. }
  314. //
  315. //====================== GET STATUS =============================================
  316. //
  317. template<class T, const IID* piid, const CLSID *pcid>
  318. STDMETHODIMP
  319. CFaxJobInner<T, piid, pcid>::get_Status(
  320. FAX_JOB_STATUS_ENUM *pStatus
  321. )
  322. /*++
  323. Routine name : CFaxJobInner::get_Status
  324. Routine description:
  325. The current Queue Status of the Fax Job
  326. Author:
  327. Iv Garber (IvG), May, 2000
  328. Arguments:
  329. pStatus [out] - Pointer to the place to put the Bit-Wise Combination of status
  330. Return Value:
  331. Standard HRESULT code
  332. --*/
  333. {
  334. HRESULT hr = S_OK;
  335. DBG_ENTER (TEXT("CFaxJobInner::get_Status"), hr);
  336. hr = m_JobStatus.get_Status(pStatus);
  337. return hr;
  338. }
  339. //
  340. //====================== GET EXTENDED STATUS CODE ===============================
  341. //
  342. template<class T, const IID* piid, const CLSID *pcid>
  343. STDMETHODIMP
  344. CFaxJobInner<T, piid, pcid>::get_ExtendedStatusCode(
  345. FAX_JOB_EXTENDED_STATUS_ENUM *pExtendedStatusCode
  346. )
  347. /*++
  348. Routine name : CFaxJobInner::get_ExtendedStatusCode
  349. Routine description:
  350. The Code of the Extended Status of the Fax Job
  351. Author:
  352. Iv Garber (IvG), May, 2000
  353. Arguments:
  354. pExtendedStatusCode [out] - Pointer to the place to put the status code
  355. Return Value:
  356. Standard HRESULT code
  357. --*/
  358. {
  359. HRESULT hr = S_OK;
  360. DBG_ENTER (TEXT("CFaxJobInner::get_ExtendedStatusCode"), hr);
  361. hr = m_JobStatus.get_ExtendedStatusCode(pExtendedStatusCode);
  362. return hr;
  363. }
  364. //
  365. //====================== GET RETRIES =============================================
  366. //
  367. template<class T, const IID* piid, const CLSID *pcid>
  368. STDMETHODIMP
  369. CFaxJobInner<T, piid, pcid>::get_Retries(
  370. long *plRetries
  371. )
  372. /*++
  373. Routine name : CFaxJobInner::get_Retries
  374. Routine description:
  375. The number of unsuccessful retries of the Fax Job
  376. Author:
  377. Iv Garber (IvG), May, 2000
  378. Arguments:
  379. plRetries [out] - Pointer to the place to put the number of Retries
  380. Return Value:
  381. Standard HRESULT code
  382. --*/
  383. {
  384. HRESULT hr = S_OK;
  385. DBG_ENTER (TEXT("CFaxJobInner::get_Retries"), hr);
  386. hr = m_JobStatus.get_Retries(plRetries);
  387. return hr;
  388. }
  389. //
  390. //====================== GET TSID ================================================
  391. //
  392. template<class T, const IID* piid, const CLSID *pcid>
  393. STDMETHODIMP
  394. CFaxJobInner<T, piid, pcid>::get_TSID(
  395. BSTR *pbstrTSID
  396. )
  397. /*++
  398. Routine name : CFaxJobInner::get_TSID
  399. Routine description:
  400. Return Transmitting Station ID of the Job
  401. Author:
  402. Iv Garber (IvG), May, 2000
  403. Arguments:
  404. pbstrTSID [out] - pointer to the place to put the TSID
  405. Return Value:
  406. Standard HRESULT code
  407. --*/
  408. {
  409. HRESULT hr = S_OK;
  410. DBG_ENTER (TEXT("CFaxJobInner::get_TSID"), hr);
  411. hr = m_JobStatus.get_TSID(pbstrTSID);
  412. return hr;
  413. }
  414. //
  415. //====================== GET CSID ================================================
  416. //
  417. template<class T, const IID* piid, const CLSID *pcid>
  418. STDMETHODIMP
  419. CFaxJobInner<T, piid, pcid>::get_CSID(
  420. BSTR *pbstrCSID
  421. )
  422. /*++
  423. Routine name : CFaxJobInner::get_CSID
  424. Routine description:
  425. Return Called Station ID of the Job
  426. Author:
  427. Iv Garber (IvG), May, 2000
  428. Arguments:
  429. pbstrCSID [out] - pointer to the place to put the CSID
  430. Return Value:
  431. Standard HRESULT code
  432. --*/
  433. {
  434. HRESULT hr = S_OK;
  435. DBG_ENTER (TEXT("CFaxJobInner::get_CSID"), hr);
  436. hr = m_JobStatus.get_CSID(pbstrCSID);
  437. return hr;
  438. }
  439. //
  440. //====================== GET EXTENDED STATUS =======================================
  441. //
  442. template<class T, const IID* piid, const CLSID *pcid>
  443. STDMETHODIMP
  444. CFaxJobInner<T, piid, pcid>::get_ExtendedStatus(
  445. BSTR *pbstrExtendedStatus
  446. )
  447. /*++
  448. Routine name : CFaxJobInner::get_ExtendedStatus
  449. Routine description:
  450. Return String Description of the Extended Status of the Job
  451. Author:
  452. Iv Garber (IvG), May, 2000
  453. Arguments:
  454. pbstrExtendedStatus [out] - pointer to the place to put the Extended Status
  455. Return Value:
  456. Standard HRESULT code
  457. --*/
  458. {
  459. HRESULT hr = S_OK;
  460. DBG_ENTER (TEXT("CFaxJobInner::get_ExtendedStatus"), hr);
  461. hr = m_JobStatus.get_ExtendedStatus(pbstrExtendedStatus);
  462. return hr;
  463. }
  464. //
  465. //====================== GET SUBJECT ================================================
  466. //
  467. template<class T, const IID* piid, const CLSID *pcid>
  468. STDMETHODIMP
  469. CFaxJobInner<T, piid, pcid>::get_Subject(
  470. BSTR *pbstrSubject
  471. )
  472. /*++
  473. Routine name : CFaxJobInner::get_Subject
  474. Routine description:
  475. Return the Subject field of the Cover Page
  476. Author:
  477. Iv Garber (IvG), May, 2000
  478. Arguments:
  479. pbstrSubject [out] - pointer to the place to put Subject contents
  480. Return Value:
  481. Standard HRESULT code
  482. --*/
  483. {
  484. HRESULT hr = S_OK;
  485. DBG_ENTER (TEXT("CFaxJobInner::get_Subject"), hr);
  486. hr = GetBstr(pbstrSubject, m_bstrSubject);
  487. if (FAILED(hr))
  488. {
  489. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  490. return hr;
  491. }
  492. return hr;
  493. }
  494. //
  495. //====================== GET CALLER ID ================================================
  496. //
  497. template<class T, const IID* piid, const CLSID *pcid>
  498. STDMETHODIMP
  499. CFaxJobInner<T, piid, pcid>::get_CallerId(
  500. BSTR *pbstrCallerId
  501. )
  502. /*++
  503. Routine name : CFaxJobInner::get_CallerId
  504. Routine description:
  505. Return the Caller Id of Job's Phone Call
  506. Author:
  507. Iv Garber (IvG), May, 2000
  508. Arguments:
  509. pbstrCallerId [out] - pointer to the place to put the Caller Id
  510. Return Value:
  511. Standard HRESULT code
  512. --*/
  513. {
  514. HRESULT hr = S_OK;
  515. DBG_ENTER (TEXT("CFaxJobInner::get_CallerId"), hr);
  516. hr = m_JobStatus.get_CallerId(pbstrCallerId);
  517. return hr;
  518. }
  519. //
  520. //====================== GET ROUTING INFORMATION ======================================
  521. //
  522. template<class T, const IID* piid, const CLSID *pcid>
  523. STDMETHODIMP
  524. CFaxJobInner<T, piid, pcid>::get_RoutingInformation(
  525. BSTR *pbstrRoutingInformation
  526. )
  527. /*++
  528. Routine name : CFaxJobInner::get_RoutingInformation
  529. Routine description:
  530. Return the Routing Information of the Job
  531. Author:
  532. Iv Garber (IvG), May, 2000
  533. Arguments:
  534. pbstrRoutingInformation [out] - pointer to place to put Routing Information
  535. Return Value:
  536. Standard HRESULT code
  537. --*/
  538. {
  539. HRESULT hr = S_OK;
  540. DBG_ENTER (TEXT("CFaxJobInner::get_RoutingInformation"), hr);
  541. hr = m_JobStatus.get_RoutingInformation(pbstrRoutingInformation);
  542. return hr;
  543. }
  544. //
  545. //====================== GET DOCUMENT NAME ================================================
  546. //
  547. template<class T, const IID* piid, const CLSID *pcid>
  548. STDMETHODIMP
  549. CFaxJobInner<T, piid, pcid>::get_DocumentName(
  550. BSTR *pbstrDocumentName
  551. )
  552. /*++
  553. Routine name : CFaxJobInner::get_DocumentName
  554. Routine description:
  555. Return the Friendly Name of the Document
  556. Author:
  557. Iv Garber (IvG), May, 2000
  558. Arguments:
  559. pbstrDocumentName [out] - pointer to the place to put Document Name
  560. Return Value:
  561. Standard HRESULT code
  562. --*/
  563. {
  564. HRESULT hr = S_OK;
  565. DBG_ENTER (TEXT("CFaxJobInner::get_DocumentName"), hr);
  566. hr = GetBstr(pbstrDocumentName, m_bstrDocumentName);
  567. if (FAILED(hr))
  568. {
  569. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  570. return hr;
  571. }
  572. return hr;
  573. }
  574. //
  575. //====================== GET PAGES ================================================
  576. //
  577. template<class T, const IID* piid, const CLSID *pcid>
  578. STDMETHODIMP
  579. CFaxJobInner<T, piid, pcid>::get_Pages(
  580. long *plPages
  581. )
  582. /*++
  583. Routine name : CFaxJobInner::get_Pages
  584. Routine description:
  585. Return total number of pages of the message
  586. Author:
  587. Iv Garber (IvG), May, 2000
  588. Arguments:
  589. plPages [out] - Pointer to the place to put the value
  590. Return Value:
  591. Standard HRESULT code
  592. --*/
  593. {
  594. HRESULT hr = S_OK;
  595. DBG_ENTER (TEXT("CFaxJobInner::get_Pages"), hr);
  596. hr = m_JobStatus.get_Pages(plPages);
  597. return hr;
  598. }
  599. //
  600. //====================== GET PRIORITY ================================================
  601. //
  602. template<class T, const IID* piid, const CLSID *pcid>
  603. STDMETHODIMP
  604. CFaxJobInner<T, piid, pcid>::get_Priority(
  605. FAX_PRIORITY_TYPE_ENUM *pPriority
  606. )
  607. /*++
  608. Routine name : CFaxJobInner::get_Priority
  609. Routine description:
  610. Return the Priority of Fax Job
  611. Author:
  612. Iv Garber (IvG), May, 2000
  613. Arguments:
  614. pPriority [out] - Pointer to the place to put the Priority
  615. Return Value:
  616. Standard HRESULT code
  617. --*/
  618. {
  619. HRESULT hr = S_OK;
  620. DBG_ENTER (TEXT("CFaxJobInner::get_Priority"), hr);
  621. //
  622. // Check that we can write to the given pointer
  623. //
  624. if (::IsBadWritePtr(pPriority, sizeof(FAX_PRIORITY_TYPE_ENUM)))
  625. {
  626. //
  627. // Got Bad Return Pointer
  628. //
  629. hr = E_POINTER;
  630. AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr);
  631. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr"), hr);
  632. return hr;
  633. }
  634. *pPriority = m_Priority;
  635. return hr;
  636. }
  637. //
  638. //====================== GET AVAILABLE OPERATIONS ==================================
  639. //
  640. template<class T, const IID* piid, const CLSID *pcid>
  641. STDMETHODIMP
  642. CFaxJobInner<T, piid, pcid>::get_AvailableOperations(
  643. FAX_JOB_OPERATIONS_ENUM *pAvailableOperations
  644. )
  645. /*++
  646. Routine name : CFaxJobInner::get_AvailableOperations
  647. Routine description:
  648. The operations available for the Fax Job
  649. Author:
  650. Iv Garber (IvG), May, 2000
  651. Arguments:
  652. pAvailableOperations [out] - Pointer to the place to put the Bit-Wise Combination of result
  653. Return Value:
  654. Standard HRESULT code
  655. --*/
  656. {
  657. HRESULT hr = S_OK;
  658. DBG_ENTER (TEXT("CFaxJobInner::get_AvailableOperations"), hr);
  659. hr = m_JobStatus.get_AvailableOperations(pAvailableOperations);
  660. return hr;
  661. }
  662. //
  663. //====================== GET SUBMISSION ID ================================================
  664. //
  665. template<class T, const IID* piid, const CLSID *pcid>
  666. STDMETHODIMP
  667. CFaxJobInner<T, piid, pcid>::get_SubmissionId(
  668. BSTR *pbstrSubmissionId
  669. )
  670. /*++
  671. Routine name : CFaxJobInner::get_SubmissionId
  672. Routine description:
  673. Return Submission ID of the Job
  674. Author:
  675. Iv Garber (IvG), May, 2000
  676. Arguments:
  677. pbstrSubmissionId [out] - pointer to the place to put the Submission ID
  678. Return Value:
  679. Standard HRESULT code
  680. --*/
  681. {
  682. HRESULT hr = S_OK;
  683. DBG_ENTER (TEXT("CFaxJobInner::get_SubmissionId"), hr);
  684. //
  685. // Check that we can write to the given pointer
  686. //
  687. if (::IsBadWritePtr(pbstrSubmissionId, sizeof(BSTR)))
  688. {
  689. //
  690. // got bad pointer
  691. //
  692. hr = E_POINTER;
  693. AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr);
  694. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr()"), hr);
  695. return hr;
  696. }
  697. //
  698. // Translate m_dwlBroadcastId into BSTR
  699. //
  700. TCHAR tcBuffer[25];
  701. BSTR bstrTemp;
  702. ::_i64tot(m_dwlBroadcastId, tcBuffer, 16);
  703. bstrTemp = ::SysAllocString(tcBuffer);
  704. if (!bstrTemp)
  705. {
  706. //
  707. // Not enough memory
  708. //
  709. hr = E_OUTOFMEMORY;
  710. AtlReportError(*pcid, IDS_ERROR_OUTOFMEMORY, *piid, hr);
  711. CALL_FAIL(MEM_ERR, _T("SysAllocString()"), hr);
  712. return hr;
  713. }
  714. *pbstrSubmissionId = bstrTemp;
  715. return hr;
  716. }
  717. //
  718. //====================== GET RECIPIENT ================================================
  719. //
  720. template<class T, const IID* piid, const CLSID *pcid>
  721. STDMETHODIMP
  722. CFaxJobInner<T, piid, pcid>::get_Recipient(
  723. /*[out, retval] */IFaxRecipient **ppRecipient
  724. )
  725. /*++
  726. Routine name : CFaxJobInner::get_Recipient
  727. Routine description:
  728. Return Job's Recipient Information
  729. Author:
  730. Iv Garber (IvG), May, 2000
  731. Arguments:
  732. ppRecipient [out] - Ptr to the Place to put Recipient Information
  733. Return Value:
  734. Standard HRESULT code
  735. --*/
  736. {
  737. HRESULT hr = S_OK;
  738. DBG_ENTER (_T("CFaxJobInner::get_Recipient"), hr);
  739. //
  740. // Check that we can write to the given pointer
  741. //
  742. if (::IsBadWritePtr(ppRecipient, sizeof(IFaxRecipient* )))
  743. {
  744. //
  745. // got bad pointer
  746. //
  747. hr = E_POINTER;
  748. AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr);
  749. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr()"), hr);
  750. return hr;
  751. }
  752. if (!m_pRecipient)
  753. {
  754. //
  755. // First Time Calling. Take the Recipient Info from Server
  756. //
  757. //
  758. // Get Fax Server Handle
  759. //
  760. HANDLE hFaxHandle = NULL;
  761. hr = GetFaxHandle(&hFaxHandle);
  762. if (FAILED(hr))
  763. {
  764. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  765. return hr;
  766. }
  767. //
  768. // Get Personal Profile Info
  769. //
  770. CFaxPtr<FAX_PERSONAL_PROFILE> pPersonalProfile;
  771. if (!FaxGetRecipientInfo(hFaxHandle, m_dwlMessageId, FAX_MESSAGE_FOLDER_QUEUE, &pPersonalProfile))
  772. {
  773. //
  774. // Failed to get Personal Profile Info
  775. //
  776. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  777. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  778. CALL_FAIL(GENERAL_ERR, _T("FaxGetRecipientInfo()"), hr);
  779. return hr;
  780. }
  781. //
  782. // Check that pPersonalProfile is valid
  783. //
  784. if (!pPersonalProfile || pPersonalProfile->dwSizeOfStruct != sizeof(FAX_PERSONAL_PROFILE))
  785. {
  786. //
  787. // Failed to Get Personal Profile
  788. //
  789. hr = E_FAIL;
  790. AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr);
  791. CALL_FAIL(GENERAL_ERR, _T("Invalid pPersonalProfile"), hr);
  792. return hr;
  793. }
  794. //
  795. // Create Recipient Object
  796. //
  797. hr = CComObject<CFaxRecipient>::CreateInstance(&m_pRecipient);
  798. if (FAILED(hr) || !m_pRecipient)
  799. {
  800. hr = E_OUTOFMEMORY;
  801. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  802. CALL_FAIL(GENERAL_ERR, _T("CComObject<CFaxRecipient>::CreateInstance(&m_pRecipient)"), hr);
  803. return hr;
  804. }
  805. //
  806. // We want Recipient object to live
  807. //
  808. m_pRecipient->AddRef();
  809. //
  810. // Fill the Data
  811. //
  812. hr = m_pRecipient->PutRecipientProfile(pPersonalProfile);
  813. if (FAILED(hr))
  814. {
  815. //
  816. // Failed to fill the Recipient's Object with RPC's data
  817. //
  818. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  819. CALL_FAIL(GENERAL_ERR, _T("m_pRecipient->PutRecipientProfile(pPersonalProfile)"), hr);
  820. m_pRecipient->Release();
  821. m_pRecipient = NULL;
  822. return hr;
  823. }
  824. }
  825. //
  826. // Return Recipient Object to Caller
  827. //
  828. hr = m_pRecipient->QueryInterface(ppRecipient);
  829. if (FAILED(hr))
  830. {
  831. //
  832. // Failed to Query Interface
  833. //
  834. AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr);
  835. CALL_FAIL(MEM_ERR, _T("CComObject<CFaxRecipient>::QueryInterface()"), hr);
  836. return hr;
  837. }
  838. return hr;
  839. }
  840. //
  841. //====================== GET SENDER ================================================
  842. //
  843. template<class T, const IID* piid, const CLSID *pcid>
  844. STDMETHODIMP
  845. CFaxJobInner<T, piid, pcid>::get_Sender(
  846. /*[out, retval] */IFaxSender **ppSender
  847. )
  848. /*++
  849. Routine name : CFaxJobInner::get_Sender
  850. Routine description:
  851. Return Job's Sender Information
  852. Author:
  853. Iv Garber (IvG), May, 2000
  854. Arguments:
  855. ppSender [out] - Ptr to the Place to put Sender Information
  856. Return Value:
  857. Standard HRESULT code
  858. --*/
  859. {
  860. HRESULT hr = S_OK;
  861. DBG_ENTER (_T("CFaxJobInner::get_Sender"), hr);
  862. //
  863. // Check that we can write to the given pointer
  864. //
  865. if (::IsBadWritePtr(ppSender, sizeof(IFaxSender* )))
  866. {
  867. //
  868. // got bad pointer
  869. //
  870. hr = E_POINTER;
  871. AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr);
  872. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr()"), hr);
  873. return hr;
  874. }
  875. if (!m_pSender)
  876. {
  877. //
  878. // The Function is called for the First Time. Let's bring Sender's Data from Server
  879. //
  880. //
  881. // Get Fax Server Handle
  882. //
  883. HANDLE hFaxHandle = NULL;
  884. hr = GetFaxHandle(&hFaxHandle);
  885. if (FAILED(hr))
  886. {
  887. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  888. return hr;
  889. }
  890. //
  891. // Get Personal Profile Info
  892. //
  893. CFaxPtr<FAX_PERSONAL_PROFILE> pPersonalProfile;
  894. if (!FaxGetSenderInfo(hFaxHandle, m_dwlMessageId, FAX_MESSAGE_FOLDER_QUEUE, &pPersonalProfile))
  895. {
  896. //
  897. // Failed to get Personal Profile Info
  898. //
  899. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  900. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  901. CALL_FAIL(GENERAL_ERR, _T("FaxGetSenderInfo()"), hr);
  902. return hr;
  903. }
  904. //
  905. // Check that pPersonalProfile is valid
  906. //
  907. if (!pPersonalProfile || pPersonalProfile->dwSizeOfStruct != sizeof(FAX_PERSONAL_PROFILE))
  908. {
  909. //
  910. // Failed to Get Personal Profile
  911. //
  912. hr = E_FAIL;
  913. AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr);
  914. CALL_FAIL(GENERAL_ERR, _T("Invalid pPersonalProfile"), hr);
  915. return hr;
  916. }
  917. //
  918. // Create Sender Object
  919. //
  920. hr = CComObject<CFaxSender>::CreateInstance(&m_pSender);
  921. if (FAILED(hr) || !m_pSender)
  922. {
  923. hr = E_OUTOFMEMORY;
  924. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  925. CALL_FAIL(GENERAL_ERR, _T("CComObject<CFaxSender>::CreateInstance(&m_pSender)"), hr);
  926. return hr;
  927. }
  928. //
  929. // We want Sender object to live
  930. //
  931. m_pSender->AddRef();
  932. //
  933. // Fill the Data
  934. //
  935. hr = m_pSender->PutSenderProfile(pPersonalProfile);
  936. if (FAILED(hr))
  937. {
  938. //
  939. // Failed to fill the Sender's Object with RPC's data
  940. //
  941. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  942. CALL_FAIL(GENERAL_ERR, _T("m_pSender->PutSenderProfile(pPersonalProfile)"), hr);
  943. m_pSender->Release();
  944. m_pSender = NULL;
  945. return hr;
  946. }
  947. }
  948. //
  949. // Return Sender Object to Caller
  950. //
  951. hr = m_pSender->QueryInterface(ppSender);
  952. if (FAILED(hr))
  953. {
  954. //
  955. // Failed to Query Interface
  956. //
  957. AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr);
  958. CALL_FAIL(MEM_ERR, _T("CComObject<CFaxSender>::QueryInterface()"), hr);
  959. return hr;
  960. }
  961. return hr;
  962. }
  963. //
  964. //========================= GET ORIGINAL SCHEDULED TIME ===============================
  965. //
  966. template<class T, const IID* piid, const CLSID *pcid>
  967. STDMETHODIMP
  968. CFaxJobInner<T, piid, pcid>::get_OriginalScheduledTime(
  969. DATE *pdateOriginalScheduledTime
  970. )
  971. /*++
  972. Routine name : CFaxJobInner::get_OriginalScheduledTime
  973. Routine description:
  974. Return Time the Job was originally scheduled
  975. Author:
  976. Iv Garber (IvG), May, 2000
  977. Arguments:
  978. pdateOriginalScheduledTime [out] - pointer to place to put Original Scheduled Time
  979. Return Value:
  980. Standard HRESULT code
  981. --*/
  982. {
  983. HRESULT hr = S_OK;
  984. DBG_ENTER (TEXT("CFaxJobInner::get_OriginalScheduledTime"), hr);
  985. //
  986. // Check that we can write to the given pointer
  987. //
  988. if (::IsBadWritePtr(pdateOriginalScheduledTime, sizeof(DATE)))
  989. {
  990. //
  991. // Got Bad Ptr
  992. //
  993. hr = E_POINTER;
  994. AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr);
  995. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr()"), hr);
  996. return hr;
  997. }
  998. hr = SystemTime2LocalDate(m_tmOriginalScheduleTime, pdateOriginalScheduledTime);
  999. if (FAILED(hr))
  1000. {
  1001. //
  1002. // Failed to convert the system time to localized variant date
  1003. //
  1004. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1005. return hr;
  1006. }
  1007. return hr;
  1008. }
  1009. //
  1010. //========================= GET SUBMISSION TIME ===============================
  1011. //
  1012. template<class T, const IID* piid, const CLSID *pcid>
  1013. STDMETHODIMP
  1014. CFaxJobInner<T, piid, pcid>::get_SubmissionTime(
  1015. DATE *pdateSubmissionTime
  1016. )
  1017. /*++
  1018. Routine name : CFaxJobInner::get_SubmissionTime
  1019. Routine description:
  1020. Return Time the Job was submitted
  1021. Author:
  1022. Iv Garber (IvG), May, 2000
  1023. Arguments:
  1024. pdateSubmissionTime [out] - pointer to place to put Submission Time
  1025. Return Value:
  1026. Standard HRESULT code
  1027. --*/
  1028. {
  1029. HRESULT hr = S_OK;
  1030. DBG_ENTER (TEXT("CFaxJobInner::get_SubmissionTime"), hr);
  1031. //
  1032. // Check that we can write to the given pointer
  1033. //
  1034. if (::IsBadWritePtr(pdateSubmissionTime, sizeof(DATE)))
  1035. {
  1036. //
  1037. // Got Bad Ptr
  1038. //
  1039. hr = E_POINTER;
  1040. AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr);
  1041. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr()"), hr);
  1042. return hr;
  1043. }
  1044. hr = SystemTime2LocalDate(m_tmSubmissionTime, pdateSubmissionTime);
  1045. if (FAILED(hr))
  1046. {
  1047. //
  1048. // Failed to convert the system time to localized variant date
  1049. //
  1050. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1051. return hr;
  1052. }
  1053. return hr;
  1054. }
  1055. //
  1056. //========================= GET SCHEDULED TIME ===============================
  1057. //
  1058. template<class T, const IID* piid, const CLSID *pcid>
  1059. STDMETHODIMP
  1060. CFaxJobInner<T, piid, pcid>::get_ScheduledTime(
  1061. DATE *pdateScheduledTime
  1062. )
  1063. /*++
  1064. Routine name : CFaxJobInner::get_ScheduledTime
  1065. Routine description:
  1066. Return Time the Job is scheduled
  1067. Author:
  1068. Iv Garber (IvG), May, 2000
  1069. Arguments:
  1070. pdateScheduledTime [out] - pointer to place to put Scheduled Time
  1071. Return Value:
  1072. Standard HRESULT code
  1073. --*/
  1074. {
  1075. HRESULT hr = S_OK;
  1076. DBG_ENTER (TEXT("CFaxJobInner::get_ScheduledTime"), hr);
  1077. hr = m_JobStatus.get_ScheduledTime(pdateScheduledTime);
  1078. return hr;
  1079. }
  1080. //
  1081. //========================= GET TRANSMISSION START ===============================
  1082. //
  1083. template<class T, const IID* piid, const CLSID *pcid>
  1084. STDMETHODIMP
  1085. CFaxJobInner<T, piid, pcid>::get_TransmissionStart(
  1086. DATE *pdateTransmissionStart
  1087. )
  1088. /*++
  1089. Routine name : CFaxJobInner::get_TransmissionStart
  1090. Routine description:
  1091. Return Time the Job is started to transmit
  1092. Author:
  1093. Iv Garber (IvG), May, 2000
  1094. Arguments:
  1095. pdateTransmissionStart [out] - pointer to place to put the Transmission Start
  1096. Return Value:
  1097. Standard HRESULT code
  1098. --*/
  1099. {
  1100. HRESULT hr = S_OK;
  1101. DBG_ENTER (TEXT("CFaxJobInner::get_TransmissionStart"), hr);
  1102. hr = m_JobStatus.get_TransmissionStart(pdateTransmissionStart);
  1103. return hr;
  1104. }
  1105. //
  1106. //====================== GET GROUP BROADCAST REPORTS ========================
  1107. //
  1108. template<class T, const IID* piid, const CLSID *pcid>
  1109. STDMETHODIMP
  1110. CFaxJobInner<T, piid, pcid>::get_GroupBroadcastReceipts(
  1111. VARIANT_BOOL *pbGroupBroadcastReceipts
  1112. )
  1113. /*++
  1114. Routine name : CFaxJobInner::get_GroupBroadcastReceipts
  1115. Routine description:
  1116. Return whether Receipts are grouped
  1117. Author:
  1118. Iv Garber (IvG), May, 2000
  1119. Arguments:
  1120. pbGroupBroadcastReceipts [out] - pointer to the place to put the value
  1121. Return Value:
  1122. Standard HRESULT code
  1123. --*/
  1124. {
  1125. HRESULT hr = S_OK;
  1126. DBG_ENTER (TEXT("CFaxJobInner::get_GroupBroadcastReceipts"), hr);
  1127. hr = GetVariantBool(pbGroupBroadcastReceipts, ((m_dwReceiptType & DRT_GRP_PARENT) ? VARIANT_TRUE : VARIANT_FALSE));
  1128. if (FAILED(hr))
  1129. {
  1130. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1131. return hr;
  1132. }
  1133. return hr;
  1134. }
  1135. //
  1136. //====================== GET RECEIPT TYPE ========================
  1137. //
  1138. template<class T, const IID* piid, const CLSID *pcid>
  1139. STDMETHODIMP
  1140. CFaxJobInner<T, piid, pcid>::get_ReceiptType(
  1141. FAX_RECEIPT_TYPE_ENUM *pReceiptType
  1142. )
  1143. /*++
  1144. Routine name : CFaxJobInner::get_ReceiptType
  1145. Routine description:
  1146. Return the type of the receipts
  1147. Author:
  1148. Iv Garber (IvG), May, 2000
  1149. Arguments:
  1150. pbReceiptType [out] - pointer to the place to put the value
  1151. Return Value:
  1152. Standard HRESULT code
  1153. --*/
  1154. {
  1155. HRESULT hr = S_OK;
  1156. DBG_ENTER (TEXT("CFaxJobInner::get_ReceiptType"), hr);
  1157. //
  1158. // Check that we can write to the given pointer
  1159. //
  1160. if (::IsBadWritePtr(pReceiptType, sizeof(FAX_RECEIPT_TYPE_ENUM)))
  1161. {
  1162. //
  1163. // Got Bad Ptr
  1164. //
  1165. hr = E_POINTER;
  1166. AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr);
  1167. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr()"), hr);
  1168. return hr;
  1169. }
  1170. //
  1171. // return the delivery report type WITHOUT the modifiers bit
  1172. //
  1173. *pReceiptType = FAX_RECEIPT_TYPE_ENUM((m_dwReceiptType) & (~DRT_MODIFIERS));
  1174. return hr;
  1175. }
  1176. //
  1177. //====================== COPY TIFF ================================================
  1178. //
  1179. template<class T, const IID* piid, const CLSID *pcid>
  1180. STDMETHODIMP
  1181. CFaxJobInner<T, piid, pcid>::CopyTiff(
  1182. /*[in]*/ BSTR bstrTiffPath
  1183. )
  1184. /*++
  1185. Routine name : CFaxJobInner::CopyTiff
  1186. Routine description:
  1187. Copies the Job's Tiff Image to a file on the local computer.
  1188. Author:
  1189. Iv Garber (IvG), May, 2000
  1190. Arguments:
  1191. bstrTiffPath [in] - the file to copy to
  1192. Return Value:
  1193. Standard HRESULT code
  1194. --*/
  1195. {
  1196. HRESULT hr = S_OK;
  1197. HANDLE hFaxHandle = NULL;
  1198. DBG_ENTER (TEXT("CFaxJobInner::CopyTiff"), hr, _T("%s"), bstrTiffPath);
  1199. //
  1200. // Get Fax Server Handle
  1201. //
  1202. hr = GetFaxHandle(&hFaxHandle);
  1203. if (FAILED(hr))
  1204. {
  1205. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1206. return hr;
  1207. }
  1208. if (!FaxGetMessageTiff(hFaxHandle, m_dwlMessageId, FAX_MESSAGE_FOLDER_QUEUE, bstrTiffPath))
  1209. {
  1210. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  1211. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1212. CALL_FAIL(GENERAL_ERR,
  1213. _T("FaxGetMessageTiff(hFaxHandle, m_pJobInfo->dwlMessageId, FAX_MESSAGE_FOLDER_QUEUE, bstrTiffPath)"),
  1214. hr);
  1215. return hr;
  1216. }
  1217. return hr;
  1218. }
  1219. //
  1220. //====================== CANCEL ================================================
  1221. //
  1222. template<class T, const IID* piid, const CLSID *pcid>
  1223. STDMETHODIMP
  1224. CFaxJobInner<T, piid, pcid>::Cancel(
  1225. )
  1226. /*++
  1227. Routine name : CFaxJobInner::Cancel
  1228. Routine description:
  1229. Cancel the Job
  1230. Author:
  1231. Iv Garber (IvG), May, 2000
  1232. Return Value:
  1233. Standard HRESULT code
  1234. --*/
  1235. {
  1236. HRESULT hr = S_OK;
  1237. DBG_ENTER (TEXT("CFaxJobInner::Cancel"), hr);
  1238. hr = UpdateJob(JC_DELETE);
  1239. return hr;
  1240. }
  1241. //
  1242. //====================== PAUSE ================================================
  1243. //
  1244. template<class T, const IID* piid, const CLSID *pcid>
  1245. STDMETHODIMP
  1246. CFaxJobInner<T, piid, pcid>::Pause(
  1247. )
  1248. /*++
  1249. Routine name : CFaxJobInner::Pause
  1250. Routine description:
  1251. Pause the Job
  1252. Author:
  1253. Iv Garber (IvG), May, 2000
  1254. Return Value:
  1255. Standard HRESULT code
  1256. --*/
  1257. {
  1258. HRESULT hr = S_OK;
  1259. HANDLE hFaxHandle = NULL;
  1260. hr = UpdateJob(JC_PAUSE);
  1261. return hr;
  1262. }
  1263. //
  1264. //====================== RESUME ================================================
  1265. //
  1266. template<class T, const IID* piid, const CLSID *pcid>
  1267. STDMETHODIMP
  1268. CFaxJobInner<T, piid, pcid>::Resume(
  1269. )
  1270. /*++
  1271. Routine name : CFaxJobInner::Resume
  1272. Routine description:
  1273. Resume the Job
  1274. Author:
  1275. Iv Garber (IvG), May, 2000
  1276. Return Value:
  1277. Standard HRESULT code
  1278. --*/
  1279. {
  1280. HRESULT hr = S_OK;
  1281. DBG_ENTER (TEXT("CFaxJobInner::Resume"), hr);
  1282. hr = UpdateJob(JC_RESUME);
  1283. return hr;
  1284. }
  1285. //
  1286. //====================== RESTART ================================================
  1287. //
  1288. template<class T, const IID* piid, const CLSID *pcid>
  1289. STDMETHODIMP
  1290. CFaxJobInner<T, piid, pcid>::Restart(
  1291. )
  1292. /*++
  1293. Routine name : CFaxJobInner::Restart
  1294. Routine description:
  1295. Restart the Job
  1296. Author:
  1297. Iv Garber (IvG), May, 2000
  1298. Return Value:
  1299. Standard HRESULT code
  1300. --*/
  1301. {
  1302. HRESULT hr = S_OK;
  1303. DBG_ENTER (TEXT("CFaxJobInner::Restart"), hr);
  1304. hr = UpdateJob(JC_RESTART);
  1305. return hr;
  1306. }
  1307. //
  1308. //====================== GET TRANSMISSION END ======================================
  1309. //
  1310. template<class T, const IID* piid, const CLSID *pcid>
  1311. STDMETHODIMP
  1312. CFaxJobInner<T, piid, pcid>::get_TransmissionEnd(
  1313. DATE *pdateTransmissionEnd
  1314. )
  1315. /*++
  1316. Routine name : CFaxJobInner::get_TransmissionEnd
  1317. Routine description:
  1318. Return Job's Transmission End
  1319. Author:
  1320. Iv Garber (IvG), May, 2000
  1321. Arguments:
  1322. pdateTransmissionEnd [out] - pointer to the place to put the value
  1323. Return Value:
  1324. Standard HRESULT code
  1325. --*/
  1326. {
  1327. HRESULT hr = S_OK;
  1328. DBG_ENTER (TEXT("CFaxJobInner::get_TransmissionEnd"), hr);
  1329. hr = m_JobStatus.get_TransmissionEnd(pdateTransmissionEnd);
  1330. return hr;
  1331. }
  1332. //
  1333. //====================== REFRESH ================================================
  1334. //
  1335. template<class T, const IID* piid, const CLSID *pcid>
  1336. STDMETHODIMP
  1337. CFaxJobInner<T, piid, pcid>::Refresh(
  1338. )
  1339. /*++
  1340. Routine name : CFaxJobInner::Refresh
  1341. Routine description:
  1342. Refresh the Job
  1343. Author:
  1344. Iv Garber (IvG), May, 2000
  1345. Return Value:
  1346. Standard HRESULT code
  1347. --*/
  1348. {
  1349. HRESULT hr = S_OK;
  1350. HANDLE hFaxHandle = NULL;
  1351. DBG_ENTER (TEXT("CFaxJobInner::Refresh"), hr);
  1352. //
  1353. // Get Fax Server Handle
  1354. //
  1355. hr = GetFaxHandle(&hFaxHandle);
  1356. if (FAILED(hr))
  1357. {
  1358. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1359. return hr;
  1360. }
  1361. CFaxPtr<FAX_JOB_ENTRY_EX> pJobInfo;
  1362. if (!FaxGetJobEx(hFaxHandle, m_dwlMessageId, &pJobInfo))
  1363. {
  1364. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  1365. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1366. CALL_FAIL(GENERAL_ERR, _T("FaxGetJobEx(hFaxHandle, m_pJobInfo->dwlMessageId, &m_pJobInfo)"), hr);
  1367. return hr;
  1368. }
  1369. hr = Init(pJobInfo, NULL);
  1370. return hr;
  1371. }
  1372. //
  1373. //====================== UPDATE JOB ================================================
  1374. //
  1375. template<class T, const IID* piid, const CLSID *pcid>
  1376. STDMETHODIMP
  1377. CFaxJobInner<T, piid, pcid>::UpdateJob(
  1378. FAX_ENUM_JOB_COMMANDS cmdToPerform
  1379. )
  1380. /*++
  1381. Routine name : CFaxJobInner::Update
  1382. Routine description:
  1383. Perform the desired operation on the Job
  1384. Author:
  1385. Iv Garber (IvG), June, 2000
  1386. Return Value:
  1387. Standard HRESULT code
  1388. --*/
  1389. {
  1390. HRESULT hr = S_OK;
  1391. HANDLE hFaxHandle = NULL;
  1392. DBG_ENTER (TEXT("CFaxJobInner::Update"), hr, _T("command is : %d"), cmdToPerform);
  1393. //
  1394. // Get Fax Server Handle
  1395. //
  1396. hr = GetFaxHandle(&hFaxHandle);
  1397. if (FAILED(hr))
  1398. {
  1399. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1400. return hr;
  1401. }
  1402. FAX_JOB_ENTRY fje = {0};
  1403. fje.SizeOfStruct = sizeof(FAX_JOB_ENTRY);
  1404. if (!FaxSetJob(hFaxHandle, m_JobStatus.GetJobId(), cmdToPerform, &fje))
  1405. {
  1406. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  1407. AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr);
  1408. CALL_FAIL(GENERAL_ERR,
  1409. _T("FaxSetJob(hFaxHandle, m_JobStatus.GtJobId(), cmdToPerform, &fje)"),
  1410. hr);
  1411. return hr;
  1412. }
  1413. return hr;
  1414. }
  1415. #endif // __FAXJOBINNER_H_