annotate src/gtk/transfer.c @ 182:33b394ebba68

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