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.

423 lines
9.5 KiB

  1. /* File: C:\WACKER\XFER\x_zm_dlg.c (Created: 17-Dec-1993)
  2. * created from:
  3. * File: C:\HA5G\ha5g\genrcdlg.c (Created: 12-Sep-1990)
  4. *
  5. * Copyright 1990,1994 by Hilgraeve Inc. -- Monroe, MI
  6. * All rights reserved
  7. *
  8. * $Revision: 3 $
  9. * $Date: 5/15/02 4:40p $
  10. */
  11. #include <windows.h>
  12. #pragma hdrstop
  13. #include <commctrl.h>
  14. #include <term\res.h>
  15. #include <tdll\stdtyp.h>
  16. #include <tdll\assert.h>
  17. #include <tdll\mc.h>
  18. #include "xfer.h"
  19. #include "xfer.hh"
  20. #if !defined(DlgParseCmd)
  21. #define DlgParseCmd(i,n,c,w,l) i=LOWORD(w);n=HIWORD(w);c=(HWND)l;
  22. #endif
  23. struct stSaveDlgStuff
  24. {
  25. LPARAM lPar;
  26. HWND hwndWaitUpDown;
  27. };
  28. typedef struct stSaveDlgStuff SDS;
  29. /* These are the control ID numbers */
  30. #define AUTOSTART_CHECK 102
  31. #define USE_SENDER_PB 104
  32. #define USE_LOCAL_PB 105
  33. #define REC_NEGOTIATE_PB 107
  34. #define REC_NEVER_PB 108
  35. #define REC_ALWAYS_PB 109
  36. #define AO_COMBO 112
  37. #define SEND_NEGOTIATE_PB 114
  38. #define SEND_ONE_TIME_PB 115
  39. #define SEND_ALWAYS_PB 116
  40. #define STREAMING_PB 119
  41. #define WINDOWED_PB 120
  42. #define WINDOW_COMBO 121
  43. #define PACKET_COMBO 124
  44. #define WAIT_ROCKER 130
  45. #define ROCKER_ID 131
  46. #define WMAX 100
  47. #define BIT_16_PB 127
  48. #define BIT_32_PB 128
  49. #define EOL_PB 132
  50. #define ESC_CODE_PB 133
  51. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  52. * FUNCTION:
  53. * ZmodemParamsDlg
  54. *
  55. * DESCRIPTION:
  56. * This function is called to allow the user to modify the ZMODEM transfer
  57. * protocol parameters.
  58. *
  59. * ARGUMENTS: Standard Windows dialog manager
  60. *
  61. * RETURNS: Standard Windows dialog manager
  62. *
  63. */
  64. BOOL CALLBACK ZmodemParamsDlg(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  65. {
  66. #if defined(UPPER_FEATURES)
  67. HWND hwndChild;
  68. INT nId;
  69. INT nNtfy;
  70. int nLoop;
  71. RECT rc;
  72. DWORD dw;
  73. SDS *pD;
  74. XFR_Z_PARAMS *pZ;
  75. switch (wMsg)
  76. {
  77. case WM_INITDIALOG:
  78. /* Save the parameter block for the exit path */
  79. pD = (SDS *)malloc(sizeof(SDS));
  80. if (pD == (SDS *)0)
  81. {
  82. /* Error, bail out, pull rip cord */
  83. /* TODO: decide if we need an error message */
  84. EndDialog(hDlg, FALSE);
  85. }
  86. pD->lPar = lPar;
  87. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pD);
  88. /* Get the parameter block to use now*/
  89. pZ = (XFR_Z_PARAMS *)lPar;
  90. /*
  91. * Do the receiving stuff
  92. */
  93. SendMessage(GetDlgItem(hDlg, AUTOSTART_CHECK),
  94. BM_SETCHECK, pZ->nAutostartOK, 0L);
  95. if (pZ->nFileExists == ZP_FE_SENDER)
  96. SendMessage(GetDlgItem(hDlg, USE_SENDER_PB),
  97. BM_SETCHECK, 1, 0L);
  98. else
  99. SendMessage(GetDlgItem(hDlg, USE_LOCAL_PB),
  100. BM_SETCHECK, 1, 0L);
  101. switch (pZ->nCrashRecRecv)
  102. {
  103. default:
  104. case ZP_CRR_NEG:
  105. SendMessage(GetDlgItem(hDlg, REC_NEGOTIATE_PB),
  106. BM_SETCHECK, 1, 0L);
  107. break;
  108. case ZP_CRR_NEVER:
  109. SendMessage(GetDlgItem(hDlg, REC_NEVER_PB),
  110. BM_SETCHECK, 1, 0L);
  111. break;
  112. case ZP_CRR_ALWAYS:
  113. SendMessage(GetDlgItem(hDlg, REC_ALWAYS_PB),
  114. BM_SETCHECK, 1, 0L);
  115. break;
  116. }
  117. /*
  118. * Do the sending stuff
  119. */
  120. for (nLoop = 0; nLoop < 8; nLoop += 1)
  121. {
  122. TCHAR acStr[64];
  123. LoadString(glblQueryDllHinst(),
  124. IDS_TM_SD_ONE + nLoop,
  125. acStr,
  126. sizeof(acStr) / sizeof(TCHAR));
  127. SendMessage(GetDlgItem(hDlg, AO_COMBO),
  128. CB_INSERTSTRING,
  129. (UINT)nLoop,
  130. (LONG)acStr);
  131. }
  132. SendMessage(GetDlgItem(hDlg, AO_COMBO),
  133. CB_SETCURSEL,
  134. pZ->nOverwriteOpt - 1,
  135. 0L);
  136. if (pZ->nCrashRecSend == ZP_CRS_NEG)
  137. SendMessage(GetDlgItem(hDlg, SEND_NEGOTIATE_PB),
  138. BM_SETCHECK, 1, 0L);
  139. else
  140. SendMessage(GetDlgItem(hDlg, SEND_ALWAYS_PB),
  141. BM_SETCHECK, 1, 0L);
  142. /*
  143. * Do the generic stuff
  144. */
  145. for (nLoop = 0; nLoop < 16; nLoop += 1)
  146. {
  147. BYTE acBuffer[16];
  148. wsprintf(acBuffer, (LPSTR)"%d K", nLoop + 1);
  149. SendMessage(GetDlgItem(hDlg, WINDOW_COMBO),
  150. CB_INSERTSTRING,
  151. (UINT)nLoop,
  152. (LONG)((LPSTR)acBuffer));
  153. }
  154. SendMessage(GetDlgItem(hDlg, WINDOW_COMBO),
  155. CB_SETCURSEL, pZ->nWinSize, 0L);
  156. if (pZ->nXferMthd == ZP_XM_STREAM)
  157. {
  158. SendMessage(GetDlgItem(hDlg, STREAMING_PB),
  159. BM_SETCHECK, 1, 0L);
  160. EnableWindow(GetDlgItem(hDlg, WINDOW_COMBO), FALSE);
  161. }
  162. else
  163. {
  164. SendMessage(GetDlgItem(hDlg, WINDOWED_PB),
  165. BM_SETCHECK, 1, 0L);
  166. }
  167. for (nLoop = 0; nLoop < 6; nLoop += 1)
  168. {
  169. BYTE acBuffer[16];
  170. wsprintf(acBuffer, (LPSTR)"%d", (1 << (nLoop + 5)));
  171. SendMessage(GetDlgItem(hDlg, PACKET_COMBO),
  172. CB_INSERTSTRING,
  173. (UINT)nLoop,
  174. (LONG)((LPSTR)acBuffer));
  175. }
  176. SendMessage(GetDlgItem(hDlg, PACKET_COMBO),
  177. CB_SETCURSEL, pZ->nBlkSize, 0L);
  178. // SetDlgItemInt(hDlg, WAIT_ROCKER, pZ->nRetryWait, FALSE);
  179. GetClientRect(GetDlgItem(hDlg, WAIT_ROCKER), &rc);
  180. nLoop = rc.top - rc.bottom;
  181. dw = WS_CHILD | WS_BORDER | WS_VISIBLE;
  182. dw |= UDS_ALIGNRIGHT;
  183. dw |= UDS_ARROWKEYS;
  184. dw |= UDS_SETBUDDYINT;
  185. pD->hwndWaitUpDown = CreateUpDownControl(
  186. dw, /* create window flags */
  187. rc.right, /* left edge */
  188. rc.top, /* top edge */
  189. (nLoop / 3) * 2,/* width */
  190. nLoop, /* height */
  191. hDlg, /* parent window */
  192. ROCKER_ID,
  193. (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE),
  194. GetDlgItem(hDlg, WAIT_ROCKER),
  195. WMAX, /* upper limit */
  196. 1, /* lower limit */
  197. pZ->nRetryWait);/* starting position */
  198. assert(pD->hwndWaitUpDown);
  199. #if 0
  200. /* Do we still use rockers ? */
  201. SendMessage(GetDlgItem(hDlg, WAIT_ROCKER),
  202. RS_SETMIN,
  203. 0, (LONG)1);
  204. SendMessage(GetDlgItem(hDlg, WAIT_ROCKER),
  205. RS_SETMAX,
  206. 0, (LONG)WMAX);
  207. SendMessage(GetDlgItem(hDlg, WAIT_ROCKER),
  208. RS_SETVALUE,
  209. 0, (LONG)wFlag);
  210. #endif
  211. if (pZ->nCrcType == ZP_CRC_32)
  212. SendMessage(GetDlgItem(hDlg, BIT_32_PB),
  213. BM_SETCHECK, 1, 0L);
  214. else
  215. SendMessage(GetDlgItem(hDlg, BIT_16_PB),
  216. BM_SETCHECK, 1, 0L);
  217. if (pZ->nEolConvert)
  218. SendMessage(GetDlgItem(hDlg, EOL_PB),
  219. BM_SETCHECK, 1, 0L);
  220. if (pZ->nEscCtrlCodes)
  221. SendMessage(GetDlgItem(hDlg, ESC_CODE_PB),
  222. BM_SETCHECK, 1, 0L);
  223. break;
  224. case WM_DESTROY:
  225. break;
  226. case WM_COMMAND:
  227. /*
  228. * Did we plan to put a macro in here to do the parsing ?
  229. */
  230. DlgParseCmd(nId, nNtfy, hwndChild, wPar, lPar);
  231. switch (nId)
  232. {
  233. case IDOK:
  234. pD = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  235. assert(pD);
  236. pZ = (XFR_Z_PARAMS *)pD->lPar;
  237. assert(pZ);
  238. /*
  239. * TODO: decide how we are going to handle confirmable changes
  240. */
  241. /*
  242. * Do the receive stuff
  243. */
  244. pZ->nAutostartOK = (IsDlgButtonChecked(hDlg, AUTOSTART_CHECK) == BST_CHECKED);
  245. pZ->nFileExists = ZP_FE_DLG;
  246. if (IsDlgButtonChecked(hDlg, USE_SENDER_PB) == BST_CHECKED)
  247. {
  248. pZ->nFileExists = ZP_FE_SENDER;
  249. }
  250. if (IsDlgButtonChecked(hDlg, REC_NEGOTIATE_PB) == BST_CHECKED)
  251. {
  252. pZ->nCrashRecRecv = ZP_CRR_NEG;
  253. }
  254. else if (IsDlgButtonChecked(hDlg, REC_NEVER_PB) == BST_CHECKED)
  255. {
  256. pZ->nCrashRecRecv = ZP_CRR_NEVER;
  257. }
  258. else
  259. {
  260. pZ->nCrashRecRecv = ZP_CRR_ALWAYS;
  261. }
  262. /*
  263. * Do the send stuff
  264. */
  265. pZ->nOverwriteOpt = (LONG)SendMessage(GetDlgItem(hDlg, AO_COMBO),
  266. CB_GETCURSEL, 0, 0L);
  267. if (pZ->nOverwriteOpt == CB_ERR)
  268. {
  269. pZ->nOverwriteOpt = 1;
  270. }
  271. else
  272. {
  273. pZ->nOverwriteOpt += 1; /* Zero vs. one base list */
  274. }
  275. pZ->nCrashRecSend = ZP_CRS_ALWAYS;
  276. if (IsDlgButtonChecked(hDlg, SEND_NEGOTIATE_PB) == BST_CHECKED)
  277. {
  278. pZ->nCrashRecSend = ZP_CRS_NEG;
  279. }
  280. else if (IsDlgButtonChecked(hDlg, SEND_ONE_TIME_PB) == BST_CHECKED)
  281. {
  282. pZ->nCrashRecSend = ZP_CRS_ONCE;
  283. }
  284. /*
  285. * Do the generic stuff
  286. */
  287. pZ->nWinSize = (LONG)SendMessage(GetDlgItem(hDlg, WINDOW_COMBO),
  288. CB_GETCURSEL, 0, 0L);
  289. if (pZ->nWinSize == CB_ERR)
  290. {
  291. pZ->nWinSize = 1;
  292. /* TODO: check the format */
  293. }
  294. if (IsDlgButtonChecked(hDlg, STREAMING_PB) == BST_CHECKED)
  295. {
  296. pZ->nXferMthd = ZP_XM_STREAM;
  297. }
  298. else
  299. {
  300. pZ->nXferMthd = ZP_XM_WINDOW;
  301. }
  302. pZ->nBlkSize = (LONG)SendMessage(GetDlgItem(hDlg, PACKET_COMBO),
  303. CB_GETCURSEL, 0, 0L);
  304. if (pZ->nBlkSize == CB_ERR)
  305. {
  306. /* TODO: check the format */
  307. pZ->nBlkSize = 1;
  308. }
  309. if (IsDlgButtonChecked(hDlg, BIT_32_PB) == BST_CHECKED)
  310. {
  311. pZ->nCrcType = ZP_CRC_32;
  312. }
  313. else
  314. {
  315. pZ->nCrcType = ZP_CRC_16;
  316. }
  317. /* TODO: remember that this used to be a rocker */
  318. pZ->nRetryWait = GetDlgItemInt(hDlg, WAIT_ROCKER, NULL, FALSE);
  319. if (pZ->nRetryWait < 5)
  320. pZ->nRetryWait = 5;
  321. if (pZ->nRetryWait > 100)
  322. pZ->nRetryWait = 100;
  323. pZ->nEolConvert = (IsDlgButtonChecked(hDlg, EOL_PB) == BST_CHECKED);
  324. pZ->nEscCtrlCodes = (IsDlgButtonChecked(hDlg, ESC_CODE_PB) == BST_CHECKED);
  325. free(pD);
  326. pD = (SDS *)0;
  327. EndDialog(hDlg, TRUE);
  328. break;
  329. case IDCANCEL:
  330. /* Not much to do except free the memory */
  331. pD = (SDS *)GetWindowLongPtr(hDlg, DWLP_USER);
  332. free(pD);
  333. pD = (SDS *)0;
  334. EndDialog(hDlg, FALSE);
  335. break;
  336. case STREAMING_PB:
  337. if (IsDlgButtonChecked(hDlg, STREAMING_PB) == BST_CHECKED)
  338. {
  339. EnableWindow(GetDlgItem(hDlg, WINDOW_COMBO), FALSE);
  340. }
  341. break;
  342. case WINDOWED_PB:
  343. if (IsDlgButtonChecked(hDlg, WINDOWED_PB) == BST_CHECKED)
  344. {
  345. EnableWindow(GetDlgItem(hDlg, WINDOW_COMBO), TRUE);
  346. }
  347. break;
  348. default:
  349. return FALSE;
  350. }
  351. break;
  352. default:
  353. return FALSE;
  354. }
  355. #endif
  356. return TRUE;
  357. }