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"
62 #include "modest-address-book.h"
64 /* Include config.h so that _() works: */
69 G_DEFINE_TYPE (ModestEasysetupWizardDialog, modest_easysetup_wizard_dialog, MODEST_TYPE_WIZARD_DIALOG);
71 #define MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
72 MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, \
73 ModestEasysetupWizardDialogPrivate))
75 #define LABELS_WIDTH 480
76 #define DIALOG_WIDTH LABELS_WIDTH + MODEST_MARGIN_DOUBLE
78 typedef struct _ModestEasysetupWizardDialogPrivate ModestEasysetupWizardDialogPrivate;
82 MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED = 0x01,
83 MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED = 0x02
84 } ModestEasysetupWizardDialogServerChanges;
86 struct _ModestEasysetupWizardDialogPrivate
88 ModestPresets *presets;
90 /* Remember what fields the user edited manually to not prefill them
92 ModestEasysetupWizardDialogServerChanges server_changes;
94 /* Check if the user changes a field to show a confirmation dialog */
97 /* If we have a pending load of settings or not. */
98 gboolean pending_load_settings;
100 /* Used by derived widgets to query existing accounts,
101 * and to create new accounts: */
102 ModestAccountMgr *account_manager;
103 ModestAccountSettings *settings;
105 /* notebook pages: */
106 GtkWidget *page_welcome;
107 GtkWidget *check_support_progress;
108 gboolean check_support_done;
109 guint check_support_show_progress_id;
110 guint check_support_progress_pulse_id;
111 gint pending_check_support;
114 GtkWidget *page_account_details;
115 GtkWidget *account_country_picker;
116 GtkWidget *account_serviceprovider_picker;
117 GtkWidget *entry_account_title;
118 GtkWidget *caption_account_title;
120 GtkWidget *page_user_details;
121 GtkWidget *entry_user_name;
122 GtkWidget *entry_user_username;
123 GtkWidget *entry_user_password;
124 GtkWidget *entry_user_email;
126 GtkWidget *page_complete_easysetup;
128 GtkWidget *page_custom_incoming;
129 GtkWidget *incoming_servertype_picker;
130 GtkWidget *caption_incoming;
131 GtkWidget *entry_incomingserver;
133 /* Security widgets */
134 GtkWidget *incoming_security;
135 GtkWidget *outgoing_security;
137 GtkWidget *page_custom_outgoing;
138 GtkWidget *entry_outgoingserver;
139 GtkWidget *checkbox_outgoing_smtp_specific;
140 GtkWidget *button_outgoing_smtp_servers;
142 GtkWidget *page_complete_customsetup;
144 ModestProtocolType last_plugin_protocol_selected;
145 GSList *missing_data_signals;
148 static void save_to_settings (ModestEasysetupWizardDialog *self);
149 static void real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next);
150 static void on_update_model (ModestWizardDialog *dialog);
151 static gboolean on_save (ModestWizardDialog *dialog);
152 static GList* check_for_supported_auth_methods (ModestEasysetupWizardDialog* self);
153 static gboolean check_has_supported_auth_methods(ModestEasysetupWizardDialog* self);
154 static void check_support_callback (ModestAccountProtocol *protocol,
157 static void check_support_of_protocols (ModestEasysetupWizardDialog *self);
158 static gboolean check_support_show_progress (gpointer userdata);
159 static gboolean check_support_progress_pulse (gpointer userdata);
162 on_delete_event (GtkWidget *widget,
164 ModestEasysetupWizardDialog *wizard)
166 gtk_dialog_response (GTK_DIALOG (wizard), GTK_RESPONSE_CANCEL);
171 on_easysetup_changed(GtkWidget* widget, ModestEasysetupWizardDialog* wizard)
173 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(wizard);
174 g_return_if_fail (priv != NULL);
179 modest_easysetup_wizard_dialog_dispose (GObject *object)
181 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (object);
182 priv->destroyed = TRUE;
184 if (priv->check_support_show_progress_id > 0) {
185 g_source_remove (priv->check_support_show_progress_id);
186 priv->check_support_show_progress_id = 0;
189 if (priv->check_support_progress_pulse_id > 0) {
190 g_source_remove (priv->check_support_progress_pulse_id);
191 priv->check_support_progress_pulse_id = 0;
194 if (G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose)
195 G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose (object);
199 modest_easysetup_wizard_dialog_finalize (GObject *object)
201 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (object);
202 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
204 if (priv->account_manager)
205 g_object_unref (G_OBJECT (priv->account_manager));
208 modest_presets_destroy (priv->presets);
211 g_object_unref (priv->settings);
213 if (priv->missing_data_signals) {
214 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
215 priv->missing_data_signals = NULL;
218 G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->finalize (object);
222 create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self);
225 set_default_custom_servernames(ModestEasysetupWizardDialog *dialog);
227 static void on_servertype_selector_changed(HildonTouchSelector *selector, gint column, gpointer user_data);
230 get_port_from_protocol (ModestProtocolType server_type,
231 gboolean alternate_port)
234 ModestProtocol *protocol;
235 ModestProtocolRegistry *protocol_registry;
237 protocol_registry = modest_runtime_get_protocol_registry ();
238 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, server_type);
240 if (alternate_port) {
241 server_port = modest_account_protocol_get_alternate_port (MODEST_ACCOUNT_PROTOCOL (protocol));
243 server_port = modest_account_protocol_get_port (MODEST_ACCOUNT_PROTOCOL (protocol));
249 invoke_enable_buttons_vfunc (ModestEasysetupWizardDialog *wizard_dialog)
251 ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog);
253 /* Call the vfunc, which may be overridden by derived classes: */
254 if (klass->enable_buttons) {
255 GtkNotebook *notebook = NULL;
256 g_object_get (wizard_dialog, "wizard-notebook", ¬ebook, NULL);
258 const gint current_page_num = gtk_notebook_get_current_page (notebook);
259 if (current_page_num == -1)
262 GtkWidget* current_page_widget = gtk_notebook_get_nth_page (notebook, current_page_num);
263 (*(klass->enable_buttons))(MODEST_WIZARD_DIALOG (wizard_dialog), current_page_widget);
268 on_caption_entry_changed (GtkEditable *editable, gpointer user_data)
270 ModestEasysetupWizardDialog *self;
272 g_return_if_fail (user_data);
274 self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
276 invoke_enable_buttons_vfunc(self);
280 on_caption_combobox_changed (GtkComboBox *widget, gpointer user_data)
282 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
284 invoke_enable_buttons_vfunc(self);
288 on_picker_button_value_changed (HildonPickerButton *widget, gpointer user_data)
290 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
292 invoke_enable_buttons_vfunc(self);
296 on_serviceprovider_picker_button_value_changed (HildonPickerButton *widget, gpointer user_data)
298 gchar* default_account_name_start;
299 gchar* default_account_name;
300 ModestEasysetupWizardDialog *self;
301 ModestEasysetupWizardDialogPrivate *priv;
302 ModestProviderPickerIdType provider_id_type;
303 ModestProtocol *protocol;
305 ModestProtocolType proto_type;
306 gboolean hide_account_title;
308 self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
309 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
311 on_picker_button_value_changed (widget, user_data);
313 provider_id_type = modest_provider_picker_get_active_id_type (
314 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
315 if (provider_id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
316 default_account_name_start = g_strdup (_("mcen_ia_emailsetup_defaultname"));
320 selector = GTK_WIDGET (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (widget)));
321 default_account_name_start =
322 g_strdup (hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector)));
325 default_account_name = modest_account_mgr_get_unused_account_display_name (
326 priv->account_manager, default_account_name_start);
327 g_free (default_account_name_start);
328 default_account_name_start = NULL;
330 hide_account_title = FALSE;
331 proto_name = modest_provider_picker_get_active_provider_id (MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
332 if (proto_name != NULL) {
333 protocol = modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
334 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
336 if (protocol != NULL) {
337 proto_type = modest_protocol_get_type_id (protocol);
339 hide_account_title = (modest_protocol_registry_protocol_type_has_tag
340 (modest_runtime_get_protocol_registry (),
342 MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS) ||
343 modest_protocol_registry_protocol_type_has_tag
344 (modest_runtime_get_protocol_registry (),
346 MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS));
350 if (hide_account_title)
351 gtk_widget_hide (priv->caption_account_title);
353 gtk_widget_show (priv->caption_account_title);
355 hildon_entry_set_text (HILDON_ENTRY (priv->entry_account_title), default_account_name);
356 g_free (default_account_name);
359 /** This is a convenience function to create a caption containing a mandatory widget.
360 * When the widget is edited, the enable_buttons() vfunc will be called.
363 create_captioned (ModestEasysetupWizardDialog *self,
364 GtkSizeGroup *title_size_group,
365 GtkSizeGroup *value_size_group,
372 result = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
373 value, use_markup, control);
375 /* Connect to the appropriate changed signal for the widget,
376 * so we can ask for the prev/next buttons to be enabled/disabled appropriately:
378 if (GTK_IS_ENTRY (control)) {
379 g_signal_connect (G_OBJECT (control), "changed",
380 G_CALLBACK (on_caption_entry_changed), self);
383 else if (GTK_IS_COMBO_BOX (control)) {
384 g_signal_connect (G_OBJECT (control), "changed",
385 G_CALLBACK (on_caption_combobox_changed), self);
392 create_page_welcome (ModestEasysetupWizardDialog *self)
397 ModestEasysetupWizardDialogPrivate *priv;
399 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
400 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
401 label = gtk_label_new(_("mcen_ia_emailsetup_intro"));
402 priv->check_support_progress = gtk_progress_bar_new ();
403 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
404 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
405 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
406 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
407 /* So that it is not truncated: */
408 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
409 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
410 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
411 gtk_box_pack_end (GTK_BOX (box), priv->check_support_progress, FALSE, FALSE, 0);
412 gtk_container_add (GTK_CONTAINER (align), box);
413 gtk_widget_show (label);
414 gtk_widget_show (GTK_WIDGET (box));
415 return GTK_WIDGET (align);
419 on_account_country_selector_changed (HildonTouchSelector *widget, gint column, gpointer user_data)
421 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
423 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
427 /* Fill the providers picker, based on the selected country: */
428 if (priv->presets != NULL) {
429 gint mcc = modest_country_picker_get_active_country_mcc (
430 MODEST_COUNTRY_PICKER (priv->account_country_picker));
431 modest_provider_picker_fill (
432 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker), priv->presets, mcc);
437 update_user_email_from_provider (ModestEasysetupWizardDialog *self)
439 ModestEasysetupWizardDialogPrivate *priv;
440 gchar* provider_id = NULL, *with_at = NULL;
443 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
445 /* Fill the providers combo, based on the selected country: */
446 provider_id = modest_provider_picker_get_active_provider_id (
447 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
450 gchar *domain_name = modest_presets_get_domain (priv->presets, provider_id);
451 with_at = g_strdup_printf ("%c%s", '@', domain_name);
452 g_free (domain_name);
455 /* The sample address already contains the '@' */
457 with_at = g_strdup (MODEST_EXAMPLE_EMAIL_ADDRESS);
459 if (priv->entry_user_email)
460 hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_email), with_at);
463 g_free (provider_id);
467 on_account_serviceprovider_selector_changed (HildonTouchSelector *widget, gint column, gpointer user_data)
469 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
471 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
475 update_user_email_from_provider (self);
479 on_entry_max (ModestValidatingEntry *self, gpointer user_data)
481 modest_platform_information_banner (GTK_WIDGET (self), NULL,
482 _CS("ckdg_ib_maximum_characters_reached"));
486 create_page_account_details (ModestEasysetupWizardDialog *self)
489 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
490 GtkWidget *label = gtk_label_new(_("mcen_ia_accountdetails"));
491 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
493 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
494 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
495 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
496 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
497 gtk_widget_show (label);
499 /* Create a size group to be used by all captions.
500 * Note that HildonCaption does not create a default size group if we do not specify one.
501 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
502 GtkSizeGroup* title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
503 GtkSizeGroup* value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
505 /* The country widgets: */
506 priv->account_country_picker = GTK_WIDGET (modest_country_picker_new (MODEST_EDITABLE_SIZE,
507 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
508 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
509 _("mcen_fi_country"), priv->account_country_picker);
510 g_signal_connect (G_OBJECT (priv->account_country_picker), "value-changed",
511 G_CALLBACK (on_picker_button_value_changed), self);
512 gtk_box_pack_start (GTK_BOX (box), priv->account_country_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
513 gtk_widget_show (priv->account_country_picker);
515 /* The service provider widgets: */
516 priv->account_serviceprovider_picker = GTK_WIDGET (modest_provider_picker_new (MODEST_EDITABLE_SIZE,
517 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
518 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
519 _("mcen_fi_serviceprovider"),
520 priv->account_serviceprovider_picker);
521 g_signal_connect (G_OBJECT (priv->account_serviceprovider_picker), "value-changed",
522 G_CALLBACK (on_serviceprovider_picker_button_value_changed), self);
523 gtk_box_pack_start (GTK_BOX (box), priv->account_serviceprovider_picker, FALSE, FALSE, 0);
524 gtk_widget_show (priv->account_serviceprovider_picker);
526 /* The description widgets: */
527 priv->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
529 /* Do use auto-capitalization: */
530 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_account_title),
531 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
533 /* Set a default account title, choosing one that does not already exist: */
534 /* Note that this is irrelevant to the non-user visible name, which we will create later. */
535 gchar* default_account_name_start = g_strdup (_("mcen_ia_emailsetup_defaultname"));
536 gchar* default_account_name = modest_account_mgr_get_unused_account_display_name (
537 priv->account_manager, default_account_name_start);
538 g_free (default_account_name_start);
539 default_account_name_start = NULL;
541 hildon_entry_set_text (HILDON_ENTRY (priv->entry_account_title), default_account_name);
542 g_free (default_account_name);
543 default_account_name = NULL;
545 /* Connect signal after changing the text in the entry */
546 g_signal_connect(G_OBJECT(priv->entry_account_title), "changed",
547 G_CALLBACK(on_easysetup_changed), self);
549 priv->caption_account_title = create_captioned (self, title_sizegroup, value_sizegroup,
550 _("mcen_fi_account_title"), FALSE,
551 priv->entry_account_title);
552 gtk_widget_show (priv->entry_account_title);
553 gtk_box_pack_start (GTK_BOX (box), priv->caption_account_title, FALSE, FALSE, 0);
554 gtk_widget_show (priv->caption_account_title);
555 gtk_widget_set_no_show_all (priv->caption_account_title, TRUE);
557 /* Prevent the use of some characters in the account title,
558 * as required by our UI specification: */
559 GList *list_prevent = NULL;
560 list_prevent = g_list_append (list_prevent, "\\");
561 list_prevent = g_list_append (list_prevent, "/");
562 list_prevent = g_list_append (list_prevent, ":");
563 list_prevent = g_list_append (list_prevent, "*");
564 list_prevent = g_list_append (list_prevent, "?");
565 list_prevent = g_list_append (list_prevent, "\""); /* The UI spec mentions “, but maybe means ", maybe both. */
566 list_prevent = g_list_append (list_prevent, "“");
567 list_prevent = g_list_append (list_prevent, "<");
568 list_prevent = g_list_append (list_prevent, ">");
569 list_prevent = g_list_append (list_prevent, "|");
570 list_prevent = g_list_append (list_prevent, "^");
571 modest_validating_entry_set_unallowed_characters (
572 MODEST_VALIDATING_ENTRY (priv->entry_account_title), list_prevent);
573 g_list_free (list_prevent);
575 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
576 modest_utils_on_entry_invalid_character, self);
578 /* Set max length as in the UI spec:
579 * The UI spec seems to want us to show a dialog if we hit the maximum. */
580 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_account_title), 64);
581 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_account_title),
584 gtk_widget_show (GTK_WIDGET (box));
586 g_object_unref (title_sizegroup);
587 g_object_unref (value_sizegroup);
589 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
590 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE, 0);
591 gtk_widget_show (align);
592 gtk_container_add (GTK_CONTAINER (align), box);
594 return GTK_WIDGET (align);
598 create_page_user_details (ModestEasysetupWizardDialog *self)
600 GtkSizeGroup* title_sizegroup;
601 GtkSizeGroup* value_sizegroup;
603 ModestEasysetupWizardDialogPrivate *priv;
605 const gchar *my_name;
607 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
609 /* Create a size group to be used by all captions.
610 * Note that HildonCaption does not create a default size group if we do not specify one.
611 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
612 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
613 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
614 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
616 /* The name widgets: (use auto cap) */
617 priv->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
618 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_name),
619 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
621 /* Set max length as in the UI spec:
622 * The UI spec seems to want us to show a dialog if we hit the maximum. */
623 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_name), 64);
624 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_name),
626 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
627 _("mcen_li_emailsetup_name"), FALSE, priv->entry_user_name);
629 /* Try to initialize the user name with my own contact */
630 my_name = modest_address_book_get_my_name ();
632 gtk_entry_set_text (GTK_ENTRY (priv->entry_user_name), my_name);
634 g_signal_connect(G_OBJECT(priv->entry_user_name), "changed",
635 G_CALLBACK(on_easysetup_changed), self);
636 gtk_widget_show (priv->entry_user_name);
637 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
638 gtk_widget_show (caption);
640 /* Prevent the use of some characters in the name,
641 * as required by our UI specification: */
642 GList *list_prevent = NULL;
643 list_prevent = g_list_append (list_prevent, "<");
644 list_prevent = g_list_append (list_prevent, ">");
645 modest_validating_entry_set_unallowed_characters (
646 MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
647 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
648 modest_utils_on_entry_invalid_character, self);
649 g_list_free (list_prevent);
651 /* The username widgets: */
652 priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
653 /* Auto-capitalization is the default, so let's turn it off: */
654 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username),
655 HILDON_GTK_INPUT_MODE_FULL);
656 caption = create_captioned (self, title_sizegroup, value_sizegroup, _("mail_fi_username"), FALSE,
657 priv->entry_user_username);
658 gtk_widget_show (priv->entry_user_username);
659 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
660 g_signal_connect(G_OBJECT(priv->entry_user_username), "changed",
661 G_CALLBACK(on_easysetup_changed), self);
662 gtk_widget_show (caption);
664 /* Prevent the use of some characters in the username,
665 * as required by our UI specification: */
666 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_username),
667 modest_utils_on_entry_invalid_character, self);
669 /* Set max length as in the UI spec:
670 * The UI spec seems to want us to show a dialog if we hit the maximum. */
671 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
672 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_username),
675 /* The password widgets: */
676 priv->entry_user_password = hildon_entry_new (MODEST_EDITABLE_SIZE);
677 /* Auto-capitalization is the default, so let's turn it off: */
678 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password),
679 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
680 gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
681 /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
682 caption = create_captioned (self, title_sizegroup, value_sizegroup,
683 _("mail_fi_password"), FALSE, priv->entry_user_password);
684 g_signal_connect(G_OBJECT(priv->entry_user_password), "changed",
685 G_CALLBACK(on_easysetup_changed), self);
686 gtk_widget_show (priv->entry_user_password);
687 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
688 gtk_widget_show (caption);
690 /* The email address widgets: */
691 priv->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
692 /* Auto-capitalization is the default, so let's turn it off: */
693 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
694 caption = create_captioned (self, title_sizegroup, value_sizegroup,
695 _("mcen_li_emailsetup_email_address"), FALSE, priv->entry_user_email);
696 update_user_email_from_provider (self);
697 gtk_widget_show (priv->entry_user_email);
698 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
699 g_signal_connect(G_OBJECT(priv->entry_user_email), "changed",
700 G_CALLBACK(on_easysetup_changed), self);
701 gtk_widget_show (caption);
703 /* Set max length as in the UI spec:
704 * The UI spec seems to want us to show a dialog if we hit the maximum. */
705 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_email), 64);
706 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_email),
710 gtk_widget_show (GTK_WIDGET (box));
711 g_object_unref (title_sizegroup);
712 g_object_unref (value_sizegroup);
714 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
715 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE, 0);
716 gtk_widget_show (align);
717 gtk_container_add (GTK_CONTAINER (align), box);
719 return GTK_WIDGET (align);
723 create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
726 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
728 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
729 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
730 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
731 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
732 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
734 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
735 gtk_widget_show (label);
737 label = gtk_label_new (_("mcen_ia_easysetup_complete"));
738 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
739 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
741 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
742 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
743 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
744 gtk_widget_show (label);
746 gtk_widget_show (GTK_WIDGET (box));
748 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
749 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE, 0);
750 gtk_widget_show (align);
751 gtk_container_add (GTK_CONTAINER (align), box);
753 return GTK_WIDGET (align);
756 /** Change the caption title for the incoming server,
757 * as specified in the UI spec:
760 update_incoming_server_title (ModestEasysetupWizardDialog *self)
762 ModestEasysetupWizardDialogPrivate* priv;
763 ModestProtocolType protocol_type;
764 ModestProtocolRegistry *protocol_registry;
766 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
767 protocol_registry = modest_runtime_get_protocol_registry ();
769 protocol_type = modest_servertype_picker_get_active_servertype (
770 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
772 /* This could happen when the combo box has still no active iter */
773 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
774 gchar* incomingserver_title;
775 const gchar *protocol_display_name;
776 ModestProtocol *protocol;
778 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry,
780 protocol_display_name = modest_protocol_get_display_name (protocol);
782 incomingserver_title = g_strconcat (_("mcen_li_emailsetup_servertype"), "\n<small>(",
783 protocol_display_name, ")</small>", NULL);
785 modest_maemo_utils_captioned_set_label (priv->caption_incoming, incomingserver_title, TRUE);
787 g_free(incomingserver_title);
791 /** Change the caption title for the incoming server,
792 * as specified in the UI spec:
795 update_incoming_server_security_choices (ModestEasysetupWizardDialog *self)
797 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
798 ModestServertypePicker *server_type_picker;
799 ModestProtocolType protocol_type;
800 ModestSecurityOptionsView *view;
803 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker);
805 modest_servertype_picker_get_active_servertype (server_type_picker);
807 /* Fill the combo with appropriately titled choices for all
809 view = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
810 modest_security_options_view_set_server_type (view, protocol_type);
814 on_servertype_selector_changed(HildonTouchSelector *selector, gint column, gpointer user_data)
816 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
817 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
822 update_incoming_server_title (self);
824 /* Update security options if needed */
825 update_incoming_server_security_choices (self);
826 gtk_widget_show (priv->incoming_security);
828 set_default_custom_servernames (self);
832 on_entry_incoming_servername_changed(GtkEntry *entry, gpointer user_data)
834 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
835 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
837 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED;
841 create_page_custom_incoming (ModestEasysetupWizardDialog *self)
843 ModestProtocolRegistry *protocol_registry;
844 ModestEasysetupWizardDialogPrivate* priv;
849 GtkSizeGroup *title_sizegroup;
850 GtkSizeGroup *value_sizegroup;
852 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
853 protocol_registry = modest_runtime_get_protocol_registry ();
855 box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
856 pannable = hildon_pannable_area_new ();
858 /* Show note that account type cannot be changed in future: */
859 label = gtk_label_new (_("mcen_ia_emailsetup_account_type"));
860 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
861 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
862 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
863 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
864 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
865 gtk_widget_show (label);
867 /* Create a size group to be used by all captions.
868 * Note that HildonCaption does not create a default size group if we do not specify one.
869 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
870 title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
871 value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
873 /* The incoming server widgets: */
874 priv->incoming_servertype_picker = GTK_WIDGET (modest_servertype_picker_new (MODEST_EDITABLE_SIZE,
875 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
877 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
878 _("mcen_li_emailsetup_type"),
879 priv->incoming_servertype_picker);
880 g_signal_connect (G_OBJECT (priv->incoming_servertype_picker), "value-changed",
881 G_CALLBACK (on_picker_button_value_changed), self);
882 gtk_box_pack_start (GTK_BOX (box), priv->incoming_servertype_picker, FALSE, FALSE, 0);
883 gtk_widget_show (priv->incoming_servertype_picker);
885 priv->entry_incomingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
887 /* Auto-capitalization is the default, so let's turn it off: */
888 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
889 set_default_custom_servernames (self);
891 /* The caption title will be updated in update_incoming_server_title().
892 * so this default text will never be seen: */
893 priv->caption_incoming = create_captioned (self, title_sizegroup, value_sizegroup,
894 "This will be removed",
895 FALSE, priv->entry_incomingserver);
896 update_incoming_server_title (self);
897 gtk_widget_show (priv->entry_incomingserver);
898 gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, 0);
899 gtk_widget_show (priv->caption_incoming);
901 /* Remember when the servername was changed manually: */
902 g_signal_connect (G_OBJECT (priv->entry_incomingserver), "changed",
903 G_CALLBACK (on_entry_incoming_servername_changed), self);
905 /* The secure connection widgets. These are only valid for
906 protocols with security */
907 priv->incoming_security =
908 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
909 FALSE, title_sizegroup, value_sizegroup);
910 gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
912 gtk_widget_show (priv->incoming_security);
914 /* Set default selection */
915 modest_servertype_picker_set_active_servertype (
916 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker),
917 MODEST_PROTOCOLS_STORE_POP);
918 update_incoming_server_title (self);
919 update_incoming_server_security_choices (self);
920 set_default_custom_servernames (self);
922 /* Change the caption title when the servertype changes,
923 * as in the UI spec: */
924 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (priv->incoming_servertype_picker))),
926 G_CALLBACK (on_servertype_selector_changed), self);
928 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
929 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
930 gtk_widget_show (align);
931 gtk_container_add (GTK_CONTAINER (align), box);
933 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), align);
934 gtk_widget_show (GTK_WIDGET (box));
935 gtk_widget_show (pannable);
937 g_object_unref (title_sizegroup);
938 g_object_unref (value_sizegroup);
940 /* Connect changed signals. We do it here after initializing everything */
941 g_signal_connect (G_OBJECT(priv->entry_incomingserver), "changed",
942 G_CALLBACK(on_easysetup_changed), self);
945 return GTK_WIDGET (pannable);
949 on_check_button_changed (HildonCheckButton *button, gpointer user_data)
951 GtkWidget *widget = GTK_WIDGET (user_data);
953 /* Enable the widget only if the check button is active: */
954 const gboolean enable = hildon_check_button_get_active (button);
955 gtk_widget_set_sensitive (widget, enable);
958 /* Make the sensitivity of a widget depend on a check button.
961 enable_widget_for_checkbutton (GtkWidget *widget, HildonCheckButton* button)
963 g_signal_connect (G_OBJECT (button), "toggled",
964 G_CALLBACK (on_check_button_changed), widget);
966 /* Set the starting sensitivity: */
967 on_check_button_changed (button, widget);
971 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
973 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
974 ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
975 GtkWidget *specific_window;
977 /* We set dirty here because setting it depending on the connection specific dialog
981 /* Create the window, if necessary: */
982 specific_window = (GtkWidget *) modest_connection_specific_smtp_window_new ();
983 modest_connection_specific_smtp_window_fill_with_connections (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window), priv->account_manager);
985 /* Show the window */
986 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (specific_window), GTK_WINDOW (self));
987 gtk_widget_show (specific_window);
991 on_entry_outgoing_servername_changed (GtkEntry *entry, gpointer user_data)
993 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
994 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
995 priv->server_changes |= MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED;
999 create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
1001 ModestEasysetupWizardDialogPrivate *priv;
1002 gchar *smtp_caption_label;
1003 GtkWidget *pannable;
1005 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
1007 pannable = hildon_pannable_area_new ();
1009 /* Create a size group to be used by all captions.
1010 * Note that HildonCaption does not create a default size group if we do not specify one.
1011 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
1012 GtkSizeGroup *title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1013 GtkSizeGroup *value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1015 /* The outgoing server widgets: */
1016 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1017 priv->entry_outgoingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
1019 /* Auto-capitalization is the default, so let's turn it off: */
1020 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
1021 smtp_caption_label = g_strconcat (_("mcen_li_emailsetup_smtp"), "\n<small>(SMTP)</small>", NULL);
1022 GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup,
1023 smtp_caption_label, TRUE, priv->entry_outgoingserver);
1024 g_free (smtp_caption_label);
1025 gtk_widget_show (priv->entry_outgoingserver);
1026 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 0);
1027 gtk_widget_show (caption);
1028 set_default_custom_servernames (self);
1030 /* The secure connection widgets. These are only valid for
1031 protocols with security */
1032 priv->outgoing_security =
1033 modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
1034 FALSE, title_sizegroup, value_sizegroup);
1035 gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security,
1037 gtk_widget_show (priv->outgoing_security);
1039 GtkWidget *separator = gtk_hseparator_new ();
1040 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0);
1041 gtk_widget_show (separator);
1043 /* connection-specific checkbox: */
1044 priv->checkbox_outgoing_smtp_specific = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
1045 hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific),
1047 gtk_button_set_label (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
1048 _("mcen_fi_advsetup_connection_smtp"));
1049 gtk_button_set_alignment (GTK_BUTTON (priv->checkbox_outgoing_smtp_specific),
1052 gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
1053 gtk_box_pack_start (GTK_BOX (box), priv->checkbox_outgoing_smtp_specific,
1056 /* Connection-specific SMTP-Severs Edit button: */
1057 priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_advsetup_optional_smtp"));
1058 hildon_gtk_widget_set_theme_size (priv->button_outgoing_smtp_servers,
1059 HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1060 gtk_widget_show (priv->button_outgoing_smtp_servers);
1061 gtk_box_pack_start (GTK_BOX (box), priv->button_outgoing_smtp_servers,
1064 /* Only enable the button when the checkbox is checked: */
1065 enable_widget_for_checkbutton (priv->button_outgoing_smtp_servers,
1066 HILDON_CHECK_BUTTON (priv->checkbox_outgoing_smtp_specific));
1068 g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
1069 G_CALLBACK (on_button_outgoing_smtp_servers), self);
1071 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
1072 G_CALLBACK (on_entry_outgoing_servername_changed), self);
1075 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
1076 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
1077 gtk_widget_show (align);
1078 gtk_container_add (GTK_CONTAINER (align), box);
1080 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), align);
1081 gtk_widget_show (GTK_WIDGET (box));
1082 gtk_widget_show (pannable);
1084 g_object_unref (title_sizegroup);
1085 g_object_unref (value_sizegroup);
1087 /* Connect changed signals. We do it here after initializing everything */
1088 g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
1089 G_CALLBACK (on_easysetup_changed), self);
1090 g_signal_connect (G_OBJECT (priv->checkbox_outgoing_smtp_specific), "toggled",
1091 G_CALLBACK (on_easysetup_changed), self);
1093 return GTK_WIDGET (pannable);
1097 show_advanced_edit(gpointer user_data)
1099 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1100 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1103 /* Show the Account Settings window: */
1104 ModestAccountSettingsDialog *dialog = modest_default_account_settings_dialog_new ();
1105 if (priv->pending_load_settings) {
1106 save_to_settings (self);
1107 priv->pending_load_settings = FALSE;
1109 modest_account_settings_dialog_load_settings (dialog, priv->settings);
1111 modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), GTK_WINDOW (self));
1113 response = gtk_dialog_run (GTK_DIALOG (dialog));
1115 gtk_widget_destroy (GTK_WIDGET (dialog));
1117 return FALSE; /* Do not call this timeout callback again. */
1121 on_button_edit_advanced_settings (GtkButton *button, gpointer user_data)
1123 ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
1125 /* Show the Account Settings window: */
1126 show_advanced_edit(self);
1129 create_page_complete_custom (ModestEasysetupWizardDialog *self)
1132 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
1133 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
1134 GtkWidget *button_edit = gtk_button_new_with_label (_("mcen_fi_advanced_settings"));
1135 hildon_gtk_widget_set_theme_size (button_edit, HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1136 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1137 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1138 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1139 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
1140 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
1141 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
1142 gtk_widget_show (label);
1144 label = gtk_label_new (_("mcen_ia_customsetup_complete"));
1145 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
1146 gtk_widget_set_size_request (label, LABELS_WIDTH, -1);
1147 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1148 gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
1149 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
1150 gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
1151 gtk_widget_show (label);
1153 gtk_widget_show (button_edit);
1154 gtk_box_pack_start (GTK_BOX (box), button_edit, FALSE, FALSE, 0);
1156 g_signal_connect (G_OBJECT (button_edit), "clicked",
1157 G_CALLBACK (on_button_edit_advanced_settings), self);
1159 gtk_widget_show (GTK_WIDGET (box));
1161 align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
1162 gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE, 0);
1163 gtk_widget_show (align);
1164 gtk_container_add (GTK_CONTAINER (align), box);
1166 return GTK_WIDGET (align);
1173 on_response (ModestWizardDialog *wizard_dialog,
1177 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1179 invoke_enable_buttons_vfunc (self);
1183 on_response_before (ModestWizardDialog *wizard_dialog,
1187 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
1188 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(wizard_dialog);
1189 if (response_id == GTK_RESPONSE_CANCEL) {
1190 /* This is mostly copied from
1191 * src/maemo/modest-account-settings-dialog.c */
1193 GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
1194 _("imum_nc_wizard_confirm_lose_changes")));
1195 /* TODO: These button names will be ambiguous, and not
1196 * specified in the UI specification. */
1198 const gint dialog_response = gtk_dialog_run (dialog);
1199 gtk_widget_destroy (GTK_WIDGET (dialog));
1201 if (dialog_response != GTK_RESPONSE_OK) {
1202 /* Don't let the dialog close */
1203 g_signal_stop_emission_by_name (wizard_dialog, "response");
1210 fill_providers (ModestEasysetupWizardDialog *self)
1212 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1214 if (MODEST_IS_COUNTRY_PICKER (priv->account_country_picker)) {
1215 /* gint mcc = get_default_country_code(); */
1217 /* Fill the combo in an idle call, as it takes a lot of time */
1218 modest_country_picker_load_data(
1219 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1220 /* connect to country picker's changed signal, so we can fill the provider picker: */
1221 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1222 (HILDON_PICKER_BUTTON (priv->account_country_picker))),
1224 G_CALLBACK (on_account_country_selector_changed), self);
1226 modest_country_picker_set_active_country_locale (
1227 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1228 mcc = modest_country_picker_get_active_country_mcc (
1229 MODEST_COUNTRY_PICKER (priv->account_country_picker));
1230 modest_provider_picker_fill (
1231 MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker),
1232 priv->presets, mcc);
1233 /* connect to providers picker's changed signal, so we can fill the email address: */
1234 g_signal_connect (G_OBJECT (hildon_picker_button_get_selector
1235 (HILDON_PICKER_BUTTON (priv->account_serviceprovider_picker))),
1237 G_CALLBACK (on_account_serviceprovider_selector_changed), self);
1239 modest_provider_picker_set_others_provider (MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
1242 priv->dirty = FALSE;
1246 typedef struct IdleData {
1247 ModestEasysetupWizardDialog *dialog;
1248 ModestPresets *presets;
1252 presets_idle (gpointer userdata)
1254 IdleData *idle_data = (IdleData *) userdata;
1255 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (idle_data->dialog);
1256 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1258 g_assert (idle_data->presets);
1260 gdk_threads_enter ();
1262 priv->presets = idle_data->presets;
1264 if (priv->check_support_done)
1265 fill_providers (self);
1267 g_object_unref (idle_data->dialog);
1270 gdk_threads_leave ();
1276 presets_loader (gpointer userdata)
1278 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (userdata);
1279 ModestPresets *presets = NULL;
1280 IdleData *idle_data;
1282 const gchar* path = NULL;
1283 const gchar* path1 = MODEST_PROVIDER_DATA_FILE;
1284 const gchar* path2 = MODEST_FALLBACK_PROVIDER_DATA_FILE;
1286 if (access(path1, R_OK) == 0)
1288 else if (access(path2, R_OK) == 0)
1291 g_warning ("%s: neither '%s' nor '%s' is a readable provider data file",
1292 __FUNCTION__, path1, path2);
1296 presets = modest_presets_new (path);
1298 g_warning ("%s: failed to parse '%s'", __FUNCTION__, path);
1302 idle_data = g_new0 (IdleData, 1);
1303 idle_data->dialog = self;
1304 idle_data->presets = presets;
1306 g_idle_add (presets_idle, idle_data);
1312 modest_easysetup_wizard_dialog_append_page (GtkNotebook *notebook,
1317 /* Append page and set attributes */
1318 index = gtk_notebook_append_page (notebook, page, gtk_label_new (label));
1319 gtk_container_child_set (GTK_CONTAINER (notebook), page,
1320 "tab-expand", TRUE, "tab-fill", TRUE,
1322 gtk_widget_show (page);
1326 init_user_page (ModestEasysetupWizardDialogPrivate *priv)
1328 priv->page_user_details = NULL;
1329 priv->entry_user_name = NULL;
1330 priv->entry_user_username = NULL;
1331 priv->entry_user_password = NULL;
1332 priv->entry_user_email = NULL;
1336 init_incoming_page (ModestEasysetupWizardDialogPrivate *priv)
1338 priv->page_custom_incoming = NULL;
1339 priv->incoming_servertype_picker = NULL;
1340 priv->caption_incoming = NULL;
1341 priv->entry_incomingserver = NULL;
1342 priv->entry_user_email = NULL;
1343 priv->incoming_security = NULL;
1347 init_outgoing_page (ModestEasysetupWizardDialogPrivate *priv)
1349 priv->page_custom_outgoing = NULL;
1350 priv->entry_outgoingserver = NULL;
1351 priv->checkbox_outgoing_smtp_specific = NULL;
1352 priv->button_outgoing_smtp_servers = NULL;
1353 priv->outgoing_security = NULL;
1357 modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
1359 gtk_container_set_border_width (GTK_CONTAINER (self), MODEST_MARGIN_HALF);
1361 /* Create the notebook to be used by the ModestWizardDialog base class:
1362 * Each page of the notebook will be a page of the wizard: */
1363 GtkNotebook *notebook = GTK_NOTEBOOK (gtk_notebook_new());
1364 gtk_widget_set_size_request (GTK_WIDGET (notebook), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
1366 /* Set the notebook used by the ModestWizardDialog base class: */
1367 g_object_set (G_OBJECT(self), "wizard-notebook", notebook, NULL);
1369 /* Set the wizard title:
1370 * The actual window title will be a combination of this and the page's tab label title. */
1371 g_object_set (G_OBJECT(self), "wizard-name", _("mcen_ti_emailsetup"), NULL);
1373 /* Read in the information about known service providers: */
1374 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1376 /* The server fields did not have been manually changed yet */
1377 priv->server_changes = 0;
1378 priv->pending_load_settings = TRUE;
1380 /* Get the account manager object,
1381 * so we can check for existing accounts,
1382 * and create new accounts: */
1383 priv->account_manager = modest_runtime_get_account_mgr ();
1384 g_object_ref (priv->account_manager);
1386 /* Initialize fields */
1387 priv->check_support_done = FALSE;
1388 priv->check_support_show_progress_id = 0;
1389 priv->check_support_progress_pulse_id = 0;
1390 priv->pending_check_support = 0;
1391 priv->destroyed = FALSE;
1392 priv->page_welcome = create_page_welcome (self);
1393 gtk_widget_show (priv->page_welcome);
1394 priv->page_account_details = create_page_account_details (self);
1396 init_user_page (priv);
1397 init_incoming_page (priv);
1398 init_outgoing_page (priv);
1400 priv->page_complete_easysetup = NULL;
1401 priv->page_complete_customsetup = NULL;
1402 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1403 priv->missing_data_signals = NULL;
1405 /* Add the common pages */
1406 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_welcome,
1407 _("mcen_ti_emailsetup_welcome"));
1408 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_account_details,
1409 _("mcen_ti_accountdetails"));
1411 /* Connect to the dialog's response signal so we can enable/disable buttons
1412 * for the newly-selected page, because the prev/next buttons cause response to be emitted.
1413 * Note that we use g_signal_connect_after() instead of g_signal_connect()
1414 * so that we can be enable/disable after ModestWizardDialog has done its own
1415 * enabling/disabling of buttons.
1417 * HOWEVER, this doesn't work because ModestWizardDialog's response signal handler
1418 * does g_signal_stop_emission_by_name(), stopping our signal handler from running.
1420 * It's not enough to connect to the notebook's switch-page signal, because
1421 * ModestWizardDialog's "response" signal handler enables the buttons itself,
1422 * _after_ switching the page (understandably).
1423 * (Note that if we had, if we used g_signal_connect() instead of g_signal_connect_after()
1424 * then gtk_notebook_get_current_page() would return an incorrect value.)
1426 g_signal_connect_after (G_OBJECT (self), "response",
1427 G_CALLBACK (on_response), self);
1429 /* This is to show a confirmation dialog when the user hits cancel */
1430 g_signal_connect (G_OBJECT (self), "response",
1431 G_CALLBACK (on_response_before), self);
1433 g_signal_connect (G_OBJECT (self), "delete-event",
1434 G_CALLBACK (on_delete_event), self);
1436 /* Reset dirty, because there was no user input until now */
1437 priv->dirty = FALSE;
1439 /* When this window is shown, hibernation should not be possible,
1440 * because there is no sensible way to save the state: */
1441 modest_window_mgr_prevent_hibernation_while_window_is_shown (
1442 modest_runtime_get_window_mgr (), GTK_WINDOW (self));
1444 /* Load provider presets */
1445 g_object_ref (self);
1446 g_thread_create (presets_loader, self, FALSE, NULL);
1448 priv->settings = modest_account_settings_new ();
1450 check_support_of_protocols (self);
1453 ModestEasysetupWizardDialog*
1454 modest_easysetup_wizard_dialog_new (void)
1457 return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
1461 create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
1463 ModestEasysetupWizardDialogPrivate *priv;
1464 GtkNotebook *notebook = NULL;
1466 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1469 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1471 if (!priv->page_user_details) {
1472 priv->page_user_details = create_page_user_details (self);
1475 /* Create the custom pages: */
1476 if(!(priv->page_custom_incoming)) {
1477 priv->page_custom_incoming = create_page_custom_incoming (self);
1480 /* TODO: only if needed */
1481 if(!(priv->page_custom_outgoing)) {
1482 priv->page_custom_outgoing = create_page_custom_outgoing (self);
1485 if(!(priv->page_complete_customsetup)) {
1486 priv->page_complete_customsetup = create_page_complete_custom (self);
1489 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_user_details)))
1490 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_user_details,
1491 _("mcen_ti_emailsetup_userdetails"));
1493 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_incoming)))
1494 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_incoming,
1495 _("mcen_ti_emailsetup_incomingdetails"));
1497 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_outgoing)))
1498 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_outgoing,
1499 _("mcen_ti_emailsetup_outgoingdetails"));
1501 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_customsetup)))
1502 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_customsetup,
1503 _("mcen_ti_emailsetup_complete"));
1505 /* This is unnecessary with GTK+ 2.10: */
1506 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1510 create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self)
1512 ModestEasysetupWizardDialogPrivate *priv;
1513 GtkNotebook *notebook = NULL;
1515 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1518 /* Create the easysetup-specific pages: */
1519 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1520 if(!priv->page_complete_easysetup)
1521 priv->page_complete_easysetup = create_page_complete_easysetup (self);
1523 if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_easysetup)))
1524 modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_easysetup,
1525 _("mcen_ti_emailsetup_complete"));
1527 /* This is unnecessary with GTK+ 2.10: */
1528 modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
1533 remove_non_common_tabs (GtkNotebook *notebook,
1534 gboolean remove_user_details)
1537 /* The first 2 tabs are the common ones (welcome tab and the
1538 providers tab), so we always remove starting from the
1541 starting_tab = (remove_user_details) ? 2 : 3;
1542 while (gtk_notebook_get_n_pages (notebook) > starting_tab)
1543 gtk_notebook_remove_page (notebook, -1);
1547 on_missing_mandatory_data (ModestAccountProtocol *protocol,
1551 real_enable_buttons (MODEST_WIZARD_DIALOG (user_data), !missing);
1554 /* After the user details page,
1555 * the following pages depend on whether "Other" was chosen
1556 * in the provider combobox on the account page
1559 create_subsequent_pages (ModestEasysetupWizardDialog *self)
1561 ModestEasysetupWizardDialogPrivate *priv;
1562 ModestProviderPicker *picker;
1563 ModestProviderPickerIdType id_type;
1564 GtkNotebook *notebook;
1566 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1567 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
1568 id_type = modest_provider_picker_get_active_id_type (picker);
1569 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
1570 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1574 if (id_type == MODEST_PROVIDER_PICKER_ID_OTHER) {
1575 /* "Other..." was selected: */
1577 /* If we come from a rollbacked easysetup */
1578 if (priv->page_complete_easysetup) {
1579 remove_non_common_tabs (notebook, FALSE);
1580 priv->page_complete_easysetup = NULL;
1583 /* If we come from a rollbacked plugin protocol setup */
1584 if (priv->last_plugin_protocol_selected != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1585 remove_non_common_tabs (notebook, TRUE);
1586 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1587 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1588 priv->missing_data_signals = NULL;
1591 create_subsequent_customsetup_pages (self);
1593 /* If we come from a rollbacked custom setup */
1594 if (priv->page_custom_incoming) {
1595 remove_non_common_tabs (notebook, TRUE);
1596 init_user_page (priv);
1597 init_incoming_page (priv);
1598 init_outgoing_page (priv);
1599 init_user_page (priv);
1600 priv->page_complete_customsetup = NULL;
1603 /* It's a pluggable protocol and not a provider with presets */
1604 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
1605 ModestProtocol *protocol;
1607 ModestProtocolType proto_type;
1609 /* Get protocol data */
1610 proto_name = modest_provider_picker_get_active_provider_id (picker);
1611 protocol = modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
1612 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
1614 proto_type = modest_protocol_get_type_id (protocol);
1617 /* If we come from a rollbacked easy setup */
1618 if (priv->last_plugin_protocol_selected != proto_type &&
1619 priv->page_complete_easysetup) {
1620 remove_non_common_tabs (notebook, TRUE);
1621 init_user_page (priv);
1622 priv->page_complete_easysetup = NULL;
1625 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
1626 proto_type != priv->last_plugin_protocol_selected) {
1627 ModestPairList *tabs;
1629 gboolean first_page = TRUE;
1630 ModestWizardDialogResponseOverrideFunc response_override;
1632 /* Remember the last selected plugin protocol */
1633 priv->last_plugin_protocol_selected = proto_type;
1636 tabs = modest_account_protocol_get_easysetupwizard_tabs (MODEST_ACCOUNT_PROTOCOL (protocol));
1637 response_override = modest_account_protocol_get_wizard_response_override
1638 (MODEST_ACCOUNT_PROTOCOL (protocol));
1639 modest_wizard_dialog_set_response_override_handler (MODEST_WIZARD_DIALOG (self),
1641 tmp = (GSList *) tabs;
1643 ModestPair *pair = (ModestPair *) tmp->data;
1644 modest_easysetup_wizard_dialog_append_page (notebook,
1645 GTK_WIDGET (pair->second),
1646 (const gchar *) pair->first);
1648 gtk_container_set_focus_child (GTK_CONTAINER (notebook),
1649 GTK_WIDGET (pair->second));
1653 /* Connect signals */
1654 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (pair->second)) {
1655 priv->missing_data_signals =
1656 modest_signal_mgr_connect (priv->missing_data_signals,
1657 G_OBJECT (pair->second),
1658 "missing-mandatory-data",
1659 G_CALLBACK (on_missing_mandatory_data),
1663 g_free (pair->first);
1664 tmp = g_slist_next (tmp);
1665 /* Critical: if you don't show the page then the dialog will ignore it */
1666 /* gtk_widget_show (GTK_WIDGET (pair->second)); */
1668 modest_pair_list_free (tabs);
1670 g_free (proto_name);
1672 if (priv->last_plugin_protocol_selected !=
1673 MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1674 remove_non_common_tabs (notebook, TRUE);
1675 init_user_page (priv);
1676 priv->page_complete_easysetup = NULL;
1677 priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
1678 modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
1679 priv->missing_data_signals = NULL;
1681 if (!priv->page_user_details) {
1682 priv->page_user_details = create_page_user_details (self);
1683 modest_easysetup_wizard_dialog_append_page (notebook,
1684 priv->page_user_details,
1685 _("mcen_ti_emailsetup_userdetails"));
1689 /* Create the easysetup pages: */
1690 create_subsequent_easysetup_pages (self);
1696 util_get_default_servername_from_email_address (const gchar* email_address, ModestProtocolType protocol_type)
1698 const gchar* hostname = NULL;
1701 ModestProtocolRegistry *protocol_registry;
1702 ModestProtocol *protocol;
1707 at = g_utf8_strchr (email_address, -1, '@');
1708 if (!at || (g_utf8_strlen (at, -1) < 2))
1711 domain = g_utf8_next_char (at);
1715 protocol_registry = modest_runtime_get_protocol_registry ();
1716 protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
1718 if (modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS) ||
1719 modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS)) {
1720 hostname = modest_protocol_get_name (protocol);
1726 return g_strdup_printf ("%s.%s", hostname, domain);
1730 set_default_custom_servernames (ModestEasysetupWizardDialog *self)
1732 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1734 if (!priv->entry_incomingserver)
1737 /* Set a default domain for the server, based on the email address,
1738 * if no server name was already specified.
1740 if (priv->entry_user_email
1741 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED) == 0)) {
1742 const ModestProtocolType protocol_type = modest_servertype_picker_get_active_servertype (
1743 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
1745 /* This could happen when the combo box has still no active iter */
1746 if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
1747 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1748 gchar* servername = util_get_default_servername_from_email_address (email_address,
1751 /* Do not set the INCOMING_CHANGED flag because of this edit */
1752 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1753 hildon_entry_set_text (HILDON_ENTRY (priv->entry_incomingserver), servername);
1754 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
1756 g_free (servername);
1760 /* Set a default domain for the server, based on the email address,
1761 * if no server name was already specified.
1763 if (!priv->entry_outgoingserver)
1766 if (priv->entry_user_email
1767 && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED) == 0)) {
1768 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
1770 gchar* servername = util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOLS_TRANSPORT_SMTP);
1772 /* Do not set the OUTGOING_CHANGED flag because of this edit */
1773 g_signal_handlers_block_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1774 hildon_entry_set_text (HILDON_ENTRY (priv->entry_outgoingserver), servername);
1775 g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
1777 g_free (servername);
1782 get_entered_account_title (ModestEasysetupWizardDialog *self)
1784 ModestEasysetupWizardDialogPrivate *priv;
1785 const gchar* account_title;
1787 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
1788 account_title = hildon_entry_get_text (HILDON_ENTRY (priv->entry_account_title));
1790 if (!account_title || (g_utf8_strlen (account_title, -1) == 0)) {
1793 /* Strip it of whitespace at the start and end: */
1794 gchar *result = g_strdup (account_title);
1795 result = g_strstrip (result);
1800 if (g_utf8_strlen (result, -1) == 0) {
1810 on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *next_page)
1812 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1813 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1814 ModestProtocolRegistry *protocol_registry;
1816 protocol_registry = modest_runtime_get_protocol_registry ();
1818 /* if are browsing pages previous to the last one, then we have pending settings in
1820 if (next_page != NULL)
1821 priv->pending_load_settings = TRUE;
1823 /* Do extra validation that couldn't be done for every key press,
1824 * either because it was too slow,
1825 * or because it requires interaction:
1827 if (current_page == priv->page_account_details) {
1828 /* Check that the title is not already in use: */
1829 gchar* account_title = get_entered_account_title (self);
1833 /* Aavoid a clash with an existing display name: */
1834 const gboolean name_in_use = modest_account_mgr_account_with_display_name_exists (
1835 priv->account_manager, account_title);
1836 g_free (account_title);
1839 /* Warn the user via a dialog: */
1840 hildon_banner_show_information(NULL, NULL, _("mail_ib_account_name_already_existing"));
1845 /* Make sure that the subsequent pages are appropriate for the provider choice. */
1846 create_subsequent_pages (self);
1848 } else if (current_page == priv->page_user_details) {
1849 /* Check that the email address is valud: */
1850 const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
1851 if ((!email_address) || (g_utf8_strlen (email_address, -1) == 0))
1854 if (!modest_text_utils_validate_email_address (email_address, NULL)) {
1855 /* Warn the user via a dialog: */
1856 hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email"));
1858 /* Return focus to the email address entry: */
1859 gtk_widget_grab_focus (priv->entry_user_email);
1860 gtk_editable_select_region (GTK_EDITABLE (priv->entry_user_email), 0, -1);
1864 } else if (current_page == priv->page_custom_incoming ||
1865 current_page == priv->page_custom_outgoing) {
1867 const gchar *hostname;
1868 GtkWidget *entry = (current_page == priv->page_custom_incoming) ?
1869 priv->entry_incomingserver :
1870 priv->entry_outgoingserver;
1872 hostname = gtk_entry_get_text (GTK_ENTRY (entry));
1873 if (!modest_text_utils_validate_domain_name (hostname)) {
1875 modest_platform_information_banner (NULL, NULL, _("mcen_ib_invalid_servername"));
1877 /* Return focus to the email address entry: */
1878 gtk_widget_grab_focus (entry);
1879 gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
1885 if (next_page == priv->page_custom_incoming) {
1886 set_default_custom_servernames (self);
1887 } else if (next_page == priv->page_custom_outgoing) {
1888 set_default_custom_servernames (self);
1890 /* Check if the server supports secure authentication */
1891 if (modest_security_options_view_auth_check (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security)))
1892 if (!check_has_supported_auth_methods (self))
1894 gtk_widget_show (priv->outgoing_security);
1897 /* If this is the last page, and this is a click on Finish,
1898 * then attempt to create the dialog.
1901 current_page != priv->page_account_details) /* This is NULL when this is a click on Finish. */
1903 if (priv->pending_load_settings) {
1904 save_to_settings (self);
1907 /* We check if there's already another account with the same configuration */
1908 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
1909 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
1913 modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
1920 static gboolean entry_is_empty (GtkWidget *entry)
1925 const gchar* text = hildon_entry_get_text (HILDON_ENTRY (entry));
1926 if ((!text) || (g_utf8_strlen (text, -1) == 0))
1929 /* Strip it of whitespace at the start and end: */
1930 gchar *stripped = g_strdup (text);
1931 stripped = g_strstrip (stripped);
1936 const gboolean result = (g_utf8_strlen (stripped, -1) == 0);
1944 real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next)
1946 GtkNotebook *notebook = NULL;
1947 gboolean is_finish_tab;
1949 ModestEasysetupWizardDialogPrivate *priv;
1952 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (dialog);
1953 g_object_get (dialog, "wizard-notebook", ¬ebook, NULL);
1955 /* Disable the Finish button until we are on the last page,
1956 * because HildonWizardDialog enables this for all but the
1958 current = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
1959 is_finish_tab = ((current == priv->page_complete_easysetup) ||
1960 (current == priv->page_complete_customsetup));
1962 if (is_finish_tab) {
1963 /* Disable Next on the last page no matter what the
1965 enable_next = FALSE;
1967 /* Not the last one */
1968 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1969 MODEST_WIZARD_DIALOG_FINISH,
1972 /* If the check support is not done then do not enable
1973 the wizard to continue */
1974 enable_next = enable_next && priv->check_support_done;
1977 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
1978 MODEST_WIZARD_DIALOG_NEXT,
1983 on_enable_buttons (ModestWizardDialog *dialog, GtkWidget *current_page)
1985 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
1986 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
1988 gboolean enable_next = TRUE;
1989 if (current_page == priv->page_welcome) {
1991 } else if (current_page == priv->page_account_details) {
1992 /* The account details title is mandatory: */
1993 if (entry_is_empty(priv->entry_account_title))
1994 enable_next = FALSE;
1995 } else if (current_page == priv->page_user_details) {
1996 /* The user details username is mandatory: */
1997 if (entry_is_empty(priv->entry_user_username))
1998 enable_next = FALSE;
2000 /* The user details email address is mandatory: */
2001 if (enable_next && entry_is_empty (priv->entry_user_email))
2002 enable_next = FALSE;
2003 } else if (current_page == priv->page_custom_incoming) {
2004 /* The custom incoming server is mandatory: */
2005 if (entry_is_empty(priv->entry_incomingserver))
2006 enable_next = FALSE;
2007 } else if (MODEST_IS_EASYSETUP_WIZARD_PAGE (current_page)) {
2008 enable_next = !modest_easysetup_wizard_page_validate (
2009 MODEST_EASYSETUP_WIZARD_PAGE (current_page));
2012 /* Enable/disable buttons */
2013 real_enable_buttons (dialog, enable_next);
2017 modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *klass)
2019 GObjectClass *object_class = G_OBJECT_CLASS (klass);
2020 g_type_class_add_private (klass, sizeof (ModestEasysetupWizardDialogPrivate));
2023 object_class->dispose = modest_easysetup_wizard_dialog_dispose;
2024 object_class->finalize = modest_easysetup_wizard_dialog_finalize;
2026 /* Provide a vfunc implementation so we can decide
2027 * when to enable/disable the prev/next buttons.
2029 ModestWizardDialogClass *base_klass = (ModestWizardDialogClass*)(klass);
2030 base_klass->before_next = on_before_next;
2031 base_klass->enable_buttons = on_enable_buttons;
2032 base_klass->update_model = on_update_model;
2033 base_klass->save = on_save;
2038 * @self: a #ModestEasysetupWizardDialog
2040 * takes information from all the wizard and stores it in settings
2043 save_to_settings (ModestEasysetupWizardDialog *self)
2045 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2047 gchar *provider_id = NULL;
2048 gchar* display_name;
2049 const gchar *username, *password;
2050 gchar *store_hostname, *transport_hostname;
2051 guint store_port, transport_port;
2052 ModestProtocolRegistry *protocol_registry;
2053 ModestProtocolType store_protocol, transport_protocol;
2054 ModestProtocolType store_security, transport_security;
2055 ModestProtocolType store_auth_protocol, transport_auth_protocol;
2056 ModestServerAccountSettings *store_settings, *transport_settings;
2057 const gchar *fullname, *email_address;
2058 ModestProviderPicker *picker;
2059 ModestProviderPickerIdType id_type;
2061 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2062 picker = MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker);
2063 protocol_registry = modest_runtime_get_protocol_registry ();
2065 /* Get details from the specified presets: */
2066 id_type = modest_provider_picker_get_active_id_type (picker);
2067 provider_id = modest_provider_picker_get_active_provider_id (picker);
2069 /* Let the plugin save the settings. We do a return in order
2070 to save an indentation level */
2071 if (id_type == MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL) {
2072 ModestProtocol *protocol;
2074 protocol = modest_protocol_registry_get_protocol_by_name (
2075 modest_runtime_get_protocol_registry (),
2076 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
2079 if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
2080 gint n_pages, i = 0;
2081 GtkNotebook *notebook;
2082 GList *wizard_pages = NULL;
2084 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
2085 n_pages = gtk_notebook_get_n_pages (notebook);
2086 for (i = 0; i < n_pages; i++) {
2087 GtkWidget *page = gtk_notebook_get_nth_page (notebook, i);
2088 if (MODEST_IS_EASYSETUP_WIZARD_PAGE (page))
2089 wizard_pages = g_list_append (wizard_pages, page);
2091 modest_account_protocol_save_wizard_settings (MODEST_ACCOUNT_PROTOCOL (protocol),
2094 g_list_free (wizard_pages);
2096 g_warning ("The selected protocol is a plugin protocol "//
2097 "but it's not a ModestAccountProtocol");
2100 g_free (provider_id);
2104 /* username and password (for both incoming and outgoing): */
2105 username = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_username));
2106 password = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_password));
2108 store_settings = modest_account_settings_get_store_settings (priv->settings);
2109 transport_settings = modest_account_settings_get_transport_settings (priv->settings);
2111 /* Incoming server: */
2112 /* Note: We need something as default for the transport store protocol values,
2113 * or modest_account_mgr_add_server_account will fail. */
2115 store_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2116 store_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2117 store_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2120 ModestProtocolType store_provider_server_type;
2121 gboolean store_provider_use_alternate_port;
2123 store_hostname = modest_presets_get_server (priv->presets, provider_id,
2126 store_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2129 store_security = modest_presets_get_info_server_security (priv->presets,
2132 store_auth_protocol = modest_presets_get_info_server_auth (priv->presets,
2135 store_provider_use_alternate_port = modest_presets_get_info_server_use_alternate_port (priv->presets,
2139 /* We don't check for SMTP here as that is impossible for an incoming server. */
2140 if (store_provider_server_type == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID)
2141 store_protocol = MODEST_PROTOCOLS_STORE_POP;
2143 store_protocol = store_provider_server_type;
2145 /* we check if there is a *special* port */
2146 special_port = modest_presets_get_port (priv->presets, provider_id, TRUE /* incoming */);
2147 if (special_port != 0) {
2148 store_port = special_port;
2150 gboolean use_alternate_port = FALSE;
2151 if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (),
2153 use_alternate_port = TRUE;
2154 store_port = get_port_from_protocol(store_provider_server_type, use_alternate_port);
2157 modest_server_account_settings_set_security_protocol (store_settings,
2159 modest_server_account_settings_set_auth_protocol (store_settings,
2160 store_auth_protocol);
2161 if (store_port != 0)
2162 modest_server_account_settings_set_port (store_settings, store_port);
2164 /* Use custom pages because no preset was specified: */
2165 store_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_incomingserver) ));
2166 store_protocol = modest_servertype_picker_get_active_servertype (
2167 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2169 modest_security_options_view_save_settings (
2170 MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
2174 /* now we store the common store account settings */
2175 modest_server_account_settings_set_hostname (store_settings, store_hostname);
2176 modest_server_account_settings_set_username (store_settings, username);
2177 modest_server_account_settings_set_password (store_settings, password);
2178 modest_server_account_settings_set_protocol (store_settings, store_protocol);
2180 g_object_unref (store_settings);
2181 g_free (store_hostname);
2183 /* Outgoing server: */
2184 transport_hostname = NULL;
2185 transport_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
2186 transport_security = MODEST_PROTOCOLS_CONNECTION_NONE;
2187 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2191 ModestProtocolType transport_provider_server_type;
2192 ModestProtocolType transport_provider_security;
2196 transport_hostname = modest_presets_get_server (priv->presets, provider_id,
2197 FALSE /* transport */);
2199 transport_provider_server_type = modest_presets_get_info_server_type (priv->presets,
2201 FALSE /* transport */);
2202 transport_provider_security = modest_presets_get_info_server_security (priv->presets,
2204 FALSE /* transport */);
2206 /* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
2207 transport_protocol = transport_provider_server_type;
2208 transport_security = transport_provider_security;
2209 is_secure = modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (),
2210 transport_security);
2212 /* we check if there is a *special* port */
2213 special_port = modest_presets_get_port (priv->presets, provider_id,
2214 FALSE /* transport */);
2215 if (special_port != 0) {
2216 transport_port = special_port;
2218 gboolean use_alternate_port = FALSE;
2219 if (transport_security == MODEST_PROTOCOLS_CONNECTION_SSL)
2220 use_alternate_port = TRUE;
2221 transport_port = get_port_from_protocol(transport_provider_server_type, use_alternate_port);
2225 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_PASSWORD;
2227 transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
2229 modest_server_account_settings_set_security_protocol (transport_settings,
2230 transport_security);
2231 modest_server_account_settings_set_auth_protocol (transport_settings,
2232 transport_auth_protocol);
2233 if (transport_port != 0)
2234 modest_server_account_settings_set_port (transport_settings,
2237 ModestProtocolRegistry *registry;
2238 ModestProtocol *store_proto;
2240 registry = modest_runtime_get_protocol_registry ();
2241 /* Use custom pages because no preset was specified: */
2242 transport_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver) ));
2244 store_proto = modest_protocol_registry_get_protocol_by_type (registry,
2247 if (transport_protocol == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
2248 /* fallback to SMTP if none was specified */
2249 g_warning ("No transport protocol was specified for store %d (%s)",
2250 modest_protocol_get_type_id (store_proto),
2251 modest_protocol_get_display_name (store_proto));
2252 transport_protocol = MODEST_PROTOCOLS_TRANSPORT_SMTP;
2255 modest_security_options_view_save_settings (
2256 MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security),
2260 /* now we store the common transport account settings */
2261 modest_server_account_settings_set_hostname (transport_settings, transport_hostname);
2262 modest_server_account_settings_set_username (transport_settings, username);
2263 modest_server_account_settings_set_password (transport_settings, password);
2264 modest_server_account_settings_set_protocol (transport_settings, transport_protocol);
2266 g_object_unref (transport_settings);
2267 g_free (transport_hostname);
2269 fullname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_name));
2270 email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
2271 modest_account_settings_set_fullname (priv->settings, fullname);
2272 modest_account_settings_set_email_address (priv->settings, email_address);
2273 /* we don't set retrieve type to preserve advanced settings if
2274 any. By default account settings are set to headers only */
2276 /* Save the connection-specific SMTP server accounts. */
2277 if (priv->checkbox_outgoing_smtp_specific) {
2278 modest_account_settings_set_use_connection_specific_smtp
2280 hildon_check_button_get_active(HILDON_CHECK_BUTTON(priv->checkbox_outgoing_smtp_specific)));
2283 display_name = get_entered_account_title (self);
2284 modest_account_settings_set_display_name (priv->settings, display_name);
2285 g_free (display_name);
2286 g_free (provider_id);
2291 on_update_model (ModestWizardDialog *dialog)
2293 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2294 save_to_settings (self);
2299 on_save (ModestWizardDialog *dialog)
2301 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
2302 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2304 save_to_settings (self);
2306 if (modest_account_mgr_check_already_configured_account (priv->account_manager, priv->settings)) {
2307 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
2311 return modest_account_mgr_add_account_from_settings (priv->account_manager, priv->settings);
2317 check_for_supported_auth_methods (ModestEasysetupWizardDialog* self)
2319 GError *error = NULL;
2320 ModestProtocolType protocol_type;
2321 const gchar* hostname;
2322 const gchar* username;
2323 ModestProtocolType security_protocol_incoming_type;
2324 ModestProtocolRegistry *registry;
2326 GList *list_auth_methods;
2327 ModestEasysetupWizardDialogPrivate *priv;
2329 priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2330 registry = modest_runtime_get_protocol_registry ();
2331 protocol_type = modest_servertype_picker_get_active_servertype (
2332 MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));
2333 hostname = gtk_entry_get_text(GTK_ENTRY(priv->entry_incomingserver));
2334 username = gtk_entry_get_text(GTK_ENTRY(priv->entry_user_username));
2335 security_protocol_incoming_type = modest_security_options_view_get_connection_protocol
2336 (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security));
2337 port_num = get_port_from_protocol(protocol_type, FALSE);
2338 list_auth_methods = modest_utils_get_supported_secure_authentication_methods (protocol_type, hostname, port_num,
2339 username, GTK_WINDOW (self), &error);
2341 if (list_auth_methods) {
2342 /* TODO: Select the correct method */
2345 for (method = list_auth_methods; method != NULL; method = g_list_next(method)) {
2346 ModestProtocolType auth_protocol_type = (ModestProtocolType) (GPOINTER_TO_INT(method->data));
2347 if (modest_protocol_registry_protocol_type_has_tag (registry, auth_protocol_type,
2348 MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS)) {
2349 list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type));
2353 g_list_free(list_auth_methods);
2359 if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
2360 error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
2362 modest_platform_information_banner (GTK_WIDGET(self), NULL,
2363 _("mcen_ib_unableto_discover_auth_methods"));
2367 g_error_free(error);
2373 check_has_supported_auth_methods(ModestEasysetupWizardDialog* self)
2375 GList* methods = check_for_supported_auth_methods(self);
2381 g_list_free(methods);
2386 check_support_progress_pulse (gpointer userdata)
2388 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2389 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2391 if (priv->destroyed) {
2392 priv->check_support_progress_pulse_id = 0;
2396 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2402 check_support_show_progress (gpointer userdata)
2404 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2405 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2407 priv->check_support_show_progress_id = 0;
2409 if (priv->destroyed)
2412 gtk_widget_show (priv->check_support_progress);
2413 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress));
2415 priv->check_support_progress_pulse_id = g_timeout_add (200, check_support_progress_pulse, self);
2421 check_support_callback (ModestAccountProtocol *protocol,
2425 ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata;
2426 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2428 priv->pending_check_support --;
2430 if (priv->check_support_show_progress_id > 0) {
2431 g_source_remove (priv->check_support_show_progress_id);
2432 priv->check_support_show_progress_id = 0;
2435 if (priv->check_support_progress_pulse_id > 0) {
2436 g_source_remove (priv->check_support_progress_pulse_id);
2437 priv->check_support_progress_pulse_id = 0;
2440 if (priv->pending_check_support == 0) {
2441 priv->check_support_done = TRUE;
2443 if (!priv->destroyed) {
2445 fill_providers (self);
2446 gtk_widget_hide (priv->check_support_progress);
2447 invoke_enable_buttons_vfunc (self);
2450 g_object_unref (self);
2455 check_support_of_protocols (ModestEasysetupWizardDialog *self)
2457 ModestProtocolRegistry *registry;
2458 GSList *provider_protos, *node;
2459 ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
2461 registry = modest_runtime_get_protocol_registry ();
2462 provider_protos = modest_protocol_registry_get_by_tag (registry,
2463 MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS);
2465 for (node = provider_protos; node != NULL; node = g_slist_next (node)) {
2466 ModestProtocol *proto = MODEST_PROTOCOL (node->data);
2468 if (!modest_protocol_registry_protocol_type_has_tag (registry,
2469 modest_protocol_get_type_id (proto),
2470 MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS))
2473 if (modest_protocol_registry_protocol_type_has_tag
2475 modest_protocol_get_type_id (proto),
2476 MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS)) {
2477 /* Check if there's already an account configured with this account type */
2478 if (modest_account_mgr_singleton_protocol_exists (modest_runtime_get_account_mgr (),
2479 modest_protocol_get_type_id (proto)))
2483 if (MODEST_ACCOUNT_PROTOCOL (proto)) {
2484 priv->pending_check_support ++;
2485 modest_account_protocol_check_support (MODEST_ACCOUNT_PROTOCOL (proto),
2486 check_support_callback,
2487 g_object_ref (self));
2490 g_slist_free (provider_protos);
2492 if (priv->pending_check_support > 0) {
2493 priv->check_support_show_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 1000,
2494 check_support_show_progress,
2495 g_object_ref (self), g_object_unref);
2497 priv->check_support_done = TRUE;
2499 invoke_enable_buttons_vfunc (self);