annotate src/gtk/transfer.c @ 356:7cb3327f96f7

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