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.

914 lines
22 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : ppFaxServerOutbox.cpp //
  3. // //
  4. // DESCRIPTION : prop pages of //
  5. // //
  6. // AUTHOR : yossg //
  7. // //
  8. // HISTORY : //
  9. // Oct 25 1999 yossg created //
  10. // Nov 3 1999 yossg OnInitDialog, SetProps //
  11. // Nov 15 1999 yossg Call RPC func //
  12. // Nov 24 1999 yossg OnApply create call to all tabs from parent //
  13. // add Branding //
  14. // Apr 24 2000 yossg Add discount rate time //
  15. // Oct 17 2000 yossg //
  16. // //
  17. // Copyright (C) 1999 - 2000 Microsoft Corporation All Rights Reserved //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "MSFxsSnp.h"
  21. #include "ppFaxServerOutbox.h"
  22. #include "FaxServer.h"
  23. #include "FaxServerNode.h"
  24. #include "FxsValid.h"
  25. #include "dlgutils.h"
  26. #ifdef _DEBUG
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. //
  31. // Constructor
  32. //
  33. CppFaxServerOutbox::CppFaxServerOutbox(
  34. LONG_PTR hNotificationHandle,
  35. CSnapInItem *pNode,
  36. BOOL bOwnsNotificationHandle,
  37. HINSTANCE hInst)
  38. : CPropertyPageExImpl<CppFaxServerOutbox>(pNode, NULL)
  39. {
  40. m_pParentNode = static_cast <CFaxServerNode *> (pNode);
  41. m_pFaxOutboxConfig = NULL;
  42. m_fAllReadyToApply = FALSE;
  43. m_fIsDialogInitiated = FALSE;
  44. m_fIsDirty = FALSE;
  45. }
  46. //
  47. // Destructor
  48. //
  49. CppFaxServerOutbox::~CppFaxServerOutbox()
  50. {
  51. if (NULL != m_pFaxOutboxConfig)
  52. {
  53. FaxFreeBuffer( m_pFaxOutboxConfig );
  54. }
  55. }
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CppFaxServerOutbox message handlers
  58. /*
  59. - CppFaxServerOutbox::InitRPC
  60. -
  61. * Purpose:
  62. * Initiates the configuration structure from RPC get Call.
  63. *
  64. * Arguments:
  65. *
  66. * Return:
  67. * OLE error code
  68. */
  69. HRESULT CppFaxServerOutbox::InitRPC( )
  70. {
  71. DEBUG_FUNCTION_NAME( _T("CppFaxServerOutbox::InitRPC"));
  72. HRESULT hRc = S_OK;
  73. DWORD ec = ERROR_SUCCESS;
  74. //
  75. // get RPC Handle
  76. //
  77. if (!m_pFaxServer->GetFaxServerHandle())
  78. {
  79. ec= GetLastError();
  80. DebugPrintEx(
  81. DEBUG_ERR,
  82. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  83. ec);
  84. goto Error;
  85. }
  86. //
  87. // Retrieve the fax Archive configuration
  88. //
  89. if (!FaxGetOutboxConfiguration(m_pFaxServer->GetFaxServerHandle(),
  90. &m_pFaxOutboxConfig))
  91. {
  92. ec = GetLastError();
  93. DebugPrintEx(
  94. DEBUG_ERR,
  95. _T("Fail to get SMTP configuration. (ec: %ld)"),
  96. ec);
  97. if (IsNetworkError(ec))
  98. {
  99. DebugPrintEx(
  100. DEBUG_ERR,
  101. _T("Network Error was found. (ec: %ld)"),
  102. ec);
  103. m_pFaxServer->Disconnect();
  104. }
  105. goto Error;
  106. }
  107. //For max verification
  108. ATLASSERT(m_pFaxOutboxConfig);
  109. ATLASSERT(S_OK == hRc);
  110. DebugPrintEx( DEBUG_MSG,
  111. _T("Succeed to get outbox configuration."));
  112. goto Exit;
  113. Error:
  114. ATLASSERT(ERROR_SUCCESS != ec);
  115. hRc = HRESULT_FROM_WIN32(ec);
  116. ATLASSERT(NULL != m_pParentNode);
  117. m_pParentNode->NodeMsgBox(GetFaxServerErrorMsg(ec));
  118. Exit:
  119. return (hRc);
  120. }
  121. /*
  122. - CppFaxServerOutbox::OnInitDialog
  123. -
  124. * Purpose:
  125. * Initiates all controls when dialog is called.
  126. *
  127. * Arguments:
  128. *
  129. * Return:
  130. * OLE error code
  131. */
  132. LRESULT CppFaxServerOutbox::OnInitDialog( UINT uiMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled )
  133. {
  134. DEBUG_FUNCTION_NAME( _T("CppFaxServerOutbox::PageInitDialog"));
  135. UNREFERENCED_PARAMETER( uiMsg );
  136. UNREFERENCED_PARAMETER( wParam );
  137. UNREFERENCED_PARAMETER( lParam );
  138. UNREFERENCED_PARAMETER( fHandled );
  139. BOOL fToCheck;
  140. UINT CheckState;
  141. int iRetries,
  142. iRetryDelay,
  143. iAgeLimit;
  144. TCHAR tszSecondsFreeTimeFormat[FXS_MAX_TIMEFORMAT_LEN];
  145. SYSTEMTIME stStart;
  146. SYSTEMTIME stStop;
  147. //
  148. // Attach controls
  149. //
  150. m_RetriesBox.Attach(GetDlgItem(IDC_RETRIES_EDIT));
  151. m_RetryDelayBox.Attach(GetDlgItem(IDC_RETRYDELAY_EDIT));
  152. m_DaysBox.Attach(GetDlgItem(IDC_DAYS_EDIT));
  153. m_RetriesBox.SetLimitText(FXS_RETRIES_LENGTH);
  154. m_RetryDelayBox.SetLimitText(FXS_RETRYDELAY_LENGTH);
  155. m_DaysBox.SetLimitText(FXS_DIRTYDAYS_LENGTH);
  156. m_RetriesSpin.Attach(GetDlgItem(IDC_RETRIES_SPIN));
  157. m_RetryDelaySpin.Attach(GetDlgItem(IDC_RETRYDELAY_SPIN));
  158. m_DaysSpin.Attach(GetDlgItem(IDC_DAYS_SPIN));
  159. m_StartTimeCtrl.Attach(GetDlgItem(IDC_DISCOUNT_START_TIME));
  160. m_StopTimeCtrl.Attach(GetDlgItem(IDC_DISCOUNT_STOP_TIME));
  161. //
  162. // Set Time Format
  163. //
  164. //
  165. // GetSecondsFreeTimeFormat is a util func
  166. // which builds TimeFormat according UserLocal without seconds
  167. // If any internal failure occures - an hardcoded default seconds free
  168. // time format ("hh:mm tt") is retreived.
  169. //
  170. GetSecondsFreeTimeFormat(tszSecondsFreeTimeFormat, FXS_MAX_TIMEFORMAT_LEN);
  171. m_StartTimeCtrl.SetFormat(tszSecondsFreeTimeFormat);
  172. m_StopTimeCtrl.SetFormat(tszSecondsFreeTimeFormat);
  173. //
  174. // init controls
  175. //
  176. ATLASSERT(NULL != m_pFaxOutboxConfig);
  177. //
  178. // Branding
  179. //
  180. fToCheck = m_pFaxOutboxConfig->bBranding;
  181. CheckState = (fToCheck) ? BST_CHECKED : BST_UNCHECKED;
  182. CheckDlgButton(IDC_BRANDING_CHECK, CheckState) ;
  183. //
  184. //ALLOW_PERSONAL_CHECK
  185. //
  186. fToCheck = m_pFaxOutboxConfig->bAllowPersonalCP;
  187. CheckState = (fToCheck) ? BST_CHECKED : BST_UNCHECKED;
  188. CheckDlgButton(IDC_ALLOW_PERSONAL_CHECK, CheckState) ;
  189. //
  190. //TSID_CHECK
  191. //
  192. fToCheck = m_pFaxOutboxConfig->bUseDeviceTSID;
  193. CheckState = (fToCheck) ? BST_CHECKED : BST_UNCHECKED;
  194. CheckDlgButton(IDC_TSID_CHECK, CheckState) ;
  195. //
  196. // Retries
  197. //
  198. iRetries = (int)m_pFaxOutboxConfig->dwRetries;
  199. m_RetriesSpin.SetRange(FXS_RETRIES_LOWER, FXS_RETRIES_UPPER);
  200. m_RetriesSpin.SetPos(iRetries);
  201. //
  202. // Retry Delay
  203. //
  204. iRetryDelay = (int)m_pFaxOutboxConfig->dwRetryDelay;
  205. m_RetryDelaySpin.SetRange(FXS_RETRYDELAY_LOWER, FXS_RETRYDELAY_UPPER);
  206. m_RetryDelaySpin.SetPos(iRetryDelay);
  207. //
  208. // Message life-time / dirty days / age limit
  209. //
  210. iAgeLimit = (int)m_pFaxOutboxConfig->dwAgeLimit;
  211. m_DaysSpin.SetRange(FXS_DIRTYDAYS_LOWER, FXS_DIRTYDAYS_UPPER);
  212. m_DaysSpin.SetPos(iAgeLimit);
  213. //
  214. // Discount rate time
  215. //
  216. ::GetLocalTime(&stStart);
  217. ::GetLocalTime(&stStop);
  218. stStart.wHour = m_pFaxOutboxConfig->dtDiscountStart.Hour;
  219. stStart.wMinute = m_pFaxOutboxConfig->dtDiscountStart.Minute;
  220. stStop.wHour = m_pFaxOutboxConfig->dtDiscountEnd.Hour;
  221. stStop.wMinute = m_pFaxOutboxConfig->dtDiscountEnd.Minute;
  222. if (!m_StartTimeCtrl.SetSystemTime(GDT_VALID, &stStart))
  223. {
  224. DebugPrintEx(DEBUG_ERR, _T("Fail to SetSystemTime for discount start."));
  225. }
  226. if (!m_StopTimeCtrl.SetSystemTime(GDT_VALID, &stStop))
  227. {
  228. DebugPrintEx(DEBUG_ERR, _T("Fail to SetSystemTime for discount end."));
  229. }
  230. //
  231. // Auto Delete
  232. //
  233. if (FXS_DIRTYDAYS_ZERO == iAgeLimit)
  234. {
  235. CheckDlgButton(IDC_DELETE_CHECK, BST_UNCHECKED);
  236. ::EnableWindow(GetDlgItem(IDC_DAYS_EDIT), FALSE);
  237. ::EnableWindow(GetDlgItem(IDC_DAYS_SPIN), FALSE);
  238. }
  239. else
  240. {
  241. CheckDlgButton(IDC_DELETE_CHECK, BST_CHECKED);
  242. }
  243. m_fIsDialogInitiated = TRUE;
  244. return(1);
  245. }
  246. /*
  247. - CppFaxServerOutbox::SetProps
  248. -
  249. * Purpose:
  250. * Sets properties on apply.
  251. *
  252. * Arguments:
  253. * pCtrlFocus - focus pointer (int)
  254. *
  255. * Return:
  256. * OLE error code
  257. */
  258. HRESULT CppFaxServerOutbox::SetProps(int *pCtrlFocus)
  259. {
  260. DEBUG_FUNCTION_NAME( _T("CppFaxServerOutbox::SetProps"));
  261. HRESULT hRc = S_OK;
  262. DWORD ec = ERROR_SUCCESS;
  263. HINSTANCE hInst = _Module.GetResourceInstance();
  264. SYSTEMTIME stStart;
  265. SYSTEMTIME stStop;
  266. FAX_OUTBOX_CONFIG FaxOutboxConfig;
  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. ZeroMemory (&FaxOutboxConfig, sizeof(FAX_OUTBOX_CONFIG));
  274. //
  275. // Size of struct.
  276. //
  277. FaxOutboxConfig.dwSizeOfStruct = sizeof(FAX_OUTBOX_CONFIG);
  278. //
  279. // Branding
  280. //
  281. if (IsDlgButtonChecked(IDC_BRANDING_CHECK) == BST_CHECKED)
  282. {
  283. FaxOutboxConfig.bBranding = TRUE;
  284. }
  285. else
  286. {
  287. FaxOutboxConfig.bBranding = FALSE;
  288. }
  289. //
  290. // IDC_ALLOW_PERSONAL_CHECK
  291. //
  292. if (IsDlgButtonChecked(IDC_ALLOW_PERSONAL_CHECK) == BST_CHECKED)
  293. {
  294. FaxOutboxConfig.bAllowPersonalCP = TRUE;
  295. }
  296. else
  297. {
  298. FaxOutboxConfig.bAllowPersonalCP = FALSE;
  299. }
  300. //
  301. // IDC_TSID_CHECK
  302. //
  303. if (IsDlgButtonChecked(IDC_TSID_CHECK) == BST_CHECKED)
  304. {
  305. FaxOutboxConfig.bUseDeviceTSID = TRUE;
  306. }
  307. else
  308. {
  309. FaxOutboxConfig.bUseDeviceTSID = FALSE;
  310. }
  311. //
  312. // Retries, Retry Delay
  313. //
  314. int iRetries = m_RetriesSpin.GetPos();
  315. FaxOutboxConfig.dwRetries = (DWORD) iRetries;
  316. int iRetryDelay = m_RetryDelaySpin.GetPos();
  317. FaxOutboxConfig.dwRetryDelay = (DWORD) iRetryDelay;
  318. //
  319. // IDC_DELETE_CHECK - AutoDelete Messages
  320. //
  321. if (IsDlgButtonChecked(IDC_DELETE_CHECK) == BST_CHECKED)
  322. {
  323. int iAgeLimit = m_DaysSpin.GetPos();
  324. FaxOutboxConfig.dwAgeLimit = (DWORD) iAgeLimit;
  325. }
  326. else
  327. {
  328. FaxOutboxConfig.dwAgeLimit = (DWORD) FXS_DIRTYDAYS_ZERO;
  329. }
  330. //
  331. // Discount rate time
  332. //
  333. m_StartTimeCtrl.GetSystemTime(&stStart);
  334. m_StopTimeCtrl.GetSystemTime(&stStop);
  335. FaxOutboxConfig.dtDiscountStart.Hour = stStart.wHour;
  336. FaxOutboxConfig.dtDiscountStart.Minute = stStart.wMinute;
  337. FaxOutboxConfig.dtDiscountEnd.Hour = stStop.wHour;
  338. FaxOutboxConfig.dtDiscountEnd.Minute = stStop.wMinute;
  339. //
  340. // get RPC Handle
  341. //
  342. if (!m_pFaxServer->GetFaxServerHandle())
  343. {
  344. ec= GetLastError();
  345. DebugPrintEx(
  346. DEBUG_ERR,
  347. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  348. ec);
  349. goto Error;
  350. }
  351. //
  352. // Set Config
  353. //
  354. if (!FaxSetOutboxConfiguration(
  355. m_pFaxServer->GetFaxServerHandle(),
  356. &FaxOutboxConfig))
  357. {
  358. ec = GetLastError();
  359. DebugPrintEx(
  360. DEBUG_ERR,
  361. _T("Fail to Set outbox configuration. (ec: %ld)"),
  362. ec);
  363. if (IsNetworkError(ec))
  364. {
  365. DebugPrintEx(
  366. DEBUG_ERR,
  367. _T("Network Error was found. (ec: %ld)"),
  368. ec);
  369. m_pFaxServer->Disconnect();
  370. }
  371. goto Error;
  372. }
  373. ATLASSERT(S_OK == hRc);
  374. m_fIsDirty = FALSE;
  375. DebugPrintEx( DEBUG_MSG,
  376. _T("Succeed to set outbox configuration."));
  377. goto Exit;
  378. Error:
  379. ATLASSERT(ERROR_SUCCESS != ec);
  380. hRc = HRESULT_FROM_WIN32(ec);
  381. PropSheet_SetCurSelByID( GetParent(), IDD);
  382. ATLASSERT(::IsWindow(m_hWnd));
  383. PageError(GetFaxServerErrorMsg(ec),m_hWnd);
  384. Exit:
  385. return(hRc);
  386. }
  387. /*
  388. - CppFaxServerOutbox::PreApply
  389. -
  390. * Purpose:
  391. * Checks properties before apply.
  392. *
  393. * Arguments:
  394. *
  395. * Return:
  396. * OLE error code
  397. */
  398. HRESULT CppFaxServerOutbox::PreApply(int *pCtrlFocus, UINT * puIds)
  399. {
  400. DEBUG_FUNCTION_NAME( _T("CppFaxServerOutbox::PreApply"));
  401. HRESULT hRc = S_OK;
  402. //
  403. // PreApply Checks
  404. //
  405. if (!AllReadyToApply(/*fSilent =*/ FALSE, pCtrlFocus , puIds))
  406. {
  407. m_fAllReadyToApply = FALSE;
  408. SetModified(FALSE);
  409. hRc = E_FAIL ;
  410. }
  411. else
  412. {
  413. m_fAllReadyToApply = TRUE;
  414. SetModified(TRUE);
  415. }
  416. return(hRc);
  417. }
  418. /*
  419. - CppFaxServerOutbox::OnApply
  420. -
  421. * Purpose:
  422. * Calls PreApply and SetProp to Apply changes.
  423. *
  424. * Arguments:
  425. *
  426. * Return:
  427. * TRUE or FALSE
  428. */
  429. BOOL CppFaxServerOutbox::OnApply()
  430. {
  431. DEBUG_FUNCTION_NAME( _T("CppFaxServerOutbox::OnApply"));
  432. HRESULT hRc = S_OK;
  433. int CtrlFocus = 0;
  434. UINT uIds = 0;
  435. if (!m_fIsDirty)
  436. {
  437. return TRUE;
  438. }
  439. hRc = PreApply(&CtrlFocus, &uIds);
  440. if (FAILED(hRc))
  441. {
  442. if (PropSheet_SetCurSelByID( GetParent(), IDD) )
  443. {
  444. PageError(uIds, m_hWnd, _Module.GetResourceInstance());
  445. if (CtrlFocus)
  446. {
  447. GotoDlgCtrl(GetDlgItem(CtrlFocus));
  448. }
  449. }
  450. return FALSE;
  451. }
  452. else //(Succeeded(hRc))
  453. {
  454. hRc = SetProps(&CtrlFocus);
  455. if (FAILED(hRc))
  456. {
  457. //Error Msg by called func.
  458. if (CtrlFocus)
  459. {
  460. GotoDlgCtrl(GetDlgItem(CtrlFocus));
  461. }
  462. return FALSE;
  463. }
  464. else //(Succeeded(hRc))
  465. {
  466. return TRUE;
  467. }
  468. }
  469. }
  470. /*
  471. - CppFaxServerOutbox::OnTimeChange
  472. -
  473. * Purpose:
  474. * Gray/Ungray the folder edit box and the
  475. * browse button. Enable apply button.
  476. *
  477. * Arguments:
  478. *
  479. * Return:
  480. * 1
  481. */
  482. LRESULT CppFaxServerOutbox::OnTimeChange(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
  483. {
  484. if (!m_fIsDialogInitiated) //event receieved in too early stage
  485. {
  486. return 0;
  487. }
  488. else
  489. {
  490. m_fIsDirty = TRUE;
  491. }
  492. if (!m_fAllReadyToApply)
  493. {
  494. if (AllReadyToApply(TRUE))
  495. {
  496. m_fAllReadyToApply = TRUE;
  497. SetModified(TRUE);
  498. }
  499. }
  500. return(1);
  501. }
  502. /*
  503. - CppFaxServerOutbox::CheckboxClicked
  504. -
  505. * Purpose:
  506. * Gray/Ungray the folder edit box and the
  507. * browse button. Enable apply button.
  508. *
  509. * Arguments:
  510. *
  511. * Return:
  512. * 1
  513. */
  514. LRESULT CppFaxServerOutbox::CheckboxClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  515. {
  516. if (!m_fIsDialogInitiated) //event receieved in too early stage
  517. {
  518. return 0;
  519. }
  520. else
  521. {
  522. m_fIsDirty = TRUE;
  523. }
  524. if (!m_fAllReadyToApply)
  525. {
  526. if (AllReadyToApply(TRUE))
  527. {
  528. m_fAllReadyToApply = TRUE;
  529. SetModified(TRUE);
  530. }
  531. }
  532. return(1);
  533. }
  534. /*
  535. - CppFaxServerOutbox::AutoDelCheckboxClicked
  536. -
  537. * Purpose:
  538. * Gray/Ungray the spin button and edit box
  539. * and enable apply button after Auto Delete Checkbox
  540. * status was changed.
  541. *
  542. * Arguments:
  543. *
  544. * Return:
  545. * 1
  546. */
  547. LRESULT CppFaxServerOutbox::AutoDelCheckboxClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  548. {
  549. BOOL State;
  550. if (!m_fIsDialogInitiated) //event receieved in too early stage
  551. {
  552. return 0;
  553. }
  554. else
  555. {
  556. m_fIsDirty = TRUE;
  557. }
  558. State = ( IsDlgButtonChecked(IDC_DELETE_CHECK) == BST_CHECKED );
  559. ::EnableWindow(GetDlgItem(IDC_DAYS_EDIT), State);
  560. ::EnableWindow(GetDlgItem(IDC_DAYS_SPIN), State);
  561. if (m_fAllReadyToApply)//only last change should be considered
  562. {
  563. if ( !m_DaysBox.GetWindowTextLength() )
  564. {
  565. m_fAllReadyToApply = FALSE;
  566. SetModified(FALSE);
  567. }
  568. else if ( 0 != HIWORD( m_DaysSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  569. {
  570. m_fAllReadyToApply = FALSE;
  571. SetModified(FALSE);
  572. }
  573. }
  574. else //m_fAllReadyToApply == FALSE
  575. {
  576. if (AllReadyToApply(TRUE))
  577. {
  578. m_fAllReadyToApply = TRUE;
  579. SetModified(TRUE);
  580. }
  581. }
  582. return(1);
  583. }
  584. /*
  585. - CppFaxServerOutbox::EditBoxChanged
  586. -
  587. * Purpose:
  588. * set Apply buttom modified.
  589. *
  590. * Arguments:
  591. *
  592. * Return:
  593. * 1
  594. */
  595. LRESULT CppFaxServerOutbox::EditBoxChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  596. {
  597. if (!m_fIsDialogInitiated)
  598. {
  599. return 1;
  600. }
  601. else
  602. {
  603. m_fIsDirty = TRUE;
  604. }
  605. if (m_fAllReadyToApply) //only last change should be considered
  606. {
  607. switch (wID)
  608. {
  609. case IDC_RETRIES_EDIT:
  610. if ( !m_RetriesBox.GetWindowTextLength() )
  611. {
  612. SetModified(FALSE);
  613. m_fAllReadyToApply = FALSE;
  614. }
  615. break;
  616. case IDC_RETRYDELAY_EDIT:
  617. if ( !m_RetryDelayBox.GetWindowTextLength() )
  618. {
  619. SetModified(FALSE);
  620. m_fAllReadyToApply = FALSE;
  621. }
  622. break;
  623. case IDC_DAYS_EDIT:
  624. if ( !m_DaysBox.GetWindowTextLength() )
  625. {
  626. SetModified(FALSE);
  627. m_fAllReadyToApply = FALSE;
  628. }
  629. else if ( 0 != HIWORD( m_DaysSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  630. {
  631. m_fAllReadyToApply = FALSE;
  632. SetModified(FALSE);
  633. }
  634. break;
  635. default:
  636. return 1;
  637. }
  638. }
  639. else //m_fAllReadyToApply == FALSE
  640. {
  641. if (AllReadyToApply(TRUE))
  642. {
  643. m_fAllReadyToApply = TRUE;
  644. SetModified(TRUE);
  645. }
  646. }
  647. return 1;
  648. }
  649. /*
  650. - CppFaxServerOutbox::AllReadyToApply
  651. -
  652. * Purpose:
  653. * This function validate that no zero length strings
  654. * are found data areas that should be saved.
  655. *
  656. * Arguments:
  657. * [in] fSilent - boolean who defines if to pop up messages (FALSE)
  658. * or not.(TRUE)
  659. *
  660. * Return:
  661. * BOOOLEAN
  662. */
  663. BOOL CppFaxServerOutbox::AllReadyToApply(BOOL fSilent, int *pCtrlFocus, UINT *pIds)
  664. {
  665. DEBUG_FUNCTION_NAME( _T("CppFaxServerOutbox::AllReadyToApply"));
  666. DWORD ec = ERROR_SUCCESS;
  667. HINSTANCE hInst = _Module.GetResourceInstance();
  668. if ( !m_RetriesBox.GetWindowTextLength() )
  669. {
  670. ec = GetLastError();
  671. DebugPrintEx(
  672. DEBUG_ERR,
  673. _T("Zero text length - m_RetriesBox. (ec: %ld)"),
  674. ec);
  675. if (!fSilent)
  676. {
  677. *pIds = IDS_OUTB_RETRIES_EMPTY;
  678. *pCtrlFocus = IDC_RETRIES_EDIT;
  679. }
  680. return FALSE;
  681. }
  682. if ( !m_RetryDelayBox.GetWindowTextLength() )
  683. {
  684. ec = GetLastError();
  685. DebugPrintEx(
  686. DEBUG_ERR,
  687. _T("Zero text length - m_RetryDelayBox. (ec: %ld)"),
  688. ec);
  689. if (!fSilent)
  690. {
  691. *pIds = IDS_OUTB_RETRYDELAY_EMPTY;
  692. *pCtrlFocus = IDC_RETRYDELAY_EDIT;
  693. }
  694. return FALSE;
  695. }
  696. if (IsDlgButtonChecked(IDC_DELETE_CHECK) == BST_CHECKED)
  697. {
  698. if ( !m_DaysBox.GetWindowTextLength() )
  699. {
  700. ec = GetLastError();
  701. DebugPrintEx(
  702. DEBUG_ERR,
  703. _T("Zero text length - m_DaysBox. (ec: %ld)"),
  704. ec);
  705. if (!fSilent)
  706. {
  707. *pIds = IDS_OUTB_DAYS_EMPTY;
  708. *pCtrlFocus = IDC_DAYS_EDIT;
  709. }
  710. return FALSE;
  711. }
  712. else if ( 0 != HIWORD( m_DaysSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  713. {
  714. DebugPrintEx(
  715. DEBUG_ERR,
  716. _T("Zero value - m_DaysBox."));
  717. if (!fSilent)
  718. {
  719. *pIds = IDS_OUTB_DAYS_EMPTY;
  720. *pCtrlFocus = IDC_DAYS_EDIT;
  721. }
  722. return FALSE;
  723. }
  724. }
  725. ATLASSERT(ERROR_SUCCESS == ec);
  726. //
  727. // Cheers!
  728. // ...every thing ready to apply now.
  729. //
  730. return TRUE;
  731. }
  732. //////////////////////////////////////////////////////////////////////////////
  733. /*++
  734. CppFaxServerOutbox::OnHelpRequest
  735. This is called in response to the WM_HELP Notify
  736. message and to the WM_CONTEXTMENU Notify message.
  737. WM_HELP Notify message.
  738. This message is sent when the user presses F1 or <Shift>-F1
  739. over an item or when the user clicks on the ? icon and then
  740. presses the mouse over an item.
  741. WM_CONTEXTMENU Notify message.
  742. This message is sent when the user right clicks over an item
  743. and then clicks "What's this?"
  744. --*/
  745. /////////////////////////////////////////////////////////////////////////////
  746. LRESULT
  747. CppFaxServerOutbox::OnHelpRequest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
  748. {
  749. DEBUG_FUNCTION_NAME(_T("CppFaxServerOutbox::OnHelpRequest"));
  750. switch (uMsg)
  751. {
  752. case WM_HELP:
  753. WinContextHelp(((LPHELPINFO)lParam)->dwContextId, m_hWnd);
  754. break;
  755. case WM_CONTEXTMENU:
  756. WinContextHelp(::GetWindowContextHelpId((HWND)wParam), m_hWnd);
  757. break;
  758. }
  759. return TRUE;
  760. }
  761. /////////////////////////////////////////////////////////////////////////////