annotate src/gtk/transfer.c @ 59:618423504fe0

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