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.

1625 lines
31 KiB

  1. // FaxDoc.cpp : Implementation of CFaxDoc
  2. #include "stdafx.h"
  3. #include "FaxDoc.h"
  4. #include "faxutil.h"
  5. long TotalRows;
  6. long IndexMax = 2;
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CFaxDoc
  9. STDMETHODIMP CFaxDoc::InterfaceSupportsErrorInfo(REFIID riid)
  10. {
  11. static const IID* arr[] =
  12. {
  13. &IID_IFaxDoc,
  14. };
  15. for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
  16. {
  17. if (InlineIsEqualGUID(*arr[i],riid))
  18. return S_OK;
  19. }
  20. return S_FALSE;
  21. }
  22. STDMETHODIMP CFaxDoc::get_FileName(BSTR * pVal)
  23. {
  24. BSTR tmp;
  25. if (!pVal) {
  26. return E_POINTER;
  27. }
  28. tmp = SysAllocString (m_FileName);
  29. if (!tmp && m_FileName) {
  30. return E_OUTOFMEMORY;
  31. }
  32. __try {
  33. *pVal = tmp;
  34. return S_OK;
  35. } __except (EXCEPTION_EXECUTE_HANDLER) {
  36. SysFreeString( tmp );
  37. }
  38. return E_UNEXPECTED;
  39. }
  40. STDMETHODIMP CFaxDoc::put_FileName(BSTR newVal)
  41. {
  42. BSTR tmp = SysAllocString( newVal );
  43. if (!tmp && newVal) {
  44. return E_OUTOFMEMORY;
  45. }
  46. if (m_FileName) {
  47. SysFreeString( m_FileName);
  48. }
  49. m_FileName = tmp;
  50. return S_OK;
  51. }
  52. STDMETHODIMP CFaxDoc::get_CoverpageName(BSTR * pVal)
  53. {
  54. BSTR tmp;
  55. if (!pVal) {
  56. return E_POINTER;
  57. }
  58. tmp = SysAllocString (m_FaxCoverpageInfo->CoverPageName);
  59. if (!tmp && m_FaxCoverpageInfo->CoverPageName) {
  60. return E_OUTOFMEMORY;
  61. }
  62. __try {
  63. *pVal = tmp;
  64. return S_OK;
  65. } __except (EXCEPTION_EXECUTE_HANDLER) {
  66. SysFreeString( tmp );
  67. }
  68. return E_UNEXPECTED;
  69. }
  70. STDMETHODIMP CFaxDoc::put_CoverpageName(BSTR newVal)
  71. {
  72. BSTR tmp = SysAllocString( newVal );
  73. if (!tmp && newVal) {
  74. return E_OUTOFMEMORY;
  75. }
  76. if (m_CoverpageName) {
  77. SysFreeString( m_CoverpageName);
  78. }
  79. m_CoverpageName = tmp;
  80. m_FaxCoverpageInfo->CoverPageName = m_CoverpageName;
  81. return S_OK;
  82. }
  83. STDMETHODIMP CFaxDoc::get_SendCoverpage(BOOL * pVal)
  84. {
  85. if (!pVal) {
  86. return E_POINTER;
  87. }
  88. __try {
  89. *pVal = m_SendCoverpage;
  90. return S_OK;
  91. } __except (EXCEPTION_EXECUTE_HANDLER) {
  92. }
  93. return E_UNEXPECTED;
  94. }
  95. STDMETHODIMP CFaxDoc::put_SendCoverpage(BOOL newVal)
  96. {
  97. m_SendCoverpage = newVal;
  98. return S_OK;
  99. }
  100. STDMETHODIMP CFaxDoc::get_ServerCoverpage(BOOL * pVal)
  101. {
  102. if (!pVal) {
  103. return E_POINTER;
  104. }
  105. __try {
  106. *pVal = m_FaxCoverpageInfo->UseServerCoverPage;
  107. return S_OK;
  108. } __except (EXCEPTION_EXECUTE_HANDLER) {
  109. }
  110. return E_UNEXPECTED;
  111. }
  112. STDMETHODIMP CFaxDoc::put_ServerCoverpage(BOOL newVal)
  113. {
  114. m_FaxCoverpageInfo->UseServerCoverPage = newVal;
  115. return S_OK;
  116. }
  117. STDMETHODIMP CFaxDoc::get_DiscountSend(BOOL * pVal)
  118. {
  119. if (!pVal) {
  120. return E_POINTER;
  121. }
  122. __try {
  123. *pVal = m_DiscountSend;
  124. return S_OK;
  125. } __except (EXCEPTION_EXECUTE_HANDLER) {
  126. }
  127. return E_UNEXPECTED;
  128. }
  129. STDMETHODIMP CFaxDoc::put_DiscountSend(BOOL newVal)
  130. {
  131. m_DiscountSend = newVal;
  132. m_FaxJobParams->ScheduleAction = m_DiscountSend ? JSA_DISCOUNT_PERIOD : JSA_NOW;
  133. return S_OK;
  134. }
  135. STDMETHODIMP CFaxDoc::get_RecipientName(BSTR * pVal)
  136. {
  137. BSTR tmp;
  138. if (!pVal) {
  139. return E_POINTER;
  140. }
  141. tmp = SysAllocString (m_FaxCoverpageInfo->RecName);
  142. if (!tmp && m_FaxCoverpageInfo->RecName) {
  143. return E_OUTOFMEMORY;
  144. }
  145. __try {
  146. *pVal = tmp;
  147. return S_OK;
  148. } __except (EXCEPTION_EXECUTE_HANDLER) {
  149. SysFreeString( tmp );
  150. }
  151. return E_UNEXPECTED;
  152. }
  153. STDMETHODIMP CFaxDoc::put_RecipientName(BSTR newVal)
  154. {
  155. BSTR tmp = SysAllocString( newVal );
  156. if (!tmp && newVal) {
  157. return E_OUTOFMEMORY;
  158. }
  159. if (m_RecipientName) {
  160. SysFreeString( m_RecipientName);
  161. }
  162. m_RecipientName = tmp;
  163. m_FaxCoverpageInfo->RecName = m_RecipientName;
  164. m_FaxJobParams->RecipientName = m_RecipientName;
  165. return S_OK;
  166. }
  167. STDMETHODIMP CFaxDoc::get_RecipientCompany(BSTR * pVal)
  168. {
  169. BSTR tmp;
  170. if (!pVal) {
  171. return E_POINTER;
  172. }
  173. tmp = SysAllocString (m_FaxCoverpageInfo->RecCompany);
  174. if (!tmp && m_FaxCoverpageInfo->RecCompany) {
  175. return E_OUTOFMEMORY;
  176. }
  177. __try {
  178. *pVal = tmp;
  179. return S_OK;
  180. } __except (EXCEPTION_EXECUTE_HANDLER) {
  181. SysFreeString( tmp );
  182. }
  183. return E_UNEXPECTED;
  184. }
  185. STDMETHODIMP CFaxDoc::put_RecipientCompany(BSTR newVal)
  186. {
  187. BSTR tmp = SysAllocString( newVal );
  188. if (!tmp && newVal) {
  189. return E_OUTOFMEMORY;
  190. }
  191. if (m_RecipientCompany) {
  192. SysFreeString( m_RecipientCompany);
  193. }
  194. m_RecipientCompany = tmp;
  195. m_FaxCoverpageInfo->RecCompany= m_RecipientCompany;
  196. return S_OK;
  197. }
  198. STDMETHODIMP CFaxDoc::get_RecipientAddress(BSTR * pVal)
  199. {
  200. BSTR tmp;
  201. if (!pVal) {
  202. return E_POINTER;
  203. }
  204. tmp = SysAllocString (m_FaxCoverpageInfo->RecStreetAddress);
  205. if (!tmp && m_FaxCoverpageInfo->RecStreetAddress) {
  206. return E_OUTOFMEMORY;
  207. }
  208. __try {
  209. *pVal = tmp;
  210. return S_OK;
  211. } __except (EXCEPTION_EXECUTE_HANDLER) {
  212. SysFreeString( tmp );
  213. }
  214. return E_UNEXPECTED;
  215. }
  216. STDMETHODIMP CFaxDoc::put_RecipientAddress(BSTR newVal)
  217. {
  218. BSTR tmp = SysAllocString( newVal );
  219. if (!tmp && newVal) {
  220. return E_OUTOFMEMORY;
  221. }
  222. if (m_RecipientAddress) {
  223. SysFreeString( m_RecipientAddress);
  224. }
  225. m_RecipientAddress = tmp;
  226. m_FaxCoverpageInfo->RecStreetAddress = m_RecipientAddress;
  227. return S_OK;
  228. }
  229. STDMETHODIMP CFaxDoc::get_RecipientCity(BSTR * pVal)
  230. {
  231. BSTR tmp;
  232. if (!pVal) {
  233. return E_POINTER;
  234. }
  235. tmp = SysAllocString (m_FaxCoverpageInfo->RecCity);
  236. if (!tmp && m_FaxCoverpageInfo->RecCity) {
  237. return E_OUTOFMEMORY;
  238. }
  239. __try {
  240. *pVal = tmp;
  241. return S_OK;
  242. } __except (EXCEPTION_EXECUTE_HANDLER) {
  243. SysFreeString( tmp );
  244. }
  245. return E_UNEXPECTED;
  246. }
  247. STDMETHODIMP CFaxDoc::put_RecipientCity(BSTR newVal)
  248. {
  249. BSTR tmp = SysAllocString( newVal );
  250. if (!tmp && newVal) {
  251. return E_OUTOFMEMORY;
  252. }
  253. if (m_RecipientCity) {
  254. SysFreeString( m_RecipientCity);
  255. }
  256. m_RecipientCity = tmp;
  257. m_FaxCoverpageInfo->RecCity = m_RecipientCity;
  258. return S_OK;
  259. }
  260. STDMETHODIMP CFaxDoc::get_RecipientState(BSTR * pVal)
  261. {
  262. BSTR tmp;
  263. if (!pVal) {
  264. return E_POINTER;
  265. }
  266. tmp = SysAllocString (m_FaxCoverpageInfo->RecState);
  267. if (!tmp && m_FaxCoverpageInfo->RecState) {
  268. return E_OUTOFMEMORY;
  269. }
  270. __try {
  271. *pVal = tmp;
  272. return S_OK;
  273. } __except (EXCEPTION_EXECUTE_HANDLER) {
  274. SysFreeString( tmp );
  275. }
  276. return E_UNEXPECTED;
  277. }
  278. STDMETHODIMP CFaxDoc::put_RecipientState(BSTR newVal)
  279. {
  280. BSTR tmp = SysAllocString( newVal );
  281. if (!tmp && newVal) {
  282. return E_OUTOFMEMORY;
  283. }
  284. if (m_RecipientState) {
  285. SysFreeString( m_RecipientState);
  286. }
  287. m_RecipientState = tmp;
  288. m_FaxCoverpageInfo->RecState = m_RecipientState;
  289. return S_OK;
  290. }
  291. STDMETHODIMP CFaxDoc::get_RecipientZip(BSTR * pVal)
  292. {
  293. BSTR tmp;
  294. if (!pVal) {
  295. return E_POINTER;
  296. }
  297. tmp = SysAllocString (m_FaxCoverpageInfo->RecZip);
  298. if (!tmp && m_FaxCoverpageInfo->RecZip) {
  299. return E_OUTOFMEMORY;
  300. }
  301. __try {
  302. *pVal = tmp;
  303. return S_OK;
  304. } __except (EXCEPTION_EXECUTE_HANDLER) {
  305. SysFreeString( tmp );
  306. }
  307. return E_UNEXPECTED;
  308. }
  309. STDMETHODIMP CFaxDoc::put_RecipientZip(BSTR newVal)
  310. {
  311. BSTR tmp = SysAllocString( newVal );
  312. if (!tmp && newVal) {
  313. return E_OUTOFMEMORY;
  314. }
  315. if (m_RecipientZip) {
  316. SysFreeString( m_RecipientZip);
  317. }
  318. m_RecipientZip = tmp;
  319. m_FaxCoverpageInfo->RecZip = m_RecipientZip;
  320. return S_OK;
  321. }
  322. STDMETHODIMP CFaxDoc::get_RecipientCountry(BSTR * pVal)
  323. {
  324. BSTR tmp;
  325. if (!pVal) {
  326. return E_POINTER;
  327. }
  328. tmp = SysAllocString (m_FaxCoverpageInfo->RecCountry);
  329. if (!tmp && m_FaxCoverpageInfo->RecCountry) {
  330. return E_OUTOFMEMORY;
  331. }
  332. __try {
  333. *pVal = tmp;
  334. return S_OK;
  335. } __except (EXCEPTION_EXECUTE_HANDLER) {
  336. SysFreeString( tmp );
  337. }
  338. return E_UNEXPECTED;
  339. }
  340. STDMETHODIMP CFaxDoc::put_RecipientCountry(BSTR newVal)
  341. {
  342. BSTR tmp = SysAllocString( newVal );
  343. if (!tmp && newVal) {
  344. return E_OUTOFMEMORY;
  345. }
  346. if (m_RecipientCountry) {
  347. SysFreeString( m_RecipientCountry);
  348. }
  349. m_RecipientCountry = tmp;
  350. m_FaxCoverpageInfo->RecCountry = m_RecipientCountry;
  351. return S_OK;
  352. }
  353. STDMETHODIMP CFaxDoc::get_RecipientTitle(BSTR * pVal)
  354. {
  355. BSTR tmp;
  356. if (!pVal) {
  357. return E_POINTER;
  358. }
  359. tmp = SysAllocString (m_FaxCoverpageInfo->RecTitle);
  360. if (!tmp && m_FaxCoverpageInfo->RecTitle) {
  361. return E_OUTOFMEMORY;
  362. }
  363. __try {
  364. *pVal = tmp;
  365. return S_OK;
  366. } __except (EXCEPTION_EXECUTE_HANDLER) {
  367. SysFreeString( tmp );
  368. }
  369. return E_UNEXPECTED;
  370. }
  371. STDMETHODIMP CFaxDoc::put_RecipientTitle(BSTR newVal)
  372. {
  373. BSTR tmp = SysAllocString( newVal );
  374. if (!tmp && newVal) {
  375. return E_OUTOFMEMORY;
  376. }
  377. if (m_RecipientTitle) {
  378. SysFreeString( m_RecipientTitle);
  379. }
  380. m_RecipientTitle = tmp;
  381. m_FaxCoverpageInfo->RecTitle = m_RecipientTitle;
  382. return S_OK;
  383. }
  384. STDMETHODIMP CFaxDoc::get_RecipientDepartment(BSTR * pVal)
  385. {
  386. BSTR tmp;
  387. if (!pVal) {
  388. return E_POINTER;
  389. }
  390. tmp = SysAllocString (m_FaxCoverpageInfo->RecDepartment);
  391. if (!tmp && m_FaxCoverpageInfo->RecDepartment) {
  392. return E_OUTOFMEMORY;
  393. }
  394. __try {
  395. *pVal = tmp;
  396. return S_OK;
  397. } __except (EXCEPTION_EXECUTE_HANDLER) {
  398. SysFreeString( tmp );
  399. }
  400. return E_UNEXPECTED;
  401. }
  402. STDMETHODIMP CFaxDoc::put_RecipientDepartment(BSTR newVal)
  403. {
  404. BSTR tmp = SysAllocString( newVal );
  405. if (!tmp && newVal) {
  406. return E_OUTOFMEMORY;
  407. }
  408. if (m_RecipientDepartment) {
  409. SysFreeString( m_RecipientDepartment);
  410. }
  411. m_RecipientDepartment = tmp;
  412. m_FaxCoverpageInfo->RecDepartment = m_RecipientDepartment;
  413. return S_OK;
  414. }
  415. STDMETHODIMP CFaxDoc::get_RecipientOffice(BSTR * pVal)
  416. {
  417. BSTR tmp;
  418. if (!pVal) {
  419. return E_POINTER;
  420. }
  421. tmp = SysAllocString (m_FaxCoverpageInfo->RecOfficeLocation);
  422. if (!tmp && m_FaxCoverpageInfo->RecOfficeLocation) {
  423. return E_OUTOFMEMORY;
  424. }
  425. __try {
  426. *pVal = tmp;
  427. return S_OK;
  428. } __except (EXCEPTION_EXECUTE_HANDLER) {
  429. SysFreeString( tmp );
  430. }
  431. return E_UNEXPECTED;
  432. }
  433. STDMETHODIMP CFaxDoc::put_RecipientOffice(BSTR newVal)
  434. {
  435. BSTR tmp = SysAllocString( newVal );
  436. if (!tmp && newVal) {
  437. return E_OUTOFMEMORY;
  438. }
  439. if (m_RecipientOffice) {
  440. SysFreeString( m_RecipientOffice);
  441. }
  442. m_RecipientOffice = tmp;
  443. m_FaxCoverpageInfo->RecOfficeLocation = m_RecipientOffice;
  444. return S_OK;
  445. }
  446. STDMETHODIMP CFaxDoc::get_RecipientHomePhone(BSTR * pVal)
  447. {
  448. BSTR tmp;
  449. if (!pVal) {
  450. return E_POINTER;
  451. }
  452. tmp = SysAllocString (m_FaxCoverpageInfo->RecHomePhone);
  453. if (!tmp && m_FaxCoverpageInfo->RecHomePhone) {
  454. return E_OUTOFMEMORY;
  455. }
  456. __try {
  457. *pVal = tmp;
  458. return S_OK;
  459. } __except (EXCEPTION_EXECUTE_HANDLER) {
  460. SysFreeString( tmp );
  461. }
  462. return E_UNEXPECTED;
  463. }
  464. STDMETHODIMP CFaxDoc::put_RecipientHomePhone(BSTR newVal)
  465. {
  466. BSTR tmp = SysAllocString( newVal );
  467. if (!tmp && newVal) {
  468. return E_OUTOFMEMORY;
  469. }
  470. if (m_RecipientHomePhone) {
  471. SysFreeString( m_RecipientHomePhone);
  472. }
  473. m_RecipientHomePhone = tmp;
  474. m_FaxCoverpageInfo->RecHomePhone = m_RecipientHomePhone;
  475. return S_OK;
  476. }
  477. STDMETHODIMP CFaxDoc::get_RecipientOfficePhone(BSTR * pVal)
  478. {
  479. BSTR tmp;
  480. if (!pVal) {
  481. return E_POINTER;
  482. }
  483. tmp = SysAllocString (m_FaxCoverpageInfo->RecOfficePhone);
  484. if (!tmp && m_FaxCoverpageInfo->RecOfficePhone ) {
  485. return E_OUTOFMEMORY;
  486. }
  487. __try {
  488. *pVal = tmp;
  489. return S_OK;
  490. } __except (EXCEPTION_EXECUTE_HANDLER) {
  491. SysFreeString( tmp );
  492. }
  493. return E_UNEXPECTED;
  494. }
  495. STDMETHODIMP CFaxDoc::put_RecipientOfficePhone(BSTR newVal)
  496. {
  497. BSTR tmp = SysAllocString( newVal );
  498. if (!tmp && newVal) {
  499. return E_OUTOFMEMORY;
  500. }
  501. if (m_RecipientOfficePhone) {
  502. SysFreeString( m_RecipientOfficePhone);
  503. }
  504. m_RecipientOfficePhone = tmp;
  505. m_FaxCoverpageInfo->RecOfficePhone = m_RecipientOfficePhone;
  506. return S_OK;
  507. }
  508. STDMETHODIMP CFaxDoc::get_SenderFax(BSTR * pVal)
  509. {
  510. BSTR tmp;
  511. if (!pVal) {
  512. return E_POINTER;
  513. }
  514. tmp = SysAllocString (m_SenderFax);
  515. if (!tmp && m_SenderFax) {
  516. return E_OUTOFMEMORY;
  517. }
  518. __try {
  519. *pVal = tmp;
  520. return S_OK;
  521. } __except (EXCEPTION_EXECUTE_HANDLER) {
  522. SysFreeString( tmp );
  523. }
  524. return E_UNEXPECTED;
  525. }
  526. STDMETHODIMP CFaxDoc::put_SenderFax(BSTR newVal)
  527. {
  528. BSTR tmp = SysAllocString( newVal );
  529. if (!tmp && newVal) {
  530. return E_OUTOFMEMORY;
  531. }
  532. if (m_SenderFax) {
  533. SysFreeString( m_SenderFax);
  534. }
  535. m_SenderFax = tmp;
  536. m_FaxCoverpageInfo->SdrFaxNumber = m_SenderFax;
  537. return S_OK;
  538. }
  539. STDMETHODIMP CFaxDoc::get_SenderName(BSTR * pVal)
  540. {
  541. BSTR tmp;
  542. if (!pVal) {
  543. return E_POINTER;
  544. }
  545. tmp = SysAllocString (m_FaxCoverpageInfo->SdrName);
  546. if (!tmp && m_FaxCoverpageInfo->SdrName) {
  547. return E_OUTOFMEMORY;
  548. }
  549. __try {
  550. *pVal = tmp;
  551. return S_OK;
  552. } __except (EXCEPTION_EXECUTE_HANDLER) {
  553. SysFreeString( tmp );
  554. }
  555. return E_UNEXPECTED;
  556. }
  557. STDMETHODIMP CFaxDoc::put_SenderName(BSTR newVal)
  558. {
  559. BSTR tmp = SysAllocString( newVal );
  560. if (!tmp && newVal) {
  561. return E_OUTOFMEMORY;
  562. }
  563. if (m_SenderName) {
  564. SysFreeString( m_SenderName);
  565. }
  566. m_SenderName = tmp;
  567. m_FaxCoverpageInfo->SdrName = m_SenderName;
  568. m_FaxJobParams->SenderName = m_SenderName;
  569. return S_OK;
  570. }
  571. STDMETHODIMP CFaxDoc::get_SenderCompany(BSTR * pVal)
  572. {
  573. BSTR tmp;
  574. if (!pVal) {
  575. return E_POINTER;
  576. }
  577. tmp = SysAllocString (m_FaxCoverpageInfo->SdrCompany);
  578. if (!tmp && m_FaxCoverpageInfo->SdrCompany) {
  579. return E_OUTOFMEMORY;
  580. }
  581. __try {
  582. *pVal = tmp;
  583. return S_OK;
  584. } __except (EXCEPTION_EXECUTE_HANDLER) {
  585. SysFreeString( tmp );
  586. }
  587. return E_UNEXPECTED;
  588. }
  589. STDMETHODIMP CFaxDoc::put_SenderCompany(BSTR newVal)
  590. {
  591. BSTR tmp = SysAllocString( newVal );
  592. if (!tmp && newVal) {
  593. return E_OUTOFMEMORY;
  594. }
  595. if (m_SenderCompany) {
  596. SysFreeString( m_SenderCompany);
  597. }
  598. m_SenderCompany = tmp;
  599. m_FaxCoverpageInfo->SdrCompany = m_SenderCompany;
  600. m_FaxJobParams->SenderCompany = m_SenderCompany;
  601. return S_OK;
  602. }
  603. STDMETHODIMP CFaxDoc::get_SenderAddress(BSTR * pVal)
  604. {
  605. BSTR tmp;
  606. if (!pVal) {
  607. return E_POINTER;
  608. }
  609. tmp = SysAllocString (m_FaxCoverpageInfo->SdrAddress);
  610. if (!tmp && m_FaxCoverpageInfo->SdrAddress) {
  611. return E_OUTOFMEMORY;
  612. }
  613. __try {
  614. *pVal = tmp;
  615. return S_OK;
  616. } __except (EXCEPTION_EXECUTE_HANDLER) {
  617. SysFreeString( tmp );
  618. }
  619. return E_UNEXPECTED;
  620. }
  621. STDMETHODIMP CFaxDoc::put_SenderAddress(BSTR newVal)
  622. {
  623. BSTR tmp = SysAllocString( newVal );
  624. if (!tmp && newVal) {
  625. return E_OUTOFMEMORY;
  626. }
  627. if (m_SenderAddress) {
  628. SysFreeString( m_SenderAddress);
  629. }
  630. m_SenderAddress = tmp;
  631. m_FaxCoverpageInfo->SdrAddress = m_SenderAddress;
  632. return S_OK;
  633. }
  634. STDMETHODIMP CFaxDoc::get_SenderTitle(BSTR * pVal)
  635. {
  636. BSTR tmp;
  637. if (!pVal) {
  638. return E_POINTER;
  639. }
  640. tmp = SysAllocString (m_FaxCoverpageInfo->SdrTitle);
  641. if (!tmp && m_FaxCoverpageInfo->SdrTitle) {
  642. return E_OUTOFMEMORY;
  643. }
  644. __try {
  645. *pVal = tmp;
  646. return S_OK;
  647. } __except (EXCEPTION_EXECUTE_HANDLER) {
  648. SysFreeString( tmp );
  649. }
  650. return E_UNEXPECTED;
  651. }
  652. STDMETHODIMP CFaxDoc::put_SenderTitle(BSTR newVal)
  653. {
  654. BSTR tmp = SysAllocString( newVal );
  655. if (!tmp && newVal) {
  656. return E_OUTOFMEMORY;
  657. }
  658. if (m_SenderTitle) {
  659. SysFreeString( m_SenderTitle);
  660. }
  661. m_SenderTitle = tmp;
  662. m_FaxCoverpageInfo->SdrTitle = m_SenderTitle;
  663. return S_OK;
  664. }
  665. STDMETHODIMP CFaxDoc::get_SenderDepartment(BSTR * pVal)
  666. {
  667. BSTR tmp;
  668. if (!pVal) {
  669. return E_POINTER;
  670. }
  671. tmp = SysAllocString (m_FaxCoverpageInfo->SdrDepartment);
  672. if (!tmp && m_FaxCoverpageInfo->SdrDepartment) {
  673. return E_OUTOFMEMORY;
  674. }
  675. __try {
  676. *pVal = tmp;
  677. return S_OK;
  678. } __except (EXCEPTION_EXECUTE_HANDLER) {
  679. SysFreeString( tmp );
  680. }
  681. return E_UNEXPECTED;
  682. }
  683. STDMETHODIMP CFaxDoc::put_SenderDepartment(BSTR newVal)
  684. {
  685. BSTR tmp = SysAllocString( newVal );
  686. if (!tmp && newVal) {
  687. return E_OUTOFMEMORY;
  688. }
  689. if (m_SenderDepartment) {
  690. SysFreeString( m_SenderDepartment);
  691. }
  692. m_SenderDepartment = tmp;
  693. m_FaxCoverpageInfo->SdrDepartment = m_SenderDepartment;
  694. m_FaxJobParams->SenderDept = m_SenderDepartment;
  695. return S_OK;
  696. }
  697. STDMETHODIMP CFaxDoc::get_SenderOffice(BSTR * pVal)
  698. {
  699. BSTR tmp;
  700. if (!pVal) {
  701. return E_POINTER;
  702. }
  703. tmp = SysAllocString (m_FaxCoverpageInfo->SdrOfficeLocation);
  704. if (!tmp && m_FaxCoverpageInfo->SdrOfficeLocation) {
  705. return E_OUTOFMEMORY;
  706. }
  707. __try {
  708. *pVal = tmp;
  709. return S_OK;
  710. } __except (EXCEPTION_EXECUTE_HANDLER) {
  711. SysFreeString( tmp );
  712. }
  713. return E_UNEXPECTED;
  714. }
  715. STDMETHODIMP CFaxDoc::put_SenderOffice(BSTR newVal)
  716. {
  717. BSTR tmp = SysAllocString( newVal );
  718. if (!tmp && newVal) {
  719. return E_OUTOFMEMORY;
  720. }
  721. if (m_SenderOfficeLocation) {
  722. SysFreeString( m_SenderOfficeLocation);
  723. }
  724. m_SenderOfficeLocation = tmp;
  725. m_FaxCoverpageInfo->SdrOfficeLocation = m_SenderOfficeLocation;
  726. return S_OK;
  727. }
  728. STDMETHODIMP CFaxDoc::get_SenderHomePhone(BSTR * pVal)
  729. {
  730. BSTR tmp;
  731. if (!pVal) {
  732. return E_POINTER;
  733. }
  734. tmp = SysAllocString (m_FaxCoverpageInfo->SdrHomePhone);
  735. if (!tmp && m_FaxCoverpageInfo->SdrHomePhone) {
  736. return E_OUTOFMEMORY;
  737. }
  738. __try {
  739. *pVal = tmp;
  740. return S_OK;
  741. } __except (EXCEPTION_EXECUTE_HANDLER) {
  742. SysFreeString( tmp );
  743. }
  744. return E_UNEXPECTED;
  745. }
  746. STDMETHODIMP CFaxDoc::put_SenderHomePhone(BSTR newVal)
  747. {
  748. BSTR tmp = SysAllocString( newVal );
  749. if (!tmp && newVal) {
  750. return E_OUTOFMEMORY;
  751. }
  752. if (m_SenderHomePhone) {
  753. SysFreeString( m_SenderHomePhone);
  754. }
  755. m_SenderHomePhone = tmp;
  756. m_FaxCoverpageInfo->SdrHomePhone = m_SenderHomePhone;
  757. return S_OK;
  758. }
  759. STDMETHODIMP CFaxDoc::get_SenderOfficePhone(BSTR * pVal)
  760. {
  761. BSTR tmp;
  762. if (!pVal) {
  763. return E_POINTER;
  764. }
  765. tmp = SysAllocString (m_FaxCoverpageInfo->SdrOfficePhone);
  766. if (!tmp && m_FaxCoverpageInfo->SdrOfficePhone) {
  767. return E_OUTOFMEMORY;
  768. }
  769. __try {
  770. *pVal = tmp;
  771. return S_OK;
  772. } __except (EXCEPTION_EXECUTE_HANDLER) {
  773. SysFreeString( tmp );
  774. }
  775. return E_UNEXPECTED;
  776. }
  777. STDMETHODIMP CFaxDoc::put_SenderOfficePhone(BSTR newVal)
  778. {
  779. BSTR tmp = SysAllocString( newVal );
  780. if (!tmp && newVal) {
  781. return E_OUTOFMEMORY;
  782. }
  783. if (m_SenderOfficePhone) {
  784. SysFreeString( m_SenderOfficePhone);
  785. }
  786. m_SenderOfficePhone = tmp;
  787. m_FaxCoverpageInfo->SdrOfficePhone = m_SenderOfficePhone;
  788. return S_OK;
  789. }
  790. STDMETHODIMP CFaxDoc::get_CoverpageNote(BSTR * pVal)
  791. {
  792. BSTR tmp;
  793. if (!pVal) {
  794. return E_POINTER;
  795. }
  796. tmp = SysAllocString (m_FaxCoverpageInfo->Note);
  797. if (!tmp && m_FaxCoverpageInfo->Note) {
  798. return E_OUTOFMEMORY;
  799. }
  800. __try {
  801. *pVal = tmp;
  802. return S_OK;
  803. } __except (EXCEPTION_EXECUTE_HANDLER) {
  804. SysFreeString( tmp );
  805. }
  806. return E_UNEXPECTED;
  807. }
  808. STDMETHODIMP CFaxDoc::put_CoverpageNote(BSTR newVal)
  809. {
  810. BSTR tmp = SysAllocString( newVal );
  811. if (!tmp && newVal) {
  812. return E_OUTOFMEMORY;
  813. }
  814. if (m_Note) {
  815. SysFreeString( m_Note);
  816. }
  817. m_Note = tmp;
  818. m_FaxCoverpageInfo->Note = m_Note;
  819. return S_OK;
  820. }
  821. STDMETHODIMP CFaxDoc::get_CoverpageSubject(BSTR * pVal)
  822. {
  823. BSTR tmp;
  824. if (!pVal) {
  825. return E_POINTER;
  826. }
  827. tmp = SysAllocString (m_FaxCoverpageInfo->Subject);
  828. if (!tmp && m_FaxCoverpageInfo->Subject) {
  829. return E_OUTOFMEMORY;
  830. }
  831. __try {
  832. *pVal = tmp;
  833. return S_OK;
  834. } __except (EXCEPTION_EXECUTE_HANDLER) {
  835. SysFreeString( tmp );
  836. }
  837. return E_UNEXPECTED;
  838. }
  839. STDMETHODIMP CFaxDoc::put_CoverpageSubject(BSTR newVal)
  840. {
  841. BSTR tmp = SysAllocString( newVal );
  842. if (!tmp && newVal) {
  843. return E_OUTOFMEMORY;
  844. }
  845. if (m_Subject) {
  846. SysFreeString( m_Subject);
  847. }
  848. m_Subject = tmp;
  849. m_FaxCoverpageInfo->Subject = m_Subject;
  850. return S_OK;
  851. }
  852. STDMETHODIMP CFaxDoc::get_Tsid(BSTR * pVal)
  853. {
  854. BSTR tmp;
  855. if (!pVal) {
  856. return E_POINTER;
  857. }
  858. tmp = SysAllocString (m_FaxJobParams->Tsid);
  859. if (!tmp && m_FaxJobParams->Tsid) {
  860. return E_OUTOFMEMORY;
  861. }
  862. __try {
  863. *pVal = tmp;
  864. return S_OK;
  865. } __except (EXCEPTION_EXECUTE_HANDLER) {
  866. SysFreeString( tmp );
  867. }
  868. return E_UNEXPECTED;
  869. }
  870. STDMETHODIMP CFaxDoc::put_Tsid(BSTR newVal)
  871. {
  872. BSTR tmp = SysAllocString( newVal );
  873. if (!tmp && newVal) {
  874. return E_OUTOFMEMORY;
  875. }
  876. if (m_Tsid) {
  877. SysFreeString( m_Tsid);
  878. }
  879. m_Tsid = tmp;
  880. m_FaxJobParams->Tsid = m_Tsid;
  881. return S_OK;
  882. }
  883. STDMETHODIMP CFaxDoc::get_BillingCode(BSTR * pVal)
  884. {
  885. BSTR tmp;
  886. if (!pVal) {
  887. return E_POINTER;
  888. }
  889. tmp = SysAllocString (m_FaxJobParams->BillingCode);
  890. if (!tmp && m_FaxJobParams->BillingCode) {
  891. return E_OUTOFMEMORY;
  892. }
  893. __try {
  894. *pVal = tmp;
  895. return S_OK;
  896. } __except (EXCEPTION_EXECUTE_HANDLER) {
  897. SysFreeString( tmp );
  898. }
  899. return E_UNEXPECTED;
  900. }
  901. STDMETHODIMP CFaxDoc::put_BillingCode(BSTR newVal)
  902. {
  903. BSTR tmp = SysAllocString( newVal );
  904. if (!tmp && newVal) {
  905. return E_OUTOFMEMORY;
  906. }
  907. if (m_BillingCode) {
  908. SysFreeString( m_BillingCode );
  909. }
  910. m_BillingCode = tmp;
  911. m_FaxJobParams->BillingCode = m_BillingCode;
  912. return S_OK;
  913. }
  914. STDMETHODIMP CFaxDoc::get_EmailAddress(BSTR * pVal)
  915. {
  916. BSTR tmp;
  917. if (!pVal) {
  918. return E_POINTER;
  919. }
  920. tmp = SysAllocString (m_FaxJobParams->DeliveryReportAddress);
  921. if (!tmp && m_FaxJobParams->DeliveryReportAddress) {
  922. return E_OUTOFMEMORY;
  923. }
  924. __try {
  925. *pVal = tmp;
  926. return S_OK;
  927. } __except (EXCEPTION_EXECUTE_HANDLER) {
  928. SysFreeString( tmp );
  929. }
  930. return E_UNEXPECTED;
  931. }
  932. STDMETHODIMP CFaxDoc::put_EmailAddress(BSTR newVal)
  933. {
  934. BSTR tmp = SysAllocString( newVal );
  935. if (!tmp && newVal) {
  936. return E_OUTOFMEMORY;
  937. }
  938. if (m_EmailAddress) {
  939. SysFreeString( m_EmailAddress);
  940. }
  941. m_EmailAddress = tmp;
  942. m_FaxJobParams->DeliveryReportAddress = m_EmailAddress;
  943. return S_OK;
  944. }
  945. STDMETHODIMP CFaxDoc::get_DisplayName(BSTR * pVal)
  946. {
  947. BSTR tmp;
  948. if (!pVal) {
  949. return E_POINTER;
  950. }
  951. tmp = SysAllocString (m_FaxJobParams->DocumentName);
  952. if (!tmp && m_FaxJobParams->DocumentName) {
  953. return E_OUTOFMEMORY;
  954. }
  955. __try {
  956. *pVal = tmp;
  957. return S_OK;
  958. } __except (EXCEPTION_EXECUTE_HANDLER) {
  959. SysFreeString( tmp );
  960. }
  961. return E_UNEXPECTED;
  962. }
  963. STDMETHODIMP CFaxDoc::put_DisplayName(BSTR newVal)
  964. {
  965. BSTR tmp = SysAllocString( newVal );
  966. if (!tmp && newVal) {
  967. return E_OUTOFMEMORY;
  968. }
  969. if (m_DocumentName) {
  970. SysFreeString( m_DocumentName);
  971. }
  972. m_DocumentName = tmp;
  973. m_FaxJobParams->DocumentName = m_DocumentName;
  974. return S_OK;
  975. }
  976. STDMETHODIMP CFaxDoc::Send(long * pVal)
  977. {
  978. //
  979. // user must specify a file name.
  980. // if user specifies a fax number, use that.
  981. // else use the tapi call handle or connection object if it's there
  982. //
  983. if (!m_FileName) {
  984. return E_INVALIDARG;
  985. }
  986. if (!m_FaxJobParams->RecipientNumber) {
  987. //
  988. // see if they have a call handle or a connection object
  989. //
  990. if (!m_FaxJobParams->CallHandle) {
  991. if (!m_TapiConnectionObject) {
  992. return E_INVALIDARG;
  993. } else {
  994. m_FaxJobParams->Reserved[0] = 0xFFFF1234;
  995. m_FaxJobParams->Reserved[1] = (ULONG_PTR)m_TapiConnectionObject;
  996. }
  997. }
  998. }
  999. if (!FaxSendDocument(m_pFaxServer->GetFaxHandle(),
  1000. m_FileName,
  1001. m_FaxJobParams,
  1002. m_SendCoverpage ? m_FaxCoverpageInfo : NULL,
  1003. &m_JobId) ) {
  1004. return Fax_HRESULT_FROM_WIN32(GetLastError());
  1005. }
  1006. if (m_TapiConnectionObject) {
  1007. m_TapiConnectionObject->Release();
  1008. m_TapiConnectionObject = NULL;
  1009. }
  1010. *pVal = m_JobId;
  1011. return S_OK;
  1012. }
  1013. STDMETHODIMP CFaxDoc::get_FaxNumber(BSTR * pVal)
  1014. {
  1015. BSTR tmp;
  1016. if (!pVal) {
  1017. return E_POINTER;
  1018. }
  1019. tmp = SysAllocString (m_FaxJobParams->RecipientNumber);
  1020. if (!tmp && m_FaxJobParams->RecipientNumber) {
  1021. return E_OUTOFMEMORY;
  1022. }
  1023. __try {
  1024. *pVal = tmp;
  1025. return S_OK;
  1026. } __except (EXCEPTION_EXECUTE_HANDLER) {
  1027. SysFreeString( tmp );
  1028. }
  1029. return E_UNEXPECTED;
  1030. }
  1031. STDMETHODIMP CFaxDoc::put_FaxNumber(BSTR newVal)
  1032. {
  1033. BSTR tmp = SysAllocString( newVal );
  1034. if (!tmp && newVal) {
  1035. return E_OUTOFMEMORY;
  1036. }
  1037. if (m_FaxNumber) {
  1038. SysFreeString( m_FaxNumber);
  1039. }
  1040. m_FaxNumber = tmp;
  1041. m_FaxCoverpageInfo->RecFaxNumber = m_FaxNumber;
  1042. m_FaxJobParams->RecipientNumber = m_FaxNumber;
  1043. return S_OK;
  1044. }
  1045. CFaxDoc::~CFaxDoc()
  1046. {
  1047. if (m_FaxJobParams) {
  1048. FaxFreeBuffer(m_FaxJobParams);
  1049. }
  1050. if (m_FaxCoverpageInfo) {
  1051. FaxFreeBuffer(m_FaxCoverpageInfo);
  1052. }
  1053. if (m_pFaxServer) {
  1054. m_pFaxServer->Release();
  1055. }
  1056. if (m_FileName) {
  1057. SysFreeString( m_FileName);
  1058. }
  1059. if (m_FaxNumber) {
  1060. SysFreeString( m_FaxNumber);
  1061. }
  1062. if (m_Tsid) {
  1063. SysFreeString( m_Tsid);
  1064. }
  1065. if (m_BillingCode) {
  1066. SysFreeString( m_BillingCode);
  1067. }
  1068. if (m_EmailAddress) {
  1069. SysFreeString( m_EmailAddress);
  1070. }
  1071. if (m_DocumentName) {
  1072. SysFreeString(m_DocumentName);
  1073. }
  1074. if (m_Note) {
  1075. SysFreeString( m_Note);
  1076. }
  1077. if (m_Subject) {
  1078. SysFreeString( m_Subject);
  1079. }
  1080. if (m_CoverpageName) {
  1081. SysFreeString( m_CoverpageName);
  1082. }
  1083. if (m_RecipientName) {
  1084. SysFreeString( m_RecipientName);
  1085. }
  1086. if (m_RecipientNumber) {
  1087. SysFreeString( m_RecipientNumber);
  1088. }
  1089. if (m_RecipientCompany) {
  1090. SysFreeString( m_RecipientCompany);
  1091. }
  1092. if (m_RecipientAddress) {
  1093. SysFreeString(m_RecipientAddress);
  1094. }
  1095. if (m_RecipientCity) {
  1096. SysFreeString(m_RecipientCity);
  1097. }
  1098. if (m_RecipientState) {
  1099. SysFreeString(m_RecipientState);
  1100. }
  1101. if (m_RecipientZip) {
  1102. SysFreeString(m_RecipientZip);
  1103. }
  1104. if (m_RecipientCountry) {
  1105. SysFreeString(m_RecipientCountry);
  1106. }
  1107. if (m_RecipientTitle) {
  1108. SysFreeString(m_RecipientTitle);
  1109. }
  1110. if (m_RecipientDepartment) {
  1111. SysFreeString(m_RecipientDepartment);
  1112. }
  1113. if (m_RecipientOffice) {
  1114. SysFreeString(m_RecipientOffice);
  1115. }
  1116. if (m_RecipientHomePhone) {
  1117. SysFreeString(m_RecipientHomePhone);
  1118. }
  1119. if (m_RecipientOfficePhone) {
  1120. SysFreeString(m_RecipientOfficePhone);
  1121. }
  1122. if (m_SenderName) {
  1123. SysFreeString(m_SenderName);
  1124. }
  1125. if (m_SenderCompany) {
  1126. SysFreeString(m_SenderCompany);
  1127. }
  1128. if (m_SenderAddress) {
  1129. SysFreeString(m_SenderAddress);
  1130. }
  1131. if (m_SenderTitle) {
  1132. SysFreeString(m_SenderTitle);
  1133. }
  1134. if (m_SenderDepartment) {
  1135. SysFreeString(m_SenderDepartment);
  1136. }
  1137. if (m_SenderFax) {
  1138. SysFreeString(m_SenderFax);
  1139. }
  1140. if (m_SenderOfficeLocation) {
  1141. SysFreeString(m_SenderOfficeLocation);
  1142. }
  1143. if (m_SenderHomePhone) {
  1144. SysFreeString(m_SenderHomePhone);
  1145. }
  1146. if (m_SenderOfficePhone) {
  1147. SysFreeString(m_SenderOfficePhone);
  1148. }
  1149. }
  1150. BOOL CFaxDoc::Init(BSTR FileName, CFaxServer * pFaxServer)
  1151. {
  1152. HRESULT hr;
  1153. m_pFaxServer = pFaxServer;
  1154. //
  1155. // make sure our fax handle doesn't get destroyed
  1156. //
  1157. hr = m_pFaxServer->AddRef();
  1158. if (FAILED(hr)) {
  1159. m_pFaxServer = NULL;
  1160. return FALSE;
  1161. }
  1162. //
  1163. // save our filename
  1164. //
  1165. hr = put_FileName(FileName);
  1166. if (FAILED(hr)) {
  1167. return FALSE;
  1168. }
  1169. return TRUE;
  1170. }
  1171. STDMETHODIMP CFaxDoc::putref_ConnectionObject(IDispatch* newVal)
  1172. {
  1173. if (!newVal) {
  1174. return E_POINTER;
  1175. }
  1176. if (m_TapiConnectionObject) {
  1177. m_TapiConnectionObject->Release();
  1178. m_TapiConnectionObject = NULL;
  1179. }
  1180. HRESULT hr = newVal->QueryInterface(IID_IDispatch,(void**) &m_TapiConnectionObject);
  1181. if (FAILED(hr)) {
  1182. return hr;
  1183. }
  1184. return S_OK;
  1185. }
  1186. STDMETHODIMP CFaxDoc::put_CallHandle(long newVal)
  1187. {
  1188. if (!newVal) {
  1189. return E_INVALIDARG;
  1190. }
  1191. m_FaxJobParams->CallHandle = (HCALL)newVal;
  1192. return S_OK;
  1193. }
  1194. STDMETHODIMP CFaxDoc::get_CallHandle(long *pVal)
  1195. {
  1196. if (!pVal) {
  1197. return E_POINTER;
  1198. }
  1199. __try {
  1200. *pVal = (long)m_FaxJobParams->CallHandle;
  1201. } __except (EXCEPTION_EXECUTE_HANDLER) {
  1202. }
  1203. return S_OK;
  1204. }