+static gboolean
+check_support_show_progress (gpointer userdata)
+{
+ ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
+ ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
+
+ priv->check_support_show_progress_id = 0;
+
+ if (priv->destroyed)
+ return FALSE;
+
+ hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), TRUE);
+
+ return FALSE;
+}
+
+static void
+check_support_callback (ModestAccountProtocol *protocol,
+ gboolean supported,
+ gpointer userdata)
+{
+ ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
+ ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
+
+ priv->pending_check_support --;
+
+ if (priv->check_support_show_progress_id > 0) {
+ g_source_remove (priv->check_support_show_progress_id);
+ priv->check_support_show_progress_id = 0;
+ }
+
+ if (priv->pending_check_support == 0) {
+ priv->check_support_done = TRUE;
+
+ if (!priv->destroyed) {
+ if (priv->presets)
+ 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);
+}
+
+
+static void
+check_support_of_protocols (ModestEasysetupWizardDialog *self)
+{
+ ModestProtocolRegistry *registry;
+ GSList *provider_protos, *node;
+ ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
+
+ registry = modest_runtime_get_protocol_registry ();
+ provider_protos = modest_protocol_registry_get_by_tag (registry,
+ MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS);
+
+ for (node = provider_protos; node != NULL; node = g_slist_next (node)) {
+ ModestProtocol *proto = MODEST_PROTOCOL (node->data);
+
+ if (!modest_protocol_registry_protocol_type_has_tag (registry,
+ modest_protocol_get_type_id (proto),
+ MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS))
+ continue;
+
+ if (modest_protocol_registry_protocol_type_has_tag
+ (registry,
+ modest_protocol_get_type_id (proto),
+ MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS)) {
+ /* Check if there's already an account configured with this account type */
+ if (modest_account_mgr_singleton_protocol_exists (modest_runtime_get_account_mgr (),
+ modest_protocol_get_type_id (proto)))
+ continue;
+ }
+
+ if (MODEST_ACCOUNT_PROTOCOL (proto)) {
+ priv->pending_check_support ++;
+ modest_account_protocol_check_support (MODEST_ACCOUNT_PROTOCOL (proto),
+ check_support_callback,
+ g_object_ref (self));
+ }
+ }
+ g_slist_free (provider_protos);
+
+ if (priv->pending_check_support > 0) {
+ priv->check_support_show_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 1000,
+ check_support_show_progress,
+ g_object_ref (self), g_object_unref);
+ } else {
+ priv->check_support_done = TRUE;
+ }
+ invoke_enable_buttons_vfunc (self);
+}