Mercurial > gftp.yaz
changeset 876:2d4e6fca8e7c
2007-2-6 Brian Masney <masneyb@gftp.org>
* src/text/textui.c src/gtk/gtkui_transfer.c src/uicommon/gftpui.h -
added new function: gftpui_cancel_file_transfer()
* src/uicommon/gftpui.c - use gftpui_cancel_file_transfer() to cancel
the file transfers
* lib/gftp.h lib/misc.c src/gtk/transfer.c - added pointer for the
thread_id of the transfer to the gftp_transfer structure. This will be
used in the GTK+ port so that the transfer can be stopped.
author | masneyb |
---|---|
date | Wed, 07 Feb 2007 02:43:57 +0000 |
parents | 19dacfb69433 |
children | 998f2a109150 |
files | ChangeLog lib/gftp.h lib/misc.c src/gtk/gtkui_transfer.c src/gtk/transfer.c src/text/textui.c src/uicommon/gftpui.c src/uicommon/gftpui.h |
diffstat | 8 files changed, 67 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Feb 07 01:56:20 2007 +0000 +++ b/ChangeLog Wed Feb 07 02:43:57 2007 +0000 @@ -1,4 +1,14 @@ 2007-2-6 Brian Masney <masneyb@gftp.org> + * src/text/textui.c src/gtk/gtkui_transfer.c src/uicommon/gftpui.h - + added new function: gftpui_cancel_file_transfer() + + * src/uicommon/gftpui.c - use gftpui_cancel_file_transfer() to cancel + the file transfers + + * lib/gftp.h lib/misc.c src/gtk/transfer.c - added pointer for the + thread_id of the transfer to the gftp_transfer structure. This will be + used in the GTK+ port so that the transfer can be stopped. + * src/gtk/menu-items.c - removed duplicated code that was found by PMD 2007-2-5 Brian Masney <masneyb@gftp.org>
--- a/lib/gftp.h Wed Feb 07 01:56:20 2007 +0000 +++ b/lib/gftp.h Wed Feb 07 02:43:57 2007 +0000 @@ -557,6 +557,7 @@ structmutex; void *user_data; + void *thread_id; void *clist; } gftp_transfer;
--- a/lib/misc.c Wed Feb 07 01:56:20 2007 +0000 +++ b/lib/misc.c Wed Feb 07 02:43:57 2007 +0000 @@ -561,6 +561,8 @@ if (tdata->toreq != NULL) gftp_request_destroy (tdata->toreq, 1); free_file_list (tdata->files); + if (tdata->thread_id != NULL) + g_free (tdata->thread_id); g_free (tdata); }
--- a/src/gtk/gtkui_transfer.c Wed Feb 07 01:56:20 2007 +0000 +++ b/src/gtk/gtkui_transfer.c Wed Feb 07 02:43:57 2007 +0000 @@ -73,6 +73,18 @@ } +void +gftpui_cancel_file_transfer (gftp_transfer * tdata) +{ + if (tdata->thread_id != NULL) + pthread_kill (*(pthread_t *) tdata->thread_id, SIGINT); + + tdata->cancel = 1; /* FIXME */ + tdata->fromreq->cancel = 1; + tdata->toreq->cancel = 1; +} + + static void gftpui_gtk_trans_selectall (GtkWidget * widget, gpointer data) {
--- a/src/gtk/transfer.c Wed Feb 07 01:56:20 2007 +0000 +++ b/src/gtk/transfer.c Wed Feb 07 02:43:57 2007 +0000 @@ -686,33 +686,35 @@ static void create_transfer (gftp_transfer * tdata) { - pthread_t tid; + if (tdata->fromreq->stopable) + return; - if (!tdata->fromreq->stopable) + if (GFTP_IS_SAME_HOST_START_TRANS ((gftp_window_data *) tdata->fromwdata, + tdata->fromreq)) { - if (GFTP_IS_SAME_HOST_START_TRANS ((gftp_window_data *) tdata->fromwdata, - tdata->fromreq)) - { - gftp_swap_socks (tdata->fromreq, - ((gftp_window_data *) tdata->fromwdata)->request); - update_window (tdata->fromwdata); - } + gftp_swap_socks (tdata->fromreq, + ((gftp_window_data *) tdata->fromwdata)->request); + update_window (tdata->fromwdata); + } - if (GFTP_IS_SAME_HOST_START_TRANS ((gftp_window_data *) tdata->towdata, - tdata->toreq)) - { - gftp_swap_socks (tdata->toreq, - ((gftp_window_data *) tdata->towdata)->request); - update_window (tdata->towdata); - } + if (GFTP_IS_SAME_HOST_START_TRANS ((gftp_window_data *) tdata->towdata, + tdata->toreq)) + { + gftp_swap_socks (tdata->toreq, + ((gftp_window_data *) tdata->towdata)->request); + update_window (tdata->towdata); + } - num_transfers_in_progress++; - tdata->started = 1; - tdata->stalled = 1; - gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->user_data, 1, - _("Connecting...")); - pthread_create (&tid, NULL, _gftpui_transfer_files, tdata); - } + num_transfers_in_progress++; + tdata->started = 1; + tdata->stalled = 1; + gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->user_data, 1, + _("Connecting...")); + + if (tdata->thread_id == NULL) + tdata->thread_id = g_malloc0 (sizeof (pthread_t)); + + pthread_create (tdata->thread_id, NULL, _gftpui_transfer_files, tdata); }
--- a/src/text/textui.c Wed Feb 07 01:56:20 2007 +0000 +++ b/src/text/textui.c Wed Feb 07 02:43:57 2007 +0000 @@ -101,6 +101,15 @@ void +gftpui_cancel_file_transfer (gftp_transfer * tdata) +{ + tdata->cancel = 1; + tdata->fromreq->cancel = 1; + tdata->toreq->cancel = 1; +} + + +void gftpui_ask_transfer (gftp_transfer * tdata) { char buf, question[1024], srcsize[50], destsize[50], *pos, defaction;
--- a/src/uicommon/gftpui.c Wed Feb 07 01:56:20 2007 +0000 +++ b/src/uicommon/gftpui.c Wed Feb 07 02:43:57 2007 +0000 @@ -1348,9 +1348,7 @@ curfle->transfer_action = GFTP_TRANS_ACTION_SKIP; if (tdata->curfle != NULL && curfle == tdata->curfle->data) { - tdata->cancel = 1; - tdata->fromreq->cancel = 1; - tdata->toreq->cancel = 1; + gftpui_cancel_file_transfer (tdata); tdata->skip_file = 1; } else if (!curfle->transfer_done) @@ -1373,9 +1371,7 @@ if (tdata->started) { - tdata->cancel = 1; - tdata->fromreq->cancel = 1; - tdata->toreq->cancel = 1; + gftpui_cancel_file_transfer (tdata); tdata->skip_file = 0; } else @@ -1552,6 +1548,8 @@ int ret, skipped_files; tdata->curfle = tdata->files; + gftpui_common_num_child_threads++; + gettimeofday (&tdata->starttime, NULL); memcpy (&tdata->lasttime, &tdata->starttime, sizeof (tdata->lasttime)); @@ -1596,6 +1594,8 @@ skipped_files); tdata->done = 1; + gftpui_common_num_child_threads--; + return (1); }
--- a/src/uicommon/gftpui.h Wed Feb 07 01:56:20 2007 +0000 +++ b/src/uicommon/gftpui.h Wed Feb 07 02:43:57 2007 +0000 @@ -133,6 +133,8 @@ void *touidata, GList * files ); +void gftpui_cancel_file_transfer ( gftp_transfer * tdata ); + void gftpui_common_skip_file_transfer ( gftp_transfer * tdata, gftp_file * curfle );