annotate src/gtk/delete_dialog.c @ 48:e5f6054590b5

2002-11-5 Brian Masney <masneyb@gftp.org> * lib/*.c src/gtk/*.c - removed function declarations for the static functions from the top of the file. I had to rearrange the order of a bunch of functions to avoid compiler warnings * lib/gftp.h - include sys/sysmacros.h. If major() and minor() isn't defined, give a compiler warning and define our own * lib/local.c (local_get_next_file) - if this file is a device, store the major/minor number in the file size * src/gtk/misc-gtk.c (add_file_listbox) - if this file is a device, use the major() and minor() macros to display the major and minor number
author masneyb
date Wed, 06 Nov 2002 02:20:25 +0000
parents eec25f215772
children a12bcbc2fce4
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 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
26 gftp_request * request;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
27 char *olddir;
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 request = user_data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
30 olddir = request->directory;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
31 request->directory = key;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
32 gftp_delete_cache_entry (request, 0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
33 request->directory = olddir;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
34 g_free (key);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
35 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
36
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
37
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
38 static void *
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
39 do_delete_thread (void *data)
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 gftp_transfer * transfer;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
42 char *pos, *tempstr;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
43 gftp_file * tempfle;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
44 GHashTable * rmhash;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
45 GList * templist;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
46 int success, sj;
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 transfer = data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
49 transfer->fromreq->user_data = (void *) 0x01;
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 (transfer->fromreq->use_threads)
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 sj = sigsetjmp (jmp_environment, 1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
54 use_jmp_environment = 1;
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 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
57 sj = 0;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
58
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
59 if (sj == 0)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
60 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
61 for (templist = transfer->files; templist->next != NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
62 templist = templist->next);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
63
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
64 rmhash = g_hash_table_new (string_hash_function, string_hash_compare);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
65 while (1)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
66 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
67 tempfle = templist->data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
68 if (tempfle->isdir)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
69 success = gftp_remove_directory (transfer->fromreq, tempfle->file);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
70 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
71 success = gftp_remove_file (transfer->fromreq, tempfle->file);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
72
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
73 if (success == 0 && (pos = strrchr (tempfle->file, '/')))
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 *pos = '\0';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
76 if (g_hash_table_lookup (rmhash, tempfle->file) == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
77 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
78 tempstr = g_strconcat (tempfle->file, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
79 g_hash_table_insert (rmhash, tempstr, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
80 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
81 *pos = '/';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
82 }
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 if (templist == transfer->files ||
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
85 !GFTP_IS_CONNECTED (transfer->fromreq))
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
86 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
87 templist = templist->prev;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
88 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
89
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
90 g_hash_table_foreach (rmhash, delete_purge_cache, transfer->fromreq);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
91 g_hash_table_destroy (rmhash);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
92 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
93 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
94 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
95 gftp_disconnect (transfer->fromreq);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
96 transfer->fromreq->logging_function (gftp_logging_error,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
97 transfer->fromreq->user_data,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
98 _("Operation canceled\n"));
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 transfer->fromreq->user_data = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
102 transfer->fromreq->stopable = 0;
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 if (transfer->fromreq->use_threads)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
105 use_jmp_environment = 0;
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 return (NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
108 }
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
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
111 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
112 yesCB (gftp_transfer * transfer, gftp_dialog_data * ddata)
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 gftp_window_data * wdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
115 void * ret;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
116
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
117 g_return_if_fail (transfer != NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
118 g_return_if_fail (transfer->files != NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
119
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
120 wdata = transfer->fromwdata;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
121 if (check_reconnect (wdata) < 0)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
122 return;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
123
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
124 gtk_clist_freeze (GTK_CLIST (wdata->listbox));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
125 swap_socks (transfer->fromreq, wdata->request);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
126 if (wdata->request->use_threads)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
127 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
128 wdata->request->stopable = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
129 transfer->fromreq->stopable = 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
130 gtk_widget_set_sensitive (stop_btn, 1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
131 pthread_create (&wdata->tid, NULL, do_delete_thread, transfer);
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 while (transfer->fromreq->stopable)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
134 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
135 GDK_THREADS_LEAVE ();
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
136 #if GTK_MAJOR_VERSION == 1
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
137 g_main_iteration (TRUE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
138 #else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
139 g_main_context_iteration (NULL, TRUE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
140 #endif
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
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
143 gtk_widget_set_sensitive (stop_btn, 0);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
144 pthread_join (wdata->tid, &ret);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
145 wdata->request->stopable = 0;
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 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
148 ret = do_delete_thread (transfer);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
149 swap_socks (wdata->request, transfer->fromreq);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
150 free_tdata (transfer);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
151
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
152 if (!GFTP_IS_CONNECTED (wdata->request))
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
153 disconnect (wdata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
154 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
155 refresh (wdata);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
156
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
157 gtk_clist_thaw (GTK_CLIST (wdata->listbox));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
158 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
159
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
160
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
161 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
162 askdel (gftp_transfer * transfer)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
163 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
164 char *tempstr;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
165
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
166 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
167
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
168 MakeYesNoDialog (_("Delete Files/Directories"), tempstr,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
169 yesCB, transfer, NULL, NULL);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
170 g_free (tempstr);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
171 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
172
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 delete_dialog (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 gftp_file * tempfle, * newfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 GList * templist, * filelist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 gftp_transfer * transfer;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180 gftp_window_data * wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 long numfiles, numdirs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 int num, timeout_num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183 void *ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 wdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 if (!check_status (_("Delete"), wdata, wdata->request->use_threads, 0, 1, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 transfer = g_malloc0 (sizeof (*transfer));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 transfer->fromreq = copy_request (wdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 transfer->fromwdata = wdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 transfer->transfer_direction = GFTP_DIRECTION_DOWNLOAD;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 templist = GTK_CLIST (wdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 filelist = wdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 templist = get_next_selection (templist, &filelist, &num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 tempfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 if (strcmp (tempfle->file, "..") == 0 ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 strcmp (tempfle->file, ".") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 newfle = copy_fdata (tempfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 transfer->files = g_list_append (transfer->files, newfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 if (transfer->files == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 free_tdata (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 swap_socks (transfer->fromreq, wdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 if (transfer->fromreq->use_threads)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 wdata->request->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 transfer->fromreq->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 gtk_widget_set_sensitive (stop_btn, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 pthread_create (&wdata->tid, NULL, do_getdir_thread, transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
223 timeout_num = gtk_timeout_add (100, progress_timeout, transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224 while (transfer->fromreq->stopable)
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
225 {
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
226 GDK_THREADS_LEAVE ();
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 42
diff changeset
227 #if GTK_MAJOR_VERSION == 1
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
228 g_main_iteration (TRUE);
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
229 #else
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
230 g_main_context_iteration (NULL, TRUE);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
231 #endif
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
232 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 gtk_widget_set_sensitive (stop_btn, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 gtk_timeout_remove (timeout_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 numfiles = transfer->numfiles;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 numdirs = transfer->numdirs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 transfer->numfiles = transfer->numdirs = -1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 update_directory_download_progress (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 transfer->numfiles = numfiles;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 transfer->numdirs = numdirs;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 pthread_join (wdata->tid, &ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244 wdata->request->stopable = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 ret = do_getdir_thread (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 if (!GFTP_IS_CONNECTED (transfer->fromreq))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 disconnect (wdata);
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
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 swap_socks (wdata->request, transfer->fromreq);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
256
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 askdel (transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260