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.

1193 lines
32 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : ppFaxServerSentItems.cpp //
  3. // //
  4. // DESCRIPTION : prop pages of Sent Items Archive //
  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. // Oct 17 2000 yossg //
  14. // Dec 10 2000 yossg Update Windows XP //
  15. // //
  16. // Copyright (C) 1999 Microsoft Corporation All Rights Reserved //
  17. // //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "MSFxsSnp.h"
  21. #include "ppFaxServerSentItems.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. CppFaxServerSentItems::CppFaxServerSentItems(
  34. LONG_PTR hNotificationHandle,
  35. CSnapInItem *pNode,
  36. BOOL fIsLocalServer,
  37. HINSTANCE hInst)
  38. : CPropertyPageExImpl<CppFaxServerSentItems>(pNode, NULL)
  39. {
  40. m_pParentNode = static_cast <CFaxServerNode *> (pNode);
  41. m_pFaxArchiveConfig = NULL;
  42. m_fAllReadyToApply = FALSE;
  43. m_fIsDialogInitiated = FALSE;
  44. m_fIsDirty = FALSE;
  45. m_fIsLocalServer = fIsLocalServer;
  46. }
  47. //
  48. // Destructor
  49. //
  50. CppFaxServerSentItems::~CppFaxServerSentItems()
  51. {
  52. if (NULL != m_pFaxArchiveConfig)
  53. {
  54. FaxFreeBuffer( m_pFaxArchiveConfig );
  55. }
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CppFaxServerSentItems message handlers
  59. /*
  60. - CppFaxServerSentItems::InitRPC
  61. -
  62. * Purpose:
  63. * Initiates the configuration structure from RPC get Call.
  64. *
  65. * Arguments:
  66. *
  67. * Return:
  68. * OLE error code
  69. */
  70. HRESULT CppFaxServerSentItems::InitRPC( )
  71. {
  72. DEBUG_FUNCTION_NAME( _T("CppFaxServerSentItems::InitRPC"));
  73. HRESULT hRc = S_OK;
  74. DWORD ec = ERROR_SUCCESS;
  75. //
  76. // get RPC Handle
  77. //
  78. if (!m_pFaxServer->GetFaxServerHandle())
  79. {
  80. ec= GetLastError();
  81. DebugPrintEx(
  82. DEBUG_ERR,
  83. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  84. ec);
  85. goto Error;
  86. }
  87. //
  88. // Retrieve the fax sent items configuration
  89. //
  90. if (!FaxGetArchiveConfiguration(m_pFaxServer->GetFaxServerHandle(),
  91. FAX_MESSAGE_FOLDER_SENTITEMS,
  92. &m_pFaxArchiveConfig))
  93. {
  94. ec = GetLastError();
  95. DebugPrintEx(
  96. DEBUG_ERR,
  97. _T("Fail to get sent items configuration. (ec: %ld)"),
  98. ec);
  99. if (IsNetworkError(ec))
  100. {
  101. DebugPrintEx(
  102. DEBUG_ERR,
  103. _T("Network Error was found. (ec: %ld)"),
  104. ec);
  105. m_pFaxServer->Disconnect();
  106. }
  107. goto Error;
  108. }
  109. //For max verification
  110. ATLASSERT(m_pFaxArchiveConfig);
  111. //
  112. // Init specific members for set proprties follow-up
  113. //
  114. m_dwLastGoodSizeQuotaHighWatermark = m_pFaxArchiveConfig->dwSizeQuotaHighWatermark;
  115. m_dwLastGoodSizeQuotaLowWatermark = m_pFaxArchiveConfig->dwSizeQuotaLowWatermark;
  116. m_bstrLastGoodFolder = m_pFaxArchiveConfig->lpcstrFolder;
  117. if (!m_bstrLastGoodFolder)
  118. {
  119. DebugPrintEx(
  120. DEBUG_ERR,
  121. TEXT("Failed to allocate string (m_bstrLastGoodFolder)."));
  122. ec = ERROR_OUTOFMEMORY;
  123. goto Error;
  124. }
  125. ATLASSERT(ERROR_SUCCESS == ec);
  126. DebugPrintEx( DEBUG_MSG,
  127. _T("Succeed to get sent items archive configuration."));
  128. goto Exit;
  129. Error:
  130. ATLASSERT(ERROR_SUCCESS != ec);
  131. hRc = HRESULT_FROM_WIN32(ec);
  132. ATLASSERT(NULL != m_pParentNode);
  133. m_pParentNode->NodeMsgBox(GetFaxServerErrorMsg(ec));
  134. Exit:
  135. return (hRc);
  136. }
  137. /*
  138. - CppFaxServerSentItems::OnInitDialog
  139. -
  140. * Purpose:
  141. * Initiates all controls when dialog is called.
  142. *
  143. * Arguments:
  144. *
  145. * Return:
  146. * OLE error code
  147. */
  148. LRESULT CppFaxServerSentItems::OnInitDialog( UINT uiMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled )
  149. {
  150. DEBUG_FUNCTION_NAME( _T("CppFaxServerSentItems::PageInitDialog"));
  151. UNREFERENCED_PARAMETER( uiMsg );
  152. UNREFERENCED_PARAMETER( wParam );
  153. UNREFERENCED_PARAMETER( lParam );
  154. UNREFERENCED_PARAMETER( fHandled );
  155. int iLow,
  156. iHigh,
  157. iAgeLimit;
  158. //
  159. // init controls
  160. //
  161. m_FolderBox.Attach(GetDlgItem(IDC_FOLDER_EDIT));
  162. m_FolderBox.SetLimitText(MAX_ARCHIVE_FOLDER_PATH);
  163. SHAutoComplete (GetDlgItem(IDC_FOLDER_EDIT), SHACF_FILESYSTEM);
  164. m_HighWatermarkBox.Attach(GetDlgItem(IDC_SENT_HIGH_EDIT));
  165. m_LowWatermarkBox.Attach(GetDlgItem(IDC_SENT_LOW_EDIT));
  166. m_AutoDelBox.Attach(GetDlgItem(IDC_SENT_AUTODEL_EDIT));
  167. m_HighWatermarkBox.SetLimitText(FXS_QUOTA_LENGTH);
  168. m_LowWatermarkBox.SetLimitText(FXS_QUOTA_LENGTH);
  169. m_AutoDelBox.SetLimitText(FXS_DIRTYDAYS_LENGTH);
  170. m_HighWatermarkSpin.Attach(GetDlgItem(IDC_SENT_HIGH_SPIN));
  171. m_LowWatermarkSpin.Attach(GetDlgItem(IDC_SENT_LOW_SPIN));
  172. m_AutoDelSpin.Attach(GetDlgItem(IDC_SENT_AUTODEL_SPIN));
  173. ATLASSERT(NULL != m_pFaxArchiveConfig);
  174. //
  175. // FOLDER_EDIT
  176. //
  177. m_FolderBox.SetWindowText(m_pFaxArchiveConfig->lpcstrFolder);
  178. //
  179. // Disable Browse button for remote admin
  180. //
  181. if (!m_fIsLocalServer)
  182. {
  183. ::EnableWindow(GetDlgItem(IDC_SENT_BROWSE_BUTTON), FALSE);
  184. }
  185. //
  186. // TO_ARCHIVE_CHECK
  187. //
  188. if (m_pFaxArchiveConfig->bUseArchive)
  189. {
  190. CheckDlgButton(IDC_SENT_TO_ARCHIVE_CHECK, BST_CHECKED) ;
  191. }
  192. else
  193. {
  194. CheckDlgButton(IDC_SENT_TO_ARCHIVE_CHECK, BST_UNCHECKED) ;
  195. ::EnableWindow(GetDlgItem(IDC_FOLDER_EDIT), FALSE);
  196. ::EnableWindow(GetDlgItem(IDC_SENT_BROWSE_BUTTON), FALSE);
  197. }
  198. //
  199. // Quota size - Low
  200. //
  201. iLow = (int)m_pFaxArchiveConfig->dwSizeQuotaLowWatermark;
  202. m_LowWatermarkSpin.SetRange(FXS_QUOTA_LOW_LOWER, FXS_QUOTA_LOW_UPPER);
  203. m_LowWatermarkSpin.SetPos(iLow);
  204. //
  205. // Quota size - High
  206. //
  207. iHigh = (int)m_pFaxArchiveConfig->dwSizeQuotaHighWatermark;
  208. m_HighWatermarkSpin.SetRange(FXS_QUOTA_HIGH_LOWER, FXS_QUOTA_HIGH_UPPER);
  209. m_HighWatermarkSpin.SetPos(iHigh);
  210. //
  211. //Generate event log warning
  212. //
  213. if (m_pFaxArchiveConfig->bSizeQuotaWarning)
  214. {
  215. CheckDlgButton(IDC_SENT_GENERATE_WARNING_CHECK, BST_CHECKED) ;
  216. }
  217. else
  218. {
  219. CheckDlgButton(IDC_SENT_GENERATE_WARNING_CHECK, BST_UNCHECKED) ;
  220. ::EnableWindow(GetDlgItem(IDC_SENT_HIGH_EDIT), FALSE);
  221. ::EnableWindow(GetDlgItem(IDC_SENT_HIGH_SPIN), FALSE);
  222. ::EnableWindow(GetDlgItem(IDC_SENT_LOW_EDIT), FALSE);
  223. ::EnableWindow(GetDlgItem(IDC_SENT_LOW_SPIN), FALSE);
  224. }
  225. //
  226. // message Age Limit (dirty days)
  227. //
  228. iAgeLimit = (int)m_pFaxArchiveConfig->dwAgeLimit;
  229. m_AutoDelSpin.SetRange(FXS_DIRTYDAYS_LOWER, FXS_DIRTYDAYS_UPPER);
  230. m_AutoDelSpin.SetPos(iAgeLimit);
  231. //
  232. // Auto Delete
  233. //
  234. if (FXS_DIRTYDAYS_ZERO == iAgeLimit)
  235. {
  236. CheckDlgButton(IDC_SENT_AUTODEL_CHECK, BST_UNCHECKED);
  237. ::EnableWindow(GetDlgItem(IDC_SENT_AUTODEL_EDIT), FALSE);
  238. ::EnableWindow(GetDlgItem(IDC_SENT_AUTODEL_SPIN), FALSE);
  239. }
  240. else
  241. {
  242. CheckDlgButton(IDC_SENT_AUTODEL_CHECK, BST_CHECKED);
  243. }
  244. m_fIsDialogInitiated = TRUE;
  245. return(1);
  246. }
  247. /*
  248. - CppFaxServerSentItems::SetProps
  249. -
  250. * Purpose:
  251. * Sets properties on apply.
  252. *
  253. * Arguments:
  254. * pCtrlFocus - focus pointer (int)
  255. *
  256. * Return:
  257. * OLE error code
  258. */
  259. HRESULT CppFaxServerSentItems::SetProps(int *pCtrlFocus, UINT * puIds)
  260. {
  261. DEBUG_FUNCTION_NAME( _T("CppFaxServerSentItems::SetProps"));
  262. HRESULT hRc = S_OK;
  263. DWORD ec = ERROR_SUCCESS;
  264. HINSTANCE hInst = _Module.GetResourceInstance();
  265. BOOL fSkipMessage = FALSE;
  266. CComBSTR bstrFolder = L"";
  267. FAX_ARCHIVE_CONFIG FaxArchiveConfig;
  268. ATLASSERT(TRUE == m_fAllReadyToApply);
  269. m_fAllReadyToApply = FALSE;
  270. //
  271. // Collect all data and init the structure's fields
  272. // uses Copy() to copy and also allocate before
  273. //
  274. ZeroMemory (&FaxArchiveConfig, sizeof(FAX_ARCHIVE_CONFIG));
  275. //
  276. // Size of struct.
  277. //
  278. FaxArchiveConfig.dwSizeOfStruct = sizeof(FAX_ARCHIVE_CONFIG);
  279. //
  280. // IDC_SENT_TO_ARCHIVE_CHECK
  281. //
  282. if (IsDlgButtonChecked(IDC_SENT_TO_ARCHIVE_CHECK) == BST_CHECKED)
  283. {
  284. FaxArchiveConfig.bUseArchive = TRUE;
  285. //IDC_FOLDER_EDIT
  286. if ( !m_FolderBox.GetWindowText(&bstrFolder))
  287. {
  288. *pCtrlFocus = IDC_FOLDER_EDIT;
  289. DebugPrintEx(
  290. DEBUG_ERR,
  291. TEXT("Failed to GetWindowText(&bstrFolder)"));
  292. ec = ERROR_OUTOFMEMORY;
  293. goto Error;
  294. }
  295. if (!IsNotEmptyString(bstrFolder))
  296. {
  297. *pCtrlFocus = IDC_FOLDER_EDIT;
  298. * puIds = IDS_SENT_ARCHIVE_PATH_EMPTY;
  299. DebugPrintEx( DEBUG_ERR,
  300. _T("Archive path string is empty or includes spaces only."));
  301. fSkipMessage = TRUE;
  302. ec = ERROR_INVALID_DATA;
  303. goto Error;
  304. }
  305. FaxArchiveConfig.lpcstrFolder = bstrFolder;
  306. //
  307. // follow-up for an OnApply following submition
  308. // with unchecked IDC_SENT_TO_ARCHIVE_CHECK
  309. //
  310. m_bstrLastGoodFolder = bstrFolder;
  311. if (!m_bstrLastGoodFolder)
  312. {
  313. *pCtrlFocus = IDC_FOLDER_EDIT;
  314. DebugPrintEx(
  315. DEBUG_ERR,
  316. TEXT("Failed to allocate string (m_bstrLastGoodFolder)."));
  317. ec = ERROR_OUTOFMEMORY;
  318. goto Error;
  319. }
  320. }
  321. else
  322. {
  323. FaxArchiveConfig.bUseArchive = FALSE;
  324. FaxArchiveConfig.lpcstrFolder = m_bstrLastGoodFolder;
  325. }
  326. //
  327. // IDC_SENT_GENERATE_WARNING_CHECK
  328. //
  329. if (IsDlgButtonChecked(IDC_SENT_GENERATE_WARNING_CHECK) == BST_CHECKED)
  330. {
  331. FaxArchiveConfig.bSizeQuotaWarning = TRUE;
  332. int iHigh = m_HighWatermarkSpin.GetPos();
  333. FaxArchiveConfig.dwSizeQuotaHighWatermark = (DWORD) iHigh;
  334. int iLow = m_LowWatermarkSpin.GetPos();
  335. FaxArchiveConfig.dwSizeQuotaLowWatermark = (DWORD) iLow;
  336. if (iHigh <= iLow)
  337. {
  338. *pCtrlFocus = IDC_SENT_HIGH_EDIT;
  339. * puIds = IDS_WATERMARK_HI_LOW;
  340. DebugPrintEx( DEBUG_ERR,
  341. _T("Watermark High < Low."));
  342. fSkipMessage = TRUE;
  343. ec = ERROR_INVALID_DATA;
  344. goto Error;
  345. }
  346. //
  347. // follow-up for an OnApply following submition
  348. // with unchecked IDC_SENT_GENERATE_WARNING_CHECK
  349. //
  350. m_dwLastGoodSizeQuotaHighWatermark = (DWORD)iHigh;
  351. m_dwLastGoodSizeQuotaLowWatermark = (DWORD)iLow;
  352. }
  353. else
  354. {
  355. FaxArchiveConfig.bSizeQuotaWarning = FALSE;
  356. FaxArchiveConfig.dwSizeQuotaHighWatermark = m_dwLastGoodSizeQuotaHighWatermark;
  357. FaxArchiveConfig.dwSizeQuotaLowWatermark = m_dwLastGoodSizeQuotaLowWatermark;
  358. }
  359. //
  360. // IDC_SENT_AUTODEL_CHECK - AutoDelete Messages
  361. //
  362. if (IsDlgButtonChecked(IDC_SENT_AUTODEL_CHECK) == BST_CHECKED)
  363. {
  364. int iAgeLimit = m_AutoDelSpin.GetPos();
  365. FaxArchiveConfig.dwAgeLimit = (DWORD) iAgeLimit;
  366. }
  367. else
  368. {
  369. FaxArchiveConfig.dwAgeLimit = (DWORD)FXS_DIRTYDAYS_ZERO;
  370. }
  371. //
  372. // get RPC Handle
  373. //
  374. if (!m_pFaxServer->GetFaxServerHandle())
  375. {
  376. ec= GetLastError();
  377. DebugPrintEx(
  378. DEBUG_ERR,
  379. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  380. ec);
  381. goto Error;
  382. }
  383. //
  384. // Set Config
  385. //
  386. if (!FaxSetArchiveConfiguration(
  387. m_pFaxServer->GetFaxServerHandle(),
  388. FAX_MESSAGE_FOLDER_SENTITEMS,
  389. &FaxArchiveConfig))
  390. {
  391. ec = GetLastError();
  392. DebugPrintEx(DEBUG_ERR, _T("Fail to Set sent items configuration. (ec: %ld)"), ec);
  393. //
  394. // Try to adjust folder
  395. //
  396. PropSheet_SetCurSelByID( GetParent(), IDD);
  397. GotoDlgCtrl(GetDlgItem(IDC_FOLDER_EDIT));
  398. ec = AskUserAndAdjustFaxFolder(m_hWnd,
  399. m_pFaxServer->GetServerName(),
  400. FaxArchiveConfig.lpcstrFolder,
  401. ec);
  402. if(ERROR_SUCCESS != ec)
  403. {
  404. if(ERROR_BAD_PATHNAME == ec)
  405. {
  406. //
  407. // The error message has been shown by AskUserAndAdjustFaxFolder
  408. //
  409. fSkipMessage = TRUE;
  410. }
  411. goto Error;
  412. }
  413. //
  414. // The folder has been adjusted, set it again
  415. //
  416. if (!FaxSetArchiveConfiguration(m_pFaxServer->GetFaxServerHandle(),
  417. FAX_MESSAGE_FOLDER_SENTITEMS,
  418. &FaxArchiveConfig))
  419. {
  420. ec = GetLastError();
  421. DebugPrintEx(DEBUG_ERR, _T("Fail to Set inbox configuration. (ec: %ld)"), ec);
  422. goto Error;
  423. }
  424. }
  425. ATLASSERT(S_OK == hRc);
  426. m_fIsDirty = FALSE;
  427. DebugPrintEx( DEBUG_MSG, _T("Succeed to set sent-items archive configuration."));
  428. return hRc;
  429. Error:
  430. ATLASSERT(ERROR_SUCCESS != ec);
  431. hRc = HRESULT_FROM_WIN32(ec);
  432. DWORD dwIDS = 0;
  433. switch (ec)
  434. {
  435. case ERROR_DISK_FULL:
  436. DebugPrintEx( DEBUG_ERR, _T("ERROR_DISK_FULL == ec"));
  437. dwIDS = IDS_SENT_ERROR_DISK_FULL;
  438. break;
  439. case FAX_ERR_NOT_NTFS:
  440. DebugPrintEx( DEBUG_ERR, _T("FAX_ERR_NOT_NTFS == ec"));
  441. dwIDS = IDS_SENT_FAX_ERR_NOT_NTFS;
  442. break;
  443. case FAX_ERR_FILE_ACCESS_DENIED:
  444. DebugPrintEx( DEBUG_ERR, _T("FAX_ERR_FILE_ACCESS_DENIED == ec"));
  445. dwIDS = IDS_SENT_FAX_ERR_FILE_ACCESS_DENIED;
  446. break;
  447. default:
  448. dwIDS = GetFaxServerErrorMsg(ec);
  449. break;
  450. }
  451. if (dwIDS && !fSkipMessage)
  452. {
  453. PropSheet_SetCurSelByID( GetParent(), IDD);
  454. ATLASSERT(::IsWindow(m_hWnd));
  455. PageError(dwIDS, m_hWnd);
  456. }
  457. if (IsNetworkError(ec))
  458. {
  459. DebugPrintEx(DEBUG_ERR, _T("Network Error was found. (ec: %ld)"), ec);
  460. m_pFaxServer->Disconnect();
  461. }
  462. return hRc;
  463. }
  464. /*
  465. - CppFaxServerSentItems::PreApply
  466. -
  467. * Purpose:
  468. * Checks properties before apply.
  469. *
  470. * Arguments:
  471. *
  472. * Return:
  473. * OLE error code
  474. */
  475. HRESULT CppFaxServerSentItems::PreApply(int *pCtrlFocus, UINT * puIds)
  476. {
  477. HRESULT hRc = S_OK;
  478. //
  479. // PreApply Checks
  480. //
  481. if (!AllReadyToApply(/*fSilent =*/ FALSE, pCtrlFocus , puIds))
  482. {
  483. m_fAllReadyToApply = FALSE;
  484. SetModified(FALSE);
  485. hRc = E_FAIL ;
  486. }
  487. else
  488. {
  489. m_fAllReadyToApply = TRUE;
  490. SetModified(TRUE);
  491. }
  492. return(hRc);
  493. }
  494. /*
  495. - CppFaxServerSentItems::OnApply
  496. -
  497. * Purpose:
  498. * Calls PreApply and SetProp to Apply changes.
  499. *
  500. * Arguments:
  501. *
  502. * Return:
  503. * TRUE or FALSE
  504. */
  505. BOOL CppFaxServerSentItems::OnApply()
  506. {
  507. DEBUG_FUNCTION_NAME( _T("CppFaxServerSentItems::OnApply"));
  508. HRESULT hRc = S_OK;
  509. int CtrlFocus = 0;
  510. UINT uIds = 0;
  511. if (!m_fIsDirty)
  512. {
  513. return TRUE;
  514. }
  515. hRc = PreApply(&CtrlFocus, &uIds);
  516. if (FAILED(hRc))
  517. {
  518. if (PropSheet_SetCurSelByID( GetParent(), IDD) )
  519. {
  520. ATLASSERT(uIds);
  521. PageError(uIds, m_hWnd, _Module.GetResourceInstance());
  522. if (CtrlFocus)
  523. {
  524. GotoDlgCtrl(GetDlgItem(CtrlFocus));
  525. }
  526. }
  527. return FALSE;
  528. }
  529. else //(Succeeded(hRc))
  530. {
  531. hRc = SetProps(&CtrlFocus, &uIds);
  532. if (FAILED(hRc))
  533. {
  534. if (uIds)
  535. {
  536. if (PropSheet_SetCurSelByID( GetParent(), IDD) )
  537. {
  538. PageError(uIds, m_hWnd, _Module.GetResourceInstance());
  539. if (CtrlFocus)
  540. {
  541. GotoDlgCtrl(GetDlgItem(CtrlFocus));
  542. }
  543. }
  544. }
  545. //else Error Msg by called func.
  546. return FALSE;
  547. }
  548. else //(Succeeded(hRc))
  549. {
  550. return TRUE;
  551. }
  552. }
  553. }
  554. /*
  555. - CppFaxServerInbox::ToArchiveCheckboxClicked
  556. -
  557. * Purpose:
  558. * Gray/Ungray the folder edit box and the
  559. * browse button. Enable apply button.
  560. *
  561. * Arguments:
  562. *
  563. * Return:
  564. * 1
  565. */
  566. LRESULT CppFaxServerSentItems::ToArchiveCheckboxClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  567. {
  568. BOOL State;
  569. if (!m_fIsDialogInitiated) //event receieved in too early stage
  570. {
  571. return 0;
  572. }
  573. else
  574. {
  575. m_fIsDirty = TRUE;
  576. }
  577. State = ( IsDlgButtonChecked(IDC_SENT_TO_ARCHIVE_CHECK) == BST_CHECKED );
  578. ::EnableWindow(GetDlgItem(IDC_FOLDER_EDIT), State);
  579. ::EnableWindow(GetDlgItem(IDC_SENT_BROWSE_BUTTON), State && m_fIsLocalServer);
  580. if (m_fAllReadyToApply)//only last change should be considered
  581. {
  582. if ( !m_FolderBox.GetWindowTextLength() )
  583. {
  584. m_fAllReadyToApply = FALSE;
  585. SetModified(FALSE);
  586. }
  587. }
  588. else //m_fAllReadyToApply == FALSE
  589. {
  590. if (AllReadyToApply(TRUE))
  591. {
  592. m_fAllReadyToApply = TRUE;
  593. SetModified(TRUE);
  594. }
  595. }
  596. return 1;
  597. }
  598. /*
  599. - CppFaxServerSentItems::GenerateEventLogCheckboxClicked
  600. -
  601. * Purpose:
  602. * Gray/Ungray the spin buttons and edit boxes
  603. * Enable apply button.
  604. *
  605. * Arguments:
  606. *
  607. * Return:
  608. * 1
  609. */
  610. LRESULT CppFaxServerSentItems::GenerateEventLogCheckboxClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  611. {
  612. BOOL State;
  613. if (!m_fIsDialogInitiated) //event receieved in too early stage
  614. {
  615. return 0;
  616. }
  617. else
  618. {
  619. m_fIsDirty = TRUE;
  620. }
  621. State = ( IsDlgButtonChecked(IDC_SENT_GENERATE_WARNING_CHECK) == BST_CHECKED );
  622. ::EnableWindow(GetDlgItem(IDC_SENT_HIGH_EDIT), State);
  623. ::EnableWindow(GetDlgItem(IDC_SENT_HIGH_SPIN), State);
  624. ::EnableWindow(GetDlgItem(IDC_SENT_QUOTA_HIGH_STATIC), State);
  625. ::EnableWindow(GetDlgItem(IDC_SENT_MB1_STATIC), State);
  626. ::EnableWindow(GetDlgItem(IDC_SENT_LOW_EDIT), State);
  627. ::EnableWindow(GetDlgItem(IDC_SENT_LOW_SPIN), State);
  628. ::EnableWindow(GetDlgItem(IDC_SENT_QUOTA_LOW_STATIC), State);
  629. ::EnableWindow(GetDlgItem(IDC_SENT_MB2_STATIC), State);
  630. if (m_fAllReadyToApply)//only last change should be considered
  631. {
  632. if ( !m_HighWatermarkBox.GetWindowTextLength() )
  633. {
  634. m_fAllReadyToApply = FALSE;
  635. SetModified(FALSE);
  636. }
  637. else if ( 0 != HIWORD( m_HighWatermarkSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  638. {
  639. m_fAllReadyToApply = FALSE;
  640. SetModified(FALSE);
  641. }
  642. else if ( !m_LowWatermarkBox.GetWindowTextLength() )
  643. {
  644. m_fAllReadyToApply = FALSE;
  645. SetModified(FALSE);
  646. }
  647. }
  648. else //m_fAllReadyToApply == FALSE
  649. {
  650. if (AllReadyToApply(TRUE))
  651. {
  652. m_fAllReadyToApply = TRUE;
  653. SetModified(TRUE);
  654. }
  655. }
  656. return(1);
  657. }
  658. /*
  659. - CppFaxServerSentItems::AutoDelCheckboxClicked
  660. -
  661. * Purpose:
  662. * Gray/Ungray the spin button and edit box
  663. * and enable apply button after Auto Delete Checkbox
  664. * status was changed.
  665. *
  666. * Arguments:
  667. *
  668. * Return:
  669. * 1
  670. */
  671. LRESULT CppFaxServerSentItems::AutoDelCheckboxClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  672. {
  673. BOOL State;
  674. if (!m_fIsDialogInitiated) //event receieved in too early stage
  675. {
  676. return 0;
  677. }
  678. else
  679. {
  680. m_fIsDirty = TRUE;
  681. }
  682. State = ( IsDlgButtonChecked(IDC_SENT_AUTODEL_CHECK) == BST_CHECKED );
  683. ::EnableWindow(GetDlgItem(IDC_SENT_AUTODEL_EDIT), State);
  684. ::EnableWindow(GetDlgItem(IDC_SENT_AUTODEL_SPIN), State);
  685. if (m_fAllReadyToApply)//only last change should be considered
  686. {
  687. if ( !m_AutoDelBox.GetWindowTextLength() )
  688. {
  689. m_fAllReadyToApply = FALSE;
  690. SetModified(FALSE);
  691. }
  692. else if ( 0 != HIWORD( m_AutoDelSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  693. {
  694. m_fAllReadyToApply = FALSE;
  695. SetModified(FALSE);
  696. }
  697. }
  698. else //m_fAllReadyToApply == FALSE
  699. {
  700. if (AllReadyToApply(TRUE))
  701. {
  702. m_fAllReadyToApply = TRUE;
  703. SetModified(TRUE);
  704. }
  705. }
  706. return(1);
  707. }
  708. /*
  709. + Routine Description:
  710. +
  711. * Browse for a directory
  712. *
  713. * Arguments:
  714. *
  715. * hwndDlg - Specifies the dialog window on which the Browse button is displayed
  716. *
  717. * Return Value:
  718. *
  719. * TRUE if successful, FALSE if the user presses Cancel
  720. -
  721. -
  722. */
  723. BOOL
  724. CppFaxServerSentItems::BrowseForDirectory( WORD wNotifyCode, WORD wID, HWND hwndDlg, BOOL& bHandled )
  725. {
  726. UNREFERENCED_PARAMETER( wNotifyCode );
  727. UNREFERENCED_PARAMETER( wID );
  728. UNREFERENCED_PARAMETER( hwndDlg );
  729. UNREFERENCED_PARAMETER( bHandled );
  730. DEBUG_FUNCTION_NAME( _T("CppFaxServerSentItems::BrowseForDirectory"));
  731. BOOL fResult = FALSE;
  732. WCHAR szBrowseFolder[MAX_PATH] = {0};
  733. WCHAR szBrowseDlgTitle[FXS_MAX_TITLE_LEN];
  734. CComBSTR bstrOldPath;
  735. unsigned int len;
  736. unsigned long ulBrowseFlags;
  737. //
  738. // Collecting the browse dialog headline
  739. //
  740. if (!LoadString( _Module.GetResourceInstance(),
  741. IDS_GET_ARCHIVE_DIRECTORY,
  742. szBrowseDlgTitle,
  743. FXS_MAX_TITLE_LEN))
  744. {
  745. DWORD ec;
  746. ec = GetLastError();
  747. if (ec == ERROR_NOT_ENOUGH_MEMORY)
  748. {
  749. DebugPrintEx(
  750. DEBUG_ERR,
  751. _T("Out of Memory - fail to load string."));
  752. DlgMsgBox(this, IDS_MEMORY);
  753. return fResult;
  754. }
  755. DebugPrintEx(
  756. DEBUG_ERR,
  757. _T("Failed to load titile string - unexpected behavior."));
  758. szBrowseDlgTitle[0] = 0;
  759. }
  760. //
  761. // Collecting the old path from the calling dialog edit box
  762. //
  763. if(! GetDlgItemText( IDC_FOLDER_EDIT, bstrOldPath.m_str))
  764. {
  765. DebugPrintEx(
  766. DEBUG_ERR,
  767. _T("Failed to collect old path from the property page edit box."));
  768. szBrowseFolder[0] = 0;
  769. }
  770. else
  771. {
  772. len = bstrOldPath.Length();
  773. if ( len > MAX_PATH )
  774. {
  775. DebugPrintEx(
  776. DEBUG_ERR,
  777. _T("Old Path Length is bigger then alowed maximal path."));
  778. szBrowseFolder[0] = 0;
  779. }
  780. else
  781. {
  782. wcsncpy(szBrowseFolder, bstrOldPath, ARR_SIZE(szBrowseFolder)-1);
  783. }
  784. }
  785. //
  786. // Preparing the browse dialog style flags.
  787. //
  788. ulBrowseFlags = BIF_RETURNONLYFSDIRS |
  789. BIF_STATUSTEXT |
  790. BIF_NEWDIALOGSTYLE |
  791. BIF_NONEWFOLDERBUTTON |
  792. BIF_VALIDATE;
  793. //
  794. // Invoke the browse dialog with a function based on
  795. // Shell functions.
  796. //
  797. if (InvokeBrowseDialog(szBrowseFolder,
  798. MAX_ARCHIVE_FOLDER_PATH,
  799. szBrowseDlgTitle,
  800. ulBrowseFlags,
  801. this))
  802. {
  803. SetDlgItemText(IDC_FOLDER_EDIT, szBrowseFolder);
  804. fResult = TRUE;
  805. }
  806. return fResult;
  807. }
  808. /*
  809. - CppFaxServerSentItems::OnEditBoxChanged
  810. -
  811. * Purpose:
  812. * set Apply buttom modified.
  813. *
  814. * Arguments:
  815. *
  816. * Return:
  817. * 1
  818. */
  819. LRESULT CppFaxServerSentItems::OnEditBoxChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  820. {
  821. if (!m_fIsDialogInitiated)
  822. {
  823. return 1;
  824. }
  825. else
  826. {
  827. m_fIsDirty = TRUE;
  828. }
  829. if (m_fAllReadyToApply) //only last change should be considered
  830. {
  831. switch (wID)
  832. {
  833. case IDC_FOLDER_EDIT:
  834. if ( !m_FolderBox.GetWindowTextLength() )
  835. {
  836. SetModified(FALSE);
  837. m_fAllReadyToApply = FALSE;
  838. }
  839. break;
  840. case IDC_SENT_HIGH_EDIT:
  841. if ( !m_HighWatermarkBox.GetWindowTextLength() )
  842. {
  843. SetModified(FALSE);
  844. m_fAllReadyToApply = FALSE;
  845. }
  846. else if ( 0 != HIWORD( m_HighWatermarkSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  847. {
  848. SetModified(FALSE);
  849. m_fAllReadyToApply = FALSE;
  850. }
  851. break;
  852. case IDC_SENT_LOW_EDIT:
  853. if ( !m_LowWatermarkBox.GetWindowTextLength() )
  854. {
  855. SetModified(FALSE);
  856. m_fAllReadyToApply = FALSE;
  857. }
  858. break;
  859. case IDC_SENT_AUTODEL_EDIT:
  860. if ( !m_AutoDelBox.GetWindowTextLength() )
  861. {
  862. SetModified(FALSE);
  863. m_fAllReadyToApply = FALSE;
  864. }
  865. else if ( 0 != HIWORD( m_AutoDelSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  866. {
  867. m_fAllReadyToApply = FALSE;
  868. SetModified(FALSE);
  869. }
  870. break;
  871. default:
  872. return 1;
  873. }
  874. }
  875. else //m_fAllReadyToApply == FALSE
  876. {
  877. if (AllReadyToApply(TRUE))
  878. {
  879. m_fAllReadyToApply = TRUE;
  880. SetModified(TRUE);
  881. }
  882. }
  883. return 1;
  884. }
  885. /*
  886. - CppFaxServerSentItems::AllReadyToApply
  887. -
  888. * Purpose:
  889. * This function validate that no zero length strings
  890. * are found data areas that should be saved.
  891. *
  892. * Arguments:
  893. * [in] fSilent - boolean who defines if to pop up messages (FALSE)
  894. * or not.(TRUE)
  895. *
  896. * Return:
  897. * BOOOLEAN
  898. */
  899. BOOL CppFaxServerSentItems::AllReadyToApply(BOOL fSilent, int *pCtrlFocus, UINT *pIds)
  900. {
  901. DEBUG_FUNCTION_NAME( _T("CppFaxServerSentItems::AllReadyToApply"));
  902. DWORD ec = ERROR_SUCCESS;
  903. if (IsDlgButtonChecked(IDC_SENT_TO_ARCHIVE_CHECK) == BST_CHECKED)
  904. {
  905. if ( !m_FolderBox.GetWindowTextLength() )
  906. {
  907. ec = GetLastError();
  908. DebugPrintEx(
  909. DEBUG_ERR,
  910. _T("Zero text length - m_FolderBox. (ec: %ld)"),
  911. ec);
  912. if (!fSilent)
  913. {
  914. *pCtrlFocus = IDC_FOLDER_EDIT;
  915. *pIds = IDS_SENT_ARCHIVE_PATH_EMPTY;
  916. }
  917. return FALSE;
  918. }
  919. }
  920. if (IsDlgButtonChecked(IDC_SENT_GENERATE_WARNING_CHECK) == BST_CHECKED)
  921. {
  922. if ( !m_HighWatermarkBox.GetWindowTextLength() )
  923. {
  924. ec = GetLastError();
  925. DebugPrintEx(
  926. DEBUG_ERR,
  927. _T("Zero text length - m_HighWatermarkBox. (ec: %ld)"),
  928. ec);
  929. if (!fSilent)
  930. {
  931. *pCtrlFocus = IDC_SENT_HIGH_EDIT;
  932. *pIds = IDS_WATERMARK_EMPTY;
  933. }
  934. return FALSE;
  935. }
  936. else if ( 0 != HIWORD( m_HighWatermarkSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  937. {
  938. DebugPrintEx(
  939. DEBUG_ERR,
  940. _T("Zero value - m_HighWatermarkBox. (ec: %ld)"));
  941. if (!fSilent)
  942. {
  943. *pIds = IDS_SENT_HIGH_WATERMARK_ZERO;
  944. *pCtrlFocus = IDC_SENT_HIGH_EDIT;
  945. }
  946. return FALSE;
  947. }
  948. if ( !m_LowWatermarkBox.GetWindowTextLength() )
  949. {
  950. ec = GetLastError();
  951. DebugPrintEx(
  952. DEBUG_ERR,
  953. _T("Zero text length - m_LowWatermarkBox. (ec: %ld)"),
  954. ec);
  955. if (!fSilent)
  956. {
  957. *pCtrlFocus = IDC_SENT_LOW_EDIT;
  958. *pIds = IDS_WATERMARK_EMPTY;
  959. }
  960. return FALSE;
  961. }
  962. }
  963. if (IsDlgButtonChecked(IDC_SENT_AUTODEL_CHECK) == BST_CHECKED)
  964. {
  965. if ( !m_AutoDelBox.GetWindowTextLength() )
  966. {
  967. ec = GetLastError();
  968. DebugPrintEx(
  969. DEBUG_ERR,
  970. _T("Zero text length - m_AutoDelBox. (ec: %ld)"),
  971. ec);
  972. if (!fSilent)
  973. {
  974. *pCtrlFocus = IDC_SENT_AUTODEL_EDIT;
  975. *pIds = IDS_AUTODEL_EMPTY;
  976. }
  977. return FALSE;
  978. }
  979. else if ( 0 != HIWORD( m_AutoDelSpin.GetPos() ) ) //occures for out of range such zero. MSDN UDM_GETPOS
  980. {
  981. DebugPrintEx(
  982. DEBUG_ERR,
  983. _T("Zero value - m_AutoDelBox."));
  984. if (!fSilent)
  985. {
  986. *pCtrlFocus = IDC_SENT_AUTODEL_EDIT;
  987. *pIds = IDS_AUTODEL_EMPTY;
  988. }
  989. return FALSE;
  990. }
  991. }
  992. ATLASSERT(ERROR_SUCCESS == ec);
  993. //
  994. // Cheers!
  995. // ...every thing ready to apply now.
  996. //
  997. return TRUE;
  998. }
  999. //////////////////////////////////////////////////////////////////////////////
  1000. /*++
  1001. CppFaxServerSentItems::OnHelpRequest
  1002. This is called in response to the WM_HELP Notify
  1003. message and to the WM_CONTEXTMENU Notify message.
  1004. WM_HELP Notify message.
  1005. This message is sent when the user presses F1 or <Shift>-F1
  1006. over an item or when the user clicks on the ? icon and then
  1007. presses the mouse over an item.
  1008. WM_CONTEXTMENU Notify message.
  1009. This message is sent when the user right clicks over an item
  1010. and then clicks "What's this?"
  1011. --*/
  1012. /////////////////////////////////////////////////////////////////////////////
  1013. LRESULT
  1014. CppFaxServerSentItems::OnHelpRequest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
  1015. {
  1016. DEBUG_FUNCTION_NAME(_T("CppFaxServerSentItems::OnHelpRequest"));
  1017. switch (uMsg)
  1018. {
  1019. case WM_HELP:
  1020. WinContextHelp(((LPHELPINFO)lParam)->dwContextId, m_hWnd);
  1021. break;
  1022. case WM_CONTEXTMENU:
  1023. WinContextHelp(::GetWindowContextHelpId((HWND)wParam), m_hWnd);
  1024. break;
  1025. }
  1026. return TRUE;
  1027. }