+typedef struct IdleData {
+ ModestEasysetupWizardDialog *dialog;
+ ModestPresets *presets;
+} IdleData;
+
+gboolean
+presets_idle (gpointer userdata)
+{
+ IdleData *idle_data = (IdleData *) userdata;
+ ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (idle_data->dialog);
+ ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
+
+ g_assert (idle_data->presets);
+
+ gdk_threads_enter ();
+
+ priv->presets = idle_data->presets;
+
+ if (self->combo_account_country) {
+ gint mcc = get_default_country_code();
+ /* Fill the combo in an idle call, as it takes a lot of time */
+ easysetup_country_combo_box_load_data(
+ EASYSETUP_COUNTRY_COMBO_BOX (self->combo_account_country));
+ easysetup_country_combo_box_set_active_country_mcc (
+ EASYSETUP_COUNTRY_COMBO_BOX (self->combo_account_country), mcc);
+ easysetup_provider_combo_box_fill (
+ EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider),
+ priv->presets, mcc);
+ }
+
+ priv->dirty = FALSE;
+
+ g_object_unref (idle_data->dialog);
+ g_free (idle_data);
+
+ gdk_threads_leave ();
+
+ return FALSE;
+}
+
+gpointer
+presets_loader (gpointer userdata)
+{
+ ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (userdata);
+ ModestPresets *presets = NULL;
+ IdleData *idle_data;
+
+ const gchar* path = NULL;
+ const gchar* path1 = MODEST_PROVIDER_DATA_FILE;
+ const gchar* path2 = MODEST_MAEMO_PROVIDER_DATA_FILE;
+
+ if (access(path1, R_OK) == 0)
+ path = path1;
+ else if (access(path2, R_OK) == 0)
+ path = path2;
+ else {
+ g_warning ("%s: neither '%s' nor '%s' is a readable provider data file",
+ __FUNCTION__, path1, path2);
+ return NULL;
+ }
+
+ presets = modest_presets_new (path);
+ if (!presets) {
+ g_warning ("%s: failed to parse '%s'", __FUNCTION__, path);
+ return NULL;
+ }
+
+ idle_data = g_new0 (IdleData, 1);
+ idle_data->dialog = self;
+ idle_data->presets = presets;
+
+ g_idle_add (presets_idle, idle_data);
+
+ return NULL;
+}
+