From e3dcee39218e26a6b0ce29865f0cb6f0d36c0a04 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 5 Feb 2010 06:51:07 +0000 Subject: check the input values for address, ID and server. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2459 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 4 ++++ src/setup.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 91f1befc..8189e66f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-02-05 + + * src/setup.c: check the input values for address, ID and server. + 2010-02-05 * src/mainwindow.c: new_account_cb(): don't update UI when cancelled. diff --git a/src/setup.c b/src/setup.c index 5bbdb865..1652799c 100644 --- a/src/setup.c +++ b/src/setup.c @@ -408,6 +408,25 @@ static void entry_changed(GtkEditable *editable, gpointer data) GTK_RESPONSE_ACCEPT, next_enable); } +static gboolean entry_is_valid(GtkWidget *entry) +{ + const gchar *str, *p; + guchar c; + + p = str = gtk_entry_get_text(GTK_ENTRY(entry)); + if (!str || *p == '\0') + return FALSE; + + while (*p) { + c = *p; + if (g_ascii_isspace(c) || c < 32 || c > 127) + return FALSE; + p++; + } + + return TRUE; +} + #define GET_STR(s, m) \ { \ setupac.s = gtk_editable_get_chars(GTK_EDITABLE(setupac.m), 0, -1); \ @@ -434,16 +453,31 @@ static void setup_account_response_cb(GtkDialog *dialog, gint response_id, if (page != SETUP_PAGE_FINISH) setupac.cancelled = TRUE; } else if (response_id == GTK_RESPONSE_ACCEPT) { - if (prev_page == SETUP_PAGE_ADDRESS && - (setupac.type == SETUP_TYPE_POP3G || - setupac.type == SETUP_TYPE_IMAPG)) { - gtk_notebook_set_current_page - (GTK_NOTEBOOK(setupac.notebook), - SETUP_PAGE_FINISH); + if (prev_page == SETUP_PAGE_ADDRESS) { + if (entry_is_valid(setupac.addr_entry)) { + if (setupac.type == SETUP_TYPE_POP3G || + setupac.type == SETUP_TYPE_IMAPG) + gtk_notebook_set_current_page + (GTK_NOTEBOOK(setupac.notebook), + SETUP_PAGE_FINISH); + else + gtk_notebook_set_current_page + (GTK_NOTEBOOK(setupac.notebook), page + 1); + } else + alertpanel_error(_("Input value is not valid.")); + } else if (prev_page == SETUP_PAGE_ACCOUNT) { + if (entry_is_valid(setupac.id_entry) && + entry_is_valid(setupac.serv_entry) && + entry_is_valid(setupac.smtp_entry)) + gtk_notebook_set_current_page + (GTK_NOTEBOOK(setupac.notebook), page + 1); + else + alertpanel_error(_("Input value is not valid.")); } else { gtk_notebook_set_current_page (GTK_NOTEBOOK(setupac.notebook), page + 1); } + if (prev_page == SETUP_PAGE_START) { setupac.type = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.pop3_radio)) ? SETUP_TYPE_POP3 : gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(setupac.imap_radio)) ? SETUP_TYPE_IMAP -- cgit v1.2.3