annotate src/gtk/transfer.c @ 433:77fffba5e170

2004-3-17 Brian Masney <masneyb@gftp.org> * lib/options.h src/gtk/transfer.c - added start file transfers option
author masneyb
date Wed, 17 Mar 2004 20:42:53 +0000
parents 14ef37b62c20
children 39d9cf1bf0df
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 */
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 246
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
1
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
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
23 static int num_transfers_in_progress = 0;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
25 int
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
26 ftp_list_files (gftp_window_data * wdata, int usecache)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
27 {
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
28 gftpui_callback_data * cdata;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
29
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
30 gtk_label_set (GTK_LABEL (wdata->hoststxt), _("Receiving file names..."));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
31
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
32 cdata = g_malloc0 (sizeof (*cdata));
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
33 cdata->request = wdata->request;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
34 cdata->uidata = wdata;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
35 cdata->run_function = gftpui_common_run_ls;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
36
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
37 gftpui_common_run_callback_function (cdata);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
38
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
39 wdata->files = cdata->files;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
40 g_free (cdata);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
41
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
42 if (wdata->files == NULL || !GFTP_IS_CONNECTED (wdata->request))
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
43 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
44 gftpui_disconnect (wdata);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
45 return (0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
46 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
47
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
48 wdata->sorted = 0;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
49 sortrows (GTK_CLIST (wdata->listbox), -1, (gpointer) wdata);
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
50
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
51 if (IS_NONE_SELECTED (wdata))
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
52 gtk_clist_select_row (GTK_CLIST (wdata->listbox), 0, 0);
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
53
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
54 return (1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
55 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
56
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
57
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
58 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
59 ftp_connect (gftp_window_data * wdata, gftp_request * request, int getdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
60 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
61 if (wdata->request == request)
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
62 gtk_label_set (GTK_LABEL (wdata->hoststxt), _("Connecting..."));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
63
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
64 return (gftpui_common_cmd_open (wdata, request, NULL, NULL, NULL));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
65 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
66
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
67
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
68 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
69 get_files (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
70 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
71 transfer_window_files (&window2, &window1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
72 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
73
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
74
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
75 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
76 put_files (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78 transfer_window_files (&window1, &window2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
82 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
83 transfer_window_files (gftp_window_data * fromwdata, gftp_window_data * towdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
84 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
85 gftp_file * tempfle, * newfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
86 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
87 gftp_transfer * transfer;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
88 guint timeout_num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
89 void *ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
90 int num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
91
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
92 if (!check_status (_("Transfer Files"), fromwdata, 1, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
93 towdata->request->put_file != NULL && fromwdata->request->get_file != NULL))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
94 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
95
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
96 if (!GFTP_IS_CONNECTED (fromwdata->request) ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
97 !GFTP_IS_CONNECTED (towdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
98 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
99 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
100 _("Retrieve Files: Not connected to a remote site\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
101 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
102 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104 if (check_reconnect (fromwdata) < 0 || check_reconnect (towdata) < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107 transfer = g_malloc0 (sizeof (*transfer));
368
af541d789f4c 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
108 transfer->fromreq = gftp_copy_request (fromwdata->request);
af541d789f4c 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
109 transfer->toreq = gftp_copy_request (towdata->request);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110 transfer->fromwdata = fromwdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
111 transfer->towdata = towdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113 num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 templist = GTK_CLIST (fromwdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 filelist = fromwdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
117 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 templist = get_next_selection (templist, &filelist, &num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 if (strcmp (tempfle->file, "..") != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122 newfle = copy_fdata (tempfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123 transfer->files = g_list_append (transfer->files, newfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 if (transfer->files != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 {
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 59
diff changeset
129 gftp_swap_socks (transfer->fromreq, fromwdata->request);
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 59
diff changeset
130 gftp_swap_socks (transfer->toreq, towdata->request);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
132 if (gftpui_common_use_threads (transfer->fromreq) ||
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
133 (transfer->toreq && gftpui_common_use_threads (transfer->toreq)))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 transfer->fromreq->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 pthread_create (&fromwdata->tid, NULL, do_getdir_thread, transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
137
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
138 timeout_num = gtk_timeout_add (100, progress_timeout, transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140 while (transfer->fromreq->stopable)
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
141 {
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
142 GDK_THREADS_LEAVE ();
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
143 #if GTK_MAJOR_VERSION == 1
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
144 g_main_iteration (TRUE);
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
145 #else
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
146 g_main_context_iteration (NULL, TRUE);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 40
diff changeset
147 #endif
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
148 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
149
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
150 gtk_timeout_remove (timeout_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
151 transfer->numfiles = transfer->numdirs = -1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 update_directory_download_progress (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
154 pthread_join (fromwdata->tid, &ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
155 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
157 ret = do_getdir_thread (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159 if (!GFTP_IS_CONNECTED (transfer->fromreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
161 gftpui_disconnect (fromwdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 if (!GFTP_IS_CONNECTED (transfer->toreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 {
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
167 gftpui_disconnect (towdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 59
diff changeset
171 gftp_swap_socks (fromwdata->request, transfer->fromreq);
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 59
diff changeset
172 gftp_swap_socks (towdata->request, transfer->toreq);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 if (transfer->files != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
177 gftpui_common_add_file_transfer (transfer->fromreq, transfer->toreq,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
178 transfer->fromwdata, transfer->towdata,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
179 transfer->files);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180 g_free (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 else
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
183 free_tdata (transfer);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 void *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 do_getdir_thread (void * data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 gftp_transfer * transfer;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 int success, sj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 transfer = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
194 if (gftpui_common_use_threads (transfer->fromreq) ||
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
195 (transfer->toreq && gftpui_common_use_threads (transfer->toreq)))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 {
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
197 sj = sigsetjmp (gftpui_common_jmp_environment, 1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
198 gftpui_common_use_jmp_environment = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 sj = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 success = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 if (sj == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 success = gftp_get_all_subdirs (transfer, NULL) == 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 gftp_disconnect (transfer->fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 if (transfer->toreq)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 gftp_disconnect (transfer->toreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 transfer->fromreq->logging_function (gftp_logging_error,
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
212 transfer->fromreq,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 _("Operation canceled\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
216 if (gftpui_common_use_threads (transfer->fromreq) ||
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
217 (transfer->toreq && gftpui_common_use_threads (transfer->toreq)))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
218 gftpui_common_use_jmp_environment = 0;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 transfer->fromreq->stopable = 0;
195
3fa7b4f4ab78 2003-6-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
221 return (GINT_TO_POINTER (success));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
223
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224
305
6d180e6a8ba5 2003-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
225 static void
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
226 remove_file (char *filename)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
227 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
228 if (unlink (filename) == 0)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
229 ftp_log (gftp_logging_misc, NULL, _("Successfully removed %s\n"),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
230 filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
231 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
232 ftp_log (gftp_logging_error, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
233 _("Error: Could not remove file %s: %s\n"), filename,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
234 g_strerror (errno));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
235 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
236
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
237
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
238 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
239 free_edit_data (gftp_viewedit_data * ve_proc)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
240 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
241 int i;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
242
294
4747f621b79b 2003-10-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 278
diff changeset
243 if (ve_proc->torequest)
4747f621b79b 2003-10-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 278
diff changeset
244 gftp_request_destroy (ve_proc->torequest, 1);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
245 if (ve_proc->filename)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
246 g_free (ve_proc->filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
247 if (ve_proc->remote_filename)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
248 g_free (ve_proc->remote_filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
249 for (i = 0; ve_proc->argv[i] != NULL; i++)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
250 g_free (ve_proc->argv[i]);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
251 g_free (ve_proc->argv);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
252 g_free (ve_proc);
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
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
255
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
256 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
257 dont_upload (gftp_viewedit_data * ve_proc, gftp_dialog_data * ddata)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
259 remove_file (ve_proc->filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
260 free_edit_data (ve_proc);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
261 }
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
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
264 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
265 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
266 {
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 297
diff changeset
267 gftp_transfer * tdata;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
268 gftp_file * tempfle;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
269 GList * newfile;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
271 tempfle = g_malloc0 (sizeof (*tempfle));
294
4747f621b79b 2003-10-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 278
diff changeset
272 tempfle->destfile = gftp_build_path (ve_proc->torequest->directory,
4747f621b79b 2003-10-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 278
diff changeset
273 ve_proc->remote_filename, NULL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
274 ve_proc->remote_filename = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
275 tempfle->file = ve_proc->filename;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
276 ve_proc->filename = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
277 tempfle->done_rm = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
278 newfile = g_list_append (NULL, tempfle);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
279 tdata = gftpui_common_add_file_transfer (ve_proc->fromwdata->request,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
280 ve_proc->torequest,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
281 ve_proc->fromwdata,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
282 ve_proc->towdata, newfile);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
283 free_edit_data (ve_proc);
303
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 297
diff changeset
284
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 297
diff changeset
285 if (tdata != NULL)
3b9d5797050f 2003-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 297
diff changeset
286 tdata->conn_error_no_timeout = 1;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
287 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
288
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
289
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
290 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
291 check_done_process (void)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
292 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
293 gftp_viewedit_data * ve_proc;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
294 GList * curdata, *deldata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
295 struct stat st;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
296 int ret;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
297 char *str;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
298 pid_t pid;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
299
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
300 viewedit_process_done = 0;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
301 while ((pid = waitpid (-1, &ret, WNOHANG)) > 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
302 {
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
303 curdata = viewedit_processes;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
304 while (curdata != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
305 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
306 ve_proc = curdata->data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
307 deldata = curdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
308 curdata = curdata->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
309 if (ve_proc->pid == pid)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
310 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
311 viewedit_processes = g_list_remove_link (viewedit_processes,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
312 deldata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
313 if (ret != 0)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
314 ftp_log (gftp_logging_error, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
315 _("Error: Child %d returned %d\n"), pid, ret);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
316 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
317 ftp_log (gftp_logging_misc, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
318 _("Child %d returned successfully\n"), pid);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
319
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
320 if (!ve_proc->view && !ve_proc->dontupload)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
321 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
322 /* We was editing the file. Upload it */
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
323 if (stat (ve_proc->filename, &st) == -1)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
324 ftp_log (gftp_logging_error, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
325 _("Error: Cannot get information about file %s: %s\n"),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
326 ve_proc->filename, g_strerror (errno));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
327 else if (st.st_mtime == ve_proc->st.st_mtime)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
328 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
329 ftp_log (gftp_logging_misc, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
330 _("File %s was not changed\n"),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
331 ve_proc->filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
332 remove_file (ve_proc->filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
333 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
334 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
335 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
336 memcpy (&ve_proc->st, &st, sizeof (ve_proc->st));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
337 str = g_strdup_printf (
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
338 _("File %s has changed.\nWould you like to upload it?"),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
339 ve_proc->remote_filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
340
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
341 MakeYesNoDialog (_("Edit File"), str,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
342 do_upload, ve_proc,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
343 dont_upload, ve_proc);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
344 g_free (str);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
345 continue;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
346 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
347 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
348
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
349 free_edit_data (ve_proc);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
350 continue;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
351 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
352 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
353 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
354 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
355
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
356
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
357 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
358 on_next_transfer (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
359 {
326
cdabbe5c9a95 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
360 int fd;
cdabbe5c9a95 2003-12-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 320
diff changeset
361 intptr_t refresh_files;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
363
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
364 tdata->next_file = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365 for (; tdata->updfle != tdata->curfle; tdata->updfle = tdata->updfle->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
366 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367 tempfle = tdata->updfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
369 if (tempfle->is_fd)
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
370 fd = tempfle->fd;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
371 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
372 fd = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
373
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
374 if (tempfle->done_view)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
375 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
376 if (tempfle->transfer_action != GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
377 view_file (tempfle->destfile, fd, 1, tempfle->done_rm, 1, 0,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
378 tempfle->file, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
379
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
380 if (tempfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
381 {
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
382 close (tempfle->fd);
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
383 tempfle->fd = -1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386 else if (tempfle->done_edit)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388 if (tempfle->transfer_action != GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389 view_file (tempfle->destfile, fd, 0, tempfle->done_rm, 1, 0,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390 tempfle->file, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392 if (tempfle->is_fd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
393 {
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
394 close (tempfle->fd);
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
395 tempfle->fd = -1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398 else if (tempfle->done_rm)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399 tdata->fromreq->rmfile (tdata->fromreq, tempfle->file);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401 if (tempfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
402 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
403 _("Skipped"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404 else
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
405 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406 _("Finished"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
407 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
408
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
409 gftp_lookup_request_option (tdata->fromreq, "refresh_files", &refresh_files);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
410
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
411 if (refresh_files && tdata->curfle && tdata->curfle->next &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
412 compare_request (tdata->toreq,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
413 ((gftp_window_data *) tdata->towdata)->request, 1))
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
414 gftpui_refresh (tdata->towdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
415 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
416
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
418 static void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
419 get_trans_password (gftp_request * request, gftp_dialog_data * ddata)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
420 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
421 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
422 request->stopable = 0;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
423 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
424
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
425
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
426 static void
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
427 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
428 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
429 if (tdata->fromreq->stopable == 0)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
430 return;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
431
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
432 g_static_mutex_lock (&tdata->structmutex);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
433 if (tdata->started)
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
434 {
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
435 tdata->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
436 tdata->fromreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
437 tdata->toreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
438 }
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
439 else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
440 tdata->done = 1;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
441
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
442 tdata->fromreq->stopable = 0;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
443 tdata->toreq->stopable = 0;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
444 g_static_mutex_unlock (&tdata->structmutex);
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
445
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
446 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
447 ((gftp_file *) tdata->curfle->data)->file);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
448 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
449
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
450
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
451 static void
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
452 show_transfer (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
453 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
454 GdkPixmap * closedir_pixmap, * opendir_pixmap;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
455 GdkBitmap * closedir_bitmap, * opendir_bitmap;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
456 gftpui_common_curtrans_data * transdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
457 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
458 GList * templist;
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
459 char *text[2];
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
460
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
461 gftp_get_pixmap (dlwdw, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
462 gftp_get_pixmap (dlwdw, "dir.xpm", &closedir_pixmap, &closedir_bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
463
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
464 text[0] = tdata->fromreq->hostname;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
465 text[1] = _("Waiting...");
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
466 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
467 text, 5,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
468 closedir_pixmap, closedir_bitmap,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
469 opendir_pixmap, opendir_bitmap,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
470 FALSE,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
471 tdata->numdirs + tdata->numfiles < 50);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
472 transdata = g_malloc (sizeof (*transdata));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
473 transdata->transfer = tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
474 transdata->curfle = NULL;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
475 gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tdata->user_data, transdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
476 tdata->show = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
477 tdata->curfle = tdata->updfle = tdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
478
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
479 tdata->total_bytes = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
480 for (templist = tdata->files; templist != NULL; templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
481 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
482 tempfle = templist->data;
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
483
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
484 text[0] = gftpui_gtk_get_utf8_file_pos (tempfle);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
485 if (tempfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
486 text[1] = _("Skipped");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
487 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
488 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
489 tdata->total_bytes += tempfle->size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
490 text[1] = _("Waiting...");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
491 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
492
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
493 tempfle->user_data = gtk_ctree_insert_node (GTK_CTREE (dlwdw),
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
494 tdata->user_data,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
495 NULL, text, 5, NULL, NULL, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
496 NULL, FALSE, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
497 transdata = g_malloc (sizeof (*transdata));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
498 transdata->transfer = tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
499 transdata->curfle = templist;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
500 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
501 transdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
502 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
503
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
504 if (!tdata->toreq->stopable && tdata->toreq->need_userpass &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
505 (tdata->toreq->password == NULL || *tdata->toreq->password == '\0'))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
506 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
507 tdata->toreq->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
508 MakeEditDialog (_("Enter Password"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
509 _("Please enter your password for this site"), NULL, 0,
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
510 NULL, gftp_dialog_button_connect,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
511 get_trans_password, tdata->toreq,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
512 cancel_get_trans_password, tdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
513 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
514
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
515 if (!tdata->fromreq->stopable && tdata->fromreq->need_userpass &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
516 (tdata->fromreq->password == NULL || *tdata->fromreq->password == '\0'))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
517 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
518 tdata->fromreq->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
519 MakeEditDialog (_("Enter Password"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
520 _("Please enter your password for this site"), NULL, 0,
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
521 NULL, gftp_dialog_button_connect,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
522 get_trans_password, tdata->fromreq,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
523 cancel_get_trans_password, tdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
524 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
525 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
526
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
527
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
528 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
529 transfer_done (GList * node)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
530 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
531 gftpui_common_curtrans_data * transdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
532 gftp_request * fromreq;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
533 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
534 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
535 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
536
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
537 tdata = node->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
538 if (tdata->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
539 {
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
540 fromreq = tdata->fromwdata != NULL ? ((gftp_window_data *) tdata->fromwdata)->request : NULL;
297
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
541
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
542 if (GFTP_IS_SAME_HOST_STOP_TRANS ((gftp_window_data *) tdata->fromwdata,
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
543 tdata->fromreq))
309
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
544 {
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
545 gftp_copy_param_options (((gftp_window_data *) tdata->fromwdata)->request, tdata->fromreq);
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
546
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
547 gftp_swap_socks (((gftp_window_data *) tdata->fromwdata)->request,
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
548 tdata->fromreq);
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
549 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
550 else
297
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
551 gftp_disconnect (tdata->fromreq);
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
552
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
553 if (GFTP_IS_SAME_HOST_STOP_TRANS ((gftp_window_data *) tdata->towdata,
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
554 tdata->toreq))
309
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
555 {
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
556 gftp_copy_param_options (((gftp_window_data *) tdata->towdata)->request, tdata->toreq);
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
557
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
558 gftp_swap_socks (((gftp_window_data *) tdata->towdata)->request,
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
559 tdata->toreq);
cc2eeb30b793 2003-11-7 Brian Masney <masneyb@gftp.org>
masneyb
parents: 305
diff changeset
560 }
297
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
561 else
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
562 gftp_disconnect (tdata->toreq);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
563
305
6d180e6a8ba5 2003-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
564 if (tdata->towdata != NULL && compare_request (tdata->toreq,
6d180e6a8ba5 2003-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
565 ((gftp_window_data *) tdata->towdata)->request, 1))
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 326
diff changeset
566 gftpui_refresh (tdata->towdata);
305
6d180e6a8ba5 2003-11-3 Brian Masney <masneyb@gftp.org>
masneyb
parents: 303
diff changeset
567
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
568 num_transfers_in_progress--;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
569 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
570
2
a171df6764a7 * Fixed crash if you was already transfering a file, and you started another
masneyb
parents: 1
diff changeset
571 if (!tdata->show && tdata->started)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
572 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
573 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw),
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
574 tdata->user_data);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
575 if (transdata != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
576 g_free (transdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
577
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
578 for (templist = tdata->files; templist != NULL; templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
579 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
580 tempfle = templist->data;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
581 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw),
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
582 tempfle->user_data);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
583 if (transdata != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
584 g_free (transdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
585 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
586
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
587 gtk_ctree_remove_node (GTK_CTREE (dlwdw), tdata->user_data);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
588 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
589
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
590 g_static_mutex_lock (&gftpui_common_transfer_mutex);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
591 gftp_file_transfers = g_list_remove_link (gftp_file_transfers, node);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
592 g_static_mutex_unlock (&gftpui_common_transfer_mutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
593
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
594 gdk_window_set_title (gtk_widget_get_parent_window (GTK_WIDGET(dlwdw)),
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
595 gftp_version);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
596
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
597 free_tdata (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
598 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
599
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
600
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
601 static void *
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
602 _gftpui_transfer_files (void *data)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
603 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
604 int ret;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
605
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
606 pthread_detach (pthread_self ());
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
607 ret = gftpui_common_transfer_files (data);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
608 return (GINT_TO_POINTER(ret));
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
609 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
610
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
611
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
612 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
613 create_transfer (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
614 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
615 pthread_t tid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
616
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
617 if (!tdata->fromreq->stopable)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
618 {
297
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
619 if (GFTP_IS_SAME_HOST_START_TRANS ((gftp_window_data *) tdata->fromwdata,
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
620 tdata->fromreq))
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
621 {
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
622 gftp_swap_socks (tdata->fromreq,
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
623 ((gftp_window_data *) tdata->fromwdata)->request);
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
624 update_window (tdata->fromwdata);
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
625 }
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
626
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
627 if (GFTP_IS_SAME_HOST_START_TRANS ((gftp_window_data *) tdata->towdata,
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
628 tdata->toreq))
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
629 {
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 59
diff changeset
630 gftp_swap_socks (tdata->toreq,
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 59
diff changeset
631 ((gftp_window_data *) tdata->towdata)->request);
297
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
632 update_window (tdata->towdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
633 }
297
6d088dfece0b 2003-10-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
634
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
635 num_transfers_in_progress++;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
636 tdata->started = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
637 tdata->stalled = 1;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
638 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->user_data, 1,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
639 _("Connecting..."));
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
640 pthread_create (&tid, NULL, _gftpui_transfer_files, tdata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
641 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
642 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
643
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
644
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
645 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
646 update_file_status (gftp_transfer * tdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
647 {
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
648 char totstr[100], dlstr[100], winstr[150], gotstr[50], ofstr[50];
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
649 int hours, mins, secs, pcent, st, show_trans_in_title;
246
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
650 unsigned long remaining_secs, lkbs;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
651 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
652 struct timeval tv;
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
653
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
654 g_static_mutex_lock (&tdata->statmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
655 tempfle = tdata->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
656
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
657 gettimeofday (&tv, NULL);
220
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
658
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
659 remaining_secs = (tdata->total_bytes - tdata->trans_bytes - tdata->resumed_bytes) / 1024;
246
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
660
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
661 lkbs = (unsigned long) tdata->kbs;
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
662 if (lkbs > 0)
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
663 remaining_secs /= lkbs;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
664
220
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
665 hours = remaining_secs / 3600;
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
666 remaining_secs -= hours * 3600;
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
667 mins = remaining_secs / 60;
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
668 remaining_secs -= mins * 60;
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
669 secs = remaining_secs;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
670
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
671 if (hours < 0 || mins < 0 || secs < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
672 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
673 g_static_mutex_unlock (&tdata->statmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
674 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
675 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
676
246
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
677 if ((double) tdata->total_bytes > 0)
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
678 pcent = (int) ((double) (tdata->trans_bytes + tdata->resumed_bytes) / (double) tdata->total_bytes * 100.0);
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
679 else
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
680 pcent = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
681
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
682 g_snprintf (totstr, sizeof (totstr),
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
683 _("%d%% complete, %02d:%02d:%02d est. time remaining. (File %ld of %ld)"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
684 pcent, hours, mins, secs, tdata->current_file_number,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
685 tdata->numdirs + tdata->numfiles);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
686
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
687 *dlstr = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
688 if (!tdata->stalled)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
689 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
690 insert_commas (tdata->curtrans + tdata->curresumed, gotstr, sizeof (gotstr));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
691 insert_commas (tempfle->size, ofstr, sizeof (ofstr));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
692 st = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
693 if (tv.tv_sec - tdata->lasttime.tv_sec <= 5)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
694 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
695 if (tdata->curfle->next != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
696 {
220
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
697 remaining_secs = (tempfle->size - tdata->curtrans - tdata->curresumed) / 1024;
246
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
698
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
699 lkbs = (unsigned long) tdata->kbs;
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
700 if (lkbs > 0)
290d00853950 2003-8-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 234
diff changeset
701 remaining_secs /= lkbs;
220
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
702
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
703 hours = remaining_secs / 3600;
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
704 remaining_secs -= hours * 3600;
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
705 mins = remaining_secs / 60;
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
706 remaining_secs -= mins * 60;
6de9a8280aa4 2003-7-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 207
diff changeset
707 secs = remaining_secs;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
708 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
709
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
710 if (!(hours < 0 || mins < 0 || secs < 0))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
711 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
712 g_snprintf (dlstr, sizeof (dlstr),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
713 _("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
714 st = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
715 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
716 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
717
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
718 if (st)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
719 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
720 tdata->stalled = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
721 g_snprintf (dlstr, sizeof (dlstr),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
722 _("Recv %s of %s, transfer stalled, unknown time remaining"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
723 gotstr, ofstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
724 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
725 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
726
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
727 g_static_mutex_unlock (&tdata->statmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
728
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
729 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->user_data, 1, totstr);
320
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
730
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
731 gftp_lookup_global_option ("show_trans_in_title", &show_trans_in_title);
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
732 if (gftp_file_transfers->data == tdata && show_trans_in_title)
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
733 {
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
734 g_snprintf (winstr, sizeof(winstr), "%s: %s", gftp_version, totstr);
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
735 gdk_window_set_title (gtk_widget_get_parent_window (GTK_WIDGET(dlwdw)),
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
736 winstr);
853981bbd4d7 2003-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 319
diff changeset
737 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
738
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
739 if (*dlstr != '\0')
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
740 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1, dlstr);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
741 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
742
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
743
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
744 static void
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
745 update_window_transfer_bytes (gftp_window_data * wdata)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
746 {
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
747 char *tempstr, *temp1str;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
748
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
749 if (wdata->request->gotbytes == -1)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
750 {
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
751 update_window_info ();
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
752 wdata->request->gotbytes = 0;
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
753 }
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
754 else
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
755 {
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
756 tempstr = insert_commas (wdata->request->gotbytes, NULL, 0);
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
757 temp1str = g_strdup_printf (_("Retrieving file names...%s bytes"),
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
758 tempstr);
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
759 gtk_label_set (GTK_LABEL (wdata->hoststxt), temp1str);
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
760 g_free (tempstr);
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
761 g_free (temp1str);
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
762 }
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
763 }
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
764
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
765
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
766 gint
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
767 update_downloads (gpointer data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
768 {
433
77fffba5e170 2004-3-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
769 intptr_t do_one_transfer_at_a_time, start_transfers;
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
770 GList * templist, * next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
771 gftp_transfer * tdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
772
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
773 if (gftp_file_transfer_logs != NULL)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
774 display_cached_logs ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
775
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
776 if (window1.request->gotbytes != 0)
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
777 update_window_transfer_bytes (&window1);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
778 if (window2.request->gotbytes != 0)
56
a12bcbc2fce4 2002-11-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 49
diff changeset
779 update_window_transfer_bytes (&window2);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
780
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
781 if (viewedit_process_done)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
782 check_done_process ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
783
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
784 for (templist = gftp_file_transfers; templist != NULL;)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
785 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
786 tdata = templist->data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
787 if (tdata->ready)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
788 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
789 g_static_mutex_lock (&tdata->structmutex);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
790
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
791 if (tdata->next_file)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
792 on_next_transfer (tdata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
793 else if (tdata->show)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
794 show_transfer (tdata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
795 else if (tdata->done)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
796 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
797 next = templist->next;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
798 g_static_mutex_unlock (&tdata->structmutex);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
799 transfer_done (templist);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
800 templist = next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
801 continue;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
802 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
803
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
804 if (tdata->curfle != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
805 {
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 143
diff changeset
806 gftp_lookup_global_option ("one_transfer",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
807 &do_one_transfer_at_a_time);
433
77fffba5e170 2004-3-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
808 gftp_lookup_global_option ("start_transfers", &start_transfers);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
809
433
77fffba5e170 2004-3-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 397
diff changeset
810 if (!tdata->started && start_transfers &&
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
811 (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
812 create_transfer (tdata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
813
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
814 if (tdata->started)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
815 update_file_status (tdata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
816 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
817 g_static_mutex_unlock (&tdata->structmutex);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
818 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
819 templist = templist->next;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
820 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
821
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
822 gtk_timeout_add (500, update_downloads, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
823 return (0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
824 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
825
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
826
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
827 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
828 start_transfer (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
829 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
830 gftpui_common_curtrans_data * transdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
831 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
832
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
833 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
834 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
835 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
836 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
837 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
838 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
839 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
840 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
841
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
842 g_static_mutex_lock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
843 if (!transdata->transfer->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
844 create_transfer (transdata->transfer);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
845 g_static_mutex_unlock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
846 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
847
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
848
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
849 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
850 stop_transfer (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
851 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
852 gftpui_common_curtrans_data * transdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
853 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
854
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
855 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
856 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
857 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
858 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
859 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
860 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
861 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
862 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
863
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
864 g_static_mutex_lock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
865 if (transdata->transfer->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
866 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
867 transdata->transfer->cancel = 1;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
868 transdata->transfer->fromreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
869 transdata->transfer->toreq->cancel = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
870 transdata->transfer->skip_file = 0;
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 transdata->transfer->done = 1;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
874 g_static_mutex_unlock (&transdata->transfer->structmutex);
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
875
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
876 ftp_log (gftp_logging_misc, NULL, _("Stopping the transfer on host %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
877 transdata->transfer->fromreq->hostname);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
878 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
879
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
880
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
881 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
882 skip_transfer (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
883 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
884 gftpui_common_curtrans_data * transdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
885 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
886 gftp_file * curfle;
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
887 char *file;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
888
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
889 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
890 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
891 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
892 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
893 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
894 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
895 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
896 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
897
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
898 g_static_mutex_lock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
899 if (transdata->transfer->curfle != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
900 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
901 curfle = transdata->transfer->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
902 if (transdata->transfer->started)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
903 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
904 transdata->transfer->cancel = 1;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
905 transdata->transfer->fromreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
906 transdata->transfer->toreq->cancel = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
907 transdata->transfer->skip_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
908 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
909
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
910 curfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
911 file = curfle->file;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
912 }
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
913 else
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
914 file = NULL;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
915 g_static_mutex_unlock (&transdata->transfer->structmutex);
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
916
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
917 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
918 file, transdata->transfer->fromreq->hostname);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
919 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
920
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
921
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
922 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
923 remove_file_transfer (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
924 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
925 gftpui_common_curtrans_data * transdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
926 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
927 gftp_file * curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
928
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
929 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
930 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
931 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
932 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
933 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
934 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
935
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
936 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
937 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
938
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
939
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
940 if (transdata->curfle == NULL || transdata->curfle->data == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
941 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
942
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
943 curfle = transdata->curfle->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
944
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
945 if (curfle->transfer_action & GFTP_TRANS_ACTION_SKIP)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
946 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
947
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
948 g_static_mutex_lock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
949
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
950 curfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
951
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
952 if (transdata->transfer->started &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
953 transdata->curfle == transdata->transfer->curfle)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
954 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
955 transdata->transfer->cancel = 1;
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
956 transdata->transfer->fromreq->cancel = 1;
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
957 transdata->transfer->toreq->cancel = 1;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
958 transdata->transfer->skip_file = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
959 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
960 else if (transdata->curfle != transdata->transfer->curfle &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
961 !curfle->transfer_done)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
962 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
963 gtk_ctree_node_set_text (GTK_CTREE (dlwdw), curfle->user_data, 1,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
964 _("Skipped"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
965 transdata->transfer->total_bytes -= curfle->size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
966 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
967
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
968 g_static_mutex_unlock (&transdata->transfer->structmutex);
40
66c064fd05bc 2002-10-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 37
diff changeset
969
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
970 ftp_log (gftp_logging_misc, NULL, _("Skipping file %s on host %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
971 curfle->file, transdata->transfer->fromreq->hostname);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
972 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
973
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
974
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
975 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
976 move_transfer_up (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
977 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
978 GList * firstentry, * secentry, * lastentry;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
979 gftpui_common_curtrans_data * transdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
980 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
981
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
982 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
983 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
984 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
985 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
986 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
987 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
988 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
989 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
990
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
991 if (transdata->curfle == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
992 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
993
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
994 g_static_mutex_lock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
995 if (transdata->curfle->prev != NULL && (!transdata->transfer->started ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
996 (transdata->transfer->curfle != transdata->curfle &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
997 transdata->transfer->curfle != transdata->curfle->prev)))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
998 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
999 if (transdata->curfle->prev->prev == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1000 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1001 firstentry = transdata->curfle->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1002 lastentry = transdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1003 transdata->transfer->files = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1004 transdata->curfle->next = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1005 transdata->transfer->files->prev = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1006 firstentry->prev = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1007 firstentry->next = lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1008 if (lastentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1009 lastentry->prev = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1010 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1011 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1012 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1013 firstentry = transdata->curfle->prev->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1014 secentry = transdata->curfle->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1015 lastentry = transdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1016 firstentry->next = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1017 transdata->curfle->prev = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1018 transdata->curfle->next = secentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1019 secentry->prev = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1020 secentry->next = lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1021 if (lastentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1022 lastentry->prev = secentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1023 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1024
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1025 gtk_ctree_move (GTK_CTREE (dlwdw),
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1026 ((gftp_file *) transdata->curfle->data)->user_data,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1027 transdata->transfer->user_data,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1028 transdata->curfle->next != NULL ?
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1029 ((gftp_file *) transdata->curfle->next->data)->user_data: NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1030 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1031 g_static_mutex_unlock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1032 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1033
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1034
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1035 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1036 move_transfer_down (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1037 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1038 GList * firstentry, * secentry, * lastentry;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1039 gftpui_common_curtrans_data * transdata;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1040 GtkCTreeNode * node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1041
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1042 if (GTK_CLIST (dlwdw)->selection == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1043 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1044 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1045 _("There are no file transfers selected\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1046 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1047 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1048 node = GTK_CLIST (dlwdw)->selection->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1049 transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1050
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1051 if (transdata->curfle == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1052 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1053
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1054 g_static_mutex_lock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1055 if (transdata->curfle->next != NULL && (!transdata->transfer->started ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1056 (transdata->transfer->curfle != transdata->curfle &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1057 transdata->transfer->curfle != transdata->curfle->next)))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1058 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1059 if (transdata->curfle->prev == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1060 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1061 firstentry = transdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1062 lastentry = transdata->curfle->next->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1063 transdata->transfer->files = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1064 transdata->transfer->files->prev = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1065 transdata->transfer->files->next = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1066 transdata->curfle->prev = transdata->transfer->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1067 transdata->curfle->next = lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1068 if (lastentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1069 lastentry->prev = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1070 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1071 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1072 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1073 firstentry = transdata->curfle->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1074 secentry = transdata->curfle->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1075 lastentry = transdata->curfle->next->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1076 firstentry->next = secentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1077 secentry->prev = firstentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1078 secentry->next = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1079 transdata->curfle->prev = secentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1080 transdata->curfle->next = lastentry;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1081 if (lastentry != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1082 lastentry->prev = transdata->curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1083 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1084
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1085 gtk_ctree_move (GTK_CTREE (dlwdw),
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1086 ((gftp_file *) transdata->curfle->data)->user_data,
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1087 transdata->transfer->user_data,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1088 transdata->curfle->next != NULL ?
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1089 ((gftp_file *) transdata->curfle->next->data)->user_data: NULL);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1090 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 86
diff changeset
1091 g_static_mutex_unlock (&transdata->transfer->structmutex);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1092 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1093