annotate src/text/textui.c @ 685:cc98fe1b53b2

2005-2-4 Brian Masney <masneyb@gftp.org> * docs/website/announce.txt - updated announcement with release of 2.0.18
author masneyb
date Fri, 04 Feb 2005 16:14:54 +0000
parents 739afd9df73c
children 1ad4eb5c29de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1 /*****************************************************************************/
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
2 /* textui.c - Text UI related functions for gFTP */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
4 /* */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
9 /* */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
14 /* */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
18 /*****************************************************************************/
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
19
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
20 #include "gftp-text.h"
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
21 static const char cvsid[] = "$Id$";
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
22
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
23 void
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
24 gftpui_lookup_file_colors (gftp_file * fle, char **start_color,
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
25 char ** end_color)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
26 {
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
27 if (S_ISDIR (fle->st_mode))
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
28 *start_color = GFTPUI_COMMON_COLOR_BLUE;
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
29 else if (S_ISLNK (fle->st_mode))
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
30 *start_color = GFTPUI_COMMON_COLOR_WHITE;
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
31 else if ((fle->st_mode & S_IXUSR) ||
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
32 (fle->st_mode & S_IXGRP) ||
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
33 (fle->st_mode & S_IXOTH))
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
34 *start_color = GFTPUI_COMMON_COLOR_GREEN;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
35 else
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
36 *start_color = GFTPUI_COMMON_COLOR_DEFAULT;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
37
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
38 *end_color = GFTPUI_COMMON_COLOR_DEFAULT;
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
39 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
40
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
41
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
42 void
521
739afd9df73c 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 514
diff changeset
43 gftpui_refresh (void *uidata, int clear_cache_entry)
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
44 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
45 gftp_request * request;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
46
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
47 request = uidata; /* Note: uidata is set to the request in gftp_text.c */
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
48
521
739afd9df73c 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 514
diff changeset
49 if (clear_cache_entry)
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
50 gftp_delete_cache_entry (request, NULL, 0);
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
51 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
52
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
53
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
54 void *
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
55 gftpui_generic_thread (void * (*func) (void *), void *data)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
56 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
57 return (func (data));
342
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
58 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
59
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
60
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
61 int
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
62 gftpui_check_reconnect (gftpui_callback_data * cdata)
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
63 {
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
64 return (1);
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
65 }
07d635081926 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
66
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
67
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
68 void
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
69 gftpui_prompt_username (void *uidata, gftp_request * request)
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
70 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
71 char tempstr[256];
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
72
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
73 gftp_set_username (request,
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
74 gftp_text_ask_question (_("Username [anonymous]:"), 1,
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
75 tempstr, sizeof (tempstr)));
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
76 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
77
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
78
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
79
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
80 void
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
81 gftpui_prompt_password (void *uidata, gftp_request * request)
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
82 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
83 char tempstr[256];
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
84
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
85 gftp_set_password (request,
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
86 gftp_text_ask_question (_("Password:"), 0,
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
87 tempstr, sizeof (tempstr)));
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
88 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 342
diff changeset
89
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
90
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
91 void
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 387
diff changeset
92 gftpui_add_file_to_transfer (gftp_transfer * tdata, GList * curfle)
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
93 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
94 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
95
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
96
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
97 void
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
98 gftpui_ask_transfer (gftp_transfer * tdata)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
99 {
378
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
100 char buf, question[1024], srcsize[50], destsize[50], *pos, defaction;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
101 int action, newaction;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
102 gftp_file * tempfle;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
103 GList * templist;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
104
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
105 action = newaction = -1;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
106
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
107 for (templist = tdata->files; templist != NULL; templist = templist->next)
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
108 {
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
109 tempfle = templist->data;
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 484
diff changeset
110 if (tempfle->startsize == 0 || S_ISDIR (tempfle->st_mode))
378
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
111 continue;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
112
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
113 while (action == -1)
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
114 {
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
115 insert_commas (tempfle->size, srcsize, sizeof (srcsize));
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
116 insert_commas (tempfle->startsize, destsize, sizeof (destsize));
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
117
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
118 if ((pos = strrchr (tempfle->file, '/')) != NULL)
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
119 pos++;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
120 else
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
121 pos = tempfle->file;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
122
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
123 gftp_get_transfer_action (tdata->fromreq, tempfle);
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
124 switch (tempfle->transfer_action)
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
125 {
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
126 case GFTP_TRANS_ACTION_OVERWRITE:
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
127 action = GFTP_TRANS_ACTION_OVERWRITE;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
128 defaction = 'o';
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
129 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
130 case GFTP_TRANS_ACTION_SKIP:
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
131 action = GFTP_TRANS_ACTION_SKIP;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
132 defaction = 's';
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
133 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
134 case GFTP_TRANS_ACTION_RESUME:
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
135 action = GFTP_TRANS_ACTION_RESUME;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
136 defaction = 'r';
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
137 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
138 default:
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
139 defaction = ' ';
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
140 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
141 }
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
142
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
143 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);
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
144
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
145 gftp_text_ask_question (question, 1, &buf, 1);
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
146
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
147 switch (buf)
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
148 {
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
149 case 'o':
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
150 action = GFTP_TRANS_ACTION_OVERWRITE;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
151 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
152 case 'O':
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
153 action = newaction = GFTP_TRANS_ACTION_OVERWRITE;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
154 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
155 case 'r':
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
156 action = GFTP_TRANS_ACTION_RESUME;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
157 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
158 case 'R':
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
159 action = newaction = GFTP_TRANS_ACTION_RESUME;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
160 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
161 case 's':
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
162 action = GFTP_TRANS_ACTION_SKIP;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
163 break;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
164 case 'S':
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
165 action = newaction = GFTP_TRANS_ACTION_SKIP;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
166 break;
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
167 case '\0':
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
168 case '\n':
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
169 break;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
170 default:
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
171 action = -1;
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
172 break;
378
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
173 }
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
174 }
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
175
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
176 tempfle->transfer_action = action;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
177 action = newaction;
712d3810f4e1 2003-1-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
178 }
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
179 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
180
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
181
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
182 static void
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
183 _gftpui_text_print_status (gftp_transfer * tdata)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
184 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
185 static int progress_pos = 0;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
186 char *progress = "|/-\\";
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
187 int sw, tot, i;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
188
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
189 printf ("\r%c [", progress[progress_pos++]);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
190
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
191 if (progress[progress_pos] == '\0')
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
192 progress_pos = 0;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
193
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
194 sw = gftp_text_get_win_size () - 20;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
195 tot = (float) tdata->curtrans / (float) tdata->tot_file_trans * (float) sw;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
196
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
197 if (tot > sw)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
198 tot = sw;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
199
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
200 for (i=0; i<tot; i++)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
201 printf ("=");
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
202
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
203 for (i=0; i<sw-tot; i++)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
204 printf (" ");
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
205
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
206 printf ("] @ %.2fKB/s", tdata->kbs);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
207
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
208 fflush (stdout);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
209 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
210
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
211
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
212 void
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
213 gftpui_start_current_file_in_transfer (gftp_transfer * tdata)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
214 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
215 _gftpui_text_print_status (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
216 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
217
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
218
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
219 void
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
220 gftpui_update_current_file_in_transfer (gftp_transfer * tdata)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
221 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
222 _gftpui_text_print_status (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
223 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
224
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
225
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
226 void
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
227 gftpui_finish_current_file_in_transfer (gftp_transfer * tdata)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
228 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
229 _gftpui_text_print_status (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
230 printf ("\n");
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
231 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
232
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
233
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
234 void
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
235 gftpui_start_transfer (gftp_transfer * tdata)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
236 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
237 gftpui_common_transfer_files (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
238 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
239
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
240
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
241 void
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
242 gftpui_disconnect (void *uidata)
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
243 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
244 gftp_request * request;
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
245
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
246 request = uidata; /* Note: uidata is set to the request in gftp_text.c */
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
247 gftp_disconnect (request);
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
248 }
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 378
diff changeset
249
460
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
250
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
251 int
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
252 gftpui_protocol_ask_yes_no (gftp_request * request, char *title, char *question)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
253 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
254 char buf[10];
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
255 int ret;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
256
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
257 do
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
258 {
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
259 gftp_text_ask_question (question, 1, buf, sizeof (buf));
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
260 if (strcasecmp (buf, "yes") == 0)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
261 ret = 1;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
262 else if (strcasecmp (buf, "no") == 0)
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
263 ret = 0;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
264 else
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
265 ret = -1;
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
266 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
267 while (ret == -1);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
268
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
269 return (ret);
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
270 }
075f89b4395c 2004-4-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
271
484
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
272
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
273 char *
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
274 gftpui_protocol_ask_user_input (gftp_request * request, char *title,
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
275 char *question, int shown)
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
276 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
277 char buf[255];
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
278
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
279 do
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
280 {
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
281 gftp_text_ask_question (question, shown, buf, sizeof (buf));
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
282 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
283 while (*buf == '\0');
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
284
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
285 return (g_strdup (buf));
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
286 }
632036c6e4a4 2004-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 460
diff changeset
287