changeset 297:6d088dfece0b

2003-10-26 Brian Masney <masneyb@gftp.org> * src/gtk/gftp-gtk.h src/gtk/transfer.c - (create_transfer, transfer_done) - added more checks whenever a transfer is created and stopped to make sure we don't log into the same remote host twice. This is mainly for DnD.
author masneyb
date Mon, 27 Oct 2003 01:22:45 +0000
parents 51725086634d
children 6e0b9ca541e2
files ChangeLog src/gtk/gftp-gtk.h src/gtk/transfer.c
diffstat 3 files changed, 47 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 27 00:54:25 2003 +0000
+++ b/ChangeLog	Mon Oct 27 01:22:45 2003 +0000
@@ -1,4 +1,9 @@
 2003-10-26 Brian Masney <masneyb@gftp.org>
+	* src/gtk/gftp-gtk.h src/gtk/transfer.c - (create_transfer, 
+	transfer_done) - added more checks whenever a transfer is created and
+	stopped to make sure we don't log into the same remote host twice. This
+	is mainly for DnD.
+
 	* lib/misc.c (copy_request) - don't copy over the hostp pointer. This
 	fixes a segfault in DnD
 
@@ -1626,7 +1631,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.158 2003/10/27 00:54:24 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.159 2003/10/27 01:22:45 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/src/gtk/gftp-gtk.h	Mon Oct 27 00:54:25 2003 +0000
+++ b/src/gtk/gftp-gtk.h	Mon Oct 27 01:22:45 2003 +0000
@@ -30,6 +30,19 @@
 #define IS_ONE_SELECTED(wdata)		(GTK_CLIST ((wdata)->listbox)->selection && GTK_CLIST ((wdata)->listbox)->selection->next == NULL)
 #define IS_NONE_SELECTED(wdata)		(GTK_CLIST ((wdata)->listbox)->selection == NULL)
 
+#define GFTP_IS_SAME_HOST_START_TRANS(wdata,trequest) \
+  ((wdata) != NULL && (wdata)->request != NULL && \
+  (wdata)->request->datafd > 0 && !(wdata)->request->always_connected && \
+  !(wdata)->request->stopable && \
+  compare_request (trequest, (wdata)->request, 0))
+
+#define GFTP_IS_SAME_HOST_STOP_TRANS(wdata,trequest) \
+  ((wdata) != NULL && (wdata)->request != NULL && \
+  (wdata)->request->datafd < 0 && !(wdata)->request->always_connected && \
+  (wdata)->request->cached && !(wdata)->request->stopable && \
+  trequest->datafd > 0 && !trequest->always_connected && \
+  compare_request (trequest, (wdata)->request, 0))
+
 #if GTK_MAJOR_VERSION == 1
   #define gtk_widget_set_size_request(widget, width, height)	\
 				gtk_widget_set_usize (widget, width, height)
--- a/src/gtk/transfer.c	Mon Oct 27 00:54:25 2003 +0000
+++ b/src/gtk/transfer.c	Mon Oct 27 01:22:45 2003 +0000
@@ -1220,25 +1220,26 @@
   if (tdata->started)
     {
       fromreq = tdata->fromwdata != NULL ? ((gftp_window_data *) tdata->fromwdata)->request : NULL;
-      if (!tdata->fromreq->stopable && tdata->fromwdata &&
-          ((fromreq->datafd < 0 && fromreq->cached) || fromreq->always_connected) &&
-          (tdata->fromreq->datafd > 0 || tdata->fromreq->always_connected) &&
-          compare_request (tdata->fromreq, fromreq, 0))
-	{
-          gftp_swap_socks (((gftp_window_data *) tdata->towdata)->request, 
-                           tdata->toreq);
+
+      if (GFTP_IS_SAME_HOST_STOP_TRANS ((gftp_window_data *) tdata->fromwdata,
+                                         tdata->fromreq))
+        {
           gftp_swap_socks (((gftp_window_data *) tdata->fromwdata)->request, 
                            tdata->fromreq);
-	}
+	  refresh (tdata->fromwdata);
+        }
       else
+	gftp_disconnect (tdata->fromreq);
+
+      if (GFTP_IS_SAME_HOST_STOP_TRANS ((gftp_window_data *) tdata->towdata,
+                                         tdata->toreq))
         {
-	  gftp_disconnect (tdata->fromreq);
-          gftp_disconnect (tdata->toreq);
+          gftp_swap_socks (((gftp_window_data *) tdata->towdata)->request, 
+                           tdata->toreq);
+	  refresh (tdata->towdata);
         }
-
-      if (tdata->towdata != NULL && compare_request (tdata->toreq, 
-                           ((gftp_window_data *) tdata->towdata)->request, 1)) 
-	refresh (tdata->towdata);
+      else
+	gftp_disconnect (tdata->toreq);
 
       num_transfers_in_progress--;
     }
@@ -1277,18 +1278,22 @@
 
   if (!tdata->fromreq->stopable)
     {
-      if (tdata->fromwdata && 
-          (((gftp_window_data *) tdata->fromwdata)->request->datafd > 0 ||
-           ((gftp_window_data *) tdata->fromwdata)->request->always_connected) && 
-          !((gftp_window_data *) tdata->fromwdata)->request->stopable &&
-          compare_request (tdata->fromreq, ((gftp_window_data *) tdata->fromwdata)->request, 0))
-	{
+      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);
+        }
+
+      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);
-          gftp_swap_socks (tdata->fromreq, 
-                           ((gftp_window_data *) tdata->fromwdata)->request);
-	  update_window_info ();
+	  update_window (tdata->towdata);
 	}
+
       num_transfers_in_progress++;
       tdata->started = 1;
       tdata->stalled = 1;