Source code of Windows XP (NT5)
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.

273 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. srvopts.c
  5. Abstract:
  6. Functions for handling events in the "Server Options" tab of
  7. the fax server configuration property sheet
  8. Environment:
  9. Fax configuration applet
  10. Revision History:
  11. 03/13/96 -davidx-
  12. Created it.
  13. mm/dd/yy -author-
  14. description
  15. --*/
  16. #include "faxcpl.h"
  17. VOID
  18. DoInitServerOptions(
  19. HWND hDlg
  20. )
  21. /*++
  22. Routine Description:
  23. Perform one-time initialization of "Server Options" property page
  24. Arguments:
  25. hDlg - Window handle to the "Server Options" property page
  26. Return Value:
  27. NONE
  28. --*/
  29. {
  30. PFAX_CONFIGURATION pFaxConfig;
  31. //
  32. // Connect to the fax service and retrieve the list of fax devices
  33. //
  34. GetFaxDeviceAndConfigInfo();
  35. //
  36. // Initialize retries characteristics and toll prefix list boxes
  37. //
  38. if (pFaxConfig = gConfigData->pFaxConfig) {
  39. insideSetDlgItemText = TRUE;
  40. SetDlgItemInt(hDlg, IDC_NUMRETRIES, pFaxConfig->Retries, FALSE);
  41. SetDlgItemInt(hDlg, IDC_RETRY_INTERVAL, pFaxConfig->RetryDelay, FALSE);
  42. SetDlgItemInt(hDlg, IDC_MAXJOBLIFE, pFaxConfig->DirtyDays, FALSE);
  43. insideSetDlgItemText = FALSE;
  44. CheckDlgButton(hDlg, IDC_PRINT_BANNER, pFaxConfig->Branding);
  45. CheckDlgButton(hDlg, IDC_USE_DEVICE_TSID, pFaxConfig->UseDeviceTsid);
  46. }
  47. }
  48. BOOL
  49. DoSaveServerOptions(
  50. HWND hDlg
  51. )
  52. /*++
  53. Routine Description:
  54. Save the information on the "Server Options" property page
  55. Arguments:
  56. hDlg - Handle to the "Server Options" property page
  57. Return Value:
  58. TRUE if successful, FALSE if there is an error
  59. --*/
  60. {
  61. PFAX_CONFIGURATION pFaxConfig;
  62. BOOL success;
  63. DWORD value;
  64. //
  65. // Check if anything on this page was changed
  66. //
  67. Verbose(("Saving 'Server Options' page ...\n"));
  68. if (! GetChangedFlag(SERVER_OPTIONS_PAGE))
  69. return TRUE;
  70. if (pFaxConfig = gConfigData->pFaxConfig) {
  71. //
  72. // Retrieve the information in the text fields
  73. //
  74. value = GetDlgItemInt(hDlg, IDC_NUMRETRIES, &success, FALSE);
  75. if (success)
  76. pFaxConfig->Retries = value;
  77. value = GetDlgItemInt(hDlg, IDC_RETRY_INTERVAL, &success, FALSE);
  78. if (success)
  79. pFaxConfig->RetryDelay = value;
  80. value = GetDlgItemInt(hDlg, IDC_MAXJOBLIFE, &success, FALSE);
  81. if (success)
  82. pFaxConfig->DirtyDays = value;
  83. pFaxConfig->Branding = IsDlgButtonChecked(hDlg, IDC_PRINT_BANNER);
  84. pFaxConfig->UseDeviceTsid = IsDlgButtonChecked(hDlg, IDC_USE_DEVICE_TSID);
  85. }
  86. //
  87. // Save the fax device information if this is the last modified page
  88. //
  89. return SaveFaxDeviceAndConfigInfo(hDlg, SERVER_OPTIONS_PAGE);
  90. }
  91. BOOL
  92. ServerOptionsProc(
  93. HWND hDlg,
  94. UINT message,
  95. UINT wParam,
  96. LONG lParam
  97. )
  98. /*++
  99. Routine Description:
  100. Procedure for handling the "Server Options" tab
  101. Arguments:
  102. hDlg - Identifies the property sheet page
  103. message - Specifies the message
  104. wParam - Specifies additional message-specific information
  105. lParam - Specifies additional message-specific information
  106. Return Value:
  107. Depends on the value of message parameter
  108. --*/
  109. #define MAX_RETRIES 15
  110. #define MAX_RETRY_INTERVAL 1440
  111. #define MAX_JOBLIFE 365
  112. {
  113. INT cmdId;
  114. switch (message) {
  115. case WM_INITDIALOG:
  116. DoInitServerOptions(hDlg);
  117. return TRUE;
  118. case WM_COMMAND:
  119. switch (cmdId = GET_WM_COMMAND_ID(wParam, lParam)) {
  120. case IDC_PRINT_BANNER:
  121. case IDC_USE_DEVICE_TSID:
  122. break;
  123. case IDC_NUMRETRIES:
  124. case IDC_RETRY_INTERVAL:
  125. case IDC_MAXJOBLIFE:
  126. if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE && !insideSetDlgItemText) {
  127. INT maxVal, curVal;
  128. BOOL valid;
  129. HWND hwndText;
  130. maxVal = (cmdId == IDC_NUMRETRIES) ? MAX_RETRIES :
  131. (cmdId == IDC_RETRY_INTERVAL) ? MAX_RETRY_INTERVAL : MAX_JOBLIFE;
  132. hwndText = GetDlgItem(hDlg, cmdId);
  133. curVal = GetDlgItemInt(hDlg, cmdId, &valid, FALSE);
  134. if (curVal > maxVal) {
  135. valid = FALSE;
  136. curVal = maxVal;
  137. }
  138. if (! valid) {
  139. MessageBeep(MB_OK);
  140. insideSetDlgItemText = TRUE;
  141. SetDlgItemInt(hDlg, cmdId, curVal, FALSE);
  142. SendMessage(hwndText, EM_SETSEL, 0, -1);
  143. insideSetDlgItemText = FALSE;
  144. }
  145. break;
  146. }
  147. return TRUE;
  148. default:
  149. return FALSE;
  150. }
  151. SetChangedFlag(hDlg, SERVER_OPTIONS_PAGE, TRUE);
  152. return TRUE;
  153. case WM_NOTIFY:
  154. if (((NMHDR *) lParam)->code == PSN_APPLY) {
  155. //
  156. // User pressed OK or Apply - validate inputs and save changes
  157. //
  158. if (! DoSaveServerOptions(hDlg)) {
  159. SetWindowLong(hDlg, DWL_MSGRESULT, -1);
  160. return PSNRET_INVALID_NOCHANGEPAGE;
  161. } else {
  162. SetChangedFlag(hDlg, SERVER_OPTIONS_PAGE, FALSE);
  163. return PSNRET_NOERROR;
  164. }
  165. }
  166. break;
  167. case WM_HELP:
  168. case WM_CONTEXTMENU:
  169. return HandleHelpPopup(hDlg, message, wParam, lParam, SERVER_OPTIONS_PAGE);
  170. }
  171. return FALSE;
  172. }