Mercurial > gftp.yaz
diff src/text/textui.c @ 378:712d3810f4e1
2003-1-27 Brian Masney <masneyb@gftp.org>
* lib/gftp.h lib/misc.c src/gtk/gtkui_transfer.c src/text/textui.c -
added gftp_get_transfer_action(). When a file is to be transfered and
already exists, this will return the default action that should be
taken.
* src/text/textui.c (gftpui_ask_transfer) - implemented this function
so that whenever a file exists and is to be transfered, the user will
be prompted on whether or not to overwrite/skip/resume
* src/text/gftp-text.c (gftp_text_ask_question) - fixups for inputing
a single character
author | masneyb |
---|---|
date | Tue, 27 Jan 2004 23:48:26 +0000 |
parents | 14da115b149b |
children | 05ee37a5558b |
line wrap: on
line diff
--- a/src/text/textui.c Sat Jan 24 11:45:11 2004 +0000 +++ b/src/text/textui.c Tue Jan 27 23:48:26 2004 +0000 @@ -92,7 +92,79 @@ void gftpui_ask_transfer (gftp_transfer * tdata) { - /* FIXME */ + char buf, question[1024], srcsize[50], destsize[50], *pos, defaction; + int action, newaction; + gftp_file * tempfle; + GList * templist; + + action = newaction = -1; + + for (templist = tdata->files; templist != NULL; templist = templist->next) + { + tempfle = templist->data; + if (tempfle->startsize == 0 || tempfle->isdir) + continue; + + while (action == -1) + { + insert_commas (tempfle->size, srcsize, sizeof (srcsize)); + insert_commas (tempfle->startsize, destsize, sizeof (destsize)); + + if ((pos = strrchr (tempfle->file, '/')) != NULL) + pos++; + else + pos = tempfle->file; + + gftp_get_transfer_action (tdata->fromreq, tempfle); + switch (tempfle->transfer_action) + { + case GFTP_TRANS_ACTION_OVERWRITE: + action = GFTP_TRANS_ACTION_OVERWRITE; + defaction = 'o'; + break; + case GFTP_TRANS_ACTION_SKIP: + action = GFTP_TRANS_ACTION_SKIP; + defaction = 's'; + break; + case GFTP_TRANS_ACTION_RESUME: + action = GFTP_TRANS_ACTION_RESUME; + defaction = 'r'; + break; + default: + defaction = ' '; + break; + } + + g_snprintf (question, sizeof (question), _("%s already exists. (%s source size, %s destination size):\n(o)verwrite, (r)esume, (s)kip, (O)verwrite All, (R)esume All, (S)kip All: (%c)"), pos, srcsize, destsize, defaction); + + gftp_text_ask_question (question, 1, &buf, 1); + + switch (buf) + { + case 'o': + action = GFTP_TRANS_ACTION_OVERWRITE; + break; + case 'O': + action = newaction = GFTP_TRANS_ACTION_OVERWRITE; + break; + case 'r': + action = GFTP_TRANS_ACTION_RESUME; + break; + case 'R': + action = newaction = GFTP_TRANS_ACTION_RESUME; + break; + case 's': + action = GFTP_TRANS_ACTION_SKIP; + break; + case 'S': + action = newaction = GFTP_TRANS_ACTION_SKIP; + break; + } + } + + tempfle->transfer_action = action; + action = newaction; + } }