changeset 542:fd9ce7797984

2004-8-21 Brian Masney <masneyb@gftp.org> * lib/gftp.h lib/options.h lib/protocols.c - added gftp_protocol_default_port() that will return the default port for the current protocol * src/gtk/misc-gtk.c (update_window_info) - when updating the toolbar with the connection status, if the current connection is using the default port for it's protocol, then leave the port field blank. This should help users who want to reconnect to the current site using a different protocol * src/gtk/gftp-gtk.c (CreateConnectToolbar) - expanded the size of the Port input box
author masneyb
date Sat, 21 Aug 2004 15:49:34 +0000
parents e46278e7ef1d
children 87ea7ff84a5d
files ChangeLog lib/gftp.h lib/options.h lib/protocols.c src/gtk/gftp-gtk.c src/gtk/misc-gtk.c
diffstat 6 files changed, 47 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Aug 21 14:40:41 2004 +0000
+++ b/ChangeLog	Sat Aug 21 15:49:34 2004 +0000
@@ -1,4 +1,17 @@
 2004-8-21 Brian Masney <masneyb@gftp.org>
+	* lib/gftp.h lib/options.h lib/protocols.c - added
+	gftp_protocol_default_port() that will return the default port for
+	the current protocol
+
+	* src/gtk/misc-gtk.c (update_window_info) - when updating the toolbar
+	with the connection status, if the current connection is using the
+	default port for it's protocol, then leave the port field blank. This
+	should help users who want to reconnect to the current site using a
+	different protocol
+
+	* src/gtk/gftp-gtk.c (CreateConnectToolbar) - expanded the size of
+	the Port input box
+
 	* lib/rfc959.c lib/ftpcommon.h - added internal option to quote
 	the filename in the SITE command. This is only enabled for servers
 	that return UNIX in the SYST output. It is disabled if it is a BSD
@@ -2774,7 +2787,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.313 2004/08/21 14:40:41 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.314 2004/08/21 15:49:34 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/gftp.h	Sat Aug 21 14:40:41 2004 +0000
+++ b/lib/gftp.h	Sat Aug 21 15:49:34 2004 +0000
@@ -554,6 +554,7 @@
   int (*init) (gftp_request * request);		/* Init function */
   void (*register_options) (void);		/* Protocol options */
   char *url_prefix;				/* URL Prefix */
+  unsigned int default_port;			/* Default port */
   unsigned int shown : 1,			/* Whether this protocol is 
                                                    shown or not to the user in 
                                                    the protocol dropdown box */
@@ -1033,6 +1034,8 @@
 
 void gftp_setup_startup_directory 	( gftp_request * request );
 
+unsigned int gftp_protocol_default_port	( gftp_request * request );
+
 /* pty.c */
 char * gftp_get_pty_impl 		( void );
 
--- a/lib/options.h	Sat Aug 21 14:40:41 2004 +0000
+++ b/lib/options.h	Sat Aug 21 15:49:34 2004 +0000
@@ -225,29 +225,29 @@
 
 supported_gftp_protocols gftp_protocols[] =
 {
-  {N_("FTP"), rfc959_init, rfc959_register_module, "ftp", 1, 1},
+  {N_("FTP"), rfc959_init, rfc959_register_module, "ftp", 21, 1, 1},
 
 #ifdef USE_SSL
-  {N_("FTPS"), ftps_init, ftps_register_module, "ftps", 1, 1},
+  {N_("FTPS"), ftps_init, ftps_register_module, "ftps", 21, 1, 1},
 #else
-  {N_("FTPS"), ftps_init, ftps_register_module, "ftps", 0, 1},
+  {N_("FTPS"), ftps_init, ftps_register_module, "ftps", 21, 0, 1},
 #endif
 
-  {N_("HTTP"), rfc2068_init, rfc2068_register_module, "http", 1, 1},
+  {N_("HTTP"), rfc2068_init, rfc2068_register_module, "http", 80, 1, 1},
 
 #ifdef USE_SSL
-  {N_("HTTPS"), https_init, https_register_module, "https", 1, 1},
+  {N_("HTTPS"), https_init, https_register_module, "https", 443, 1, 1},
 #else
-  {N_("HTTPS"), https_init, https_register_module, "https", 0, 1},
+  {N_("HTTPS"), https_init, https_register_module, "https", 443, 0, 1},
 #endif
 
-  {N_("Local"), local_init, local_register_module, "file", 1, 0},
+  {N_("Local"), local_init, local_register_module, "file", 0, 1, 0},
 
-  {N_("SSH2"), sshv2_init, sshv2_register_module, "ssh2", 1, 1},
+  {N_("SSH2"), sshv2_init, sshv2_register_module, "ssh2", 22, 1, 1},
 
-  {N_("Bookmark"), bookmark_init, bookmark_register_module, "bookmark", 0, 0},
+  {N_("Bookmark"), bookmark_init, bookmark_register_module, "bookmark", 0, 0, 0},
 
-  {NULL, NULL, NULL, NULL, 0, 0}
+  {NULL, NULL, NULL, NULL, 0, 0, 0}
 };
 
 GHashTable * gftp_global_options_htable = NULL, 	
--- a/lib/protocols.c	Sat Aug 21 14:40:41 2004 +0000
+++ b/lib/protocols.c	Sat Aug 21 15:49:34 2004 +0000
@@ -3050,3 +3050,16 @@
   return (mode);
 }
 
+
+unsigned int
+gftp_protocol_default_port (gftp_request * request)
+{
+  struct servent serv_struct;
+
+  if (r_getservbyname (gftp_protocols[request->protonum].url_prefix, "tcp",
+                       &serv_struct, NULL) == NULL)
+    return (gftp_protocols[request->protonum].default_port);
+  else
+    return (ntohs (serv_struct.s_port));
+}
+
--- a/src/gtk/gftp-gtk.c	Sat Aug 21 14:40:41 2004 +0000
+++ b/src/gtk/gftp-gtk.c	Sat Aug 21 15:49:34 2004 +0000
@@ -463,7 +463,7 @@
 
   portedit = gtk_combo_new ();
   gtk_combo_set_case_sensitive (GTK_COMBO (portedit), 1);
-  gtk_widget_set_size_request (portedit, 45, -1);
+  gtk_widget_set_size_request (portedit, 50, -1);
 
   gtk_signal_connect (GTK_OBJECT (GTK_COMBO (portedit)->entry), "activate",
 		      GTK_SIGNAL_FUNC (toolbar_hostedit), NULL);
--- a/src/gtk/misc-gtk.c	Sat Aug 21 14:40:41 2004 +0000
+++ b/src/gtk/misc-gtk.c	Sat Aug 21 15:49:34 2004 +0000
@@ -210,6 +210,7 @@
 {
   char *tempstr, empty[] = "";
   GtkWidget * tempwid;
+  unsigned int port;
   int i;
 
   if (current_wdata->request != NULL)
@@ -226,12 +227,16 @@
         tempstr = empty;
       gtk_entry_set_text (GTK_ENTRY (passedit), tempstr);
 
-      if (current_wdata->request->port != 0)
+      port = gftp_protocol_default_port (current_wdata->request);
+      if (current_wdata->request->port != 0 &&
+          port != current_wdata->request->port)
         {
           tempstr = g_strdup_printf ("%d", current_wdata->request->port);
           gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (portedit)->entry), tempstr);
           g_free (tempstr);
         }
+      else
+        gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (portedit)->entry), "");
 
       for (i=0; gftp_protocols[i].init != NULL; i++)
         {