Mercurial > gftp.yaz
changeset 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 | d44a1b128fed |
files | ChangeLog lib/gftp.h lib/misc.c lib/protocols.c src/gtk/gtkui.c src/gtk/transfer.c src/text/gftp-text.c src/text/gftp-text.h src/text/textui.c src/uicommon/gftpui.c src/uicommon/gftpui.h |
diffstat | 11 files changed, 183 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Jan 06 01:44:09 2004 +0000 +++ b/ChangeLog Tue Jan 06 02:42:30 2004 +0000 @@ -1,4 +1,20 @@ 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. + * src/gtk/gftp-gtk.h src/gtk/gtkui.c - when spawning a thread, make sure that the GUI will be updated properly as soon as the thread is finished. @@ -1937,7 +1953,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.196 2004/01/06 01:44:07 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.197 2004/01/06 02:41:34 masneyb Exp $ tags * debian/* - updated files from Debian maintainer
--- a/lib/gftp.h Tue Jan 06 01:44:09 2004 +0000 +++ b/lib/gftp.h Tue Jan 06 02:42:30 2004 +0000 @@ -167,6 +167,7 @@ #define BOOKMARKS_FILE BASE_CONF_DIR "/bookmarks" #define LOG_FILE BASE_CONF_DIR "/gftp.log" #define MAX_HIST_LEN 10 +#define GFTP_URL_USAGE "[[protocol://][user[:pass]@]site[:port][/directory]]" typedef enum gftp_logging_level_tag {
--- a/lib/misc.c Tue Jan 06 01:44:09 2004 +0000 +++ b/lib/misc.c Tue Jan 06 02:42:30 2004 +0000 @@ -411,7 +411,7 @@ void gftp_usage (void) { - printf (_("usage: gftp [[protocol://][user[:pass]@]site[:port][/directory]]\n")); + printf (_("usage: gftp " GFTP_URL_USAGE "\n")); exit (0); }
--- a/lib/protocols.c Tue Jan 06 01:44:09 2004 +0000 +++ b/lib/protocols.c Tue Jan 06 02:42:30 2004 +0000 @@ -821,7 +821,6 @@ gftp_set_password (gftp_request * request, const char *password) { g_return_if_fail (request != NULL); - g_return_if_fail (password != NULL); if (request->password) g_free (request->password);
--- a/src/gtk/gtkui.c Tue Jan 06 01:44:09 2004 +0000 +++ b/src/gtk/gtkui.c Tue Jan 06 02:42:30 2004 +0000 @@ -61,6 +61,82 @@ } +#define _GFTPUI_GTK_USER_PW_SIZE 256 + +static void +_gftpui_gtk_try_connect_again (char *tempstr, gftp_dialog_data * ddata) +{ + strncpy (tempstr, gtk_entry_get_text (GTK_ENTRY (ddata->edit)), + _GFTPUI_GTK_USER_PW_SIZE); + /* FIXME request->stopable = 0; */ +} + + +static void +_gftpui_gtk_dont_connect_again (char *tempstr, gftp_dialog_data * ddata) +{ + /* FIXME request->stopable = 0; */ +} + + +char * +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); + + *tempstr = '\0'; + while (*tempstr == '\0') /* FIXME */ + { + GDK_THREADS_LEAVE (); +#if GTK_MAJOR_VERSION == 1 + g_main_iteration (TRUE); +#else + g_main_context_iteration (NULL, TRUE); +#endif + } + + if (*tempstr == '\0') + return (NULL); + else + return (g_strdup (tempstr)); +} + + +char * +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); + + *tempstr = '\0'; + while (*tempstr == '\0') /* FIXME */ + { + GDK_THREADS_LEAVE (); +#if GTK_MAJOR_VERSION == 1 + g_main_iteration (TRUE); +#else + g_main_context_iteration (NULL, TRUE); +#endif + } + + if (*tempstr == '\0') + return (NULL); + else + return (g_strdup (tempstr)); +} + + /* The wakeup main thread functions are so that after the thread terminates there won't be a delay in updating the GUI */ static void
--- a/src/gtk/transfer.c Tue Jan 06 01:44:09 2004 +0000 +++ b/src/gtk/transfer.c Tue Jan 06 02:42:30 2004 +0000 @@ -38,7 +38,6 @@ gftpui_common_run_callback_function (cdata); wdata->files = cdata->files; - cdata->files = NULL; g_free (cdata); if (wdata->files == NULL || !GFTP_IS_CONNECTED (wdata->request))
--- a/src/text/gftp-text.c Tue Jan 06 01:44:09 2004 +0000 +++ b/src/text/gftp-text.c Tue Jan 06 02:42:30 2004 +0000 @@ -155,7 +155,7 @@ else infd = stdin; - printf ("%s%s%s: ", GFTPUI_COMMON_COLOR_BLUE, question, GFTPUI_COMMON_COLOR_DEFAULT); + printf ("%s%s%s ", GFTPUI_COMMON_COLOR_BLUE, question, GFTPUI_COMMON_COLOR_DEFAULT); if (fgets (buf, size, infd) == NULL) return (NULL); @@ -275,7 +275,6 @@ return (0); } - #if 0 int gftp_text_open (gftp_request * request, char *command, gpointer *data)
--- a/src/text/gftp-text.h Tue Jan 06 01:44:09 2004 +0000 +++ b/src/text/gftp-text.h Tue Jan 06 02:42:30 2004 +0000 @@ -30,5 +30,10 @@ #include <readline/history.h> #endif +char * gftp_text_ask_question ( const char *question, + int echo, + char *buf, + size_t size ); + #endif
--- a/src/text/textui.c Tue Jan 06 01:44:09 2004 +0000 +++ b/src/text/textui.c Tue Jan 06 02:42:30 2004 +0000 @@ -57,3 +57,26 @@ return (1); } + +char * +gftpui_prompt_username (void *uidata, gftp_request * request) +{ + char tempstr[256], *ret; + + ret = g_strdup (gftp_text_ask_question (_("Username [anonymous]:"), 1, + tempstr, sizeof (tempstr))); + return (ret); +} + + + +char * +gftpui_prompt_password (void *uidata, gftp_request * request) +{ + char tempstr[256], *ret; + + ret = g_strdup (gftp_text_ask_question (_("Password:"), 0, + tempstr, sizeof (tempstr))); + return (ret); +} +
--- 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}, */
--- a/src/uicommon/gftpui.h Tue Jan 06 01:44:09 2004 +0000 +++ b/src/uicommon/gftpui.h Tue Jan 06 02:42:30 2004 +0000 @@ -119,4 +119,10 @@ void *gftpui_generic_thread ( void *(*run_function)(void *data), void *data); +char *gftpui_prompt_username ( void *uidata, + gftp_request * request ); + +char *gftpui_prompt_password ( void *uidata, + gftp_request * request ); + #endif