diff src/uicommon/gftpui.c @ 356:7cb3327f96f7

2003-1-5 Brian Masney <masneyb@gftp.org> * lib/gftp.h lib/misc.c src/gtk/gftpui.c - added GFTP_URL_USAGE that is the sytax for a valid URL. * lib/protocols.c (gftp_set_password) - allow the password to be NULL * src/gtk/gtkui.c src/text/textui.c src/uicommon/gftpui.h - added gftpui_prompt_username() and gftpui_promot_password() to each UI * src/text/gftp-text.c (gftp_text_ask_question) - don't display a : at the end of the question here. * src/text/gftp-text.h - added declaration of gftp_text_ask_question() * src/uicommon/gftpui.c - added gftpui_common_cmd_open(). This still needs a little bit more work done to it.
author masneyb
date Tue, 06 Jan 2004 02:42:30 +0000
parents 60d3da6ab336
children d5409bf03ff1
line wrap: on
line diff
--- a/src/uicommon/gftpui.c	Tue Jan 06 01:44:09 2004 +0000
+++ b/src/uicommon/gftpui.c	Tue Jan 06 02:42:30 2004 +0000
@@ -546,6 +546,56 @@
 
 
 static int
+gftpui_common_cmd_open (void *uidata, gftp_request * request, char *command)
+{
+  char *tempstr;
+
+  if (GFTP_IS_CONNECTED (request))
+    {
+      gftp_disconnect (request); /* FIXME */
+    }
+  
+  if (*command == '\0')
+    {
+      request->logging_function (gftp_logging_error, request,
+          _("usage: open " GFTP_URL_USAGE "\n"));
+      return (1);
+    }
+    
+  if (gftp_parse_url (request, command) < 0)
+    return (1);
+
+  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);
+            }
+        }
+
+      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);               
+            }
+        }
+    }
+
+  /* FIXME gftp_connect (request); */
+
+  return (1);
+}
+
+
+static int
 gftpui_common_cmd_set (void *uidata, gftp_request * request, char *command)
 {
   gftp_config_vars * cv, newcv;
@@ -749,8 +799,10 @@
 /* FIXME
         {N_("mput"),    2, gftp_text_mput_file, gftpui_common_request_none,
          N_("Uploads local file(s)"), NULL},
-        {N_("open"),    1, gftp_text_open,      gftpui_common_request_remote,
+*/
+        {N_("open"),    1, gftpui_common_cmd_open, gftpui_common_request_remote,
          N_("Opens a connection to a remote site"), NULL},
+/* FIXME
         {N_("put"),     2, gftp_text_mput_file, gftpui_common_request_none,
          N_("Uploads local file(s)"), NULL},
 */