return GTK_WIDGET (scrollwin);
}
+
+
+
static gboolean
check_data (ModestAccountSettingsDialog *self)
{
return FALSE;
}
}
-
- /* Check that the email address is valud: */
+
+ /* Check that the email address is valid: */
const gchar* email_address = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
if ((!email_address) || (strlen(email_address) == 0))
return FALSE;
return FALSE;
}
- /* Find a suitable authentication method when secure authentication is desired */
+ /* make sure the domain name for the incoming server is valid */
const gchar* hostname = gtk_entry_get_text (GTK_ENTRY (self->entry_incomingserver));
+ if ((!hostname) || (strlen(hostname) == 0))
+ return FALSE;
+ if (!modest_text_utils_validate_domain_name (hostname)) {
+ /* Warn the user via a dialog: */
+ /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
+ hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_servername"));
+
+ /* Return focus to the email address entry: */
+ gtk_widget_grab_focus (self->entry_incomingserver);
+ gtk_editable_select_region (GTK_EDITABLE (self->entry_incomingserver), 0, -1);
+ return FALSE;
+ }
+
+ /* make sure the domain name for the outgoing server is valid */
+ const gchar* hostname2 = gtk_entry_get_text (GTK_ENTRY (self->entry_outgoingserver));
+ if ((!hostname2) || (strlen(hostname2) == 0))
+ return FALSE;
+ if (!modest_text_utils_validate_domain_name (hostname2)) {
+ /* Warn the user via a dialog: */
+ /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
+ hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_servername"));
+
+ /* Return focus to the email address entry: */
+ gtk_widget_grab_focus (self->entry_outgoingserver);
+ gtk_editable_select_region (GTK_EDITABLE (self->entry_outgoingserver), 0, -1);
+ return FALSE;
+ }
+
+
+ /* Find a suitable authentication method when secure authentication is desired */
+
gint port_num = hildon_number_editor_get_value (
HILDON_NUMBER_EDITOR (self->entry_incoming_port));
const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username));
}
}
}
+
+
- /* TODO: The UI Spec wants us to check that the servernames are valid,
- * but does not specify how.
- */
-
+
return TRUE;
}
/*
{ "(file|rtsp|http|ftp|https)://[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]+[-A-Za-z0-9_$%&=?/~#]",\
NULL, NULL },\
{ "www\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]}\\),?!;:\"]?)?",\
- NULL, "http://" },\
+ NULL, "http://" }, \
{ "ftp\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]}\\),?!;:\"]?)?",\
NULL, "ftp://" },\
{ "(voipto|callto|chatto|jabberto|xmpp):[-_a-z@0-9.\\+]+", \
return g_strdup(date_buf);
}
+
+gboolean
+modest_text_utils_validate_domain_name (const gchar *domain)
+{
+ gboolean valid = FALSE;
+ regex_t rx;
+ const gchar* domain_regex = "^[a-z0-9]([.]?[a-z0-9-])*[a-z0-9]$";
+
+ if (!domain)
+ return FALSE;
+
+ /* domain name: all alphanum or '-' or '.',
+ * but beginning/ending in alphanum */
+ if (regcomp (&rx, domain_regex, REG_ICASE|REG_EXTENDED|REG_NOSUB)) {
+ g_warning ("BUG: error in regexp");
+ return FALSE;
+ }
+
+ valid = (regexec (&rx, domain, 1, NULL, 0) == 0);
+ regfree (&rx);
+
+ return valid;
+}
+
+
+
gboolean
modest_text_utils_validate_email_address (const gchar *email_address, const gchar **invalid_char_position)
{
gchar * modest_text_utils_get_display_size (guint64 size);
+
+/**
+ * modest_text_utils_validate_domain_name:
+ * @email_address: a NULL-terminated string
+ *
+ * validates the domain name passed as argument
+ *
+ * Returns: TRUE if the domain name is valid, FALSE otherwise
+ **/
+gboolean modest_text_utils_validate_domain_name (const gchar *domain);
+
/**
* modest_text_utils_validate_email_address:
* @email_address: a string