changeset 218:de6a2e8e51cb

2003-7-9 Brian Masney <masneyb@gftp.org> * lib/config_file.c (gftp_write_config_file) - fix for writing out list items to the config file. * lib/config_file.c lib/gftp.h - added gftp_free_proxy_hosts() and gftp_copy_proxy_hosts() * lib/protocols.c (gftp_connect_server) - look up dont_use_proxy instead of ext * lib/protocols.c lib/sshv2.c src/gtk/dnd.c src/gtk/menu-items.c - when calling g_build_path(), set the directory separator to / instead of G_DIR_SEPARATOR_S * src/gtk/gftp-gtk.c (toolbar_hostedit) - fixed crash * src/gtk/gftp-gtk.h - removed gotbytes from gftp_window_data structure * src/gtk/options_dialog.c - show proxy hosts in options dialog * docs/sample.gftp/gftprc - new default config file
author masneyb
date Wed, 09 Jul 2003 23:25:56 +0000
parents c102e1509d91
children b9584a877daf
files ChangeLog docs/sample.gftp/gftprc lib/config_file.c lib/gftp.h lib/protocols.c lib/sshv2.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/menu-items.c src/gtk/options_dialog.c
diffstat 11 files changed, 245 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jul 08 19:44:12 2003 +0000
+++ b/ChangeLog	Wed Jul 09 23:25:56 2003 +0000
@@ -1,3 +1,26 @@
+2003-7-9 Brian Masney <masneyb@gftp.org>
+	* lib/config_file.c (gftp_write_config_file) - fix for writing out
+	list items to the config file. 
+
+	* lib/config_file.c lib/gftp.h - added gftp_free_proxy_hosts() and
+	gftp_copy_proxy_hosts()
+
+	* lib/protocols.c (gftp_connect_server) - look up dont_use_proxy
+	instead of ext
+
+	* lib/protocols.c lib/sshv2.c src/gtk/dnd.c src/gtk/menu-items.c - 
+	when calling g_build_path(), set the directory separator to / instead
+	of G_DIR_SEPARATOR_S
+
+	* src/gtk/gftp-gtk.c (toolbar_hostedit) - fixed crash
+
+	* src/gtk/gftp-gtk.h - removed gotbytes from gftp_window_data
+	structure
+
+	* src/gtk/options_dialog.c - show proxy hosts in options dialog
+
+	* docs/sample.gftp/gftprc - new default config file
+
 2003-7-7 Brian Masney <masneyb@gftp.org>
 	* configure.in src/gtk/Makefile.am src/text/Makefile.am - if the 
 	OpenSSL libraries are available on the system, link them in and
@@ -1207,7 +1230,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.109 2003/07/08 02:09:27 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.110 2003/07/09 23:25:53 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/docs/sample.gftp/gftprc	Tue Jul 08 19:44:12 2003 +0000
+++ b/docs/sample.gftp/gftprc	Wed Jul 09 23:25:56 2003 +0000
@@ -1,11 +1,8 @@
-# Config file for gFTP. Copyright (C) 1998-2002 Brian Masney
+# Config file for gFTP. Copyright (C) 1998-2003 Brian Masney
 # <masneyb@gftp.org>. Warning: Any comments that you add to this file WILL be
 # overwritten. If a entry has a (*) in it's comment, you can't change it
 # inside gFTP
 
-# Enter your email address here
-email=
-
 # The default program used to view files. If this is blank, the internal file
 # viewer will be used
 view_program=
@@ -19,6 +16,10 @@
 # The maximum size of the log window in bytes for the GTK+ port
 max_log_window_size=5000
 
+# This is a comma separated list of charsets to try to convert the remote
+# messages to the current locale
+remote_charsets=
+
 # Append new file transfers onto existing ones
 append_transfers=1
 
@@ -28,15 +29,15 @@
 # Overwrite files by default or set to resume file transfers
 overwrite_default=0
 
+# Preserve file permissions of transfered files
+preserve_permissions=1
+
 # Refresh the listbox after each file is transfered
 refresh_files=0
 
 # Put the directories first then the files
 sort_dirs_first=1
 
-# Automatically start the file transfers when they get queued?
-start_transfers=1
-
 # Show hidden files in the listboxes
 show_hidden_files=1
 
@@ -55,74 +56,15 @@
 # This specifies the default protocol to use
 default_protocol=FTP
 
-# Firewall hostname
-firewall_host=
-
-# Port to connect to on the firewall
-firewall_port=21
-
-# Your firewall username
-firewall_username=
-
-# Your firewall password
-firewall_password=
-
-# Your firewall account (optional)
-firewall_account=
-
-# Send PASV command or PORT command for data transfers
-passive_transfer=1
-
-# If you disable this feature, then gFTP will only send LIST to the remote
-# server instead of LIST -L
-resolve_symlinks=1
-
-# This specifies how your proxy server expects us to log in
-proxy_config=
-
-# Firewall hostname
-http_proxy_host=
-
-# Port to connect to on the firewall
-http_proxy_port=80
-
-# Your firewall username
-http_proxy_username=
-
-# Your firewall password
-http_proxy_password=
-
-# Do you want to use HTTP/1.1 or HTTP/1.0
-use_http11=1
-
-# The path to the SSH executable
-ssh_prog_name=
-
-# Extra parameters to pass to the SSH program
-ssh_extra_params=
-
-# Default remote SSH2 sftp-server path
-ssh2_sftp_path=
-
-# Require a username/password for SSH connections
-ssh_need_userpass=0
-
-# Use the ssh-askpass utility to grab the users password
-ssh_use_askpass=0
-
-# Call ssh with the -s sftp flag. This is helpful because you won't have to
-# know the remote path to the remote sftp-server
-sshv2_use_sftp_subsys=0
-
 # This defines what will happen when you double click a file in the file
 # listboxes. 0=View file 1=Edit file 2=Transfer file
 list_dblclk_action=2
 
 # The default width of the local files listbox
-listbox_local_width=313
+listbox_local_width=318
 
 # The default width of the remote files listbox
-listbox_remote_width=314
+listbox_remote_width=320
 
 # The default height of the local/remote files listboxes
 listbox_file_height=265
@@ -137,6 +79,18 @@
 # have this column automagically resize.
 file_trans_column=100
 
+# The default column to sort by
+local_sortcol=file
+
+# Sort ascending or descending
+local_sortasds=ascending
+
+# The default column to sort by
+remote_sortcol=file
+
+# Sort ascending or descending
+remote_sortasds=ascending
+
 # The width of the filename column in the file listboxes. Set this to 0 to
 # have this column automagically resize. Set this to -1 to disable this column
 local_file_width=100
@@ -197,6 +151,94 @@
 # The color of the rest of the log messages
 misc_color=a000:8d00:4600
 
+# This is the password that will be used whenever you log into a remote FTP
+# server as anonymous
+email=
+
+# Firewall hostname
+ftp_proxy_host=
+
+# Port to connect to on the firewall
+ftp_proxy_port=21
+
+# Your firewall username
+ftp_proxy_username=
+
+# Your firewall password
+ftp_proxy_password=
+
+# Your firewall account (optional)
+ftp_proxy_account=
+
+# This specifies how your proxy server expects us to log in. You can specify a
+# 2 character replacement string prefixed by a % that will be replaced with
+# the proper data. The first character can be either p for proxy or h for the
+# host of the FTP server. The second character can be u (user), p (pass), h
+# (host), o (port) or a (account). For example, to specify the proxy user, you
+# can you type in %pu
+proxy_config=
+
+# If this is enabled, then the remote FTP server will open up a port for the
+# data connection. If you are behind a firewall, you will need to enable this.
+# Generally, it is a good idea to keep this enabled unless you are connecting
+# to an older FTP server that doesn't support this. If this is disabled, then
+# gFTP will open up a port on the client side and the remote server will
+# attempt to connect to it.
+passive_transfer=1
+
+# The remote FTP server will attempt to resolve symlinks in the directory
+# listings. Generally, this is a good idea to leave enabled. The only time you
+# will want to disable this is if the remote FTP server doesn't support the -L
+# option to LIST
+resolve_symlinks=1
+
+# If you are transfering a text file from Windows to UNIX box or vice versa,
+# then you should enable this. Each system represents newlines differently for
+# text files. If you are transfering from UNIX to UNIX, then it is safe to
+# leave this off. If you are downloading binary data, you will want to disable
+# this.
+ascii_transfers=0
+
+# Firewall hostname
+http_proxy_host=
+
+# Port to connect to on the firewall
+http_proxy_port=80
+
+# Your firewall username
+http_proxy_username=
+
+# Your firewall password
+http_proxy_password=
+
+# Do you want to use HTTP/1.1 or HTTP/1.0
+use_http11=1
+
+# SSL entropy file
+entropy_source=/dev/urandom
+
+# The maximum number of bytes to seed the SSL engine with
+entropy_len=1024
+
+# The path to the SSH executable
+ssh_prog_name=
+
+# Extra parameters to pass to the SSH program
+ssh_extra_params=
+
+# Default remote SSH2 sftp-server path
+ssh2_sftp_path=
+
+# Require a username/password for SSH connections
+ssh_need_userpass=0
+
+# Use the ssh-askpass utility to supply the remote password
+ssh_use_askpass=0
+
+# Call ssh with the -s sftp flag. This is helpful because you won't have to
+# know the remote path to the remote sftp-server
+sshv2_use_sftp_subsys=0
+
 # This section specifies which hosts are on the local subnet and won't need to
 # go out the proxy server (if available). Syntax: dont_use_proxy=.domain or
 # dont_use_proxy=network number/netmask
@@ -232,5 +274,3 @@
 ext=.8:man.xpm:B:xman
 ext=.tar:tar.xpm:B:
 ext=.tgz:tar.xpm:B:
-
-# This section contains the data that is in the history
--- a/lib/config_file.c	Tue Jul 08 19:44:12 2003 +0000
+++ b/lib/config_file.c	Wed Jul 09 23:25:56 2003 +0000
@@ -784,13 +784,17 @@
         }
     }
     
-  for (i=0; gftp_config_list[i].list != NULL; i++)
+  for (i=0; gftp_config_list[i].key != NULL; i++)
     {
+      if (gftp_config_list[i].header == NULL &&
+          gftp_config_list[i].list == NULL)
+        continue;
+
       fprintf (conffile, "\n");
       if (gftp_config_list[i].header != NULL)
         write_comment (conffile, _(gftp_config_list[i].header));
 
-      for (templist = gftp_options_list;
+      for (templist = gftp_config_list[i].list;
            templist != NULL;
            templist = templist->next)
         {
@@ -1326,3 +1330,54 @@
   g_free (bookmarks);
 }
 
+
+void
+gftp_free_proxy_hosts (GList * proxy_hosts)
+{
+  gftp_proxy_hosts * hosts;
+  GList * templist;
+
+  for (templist = proxy_hosts;
+       templist != NULL; 
+       templist = templist->next)
+    {
+      hosts = templist->data;
+
+      if (hosts->domain)
+        g_free (hosts->domain);
+      g_free (hosts);
+    }
+
+  g_list_free (proxy_hosts);
+}
+
+
+GList *
+gftp_copy_proxy_hosts (GList * proxy_hosts)
+{
+  gftp_proxy_hosts * oldhosts, * newhosts;
+  GList * templist, * new_proxy_hosts;
+
+  new_proxy_hosts = NULL;
+
+  if (proxy_hosts != NULL)
+    {
+      for (templist = proxy_hosts;
+           templist != NULL; 
+           templist = templist->next)
+        {
+          oldhosts = templist->data;
+
+          newhosts = g_malloc0 (sizeof (*newhosts));
+          memcpy (newhosts, oldhosts, sizeof (*newhosts));
+
+          if (oldhosts->domain)
+            newhosts->domain = g_strdup (oldhosts->domain);
+
+          new_proxy_hosts = g_list_append (new_proxy_hosts, newhosts);
+        }
+    }
+
+  return (new_proxy_hosts);
+}
+
--- a/lib/gftp.h	Tue Jul 08 19:44:12 2003 +0000
+++ b/lib/gftp.h	Wed Jul 09 23:25:56 2003 +0000
@@ -655,6 +655,10 @@
 
 void gftp_bookmarks_destroy 		( gftp_bookmarks_var * bookmarks );
 
+void gftp_free_proxy_hosts 		( GList * proxy_hosts );
+
+GList * gftp_copy_proxy_hosts 		( GList * proxy_hosts );
+
 /* misc.c */
 char *insert_commas 			( off_t number, 
 					  char *dest_str, 
--- a/lib/protocols.c	Tue Jul 08 19:44:12 2003 +0000
+++ b/lib/protocols.c	Wed Jul 09 23:25:56 2003 +0000
@@ -893,7 +893,7 @@
   char serv[8];
 #endif
 
-  gftp_lookup_global_option ("ext", &proxy_hosts);
+  gftp_lookup_global_option ("dont_use_proxy", &proxy_hosts);
 
   if (proxy_hostname == NULL || *proxy_hostname == '\0')
     return (0);
@@ -1540,11 +1540,10 @@
         fle->startsize = *newsize;
 
       if (transfer->toreq)
-        fle->destfile = g_build_path (G_DIR_SEPARATOR_S, 
-                                      transfer->toreq->directory, fle->file, 
-                                      NULL);
-
-      newname = g_build_path (G_DIR_SEPARATOR_S, transfer->fromreq->directory,
+        fle->destfile = g_build_path ("/", transfer->toreq->directory, 
+                                      fle->file, NULL);
+
+      newname = g_build_path ("/", transfer->fromreq->directory,
 			     fle->file, NULL);
 
       g_free (fle->file);
--- a/lib/sshv2.c	Tue Jul 08 19:44:12 2003 +0000
+++ b/lib/sshv2.c	Wed Jul 09 23:25:56 2003 +0000
@@ -1626,7 +1626,7 @@
   else
     {
       oldlen = strlen (request->directory) + strlen (oldname) + 1;
-      oldstr = g_build_path (G_DIR_SEPARATOR_S, request->directory, oldname, 
+      oldstr = g_build_path ("/", request->directory, oldname, 
                              NULL);
     }
 
@@ -1638,7 +1638,7 @@
   else
     {
       newlen = strlen (request->directory) + strlen (newname) + 1;
-      newstr = g_build_path (G_DIR_SEPARATOR_S, request->directory, newname, 
+      newstr = g_build_path ("/", request->directory, newname, 
                              NULL);
     }
 
--- a/src/gtk/dnd.c	Tue Jul 08 19:44:12 2003 +0000
+++ b/src/gtk/dnd.c	Wed Jul 09 23:25:56 2003 +0000
@@ -79,8 +79,7 @@
   newfle->file = g_strdup (current_ftpdata->directory);
   *(pos - 1) = '\0';
   
-  newfle->destfile = g_build_path (G_DIR_SEPARATOR_S, wdata->request->directory, pos, 
-                                   NULL);
+  newfle->destfile = g_build_path ("/", wdata->request->directory, pos, NULL);
   templist = g_malloc0 (sizeof (*templist));
   templist->data = newfle;
   templist->next = NULL;
--- a/src/gtk/gftp-gtk.c	Tue Jul 08 19:44:12 2003 +0000
+++ b/src/gtk/gftp-gtk.c	Wed Jul 09 23:25:56 2003 +0000
@@ -914,6 +914,8 @@
     return;
  
   gftp_set_hostname (current_wdata->request, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)));
+  if (current_wdata->request->hostname == NULL)
+    return;
   alltrim (current_wdata->request->hostname);
 
   if (current_wdata->request->need_hostport && 
@@ -943,7 +945,9 @@
   add_history (portedit, &tmplistvar->list, &tmplistvar->num_items, txt);
 
   gftp_set_username (current_wdata->request, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry)));
-  alltrim (current_wdata->request->username);
+  if (current_wdata->request->username != NULL)
+    alltrim (current_wdata->request->username);
+
 
   gftp_lookup_global_option ("userhistory", &tmplistvar);
   add_history (useredit, &tmplistvar->list, &tmplistvar->num_items, 
@@ -953,7 +957,8 @@
 		     gtk_entry_get_text (GTK_ENTRY (passedit)));
 
   gftp_set_directory (current_wdata->request, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (current_wdata->combo)->entry)));
-  alltrim (current_wdata->request->directory);
+  if (current_wdata->request->directory != NULL)
+    alltrim (current_wdata->request->directory);
 
   add_history (current_wdata->combo, current_wdata->history, 
                current_wdata->histlen, current_wdata->request->directory);
--- a/src/gtk/gftp-gtk.h	Tue Jul 08 19:44:12 2003 +0000
+++ b/src/gtk/gftp-gtk.h	Wed Jul 09 23:25:56 2003 +0000
@@ -75,7 +75,6 @@
   GtkItemFactory *ifactory; 	/* This is for the menus that will
                                    come up when you right click */
   pthread_t tid;		/* Thread for the stop button */
-  unsigned long gotbytes;
   char *prefix_col_str;
 } gftp_window_data;
 
--- a/src/gtk/menu-items.c	Tue Jul 08 19:44:12 2003 +0000
+++ b/src/gtk/menu-items.c	Wed Jul 09 23:25:56 2003 +0000
@@ -533,8 +533,7 @@
   templist = get_next_selection (templist, &filelist, &num);
   tempfle = filelist->data;
 
-  newdir = g_build_path (G_DIR_SEPARATOR_S, wdata->request->directory, 
-                         tempfle->file, NULL);
+  newdir = g_build_path ("/", wdata->request->directory, tempfle->file, NULL);
 
   if ((tempstr = expand_path (newdir)) == NULL)
     {
--- a/src/gtk/options_dialog.c	Tue Jul 08 19:44:12 2003 +0000
+++ b/src/gtk/options_dialog.c	Wed Jul 09 23:25:56 2003 +0000
@@ -107,7 +107,9 @@
   option_data = user_data;
 
   tempwid = _gen_input_widget (option_data, cv->description, cv->comment);
-  gtk_entry_set_text (GTK_ENTRY (tempwid), (char *) cv->value);
+  if (cv->value != NULL)
+    gtk_entry_set_text (GTK_ENTRY (tempwid), (char *) cv->value);
+
   return (tempwid);
 }
 
@@ -642,26 +644,18 @@
 static void
 clean_old_changes (GtkWidget * widget, gpointer data)
 {
-  gftp_proxy_hosts *hosts;
-  GList *templist;
-
-  templist = new_proxy_hosts;
-  while (templist != NULL)
+  if (new_proxy_hosts != NULL)
     {
-      hosts = templist->data;
-      if (hosts->domain)
-        g_free (hosts->domain);
-      g_free (hosts);
-      templist = templist->next;
+      gftp_free_proxy_hosts (new_proxy_hosts);
+      new_proxy_hosts = NULL;
     }
-  g_list_free (new_proxy_hosts);
-  new_proxy_hosts = NULL;
 }
 
 
 static void
 apply_changes (GtkWidget * widget, gpointer data)
 {
+  gftp_config_list_vars * proxy_hosts;
   gftp_config_vars * cv;
   GList * templist;
   int i;
@@ -683,6 +677,14 @@
           gftp_option_types[cv[i].otype].ui_save_function (&cv[i], gftp_option_types[cv[i].otype].user_data);
         }
     }
+
+  gftp_lookup_global_option ("dont_use_proxy", &proxy_hosts);
+
+  if (proxy_hosts->list != NULL)
+    gftp_free_proxy_hosts (proxy_hosts->list);
+
+  proxy_hosts->list = new_proxy_hosts;
+  new_proxy_hosts = NULL;
 }
 
 
@@ -699,6 +701,7 @@
         apply_changes (widget, NULL);
         /* no break */
       default:
+        clean_old_changes (widget, user_data);
         gtk_widget_destroy (widget);
     }
 }
@@ -735,6 +738,7 @@
       g_free (add_data[0]);
       g_free (add_data[1]);
     }
+
   gtk_clist_set_row_data (GTK_CLIST (proxy_list), num, (gpointer) templist);
 }
 
@@ -747,7 +751,8 @@
   GList *templist;
   int num;
 
-  if ((templist = data) == NULL)
+  templist = data;
+  if (templist == NULL)
     {
       hosts = g_malloc0 (sizeof (*hosts));
       new_proxy_hosts = g_list_append (new_proxy_hosts, hosts);
@@ -771,8 +776,7 @@
   if (GTK_TOGGLE_BUTTON (domain_active)->active)
     {
       edttxt = gtk_entry_get_text (GTK_ENTRY (new_proxy_domain));
-      hosts->domain = g_malloc (strlen (edttxt) + 1);
-      strcpy (hosts->domain, edttxt);
+      hosts->domain = g_strdup (edttxt);
       hosts->ipv4_netmask = hosts->ipv4_network_address = 0;
     }
   else
@@ -801,6 +805,7 @@
       edttxt = gtk_entry_get_text (GTK_ENTRY (netmask4));
       hosts->ipv4_netmask |= strtol (edttxt, NULL, 10) & 0xff;
     }
+
   add_host_to_listbox (templist);
 }
 
@@ -1093,7 +1098,9 @@
 make_proxy_hosts_tab (GtkWidget * notebook)
 {
   GtkWidget *tempwid, *box, *hbox, *scroll;
+  gftp_config_list_vars * proxy_hosts;
   char *add_data[2];
+  GList * templist;
 
   add_data[0] = _("Network");
   add_data[1] = _("Netmask");
@@ -1118,7 +1125,16 @@
   gtk_widget_show (proxy_list);
   gtk_widget_show (scroll);
 
+  gftp_lookup_global_option ("dont_use_proxy", &proxy_hosts);
+  new_proxy_hosts = gftp_copy_proxy_hosts (proxy_hosts->list);
+
+  for (templist = new_proxy_hosts;
+       templist != NULL;
+       templist = templist->next)
+    add_host_to_listbox (templist);
+
   hbox = gtk_hbox_new (TRUE, 15);
+
   gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
   gtk_widget_show (hbox);
 
@@ -1233,6 +1249,8 @@
         }
     }
 
+  make_proxy_hosts_tab (option_data.notebook);
+
 #if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("OK"));
   GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);