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_widget_set_size_request (label, LABELS_WIDTH, -1);
474 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, MODEST_MARGIN_HALF);
475 gtk_widget_show (label);
477 /* Create a size group to be used by all captions.
478 * Note that HildonCaption does not create a default size group if we do not specify one.
479 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
480 GtkSizeGroup* title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
481 GtkSizeGroup* value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
483 /* The country widgets: */
484 priv->account_country_picker = GTK_WIDGET (modest_country_picker_new (MODEST_EDITABLE_SIZE,
485 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
486 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
487 _("mcen_fi_country"), priv->account_country_picker);
488 g_signal_connect (G_OBJECT (priv->account_country_picker), "value-changed",
489 G_CALLBACK (on_picker_button_value_changed), self);
490 gtk_box_pack_start (GTK_BOX (box), priv->account_country_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
491 gtk_widget_show (priv->account_country_picker);
493 GtkWidget *separator = gtk_hseparator_new ();
494 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
495 gtk_widget_show (separator);
497 /* The service provider widgets: */
498 priv->account_serviceprovider_picker = GTK_WIDGET (modest_provider_picker_new (MODEST_EDITABLE_SIZE,
499 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
500 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
501 _("mcen_fi_serviceprovider"),
502 priv->account_serviceprovider_picker);
503 g_signal_connect (G_OBJECT (priv->account_serviceprovider_picker), "value-changed",
504 G_CALLBACK (on_serviceprovider_picker_button_value_changed), self);
505 gtk_box_pack_start (GTK_BOX (box), priv->account_serviceprovider_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
506 gtk_widget_show (priv->account_serviceprovider_picker);
508 /* The description widgets: */
509 priv->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
510 g_signal_connect(G_OBJECT(priv->entry_account_title), "changed",
511 G_CALLBACK(on_easysetup_changed), self);
512 /* Do use auto-capitalization: */
513 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_account_title),
514 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
516 /* Set a default account title, choosing one that does not already exist: */
517 /* Note that this is irrelevant to the non-user visible name, which we will create later. */
518 gchar* default_account_name_start = g_strdup (_("mcen_ia_emailsetup_defaultname"));
519 gchar* default_account_name = modest_account_mgr_get_unused_account_display_name (
520 priv->account_manager, default_account_name_start);
521 g_free (default_account_name_start);
522 default_account_name_start = NULL;
524 hildon_entry_set_text (HILDON_ENTRY (priv->entry_account_title), default_account_name);
525 g_free (default_account_name);
526 default_account_name = NULL;
528 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mcen_fi_account_title"), FALSE,
529 priv->entry_account_title);
530 gtk_widget_show (priv->entry_account_title);
531 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
532 gtk_widget_show (caption);
534 /* Prevent the use of some characters in the account title,
535 * as required by our UI specification: */
536 GList *list_prevent = NULL;
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, "*");
541 list_prevent = g_list_append (list_prevent, "?");
542 list_prevent = g_list_append (list_prevent, "\""); /* The UI spec mentions “, but maybe means ", maybe both. */
543 list_prevent = g_list_append (list_prevent, "“");
544 list_prevent = g_list_append (list_prevent, "<");
545 list_prevent = g_list_append (list_prevent, ">");
546 list_prevent = g_list_append (list_prevent, "|");
547 list_prevent = g_list_append (list_prevent, "^");
548 modest_validating_entry_set_unallowed_characters (
549 MODEST_VALIDATING_ENTRY (priv->entry_account_title), list_prevent);
550 g_list_free (list_prevent);
552 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
553 modest_utils_on_entry_invalid_character, self);
555 /* Set max length as in the UI spec:
556 * The UI spec seems to want us to show a dialog if we hit the maximum. */
557 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_account_title), 64);
558 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_account_title),
561 gtk_widget_show (GTK_WIDGET (box));
563 g_object_unref (title_sizegroup);
564 g_object_unref (value_sizegroup);
566 return GTK_WIDGET (box);
570 create_page_user_details (ModestEasysetupWizardDialog *self)
572 GtkSizeGroup* title_sizegroup;
573 GtkSizeGroup* value_sizegroup;
575 ModestEasysetupWizardDialogPrivate *priv;
577 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
579 /* Create a size group to be used by all captions.
580 * Note that HildonCaption does not create a default size group if we do not specify one.
581 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
582 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
583 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
584 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
586 /* The name widgets: (use auto cap) */
587 priv->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
588 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_name),
589 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
591 /* Set max length as in the UI spec:
592 * The UI spec seems to want us to show a dialog if we hit the maximum. */
593 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_name), 64);
594 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_name),
596 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
597 _("mcen_li_emailsetup_name"), FALSE, priv->entry_user_name);
598 g_signal_connect(G_OBJECT(priv->entry_user_name), "changed",
599 G_CALLBACK(on_easysetup_changed), self);
600 gtk_widget_show (priv->entry_user_name);
601 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
602 gtk_widget_show (caption);
604 /* Prevent the use of some characters in the name,
605 * as required by our UI specification: */
606 GList *list_prevent = NULL;
607 list_prevent = g_list_append (list_prevent, "<");
608 list_prevent = g_list_append (list_prevent, ">");
609 modest_validating_entry_set_unallowed_characters (
610 MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
611 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
612 modest_utils_on_entry_invalid_character, self);
613 g_list_free (list_prevent);
615 /* The username widgets: */
616 priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
617 /* Auto-capitalization is the default, so let's turn it off: */
618 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username),
619 HILDON_GTK_INPUT_MODE_FULL);
620 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mail_fi_username"), FALSE,
621 priv->entry_user_username);
622 gtk_widget_show (priv->entry_user_username);
623 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
624 g_signal_connect(G_OBJECT(priv->entry_user_username), "changed",
625 G_CALLBACK(on_easysetup_changed), self);
626 gtk_widget_show (caption);
628 /* Prevent the use of some characters in the username,
629 * as required by our UI specification: */
630 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_username),
631 modest_utils_on_entry_invalid_character, self);
633 /* Set max length as in the UI spec:
634 * The UI spec seems to want us to show a dialog if we hit the maximum. */
635 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
636 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_username),
639 /* The password widgets: */
640 priv->entry_user_password = hildon_entry_new (MODEST_EDITABLE_SIZE);
641 /* Auto-capitalization is the default, so let's turn it off: */
642 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password),
643 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
644 gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
645 /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
646 caption = create_captioned (self, title_sizegroup, value_sizegroup,
647 _("mail_fi_password"), FALSE, priv->entry_user_password);
648 g_signal_connect(G_OBJECT(priv->entry_user_password), "changed",
649 G_CALLBACK(on_easysetup_changed), self);
650 gtk_widget_show (priv->entry_user_password);
651 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
652 gtk_widget_show (caption);
654 /* The email address widgets: */
655 priv->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
656 /* Auto-capitalization is the default, so let's turn it off: */
657 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
658 caption = create_captioned (self, title_sizegroup, value_sizegroup,
659 _("mcen_li_emailsetup_email_address"), FALSE, priv->entry_user_email);
660 update_user_email_from_provider (self);
661 gtk_widget_show (priv->entry_user_email);
662 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
663 g_signal_connect(G_OBJECT(priv->entry_user_email), "changed",
664 G_CALLBACK(on_easysetup_changed), self);
665 gtk_widget_show (caption);
667 /* Set max length as in the UI spec:
668 * The UI spec seems to want us to show a dialog if we hit the maximum. */
669 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_email), 64);
670 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_email),
674 gtk_widget_show (GTK_WIDGET (box));
675 g_object_unref (title_sizegroup);
676 g_object_unref (value_sizegroup);
678 return GTK_WIDGET (box);
682 create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
684 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
686 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
687 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
688 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
689 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
691 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
692 gtk_widget_show (label);
694 label = gtk_label_new (_("mcen_ia_easysetup_complete"));
695 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
696 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
698 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
699 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
700 gtk_widget_show (label);
702 gtk_widget_show (GTK_WIDGET (box));
703 return GTK_WIDGET (box);
706 /** Change the caption title for the incoming server,
707 * as specified in the UI spec:
710 update_incoming_server_title (ModestEasysetupWizardDialog *self)
712 ModestEasysetupWizardDialogPrivate* priv;
713 ModestProtocolType protocol_type;
714 ModestProtocolRegistry *protocol_registry;
716 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
717 protocol_registry = modest_runtime_get_protocol_registry ();
719 protocol_type = modest_servertype_picker_get_active_servertype (
720 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
722 /* This could happen when the combo box has still no active iter */
723 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
724 gchar* incomingserver_title;
725 const gchar *protocol_display_name;
726 ModestProtocol *protocol;
728 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry,
730 protocol_display_name = modest_protocol_get_display_name (protocol);
732 incomingserver_title = g_strconcat (_("mcen_li_emailsetup_servertype"), "\n<small>(",
733 protocol_display_name, ")</small>", NULL);
735 modest_maemo_utils_captioned_set_label (priv->caption_incoming, incomingserver_title, TRUE);
737 g_free(incomingserver_title);
741 /** Change the caption title for the incoming server,
742 * as specified in the UI spec:
745 update_incoming_server_security_choices (ModestEasysetupWizardDialog *self)
747 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
748 ModestServertypePicker *server_type_picker;
749 ModestProtocolType protocol_type;
750 ModestSecurityOptionsView *view;
753 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
755 modest_servertype_picker_get_active_servertype (server_type_picker);
757 /* Fill the combo with appropriately titled choices for all
759 view = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
760 modest_security_options_view_set_server_type (view, protocol_type);
764 on_servertype_selector_changed(HildonTouchSelector *selector, gint column, gpointer user_data)
766 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
767 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
768 ModestServertypePicker *picker;
769 ModestProtocolType protocol_type;
774 update_incoming_server_title (self);
776 /* Update security options if needed */
777 picker = MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
778 protocol_type = modest_servertype_picker_get_active_servertype (picker);
779 update_incoming_server_security_choices (self);
780 gtk_widget_show (priv->incoming_security);
782 set_default_custom_servernames (self);
786 on_entry_incoming_servername_changed(GtkEntry *entry, gpointer user_data)
788 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
789 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
791 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED;
795 create_page_custom_incoming (ModestEasysetupWizardDialog *self)
797 ModestProtocolRegistry *protocol_registry;
798 ModestEasysetupWizardDialogPrivate* priv;
802 GtkSizeGroup *title_sizegroup;
803 GtkSizeGroup *value_sizegroup;
805 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
806 protocol_registry = modest_runtime_get_protocol_registry ();
808 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
809 pannable = hildon_pannable_area_new ();
811 /* Show note that account type cannot be changed in future: */
812 label = gtk_label_new (_("mcen_ia_emailsetup_account_type"));
813 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
814 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
815 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
816 gtk_widget_show (label);
818 /* Create a size group to be used by all captions.
819 * Note that HildonCaption does not create a default size group if we do not specify one.
820 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
821 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
822 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
824 /* The incoming server widgets: */
825 priv->incoming_servertype_picker = GTK_WIDGET (modest_servertype_picker_new (MODEST_EDITABLE_SIZE,
826 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
828 hildon_button_set_title (HILDON_BUTTON (priv->incoming_servertype_picker), _("mcen_li_emailsetup_type"));
829 g_signal_connect (G_OBJECT (priv->incoming_servertype_picker), "value-changed",
830 G_CALLBACK (on_picker_button_value_changed), self);
831 gtk_box_pack_start (GTK_BOX (box), priv->incoming_servertype_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
832 gtk_widget_show (priv->incoming_servertype_picker);
834 priv->entry_incomingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
835 g_signal_connect(G_OBJECT(priv->entry_incomingserver), "changed", G_CALLBACK(on_easysetup_changed), self);
836 /* Auto-capitalization is the default, so let's turn it off: */
837 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
838 set_default_custom_servernames (self);
840 /* The caption title will be updated in update_incoming_server_title().
841 * so this default text will never be seen: */
842 priv->caption_incoming = create_captioned (self, title_sizegroup, value_sizegroup,
843 "This will be removed",
844 FALSE, priv->entry_incomingserver);
845 update_incoming_server_title (self);
846 gtk_widget_show (priv->entry_incomingserver);
847 gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
848 gtk_widget_show (priv->caption_incoming);
850 /* Change the caption title when the servertype changes,
851 * as in the UI spec: */
852 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (priv->incoming_servertype_picker))),
854 G_CALLBACK (on_servertype_selector_changed), self);
856 /* Remember when the servername was changed manually: */
857 g_signal_connect (G_OBJECT (priv->entry_incomingserver), "changed",
858 G_CALLBACK (on_entry_incoming_servername_changed), self);
860 /* The secure connection widgets. These are only valid for
861 protocols with security */
862 priv->incoming_security =
863 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
864 FALSE, title_sizegroup, value_sizegroup);
865 gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
866 FALSE, FALSE, MODEST_MARGIN_HALF);
867 gtk_widget_show_all (priv->incoming_security);
869 /* Set default selection */
870 modest_servertype_picker_set_active_servertype (
871 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker),
872 MODEST_PROTOCOLS_STORE_POP);
874 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), box);
875 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
876 hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pannable)));
877 gtk_widget_show (GTK_WIDGET (box));
878 gtk_widget_show (pannable);
880 g_object_unref (title_sizegroup);
881 g_object_unref (value_sizegroup);
883 return GTK_WIDGET (pannable);
887 on_check_button_changed (HildonCheckButton *button, gpointer user_data)
889 GtkWidget *widget = GTK_WIDGET (user_data);
891 /* Enable the widget only if the check button is active: */
892 const gboolean enable = hildon_check_button_get_active (button);
893 gtk_widget_set_sensitive (widget, enable);
896 /* Make the sensitivity of a widget depend on a check button.
899 enable_widget_for_checkbutton (GtkWidget *widget, HildonCheckButton* button)
901 g_signal_connect (G_OBJECT (button), "toggled",
902 G_CALLBACK (on_check_button_changed), widget);
904 /* Set the starting sensitivity: */
905 on_check_button_changed (button, widget);
909 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
911 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
912 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
913 GtkWidget *specific_window;
915 /* We set dirty here because setting it depending on the connection specific dialog
919 /* Create the window, if necessary: */
920 specific_window = (GtkWidget *) modest_connection_specific_smtp_window_new ();
921 modest_connection_specific_smtp_window_fill_with_connections (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window), priv->account_manager);
923 /* Show the window */
924 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (specific_window), GTK_WINDOW (self));
925 gtk_widget_show (specific_window);
929 on_entry_outgoing_servername_changed (GtkEntry *entry, gpointer user_data)
931 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
932 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
933 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED;
937 create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
939 ModestEasysetupWizardDialogPrivate *priv;
940 gchar *smtp_caption_label;
942 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
944 pannable = hildon_pannable_area_new ();
946 /* Create a size group to be used by all captions.
947 * Note that HildonCaption does not create a default size group if we do not specify one.
948 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
949 GtkSizeGroup *title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
950 GtkSizeGroup *value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
952 /* The outgoing server widgets: */
953 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
954 priv->entry_outgoingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
955 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
956 G_CALLBACK (on_easysetup_changed), self);
957 /* Auto-capitalization is the default, so let's turn it off: */
958 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
959 smtp_caption_label = g_strconcat (_("mcen_li_emailsetup_smtp"), "\n<small>(SMTP)</small>", NULL);
960 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
961 smtp_caption_label, TRUE, priv->entry_outgoingserver);
962 g_free (smtp_caption_label);
963 gtk_widget_show (priv->entry_outgoingserver);
964 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
965 gtk_widget_show (caption);
966 set_default_custom_servernames (self);
968 /* The secure connection widgets. These are only valid for
969 protocols with security */
970 priv->outgoing_security =
971 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
972 FALSE, title_sizegroup, value_sizegroup);
973 gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security,
974 FALSE, FALSE, MODEST_MARGIN_HALF);
975 gtk_widget_show (priv->outgoing_security);
977 GtkWidget *separator = gtk_hseparator_new ();
978 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
979 gtk_widget_show (separator);
981 /* connection-specific checkbox: */
982 priv->checkbox_outgoing_smtp_specific = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
983 hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific),
985 gtk_button_set_label (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
986 _("mcen_fi_advsetup_connection_smtp"));
987 gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
989 g_signal_connect (G_OBJECT (priv->checkbox_outgoing_smtp_specific), "toggled",
990 G_CALLBACK (on_easysetup_changed), self);
992 gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
993 gtk_box_pack_start (GTK_BOX (box), priv->checkbox_outgoing_smtp_specific,
994 FALSE, FALSE, MODEST_MARGIN_HALF);
996 /* Connection-specific SMTP-Severs Edit button: */
997 priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_advsetup_optional_smtp"));
998 hildon_gtk_widget_set_theme_size (priv->button_outgoing_smtp_servers,
999 HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1000 gtk_widget_show (priv->button_outgoing_smtp_servers);
1001 gtk_box_pack_start (GTK_BOX (box), priv->button_outgoing_smtp_servers,
1002 FALSE, FALSE, MODEST_MARGIN_HALF);
1004 /* Only enable the button when the checkbox is checked: */
1005 enable_widget_for_checkbutton (priv->button_outgoing_smtp_servers,
1006 HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific));
1008 g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
1009 G_CALLBACK (on_button_outgoing_smtp_servers), self);
1011 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
1012 G_CALLBACK (on_entry_outgoing_servername_changed), self);
1015 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), box);
1016 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
1017 hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pannable)));
1018 gtk_widget_show (GTK_WIDGET (box));
1019 gtk_widget_show (pannable);
1021 g_object_unref (title_sizegroup);
1022 g_object_unref (value_sizegroup);
1024 return GTK_WIDGET (pannable);
1028 show_advanced_edit(gpointer user_data)
1030 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1031 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1034 /* Show the Account Settings window: */
1035 ModestAccountSettingsDialog *dialog = modest_default_account_settings_dialog_new ();
1036 if (priv->pending_load_settings) {
1037 save_to_settings (self);
1038 priv->pending_load_settings = FALSE;
1040 modest_account_settings_dialog_load_settings (dialog, priv->settings);
1042 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), GTK_WINDOW (self));
1044 response = gtk_dialog_run (GTK_DIALOG (dialog));
1046 gtk_widget_destroy (GTK_WIDGET (dialog));
1048 return FALSE; /* Do not call this timeout callback again. */
1052 on_button_edit_advanced_settings (GtkButton *button, gpointer user_data)
1054 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1056 /* Show the Account Settings window: */
1057 show_advanced_edit(self);
1060 create_page_complete_custom (ModestEasysetupWizardDialog *self)
1062 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
1063 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
1064 GtkWidget *button_edit = gtk_button_new_with_label (_("mcen_fi_advanced_settings"));
1065 hildon_gtk_widget_set_theme_size (button_edit, HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1066 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1067 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1068 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1069 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
1070 gtk_widget_show (label);
1072 label = gtk_label_new (_("mcen_ia_customsetup_complete"));
1073 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
1074 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1075 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1076 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
1077 gtk_widget_show (label);
1079 gtk_widget_show (button_edit);
1080 gtk_box_pack_start (GTK_BOX (box), button_edit, FALSE, FALSE, MODEST_MARGIN_HALF);
1082 g_signal_connect (G_OBJECT (button_edit), "clicked",
1083 G_CALLBACK (on_button_edit_advanced_settings), self);
1085 gtk_widget_show (GTK_WIDGET (box));
1086 return GTK_WIDGET (box);
1093 on_response (ModestWizardDialog *wizard_dialog,
1097 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1099 invoke_enable_buttons_vfunc (self);
1103 on_response_before (ModestWizardDialog *wizard_dialog,
1107 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1108 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(wizard_dialog);
1109 if (response_id == GTK_RESPONSE_CANCEL) {
1110 /* This is mostly copied from
1111 * src/maemo/modest-account-settings-dialog.c */
1113 GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
1114 _("imum_nc_wizard_confirm_lose_changes")));
1115 /* TODO: These button names will be ambiguous, and not
1116 * specified in the UI specification. */
1118 const gint dialog_response = gtk_dialog_run (dialog);
1119 gtk_widget_destroy (GTK_WIDGET (dialog));
1121 if (dialog_response != GTK_RESPONSE_OK) {
1122 /* Don't let the dialog close */
1123 g_signal_stop_emission_by_name (wizard_dialog, "response");
1130 fill_providers (ModestEasysetupWizardDialog *self)
1132 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1134 if (MODEST_IS_COUNTRY_PICKER (priv->account_country_picker)) {
1135 /* gint mcc = get_default_country_code(); */
1137 /* Fill the combo in an idle call, as it takes a lot of time */
1138 modest_country_picker_load_data(
1139 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1140 /* connect to country picker's changed signal, so we can fill the provider picker: */
1141 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1142 (HILDON_PICKER_BUTTON (priv->account_country_picker))),
1144 G_CALLBACK (on_account_country_selector_changed), self);
1146 modest_country_picker_set_active_country_locale (
1147 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1148 mcc = modest_country_picker_get_active_country_mcc (
1149 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1150 modest_provider_picker_fill (
1151 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker),
1152 priv->presets, mcc);
1153 /* connect to providers picker's changed signal, so we can fill the email address: */
1154 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1155 (HILDON_PICKER_BUTTON (priv->account_serviceprovider_picker))),
1157 G_CALLBACK (on_account_serviceprovider_selector_changed), self);
1159 modest_provider_picker_set_others_provider (MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
1162 priv->dirty = FALSE;
1166 typedef struct IdleData {
1167 ModestEasysetupWizardDialog *dialog;
1168 ModestPresets *presets;
1172 presets_idle (gpointer userdata)
1174 IdleData *idle_data = (IdleData *) userdata;
1175 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (idle_data->dialog);
1176 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1178 g_assert (idle_data->presets);
1180 gdk_threads_enter ();
1182 priv->presets = idle_data->presets;
1184 if (priv->check_support_done)
1185 fill_providers (self);
1187 g_object_unref (idle_data->dialog);
1190 gdk_threads_leave ();
1196 presets_loader (gpointer userdata)
1198 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (userdata);
1199 ModestPresets *presets = NULL;
1200 IdleData *idle_data;
1202 const gchar* path = NULL;
1203 const gchar* path1 = MODEST_PROVIDER_DATA_FILE;
1204 const gchar* path2 = MODEST_MAEMO_PROVIDER_DATA_FILE;
1206 if (access(path1, R_OK) == 0)
1208 else if (access(path2, R_OK) == 0)
1211 g_warning ("%s: neither '%s' nor '%s' is a readable provider data file",
1212 __FUNCTION__, path1, path2);
1216 presets = modest_presets_new (path);
1218 g_warning ("%s: failed to parse '%s'", __FUNCTION__, path);
1222 idle_data = g_new0 (IdleData, 1);
1223 idle_data->dialog = self;
1224 idle_data->presets = presets;
1226 g_idle_add (presets_idle, idle_data);
1232 modest_easysetup_wizard_dialog_append_page (GtkNotebook *notebook,
1237 /* Append page and set attributes */
1238 index = gtk_notebook_append_page (notebook, page, gtk_label_new (label));
1239 gtk_container_child_set (GTK_CONTAINER (notebook), page,
1240 "tab-expand", TRUE, "tab-fill", TRUE,
1242 gtk_widget_show (page);
1246 init_user_page (ModestEasysetupWizardDialogPrivate *priv)
1248 priv->page_user_details = NULL;
1249 priv->entry_user_name = NULL;
1250 priv->entry_user_username = NULL;
1251 priv->entry_user_password = NULL;
1252 priv->entry_user_email = NULL;
1256 init_incoming_page (ModestEasysetupWizardDialogPrivate *priv)
1258 priv->page_custom_incoming = NULL;
1259 priv->incoming_servertype_picker = NULL;
1260 priv->caption_incoming = NULL;
1261 priv->entry_incomingserver = NULL;
1262 priv->entry_user_email = NULL;
1263 priv->incoming_security = NULL;
1267 init_outgoing_page (ModestEasysetupWizardDialogPrivate *priv)
1269 priv->page_custom_outgoing = NULL;
1270 priv->entry_outgoingserver = NULL;
1271 priv->checkbox_outgoing_smtp_specific = NULL;
1272 priv->button_outgoing_smtp_servers = NULL;
1273 priv->outgoing_security = NULL;
1277 modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
1279 gtk_container_set_border_width (GTK_CONTAINER (self), MODEST_MARGIN_HALF);
1281 /* Create the notebook to be used by the ModestWizardDialog base class:
1282 * Each page of the notebook will be a page of the wizard: */
1283 GtkNotebook *notebook = GTK_NOTEBOOK (gtk_notebook_new());
1284 gtk_widget_set_size_request (GTK_WIDGET (notebook), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
1286 /* Set the notebook used by the ModestWizardDialog base class: */
1287 g_object_set (G_OBJECT(self), "wizard-notebook", notebook, NULL);
1289 /* Set the wizard title:
1290 * The actual window title will be a combination of this and the page's tab label title. */
1291 g_object_set (G_OBJECT(self), "wizard-name", _("mcen_ti_emailsetup"), NULL);
1293 /* Read in the information about known service providers: */
1294 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1296 /* The server fields did not have been manually changed yet */
1297 priv->server_changes = 0;
1298 priv->pending_load_settings = TRUE;
1300 /* Get the account manager object,
1301 * so we can check for existing accounts,
1302 * and create new accounts: */
1303 priv->account_manager = modest_runtime_get_account_mgr ();
1304 g_object_ref (priv->account_manager);
1306 /* Initialize fields */
1307 priv->check_support_done = FALSE;
1308 priv->check_support_show_progress_id = 0;
1309 priv->check_support_progress_pulse_id = 0;
1310 priv->pending_check_support = 0;
1311 priv->destroyed = FALSE;
1312 priv->page_welcome = create_page_welcome (self);
1313 priv->page_account_details = create_page_account_details (self);
1315 init_user_page (priv);
1316 init_incoming_page (priv);
1317 init_outgoing_page (priv);
1319 priv->page_complete_easysetup = NULL;
1320 priv->page_complete_customsetup = NULL;
1321 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1322 priv->missing_data_signals = NULL;
1324 /* Add the common pages */
1325 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_welcome,
1326 _("mcen_ti_emailsetup_welcome"));
1327 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_account_details,
1328 _("mcen_ti_accountdetails"));
1330 /* Connect to the dialog's response signal so we can enable/disable buttons
1331 * for the newly-selected page, because the prev/next buttons cause response to be emitted.
1332 * Note that we use g_signal_connect_after() instead of g_signal_connect()
1333 * so that we can be enable/disable after ModestWizardDialog has done its own
1334 * enabling/disabling of buttons.
1336 * HOWEVER, this doesn't work because ModestWizardDialog's response signal handler
1337 * does g_signal_stop_emission_by_name(), stopping our signal handler from running.
1339 * It's not enough to connect to the notebook's switch-page signal, because
1340 * ModestWizardDialog's "response" signal handler enables the buttons itself,
1341 * _after_ switching the page (understandably).
1342 * (Note that if we had, if we used g_signal_connect() instead of g_signal_connect_after()
1343 * then gtk_notebook_get_current_page() would return an incorrect value.)
1345 g_signal_connect_after (G_OBJECT (self), "response",
1346 G_CALLBACK (on_response), self);
1348 /* This is to show a confirmation dialog when the user hits cancel */
1349 g_signal_connect (G_OBJECT (self), "response",
1350 G_CALLBACK (on_response_before), self);
1352 g_signal_connect (G_OBJECT (self), "delete-event",
1353 G_CALLBACK (on_delete_event), self);
1355 /* Reset dirty, because there was no user input until now */
1356 priv->dirty = FALSE;
1358 /* When this window is shown, hibernation should not be possible,
1359 * because there is no sensible way to save the state: */
1360 modest_window_mgr_prevent_hibernation_while_window_is_shown (
1361 modest_runtime_get_window_mgr (), GTK_WINDOW (self));
1363 /* Load provider presets */
1364 g_object_ref (self);
1365 g_thread_create (presets_loader, self, FALSE, NULL);
1367 priv->settings = modest_account_settings_new ();
1369 check_support_of_protocols (self);
1372 ModestEasysetupWizardDialog*
1373 modest_easysetup_wizard_dialog_new (void)
1376 return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
1380 create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
1382 ModestEasysetupWizardDialogPrivate *priv;
1383 GtkNotebook *notebook = NULL;
1385 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1388 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1390 if (!priv->page_user_details) {
1391 priv->page_user_details = create_page_user_details (self);
1394 /* Create the custom pages: */
1395 if(!(priv->page_custom_incoming)) {
1396 priv->page_custom_incoming = create_page_custom_incoming (self);
1399 /* TODO: only if needed */
1400 if(!(priv->page_custom_outgoing)) {
1401 priv->page_custom_outgoing = create_page_custom_outgoing (self);
1404 if(!(priv->page_complete_customsetup)) {
1405 priv->page_complete_customsetup = create_page_complete_custom (self);
1408 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_user_details)))
1409 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_user_details,
1410 _("mcen_ti_emailsetup_userdetails"));
1412 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_incoming)))
1413 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_incoming,
1414 _("mcen_ti_emailsetup_incomingdetails"));
1416 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_outgoing)))
1417 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_outgoing,
1418 _("mcen_ti_emailsetup_outgoingdetails"));
1420 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_customsetup)))
1421 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_customsetup,
1422 _("mcen_ti_emailsetup_complete"));
1424 /* This is unnecessary with GTK+ 2.10: */
1425 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1429 create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self)
1431 ModestEasysetupWizardDialogPrivate *priv;
1432 GtkNotebook *notebook = NULL;
1434 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1437 /* Create the easysetup-specific pages: */
1438 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1439 if(!priv->page_complete_easysetup)
1440 priv->page_complete_easysetup = create_page_complete_easysetup (self);
1442 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_easysetup)))
1443 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_easysetup,
1444 _("mcen_ti_emailsetup_complete"));
1446 /* This is unnecessary with GTK+ 2.10: */
1447 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1452 remove_non_common_tabs (GtkNotebook *notebook,
1453 gboolean remove_user_details)
1456 /* The first 2 tabs are the common ones (welcome tab and the
1457 providers tab), so we always remove starting from the
1460 starting_tab = (remove_user_details) ? 2 : 3;
1461 while (gtk_notebook_get_n_pages (notebook) > starting_tab)
1462 gtk_notebook_remove_page (notebook, -1);
1466 on_missing_mandatory_data (ModestAccountProtocol *protocol,
1470 real_enable_buttons (MODEST_WIZARD_DIALOG (user_data), !missing);
1473 /* After the user details page,
1474 * the following pages depend on whether "Other" was chosen
1475 * in the provider combobox on the account page
1478 create_subsequent_pages (ModestEasysetupWizardDialog *self)
1480 ModestEasysetupWizardDialogPrivate *priv;
1481 ModestProviderPicker *picker;
1482 ModestProviderPickerIdType id_type;
1483 GtkNotebook *notebook;
1485 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1486 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1487 id_type = modest_provider_picker_get_active_id_type (picker);
1488 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1489 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1493 if (id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
1494 /* "Other..." was selected: */
1496 /* If we come from a rollbacked easysetup */
1497 if (priv->page_complete_easysetup) {
1498 remove_non_common_tabs (notebook, FALSE);
1499 priv->page_complete_easysetup = NULL;
1502 /* If we come from a rollbacked plugin protocol setup */
1503 if (priv->last_plugin_protocol_selected != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1504 remove_non_common_tabs (notebook, TRUE);
1505 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1506 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1507 priv->missing_data_signals = NULL;
1510 create_subsequent_customsetup_pages (self);
1512 /* If we come from a rollbacked custom setup */
1513 if (priv->page_custom_incoming) {
1514 remove_non_common_tabs (notebook, TRUE);
1515 init_user_page (priv);
1516 init_incoming_page (priv);
1517 init_outgoing_page (priv);
1518 init_user_page (priv);
1519 priv->page_complete_customsetup = NULL;
1522 /* It's a pluggable protocol and not a provider with presets */
1523 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1524 ModestProtocol *protocol;
1526 ModestProtocolType proto_type;
1529 /* If we come from a rollbacked easy setup */
1530 if (priv->last_plugin_protocol_selected ==
1531 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID &&
1532 priv->page_complete_easysetup) {
1533 remove_non_common_tabs (notebook, TRUE);
1534 init_user_page (priv);
1535 priv->page_complete_easysetup = NULL;
1538 proto_name = modest_provider_picker_get_active_provider_id (picker);
1539 protocol = modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
1540 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
1542 proto_type = modest_protocol_get_type_id (protocol);
1544 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
1545 proto_type != priv->last_plugin_protocol_selected) {
1546 ModestPairList *tabs;
1548 gboolean first_page = TRUE;
1549 ModestWizardDialogResponseOverrideFunc response_override;
1551 /* Remember the last selected plugin protocol */
1552 priv->last_plugin_protocol_selected = proto_type;
1555 tabs = modest_account_protocol_get_easysetupwizard_tabs (MODEST_ACCOUNT_PROTOCOL (protocol));
1556 response_override = modest_account_protocol_get_wizard_response_override
1557 (MODEST_ACCOUNT_PROTOCOL (protocol));
1558 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1560 tmp = (GSList *) tabs;
1562 ModestPair *pair = (ModestPair *) tmp->data;
1563 modest_easysetup_wizard_dialog_append_page (notebook,
1564 GTK_WIDGET (pair->second),
1565 (const gchar *) pair->first);
1567 gtk_container_set_focus_child (GTK_CONTAINER (notebook),
1568 GTK_WIDGET (pair->second));
1572 /* Connect signals */
1573 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (pair->second)) {
1574 priv->missing_data_signals =
1575 modest_signal_mgr_connect (priv->missing_data_signals,
1576 G_OBJECT (pair->second),
1577 "missing-mandatory-data",
1578 G_CALLBACK (on_missing_mandatory_data),
1582 g_free (pair->first);
1583 tmp = g_slist_next (tmp);
1584 /* Critical: if you don't show the page then the dialog will ignore it */
1585 /* gtk_widget_show (GTK_WIDGET (pair->second)); */
1587 modest_pair_list_free (tabs);
1589 g_free (proto_name);
1591 if (priv->last_plugin_protocol_selected !=
1592 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1593 remove_non_common_tabs (notebook, TRUE);
1594 init_user_page (priv);
1595 priv->page_complete_easysetup = NULL;
1596 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1597 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1598 priv->missing_data_signals = NULL;
1600 if (!priv->page_user_details) {
1601 priv->page_user_details = create_page_user_details (self);
1602 modest_easysetup_wizard_dialog_append_page (notebook,
1603 priv->page_user_details,
1604 _("mcen_ti_emailsetup_userdetails"));
1608 /* Create the easysetup pages: */
1609 create_subsequent_easysetup_pages (self);
1615 util_get_default_servername_from_email_address (const gchar* email_address, ModestProtocolType protocol_type)
1617 const gchar* hostname = NULL;
1620 ModestProtocolRegistry *protocol_registry;
1621 ModestProtocol *protocol;
1626 at = g_utf8_strchr (email_address, -1, '@');
1627 if (!at || (g_utf8_strlen (at, -1) < 2))
1630 domain = g_utf8_next_char (at);
1634 protocol_registry = modest_runtime_get_protocol_registry ();
1635 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
1637 if (modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS) ||
1638 modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS)) {
1639 hostname = modest_protocol_get_name (protocol);
1645 return g_strdup_printf ("%s.%s", hostname, domain);
1649 set_default_custom_servernames (ModestEasysetupWizardDialog *self)
1651 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1653 if (!priv->entry_incomingserver)
1656 /* Set a default domain for the server, based on the email address,
1657 * if no server name was already specified.
1659 if (priv->entry_user_email
1660 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED) == 0)) {
1661 const ModestProtocolType protocol_type = modest_servertype_picker_get_active_servertype (
1662 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
1664 /* This could happen when the combo box has still no active iter */
1665 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1666 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1667 gchar* servername = util_get_default_servername_from_email_address (email_address,
1670 /* Do not set the INCOMING_CHANGED flag because of this edit */
1671 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1672 hildon_entry_set_text (HILDON_ENTRY (priv->entry_incomingserver), servername);
1673 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1675 g_free (servername);
1679 /* Set a default domain for the server, based on the email address,
1680 * if no server name was already specified.
1682 if (!priv->entry_outgoingserver)
1685 if (priv->entry_user_email
1686 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED) == 0)) {
1687 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1689 gchar* servername = util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOLS_TRANSPORT_SMTP);
1691 /* Do not set the OUTGOING_CHANGED flag because of this edit */
1692 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1693 hildon_entry_set_text (HILDON_ENTRY (priv->entry_outgoingserver), servername);
1694 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1696 g_free (servername);
1701 get_entered_account_title (ModestEasysetupWizardDialog *self)
1703 ModestEasysetupWizardDialogPrivate *priv;
1704 const gchar* account_title;
1706 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1707 account_title = hildon_entry_get_text (HILDON_ENTRY (priv->entry_account_title));
1709 if (!account_title || (g_utf8_strlen (account_title, -1) == 0)) {
1712 /* Strip it of whitespace at the start and end: */
1713 gchar *result = g_strdup (account_title);
1714 result = g_strstrip (result);
1719 if (g_utf8_strlen (result, -1) == 0) {
1729 on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *next_page)
1731 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1732 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1733 ModestProtocolRegistry *protocol_registry;
1735 protocol_registry = modest_runtime_get_protocol_registry ();
1737 /* if are browsing pages previous to the last one, then we have pending settings in
1739 if (next_page != NULL)
1740 priv->pending_load_settings = TRUE;
1742 /* Do extra validation that couldn't be done for every key press,
1743 * either because it was too slow,
1744 * or because it requires interaction:
1746 if (current_page == priv->page_account_details) {
1747 /* Check that the title is not already in use: */
1748 gchar* account_title = get_entered_account_title (self);
1752 /* Aavoid a clash with an existing display name: */
1753 const gboolean name_in_use = modest_account_mgr_account_with_display_name_exists (
1754 priv->account_manager, account_title);
1755 g_free (account_title);
1758 /* Warn the user via a dialog: */
1759 hildon_banner_show_information(NULL, NULL, _("mail_ib_account_name_already_existing"));
1764 /* Make sure that the subsequent pages are appropriate for the provider choice. */
1765 create_subsequent_pages (self);
1767 } else if (current_page == priv->page_user_details) {
1768 /* Check that the email address is valud: */
1769 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
1770 if ((!email_address) || (g_utf8_strlen (email_address, -1) == 0))
1773 if (!modest_text_utils_validate_email_address (email_address, NULL)) {
1774 /* Warn the user via a dialog: */
1775 hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email"));
1777 /* Return focus to the email address entry: */
1778 gtk_widget_grab_focus (priv->entry_user_email);
1779 gtk_editable_select_region (GTK_EDITABLE (priv->entry_user_email), 0, -1);
1785 if (next_page == priv->page_custom_incoming) {
1786 set_default_custom_servernames (self);
1787 } else if (next_page == priv->page_custom_outgoing) {
1788 set_default_custom_servernames (self);
1790 /* Check if the server supports secure authentication */
1791 if (modest_security_options_view_auth_check (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security)))
1792 if (!check_has_supported_auth_methods (self))
1794 gtk_widget_show (priv->outgoing_security);
1797 /* If this is the last page, and this is a click on Finish,
1798 * then attempt to create the dialog.
1801 current_page != priv->page_account_details) /* This is NULL when this is a click on Finish. */
1803 if (priv->pending_load_settings) {
1804 save_to_settings (self);
1807 /* We check if there's already another account with the same configuration */
1808 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
1809 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
1813 modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
1820 static gboolean entry_is_empty (GtkWidget *entry)
1825 const gchar* text = hildon_entry_get_text (HILDON_ENTRY (entry));
1826 if ((!text) || (g_utf8_strlen (text, -1) == 0))
1829 /* Strip it of whitespace at the start and end: */
1830 gchar *stripped = g_strdup (text);
1831 stripped = g_strstrip (stripped);
1836 const gboolean result = (g_utf8_strlen (stripped, -1) == 0);
1844 real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next)
1846 GtkNotebook *notebook = NULL;
1847 gboolean is_finish_tab;
1849 ModestEasysetupWizardDialogPrivate *priv;
1852 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (dialog);
1853 g_object_get (dialog, "wizard-notebook", ¬ebook, NULL);
1855 /* Disable the Finish button until we are on the last page,
1856 * because HildonWizardDialog enables this for all but the
1858 current = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
1859 is_finish_tab = ((current == priv->page_complete_easysetup) ||
1860 (current == priv->page_complete_customsetup));
1862 if (is_finish_tab) {
1863 /* Disable Next on the last page no matter what the
1865 enable_next = FALSE;
1867 /* Not the last one */
1868 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1869 MODEST_WIZARD_DIALOG_FINISH,
1872 /* If the check support is not done then do not enable
1873 the wizard to continue */
1874 enable_next = enable_next && priv->check_support_done;
1877 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1878 MODEST_WIZARD_DIALOG_NEXT,
1883 on_enable_buttons (ModestWizardDialog *dialog, GtkWidget *current_page)
1885 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1886 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1888 gboolean enable_next = TRUE;
1889 if (current_page == priv->page_welcome) {
1891 } else if (current_page == priv->page_account_details) {
1892 /* The account details title is mandatory: */
1893 if (entry_is_empty(priv->entry_account_title))
1894 enable_next = FALSE;
1895 } else if (current_page == priv->page_user_details) {
1896 /* The user details username is mandatory: */
1897 if (entry_is_empty(priv->entry_user_username))
1898 enable_next = FALSE;
1900 /* The user details email address is mandatory: */
1901 if (enable_next && entry_is_empty (priv->entry_user_email))
1902 enable_next = FALSE;
1903 } else if (current_page == priv->page_custom_incoming) {
1904 /* The custom incoming server is mandatory: */
1905 if (entry_is_empty(priv->entry_incomingserver))
1906 enable_next = FALSE;
1907 } else if (MODEST_IS_EASYSETUP_WIZARD_PAGE (current_page)) {
1908 enable_next = !modest_easysetup_wizard_page_validate (
1909 MODEST_EASYSETUP_WIZARD_PAGE (current_page));
1912 /* Enable/disable buttons */
1913 real_enable_buttons (dialog, enable_next);
1917 modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *klass)
1919 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1920 g_type_class_add_private (klass, sizeof (ModestEasysetupWizardDialogPrivate));
1923 object_class->dispose = modest_easysetup_wizard_dialog_dispose;
1924 object_class->finalize = modest_easysetup_wizard_dialog_finalize;
1926 /* Provide a vfunc implementation so we can decide
1927 * when to enable/disable the prev/next buttons.
1929 ModestWizardDialogClass *base_klass = (ModestWizardDialogClass*)(klass);
1930 base_klass->before_next = on_before_next;
1931 base_klass->enable_buttons = on_enable_buttons;
1932 base_klass->update_model = on_update_model;
1933 base_klass->save = on_save;
1938 * @self: a #ModestEasysetupWizardDialog
1940 * takes information from all the wizard and stores it in settings
1943 save_to_settings (ModestEasysetupWizardDialog *self)
1945 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1947 gchar *provider_id = NULL;
1948 gchar* display_name;
1949 const gchar *username, *password;
1950 gchar *store_hostname, *transport_hostname;
1951 guint store_port, transport_port;
1952 ModestProtocolRegistry *protocol_registry;
1953 ModestProtocolType store_protocol, transport_protocol;
1954 ModestProtocolType store_security, transport_security;
1955 ModestProtocolType store_auth_protocol, transport_auth_protocol;
1956 ModestServerAccountSettings *store_settings, *transport_settings;
1957 const gchar *fullname, *email_address;
1958 ModestProviderPicker *picker;
1959 ModestProviderPickerIdType id_type;
1961 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1962 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1963 protocol_registry = modest_runtime_get_protocol_registry ();
1965 /* Get details from the specified presets: */
1966 id_type = modest_provider_picker_get_active_id_type (picker);
1967 provider_id = modest_provider_picker_get_active_provider_id (picker);
1969 /* Let the plugin save the settings. We do a return in order
1970 to save an indentation level */
1971 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1972 ModestProtocol *protocol;
1974 protocol = modest_protocol_registry_get_protocol_by_name (
1975 modest_runtime_get_protocol_registry (),
1976 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
1979 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
1980 gint n_pages, i = 0;
1981 GtkNotebook *notebook;
1982 GList *wizard_pages = NULL;
1984 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1985 n_pages = gtk_notebook_get_n_pages (notebook);
1986 for (i = 0; i < n_pages; i++) {
1987 GtkWidget *page = gtk_notebook_get_nth_page (notebook, i);
1988 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (page))
1989 wizard_pages = g_list_append (wizard_pages, page);
1991 modest_account_protocol_save_wizard_settings (MODEST_ACCOUNT_PROTOCOL (protocol),
1994 g_list_free (wizard_pages);
1996 g_warning ("The selected protocol is a plugin protocol "//
1997 "but it's not a ModestAccountProtocol");
2000 g_free (provider_id);
2004 /* username and password (for both incoming and outgoing): */
2005 username = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_username));
2006 password = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_password));
2008 store_settings = modest_account_settings_get_store_settings (priv->settings);
2009 transport_settings = modest_account_settings_get_transport_settings (priv->settings);
2011 /* Incoming server: */
2012 /* Note: We need something as default for the transport store protocol values,
2013 * or modest_account_mgr_add_server_account will fail. */
2015 store_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2016 store_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2017 store_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2020 ModestProtocolType store_provider_server_type;
2021 gboolean store_provider_use_alternate_port;
2023 store_hostname = modest_presets_get_server (priv->presets, provider_id,
2026 store_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2029 store_security = modest_presets_get_info_server_security (priv->presets,
2032 store_auth_protocol = modest_presets_get_info_server_auth (priv->presets,
2035 store_provider_use_alternate_port = modest_presets_get_info_server_use_alternate_port (priv->presets,
2039 /* We don't check for SMTP here as that is impossible for an incoming server. */
2040 if (store_provider_server_type == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID)
2041 store_protocol = MODEST_PROTOCOLS_STORE_POP;
2043 store_protocol = store_provider_server_type;
2045 /* we check if there is a *special* port */
2046 special_port = modest_presets_get_port (priv->presets, provider_id, TRUE /* incoming */);
2047 if (special_port != 0) {
2048 store_port = special_port;
2050 gboolean use_alternate_port = FALSE;
2051 if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (),
2053 use_alternate_port = TRUE;
2054 store_port = get_port_from_protocol(store_provider_server_type, use_alternate_port);
2057 modest_server_account_settings_set_security_protocol (store_settings,
2059 modest_server_account_settings_set_auth_protocol (store_settings,
2060 store_auth_protocol);
2061 if (store_port != 0)
2062 modest_server_account_settings_set_port (store_settings, store_port);
2064 /* Use custom pages because no preset was specified: */
2065 store_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_incomingserver) ));
2066 store_protocol = modest_servertype_picker_get_active_servertype (
2067 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2069 modest_security_options_view_save_settings (
2070 MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
2074 /* now we store the common store account settings */
2075 modest_server_account_settings_set_hostname (store_settings, store_hostname);
2076 modest_server_account_settings_set_username (store_settings, username);
2077 modest_server_account_settings_set_password (store_settings, password);
2078 modest_server_account_settings_set_protocol (store_settings, store_protocol);
2080 g_object_unref (store_settings);
2081 g_free (store_hostname);
2083 /* Outgoing server: */
2084 transport_hostname = NULL;
2085 transport_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2086 transport_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2087 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2091 ModestProtocolType transport_provider_server_type;
2092 ModestProtocolType transport_provider_security;
2095 transport_hostname = modest_presets_get_server (priv->presets, provider_id,
2096 FALSE /* transport */);
2098 transport_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2100 FALSE /* transport */);
2101 transport_provider_security = modest_presets_get_info_server_security (priv->presets,
2103 FALSE /* transport */);
2105 /* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
2106 transport_protocol = transport_provider_server_type;
2107 transport_security = transport_provider_security;
2108 if (transport_security == MODEST_PROTOCOLS_CONNECTION_SSL) {
2109 /* printf("DEBUG: %s: using secure SMTP\n", __FUNCTION__); */
2110 /* we check if there is a *special* port */
2111 special_port = modest_presets_get_port (priv->presets, provider_id,
2112 FALSE /* transport */);
2113 if (special_port != 0)
2114 transport_port = special_port;
2116 transport_port = 465;
2117 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_PASSWORD;
2119 /* printf("DEBUG: %s: using non-secure SMTP\n", __FUNCTION__); */
2120 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2123 modest_server_account_settings_set_security_protocol (transport_settings,
2124 transport_security);
2125 modest_server_account_settings_set_auth_protocol (transport_settings,
2126 transport_auth_protocol);
2127 if (transport_port != 0)
2128 modest_server_account_settings_set_port (transport_settings,
2131 ModestProtocolRegistry *registry;
2132 ModestProtocol *store_proto;
2134 registry = modest_runtime_get_protocol_registry ();
2135 /* Use custom pages because no preset was specified: */
2136 transport_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver) ));
2138 store_proto = modest_protocol_registry_get_protocol_by_type (registry,
2141 if (transport_protocol == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
2142 /* fallback to SMTP if none was specified */
2143 g_warning ("No transport protocol was specified for store %d (%s)",
2144 modest_protocol_get_type_id (store_proto),
2145 modest_protocol_get_display_name (store_proto));
2146 transport_protocol = MODEST_PROTOCOLS_TRANSPORT_SMTP;
2149 modest_security_options_view_save_settings (
2150 MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security),
2154 /* now we store the common transport account settings */
2155 modest_server_account_settings_set_hostname (transport_settings, transport_hostname);
2156 modest_server_account_settings_set_username (transport_settings, username);
2157 modest_server_account_settings_set_password (transport_settings, password);
2158 modest_server_account_settings_set_protocol (transport_settings, transport_protocol);
2160 g_object_unref (transport_settings);
2161 g_free (transport_hostname);
2163 fullname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_name));
2164 email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
2165 modest_account_settings_set_fullname (priv->settings, fullname);
2166 modest_account_settings_set_email_address (priv->settings, email_address);
2167 /* we don't set retrieve type to preserve advanced settings if
2168 any. By default account settings are set to headers only */
2170 /* Save the connection-specific SMTP server accounts. */
2171 if (priv->checkbox_outgoing_smtp_specific) {
2172 modest_account_settings_set_use_connection_specific_smtp
2174 hildon_check_button_get_active(HILDON_CHECK_BUTTON(priv->checkbox_outgoing_smtp_specific)));
2177 display_name = get_entered_account_title (self);
2178 modest_account_settings_set_display_name (priv->settings, display_name);
2179 g_free (display_name);
2180 g_free (provider_id);
2185 on_update_model (ModestWizardDialog *dialog)
2187 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2188 save_to_settings (self);
2193 on_save (ModestWizardDialog *dialog)
2195 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2196 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2198 save_to_settings (self);
2200 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
2201 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
2205 return modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
2211 check_for_supported_auth_methods (ModestEasysetupWizardDialog* self)
2213 GError *error = NULL;
2214 ModestProtocolType protocol_type;
2215 const gchar* hostname;
2216 const gchar* username;
2217 ModestProtocolType security_protocol_incoming_type;
2218 ModestProtocolRegistry *registry;
2220 GList *list_auth_methods;
2221 ModestEasysetupWizardDialogPrivate *priv;
2223 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2224 registry = modest_runtime_get_protocol_registry ();
2225 protocol_type = modest_servertype_picker_get_active_servertype (
2226 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2227 hostname = gtk_entry_get_text(GTK_ENTRY(priv->entry_incomingserver));
2228 username = gtk_entry_get_text(GTK_ENTRY(priv->entry_user_username));
2229 security_protocol_incoming_type = modest_security_options_view_get_connection_protocol
2230 (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security));
2231 port_num = get_port_from_protocol(protocol_type, FALSE);
2232 list_auth_methods = modest_utils_get_supported_secure_authentication_methods (protocol_type, hostname, port_num,
2233 username, GTK_WINDOW (self), &error);
2235 if (list_auth_methods) {
2236 /* TODO: Select the correct method */
2239 for (method = list_auth_methods; method != NULL; method = g_list_next(method)) {
2240 ModestProtocolType auth_protocol_type = (ModestProtocolType) (GPOINTER_TO_INT(method->data));
2241 if (modest_protocol_registry_protocol_type_has_tag (registry, auth_protocol_type,
2242 MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS)) {
2243 list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type));
2247 g_list_free(list_auth_methods);
2253 if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
2254 error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
2256 modest_platform_information_banner (GTK_WIDGET(self), NULL,
2257 _("mcen_ib_unableto_discover_auth_methods"));
2261 g_error_free(error);
2267 check_has_supported_auth_methods(ModestEasysetupWizardDialog* self)
2269 GList* methods = check_for_supported_auth_methods(self);
2275 g_list_free(methods);
2280 check_support_progress_pulse (gpointer userdata)
2282 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2283 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2285 if (priv->destroyed) {
2286 priv->check_support_progress_pulse_id = 0;
2290 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2296 check_support_show_progress (gpointer userdata)
2298 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2299 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2301 priv->check_support_show_progress_id = 0;
2303 if (priv->destroyed)
2306 gtk_widget_show (priv->check_support_progress);
2307 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2309 priv->check_support_progress_pulse_id = g_timeout_add (200, check_support_progress_pulse, self);
2315 check_support_callback (ModestAccountProtocol *protocol,
2319 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2320 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2322 priv->pending_check_support --;
2324 if (priv->check_support_show_progress_id > 0) {
2325 g_source_remove (priv->check_support_show_progress_id);
2326 priv->check_support_show_progress_id = 0;
2329 if (priv->check_support_progress_pulse_id > 0) {
2330 g_source_remove (priv->check_support_progress_pulse_id);
2331 priv->check_support_progress_pulse_id = 0;
2334 if (priv->pending_check_support == 0) {
2335 priv->check_support_done = TRUE;
2337 if (!priv->destroyed) {
2339 fill_providers (self);
2340 gtk_widget_hide (priv->check_support_progress);
2341 invoke_enable_buttons_vfunc (self);
2344 g_object_unref (self);
2349 check_support_of_protocols (ModestEasysetupWizardDialog *self)
2351 ModestProtocolRegistry *registry;
2352 GSList *provider_protos, *node;
2353 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2355 registry = modest_runtime_get_protocol_registry ();
2356 provider_protos = modest_protocol_registry_get_by_tag (registry,
2357 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS);
2359 for (node = provider_protos; node != NULL; node = g_slist_next (node)) {
2360 ModestProtocol *proto = MODEST_PROTOCOL (node->data);
2362 if (!modest_protocol_registry_protocol_type_has_tag (registry,
2363 modest_protocol_get_type_id (proto),
2364 MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS))
2367 if (modest_protocol_registry_protocol_type_has_tag
2369 modest_protocol_get_type_id (proto),
2370 MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS)) {
2371 /* Check if there's already an account configured with this account type */
2372 if (modest_account_mgr_singleton_protocol_exists (modest_runtime_get_account_mgr (),
2373 modest_protocol_get_type_id (proto)))
2377 if (MODEST_ACCOUNT_PROTOCOL (proto)) {
2378 priv->pending_check_support ++;
2379 modest_account_protocol_check_support (MODEST_ACCOUNT_PROTOCOL (proto),
2380 check_support_callback,
2381 g_object_ref (self));
2384 g_slist_free (provider_protos);
2386 if (priv->pending_check_support > 0) {
2387 priv->check_support_show_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 1000,
2388 check_support_show_progress,
2389 g_object_ref (self), g_object_unref);
2391 priv->check_support_done = TRUE;
2393 invoke_enable_buttons_vfunc (self);