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;
420 gchar* domain_name = NULL;
423 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
425 /* Fill the providers combo, based on the selected country: */
426 provider_id = modest_provider_picker_get_active_provider_id (
427 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
430 domain_name = modest_presets_get_domain (priv->presets, provider_id);
433 domain_name = g_strdup (MODEST_EXAMPLE_EMAIL_ADDRESS);
435 if (priv->entry_user_email)
436 hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_email), domain_name);
438 g_free (domain_name);
440 g_free (provider_id);
444 on_account_serviceprovider_selector_changed (HildonTouchSelector *widget, gint column, gpointer user_data)
446 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
448 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
452 update_user_email_from_provider (self);
456 on_entry_max (ModestValidatingEntry *self, gpointer user_data)
458 modest_platform_information_banner (GTK_WIDGET (self), NULL,
459 _CS("ckdg_ib_maximum_characters_reached"));
463 create_page_account_details (ModestEasysetupWizardDialog *self)
466 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
467 GtkWidget *label = gtk_label_new(_("mcen_ia_accountdetails"));
468 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
470 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
471 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
472 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, MODEST_MARGIN_HALF);
473 gtk_widget_show (label);
475 /* Create a size group to be used by all captions.
476 * Note that HildonCaption does not create a default size group if we do not specify one.
477 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
478 GtkSizeGroup* title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
479 GtkSizeGroup* value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
481 /* The country widgets: */
482 priv->account_country_picker = GTK_WIDGET (modest_country_picker_new (MODEST_EDITABLE_SIZE,
483 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
484 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
485 _("mcen_fi_country"), priv->account_country_picker);
486 g_signal_connect (G_OBJECT (priv->account_country_picker), "value-changed",
487 G_CALLBACK (on_picker_button_value_changed), self);
488 gtk_box_pack_start (GTK_BOX (box), priv->account_country_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
489 gtk_widget_show (priv->account_country_picker);
491 GtkWidget *separator = gtk_hseparator_new ();
492 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
493 gtk_widget_show (separator);
495 /* The service provider widgets: */
496 priv->account_serviceprovider_picker = GTK_WIDGET (modest_provider_picker_new (MODEST_EDITABLE_SIZE,
497 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
498 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
499 _("mcen_fi_serviceprovider"),
500 priv->account_serviceprovider_picker);
501 g_signal_connect (G_OBJECT (priv->account_serviceprovider_picker), "value-changed",
502 G_CALLBACK (on_serviceprovider_picker_button_value_changed), self);
503 gtk_box_pack_start (GTK_BOX (box), priv->account_serviceprovider_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
504 gtk_widget_show (priv->account_serviceprovider_picker);
506 /* The description widgets: */
507 priv->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
508 g_signal_connect(G_OBJECT(priv->entry_account_title), "changed",
509 G_CALLBACK(on_easysetup_changed), self);
510 /* Do use auto-capitalization: */
511 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_account_title),
512 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
514 /* Set a default account title, choosing one that does not already exist: */
515 /* Note that this is irrelevant to the non-user visible name, which we will create later. */
516 gchar* default_account_name_start = g_strdup (_("mcen_ia_emailsetup_defaultname"));
517 gchar* default_account_name = modest_account_mgr_get_unused_account_display_name (
518 priv->account_manager, default_account_name_start);
519 g_free (default_account_name_start);
520 default_account_name_start = NULL;
522 hildon_entry_set_text (HILDON_ENTRY (priv->entry_account_title), default_account_name);
523 g_free (default_account_name);
524 default_account_name = NULL;
526 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mcen_fi_account_title"), FALSE,
527 priv->entry_account_title);
528 gtk_widget_show (priv->entry_account_title);
529 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
530 gtk_widget_show (caption);
532 /* Prevent the use of some characters in the account title,
533 * as required by our UI specification: */
534 GList *list_prevent = NULL;
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, "?");
540 list_prevent = g_list_append (list_prevent, "\""); /* The UI spec mentions “, but maybe means ", maybe both. */
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 modest_validating_entry_set_unallowed_characters (
547 MODEST_VALIDATING_ENTRY (priv->entry_account_title), list_prevent);
548 g_list_free (list_prevent);
550 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
551 modest_utils_on_entry_invalid_character, self);
553 /* Set max length as in the UI spec:
554 * The UI spec seems to want us to show a dialog if we hit the maximum. */
555 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_account_title), 64);
556 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_account_title),
559 gtk_widget_show (GTK_WIDGET (box));
561 g_object_unref (title_sizegroup);
562 g_object_unref (value_sizegroup);
564 return GTK_WIDGET (box);
568 create_page_user_details (ModestEasysetupWizardDialog *self)
570 GtkSizeGroup* title_sizegroup;
571 GtkSizeGroup* value_sizegroup;
573 ModestEasysetupWizardDialogPrivate *priv;
575 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
577 /* Create a size group to be used by all captions.
578 * Note that HildonCaption does not create a default size group if we do not specify one.
579 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
580 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
581 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
582 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
584 /* The name widgets: (use auto cap) */
585 priv->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
586 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_name),
587 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
589 /* Set max length as in the UI spec:
590 * The UI spec seems to want us to show a dialog if we hit the maximum. */
591 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_name), 64);
592 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_name),
594 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
595 _("mcen_li_emailsetup_name"), FALSE, priv->entry_user_name);
596 g_signal_connect(G_OBJECT(priv->entry_user_name), "changed",
597 G_CALLBACK(on_easysetup_changed), self);
598 gtk_widget_show (priv->entry_user_name);
599 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
600 gtk_widget_show (caption);
602 /* Prevent the use of some characters in the name,
603 * as required by our UI specification: */
604 GList *list_prevent = NULL;
605 list_prevent = g_list_append (list_prevent, "<");
606 list_prevent = g_list_append (list_prevent, ">");
607 modest_validating_entry_set_unallowed_characters (
608 MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
609 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
610 modest_utils_on_entry_invalid_character, self);
611 g_list_free (list_prevent);
613 /* The username widgets: */
614 priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
615 /* Auto-capitalization is the default, so let's turn it off: */
616 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username),
617 HILDON_GTK_INPUT_MODE_FULL);
618 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mail_fi_username"), FALSE,
619 priv->entry_user_username);
620 gtk_widget_show (priv->entry_user_username);
621 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
622 g_signal_connect(G_OBJECT(priv->entry_user_username), "changed",
623 G_CALLBACK(on_easysetup_changed), self);
624 gtk_widget_show (caption);
626 /* Prevent the use of some characters in the username,
627 * as required by our UI specification: */
628 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_username),
629 modest_utils_on_entry_invalid_character, self);
631 /* Set max length as in the UI spec:
632 * The UI spec seems to want us to show a dialog if we hit the maximum. */
633 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
634 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_username),
637 /* The password widgets: */
638 priv->entry_user_password = hildon_entry_new (MODEST_EDITABLE_SIZE);
639 /* Auto-capitalization is the default, so let's turn it off: */
640 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password),
641 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
642 gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
643 /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
644 caption = create_captioned (self, title_sizegroup, value_sizegroup,
645 _("mail_fi_password"), FALSE, priv->entry_user_password);
646 g_signal_connect(G_OBJECT(priv->entry_user_password), "changed",
647 G_CALLBACK(on_easysetup_changed), self);
648 gtk_widget_show (priv->entry_user_password);
649 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
650 gtk_widget_show (caption);
652 /* The email address widgets: */
653 priv->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
654 /* Auto-capitalization is the default, so let's turn it off: */
655 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
656 caption = create_captioned (self, title_sizegroup, value_sizegroup,
657 _("mcen_li_emailsetup_email_address"), FALSE, priv->entry_user_email);
658 update_user_email_from_provider (self);
659 gtk_widget_show (priv->entry_user_email);
660 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
661 g_signal_connect(G_OBJECT(priv->entry_user_email), "changed",
662 G_CALLBACK(on_easysetup_changed), self);
663 gtk_widget_show (caption);
665 /* Set max length as in the UI spec:
666 * The UI spec seems to want us to show a dialog if we hit the maximum. */
667 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_email), 64);
668 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_email),
672 gtk_widget_show (GTK_WIDGET (box));
673 g_object_unref (title_sizegroup);
674 g_object_unref (value_sizegroup);
676 return GTK_WIDGET (box);
680 create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
682 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
684 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
685 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
686 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
687 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
689 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
690 gtk_widget_show (label);
692 label = gtk_label_new (_("mcen_ia_easysetup_complete"));
693 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
694 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
696 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
697 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
698 gtk_widget_show (label);
700 gtk_widget_show (GTK_WIDGET (box));
701 return GTK_WIDGET (box);
704 /** Change the caption title for the incoming server,
705 * as specified in the UI spec:
708 update_incoming_server_title (ModestEasysetupWizardDialog *self)
710 ModestEasysetupWizardDialogPrivate* priv;
711 ModestProtocolType protocol_type;
712 ModestProtocolRegistry *protocol_registry;
714 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
715 protocol_registry = modest_runtime_get_protocol_registry ();
717 protocol_type = modest_servertype_picker_get_active_servertype (
718 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
720 /* This could happen when the combo box has still no active iter */
721 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
722 gchar* incomingserver_title;
723 const gchar *protocol_display_name;
724 ModestProtocol *protocol;
726 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry,
728 protocol_display_name = modest_protocol_get_display_name (protocol);
730 incomingserver_title = g_strconcat (_("mcen_li_emailsetup_servertype"), "\n<small>(",
731 protocol_display_name, ")</small>", NULL);
733 modest_maemo_utils_captioned_set_label (priv->caption_incoming, incomingserver_title, TRUE);
735 g_free(incomingserver_title);
739 /** Change the caption title for the incoming server,
740 * as specified in the UI spec:
743 update_incoming_server_security_choices (ModestEasysetupWizardDialog *self)
745 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
746 ModestServertypePicker *server_type_picker;
747 ModestProtocolType protocol_type;
748 ModestSecurityOptionsView *view;
751 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
753 modest_servertype_picker_get_active_servertype (server_type_picker);
755 /* Fill the combo with appropriately titled choices for all
757 view = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
758 modest_security_options_view_set_server_type (view, protocol_type);
762 on_servertype_selector_changed(HildonTouchSelector *selector, gint column, gpointer user_data)
764 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
765 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
766 ModestServertypePicker *picker;
767 ModestProtocolType protocol_type;
772 update_incoming_server_title (self);
774 /* Update security options if needed */
775 picker = MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
776 protocol_type = modest_servertype_picker_get_active_servertype (picker);
777 update_incoming_server_security_choices (self);
778 gtk_widget_show (priv->incoming_security);
780 set_default_custom_servernames (self);
784 on_entry_incoming_servername_changed(GtkEntry *entry, gpointer user_data)
786 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
787 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
789 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED;
793 create_page_custom_incoming (ModestEasysetupWizardDialog *self)
795 ModestProtocolRegistry *protocol_registry;
796 ModestEasysetupWizardDialogPrivate* priv;
800 GtkSizeGroup *title_sizegroup;
801 GtkSizeGroup *value_sizegroup;
803 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
804 protocol_registry = modest_runtime_get_protocol_registry ();
806 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
807 pannable = hildon_pannable_area_new ();
809 /* Show note that account type cannot be changed in future: */
810 label = gtk_label_new (_("mcen_ia_emailsetup_account_type"));
811 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
812 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
813 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
814 gtk_widget_show (label);
816 /* Create a size group to be used by all captions.
817 * Note that HildonCaption does not create a default size group if we do not specify one.
818 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
819 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
820 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
822 /* The incoming server widgets: */
823 priv->incoming_servertype_picker = GTK_WIDGET (modest_servertype_picker_new (MODEST_EDITABLE_SIZE,
824 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
826 hildon_button_set_title (HILDON_BUTTON (priv->incoming_servertype_picker), _("mcen_li_emailsetup_type"));
827 g_signal_connect (G_OBJECT (priv->incoming_servertype_picker), "value-changed",
828 G_CALLBACK (on_picker_button_value_changed), self);
829 gtk_box_pack_start (GTK_BOX (box), priv->incoming_servertype_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
830 gtk_widget_show (priv->incoming_servertype_picker);
832 priv->entry_incomingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
833 g_signal_connect(G_OBJECT(priv->entry_incomingserver), "changed", G_CALLBACK(on_easysetup_changed), self);
834 /* Auto-capitalization is the default, so let's turn it off: */
835 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
836 set_default_custom_servernames (self);
838 /* The caption title will be updated in update_incoming_server_title().
839 * so this default text will never be seen: */
840 priv->caption_incoming = create_captioned (self, title_sizegroup, value_sizegroup,
841 "This will be removed",
842 FALSE, priv->entry_incomingserver);
843 update_incoming_server_title (self);
844 gtk_widget_show (priv->entry_incomingserver);
845 gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
846 gtk_widget_show (priv->caption_incoming);
848 /* Change the caption title when the servertype changes,
849 * as in the UI spec: */
850 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (priv->incoming_servertype_picker))),
852 G_CALLBACK (on_servertype_selector_changed), self);
854 /* Remember when the servername was changed manually: */
855 g_signal_connect (G_OBJECT (priv->entry_incomingserver), "changed",
856 G_CALLBACK (on_entry_incoming_servername_changed), self);
858 /* The secure connection widgets. These are only valid for
859 protocols with security */
860 priv->incoming_security =
861 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
862 FALSE, title_sizegroup, value_sizegroup);
863 gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
864 FALSE, FALSE, MODEST_MARGIN_HALF);
865 gtk_widget_show_all (priv->incoming_security);
867 /* Set default selection */
868 modest_servertype_picker_set_active_servertype (
869 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker),
870 MODEST_PROTOCOLS_STORE_POP);
872 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), box);
873 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
874 hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pannable)));
875 gtk_widget_show (GTK_WIDGET (box));
876 gtk_widget_show (pannable);
878 g_object_unref (title_sizegroup);
879 g_object_unref (value_sizegroup);
881 return GTK_WIDGET (pannable);
885 on_check_button_changed (HildonCheckButton *button, gpointer user_data)
887 GtkWidget *widget = GTK_WIDGET (user_data);
889 /* Enable the widget only if the check button is active: */
890 const gboolean enable = hildon_check_button_get_active (button);
891 gtk_widget_set_sensitive (widget, enable);
894 /* Make the sensitivity of a widget depend on a check button.
897 enable_widget_for_checkbutton (GtkWidget *widget, HildonCheckButton* button)
899 g_signal_connect (G_OBJECT (button), "toggled",
900 G_CALLBACK (on_check_button_changed), widget);
902 /* Set the starting sensitivity: */
903 on_check_button_changed (button, widget);
907 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
909 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
910 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
911 GtkWidget *specific_window;
913 /* We set dirty here because setting it depending on the connection specific dialog
917 /* Create the window, if necessary: */
918 specific_window = (GtkWidget *) modest_connection_specific_smtp_window_new ();
919 modest_connection_specific_smtp_window_fill_with_connections (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window), priv->account_manager);
921 /* Show the window */
922 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (specific_window), GTK_WINDOW (self));
923 gtk_widget_show (specific_window);
927 on_entry_outgoing_servername_changed (GtkEntry *entry, gpointer user_data)
929 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
930 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
931 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED;
935 create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
937 ModestEasysetupWizardDialogPrivate *priv;
938 gchar *smtp_caption_label;
940 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
942 pannable = hildon_pannable_area_new ();
944 /* Create a size group to be used by all captions.
945 * Note that HildonCaption does not create a default size group if we do not specify one.
946 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
947 GtkSizeGroup *title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
948 GtkSizeGroup *value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
950 /* The outgoing server widgets: */
951 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
952 priv->entry_outgoingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
953 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
954 G_CALLBACK (on_easysetup_changed), self);
955 /* Auto-capitalization is the default, so let's turn it off: */
956 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
957 smtp_caption_label = g_strconcat (_("mcen_li_emailsetup_smtp"), "\n<small>(SMTP)</small>", NULL);
958 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
959 smtp_caption_label, TRUE, priv->entry_outgoingserver);
960 g_free (smtp_caption_label);
961 gtk_widget_show (priv->entry_outgoingserver);
962 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
963 gtk_widget_show (caption);
964 set_default_custom_servernames (self);
966 /* The secure connection widgets. These are only valid for
967 protocols with security */
968 priv->outgoing_security =
969 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
970 FALSE, title_sizegroup, value_sizegroup);
971 gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security,
972 FALSE, FALSE, MODEST_MARGIN_HALF);
973 gtk_widget_show (priv->outgoing_security);
975 GtkWidget *separator = gtk_hseparator_new ();
976 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
977 gtk_widget_show (separator);
979 /* connection-specific checkbox: */
980 priv->checkbox_outgoing_smtp_specific = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
981 hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific),
983 gtk_button_set_label (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
984 _("mcen_fi_advsetup_connection_smtp"));
985 gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
987 g_signal_connect (G_OBJECT (priv->checkbox_outgoing_smtp_specific), "toggled",
988 G_CALLBACK (on_easysetup_changed), self);
990 gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
991 gtk_box_pack_start (GTK_BOX (box), priv->checkbox_outgoing_smtp_specific,
992 FALSE, FALSE, MODEST_MARGIN_HALF);
994 /* Connection-specific SMTP-Severs Edit button: */
995 priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_advsetup_optional_smtp"));
996 hildon_gtk_widget_set_theme_size (priv->button_outgoing_smtp_servers,
997 HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
998 gtk_widget_show (priv->button_outgoing_smtp_servers);
999 gtk_box_pack_start (GTK_BOX (box), priv->button_outgoing_smtp_servers,
1000 FALSE, FALSE, MODEST_MARGIN_HALF);
1002 /* Only enable the button when the checkbox is checked: */
1003 enable_widget_for_checkbutton (priv->button_outgoing_smtp_servers,
1004 HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific));
1006 g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
1007 G_CALLBACK (on_button_outgoing_smtp_servers), self);
1009 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
1010 G_CALLBACK (on_entry_outgoing_servername_changed), self);
1013 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), box);
1014 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
1015 hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pannable)));
1016 gtk_widget_show (GTK_WIDGET (box));
1017 gtk_widget_show (pannable);
1019 g_object_unref (title_sizegroup);
1020 g_object_unref (value_sizegroup);
1022 return GTK_WIDGET (pannable);
1026 show_advanced_edit(gpointer user_data)
1028 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1029 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1032 /* Show the Account Settings window: */
1033 ModestAccountSettingsDialog *dialog = modest_default_account_settings_dialog_new ();
1034 if (priv->pending_load_settings) {
1035 save_to_settings (self);
1036 priv->pending_load_settings = FALSE;
1038 modest_account_settings_dialog_load_settings (dialog, priv->settings);
1040 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), GTK_WINDOW (self));
1042 response = gtk_dialog_run (GTK_DIALOG (dialog));
1044 gtk_widget_destroy (GTK_WIDGET (dialog));
1046 return FALSE; /* Do not call this timeout callback again. */
1050 on_button_edit_advanced_settings (GtkButton *button, gpointer user_data)
1052 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1054 /* Show the Account Settings window: */
1055 show_advanced_edit(self);
1058 create_page_complete_custom (ModestEasysetupWizardDialog *self)
1060 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
1061 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
1062 GtkWidget *button_edit = gtk_button_new_with_label (_("mcen_fi_advanced_settings"));
1063 hildon_gtk_widget_set_theme_size (button_edit, HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1064 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1065 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1066 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1067 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
1068 gtk_widget_show (label);
1070 label = gtk_label_new (_("mcen_ia_customsetup_complete"));
1071 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
1072 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1073 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1074 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
1075 gtk_widget_show (label);
1077 gtk_widget_show (button_edit);
1078 gtk_box_pack_start (GTK_BOX (box), button_edit, FALSE, FALSE, MODEST_MARGIN_HALF);
1080 g_signal_connect (G_OBJECT (button_edit), "clicked",
1081 G_CALLBACK (on_button_edit_advanced_settings), self);
1083 gtk_widget_show (GTK_WIDGET (box));
1084 return GTK_WIDGET (box);
1091 on_response (ModestWizardDialog *wizard_dialog,
1095 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1097 invoke_enable_buttons_vfunc (self);
1101 on_response_before (ModestWizardDialog *wizard_dialog,
1105 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1106 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(wizard_dialog);
1107 if (response_id == GTK_RESPONSE_CANCEL) {
1108 /* This is mostly copied from
1109 * src/maemo/modest-account-settings-dialog.c */
1111 GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
1112 _("imum_nc_wizard_confirm_lose_changes")));
1113 /* TODO: These button names will be ambiguous, and not
1114 * specified in the UI specification. */
1116 const gint dialog_response = gtk_dialog_run (dialog);
1117 gtk_widget_destroy (GTK_WIDGET (dialog));
1119 if (dialog_response != GTK_RESPONSE_OK) {
1120 /* Don't let the dialog close */
1121 g_signal_stop_emission_by_name (wizard_dialog, "response");
1128 fill_providers (ModestEasysetupWizardDialog *self)
1130 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1132 if (MODEST_IS_COUNTRY_PICKER (priv->account_country_picker)) {
1133 /* gint mcc = get_default_country_code(); */
1135 /* Fill the combo in an idle call, as it takes a lot of time */
1136 modest_country_picker_load_data(
1137 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1138 /* connect to country picker's changed signal, so we can fill the provider picker: */
1139 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1140 (HILDON_PICKER_BUTTON (priv->account_country_picker))),
1142 G_CALLBACK (on_account_country_selector_changed), self);
1144 modest_country_picker_set_active_country_locale (
1145 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1146 mcc = modest_country_picker_get_active_country_mcc (
1147 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1148 modest_provider_picker_fill (
1149 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker),
1150 priv->presets, mcc);
1151 /* connect to providers picker's changed signal, so we can fill the email address: */
1152 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1153 (HILDON_PICKER_BUTTON (priv->account_serviceprovider_picker))),
1155 G_CALLBACK (on_account_serviceprovider_selector_changed), self);
1157 modest_provider_picker_set_others_provider (MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
1160 priv->dirty = FALSE;
1164 typedef struct IdleData {
1165 ModestEasysetupWizardDialog *dialog;
1166 ModestPresets *presets;
1170 presets_idle (gpointer userdata)
1172 IdleData *idle_data = (IdleData *) userdata;
1173 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (idle_data->dialog);
1174 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1176 g_assert (idle_data->presets);
1178 gdk_threads_enter ();
1180 priv->presets = idle_data->presets;
1182 if (priv->check_support_done)
1183 fill_providers (self);
1185 g_object_unref (idle_data->dialog);
1188 gdk_threads_leave ();
1194 presets_loader (gpointer userdata)
1196 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (userdata);
1197 ModestPresets *presets = NULL;
1198 IdleData *idle_data;
1200 const gchar* path = NULL;
1201 const gchar* path1 = MODEST_PROVIDER_DATA_FILE;
1202 const gchar* path2 = MODEST_MAEMO_PROVIDER_DATA_FILE;
1204 if (access(path1, R_OK) == 0)
1206 else if (access(path2, R_OK) == 0)
1209 g_warning ("%s: neither '%s' nor '%s' is a readable provider data file",
1210 __FUNCTION__, path1, path2);
1214 presets = modest_presets_new (path);
1216 g_warning ("%s: failed to parse '%s'", __FUNCTION__, path);
1220 idle_data = g_new0 (IdleData, 1);
1221 idle_data->dialog = self;
1222 idle_data->presets = presets;
1224 g_idle_add (presets_idle, idle_data);
1230 modest_easysetup_wizard_dialog_append_page (GtkNotebook *notebook,
1235 /* Append page and set attributes */
1236 index = gtk_notebook_append_page (notebook, page, gtk_label_new (label));
1237 gtk_container_child_set (GTK_CONTAINER (notebook), page,
1238 "tab-expand", TRUE, "tab-fill", TRUE,
1240 gtk_widget_show (page);
1244 init_user_page (ModestEasysetupWizardDialogPrivate *priv)
1246 priv->page_user_details = NULL;
1247 priv->entry_user_name = NULL;
1248 priv->entry_user_username = NULL;
1249 priv->entry_user_password = NULL;
1250 priv->entry_user_email = NULL;
1254 init_incoming_page (ModestEasysetupWizardDialogPrivate *priv)
1256 priv->page_custom_incoming = NULL;
1257 priv->incoming_servertype_picker = NULL;
1258 priv->caption_incoming = NULL;
1259 priv->entry_incomingserver = NULL;
1260 priv->entry_user_email = NULL;
1261 priv->incoming_security = NULL;
1265 init_outgoing_page (ModestEasysetupWizardDialogPrivate *priv)
1267 priv->page_custom_outgoing = NULL;
1268 priv->entry_outgoingserver = NULL;
1269 priv->checkbox_outgoing_smtp_specific = NULL;
1270 priv->button_outgoing_smtp_servers = NULL;
1271 priv->outgoing_security = NULL;
1275 modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
1277 gtk_container_set_border_width (GTK_CONTAINER (self), MODEST_MARGIN_HALF);
1279 /* Create the notebook to be used by the ModestWizardDialog base class:
1280 * Each page of the notebook will be a page of the wizard: */
1281 GtkNotebook *notebook = GTK_NOTEBOOK (gtk_notebook_new());
1282 gtk_widget_set_size_request (GTK_WIDGET (notebook), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
1284 /* Set the notebook used by the ModestWizardDialog base class: */
1285 g_object_set (G_OBJECT(self), "wizard-notebook", notebook, NULL);
1287 /* Set the wizard title:
1288 * The actual window title will be a combination of this and the page's tab label title. */
1289 g_object_set (G_OBJECT(self), "wizard-name", _("mcen_ti_emailsetup"), NULL);
1291 /* Read in the information about known service providers: */
1292 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1294 /* The server fields did not have been manually changed yet */
1295 priv->server_changes = 0;
1296 priv->pending_load_settings = TRUE;
1298 /* Get the account manager object,
1299 * so we can check for existing accounts,
1300 * and create new accounts: */
1301 priv->account_manager = modest_runtime_get_account_mgr ();
1302 g_object_ref (priv->account_manager);
1304 /* Initialize fields */
1305 priv->check_support_done = FALSE;
1306 priv->check_support_show_progress_id = 0;
1307 priv->check_support_progress_pulse_id = 0;
1308 priv->pending_check_support = 0;
1309 priv->destroyed = FALSE;
1310 priv->page_welcome = create_page_welcome (self);
1311 priv->page_account_details = create_page_account_details (self);
1313 init_user_page (priv);
1314 init_incoming_page (priv);
1315 init_outgoing_page (priv);
1317 priv->page_complete_easysetup = NULL;
1318 priv->page_complete_customsetup = NULL;
1319 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1320 priv->missing_data_signals = NULL;
1322 /* Add the common pages */
1323 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_welcome,
1324 _("mcen_ti_emailsetup_welcome"));
1325 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_account_details,
1326 _("mcen_ti_accountdetails"));
1328 /* Connect to the dialog's response signal so we can enable/disable buttons
1329 * for the newly-selected page, because the prev/next buttons cause response to be emitted.
1330 * Note that we use g_signal_connect_after() instead of g_signal_connect()
1331 * so that we can be enable/disable after ModestWizardDialog has done its own
1332 * enabling/disabling of buttons.
1334 * HOWEVER, this doesn't work because ModestWizardDialog's response signal handler
1335 * does g_signal_stop_emission_by_name(), stopping our signal handler from running.
1337 * It's not enough to connect to the notebook's switch-page signal, because
1338 * ModestWizardDialog's "response" signal handler enables the buttons itself,
1339 * _after_ switching the page (understandably).
1340 * (Note that if we had, if we used g_signal_connect() instead of g_signal_connect_after()
1341 * then gtk_notebook_get_current_page() would return an incorrect value.)
1343 g_signal_connect_after (G_OBJECT (self), "response",
1344 G_CALLBACK (on_response), self);
1346 /* This is to show a confirmation dialog when the user hits cancel */
1347 g_signal_connect (G_OBJECT (self), "response",
1348 G_CALLBACK (on_response_before), self);
1350 g_signal_connect (G_OBJECT (self), "delete-event",
1351 G_CALLBACK (on_delete_event), self);
1353 /* Reset dirty, because there was no user input until now */
1354 priv->dirty = FALSE;
1356 /* When this window is shown, hibernation should not be possible,
1357 * because there is no sensible way to save the state: */
1358 modest_window_mgr_prevent_hibernation_while_window_is_shown (
1359 modest_runtime_get_window_mgr (), GTK_WINDOW (self));
1361 /* Load provider presets */
1362 g_object_ref (self);
1363 g_thread_create (presets_loader, self, FALSE, NULL);
1365 priv->settings = modest_account_settings_new ();
1367 check_support_of_protocols (self);
1370 ModestEasysetupWizardDialog*
1371 modest_easysetup_wizard_dialog_new (void)
1374 return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
1378 create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
1380 ModestEasysetupWizardDialogPrivate *priv;
1381 GtkNotebook *notebook = NULL;
1383 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1386 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1388 if (!priv->page_user_details) {
1389 priv->page_user_details = create_page_user_details (self);
1392 /* Create the custom pages: */
1393 if(!(priv->page_custom_incoming)) {
1394 priv->page_custom_incoming = create_page_custom_incoming (self);
1397 /* TODO: only if needed */
1398 if(!(priv->page_custom_outgoing)) {
1399 priv->page_custom_outgoing = create_page_custom_outgoing (self);
1402 if(!(priv->page_complete_customsetup)) {
1403 priv->page_complete_customsetup = create_page_complete_custom (self);
1406 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_user_details)))
1407 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_user_details,
1408 _("mcen_ti_emailsetup_userdetails"));
1410 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_incoming)))
1411 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_incoming,
1412 _("mcen_ti_emailsetup_incomingdetails"));
1414 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_outgoing)))
1415 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_outgoing,
1416 _("mcen_ti_emailsetup_outgoingdetails"));
1418 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_customsetup)))
1419 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_customsetup,
1420 _("mcen_ti_emailsetup_complete"));
1422 /* This is unnecessary with GTK+ 2.10: */
1423 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1427 create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self)
1429 ModestEasysetupWizardDialogPrivate *priv;
1430 GtkNotebook *notebook = NULL;
1432 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1435 /* Create the easysetup-specific pages: */
1436 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1437 if(!priv->page_complete_easysetup)
1438 priv->page_complete_easysetup = create_page_complete_easysetup (self);
1440 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_easysetup)))
1441 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_easysetup,
1442 _("mcen_ti_emailsetup_complete"));
1444 /* This is unnecessary with GTK+ 2.10: */
1445 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1450 remove_non_common_tabs (GtkNotebook *notebook,
1451 gboolean remove_user_details)
1454 /* The first 2 tabs are the common ones (welcome tab and the
1455 providers tab), so we always remove starting from the
1458 starting_tab = (remove_user_details) ? 2 : 3;
1459 while (gtk_notebook_get_n_pages (notebook) > starting_tab)
1460 gtk_notebook_remove_page (notebook, -1);
1464 on_missing_mandatory_data (ModestAccountProtocol *protocol,
1468 real_enable_buttons (MODEST_WIZARD_DIALOG (user_data), !missing);
1471 /* After the user details page,
1472 * the following pages depend on whether "Other" was chosen
1473 * in the provider combobox on the account page
1476 create_subsequent_pages (ModestEasysetupWizardDialog *self)
1478 ModestEasysetupWizardDialogPrivate *priv;
1479 ModestProviderPicker *picker;
1480 ModestProviderPickerIdType id_type;
1481 GtkNotebook *notebook;
1483 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1484 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1485 id_type = modest_provider_picker_get_active_id_type (picker);
1486 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1487 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1491 if (id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
1492 /* "Other..." was selected: */
1494 /* If we come from a rollbacked easysetup */
1495 if (priv->page_complete_easysetup) {
1496 remove_non_common_tabs (notebook, FALSE);
1497 priv->page_complete_easysetup = NULL;
1500 /* If we come from a rollbacked plugin protocol setup */
1501 if (priv->last_plugin_protocol_selected != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1502 remove_non_common_tabs (notebook, TRUE);
1503 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1504 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1505 priv->missing_data_signals = NULL;
1508 create_subsequent_customsetup_pages (self);
1510 /* If we come from a rollbacked custom setup */
1511 if (priv->page_custom_incoming) {
1512 remove_non_common_tabs (notebook, TRUE);
1513 init_user_page (priv);
1514 init_incoming_page (priv);
1515 init_outgoing_page (priv);
1516 init_user_page (priv);
1517 priv->page_complete_customsetup = NULL;
1520 /* It's a pluggable protocol and not a provider with presets */
1521 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1522 ModestProtocol *protocol;
1524 ModestProtocolType proto_type;
1527 /* If we come from a rollbacked easy setup */
1528 if (priv->last_plugin_protocol_selected ==
1529 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID &&
1530 priv->page_complete_easysetup) {
1531 remove_non_common_tabs (notebook, TRUE);
1532 init_user_page (priv);
1533 priv->page_complete_easysetup = NULL;
1536 proto_name = modest_provider_picker_get_active_provider_id (picker);
1537 protocol = modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
1538 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
1540 proto_type = modest_protocol_get_type_id (protocol);
1542 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
1543 proto_type != priv->last_plugin_protocol_selected) {
1544 ModestPairList *tabs;
1546 gboolean first_page = TRUE;
1547 ModestWizardDialogResponseOverrideFunc response_override;
1549 /* Remember the last selected plugin protocol */
1550 priv->last_plugin_protocol_selected = proto_type;
1553 tabs = modest_account_protocol_get_easysetupwizard_tabs (MODEST_ACCOUNT_PROTOCOL (protocol));
1554 response_override = modest_account_protocol_get_wizard_response_override
1555 (MODEST_ACCOUNT_PROTOCOL (protocol));
1556 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1558 tmp = (GSList *) tabs;
1560 ModestPair *pair = (ModestPair *) tmp->data;
1561 modest_easysetup_wizard_dialog_append_page (notebook,
1562 GTK_WIDGET (pair->second),
1563 (const gchar *) pair->first);
1565 gtk_container_set_focus_child (GTK_CONTAINER (notebook),
1566 GTK_WIDGET (pair->second));
1570 /* Connect signals */
1571 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (pair->second)) {
1572 priv->missing_data_signals =
1573 modest_signal_mgr_connect (priv->missing_data_signals,
1574 G_OBJECT (pair->second),
1575 "missing-mandatory-data",
1576 G_CALLBACK (on_missing_mandatory_data),
1580 g_free (pair->first);
1581 tmp = g_slist_next (tmp);
1582 /* Critical: if you don't show the page then the dialog will ignore it */
1583 /* gtk_widget_show (GTK_WIDGET (pair->second)); */
1585 modest_pair_list_free (tabs);
1587 g_free (proto_name);
1589 if (priv->last_plugin_protocol_selected !=
1590 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1591 remove_non_common_tabs (notebook, TRUE);
1592 init_user_page (priv);
1593 priv->page_complete_easysetup = NULL;
1594 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1595 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1596 priv->missing_data_signals = NULL;
1598 if (!priv->page_user_details) {
1599 priv->page_user_details = create_page_user_details (self);
1600 modest_easysetup_wizard_dialog_append_page (notebook,
1601 priv->page_user_details,
1602 _("mcen_ti_emailsetup_userdetails"));
1606 /* Create the easysetup pages: */
1607 create_subsequent_easysetup_pages (self);
1613 util_get_default_servername_from_email_address (const gchar* email_address, ModestProtocolType protocol_type)
1615 const gchar* hostname = NULL;
1618 ModestProtocolRegistry *protocol_registry;
1619 ModestProtocol *protocol;
1624 at = g_utf8_strchr (email_address, -1, '@');
1625 if (!at || (g_utf8_strlen (at, -1) < 2))
1628 domain = g_utf8_next_char (at);
1632 protocol_registry = modest_runtime_get_protocol_registry ();
1633 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
1635 if (modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS) ||
1636 modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS)) {
1637 hostname = modest_protocol_get_name (protocol);
1643 return g_strdup_printf ("%s.%s", hostname, domain);
1647 set_default_custom_servernames (ModestEasysetupWizardDialog *self)
1649 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1651 if (!priv->entry_incomingserver)
1654 /* Set a default domain for the server, based on the email address,
1655 * if no server name was already specified.
1657 if (priv->entry_user_email
1658 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED) == 0)) {
1659 const ModestProtocolType protocol_type = modest_servertype_picker_get_active_servertype (
1660 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
1662 /* This could happen when the combo box has still no active iter */
1663 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1664 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1665 gchar* servername = util_get_default_servername_from_email_address (email_address,
1668 /* Do not set the INCOMING_CHANGED flag because of this edit */
1669 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1670 hildon_entry_set_text (HILDON_ENTRY (priv->entry_incomingserver), servername);
1671 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1673 g_free (servername);
1677 /* Set a default domain for the server, based on the email address,
1678 * if no server name was already specified.
1680 if (!priv->entry_outgoingserver)
1683 if (priv->entry_user_email
1684 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED) == 0)) {
1685 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1687 gchar* servername = util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOLS_TRANSPORT_SMTP);
1689 /* Do not set the OUTGOING_CHANGED flag because of this edit */
1690 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1691 hildon_entry_set_text (HILDON_ENTRY (priv->entry_outgoingserver), servername);
1692 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1694 g_free (servername);
1699 get_entered_account_title (ModestEasysetupWizardDialog *self)
1701 ModestEasysetupWizardDialogPrivate *priv;
1702 const gchar* account_title;
1704 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1705 account_title = hildon_entry_get_text (HILDON_ENTRY (priv->entry_account_title));
1707 if (!account_title || (g_utf8_strlen (account_title, -1) == 0)) {
1710 /* Strip it of whitespace at the start and end: */
1711 gchar *result = g_strdup (account_title);
1712 result = g_strstrip (result);
1717 if (g_utf8_strlen (result, -1) == 0) {
1727 on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *next_page)
1729 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1730 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1731 ModestProtocolRegistry *protocol_registry;
1733 protocol_registry = modest_runtime_get_protocol_registry ();
1735 /* if are browsing pages previous to the last one, then we have pending settings in
1737 if (next_page != NULL)
1738 priv->pending_load_settings = TRUE;
1740 /* Do extra validation that couldn't be done for every key press,
1741 * either because it was too slow,
1742 * or because it requires interaction:
1744 if (current_page == priv->page_account_details) {
1745 /* Check that the title is not already in use: */
1746 gchar* account_title = get_entered_account_title (self);
1750 /* Aavoid a clash with an existing display name: */
1751 const gboolean name_in_use = modest_account_mgr_account_with_display_name_exists (
1752 priv->account_manager, account_title);
1753 g_free (account_title);
1756 /* Warn the user via a dialog: */
1757 hildon_banner_show_information(NULL, NULL, _("mail_ib_account_name_already_existing"));
1762 /* Make sure that the subsequent pages are appropriate for the provider choice. */
1763 create_subsequent_pages (self);
1765 } else if (current_page == priv->page_user_details) {
1766 /* Check that the email address is valud: */
1767 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
1768 if ((!email_address) || (g_utf8_strlen (email_address, -1) == 0))
1771 if (!modest_text_utils_validate_email_address (email_address, NULL)) {
1772 /* Warn the user via a dialog: */
1773 hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email"));
1775 /* Return focus to the email address entry: */
1776 gtk_widget_grab_focus (priv->entry_user_email);
1777 gtk_editable_select_region (GTK_EDITABLE (priv->entry_user_email), 0, -1);
1783 if (next_page == priv->page_custom_incoming) {
1784 set_default_custom_servernames (self);
1785 } else if (next_page == priv->page_custom_outgoing) {
1786 set_default_custom_servernames (self);
1788 /* Check if the server supports secure authentication */
1789 if (modest_security_options_view_auth_check (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security)))
1790 if (!check_has_supported_auth_methods (self))
1792 gtk_widget_show (priv->outgoing_security);
1795 /* If this is the last page, and this is a click on Finish,
1796 * then attempt to create the dialog.
1799 current_page != priv->page_account_details) /* This is NULL when this is a click on Finish. */
1801 if (priv->pending_load_settings) {
1802 save_to_settings (self);
1805 /* We check if there's already another account with the same configuration */
1806 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
1807 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
1811 modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
1818 static gboolean entry_is_empty (GtkWidget *entry)
1823 const gchar* text = hildon_entry_get_text (HILDON_ENTRY (entry));
1824 if ((!text) || (g_utf8_strlen (text, -1) == 0))
1827 /* Strip it of whitespace at the start and end: */
1828 gchar *stripped = g_strdup (text);
1829 stripped = g_strstrip (stripped);
1834 const gboolean result = (g_utf8_strlen (stripped, -1) == 0);
1842 real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next)
1844 GtkNotebook *notebook = NULL;
1845 gboolean is_finish_tab;
1847 ModestEasysetupWizardDialogPrivate *priv;
1850 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (dialog);
1851 g_object_get (dialog, "wizard-notebook", ¬ebook, NULL);
1853 /* Disable the Finish button until we are on the last page,
1854 * because HildonWizardDialog enables this for all but the
1856 current = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
1857 is_finish_tab = ((current == priv->page_complete_easysetup) ||
1858 (current == priv->page_complete_customsetup));
1860 if (is_finish_tab) {
1861 /* Disable Next on the last page no matter what the
1863 enable_next = FALSE;
1865 /* Not the last one */
1866 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1867 MODEST_WIZARD_DIALOG_FINISH,
1870 /* If the check support is not done then do not enable
1871 the wizard to continue */
1872 enable_next = enable_next && priv->check_support_done;
1875 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1876 MODEST_WIZARD_DIALOG_NEXT,
1881 on_enable_buttons (ModestWizardDialog *dialog, GtkWidget *current_page)
1883 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1884 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1886 gboolean enable_next = TRUE;
1887 if (current_page == priv->page_welcome) {
1889 } else if (current_page == priv->page_account_details) {
1890 /* The account details title is mandatory: */
1891 if (entry_is_empty(priv->entry_account_title))
1892 enable_next = FALSE;
1893 } else if (current_page == priv->page_user_details) {
1894 /* The user details username is mandatory: */
1895 if (entry_is_empty(priv->entry_user_username))
1896 enable_next = FALSE;
1898 /* The user details email address is mandatory: */
1899 if (enable_next && entry_is_empty (priv->entry_user_email))
1900 enable_next = FALSE;
1901 } else if (current_page == priv->page_custom_incoming) {
1902 /* The custom incoming server is mandatory: */
1903 if (entry_is_empty(priv->entry_incomingserver))
1904 enable_next = FALSE;
1905 } else if (MODEST_IS_EASYSETUP_WIZARD_PAGE (current_page)) {
1906 enable_next = !modest_easysetup_wizard_page_validate (
1907 MODEST_EASYSETUP_WIZARD_PAGE (current_page));
1910 /* Enable/disable buttons */
1911 real_enable_buttons (dialog, enable_next);
1915 modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *klass)
1917 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1918 g_type_class_add_private (klass, sizeof (ModestEasysetupWizardDialogPrivate));
1921 object_class->dispose = modest_easysetup_wizard_dialog_dispose;
1922 object_class->finalize = modest_easysetup_wizard_dialog_finalize;
1924 /* Provide a vfunc implementation so we can decide
1925 * when to enable/disable the prev/next buttons.
1927 ModestWizardDialogClass *base_klass = (ModestWizardDialogClass*)(klass);
1928 base_klass->before_next = on_before_next;
1929 base_klass->enable_buttons = on_enable_buttons;
1930 base_klass->update_model = on_update_model;
1931 base_klass->save = on_save;
1936 * @self: a #ModestEasysetupWizardDialog
1938 * takes information from all the wizard and stores it in settings
1941 save_to_settings (ModestEasysetupWizardDialog *self)
1943 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1945 gchar *provider_id = NULL;
1946 gchar* display_name;
1947 const gchar *username, *password;
1948 gchar *store_hostname, *transport_hostname;
1949 guint store_port, transport_port;
1950 ModestProtocolRegistry *protocol_registry;
1951 ModestProtocolType store_protocol, transport_protocol;
1952 ModestProtocolType store_security, transport_security;
1953 ModestProtocolType store_auth_protocol, transport_auth_protocol;
1954 ModestServerAccountSettings *store_settings, *transport_settings;
1955 const gchar *fullname, *email_address;
1956 ModestProviderPicker *picker;
1957 ModestProviderPickerIdType id_type;
1959 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1960 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1961 protocol_registry = modest_runtime_get_protocol_registry ();
1963 /* Get details from the specified presets: */
1964 id_type = modest_provider_picker_get_active_id_type (picker);
1965 provider_id = modest_provider_picker_get_active_provider_id (picker);
1967 /* Let the plugin save the settings. We do a return in order
1968 to save an indentation level */
1969 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1970 ModestProtocol *protocol;
1972 protocol = modest_protocol_registry_get_protocol_by_name (
1973 modest_runtime_get_protocol_registry (),
1974 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
1977 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
1978 gint n_pages, i = 0;
1979 GtkNotebook *notebook;
1980 GList *wizard_pages = NULL;
1982 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1983 n_pages = gtk_notebook_get_n_pages (notebook);
1984 for (i = 0; i < n_pages; i++) {
1985 GtkWidget *page = gtk_notebook_get_nth_page (notebook, i);
1986 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (page))
1987 wizard_pages = g_list_append (wizard_pages, page);
1989 modest_account_protocol_save_wizard_settings (MODEST_ACCOUNT_PROTOCOL (protocol),
1992 g_list_free (wizard_pages);
1994 g_warning ("The selected protocol is a plugin protocol "//
1995 "but it's not a ModestAccountProtocol");
1998 g_free (provider_id);
2002 /* username and password (for both incoming and outgoing): */
2003 username = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_username));
2004 password = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_password));
2006 store_settings = modest_account_settings_get_store_settings (priv->settings);
2007 transport_settings = modest_account_settings_get_transport_settings (priv->settings);
2009 /* Incoming server: */
2010 /* Note: We need something as default for the transport store protocol values,
2011 * or modest_account_mgr_add_server_account will fail. */
2013 store_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2014 store_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2015 store_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2018 ModestProtocolType store_provider_server_type;
2019 gboolean store_provider_use_alternate_port;
2021 store_hostname = modest_presets_get_server (priv->presets, provider_id,
2024 store_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2027 store_security = modest_presets_get_info_server_security (priv->presets,
2030 store_auth_protocol = modest_presets_get_info_server_auth (priv->presets,
2033 store_provider_use_alternate_port = modest_presets_get_info_server_use_alternate_port (priv->presets,
2037 /* We don't check for SMTP here as that is impossible for an incoming server. */
2038 if (store_provider_server_type == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID)
2039 store_protocol = MODEST_PROTOCOLS_STORE_POP;
2041 store_protocol = store_provider_server_type;
2043 /* we check if there is a *special* port */
2044 special_port = modest_presets_get_port (priv->presets, provider_id, TRUE /* incoming */);
2045 if (special_port != 0) {
2046 store_port = special_port;
2048 gboolean use_alternate_port = FALSE;
2049 if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (),
2051 use_alternate_port = TRUE;
2052 store_port = get_port_from_protocol(store_provider_server_type, use_alternate_port);
2055 modest_server_account_settings_set_security_protocol (store_settings,
2057 modest_server_account_settings_set_auth_protocol (store_settings,
2058 store_auth_protocol);
2059 if (store_port != 0)
2060 modest_server_account_settings_set_port (store_settings, store_port);
2062 /* Use custom pages because no preset was specified: */
2063 store_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_incomingserver) ));
2064 store_protocol = modest_servertype_picker_get_active_servertype (
2065 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2067 modest_security_options_view_save_settings (
2068 MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
2072 /* now we store the common store account settings */
2073 modest_server_account_settings_set_hostname (store_settings, store_hostname);
2074 modest_server_account_settings_set_username (store_settings, username);
2075 modest_server_account_settings_set_password (store_settings, password);
2076 modest_server_account_settings_set_protocol (store_settings, store_protocol);
2078 g_object_unref (store_settings);
2079 g_free (store_hostname);
2081 /* Outgoing server: */
2082 transport_hostname = NULL;
2083 transport_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2084 transport_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2085 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2089 ModestProtocolType transport_provider_server_type;
2090 ModestProtocolType transport_provider_security;
2093 transport_hostname = modest_presets_get_server (priv->presets, provider_id,
2094 FALSE /* transport */);
2096 transport_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2098 FALSE /* transport */);
2099 transport_provider_security = modest_presets_get_info_server_security (priv->presets,
2101 FALSE /* transport */);
2103 /* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
2104 transport_protocol = transport_provider_server_type;
2105 transport_security = transport_provider_security;
2106 if (transport_security == MODEST_PROTOCOLS_CONNECTION_SSL) {
2107 /* printf("DEBUG: %s: using secure SMTP\n", __FUNCTION__); */
2108 /* we check if there is a *special* port */
2109 special_port = modest_presets_get_port (priv->presets, provider_id,
2110 FALSE /* transport */);
2111 if (special_port != 0)
2112 transport_port = special_port;
2114 transport_port = 465;
2115 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_PASSWORD;
2117 /* printf("DEBUG: %s: using non-secure SMTP\n", __FUNCTION__); */
2118 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2121 modest_server_account_settings_set_security_protocol (transport_settings,
2122 transport_security);
2123 modest_server_account_settings_set_auth_protocol (transport_settings,
2124 transport_auth_protocol);
2125 if (transport_port != 0)
2126 modest_server_account_settings_set_port (transport_settings,
2129 ModestProtocolRegistry *registry;
2130 ModestProtocol *store_proto;
2132 registry = modest_runtime_get_protocol_registry ();
2133 /* Use custom pages because no preset was specified: */
2134 transport_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver) ));
2136 store_proto = modest_protocol_registry_get_protocol_by_type (registry,
2139 if (transport_protocol == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
2140 /* fallback to SMTP if none was specified */
2141 g_warning ("No transport protocol was specified for store %d (%s)",
2142 modest_protocol_get_type_id (store_proto),
2143 modest_protocol_get_display_name (store_proto));
2144 transport_protocol = MODEST_PROTOCOLS_TRANSPORT_SMTP;
2147 modest_security_options_view_save_settings (
2148 MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security),
2152 /* now we store the common transport account settings */
2153 modest_server_account_settings_set_hostname (transport_settings, transport_hostname);
2154 modest_server_account_settings_set_username (transport_settings, username);
2155 modest_server_account_settings_set_password (transport_settings, password);
2156 modest_server_account_settings_set_protocol (transport_settings, transport_protocol);
2158 g_object_unref (transport_settings);
2159 g_free (transport_hostname);
2161 fullname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_name));
2162 email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
2163 modest_account_settings_set_fullname (priv->settings, fullname);
2164 modest_account_settings_set_email_address (priv->settings, email_address);
2165 /* we don't set retrieve type to preserve advanced settings if
2166 any. By default account settings are set to headers only */
2168 /* Save the connection-specific SMTP server accounts. */
2169 if (priv->checkbox_outgoing_smtp_specific) {
2170 modest_account_settings_set_use_connection_specific_smtp
2172 hildon_check_button_get_active(HILDON_CHECK_BUTTON(priv->checkbox_outgoing_smtp_specific)));
2175 display_name = get_entered_account_title (self);
2176 modest_account_settings_set_display_name (priv->settings, display_name);
2177 g_free (display_name);
2178 g_free (provider_id);
2183 on_update_model (ModestWizardDialog *dialog)
2185 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2186 save_to_settings (self);
2191 on_save (ModestWizardDialog *dialog)
2193 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2194 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2196 save_to_settings (self);
2198 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
2199 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
2203 return modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
2209 check_for_supported_auth_methods (ModestEasysetupWizardDialog* self)
2211 GError *error = NULL;
2212 ModestProtocolType protocol_type;
2213 const gchar* hostname;
2214 const gchar* username;
2215 ModestProtocolType security_protocol_incoming_type;
2216 ModestProtocolRegistry *registry;
2218 GList *list_auth_methods;
2219 ModestEasysetupWizardDialogPrivate *priv;
2221 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2222 registry = modest_runtime_get_protocol_registry ();
2223 protocol_type = modest_servertype_picker_get_active_servertype (
2224 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2225 hostname = gtk_entry_get_text(GTK_ENTRY(priv->entry_incomingserver));
2226 username = gtk_entry_get_text(GTK_ENTRY(priv->entry_user_username));
2227 security_protocol_incoming_type = modest_security_options_view_get_connection_protocol
2228 (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security));
2229 port_num = get_port_from_protocol(protocol_type, FALSE);
2230 list_auth_methods = modest_utils_get_supported_secure_authentication_methods (protocol_type, hostname, port_num,
2231 username, GTK_WINDOW (self), &error);
2233 if (list_auth_methods) {
2234 /* TODO: Select the correct method */
2237 for (method = list_auth_methods; method != NULL; method = g_list_next(method)) {
2238 ModestProtocolType auth_protocol_type = (ModestProtocolType) (GPOINTER_TO_INT(method->data));
2239 if (modest_protocol_registry_protocol_type_has_tag (registry, auth_protocol_type,
2240 MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS)) {
2241 list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type));
2245 g_list_free(list_auth_methods);
2251 if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
2252 error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
2254 modest_platform_information_banner (GTK_WIDGET(self), NULL,
2255 _("mcen_ib_unableto_discover_auth_methods"));
2259 g_error_free(error);
2265 check_has_supported_auth_methods(ModestEasysetupWizardDialog* self)
2267 GList* methods = check_for_supported_auth_methods(self);
2273 g_list_free(methods);
2278 check_support_progress_pulse (gpointer userdata)
2280 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2281 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2283 if (priv->destroyed) {
2284 priv->check_support_progress_pulse_id = 0;
2288 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2294 check_support_show_progress (gpointer userdata)
2296 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2297 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2299 priv->check_support_show_progress_id = 0;
2301 if (priv->destroyed)
2304 gtk_widget_show (priv->check_support_progress);
2305 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2307 priv->check_support_progress_pulse_id = g_timeout_add (200, check_support_progress_pulse, self);
2313 check_support_callback (ModestAccountProtocol *protocol,
2317 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2318 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2320 priv->pending_check_support --;
2322 if (priv->check_support_show_progress_id > 0) {
2323 g_source_remove (priv->check_support_show_progress_id);
2324 priv->check_support_show_progress_id = 0;
2327 if (priv->check_support_progress_pulse_id > 0) {
2328 g_source_remove (priv->check_support_progress_pulse_id);
2329 priv->check_support_progress_pulse_id = 0;
2332 if (priv->pending_check_support == 0) {
2333 priv->check_support_done = TRUE;
2335 if (!priv->destroyed) {
2337 fill_providers (self);
2338 gtk_widget_hide (priv->check_support_progress);
2339 invoke_enable_buttons_vfunc (self);
2342 g_object_unref (self);
2347 check_support_of_protocols (ModestEasysetupWizardDialog *self)
2349 ModestProtocolRegistry *registry;
2350 GSList *provider_protos, *node;
2351 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2353 registry = modest_runtime_get_protocol_registry ();
2354 provider_protos = modest_protocol_registry_get_by_tag (registry,
2355 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS);
2357 for (node = provider_protos; node != NULL; node = g_slist_next (node)) {
2358 ModestProtocol *proto = MODEST_PROTOCOL (node->data);
2360 if (!modest_protocol_registry_protocol_type_has_tag (registry,
2361 modest_protocol_get_type_id (proto),
2362 MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS))
2365 if (modest_protocol_registry_protocol_type_has_tag
2367 modest_protocol_get_type_id (proto),
2368 MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS)) {
2369 /* Check if there's already an account configured with this account type */
2370 if (modest_account_mgr_singleton_protocol_exists (modest_runtime_get_account_mgr (),
2371 modest_protocol_get_type_id (proto)))
2375 if (MODEST_ACCOUNT_PROTOCOL (proto)) {
2376 priv->pending_check_support ++;
2377 modest_account_protocol_check_support (MODEST_ACCOUNT_PROTOCOL (proto),
2378 check_support_callback,
2379 g_object_ref (self));
2382 g_slist_free (provider_protos);
2384 if (priv->pending_check_support > 0) {
2385 priv->check_support_show_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 1000,
2386 check_support_show_progress,
2387 g_object_ref (self), g_object_unref);
2389 priv->check_support_done = TRUE;
2391 invoke_enable_buttons_vfunc (self);