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.

392 lines
11 KiB

  1. #include "faxcfgwz.h"
  2. #include <strsafe.h>
  3. #define MAX_SUMMARY_LEN 4096
  4. static
  5. BOOL
  6. AppendSummaryText(
  7. LPTSTR pSummaryText,
  8. DWORD dwSummaryTextLen,
  9. INT iRes,
  10. ...
  11. )
  12. /*++
  13. Routine Description:
  14. Create summary information depending on config settings
  15. Arguments:
  16. pSummaryText - pointer of summary text
  17. dwSummaryTextLen - total length (in TCHARs) of pSummaryText
  18. iRes - resource ID for the text to be added into the summary text
  19. ... = arguments as required for the formatting
  20. Return Value:
  21. TRUE if successful, FALSE for failure.
  22. --*/
  23. {
  24. va_list va;
  25. HRESULT hr;
  26. TCHAR szBuffer[MAX_SUMMARY_LEN] = {0};
  27. TCHAR szFormat[2*MAX_PATH + 1] = {0};
  28. DEBUG_FUNCTION_NAME(TEXT("AppendSummaryText"));
  29. if(!LoadString(g_hResource, iRes, szFormat, ARR_SIZE(szFormat)-1))
  30. {
  31. DebugPrintEx(DEBUG_ERR,
  32. TEXT("LoadString failed. string ID=%d, error=%d"),
  33. iRes,
  34. GetLastError());
  35. Assert(FALSE);
  36. return FALSE;
  37. }
  38. va_start(va, iRes);
  39. hr = StringCchVPrintf (szBuffer, ARR_SIZE(szBuffer), szFormat, va);
  40. va_end(va);
  41. if (FAILED(hr))
  42. {
  43. //
  44. // Failed to format string - buffer is too small
  45. //
  46. DebugPrintEx(DEBUG_ERR,
  47. TEXT("Failed to format string - buffer is too small. 0x%08x"), hr);
  48. Assert(FALSE);
  49. return FALSE;
  50. }
  51. hr = StringCchCat (pSummaryText, dwSummaryTextLen, szBuffer);
  52. if (FAILED(hr))
  53. {
  54. //
  55. // Failed to concat string - buffer is too small
  56. //
  57. DebugPrintEx(DEBUG_ERR,
  58. TEXT("Failed to concat string - buffer is too small. 0x%08x"), hr);
  59. Assert(FALSE);
  60. return FALSE;
  61. }
  62. return TRUE;
  63. } // AppendSummaryText
  64. BOOL
  65. ShowSummaryText(
  66. HWND hDlg
  67. )
  68. /*++
  69. Routine Description:
  70. Create summary information depending on config settings
  71. Arguments:
  72. hDlg - Handle to the complete page
  73. Return Value:
  74. TRUE if successful, FALSE for failure.
  75. --*/
  76. {
  77. TCHAR szSummaryText[MAX_SUMMARY_LEN] = {0};
  78. HWND hControl;
  79. BOOL bRes = FALSE;
  80. DWORD dwRoutingEnabled = FALSE; // indicate whether at least one routing method is enabled
  81. DWORD dwIndex;
  82. DEBUG_FUNCTION_NAME(TEXT("ShowSummaryText()"));
  83. hControl = GetDlgItem(hDlg, IDC_SUMMARY);
  84. // get the control ID and clear the current content.
  85. SetWindowText(hControl, TEXT(""));
  86. // if no device is selected, don't show the summary page.
  87. if(!IsSendEnable() && !IsReceiveEnable())
  88. {
  89. ShowWindow(hControl, SW_HIDE);
  90. goto exit;
  91. }
  92. if(!LoadString(g_hResource, IDS_SUMMARY, szSummaryText, MAX_PATH))
  93. {
  94. DebugPrintEx(DEBUG_ERR,
  95. TEXT("LoadString failed: string ID=%d, error=%d"),
  96. IDS_SUMMARY,
  97. GetLastError());
  98. ShowWindow(hControl, SW_HIDE);
  99. goto exit;
  100. }
  101. //
  102. // Add send device settings
  103. //
  104. if(IsSendEnable())
  105. {
  106. if (!AppendSummaryText(szSummaryText, ARR_SIZE (szSummaryText), IDS_SUMMARY_SEND_DEVICES))
  107. {
  108. goto exit;
  109. }
  110. for(dwIndex = 0; dwIndex < g_wizData.dwDeviceCount; dwIndex++)
  111. {
  112. if(g_wizData.pDevInfo[dwIndex].bSend)
  113. {
  114. if (!AppendSummaryText(szSummaryText,
  115. ARR_SIZE (szSummaryText),
  116. IDS_SUMMARY_DEVICE_ITEM,
  117. g_wizData.pDevInfo[dwIndex].szDeviceName))
  118. {
  119. goto exit;
  120. }
  121. }
  122. }
  123. if(g_wizData.szTsid)
  124. {
  125. if (!AppendSummaryText(szSummaryText, ARR_SIZE (szSummaryText), IDS_SUMMARY_TSID, g_wizData.szTsid))
  126. {
  127. goto exit;
  128. }
  129. }
  130. }
  131. //
  132. // Add receive device settings
  133. //
  134. if(IsReceiveEnable())
  135. {
  136. BOOL bAuto = FALSE;
  137. int iManualAnswerDeviceIndex = -1;
  138. if (!AppendSummaryText(szSummaryText, ARR_SIZE (szSummaryText), IDS_SUMMARY_RECEIVE_DEVICES))
  139. {
  140. goto exit;
  141. }
  142. for(dwIndex = 0; dwIndex < g_wizData.dwDeviceCount; dwIndex++)
  143. {
  144. if(FAX_DEVICE_RECEIVE_MODE_AUTO == g_wizData.pDevInfo[dwIndex].ReceiveMode)
  145. {
  146. bAuto = TRUE;
  147. if (!AppendSummaryText(szSummaryText,
  148. ARR_SIZE (szSummaryText),
  149. IDS_SUMMARY_DEVICE_ITEM,
  150. g_wizData.pDevInfo[dwIndex].szDeviceName))
  151. {
  152. goto exit;
  153. }
  154. }
  155. else if (FAX_DEVICE_RECEIVE_MODE_MANUAL == g_wizData.pDevInfo[dwIndex].ReceiveMode)
  156. {
  157. iManualAnswerDeviceIndex = dwIndex;
  158. }
  159. }
  160. if(bAuto)
  161. {
  162. if (!AppendSummaryText(szSummaryText,
  163. ARR_SIZE (szSummaryText),
  164. IDS_SUMMARY_AUTO_ANSWER,
  165. g_wizData.dwRingCount))
  166. {
  167. goto exit;
  168. }
  169. }
  170. if(iManualAnswerDeviceIndex != -1)
  171. {
  172. Assert(!bAuto);
  173. if (!AppendSummaryText(szSummaryText,
  174. ARR_SIZE (szSummaryText),
  175. IDS_SUMMARY_DEVICE_ITEM,
  176. g_wizData.pDevInfo[iManualAnswerDeviceIndex].szDeviceName))
  177. {
  178. goto exit;
  179. }
  180. if (!AppendSummaryText(szSummaryText, ARR_SIZE (szSummaryText), IDS_SUMMARY_MANUAL_ANSWER))
  181. {
  182. goto exit;
  183. }
  184. }
  185. if(g_wizData.szCsid)
  186. {
  187. if (!AppendSummaryText(szSummaryText, ARR_SIZE (szSummaryText), IDS_SUMMARY_CSID, g_wizData.szCsid))
  188. {
  189. goto exit;
  190. }
  191. }
  192. // check whether user selects routing methods
  193. for(dwIndex = 0; dwIndex < RM_COUNT; dwIndex++)
  194. {
  195. if(g_wizData.pRouteInfo[dwIndex].bEnabled)
  196. {
  197. dwRoutingEnabled = TRUE;
  198. break;
  199. }
  200. }
  201. //
  202. // add routing information:
  203. //
  204. if(dwRoutingEnabled)
  205. {
  206. if (!AppendSummaryText(szSummaryText, ARR_SIZE (szSummaryText), IDS_SUMMARY_ROUTING_METHODS))
  207. {
  208. goto exit;
  209. }
  210. for(dwIndex = 0; dwIndex < RM_COUNT; dwIndex++)
  211. {
  212. BOOL bEnabled;
  213. LPTSTR tszCurSel;
  214. //
  215. // if we don't have this kind of method, go to the next one
  216. //
  217. tszCurSel = g_wizData.pRouteInfo[dwIndex].tszCurSel;
  218. bEnabled = g_wizData.pRouteInfo[dwIndex].bEnabled;
  219. switch (dwIndex)
  220. {
  221. case RM_FOLDER:
  222. if(bEnabled)
  223. {
  224. if (!AppendSummaryText(szSummaryText, ARR_SIZE (szSummaryText), IDS_SUMMARY_SAVE_FOLDER, tszCurSel))
  225. {
  226. goto exit;
  227. }
  228. }
  229. break;
  230. case RM_PRINT:
  231. if(bEnabled)
  232. {
  233. if (!AppendSummaryText(szSummaryText, ARR_SIZE (szSummaryText), IDS_SUMMARY_PRINT, tszCurSel))
  234. {
  235. goto exit;
  236. }
  237. }
  238. break;
  239. }
  240. }
  241. }
  242. }
  243. ShowWindow(hControl, SW_NORMAL);
  244. SetWindowText(hControl, szSummaryText);
  245. bRes = TRUE;
  246. exit:
  247. return bRes;
  248. }
  249. INT_PTR CALLBACK
  250. CompleteDlgProc (
  251. HWND hDlg,
  252. UINT uMsg,
  253. WPARAM wParam,
  254. LPARAM lParam
  255. )
  256. /*++
  257. Routine Description:
  258. Procedure for handling the "Complete" page
  259. Arguments:
  260. hDlg - Identifies the property sheet page
  261. uMsg - Specifies the message
  262. wParam - Specifies additional message-specific information
  263. lParam - Specifies additional message-specific information
  264. Return Value:
  265. Depends on the value of message parameter
  266. --*/
  267. {
  268. HWND hwndControl;
  269. switch (uMsg)
  270. {
  271. case WM_INITDIALOG :
  272. {
  273. // It's an intro/end page, so get the title font
  274. // from the shared data and use it for the title control
  275. hwndControl = GetDlgItem(hDlg, IDCSTATIC_COMPLETE);
  276. SetWindowFont(hwndControl, g_wizData.hTitleFont, TRUE);
  277. return TRUE;
  278. }
  279. case WM_NOTIFY :
  280. {
  281. LPNMHDR lpnm = (LPNMHDR) lParam;
  282. switch (lpnm->code)
  283. {
  284. case PSN_SETACTIVE : // Enable the Back and Finish button
  285. ShowSummaryText(hDlg);
  286. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_FINISH);
  287. break;
  288. case PSN_WIZBACK :
  289. {
  290. //
  291. // Handle a Back button click here
  292. //
  293. if(RemoveLastPage(hDlg))
  294. {
  295. return TRUE;
  296. }
  297. break;
  298. }
  299. break;
  300. case PSN_WIZFINISH :
  301. //
  302. // Handle a Finish button click, if necessary
  303. //
  304. g_wizData.bFinishPressed = TRUE;
  305. break;
  306. case PSN_RESET :
  307. {
  308. // Handle a Cancel button click, if necessary
  309. break;
  310. }
  311. default :
  312. break;
  313. }
  314. break;
  315. }
  316. default:
  317. break;
  318. }
  319. return FALSE;
  320. }