annotate src/gtk/transfer.c @ 234:251845fc1ef1

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