annotate src/gtk/transfer.c @ 43:36e2868ce8b7

2002-10-30 Brian Masney <masneyb@gftp.org> * src/gtk/transfer.c (getdir_thread) - set use_jmp_environment to 0 instead of 1 * src/gtk/misc-gtk.c (signal_handler) - if use_jmp_environment is 0, and SIGINT is received, terminate the program
author masneyb
date Wed, 30 Oct 2002 22:34:15 +0000
parents cd169e4789df
children 311e29c40ed6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2 /* transfer.c - functions to handle transfering files */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 #include <gftp-gtk.h>
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
21 static const char cvsid[] = "$Id$";
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
23 static void *getdir_thread ( void *data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24 static void *connect_thread ( void *data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
25 static void on_next_transfer ( gftp_transfer * tdata );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
26 static void show_transfer ( gftp_transfer * tdata );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
27 static void transfer_done ( GList * node );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
28 static void create_transfer ( gftp_transfer * tdata );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
29 static void update_file_status ( gftp_transfer * tdata );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
30 static void trans_selectall ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
31 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
32 static void trans_unselectall ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
33 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
34 static void overwrite ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
35 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
36 static void resume ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
37 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
38 static void skip ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
39 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
40 static void ok ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
41 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
42 static void cancel ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
43 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
44 static void gftp_gtk_calc_kbs ( gftp_transfer * tdata,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
45 ssize_t num_read );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
46 static void check_done_process ( void );
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
47 static void do_upload ( gftp_viewedit_data * ve_proc,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
48 gftp_dialog_data * ddata );
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
49 static void dont_upload ( gftp_viewedit_data * ve_proc,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
50 gftp_dialog_data * ddata );
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
51 static void free_edit_data ( gftp_viewedit_data *ve_proc );
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
52 static int get_status ( gftp_transfer * tdata,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
53 ssize_t num_read );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
54 static void wakeup_main_thread ( gpointer data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
55 gint source,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
56 GdkInputCondition condition );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
57 static gint setup_wakeup_main_thread ( gftp_request * request );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
58 static void teardown_wakeup_main_thread ( gftp_request * request,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
59 gint handler );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
60 static mode_t parse_attribs ( char *attribs );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
61 static void remove_file ( char *filename );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
62
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
63 static GtkWidget * dialog;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
64
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
65 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
66 ftp_list_files (gftp_window_data * wdata, int usecache)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
67 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
68 guint handler;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
69 void *success;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
70
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
71 gtk_label_set (GTK_LABEL (wdata->hoststxt), _("Receiving file names..."));
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
72 if (gftp_is_started)
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
73 fix_display ();
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
74
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
75 wdata->show_selected = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
76 if (wdata->files == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78 if (check_reconnect (wdata) < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81 gtk_clist_freeze (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
82 wdata->request->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
83 if (wdata->request->use_threads)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
84 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
85 gtk_widget_set_sensitive (stop_btn, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
86
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
87 handler = setup_wakeup_main_thread (wdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
88 pthread_create (&wdata->tid, NULL, getdir_thread, wdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
89 while (wdata->request->stopable)
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
90 {
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
91 GDK_THREADS_LEAVE ();
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
92 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
93 g_main_iteration (TRUE);
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
94 #else
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
95 g_main_context_iteration (NULL, TRUE);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
96 #endif
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
97 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
98 teardown_wakeup_main_thread (wdata->request, handler);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
99
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
100 pthread_join (wdata->tid, &success);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
101 gtk_widget_set_sensitive (stop_btn, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
102 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104 success = getdir_thread (wdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 wdata->files = success;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 gtk_clist_thaw (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107 memset (&wdata->tid, 0, sizeof (wdata->tid));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110 if (wdata->files == NULL || !GFTP_IS_CONNECTED (wdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
111 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112 disconnect (wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 wdata->sorted = 0;
37
5a178bd04ca5 2002-10-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 36
diff changeset
117 sortrows (GTK_CLIST (wdata->listbox), *wdata->sortcol, (gpointer) wdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 if (IS_NONE_SELECTED (wdata))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119 gtk_clist_select_row (GTK_CLIST (wdata->listbox), 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 return (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 static void *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 getdir_thread (void * data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 int sj, havedotdot, got;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 gftp_request * request;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 gftp_file * fle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130 GList * files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132 request = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 request->user_data = (void *) 0x1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 if (request->use_threads)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 {
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
137 sj = sigsetjmp (jmp_environment, 1);
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
138 use_jmp_environment = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141 sj = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
142
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
143 files = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
144 if (sj == 0 || sj == 2)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
145 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
146 if (gftp_list_files (request) != 0 || !GFTP_IS_CONNECTED (request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
147 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
148 if (request->use_threads)
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
149 use_jmp_environment = 0;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
150
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
151 request->user_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 request->stopable = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 if (request->wakeup_main_thread[1] > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
154 write (request->wakeup_main_thread[1], " ", 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
155 return (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
157
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158 request->gotbytes = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159 havedotdot = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160 fle = g_malloc0 (sizeof (*fle));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
161 while ((got = gftp_get_next_file (request, NULL, fle)) > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 request->gotbytes += got;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 if (strcmp (fle->file, ".") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 gftp_file_destroy (fle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
167 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169 else if (strcmp (fle->file, "..") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170 havedotdot = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172 files = g_list_append (files, fle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 fle = g_malloc0 (sizeof (*fle));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 g_free (fle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 if (!GFTP_IS_CONNECTED (request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 if (request->use_threads)
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
180 use_jmp_environment = 0;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
181
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 request->user_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183 request->stopable = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184 if (request->wakeup_main_thread[1] > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 write (request->wakeup_main_thread[1], " ", 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 return (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 gftp_end_transfer (request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 request->gotbytes = -1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 if (!havedotdot)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 fle = g_malloc0 (sizeof (*fle));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 fle->file = g_malloc (3);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 strcpy (fle->file, "..");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 fle->user = g_malloc0 (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 fle->group = g_malloc0 (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 fle->attribs = g_malloc0 (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 *fle->attribs = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 fle->isdir = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 files = g_list_prepend (files, fle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 request->user_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 if (request->use_threads)
43
36e2868ce8b7 2002-10-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 42
diff changeset
208 use_jmp_environment = 0;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
209
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 request->stopable = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 if (request->wakeup_main_thread[1] > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 write (request->wakeup_main_thread[1], " ", 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 return (files);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
217 static void
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
218 try_connect_again (gftp_request * request, gftp_dialog_data * ddata)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
219 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
220 gftp_set_password (request, gtk_entry_get_text (GTK_ENTRY (ddata->edit)));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
221 request->stopable = 0;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
222 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
223
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
224
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
225 static void
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
226 dont_connect_again (gftp_request * request, gftp_dialog_data * ddata)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
227 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
228 request->stopable = 0;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
229 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
230
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
231
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233 ftp_connect (gftp_window_data * wdata, gftp_request * request, int getdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 int success;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 guint handler;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 void *ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 ret = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 if (wdata->request == request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 gtk_label_set (GTK_LABEL (wdata->hoststxt), _("Connecting..."));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 2
diff changeset
245 if (request->need_userpass && request->username != NULL &&
5551ab2301fe * Fixed a DND crash
masneyb
parents: 2
diff changeset
246 *request->username != '\0' &&
5551ab2301fe * Fixed a DND crash
masneyb
parents: 2
diff changeset
247 (request->password == NULL || *request->password == '\0'))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 if (wdata && wdata->request == request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 request->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 MakeEditDialog (_("Enter Password"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 _("Please enter your password for this site"), NULL,
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
254 0, NULL, gftp_dialog_button_connect,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
255 try_connect_again, request,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
256 dont_connect_again, request);
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
257
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 while (request->stopable)
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
259 {
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
260 GDK_THREADS_LEAVE ();
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
261 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
262 g_main_iteration (TRUE);
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
263 #else
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
264 g_main_context_iteration (NULL, TRUE);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
265 #endif
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
266 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 if (GFTP_GET_PASSWORD (request) == NULL ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269 *GFTP_GET_PASSWORD (request) == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
271 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
272 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
273 gftp_set_password (request, "");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
275
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 if (wdata && wdata->request == request && request->use_threads)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
278 request->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279 if (wdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
280 gtk_clist_freeze (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
281 gtk_widget_set_sensitive (stop_btn, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
282 pthread_create (&wdata->tid, NULL, connect_thread, request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
283
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
284 handler = setup_wakeup_main_thread (wdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
285 while (request->stopable)
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
286 {
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
287 GDK_THREADS_LEAVE ();
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
288 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
289 g_main_iteration (TRUE);
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
290 #else
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
291 g_main_context_iteration (NULL, TRUE);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
292 #endif
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
293 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
294 pthread_join (wdata->tid, &ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
295 teardown_wakeup_main_thread (wdata->request, handler);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
296
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
297 gtk_widget_set_sensitive (stop_btn, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
298 if (wdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
299 gtk_clist_thaw (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
300 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
301 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
302 ret = connect_thread (request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
303 success = (int) ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
304 memset (&wdata->tid, 0, sizeof (wdata->tid));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
305
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
306 if (!GFTP_IS_CONNECTED (wdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
307 disconnect (wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
308 else if (success)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
309 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
310 ftp_list_files (wdata, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
311 if (!GFTP_IS_CONNECTED (wdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
312 disconnect (wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
313 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
314
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
315 return (success);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
316 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
317
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
318
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
319 static void *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
320 connect_thread (void *data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
321 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
322 static int conn_num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
323 gftp_request * request;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
324 int ret, sj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
325
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
326 request = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
327 request->user_data = (void *) 0x1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
328
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
329 conn_num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
330 if (request->use_threads)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
331 {
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
332 sj = sigsetjmp (jmp_environment, 1);
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
333 use_jmp_environment = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
334 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
335 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
336 sj = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
337
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
338 ret = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
339 if (sj != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
340 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
341 ret = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
342 gftp_disconnect (request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
343 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
344
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
345 while (sj != 1 && (request->retries == 0 || conn_num < request->retries))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
346 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
347 conn_num++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
348 if (request->network_timeout > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
349 alarm (request->network_timeout);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
350 ret = gftp_connect (request) == 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
351 alarm (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
352
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
353 if (ret)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
354 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
355 else if (request->retries == 0 || conn_num < request->retries)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
356 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
357 request->logging_function (gftp_logging_misc, request->user_data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
358 _("Waiting %d seconds until trying to connect again\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
359 request->sleep_time);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
360 alarm (request->sleep_time);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
361 pause ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
363 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
364
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365 if (request->use_threads)
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
366 use_jmp_environment = 0;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368 request->user_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
369 request->stopable = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
370 if (request->wakeup_main_thread[1] > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
371 write (request->wakeup_main_thread[1], " ", 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
372 return ((void *) ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
373 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
374
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
375
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
376 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
377 get_files (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
378 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
379 transfer_window_files (&window2, &window1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
380 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
381
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
382
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
383 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384 put_files (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386 transfer_window_files (&window1, &window2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 transfer_window_files (gftp_window_data * fromwdata, gftp_window_data * towdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
393 gftp_file * tempfle, * newfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
394 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395 gftp_transfer * transfer;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 guint timeout_num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397 void *ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398 int num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 if (!check_status (_("Transfer Files"), fromwdata, 1, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401 towdata->request->put_file != NULL && fromwdata->request->get_file != NULL))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
402 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
403
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404 if (!GFTP_IS_CONNECTED (fromwdata->request) ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
405 !GFTP_IS_CONNECTED (towdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
407 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
408 _("Retrieve Files: Not connected to a remote site\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
409 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
410 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
411
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
412 if (check_reconnect (fromwdata) < 0 || check_reconnect (towdata) < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
413 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
414
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
415 transfer = g_malloc0 (sizeof (*transfer));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
416 transfer->fromreq = copy_request (fromwdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417 transfer->toreq = copy_request (towdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
418 transfer->transfer_direction = fromwdata == &window2 ?
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
419 GFTP_DIRECTION_DOWNLOAD : GFTP_DIRECTION_UPLOAD;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
420 transfer->fromwdata = fromwdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
421 transfer->towdata = towdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
422
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
423 num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
424 templist = GTK_CLIST (fromwdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
425 filelist = fromwdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
426 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
427 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
428 templist = get_next_selection (templist, &filelist, &num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
429 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
430 if (strcmp (tempfle->file, "..") != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
431 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
432 newfle = copy_fdata (tempfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
433 transfer->files = g_list_append (transfer->files, newfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
434 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
435 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
436
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
437 if (transfer->files != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
438 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
439 swap_socks (transfer->fromreq, fromwdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
440 swap_socks (transfer->toreq, towdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
441
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
442 if (transfer->fromreq->use_threads ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
443 (transfer->toreq && transfer->toreq->use_threads))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
444 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
445 transfer->fromreq->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
446 pthread_create (&fromwdata->tid, NULL, do_getdir_thread, transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
447
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
448 timeout_num = gtk_timeout_add (100, progress_timeout, transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
449
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
450 while (transfer->fromreq->stopable)
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
451 {
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
452 GDK_THREADS_LEAVE ();
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
453 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
454 g_main_iteration (TRUE);
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
455 #else
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
456 g_main_context_iteration (NULL, TRUE);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
457 #endif
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
458 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
459
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
460 gtk_timeout_remove (timeout_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
461 transfer->numfiles = transfer->numdirs = -1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
462 update_directory_download_progress (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
463
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
464 pthread_join (fromwdata->tid, &ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
465 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
466 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
467 ret = do_getdir_thread (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
468
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
469 if (!GFTP_IS_CONNECTED (transfer->fromreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
470 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
471 disconnect (fromwdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
472 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
473 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
474
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
475 if (!GFTP_IS_CONNECTED (transfer->toreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
476 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
477 disconnect (towdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
478 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
479 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
480
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
481 swap_socks (fromwdata->request, transfer->fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
482 swap_socks (towdata->request, transfer->toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
483 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
484
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
485 if (transfer->files != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
486 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
487 add_file_transfer (transfer->fromreq, transfer->toreq,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
488 transfer->fromwdata, transfer->towdata,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
489 transfer->files, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
490 g_free (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
491 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
492 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
493 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
494 if (transfer->statmutex)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
495 pthread_mutex_destroy (transfer->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
496 if (transfer->structmutex)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
497 pthread_mutex_destroy (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
498 free_tdata (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
499 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
500 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
501
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
502 void *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
503 do_getdir_thread (void * data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
504 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
505 gftp_transfer * transfer;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
506 int success, sj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
507
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
508 transfer = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
509 transfer->fromreq->user_data = (void *) 0x01;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
510 if (transfer->toreq)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
511 transfer->toreq->user_data = (void *) 0x01;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
512
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
513 if (transfer->fromreq->use_threads ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
514 (transfer->toreq && transfer->toreq->use_threads))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
515 {
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
516 sj = sigsetjmp (jmp_environment, 1);
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
517 use_jmp_environment = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
518 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
519 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
520 sj = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
521
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
522 success = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
523 if (sj == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
524 success = gftp_get_all_subdirs (transfer, NULL) == 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
525 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
526 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
527 gftp_disconnect (transfer->fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
528 if (transfer->toreq)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
529 gftp_disconnect (transfer->toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
530 transfer->fromreq->logging_function (gftp_logging_error,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
531 transfer->fromreq->user_data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
532 _("Operation canceled\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
533 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
534
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
535 if (transfer->fromreq->use_threads ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
536 (transfer->toreq && transfer->toreq->use_threads))
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
537 use_jmp_environment = 0;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
538
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
539 transfer->fromreq->user_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
540 if (transfer->toreq)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
541 transfer->toreq->user_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
542 transfer->fromreq->stopable = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
543 return ((void *) success);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
544 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
545
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
546
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
547
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
548 void *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
549 gftp_gtk_transfer_files (void *data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
550 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
551 gftp_transfer * transfer;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
552 char *tempstr, buf[8192];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
553 FILE * tofd, * fromfd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
554 off_t fromsize, total;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
555 gftp_file * curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
556 ssize_t num_read;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
557 int i, mode;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
558
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
559 pthread_detach (pthread_self ());
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
560 transfer = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
561 transfer->fromreq->user_data = (void *) 0x1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
562 transfer->toreq->user_data = (void *) 0x1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
563 transfer->curfle = transfer->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
564 gettimeofday (&transfer->starttime, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
565 memcpy (&transfer->lasttime, &transfer->starttime,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
566 sizeof (transfer->lasttime));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
567 while (transfer->curfle != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
568 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
569 pthread_mutex_lock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
570 curfle = transfer->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
571 transfer->current_file_number++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
572 pthread_mutex_unlock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
573
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
574 if (curfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
575 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
576 pthread_mutex_lock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
577 transfer->next_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
578 transfer->curfle = transfer->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
579 pthread_mutex_unlock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
580 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
581 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
582
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
583 fromsize = -1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
584 if (gftp_connect (transfer->fromreq) == 0 &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
585 gftp_connect (transfer->toreq) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
586 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
587 if (curfle->isdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
588 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
589 if (transfer->toreq->mkdir != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
590 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
591 transfer->toreq->mkdir (transfer->toreq, curfle->destfile);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
592 if (!GFTP_IS_CONNECTED (transfer->toreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
593 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
594 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
595
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
596 pthread_mutex_lock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
597 transfer->next_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
598 transfer->curfle = transfer->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
599 pthread_mutex_unlock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
600 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
601 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
602
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
603 if (transfer->fromreq->maxkbs > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
604 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
605 transfer->fromreq->logging_function (gftp_logging_misc,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
606 transfer->fromreq->user_data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
607 _("File transfer will be throttled to %.2f KB/s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
608 transfer->fromreq->maxkbs);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
609 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
610
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
611 if (curfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
612 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
613 if (transfer->transfer_direction == GFTP_DIRECTION_DOWNLOAD)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
614 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
615 tofd = curfle->fd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
616 fromfd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
617 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
618 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
619 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
620 tofd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
621 fromfd = curfle->fd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
622 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
623 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
624 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
625 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
626 tofd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
627 fromfd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
628 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
629
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
630 if (curfle->size == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
631 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
632 curfle->size = gftp_get_file_size (transfer->fromreq, curfle->file);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
633 transfer->total_bytes += curfle->size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
634 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
635
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
636 if (GFTP_IS_CONNECTED (transfer->fromreq) &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
637 GFTP_IS_CONNECTED (transfer->toreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
638 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
639 fromsize = gftp_transfer_file (transfer->fromreq, curfle->file,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
640 fromfd,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
641 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
642 curfle->startsize : 0,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
643 transfer->toreq, curfle->destfile, tofd,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
644 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
645 curfle->startsize : 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
646 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
647 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
648
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
649 if (!GFTP_IS_CONNECTED (transfer->fromreq) ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
650 !GFTP_IS_CONNECTED (transfer->toreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
651 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
652 transfer->fromreq->logging_function (gftp_logging_misc,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
653 transfer->fromreq->user_data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
654 _("Error: Remote site disconnected after trying to transfer file\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
655 num_read = -1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
656 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
657 else if (fromsize < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
658 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
659 if (curfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
660 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
661 if (transfer->transfer_direction == GFTP_DIRECTION_DOWNLOAD)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
662 transfer->toreq->datafd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
663 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
664 transfer->fromreq->datafd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
665 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
666
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
667 pthread_mutex_lock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
668 curfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
669 transfer->next_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
670 transfer->curfle = transfer->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
671 pthread_mutex_unlock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
672 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
673 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
674 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
675 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
676 pthread_mutex_lock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
677 transfer->curtrans = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
678 transfer->curresumed = curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? curfle->startsize : 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
679 transfer->resumed_bytes += transfer->curresumed;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
680 pthread_mutex_unlock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
681
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
682 total = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
683 i = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
684 while (!transfer->cancel &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
685 (num_read = gftp_get_next_file_chunk (transfer->fromreq,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
686 buf, sizeof (buf))) > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
687 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
688 total += num_read;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
689 gftp_gtk_calc_kbs (transfer, num_read);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
690
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
691 if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
692 tempstr = gftp_convert_ascii (buf, &num_read, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
693 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
694 tempstr = buf;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
695
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
696 if (gftp_put_next_file_chunk (transfer->toreq, tempstr,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
697 num_read) < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
698 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
699 num_read = -1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
700 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
701 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
702
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
703 /* We don't have to free tempstr for a download because new
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
704 memory is not allocated for it in that case */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
705 if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
706 transfer->transfer_direction == GFTP_DIRECTION_UPLOAD)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
707 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
708 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
709 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
710
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
711 if (transfer->cancel)
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
712 {
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
713 if (gftp_abort_transfer (transfer->fromreq) != 0)
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
714 gftp_disconnect (transfer->fromreq);
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
715
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
716 if (gftp_abort_transfer (transfer->toreq) != 0)
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
717 gftp_disconnect (transfer->toreq);
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
718 }
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
719 else if (num_read < 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
720 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
721 transfer->fromreq->logging_function (gftp_logging_misc,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
722 transfer->fromreq->user_data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
723 _("Could not download %s from %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
724 curfle->file,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
725 transfer->fromreq->hostname);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
726
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
727 if (get_status (transfer, num_read) == 1)
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
728 continue;
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
729
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
730 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
731 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
732 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
733 {
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
734 /* FIXME - this needs cleaned up. NOTE: view/edit file will be
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
735 broken if the file has to be resumed */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
736 if (curfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
737 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
738 if (transfer->transfer_direction == GFTP_DIRECTION_DOWNLOAD)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
739 transfer->toreq->datafd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
740 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
741 transfer->fromreq->datafd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
742 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
743
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
744 if (gftp_end_transfer (transfer->fromreq) != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
745 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
746 if (get_status (transfer, -1) == 1)
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
747 continue;
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
748
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
749 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
750 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
751 gftp_end_transfer (transfer->toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
752
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
753 transfer->fromreq->logging_function (gftp_logging_misc,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
754 transfer->fromreq->user_data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
755 _("Successfully transferred %s at %.2f KB/s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
756 curfle->file, transfer->kbs);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
757 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
758
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
759 if (!curfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
760 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
761 if (curfle->attribs)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
762 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
763 mode = parse_attribs (curfle->attribs);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
764 if (mode != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
765 gftp_chmod (transfer->toreq, curfle->destfile,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
766 parse_attribs (curfle->attribs));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
767 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
768
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
769 if (curfle->datetime != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
770 gftp_set_file_time (transfer->toreq, curfle->destfile,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
771 curfle->datetime);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
772 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
773
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
774 pthread_mutex_lock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
775 transfer->next_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
776 curfle->transfer_done = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
777 transfer->curfle = transfer->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
778 pthread_mutex_unlock (transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
779
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
780 if (transfer->cancel && !transfer->skip_file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
781 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
782 transfer->cancel = 0;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
783 transfer->fromreq->cancel = 0;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
784 transfer->toreq->cancel = 0;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
785 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
786 transfer->done = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
787 transfer->fromreq->user_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
788 transfer->toreq->user_data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
789 return (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
790 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
791
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
792
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
793 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
794 add_file_transfer (gftp_request * fromreq, gftp_request * toreq,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
795 gftp_window_data * fromwdata, gftp_window_data * towdata,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
796 GList * files, int copy_req)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
797 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
798 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
799 GList * templist, *curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
800 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
801 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
802 char *pos, *text[2];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
803 int dialog;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
804
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
805 for (templist = files; templist != NULL; templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
806 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
807 tempfle = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
808 if (tempfle->startsize > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
809 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
810 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
811 dialog = templist != NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
812
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
813 if (append_file_transfers)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
814 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
815 pthread_mutex_lock (&transfer_mutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
816 for (templist = file_transfers; templist != NULL; templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
817 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
818 tdata = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
819 pthread_mutex_lock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
820 if (compare_request (tdata->fromreq, fromreq, 0) &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
821 compare_request (tdata->toreq, toreq, 0) &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
822 tdata->curfle != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
823 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
824 if (!copy_req)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
825 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
826 gftp_request_destroy (fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
827 gftp_request_destroy (toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
828 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
829 fromreq = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
830 toreq = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
831
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
832 for (curfle = tdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
833 curfle != NULL && curfle->next != NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
834 curfle = curfle->next);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
835 if (curfle == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
836 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
837 curfle = files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
838 files->prev = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
839 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
840 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
841 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
842 curfle->next = files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
843 files->prev = curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
844 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
845
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
846 for (curfle = files; curfle != NULL; curfle = curfle->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
847 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
848 tempfle = curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
849 if (tempfle->isdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
850 tdata->numdirs++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
851 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
852 tdata->numfiles++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
853 if ((pos = strrchr (tempfle->file, '/')) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
854 pos = tempfle->file;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
855 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
856 pos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
857
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
858 text[0] = pos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
859 if (tempfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
860 text[1] = _("Skipped");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
861 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
862 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
863 tdata->total_bytes += tempfle->size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
864 text[1] = _("Waiting...");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
865 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
866
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
867 tempfle->node = gtk_ctree_insert_node (GTK_CTREE (dlwdw),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
868 tdata->node, NULL, text, 5,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
869 NULL, NULL, NULL, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
870 FALSE, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
871 transdata = g_malloc (sizeof (*transdata));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
872 transdata->transfer = tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
873 transdata->curfle = curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
874 gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tempfle->node,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
875 transdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
876 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
877 pthread_mutex_unlock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
878 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
879 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
880 pthread_mutex_unlock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
881 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
882 pthread_mutex_unlock (&transfer_mutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
883 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
884 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
885 templist = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
886
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
887 if (templist == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
888 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
889 tdata = g_malloc0 (sizeof (*tdata));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
890 if (copy_req)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
891 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
892 tdata->fromreq = copy_request (fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
893 tdata->toreq = copy_request (toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
894 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
895 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
896 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
897 tdata->fromreq = fromreq;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
898 tdata->toreq = toreq;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
899 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
900 tdata->transfer_direction = fromwdata && fromwdata == &window1 ?
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
901 GFTP_DIRECTION_UPLOAD : GFTP_DIRECTION_DOWNLOAD;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
902 tdata->fromwdata = fromwdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
903 tdata->towdata = towdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
904 if (!dialog)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
905 tdata->show = tdata->ready = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
906 tdata->files = files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
907 for (curfle = files; curfle != NULL; curfle = curfle->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
908 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
909 tempfle = curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
910 if (tempfle->isdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
911 tdata->numdirs++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
912 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
913 tdata->numfiles++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
914 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
915 tdata->structmutex = g_malloc (sizeof (pthread_mutex_t));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
916 pthread_mutex_init (tdata->structmutex, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
917 tdata->statmutex = g_malloc (sizeof (pthread_mutex_t));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
918 pthread_mutex_init (tdata->statmutex, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
919 pthread_mutex_lock (&transfer_mutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
920 file_transfers = g_list_append (file_transfers, tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
921 pthread_mutex_unlock (&transfer_mutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
922 if (dialog)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
923 gftp_gtk_ask_transfer (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
924 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
925 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
926
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
927
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
928 gint
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
929 update_downloads (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
930 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
931 char tempstr[50], temp1str[127];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
932 GList * templist, * next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
933 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
934
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
935 if (file_transfer_logs != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
936 display_cached_logs ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
937
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
938 if (window2.request->gotbytes != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
939 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
940 if (window2.request->gotbytes == -1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
941 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
942 update_window_info ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
943 window2.request->gotbytes = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
944 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
945 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
946 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
947 insert_commas (window2.request->gotbytes, tempstr, sizeof (tempstr));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
948 g_snprintf (temp1str, sizeof (temp1str),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
949 _("Retrieving file names...%s bytes"), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
950 gtk_label_set (GTK_LABEL (window2.hoststxt), temp1str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
951 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
952 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
953
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
954 if (viewedit_process_done)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
955 check_done_process ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
956
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
957 for (templist = file_transfers; templist != NULL;)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
958 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
959 tdata = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
960 if (tdata->ready)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
961 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
962 pthread_mutex_lock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
963
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
964 if (tdata->next_file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
965 on_next_transfer (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
966 else if (tdata->show)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
967 show_transfer (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
968 else if (tdata->done)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
969 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
970 next = templist->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
971 transfer_done (templist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
972 templist = next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
973 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
974 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
975
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
976 if (tdata->curfle != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
977 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
978 if (!tdata->started && start_file_transfers &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
979 (transfer_in_progress == 0 || !do_one_transfer_at_a_time))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
980 create_transfer (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
981
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
982 if (tdata->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
983 update_file_status (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
984 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
985 pthread_mutex_unlock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
986 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
987 templist = templist->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
988 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
989
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
990 gtk_timeout_add (500, update_downloads, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
991 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
992 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
993
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
994
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
995 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
996 on_next_transfer (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
997 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
998 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
999 int fd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1000
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1001 tdata->next_file = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1002 for (; tdata->updfle != tdata->curfle; tdata->updfle = tdata->updfle->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1003 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1004 tempfle = tdata->updfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1005
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1006 if (tempfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1007 fd = fileno (tempfle->fd);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1008 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1009 fd = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1010
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1011 if (tempfle->done_view)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1012 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1013 if (tempfle->transfer_action != GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1014 view_file (tempfle->destfile, fd, 1, tempfle->done_rm, 1, 0,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1015 tempfle->file, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1016
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1017 if (tempfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1018 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1019 fclose (tempfle->fd);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1020 tempfle->fd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1021 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1022 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1023 else if (tempfle->done_edit)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1024 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1025 if (tempfle->transfer_action != GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1026 view_file (tempfle->destfile, fd, 0, tempfle->done_rm, 1, 0,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1027 tempfle->file, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1028
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1029 if (tempfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1030 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1031 fclose (tempfle->fd);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1032 tempfle->fd = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1033 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1034 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1035 else if (tempfle->done_rm)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1036 tdata->fromreq->rmfile (tdata->fromreq, tempfle->file);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1037
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1038 if (tempfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1039 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->node, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1040 _("Skipped"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1041 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1042 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->node, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1043 _("Finished"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1044 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1045
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1046 if (refresh_files && tdata->curfle && tdata->curfle->next &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1047 compare_request (tdata->toreq,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1048 ((gftp_window_data *) tdata->towdata)->request, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1049 refresh (tdata->towdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1050 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1051
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1052
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1053 static void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1054 get_trans_password (gftp_request * request, gftp_dialog_data * ddata)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1055 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1056 gftp_set_password (request, gtk_entry_get_text (GTK_ENTRY (ddata->edit)));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1057 request->stopable = 0;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1058 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1059
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1060
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1061 static void
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1062 cancel_get_trans_password (gftp_transfer * tdata, gftp_dialog_data * ddata)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1063 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1064 if (tdata->fromreq->stopable == 0)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1065 return;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1066
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1067 pthread_mutex_lock (tdata->structmutex);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1068 if (tdata->started)
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1069 {
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1070 tdata->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1071 tdata->fromreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1072 tdata->toreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1073 }
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1074 else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1075 tdata->done = 1;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1076
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1077 tdata->fromreq->stopable = 0;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1078 tdata->toreq->stopable = 0;
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1079 pthread_mutex_unlock (tdata->structmutex);
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1080
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1081 ftp_log (gftp_logging_misc, NULL, _("Stopping the transfer of %s\n"),
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1082 ((gftp_file *) tdata->curfle->data)->file);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1083 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1084
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1085
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1086 static void
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1087 show_transfer (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1088 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1089 GdkPixmap * closedir_pixmap, * opendir_pixmap;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1090 GdkBitmap * closedir_bitmap, * opendir_bitmap;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1091 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1092 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1093 char *pos, *text[2];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1094 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1095
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1096 gftp_get_pixmap (dlwdw, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1097 gftp_get_pixmap (dlwdw, "dir.xpm", &closedir_pixmap, &closedir_bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1098
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1099 text[0] = GFTP_GET_HOSTNAME (tdata->fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1100 text[1] = _("Waiting...");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1101 tdata->node = gtk_ctree_insert_node (GTK_CTREE (dlwdw), NULL, NULL, text, 5,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1102 closedir_pixmap, closedir_bitmap,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1103 opendir_pixmap, opendir_bitmap,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1104 FALSE,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1105 tdata->numdirs + tdata->numfiles < 50);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1106 transdata = g_malloc (sizeof (*transdata));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1107 transdata->transfer = tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1108 transdata->curfle = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1109 gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tdata->node, transdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1110 tdata->show = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1111 tdata->curfle = tdata->updfle = tdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1112
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1113 tdata->total_bytes = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1114 for (templist = tdata->files; templist != NULL; templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1115 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1116 tempfle = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1117 if ((pos = strrchr (tempfle->file, '/')) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1118 pos = tempfle->file;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1119 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1120 pos++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1121 text[0] = pos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1122 if (tempfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1123 text[1] = _("Skipped");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1124 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1125 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1126 tdata->total_bytes += tempfle->size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1127 text[1] = _("Waiting...");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1128 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1129
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1130 tempfle->node = gtk_ctree_insert_node (GTK_CTREE (dlwdw), tdata->node,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1131 NULL, text, 5, NULL, NULL, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1132 NULL, FALSE, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1133 transdata = g_malloc (sizeof (*transdata));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1134 transdata->transfer = tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1135 transdata->curfle = templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1136 gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tempfle->node, transdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1137 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1138
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1139 if (!tdata->toreq->stopable && tdata->toreq->need_userpass &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1140 (tdata->toreq->password == NULL || *tdata->toreq->password == '\0'))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1141 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1142 tdata->toreq->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1143 MakeEditDialog (_("Enter Password"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1144 _("Please enter your password for this site"), NULL, 0,
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1145 NULL, gftp_dialog_button_connect,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1146 get_trans_password, tdata->toreq,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1147 cancel_get_trans_password, tdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1148 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1149
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1150 if (!tdata->fromreq->stopable && tdata->fromreq->need_userpass &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1151 (tdata->fromreq->password == NULL || *tdata->fromreq->password == '\0'))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1152 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1153 tdata->fromreq->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1154 MakeEditDialog (_("Enter Password"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1155 _("Please enter your password for this site"), NULL, 0,
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1156 NULL, gftp_dialog_button_connect,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1157 get_trans_password, tdata->fromreq,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1158 cancel_get_trans_password, tdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1159 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1160 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1161
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1162
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1163 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1164 transfer_done (GList * node)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1165 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1166 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1167 gftp_request * fromreq;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1168 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1169 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1170 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1171
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1172 tdata = node->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1173 if (tdata->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1174 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1175 fromreq = ((gftp_window_data *) tdata->fromwdata)->request;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1176 if (!tdata->fromreq->stopable && tdata->fromwdata &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1177 ((fromreq->sockfd == NULL && fromreq->cached) ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1178 fromreq->always_connected) && tdata->fromreq->sockfd != NULL &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1179 compare_request (tdata->fromreq, fromreq, 0))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1180 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1181 swap_socks (((gftp_window_data *) tdata->towdata)->request,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1182 tdata->toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1183 swap_socks (((gftp_window_data *) tdata->fromwdata)->request,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1184 tdata->fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1185 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1186 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1187 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1188 gftp_disconnect (tdata->fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1189 gftp_disconnect (tdata->toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1190 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1191
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1192 if (tdata->towdata != NULL && compare_request (tdata->toreq,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1193 ((gftp_window_data *) tdata->towdata)->request, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1194 refresh (tdata->towdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1195
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1196 transfer_in_progress--;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1197 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1198
2
a171df6764a7 * Fixed crash if you was already transfering a file, and you started another
masneyb
parents: 1
diff changeset
1199 if (!tdata->show && tdata->started)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1200 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1201 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), tdata->node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1202 if (transdata != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1203 g_free (transdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1204
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1205 for (templist = tdata->files; templist != NULL; templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1206 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1207 tempfle = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1208 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), tempfle->node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1209 if (transdata != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1210 g_free (transdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1211 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1212
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1213 gtk_ctree_remove_node (GTK_CTREE (dlwdw), tdata->node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1214 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1215 pthread_mutex_lock (&transfer_mutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1216 file_transfers = g_list_remove_link (file_transfers, node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1217 pthread_mutex_unlock (&transfer_mutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1218 pthread_mutex_destroy (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1219 pthread_mutex_destroy (tdata->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1220 free_tdata (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1221 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1222
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1223
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1224 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1225 create_transfer (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1226 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1227 pthread_t tid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1228
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1229 if (!tdata->fromreq->stopable)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1230 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1231 if (tdata->fromwdata &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1232 ((gftp_window_data *) tdata->fromwdata)->request->sockfd != NULL &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1233 !((gftp_window_data *) tdata->fromwdata)->request->stopable &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1234 compare_request (tdata->fromreq, ((gftp_window_data *) tdata->fromwdata)->request, 0))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1235 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1236 swap_socks (tdata->toreq,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1237 ((gftp_window_data *) tdata->towdata)->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1238 swap_socks (tdata->fromreq,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1239 ((gftp_window_data *) tdata->fromwdata)->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1240 update_window_info ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1241 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1242 transfer_in_progress++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1243 tdata->started = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1244 tdata->stalled = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1245 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->node, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1246 _("Connecting..."));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1247 pthread_create (&tid, NULL, gftp_gtk_transfer_files, tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1248 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1249 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1250
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1251
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1252 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1253 update_file_status (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1254 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1255 char totstr[100], dlstr[100], gotstr[50], ofstr[50];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1256 int hours, mins, secs, pcent, st;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1257 double remaining;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1258 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1259 struct timeval tv;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1260
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1261 pthread_mutex_lock (tdata->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1262 tempfle = tdata->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1263
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1264 gettimeofday (&tv, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1265 if ((remaining = (double) (tv.tv_sec - tdata->starttime.tv_sec) + ((double) (tv.tv_usec - tdata->starttime.tv_usec) / 1000000.0)) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1266 remaining = 1.0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1267
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1268 remaining = ((double) (tdata->total_bytes - tdata->trans_bytes - tdata->resumed_bytes)) / 1024.0 / tdata->kbs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1269 hours = (off_t) remaining / 3600;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1270 remaining -= hours * 3600;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1271 mins = (off_t) remaining / 60;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1272 remaining -= mins * 60;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1273 secs = (off_t) remaining;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1274
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1275 if (hours < 0 || mins < 0 || secs < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1276 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1277 pthread_mutex_unlock (tdata->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1278 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1279 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1280
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1281 pcent = (int) ((double) (tdata->trans_bytes + tdata->resumed_bytes) / (double) tdata->total_bytes * 100.0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1282 if (pcent < 0 || pcent > 100)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1283 pcent = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1284
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1285 g_snprintf (totstr, sizeof (totstr),
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
1286 _("%d%% complete, %02d:%02d:%02d est. time remaining. (File %ld of %ld)"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1287 pcent, hours, mins, secs, tdata->current_file_number,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1288 tdata->numdirs + tdata->numfiles);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1289
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1290 *dlstr = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1291 if (!tdata->stalled)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1292 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1293 insert_commas (tdata->curtrans + tdata->curresumed, gotstr, sizeof (gotstr));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1294 insert_commas (tempfle->size, ofstr, sizeof (ofstr));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1295 st = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1296 if (tv.tv_sec - tdata->lasttime.tv_sec <= 5)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1297 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1298 if (tdata->curfle->next != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1299 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1300 remaining = ((double) (tempfle->size - tdata->curtrans - tdata->curresumed)) / 1024.0 / tdata->kbs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1301 hours = (off_t) remaining / 3600;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1302 remaining -= hours * 3600;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1303 mins = (off_t) remaining / 60;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1304 remaining -= mins * 60;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1305 secs = (off_t) remaining;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1306 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1307
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1308 if (!(hours < 0 || mins < 0 || secs < 0))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1309 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1310 g_snprintf (dlstr, sizeof (dlstr),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1311 _("Recv %s of %s at %.2fKB/s, %02d:%02d:%02d est. time remaining"), gotstr, ofstr, tdata->kbs, hours, mins, secs);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1312 st = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1313 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1314 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1315
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1316 if (st)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1317 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1318 tdata->stalled = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1319 g_snprintf (dlstr, sizeof (dlstr),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1320 _("Recv %s of %s, transfer stalled, unknown time remaining"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1321 gotstr, ofstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1322 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1323 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1324
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1325 pthread_mutex_unlock (tdata->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1326
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1327 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->node, 1, totstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1328
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1329 if (*dlstr != '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1330 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->node, 1, dlstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1331 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1332
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1333
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1334 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1335 start_transfer (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1336 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1337 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1338 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1339
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1340 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1341 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1342 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1343 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1344 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1345 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1346 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1347 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1348
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1349 pthread_mutex_lock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1350 if (!transdata->transfer->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1351 create_transfer (transdata->transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1352 pthread_mutex_unlock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1353 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1354
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1355
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1356 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1357 stop_transfer (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1358 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1359 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1360 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1361
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1362 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1363 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1364 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1365 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1366 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1367 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1368 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1369 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1370
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1371 pthread_mutex_lock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1372 if (transdata->transfer->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1373 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1374 transdata->transfer->cancel = 1;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1375 transdata->transfer->fromreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1376 transdata->transfer->toreq->cancel = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1377 transdata->transfer->skip_file = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1378 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1379 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1380 transdata->transfer->done = 1;
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1381 pthread_mutex_unlock (transdata->transfer->structmutex);
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1382
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1383 ftp_log (gftp_logging_misc, NULL, _("Stopping the transfer on host %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1384 transdata->transfer->fromreq->hostname);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1385 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1386
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1387
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1388 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1389 skip_transfer (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1390 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1391 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1392 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1393 gftp_file * curfle;
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1394 char *file;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1395
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1396 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1397 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1398 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1399 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1400 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1401 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1402 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1403 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1404
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1405 pthread_mutex_lock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1406 if (transdata->transfer->curfle != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1407 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1408 curfle = transdata->transfer->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1409 if (transdata->transfer->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1410 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1411 transdata->transfer->cancel = 1;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1412 transdata->transfer->fromreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1413 transdata->transfer->toreq->cancel = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1414 transdata->transfer->skip_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1415 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1416
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1417 curfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1418 file = curfle->file;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1419 }
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1420 else
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1421 file = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1422 pthread_mutex_unlock (transdata->transfer->structmutex);
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1423
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1424 ftp_log (gftp_logging_misc, NULL, _("Skipping file %s on host %s\n"),
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1425 file, transdata->transfer->fromreq->hostname);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1426 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1427
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1428
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1429 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1430 remove_file_transfer (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1431 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1432 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1433 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1434 gftp_file * curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1435
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1436 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1437 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1438 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1439 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1440 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1441 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1442
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1443 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1444 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1445
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1446
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1447 if (transdata->curfle == NULL || transdata->curfle->data == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1448 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1449
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1450 curfle = transdata->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1451
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1452 if (curfle->transfer_action & GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1453 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1454
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1455 pthread_mutex_lock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1456
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1457 curfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1458
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1459 if (transdata->transfer->started &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1460 transdata->curfle == transdata->transfer->curfle)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1461 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1462 transdata->transfer->cancel = 1;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1463 transdata->transfer->fromreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1464 transdata->transfer->toreq->cancel = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1465 transdata->transfer->skip_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1466 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1467 else if (transdata->curfle != transdata->transfer->curfle &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1468 !curfle->transfer_done)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1469 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1470 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), curfle->node, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1471 _("Skipped"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1472 transdata->transfer->total_bytes -= curfle->size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1473 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1474
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1475 pthread_mutex_unlock (transdata->transfer->structmutex);
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
1476
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1477 ftp_log (gftp_logging_misc, NULL, _("Skipping file %s on host %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1478 curfle->file, transdata->transfer->fromreq->hostname);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1479 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1480
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1481
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1482 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1483 move_transfer_up (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1484 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1485 GList * firstentry, * secentry, * lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1486 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1487 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1488
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1489 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1490 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1491 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1492 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1493 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1494 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1495 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1496 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1497
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1498 if (transdata->curfle == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1499 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1500
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1501 pthread_mutex_lock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1502 if (transdata->curfle->prev != NULL && (!transdata->transfer->started ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1503 (transdata->transfer->curfle != transdata->curfle &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1504 transdata->transfer->curfle != transdata->curfle->prev)))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1505 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1506 if (transdata->curfle->prev->prev == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1507 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1508 firstentry = transdata->curfle->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1509 lastentry = transdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1510 transdata->transfer->files = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1511 transdata->curfle->next = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1512 transdata->transfer->files->prev = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1513 firstentry->prev = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1514 firstentry->next = lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1515 if (lastentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1516 lastentry->prev = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1517 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1518 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1519 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1520 firstentry = transdata->curfle->prev->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1521 secentry = transdata->curfle->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1522 lastentry = transdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1523 firstentry->next = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1524 transdata->curfle->prev = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1525 transdata->curfle->next = secentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1526 secentry->prev = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1527 secentry->next = lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1528 if (lastentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1529 lastentry->prev = secentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1530 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1531
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1532 gtk_ctree_move (GTK_CTREE (dlwdw),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1533 ((gftp_file *) transdata->curfle->data)->node,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1534 transdata->transfer->node,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1535 transdata->curfle->next != NULL ?
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1536 ((gftp_file *) transdata->curfle->next->data)->node :
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1537 NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1538 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1539 pthread_mutex_unlock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1540 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1541
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1542 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1543 move_transfer_down (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1544 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1545 GList * firstentry, * secentry, * lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1546 gftp_curtrans_data * transdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1547 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1548
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1549 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1550 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1551 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1552 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1553 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1554 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1555 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1556 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1557
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1558 if (transdata->curfle == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1559 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1560
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1561 pthread_mutex_lock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1562 if (transdata->curfle->next != NULL && (!transdata->transfer->started ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1563 (transdata->transfer->curfle != transdata->curfle &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1564 transdata->transfer->curfle != transdata->curfle->next)))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1565 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1566 if (transdata->curfle->prev == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1567 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1568 firstentry = transdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1569 lastentry = transdata->curfle->next->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1570 transdata->transfer->files = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1571 transdata->transfer->files->prev = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1572 transdata->transfer->files->next = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1573 transdata->curfle->prev = transdata->transfer->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1574 transdata->curfle->next = lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1575 if (lastentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1576 lastentry->prev = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1577 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1578 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1579 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1580 firstentry = transdata->curfle->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1581 secentry = transdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1582 lastentry = transdata->curfle->next->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1583 firstentry->next = secentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1584 secentry->prev = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1585 secentry->next = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1586 transdata->curfle->prev = secentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1587 transdata->curfle->next = lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1588 if (lastentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1589 lastentry->prev = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1590 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1591
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1592 gtk_ctree_move (GTK_CTREE (dlwdw),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1593 ((gftp_file *) transdata->curfle->data)->node,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1594 transdata->transfer->node,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1595 transdata->curfle->next != NULL ?
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1596 ((gftp_file *) transdata->curfle->next->data)->node :
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1597 NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1598 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1599 pthread_mutex_unlock (transdata->transfer->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1600 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1601
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1602
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1603 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1604 gftp_gtk_ask_transfer (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1605 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1606 char *dltitles[4], *add_data[4] = { NULL, NULL, NULL, NULL },
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1607 tempstr[50], temp1str[50];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1608 GtkWidget * tempwid, * scroll, * hbox;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1609 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1610 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1611 size_t len;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1612 char *pos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1613 int i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1614
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1615 dltitles[0] = _("Filename");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1616 dltitles[1] = _("Local Size");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1617 dltitles[2] = _("Remote Size");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1618 dltitles[3] = _("Action");
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1619 dialog = gtk_dialog_new (); /* FIXME - gtk+ 2.0 stock icons */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1620 gtk_grab_add (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1621 gtk_window_set_title (GTK_WINDOW (dialog),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1622 tdata->transfer_direction == GFTP_DIRECTION_DOWNLOAD ?
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1623 _("Download Files") : _("Upload Files"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1624 gtk_window_set_wmclass (GTK_WINDOW(dialog), "transfer", "gFTP");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1625 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1626 gtk_container_border_width (GTK_CONTAINER
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1627 (GTK_DIALOG (dialog)->action_area), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1628 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1629 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 35);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1630 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1631 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1632 gtk_signal_connect_object (GTK_OBJECT (dialog), "delete_event",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1633 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1634 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1635
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1636 tempwid = gtk_label_new (_("The following file(s) exist on both the local and remote computer\nPlease select what you would like to do"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1637 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), tempwid, FALSE,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1638 FALSE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1639 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1640
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1641 scroll = gtk_scrolled_window_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1642 gtk_widget_set_size_request (scroll, 450, 200);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1643
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1644 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1645 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1646 tdata->clist = gtk_clist_new_with_titles (4, dltitles);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1647 gtk_container_add (GTK_CONTAINER (scroll), tdata->clist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1648
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1649 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1650 gtk_clist_set_selection_mode (GTK_CLIST (tdata->clist),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1651 GTK_SELECTION_EXTENDED);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1652 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1653 gtk_clist_set_selection_mode (GTK_CLIST (tdata->clist),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1654 GTK_SELECTION_MULTIPLE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1655 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1656 gtk_clist_set_column_width (GTK_CLIST (tdata->clist), 0, 100);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1657 gtk_clist_set_column_justification (GTK_CLIST (tdata->clist), 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1658 GTK_JUSTIFY_RIGHT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1659 gtk_clist_set_column_width (GTK_CLIST (tdata->clist), 1, 85);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1660 gtk_clist_set_column_justification (GTK_CLIST (tdata->clist), 2,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1661 GTK_JUSTIFY_RIGHT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1662 gtk_clist_set_column_width (GTK_CLIST (tdata->clist), 2, 85);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1663 gtk_clist_set_column_width (GTK_CLIST (tdata->clist), 3, 85);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1664 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scroll, TRUE, TRUE,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1665 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1666 gtk_widget_show (tdata->clist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1667 gtk_widget_show (scroll);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1668
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1669 for (templist = tdata->files; templist != NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1670 templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1671 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1672 tempfle = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1673 if (tempfle->startsize == 0 || tempfle->isdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1674 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1675 tempfle->shown = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1676 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1677 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1678 tempfle->shown = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1679
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1680 pos = tempfle->destfile;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1681 len = strlen (GFTP_GET_DIRECTORY (tdata->toreq));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1682 if (strncmp (pos, GFTP_GET_DIRECTORY (tdata->toreq), len) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1683 pos = tempfle->destfile + len + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1684 add_data[0] = pos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1685
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1686 if (overwrite_by_default)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1687 add_data[3] = _("Overwrite");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1688 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1689 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1690 if (tempfle->startsize >= tempfle->size)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1691 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1692 add_data[3] = _("Skip");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1693 tempfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1694 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1695 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1696 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1697 add_data[3] = _("Resume");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1698 tempfle->transfer_action = GFTP_TRANS_ACTION_RESUME;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1699 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1700 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1701
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1702 if (tdata->transfer_direction == GFTP_DIRECTION_DOWNLOAD)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1703 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1704 add_data[2] = insert_commas (tempfle->size, tempstr,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1705 sizeof (tempstr));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1706 add_data[1] = insert_commas (tempfle->startsize, temp1str,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1707 sizeof (temp1str));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1708 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1709 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1710 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1711 add_data[1] = insert_commas (tempfle->size, tempstr,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1712 sizeof (tempstr));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1713 add_data[2] = insert_commas (tempfle->startsize, temp1str,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1714 sizeof (temp1str));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1715 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1716 i = gtk_clist_append (GTK_CLIST (tdata->clist), add_data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1717 gtk_clist_set_row_data (GTK_CLIST (tdata->clist), i, tempfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1718 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1719
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1720 gtk_clist_select_all (GTK_CLIST (tdata->clist));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1721
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1722 hbox = gtk_hbox_new (TRUE, 20);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1723 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1724 gtk_widget_show (hbox);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1725
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1726 tempwid = gtk_button_new_with_label (_("Overwrite"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1727 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1728 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1729 GTK_SIGNAL_FUNC (overwrite), (gpointer) tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1730 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1731
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1732 tempwid = gtk_button_new_with_label (_("Resume"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1733 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1734 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1735 GTK_SIGNAL_FUNC (resume), (gpointer) tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1736 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1737
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1738 tempwid = gtk_button_new_with_label (_("Skip File"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1739 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1740 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", GTK_SIGNAL_FUNC (skip),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1741 (gpointer) tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1742 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1743
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1744 hbox = gtk_hbox_new (TRUE, 20);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1745 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1746 gtk_widget_show (hbox);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1747
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1748 tempwid = gtk_button_new_with_label (_("Select All"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1749 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1750 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1751 GTK_SIGNAL_FUNC (trans_selectall), (gpointer) tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1752 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1753
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1754 tempwid = gtk_button_new_with_label (_("Deselect All"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1755 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1756 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1757 GTK_SIGNAL_FUNC (trans_unselectall), (gpointer) tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1758 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1759
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1760 tempwid = gtk_button_new_with_label (_("OK"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1761 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1762 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1763 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1764 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", GTK_SIGNAL_FUNC (ok),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1765 (gpointer) tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1766 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1767 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1768 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1769 gtk_widget_grab_default (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1770 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1771
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1772 tempwid = gtk_button_new_with_label (_(" Cancel "));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1773 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1774 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1775 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1776 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1777 GTK_SIGNAL_FUNC (cancel), (gpointer) tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1778 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1779 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1780 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1781 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1782
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1783 gtk_widget_show (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1784 dialog = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1785 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1786
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1787
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1788 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1789 trans_selectall (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1790 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1791 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1792 tdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1793
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1794 gtk_clist_select_all (GTK_CLIST (tdata->clist));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1795 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1796
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1797
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1798 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1799 trans_unselectall (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1800 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1801 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1802 tdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1803
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1804 gtk_clist_unselect_all (GTK_CLIST (tdata->clist));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1805 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1806
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1807
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1808 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1809 overwrite (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1810 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1811 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1812 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1813 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1814 int curpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1815
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1816 tdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1817 curpos = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1818 filelist = tdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1819 templist = GTK_CLIST (tdata->clist)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1820 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1821 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1822 templist = get_next_selection (templist, &filelist, &curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1823 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1824 tempfle->transfer_action = GFTP_TRANS_ACTION_OVERWRITE;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1825 gtk_clist_set_text (GTK_CLIST (tdata->clist), curpos, 3, _("Overwrite"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1826 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1827 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1828
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1829
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1830 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1831 resume (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1832 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1833 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1834 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1835 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1836 int curpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1837
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1838 tdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1839 curpos = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1840 filelist = tdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1841 templist = GTK_CLIST (tdata->clist)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1842 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1843 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1844 templist = get_next_selection (templist, &filelist, &curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1845 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1846 tempfle->transfer_action = GFTP_TRANS_ACTION_RESUME;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1847 gtk_clist_set_text (GTK_CLIST (tdata->clist), curpos, 3, _("Resume"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1848 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1849 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1850
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1851
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1852 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1853 skip (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1854 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1855 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1856 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1857 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1858 int curpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1859
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1860 tdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1861 curpos = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1862 filelist = tdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1863 templist = GTK_CLIST (tdata->clist)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1864 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1865 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1866 templist = get_next_selection (templist, &filelist, &curpos);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1867 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1868 tempfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1869 gtk_clist_set_text (GTK_CLIST (tdata->clist), curpos, 3, _("Skip"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1870 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1871 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1872
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1873
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1874 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1875 ok (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1876 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1877 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1878 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1879 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1880
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1881 tdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1882 pthread_mutex_lock ((pthread_mutex_t *) tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1883 for (templist = tdata->files; templist != NULL; templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1884 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1885 tempfle = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1886 if (tempfle->transfer_action != GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1887 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1888 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1889
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1890 if (templist == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1891 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1892 tdata->show = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1893 tdata->ready = tdata->done = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1894 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1895 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1896 tdata->show = tdata->ready = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1897 pthread_mutex_unlock ((pthread_mutex_t *) tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1898 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1899
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1900
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1901 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1902 cancel (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1903 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1904 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1905
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1906 tdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1907 pthread_mutex_lock ((pthread_mutex_t *) tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1908 tdata->show = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1909 tdata->done = tdata->ready = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1910 pthread_mutex_unlock ((pthread_mutex_t *) tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1911 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1912
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1913
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1914 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1915 gftp_gtk_calc_kbs (gftp_transfer * tdata, ssize_t num_read)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1916 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1917 unsigned long waitusecs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1918 double difftime, curkbs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1919 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1920 struct timeval tv;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1921 unsigned long toadd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1922
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1923 gettimeofday (&tv, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1924 pthread_mutex_lock (tdata->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1925
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1926 tempfle = tdata->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1927 tdata->trans_bytes += num_read;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1928 tdata->curtrans += num_read;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1929 tdata->stalled = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1930
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1931 difftime = (tv.tv_sec - tdata->starttime.tv_sec) + ((double) (tv.tv_usec - tdata->starttime.tv_usec) / 1000000.0);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1932 if (difftime <= 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1933 tdata->kbs = (double) tdata->trans_bytes / 1024.0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1934 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1935 tdata->kbs = (double) tdata->trans_bytes / 1024.0 / difftime;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1936
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1937 difftime = (tv.tv_sec - tdata->lasttime.tv_sec) + ((double) (tv.tv_usec - tdata->lasttime.tv_usec) / 1000000.0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1938
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1939 if (difftime <= 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1940 curkbs = (double) (num_read / 1024.0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1941 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1942 curkbs = (double) (num_read / 1024.0 / difftime);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1943
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1944 if (tdata->fromreq->maxkbs > 0 &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1945 curkbs > tdata->fromreq->maxkbs)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1946 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1947 waitusecs = (double) num_read / 1024.0 / tdata->fromreq->maxkbs * 1000000.0 - difftime;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1948
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1949 if (waitusecs > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1950 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1951 pthread_mutex_unlock (tdata->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1952 difftime += ((double) waitusecs / 1000000.0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1953 usleep (waitusecs);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1954 pthread_mutex_lock (tdata->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1955 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1956 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1957
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1958 /* I don't call gettimeofday (&tdata->lasttime) here because this will use
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1959 less system resources. This will be close enough for what we need */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1960 difftime += tdata->lasttime.tv_usec / 1000000.0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1961 toadd = (long) difftime;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1962 difftime -= toadd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1963 tdata->lasttime.tv_sec += toadd;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1964 tdata->lasttime.tv_usec = difftime * 1000000.0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1965
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1966 pthread_mutex_unlock (tdata->statmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1967 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1968
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1969
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1970 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1971 check_done_process (void)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1972 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1973 gftp_viewedit_data * ve_proc;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1974 GList * curdata, *deldata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1975 struct stat st;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1976 int ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1977 char *str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1978 pid_t pid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1979
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1980 viewedit_process_done = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1981 while ((pid = waitpid (-1, &ret, WNOHANG)) > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1982 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1983 curdata = viewedit_processes;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1984 while (curdata != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1985 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1986 ve_proc = curdata->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1987 deldata = curdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1988 curdata = curdata->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1989 if (ve_proc->pid == pid)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1990 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1991 viewedit_processes = g_list_remove_link (viewedit_processes,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1992 deldata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1993 if (ret != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1994 ftp_log (gftp_logging_error, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1995 _("Error: Child %d returned %d\n"), pid, ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1996 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1997 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1998 _("Child %d returned successfully\n"), pid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1999
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2000 if (!ve_proc->view && !ve_proc->dontupload)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2001 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2002 /* We was editing the file. Upload it */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2003 if (stat (ve_proc->filename, &st) == -1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2004 ftp_log (gftp_logging_error, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2005 _("Error: Cannot get information about file %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2006 ve_proc->filename, g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2007 else if (st.st_mtime == ve_proc->st.st_mtime)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2008 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2009 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2010 _("File %s was not changed\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2011 ve_proc->filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2012 remove_file (ve_proc->filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2013 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2014 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2015 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2016 memcpy (&ve_proc->st, &st, sizeof (ve_proc->st));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2017 str = g_strdup_printf (
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2018 _("File %s has changed.\nWould you like to upload it?"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2019 ve_proc->remote_filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2020
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2021 MakeYesNoDialog (_("Edit File"), str,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2022 do_upload, ve_proc,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2023 dont_upload, ve_proc);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2024 g_free (str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2025 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2026 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2027 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2028
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2029 free_edit_data (ve_proc);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2030 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2031 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2032 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2033 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2034 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2035
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2036
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2037 static void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2038 do_upload (gftp_viewedit_data * ve_proc, gftp_dialog_data * ddata)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2039 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2040 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2041 GList * newfile;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2042
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2043 tempfle = g_malloc0 (sizeof (*tempfle));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2044 tempfle->destfile = ve_proc->remote_filename;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2045 ve_proc->remote_filename = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2046 tempfle->file = ve_proc->filename;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2047 ve_proc->filename = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2048 tempfle->done_rm = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2049 newfile = g_list_append (NULL, tempfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2050 add_file_transfer (ve_proc->fromwdata->request, ve_proc->towdata->request,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2051 ve_proc->fromwdata, ve_proc->towdata, newfile, 1);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2052 free_edit_data (ve_proc);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2053 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2054
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2055
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2056 static void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2057 dont_upload (gftp_viewedit_data * ve_proc, gftp_dialog_data * ddata)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2058 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2059 remove_file (ve_proc->filename);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2060 free_edit_data (ve_proc);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2061 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2062
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2063
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2064 static void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
2065 free_edit_data (gftp_viewedit_data * ve_proc)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2066 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2067 int i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2068
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2069 if (ve_proc->filename)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2070 g_free (ve_proc->filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2071 if (ve_proc->remote_filename)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2072 g_free (ve_proc->remote_filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2073 for (i = 0; ve_proc->argv[i] != NULL; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2074 g_free (ve_proc->argv[i]);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2075 g_free (ve_proc->argv);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2076 g_free (ve_proc);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2077 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2078
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2079
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2080 static int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2081 get_status (gftp_transfer * tdata, ssize_t num_read)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2082 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2083 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2084 struct timeval tv;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2085
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2086 pthread_mutex_lock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2087 if (tdata->curfle == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2088 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2089 pthread_mutex_unlock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2090 return (-1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2091 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2092 tempfle = tdata->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2093 pthread_mutex_unlock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2094
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2095 gftp_disconnect (tdata->fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2096 gftp_disconnect (tdata->toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2097 if (num_read < 0 || tdata->skip_file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2098 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2099 if (tdata->fromreq->retries != 0 && tdata->current_file_retries >= tdata->fromreq->retries)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2100 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2101 tdata->fromreq->logging_function (gftp_logging_error,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2102 tdata->fromreq->user_data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2103 _("Error: Remote site %s disconnected. Max retries reached...giving up\n"),
36
bc9473ba9a90 2002-10-07 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
2104 tdata->fromreq->hostname != NULL ?
bc9473ba9a90 2002-10-07 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
2105 tdata->fromreq->hostname : tdata->toreq->hostname);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2106 return (-1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2107 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2108 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2109 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2110 tdata->fromreq->logging_function (gftp_logging_error,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2111 tdata->fromreq->user_data,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2112 _("Error: Remote site %s disconnected. Will reconnect in %d seconds\n"),
36
bc9473ba9a90 2002-10-07 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
2113 tdata->fromreq->hostname != NULL ?
bc9473ba9a90 2002-10-07 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
2114 tdata->fromreq->hostname : tdata->toreq->hostname,
bc9473ba9a90 2002-10-07 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
2115 tdata->fromreq->sleep_time);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2116 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2117
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2118 while (tdata->fromreq->retries == 0 ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2119 tdata->current_file_retries <= tdata->fromreq->retries)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2120 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2121 if (!tdata->skip_file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2122 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2123 tv.tv_sec = tdata->fromreq->sleep_time;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2124 tv.tv_usec = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2125 select (0, NULL, NULL, NULL, &tv);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2126 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2127
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2128 if (gftp_connect (tdata->fromreq) == 0 &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2129 gftp_connect (tdata->toreq) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2130 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2131 pthread_mutex_lock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2132 tdata->resumed_bytes = tdata->resumed_bytes + tdata->trans_bytes - tdata->curresumed - tdata->curtrans;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2133 tdata->trans_bytes = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2134 if (tdata->skip_file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2135 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2136 tdata->total_bytes -= tempfle->size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2137 tdata->curtrans = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2138
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2139 tdata->curfle = tdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2140 tdata->next_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2141 tdata->skip_file = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2142 tdata->cancel = 0;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2143 tdata->fromreq->cancel = 0;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
2144 tdata->toreq->cancel = 0;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2145 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2146 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2147 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2148 tempfle->transfer_action = GFTP_TRANS_ACTION_RESUME;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2149 tempfle->startsize = tdata->curtrans + tdata->curresumed;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2150 /* We decrement this here because it will be incremented in
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2151 the loop again */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2152 tdata->curresumed = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2153 tdata->current_file_number--; /* Decrement this because it
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2154 will be incremented when we
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2155 continue in the loop */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2156 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2157 gettimeofday (&tdata->starttime, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2158 pthread_mutex_unlock (tdata->structmutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2159 return (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2160 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2161 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2162 tdata->current_file_retries++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2163 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2164 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2165 else if (tdata->cancel)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2166 return (-1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2167
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2168 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2169 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2170
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2171
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2172 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2173 wakeup_main_thread (gpointer data, gint source, GdkInputCondition condition)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2174 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2175 gftp_request * request;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2176 char c;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2177
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2178 request = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2179 if (request->wakeup_main_thread[0] > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2180 read (request->wakeup_main_thread[0], &c, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2181 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2182
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2183
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2184 static gint
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2185 setup_wakeup_main_thread (gftp_request * request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2186 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2187 gint handler;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2188
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2189 if (socketpair (AF_UNIX, SOCK_STREAM, 0, request->wakeup_main_thread) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2190 {
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
2191 /* FIXME - depreciated in GDK 2.0 */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2192 handler = gdk_input_add (request->wakeup_main_thread[0],
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2193 GDK_INPUT_READ, wakeup_main_thread, request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2194 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2195 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2196 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2197 request->wakeup_main_thread[0] = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2198 request->wakeup_main_thread[1] = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2199 handler = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2200 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2201 return (handler);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2202 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2203
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2204
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2205 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2206 teardown_wakeup_main_thread (gftp_request * request, gint handler)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2207 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2208 if (request->wakeup_main_thread[0] > 0 && request->wakeup_main_thread[1] > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2209 {
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
2210 /* FIXME - depreciated in GDK 2.0 */
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2211 gdk_input_remove (handler);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2212 close (request->wakeup_main_thread[0]);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2213 close (request->wakeup_main_thread[1]);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2214 request->wakeup_main_thread[0] = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2215 request->wakeup_main_thread[1] = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2216 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2217 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2218
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2219
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2220 static mode_t
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2221 parse_attribs (char *attribs)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2222 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2223 mode_t mode;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2224 int cur;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2225
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2226 cur = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2227 if (attribs[1] == 'r')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2228 cur += 4;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2229 if (attribs[2] == 'w')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2230 cur += 2;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2231 if (attribs[3] == 'x' ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2232 attribs[3] == 's')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2233 cur += 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2234 mode = cur;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2235
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2236 cur = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2237 if (attribs[4] == 'r')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2238 cur += 4;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2239 if (attribs[5] == 'w')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2240 cur += 2;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2241 if (attribs[6] == 'x' ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2242 attribs[6] == 's')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2243 cur += 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2244 mode = (mode * 10) + cur;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2245
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2246 cur = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2247 if (attribs[7] == 'r')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2248 cur += 4;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2249 if (attribs[8] == 'w')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2250 cur += 2;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2251 if (attribs[9] == 'x' ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2252 attribs[9] == 's')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2253 cur += 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2254 mode = (mode * 10) + cur;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2255
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2256 return (mode);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2257 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2258
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2259
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2260 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2261 remove_file (char *filename)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2262 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2263 if (unlink (filename) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2264 ftp_log (gftp_logging_misc, NULL, _("Successfully removed %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2265 filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2266 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2267 ftp_log (gftp_logging_error, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2268 _("Error: Could not remove file %s: %s\n"), filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2269 g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2270 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2271