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.

830 lines
20 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FaxOutboundRoutingRules.cpp
  5. Abstract:
  6. Implementation of CFaxOutboundRoutingRules class.
  7. Author:
  8. Iv Garber (IvG) Jun, 2000
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "FaxComEx.h"
  13. #include "FaxOutboundRoutingRules.h"
  14. #include "FaxOutboundRoutingRule.h"
  15. //
  16. //======================= ADD RULE ============================================
  17. //
  18. STDMETHODIMP
  19. CFaxOutboundRoutingRules::AddRule(
  20. /*[in]*/ FAX_OUTBOUND_ROUTING_RULE *pInfo,
  21. /*[out]*/ IFaxOutboundRoutingRule **ppNewRule
  22. )
  23. /*++
  24. Routine name : CFaxOutboundRoutingRules::AddRule
  25. Routine description:
  26. Create new Rule Object and put it into the Collection.
  27. Returns pointer to this new Rule Object, if ppNewRule is valid ptr.
  28. Author:
  29. Iv Garber (IvG), Jun, 2000
  30. Arguments:
  31. pInfo [in] - Ptr to the Rule's Data
  32. ppRule [out] - Ptr to the Rule's Object in the Collection
  33. Return Value:
  34. Standard HRESULT code
  35. --*/
  36. {
  37. HRESULT hr = S_OK;
  38. DBG_ENTER(_T("CFaxOutboundRoutingRules::AddRule"), hr);
  39. //
  40. // Create Rule Object
  41. //
  42. CComObject<CFaxOutboundRoutingRule> *pClass = NULL;
  43. hr = CComObject<CFaxOutboundRoutingRule>::CreateInstance(&pClass);
  44. if (FAILED(hr) || (!pClass))
  45. {
  46. if (!pClass)
  47. {
  48. hr = E_OUTOFMEMORY;
  49. CALL_FAIL(MEM_ERR, _T("CComObject<CFaxOutboundRoutingRule>::CreateInstance(&pClass)"), hr);
  50. }
  51. else
  52. {
  53. CALL_FAIL(GENERAL_ERR, _T("CComObject<CFaxOutboundRoutingRule>::CreateInstance(&pClass)"), hr);
  54. }
  55. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  56. return hr;
  57. }
  58. //
  59. // Init the Rule Object
  60. //
  61. hr = pClass->Init(pInfo, m_pIFaxServerInner);
  62. if (FAILED(hr))
  63. {
  64. CALL_FAIL(GENERAL_ERR, _T("pClass->Init(pInfo, m_pIFaxServerInner)"), hr);
  65. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  66. delete pClass;
  67. return hr;
  68. }
  69. //
  70. // Get Interface from the pClass.
  71. // This will make AddRef() on the Interface.
  72. // This is the Collection's AddRef, which is freed at Collection's Dtor.
  73. //
  74. CComPtr<IFaxOutboundRoutingRule> pObject = NULL;
  75. hr = pClass->QueryInterface(&pObject);
  76. if (FAILED(hr) || (!pObject))
  77. {
  78. if (!pObject)
  79. {
  80. hr = E_FAIL;
  81. }
  82. CALL_FAIL(GENERAL_ERR, _T("pClass->QueryInterface(&pObject)"), hr);
  83. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  84. delete pClass;
  85. return hr;
  86. }
  87. //
  88. // Put the Object in the collection
  89. //
  90. try
  91. {
  92. m_coll.push_back(pObject);
  93. }
  94. catch (exception &)
  95. {
  96. hr = E_OUTOFMEMORY;
  97. AtlReportError(CLSID_FaxOutboundRoutingRules, IDS_ERROR_OUTOFMEMORY, IID_IFaxOutboundRoutingRules, hr);
  98. CALL_FAIL(MEM_ERR, _T("m_coll.push_back(pObject)"), hr);
  99. //
  100. // pObject will call Release(), which will delete the pClass
  101. //
  102. return hr;
  103. }
  104. //
  105. // We want to save the current AddRef() to Collection
  106. //
  107. pObject.Detach();
  108. //
  109. // if required, return ptr to the new Rule Object
  110. //
  111. if (ppNewRule)
  112. {
  113. if (::IsBadWritePtr(ppNewRule, sizeof(IFaxOutboundRoutingRule *)))
  114. {
  115. hr = E_POINTER;
  116. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr(ppNewRule, sizeof(IFaxOutboundRoutingRule *))"), hr);
  117. return hr;
  118. }
  119. else
  120. {
  121. *ppNewRule = m_coll.back();
  122. (*ppNewRule)->AddRef();
  123. }
  124. }
  125. return hr;
  126. }
  127. //
  128. //==================== INIT ===================================================
  129. //
  130. STDMETHODIMP
  131. CFaxOutboundRoutingRules::Init(
  132. /*[in]*/ IFaxServerInner *pServer
  133. )
  134. /*++
  135. Routine name : CFaxOutboundRoutingRules::Init
  136. Routine description:
  137. Initialize the Rules Collection
  138. Author:
  139. Iv Garber (IvG), Jun, 2000
  140. Arguments:
  141. pServer [in] - Ptr to the Server
  142. Return Value:
  143. Standard HRESULT code
  144. --*/
  145. {
  146. HRESULT hr = S_OK;
  147. DBG_ENTER(_T("CFaxOutboundRoutingRules::Init"), hr);
  148. //
  149. // First, set the Ptr to the Server
  150. //
  151. hr = CFaxInitInnerAddRef::Init(pServer);
  152. if (FAILED(hr))
  153. {
  154. return hr;
  155. }
  156. //
  157. // Get Fax Handle
  158. //
  159. HANDLE faxHandle;
  160. hr = m_pIFaxServerInner->GetHandle(&faxHandle);
  161. ATLASSERT(SUCCEEDED(hr));
  162. if (faxHandle == NULL)
  163. {
  164. //
  165. // Fax Server is not connected
  166. //
  167. hr = Fax_HRESULT_FROM_WIN32(ERROR_NOT_CONNECTED);
  168. CALL_FAIL(GENERAL_ERR, _T("faxHandle == NULL"), hr);
  169. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  170. return hr;
  171. }
  172. //
  173. // Call Server to Return all OR Rules
  174. //
  175. CFaxPtr<FAX_OUTBOUND_ROUTING_RULE> pRules;
  176. DWORD dwNum = 0;
  177. if (!FaxEnumOutboundRules(faxHandle, &pRules, &dwNum))
  178. {
  179. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  180. CALL_FAIL(GENERAL_ERR, _T("FaxEnumOutboundRules(faxHandle, &pRules, &dwNum)"), hr);
  181. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  182. return hr;
  183. }
  184. //
  185. // Fill the Collection with Objects
  186. //
  187. for (DWORD i=0 ; i<dwNum ; i++ )
  188. {
  189. hr = AddRule(&pRules[i]);
  190. if (FAILED(hr))
  191. {
  192. return hr;
  193. }
  194. }
  195. return hr;
  196. }
  197. //
  198. //==================== ADD ===================================================
  199. //
  200. STDMETHODIMP
  201. CFaxOutboundRoutingRules::Add(
  202. /*[in]*/ long lCountryCode,
  203. /*[in]*/ long lAreaCode,
  204. /*[in]*/ VARIANT_BOOL bUseDevice,
  205. /*[in]*/ BSTR bstrGroupName,
  206. /*[in]*/ long lDeviceId,
  207. /*[out]*/ IFaxOutboundRoutingRule **ppRule
  208. )
  209. /*++
  210. Routine name : CFaxOutboundRoutingRules::Add
  211. Routine description:
  212. Add new Rule to the Collection and to the Server.
  213. Author:
  214. Iv Garber (IvG), Jun, 2000
  215. Arguments:
  216. lCountryCode [in] - Country Code of the new Rule
  217. lAreaCode [in] - Area Code for the new Rule
  218. bUseDevice [in] - bUseDevice Flag of the new Rule
  219. bstrGroupName [in] - Group Name of the new Rule
  220. lDeviceId [in] - Device Id of the new Rule
  221. ppRule [in] - the created Rule
  222. Return Value:
  223. Standard HRESULT code
  224. --*/
  225. {
  226. HRESULT hr = S_OK;
  227. DBG_ENTER(_T("CFaxOutboundRoutingRules::Add"), hr, _T("Country=%ld Area=%ld bUseDevice=%ld Group=%s DeviceId=%ld"), lCountryCode, lAreaCode, bUseDevice, bstrGroupName, lDeviceId);
  228. //
  229. // Get Fax Handle
  230. //
  231. HANDLE faxHandle;
  232. hr = m_pIFaxServerInner->GetHandle(&faxHandle);
  233. ATLASSERT(SUCCEEDED(hr));
  234. if (faxHandle == NULL)
  235. {
  236. //
  237. // Fax Server is not connected
  238. //
  239. hr = Fax_HRESULT_FROM_WIN32(ERROR_NOT_CONNECTED);
  240. CALL_FAIL(GENERAL_ERR, _T("faxHandle == NULL"), hr);
  241. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  242. return hr;
  243. }
  244. //
  245. // Call Server to Add the Rule
  246. //
  247. bool bUseDeviceRule = VARIANT_BOOL2bool(bUseDevice);
  248. if (!FaxAddOutboundRule(faxHandle, lAreaCode, lCountryCode, lDeviceId, bstrGroupName, (!bUseDeviceRule)))
  249. {
  250. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  251. CALL_FAIL(GENERAL_ERR, _T("FaxAddOutboundRule(faxHandle, lAreaCode, lCountryCode, lDeviceId, bstrGroupName, (!bUseDeviceRule))"), hr);
  252. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  253. return hr;
  254. }
  255. //
  256. // Take from the Server updated list of Rules -- because of unknown Status of new Rule
  257. //
  258. CFaxPtr<FAX_OUTBOUND_ROUTING_RULE> pRules;
  259. DWORD dwNum = 0;
  260. if (!FaxEnumOutboundRules(faxHandle, &pRules, &dwNum))
  261. {
  262. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  263. CALL_FAIL(GENERAL_ERR, _T("FaxEnumOutboundRules(faxHandle, &pRules, &dwNum)"), hr);
  264. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  265. return hr;
  266. }
  267. //
  268. // Find Our Rule
  269. //
  270. for (DWORD i=0 ; i<dwNum ; i++ )
  271. {
  272. if ( (pRules[i].dwAreaCode == lAreaCode) && (pRules[i].dwCountryCode == lCountryCode) )
  273. {
  274. //
  275. // Add it to the Collection
  276. //
  277. hr = AddRule(&pRules[i], ppRule);
  278. return hr;
  279. }
  280. }
  281. return hr;
  282. }
  283. //
  284. //================= FIND RULE =================================================
  285. //
  286. STDMETHODIMP
  287. CFaxOutboundRoutingRules::FindRule(
  288. /*[in]*/ long lCountryCode,
  289. /*[in]*/ long lAreaCode,
  290. /*[out]*/ ContainerType::iterator *pRule
  291. )
  292. /*++
  293. Routine name : CFaxOutboundRoutingRules::FindRule
  294. Routine description:
  295. Find Rule in the Collection by its Country and Area Code
  296. Author:
  297. Iv Garber (IvG), Jun, 2000
  298. Arguments:
  299. lCountryCode [in] - the Country Code to look for
  300. lAreaCode [in] - the Area Code to look for
  301. pRule [out] - the resultant Rule
  302. Return Value:
  303. Standard HRESULT code
  304. --*/
  305. {
  306. HRESULT hr = S_OK;
  307. DBG_ENTER(_T("CFaxOutboundRoutingRules::FindRule"), hr, _T("Area=%ld Country=%ld"), lAreaCode, lCountryCode);
  308. long lRuleAreaCode;
  309. long lRuleCountryCode;
  310. ContainerType::iterator it;
  311. it = m_coll.begin();
  312. while ( it != m_coll.end() )
  313. {
  314. //
  315. // Get Country Code of the Current Rule
  316. //
  317. hr = (*it)->get_CountryCode(&lRuleCountryCode);
  318. if (FAILED(hr))
  319. {
  320. CALL_FAIL(GENERAL_ERR, _T("(*it)->get_CountryCode(&lCountryCode)"), hr);
  321. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  322. return hr;
  323. }
  324. if (lRuleCountryCode == lCountryCode)
  325. {
  326. //
  327. // Get Area Code of the Current Rule
  328. //
  329. hr = (*it)->get_AreaCode(&lRuleAreaCode);
  330. if (FAILED(hr))
  331. {
  332. CALL_FAIL(GENERAL_ERR, _T("(*it)->get_AreaCode(&lAreaCode)"), hr);
  333. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  334. return hr;
  335. }
  336. if (lAreaCode == lRuleAreaCode)
  337. {
  338. *pRule = it;
  339. return hr;
  340. }
  341. }
  342. it++;
  343. }
  344. //
  345. // Rule Not Found
  346. //
  347. hr = E_INVALIDARG;
  348. CALL_FAIL(GENERAL_ERR, _T("Such Rule is not found"), hr);
  349. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  350. return hr;
  351. };
  352. //
  353. //==================== ITEM BY COUNTRY AND AREA ========================================
  354. //
  355. STDMETHODIMP
  356. CFaxOutboundRoutingRules::ItemByCountryAndArea(
  357. /*[in]*/ long lCountryCode,
  358. /*[in]*/ long lAreaCode,
  359. /*[out, retval]*/ IFaxOutboundRoutingRule **ppRule)
  360. /*++
  361. Routine name : CFaxOutboundRoutingRules::ItemByCountryAndArea
  362. Routine description:
  363. Return Item by given Country and Area Code
  364. Author:
  365. Iv Garber (IvG), Jun, 2000
  366. Arguments:
  367. lCountryCode [in] - the Country Code
  368. lAreaCode [in] - the Area COde
  369. ppRule [out] - the Rule to return
  370. Return Value:
  371. Standard HRESULT code
  372. --*/
  373. {
  374. HRESULT hr = S_OK;
  375. DBG_ENTER(_T("CFaxOutboundRoutingRules::ItemByCountryAndArea"), hr, _T("Area=%ld Country=%ld"), lAreaCode, lCountryCode);
  376. //
  377. // Check that we have got a good Ptr
  378. //
  379. if (::IsBadWritePtr(ppRule, sizeof(IFaxOutboundRoutingRule *)))
  380. {
  381. hr = E_POINTER;
  382. CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr(ppRule, sizeof(IFaxOutboundRoutingRule *))"), hr);
  383. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  384. return hr;
  385. }
  386. //
  387. // Find the Item
  388. //
  389. ContainerType::iterator ruleIt;
  390. hr = FindRule(lCountryCode, lAreaCode, &ruleIt);
  391. if (FAILED(hr))
  392. {
  393. return hr;
  394. }
  395. //
  396. // Return the found Rule
  397. //
  398. (*ruleIt)->AddRef();
  399. *ppRule = (*ruleIt);
  400. return hr;
  401. }
  402. //
  403. //==================== REMOVE BY COUNTRY AND AREA ========================================
  404. //
  405. STDMETHODIMP
  406. CFaxOutboundRoutingRules::RemoveByCountryAndArea(
  407. /*[in]*/ long lCountryCode,
  408. /*[in]*/ long lAreaCode
  409. )
  410. /*++
  411. Routine name : CFaxOutboundRoutingRules::RemoveByCountryAndArea
  412. Routine description:
  413. Remove Rule from the Collection and at Server as well.
  414. Author:
  415. Iv Garber (IvG), Jun, 2000
  416. Arguments:
  417. lAreaCode [in] - Area Code of the Rule to Remove
  418. lCountryCode [in] - Country Code of the Rule to Remove
  419. Return Value:
  420. Standard HRESULT code
  421. --*/
  422. {
  423. HRESULT hr = S_OK;
  424. DBG_ENTER(_T("CFaxOutboundRoutingRules::RemoveByCountryAndArea"), hr, _T("Area=%ld Country=%ld"), lAreaCode, lCountryCode);
  425. //
  426. // Check that this is not a Default Rule
  427. //
  428. if (lAreaCode == frrcANY_CODE && lCountryCode == frrcANY_CODE)
  429. {
  430. hr = E_INVALIDARG;
  431. CALL_FAIL(GENERAL_ERR, _T("Remove the Default Rule"), hr);
  432. AtlReportError(CLSID_FaxOutboundRoutingRules, IDS_ERROR_REMOVEDEFAULTRULE, IID_IFaxOutboundRoutingRules, hr);
  433. return hr;
  434. }
  435. //
  436. // Find the Rule
  437. //
  438. ContainerType::iterator ruleIt;
  439. hr = FindRule(lCountryCode, lAreaCode, &ruleIt);
  440. if (FAILED(hr))
  441. {
  442. return hr;
  443. }
  444. //
  445. // Remove the found Rule
  446. //
  447. hr = RemoveRule(lAreaCode, lCountryCode, ruleIt);
  448. return hr;
  449. }
  450. //
  451. //==================== REMOVE RULE ========================================
  452. //
  453. STDMETHODIMP
  454. CFaxOutboundRoutingRules::RemoveRule (
  455. /*[in]*/ long lAreaCode,
  456. /*[in]*/ long lCountryCode,
  457. /*[in]*/ ContainerType::iterator &it
  458. )
  459. /*++
  460. Routine name : CFaxOutboundRoutingRules::RemoveRule
  461. Routine description:
  462. Remove Rule from the Collection and from the Server.
  463. Author:
  464. Iv Garber (IvG), Jun, 2000
  465. Arguments:
  466. lAreaCode [in] - Area Code of the Rule to Remove
  467. lCountryCode [in] - Country Code of the Rule to Remove
  468. it [in] - Reference to the Iterator poiting to the Rule in the Collection
  469. Return Value:
  470. Standard HRESULT code
  471. --*/
  472. {
  473. HRESULT hr = S_OK;
  474. DBG_ENTER(_T("CFaxOutboundRoutingRules::RemoveRule"), hr, _T("Area=%ld Country=%ld"), lAreaCode, lCountryCode);
  475. //
  476. // Get Fax Handle
  477. //
  478. HANDLE faxHandle;
  479. hr = m_pIFaxServerInner->GetHandle(&faxHandle);
  480. ATLASSERT(SUCCEEDED(hr));
  481. if (faxHandle == NULL)
  482. {
  483. //
  484. // Fax Server is not connected
  485. //
  486. hr = Fax_HRESULT_FROM_WIN32(ERROR_NOT_CONNECTED);
  487. CALL_FAIL(GENERAL_ERR, _T("faxHandle == NULL"), hr);
  488. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  489. return hr;
  490. }
  491. //
  492. // Call Server to Remove the Rule
  493. //
  494. if (!FaxRemoveOutboundRule(faxHandle, lAreaCode, lCountryCode))
  495. {
  496. hr = Fax_HRESULT_FROM_WIN32(GetLastError());
  497. CALL_FAIL(GENERAL_ERR, _T("FaxRemoveOutboundRule(faxHandle, lAreaCode, lCountryCode)"), hr);
  498. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  499. return hr;
  500. }
  501. //
  502. // Remove from our Collection as well
  503. //
  504. try
  505. {
  506. m_coll.erase(it);
  507. }
  508. catch(exception &)
  509. {
  510. //
  511. // Failed to remove the Rule
  512. //
  513. hr = E_OUTOFMEMORY;
  514. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  515. CALL_FAIL(MEM_ERR, _T("m_coll.erase(it)"), hr);
  516. return hr;
  517. }
  518. return hr;
  519. }
  520. //
  521. //==================== REMOVE ========================================
  522. //
  523. STDMETHODIMP
  524. CFaxOutboundRoutingRules::Remove (
  525. /*[in]*/ long lIndex
  526. )
  527. /*++
  528. Routine name : CFaxOutboundRoutingRules::Remove
  529. Routine description:
  530. Remove Rule from the Collection and at Server as well.
  531. Author:
  532. Iv Garber (IvG), Jun, 2000
  533. Arguments:
  534. lIndex [in] - Index of the Rule to Remove.
  535. Return Value:
  536. Standard HRESULT code
  537. --*/
  538. {
  539. HRESULT hr = S_OK;
  540. DBG_ENTER(_T("CFaxOutboundRoutingRules::Remove"), hr, _T("Index=%ld"), lIndex);
  541. if (lIndex < 1 || lIndex > m_coll.size())
  542. {
  543. //
  544. // Invalid Index
  545. //
  546. hr = E_INVALIDARG;
  547. AtlReportError(CLSID_FaxOutboundRoutingRules, IDS_ERROR_OUTOFRANGE, IID_IFaxOutboundRoutingRules, hr);
  548. CALL_FAIL(GENERAL_ERR, _T("lIndex < 1 || lIndex > m_coll.size()"), hr);
  549. return hr;
  550. }
  551. ContainerType::iterator it;
  552. it = m_coll.begin() + lIndex - 1;
  553. //
  554. // Get Area Code of the Rule to Remove
  555. //
  556. long lAreaCode;
  557. hr = (*it)->get_AreaCode(&lAreaCode);
  558. if (FAILED(hr))
  559. {
  560. CALL_FAIL(GENERAL_ERR, _T("(*it)->get_AreaCode(&lAreaCode)"), hr);
  561. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  562. return hr;
  563. }
  564. //
  565. // Get Country Code of the Rule to Remove
  566. //
  567. long lCountryCode;
  568. hr = (*it)->get_CountryCode(&lCountryCode);
  569. if (FAILED(hr))
  570. {
  571. CALL_FAIL(GENERAL_ERR, _T("(*it)->get_CountryCode(&lCountryCode)"), hr);
  572. AtlReportError(CLSID_FaxOutboundRoutingRules, GetErrorMsgId(hr), IID_IFaxOutboundRoutingRules, hr);
  573. return hr;
  574. }
  575. //
  576. // Check that this is not a Default Rule
  577. //
  578. if (lAreaCode == frrcANY_CODE && lCountryCode == frrcANY_CODE)
  579. {
  580. hr = E_INVALIDARG;
  581. CALL_FAIL(GENERAL_ERR, _T("Remove the Default Rule"), hr);
  582. AtlReportError(CLSID_FaxOutboundRoutingRules, IDS_ERROR_REMOVEDEFAULTRULE, IID_IFaxOutboundRoutingRules, hr);
  583. return hr;
  584. }
  585. //
  586. // Remove the Rule from the Server and from our Collection
  587. //
  588. hr = RemoveRule(lAreaCode, lCountryCode, it);
  589. return hr;
  590. }
  591. //
  592. //==================== CREATE ========================================
  593. //
  594. HRESULT
  595. CFaxOutboundRoutingRules::Create (
  596. /*[out, retval]*/IFaxOutboundRoutingRules **ppRules
  597. )
  598. /*++
  599. Routine name : CFaxOutboundRoutingRules::Create
  600. Routine description:
  601. Static function to create the Fax Outbound Routing Rules Collection Object
  602. Author:
  603. Iv Garber (IvG), Jun, 2000
  604. Arguments:
  605. ppRules [out] -- the new Fax OR Rules Collection Object
  606. Return Value:
  607. Standard HRESULT code
  608. --*/
  609. {
  610. HRESULT hr = S_OK;
  611. DBG_ENTER (_T("CFaxOutboundRoutingRules::Create"), hr);
  612. //
  613. // Create Instance of the Collection
  614. //
  615. CComObject<CFaxOutboundRoutingRules> *pClass;
  616. hr = CComObject<CFaxOutboundRoutingRules>::CreateInstance(&pClass);
  617. if (FAILED(hr))
  618. {
  619. CALL_FAIL(GENERAL_ERR, _T("CComObject<CFaxOutboundRoutingRules>::CreateInstance(&pClass)"), hr);
  620. return hr;
  621. }
  622. //
  623. // Return the desired Interface Ptr
  624. //
  625. hr = pClass->QueryInterface(ppRules);
  626. if (FAILED(hr))
  627. {
  628. CALL_FAIL(GENERAL_ERR, _T("pClass->QueryInterface(ppRules)"), hr);
  629. return hr;
  630. }
  631. return hr;
  632. } // CFaxOutboundRoutingRules::Create()
  633. //
  634. //===================== SUPPORT ERROR INFO ======================================
  635. //
  636. STDMETHODIMP
  637. CFaxOutboundRoutingRules::InterfaceSupportsErrorInfo(
  638. REFIID riid
  639. )
  640. /*++
  641. Routine name : CFaxOutboundRoutingRules::InterfaceSupportsErrorInfo
  642. Routine description:
  643. ATL's implementation of Support Error Info.
  644. Author:
  645. Iv Garber (IvG), Jun, 2000
  646. Arguments:
  647. riid [in] - reference to the Interface.
  648. Return Value:
  649. Standard HRESULT code
  650. --*/
  651. {
  652. static const IID* arr[] =
  653. {
  654. &IID_IFaxOutboundRoutingRules
  655. };
  656. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  657. {
  658. if (InlineIsEqualGUID(*arr[i],riid))
  659. return S_OK;
  660. }
  661. return S_FALSE;
  662. }