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.

1554 lines
38 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : ppFaxOutboundRoutingRule.cpp //
  3. // //
  4. // DESCRIPTION : prop pages of Outbound Routing Methods //
  5. // //
  6. // AUTHOR : yossg //
  7. // //
  8. // HISTORY : //
  9. // Jan 9 2000 yossg Created //
  10. // Jan 25 2000 yossg Change the Dialog Design //
  11. // Oct 17 2000 yossg //
  12. // //
  13. // Copyright (C) 1999 - 2000 Microsoft Corporation All Rights Reserved //
  14. // //
  15. /////////////////////////////////////////////////////////////////////////////
  16. #include "stdafx.h"
  17. #include "MSFxsSnp.h"
  18. #include "ppFaxOutboundRoutingRule.h"
  19. #include "DlgSelectCountry.h"
  20. #include "FaxMMCGlobals.h"
  21. #include "FaxServer.h"
  22. #include "FaxServerNode.h"
  23. #include "dlgutils.h"
  24. #include "FaxMMCPropertyChange.h"
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. //
  30. // Constructor
  31. //
  32. CppFaxOutboundRoutingRule::CppFaxOutboundRoutingRule(
  33. LONG_PTR hNotificationHandle,
  34. CSnapInItem *pNode,
  35. BOOL bOwnsNotificationHandle,
  36. HINSTANCE hInst)
  37. : CPropertyPageExImpl<CppFaxOutboundRoutingRule>(pNode,NULL)
  38. {
  39. m_lpNotifyHandle = hNotificationHandle;
  40. m_pFaxDevicesConfig = NULL;
  41. m_dwNumOfDevices = 0;
  42. m_pFaxGroupsConfig = NULL;
  43. m_dwNumOfGroups = 0;
  44. m_fAllReadyToApply = FALSE;
  45. m_dwCountryCode = 0;
  46. m_dwAreaCode = 0;
  47. m_dwDeviceID = 0;
  48. m_bstrGroupName = L"";
  49. m_fIsDialogInitiated = FALSE;
  50. m_fIsDirty = FALSE;
  51. }
  52. //
  53. // Destructor
  54. //
  55. CppFaxOutboundRoutingRule::~CppFaxOutboundRoutingRule()
  56. {
  57. if (NULL != m_pFaxDevicesConfig)
  58. FaxFreeBuffer(m_pFaxDevicesConfig);
  59. if (NULL != m_pFaxGroupsConfig)
  60. FaxFreeBuffer(m_pFaxGroupsConfig);
  61. // Note - This needs to be called only once per property sheet.
  62. // In our convention called in the general tab.
  63. if (NULL != m_lpNotifyHandle)
  64. {
  65. MMCFreeNotifyHandle(m_lpNotifyHandle);
  66. m_lpNotifyHandle = NULL;
  67. }
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CppFaxOutboundRoutingRule message handlers
  71. /*
  72. - CppFaxOutboundRoutingRule::OnInitDialog
  73. -
  74. * Purpose:
  75. * Initiates all controls when dialog is called.
  76. *
  77. * Arguments:
  78. *
  79. * Return:
  80. *
  81. */
  82. LRESULT CppFaxOutboundRoutingRule::OnInitDialog( UINT uiMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled )
  83. {
  84. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::PageInitDialog"));
  85. UNREFERENCED_PARAMETER( uiMsg );
  86. UNREFERENCED_PARAMETER( wParam );
  87. UNREFERENCED_PARAMETER( lParam );
  88. UNREFERENCED_PARAMETER( fHandled );
  89. HRESULT hRc = S_OK;
  90. int k, l;
  91. k = l = 0;
  92. const int iAllDevicesComboIndex = 0;
  93. int iAllDevicesRPCIndex = 0;
  94. int iGroupListIndexToSelect = 0;
  95. HINSTANCE hInst = _Module.GetResourceInstance();
  96. PFAX_TAPI_LINECOUNTRY_ENTRYW pCountryEntries = NULL;
  97. WCHAR buf[FXS_MAX_DISPLAY_NAME_LEN+1];
  98. WCHAR buffAreaCode[FXS_MAX_AREACODE_LEN+1];
  99. int iCount;
  100. //
  101. // Attach controls
  102. //
  103. m_CountryCodeEdit.Attach(GetDlgItem(IDC_RULE_COUNTRYCODE_EDIT1));
  104. m_AreaCodeEdit.Attach(GetDlgItem(IDC_RULE_AREACODE_EDIT1));
  105. m_DeviceCombo.Attach(GetDlgItem(IDC_DEVICES4RULE_COMBO1));
  106. m_GroupCombo.Attach(GetDlgItem(IDC_GROUP4RULE_COMBO1));
  107. //
  108. // Set length limit to area code
  109. //
  110. m_CountryCodeEdit.SetLimitText(FXS_MAX_COUNTRYCODE_LEN -1);
  111. m_AreaCodeEdit.SetLimitText(FXS_MAX_AREACODE_LEN -1);
  112. //
  113. // Step 1: Init Lists
  114. //
  115. //
  116. // Init Country code edit box (below)
  117. //
  118. //
  119. // Init Devices
  120. //
  121. for (k = 0; (DWORD)k < m_dwNumOfDevices; k++ )
  122. {
  123. hRc = AddComboBoxItem ( m_DeviceCombo,
  124. m_pFaxDevicesConfig[k].lpctstrDeviceName,
  125. m_pFaxDevicesConfig[k].dwDeviceID,
  126. hInst);
  127. if (FAILED(hRc))
  128. {
  129. DebugPrintEx(
  130. DEBUG_ERR, _T("Fail to load device list."));
  131. PageError(IDS_FAIL2LOADDEVICELIST, m_hWnd, hInst);
  132. ::EnableWindow(GetDlgItem(IDC_DEVICES4RULE_COMBO1), FALSE);
  133. goto Cleanup;
  134. }
  135. }
  136. //
  137. // Init groups
  138. //
  139. for (l = 0; (DWORD)l < m_dwNumOfGroups; l++ )
  140. {
  141. if ( 0 == wcscmp(ROUTING_GROUP_ALL_DEVICES, m_pFaxGroupsConfig[l].lpctstrGroupName))
  142. {
  143. iAllDevicesRPCIndex = l;
  144. //Do not do any more;
  145. }
  146. else
  147. {
  148. hRc = AddComboBoxItem ( m_GroupCombo,
  149. m_pFaxGroupsConfig[l].lpctstrGroupName,
  150. (DWORD)l,
  151. hInst);
  152. if (FAILED(hRc))
  153. {
  154. DebugPrintEx( DEBUG_ERR, _T("Fail to load group list."));
  155. PageError(IDS_FAIL2LOADDEVICELIST, m_hWnd, hInst);
  156. ::EnableWindow(GetDlgItem(IDC_GROUP4RULE_COMBO), FALSE);
  157. goto Cleanup;
  158. }
  159. }
  160. //
  161. // Moreover we'll pick the the index of selected group
  162. //
  163. if ( m_fIsGroup)
  164. {
  165. if ( 0 == wcscmp( m_bstrGroupName, m_pFaxGroupsConfig[l].lpctstrGroupName))
  166. {
  167. iGroupListIndexToSelect = l;
  168. }
  169. }
  170. }
  171. if (!LoadString(hInst, IDS_ALL_DEVICES, buf, FXS_MAX_DISPLAY_NAME_LEN))
  172. {
  173. hRc = E_OUTOFMEMORY;
  174. DebugPrintEx( DEBUG_ERR, _T("Fail to load string. Out of memory."));
  175. PageError(IDS_FAXOUTOFMEMORY, m_hWnd, hInst);
  176. goto Cleanup;
  177. }
  178. //
  179. // insert "All Devices" Group as the first one in the groups list
  180. //
  181. ATLASSERT( 0 == iAllDevicesComboIndex );
  182. hRc = SetComboBoxItem ( m_GroupCombo,
  183. iAllDevicesComboIndex,
  184. buf,
  185. iAllDevicesRPCIndex,
  186. hInst);
  187. if (FAILED(hRc))
  188. {
  189. DebugPrintEx( DEBUG_ERR, _T("Fail to load group list."));
  190. PageError(IDS_FAIL2LOADGROUPLIST, m_hWnd, hInst);
  191. ::EnableWindow(GetDlgItem(IDC_GROUP4RULE_COMBO), FALSE);
  192. goto Cleanup;
  193. }
  194. //
  195. // Step 2: Set current status
  196. // (Select items in Lists, select radio button etc.)
  197. // (Gray/UnGray controls)
  198. //
  199. //
  200. // Select Country in the list
  201. //
  202. if (ROUTING_RULE_COUNTRY_CODE_ANY != m_dwCountryCode)
  203. {
  204. int iCountSring = 0;
  205. WCHAR szwCountryCode[FXS_MAX_COUNTRYCODE_LEN+1];
  206. iCountSring = swprintf(szwCountryCode, L"%ld", m_dwCountryCode);
  207. if( iCountSring <= 0 )
  208. {
  209. DebugPrintEx(
  210. DEBUG_ERR,
  211. TEXT("Fail to read member - m_dwCountryCode."));
  212. PageError(IDS_MEMORY, m_hWnd, hInst);
  213. goto Cleanup;
  214. }
  215. m_CountryCodeEdit.SetWindowText(szwCountryCode);
  216. if (ROUTING_RULE_AREA_CODE_ANY == m_dwAreaCode)
  217. {
  218. CheckDlgButton(IDC_COUNTRY_RADIO1, BST_CHECKED);
  219. ::EnableWindow(GetDlgItem(IDC_RULE_AREACODE_EDIT1), FALSE);
  220. }
  221. else
  222. {
  223. CheckDlgButton(IDC_AREA_RADIO1, BST_CHECKED);
  224. //
  225. // Set Area Code
  226. //
  227. iCount = swprintf(buffAreaCode,
  228. L"%ld", m_dwAreaCode);
  229. ATLASSERT(iCount > 0);
  230. if( iCount > 0 )
  231. {
  232. m_AreaCodeEdit.SetWindowText(buffAreaCode);
  233. }
  234. }
  235. }
  236. else //m_dwCountryCode == ROUTING_RULE_COUNTRY_CODE_ANY
  237. {
  238. ::EnableWindow(GetDlgItem(IDC_RULETYPE_FSTATIC), FALSE);
  239. ::EnableWindow(GetDlgItem(IDC_COUNTRY1_STATIC), FALSE);
  240. ::EnableWindow(GetDlgItem(IDC_AREA_STATIC), FALSE);
  241. ::EnableWindow(GetDlgItem(IDC_RULE_AREACODE_EDIT1), FALSE);
  242. ::EnableWindow(GetDlgItem(IDC_RULE_SELECT_BUTTON1), FALSE);
  243. ::EnableWindow(GetDlgItem(IDC_RULE_COUNTRYCODE_EDIT1), FALSE);
  244. ::EnableWindow(GetDlgItem(IDC_COUNTRY_RADIO1), FALSE);
  245. ::EnableWindow(GetDlgItem(IDC_AREA_RADIO1), FALSE);
  246. }
  247. if (!m_fIsGroup)
  248. {
  249. CheckDlgButton(IDC_DESTINATION_RADIO11, BST_CHECKED);
  250. //
  251. // Select device in the list
  252. //
  253. hRc = SelectComboBoxItemData(m_DeviceCombo, m_dwDeviceID);
  254. if ( FAILED(hRc))
  255. {
  256. DebugPrintEx( DEBUG_ERR, _T("Fail to select device in combo box."));
  257. PageError(IDS_FAIL2LOADDEVICELIST, m_hWnd, hInst);
  258. ::EnableWindow(GetDlgItem(IDC_DEVICES4RULE_COMBO1), FALSE);
  259. goto Cleanup;
  260. }
  261. ::EnableWindow(GetDlgItem(IDC_GROUP4RULE_COMBO1), FALSE);
  262. }
  263. else
  264. {
  265. CheckDlgButton(IDC_DESTINATION_RADIO21, BST_CHECKED) ;
  266. //
  267. // Select Group in list
  268. //
  269. hRc = SelectComboBoxItemData(m_GroupCombo, iGroupListIndexToSelect);
  270. if ( FAILED(hRc))
  271. {
  272. DebugPrintEx( DEBUG_ERR, _T("Fail to select group in combo box."));
  273. PageError(IDS_FAIL2LOADGROUPLIST, m_hWnd, hInst);
  274. ::EnableWindow(GetDlgItem(IDC_DEVICES4RULE_COMBO1), FALSE);
  275. goto Cleanup;
  276. }
  277. ::EnableWindow(GetDlgItem(IDC_DEVICES4RULE_COMBO1), FALSE);
  278. }
  279. ATLASSERT(S_OK == hRc);
  280. m_fIsDialogInitiated = TRUE;
  281. Cleanup:
  282. return (1);
  283. }
  284. /*
  285. - CppFaxOutboundRoutingRule::SetProps
  286. -
  287. * Purpose:
  288. * Sets properties on apply.
  289. *
  290. * Arguments:
  291. * pCtrlFocus - focus pointer (int)
  292. *
  293. * Return:
  294. * OLE error code
  295. */
  296. HRESULT CppFaxOutboundRoutingRule::SetProps(int *pCtrlFocus)
  297. {
  298. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::SetProps"));
  299. HRESULT hRc = S_OK;
  300. DWORD ec = ERROR_SUCCESS;
  301. CComBSTR bstrAreaCode;
  302. int iCurrentSelectedItem = 0;
  303. DWORD dwAreaCode = 0;
  304. DWORD dwCountryCode = 0;
  305. BOOL bUseGroup;
  306. DWORD dwDeviceID = 0;
  307. WCHAR lpszGroupName[MAX_ROUTING_GROUP_NAME];
  308. LPCTSTR lpctstrGroupName = NULL;
  309. HINSTANCE hInst;
  310. hInst = _Module.GetResourceInstance();
  311. CFaxRulePropertyChangeNotification * pRulePropPageNotification = NULL;
  312. CComBSTR bstrCountryName;
  313. //
  314. // Step 0: PreApply Checks
  315. //
  316. m_fAllReadyToApply = FALSE;
  317. if (!AllReadyToApply( FALSE))
  318. {
  319. SetModified(FALSE);
  320. hRc = E_FAIL;
  321. goto Exit;
  322. }
  323. //
  324. // Step 1: get data
  325. //
  326. if (ROUTING_RULE_COUNTRY_CODE_ANY != m_dwCountryCode)
  327. {
  328. //
  329. // Country Code
  330. //
  331. CComBSTR bstrCountryCode;
  332. if ( !m_CountryCodeEdit.GetWindowText(&bstrCountryCode))
  333. {
  334. DebugPrintEx(
  335. DEBUG_ERR,
  336. TEXT("Failed to GetWindowText(&bstrCountryCode)"));
  337. DlgMsgBox(this, IDS_FAIL2READ_COUNTRYCODE);
  338. ::SetFocus(GetDlgItem(IDC_RULE_COUNTRYCODE_EDIT));
  339. hRc = S_FALSE;
  340. goto Exit;
  341. }
  342. dwCountryCode = (DWORD)wcstoul( bstrCountryCode, NULL, 10 );
  343. if (ROUTING_RULE_COUNTRY_CODE_ANY == dwCountryCode)
  344. {
  345. //
  346. // The user try to replace the country code to zero
  347. //
  348. DebugPrintEx(
  349. DEBUG_ERR,
  350. TEXT(" CountryCode == ROUTING_RULE_COUNTRY_CODE_ANY "));
  351. DlgMsgBox(this, IDS_ZERO_COUNTRYCODE);
  352. ::SetFocus(GetDlgItem(IDC_RULE_COUNTRYCODE_EDIT));
  353. hRc = S_FALSE;
  354. goto Exit;
  355. }
  356. //
  357. // Area Code
  358. //
  359. if ( IsDlgButtonChecked(IDC_COUNTRY_RADIO1) == BST_CHECKED )
  360. {
  361. dwAreaCode = (DWORD)ROUTING_RULE_AREA_CODE_ANY;
  362. }
  363. else // IsDlgButtonChecked(IDC_AREA_RADIO1) == BST_CHECKED
  364. {
  365. if ( !m_AreaCodeEdit.GetWindowText(&bstrAreaCode))
  366. {
  367. DebugPrintEx(
  368. DEBUG_ERR,
  369. TEXT("Failed to GetWindowText(&bstrAreaCode)"));
  370. PageError(IDS_FAIL2READ_AREACODE, m_hWnd, hInst);
  371. ::SetFocus(GetDlgItem(IDC_RULE_AREACODE_EDIT1));
  372. hRc = E_FAIL ;
  373. goto Exit;
  374. }
  375. dwAreaCode = (DWORD)wcstoul( bstrAreaCode, NULL, 10 );
  376. }
  377. ATLASSERT(bstrCountryName);
  378. }
  379. if ( IsDlgButtonChecked(IDC_DESTINATION_RADIO11) == BST_CHECKED )
  380. {
  381. //
  382. // Use Group ?
  383. //
  384. bUseGroup = FALSE;
  385. //
  386. // Device
  387. //
  388. iCurrentSelectedItem = m_DeviceCombo.GetCurSel();
  389. ATLASSERT(iCurrentSelectedItem != CB_ERR); //should be chacked pre apply
  390. dwDeviceID = (DWORD)m_DeviceCombo.GetItemData (iCurrentSelectedItem);
  391. }
  392. else // IsDlgButtonChecked(IDC_DESTINATION_RADIO21) == BST_CHECKED
  393. {
  394. //
  395. // Use Group ?
  396. //
  397. bUseGroup = TRUE;
  398. //
  399. // Group
  400. //
  401. iCurrentSelectedItem = m_GroupCombo.GetCurSel();
  402. //ATLASSERT(iCurrentSelectedItem != CB_ERR); //should be chacked pre apply
  403. if (0 == iCurrentSelectedItem) //All Devices
  404. {
  405. lpctstrGroupName = ROUTING_GROUP_ALL_DEVICES;
  406. }
  407. else
  408. {
  409. ATLASSERT(MAX_ROUTING_GROUP_NAME > m_GroupCombo.GetLBTextLen(iCurrentSelectedItem)); //should be chacked by service before
  410. m_GroupCombo.GetLBText( iCurrentSelectedItem, lpszGroupName );
  411. lpctstrGroupName = (LPCTSTR)lpszGroupName;
  412. }
  413. }
  414. //
  415. // Step 2: Configure Rule via RPC call
  416. //
  417. if (
  418. (dwAreaCode != m_dwAreaCode)
  419. ||
  420. (dwCountryCode != m_dwCountryCode)
  421. )
  422. {
  423. hRc = FaxReplaceRule(
  424. dwAreaCode,
  425. dwCountryCode,
  426. bUseGroup,
  427. dwDeviceID,
  428. lpctstrGroupName
  429. );
  430. if (FAILED(hRc))
  431. {
  432. //DebugPrint and MsgBox by called func.
  433. goto Exit;
  434. }
  435. else
  436. {
  437. m_dwAreaCode = dwAreaCode;
  438. m_dwCountryCode = dwCountryCode;
  439. }
  440. }
  441. else
  442. {
  443. //
  444. //(dwAreaCode == m_dwAreaCode) &&
  445. //(dwCountryCode == m_dwCountryCode)
  446. //
  447. hRc = FaxConfigureRule(
  448. bUseGroup,
  449. dwDeviceID,
  450. lpctstrGroupName
  451. );
  452. if (FAILED(hRc))
  453. {
  454. //DebugPrint and MsgBox by called func.
  455. goto Exit;
  456. }
  457. }
  458. //
  459. // Step 3: Send notification to cause MMC view refresh
  460. //
  461. //
  462. // Prepare the notification fields before submit
  463. //
  464. pRulePropPageNotification = new CFaxRulePropertyChangeNotification();
  465. if (!pRulePropPageNotification)
  466. {
  467. ec = ERROR_NOT_ENOUGH_MEMORY;
  468. DebugPrintEx( DEBUG_ERR, _T("Out of Memory - fail to operate new"));
  469. goto Error;
  470. }
  471. pRulePropPageNotification->dwAreaCode = dwAreaCode;
  472. pRulePropPageNotification->dwCountryCode = dwCountryCode;
  473. pRulePropPageNotification->bstrCountryName = bstrCountryName;
  474. if (!pRulePropPageNotification->bstrCountryName)
  475. {
  476. ec = ERROR_NOT_ENOUGH_MEMORY;
  477. DebugPrintEx( DEBUG_ERR, _T("Out of Memory - fail to load string."));
  478. goto Error;
  479. }
  480. pRulePropPageNotification->fIsGroup = bUseGroup;
  481. if (pRulePropPageNotification->fIsGroup)
  482. {
  483. pRulePropPageNotification->bstrGroupName = lpctstrGroupName;
  484. if (!pRulePropPageNotification->bstrGroupName)
  485. {
  486. ec = ERROR_NOT_ENOUGH_MEMORY;
  487. DebugPrintEx( DEBUG_ERR, _T("Out of Memory - fail to load string."));
  488. goto Error;
  489. }
  490. }
  491. else
  492. {
  493. pRulePropPageNotification->dwDeviceID = dwDeviceID;
  494. }
  495. pRulePropPageNotification->pItem = (CSnapInItem *)m_pParentNode;
  496. pRulePropPageNotification->enumType = RuleFaxPropNotification;
  497. //
  498. // Notify MMC console thread
  499. //
  500. hRc = MMCPropertyChangeNotify(m_lpNotifyHandle, reinterpret_cast<LPARAM>(pRulePropPageNotification));
  501. if (FAILED(hRc))
  502. {
  503. DebugPrintEx(
  504. DEBUG_ERR,
  505. _T("Fail to call MMCPropertyChangeNotify. (hRc: %08X)"),
  506. hRc);
  507. ATLASSERT(NULL != m_pParentNode);
  508. PageError(IDS_FAIL_NOTIFY_MMCPROPCHANGE,m_hWnd);
  509. goto Exit;
  510. }
  511. //
  512. // To prevent deletion on error since it will be deleted
  513. // by the reciever of the notification.
  514. //
  515. pRulePropPageNotification = NULL;
  516. ATLASSERT(S_OK == hRc && ERROR_SUCCESS == ec);
  517. m_fIsDirty = FALSE;
  518. DebugPrintEx( DEBUG_MSG,
  519. _T("The rule was added successfully."));
  520. goto Exit;
  521. Error:
  522. ATLASSERT(ERROR_SUCCESS != ec);
  523. hRc = HRESULT_FROM_WIN32(ec);
  524. PropSheet_SetCurSelByID( GetParent(), IDD);
  525. ATLASSERT(::IsWindow(m_hWnd));
  526. PageError(GetFaxServerErrorMsg(ec),m_hWnd);
  527. if (pRulePropPageNotification)
  528. {
  529. delete pRulePropPageNotification;
  530. pRulePropPageNotification = NULL;
  531. }
  532. Exit:
  533. return(hRc);
  534. }
  535. /*
  536. - CppFaxOutboundRoutingRule::PreApply
  537. -
  538. * Purpose:
  539. * Checks properties before apply.
  540. *
  541. * Arguments:
  542. *
  543. * Return:
  544. * OLE error code
  545. */
  546. HRESULT CppFaxOutboundRoutingRule::PreApply(int *pCtrlFocus)
  547. {
  548. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::PreApply"));
  549. HRESULT hRc = S_OK;
  550. //
  551. // PreApply Checks
  552. //
  553. m_fAllReadyToApply = FALSE;
  554. if (!AllReadyToApply(/*fSilent =*/ FALSE))
  555. {
  556. SetModified(FALSE);
  557. hRc = E_FAIL ;
  558. }
  559. else
  560. {
  561. SetModified(TRUE);
  562. }
  563. return(hRc);
  564. }
  565. /*
  566. - CppFaxOutboundRoutingRule::OnApply
  567. -
  568. * Purpose:
  569. * Calls PreApply and SetProp to Apply changes.
  570. *
  571. * Arguments:
  572. *
  573. * Return:
  574. * TRUE or FALSE
  575. */
  576. BOOL CppFaxOutboundRoutingRule::OnApply()
  577. {
  578. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::OnApply"));
  579. HRESULT hRc = S_OK;
  580. int CtrlFocus = 0;
  581. if (!m_fIsDirty)
  582. {
  583. return TRUE;
  584. }
  585. hRc = PreApply(&CtrlFocus);
  586. if (FAILED(hRc))
  587. {
  588. //Error Msg by called func.
  589. if (CtrlFocus)
  590. {
  591. GotoDlgCtrl(GetDlgItem(CtrlFocus));
  592. }
  593. return FALSE;
  594. }
  595. else //(Succeeded(hRc))
  596. {
  597. hRc = SetProps(&CtrlFocus);
  598. if (FAILED(hRc))
  599. {
  600. //Error Msg by called func.
  601. if (CtrlFocus)
  602. {
  603. GotoDlgCtrl(GetDlgItem(CtrlFocus));
  604. }
  605. return FALSE;
  606. }
  607. else //(Succeeded(hRc))
  608. {
  609. return TRUE;
  610. }
  611. }
  612. }
  613. /*
  614. - CppFaxOutboundRoutingRule::SetApplyButton
  615. -
  616. * Purpose:
  617. * set Apply buttom modified.
  618. *
  619. * Arguments:
  620. *
  621. * Return:
  622. * 1 (0)
  623. */
  624. LRESULT CppFaxOutboundRoutingRule::SetApplyButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  625. {
  626. if (!m_fIsDialogInitiated) //event receieved in too early stage
  627. {
  628. return 0;
  629. }
  630. m_fIsDirty = TRUE;
  631. SetModified(TRUE);
  632. bHandled = TRUE;
  633. return(1);
  634. }
  635. /*
  636. - CppFaxOutboundRoutingRule::OnDestenationRadioClicked
  637. -
  638. * Purpose:
  639. * Gray/Ungray the folder edit box and the
  640. * browse button. Enable apply button.
  641. *
  642. * Arguments:
  643. *
  644. * Return:
  645. * 1
  646. */
  647. LRESULT CppFaxOutboundRoutingRule::OnDestenationRadioClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  648. {
  649. BOOL State;
  650. if (!m_fIsDialogInitiated) //event receieved in too early stage
  651. {
  652. return 0;
  653. }
  654. else
  655. {
  656. m_fIsDirty = TRUE;
  657. }
  658. State = ( IsDlgButtonChecked(IDC_DESTINATION_RADIO11) == BST_CHECKED );
  659. ::EnableWindow(GetDlgItem(IDC_DEVICES4RULE_COMBO1), State);
  660. ATLASSERT(!State == (IsDlgButtonChecked(IDC_DESTINATION_RADIO21) == BST_CHECKED));
  661. ::EnableWindow(GetDlgItem(IDC_GROUP4RULE_COMBO1), !State);
  662. if (State)//IsDlgButtonChecked(IDC_DESTINATION_RADIO11) == BST_CHECKED
  663. {
  664. if ( CB_ERR == m_DeviceCombo.GetCurSel())
  665. {
  666. m_fAllReadyToApply = FALSE;
  667. SetModified(FALSE);
  668. goto Exit;
  669. }
  670. //else continue to whole controls check
  671. }
  672. else //IsDlgButtonChecked(IDC_DESTINATION_RADIO21) == BST_CHECKED
  673. {
  674. if ( CB_ERR == m_GroupCombo.GetCurSel())
  675. {
  676. m_fAllReadyToApply = FALSE;
  677. SetModified(FALSE);
  678. goto Exit;
  679. }
  680. //else continue to whole controls check
  681. }
  682. if (!m_fAllReadyToApply)
  683. {
  684. if (AllReadyToApply(TRUE))
  685. {
  686. m_fAllReadyToApply = TRUE;
  687. SetModified(TRUE);
  688. }
  689. else
  690. {
  691. //Should be EnableOK(FALSE);
  692. }
  693. }
  694. Exit:
  695. return(1);
  696. }
  697. /*
  698. - CppFaxOutboundRoutingRule::OnRuleTypeRadioClicked
  699. -
  700. * Purpose:
  701. * Gray/Ungray the folder edit box and the
  702. * browse button. Enable apply button.
  703. *
  704. * Arguments:
  705. *
  706. * Return:
  707. * 1
  708. */
  709. LRESULT CppFaxOutboundRoutingRule::OnRuleTypeRadioClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  710. {
  711. BOOL State;
  712. if (!m_fIsDialogInitiated) //event receieved in too early stage
  713. {
  714. return 0;
  715. }
  716. else
  717. {
  718. m_fIsDirty = TRUE;
  719. }
  720. State = ( IsDlgButtonChecked(IDC_COUNTRY_RADIO1) == BST_CHECKED );
  721. ATLASSERT(!State == ( IsDlgButtonChecked(IDC_AREA_RADIO1) == BST_CHECKED ) );
  722. ::EnableWindow(GetDlgItem(IDC_RULE_AREACODE_EDIT1), !State);
  723. if (!State)//IsDlgButtonChecked(IDC_AREA_RADIO1) == BST_CHECKED
  724. {
  725. if ( !m_AreaCodeEdit.GetWindowTextLength() )
  726. {
  727. m_fAllReadyToApply = FALSE;
  728. SetModified(FALSE);
  729. goto Exit;
  730. }
  731. //else continue to whole controls check
  732. }
  733. //else //IsDlgButtonChecked(IDC_COUNTRY_RADIO1) == BST_CHECKED
  734. //Do noting - continue to whole controls check
  735. if (!m_fAllReadyToApply)
  736. {
  737. if (AllReadyToApply(TRUE))
  738. {
  739. m_fAllReadyToApply = TRUE;
  740. SetModified(TRUE);
  741. }
  742. }
  743. Exit:
  744. return(1);
  745. }
  746. /*
  747. - CppFaxOutboundRoutingRule::OnComboChanged
  748. -
  749. * Purpose:
  750. * Gray/Ungray the submit button.
  751. *
  752. * Arguments:
  753. *
  754. * Return:
  755. * 1
  756. */
  757. LRESULT
  758. CppFaxOutboundRoutingRule::OnComboChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  759. {
  760. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::OnComboChanged"));
  761. if (!m_fIsDialogInitiated) //event receieved in too early stage
  762. {
  763. return 0;
  764. }
  765. else
  766. {
  767. m_fIsDirty = TRUE;
  768. }
  769. if (!m_fAllReadyToApply)
  770. {
  771. if (AllReadyToApply(TRUE))
  772. {
  773. m_fAllReadyToApply = TRUE;
  774. SetModified(TRUE);
  775. }
  776. }
  777. return 0;
  778. }
  779. /*
  780. - CppFaxOutboundRoutingRule::OnTextChanged
  781. -
  782. * Purpose:
  783. * Enable/Disable the submit button.
  784. *
  785. * Arguments:
  786. *
  787. * Return:
  788. * 1
  789. */
  790. LRESULT
  791. CppFaxOutboundRoutingRule::OnTextChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  792. {
  793. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::OnTextChanged"));
  794. UINT fEnableOK = 0;
  795. if (!m_fIsDialogInitiated) //event receieved in too early stage
  796. {
  797. return 0;
  798. }
  799. else
  800. {
  801. m_fIsDirty = TRUE;
  802. }
  803. switch (wID)
  804. {
  805. case IDC_RULE_AREACODE_EDIT1:
  806. fEnableOK = ( m_AreaCodeEdit.GetWindowTextLength() );
  807. break;
  808. case IDC_RULE_COUNTRYCODE_EDIT1:
  809. fEnableOK = ( m_CountryCodeEdit.GetWindowTextLength() );
  810. break;
  811. default:
  812. ATLASSERT(FALSE);
  813. }
  814. if(!!fEnableOK)
  815. {
  816. if (!m_fAllReadyToApply)
  817. {
  818. if (AllReadyToApply(TRUE))
  819. {
  820. m_fAllReadyToApply = TRUE;
  821. SetModified(TRUE);
  822. }
  823. }
  824. }
  825. else
  826. {
  827. SetModified(FALSE);
  828. m_fAllReadyToApply = FALSE;
  829. }
  830. return 0;
  831. }
  832. BOOL
  833. CppFaxOutboundRoutingRule::AllReadyToApply(BOOL fSilent)
  834. {
  835. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::AllReadyToApply"));
  836. HINSTANCE hInst;
  837. hInst = _Module.GetResourceInstance();
  838. if (ROUTING_RULE_COUNTRY_CODE_ANY != m_dwCountryCode)
  839. {
  840. if ( !m_CountryCodeEdit.GetWindowTextLength() )
  841. {
  842. if (!fSilent)
  843. {
  844. PageError(IDS_ZERO_COUNTRYCODE, m_hWnd, hInst);
  845. ::SetFocus(GetDlgItem(IDC_NEWRULE_COUNTRYCODE_EDIT));
  846. }
  847. return FALSE;
  848. }
  849. if ( IsDlgButtonChecked(IDC_AREA_RADIO1) == BST_CHECKED )
  850. {
  851. if ( !m_AreaCodeEdit.GetWindowTextLength() )
  852. {
  853. if (!fSilent)
  854. {
  855. PageError(IDS_EMPTY_AREACODE, m_hWnd, hInst);
  856. ::SetFocus(GetDlgItem(IDC_RULE_AREACODE_EDIT1));
  857. }
  858. return FALSE;
  859. }
  860. }
  861. //else - Do noting
  862. }
  863. if ( IsDlgButtonChecked(IDC_DESTINATION_RADIO11) == BST_CHECKED )
  864. {
  865. if ( CB_ERR == m_DeviceCombo.GetCurSel())
  866. {
  867. if (!fSilent)
  868. {
  869. PageError(IDS_PLEASESELECT_DEVICE, m_hWnd, hInst);
  870. ::SetFocus(GetDlgItem(IDC_DEVICES4RULE_COMBO1));
  871. }
  872. return FALSE;
  873. }
  874. }
  875. else if ( CB_ERR == m_GroupCombo.GetCurSel())
  876. {
  877. if (!fSilent)
  878. {
  879. PageError(IDS_PLEASESELECT_GROUP, m_hWnd, hInst);
  880. ::SetFocus(GetDlgItem(IDC_GROUP4RULE_COMBO1));
  881. }
  882. return FALSE;
  883. }
  884. //
  885. // Cheers!
  886. // ...every thing ready to apply now.
  887. //
  888. return TRUE;
  889. }
  890. HRESULT CppFaxOutboundRoutingRule::InitFaxRulePP(CFaxOutboundRoutingRuleNode * pParentNode)
  891. {
  892. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::InitFaxRulePP"));
  893. HRESULT hRc = S_OK;
  894. DWORD ec = ERROR_SUCCESS;
  895. //
  896. // Step 0: Init Parent
  897. //
  898. m_pParentNode = pParentNode;
  899. //
  900. // Step 1: Init Lists from RPC
  901. //
  902. //
  903. // get Fax Handle
  904. //
  905. if (!m_pFaxServer->GetFaxServerHandle())
  906. {
  907. ec= GetLastError();
  908. DebugPrintEx(
  909. DEBUG_ERR,
  910. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  911. ec);
  912. goto Error;
  913. }
  914. //
  915. // Devices (id, name)
  916. //
  917. if (!FaxEnumPortsEx(m_pFaxServer->GetFaxServerHandle(),
  918. &m_pFaxDevicesConfig,
  919. &m_dwNumOfDevices))
  920. {
  921. ec = GetLastError();
  922. DebugPrintEx(
  923. DEBUG_ERR,
  924. _T("Fail to get devices configuration. (ec: %ld)"),
  925. ec);
  926. if (IsNetworkError(ec))
  927. {
  928. DebugPrintEx(
  929. DEBUG_ERR,
  930. _T("Network Error was found. (ec: %ld)"),
  931. ec);
  932. m_pFaxServer->Disconnect();
  933. }
  934. goto Error;
  935. }
  936. ATLASSERT(m_pFaxDevicesConfig);
  937. //
  938. // Groups (names)
  939. //
  940. if (!FaxEnumOutboundGroups(m_pFaxServer->GetFaxServerHandle(),
  941. &m_pFaxGroupsConfig,
  942. &m_dwNumOfGroups))
  943. {
  944. ec = GetLastError();
  945. DebugPrintEx(
  946. DEBUG_ERR,
  947. _T("Fail to get groups configuration. (ec: %ld)"),
  948. ec);
  949. if (IsNetworkError(ec))
  950. {
  951. DebugPrintEx(
  952. DEBUG_ERR,
  953. _T("Network Error was found. (ec: %ld)"),
  954. ec);
  955. m_pFaxServer->Disconnect();
  956. }
  957. goto Error;
  958. }
  959. ATLASSERT(m_pFaxGroupsConfig);
  960. //
  961. // Step 2 : Init members from parent
  962. //
  963. ATLASSERT(m_pParentNode);
  964. m_dwCountryCode = m_pParentNode->GetCountryCode();
  965. m_dwAreaCode = m_pParentNode->GetAreaCode();
  966. m_fIsGroup = m_pParentNode->GetIsGroup();
  967. if (m_fIsGroup)
  968. {
  969. m_bstrGroupName = m_pParentNode->GetGroupName();
  970. if (!m_bstrGroupName)
  971. {
  972. hRc = E_OUTOFMEMORY;
  973. goto Error;
  974. }
  975. }
  976. else
  977. {
  978. m_dwDeviceID = m_pParentNode->GetDeviceID();
  979. }
  980. ATLASSERT(S_OK == hRc);
  981. DebugPrintEx( DEBUG_MSG,
  982. _T("Succeed to get all configurations."));
  983. goto Exit;
  984. Error:
  985. ATLASSERT(ERROR_SUCCESS != ec);
  986. hRc = HRESULT_FROM_WIN32(ec);
  987. //MsgBox will be done by calling Func.
  988. Exit:
  989. return hRc;
  990. }
  991. /*
  992. - CppFaxOutboundRoutingRule::FaxConfigureRule
  993. -
  994. * Purpose:
  995. * Configure the rule's device or group.
  996. *
  997. * Arguments:
  998. *
  999. * Return:
  1000. *
  1001. */
  1002. HRESULT CppFaxOutboundRoutingRule::FaxConfigureRule(
  1003. BOOL fNewUseGroup,
  1004. DWORD dwNewDeviceID,
  1005. LPCTSTR lpctstrNewGroupName)
  1006. {
  1007. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::FaxConfigureRule"));
  1008. HRESULT hRc = S_OK;
  1009. DWORD ec = ERROR_SUCCESS;
  1010. BOOL fSkipMessage = FALSE;
  1011. FAX_OUTBOUND_ROUTING_RULE FaxRuleConfig;
  1012. //
  1013. // Collect all data and init the structure's fields
  1014. // uses Copy() to copy and also allocate before
  1015. //
  1016. ZeroMemory (&FaxRuleConfig, sizeof(FAX_OUTBOUND_ROUTING_RULE));
  1017. //
  1018. // Init the needed fields
  1019. //
  1020. FaxRuleConfig.dwSizeOfStruct = sizeof(FAX_OUTBOUND_ROUTING_RULE);
  1021. FaxRuleConfig.dwAreaCode = m_dwAreaCode;
  1022. FaxRuleConfig.dwCountryCode = m_dwCountryCode;
  1023. FaxRuleConfig.bUseGroup = fNewUseGroup;
  1024. if (fNewUseGroup)
  1025. {
  1026. FaxRuleConfig.Destination.lpcstrGroupName = lpctstrNewGroupName;
  1027. }
  1028. else
  1029. {
  1030. FaxRuleConfig.Destination.dwDeviceId = dwNewDeviceID;
  1031. }
  1032. //
  1033. // get RPC Handle
  1034. //
  1035. if (!m_pFaxServer->GetFaxServerHandle())
  1036. {
  1037. ec= GetLastError();
  1038. DebugPrintEx(
  1039. DEBUG_ERR,
  1040. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  1041. ec);
  1042. goto Error;
  1043. }
  1044. //
  1045. // Configure the rule
  1046. //
  1047. if (!FaxSetOutboundRule (
  1048. m_pFaxServer->GetFaxServerHandle(),
  1049. &FaxRuleConfig))
  1050. {
  1051. ec = GetLastError();
  1052. // specific
  1053. if (FAX_ERR_BAD_GROUP_CONFIGURATION == ec)
  1054. {
  1055. DebugPrintEx(
  1056. DEBUG_ERR,
  1057. _T("The group is empty or none of group devices is valid. (ec: %ld)"),
  1058. ec);
  1059. PageError(IDS_BAD_GROUP_CONFIGURATION, m_hWnd);
  1060. fSkipMessage = TRUE;
  1061. goto Error;
  1062. }
  1063. //general
  1064. DebugPrintEx(
  1065. DEBUG_ERR,
  1066. _T("Fail to set rule %ld:%ld. (ec: %ld)"),
  1067. m_dwCountryCode, m_dwAreaCode, ec);
  1068. if (IsNetworkError(ec))
  1069. {
  1070. DebugPrintEx(
  1071. DEBUG_ERR,
  1072. _T("Network Error was found. (ec: %ld)"),
  1073. ec);
  1074. m_pFaxServer->Disconnect();
  1075. }
  1076. goto Error;
  1077. }
  1078. ATLASSERT(S_OK == hRc && ERROR_SUCCESS == ec);
  1079. DebugPrintEx( DEBUG_MSG,
  1080. _T("The rule was configured successfully."));
  1081. goto Exit;
  1082. Error:
  1083. ATLASSERT(ERROR_SUCCESS != ec);
  1084. hRc = HRESULT_FROM_WIN32(ec);
  1085. if (!fSkipMessage)
  1086. {
  1087. PageError(GetFaxServerErrorMsg(ec),m_hWnd);
  1088. }
  1089. Exit:
  1090. return(hRc);
  1091. }
  1092. /*
  1093. - CppFaxOutboundRoutingRule::FaxReplaceRule
  1094. -
  1095. * Purpose:
  1096. * Configure the rule's device or group.
  1097. *
  1098. * Arguments:
  1099. *
  1100. * Return:
  1101. *
  1102. */
  1103. HRESULT CppFaxOutboundRoutingRule::FaxReplaceRule(
  1104. DWORD dwNewAreaCode,
  1105. DWORD dwNewCountryCode,
  1106. BOOL fNewUseGroup,
  1107. DWORD dwNewDeviceID,
  1108. LPCTSTR lpctstrNewGroupName)
  1109. {
  1110. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::FaxReplaceRule"));
  1111. HRESULT hRc = S_OK;
  1112. DWORD ec = ERROR_SUCCESS;
  1113. BOOL fSkipMessage = FALSE;
  1114. //
  1115. // get RPC Handle
  1116. //
  1117. if (!m_pFaxServer->GetFaxServerHandle())
  1118. {
  1119. ec= GetLastError();
  1120. DebugPrintEx(
  1121. DEBUG_ERR,
  1122. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  1123. ec);
  1124. goto Error;
  1125. }
  1126. //
  1127. // Add the rule
  1128. //
  1129. if (!FaxAddOutboundRule (
  1130. m_pFaxServer->GetFaxServerHandle(),
  1131. dwNewAreaCode,
  1132. dwNewCountryCode,
  1133. dwNewDeviceID,
  1134. lpctstrNewGroupName,
  1135. fNewUseGroup))
  1136. {
  1137. ec = GetLastError();
  1138. DebugPrintEx(
  1139. DEBUG_ERR,
  1140. _T("Fail to add rule %ld:%ld. (ec: %ld)"),
  1141. m_dwCountryCode, m_dwAreaCode, ec);
  1142. if (ERROR_DUP_NAME == ec)
  1143. {
  1144. DlgMsgBox(this, IDS_OUTRULE_EXISTS);
  1145. goto Exit;
  1146. }
  1147. if (FAX_ERR_BAD_GROUP_CONFIGURATION == ec)
  1148. {
  1149. DebugPrintEx(
  1150. DEBUG_ERR,
  1151. _T("The group is empty or none of group devices is valid. (ec: %ld)"),
  1152. ec);
  1153. PageError(IDS_BAD_GROUP_CONFIGURATION, m_hWnd);
  1154. fSkipMessage = TRUE;
  1155. goto Error;
  1156. }
  1157. if (IsNetworkError(ec))
  1158. {
  1159. DebugPrintEx(
  1160. DEBUG_ERR,
  1161. _T("Network Error was found. (ec: %ld)"),
  1162. ec);
  1163. m_pFaxServer->Disconnect();
  1164. }
  1165. goto Error;
  1166. }
  1167. ATLASSERT(S_OK == hRc && ERROR_SUCCESS == ec);
  1168. DebugPrintEx( DEBUG_MSG,
  1169. _T("Step 1 - The new rule was added successfully."));
  1170. if (!FaxRemoveOutboundRule (
  1171. m_pFaxServer->GetFaxServerHandle(),
  1172. m_dwAreaCode,
  1173. m_dwCountryCode))
  1174. {
  1175. ec = GetLastError();
  1176. DebugPrintEx(
  1177. DEBUG_ERR,
  1178. _T("Fail to remove rule. (ec: %ld)"),
  1179. ec);
  1180. if (IsNetworkError(ec))
  1181. {
  1182. DebugPrintEx(
  1183. DEBUG_ERR,
  1184. _T("Network Error was found. (ec: %ld)"),
  1185. ec);
  1186. m_pFaxServer->Disconnect();
  1187. }
  1188. goto Error;
  1189. }
  1190. ATLASSERT(S_OK == hRc && ERROR_SUCCESS == ec);
  1191. DebugPrintEx( DEBUG_MSG,
  1192. _T("Step 2 - The old rule was removed successfully."));
  1193. goto Exit;
  1194. Error:
  1195. ATLASSERT(ERROR_SUCCESS != ec);
  1196. hRc = HRESULT_FROM_WIN32(ec);
  1197. if (!fSkipMessage)
  1198. {
  1199. PageError(GetFaxServerErrorMsg(ec),m_hWnd);
  1200. }
  1201. Exit:
  1202. return(hRc);
  1203. }
  1204. /*
  1205. - CppFaxOutboundRoutingRule::OnSelectCountryCodeClicked
  1206. -
  1207. * Purpose:
  1208. *
  1209. *
  1210. * Arguments:
  1211. * [out] bHandled - Do we handle it?
  1212. * [in] pRoot - The root node
  1213. *
  1214. * Return:
  1215. * OLE Error code
  1216. */
  1217. LRESULT
  1218. CppFaxOutboundRoutingRule::OnSelectCountryCodeClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)//(bool &bHandled, CSnapInObjectRootBase *pRoot)
  1219. {
  1220. DEBUG_FUNCTION_NAME( _T("CppFaxOutboundRoutingRule::OnSelectCountryCodeClicked"));
  1221. HRESULT hRc = S_OK;
  1222. INT_PTR rc = IDOK;
  1223. int iCount = 0;
  1224. WCHAR szwCountryCode[FXS_MAX_COUNTRYCODE_LEN+1];
  1225. DWORD dwCountryCode = 0;
  1226. CDlgSelectCountry DlgSelectCountry(m_pFaxServer);
  1227. hRc = DlgSelectCountry.InitSelectCountryCodeDlg();
  1228. if (S_OK != hRc)
  1229. {
  1230. //MsgBox + debug print by called func.
  1231. goto Cleanup;
  1232. }
  1233. //
  1234. // Dialog select country code
  1235. //
  1236. rc = DlgSelectCountry.DoModal();
  1237. if (rc != IDOK)
  1238. {
  1239. goto Cleanup;
  1240. }
  1241. //
  1242. // Retreive CountryCode
  1243. //
  1244. dwCountryCode = DlgSelectCountry.GetCountryCode();
  1245. iCount = swprintf(szwCountryCode, L"%ld", dwCountryCode);
  1246. if( iCount <= 0 )
  1247. {
  1248. DebugPrintEx(
  1249. DEBUG_ERR,
  1250. TEXT("Fail to read member - m_dwCountryCode."));
  1251. goto Cleanup;
  1252. }
  1253. m_CountryCodeEdit.SetWindowText(szwCountryCode);
  1254. //
  1255. // EnableOK
  1256. //
  1257. if (!m_fAllReadyToApply)
  1258. {
  1259. if (AllReadyToApply(TRUE))
  1260. {
  1261. m_fAllReadyToApply = TRUE;
  1262. SetModified(TRUE);
  1263. }
  1264. else
  1265. {
  1266. //Should be EnableOK(FALSE);
  1267. }
  1268. }
  1269. Cleanup:
  1270. return hRc;
  1271. }
  1272. //////////////////////////////////////////////////////////////////////////////
  1273. /*++
  1274. CppFaxServerSentItems::OnHelpRequest
  1275. This is called in response to the WM_HELP Notify
  1276. message and to the WM_CONTEXTMENU Notify message.
  1277. WM_HELP Notify message.
  1278. This message is sent when the user presses F1 or <Shift>-F1
  1279. over an item or when the user clicks on the ? icon and then
  1280. presses the mouse over an item.
  1281. WM_CONTEXTMENU Notify message.
  1282. This message is sent when the user right clicks over an item
  1283. and then clicks "What's this?"
  1284. --*/
  1285. /////////////////////////////////////////////////////////////////////////////
  1286. LRESULT
  1287. CppFaxOutboundRoutingRule::OnHelpRequest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
  1288. {
  1289. DEBUG_FUNCTION_NAME(_T("CppFaxOutboundRoutingRule::OnHelpRequest"));
  1290. switch (uMsg)
  1291. {
  1292. case WM_HELP:
  1293. WinContextHelp(((LPHELPINFO)lParam)->dwContextId, m_hWnd);
  1294. break;
  1295. case WM_CONTEXTMENU:
  1296. WinContextHelp(::GetWindowContextHelpId((HWND)wParam), m_hWnd);
  1297. break;
  1298. }
  1299. return TRUE;
  1300. }
  1301. /////////////////////////////////////////////////////////////////////////////