annotate src/gtk/delete_dialog.c @ 253:a46c2eef5139

2003-8-11 Brian Masney <masneyb@gftp.org> * src/gtk/delete_dialog.c - don't attempt to clear the cache for the protocols that have the cache disabled * lib/local.c (local_chdir) - if request->directory == directory, don't free the request->directory and run getcwd(). This fixes a double free in the delete dialog in the GTK+ port * lib/gftp.h - added FIXME comment * lib/cache.c (gftp_delete_cache_entry) - added assertion
author masneyb
date Tue, 12 Aug 2003 00:04:37 +0000
parents 13ca1defdc75
children 2ad324cf4930
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 /* delete_dialog.c - the delete dialog */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 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
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
23 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
24 delete_purge_cache (gpointer key, gpointer value, gpointer user_data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
25 {
182
33b394ebba68 2003-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
26 gftp_delete_cache_entry (NULL, key, 0);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
27 g_free (key);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
28 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
29
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
30
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
31 static void *
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
32 do_delete_thread (void *data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
33 {
182
33b394ebba68 2003-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
34 char *tempstr, description[BUFSIZ];
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
35 gftp_transfer * transfer;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
36 gftp_file * tempfle;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
37 GHashTable * rmhash;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
38 GList * templist;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
39 int success, sj;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
40
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
41 transfer = data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
42
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
43 if (transfer->fromreq->use_threads)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
44 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
45 sj = sigsetjmp (jmp_environment, 1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
46 use_jmp_environment = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
47 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
48 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
49 sj = 0;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
50
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
51 if (sj == 0)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
52 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
53 for (templist = transfer->files; templist->next != NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
54 templist = templist->next);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
55
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
56 rmhash = g_hash_table_new (string_hash_function, string_hash_compare);
253
a46c2eef5139 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
57
a46c2eef5139 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
58 for (; templist != NULL; templist = templist->prev)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
59 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
60 tempfle = templist->data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
61 if (tempfle->isdir)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
62 success = gftp_remove_directory (transfer->fromreq, tempfle->file);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
63 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
64 success = gftp_remove_file (transfer->fromreq, tempfle->file);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
65
253
a46c2eef5139 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
66 if (success == 0 && transfer->fromreq->use_cache)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
67 {
182
33b394ebba68 2003-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
68 gftp_generate_cache_description (transfer->fromreq, description,
33b394ebba68 2003-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
69 sizeof (description), 0);
33b394ebba68 2003-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
70 if (g_hash_table_lookup (rmhash, description) == NULL)
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
71 {
182
33b394ebba68 2003-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
72 tempstr = g_strdup (description);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
73 g_hash_table_insert (rmhash, tempstr, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
74 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
75 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
76
253
a46c2eef5139 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
77 if (!GFTP_IS_CONNECTED (transfer->fromreq))
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
78 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
79 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
80
182
33b394ebba68 2003-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
81 g_hash_table_foreach (rmhash, delete_purge_cache, NULL);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
82 g_hash_table_destroy (rmhash);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
83 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
84 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
85 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
86 gftp_disconnect (transfer->fromreq);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
87 transfer->fromreq->logging_function (gftp_logging_error,
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
88 transfer->fromreq,
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
89 _("Operation canceled\n"));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
90 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
91
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
92 transfer->fromreq->stopable = 0;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
93
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
94 if (transfer->fromreq->use_threads)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
95 use_jmp_environment = 0;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
96
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
97 return (NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
98 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
99
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
100
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
101 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
102 yesCB (gftp_transfer * transfer, gftp_dialog_data * ddata)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
103 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
104 gftp_window_data * wdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
105 void * ret;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
106
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
107 g_return_if_fail (transfer != NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
108 g_return_if_fail (transfer->files != NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
109
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
110 wdata = transfer->fromwdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
111 if (check_reconnect (wdata) < 0)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
112 return;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
113
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
114 gtk_clist_freeze (GTK_CLIST (wdata->listbox));
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
115 gftp_swap_socks (transfer->fromreq, wdata->request);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
116 if (wdata->request->use_threads)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
117 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
118 wdata->request->stopable = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
119 transfer->fromreq->stopable = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
120 gtk_widget_set_sensitive (stop_btn, 1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
121 pthread_create (&wdata->tid, NULL, do_delete_thread, transfer);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
122
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
123 while (transfer->fromreq->stopable)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
124 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
125 GDK_THREADS_LEAVE ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
126 #if GTK_MAJOR_VERSION == 1
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
127 g_main_iteration (TRUE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
128 #else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
129 g_main_context_iteration (NULL, TRUE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
130 #endif
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
131 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
132
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
133 gtk_widget_set_sensitive (stop_btn, 0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
134 pthread_join (wdata->tid, &ret);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
135 wdata->request->stopable = 0;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
136 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
137 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
138 ret = do_delete_thread (transfer);
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
139 gftp_swap_socks (wdata->request, transfer->fromreq);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
140 free_tdata (transfer);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
141
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
142 if (!GFTP_IS_CONNECTED (wdata->request))
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
143 disconnect (wdata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
144 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
145 refresh (wdata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
146
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
147 gtk_clist_thaw (GTK_CLIST (wdata->listbox));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
148 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
149
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
150
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
151 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
152 askdel (gftp_transfer * transfer)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
153 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
154 char *tempstr;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
155
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
156 tempstr = g_strdup_printf (_("Are you sure you want to delete these %ld files and %ld directories"), transfer->numfiles, transfer->numdirs);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
157
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
158 MakeYesNoDialog (_("Delete Files/Directories"), tempstr,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
159 yesCB, transfer, NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
160 g_free (tempstr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
161 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
162
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 delete_dialog (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
167 gftp_file * tempfle, * newfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169 gftp_transfer * transfer;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171 long numfiles, numdirs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172 int num, timeout_num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 void *ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176 if (!check_status (_("Delete"), wdata, wdata->request->use_threads, 0, 1, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 transfer = g_malloc0 (sizeof (*transfer));
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
180 transfer->fromreq = copy_request (wdata->request, 0);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 transfer->fromwdata = wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 transfer->transfer_direction = GFTP_DIRECTION_DOWNLOAD;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184 num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 templist = GTK_CLIST (wdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 filelist = wdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 templist = get_next_selection (templist, &filelist, &num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 if (strcmp (tempfle->file, "..") == 0 ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 strcmp (tempfle->file, ".") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 newfle = copy_fdata (tempfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 transfer->files = g_list_append (transfer->files, newfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 if (transfer->files == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 free_tdata (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
204 gftp_swap_socks (transfer->fromreq, wdata->request);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 if (transfer->fromreq->use_threads)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 wdata->request->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 transfer->fromreq->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 gtk_widget_set_sensitive (stop_btn, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 pthread_create (&wdata->tid, NULL, do_getdir_thread, transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 timeout_num = gtk_timeout_add (100, progress_timeout, transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 while (transfer->fromreq->stopable)
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
215 {
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
216 GDK_THREADS_LEAVE ();
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 42
diff changeset
217 #if GTK_MAJOR_VERSION == 1
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
218 g_main_iteration (TRUE);
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
219 #else
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
220 g_main_context_iteration (NULL, TRUE);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
221 #endif
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
222 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
223
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224 gtk_widget_set_sensitive (stop_btn, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 gtk_timeout_remove (timeout_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
226 numfiles = transfer->numfiles;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
227 numdirs = transfer->numdirs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 transfer->numfiles = transfer->numdirs = -1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229 update_directory_download_progress (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
230 transfer->numfiles = numfiles;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 transfer->numdirs = numdirs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233 pthread_join (wdata->tid, &ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 wdata->request->stopable = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 ret = do_getdir_thread (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 if (!GFTP_IS_CONNECTED (transfer->fromreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 disconnect (wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244
63
41b71c4e5076 2002-11-2333 Brian Masney <masneyb@gftp.org>
masneyb
parents: 56
diff changeset
245 gftp_swap_socks (wdata->request, transfer->fromreq);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 askdel (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250