home *** CD-ROM | disk | FTP | other *** search
- /*
- * Display the file transfer window, and invoke the transfer protocol.
- */
-
- #include <stdio.h>
- #include <curses.h>
- #include "dial_dir.h"
- #include "misc.h"
- #include "status.h"
- #include "xmodem.h"
-
- void
- xfer_win(list, up, type)
- char *list;
- int up, type;
- {
- WINDOW *xf_win, *newwin();
- int ret_code, fast, my_speed;
- void xmodem_mode(), input_off(), line_set(), error_win();
- struct termio tbuf;
-
- if (status->fd == -1) {
- error_win(0, "Not currently connected to any host", NULL);
- return;
- }
-
- xf_win = newwin(15, 44, 2, 30);
- /*
- * This window should be in the non-blocking mode, so we can
- * scan the keyboard for input while transferring a file.
- */
- nodelay(xf_win, 1);
- /* basic window stuff */
- mvwaddstr(xf_win, 2, 14, "Protocol:");
- mvwaddstr(xf_win, 3, 13, "File name:");
- mvwaddstr(xf_win, 4, 13, "File size:");
- mvwaddstr(xf_win, 5, 4, "Error check method:");
- mvwaddstr(xf_win, 6, 5, "Est transfer time:");
- mvwaddstr(xf_win, 7, 11, "Block count:");
- mvwaddstr(xf_win, 8, 6, "Percent complete:");
- mvwaddstr(xf_win, 9, 5, "Bytes transferred:");
- mvwaddstr(xf_win, 10, 5, "Errors this block:");
- mvwaddstr(xf_win, 11, 5, "Total error count:");
- mvwaddstr(xf_win, 12, 10, "Last message: NONE");
- box(xf_win, '|', '-');
-
- if (up)
- mvwattrstr(xf_win, 0, 17, A_BOLD, " Uploading ");
- else
- mvwattrstr(xf_win, 0, 16, A_BOLD, " Downloading ");
- mvwaddstr(xf_win, 14, 12, " Press ESC to abort ");
- wrefresh(xf_win);
- /* fix up the terminal mode */
- input_off();
- xmodem_mode(status->fd);
-
- /*
- * Is your terminal slower than the xfer baud rate? For example:
- * I'm at home with my PC and 1200 baud modem, I call my system
- * at work so I can use their 2400 baud modems to call some other
- * system. In this case, I don't wanna spend too much time updating
- * my screen at 1200 baud, when I'm transferring the file at 2400 baud.
- */
- my_speed = 0;
- fast = 0;
-
- ioctl(0, TCGETA, &tbuf);
- /* only reasonable values are here */
- switch(tbuf.c_cflag & CBAUD) {
- case B300:
- my_speed = 300;
- break;
- case B1200:
- my_speed = 1200;
- break;
- case B2400:
- my_speed = 2400;
- break;
- case B4800:
- my_speed = 4800;
- break;
- case B9600:
- my_speed = 9600;
- break;
- case B19200:
- my_speed = 19200;
- break;
- }
- if (my_speed >= dir->baud[dir->d_cur])
- fast++;
-
- if (up)
- ret_code = send_xmodem(xf_win, list, type, fast);
- else
- ret_code = rcv_xmodem(xf_win, list, type, fast);
-
- nodelay(xf_win, 0);
- /* prompt for a key on errors */
- if (ret_code) {
- beep();
- clear_line(xf_win, 13, 9, 1);
- wattrstr(xf_win, A_BOLD, "Press any key to continue");
- wrefresh(xf_win);
- wgetch(xf_win);
- }
- werase(xf_win);
- wrefresh(xf_win);
- delwin(xf_win);
- /* undo what xmodem_mode() did */
- line_set();
- return;
- }
-