Run plugins availability check after tapping on next, not before.
[modest] / src / hildon2 / modest-easysetup-wizard-dialog.c
index b0b47ef..2da4f55 100644 (file)
@@ -1484,7 +1484,6 @@ modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
 
        priv->settings = modest_account_settings_new ();
 
-       check_support_of_protocols (self);
 }
 
 ModestEasysetupWizardDialog*
@@ -1618,8 +1617,12 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
        picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
        id_type = modest_provider_picker_get_active_id_type (picker);
        g_object_get (self, "wizard-notebook", &notebook, NULL);
-       modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
-                                                           NULL);
+
+       /* Remove the response override handler for non-plugin
+          protocols. For plugins it'll be overriden later */
+       if (id_type != MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL)
+               modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
+                                                                   NULL);
 
 
        if (id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
@@ -1656,6 +1659,7 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
                        ModestProtocol *protocol;
                        gchar *proto_name;
                        ModestProtocolType proto_type;
+                       ModestWizardDialogResponseOverrideFunc response_override;
 
                        /* Get protocol data */
                        proto_name = modest_provider_picker_get_active_provider_id (picker);
@@ -1673,22 +1677,25 @@ create_subsequent_pages (ModestEasysetupWizardDialog *self)
                                priv->page_complete_easysetup = NULL;
                        }
 
+                       /* Ensure that the response override handler
+                          is set. It might happen that plugins clear
+                          them incorrectly */
+                       response_override = modest_account_protocol_get_wizard_response_override
+                               (MODEST_ACCOUNT_PROTOCOL (protocol));
+                       modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
+                                                                           response_override);
+
                        if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
                            proto_type != priv->last_plugin_protocol_selected) {
                                ModestPairList *tabs;
                                GSList *tmp;
                                gboolean first_page = TRUE;
-                               ModestWizardDialogResponseOverrideFunc response_override;
 
                                /* Remember the last selected plugin protocol */
                                priv->last_plugin_protocol_selected = proto_type;
 
                                /* Get tabs */
                                tabs = modest_account_protocol_get_easysetupwizard_tabs (MODEST_ACCOUNT_PROTOCOL (protocol));
-                               response_override = modest_account_protocol_get_wizard_response_override
-                                       (MODEST_ACCOUNT_PROTOCOL (protocol));
-                               modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
-                                                                                   response_override);
                                tmp = (GSList *) tabs;
                                while (tmp) {
                                        ModestPair *pair = (ModestPair *) tmp->data;
@@ -1875,7 +1882,12 @@ on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *
         * either because it was too slow,
         * or because it requires interaction:
         */
-       if (current_page == priv->page_account_details) {
+       if (current_page == priv->page_welcome) {
+               if (!priv->check_support_done) {
+                       check_support_of_protocols (self);
+                       return priv->check_support_done;
+               }
+       } else if (current_page == priv->page_account_details) {
                /* Check that the title is not already in use: */
                gchar* account_title = get_entered_account_title (self);
                if (!account_title)
@@ -2022,7 +2034,7 @@ real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next)
 
                /* If the check support is not done then do not enable
                   the wizard to continue */
-               enable_next = enable_next && priv->check_support_done;
+               enable_next = enable_next && priv->pending_check_support == 0;
        }
 
        gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
@@ -2477,6 +2489,7 @@ check_support_callback (ModestAccountProtocol *protocol,
                                fill_providers (self);
                        hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), FALSE);
                        invoke_enable_buttons_vfunc (self);
+                       gtk_dialog_response (GTK_DIALOG (self), MODEST_WIZARD_DIALOG_NEXT);
                }
        }
        g_object_unref (self);