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.

652 lines
14 KiB

  1. /* xfr_dsp.c -- Transfer display functions
  2. *
  3. * Copyright 1990 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 4 $
  7. * $Date: 7/11/02 11:13a $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #define BYTE char
  12. #include <tdll\stdtyp.h>
  13. #include <tdll\session.h>
  14. #include <tdll\xfdspdlg.h>
  15. #include <tdll\xfer_msc.hh>
  16. #include <tdll\htchar.h>
  17. #include <tdll\assert.h>
  18. #include "xfr_dsp.h"
  19. #include "xfr_srvc.h"
  20. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. * FUNCTION:
  22. * xferMsgProgress
  23. *
  24. * DESCRIPTION:
  25. * This function is called by the transfer routines to update various parts
  26. * of the transfer display.
  27. *
  28. * PARAMETERS:
  29. * hSession -- the session handle
  30. * stime -- elapsed time (maybe)
  31. * ttime -- remaining time (maybe)
  32. * cps -- speed of transfer
  33. * file_so_far -- what it says
  34. * total_so_far -- what it says
  35. *
  36. * RETURNS:
  37. * Nothing.
  38. */
  39. void xferMsgProgress(HSESSION hSession,
  40. long stime,
  41. long ttime,
  42. long cps,
  43. long file_so_far,
  44. long total_so_far)
  45. {
  46. XD_TYPE *pX;
  47. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  48. if (pX)
  49. {
  50. if (stime != -1)
  51. {
  52. pX->lElapsedTime = stime;
  53. pX->bElapsedTime = 1;
  54. }
  55. if (ttime != -1)
  56. {
  57. pX->lRemainingTime = ttime;
  58. pX->bRemainingTime = 1;
  59. }
  60. if (cps != -1)
  61. {
  62. pX->lThroughput = cps;
  63. pX->bThroughput = 1;
  64. }
  65. if (file_so_far != -1)
  66. {
  67. pX->lFileSoFar = file_so_far;
  68. pX->bFileSoFar = 1;
  69. }
  70. if (total_so_far != -1)
  71. {
  72. pX->lTotalSoFar = total_so_far;
  73. pX->bTotalSoFar = 1;
  74. }
  75. if (IsWindow(pX->hwndXfrDisplay))
  76. {
  77. PostMessage(pX->hwndXfrDisplay,
  78. WM_DLG_TO_DISPLAY,
  79. XFR_UPDATE_DLG, 0);
  80. }
  81. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  82. }
  83. }
  84. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  85. * FUNCTION:
  86. * xferMsgNewfile
  87. *
  88. * DESCRIPTION:
  89. * This function is called by the transfer routines to update various parts
  90. * of the transfer display.
  91. *
  92. * PARAMETERS:
  93. * hSession -- the session handle
  94. * filen -- the file number
  95. * theirname -- an ASCII copy of their name (TODO: convert to UNICODE)
  96. * ourname -- a copy of the filename as we used it
  97. *
  98. * RETURNS:
  99. * Nothing.
  100. */
  101. void xferMsgNewfile(HSESSION hSession,
  102. int filen,
  103. BYTE *theirname,
  104. TCHAR *ourname)
  105. {
  106. XD_TYPE *pX;
  107. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  108. assert(pX);
  109. if (pX)
  110. {
  111. pX->wFileCnt = (WORD)filen;
  112. pX->bFileCnt = 1;
  113. if (theirname != NULL)
  114. {
  115. StrCharCopyN(pX->acTheirName, theirname, XFER_NAME_LENGTH);
  116. pX->bTheirName = 1;
  117. }
  118. //assert(pX->bTheirName == 1);
  119. if (ourname != NULL)
  120. {
  121. StrCharCopyN(pX->acOurName, ourname, XFER_NAME_LENGTH);
  122. pX->bOurName = 1;
  123. }
  124. if (IsWindow(pX->hwndXfrDisplay))
  125. {
  126. PostMessage(pX->hwndXfrDisplay,
  127. WM_DLG_TO_DISPLAY,
  128. XFR_UPDATE_DLG, 0);
  129. }
  130. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  131. }
  132. }
  133. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  134. * FUNCTION:
  135. * xferMsgFilesize
  136. *
  137. * DESCRIPTION:
  138. * This function is called by the transfer routines to update various parts
  139. * of the transfer display.
  140. *
  141. * PARAMETERS:
  142. * hSession -- the session handle
  143. * fsize -- the size of the current file
  144. *
  145. * RETURNS:
  146. * Nothing.
  147. */
  148. void xferMsgFilesize(HSESSION hSession, long fsize)
  149. {
  150. XD_TYPE *pX;
  151. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  152. if (pX)
  153. {
  154. pX->lFileSize = (LONG)fsize;
  155. pX->bFileSize = 1;
  156. pX->lFileSoFar = 0;
  157. pX->bFileSoFar = 1;
  158. if (IsWindow(pX->hwndXfrDisplay))
  159. {
  160. PostMessage(pX->hwndXfrDisplay,
  161. WM_DLG_TO_DISPLAY,
  162. XFR_UPDATE_DLG, 0);
  163. }
  164. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  165. }
  166. }
  167. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  168. * FUNCTION:
  169. * xferMsgStatus
  170. *
  171. * DESCRIPTION:
  172. * This function is called by the transfer routines to update various parts
  173. * of the transfer display.
  174. *
  175. * PARAMETERS:
  176. * hSession -- the session handle
  177. * status -- a protocol specific status code
  178. *
  179. * RETURNS:
  180. * Nothing.
  181. */
  182. void xferMsgStatus(HSESSION hSession, int status)
  183. {
  184. XD_TYPE *pX;
  185. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  186. if (pX)
  187. {
  188. pX->wStatus = (WORD)status;
  189. pX->bStatus = 1;
  190. if (IsWindow(pX->hwndXfrDisplay))
  191. {
  192. PostMessage(pX->hwndXfrDisplay,
  193. WM_DLG_TO_DISPLAY,
  194. XFR_UPDATE_DLG, 0);
  195. }
  196. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  197. }
  198. }
  199. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  200. * FUNCTION:
  201. * xferMsgEvent
  202. *
  203. * DESCRIPTION:
  204. * This function is called by the transfer routines to update various parts
  205. * of the transfer display.
  206. *
  207. * PARAMETERS:
  208. * hSession -- the session handle
  209. * event -- a protocol specific event code
  210. *
  211. * RETURNS:
  212. * Nothing.
  213. */
  214. void xferMsgEvent(HSESSION hSession, int event)
  215. {
  216. XD_TYPE *pX;
  217. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  218. if (pX)
  219. {
  220. pX->wEvent = (WORD)event;
  221. pX->bEvent = 1;
  222. if (IsWindow(pX->hwndXfrDisplay))
  223. {
  224. PostMessage(pX->hwndXfrDisplay,
  225. WM_DLG_TO_DISPLAY,
  226. XFR_UPDATE_DLG, 0);
  227. }
  228. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  229. }
  230. }
  231. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  232. * FUNCTION:
  233. * xferMsgErrorcnt
  234. *
  235. * DESCRIPTION:
  236. * This function is called by the transfer routines to update various parts
  237. * of the transfer display.
  238. *
  239. * PARAMETERS:
  240. * hSession -- the session handle
  241. * cnt -- the new number of errors to display
  242. *
  243. * RETURNS:
  244. * Nothing.
  245. */
  246. void xferMsgErrorcnt(HSESSION hSession, int cnt)
  247. {
  248. XD_TYPE *pX;
  249. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  250. if (pX)
  251. {
  252. pX->wErrorCnt = (WORD)cnt;
  253. pX->bErrorCnt = 1;
  254. if (IsWindow(pX->hwndXfrDisplay))
  255. {
  256. PostMessage(pX->hwndXfrDisplay,
  257. WM_DLG_TO_DISPLAY,
  258. XFR_UPDATE_DLG, 0);
  259. }
  260. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  261. }
  262. }
  263. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  264. * FUNCTION:
  265. * xferMsgFilecnt
  266. *
  267. * DESCRIPTION:
  268. * This function is called by the transfer routines to update various parts
  269. * of the transfer display.
  270. *
  271. * PARAMETERS:
  272. * hSession -- the session handle
  273. * cnt -- the total number of files in the transfer
  274. *
  275. * RETURNS:
  276. * Nothing.
  277. */
  278. void xferMsgFilecnt(HSESSION hSession, int cnt)
  279. {
  280. XD_TYPE *pX;
  281. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  282. if (pX)
  283. {
  284. pX->wTotalCnt = (WORD)cnt;
  285. pX->bTotalCnt = 1;
  286. if (IsWindow(pX->hwndXfrDisplay))
  287. {
  288. PostMessage(pX->hwndXfrDisplay,
  289. WM_DLG_TO_DISPLAY,
  290. XFR_UPDATE_DLG, 0);
  291. }
  292. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  293. }
  294. }
  295. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  296. * FUNCTION:
  297. * xferMsgTotalsize
  298. *
  299. * DESCRIPTION:
  300. * This function is called by the transfer routines to update various parts
  301. * of the transfer display.
  302. *
  303. * PARAMETERS:
  304. * hSession -- the session handle
  305. * bytes -- the total size of all the files in the transfer operation
  306. *
  307. * RETURNS:
  308. * Nothing.
  309. */
  310. void xferMsgTotalsize(HSESSION hSession, long bytes)
  311. {
  312. XD_TYPE *pX;
  313. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  314. if (pX)
  315. {
  316. pX->lTotalSize = (LONG)bytes;
  317. pX->bTotalSize = 1;
  318. if (IsWindow(pX->hwndXfrDisplay))
  319. {
  320. PostMessage(pX->hwndXfrDisplay,
  321. WM_DLG_TO_DISPLAY,
  322. XFR_UPDATE_DLG, 0);
  323. }
  324. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  325. }
  326. }
  327. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  328. * FUNCTION:
  329. * xferMsgClose
  330. *
  331. * DESCRIPTION:
  332. * This function is called by the transfer routines to update various parts
  333. * of the transfer display. This function is actually called to indicate
  334. * that a transfer is finished.
  335. *
  336. * PARAMETERS:
  337. * hSession -- the session handle
  338. *
  339. * RETURNS:
  340. * Nothing.
  341. */
  342. void xferMsgClose(HSESSION hSession)
  343. {
  344. XD_TYPE *pX;
  345. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  346. if (pX)
  347. {
  348. pX->nClose = TRUE;
  349. if (IsWindow(pX->hwndXfrDisplay))
  350. {
  351. PostMessage(pX->hwndXfrDisplay,
  352. WM_DLG_TO_DISPLAY,
  353. XFR_UPDATE_DLG, 0);
  354. }
  355. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  356. }
  357. }
  358. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  359. * FUNCTION:
  360. * xferMsgChecktype
  361. *
  362. * DESCRIPTION:
  363. * This function is called by the transfer routines to update various parts
  364. * of the transfer display.
  365. *
  366. * PARAMETERS:
  367. * hSession -- the session handle
  368. * ctype -- indicates the current checksum type
  369. *
  370. * RETURNS:
  371. * Nothing.
  372. */
  373. void xferMsgChecktype(HSESSION hSession, int ctype)
  374. {
  375. XD_TYPE *pX;
  376. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  377. if (pX)
  378. {
  379. pX->wChecktype = (WORD)ctype;
  380. pX->bChecktype = 1;
  381. if (IsWindow(pX->hwndXfrDisplay))
  382. {
  383. PostMessage(pX->hwndXfrDisplay,
  384. WM_DLG_TO_DISPLAY,
  385. XFR_UPDATE_DLG, 0);
  386. }
  387. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  388. }
  389. }
  390. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  391. * FUNCTION:
  392. * xferMsgPacketnumber
  393. *
  394. * DESCRIPTION:
  395. * This function is called by the transfer routines to update various parts
  396. * of the transfer display.
  397. *
  398. * PARAMETERS:
  399. * hSession -- the session handle
  400. * number -- the current packet number
  401. *
  402. * RETURNS:
  403. * Nothing.
  404. */
  405. void xferMsgPacketnumber(HSESSION hSession, long number)
  406. {
  407. XD_TYPE *pX;
  408. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  409. if (pX)
  410. {
  411. pX->lPacketNumber = number;
  412. pX->bPacketNumber = 1;
  413. if (IsWindow(pX->hwndXfrDisplay))
  414. {
  415. PostMessage(pX->hwndXfrDisplay,
  416. WM_DLG_TO_DISPLAY,
  417. XFR_UPDATE_DLG, 0);
  418. }
  419. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  420. }
  421. }
  422. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  423. * FUNCTION:
  424. * xfrMsgLasterror
  425. *
  426. * DESCRIPTION:
  427. * This function is called by the transfer routines to update various parts
  428. * of the transfer display.
  429. *
  430. * PARAMETERS:
  431. * hSession -- the session handle
  432. * event -- indicates the last error type for a specific protocol
  433. *
  434. * RETURNS:
  435. * Nothing.
  436. */
  437. void xferMsgLasterror(HSESSION hSession, int event)
  438. {
  439. XD_TYPE *pX;
  440. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  441. if (pX)
  442. {
  443. pX->wLastErrtype = (WORD)event;
  444. pX->bLastErrtype = 1;
  445. if (IsWindow(pX->hwndXfrDisplay))
  446. {
  447. PostMessage(pX->hwndXfrDisplay,
  448. WM_DLG_TO_DISPLAY,
  449. XFR_UPDATE_DLG, 0);
  450. }
  451. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  452. }
  453. }
  454. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  455. * FUNCTION:
  456. * xferMsgPacketErrcnt
  457. *
  458. * DESCRIPTION:
  459. * This function is called by the transfer routines to update various parts
  460. * of the transfer display.
  461. *
  462. * PARAMETERS:
  463. * hSession -- the session handle
  464. * ecount -- indicates the number of errors in the current packet
  465. *
  466. * RETURNS:
  467. * Nothing.
  468. */
  469. void xferMsgPacketErrcnt(HSESSION hSession, int ecount)
  470. {
  471. XD_TYPE *pX;
  472. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  473. if (pX)
  474. {
  475. pX->wPcktErrCnt = (WORD)ecount;
  476. pX->bPcktErrCnt = 1;
  477. if (IsWindow(pX->hwndXfrDisplay))
  478. {
  479. PostMessage(pX->hwndXfrDisplay,
  480. WM_DLG_TO_DISPLAY,
  481. XFR_UPDATE_DLG, 0);
  482. }
  483. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  484. }
  485. }
  486. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  487. * FUNCTION:
  488. * xferMsgProtocol
  489. *
  490. * DESCRIPTION:
  491. * This function is called by the transfer routines to update various parts
  492. * of the transfer display.
  493. *
  494. * PARAMETERS:
  495. * hSession -- the session handle
  496. * nProtocol -- which CSB protocol is being used
  497. *
  498. * RETURNS:
  499. * Nothing.
  500. */
  501. void xferMsgProtocol(HSESSION hSession, int nProtocol)
  502. {
  503. XD_TYPE *pX;
  504. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  505. if (pX)
  506. {
  507. switch (nProtocol)
  508. {
  509. default:
  510. pX->uProtocol = 0;
  511. break;
  512. case 0:
  513. pX->uProtocol = 1;
  514. break;
  515. case 1:
  516. pX->uProtocol = 2;
  517. break;
  518. }
  519. pX->bProtocol = 1;
  520. if (IsWindow(pX->hwndXfrDisplay))
  521. {
  522. PostMessage(pX->hwndXfrDisplay,
  523. WM_DLG_TO_DISPLAY,
  524. XFR_UPDATE_DLG, 0);
  525. }
  526. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  527. }
  528. }
  529. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  530. * FUNCTION:
  531. * xferMsgMessage
  532. *
  533. * DESCRIPTION:
  534. * This function is called by the transfer routines to update various parts
  535. * of the transfer display.
  536. *
  537. * PARAMETERS:
  538. * hSession -- the session handle
  539. * pszMsg -- pointer to the CSP ASCII message string (TODO: convert)
  540. *
  541. * RETURNS:
  542. * Nothing.
  543. */
  544. void xferMsgMessage(HSESSION hSession, BYTE *pszMsg)
  545. {
  546. XD_TYPE *pX;
  547. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  548. if (pX)
  549. {
  550. // _fmemset(pW->acMessage, 0, sizeof(pW->acMessage));
  551. // _fstrncpy(pW->acMessage, pszMsg, sizeof(pW->acMessage) - 1);
  552. StrCharCopyN(pX->acMessage, pszMsg, XFER_MESSAGE_LENGTH);
  553. pX->bMessage = 1;
  554. if (IsWindow(pX->hwndXfrDisplay))
  555. {
  556. PostMessage(pX->hwndXfrDisplay,
  557. WM_DLG_TO_DISPLAY,
  558. XFR_UPDATE_DLG, 0);
  559. }
  560. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  561. }
  562. }
  563. #if FALSE
  564. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  565. * FUNCTION:
  566. *
  567. * DESCRIPTION:
  568. * This function is called by the transfer routines to update various parts
  569. * of the transfer display.
  570. *
  571. * PARAMETERS:
  572. * hSession -- the session handle
  573. *
  574. * RETURNS:
  575. * Nothing.
  576. */
  577. void xferMsg(HSESSION hSession)
  578. {
  579. XD_TYPE *pX;
  580. pX = (XD_TYPE *)sessQueryXferHdl(hSession);
  581. if (pX)
  582. {
  583. if (IsWindow(pX->hwndXfrDisplay))
  584. {
  585. PostMessage(pX->hwndXfrDisplay,
  586. WM_DLG_TO_DISPLAY,
  587. XFR_UPDATE_DLG, 0);
  588. }
  589. xfer_idle(hSession, XFER_IDLE_DISPLAY);
  590. }
  591. }
  592. #endif