changeset 508:a95c5acdacf6

2004-7-19 Brian Masney <masneyb@gftp.org> * src/gtk/transfer.c src/uicommon/gftpui.h - use the new thread callback functions for retrieving the list of subdirectories
author masneyb
date Tue, 20 Jul 2004 02:00:59 +0000
parents 34a4c6ec453c
children b6ce74de1cd9
files ChangeLog src/gtk/transfer.c src/uicommon/gftpui.h
diffstat 3 files changed, 26 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jul 20 01:23:19 2004 +0000
+++ b/ChangeLog	Tue Jul 20 02:00:59 2004 +0000
@@ -1,4 +1,7 @@
 2004-7-19 Brian Masney <masneyb@gftp.org>
+	* src/gtk/transfer.c src/uicommon/gftpui.h - use the new thread callback
+	functions for retrieving the list of subdirectories
+
 	* src/gtk/delete_dialog.c src/uicommon/gftpuicallbacks.c - use the
 	new thread callback functions for deleting items from the GTK+ GUI
 
@@ -2591,7 +2594,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.285 2004/07/20 01:23:19 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.286 2004/07/20 02:00:59 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/src/gtk/transfer.c	Tue Jul 20 01:23:19 2004 +0000
+++ b/src/gtk/transfer.c	Tue Jul 20 02:00:59 2004 +0000
@@ -167,88 +167,41 @@
 }
 
 
-static void *
-_gftp_getdir_thread (void * data)
+static int
+_gftp_getdir_thread (gftpui_callback_data * cdata)
 {
-  gftp_transfer * transfer;
-  int success, sj;
-
-  transfer = data;
-
-  if (gftpui_common_use_threads (transfer->fromreq) || 
-      (transfer->toreq && gftpui_common_use_threads (transfer->toreq)))
-    {
-      sj = sigsetjmp (gftpui_common_jmp_environment, 1);
-      gftpui_common_use_jmp_environment = 1;
-    }
-  else
-    sj = 0;
-
-  success = 0;
-  if (sj == 0)
-    success = gftp_get_all_subdirs (transfer, NULL) == 0;
-  else
-    {
-      gftp_disconnect (transfer->fromreq);
-      if (transfer->toreq)
-        gftp_disconnect (transfer->toreq);
-      transfer->fromreq->logging_function (gftp_logging_error,
-                                           transfer->fromreq,
-                                           _("Operation canceled\n"));
-    }
-
-  if (gftpui_common_use_threads (transfer->fromreq) || 
-      (transfer->toreq && gftpui_common_use_threads (transfer->toreq)))
-    gftpui_common_use_jmp_environment = 0;
-
-  transfer->fromreq->stopable = 0;
-  return (GINT_TO_POINTER (success));
+  return (gftp_get_all_subdirs (cdata->user_data, NULL));
 }
 
 
 int
 gftp_gtk_get_subdirs (gftp_transfer * transfer, pthread_t *tid)
 {
+  gftpui_callback_data * cdata; 
   long numfiles, numdirs;
   guint timeout_num;
-  void *ret;
+  int ret;
 
-  if (gftpui_common_use_threads (transfer->fromreq) || 
-      (transfer->toreq && gftpui_common_use_threads (transfer->toreq)))
-    {
-      transfer->fromreq->stopable = 1;
-      gtk_widget_set_sensitive (stop_btn, 1);
-
-      pthread_create (tid, NULL, _gftp_getdir_thread, transfer);
-
-      timeout_num = gtk_timeout_add (100, progress_timeout, transfer);
+  cdata = g_malloc0 (sizeof (*cdata));
+  cdata->user_data = transfer;
+  cdata->uidata = transfer->fromwdata;
+  cdata->request = ((gftp_window_data *) transfer->fromwdata)->request;
+  cdata->run_function = _gftp_getdir_thread;
 
-      while (transfer->fromreq->stopable)
-        {
-          GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1
-          g_main_iteration (TRUE);
-#else
-          g_main_context_iteration (NULL, TRUE);
-#endif
-        }
-
-      gtk_widget_set_sensitive (stop_btn, 0);
-      gtk_timeout_remove (timeout_num);
+  timeout_num = gtk_timeout_add (100, progress_timeout, transfer);
+  ret = gftpui_common_run_callback_function (cdata);
+  gtk_timeout_remove (timeout_num);
 
-      numfiles = transfer->numfiles;
-      numdirs = transfer->numdirs;
-      transfer->numfiles = transfer->numdirs = -1; 
-      update_directory_download_progress (transfer);
-      transfer->numfiles = numfiles;
-      transfer->numdirs = numdirs;
+  numfiles = transfer->numfiles;
+  numdirs = transfer->numdirs;
+  transfer->numfiles = transfer->numdirs = -1; 
+  update_directory_download_progress (transfer);
+  transfer->numfiles = numfiles;
+  transfer->numdirs = numdirs;
 
-      pthread_join (*tid, &ret);
-    }
-  else
-    ret = _gftp_getdir_thread (transfer);
+  g_free (cdata);
 
-  return (GPOINTER_TO_INT (ret));
+  return (ret);
 }
 
 
--- a/src/uicommon/gftpui.h	Tue Jul 20 01:23:19 2004 +0000
+++ b/src/uicommon/gftpui.h	Tue Jul 20 02:00:59 2004 +0000
@@ -33,6 +33,7 @@
   char *input_string,
        *source_string;
   GList * files;
+  void *user_data;
   int retries;
   int (*run_function) (gftpui_callback_data * cdata);
   unsigned int dont_check_connection : 1;