# HG changeset patch # User masneyb # Date 1075674287 0 # Node ID c5acf744ad7903f18dcef91e2f9a2ea34d760819 # Parent 1c86bcb0b232970f14814cae767e97df628044bb 2003-2-1 Brian Masney * src/gtk/dnd.c - whenever a file(s)/directories are dropped onto gftp, allow resuming the file transfers diff -r 1c86bcb0b232 -r c5acf744ad79 ChangeLog --- a/ChangeLog Sun Feb 01 22:14:15 2004 +0000 +++ b/ChangeLog Sun Feb 01 22:24:47 2004 +0000 @@ -1,4 +1,7 @@ 2003-2-1 Brian Masney + * src/gtk/dnd.c - whenever a file(s)/directories are dropped onto + gftp, allow resuming the file transfers + * lib/protocols.c (gftp_get_dir_listing, gftp_get_all_subdirs) - don't modify the file variable if it begins with a /. Do not touch the destfile variable if it already exists @@ -2117,7 +2120,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.211 2004/02/01 22:14:14 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.212 2004/02/01 22:24:45 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r 1c86bcb0b232 -r c5acf744ad79 src/gtk/dnd.c --- a/src/gtk/dnd.c Sun Feb 01 22:14:15 2004 +0000 +++ b/src/gtk/dnd.c Sun Feb 01 22:24:47 2004 +0000 @@ -22,10 +22,11 @@ static int -dnd_remote_file (char *url, gftp_window_data * wdata) +dnd_remote_file (gftp_window_data * wdata, GList ** trans_list, char *url) { gftp_window_data * other_wdata, * fromwdata; gftp_request * current_ftpdata; + gftp_transfer * tdata; gftp_file * newfle; GList * templist; char *pos; @@ -61,11 +62,12 @@ if (compare_request (current_ftpdata, wdata->request, 1)) { gftp_request_destroy (current_ftpdata, 1); + free_fdata (newfle); return (0); } if (other_wdata != NULL && - compare_request (current_ftpdata, other_wdata->request, 1)) + compare_request (current_ftpdata, other_wdata->request, 0)) { if (other_wdata->request->password != NULL) gftp_set_password (current_ftpdata, other_wdata->request->password); @@ -80,14 +82,30 @@ *(pos - 1) = '\0'; newfle->destfile = gftp_build_path (wdata->request->directory, pos, NULL); - templist = g_malloc0 (sizeof (*templist)); - templist->data = newfle; - templist->next = NULL; - gftpui_common_add_file_transfer (current_ftpdata, wdata->request, fromwdata, - wdata, templist); - gftp_request_destroy (current_ftpdata, 1); + + for (templist = *trans_list; templist != NULL; templist = templist->next) + { + tdata = templist->data; + if (compare_request (current_ftpdata, tdata->fromreq, 0)) + break; + } + + if (templist == NULL) + { + tdata = gftp_tdata_new (); - /* FIXME resume files and download entire directories */ + tdata->fromreq = current_ftpdata; + tdata->fromwdata = fromwdata; + + tdata->toreq = wdata->request; + tdata->towdata = wdata; + + *trans_list = g_list_append (*trans_list, tdata); + } + else + gftp_request_destroy (current_ftpdata, 1); + + tdata->files = g_list_append (tdata->files, newfle); return (1); } @@ -205,7 +223,9 @@ guint32 clk_time, gpointer data) { char *newpos, *oldpos, *tempstr; + GList * trans_list, * templist; gftp_window_data * wdata; + gftp_transfer * tdata; int finish_drag; size_t len; @@ -213,6 +233,7 @@ if (!check_status (_("Drag-N-Drop"), wdata, 1, 0, 0, 1)) return; + trans_list = NULL; finish_drag = 0; if ((selection_data->length >= 0) && (selection_data->format == 8)) { @@ -233,8 +254,9 @@ ftp_log (gftp_logging_misc, NULL, _("Received URL %s\n"), tempstr); - if (dnd_remote_file (tempstr, wdata)) + if (dnd_remote_file (wdata, &trans_list, tempstr)) finish_drag = 1; + g_free (tempstr); if (*newpos == '\0') @@ -245,4 +267,28 @@ } gtk_drag_finish (context, finish_drag, FALSE, clk_time); + + for (templist = trans_list; templist != NULL; templist = templist->next) + { + tdata = templist->data; + + if (tdata->files == NULL || gftp_get_all_subdirs (tdata, NULL) != 0) + { + g_free (tdata); + continue; + } + + if (tdata->files == NULL) + { + g_free (tdata); + continue; + } + + gftpui_common_add_file_transfer (tdata->fromreq, tdata->toreq, + tdata->fromwdata, tdata->towdata, + tdata->files); + g_free (tdata); + } + + g_list_free (trans_list); }