aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-02-05 06:51:07 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-02-05 06:51:07 +0000
commite3dcee39218e26a6b0ce29865f0cb6f0d36c0a04 (patch)
tree3557b5380cbdca5c00a90e852e99d289c31374ac
parent0f57a2f733e451a81555a99612b9f215ac6f7a1d (diff)
check the input values for address, ID and server.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2459 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog4
-rw-r--r--src/setup.c46
2 files changed, 44 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 91f1befc..8189e66f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
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.
2010-02-05
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