changeset 380:05ee37a5558b

2003-1-28 Brian Masney <masneyb@gftp.org> * src/gtk/bookmarks.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/gtkui.c src/gtk/menu-items.c src/gtk/transfer.c - renamed disconnect() to gftpui_disconnect() * src/gtk/gtkui.c src/text/textui.c src/uicommon/gftpui.c - improved prompting for the username/password * src/gtk/gtkui.c src/text/textui.c src/uicommon/gftpui.c - call gftpui_disconnect() after a command is run and if we are no longer connected to the remote host * src/text/gftp-text.c - parse the command line arguments for the host to connect to * src/text/textui.c (gftpui_refresh) - clear the cache. (gftpui_ask_transfer) - check for carriage return or empty string * src/uicommon/gftp.h - define gftpui_common_cmd_m{get,put}_file() * lib/sshv2.c - removed temporary "fix"
author masneyb
date Wed, 28 Jan 2004 23:46:28 +0000
parents c9aa122a1b92
children 1c86bcb0b232
files ChangeLog lib/sshv2.c src/gtk/bookmarks.c src/gtk/delete_dialog.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/gtkui.c src/gtk/menu-items.c src/gtk/transfer.c src/text/gftp-text.c src/text/textui.c src/uicommon/gftpui.c src/uicommon/gftpui.h
diffstat 14 files changed, 139 insertions(+), 97 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 28 10:52:53 2004 +0000
+++ b/ChangeLog	Wed Jan 28 23:46:28 2004 +0000
@@ -1,3 +1,25 @@
+2003-1-28 Brian Masney <masneyb@gftp.org>
+	* src/gtk/bookmarks.c src/gtk/dnd.c src/gtk/gftp-gtk.c
+	src/gtk/gftp-gtk.h src/gtk/gtkui.c src/gtk/menu-items.c 
+	src/gtk/transfer.c - renamed disconnect() to gftpui_disconnect()
+
+	* src/gtk/gtkui.c src/text/textui.c src/uicommon/gftpui.c - improved
+	prompting for the username/password
+
+	* src/gtk/gtkui.c src/text/textui.c src/uicommon/gftpui.c - call
+	gftpui_disconnect() after a command is run and if we are no longer
+	connected to the remote host
+
+	* src/text/gftp-text.c - parse the command line arguments for the host
+	to connect to
+
+	* src/text/textui.c (gftpui_refresh) - clear the cache.
+	(gftpui_ask_transfer) - check for carriage return or empty string
+
+	* src/uicommon/gftp.h - define gftpui_common_cmd_m{get,put}_file()
+
+	* lib/sshv2.c - removed temporary "fix"
+
 2003-1-27 Brian Masney <masneyb@gftp.org>
 	* lib/gftp.h lib/misc.c src/gtk/gtkui_transfer.c src/text/textui.c - 
 	added gftp_get_transfer_action(). When a file is to be transfered and
@@ -2090,7 +2112,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.209 2004/01/27 23:48:24 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.210 2004/01/28 23:46:25 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/sshv2.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/lib/sshv2.c	Wed Jan 28 23:46:28 2004 +0000
@@ -2154,7 +2154,7 @@
 {
   sshv2_params * params;
   sshv2_message message;
-  static char tempstr[32768]; /* FIXME - temporary fix for FreeBSD */
+  char tempstr[32768];
   gint32 num;
   size_t len;
   int ret;
--- a/src/gtk/bookmarks.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/gtk/bookmarks.c	Wed Jan 28 23:46:28 2004 +0000
@@ -42,7 +42,7 @@
     }
 
   if (GFTP_IS_CONNECTED (current_wdata->request))
-    disconnect (current_wdata);
+    gftpui_disconnect (current_wdata);
 
   if (gftp_parse_bookmark (current_wdata->request, other_wdata->request,
                            (char *) data, &refresh_local) < 0)
--- a/src/gtk/delete_dialog.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/gtk/delete_dialog.c	Wed Jan 28 23:46:28 2004 +0000
@@ -140,7 +140,7 @@
   free_tdata (transfer);
 
   if (!GFTP_IS_CONNECTED (wdata->request))
-    disconnect (wdata);
+    gftpui_disconnect (wdata);
   else
     gftpui_refresh (wdata);
 
@@ -237,7 +237,7 @@
 
   if (!GFTP_IS_CONNECTED (transfer->fromreq))
     {
-      disconnect (wdata);
+      gftpui_disconnect (wdata);
       return;
     }
 
--- a/src/gtk/dnd.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/gtk/dnd.c	Wed Jan 28 23:46:28 2004 +0000
@@ -101,7 +101,7 @@
   if ((selection_data->length >= 0) && (selection_data->format == 8)) 
     {
       if (GFTP_IS_CONNECTED (current_wdata->request))
-        disconnect (current_wdata);
+        gftpui_disconnect (current_wdata);
 
       if (gftp_parse_url (current_wdata->request, 
                           (char *) selection_data->data) == 0)
--- a/src/gtk/gftp-gtk.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/gtk/gftp-gtk.c	Wed Jan 28 23:46:28 2004 +0000
@@ -199,7 +199,7 @@
   edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry));
 
   if (GFTP_IS_CONNECTED (current_wdata->request))
-    disconnect (current_wdata);
+    gftpui_disconnect (current_wdata);
   else if (edttxt != NULL && *edttxt != '\0')
     toolbar_hostedit (NULL, NULL);
   else
@@ -230,7 +230,7 @@
     {N_("/_Local"), NULL, 0, 0, MN_("<Branch>")},
     {N_("/Local/tearoff"), NULL, 0, 0, MN_("<Tearoff>")},
     {N_("/Local/Open _URL..."), NULL, openurl_dialog, 0, MS_(GTK_STOCK_OPEN)},
-    {N_("/Local/Disconnect"), NULL, disconnect, 0, MS_(GTK_STOCK_CLOSE)},
+    {N_("/Local/Disconnect"), NULL, gftpui_disconnect, 0, MS_(GTK_STOCK_CLOSE)},
     {N_("/Local/sep"), NULL, 0, 0, MN_("<Separator>")},
     {N_("/Local/Change Filespec..."), NULL, change_filespec, 0, MN_(NULL)},
     {N_("/Local/Show selected"), NULL, show_selected, 0, MN_(NULL)},
@@ -252,7 +252,7 @@
     {N_("/Remote/tearoff"), NULL, 0, 0, MN_("<Tearoff>")},
     {N_("/Remote/Open _URL..."), "<control>U", openurl_dialog, 0,
 	MS_(GTK_STOCK_OPEN)},
-    {N_("/Remote/Disconnect"), "<control>D", disconnect, 0,
+    {N_("/Remote/Disconnect"), "<control>D", gftpui_disconnect, 0,
 	MS_(GTK_STOCK_CLOSE)},
     {N_("/Remote/sep"), NULL, 0, 0, MN_("<Separator>")},
     {N_("/Remote/Change Filespec..."), NULL, change_filespec, 0, MN_(NULL)},
@@ -1012,7 +1012,7 @@
     }
 
   if (GFTP_IS_CONNECTED (current_wdata->request))
-    disconnect (current_wdata);
+    gftpui_disconnect (current_wdata);
 
   tempwid = gtk_menu_get_active (GTK_MENU (protocol_menu));
   num = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (tempwid)));
--- a/src/gtk/gftp-gtk.h	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/gtk/gftp-gtk.h	Wed Jan 28 23:46:28 2004 +0000
@@ -265,8 +265,6 @@
 void gftpui_chdir_dialog 			( gpointer data );
 
 /* menu_items.c */
-void disconnect 				( gpointer data );
-
 void change_filespec 				( gpointer data );
 
 void save_directory_listing 			( gpointer data );
--- a/src/gtk/gtkui.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/gtk/gtkui.c	Wed Jan 28 23:46:28 2004 +0000
@@ -65,34 +65,39 @@
 #define _GFTPUI_GTK_USER_PW_SIZE	256
 
 static void 
-_gftpui_gtk_try_connect_again (char *tempstr, gftp_dialog_data * ddata)
+_gftpui_gtk_set_username (gftp_request * request, gftp_dialog_data * ddata)
 {
-  strncpy (tempstr, gtk_entry_get_text (GTK_ENTRY (ddata->edit)),
-           _GFTPUI_GTK_USER_PW_SIZE);
-  /* FIXME request->stopable = 0; */
+  gftp_set_username (request, gtk_entry_get_text (GTK_ENTRY (ddata->edit)));
+  request->stopable = 0;
+}
+
+
+static void 
+_gftpui_gtk_set_password (gftp_request * request, gftp_dialog_data * ddata)
+{
+  gftp_set_password (request, gtk_entry_get_text (GTK_ENTRY (ddata->edit)));
+  request->stopable = 0;
 }
 
 
 static void
-_gftpui_gtk_dont_connect_again (char *tempstr, gftp_dialog_data * ddata)
+_gftpui_gtk_abort (gftp_request * request, gftp_dialog_data * ddata)
 {
-  /* FIXME request->stopable = 0; */
+  request->stopable = 0;
 }
 
 
-char *
+void
 gftpui_prompt_username (void *uidata, gftp_request * request)
 {
-  char tempstr[_GFTPUI_GTK_USER_PW_SIZE];
-
   MakeEditDialog (_("Enter Username"),
                   _("Please enter your username for this site"), NULL,
                   0, NULL, gftp_dialog_button_connect,
-                  _gftpui_gtk_try_connect_again, tempstr,
-                  _gftpui_gtk_dont_connect_again, tempstr);
+                  _gftpui_gtk_set_username, request,
+                  _gftpui_gtk_abort, request);
 
-  *tempstr = '\0';
-  while (*tempstr == '\0') /* FIXME */
+  request->stopable = 1;
+  while (request->stopable)
     {
       GDK_THREADS_LEAVE ();
 #if GTK_MAJOR_VERSION == 1
@@ -101,27 +106,20 @@
       g_main_context_iteration (NULL, TRUE);
 #endif
     }
-
-  if (*tempstr == '\0')
-    return (NULL);
-  else
-    return (g_strdup (tempstr));
 }
 
 
-char *
+void
 gftpui_prompt_password (void *uidata, gftp_request * request)
 {
-  char tempstr[_GFTPUI_GTK_USER_PW_SIZE];
-
   MakeEditDialog (_("Enter Password"),
                   _("Please enter your password for this site"), NULL,
                   0, NULL, gftp_dialog_button_connect,
-                  _gftpui_gtk_try_connect_again, tempstr,
-                  _gftpui_gtk_dont_connect_again, tempstr);
+                  _gftpui_gtk_set_password, request,
+                  _gftpui_gtk_abort, request);
 
-  *tempstr = '\0';
-  while (*tempstr == '\0') /* FIXME */
+  request->stopable = 1;
+  while (request->stopable)
     {
       GDK_THREADS_LEAVE ();
 #if GTK_MAJOR_VERSION == 1
@@ -130,11 +128,6 @@
       g_main_context_iteration (NULL, TRUE);
 #endif
     }
-
-  if (*tempstr == '\0')
-    return (NULL);
-  else
-    return (g_strdup (tempstr));
 }
 
 
@@ -243,7 +236,7 @@
   gtk_widget_set_sensitive (stop_btn, 0);
 
   if (!GFTP_IS_CONNECTED (wdata->request))
-    disconnect (wdata);
+    gftpui_disconnect (wdata);
 
   return (ret);
 }
@@ -428,3 +421,16 @@
   g_free (tempstr);
 }
 
+
+void 
+gftpui_disconnect (void *uidata)
+{
+  gftp_window_data * wdata;
+
+  wdata = uidata;
+  gftp_delete_cache_entry (wdata->request, NULL, 1);
+  gftp_disconnect (wdata->request);
+  remove_files_window (wdata);
+  update_window (wdata);
+}
+
--- a/src/gtk/menu-items.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/gtk/menu-items.c	Wed Jan 28 23:46:28 2004 +0000
@@ -20,19 +20,6 @@
 #include <gftp-gtk.h>
 static const char cvsid[] = "$Id$";
 
-void 
-disconnect (gpointer data)
-{
-  gftp_window_data * wdata;
-
-  wdata = data;
-  gftp_delete_cache_entry (wdata->request, NULL, 1);
-  gftp_disconnect (wdata->request);
-  remove_files_window (wdata);
-  update_window (wdata);
-}
-
-
 static void
 dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata)
 {
--- a/src/gtk/transfer.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/gtk/transfer.c	Wed Jan 28 23:46:28 2004 +0000
@@ -41,7 +41,7 @@
   
   if (wdata->files == NULL || !GFTP_IS_CONNECTED (wdata->request))
     {
-      disconnect (wdata);
+      gftpui_disconnect (wdata);
       return (0);
     }
 
@@ -158,13 +158,13 @@
 
       if (!GFTP_IS_CONNECTED (transfer->fromreq))
         {
-          disconnect (fromwdata);
+          gftpui_disconnect (fromwdata);
           return;
         } 
 
       if (!GFTP_IS_CONNECTED (transfer->toreq))
         {
-          disconnect (towdata);
+          gftpui_disconnect (towdata);
           return;
         } 
 
--- a/src/text/gftp-text.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/text/gftp-text.c	Wed Jan 28 23:46:28 2004 +0000
@@ -194,7 +194,8 @@
 int
 main (int argc, char **argv)
 {
-  char *startup_directory;
+  char *startup_directory, *pos;
+  void *locuidata, *remuidata;
 #if HAVE_LIBREADLINE
   char *tempstr, prompt[20];
 #else
@@ -207,6 +208,7 @@
      line */
 
   gftp_text_remreq = gftp_request_new ();
+  remuidata = gftp_text_remreq;
   gftp_set_request_option (gftp_text_remreq, "ssh_use_askpass", 
                            GINT_TO_POINTER(0));
   gftp_set_request_option (gftp_text_remreq, "sshv2_use_sftp_subsys", 
@@ -214,6 +216,7 @@
   gftp_text_remreq->logging_function = gftp_text_log;
 
   gftp_text_locreq = gftp_request_new ();
+  locuidata = gftp_text_locreq;
   gftp_set_request_option (gftp_text_locreq, "ssh_use_askpass", 
                            GINT_TO_POINTER(0));
   gftp_set_request_option (gftp_text_locreq, "sshv2_use_sftp_subsys", 
@@ -233,29 +236,37 @@
   gftpui_common_about (gftp_text_log, NULL);
   gftp_text_log (gftp_logging_misc, NULL, "\n");
 
-/* FIXME
   if (argc == 3 && strcmp (argv[1], "-d") == 0)
     {
       if ((pos = strrchr (argv[2], '/')) != NULL)
         *pos = '\0';
-      gftp_text_open (gftp_text_remreq, argv[2], NULL);
+
+      gftpui_common_cmd_open (remuidata, gftp_text_remreq,
+                              locuidata, gftp_text_locreq,
+                              argv[2]);
 
       if (pos != NULL)
         *pos = '/';
 
-      gftp_text_mget_file (gftp_text_remreq, pos + 1, NULL);
+      gftpui_common_cmd_mget_file (remuidata, gftp_text_remreq,
+                                   locuidata, gftp_text_locreq,
+                                   pos + 1);
       exit (0);
     }
   else if (argc == 2)
-    gftp_text_open (gftp_text_remreq, argv[1], NULL);
-*/
+    {
+      gftpui_common_cmd_open (remuidata, gftp_text_remreq,
+                              locuidata, gftp_text_locreq,
+                              argv[1]);
+    }
 
 #if HAVE_LIBREADLINE
   g_snprintf (prompt, sizeof (prompt), "%sftp%s> ", GFTPUI_COMMON_COLOR_BLUE, GFTPUI_COMMON_COLOR_DEFAULT);
   while ((tempstr = readline (prompt)))
     {
-      if (gftpui_common_process_command (NULL, gftp_text_locreq,
-                                         NULL, gftp_text_remreq, tempstr) == 0)
+      if (gftpui_common_process_command (locuidata, gftp_text_locreq,
+                                         remuidata, gftp_text_remreq,
+                                         tempstr) == 0)
         break;
    
       add_history (tempstr);
--- a/src/text/textui.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/text/textui.c	Wed Jan 28 23:46:28 2004 +0000
@@ -40,7 +40,10 @@
 void
 gftpui_refresh (void *uidata)
 {
-  /* FIXME - clear the cache entry */
+  gftp_request * request;
+
+  request = uidata; /* Note: uidata is set to the request in gftp_text.c */
+  gftp_delete_cache_entry (request, NULL, 0);
 }
 
 
@@ -58,26 +61,26 @@
 }
 
 
-char *
+void
 gftpui_prompt_username (void *uidata, gftp_request * request)
 {
-  char tempstr[256], *ret;
+  char tempstr[256];
 
-  ret = g_strdup (gftp_text_ask_question (_("Username [anonymous]:"), 1,
-                                          tempstr, sizeof (tempstr)));
-  return (ret);
+  gftp_set_username (request, 
+                     gftp_text_ask_question (_("Username [anonymous]:"), 1,
+                                             tempstr, sizeof (tempstr)));
 }
 
 
 
-char *
+void
 gftpui_prompt_password (void *uidata, gftp_request * request)
 {
-  char tempstr[256], *ret;
+  char tempstr[256];
 
-  ret = g_strdup (gftp_text_ask_question (_("Password:"), 0,
-                                          tempstr, sizeof (tempstr)));
-  return (ret);
+  gftp_set_password (request,
+                     gftp_text_ask_question (_("Password:"), 0,
+                                             tempstr, sizeof (tempstr)));
 }
 
 
@@ -85,7 +88,6 @@
 gftpui_add_file_to_transfer (gftp_transfer * tdata, GList * curfle,
                              char *filepos )
 {
-  /* FIXME */
 }
 
 
@@ -159,6 +161,12 @@
               case 'S':
                 action = newaction = GFTP_TRANS_ACTION_SKIP;
                 break;
+              case '\0':
+              case '\n':
+                break;
+              default:
+                action = -1;
+                break;
             }
         }
 
@@ -226,3 +234,9 @@
   gftpui_common_transfer_files (tdata);
 }
 
+
+void
+gftpui_disconnect (void *uidata)
+{
+}
+
--- a/src/uicommon/gftpui.c	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/uicommon/gftpui.c	Wed Jan 28 23:46:28 2004 +0000
@@ -604,7 +604,6 @@
 {
   gftpui_callback_data * cdata;
   intptr_t retries;
-  char *tempstr;
 
   if (GFTP_IS_CONNECTED (request))
     {
@@ -627,25 +626,12 @@
   if (request->need_userpass)
     {
       if (request->username == NULL || *request->username == '\0')
-        {
-          if ((tempstr = gftpui_prompt_username (uidata, request)) != NULL)
-            {
-              gftp_set_username (request, tempstr);
-              gftp_set_password (request, NULL);
-              g_free (tempstr);
-            }
-        }
+        gftpui_prompt_username (uidata, request);
 
       if (request->username != NULL &&
           strcmp (request->username, "anonymous") != 0 &&
           (request->password == NULL || *request->password == '\0'))
-        {
-          if ((tempstr = gftpui_prompt_password (uidata, request)) != NULL)
-            {
-              gftp_set_password (request, tempstr);
-              g_free (tempstr);               
-            }
-        }
+        gftpui_prompt_password (uidata, request);
     }
 
   gftp_lookup_request_option (request, "retries", &retries);
@@ -1065,6 +1051,9 @@
     {
       ret = gftpui_common_commands[i].func (uidata, request,
                                             other_uidata, other_request, pos);
+
+      if (!GFTP_IS_CONNECTED (request))
+        gftpui_disconnect (uidata);
     }
   else
     {
--- a/src/uicommon/gftpui.h	Wed Jan 28 10:52:53 2004 +0000
+++ b/src/uicommon/gftpui.h	Wed Jan 28 23:46:28 2004 +0000
@@ -108,6 +108,18 @@
 					  gftp_request * other_request,
 					  const char *command );
 
+int gftpui_common_cmd_mget_file 	( void *uidata,
+					  gftp_request * request, 
+					  void *other_uidata,
+					  gftp_request * other_request,
+					  const char *command );
+
+int gftpui_common_cmd_mput_file 	( void *uidata,
+					  gftp_request * request, 
+					  void *other_uidata,
+					  gftp_request * other_request,
+					  const char *command );
+
 gftp_transfer * gftpui_common_add_file_transfer ( gftp_request * fromreq,
 						  gftp_request * toreq,
 						  void *fromuidata,
@@ -147,10 +159,10 @@
 void *gftpui_generic_thread 		( void *(*run_function)(void *data),
 					  void *data);
 
-char *gftpui_prompt_username		( void *uidata,
+void gftpui_prompt_username		( void *uidata,
 					  gftp_request * request );
 
-char *gftpui_prompt_password 		( void *uidata,
+void gftpui_prompt_password 		( void *uidata,
 					  gftp_request * request );
 
 void gftpui_add_file_to_transfer 	( gftp_transfer * tdata,
@@ -167,4 +179,7 @@
 
 void gftpui_start_transfer 		( gftp_transfer * tdata );
 
+void gftpui_disconnect 			( void *uidata );
+
+
 #endif