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.

1579 lines
40 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : ppFaxServerReceipts.cpp //
  3. // //
  4. // DESCRIPTION : prop pages of Fax Receipts server defaults //
  5. // //
  6. // AUTHOR : yossg //
  7. // //
  8. // HISTORY : //
  9. // Jul 20 2000 yossg New design - all delivery receipts options //
  10. // Oct 17 2000 yossg //
  11. // //
  12. // Copyright (C) 2000 Microsoft Corporation All Rights Reserved //
  13. /////////////////////////////////////////////////////////////////////////////
  14. #include "stdafx.h"
  15. #include "MSFxsSnp.h"
  16. #include "ppFaxServerReceipts.h"
  17. #include "FaxServer.h"
  18. #include "FaxServerNode.h"
  19. #include "DlgSMTPConfig.h"
  20. #include "BosSmtpConfigDlg.h"
  21. #include "FxsValid.h"
  22. #include "dlgutils.h"
  23. #include <windns.h> //DNS_MAX_NAME_BUFFER_LENGTH
  24. #include <htmlHelp.h> //HtmlHelp()
  25. #include "resutil.h"
  26. #include <shlobjp.h>
  27. #include <shellapi.h>
  28. #include <faxreg.h>
  29. #include <faxres.h>
  30. EXTERN_C BOOL WINAPI LinkWindow_RegisterClass() ;
  31. EXTERN_C BOOL WINAPI LinkWindow_UnregisterClass( HINSTANCE ) ;
  32. #ifdef _DEBUG
  33. #undef THIS_FILE
  34. static char THIS_FILE[] = __FILE__;
  35. #endif
  36. //
  37. // Constructor
  38. //
  39. CppFaxServerReceipts::CppFaxServerReceipts(
  40. LONG_PTR hNotificationHandle,
  41. CSnapInItem *pNode,
  42. BOOL bOwnsNotificationHandle,
  43. HINSTANCE hInst)
  44. : CPropertyPageExImpl<CppFaxServerReceipts>(pNode,NULL)
  45. {
  46. m_pParentNode = static_cast <CFaxServerNode *> (pNode);
  47. m_pFaxReceiptsConfig = NULL;
  48. m_fAllReadyToApply = FALSE;
  49. m_fIsDialogInitiated = FALSE;
  50. m_fIsDirty = FALSE;
  51. m_enumSmtpAuthOption = FAX_SMTP_AUTH_ANONYMOUS;
  52. m_bstrUserName = L"";
  53. m_fLastGoodIsSMTPRouteConfigured = FALSE;
  54. }
  55. //
  56. // Destructor
  57. //
  58. CppFaxServerReceipts::~CppFaxServerReceipts()
  59. {
  60. if (NULL != m_pFaxReceiptsConfig)
  61. {
  62. FaxFreeBuffer( m_pFaxReceiptsConfig );
  63. }
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CppFaxServerReceipts message handlers
  67. /*
  68. - CppFaxServerReceipts::InitRPC
  69. -
  70. * Purpose:
  71. * Initiates the configuration structure from RPC get Call.
  72. *
  73. * Arguments:
  74. *
  75. * Return:
  76. * OLE error code
  77. */
  78. HRESULT CppFaxServerReceipts::InitRPC()
  79. {
  80. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::InitRPC"));
  81. HRESULT hRc = S_OK;
  82. DWORD ec = ERROR_SUCCESS;
  83. //
  84. // get RPC Handle
  85. //
  86. if (!m_pFaxServer->GetFaxServerHandle())
  87. {
  88. ec= GetLastError();
  89. DebugPrintEx(
  90. DEBUG_ERR,
  91. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  92. ec);
  93. goto Error;
  94. }
  95. //
  96. // Retrieve the fax SMTP configuration
  97. //
  98. if (!FaxGetReceiptsConfiguration(m_pFaxServer->GetFaxServerHandle(),
  99. &m_pFaxReceiptsConfig))
  100. {
  101. ec = GetLastError();
  102. DebugPrintEx(
  103. DEBUG_ERR,
  104. _T("Fail to get mail configuration. (ec: %ld)"),
  105. ec);
  106. if (IsNetworkError(ec))
  107. {
  108. DebugPrintEx(
  109. DEBUG_ERR,
  110. _T("Network Error was found. (ec: %ld)"),
  111. ec);
  112. m_pFaxServer->Disconnect();
  113. }
  114. goto Error;
  115. }
  116. //For max verification
  117. ATLASSERT(m_pFaxReceiptsConfig);
  118. //
  119. // Init members - for advance dialog or save operation
  120. //
  121. m_enumSmtpAuthOption = m_pFaxReceiptsConfig->SMTPAuthOption;
  122. m_bstrUserName = m_pFaxReceiptsConfig->lptstrSMTPUserName;
  123. if ( !m_bstrUserName)
  124. {
  125. ec = ERROR_NOT_ENOUGH_MEMORY;
  126. DebugPrintEx( DEBUG_ERR,
  127. _T("Null bstr - out of memory."));
  128. goto Error;
  129. }
  130. // m_pszPassword is NULL from the constructor
  131. // there is no need to read from the server.
  132. // init status for unselcting this feature
  133. // with still assigned devices to this Microsoft SMTP method
  134. if ( m_pFaxReceiptsConfig->bIsToUseForMSRouteThroughEmailMethod )
  135. {
  136. m_fLastGoodIsSMTPRouteConfigured = TRUE;
  137. }
  138. ATLASSERT(ERROR_SUCCESS == ec);
  139. DebugPrintEx( DEBUG_MSG,
  140. _T("Succeed to get mail configuration."));
  141. goto Exit;
  142. Error:
  143. ATLASSERT(ERROR_SUCCESS != ec);
  144. hRc = HRESULT_FROM_WIN32(ec);
  145. ATLASSERT(NULL != m_pParentNode);
  146. m_pParentNode->NodeMsgBox(GetFaxServerErrorMsg(ec));
  147. Exit:
  148. return (hRc);
  149. }
  150. /*
  151. - CppFaxServerReceipts::OnInitDialog
  152. -
  153. * Purpose:
  154. * Initiates all controls when dialog is called.
  155. *
  156. * Arguments:
  157. *
  158. * Return:
  159. *
  160. */
  161. LRESULT CppFaxServerReceipts::OnInitDialog( UINT uiMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled )
  162. {
  163. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::OnInitDialog"));
  164. UNREFERENCED_PARAMETER( uiMsg );
  165. UNREFERENCED_PARAMETER( wParam );
  166. UNREFERENCED_PARAMETER( lParam );
  167. UNREFERENCED_PARAMETER( fHandled );
  168. BOOL fIsUnderLocalUserAccount = FALSE;
  169. WCHAR buff[100];
  170. int count;
  171. //
  172. // Attach
  173. //
  174. m_SmtpBox.Attach(GetDlgItem(IDC_SMTP_EDIT));
  175. m_PortBox.Attach(GetDlgItem(IDC_PORT_EDIT));
  176. m_AddressBox.Attach(GetDlgItem(IDC_ADDRESS_EDIT));
  177. //
  178. // Limit text length
  179. //
  180. m_PortBox.SetLimitText(FXS_MAX_PORT_NUM_LEN);
  181. m_SmtpBox.SetLimitText(DNS_MAX_NAME_BUFFER_LENGTH);
  182. m_AddressBox.SetLimitText(FXS_MAX_EMAIL_ADDRESS);
  183. //
  184. // init controls
  185. //
  186. ATLASSERT(NULL != m_pFaxReceiptsConfig);
  187. //
  188. // Port
  189. //
  190. count = swprintf(buff,
  191. L"%ld", m_pFaxReceiptsConfig->dwSMTPPort);
  192. ATLASSERT(count > 0);
  193. if( count > 0 )
  194. {
  195. m_PortBox.SetWindowText(buff);
  196. }
  197. //
  198. //
  199. //
  200. m_SmtpBox.SetWindowText (m_pFaxReceiptsConfig->lptstrSMTPServer);
  201. m_AddressBox.SetWindowText(m_pFaxReceiptsConfig->lptstrSMTPFrom);
  202. if (m_fLastGoodIsSMTPRouteConfigured)
  203. {
  204. CheckDlgButton(IDC_SMTP_ROUTE_CHECK, BST_CHECKED);
  205. }
  206. DWORD dwReceiptsOptions = m_pFaxReceiptsConfig->dwAllowedReceipts;
  207. if (DRT_NONE == dwReceiptsOptions && !m_fLastGoodIsSMTPRouteConfigured)
  208. {
  209. EnableSmtpFields(FALSE);
  210. }
  211. else
  212. {
  213. if( dwReceiptsOptions & DRT_EMAIL )
  214. {
  215. CheckDlgButton(IDC_RECEIPT_ENABLE_SMTP_CHECK, BST_CHECKED);
  216. }
  217. else
  218. {
  219. CheckDlgButton(IDC_RECEIPT_ENABLE_SMTP_CHECK, BST_UNCHECKED);
  220. if (!m_fLastGoodIsSMTPRouteConfigured)
  221. {
  222. EnableSmtpFields(FALSE);
  223. }
  224. else
  225. {
  226. CheckDlgButton(IDC_SMTP_ROUTE_CHECK, BST_CHECKED);
  227. }
  228. }
  229. if ( dwReceiptsOptions & DRT_MSGBOX )
  230. {
  231. CheckDlgButton(IDC_RECEIPT_ENABLE_MSGBOX_CHECK, BST_CHECKED);
  232. }
  233. else
  234. {
  235. CheckDlgButton(IDC_RECEIPT_ENABLE_MSGBOX_CHECK, BST_UNCHECKED);
  236. }
  237. }
  238. m_fIsDialogInitiated = TRUE;
  239. return(1);
  240. }
  241. /*
  242. - CppFaxServerReceipts::SetProps
  243. -
  244. * Purpose:
  245. * Sets properties on apply.
  246. *
  247. * Arguments:
  248. * IN pCtrlFocus - focus pointer (int)
  249. *
  250. * Return:
  251. * OLE error code
  252. */
  253. HRESULT CppFaxServerReceipts::SetProps(int *pCtrlFocus, UINT * puIds)
  254. {
  255. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::SetProps"));
  256. HRESULT hRc = S_OK;
  257. DWORD ec = ERROR_SUCCESS;
  258. BOOL fSkipMessage = FALSE;
  259. CComBSTR bstrSmtpSever,
  260. bstrPort,
  261. bstrSenderAddress;
  262. DWORD dwPort;
  263. BOOL fIsSMTPRouteConfigured = FALSE;
  264. BOOL fIsSMTPReceiptsConfigured = FALSE;
  265. FAX_RECEIPTS_CONFIG FaxReceiptsConfig;
  266. *pCtrlFocus = 0; //safty
  267. ATLASSERT(TRUE == m_fAllReadyToApply);
  268. m_fAllReadyToApply = FALSE;
  269. //
  270. // Collect all data and init the structure's fields
  271. // uses Copy() to copy and also allocate before
  272. //
  273. //
  274. // This operation is very important for the case of unchecked email option
  275. // the service will neglect the SMTP fields.
  276. //
  277. ZeroMemory (&FaxReceiptsConfig, sizeof(FaxReceiptsConfig));
  278. FaxReceiptsConfig.dwSizeOfStruct = sizeof(FAX_RECEIPTS_CONFIG);
  279. FaxReceiptsConfig.dwAllowedReceipts = DRT_NONE; // 0x0000
  280. fIsSMTPRouteConfigured = (IsDlgButtonChecked(IDC_SMTP_ROUTE_CHECK) == BST_CHECKED);
  281. //
  282. // While tring to sumbmit unchecking of IDC_SMTP_ROUTE_CHECK
  283. // Special search for any left assigned devices' to Microsoft e-mail routing method
  284. //
  285. if ( !fIsSMTPRouteConfigured && m_fLastGoodIsSMTPRouteConfigured)
  286. {
  287. //Call function that will make loop on all FaxEnumPorts(/Ex) and FaxEnumRoutingMethods
  288. //and will pop-up ErrMsgBox in case in any Device The SMTP Microsoft Route
  289. //Through e-mail method is still enabled while the user tries to unchecked.
  290. if (IsMsSMTPRoutingMethodStillAssigned())
  291. {
  292. PropSheet_SetCurSelByID( GetParent(), IDD);
  293. ATLASSERT(::IsWindow(m_hWnd));
  294. PageError(IDS_MS_SMTPROUTINGMETHOD_ASSIGNED, m_hWnd);
  295. fSkipMessage = TRUE;
  296. goto Error;
  297. }
  298. }
  299. //
  300. // SMTP server details
  301. //
  302. if ( IsDlgButtonChecked(IDC_RECEIPT_ENABLE_SMTP_CHECK) == BST_CHECKED )
  303. {
  304. fIsSMTPReceiptsConfigured = TRUE;
  305. FaxReceiptsConfig.dwAllowedReceipts |= DRT_EMAIL;
  306. }
  307. if (
  308. fIsSMTPReceiptsConfigured
  309. ||
  310. fIsSMTPRouteConfigured
  311. )
  312. {
  313. if ( !m_SmtpBox.GetWindowText(&bstrSmtpSever))
  314. {
  315. *pCtrlFocus = IDC_SMTP_EDIT;
  316. DebugPrintEx(
  317. DEBUG_ERR,
  318. TEXT("Failed to GetWindowText(&bstrSmtpSever)"));
  319. ec = ERROR_OUTOFMEMORY;
  320. goto Error;
  321. }
  322. if ( !m_PortBox.GetWindowText(&bstrPort))
  323. {
  324. *pCtrlFocus = IDC_PORT_EDIT;
  325. DebugPrintEx(
  326. DEBUG_ERR,
  327. TEXT("Failed to GetWindowText(&bstrPort)"));
  328. ec = ERROR_OUTOFMEMORY;
  329. goto Error;
  330. }
  331. if ( !m_AddressBox.GetWindowText(&bstrSenderAddress))
  332. {
  333. *pCtrlFocus = IDC_SMTP_EDIT;
  334. DebugPrintEx(
  335. DEBUG_ERR,
  336. TEXT("Failed to GetWindowText(&bstrSenderAddress)"));
  337. ec = ERROR_OUTOFMEMORY;
  338. goto Error;
  339. }
  340. //
  341. // Validation
  342. //
  343. if (!IsValidData(bstrSmtpSever,
  344. bstrPort,
  345. &dwPort,
  346. bstrSenderAddress,
  347. pCtrlFocus,
  348. puIds)
  349. )
  350. {
  351. ATLASSERT(pCtrlFocus);
  352. ATLASSERT(puIds);
  353. ec = ERROR_INVALID_DATA;
  354. //in this case detailed message box was given by the called functions
  355. fSkipMessage = TRUE;
  356. goto Error;
  357. }
  358. //
  359. // subtitute all data
  360. //
  361. FaxReceiptsConfig.lptstrSMTPServer = bstrSmtpSever;
  362. FaxReceiptsConfig.dwSMTPPort = dwPort;
  363. FaxReceiptsConfig.lptstrSMTPFrom = bstrSenderAddress;
  364. FaxReceiptsConfig.SMTPAuthOption = m_enumSmtpAuthOption;
  365. FaxReceiptsConfig.lptstrSMTPUserName = m_bstrUserName;
  366. FaxReceiptsConfig.lptstrSMTPPassword = m_bstrPassword;
  367. }
  368. //
  369. // Set dwAllowedReceipts
  370. //
  371. FaxReceiptsConfig.bIsToUseForMSRouteThroughEmailMethod = fIsSMTPRouteConfigured;
  372. //
  373. // Message box
  374. //
  375. if (IsDlgButtonChecked(IDC_RECEIPT_ENABLE_MSGBOX_CHECK) == BST_CHECKED)
  376. {
  377. FaxReceiptsConfig.dwAllowedReceipts |= DRT_MSGBOX;
  378. }
  379. //
  380. // get RPC Handle
  381. //
  382. if (!m_pFaxServer->GetFaxServerHandle())
  383. {
  384. ec= GetLastError();
  385. DebugPrintEx(
  386. DEBUG_ERR,
  387. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  388. ec);
  389. goto Error;
  390. }
  391. //
  392. // Set Config
  393. //
  394. if (!FaxSetReceiptsConfiguration(
  395. m_pFaxServer->GetFaxServerHandle(),
  396. &FaxReceiptsConfig))
  397. {
  398. ec = GetLastError();
  399. DebugPrintEx(
  400. DEBUG_ERR,
  401. _T("Fail to Set receipts configuration. (ec: %ld)"),
  402. ec);
  403. if (IsNetworkError(ec))
  404. {
  405. DebugPrintEx(
  406. DEBUG_ERR,
  407. _T("Network Error was found. (ec: %ld)"),
  408. ec);
  409. m_pFaxServer->Disconnect();
  410. }
  411. goto Error;
  412. }
  413. ATLASSERT(ERROR_SUCCESS == ec);
  414. m_fLastGoodIsSMTPRouteConfigured = fIsSMTPRouteConfigured;
  415. DebugPrintEx( DEBUG_MSG,
  416. _T("Succeed to set receipts configuration."));
  417. m_fIsDirty = FALSE;
  418. goto Exit;
  419. Error:
  420. ATLASSERT(ERROR_SUCCESS != ec);
  421. hRc = HRESULT_FROM_WIN32(ec);
  422. if (!fSkipMessage)
  423. {
  424. PropSheet_SetCurSelByID( GetParent(), IDD);
  425. ATLASSERT(::IsWindow(m_hWnd));
  426. PageError(GetFaxServerErrorMsg(ec), m_hWnd);
  427. }
  428. Exit:
  429. return hRc;
  430. }
  431. /*
  432. - CppFaxServerReceipts::PreApply
  433. -
  434. * Purpose:
  435. * Checks data validity before apply.
  436. *
  437. * Arguments:
  438. *
  439. * Return:
  440. * OLE error code
  441. */
  442. HRESULT CppFaxServerReceipts::PreApply(int *pCtrlFocus, UINT * puIds)
  443. {
  444. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::PreApply"));
  445. HRESULT hRc = S_OK;
  446. //
  447. // PreApply Checks
  448. //
  449. if (!AllReadyToApply(/*fSilent =*/ FALSE, pCtrlFocus , puIds))
  450. {
  451. m_fAllReadyToApply = FALSE;
  452. SetModified(FALSE);
  453. hRc = E_FAIL ;
  454. }
  455. else
  456. {
  457. m_fAllReadyToApply = TRUE;
  458. SetModified(TRUE);
  459. }
  460. return(hRc);
  461. }
  462. /*
  463. - CppFaxServerReceipts::OnApply
  464. -
  465. * Purpose:
  466. * Calls PreApply and SetProp to Apply changes.
  467. *
  468. * Arguments:
  469. *
  470. * Return:
  471. * TRUE or FALSE
  472. */
  473. BOOL CppFaxServerReceipts::OnApply()
  474. {
  475. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::OnApply"));
  476. HRESULT hRc = S_OK;
  477. int CtrlFocus = 0;
  478. UINT uIds = 0;
  479. if (!m_fIsDirty)
  480. {
  481. return TRUE;
  482. }
  483. hRc = PreApply(&CtrlFocus, &uIds);
  484. if (FAILED(hRc))
  485. {
  486. if (PropSheet_SetCurSelByID( GetParent(), IDD) )
  487. {
  488. PageError(uIds, m_hWnd, _Module.GetResourceInstance());
  489. if (CtrlFocus)
  490. {
  491. GotoDlgCtrl(GetDlgItem(CtrlFocus));
  492. }
  493. }
  494. return FALSE;
  495. }
  496. else //(Succeeded(hRc))
  497. {
  498. hRc = SetProps(&CtrlFocus, &uIds);
  499. if (FAILED(hRc))
  500. {
  501. if (uIds)
  502. {
  503. if (PropSheet_SetCurSelByID( GetParent(), IDD) )
  504. {
  505. PageError(uIds, m_hWnd, _Module.GetResourceInstance());
  506. if (CtrlFocus)
  507. {
  508. GotoDlgCtrl(GetDlgItem(CtrlFocus));
  509. }
  510. }
  511. }
  512. //else Error Msg by called func.
  513. return FALSE;
  514. }
  515. else //(Succeeded(hRc))
  516. {
  517. return TRUE;
  518. }
  519. }
  520. }
  521. /*
  522. - CppFaxServerReceipts::SetApplyButton
  523. -
  524. * Purpose:
  525. * set Apply buttom modified.
  526. *
  527. * Arguments:
  528. *
  529. * Return:
  530. * 1
  531. */
  532. LRESULT CppFaxServerReceipts::SetApplyButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  533. {
  534. SetModified(TRUE);
  535. bHandled = TRUE;
  536. return(1);
  537. }
  538. /*
  539. - CppFaxServerReceipts::EnableSmtpFields
  540. -
  541. * Purpose:
  542. * Enable/dissable Authenticated Access dialog controls.
  543. *
  544. * Arguments:
  545. * [in] state - boolean value to enable TRUE or FALSE to disable
  546. *
  547. * Return:
  548. * void
  549. */
  550. void CppFaxServerReceipts::EnableSmtpFields(BOOL state)
  551. {
  552. ::EnableWindow(GetDlgItem(IDC_ADDRESS_STATIC), state);
  553. ::EnableWindow(GetDlgItem(IDC_ADDRESS_EDIT), state);
  554. ::EnableWindow(GetDlgItem(IDC_SMTP_STATIC), state);
  555. ::EnableWindow(GetDlgItem(IDC_SMTP_EDIT), state);
  556. ::EnableWindow(GetDlgItem(IDC_PORT_STATIC), state);
  557. ::EnableWindow(GetDlgItem(IDC_PORT_EDIT), state);
  558. ::EnableWindow(GetDlgItem(IDC_AUTHENTICATION_BUTTON), state);
  559. }
  560. /*
  561. - CppFaxServerReceipts::OnMsgBoxDeliveryOptionChecked
  562. -
  563. * Purpose:
  564. * Handles the checking/unchecking of the 'Msg box' receipt checkbox.
  565. * Checks if the Messenger service is disabled.
  566. *
  567. * Arguments:
  568. *
  569. * Return:
  570. * 1
  571. */
  572. LRESULT CppFaxServerReceipts::OnMsgBoxDeliveryOptionChecked(
  573. WORD wNotifyCode,
  574. WORD wID,
  575. HWND hWndCtl,
  576. BOOL& bHandled)
  577. {
  578. if (!m_fIsDialogInitiated)
  579. {
  580. //
  581. // Event receieved too early
  582. //
  583. return 0;
  584. }
  585. else
  586. {
  587. m_fIsDirty = TRUE;
  588. }
  589. if (BST_CHECKED == IsDlgButtonChecked(IDC_RECEIPT_ENABLE_MSGBOX_CHECK))
  590. {
  591. //
  592. // The 'Allow message boxes receipt' check-box was just checked
  593. //
  594. DWORD dwMessengerStartupType;
  595. ATLASSERT(m_pParentNode);
  596. CComBSTR bstrServerName = m_pParentNode->GetServerName();
  597. if (ERROR_SUCCESS == GetServiceStartupType (bstrServerName, MESSENGER_SERVICE_NAME, &dwMessengerStartupType))
  598. {
  599. if (SERVICE_DISABLED == dwMessengerStartupType)
  600. {
  601. //
  602. // Ooops. The Messenger service is disabled. We can't send message boxes.
  603. // Ask the user if he want's us to enable the messenger service.
  604. //
  605. WCHAR wszTitle[MAX_PATH * 2];
  606. WCHAR wszQuestion[MAX_PATH * 2];
  607. if (LoadString( _Module.GetResourceInstance(),
  608. IDS_FAX_WRN_MESSENGER_TITLE,
  609. wszTitle,
  610. ARR_SIZE (wszTitle)) &&
  611. LoadString( _Module.GetResourceInstance(),
  612. IDS_FAX_WRN_MESSENGER_DISABLED,
  613. wszQuestion,
  614. ARR_SIZE (wszQuestion)))
  615. {
  616. if (IDYES == AlignedMessageBox (m_hWnd, wszQuestion, wszTitle, MB_YESNO | MB_ICONWARNING))
  617. {
  618. //
  619. // User chose to enble the Messenger service
  620. //
  621. HCURSOR hOldCursor = SetCursor (LoadCursor (NULL, IDC_WAIT));
  622. DWORD dwRes = SetServiceStartupType (bstrServerName, MESSENGER_SERVICE_NAME, SERVICE_AUTO_START);
  623. if (ERROR_SUCCESS != dwRes)
  624. {
  625. PageError(GetErrorStringId(dwRes), m_hWnd, _Module.GetResourceInstance());
  626. }
  627. else
  628. {
  629. //
  630. // Also start it
  631. //
  632. dwRes = StartServiceEx (bstrServerName, MESSENGER_SERVICE_NAME, 0, NULL, INFINITE);
  633. if (ERROR_SUCCESS != dwRes)
  634. {
  635. PageError(GetErrorStringId(dwRes), m_hWnd, _Module.GetResourceInstance());
  636. }
  637. }
  638. SetCursor (hOldCursor);
  639. }
  640. }
  641. }
  642. }
  643. }
  644. if (AllReadyToApply(TRUE))
  645. {
  646. m_fAllReadyToApply = TRUE;
  647. SetModified(TRUE);
  648. }
  649. else
  650. {
  651. m_fAllReadyToApply = FALSE;
  652. SetModified(FALSE);
  653. }
  654. return 1;
  655. } // CppFaxServerReceipts::OnMsgBoxDeliveryOptionChecked
  656. /*
  657. - CppFaxServerReceipts::OnDeliveryOptionChecked
  658. -
  659. * Purpose:
  660. * Gray/Ungray controls
  661. * Enable apply button.
  662. *
  663. * Arguments:
  664. *
  665. * Return:
  666. * 1
  667. */
  668. LRESULT CppFaxServerReceipts::OnDeliveryOptionChecked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  669. {
  670. BOOL fState;
  671. if (!m_fIsDialogInitiated) //event receieved in too early stage
  672. {
  673. return 0;
  674. }
  675. else
  676. {
  677. m_fIsDirty = TRUE;
  678. }
  679. fState = (
  680. IsDlgButtonChecked(IDC_RECEIPT_ENABLE_SMTP_CHECK) == BST_CHECKED
  681. ||
  682. IsDlgButtonChecked(IDC_SMTP_ROUTE_CHECK) == BST_CHECKED
  683. );
  684. EnableSmtpFields(fState);
  685. if (AllReadyToApply(TRUE))
  686. {
  687. m_fAllReadyToApply = TRUE;
  688. SetModified(TRUE);
  689. }
  690. else
  691. {
  692. m_fAllReadyToApply = FALSE;
  693. SetModified(FALSE);
  694. }
  695. return(1);
  696. }
  697. /*
  698. - CppFaxServerReceipts::OnAuthenticationButtonClicked
  699. -
  700. * Purpose:
  701. * To allow opening of the advance SMTP configuration server.
  702. *
  703. * Arguments:
  704. *
  705. * Return:
  706. * 1
  707. */
  708. LRESULT CppFaxServerReceipts::OnAuthenticationButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  709. {
  710. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::OnAuthenticationButtonClicked"));
  711. INT_PTR rc = IDCANCEL;
  712. HRESULT hRc = S_OK;
  713. DWORD dwRet = ERROR_SUCCESS;
  714. if(m_pFaxServer->GetServerAPIVersion() == FAX_API_VERSION_0)
  715. {
  716. //
  717. // The remote fax server is SBS/BOS 2000
  718. // it uses different authentication mechanism
  719. //
  720. OpenBosAuthenticationDlg();
  721. return 1;
  722. }
  723. CDlgSMTPConfig DlgSMTPConfig;
  724. //
  725. // Dialog to configure SMTP authentication mode
  726. //
  727. hRc = DlgSMTPConfig.InitSmtpDlg(
  728. m_enumSmtpAuthOption,
  729. m_bstrUserName);
  730. if (FAILED(hRc))
  731. {
  732. m_pParentNode->NodeMsgBox(IDS_MEMORY);
  733. goto Cleanup;
  734. }
  735. rc = DlgSMTPConfig.DoModal();
  736. if (rc != IDOK)
  737. {
  738. goto Cleanup;
  739. }
  740. //else
  741. m_enumSmtpAuthOption = DlgSMTPConfig.GetAuthenticationOption();
  742. if (
  743. FAX_SMTP_AUTH_BASIC == m_enumSmtpAuthOption
  744. ||
  745. FAX_SMTP_AUTH_NTLM == m_enumSmtpAuthOption
  746. )
  747. {
  748. m_bstrUserName = DlgSMTPConfig.GetUserName();
  749. if (!m_bstrUserName)
  750. {
  751. DebugPrintEx(
  752. DEBUG_ERR,
  753. TEXT("Null memeber BSTR - m_bstrUserName."));
  754. m_pParentNode->NodeMsgBox(IDS_MEMORY);
  755. goto Cleanup;
  756. }
  757. if ( DlgSMTPConfig.IsPasswordModified() )
  758. {
  759. m_bstrPassword = DlgSMTPConfig.GetPassword();
  760. if (!m_bstrPassword)
  761. {
  762. DebugPrintEx(
  763. DEBUG_ERR,
  764. TEXT("Out of memory while setting m_bstrPassword"));
  765. m_pParentNode->NodeMsgBox(IDS_MEMORY);
  766. goto Cleanup;
  767. }
  768. }
  769. else
  770. {
  771. m_bstrPassword.Empty();
  772. }
  773. }
  774. m_fIsDirty = TRUE;
  775. if (AllReadyToApply(TRUE))
  776. {
  777. m_fAllReadyToApply = TRUE;
  778. SetModified(TRUE);
  779. }
  780. Cleanup:
  781. return 1;
  782. }
  783. /*
  784. - CppFaxServerReceipts::OpenBosAuthenticationDlg
  785. -
  786. * Purpose:
  787. * Open the old (BOS/SBS 2000) version of Authentication dialog.
  788. *
  789. * Arguments:
  790. *
  791. * Return:
  792. * 1
  793. */
  794. LRESULT CppFaxServerReceipts::OpenBosAuthenticationDlg()
  795. {
  796. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::OnAuthenticationButtonClicked"));
  797. INT_PTR rc = IDOK;
  798. HRESULT hRc = S_OK;
  799. DWORD dwRet = ERROR_SUCCESS;
  800. CBosSmtpConfigDlg DlgSMTPConfig;
  801. //
  802. // IsUnderLocalUserAccount.
  803. //
  804. BOOL fIsUnderLocalUserAccount = FALSE;
  805. hRc = IsUnderLocalUserAccount(&fIsUnderLocalUserAccount);
  806. if ( S_OK != hRc )
  807. {
  808. DebugPrintEx(DEBUG_ERR,
  809. _T("IsUnderLocalUserAccount failed. (hRc: %08X)"),
  810. hRc);
  811. goto Cleanup;
  812. }
  813. //
  814. // Dialog to configure SMTP authentication mode
  815. //
  816. hRc = DlgSMTPConfig.InitSmtpDlg(
  817. m_enumSmtpAuthOption,
  818. m_bstrUserName,
  819. fIsUnderLocalUserAccount);
  820. if (FAILED(hRc))
  821. {
  822. m_pParentNode->NodeMsgBox(IDS_MEMORY);
  823. goto Cleanup;
  824. }
  825. rc = DlgSMTPConfig.DoModal();
  826. if (rc != IDOK)
  827. {
  828. goto Cleanup;
  829. }
  830. //else
  831. m_bstrUserName = DlgSMTPConfig.GetUserName();
  832. if (!m_bstrUserName)
  833. {
  834. DebugPrintEx(
  835. DEBUG_ERR,
  836. TEXT("Out of memory while setting m_bstrUserName"));
  837. m_pParentNode->NodeMsgBox(IDS_MEMORY);
  838. goto Cleanup;
  839. }
  840. if (DlgSMTPConfig.IsPasswordModified())
  841. {
  842. m_bstrPassword = DlgSMTPConfig.GetPassword();
  843. if (!m_bstrPassword)
  844. {
  845. DebugPrintEx(
  846. DEBUG_ERR,
  847. TEXT("Out of memory while setting m_bstrPassword"));
  848. m_pParentNode->NodeMsgBox(IDS_MEMORY);
  849. goto Cleanup;
  850. }
  851. }
  852. else
  853. {
  854. m_bstrPassword.Empty();
  855. }
  856. m_enumSmtpAuthOption = DlgSMTPConfig.GetAuthenticationOption();
  857. m_fIsDirty = TRUE;
  858. if (AllReadyToApply(TRUE))
  859. {
  860. m_fAllReadyToApply = TRUE;
  861. SetModified(TRUE);
  862. }
  863. Cleanup:
  864. return 1;
  865. }
  866. /*
  867. - CppFaxServerReceipts::IsUnderLocalUserAccount
  868. -
  869. * Purpose:
  870. * Check if fax service Is running Under LocalUser Account.
  871. *
  872. * Arguments:
  873. *
  874. * Return:
  875. * OLE error code.
  876. */
  877. HRESULT CppFaxServerReceipts::IsUnderLocalUserAccount(OUT BOOL * pfIsUnderLocalUserAccount)
  878. {
  879. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::IsUnderLocalUserAccount"));
  880. HRESULT hRc = S_OK;
  881. DWORD dwRet = ERROR_SUCCESS;
  882. ATLASSERT(m_pParentNode);
  883. CComBSTR bstrServerName = m_pParentNode->GetServerName();
  884. if (!bstrServerName)
  885. {
  886. DebugPrintEx(
  887. DEBUG_ERR,
  888. TEXT("Out of memory. Failed to load server name string."));
  889. m_pParentNode->NodeMsgBox(IDS_MEMORY);
  890. hRc = E_OUTOFMEMORY;
  891. goto Cleanup;
  892. }
  893. if (0 == bstrServerName.Length())
  894. {
  895. dwRet= IsFaxServiceRunningUnderLocalSystemAccount(NULL, pfIsUnderLocalUserAccount);
  896. }
  897. else
  898. {
  899. dwRet= IsFaxServiceRunningUnderLocalSystemAccount(bstrServerName.m_str, pfIsUnderLocalUserAccount);
  900. }
  901. if(ERROR_SUCCESS != dwRet)
  902. {
  903. DebugPrintEx(DEBUG_ERR,
  904. _T("IsFaxServiceRunningUnderLocalSystemAccount failed: %d\n"),
  905. dwRet);
  906. hRc = HRESULT_FROM_WIN32(dwRet);
  907. goto Cleanup;
  908. }
  909. ATLASSERT( S_OK == hRc);
  910. Cleanup:
  911. return hRc;
  912. }
  913. /*
  914. - CppFaxServerReceipts::IsValidData
  915. -
  916. * Purpose:
  917. * To validate all data types before save data.
  918. * This level should be responsible that detailed
  919. * error description will be shown to user.
  920. *
  921. * Arguments:
  922. * [in] BSTRs and DWORDs
  923. * [out] dwPort pointer to DWORD that
  924. * was derived from the port bstr if validation success.
  925. * [out] iFocus
  926. *
  927. * Return:
  928. * BOOOLEAN
  929. */
  930. BOOL CppFaxServerReceipts::IsValidData(BSTR bstrSmtpSever,
  931. BSTR bstrPort,
  932. DWORD *pdwPort,
  933. BSTR bstrSenderAddress,
  934. int *pCtrlFocus,
  935. UINT *pIds)
  936. {
  937. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::IsValidData"));
  938. UINT uRetIDS = 0;
  939. ATLASSERT(pdwPort);
  940. if (!IsValidPortNumber(bstrPort, pdwPort, &uRetIDS))
  941. {
  942. ATLASSERT(0 != uRetIDS);
  943. DebugPrintEx( DEBUG_ERR,
  944. _T("Invalid port number."));
  945. *pCtrlFocus = IDC_PORT_EDIT;
  946. goto Error;
  947. }
  948. if (!IsValidServerNameString(bstrSmtpSever, &uRetIDS, TRUE /*DNS NAME LENGTH*/))
  949. {
  950. ATLASSERT(0 != uRetIDS);
  951. DebugPrintEx( DEBUG_ERR,
  952. _T("Invalid SMTP server name."));
  953. *pCtrlFocus = IDC_SMTP_USERNAME_EDIT;
  954. goto Error;
  955. }
  956. if (!IsNotEmptyString(bstrSenderAddress))
  957. {
  958. DebugPrintEx( DEBUG_ERR,
  959. _T("Sender address string empty or spaces only."));
  960. uRetIDS = IDS_SENDER_ADDRESS_EMPTY;
  961. *pCtrlFocus = IDC_SMTP_PASSWORD_EDIT;
  962. goto Error;
  963. }
  964. ATLASSERT(0 == uRetIDS);
  965. goto Exit;
  966. Error:
  967. ATLASSERT(0 != uRetIDS);
  968. *pIds = uRetIDS;
  969. return FALSE;
  970. Exit:
  971. return TRUE;
  972. }
  973. /*
  974. - CppFaxServerReceipts::AllReadyToApply
  975. -
  976. * Purpose:
  977. * This function validate that no zero length strings
  978. * are found data areas that should be saved.
  979. *
  980. * Arguments:
  981. * [in] fSilent - boolean who defines if to pop up messages (FALSE)
  982. * or not.(TRUE)
  983. *
  984. * Return:
  985. * BOOOLEAN
  986. */
  987. BOOL CppFaxServerReceipts::AllReadyToApply(BOOL fSilent, int *pCtrlFocus, UINT *pIds)
  988. {
  989. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::AllReadyToApply"));
  990. DWORD ec = ERROR_SUCCESS;
  991. if (
  992. IsDlgButtonChecked(IDC_RECEIPT_ENABLE_SMTP_CHECK) == BST_CHECKED
  993. ||
  994. IsDlgButtonChecked(IDC_SMTP_ROUTE_CHECK) == BST_CHECKED
  995. )
  996. {
  997. if ( !m_SmtpBox.GetWindowTextLength() )
  998. {
  999. ec = GetLastError();
  1000. DebugPrintEx(
  1001. DEBUG_ERR,
  1002. _T("Zero text length - m_SmtpBox. (ec: %ld)"),
  1003. ec);
  1004. if (!fSilent)
  1005. {
  1006. *pIds = IDS_SERVERNAME_EMPTY_STRING;
  1007. *pCtrlFocus = IDC_SMTP_EDIT;
  1008. }
  1009. return FALSE;
  1010. }
  1011. if ( !m_PortBox.GetWindowTextLength() )
  1012. {
  1013. ec = GetLastError();
  1014. DebugPrintEx(
  1015. DEBUG_ERR,
  1016. _T("Zero text length - m_PortBox. (ec: %ld)"),
  1017. ec);
  1018. if (!fSilent)
  1019. {
  1020. *pIds = IDS_PORT_EMPTY_STRING;
  1021. *pCtrlFocus = IDC_PORT_EDIT;
  1022. }
  1023. return FALSE;
  1024. }
  1025. if ( !m_AddressBox.GetWindowTextLength() )
  1026. {
  1027. ec = GetLastError();
  1028. DebugPrintEx(
  1029. DEBUG_ERR,
  1030. _T("Zero text length - m_AddressBox. (ec: %ld)"),
  1031. ec);
  1032. if (!fSilent)
  1033. {
  1034. *pIds = IDS_SENDER_ADDRESS_EMPTY;
  1035. *pCtrlFocus = IDC_ADDRESS_EDIT;
  1036. }
  1037. return FALSE;
  1038. }
  1039. }
  1040. ATLASSERT(ERROR_SUCCESS == ec);
  1041. //
  1042. // Cheers!
  1043. // ...every thing ready to apply now.
  1044. //
  1045. return TRUE;
  1046. }
  1047. /*
  1048. - CppFaxServerReceipts::OnTextChanged
  1049. -
  1050. * Purpose:
  1051. * Enable/Disable the submit button.
  1052. *
  1053. * Arguments:
  1054. *
  1055. * Return:
  1056. * 1
  1057. */
  1058. LRESULT CppFaxServerReceipts::OnTextChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1059. {
  1060. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::OnTextChanged"));
  1061. if (!m_fIsDialogInitiated) //event receieved in too early stage
  1062. {
  1063. return 0;
  1064. }
  1065. else
  1066. {
  1067. m_fIsDirty = TRUE;
  1068. }
  1069. if (AllReadyToApply(TRUE))
  1070. {
  1071. m_fAllReadyToApply = TRUE;
  1072. SetModified(TRUE);
  1073. }
  1074. else
  1075. {
  1076. m_fAllReadyToApply = FALSE;
  1077. SetModified(FALSE);
  1078. }
  1079. return 1;
  1080. }
  1081. /*
  1082. - CppFaxServerReceipts::IsMsSMTPRoutingMethodStillAssigned
  1083. -
  1084. * Purpose:
  1085. * This function makes loop on all FaxEnumPortsEx and FaxEnumRoutingMethods
  1086. * and should pop-up ErrMsgBox in case in any Device The SMTP Microsoft Route
  1087. * Through e-mail method is still enabled while the user tries to unchecked.
  1088. *
  1089. * Arguments:
  1090. *
  1091. * Return:
  1092. * BOOOLEAN
  1093. */
  1094. BOOL CppFaxServerReceipts::IsMsSMTPRoutingMethodStillAssigned()
  1095. {
  1096. DEBUG_FUNCTION_NAME( _T("CppFaxServerReceipts::IsMsSMTPRoutingMethodStillAssigned"));
  1097. DWORD ec = ERROR_SUCCESS;
  1098. PFAX_PORT_INFO_EX pFaxDevicesConfig;
  1099. DWORD dwNumOfDevices;
  1100. PFAX_ROUTING_METHOD pFaxInboundMethodsConfig;
  1101. DWORD dwNumOfInboundMethods;
  1102. DWORD dwIndex = 0;
  1103. //
  1104. // get Fax Handle
  1105. //
  1106. ATLASSERT(m_pFaxServer);
  1107. if (!m_pFaxServer->GetFaxServerHandle())
  1108. {
  1109. ec= GetLastError();
  1110. DebugPrintEx(
  1111. DEBUG_ERR,
  1112. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  1113. ec);
  1114. goto Error;
  1115. }
  1116. //
  1117. // Retrieve the fax devices configuration
  1118. //
  1119. if (!FaxEnumPortsEx(m_pFaxServer->GetFaxServerHandle(),
  1120. &pFaxDevicesConfig,
  1121. &dwNumOfDevices))
  1122. {
  1123. ec = GetLastError();
  1124. DebugPrintEx(
  1125. DEBUG_ERR,
  1126. _T("Fail to get devices configuration. (ec: %ld)"),
  1127. ec);
  1128. if (IsNetworkError(ec))
  1129. {
  1130. DebugPrintEx(
  1131. DEBUG_ERR,
  1132. _T("Network Error was found. (ec: %ld)"),
  1133. ec);
  1134. m_pFaxServer->Disconnect();
  1135. }
  1136. goto Error;
  1137. }
  1138. //For max verification
  1139. ATLASSERT(pFaxDevicesConfig);
  1140. for (dwIndex = 0; dwIndex < dwNumOfDevices; dwIndex++)
  1141. {
  1142. HANDLE hFaxPortHandle = NULL;
  1143. //
  1144. // only a PORT_OPEN_QUERY is needed to show the methods
  1145. // the handle with PORT_OPEN_MODIFY priviledge will be
  1146. // given for limited short period for opertion required it.
  1147. //
  1148. if (!FaxOpenPort( m_pFaxServer->GetFaxServerHandle(),
  1149. pFaxDevicesConfig[dwIndex].dwDeviceID,
  1150. PORT_OPEN_QUERY,
  1151. &hFaxPortHandle ))
  1152. {
  1153. ec = GetLastError();
  1154. if (ERROR_INVALID_HANDLE == ec)
  1155. {
  1156. //Special case of ERROR_INVALID_HANDLE
  1157. DebugPrintEx(DEBUG_ERR,
  1158. _T("FaxOpenPort() failed with ERROR_INVALID_HANDLE. (ec:%ld)"),
  1159. ec);
  1160. PropSheet_SetCurSelByID( GetParent(), IDD);
  1161. ATLASSERT(::IsWindow(m_hWnd));
  1162. PageError(IDS_OPENPORT_INVALID_HANDLE, m_hWnd);
  1163. goto Exit;
  1164. }
  1165. DebugPrintEx(
  1166. DEBUG_ERR,
  1167. TEXT("FaxOpenPort() failed. (ec:%ld)"),
  1168. ec);
  1169. goto Error;
  1170. }
  1171. ATLASSERT(NULL != hFaxPortHandle);
  1172. //
  1173. // Retrieve the fax Inbound Methods configuration
  1174. //
  1175. if (!FaxEnumRoutingMethods(hFaxPortHandle,
  1176. &pFaxInboundMethodsConfig,
  1177. &dwNumOfInboundMethods))
  1178. {
  1179. ec = GetLastError();
  1180. DebugPrintEx(
  1181. DEBUG_ERR,
  1182. _T("Fail to get Inbound Methods configuration. (ec: %ld)"),
  1183. ec);
  1184. if (NULL != hFaxPortHandle)
  1185. {
  1186. if (!FaxClose( hFaxPortHandle ))
  1187. {
  1188. DebugPrintEx(
  1189. DEBUG_ERR,
  1190. TEXT("FaxClose() on port handle failed (ec: %ld)"),
  1191. GetLastError());
  1192. }
  1193. }
  1194. if (IsNetworkError(ec))
  1195. {
  1196. DebugPrintEx(
  1197. DEBUG_ERR,
  1198. _T("Network Error was found. (ec: %ld)"),
  1199. ec);
  1200. m_pFaxServer->Disconnect();
  1201. }
  1202. goto Error;
  1203. }
  1204. //For max verification
  1205. ATLASSERT(pFaxInboundMethodsConfig);
  1206. //
  1207. // Close Fax Port handle
  1208. //
  1209. if (NULL != hFaxPortHandle)
  1210. {
  1211. if (!FaxClose( hFaxPortHandle ))
  1212. {
  1213. DebugPrintEx(
  1214. DEBUG_ERR,
  1215. TEXT("FaxClose() on port handle failed (ec: %ld)"),
  1216. GetLastError());
  1217. }
  1218. }
  1219. //
  1220. // Main loop search for MS email routing method's GUID
  1221. //
  1222. for ( DWORD dwMethodsIndex = 0; dwMethodsIndex < dwNumOfInboundMethods; dwMethodsIndex++ )
  1223. {
  1224. pFaxInboundMethodsConfig[dwMethodsIndex];
  1225. if (CSTR_EQUAL == CompareString(LOCALE_INVARIANT,
  1226. NORM_IGNORECASE,
  1227. pFaxInboundMethodsConfig[dwMethodsIndex].Guid,
  1228. -1,
  1229. REGVAL_RM_EMAIL_GUID,
  1230. -1))
  1231. {
  1232. if (pFaxInboundMethodsConfig[dwMethodsIndex].Enabled)
  1233. {
  1234. return TRUE;
  1235. }
  1236. }
  1237. }
  1238. }
  1239. ATLASSERT(ERROR_SUCCESS == ec);
  1240. goto Exit;
  1241. Error:
  1242. PropSheet_SetCurSelByID( GetParent(), IDD);
  1243. ATLASSERT(::IsWindow(m_hWnd));
  1244. PageError(GetFaxServerErrorMsg(ec), m_hWnd);
  1245. Exit:
  1246. return FALSE;
  1247. }
  1248. /*
  1249. - CppFaxServerReceipts::OnHelpLinkClicked
  1250. -
  1251. * Purpose:
  1252. * On HTML like link was clicked open chm help window.
  1253. *
  1254. * Arguments:
  1255. *
  1256. * Return:
  1257. * 1
  1258. */
  1259. #define FAX_USER_ACCOUNT_HELP FAX_ADMIN_HELP_FILE TEXT("::/FaxS_H_UserAcct.htm")
  1260. LRESULT CppFaxServerReceipts::OnHelpLinkClicked(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled)
  1261. {
  1262. ATLASSERT( IDC_RECEIPTS_HELP_LINK == idCtrl);
  1263. if (!m_fIsDialogInitiated) //event receieved in too early stage
  1264. {
  1265. return 0;
  1266. }
  1267. HtmlHelp(m_hWnd, FAX_USER_ACCOUNT_HELP, HH_DISPLAY_TOC, NULL);
  1268. return 1;
  1269. }
  1270. //////////////////////////////////////////////////////////////////////////////
  1271. /*++
  1272. CppFaxServerReceipts::OnHelpRequest
  1273. This is called in response to the WM_HELP Notify
  1274. message and to the WM_CONTEXTMENU Notify message.
  1275. WM_HELP Notify message.
  1276. This message is sent when the user presses F1 or <Shift>-F1
  1277. over an item or when the user clicks on the ? icon and then
  1278. presses the mouse over an item.
  1279. WM_CONTEXTMENU Notify message.
  1280. This message is sent when the user right clicks over an item
  1281. and then clicks "What's this?"
  1282. --*/
  1283. /////////////////////////////////////////////////////////////////////////////
  1284. LRESULT
  1285. CppFaxServerReceipts::OnHelpRequest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
  1286. {
  1287. DEBUG_FUNCTION_NAME(_T("CppFaxServerReceipts::OnHelpRequest"));
  1288. switch (uMsg)
  1289. {
  1290. case WM_HELP:
  1291. WinContextHelp(((LPHELPINFO)lParam)->dwContextId, m_hWnd);
  1292. break;
  1293. case WM_CONTEXTMENU:
  1294. WinContextHelp(::GetWindowContextHelpId((HWND)wParam), m_hWnd);
  1295. break;
  1296. }
  1297. return TRUE;
  1298. }
  1299. /////////////////////////////////////////////////////////////////////////////