Fix regular expression used to check domain names.
[modest] / src / maemo / modest-connection-specific-smtp-edit-window.c
index 845aec9..f4047d1 100644 (file)
@@ -41,6 +41,7 @@
 #include <gtk/gtkvbox.h>
 #include <gtk/gtkstock.h>
 #include "modest-text-utils.h"
+#include "modest-maemo-utils.h"
 
 #include <glib/gi18n.h>
 
@@ -164,8 +165,18 @@ on_response (GtkDialog *dialog, int response_id, gpointer user_data)
        hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
 
        /* Don't close the dialog if a range error occured */
+       if(priv->range_error_occured)
+       {
+               priv->range_error_occured = FALSE;
+               g_signal_stop_emission_by_name (dialog, "response");
+               gtk_widget_grab_focus (priv->entry_port);
+               return;
+       }
+
+       /* Don't close the dialog if a range error occured */
        if(response_id == GTK_RESPONSE_OK) {
-               if (!modest_text_utils_validate_domain_name (hostname)) { 
+               if (hostname && (hostname[0] != '\0') &&
+                   (!modest_text_utils_validate_domain_name (hostname))) { 
                        g_signal_stop_emission_by_name (dialog, "response");
                        hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_servername"));
                        gtk_widget_grab_focus (priv->entry_outgoingserver);
@@ -174,13 +185,6 @@ on_response (GtkDialog *dialog, int response_id, gpointer user_data)
                }
        }
        
-       /* Don't close the dialog if a range error occured */
-       if(response_id == GTK_RESPONSE_OK && priv->range_error_occured)
-       {
-               g_signal_stop_emission_by_name (dialog, "response");
-               gtk_widget_grab_focus (priv->entry_port);
-               return;
-       }
 }
 
 static void on_set_focus_child (GtkContainer *container, GtkWidget *widget, gpointer user_data)
@@ -331,7 +335,11 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
        /* When this window is shown, hibernation should not be possible, 
         * because there is no sensible way to save the state: */
        modest_window_mgr_prevent_hibernation_while_window_is_shown (
-       modest_runtime_get_window_mgr (), GTK_WINDOW (self)); 
+               modest_runtime_get_window_mgr (), GTK_WINDOW (self)); 
+       
+       hildon_help_dialog_help_enable (GTK_DIALOG(self),
+                                       "applications_email_connectionspecificsmtpconf",
+                                       modest_maemo_utils_get_osso_context());
 }
 
 ModestConnectionSpecificSmtpEditWindow*
@@ -382,12 +390,22 @@ modest_connection_specific_smtp_edit_window_get_settings (
        ModestConnectionSpecificSmtpEditWindow *window, 
        ModestAccountMgr *account_manager)
 {
-       ModestConnectionSpecificSmtpEditWindowPrivate *priv = 
-               CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
+       ModestConnectionSpecificSmtpEditWindowPrivate *priv = NULL;
+       ModestServerAccountData *result = NULL;
+       const gchar *outgoing_server = NULL;
+
+       priv =  CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
+       outgoing_server = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
+
+       /* If the outgoing server is NULL, we are removing the connection specific
+        * settings */
+       if ((outgoing_server == NULL) || (outgoing_server[0] == '\0')) {
+               return NULL;
+       }
        
        /* Use g_slice_new0(), because that's what modest_account_mgr_free_server_account_data() 
         * expects us to use. */
-       ModestServerAccountData *result = g_slice_new0 (ModestServerAccountData);
+       result = g_slice_new0 (ModestServerAccountData);
        
        result->hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver)));
        result->username = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username)));