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)
380 ModestEasysetupWizardDialogPrivate *priv;
382 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
383 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
384 label = gtk_label_new(_("mcen_ia_emailsetup_intro"));
385 priv->check_support_progress = gtk_progress_bar_new ();
386 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
387 /* So that it is not truncated: */
388 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
389 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
390 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
391 gtk_box_pack_end (GTK_BOX (box), priv->check_support_progress, FALSE, FALSE, 0);
392 gtk_widget_show (label);
393 gtk_widget_show (GTK_WIDGET (box));
394 return GTK_WIDGET (box);
398 on_account_country_selector_changed (HildonTouchSelector *widget, gint column, gpointer user_data)
400 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
402 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
406 /* Fill the providers picker, based on the selected country: */
407 if (priv->presets != NULL) {
408 gint mcc = modest_country_picker_get_active_country_mcc (
409 MODEST_COUNTRY_PICKER (priv->account_country_picker));
410 modest_provider_picker_fill (
411 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker), priv->presets, mcc);
416 update_user_email_from_provider (ModestEasysetupWizardDialog *self)
418 ModestEasysetupWizardDialogPrivate *priv;
419 gchar* provider_id = NULL, *with_at = NULL;
422 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
424 /* Fill the providers combo, based on the selected country: */
425 provider_id = modest_provider_picker_get_active_provider_id (
426 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
429 gchar *domain_name = modest_presets_get_domain (priv->presets, provider_id);
430 with_at = g_strdup_printf ("%c%s", '@', domain_name);
431 g_free (domain_name);
434 /* The sample address already contains the '@' */
436 with_at = g_strdup (MODEST_EXAMPLE_EMAIL_ADDRESS);
438 if (priv->entry_user_email)
439 hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_email), with_at);
442 g_free (provider_id);
446 on_account_serviceprovider_selector_changed (HildonTouchSelector *widget, gint column, gpointer user_data)
448 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
450 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
454 update_user_email_from_provider (self);
458 on_entry_max (ModestValidatingEntry *self, gpointer user_data)
460 modest_platform_information_banner (GTK_WIDGET (self), NULL,
461 _CS("ckdg_ib_maximum_characters_reached"));
465 create_page_account_details (ModestEasysetupWizardDialog *self)
468 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
469 GtkWidget *label = gtk_label_new(_("mcen_ia_accountdetails"));
470 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
472 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
473 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
474 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
475 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
476 gtk_widget_show (label);
478 /* Create a size group to be used by all captions.
479 * Note that HildonCaption does not create a default size group if we do not specify one.
480 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
481 GtkSizeGroup* title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
482 GtkSizeGroup* value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
484 /* The country widgets: */
485 priv->account_country_picker = GTK_WIDGET (modest_country_picker_new (MODEST_EDITABLE_SIZE,
486 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
487 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
488 _("mcen_fi_country"), priv->account_country_picker);
489 g_signal_connect (G_OBJECT (priv->account_country_picker), "value-changed",
490 G_CALLBACK (on_picker_button_value_changed), self);
491 gtk_box_pack_start (GTK_BOX (box), priv->account_country_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
492 gtk_widget_show (priv->account_country_picker);
494 /* The service provider widgets: */
495 priv->account_serviceprovider_picker = GTK_WIDGET (modest_provider_picker_new (MODEST_EDITABLE_SIZE,
496 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
497 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
498 _("mcen_fi_serviceprovider"),
499 priv->account_serviceprovider_picker);
500 g_signal_connect (G_OBJECT (priv->account_serviceprovider_picker), "value-changed",
501 G_CALLBACK (on_serviceprovider_picker_button_value_changed), self);
502 gtk_box_pack_start (GTK_BOX (box), priv->account_serviceprovider_picker, FALSE, FALSE, 0);
503 gtk_widget_show (priv->account_serviceprovider_picker);
505 /* The description widgets: */
506 priv->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
507 g_signal_connect(G_OBJECT(priv->entry_account_title), "changed",
508 G_CALLBACK(on_easysetup_changed), self);
509 /* Do use auto-capitalization: */
510 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_account_title),
511 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
513 /* Set a default account title, choosing one that does not already exist: */
514 /* Note that this is irrelevant to the non-user visible name, which we will create later. */
515 gchar* default_account_name_start = g_strdup (_("mcen_ia_emailsetup_defaultname"));
516 gchar* default_account_name = modest_account_mgr_get_unused_account_display_name (
517 priv->account_manager, default_account_name_start);
518 g_free (default_account_name_start);
519 default_account_name_start = NULL;
521 hildon_entry_set_text (HILDON_ENTRY (priv->entry_account_title), default_account_name);
522 g_free (default_account_name);
523 default_account_name = NULL;
525 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mcen_fi_account_title"), FALSE,
526 priv->entry_account_title);
527 gtk_widget_show (priv->entry_account_title);
528 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
529 gtk_widget_show (caption);
531 /* Prevent the use of some characters in the account title,
532 * as required by our UI specification: */
533 GList *list_prevent = NULL;
534 list_prevent = g_list_append (list_prevent, "\\");
535 list_prevent = g_list_append (list_prevent, "/");
536 list_prevent = g_list_append (list_prevent, ":");
537 list_prevent = g_list_append (list_prevent, "*");
538 list_prevent = g_list_append (list_prevent, "?");
539 list_prevent = g_list_append (list_prevent, "\""); /* The UI spec mentions “, but maybe means ", maybe both. */
540 list_prevent = g_list_append (list_prevent, "“");
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 modest_validating_entry_set_unallowed_characters (
546 MODEST_VALIDATING_ENTRY (priv->entry_account_title), list_prevent);
547 g_list_free (list_prevent);
549 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
550 modest_utils_on_entry_invalid_character, self);
552 /* Set max length as in the UI spec:
553 * The UI spec seems to want us to show a dialog if we hit the maximum. */
554 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_account_title), 64);
555 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_account_title),
558 gtk_widget_show (GTK_WIDGET (box));
560 g_object_unref (title_sizegroup);
561 g_object_unref (value_sizegroup);
563 return GTK_WIDGET (box);
567 create_page_user_details (ModestEasysetupWizardDialog *self)
569 GtkSizeGroup* title_sizegroup;
570 GtkSizeGroup* value_sizegroup;
572 ModestEasysetupWizardDialogPrivate *priv;
574 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
576 /* Create a size group to be used by all captions.
577 * Note that HildonCaption does not create a default size group if we do not specify one.
578 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
579 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
580 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
581 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
583 /* The name widgets: (use auto cap) */
584 priv->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
585 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_name),
586 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
588 /* Set max length as in the UI spec:
589 * The UI spec seems to want us to show a dialog if we hit the maximum. */
590 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_name), 64);
591 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_name),
593 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
594 _("mcen_li_emailsetup_name"), FALSE, priv->entry_user_name);
595 g_signal_connect(G_OBJECT(priv->entry_user_name), "changed",
596 G_CALLBACK(on_easysetup_changed), self);
597 gtk_widget_show (priv->entry_user_name);
598 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
599 gtk_widget_show (caption);
601 /* Prevent the use of some characters in the name,
602 * as required by our UI specification: */
603 GList *list_prevent = NULL;
604 list_prevent = g_list_append (list_prevent, "<");
605 list_prevent = g_list_append (list_prevent, ">");
606 modest_validating_entry_set_unallowed_characters (
607 MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
608 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
609 modest_utils_on_entry_invalid_character, self);
610 g_list_free (list_prevent);
612 /* The username widgets: */
613 priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
614 /* Auto-capitalization is the default, so let's turn it off: */
615 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username),
616 HILDON_GTK_INPUT_MODE_FULL);
617 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mail_fi_username"), FALSE,
618 priv->entry_user_username);
619 gtk_widget_show (priv->entry_user_username);
620 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
621 g_signal_connect(G_OBJECT(priv->entry_user_username), "changed",
622 G_CALLBACK(on_easysetup_changed), self);
623 gtk_widget_show (caption);
625 /* Prevent the use of some characters in the username,
626 * as required by our UI specification: */
627 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_username),
628 modest_utils_on_entry_invalid_character, self);
630 /* Set max length as in the UI spec:
631 * The UI spec seems to want us to show a dialog if we hit the maximum. */
632 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
633 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_username),
636 /* The password widgets: */
637 priv->entry_user_password = hildon_entry_new (MODEST_EDITABLE_SIZE);
638 /* Auto-capitalization is the default, so let's turn it off: */
639 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password),
640 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
641 gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
642 /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
643 caption = create_captioned (self, title_sizegroup, value_sizegroup,
644 _("mail_fi_password"), FALSE, priv->entry_user_password);
645 g_signal_connect(G_OBJECT(priv->entry_user_password), "changed",
646 G_CALLBACK(on_easysetup_changed), self);
647 gtk_widget_show (priv->entry_user_password);
648 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
649 gtk_widget_show (caption);
651 /* The email address widgets: */
652 priv->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
653 /* Auto-capitalization is the default, so let's turn it off: */
654 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
655 caption = create_captioned (self, title_sizegroup, value_sizegroup,
656 _("mcen_li_emailsetup_email_address"), FALSE, priv->entry_user_email);
657 update_user_email_from_provider (self);
658 gtk_widget_show (priv->entry_user_email);
659 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
660 g_signal_connect(G_OBJECT(priv->entry_user_email), "changed",
661 G_CALLBACK(on_easysetup_changed), self);
662 gtk_widget_show (caption);
664 /* Set max length as in the UI spec:
665 * The UI spec seems to want us to show a dialog if we hit the maximum. */
666 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_email), 64);
667 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_email),
671 gtk_widget_show (GTK_WIDGET (box));
672 g_object_unref (title_sizegroup);
673 g_object_unref (value_sizegroup);
675 return GTK_WIDGET (box);
679 create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
681 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
683 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
684 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
685 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
686 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
688 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
689 gtk_widget_show (label);
691 label = gtk_label_new (_("mcen_ia_easysetup_complete"));
692 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
693 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
695 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
696 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
697 gtk_widget_show (label);
699 gtk_widget_show (GTK_WIDGET (box));
700 return GTK_WIDGET (box);
703 /** Change the caption title for the incoming server,
704 * as specified in the UI spec:
707 update_incoming_server_title (ModestEasysetupWizardDialog *self)
709 ModestEasysetupWizardDialogPrivate* priv;
710 ModestProtocolType protocol_type;
711 ModestProtocolRegistry *protocol_registry;
713 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
714 protocol_registry = modest_runtime_get_protocol_registry ();
716 protocol_type = modest_servertype_picker_get_active_servertype (
717 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
719 /* This could happen when the combo box has still no active iter */
720 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
721 gchar* incomingserver_title;
722 const gchar *protocol_display_name;
723 ModestProtocol *protocol;
725 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry,
727 protocol_display_name = modest_protocol_get_display_name (protocol);
729 incomingserver_title = g_strconcat (_("mcen_li_emailsetup_servertype"), "\n<small>(",
730 protocol_display_name, ")</small>", NULL);
732 modest_maemo_utils_captioned_set_label (priv->caption_incoming, incomingserver_title, TRUE);
734 g_free(incomingserver_title);
738 /** Change the caption title for the incoming server,
739 * as specified in the UI spec:
742 update_incoming_server_security_choices (ModestEasysetupWizardDialog *self)
744 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
745 ModestServertypePicker *server_type_picker;
746 ModestProtocolType protocol_type;
747 ModestSecurityOptionsView *view;
750 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
752 modest_servertype_picker_get_active_servertype (server_type_picker);
754 /* Fill the combo with appropriately titled choices for all
756 view = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
757 modest_security_options_view_set_server_type (view, protocol_type);
761 on_servertype_selector_changed(HildonTouchSelector *selector, gint column, gpointer user_data)
763 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
764 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
765 ModestServertypePicker *picker;
766 ModestProtocolType protocol_type;
771 update_incoming_server_title (self);
773 /* Update security options if needed */
774 picker = MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
775 protocol_type = modest_servertype_picker_get_active_servertype (picker);
776 update_incoming_server_security_choices (self);
777 gtk_widget_show (priv->incoming_security);
779 set_default_custom_servernames (self);
783 on_entry_incoming_servername_changed(GtkEntry *entry, gpointer user_data)
785 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
786 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
788 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED;
792 create_page_custom_incoming (ModestEasysetupWizardDialog *self)
794 ModestProtocolRegistry *protocol_registry;
795 ModestEasysetupWizardDialogPrivate* priv;
799 GtkSizeGroup *title_sizegroup;
800 GtkSizeGroup *value_sizegroup;
802 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
803 protocol_registry = modest_runtime_get_protocol_registry ();
805 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
806 pannable = hildon_pannable_area_new ();
808 /* Show note that account type cannot be changed in future: */
809 label = gtk_label_new (_("mcen_ia_emailsetup_account_type"));
810 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
811 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
812 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
813 gtk_widget_show (label);
815 /* Create a size group to be used by all captions.
816 * Note that HildonCaption does not create a default size group if we do not specify one.
817 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
818 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
819 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
821 /* The incoming server widgets: */
822 priv->incoming_servertype_picker = GTK_WIDGET (modest_servertype_picker_new (MODEST_EDITABLE_SIZE,
823 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
825 hildon_button_set_title (HILDON_BUTTON (priv->incoming_servertype_picker), _("mcen_li_emailsetup_type"));
826 g_signal_connect (G_OBJECT (priv->incoming_servertype_picker), "value-changed",
827 G_CALLBACK (on_picker_button_value_changed), self);
828 gtk_box_pack_start (GTK_BOX (box), priv->incoming_servertype_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
829 gtk_widget_show (priv->incoming_servertype_picker);
831 priv->entry_incomingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
832 g_signal_connect(G_OBJECT(priv->entry_incomingserver), "changed", G_CALLBACK(on_easysetup_changed), self);
833 /* Auto-capitalization is the default, so let's turn it off: */
834 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
835 set_default_custom_servernames (self);
837 /* The caption title will be updated in update_incoming_server_title().
838 * so this default text will never be seen: */
839 priv->caption_incoming = create_captioned (self, title_sizegroup, value_sizegroup,
840 "This will be removed",
841 FALSE, priv->entry_incomingserver);
842 update_incoming_server_title (self);
843 gtk_widget_show (priv->entry_incomingserver);
844 gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
845 gtk_widget_show (priv->caption_incoming);
847 /* Change the caption title when the servertype changes,
848 * as in the UI spec: */
849 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (priv->incoming_servertype_picker))),
851 G_CALLBACK (on_servertype_selector_changed), self);
853 /* Remember when the servername was changed manually: */
854 g_signal_connect (G_OBJECT (priv->entry_incomingserver), "changed",
855 G_CALLBACK (on_entry_incoming_servername_changed), self);
857 /* The secure connection widgets. These are only valid for
858 protocols with security */
859 priv->incoming_security =
860 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
861 FALSE, title_sizegroup, value_sizegroup);
862 gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
863 FALSE, FALSE, MODEST_MARGIN_HALF);
864 gtk_widget_show_all (priv->incoming_security);
866 /* Set default selection */
867 modest_servertype_picker_set_active_servertype (
868 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker),
869 MODEST_PROTOCOLS_STORE_POP);
871 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), box);
872 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
873 hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pannable)));
874 gtk_widget_show (GTK_WIDGET (box));
875 gtk_widget_show (pannable);
877 g_object_unref (title_sizegroup);
878 g_object_unref (value_sizegroup);
880 return GTK_WIDGET (pannable);
884 on_check_button_changed (HildonCheckButton *button, gpointer user_data)
886 GtkWidget *widget = GTK_WIDGET (user_data);
888 /* Enable the widget only if the check button is active: */
889 const gboolean enable = hildon_check_button_get_active (button);
890 gtk_widget_set_sensitive (widget, enable);
893 /* Make the sensitivity of a widget depend on a check button.
896 enable_widget_for_checkbutton (GtkWidget *widget, HildonCheckButton* button)
898 g_signal_connect (G_OBJECT (button), "toggled",
899 G_CALLBACK (on_check_button_changed), widget);
901 /* Set the starting sensitivity: */
902 on_check_button_changed (button, widget);
906 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
908 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
909 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
910 GtkWidget *specific_window;
912 /* We set dirty here because setting it depending on the connection specific dialog
916 /* Create the window, if necessary: */
917 specific_window = (GtkWidget *) modest_connection_specific_smtp_window_new ();
918 modest_connection_specific_smtp_window_fill_with_connections (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window), priv->account_manager);
920 /* Show the window */
921 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (specific_window), GTK_WINDOW (self));
922 gtk_widget_show (specific_window);
926 on_entry_outgoing_servername_changed (GtkEntry *entry, gpointer user_data)
928 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
929 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
930 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED;
934 create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
936 ModestEasysetupWizardDialogPrivate *priv;
937 gchar *smtp_caption_label;
939 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
941 pannable = hildon_pannable_area_new ();
943 /* Create a size group to be used by all captions.
944 * Note that HildonCaption does not create a default size group if we do not specify one.
945 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
946 GtkSizeGroup *title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
947 GtkSizeGroup *value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
949 /* The outgoing server widgets: */
950 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
951 priv->entry_outgoingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
952 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
953 G_CALLBACK (on_easysetup_changed), self);
954 /* Auto-capitalization is the default, so let's turn it off: */
955 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
956 smtp_caption_label = g_strconcat (_("mcen_li_emailsetup_smtp"), "\n<small>(SMTP)</small>", NULL);
957 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
958 smtp_caption_label, TRUE, priv->entry_outgoingserver);
959 g_free (smtp_caption_label);
960 gtk_widget_show (priv->entry_outgoingserver);
961 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
962 gtk_widget_show (caption);
963 set_default_custom_servernames (self);
965 /* The secure connection widgets. These are only valid for
966 protocols with security */
967 priv->outgoing_security =
968 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
969 FALSE, title_sizegroup, value_sizegroup);
970 gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security,
971 FALSE, FALSE, MODEST_MARGIN_HALF);
972 gtk_widget_show (priv->outgoing_security);
974 GtkWidget *separator = gtk_hseparator_new ();
975 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
976 gtk_widget_show (separator);
978 /* connection-specific checkbox: */
979 priv->checkbox_outgoing_smtp_specific = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
980 hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific),
982 gtk_button_set_label (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
983 _("mcen_fi_advsetup_connection_smtp"));
984 gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
986 g_signal_connect (G_OBJECT (priv->checkbox_outgoing_smtp_specific), "toggled",
987 G_CALLBACK (on_easysetup_changed), self);
989 gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
990 gtk_box_pack_start (GTK_BOX (box), priv->checkbox_outgoing_smtp_specific,
991 FALSE, FALSE, MODEST_MARGIN_HALF);
993 /* Connection-specific SMTP-Severs Edit button: */
994 priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_advsetup_optional_smtp"));
995 hildon_gtk_widget_set_theme_size (priv->button_outgoing_smtp_servers,
996 HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
997 gtk_widget_show (priv->button_outgoing_smtp_servers);
998 gtk_box_pack_start (GTK_BOX (box), priv->button_outgoing_smtp_servers,
999 FALSE, FALSE, MODEST_MARGIN_HALF);
1001 /* Only enable the button when the checkbox is checked: */
1002 enable_widget_for_checkbutton (priv->button_outgoing_smtp_servers,
1003 HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific));
1005 g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
1006 G_CALLBACK (on_button_outgoing_smtp_servers), self);
1008 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
1009 G_CALLBACK (on_entry_outgoing_servername_changed), self);
1012 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), box);
1013 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
1014 hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pannable)));
1015 gtk_widget_show (GTK_WIDGET (box));
1016 gtk_widget_show (pannable);
1018 g_object_unref (title_sizegroup);
1019 g_object_unref (value_sizegroup);
1021 return GTK_WIDGET (pannable);
1025 show_advanced_edit(gpointer user_data)
1027 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1028 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1031 /* Show the Account Settings window: */
1032 ModestAccountSettingsDialog *dialog = modest_default_account_settings_dialog_new ();
1033 if (priv->pending_load_settings) {
1034 save_to_settings (self);
1035 priv->pending_load_settings = FALSE;
1037 modest_account_settings_dialog_load_settings (dialog, priv->settings);
1039 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), GTK_WINDOW (self));
1041 response = gtk_dialog_run (GTK_DIALOG (dialog));
1043 gtk_widget_destroy (GTK_WIDGET (dialog));
1045 return FALSE; /* Do not call this timeout callback again. */
1049 on_button_edit_advanced_settings (GtkButton *button, gpointer user_data)
1051 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1053 /* Show the Account Settings window: */
1054 show_advanced_edit(self);
1057 create_page_complete_custom (ModestEasysetupWizardDialog *self)
1059 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
1060 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
1061 GtkWidget *button_edit = gtk_button_new_with_label (_("mcen_fi_advanced_settings"));
1062 hildon_gtk_widget_set_theme_size (button_edit, HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1063 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1064 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1065 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1066 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
1067 gtk_widget_show (label);
1069 label = gtk_label_new (_("mcen_ia_customsetup_complete"));
1070 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
1071 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1072 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1073 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
1074 gtk_widget_show (label);
1076 gtk_widget_show (button_edit);
1077 gtk_box_pack_start (GTK_BOX (box), button_edit, FALSE, FALSE, MODEST_MARGIN_HALF);
1079 g_signal_connect (G_OBJECT (button_edit), "clicked",
1080 G_CALLBACK (on_button_edit_advanced_settings), self);
1082 gtk_widget_show (GTK_WIDGET (box));
1083 return GTK_WIDGET (box);
1090 on_response (ModestWizardDialog *wizard_dialog,
1094 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1096 invoke_enable_buttons_vfunc (self);
1100 on_response_before (ModestWizardDialog *wizard_dialog,
1104 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1105 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(wizard_dialog);
1106 if (response_id == GTK_RESPONSE_CANCEL) {
1107 /* This is mostly copied from
1108 * src/maemo/modest-account-settings-dialog.c */
1110 GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
1111 _("imum_nc_wizard_confirm_lose_changes")));
1112 /* TODO: These button names will be ambiguous, and not
1113 * specified in the UI specification. */
1115 const gint dialog_response = gtk_dialog_run (dialog);
1116 gtk_widget_destroy (GTK_WIDGET (dialog));
1118 if (dialog_response != GTK_RESPONSE_OK) {
1119 /* Don't let the dialog close */
1120 g_signal_stop_emission_by_name (wizard_dialog, "response");
1127 fill_providers (ModestEasysetupWizardDialog *self)
1129 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1131 if (MODEST_IS_COUNTRY_PICKER (priv->account_country_picker)) {
1132 /* gint mcc = get_default_country_code(); */
1134 /* Fill the combo in an idle call, as it takes a lot of time */
1135 modest_country_picker_load_data(
1136 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1137 /* connect to country picker's changed signal, so we can fill the provider picker: */
1138 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1139 (HILDON_PICKER_BUTTON (priv->account_country_picker))),
1141 G_CALLBACK (on_account_country_selector_changed), self);
1143 modest_country_picker_set_active_country_locale (
1144 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1145 mcc = modest_country_picker_get_active_country_mcc (
1146 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1147 modest_provider_picker_fill (
1148 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker),
1149 priv->presets, mcc);
1150 /* connect to providers picker's changed signal, so we can fill the email address: */
1151 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1152 (HILDON_PICKER_BUTTON (priv->account_serviceprovider_picker))),
1154 G_CALLBACK (on_account_serviceprovider_selector_changed), self);
1156 modest_provider_picker_set_others_provider (MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
1159 priv->dirty = FALSE;
1163 typedef struct IdleData {
1164 ModestEasysetupWizardDialog *dialog;
1165 ModestPresets *presets;
1169 presets_idle (gpointer userdata)
1171 IdleData *idle_data = (IdleData *) userdata;
1172 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (idle_data->dialog);
1173 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1175 g_assert (idle_data->presets);
1177 gdk_threads_enter ();
1179 priv->presets = idle_data->presets;
1181 if (priv->check_support_done)
1182 fill_providers (self);
1184 g_object_unref (idle_data->dialog);
1187 gdk_threads_leave ();
1193 presets_loader (gpointer userdata)
1195 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (userdata);
1196 ModestPresets *presets = NULL;
1197 IdleData *idle_data;
1199 const gchar* path = NULL;
1200 const gchar* path1 = MODEST_PROVIDER_DATA_FILE;
1201 const gchar* path2 = MODEST_MAEMO_PROVIDER_DATA_FILE;
1203 if (access(path1, R_OK) == 0)
1205 else if (access(path2, R_OK) == 0)
1208 g_warning ("%s: neither '%s' nor '%s' is a readable provider data file",
1209 __FUNCTION__, path1, path2);
1213 presets = modest_presets_new (path);
1215 g_warning ("%s: failed to parse '%s'", __FUNCTION__, path);
1219 idle_data = g_new0 (IdleData, 1);
1220 idle_data->dialog = self;
1221 idle_data->presets = presets;
1223 g_idle_add (presets_idle, idle_data);
1229 modest_easysetup_wizard_dialog_append_page (GtkNotebook *notebook,
1234 /* Append page and set attributes */
1235 index = gtk_notebook_append_page (notebook, page, gtk_label_new (label));
1236 gtk_container_child_set (GTK_CONTAINER (notebook), page,
1237 "tab-expand", TRUE, "tab-fill", TRUE,
1239 gtk_widget_show (page);
1243 init_user_page (ModestEasysetupWizardDialogPrivate *priv)
1245 priv->page_user_details = NULL;
1246 priv->entry_user_name = NULL;
1247 priv->entry_user_username = NULL;
1248 priv->entry_user_password = NULL;
1249 priv->entry_user_email = NULL;
1253 init_incoming_page (ModestEasysetupWizardDialogPrivate *priv)
1255 priv->page_custom_incoming = NULL;
1256 priv->incoming_servertype_picker = NULL;
1257 priv->caption_incoming = NULL;
1258 priv->entry_incomingserver = NULL;
1259 priv->entry_user_email = NULL;
1260 priv->incoming_security = NULL;
1264 init_outgoing_page (ModestEasysetupWizardDialogPrivate *priv)
1266 priv->page_custom_outgoing = NULL;
1267 priv->entry_outgoingserver = NULL;
1268 priv->checkbox_outgoing_smtp_specific = NULL;
1269 priv->button_outgoing_smtp_servers = NULL;
1270 priv->outgoing_security = NULL;
1274 modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
1276 gtk_container_set_border_width (GTK_CONTAINER (self), MODEST_MARGIN_HALF);
1278 /* Create the notebook to be used by the ModestWizardDialog base class:
1279 * Each page of the notebook will be a page of the wizard: */
1280 GtkNotebook *notebook = GTK_NOTEBOOK (gtk_notebook_new());
1281 gtk_widget_set_size_request (GTK_WIDGET (notebook), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
1283 /* Set the notebook used by the ModestWizardDialog base class: */
1284 g_object_set (G_OBJECT(self), "wizard-notebook", notebook, NULL);
1286 /* Set the wizard title:
1287 * The actual window title will be a combination of this and the page's tab label title. */
1288 g_object_set (G_OBJECT(self), "wizard-name", _("mcen_ti_emailsetup"), NULL);
1290 /* Read in the information about known service providers: */
1291 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1293 /* The server fields did not have been manually changed yet */
1294 priv->server_changes = 0;
1295 priv->pending_load_settings = TRUE;
1297 /* Get the account manager object,
1298 * so we can check for existing accounts,
1299 * and create new accounts: */
1300 priv->account_manager = modest_runtime_get_account_mgr ();
1301 g_object_ref (priv->account_manager);
1303 /* Initialize fields */
1304 priv->check_support_done = FALSE;
1305 priv->check_support_show_progress_id = 0;
1306 priv->check_support_progress_pulse_id = 0;
1307 priv->pending_check_support = 0;
1308 priv->destroyed = FALSE;
1309 priv->page_welcome = create_page_welcome (self);
1310 priv->page_account_details = create_page_account_details (self);
1312 init_user_page (priv);
1313 init_incoming_page (priv);
1314 init_outgoing_page (priv);
1316 priv->page_complete_easysetup = NULL;
1317 priv->page_complete_customsetup = NULL;
1318 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1319 priv->missing_data_signals = NULL;
1321 /* Add the common pages */
1322 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_welcome,
1323 _("mcen_ti_emailsetup_welcome"));
1324 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_account_details,
1325 _("mcen_ti_accountdetails"));
1327 /* Connect to the dialog's response signal so we can enable/disable buttons
1328 * for the newly-selected page, because the prev/next buttons cause response to be emitted.
1329 * Note that we use g_signal_connect_after() instead of g_signal_connect()
1330 * so that we can be enable/disable after ModestWizardDialog has done its own
1331 * enabling/disabling of buttons.
1333 * HOWEVER, this doesn't work because ModestWizardDialog's response signal handler
1334 * does g_signal_stop_emission_by_name(), stopping our signal handler from running.
1336 * It's not enough to connect to the notebook's switch-page signal, because
1337 * ModestWizardDialog's "response" signal handler enables the buttons itself,
1338 * _after_ switching the page (understandably).
1339 * (Note that if we had, if we used g_signal_connect() instead of g_signal_connect_after()
1340 * then gtk_notebook_get_current_page() would return an incorrect value.)
1342 g_signal_connect_after (G_OBJECT (self), "response",
1343 G_CALLBACK (on_response), self);
1345 /* This is to show a confirmation dialog when the user hits cancel */
1346 g_signal_connect (G_OBJECT (self), "response",
1347 G_CALLBACK (on_response_before), self);
1349 g_signal_connect (G_OBJECT (self), "delete-event",
1350 G_CALLBACK (on_delete_event), self);
1352 /* Reset dirty, because there was no user input until now */
1353 priv->dirty = FALSE;
1355 /* When this window is shown, hibernation should not be possible,
1356 * because there is no sensible way to save the state: */
1357 modest_window_mgr_prevent_hibernation_while_window_is_shown (
1358 modest_runtime_get_window_mgr (), GTK_WINDOW (self));
1360 /* Load provider presets */
1361 g_object_ref (self);
1362 g_thread_create (presets_loader, self, FALSE, NULL);
1364 priv->settings = modest_account_settings_new ();
1366 check_support_of_protocols (self);
1369 ModestEasysetupWizardDialog*
1370 modest_easysetup_wizard_dialog_new (void)
1373 return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
1377 create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
1379 ModestEasysetupWizardDialogPrivate *priv;
1380 GtkNotebook *notebook = NULL;
1382 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1385 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1387 if (!priv->page_user_details) {
1388 priv->page_user_details = create_page_user_details (self);
1391 /* Create the custom pages: */
1392 if(!(priv->page_custom_incoming)) {
1393 priv->page_custom_incoming = create_page_custom_incoming (self);
1396 /* TODO: only if needed */
1397 if(!(priv->page_custom_outgoing)) {
1398 priv->page_custom_outgoing = create_page_custom_outgoing (self);
1401 if(!(priv->page_complete_customsetup)) {
1402 priv->page_complete_customsetup = create_page_complete_custom (self);
1405 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_user_details)))
1406 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_user_details,
1407 _("mcen_ti_emailsetup_userdetails"));
1409 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_incoming)))
1410 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_incoming,
1411 _("mcen_ti_emailsetup_incomingdetails"));
1413 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_outgoing)))
1414 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_outgoing,
1415 _("mcen_ti_emailsetup_outgoingdetails"));
1417 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_customsetup)))
1418 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_customsetup,
1419 _("mcen_ti_emailsetup_complete"));
1421 /* This is unnecessary with GTK+ 2.10: */
1422 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1426 create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self)
1428 ModestEasysetupWizardDialogPrivate *priv;
1429 GtkNotebook *notebook = NULL;
1431 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1434 /* Create the easysetup-specific pages: */
1435 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1436 if(!priv->page_complete_easysetup)
1437 priv->page_complete_easysetup = create_page_complete_easysetup (self);
1439 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_easysetup)))
1440 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_easysetup,
1441 _("mcen_ti_emailsetup_complete"));
1443 /* This is unnecessary with GTK+ 2.10: */
1444 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1449 remove_non_common_tabs (GtkNotebook *notebook,
1450 gboolean remove_user_details)
1453 /* The first 2 tabs are the common ones (welcome tab and the
1454 providers tab), so we always remove starting from the
1457 starting_tab = (remove_user_details) ? 2 : 3;
1458 while (gtk_notebook_get_n_pages (notebook) > starting_tab)
1459 gtk_notebook_remove_page (notebook, -1);
1463 on_missing_mandatory_data (ModestAccountProtocol *protocol,
1467 real_enable_buttons (MODEST_WIZARD_DIALOG (user_data), !missing);
1470 /* After the user details page,
1471 * the following pages depend on whether "Other" was chosen
1472 * in the provider combobox on the account page
1475 create_subsequent_pages (ModestEasysetupWizardDialog *self)
1477 ModestEasysetupWizardDialogPrivate *priv;
1478 ModestProviderPicker *picker;
1479 ModestProviderPickerIdType id_type;
1480 GtkNotebook *notebook;
1482 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1483 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1484 id_type = modest_provider_picker_get_active_id_type (picker);
1485 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1486 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1490 if (id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
1491 /* "Other..." was selected: */
1493 /* If we come from a rollbacked easysetup */
1494 if (priv->page_complete_easysetup) {
1495 remove_non_common_tabs (notebook, FALSE);
1496 priv->page_complete_easysetup = NULL;
1499 /* If we come from a rollbacked plugin protocol setup */
1500 if (priv->last_plugin_protocol_selected != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1501 remove_non_common_tabs (notebook, TRUE);
1502 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1503 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1504 priv->missing_data_signals = NULL;
1507 create_subsequent_customsetup_pages (self);
1509 /* If we come from a rollbacked custom setup */
1510 if (priv->page_custom_incoming) {
1511 remove_non_common_tabs (notebook, TRUE);
1512 init_user_page (priv);
1513 init_incoming_page (priv);
1514 init_outgoing_page (priv);
1515 init_user_page (priv);
1516 priv->page_complete_customsetup = NULL;
1519 /* It's a pluggable protocol and not a provider with presets */
1520 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1521 ModestProtocol *protocol;
1523 ModestProtocolType proto_type;
1526 /* If we come from a rollbacked easy setup */
1527 if (priv->last_plugin_protocol_selected ==
1528 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID &&
1529 priv->page_complete_easysetup) {
1530 remove_non_common_tabs (notebook, TRUE);
1531 init_user_page (priv);
1532 priv->page_complete_easysetup = NULL;
1535 proto_name = modest_provider_picker_get_active_provider_id (picker);
1536 protocol = modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
1537 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
1539 proto_type = modest_protocol_get_type_id (protocol);
1541 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
1542 proto_type != priv->last_plugin_protocol_selected) {
1543 ModestPairList *tabs;
1545 gboolean first_page = TRUE;
1546 ModestWizardDialogResponseOverrideFunc response_override;
1548 /* Remember the last selected plugin protocol */
1549 priv->last_plugin_protocol_selected = proto_type;
1552 tabs = modest_account_protocol_get_easysetupwizard_tabs (MODEST_ACCOUNT_PROTOCOL (protocol));
1553 response_override = modest_account_protocol_get_wizard_response_override
1554 (MODEST_ACCOUNT_PROTOCOL (protocol));
1555 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1557 tmp = (GSList *) tabs;
1559 ModestPair *pair = (ModestPair *) tmp->data;
1560 modest_easysetup_wizard_dialog_append_page (notebook,
1561 GTK_WIDGET (pair->second),
1562 (const gchar *) pair->first);
1564 gtk_container_set_focus_child (GTK_CONTAINER (notebook),
1565 GTK_WIDGET (pair->second));
1569 /* Connect signals */
1570 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (pair->second)) {
1571 priv->missing_data_signals =
1572 modest_signal_mgr_connect (priv->missing_data_signals,
1573 G_OBJECT (pair->second),
1574 "missing-mandatory-data",
1575 G_CALLBACK (on_missing_mandatory_data),
1579 g_free (pair->first);
1580 tmp = g_slist_next (tmp);
1581 /* Critical: if you don't show the page then the dialog will ignore it */
1582 /* gtk_widget_show (GTK_WIDGET (pair->second)); */
1584 modest_pair_list_free (tabs);
1586 g_free (proto_name);
1588 if (priv->last_plugin_protocol_selected !=
1589 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1590 remove_non_common_tabs (notebook, TRUE);
1591 init_user_page (priv);
1592 priv->page_complete_easysetup = NULL;
1593 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1594 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1595 priv->missing_data_signals = NULL;
1597 if (!priv->page_user_details) {
1598 priv->page_user_details = create_page_user_details (self);
1599 modest_easysetup_wizard_dialog_append_page (notebook,
1600 priv->page_user_details,
1601 _("mcen_ti_emailsetup_userdetails"));
1605 /* Create the easysetup pages: */
1606 create_subsequent_easysetup_pages (self);
1612 util_get_default_servername_from_email_address (const gchar* email_address, ModestProtocolType protocol_type)
1614 const gchar* hostname = NULL;
1617 ModestProtocolRegistry *protocol_registry;
1618 ModestProtocol *protocol;
1623 at = g_utf8_strchr (email_address, -1, '@');
1624 if (!at || (g_utf8_strlen (at, -1) < 2))
1627 domain = g_utf8_next_char (at);
1631 protocol_registry = modest_runtime_get_protocol_registry ();
1632 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
1634 if (modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS) ||
1635 modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS)) {
1636 hostname = modest_protocol_get_name (protocol);
1642 return g_strdup_printf ("%s.%s", hostname, domain);
1646 set_default_custom_servernames (ModestEasysetupWizardDialog *self)
1648 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1650 if (!priv->entry_incomingserver)
1653 /* Set a default domain for the server, based on the email address,
1654 * if no server name was already specified.
1656 if (priv->entry_user_email
1657 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED) == 0)) {
1658 const ModestProtocolType protocol_type = modest_servertype_picker_get_active_servertype (
1659 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
1661 /* This could happen when the combo box has still no active iter */
1662 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1663 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1664 gchar* servername = util_get_default_servername_from_email_address (email_address,
1667 /* Do not set the INCOMING_CHANGED flag because of this edit */
1668 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1669 hildon_entry_set_text (HILDON_ENTRY (priv->entry_incomingserver), servername);
1670 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1672 g_free (servername);
1676 /* Set a default domain for the server, based on the email address,
1677 * if no server name was already specified.
1679 if (!priv->entry_outgoingserver)
1682 if (priv->entry_user_email
1683 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED) == 0)) {
1684 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1686 gchar* servername = util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOLS_TRANSPORT_SMTP);
1688 /* Do not set the OUTGOING_CHANGED flag because of this edit */
1689 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1690 hildon_entry_set_text (HILDON_ENTRY (priv->entry_outgoingserver), servername);
1691 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1693 g_free (servername);
1698 get_entered_account_title (ModestEasysetupWizardDialog *self)
1700 ModestEasysetupWizardDialogPrivate *priv;
1701 const gchar* account_title;
1703 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1704 account_title = hildon_entry_get_text (HILDON_ENTRY (priv->entry_account_title));
1706 if (!account_title || (g_utf8_strlen (account_title, -1) == 0)) {
1709 /* Strip it of whitespace at the start and end: */
1710 gchar *result = g_strdup (account_title);
1711 result = g_strstrip (result);
1716 if (g_utf8_strlen (result, -1) == 0) {
1726 on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *next_page)
1728 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1729 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1730 ModestProtocolRegistry *protocol_registry;
1732 protocol_registry = modest_runtime_get_protocol_registry ();
1734 /* if are browsing pages previous to the last one, then we have pending settings in
1736 if (next_page != NULL)
1737 priv->pending_load_settings = TRUE;
1739 /* Do extra validation that couldn't be done for every key press,
1740 * either because it was too slow,
1741 * or because it requires interaction:
1743 if (current_page == priv->page_account_details) {
1744 /* Check that the title is not already in use: */
1745 gchar* account_title = get_entered_account_title (self);
1749 /* Aavoid a clash with an existing display name: */
1750 const gboolean name_in_use = modest_account_mgr_account_with_display_name_exists (
1751 priv->account_manager, account_title);
1752 g_free (account_title);
1755 /* Warn the user via a dialog: */
1756 hildon_banner_show_information(NULL, NULL, _("mail_ib_account_name_already_existing"));
1761 /* Make sure that the subsequent pages are appropriate for the provider choice. */
1762 create_subsequent_pages (self);
1764 } else if (current_page == priv->page_user_details) {
1765 /* Check that the email address is valud: */
1766 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
1767 if ((!email_address) || (g_utf8_strlen (email_address, -1) == 0))
1770 if (!modest_text_utils_validate_email_address (email_address, NULL)) {
1771 /* Warn the user via a dialog: */
1772 hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email"));
1774 /* Return focus to the email address entry: */
1775 gtk_widget_grab_focus (priv->entry_user_email);
1776 gtk_editable_select_region (GTK_EDITABLE (priv->entry_user_email), 0, -1);
1782 if (next_page == priv->page_custom_incoming) {
1783 set_default_custom_servernames (self);
1784 } else if (next_page == priv->page_custom_outgoing) {
1785 set_default_custom_servernames (self);
1787 /* Check if the server supports secure authentication */
1788 if (modest_security_options_view_auth_check (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security)))
1789 if (!check_has_supported_auth_methods (self))
1791 gtk_widget_show (priv->outgoing_security);
1794 /* If this is the last page, and this is a click on Finish,
1795 * then attempt to create the dialog.
1798 current_page != priv->page_account_details) /* This is NULL when this is a click on Finish. */
1800 if (priv->pending_load_settings) {
1801 save_to_settings (self);
1804 /* We check if there's already another account with the same configuration */
1805 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
1806 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
1810 modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
1817 static gboolean entry_is_empty (GtkWidget *entry)
1822 const gchar* text = hildon_entry_get_text (HILDON_ENTRY (entry));
1823 if ((!text) || (g_utf8_strlen (text, -1) == 0))
1826 /* Strip it of whitespace at the start and end: */
1827 gchar *stripped = g_strdup (text);
1828 stripped = g_strstrip (stripped);
1833 const gboolean result = (g_utf8_strlen (stripped, -1) == 0);
1841 real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next)
1843 GtkNotebook *notebook = NULL;
1844 gboolean is_finish_tab;
1846 ModestEasysetupWizardDialogPrivate *priv;
1849 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (dialog);
1850 g_object_get (dialog, "wizard-notebook", ¬ebook, NULL);
1852 /* Disable the Finish button until we are on the last page,
1853 * because HildonWizardDialog enables this for all but the
1855 current = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
1856 is_finish_tab = ((current == priv->page_complete_easysetup) ||
1857 (current == priv->page_complete_customsetup));
1859 if (is_finish_tab) {
1860 /* Disable Next on the last page no matter what the
1862 enable_next = FALSE;
1864 /* Not the last one */
1865 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1866 MODEST_WIZARD_DIALOG_FINISH,
1869 /* If the check support is not done then do not enable
1870 the wizard to continue */
1871 enable_next = enable_next && priv->check_support_done;
1874 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1875 MODEST_WIZARD_DIALOG_NEXT,
1880 on_enable_buttons (ModestWizardDialog *dialog, GtkWidget *current_page)
1882 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1883 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1885 gboolean enable_next = TRUE;
1886 if (current_page == priv->page_welcome) {
1888 } else if (current_page == priv->page_account_details) {
1889 /* The account details title is mandatory: */
1890 if (entry_is_empty(priv->entry_account_title))
1891 enable_next = FALSE;
1892 } else if (current_page == priv->page_user_details) {
1893 /* The user details username is mandatory: */
1894 if (entry_is_empty(priv->entry_user_username))
1895 enable_next = FALSE;
1897 /* The user details email address is mandatory: */
1898 if (enable_next && entry_is_empty (priv->entry_user_email))
1899 enable_next = FALSE;
1900 } else if (current_page == priv->page_custom_incoming) {
1901 /* The custom incoming server is mandatory: */
1902 if (entry_is_empty(priv->entry_incomingserver))
1903 enable_next = FALSE;
1904 } else if (MODEST_IS_EASYSETUP_WIZARD_PAGE (current_page)) {
1905 enable_next = !modest_easysetup_wizard_page_validate (
1906 MODEST_EASYSETUP_WIZARD_PAGE (current_page));
1909 /* Enable/disable buttons */
1910 real_enable_buttons (dialog, enable_next);
1914 modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *klass)
1916 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1917 g_type_class_add_private (klass, sizeof (ModestEasysetupWizardDialogPrivate));
1920 object_class->dispose = modest_easysetup_wizard_dialog_dispose;
1921 object_class->finalize = modest_easysetup_wizard_dialog_finalize;
1923 /* Provide a vfunc implementation so we can decide
1924 * when to enable/disable the prev/next buttons.
1926 ModestWizardDialogClass *base_klass = (ModestWizardDialogClass*)(klass);
1927 base_klass->before_next = on_before_next;
1928 base_klass->enable_buttons = on_enable_buttons;
1929 base_klass->update_model = on_update_model;
1930 base_klass->save = on_save;
1935 * @self: a #ModestEasysetupWizardDialog
1937 * takes information from all the wizard and stores it in settings
1940 save_to_settings (ModestEasysetupWizardDialog *self)
1942 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1944 gchar *provider_id = NULL;
1945 gchar* display_name;
1946 const gchar *username, *password;
1947 gchar *store_hostname, *transport_hostname;
1948 guint store_port, transport_port;
1949 ModestProtocolRegistry *protocol_registry;
1950 ModestProtocolType store_protocol, transport_protocol;
1951 ModestProtocolType store_security, transport_security;
1952 ModestProtocolType store_auth_protocol, transport_auth_protocol;
1953 ModestServerAccountSettings *store_settings, *transport_settings;
1954 const gchar *fullname, *email_address;
1955 ModestProviderPicker *picker;
1956 ModestProviderPickerIdType id_type;
1958 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1959 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1960 protocol_registry = modest_runtime_get_protocol_registry ();
1962 /* Get details from the specified presets: */
1963 id_type = modest_provider_picker_get_active_id_type (picker);
1964 provider_id = modest_provider_picker_get_active_provider_id (picker);
1966 /* Let the plugin save the settings. We do a return in order
1967 to save an indentation level */
1968 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1969 ModestProtocol *protocol;
1971 protocol = modest_protocol_registry_get_protocol_by_name (
1972 modest_runtime_get_protocol_registry (),
1973 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
1976 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
1977 gint n_pages, i = 0;
1978 GtkNotebook *notebook;
1979 GList *wizard_pages = NULL;
1981 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1982 n_pages = gtk_notebook_get_n_pages (notebook);
1983 for (i = 0; i < n_pages; i++) {
1984 GtkWidget *page = gtk_notebook_get_nth_page (notebook, i);
1985 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (page))
1986 wizard_pages = g_list_append (wizard_pages, page);
1988 modest_account_protocol_save_wizard_settings (MODEST_ACCOUNT_PROTOCOL (protocol),
1991 g_list_free (wizard_pages);
1993 g_warning ("The selected protocol is a plugin protocol "//
1994 "but it's not a ModestAccountProtocol");
1997 g_free (provider_id);
2001 /* username and password (for both incoming and outgoing): */
2002 username = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_username));
2003 password = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_password));
2005 store_settings = modest_account_settings_get_store_settings (priv->settings);
2006 transport_settings = modest_account_settings_get_transport_settings (priv->settings);
2008 /* Incoming server: */
2009 /* Note: We need something as default for the transport store protocol values,
2010 * or modest_account_mgr_add_server_account will fail. */
2012 store_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2013 store_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2014 store_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2017 ModestProtocolType store_provider_server_type;
2018 gboolean store_provider_use_alternate_port;
2020 store_hostname = modest_presets_get_server (priv->presets, provider_id,
2023 store_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2026 store_security = modest_presets_get_info_server_security (priv->presets,
2029 store_auth_protocol = modest_presets_get_info_server_auth (priv->presets,
2032 store_provider_use_alternate_port = modest_presets_get_info_server_use_alternate_port (priv->presets,
2036 /* We don't check for SMTP here as that is impossible for an incoming server. */
2037 if (store_provider_server_type == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID)
2038 store_protocol = MODEST_PROTOCOLS_STORE_POP;
2040 store_protocol = store_provider_server_type;
2042 /* we check if there is a *special* port */
2043 special_port = modest_presets_get_port (priv->presets, provider_id, TRUE /* incoming */);
2044 if (special_port != 0) {
2045 store_port = special_port;
2047 gboolean use_alternate_port = FALSE;
2048 if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (),
2050 use_alternate_port = TRUE;
2051 store_port = get_port_from_protocol(store_provider_server_type, use_alternate_port);
2054 modest_server_account_settings_set_security_protocol (store_settings,
2056 modest_server_account_settings_set_auth_protocol (store_settings,
2057 store_auth_protocol);
2058 if (store_port != 0)
2059 modest_server_account_settings_set_port (store_settings, store_port);
2061 /* Use custom pages because no preset was specified: */
2062 store_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_incomingserver) ));
2063 store_protocol = modest_servertype_picker_get_active_servertype (
2064 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2066 modest_security_options_view_save_settings (
2067 MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
2071 /* now we store the common store account settings */
2072 modest_server_account_settings_set_hostname (store_settings, store_hostname);
2073 modest_server_account_settings_set_username (store_settings, username);
2074 modest_server_account_settings_set_password (store_settings, password);
2075 modest_server_account_settings_set_protocol (store_settings, store_protocol);
2077 g_object_unref (store_settings);
2078 g_free (store_hostname);
2080 /* Outgoing server: */
2081 transport_hostname = NULL;
2082 transport_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2083 transport_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2084 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2088 ModestProtocolType transport_provider_server_type;
2089 ModestProtocolType transport_provider_security;
2092 transport_hostname = modest_presets_get_server (priv->presets, provider_id,
2093 FALSE /* transport */);
2095 transport_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2097 FALSE /* transport */);
2098 transport_provider_security = modest_presets_get_info_server_security (priv->presets,
2100 FALSE /* transport */);
2102 /* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
2103 transport_protocol = transport_provider_server_type;
2104 transport_security = transport_provider_security;
2105 if (transport_security == MODEST_PROTOCOLS_CONNECTION_SSL) {
2106 /* printf("DEBUG: %s: using secure SMTP\n", __FUNCTION__); */
2107 /* we check if there is a *special* port */
2108 special_port = modest_presets_get_port (priv->presets, provider_id,
2109 FALSE /* transport */);
2110 if (special_port != 0)
2111 transport_port = special_port;
2113 transport_port = 465;
2114 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_PASSWORD;
2116 /* printf("DEBUG: %s: using non-secure SMTP\n", __FUNCTION__); */
2117 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2120 modest_server_account_settings_set_security_protocol (transport_settings,
2121 transport_security);
2122 modest_server_account_settings_set_auth_protocol (transport_settings,
2123 transport_auth_protocol);
2124 if (transport_port != 0)
2125 modest_server_account_settings_set_port (transport_settings,
2128 ModestProtocolRegistry *registry;
2129 ModestProtocol *store_proto;
2131 registry = modest_runtime_get_protocol_registry ();
2132 /* Use custom pages because no preset was specified: */
2133 transport_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver) ));
2135 store_proto = modest_protocol_registry_get_protocol_by_type (registry,
2138 if (transport_protocol == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
2139 /* fallback to SMTP if none was specified */
2140 g_warning ("No transport protocol was specified for store %d (%s)",
2141 modest_protocol_get_type_id (store_proto),
2142 modest_protocol_get_display_name (store_proto));
2143 transport_protocol = MODEST_PROTOCOLS_TRANSPORT_SMTP;
2146 modest_security_options_view_save_settings (
2147 MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security),
2151 /* now we store the common transport account settings */
2152 modest_server_account_settings_set_hostname (transport_settings, transport_hostname);
2153 modest_server_account_settings_set_username (transport_settings, username);
2154 modest_server_account_settings_set_password (transport_settings, password);
2155 modest_server_account_settings_set_protocol (transport_settings, transport_protocol);
2157 g_object_unref (transport_settings);
2158 g_free (transport_hostname);
2160 fullname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_name));
2161 email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
2162 modest_account_settings_set_fullname (priv->settings, fullname);
2163 modest_account_settings_set_email_address (priv->settings, email_address);
2164 /* we don't set retrieve type to preserve advanced settings if
2165 any. By default account settings are set to headers only */
2167 /* Save the connection-specific SMTP server accounts. */
2168 if (priv->checkbox_outgoing_smtp_specific) {
2169 modest_account_settings_set_use_connection_specific_smtp
2171 hildon_check_button_get_active(HILDON_CHECK_BUTTON(priv->checkbox_outgoing_smtp_specific)));
2174 display_name = get_entered_account_title (self);
2175 modest_account_settings_set_display_name (priv->settings, display_name);
2176 g_free (display_name);
2177 g_free (provider_id);
2182 on_update_model (ModestWizardDialog *dialog)
2184 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2185 save_to_settings (self);
2190 on_save (ModestWizardDialog *dialog)
2192 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2193 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2195 save_to_settings (self);
2197 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
2198 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
2202 return modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
2208 check_for_supported_auth_methods (ModestEasysetupWizardDialog* self)
2210 GError *error = NULL;
2211 ModestProtocolType protocol_type;
2212 const gchar* hostname;
2213 const gchar* username;
2214 ModestProtocolType security_protocol_incoming_type;
2215 ModestProtocolRegistry *registry;
2217 GList *list_auth_methods;
2218 ModestEasysetupWizardDialogPrivate *priv;
2220 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2221 registry = modest_runtime_get_protocol_registry ();
2222 protocol_type = modest_servertype_picker_get_active_servertype (
2223 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2224 hostname = gtk_entry_get_text(GTK_ENTRY(priv->entry_incomingserver));
2225 username = gtk_entry_get_text(GTK_ENTRY(priv->entry_user_username));
2226 security_protocol_incoming_type = modest_security_options_view_get_connection_protocol
2227 (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security));
2228 port_num = get_port_from_protocol(protocol_type, FALSE);
2229 list_auth_methods = modest_utils_get_supported_secure_authentication_methods (protocol_type, hostname, port_num,
2230 username, GTK_WINDOW (self), &error);
2232 if (list_auth_methods) {
2233 /* TODO: Select the correct method */
2236 for (method = list_auth_methods; method != NULL; method = g_list_next(method)) {
2237 ModestProtocolType auth_protocol_type = (ModestProtocolType) (GPOINTER_TO_INT(method->data));
2238 if (modest_protocol_registry_protocol_type_has_tag (registry, auth_protocol_type,
2239 MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS)) {
2240 list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type));
2244 g_list_free(list_auth_methods);
2250 if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
2251 error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
2253 modest_platform_information_banner (GTK_WIDGET(self), NULL,
2254 _("mcen_ib_unableto_discover_auth_methods"));
2258 g_error_free(error);
2264 check_has_supported_auth_methods(ModestEasysetupWizardDialog* self)
2266 GList* methods = check_for_supported_auth_methods(self);
2272 g_list_free(methods);
2277 check_support_progress_pulse (gpointer userdata)
2279 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2280 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2282 if (priv->destroyed) {
2283 priv->check_support_progress_pulse_id = 0;
2287 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2293 check_support_show_progress (gpointer userdata)
2295 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2296 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2298 priv->check_support_show_progress_id = 0;
2300 if (priv->destroyed)
2303 gtk_widget_show (priv->check_support_progress);
2304 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2306 priv->check_support_progress_pulse_id = g_timeout_add (200, check_support_progress_pulse, self);
2312 check_support_callback (ModestAccountProtocol *protocol,
2316 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2317 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2319 priv->pending_check_support --;
2321 if (priv->check_support_show_progress_id > 0) {
2322 g_source_remove (priv->check_support_show_progress_id);
2323 priv->check_support_show_progress_id = 0;
2326 if (priv->check_support_progress_pulse_id > 0) {
2327 g_source_remove (priv->check_support_progress_pulse_id);
2328 priv->check_support_progress_pulse_id = 0;
2331 if (priv->pending_check_support == 0) {
2332 priv->check_support_done = TRUE;
2334 if (!priv->destroyed) {
2336 fill_providers (self);
2337 gtk_widget_hide (priv->check_support_progress);
2338 invoke_enable_buttons_vfunc (self);
2341 g_object_unref (self);
2346 check_support_of_protocols (ModestEasysetupWizardDialog *self)
2348 ModestProtocolRegistry *registry;
2349 GSList *provider_protos, *node;
2350 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2352 registry = modest_runtime_get_protocol_registry ();
2353 provider_protos = modest_protocol_registry_get_by_tag (registry,
2354 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS);
2356 for (node = provider_protos; node != NULL; node = g_slist_next (node)) {
2357 ModestProtocol *proto = MODEST_PROTOCOL (node->data);
2359 if (!modest_protocol_registry_protocol_type_has_tag (registry,
2360 modest_protocol_get_type_id (proto),
2361 MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS))
2364 if (modest_protocol_registry_protocol_type_has_tag
2366 modest_protocol_get_type_id (proto),
2367 MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS)) {
2368 /* Check if there's already an account configured with this account type */
2369 if (modest_account_mgr_singleton_protocol_exists (modest_runtime_get_account_mgr (),
2370 modest_protocol_get_type_id (proto)))
2374 if (MODEST_ACCOUNT_PROTOCOL (proto)) {
2375 priv->pending_check_support ++;
2376 modest_account_protocol_check_support (MODEST_ACCOUNT_PROTOCOL (proto),
2377 check_support_callback,
2378 g_object_ref (self));
2381 g_slist_free (provider_protos);
2383 if (priv->pending_check_support > 0) {
2384 priv->check_support_show_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 1000,
2385 check_support_show_progress,
2386 g_object_ref (self), g_object_unref);
2388 priv->check_support_done = TRUE;
2390 invoke_enable_buttons_vfunc (self);