342
|
1 /*****************************************************************************/
|
|
2 /* textui.c - Text UI related functions for gFTP */
|
|
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
|
|
4 /* */
|
|
5 /* This program is free software; you can redistribute it and/or modify */
|
|
6 /* it under the terms of the GNU General Public License as published by */
|
|
7 /* the Free Software Foundation; either version 2 of the License, or */
|
|
8 /* (at your option) any later version. */
|
|
9 /* */
|
|
10 /* This program is distributed in the hope that it will be useful, */
|
|
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
13 /* GNU General Public License for more details. */
|
|
14 /* */
|
|
15 /* You should have received a copy of the GNU General Public License */
|
|
16 /* along with this program; if not, write to the Free Software */
|
|
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
|
|
18 /*****************************************************************************/
|
|
19
|
|
20 #include "gftp-text.h"
|
|
21 static const char cvsid[] = "$Id$";
|
|
22
|
|
23 void
|
|
24 gftpui_lookup_file_colors (gftp_file * fle, char **start_color,
|
|
25 char ** end_color)
|
|
26 {
|
|
27 if (*fle->attribs == 'd')
|
|
28 *start_color = GFTPUI_COMMON_COLOR_BLUE;
|
|
29 else if (*fle->attribs == 'l')
|
|
30 *start_color = GFTPUI_COMMON_COLOR_WHITE;
|
|
31 else if (strchr (fle->attribs, 'x') != NULL)
|
|
32 *start_color = GFTPUI_COMMON_COLOR_GREEN;
|
|
33 else
|
|
34 *start_color = GFTPUI_COMMON_COLOR_DEFAULT;
|
|
35
|
|
36 *end_color = GFTPUI_COMMON_COLOR_DEFAULT;
|
|
37 }
|
|
38
|
|
39
|
|
40 void
|
|
41 gftpui_refresh (void *uidata)
|
|
42 {
|
|
43 /* FIXME - clear the cache entry */
|
|
44 }
|
|
45
|
|
46
|
|
47 void *
|
|
48 gftpui_generic_thread (void * (*func) (void *), void *data)
|
|
49 {
|
367
|
50 return (func (data));
|
342
|
51 }
|
|
52
|
|
53
|
|
54 int
|
|
55 gftpui_check_reconnect (gftpui_callback_data * cdata)
|
|
56 {
|
|
57 return (1);
|
|
58 }
|
|
59
|
356
|
60
|
|
61 char *
|
|
62 gftpui_prompt_username (void *uidata, gftp_request * request)
|
|
63 {
|
|
64 char tempstr[256], *ret;
|
|
65
|
|
66 ret = g_strdup (gftp_text_ask_question (_("Username [anonymous]:"), 1,
|
|
67 tempstr, sizeof (tempstr)));
|
|
68 return (ret);
|
|
69 }
|
|
70
|
|
71
|
|
72
|
|
73 char *
|
|
74 gftpui_prompt_password (void *uidata, gftp_request * request)
|
|
75 {
|
|
76 char tempstr[256], *ret;
|
|
77
|
|
78 ret = g_strdup (gftp_text_ask_question (_("Password:"), 0,
|
|
79 tempstr, sizeof (tempstr)));
|
|
80 return (ret);
|
|
81 }
|
|
82
|
367
|
83
|
|
84 void
|
|
85 gftpui_add_file_to_transfer (gftp_transfer * tdata, GList * curfle,
|
377
|
86 char *filepos )
|
367
|
87 {
|
|
88 /* FIXME */
|
|
89 }
|
|
90
|
|
91
|
|
92 void
|
|
93 gftpui_ask_transfer (gftp_transfer * tdata)
|
|
94 {
|
|
95 /* FIXME */
|
|
96 }
|
|
97
|
377
|
98
|
|
99 static void
|
|
100 _gftpui_text_print_status (gftp_transfer * tdata)
|
|
101 {
|
|
102 static int progress_pos = 0;
|
|
103 char *progress = "|/-\\";
|
|
104 int sw, tot, i;
|
|
105
|
|
106 printf ("\r%c [", progress[progress_pos++]);
|
|
107
|
|
108 if (progress[progress_pos] == '\0')
|
|
109 progress_pos = 0;
|
|
110
|
|
111 sw = gftp_text_get_win_size () - 20;
|
|
112 tot = (float) tdata->curtrans / (float) tdata->tot_file_trans * (float) sw;
|
|
113
|
|
114 if (tot > sw)
|
|
115 tot = sw;
|
|
116
|
|
117 for (i=0; i<tot; i++)
|
|
118 printf ("=");
|
|
119
|
|
120 for (i=0; i<sw-tot; i++)
|
|
121 printf (" ");
|
|
122
|
|
123 printf ("] @ %.2fKB/s", tdata->kbs);
|
|
124
|
|
125 fflush (stdout);
|
|
126 }
|
|
127
|
|
128
|
|
129 void
|
|
130 gftpui_start_current_file_in_transfer (gftp_transfer * tdata)
|
|
131 {
|
|
132 _gftpui_text_print_status (tdata);
|
|
133 }
|
|
134
|
|
135
|
|
136 void
|
|
137 gftpui_update_current_file_in_transfer (gftp_transfer * tdata)
|
|
138 {
|
|
139 _gftpui_text_print_status (tdata);
|
|
140 }
|
|
141
|
|
142
|
|
143 void
|
|
144 gftpui_finish_current_file_in_transfer (gftp_transfer * tdata)
|
|
145 {
|
|
146 _gftpui_text_print_status (tdata);
|
|
147 printf ("\n");
|
|
148 }
|
|
149
|
|
150
|
|
151 void
|
|
152 gftpui_start_transfer (gftp_transfer * tdata)
|
|
153 {
|
|
154 gftpui_common_transfer_files (tdata);
|
|
155 }
|
|
156
|