2007-07-16 Murray Cumming <murrayc@murrayc.com>
[modest] / src / maemo / easysetup / modest-easysetup-wizard.c
index aa60311..ad46faf 100644 (file)
@@ -143,7 +143,7 @@ modest_easysetup_wizard_dialog_finalize (GObject *object)
 }
 
 static void
-show_error (GtkWindow *parent_window, const gchar* text);
+show_error (GtkWidget *parent_widget, const gchar* text);
 
 static gboolean
 create_account (ModestEasysetupWizardDialog *self, gboolean enabled);
@@ -206,11 +206,7 @@ static GList* check_for_supported_auth_methods(ModestEasysetupWizardDialog* acco
        if(error == NULL || error->domain != modest_maemo_utils_get_supported_secure_authentication_error_quark() ||
                        error->code != MODEST_MAEMO_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
        {
-               GtkWidget* error_dialog = gtk_message_dialog_new(GTK_WINDOW(account_wizard),
-                                                                GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
-                                                                GTK_BUTTONS_OK, (error != NULL) ? error->message : _("Server does not support secure authentication!"));
-               gtk_dialog_run(GTK_DIALOG(error_dialog));
-               gtk_widget_destroy(error_dialog);
+               show_error (GTK_WIDGET(account_wizard), _("Could not discover supported secure authentication methods."));
        }
 
        if(error != NULL) g_error_free(error);
@@ -354,19 +350,20 @@ on_combo_account_serviceprovider (GtkComboBox *widget, gpointer user_data)
 static void
 on_entry_max (ModestValidatingEntry *self, gpointer user_data)
 {
-       ModestEasysetupWizardDialog *dialog = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
-       show_error (GTK_WINDOW (dialog), _("ckdg_ib_maximum_characters_reached"));
+       /* ModestEasysetupWizardDialog *dialog = MODEST_EASYSETUP_WIZARD_DIALOG (user_data); */
+       show_error (GTK_WIDGET (self), _CS("ckdg_ib_maximum_characters_reached"));
 }
 
 static void
 on_entry_invalid_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
 {
-       ModestEasysetupWizardDialog *dialog = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);       
+       /* ModestEasysetupWizardDialog *dialog = MODEST_EASYSETUP_WIZARD_DIALOG (user_data); */
        /* We could add a special case for whitespace here 
        if (character == NULL) ...
        */
-       hildon_banner_show_information (
-                                               GTK_WIDGET(dialog), NULL, _("ckdg_ib_illegal_characters_entered"));
+       /* TODO: Should this show just this one bad character or all the not-allowed characters? */
+       gchar *message = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), character);
+       show_error (GTK_WIDGET (self), message);
 }
 
 static GtkWidget*
@@ -494,6 +491,7 @@ create_page_account_details (ModestEasysetupWizardDialog *self)
        modest_validating_entry_set_unallowed_characters (
                MODEST_VALIDATING_ENTRY (self->entry_account_title), list_prevent);
        g_list_free (list_prevent);
+       list_prevent = NULL;
        modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_account_title),
                                                                                                                                         on_entry_invalid_character, self);
        
@@ -518,10 +516,11 @@ create_page_user_details (ModestEasysetupWizardDialog *self)
         * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
        GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
         
-       /* The name widgets: */
+       /* The name widgets: (use auto cap) */
        self->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
-       /* Auto-capitalization is the default, so let's turn it off: */
-       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_name), HILDON_GTK_INPUT_MODE_FULL);
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_name), 
+                                        HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
+       
        /* Set max length as in the UI spec:
         * The UI spec seems to want us to show a dialog if we hit the maximum. */
        gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_name), 64);
@@ -542,7 +541,7 @@ create_page_user_details (ModestEasysetupWizardDialog *self)
        list_prevent = g_list_append (list_prevent, ">");
        modest_validating_entry_set_unallowed_characters (
                MODEST_VALIDATING_ENTRY (self->entry_user_name), list_prevent);
-       modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_account_title),
+       modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_user_name),
                                                                                                                                         on_entry_invalid_character, self);
        g_list_free (list_prevent);
        
@@ -562,7 +561,7 @@ create_page_user_details (ModestEasysetupWizardDialog *self)
         * as required by our UI specification: */
        modest_validating_entry_set_unallowed_characters_whitespace (
                MODEST_VALIDATING_ENTRY (self->entry_user_username));
-       modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_account_title),
+       modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_user_username),
                                                                                                                                         on_entry_invalid_character, self);
        
        /* Set max length as in the UI spec:
@@ -1508,9 +1507,12 @@ modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *kla
 }
  
 static void
-show_error (GtkWindow *parent_window, const gchar* text)
+show_error (GtkWidget *parent_widget, const gchar* text)
 {
-       GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, text));
+       hildon_banner_show_information(parent_widget, NULL, text);
+       
+#if 0
+       GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, text)); */
        /*
          GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
          (GtkDialogFlags)0,
@@ -1521,6 +1523,7 @@ show_error (GtkWindow *parent_window, const gchar* text)
                 
        gtk_dialog_run (dialog);
        gtk_widget_destroy (GTK_WIDGET (dialog));
+#endif
 }
 
 /** Attempt to create the account from the information that the user has entered.
@@ -1643,7 +1646,7 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
        
        if (!created) {
                /* TODO: Provide a Logical ID for the text: */
-               show_error (GTK_WINDOW (self), _("An error occurred while creating the incoming account."));
+               show_error (GTK_WIDGET (self), _("An error occurred while creating the incoming account."));
                return FALSE;   
        }
        
@@ -1672,8 +1675,10 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
                        modest_presets_get_info_server_security (priv->presets, provider_id, 
                                                                 FALSE /* incoming */);
 
-               /* TODO: There is no SMTP authentication enum for presets, 
-                  so we should probably check what the server supports. */
+               /* TODO: The secure-smtp information in the presets data is currently wrong,
+                * so we choose a reasonable default. Remove this when the presets data is corrected: */
+               security_outgoing = security_outgoing & MODEST_PRESETS_SECURITY_SECURE_SMTP;
+
                protocol_security_outgoing = MODEST_PROTOCOL_CONNECTION_NORMAL;
                if (security_outgoing & MODEST_PRESETS_SECURITY_SECURE_SMTP) {
                        /* printf("DEBUG: %s: using secure SMTP\n", __FUNCTION__); */
@@ -1716,7 +1721,7 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
                
        if (!created) {
                /* TODO: Provide a Logical ID for the text: */
-               show_error (GTK_WINDOW (self), _("An error occurred while creating the outgoing account."));
+               show_error (GTK_WIDGET (self), _("An error occurred while creating the outgoing account."));
                return FALSE;   
        }
        
@@ -1731,7 +1736,7 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
        
        if (!created) {
                /* TODO: Provide a Logical ID for the text: */
-               show_error (GTK_WINDOW (self), _("An error occurred while creating the account."));
+               show_error (GTK_WIDGET (self), _("An error occurred while creating the account."));
                return FALSE;   
        }