2 /* Copyright (c) 2006, Nokia Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the Nokia Corporation nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "modest-easysetup-wizard-dialog.h"
33 #include <glib/gi18n.h>
34 #include <gtk/gtknotebook.h>
35 #include <gtk/gtkvbox.h>
36 #include <gtk/gtklabel.h>
37 #include <gtk/gtkentry.h>
38 #include <gtk/gtkbutton.h>
39 #include <gtk/gtkcheckbutton.h>
40 #include <gtk/gtkmessagedialog.h>
41 #include <gtk/gtkseparator.h>
42 #include "modest-country-picker.h"
43 #include "modest-provider-picker.h"
44 #include "modest-servertype-picker.h"
45 #include "widgets/modest-validating-entry.h"
46 #include "modest-text-utils.h"
47 #include "modest-conf.h"
48 #include "modest-defs.h"
49 #include "modest-account-mgr.h"
50 #include "modest-signal-mgr.h"
51 #include "modest-account-mgr-helpers.h"
52 #include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
53 #include "modest-connection-specific-smtp-window.h"
54 #include "widgets/modest-ui-constants.h"
55 #include "widgets/modest-default-account-settings-dialog.h"
56 #include "widgets/modest-easysetup-wizard-page.h"
57 #include "modest-maemo-utils.h"
58 #include "modest-utils.h"
59 #include "modest-hildon-includes.h"
60 #include "modest-maemo-security-options-view.h"
61 #include "modest-account-protocol.h"
63 /* Include config.h so that _() works: */
68 G_DEFINE_TYPE (ModestEasysetupWizardDialog, modest_easysetup_wizard_dialog, MODEST_TYPE_WIZARD_DIALOG);
70 #define MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
71 MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, \
72 ModestEasysetupWizardDialogPrivate))
74 #define LABELS_WIDTH 480
75 #define DIALOG_WIDTH LABELS_WIDTH + MODEST_MARGIN_DOUBLE
77 typedef struct _ModestEasysetupWizardDialogPrivate ModestEasysetupWizardDialogPrivate;
81 MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED = 0x01,
82 MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED = 0x02
83 } ModestEasysetupWizardDialogServerChanges;
85 struct _ModestEasysetupWizardDialogPrivate
87 ModestPresets *presets;
89 /* Remember what fields the user edited manually to not prefill them
91 ModestEasysetupWizardDialogServerChanges server_changes;
93 /* Check if the user changes a field to show a confirmation dialog */
96 /* If we have a pending load of settings or not. */
97 gboolean pending_load_settings;
99 /* Used by derived widgets to query existing accounts,
100 * and to create new accounts: */
101 ModestAccountMgr *account_manager;
102 ModestAccountSettings *settings;
104 /* notebook pages: */
105 GtkWidget *page_welcome;
106 GtkWidget *check_support_progress;
107 gboolean check_support_done;
108 guint check_support_show_progress_id;
109 guint check_support_progress_pulse_id;
110 gint pending_check_support;
113 GtkWidget *page_account_details;
114 GtkWidget *account_country_picker;
115 GtkWidget *account_serviceprovider_picker;
116 GtkWidget *entry_account_title;
118 GtkWidget *page_user_details;
119 GtkWidget *entry_user_name;
120 GtkWidget *entry_user_username;
121 GtkWidget *entry_user_password;
122 GtkWidget *entry_user_email;
124 GtkWidget *page_complete_easysetup;
126 GtkWidget *page_custom_incoming;
127 GtkWidget *incoming_servertype_picker;
128 GtkWidget *caption_incoming;
129 GtkWidget *entry_incomingserver;
131 /* Security widgets */
132 GtkWidget *incoming_security;
133 GtkWidget *outgoing_security;
135 GtkWidget *page_custom_outgoing;
136 GtkWidget *entry_outgoingserver;
137 GtkWidget *checkbox_outgoing_smtp_specific;
138 GtkWidget *button_outgoing_smtp_servers;
140 GtkWidget *page_complete_customsetup;
142 ModestProtocolType last_plugin_protocol_selected;
143 GSList *missing_data_signals;
146 static void save_to_settings (ModestEasysetupWizardDialog *self);
147 static void real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next);
148 static void on_update_model (ModestWizardDialog *dialog);
149 static gboolean on_save (ModestWizardDialog *dialog);
150 static GList* check_for_supported_auth_methods (ModestEasysetupWizardDialog* self);
151 static gboolean check_has_supported_auth_methods(ModestEasysetupWizardDialog* self);
152 static void check_support_callback (ModestAccountProtocol *protocol,
155 static void check_support_of_protocols (ModestEasysetupWizardDialog *self);
156 static gboolean check_support_show_progress (gpointer userdata);
157 static gboolean check_support_progress_pulse (gpointer userdata);
160 on_delete_event (GtkWidget *widget,
162 ModestEasysetupWizardDialog *wizard)
164 gtk_dialog_response (GTK_DIALOG (wizard), GTK_RESPONSE_CANCEL);
169 on_easysetup_changed(GtkWidget* widget, ModestEasysetupWizardDialog* wizard)
171 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(wizard);
172 g_return_if_fail (priv != NULL);
177 modest_easysetup_wizard_dialog_dispose (GObject *object)
179 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (object);
180 priv->destroyed = TRUE;
182 if (priv->check_support_show_progress_id > 0) {
183 g_source_remove (priv->check_support_show_progress_id);
184 priv->check_support_show_progress_id = 0;
187 if (priv->check_support_progress_pulse_id > 0) {
188 g_source_remove (priv->check_support_progress_pulse_id);
189 priv->check_support_progress_pulse_id = 0;
192 if (G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose)
193 G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose (object);
197 modest_easysetup_wizard_dialog_finalize (GObject *object)
199 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (object);
200 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
202 if (priv->account_manager)
203 g_object_unref (G_OBJECT (priv->account_manager));
206 modest_presets_destroy (priv->presets);
209 g_object_unref (priv->settings);
211 if (priv->missing_data_signals) {
212 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
213 priv->missing_data_signals = NULL;
216 G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->finalize (object);
220 create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self);
223 set_default_custom_servernames(ModestEasysetupWizardDialog *dialog);
225 static void on_servertype_selector_changed(HildonTouchSelector *selector, gint column, gpointer user_data);
228 get_port_from_protocol (ModestProtocolType server_type,
229 gboolean alternate_port)
232 ModestProtocol *protocol;
233 ModestProtocolRegistry *protocol_registry;
235 protocol_registry = modest_runtime_get_protocol_registry ();
236 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, server_type);
238 if (alternate_port) {
239 server_port = modest_account_protocol_get_alternate_port (MODEST_ACCOUNT_PROTOCOL (protocol));
241 server_port = modest_account_protocol_get_port (MODEST_ACCOUNT_PROTOCOL (protocol));
247 invoke_enable_buttons_vfunc (ModestEasysetupWizardDialog *wizard_dialog)
249 ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog);
251 /* Call the vfunc, which may be overridden by derived classes: */
252 if (klass->enable_buttons) {
253 GtkNotebook *notebook = NULL;
254 g_object_get (wizard_dialog, "wizard-notebook", ¬ebook, NULL);
256 const gint current_page_num = gtk_notebook_get_current_page (notebook);
257 if (current_page_num == -1)
260 GtkWidget* current_page_widget = gtk_notebook_get_nth_page (notebook, current_page_num);
261 (*(klass->enable_buttons))(MODEST_WIZARD_DIALOG (wizard_dialog), current_page_widget);
266 on_caption_entry_changed (GtkEditable *editable, gpointer user_data)
268 ModestEasysetupWizardDialog *self;
269 gboolean mandatory, empty;
270 ModestEasysetupWizardDialogPrivate *priv;
272 g_return_if_fail (user_data);
274 self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
275 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
277 invoke_enable_buttons_vfunc(self);
279 empty = !g_utf8_collate (gtk_entry_get_text (GTK_ENTRY (editable)), "");
280 mandatory = ((GtkWidget *) editable == priv->entry_account_title) ||
281 ((GtkWidget *) editable == priv->entry_user_username) ||
282 ((GtkWidget *) editable == priv->entry_user_email);
284 /* Show a banner & get focus */
285 if (empty && mandatory) {
286 modest_platform_information_banner ((GtkWidget *) editable, NULL,
287 _CS("ckct_ib_enter_some_text"));
288 gtk_widget_grab_focus (GTK_WIDGET (editable));
293 on_caption_combobox_changed (GtkComboBox *widget, gpointer user_data)
295 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
297 invoke_enable_buttons_vfunc(self);
301 on_picker_button_value_changed (HildonPickerButton *widget, gpointer user_data)
303 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
305 invoke_enable_buttons_vfunc(self);
309 on_serviceprovider_picker_button_value_changed (HildonPickerButton *widget, gpointer user_data)
311 gchar* default_account_name_start;
312 gchar* default_account_name;
313 ModestEasysetupWizardDialog *self;
314 ModestEasysetupWizardDialogPrivate *priv;
315 ModestProviderPickerIdType provider_id_type;
317 self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
318 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
320 on_picker_button_value_changed (widget, user_data);
322 provider_id_type = modest_provider_picker_get_active_id_type (
323 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
324 if (provider_id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
325 default_account_name_start = g_strdup (_("mcen_ia_emailsetup_defaultname"));
329 selector = GTK_WIDGET (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (widget)));
330 default_account_name_start =
331 g_strdup (hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector)));
334 default_account_name = modest_account_mgr_get_unused_account_display_name (
335 priv->account_manager, default_account_name_start);
336 g_free (default_account_name_start);
337 default_account_name_start = NULL;
339 hildon_entry_set_text (HILDON_ENTRY (priv->entry_account_title), default_account_name);
340 g_free (default_account_name);
343 /** This is a convenience function to create a caption containing a mandatory widget.
344 * When the widget is edited, the enable_buttons() vfunc will be called.
347 create_captioned (ModestEasysetupWizardDialog *self,
348 GtkSizeGroup *title_size_group,
349 GtkSizeGroup *value_size_group,
356 result = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
357 value, use_markup, control);
359 /* Connect to the appropriate changed signal for the widget,
360 * so we can ask for the prev/next buttons to be enabled/disabled appropriately:
362 if (GTK_IS_ENTRY (control)) {
363 g_signal_connect (G_OBJECT (control), "changed",
364 G_CALLBACK (on_caption_entry_changed), self);
367 else if (GTK_IS_COMBO_BOX (control)) {
368 g_signal_connect (G_OBJECT (control), "changed",
369 G_CALLBACK (on_caption_combobox_changed), self);
376 create_page_welcome (ModestEasysetupWizardDialog *self)
381 ModestEasysetupWizardDialogPrivate *priv;
383 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
384 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
385 label = gtk_label_new(_("mcen_ia_emailsetup_intro"));
386 priv->check_support_progress = gtk_progress_bar_new ();
387 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
388 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
389 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
390 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
391 /* So that it is not truncated: */
392 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
393 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
394 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
395 gtk_box_pack_end (GTK_BOX (box), priv->check_support_progress, FALSE, FALSE, 0);
396 gtk_container_add (GTK_CONTAINER (align), box);
397 gtk_widget_show (label);
398 gtk_widget_show (GTK_WIDGET (box));
399 gtk_widget_show (align);
400 return GTK_WIDGET (align);
404 on_account_country_selector_changed (HildonTouchSelector *widget, gint column, gpointer user_data)
406 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
408 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
412 /* Fill the providers picker, based on the selected country: */
413 if (priv->presets != NULL) {
414 gint mcc = modest_country_picker_get_active_country_mcc (
415 MODEST_COUNTRY_PICKER (priv->account_country_picker));
416 modest_provider_picker_fill (
417 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker), priv->presets, mcc);
422 update_user_email_from_provider (ModestEasysetupWizardDialog *self)
424 ModestEasysetupWizardDialogPrivate *priv;
425 gchar* provider_id = NULL, *with_at = NULL;
428 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
430 /* Fill the providers combo, based on the selected country: */
431 provider_id = modest_provider_picker_get_active_provider_id (
432 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
435 gchar *domain_name = modest_presets_get_domain (priv->presets, provider_id);
436 with_at = g_strdup_printf ("%c%s", '@', domain_name);
437 g_free (domain_name);
440 /* The sample address already contains the '@' */
442 with_at = g_strdup (MODEST_EXAMPLE_EMAIL_ADDRESS);
444 if (priv->entry_user_email)
445 hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_email), with_at);
448 g_free (provider_id);
452 on_account_serviceprovider_selector_changed (HildonTouchSelector *widget, gint column, gpointer user_data)
454 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
456 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
460 update_user_email_from_provider (self);
464 on_entry_max (ModestValidatingEntry *self, gpointer user_data)
466 modest_platform_information_banner (GTK_WIDGET (self), NULL,
467 _CS("ckdg_ib_maximum_characters_reached"));
471 create_page_account_details (ModestEasysetupWizardDialog *self)
475 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
476 GtkWidget *label = gtk_label_new(_("mcen_ia_accountdetails"));
477 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
479 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
480 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
481 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
482 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
483 gtk_widget_show (label);
485 /* Create a size group to be used by all captions.
486 * Note that HildonCaption does not create a default size group if we do not specify one.
487 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
488 GtkSizeGroup* title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
489 GtkSizeGroup* value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
491 /* The country widgets: */
492 priv->account_country_picker = GTK_WIDGET (modest_country_picker_new (MODEST_EDITABLE_SIZE,
493 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
494 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
495 _("mcen_fi_country"), priv->account_country_picker);
496 g_signal_connect (G_OBJECT (priv->account_country_picker), "value-changed",
497 G_CALLBACK (on_picker_button_value_changed), self);
498 gtk_box_pack_start (GTK_BOX (box), priv->account_country_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
499 gtk_widget_show (priv->account_country_picker);
501 /* The service provider widgets: */
502 priv->account_serviceprovider_picker = GTK_WIDGET (modest_provider_picker_new (MODEST_EDITABLE_SIZE,
503 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
504 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
505 _("mcen_fi_serviceprovider"),
506 priv->account_serviceprovider_picker);
507 g_signal_connect (G_OBJECT (priv->account_serviceprovider_picker), "value-changed",
508 G_CALLBACK (on_serviceprovider_picker_button_value_changed), self);
509 gtk_box_pack_start (GTK_BOX (box), priv->account_serviceprovider_picker, FALSE, FALSE, 0);
510 gtk_widget_show (priv->account_serviceprovider_picker);
512 /* The description widgets: */
513 priv->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
514 g_signal_connect(G_OBJECT(priv->entry_account_title), "changed",
515 G_CALLBACK(on_easysetup_changed), self);
516 /* Do use auto-capitalization: */
517 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_account_title),
518 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
520 /* Set a default account title, choosing one that does not already exist: */
521 /* Note that this is irrelevant to the non-user visible name, which we will create later. */
522 gchar* default_account_name_start = g_strdup (_("mcen_ia_emailsetup_defaultname"));
523 gchar* default_account_name = modest_account_mgr_get_unused_account_display_name (
524 priv->account_manager, default_account_name_start);
525 g_free (default_account_name_start);
526 default_account_name_start = NULL;
528 hildon_entry_set_text (HILDON_ENTRY (priv->entry_account_title), default_account_name);
529 g_free (default_account_name);
530 default_account_name = NULL;
532 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mcen_fi_account_title"), FALSE,
533 priv->entry_account_title);
534 gtk_widget_show (priv->entry_account_title);
535 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
536 gtk_widget_show (caption);
538 /* Prevent the use of some characters in the account title,
539 * as required by our UI specification: */
540 GList *list_prevent = NULL;
541 list_prevent = g_list_append (list_prevent, "\\");
542 list_prevent = g_list_append (list_prevent, "/");
543 list_prevent = g_list_append (list_prevent, ":");
544 list_prevent = g_list_append (list_prevent, "*");
545 list_prevent = g_list_append (list_prevent, "?");
546 list_prevent = g_list_append (list_prevent, "\""); /* The UI spec mentions “, but maybe means ", maybe both. */
547 list_prevent = g_list_append (list_prevent, "“");
548 list_prevent = g_list_append (list_prevent, "<");
549 list_prevent = g_list_append (list_prevent, ">");
550 list_prevent = g_list_append (list_prevent, "|");
551 list_prevent = g_list_append (list_prevent, "^");
552 modest_validating_entry_set_unallowed_characters (
553 MODEST_VALIDATING_ENTRY (priv->entry_account_title), list_prevent);
554 g_list_free (list_prevent);
556 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
557 modest_utils_on_entry_invalid_character, self);
559 /* Set max length as in the UI spec:
560 * The UI spec seems to want us to show a dialog if we hit the maximum. */
561 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_account_title), 64);
562 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_account_title),
565 gtk_widget_show (GTK_WIDGET (box));
567 g_object_unref (title_sizegroup);
568 g_object_unref (value_sizegroup);
570 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
571 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
572 gtk_widget_show (align);
573 gtk_container_add (GTK_CONTAINER (align), box);
575 return GTK_WIDGET (align);
579 create_page_user_details (ModestEasysetupWizardDialog *self)
581 GtkSizeGroup* title_sizegroup;
582 GtkSizeGroup* value_sizegroup;
584 ModestEasysetupWizardDialogPrivate *priv;
587 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
589 /* Create a size group to be used by all captions.
590 * Note that HildonCaption does not create a default size group if we do not specify one.
591 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
592 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
593 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
594 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
596 /* The name widgets: (use auto cap) */
597 priv->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
598 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_name),
599 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
601 /* Set max length as in the UI spec:
602 * The UI spec seems to want us to show a dialog if we hit the maximum. */
603 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_name), 64);
604 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_name),
606 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
607 _("mcen_li_emailsetup_name"), FALSE, priv->entry_user_name);
608 g_signal_connect(G_OBJECT(priv->entry_user_name), "changed",
609 G_CALLBACK(on_easysetup_changed), self);
610 gtk_widget_show (priv->entry_user_name);
611 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
612 gtk_widget_show (caption);
614 /* Prevent the use of some characters in the name,
615 * as required by our UI specification: */
616 GList *list_prevent = NULL;
617 list_prevent = g_list_append (list_prevent, "<");
618 list_prevent = g_list_append (list_prevent, ">");
619 modest_validating_entry_set_unallowed_characters (
620 MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
621 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
622 modest_utils_on_entry_invalid_character, self);
623 g_list_free (list_prevent);
625 /* The username widgets: */
626 priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
627 /* Auto-capitalization is the default, so let's turn it off: */
628 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username),
629 HILDON_GTK_INPUT_MODE_FULL);
630 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mail_fi_username"), FALSE,
631 priv->entry_user_username);
632 gtk_widget_show (priv->entry_user_username);
633 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
634 g_signal_connect(G_OBJECT(priv->entry_user_username), "changed",
635 G_CALLBACK(on_easysetup_changed), self);
636 gtk_widget_show (caption);
638 /* Prevent the use of some characters in the username,
639 * as required by our UI specification: */
640 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_username),
641 modest_utils_on_entry_invalid_character, self);
643 /* Set max length as in the UI spec:
644 * The UI spec seems to want us to show a dialog if we hit the maximum. */
645 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
646 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_username),
649 /* The password widgets: */
650 priv->entry_user_password = hildon_entry_new (MODEST_EDITABLE_SIZE);
651 /* Auto-capitalization is the default, so let's turn it off: */
652 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password),
653 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
654 gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
655 /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
656 caption = create_captioned (self, title_sizegroup, value_sizegroup,
657 _("mail_fi_password"), FALSE, priv->entry_user_password);
658 g_signal_connect(G_OBJECT(priv->entry_user_password), "changed",
659 G_CALLBACK(on_easysetup_changed), self);
660 gtk_widget_show (priv->entry_user_password);
661 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
662 gtk_widget_show (caption);
664 /* The email address widgets: */
665 priv->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
666 /* Auto-capitalization is the default, so let's turn it off: */
667 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
668 caption = create_captioned (self, title_sizegroup, value_sizegroup,
669 _("mcen_li_emailsetup_email_address"), FALSE, priv->entry_user_email);
670 update_user_email_from_provider (self);
671 gtk_widget_show (priv->entry_user_email);
672 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
673 g_signal_connect(G_OBJECT(priv->entry_user_email), "changed",
674 G_CALLBACK(on_easysetup_changed), self);
675 gtk_widget_show (caption);
677 /* Set max length as in the UI spec:
678 * The UI spec seems to want us to show a dialog if we hit the maximum. */
679 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_email), 64);
680 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_email),
684 gtk_widget_show (GTK_WIDGET (box));
685 g_object_unref (title_sizegroup);
686 g_object_unref (value_sizegroup);
688 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
689 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
690 gtk_widget_show (align);
691 gtk_container_add (GTK_CONTAINER (align), box);
693 return GTK_WIDGET (align);
697 create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
700 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
702 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
703 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
704 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
705 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
706 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
708 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
709 gtk_widget_show (label);
711 label = gtk_label_new (_("mcen_ia_easysetup_complete"));
712 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
713 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
715 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
716 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
717 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
718 gtk_widget_show (label);
720 gtk_widget_show (GTK_WIDGET (box));
722 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
723 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
724 gtk_widget_show (align);
725 gtk_container_add (GTK_CONTAINER (align), box);
727 return GTK_WIDGET (align);
730 /** Change the caption title for the incoming server,
731 * as specified in the UI spec:
734 update_incoming_server_title (ModestEasysetupWizardDialog *self)
736 ModestEasysetupWizardDialogPrivate* priv;
737 ModestProtocolType protocol_type;
738 ModestProtocolRegistry *protocol_registry;
740 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
741 protocol_registry = modest_runtime_get_protocol_registry ();
743 protocol_type = modest_servertype_picker_get_active_servertype (
744 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
746 /* This could happen when the combo box has still no active iter */
747 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
748 gchar* incomingserver_title;
749 const gchar *protocol_display_name;
750 ModestProtocol *protocol;
752 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry,
754 protocol_display_name = modest_protocol_get_display_name (protocol);
756 incomingserver_title = g_strconcat (_("mcen_li_emailsetup_servertype"), "\n<small>(",
757 protocol_display_name, ")</small>", NULL);
759 modest_maemo_utils_captioned_set_label (priv->caption_incoming, incomingserver_title, TRUE);
761 g_free(incomingserver_title);
765 /** Change the caption title for the incoming server,
766 * as specified in the UI spec:
769 update_incoming_server_security_choices (ModestEasysetupWizardDialog *self)
771 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
772 ModestServertypePicker *server_type_picker;
773 ModestProtocolType protocol_type;
774 ModestSecurityOptionsView *view;
777 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
779 modest_servertype_picker_get_active_servertype (server_type_picker);
781 /* Fill the combo with appropriately titled choices for all
783 view = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
784 modest_security_options_view_set_server_type (view, protocol_type);
788 on_servertype_selector_changed(HildonTouchSelector *selector, gint column, gpointer user_data)
790 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
791 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
792 ModestServertypePicker *picker;
793 ModestProtocolType protocol_type;
798 update_incoming_server_title (self);
800 /* Update security options if needed */
801 picker = MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
802 protocol_type = modest_servertype_picker_get_active_servertype (picker);
803 update_incoming_server_security_choices (self);
804 gtk_widget_show (priv->incoming_security);
806 set_default_custom_servernames (self);
810 on_entry_incoming_servername_changed(GtkEntry *entry, gpointer user_data)
812 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
813 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
815 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED;
819 create_page_custom_incoming (ModestEasysetupWizardDialog *self)
821 ModestProtocolRegistry *protocol_registry;
822 ModestEasysetupWizardDialogPrivate* priv;
826 GtkSizeGroup *title_sizegroup;
827 GtkSizeGroup *value_sizegroup;
829 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
830 protocol_registry = modest_runtime_get_protocol_registry ();
832 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
833 pannable = hildon_pannable_area_new ();
835 /* Show note that account type cannot be changed in future: */
836 label = gtk_label_new (_("mcen_ia_emailsetup_account_type"));
837 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
838 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
839 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
840 gtk_widget_show (label);
842 /* Create a size group to be used by all captions.
843 * Note that HildonCaption does not create a default size group if we do not specify one.
844 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
845 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
846 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
848 /* The incoming server widgets: */
849 priv->incoming_servertype_picker = GTK_WIDGET (modest_servertype_picker_new (MODEST_EDITABLE_SIZE,
850 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
852 hildon_button_set_title (HILDON_BUTTON (priv->incoming_servertype_picker), _("mcen_li_emailsetup_type"));
853 g_signal_connect (G_OBJECT (priv->incoming_servertype_picker), "value-changed",
854 G_CALLBACK (on_picker_button_value_changed), self);
855 gtk_box_pack_start (GTK_BOX (box), priv->incoming_servertype_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
856 gtk_widget_show (priv->incoming_servertype_picker);
858 priv->entry_incomingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
859 g_signal_connect(G_OBJECT(priv->entry_incomingserver), "changed", G_CALLBACK(on_easysetup_changed), self);
860 /* Auto-capitalization is the default, so let's turn it off: */
861 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
862 set_default_custom_servernames (self);
864 /* The caption title will be updated in update_incoming_server_title().
865 * so this default text will never be seen: */
866 priv->caption_incoming = create_captioned (self, title_sizegroup, value_sizegroup,
867 "This will be removed",
868 FALSE, priv->entry_incomingserver);
869 update_incoming_server_title (self);
870 gtk_widget_show (priv->entry_incomingserver);
871 gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
872 gtk_widget_show (priv->caption_incoming);
874 /* Change the caption title when the servertype changes,
875 * as in the UI spec: */
876 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (priv->incoming_servertype_picker))),
878 G_CALLBACK (on_servertype_selector_changed), self);
880 /* Remember when the servername was changed manually: */
881 g_signal_connect (G_OBJECT (priv->entry_incomingserver), "changed",
882 G_CALLBACK (on_entry_incoming_servername_changed), self);
884 /* The secure connection widgets. These are only valid for
885 protocols with security */
886 priv->incoming_security =
887 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
888 FALSE, title_sizegroup, value_sizegroup);
889 gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
890 FALSE, FALSE, MODEST_MARGIN_HALF);
891 gtk_widget_show_all (priv->incoming_security);
893 /* Set default selection */
894 modest_servertype_picker_set_active_servertype (
895 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker),
896 MODEST_PROTOCOLS_STORE_POP);
898 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), box);
899 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
900 hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pannable)));
901 gtk_widget_show (GTK_WIDGET (box));
902 gtk_widget_show (pannable);
904 g_object_unref (title_sizegroup);
905 g_object_unref (value_sizegroup);
907 return GTK_WIDGET (pannable);
911 on_check_button_changed (HildonCheckButton *button, gpointer user_data)
913 GtkWidget *widget = GTK_WIDGET (user_data);
915 /* Enable the widget only if the check button is active: */
916 const gboolean enable = hildon_check_button_get_active (button);
917 gtk_widget_set_sensitive (widget, enable);
920 /* Make the sensitivity of a widget depend on a check button.
923 enable_widget_for_checkbutton (GtkWidget *widget, HildonCheckButton* button)
925 g_signal_connect (G_OBJECT (button), "toggled",
926 G_CALLBACK (on_check_button_changed), widget);
928 /* Set the starting sensitivity: */
929 on_check_button_changed (button, widget);
933 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
935 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
936 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
937 GtkWidget *specific_window;
939 /* We set dirty here because setting it depending on the connection specific dialog
943 /* Create the window, if necessary: */
944 specific_window = (GtkWidget *) modest_connection_specific_smtp_window_new ();
945 modest_connection_specific_smtp_window_fill_with_connections (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window), priv->account_manager);
947 /* Show the window */
948 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (specific_window), GTK_WINDOW (self));
949 gtk_widget_show (specific_window);
953 on_entry_outgoing_servername_changed (GtkEntry *entry, gpointer user_data)
955 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
956 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
957 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED;
961 create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
963 ModestEasysetupWizardDialogPrivate *priv;
964 gchar *smtp_caption_label;
966 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
968 pannable = hildon_pannable_area_new ();
970 /* Create a size group to be used by all captions.
971 * Note that HildonCaption does not create a default size group if we do not specify one.
972 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
973 GtkSizeGroup *title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
974 GtkSizeGroup *value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
976 /* The outgoing server widgets: */
977 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
978 priv->entry_outgoingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
979 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
980 G_CALLBACK (on_easysetup_changed), self);
981 /* Auto-capitalization is the default, so let's turn it off: */
982 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
983 smtp_caption_label = g_strconcat (_("mcen_li_emailsetup_smtp"), "\n<small>(SMTP)</small>", NULL);
984 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
985 smtp_caption_label, TRUE, priv->entry_outgoingserver);
986 g_free (smtp_caption_label);
987 gtk_widget_show (priv->entry_outgoingserver);
988 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
989 gtk_widget_show (caption);
990 set_default_custom_servernames (self);
992 /* The secure connection widgets. These are only valid for
993 protocols with security */
994 priv->outgoing_security =
995 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
996 FALSE, title_sizegroup, value_sizegroup);
997 gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security,
998 FALSE, FALSE, MODEST_MARGIN_HALF);
999 gtk_widget_show (priv->outgoing_security);
1001 GtkWidget *separator = gtk_hseparator_new ();
1002 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
1003 gtk_widget_show (separator);
1005 /* connection-specific checkbox: */
1006 priv->checkbox_outgoing_smtp_specific = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
1007 hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific),
1009 gtk_button_set_label (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
1010 _("mcen_fi_advsetup_connection_smtp"));
1011 gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
1013 g_signal_connect (G_OBJECT (priv->checkbox_outgoing_smtp_specific), "toggled",
1014 G_CALLBACK (on_easysetup_changed), self);
1016 gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
1017 gtk_box_pack_start (GTK_BOX (box), priv->checkbox_outgoing_smtp_specific,
1018 FALSE, FALSE, MODEST_MARGIN_HALF);
1020 /* Connection-specific SMTP-Severs Edit button: */
1021 priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_advsetup_optional_smtp"));
1022 hildon_gtk_widget_set_theme_size (priv->button_outgoing_smtp_servers,
1023 HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1024 gtk_widget_show (priv->button_outgoing_smtp_servers);
1025 gtk_box_pack_start (GTK_BOX (box), priv->button_outgoing_smtp_servers,
1026 FALSE, FALSE, MODEST_MARGIN_HALF);
1028 /* Only enable the button when the checkbox is checked: */
1029 enable_widget_for_checkbutton (priv->button_outgoing_smtp_servers,
1030 HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific));
1032 g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
1033 G_CALLBACK (on_button_outgoing_smtp_servers), self);
1035 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
1036 G_CALLBACK (on_entry_outgoing_servername_changed), self);
1039 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), box);
1040 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
1041 hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pannable)));
1042 gtk_widget_show (GTK_WIDGET (box));
1043 gtk_widget_show (pannable);
1045 g_object_unref (title_sizegroup);
1046 g_object_unref (value_sizegroup);
1048 return GTK_WIDGET (pannable);
1052 show_advanced_edit(gpointer user_data)
1054 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1055 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1058 /* Show the Account Settings window: */
1059 ModestAccountSettingsDialog *dialog = modest_default_account_settings_dialog_new ();
1060 if (priv->pending_load_settings) {
1061 save_to_settings (self);
1062 priv->pending_load_settings = FALSE;
1064 modest_account_settings_dialog_load_settings (dialog, priv->settings);
1066 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), GTK_WINDOW (self));
1068 response = gtk_dialog_run (GTK_DIALOG (dialog));
1070 gtk_widget_destroy (GTK_WIDGET (dialog));
1072 return FALSE; /* Do not call this timeout callback again. */
1076 on_button_edit_advanced_settings (GtkButton *button, gpointer user_data)
1078 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1080 /* Show the Account Settings window: */
1081 show_advanced_edit(self);
1084 create_page_complete_custom (ModestEasysetupWizardDialog *self)
1086 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
1087 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
1088 GtkWidget *button_edit = gtk_button_new_with_label (_("mcen_fi_advanced_settings"));
1089 hildon_gtk_widget_set_theme_size (button_edit, HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1090 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1091 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1092 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1093 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
1094 gtk_widget_show (label);
1096 label = gtk_label_new (_("mcen_ia_customsetup_complete"));
1097 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
1098 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1099 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1100 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
1101 gtk_widget_show (label);
1103 gtk_widget_show (button_edit);
1104 gtk_box_pack_start (GTK_BOX (box), button_edit, FALSE, FALSE, MODEST_MARGIN_HALF);
1106 g_signal_connect (G_OBJECT (button_edit), "clicked",
1107 G_CALLBACK (on_button_edit_advanced_settings), self);
1109 gtk_widget_show (GTK_WIDGET (box));
1110 return GTK_WIDGET (box);
1117 on_response (ModestWizardDialog *wizard_dialog,
1121 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1123 invoke_enable_buttons_vfunc (self);
1127 on_response_before (ModestWizardDialog *wizard_dialog,
1131 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1132 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(wizard_dialog);
1133 if (response_id == GTK_RESPONSE_CANCEL) {
1134 /* This is mostly copied from
1135 * src/maemo/modest-account-settings-dialog.c */
1137 GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
1138 _("imum_nc_wizard_confirm_lose_changes")));
1139 /* TODO: These button names will be ambiguous, and not
1140 * specified in the UI specification. */
1142 const gint dialog_response = gtk_dialog_run (dialog);
1143 gtk_widget_destroy (GTK_WIDGET (dialog));
1145 if (dialog_response != GTK_RESPONSE_OK) {
1146 /* Don't let the dialog close */
1147 g_signal_stop_emission_by_name (wizard_dialog, "response");
1154 fill_providers (ModestEasysetupWizardDialog *self)
1156 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1158 if (MODEST_IS_COUNTRY_PICKER (priv->account_country_picker)) {
1159 /* gint mcc = get_default_country_code(); */
1161 /* Fill the combo in an idle call, as it takes a lot of time */
1162 modest_country_picker_load_data(
1163 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1164 /* connect to country picker's changed signal, so we can fill the provider picker: */
1165 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1166 (HILDON_PICKER_BUTTON (priv->account_country_picker))),
1168 G_CALLBACK (on_account_country_selector_changed), self);
1170 modest_country_picker_set_active_country_locale (
1171 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1172 mcc = modest_country_picker_get_active_country_mcc (
1173 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1174 modest_provider_picker_fill (
1175 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker),
1176 priv->presets, mcc);
1177 /* connect to providers picker's changed signal, so we can fill the email address: */
1178 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1179 (HILDON_PICKER_BUTTON (priv->account_serviceprovider_picker))),
1181 G_CALLBACK (on_account_serviceprovider_selector_changed), self);
1183 modest_provider_picker_set_others_provider (MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
1186 priv->dirty = FALSE;
1190 typedef struct IdleData {
1191 ModestEasysetupWizardDialog *dialog;
1192 ModestPresets *presets;
1196 presets_idle (gpointer userdata)
1198 IdleData *idle_data = (IdleData *) userdata;
1199 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (idle_data->dialog);
1200 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1202 g_assert (idle_data->presets);
1204 gdk_threads_enter ();
1206 priv->presets = idle_data->presets;
1208 if (priv->check_support_done)
1209 fill_providers (self);
1211 g_object_unref (idle_data->dialog);
1214 gdk_threads_leave ();
1220 presets_loader (gpointer userdata)
1222 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (userdata);
1223 ModestPresets *presets = NULL;
1224 IdleData *idle_data;
1226 const gchar* path = NULL;
1227 const gchar* path1 = MODEST_PROVIDER_DATA_FILE;
1228 const gchar* path2 = MODEST_MAEMO_PROVIDER_DATA_FILE;
1230 if (access(path1, R_OK) == 0)
1232 else if (access(path2, R_OK) == 0)
1235 g_warning ("%s: neither '%s' nor '%s' is a readable provider data file",
1236 __FUNCTION__, path1, path2);
1240 presets = modest_presets_new (path);
1242 g_warning ("%s: failed to parse '%s'", __FUNCTION__, path);
1246 idle_data = g_new0 (IdleData, 1);
1247 idle_data->dialog = self;
1248 idle_data->presets = presets;
1250 g_idle_add (presets_idle, idle_data);
1256 modest_easysetup_wizard_dialog_append_page (GtkNotebook *notebook,
1261 /* Append page and set attributes */
1262 index = gtk_notebook_append_page (notebook, page, gtk_label_new (label));
1263 gtk_container_child_set (GTK_CONTAINER (notebook), page,
1264 "tab-expand", TRUE, "tab-fill", TRUE,
1266 gtk_widget_show (page);
1270 init_user_page (ModestEasysetupWizardDialogPrivate *priv)
1272 priv->page_user_details = NULL;
1273 priv->entry_user_name = NULL;
1274 priv->entry_user_username = NULL;
1275 priv->entry_user_password = NULL;
1276 priv->entry_user_email = NULL;
1280 init_incoming_page (ModestEasysetupWizardDialogPrivate *priv)
1282 priv->page_custom_incoming = NULL;
1283 priv->incoming_servertype_picker = NULL;
1284 priv->caption_incoming = NULL;
1285 priv->entry_incomingserver = NULL;
1286 priv->entry_user_email = NULL;
1287 priv->incoming_security = NULL;
1291 init_outgoing_page (ModestEasysetupWizardDialogPrivate *priv)
1293 priv->page_custom_outgoing = NULL;
1294 priv->entry_outgoingserver = NULL;
1295 priv->checkbox_outgoing_smtp_specific = NULL;
1296 priv->button_outgoing_smtp_servers = NULL;
1297 priv->outgoing_security = NULL;
1301 modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
1303 gtk_container_set_border_width (GTK_CONTAINER (self), MODEST_MARGIN_HALF);
1305 /* Create the notebook to be used by the ModestWizardDialog base class:
1306 * Each page of the notebook will be a page of the wizard: */
1307 GtkNotebook *notebook = GTK_NOTEBOOK (gtk_notebook_new());
1308 gtk_widget_set_size_request (GTK_WIDGET (notebook), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
1310 /* Set the notebook used by the ModestWizardDialog base class: */
1311 g_object_set (G_OBJECT(self), "wizard-notebook", notebook, NULL);
1313 /* Set the wizard title:
1314 * The actual window title will be a combination of this and the page's tab label title. */
1315 g_object_set (G_OBJECT(self), "wizard-name", _("mcen_ti_emailsetup"), NULL);
1317 /* Read in the information about known service providers: */
1318 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1320 /* The server fields did not have been manually changed yet */
1321 priv->server_changes = 0;
1322 priv->pending_load_settings = TRUE;
1324 /* Get the account manager object,
1325 * so we can check for existing accounts,
1326 * and create new accounts: */
1327 priv->account_manager = modest_runtime_get_account_mgr ();
1328 g_object_ref (priv->account_manager);
1330 /* Initialize fields */
1331 priv->check_support_done = FALSE;
1332 priv->check_support_show_progress_id = 0;
1333 priv->check_support_progress_pulse_id = 0;
1334 priv->pending_check_support = 0;
1335 priv->destroyed = FALSE;
1336 priv->page_welcome = create_page_welcome (self);
1337 priv->page_account_details = create_page_account_details (self);
1339 init_user_page (priv);
1340 init_incoming_page (priv);
1341 init_outgoing_page (priv);
1343 priv->page_complete_easysetup = NULL;
1344 priv->page_complete_customsetup = NULL;
1345 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1346 priv->missing_data_signals = NULL;
1348 /* Add the common pages */
1349 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_welcome,
1350 _("mcen_ti_emailsetup_welcome"));
1351 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_account_details,
1352 _("mcen_ti_accountdetails"));
1354 /* Connect to the dialog's response signal so we can enable/disable buttons
1355 * for the newly-selected page, because the prev/next buttons cause response to be emitted.
1356 * Note that we use g_signal_connect_after() instead of g_signal_connect()
1357 * so that we can be enable/disable after ModestWizardDialog has done its own
1358 * enabling/disabling of buttons.
1360 * HOWEVER, this doesn't work because ModestWizardDialog's response signal handler
1361 * does g_signal_stop_emission_by_name(), stopping our signal handler from running.
1363 * It's not enough to connect to the notebook's switch-page signal, because
1364 * ModestWizardDialog's "response" signal handler enables the buttons itself,
1365 * _after_ switching the page (understandably).
1366 * (Note that if we had, if we used g_signal_connect() instead of g_signal_connect_after()
1367 * then gtk_notebook_get_current_page() would return an incorrect value.)
1369 g_signal_connect_after (G_OBJECT (self), "response",
1370 G_CALLBACK (on_response), self);
1372 /* This is to show a confirmation dialog when the user hits cancel */
1373 g_signal_connect (G_OBJECT (self), "response",
1374 G_CALLBACK (on_response_before), self);
1376 g_signal_connect (G_OBJECT (self), "delete-event",
1377 G_CALLBACK (on_delete_event), self);
1379 /* Reset dirty, because there was no user input until now */
1380 priv->dirty = FALSE;
1382 /* When this window is shown, hibernation should not be possible,
1383 * because there is no sensible way to save the state: */
1384 modest_window_mgr_prevent_hibernation_while_window_is_shown (
1385 modest_runtime_get_window_mgr (), GTK_WINDOW (self));
1387 /* Load provider presets */
1388 g_object_ref (self);
1389 g_thread_create (presets_loader, self, FALSE, NULL);
1391 priv->settings = modest_account_settings_new ();
1393 check_support_of_protocols (self);
1396 ModestEasysetupWizardDialog*
1397 modest_easysetup_wizard_dialog_new (void)
1400 return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
1404 create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
1406 ModestEasysetupWizardDialogPrivate *priv;
1407 GtkNotebook *notebook = NULL;
1409 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1412 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1414 if (!priv->page_user_details) {
1415 priv->page_user_details = create_page_user_details (self);
1418 /* Create the custom pages: */
1419 if(!(priv->page_custom_incoming)) {
1420 priv->page_custom_incoming = create_page_custom_incoming (self);
1423 /* TODO: only if needed */
1424 if(!(priv->page_custom_outgoing)) {
1425 priv->page_custom_outgoing = create_page_custom_outgoing (self);
1428 if(!(priv->page_complete_customsetup)) {
1429 priv->page_complete_customsetup = create_page_complete_custom (self);
1432 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_user_details)))
1433 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_user_details,
1434 _("mcen_ti_emailsetup_userdetails"));
1436 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_incoming)))
1437 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_incoming,
1438 _("mcen_ti_emailsetup_incomingdetails"));
1440 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_outgoing)))
1441 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_outgoing,
1442 _("mcen_ti_emailsetup_outgoingdetails"));
1444 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_customsetup)))
1445 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_customsetup,
1446 _("mcen_ti_emailsetup_complete"));
1448 /* This is unnecessary with GTK+ 2.10: */
1449 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1453 create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self)
1455 ModestEasysetupWizardDialogPrivate *priv;
1456 GtkNotebook *notebook = NULL;
1458 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1461 /* Create the easysetup-specific pages: */
1462 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1463 if(!priv->page_complete_easysetup)
1464 priv->page_complete_easysetup = create_page_complete_easysetup (self);
1466 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_easysetup)))
1467 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_easysetup,
1468 _("mcen_ti_emailsetup_complete"));
1470 /* This is unnecessary with GTK+ 2.10: */
1471 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1476 remove_non_common_tabs (GtkNotebook *notebook,
1477 gboolean remove_user_details)
1480 /* The first 2 tabs are the common ones (welcome tab and the
1481 providers tab), so we always remove starting from the
1484 starting_tab = (remove_user_details) ? 2 : 3;
1485 while (gtk_notebook_get_n_pages (notebook) > starting_tab)
1486 gtk_notebook_remove_page (notebook, -1);
1490 on_missing_mandatory_data (ModestAccountProtocol *protocol,
1494 real_enable_buttons (MODEST_WIZARD_DIALOG (user_data), !missing);
1497 /* After the user details page,
1498 * the following pages depend on whether "Other" was chosen
1499 * in the provider combobox on the account page
1502 create_subsequent_pages (ModestEasysetupWizardDialog *self)
1504 ModestEasysetupWizardDialogPrivate *priv;
1505 ModestProviderPicker *picker;
1506 ModestProviderPickerIdType id_type;
1507 GtkNotebook *notebook;
1509 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1510 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1511 id_type = modest_provider_picker_get_active_id_type (picker);
1512 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1513 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1517 if (id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
1518 /* "Other..." was selected: */
1520 /* If we come from a rollbacked easysetup */
1521 if (priv->page_complete_easysetup) {
1522 remove_non_common_tabs (notebook, FALSE);
1523 priv->page_complete_easysetup = NULL;
1526 /* If we come from a rollbacked plugin protocol setup */
1527 if (priv->last_plugin_protocol_selected != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1528 remove_non_common_tabs (notebook, TRUE);
1529 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1530 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1531 priv->missing_data_signals = NULL;
1534 create_subsequent_customsetup_pages (self);
1536 /* If we come from a rollbacked custom setup */
1537 if (priv->page_custom_incoming) {
1538 remove_non_common_tabs (notebook, TRUE);
1539 init_user_page (priv);
1540 init_incoming_page (priv);
1541 init_outgoing_page (priv);
1542 init_user_page (priv);
1543 priv->page_complete_customsetup = NULL;
1546 /* It's a pluggable protocol and not a provider with presets */
1547 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1548 ModestProtocol *protocol;
1550 ModestProtocolType proto_type;
1553 /* If we come from a rollbacked easy setup */
1554 if (priv->last_plugin_protocol_selected ==
1555 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID &&
1556 priv->page_complete_easysetup) {
1557 remove_non_common_tabs (notebook, TRUE);
1558 init_user_page (priv);
1559 priv->page_complete_easysetup = NULL;
1562 proto_name = modest_provider_picker_get_active_provider_id (picker);
1563 protocol = modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
1564 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
1566 proto_type = modest_protocol_get_type_id (protocol);
1568 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
1569 proto_type != priv->last_plugin_protocol_selected) {
1570 ModestPairList *tabs;
1572 gboolean first_page = TRUE;
1573 ModestWizardDialogResponseOverrideFunc response_override;
1575 /* Remember the last selected plugin protocol */
1576 priv->last_plugin_protocol_selected = proto_type;
1579 tabs = modest_account_protocol_get_easysetupwizard_tabs (MODEST_ACCOUNT_PROTOCOL (protocol));
1580 response_override = modest_account_protocol_get_wizard_response_override
1581 (MODEST_ACCOUNT_PROTOCOL (protocol));
1582 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1584 tmp = (GSList *) tabs;
1586 ModestPair *pair = (ModestPair *) tmp->data;
1587 modest_easysetup_wizard_dialog_append_page (notebook,
1588 GTK_WIDGET (pair->second),
1589 (const gchar *) pair->first);
1591 gtk_container_set_focus_child (GTK_CONTAINER (notebook),
1592 GTK_WIDGET (pair->second));
1596 /* Connect signals */
1597 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (pair->second)) {
1598 priv->missing_data_signals =
1599 modest_signal_mgr_connect (priv->missing_data_signals,
1600 G_OBJECT (pair->second),
1601 "missing-mandatory-data",
1602 G_CALLBACK (on_missing_mandatory_data),
1606 g_free (pair->first);
1607 tmp = g_slist_next (tmp);
1608 /* Critical: if you don't show the page then the dialog will ignore it */
1609 /* gtk_widget_show (GTK_WIDGET (pair->second)); */
1611 modest_pair_list_free (tabs);
1613 g_free (proto_name);
1615 if (priv->last_plugin_protocol_selected !=
1616 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1617 remove_non_common_tabs (notebook, TRUE);
1618 init_user_page (priv);
1619 priv->page_complete_easysetup = NULL;
1620 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1621 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1622 priv->missing_data_signals = NULL;
1624 if (!priv->page_user_details) {
1625 priv->page_user_details = create_page_user_details (self);
1626 modest_easysetup_wizard_dialog_append_page (notebook,
1627 priv->page_user_details,
1628 _("mcen_ti_emailsetup_userdetails"));
1632 /* Create the easysetup pages: */
1633 create_subsequent_easysetup_pages (self);
1639 util_get_default_servername_from_email_address (const gchar* email_address, ModestProtocolType protocol_type)
1641 const gchar* hostname = NULL;
1644 ModestProtocolRegistry *protocol_registry;
1645 ModestProtocol *protocol;
1650 at = g_utf8_strchr (email_address, -1, '@');
1651 if (!at || (g_utf8_strlen (at, -1) < 2))
1654 domain = g_utf8_next_char (at);
1658 protocol_registry = modest_runtime_get_protocol_registry ();
1659 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
1661 if (modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS) ||
1662 modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS)) {
1663 hostname = modest_protocol_get_name (protocol);
1669 return g_strdup_printf ("%s.%s", hostname, domain);
1673 set_default_custom_servernames (ModestEasysetupWizardDialog *self)
1675 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1677 if (!priv->entry_incomingserver)
1680 /* Set a default domain for the server, based on the email address,
1681 * if no server name was already specified.
1683 if (priv->entry_user_email
1684 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED) == 0)) {
1685 const ModestProtocolType protocol_type = modest_servertype_picker_get_active_servertype (
1686 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
1688 /* This could happen when the combo box has still no active iter */
1689 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1690 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1691 gchar* servername = util_get_default_servername_from_email_address (email_address,
1694 /* Do not set the INCOMING_CHANGED flag because of this edit */
1695 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1696 hildon_entry_set_text (HILDON_ENTRY (priv->entry_incomingserver), servername);
1697 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1699 g_free (servername);
1703 /* Set a default domain for the server, based on the email address,
1704 * if no server name was already specified.
1706 if (!priv->entry_outgoingserver)
1709 if (priv->entry_user_email
1710 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED) == 0)) {
1711 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1713 gchar* servername = util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOLS_TRANSPORT_SMTP);
1715 /* Do not set the OUTGOING_CHANGED flag because of this edit */
1716 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1717 hildon_entry_set_text (HILDON_ENTRY (priv->entry_outgoingserver), servername);
1718 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1720 g_free (servername);
1725 get_entered_account_title (ModestEasysetupWizardDialog *self)
1727 ModestEasysetupWizardDialogPrivate *priv;
1728 const gchar* account_title;
1730 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1731 account_title = hildon_entry_get_text (HILDON_ENTRY (priv->entry_account_title));
1733 if (!account_title || (g_utf8_strlen (account_title, -1) == 0)) {
1736 /* Strip it of whitespace at the start and end: */
1737 gchar *result = g_strdup (account_title);
1738 result = g_strstrip (result);
1743 if (g_utf8_strlen (result, -1) == 0) {
1753 on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *next_page)
1755 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1756 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1757 ModestProtocolRegistry *protocol_registry;
1759 protocol_registry = modest_runtime_get_protocol_registry ();
1761 /* if are browsing pages previous to the last one, then we have pending settings in
1763 if (next_page != NULL)
1764 priv->pending_load_settings = TRUE;
1766 /* Do extra validation that couldn't be done for every key press,
1767 * either because it was too slow,
1768 * or because it requires interaction:
1770 if (current_page == priv->page_account_details) {
1771 /* Check that the title is not already in use: */
1772 gchar* account_title = get_entered_account_title (self);
1776 /* Aavoid a clash with an existing display name: */
1777 const gboolean name_in_use = modest_account_mgr_account_with_display_name_exists (
1778 priv->account_manager, account_title);
1779 g_free (account_title);
1782 /* Warn the user via a dialog: */
1783 hildon_banner_show_information(NULL, NULL, _("mail_ib_account_name_already_existing"));
1788 /* Make sure that the subsequent pages are appropriate for the provider choice. */
1789 create_subsequent_pages (self);
1791 } else if (current_page == priv->page_user_details) {
1792 /* Check that the email address is valud: */
1793 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
1794 if ((!email_address) || (g_utf8_strlen (email_address, -1) == 0))
1797 if (!modest_text_utils_validate_email_address (email_address, NULL)) {
1798 /* Warn the user via a dialog: */
1799 hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email"));
1801 /* Return focus to the email address entry: */
1802 gtk_widget_grab_focus (priv->entry_user_email);
1803 gtk_editable_select_region (GTK_EDITABLE (priv->entry_user_email), 0, -1);
1809 if (next_page == priv->page_custom_incoming) {
1810 set_default_custom_servernames (self);
1811 } else if (next_page == priv->page_custom_outgoing) {
1812 set_default_custom_servernames (self);
1814 /* Check if the server supports secure authentication */
1815 if (modest_security_options_view_auth_check (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security)))
1816 if (!check_has_supported_auth_methods (self))
1818 gtk_widget_show (priv->outgoing_security);
1821 /* If this is the last page, and this is a click on Finish,
1822 * then attempt to create the dialog.
1825 current_page != priv->page_account_details) /* This is NULL when this is a click on Finish. */
1827 if (priv->pending_load_settings) {
1828 save_to_settings (self);
1831 /* We check if there's already another account with the same configuration */
1832 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
1833 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
1837 modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
1844 static gboolean entry_is_empty (GtkWidget *entry)
1849 const gchar* text = hildon_entry_get_text (HILDON_ENTRY (entry));
1850 if ((!text) || (g_utf8_strlen (text, -1) == 0))
1853 /* Strip it of whitespace at the start and end: */
1854 gchar *stripped = g_strdup (text);
1855 stripped = g_strstrip (stripped);
1860 const gboolean result = (g_utf8_strlen (stripped, -1) == 0);
1868 real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next)
1870 GtkNotebook *notebook = NULL;
1871 gboolean is_finish_tab;
1873 ModestEasysetupWizardDialogPrivate *priv;
1876 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (dialog);
1877 g_object_get (dialog, "wizard-notebook", ¬ebook, NULL);
1879 /* Disable the Finish button until we are on the last page,
1880 * because HildonWizardDialog enables this for all but the
1882 current = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
1883 is_finish_tab = ((current == priv->page_complete_easysetup) ||
1884 (current == priv->page_complete_customsetup));
1886 if (is_finish_tab) {
1887 /* Disable Next on the last page no matter what the
1889 enable_next = FALSE;
1891 /* Not the last one */
1892 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1893 MODEST_WIZARD_DIALOG_FINISH,
1896 /* If the check support is not done then do not enable
1897 the wizard to continue */
1898 enable_next = enable_next && priv->check_support_done;
1901 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1902 MODEST_WIZARD_DIALOG_NEXT,
1907 on_enable_buttons (ModestWizardDialog *dialog, GtkWidget *current_page)
1909 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1910 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1912 gboolean enable_next = TRUE;
1913 if (current_page == priv->page_welcome) {
1915 } else if (current_page == priv->page_account_details) {
1916 /* The account details title is mandatory: */
1917 if (entry_is_empty(priv->entry_account_title))
1918 enable_next = FALSE;
1919 } else if (current_page == priv->page_user_details) {
1920 /* The user details username is mandatory: */
1921 if (entry_is_empty(priv->entry_user_username))
1922 enable_next = FALSE;
1924 /* The user details email address is mandatory: */
1925 if (enable_next && entry_is_empty (priv->entry_user_email))
1926 enable_next = FALSE;
1927 } else if (current_page == priv->page_custom_incoming) {
1928 /* The custom incoming server is mandatory: */
1929 if (entry_is_empty(priv->entry_incomingserver))
1930 enable_next = FALSE;
1931 } else if (MODEST_IS_EASYSETUP_WIZARD_PAGE (current_page)) {
1932 enable_next = !modest_easysetup_wizard_page_validate (
1933 MODEST_EASYSETUP_WIZARD_PAGE (current_page));
1936 /* Enable/disable buttons */
1937 real_enable_buttons (dialog, enable_next);
1941 modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *klass)
1943 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1944 g_type_class_add_private (klass, sizeof (ModestEasysetupWizardDialogPrivate));
1947 object_class->dispose = modest_easysetup_wizard_dialog_dispose;
1948 object_class->finalize = modest_easysetup_wizard_dialog_finalize;
1950 /* Provide a vfunc implementation so we can decide
1951 * when to enable/disable the prev/next buttons.
1953 ModestWizardDialogClass *base_klass = (ModestWizardDialogClass*)(klass);
1954 base_klass->before_next = on_before_next;
1955 base_klass->enable_buttons = on_enable_buttons;
1956 base_klass->update_model = on_update_model;
1957 base_klass->save = on_save;
1962 * @self: a #ModestEasysetupWizardDialog
1964 * takes information from all the wizard and stores it in settings
1967 save_to_settings (ModestEasysetupWizardDialog *self)
1969 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1971 gchar *provider_id = NULL;
1972 gchar* display_name;
1973 const gchar *username, *password;
1974 gchar *store_hostname, *transport_hostname;
1975 guint store_port, transport_port;
1976 ModestProtocolRegistry *protocol_registry;
1977 ModestProtocolType store_protocol, transport_protocol;
1978 ModestProtocolType store_security, transport_security;
1979 ModestProtocolType store_auth_protocol, transport_auth_protocol;
1980 ModestServerAccountSettings *store_settings, *transport_settings;
1981 const gchar *fullname, *email_address;
1982 ModestProviderPicker *picker;
1983 ModestProviderPickerIdType id_type;
1985 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1986 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1987 protocol_registry = modest_runtime_get_protocol_registry ();
1989 /* Get details from the specified presets: */
1990 id_type = modest_provider_picker_get_active_id_type (picker);
1991 provider_id = modest_provider_picker_get_active_provider_id (picker);
1993 /* Let the plugin save the settings. We do a return in order
1994 to save an indentation level */
1995 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1996 ModestProtocol *protocol;
1998 protocol = modest_protocol_registry_get_protocol_by_name (
1999 modest_runtime_get_protocol_registry (),
2000 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
2003 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
2004 gint n_pages, i = 0;
2005 GtkNotebook *notebook;
2006 GList *wizard_pages = NULL;
2008 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
2009 n_pages = gtk_notebook_get_n_pages (notebook);
2010 for (i = 0; i < n_pages; i++) {
2011 GtkWidget *page = gtk_notebook_get_nth_page (notebook, i);
2012 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (page))
2013 wizard_pages = g_list_append (wizard_pages, page);
2015 modest_account_protocol_save_wizard_settings (MODEST_ACCOUNT_PROTOCOL (protocol),
2018 g_list_free (wizard_pages);
2020 g_warning ("The selected protocol is a plugin protocol "//
2021 "but it's not a ModestAccountProtocol");
2024 g_free (provider_id);
2028 /* username and password (for both incoming and outgoing): */
2029 username = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_username));
2030 password = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_password));
2032 store_settings = modest_account_settings_get_store_settings (priv->settings);
2033 transport_settings = modest_account_settings_get_transport_settings (priv->settings);
2035 /* Incoming server: */
2036 /* Note: We need something as default for the transport store protocol values,
2037 * or modest_account_mgr_add_server_account will fail. */
2039 store_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2040 store_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2041 store_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2044 ModestProtocolType store_provider_server_type;
2045 gboolean store_provider_use_alternate_port;
2047 store_hostname = modest_presets_get_server (priv->presets, provider_id,
2050 store_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2053 store_security = modest_presets_get_info_server_security (priv->presets,
2056 store_auth_protocol = modest_presets_get_info_server_auth (priv->presets,
2059 store_provider_use_alternate_port = modest_presets_get_info_server_use_alternate_port (priv->presets,
2063 /* We don't check for SMTP here as that is impossible for an incoming server. */
2064 if (store_provider_server_type == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID)
2065 store_protocol = MODEST_PROTOCOLS_STORE_POP;
2067 store_protocol = store_provider_server_type;
2069 /* we check if there is a *special* port */
2070 special_port = modest_presets_get_port (priv->presets, provider_id, TRUE /* incoming */);
2071 if (special_port != 0) {
2072 store_port = special_port;
2074 gboolean use_alternate_port = FALSE;
2075 if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (),
2077 use_alternate_port = TRUE;
2078 store_port = get_port_from_protocol(store_provider_server_type, use_alternate_port);
2081 modest_server_account_settings_set_security_protocol (store_settings,
2083 modest_server_account_settings_set_auth_protocol (store_settings,
2084 store_auth_protocol);
2085 if (store_port != 0)
2086 modest_server_account_settings_set_port (store_settings, store_port);
2088 /* Use custom pages because no preset was specified: */
2089 store_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_incomingserver) ));
2090 store_protocol = modest_servertype_picker_get_active_servertype (
2091 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2093 modest_security_options_view_save_settings (
2094 MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
2098 /* now we store the common store account settings */
2099 modest_server_account_settings_set_hostname (store_settings, store_hostname);
2100 modest_server_account_settings_set_username (store_settings, username);
2101 modest_server_account_settings_set_password (store_settings, password);
2102 modest_server_account_settings_set_protocol (store_settings, store_protocol);
2104 g_object_unref (store_settings);
2105 g_free (store_hostname);
2107 /* Outgoing server: */
2108 transport_hostname = NULL;
2109 transport_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2110 transport_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2111 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2115 ModestProtocolType transport_provider_server_type;
2116 ModestProtocolType transport_provider_security;
2119 transport_hostname = modest_presets_get_server (priv->presets, provider_id,
2120 FALSE /* transport */);
2122 transport_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2124 FALSE /* transport */);
2125 transport_provider_security = modest_presets_get_info_server_security (priv->presets,
2127 FALSE /* transport */);
2129 /* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
2130 transport_protocol = transport_provider_server_type;
2131 transport_security = transport_provider_security;
2132 if (transport_security == MODEST_PROTOCOLS_CONNECTION_SSL) {
2133 /* printf("DEBUG: %s: using secure SMTP\n", __FUNCTION__); */
2134 /* we check if there is a *special* port */
2135 special_port = modest_presets_get_port (priv->presets, provider_id,
2136 FALSE /* transport */);
2137 if (special_port != 0)
2138 transport_port = special_port;
2140 transport_port = 465;
2141 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_PASSWORD;
2143 /* printf("DEBUG: %s: using non-secure SMTP\n", __FUNCTION__); */
2144 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2147 modest_server_account_settings_set_security_protocol (transport_settings,
2148 transport_security);
2149 modest_server_account_settings_set_auth_protocol (transport_settings,
2150 transport_auth_protocol);
2151 if (transport_port != 0)
2152 modest_server_account_settings_set_port (transport_settings,
2155 ModestProtocolRegistry *registry;
2156 ModestProtocol *store_proto;
2158 registry = modest_runtime_get_protocol_registry ();
2159 /* Use custom pages because no preset was specified: */
2160 transport_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver) ));
2162 store_proto = modest_protocol_registry_get_protocol_by_type (registry,
2165 if (transport_protocol == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
2166 /* fallback to SMTP if none was specified */
2167 g_warning ("No transport protocol was specified for store %d (%s)",
2168 modest_protocol_get_type_id (store_proto),
2169 modest_protocol_get_display_name (store_proto));
2170 transport_protocol = MODEST_PROTOCOLS_TRANSPORT_SMTP;
2173 modest_security_options_view_save_settings (
2174 MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security),
2178 /* now we store the common transport account settings */
2179 modest_server_account_settings_set_hostname (transport_settings, transport_hostname);
2180 modest_server_account_settings_set_username (transport_settings, username);
2181 modest_server_account_settings_set_password (transport_settings, password);
2182 modest_server_account_settings_set_protocol (transport_settings, transport_protocol);
2184 g_object_unref (transport_settings);
2185 g_free (transport_hostname);
2187 fullname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_name));
2188 email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
2189 modest_account_settings_set_fullname (priv->settings, fullname);
2190 modest_account_settings_set_email_address (priv->settings, email_address);
2191 /* we don't set retrieve type to preserve advanced settings if
2192 any. By default account settings are set to headers only */
2194 /* Save the connection-specific SMTP server accounts. */
2195 if (priv->checkbox_outgoing_smtp_specific) {
2196 modest_account_settings_set_use_connection_specific_smtp
2198 hildon_check_button_get_active(HILDON_CHECK_BUTTON(priv->checkbox_outgoing_smtp_specific)));
2201 display_name = get_entered_account_title (self);
2202 modest_account_settings_set_display_name (priv->settings, display_name);
2203 g_free (display_name);
2204 g_free (provider_id);
2209 on_update_model (ModestWizardDialog *dialog)
2211 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2212 save_to_settings (self);
2217 on_save (ModestWizardDialog *dialog)
2219 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2220 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2222 save_to_settings (self);
2224 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
2225 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
2229 return modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
2235 check_for_supported_auth_methods (ModestEasysetupWizardDialog* self)
2237 GError *error = NULL;
2238 ModestProtocolType protocol_type;
2239 const gchar* hostname;
2240 const gchar* username;
2241 ModestProtocolType security_protocol_incoming_type;
2242 ModestProtocolRegistry *registry;
2244 GList *list_auth_methods;
2245 ModestEasysetupWizardDialogPrivate *priv;
2247 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2248 registry = modest_runtime_get_protocol_registry ();
2249 protocol_type = modest_servertype_picker_get_active_servertype (
2250 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2251 hostname = gtk_entry_get_text(GTK_ENTRY(priv->entry_incomingserver));
2252 username = gtk_entry_get_text(GTK_ENTRY(priv->entry_user_username));
2253 security_protocol_incoming_type = modest_security_options_view_get_connection_protocol
2254 (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security));
2255 port_num = get_port_from_protocol(protocol_type, FALSE);
2256 list_auth_methods = modest_utils_get_supported_secure_authentication_methods (protocol_type, hostname, port_num,
2257 username, GTK_WINDOW (self), &error);
2259 if (list_auth_methods) {
2260 /* TODO: Select the correct method */
2263 for (method = list_auth_methods; method != NULL; method = g_list_next(method)) {
2264 ModestProtocolType auth_protocol_type = (ModestProtocolType) (GPOINTER_TO_INT(method->data));
2265 if (modest_protocol_registry_protocol_type_has_tag (registry, auth_protocol_type,
2266 MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS)) {
2267 list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type));
2271 g_list_free(list_auth_methods);
2277 if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
2278 error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
2280 modest_platform_information_banner (GTK_WIDGET(self), NULL,
2281 _("mcen_ib_unableto_discover_auth_methods"));
2285 g_error_free(error);
2291 check_has_supported_auth_methods(ModestEasysetupWizardDialog* self)
2293 GList* methods = check_for_supported_auth_methods(self);
2299 g_list_free(methods);
2304 check_support_progress_pulse (gpointer userdata)
2306 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2307 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2309 if (priv->destroyed) {
2310 priv->check_support_progress_pulse_id = 0;
2314 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2320 check_support_show_progress (gpointer userdata)
2322 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2323 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2325 priv->check_support_show_progress_id = 0;
2327 if (priv->destroyed)
2330 gtk_widget_show (priv->check_support_progress);
2331 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2333 priv->check_support_progress_pulse_id = g_timeout_add (200, check_support_progress_pulse, self);
2339 check_support_callback (ModestAccountProtocol *protocol,
2343 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2344 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2346 priv->pending_check_support --;
2348 if (priv->check_support_show_progress_id > 0) {
2349 g_source_remove (priv->check_support_show_progress_id);
2350 priv->check_support_show_progress_id = 0;
2353 if (priv->check_support_progress_pulse_id > 0) {
2354 g_source_remove (priv->check_support_progress_pulse_id);
2355 priv->check_support_progress_pulse_id = 0;
2358 if (priv->pending_check_support == 0) {
2359 priv->check_support_done = TRUE;
2361 if (!priv->destroyed) {
2363 fill_providers (self);
2364 gtk_widget_hide (priv->check_support_progress);
2365 invoke_enable_buttons_vfunc (self);
2368 g_object_unref (self);
2373 check_support_of_protocols (ModestEasysetupWizardDialog *self)
2375 ModestProtocolRegistry *registry;
2376 GSList *provider_protos, *node;
2377 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2379 registry = modest_runtime_get_protocol_registry ();
2380 provider_protos = modest_protocol_registry_get_by_tag (registry,
2381 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS);
2383 for (node = provider_protos; node != NULL; node = g_slist_next (node)) {
2384 ModestProtocol *proto = MODEST_PROTOCOL (node->data);
2386 if (!modest_protocol_registry_protocol_type_has_tag (registry,
2387 modest_protocol_get_type_id (proto),
2388 MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS))
2391 if (modest_protocol_registry_protocol_type_has_tag
2393 modest_protocol_get_type_id (proto),
2394 MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS)) {
2395 /* Check if there's already an account configured with this account type */
2396 if (modest_account_mgr_singleton_protocol_exists (modest_runtime_get_account_mgr (),
2397 modest_protocol_get_type_id (proto)))
2401 if (MODEST_ACCOUNT_PROTOCOL (proto)) {
2402 priv->pending_check_support ++;
2403 modest_account_protocol_check_support (MODEST_ACCOUNT_PROTOCOL (proto),
2404 check_support_callback,
2405 g_object_ref (self));
2408 g_slist_free (provider_protos);
2410 if (priv->pending_check_support > 0) {
2411 priv->check_support_show_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 1000,
2412 check_support_show_progress,
2413 g_object_ref (self), g_object_unref);
2415 priv->check_support_done = TRUE;
2417 invoke_enable_buttons_vfunc (self);