1 /* Copyright (c) 2007, Nokia Corporation
7 #include "modest-easysetup-wizard.h"
8 #include <glib/gi18n.h>
9 #include <gtk/gtknotebook.h>
10 #include <gtk/gtkvbox.h>
11 #include <gtk/gtklabel.h>
12 #include <gtk/gtkcombobox.h>
13 #include <gtk/gtkentry.h>
14 #include <gtk/gtkbutton.h>
15 #include <gtk/gtkcheckbutton.h>
16 #include <gtk/gtkmessagedialog.h>
17 #include <hildon-widgets/hildon-caption.h>
18 #include "modest-easysetup-country-combo-box.h"
19 #include "modest-easysetup-provider-combo-box.h"
20 #include "modest-easysetup-servertype-combo-box.h"
21 #include "modest-easysetup-serversecurity-combo-box.h"
22 #include "modest-easysetup-secureauth-combo-box.h"
23 #include "modest-validating-entry.h"
24 #include "modest-text-utils.h"
25 #include "modest-account-mgr/modest-account-mgr.h"
26 #include <gconf/gconf-client.h>
27 #include <string.h> /* For strlen(). */
29 #define EXAMPLE_EMAIL_ADDRESS "first.last@provider.com"
31 G_DEFINE_TYPE (ModestEasysetupWizardDialog, modest_easysetup_wizard_dialog, MODEST_TYPE_WIZARD_DIALOG);
33 #define WIZARD_DIALOG_GET_PRIVATE(o) \
34 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, ModestEasysetupWizardDialogPrivate))
36 typedef struct _ModestEasysetupWizardDialogPrivate ModestEasysetupWizardDialogPrivate;
38 struct _ModestEasysetupWizardDialogPrivate
40 ModestPresets *presets;
44 modest_easysetup_wizard_dialog_get_property (GObject *object, guint property_id,
45 GValue *value, GParamSpec *pspec)
47 switch (property_id) {
49 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
54 modest_easysetup_wizard_dialog_set_property (GObject *object, guint property_id,
55 const GValue *value, GParamSpec *pspec)
57 switch (property_id) {
59 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
64 modest_easysetup_wizard_dialog_dispose (GObject *object)
66 if (G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose)
67 G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose (object);
71 modest_easysetup_wizard_dialog_finalize (GObject *object)
73 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (object);
74 ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
76 if (self->account_manager)
77 g_object_unref (G_OBJECT (self->account_manager));
80 modest_presets_destroy (priv->presets);
82 G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->finalize (object);
86 show_error (GtkWindow *parent_window, const gchar* text);
89 create_account (ModestEasysetupWizardDialog *self);
92 create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self);
95 set_default_custom_servernames(ModestEasysetupWizardDialog *dialog);
98 invoke_enable_buttons_vfunc (ModestEasysetupWizardDialog *wizard_dialog)
100 ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog);
102 /* Call the vfunc, which may be overridden by derived classes: */
103 if (klass->enable_buttons) {
104 GtkNotebook *notebook = NULL;
105 g_object_get (wizard_dialog, "wizard-notebook", ¬ebook, NULL);
107 const gint current_page_num = gtk_notebook_get_current_page (notebook);
108 if (current_page_num == -1)
111 GtkWidget* current_page_widget = gtk_notebook_get_nth_page (notebook, current_page_num);
112 (*(klass->enable_buttons))(MODEST_WIZARD_DIALOG (wizard_dialog), current_page_widget);
117 on_caption_entry_changed (GtkEditable *editable, gpointer user_data)
119 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
121 invoke_enable_buttons_vfunc(self);
125 on_caption_combobox_changed (GtkComboBox *widget, gpointer user_data)
127 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
129 invoke_enable_buttons_vfunc(self);
132 /** This is a convenience function to create a caption containing a mandatory widget.
133 * When the widget is edited, the enable_buttons() vfunc will be called.
135 static GtkWidget* create_caption_new_with_asterix(ModestEasysetupWizardDialog *self,
140 HildonCaptionStatus flag)
142 GtkWidget *caption = hildon_caption_new (group, value, control, icon, flag);
144 /* The translated strings seem to already contain the *,
145 * but this code can be used if that is not true in future.
148 /* Add a * character to indicate mandatory fields,
149 * as specified in our "Email UI Specification": */
150 if (flag == HILDON_CAPTION_MANDATORY) {
151 gchar* title = g_strdup_printf("%s*", value);
152 caption = hildon_caption_new (group, title, control, icon, flag);
156 caption = hildon_caption_new (group, value, control, icon, flag);
159 /* Connect to the appropriate changed signal for the widget,
160 * so we can ask for the prev/next buttons to be enabled/disabled appropriately:
162 if (GTK_IS_ENTRY (control)) {
163 g_signal_connect (G_OBJECT (control), "changed",
164 G_CALLBACK (on_caption_entry_changed), self);
167 else if (GTK_IS_COMBO_BOX (control)) {
168 g_signal_connect (G_OBJECT (control), "changed",
169 G_CALLBACK (on_caption_combobox_changed), self);
176 create_page_welcome (ModestEasysetupWizardDialog *self)
178 GtkWidget *box = gtk_vbox_new (FALSE, 2);
179 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_intro"));
180 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
181 gtk_widget_show (label);
182 gtk_widget_show (GTK_WIDGET (box));
183 return GTK_WIDGET (box);
187 on_combo_account_country (GtkComboBox *widget, gpointer user_data)
189 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
191 ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
193 /* Fill the providers combo, based on the selected country: */
194 gint mcc_id = easysetup_country_combo_box_get_active_country_id (
195 EASYSETUP_COUNTRY_COMBO_BOX (self->combo_account_country));
196 easysetup_provider_combo_box_fill (
197 EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider), priv->presets, mcc_id);
201 on_combo_account_serviceprovider (GtkComboBox *widget, gpointer user_data)
203 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
205 ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
207 /* Fill the providers combo, based on the selected country: */
208 gchar* provider_id = easysetup_provider_combo_box_get_active_provider_id (
209 EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider));
211 gchar* domain_name = NULL;
213 domain_name = modest_presets_get_domain (priv->presets, provider_id);
216 domain_name = g_strdup (EXAMPLE_EMAIL_ADDRESS);
218 if (self->entry_user_email)
219 gtk_entry_set_text (GTK_ENTRY (self->entry_user_email), domain_name);
221 g_free (domain_name);
223 g_free (provider_id);
228 create_page_account_details (ModestEasysetupWizardDialog *self)
230 GtkWidget *box = gtk_vbox_new (FALSE, 2);
231 GtkWidget *label = gtk_label_new(_("mcen_ia_accountdetails"));
232 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 2);
233 gtk_widget_show (label);
235 /* Create a size group to be used by all captions.
236 * Note that HildonCaption does not create a default size group if we do not specify one.
237 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
238 GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
240 /* The country widgets: */
241 self->combo_account_country = GTK_WIDGET (easysetup_country_combo_box_new ());
242 GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_country"),
243 self->combo_account_country, NULL, HILDON_CAPTION_OPTIONAL);
244 gtk_widget_show (self->combo_account_country);
245 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
246 gtk_widget_show (caption);
248 /* connect to country combo's changed signal, so we can fill the provider combo: */
249 g_signal_connect (G_OBJECT (self->combo_account_country), "changed",
250 G_CALLBACK (on_combo_account_country), self);
253 /* The service provider widgets: */
254 self->combo_account_serviceprovider = GTK_WIDGET (easysetup_provider_combo_box_new ());
256 caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_serviceprovider"),
257 self->combo_account_serviceprovider, NULL, HILDON_CAPTION_OPTIONAL);
258 gtk_widget_show (self->combo_account_serviceprovider);
259 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
260 gtk_widget_show (caption);
262 /* connect to providers combo's changed signal, so we can fill the email address: */
263 g_signal_connect (G_OBJECT (self->combo_account_serviceprovider), "changed",
264 G_CALLBACK (on_combo_account_serviceprovider), self);
266 /* TODO: Default to the current country somehow.
267 * But I don't know how to get the information that is specified in the
268 * "Language and region" control panel. It does not seem be anywhere in gconf. murrayc.
270 * This is probably not the best choice of gconf key:
271 * This is the "mcc used in the last pairing", ie. the last connection you made.
272 * set by the osso-operator-wizard package, suggested by Dirk-Jan Binnema.
275 GConfClient *client = gconf_client_get_default ();
276 GError *error = NULL;
277 const gchar* key = "/apps/osso/operator-wizard/last_mcc";
278 gint mcc_id = gconf_client_get_int(client, key, &error);
284 g_warning ("Error getting gconf key %s:\n%s", key, error->message);
285 g_error_free (error);
291 /* Note that gconf_client_get_int() seems to return 0 without an error if the key is not there
292 * This might just be a Maemo bug.
296 /* For now, we default to Finland when there is nothing better: */
300 easysetup_country_combo_box_set_active_country_id (
301 EASYSETUP_COUNTRY_COMBO_BOX (self->combo_account_country), mcc_id);
304 /* The description widgets: */
305 self->entry_account_title = GTK_WIDGET (easysetup_validating_entry_new ());
306 gtk_entry_set_text( GTK_ENTRY (self->entry_account_title),
307 _("mcen_ia_emailsetup_defaultname")); /* default description. */
308 /* TODO: Check if an account with this default name exists, and increment if necessary. */
310 caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_account_title"),
311 self->entry_account_title, NULL, HILDON_CAPTION_MANDATORY);
312 gtk_widget_show (self->entry_account_title);
313 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
314 gtk_widget_show (caption);
316 /* Prevent the use of some characters in the account title,
317 * as required by our UI specification: */
318 GList *list_prevent = NULL;
319 list_prevent = g_list_append (list_prevent, "\\");
320 list_prevent = g_list_append (list_prevent, "/");
321 list_prevent = g_list_append (list_prevent, ":");
322 list_prevent = g_list_append (list_prevent, "*");
323 list_prevent = g_list_append (list_prevent, "?");
324 list_prevent = g_list_append (list_prevent, "\""); /* The UI spec mentions “, but maybe means ", maybe both. */
325 list_prevent = g_list_append (list_prevent, "“");
326 list_prevent = g_list_append (list_prevent, "<");
327 list_prevent = g_list_append (list_prevent, ">");
328 list_prevent = g_list_append (list_prevent, "|");
329 list_prevent = g_list_append (list_prevent, "^");
330 easysetup_validating_entry_set_unallowed_characters (
331 EASYSETUP_VALIDATING_ENTRY (self->entry_account_title), list_prevent);
332 g_list_free (list_prevent);
334 /* Set max length as in the UI spec:
335 * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
336 gtk_entry_set_max_length (GTK_ENTRY (self->entry_account_title), 64);
338 gtk_widget_show (GTK_WIDGET (box));
340 return GTK_WIDGET (box);
344 create_page_user_details (ModestEasysetupWizardDialog *self)
346 GtkWidget *box = gtk_vbox_new (FALSE, 2);
348 /* Create a size group to be used by all captions.
349 * Note that HildonCaption does not create a default size group if we do not specify one.
350 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
351 GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
353 /* The name widgets: */
354 self->entry_user_name = GTK_WIDGET (easysetup_validating_entry_new ());
355 /* Set max length as in the UI spec:
356 * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
357 gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_name), 64);
358 GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup,
359 _("mcen_li_emailsetup_name"), self->entry_user_name, NULL, HILDON_CAPTION_OPTIONAL);
360 gtk_widget_show (self->entry_user_name);
361 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
362 gtk_widget_show (caption);
364 /* Prevent the use of some characters in the name,
365 * as required by our UI specification: */
366 GList *list_prevent = NULL;
367 list_prevent = g_list_append (list_prevent, "<");
368 list_prevent = g_list_append (list_prevent, ">");
369 easysetup_validating_entry_set_unallowed_characters (
370 EASYSETUP_VALIDATING_ENTRY (self->entry_user_name), list_prevent);
371 g_list_free (list_prevent);
373 /* The username widgets: */
374 self->entry_user_username = GTK_WIDGET (easysetup_validating_entry_new ());
375 caption = create_caption_new_with_asterix (self, sizegroup, _("mail_fi_username"),
376 self->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
377 gtk_widget_show (self->entry_user_username);
378 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
379 gtk_widget_show (caption);
381 /* Prevent the use of some characters in the username,
382 * as required by our UI specification: */
383 easysetup_validating_entry_set_unallowed_characters_whitespace (
384 EASYSETUP_VALIDATING_ENTRY (self->entry_user_username));
386 /* Set max length as in the UI spec:
387 * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
388 gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_username), 64);
390 /* The password widgets: */
391 self->entry_user_password = gtk_entry_new ();
392 gtk_entry_set_visibility (GTK_ENTRY (self->entry_user_password), FALSE);
393 /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_user_password), '*'); */
394 caption = create_caption_new_with_asterix (self, sizegroup,
395 _("mail_fi_password"), self->entry_user_password, NULL, HILDON_CAPTION_OPTIONAL);
396 gtk_widget_show (self->entry_user_password);
397 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
398 gtk_widget_show (caption);
400 /* The email address widgets: */
401 self->entry_user_email = GTK_WIDGET (easysetup_validating_entry_new ());
402 caption = create_caption_new_with_asterix (self, sizegroup,
403 _("mcen_li_emailsetup_email_address"), self->entry_user_email, NULL, HILDON_CAPTION_MANDATORY);
404 gtk_entry_set_text (GTK_ENTRY (self->entry_user_email), EXAMPLE_EMAIL_ADDRESS); /* Default text. */
405 gtk_widget_show (self->entry_user_email);
406 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
407 gtk_widget_show (caption);
409 /* Set max length as in the UI spec:
410 * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
411 gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_email), 64);
414 gtk_widget_show (GTK_WIDGET (box));
416 return GTK_WIDGET (box);
419 static GtkWidget* create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
421 GtkWidget *box = gtk_vbox_new (FALSE, 2);
422 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
423 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
424 gtk_widget_show (label);
425 gtk_widget_show (GTK_WIDGET (box));
426 return GTK_WIDGET (box);
429 /** Change the caption title for the incoming server,
430 * as specified in the UI spec:
432 static void update_incoming_server_title (ModestEasysetupWizardDialog *self)
434 ModestProtocol protocol = easysetup_servertype_combo_box_get_active_servertype (
435 EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype));
437 (protocol == MODEST_PROTOCOL_STORE_POP ?
438 _("mail_fi_emailtype_pop3") :
439 _("mail_fi_emailtype_imap") );
442 /* Note that this produces a compiler warning,
443 * because the compiler does not know that the translated string will have a %s in it.
444 * I do not see a way to avoid the warning while still using these Logical IDs. murrayc. */
445 gchar* incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), type);
446 g_object_set (G_OBJECT (self->caption_incoming), "label", incomingserver_title, NULL);
447 g_free(incomingserver_title);
450 /** Change the caption title for the incoming server,
451 * as specified in the UI spec:
453 static void update_incoming_server_security_choices (ModestEasysetupWizardDialog *self)
455 ModestProtocol protocol = easysetup_servertype_combo_box_get_active_servertype (
456 EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype));
458 /* Fill the combo with appropriately titled choices for POP or IMAP. */
459 /* The choices are the same, but the titles are different, as in the UI spec. */
460 easysetup_serversecurity_combo_box_fill (
461 EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security), protocol);
464 void on_combo_servertype_changed(GtkComboBox *combobox, gpointer user_data)
466 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
467 update_incoming_server_title (self);
468 update_incoming_server_security_choices (self);
471 static GtkWidget* create_page_custom_incoming (ModestEasysetupWizardDialog *self)
473 GtkWidget *box = gtk_vbox_new (FALSE, 2);
475 /* Create a size group to be used by all captions.
476 * Note that HildonCaption does not create a default size group if we do not specify one.
477 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
478 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
480 /* The incoming server widgets: */
481 if (!self->combo_incoming_servertype)
482 self->combo_incoming_servertype = GTK_WIDGET (easysetup_servertype_combo_box_new ());
483 easysetup_servertype_combo_box_set_active_servertype (
484 EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype), MODEST_PROTOCOL_STORE_POP);
485 GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup,
486 _("mcen_li_emailsetup_type"), self->combo_incoming_servertype, NULL, HILDON_CAPTION_MANDATORY);
487 gtk_widget_show (self->combo_incoming_servertype);
488 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
489 gtk_widget_show (caption);
491 if(!self->entry_incomingserver)
492 self->entry_incomingserver = gtk_entry_new ();
493 set_default_custom_servernames (self);
495 if (self->caption_incoming)
496 gtk_widget_destroy (self->caption_incoming);
498 /* The caption title will be updated in update_incoming_server_title().
499 * so this default text will never be seen: */
500 /* (Note: Changing the title seems pointless. murrayc) */
501 self->caption_incoming = create_caption_new_with_asterix (self, sizegroup,
502 "Incoming Server", self->entry_incomingserver, NULL, HILDON_CAPTION_MANDATORY);
503 update_incoming_server_title (self);
504 gtk_widget_show (self->entry_incomingserver);
505 gtk_box_pack_start (GTK_BOX (box), self->caption_incoming, FALSE, FALSE, 2);
506 gtk_widget_show (self->caption_incoming);
508 /* Change the caption title when the servertype changes,
509 * as in the UI spec: */
510 g_signal_connect (G_OBJECT (self->combo_incoming_servertype), "changed",
511 G_CALLBACK (on_combo_servertype_changed), self);
513 /* The secure connection widgets: */
514 if (!self->combo_incoming_security)
515 self->combo_incoming_security = GTK_WIDGET (easysetup_serversecurity_combo_box_new ());
516 update_incoming_server_security_choices (self);
517 easysetup_serversecurity_combo_box_set_active_serversecurity (
518 EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security), MODEST_PROTOCOL_SECURITY_NONE);
519 caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
520 self->combo_incoming_security, NULL, HILDON_CAPTION_OPTIONAL);
521 gtk_widget_show (self->combo_incoming_security);
522 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
523 gtk_widget_show (caption);
525 if(!self->checkbox_incoming_auth)
526 self->checkbox_incoming_auth =
527 gtk_check_button_new_with_label (_("mcen_li_emailsetup_secure_authentication"));
528 gtk_box_pack_start (GTK_BOX (box), self->checkbox_incoming_auth, FALSE, FALSE, 2);
529 gtk_widget_show (self->checkbox_incoming_auth);
531 gtk_widget_show (GTK_WIDGET (box));
533 return GTK_WIDGET (box);
537 on_toggle_button_changed (GtkToggleButton *togglebutton, gpointer user_data)
539 GtkWidget *widget = GTK_WIDGET (user_data);
541 /* Enable the widget only if the toggle button is active: */
542 const gboolean enable = gtk_toggle_button_get_active (togglebutton);
543 gtk_widget_set_sensitive (widget, enable);
546 /* Make the sensitivity of a widget depend on a toggle button.
549 enable_widget_for_togglebutton (GtkWidget *widget, GtkToggleButton* button)
551 g_signal_connect (G_OBJECT (button), "toggled",
552 G_CALLBACK (on_toggle_button_changed), widget);
554 /* Set the starting sensitivity: */
555 on_toggle_button_changed (button, widget);
558 static GtkWidget* create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
560 GtkWidget *box = gtk_vbox_new (FALSE, 2);
562 /* Create a size group to be used by all captions.
563 * Note that HildonCaption does not create a default size group if we do not specify one.
564 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
565 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
567 /* The outgoing server widgets: */
568 if (!self->entry_outgoingserver)
569 self->entry_outgoingserver = gtk_entry_new ();
570 GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup,
571 _("mcen_li_emailsetup_smtp"), self->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL);
572 gtk_widget_show (self->entry_outgoingserver);
573 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
574 gtk_widget_show (caption);
575 set_default_custom_servernames (self);
577 /* The secure connection widgets: */
578 if (!self->combo_outgoing_security)
579 self->combo_outgoing_security = GTK_WIDGET (easysetup_serversecurity_combo_box_new ());
580 easysetup_serversecurity_combo_box_fill (
581 EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security), MODEST_PROTOCOL_TRANSPORT_SMTP);
582 easysetup_serversecurity_combo_box_set_active_serversecurity (
583 EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security), MODEST_PROTOCOL_SECURITY_NONE);
584 caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
585 self->combo_outgoing_security, NULL, HILDON_CAPTION_OPTIONAL);
586 gtk_widget_show (self->combo_outgoing_security);
587 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
588 gtk_widget_show (caption);
590 /* The secure authentication widgets: */
591 if (!self->combo_outgoing_auth)
592 self->combo_outgoing_auth = GTK_WIDGET (easysetup_secureauth_combo_box_new ());
593 caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
594 self->combo_outgoing_auth, NULL, HILDON_CAPTION_OPTIONAL);
595 gtk_widget_show (self->combo_outgoing_auth);
596 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
597 gtk_widget_show (caption);
599 /* connection-specific checkbox: */
600 if (!self->checkbox_outgoing_smtp_specific) {
601 self->checkbox_outgoing_smtp_specific = gtk_check_button_new_with_label (_("mcen_fi_advsetup_connection_smtp"));
602 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific),
605 gtk_box_pack_start (GTK_BOX (box), self->checkbox_outgoing_smtp_specific, FALSE, FALSE, 2);
606 gtk_widget_show (self->checkbox_outgoing_smtp_specific);
608 /* Connection-specific SMTP-Severs Edit button: */
609 if (!self->button_outgoing_smtp_servers)
610 self->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_emailsetup_edit"));
611 caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_optional_smtp"),
612 self->button_outgoing_smtp_servers, NULL, HILDON_CAPTION_OPTIONAL);
613 gtk_widget_show (self->button_outgoing_smtp_servers);
614 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
615 gtk_widget_show (caption);
617 /* Only enable the button when the checkbox is checked: */
618 enable_widget_for_togglebutton (self->button_outgoing_smtp_servers,
619 GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific));
622 gtk_widget_show (GTK_WIDGET (box));
624 return GTK_WIDGET (box);
627 static GtkWidget* create_page_complete_custom (ModestEasysetupWizardDialog *self)
629 GtkWidget *box = gtk_vbox_new (FALSE, 2);
630 GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
631 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
632 gtk_widget_show (label);
634 if (!self->button_edit)
635 self->button_edit = gtk_button_new_with_label (_("mcen_bd_emailsetup_edit"));
636 GtkWidget *caption = hildon_caption_new (NULL, _("mcen_fi_advanced_settings"),
637 self->button_edit, NULL, HILDON_CAPTION_OPTIONAL);
638 gtk_widget_show (self->button_edit);
639 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
640 gtk_widget_show (caption);
642 gtk_widget_show (GTK_WIDGET (box));
643 return GTK_WIDGET (box);
650 on_response (ModestWizardDialog *wizard_dialog,
654 ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
655 invoke_enable_buttons_vfunc (self);
659 modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
661 /* Create the notebook to be used by the ModestWizardDialog base class:
662 * Each page of the notebook will be a page of the wizard: */
663 GtkNotebook *notebook = GTK_NOTEBOOK (gtk_notebook_new());
665 /* Set the notebook used by the ModestWizardDialog base class: */
666 g_object_set (G_OBJECT(self), "wizard-notebook", notebook, NULL);
668 /* Set the wizard title:
669 * The actual window title will be a combination of this and the page's tab label title. */
670 g_object_set (G_OBJECT(self), "wizard-name", _("mcen_ti_emailsetup"), NULL);
672 /* Read in the information about known service providers: */
673 ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
674 priv->presets = modest_presets_new ("provider-data-test.keyfile"); /* TODO: the actual filepath. */
676 /* Create the account manager object,
677 * so we can check for existing accounts,
678 * and create new accounts: */
679 ModestConf *conf = modest_conf_new (); /* Just a thin wrapper around GConfClient. */
680 self->account_manager = modest_account_mgr_new (conf);
681 g_object_unref (conf);
683 /* Create the common pages,
685 self->page_welcome = create_page_welcome (self);
686 self->page_account_details = create_page_account_details (self);
687 self->page_user_details = create_page_user_details (self);
689 /* Add the common pages: */
690 gtk_notebook_append_page (notebook, self->page_welcome,
691 gtk_label_new (_("mcen_ti_emailsetup_welcome")));
692 gtk_notebook_append_page (notebook, self->page_account_details,
693 gtk_label_new (_("mcen_ti_accountdetails")));
694 gtk_notebook_append_page (notebook, self->page_user_details,
695 gtk_label_new (_("mcen_ti_emailsetup_userdetails")));
697 /* Create and add the easysetup-specific pages,
698 * because we need _some_ final page to enable the Next and Finish buttons: */
699 create_subsequent_easysetup_pages (self);
702 /* Connect to the dialog's response signal so we can enable/disable buttons
703 * for the newly-selected page, because the prev/next buttons cause response to be emitted.
704 * Note that we use g_signal_connect_after() instead of g_signal_connect()
705 * so that we can be enable/disable after ModestWizardDialog has done its own
706 * enabling/disabling of buttons.
708 * HOWEVER, this doesn't work because ModestWizardDialog's response signal handler
709 * does g_signal_stop_emission_by_name(), stopping our signal handler from running.
711 * It's not enough to connect to the notebook's switch-page signal, because
712 * ModestWizardDialog's "response" signal handler enables the buttons itself,
713 * _after_ switching the page (understandably).
714 * (Note that if we had, if we used g_signal_connect() instead of g_signal_connect_after()
715 * then gtk_notebook_get_current_page() would return an incorrect value.)
717 g_signal_connect_after (G_OBJECT (self), "response",
718 G_CALLBACK (on_response), self);
721 ModestEasysetupWizardDialog*
722 modest_easysetup_wizard_dialog_new (void)
724 return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
727 static void create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
729 GtkNotebook *notebook = NULL;
730 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
733 /* Create the custom pages: */
734 if(!(self->page_custom_incoming)) {
735 self->page_custom_incoming = create_page_custom_incoming (self);
738 if(!(self->page_custom_outgoing)) {
739 self->page_custom_outgoing = create_page_custom_outgoing (self);
742 if(!(self->page_complete_customsetup)) {
743 self->page_complete_customsetup = create_page_complete_custom (self);
746 if (!gtk_widget_get_parent (GTK_WIDGET (self->page_custom_incoming)))
747 gtk_notebook_append_page (notebook, self->page_custom_incoming,
748 gtk_label_new (_("mcen_ti_emailsetup_incomingdetails")));
750 if (!gtk_widget_get_parent (GTK_WIDGET (self->page_custom_outgoing)))
751 gtk_notebook_append_page (notebook, self->page_custom_outgoing,
752 gtk_label_new (_("mcen_ti_emailsetup_outgoingdetails")));
754 if (!gtk_widget_get_parent (GTK_WIDGET (self->page_complete_customsetup)))
755 gtk_notebook_append_page (notebook, self->page_complete_customsetup,
756 gtk_label_new (_("mcen_ti_emailsetup_complete")));
759 static void create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self)
761 GtkNotebook *notebook = NULL;
762 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
765 /* Create the easysetup-specific pages: */
766 if(!self->page_complete_easysetup)
767 self->page_complete_easysetup = create_page_complete_easysetup (self);
769 if (!gtk_widget_get_parent (GTK_WIDGET (self->page_complete_easysetup)))
770 gtk_notebook_append_page (notebook, self->page_complete_easysetup,
771 gtk_label_new (_("mcen_ti_emailsetup_complete")));
774 /* After the user details page,
775 * the following pages depend on whether "Other" was chosen
776 * in the provider combobox on the account page
778 static void create_subsequent_pages (ModestEasysetupWizardDialog *self)
780 if (easysetup_provider_combo_box_get_active_provider_id (
781 EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider)) == 0) {
782 /* "Other..." was selected: */
784 /* Make sure that the easysetup pages do not exist: */
785 if(self->page_complete_easysetup) {
786 gtk_widget_destroy (self->page_complete_easysetup);
787 self->page_complete_easysetup = NULL;
790 create_subsequent_customsetup_pages (self);
793 /* A specific provider was selected: */
795 /* Make sure that the custom pages do not exist:
796 * Because they will be used if they exist, when creating the account. */
797 if(self->page_custom_incoming) {
798 gtk_widget_destroy (self->page_custom_incoming);
799 self->page_custom_incoming = NULL;
802 if(self->page_custom_outgoing) {
803 gtk_widget_destroy (self->page_custom_outgoing);
804 self->page_custom_outgoing = NULL;
807 if(self->page_complete_customsetup) {
808 gtk_widget_destroy (self->page_complete_customsetup);
809 self->page_complete_customsetup = NULL;
813 /* Create the easysetup pages: */
814 create_subsequent_easysetup_pages (self);
819 util_get_default_servername_from_email_address (const gchar* email_address, ModestProtocol servertype)
824 gchar* at = g_utf8_strchr (email_address, -1, '@');
825 if (!at || (g_utf8_strlen (at, -1) < 2))
828 gchar* domain = g_utf8_next_char (at);
832 const gchar* hostname = NULL;
833 if (servertype == MODEST_PROTOCOL_STORE_POP)
835 else if (servertype == MODEST_PROTOCOL_STORE_IMAP)
837 else if (servertype == MODEST_PROTOCOL_TRANSPORT_SMTP)
843 return g_strdup_printf ("%s.%s", hostname, domain);
846 static void set_default_custom_servernames (ModestEasysetupWizardDialog *account_wizard)
848 /* Set a default domain for the server, based on the email address,
849 * if no server name was already specified.
851 const gchar* incoming_existing = gtk_entry_get_text (GTK_ENTRY (account_wizard->entry_incomingserver));
852 if ((!incoming_existing || (strlen(incoming_existing) == 0))
853 && account_wizard->entry_user_email) {
854 const ModestProtocol protocol = easysetup_servertype_combo_box_get_active_servertype (
855 EASYSETUP_SERVERTYPE_COMBO_BOX (account_wizard->combo_incoming_servertype));
856 const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(account_wizard->entry_user_email));
857 gtk_entry_set_text (GTK_ENTRY (account_wizard->entry_incomingserver), util_get_default_servername_from_email_address (email_address, protocol));
860 /* Set a default domain for the server, based on the email address,
861 * if no server name was already specified.
863 const gchar* outgoing_existing = gtk_entry_get_text (GTK_ENTRY (account_wizard->entry_outgoingserver));
864 if ((!outgoing_existing || (strlen(outgoing_existing) == 0))
865 && account_wizard->entry_user_email) {
866 const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(account_wizard->entry_user_email));
867 gtk_entry_set_text (GTK_ENTRY (account_wizard->entry_outgoingserver), util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOL_TRANSPORT_SMTP));
872 on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *next_page)
874 ModestEasysetupWizardDialog *account_wizard = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
876 /* Do extra validation that couldn't be done for every key press,
877 * either because it was too slow,
878 * or because it requires interaction:
880 if (current_page == account_wizard->page_account_details) {
881 /* Check that the title is not already in use: */
882 const gchar* account_name = gtk_entry_get_text (GTK_ENTRY (account_wizard->entry_account_title));
883 if ((!account_name) || (strlen(account_name) == 0))
886 gboolean name_in_use = FALSE;
887 name_in_use = modest_account_mgr_account_exists (account_wizard->account_manager,
888 account_name, TRUE /* server_account */);
891 /* Warn the user via a dialog: */
892 /* TODO: The UI spec says we should increment the title,
893 * as well as warning. This seems contradictory.
895 show_error (GTK_WINDOW (account_wizard), _("mail_ib_account_name_already_existing."));
900 else if (current_page == account_wizard->page_user_details) {
901 /* Check that the email address is valud: */
902 const gchar* email_address = gtk_entry_get_text (GTK_ENTRY (account_wizard->entry_user_email));
903 if ((!email_address) || (strlen(email_address) == 0))
906 if (!modest_text_utils_validate_email_address (email_address)) {
907 /* Warn the user via a dialog: */
908 show_error (GTK_WINDOW (account_wizard), _("mcen_ib_invalid_email"));
910 /* Return focus to the email address entry: */
911 gtk_widget_grab_focus (account_wizard->entry_user_email);
916 /* Make sure that the subsequent pages are appropriate for the provider choice. */
917 create_subsequent_pages (account_wizard);
920 /* TODO: The UI Spec wants us to check that the servernames are valid,
921 * but does not specify how.
924 if(next_page == account_wizard->page_custom_incoming) {
925 set_default_custom_servernames (account_wizard);
927 else if (next_page == account_wizard->page_custom_outgoing) {
928 set_default_custom_servernames (account_wizard);
931 /* If this is the last page, and this is a click on Finish,
932 * then attempt to create the dialog.
934 if(!next_page) /* This is NULL when this is a click on Finish. */
936 create_account (account_wizard);
943 static gboolean entry_is_empty (GtkWidget *entry)
948 const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
949 if ((!text) || (strlen(text) == 0))
956 on_enable_buttons (ModestWizardDialog *dialog, GtkWidget *current_page)
958 ModestEasysetupWizardDialog *account_wizard = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
960 gboolean enable_next = TRUE;
961 if (current_page == account_wizard->page_welcome) {
964 else if (current_page == account_wizard->page_account_details) {
965 /* The account details title is mandatory: */
966 if (entry_is_empty(account_wizard->entry_account_title))
969 else if (current_page == account_wizard->page_user_details) {
970 /* The user details username is mandatory: */
971 if (entry_is_empty(account_wizard->entry_user_username))
974 /* The user details email address is mandatory: */
975 if (enable_next && entry_is_empty (account_wizard->entry_user_email))
978 else if (current_page == account_wizard->page_custom_incoming) {
979 /* The custom incoming server is mandatory: */
980 if (entry_is_empty(account_wizard->entry_incomingserver))
984 /* Enable the buttons,
985 * identifying them via their associated response codes:
987 GtkDialog *dialog_base = GTK_DIALOG (dialog);
988 gtk_dialog_set_response_sensitive (dialog_base,
989 MODEST_WIZARD_DIALOG_NEXT,
992 /* Disable the Finish button until we are on the last page,
993 * because HildonWizardDialog enables this for all but the first page: */
994 GtkNotebook *notebook = NULL;
995 g_object_get (dialog_base, "wizard-notebook", ¬ebook, NULL);
997 gint current = gtk_notebook_get_current_page (notebook);
998 gint last = gtk_notebook_get_n_pages (notebook) - 1;
999 gboolean is_last = (current == last);
1002 gtk_dialog_set_response_sensitive (dialog_base,
1003 MODEST_WIZARD_DIALOG_FINISH,
1009 modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *klass)
1011 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1012 g_type_class_add_private (klass, sizeof (ModestEasysetupWizardDialogPrivate));
1015 object_class->get_property = modest_easysetup_wizard_dialog_get_property;
1016 object_class->set_property = modest_easysetup_wizard_dialog_set_property;
1017 object_class->dispose = modest_easysetup_wizard_dialog_dispose;
1018 object_class->finalize = modest_easysetup_wizard_dialog_finalize;
1020 /* Provide a vfunc implementation so we can decide
1021 * when to enable/disable the prev/next buttons.
1023 ModestWizardDialogClass *base_klass = (ModestWizardDialogClass*)(klass);
1024 base_klass->before_next = on_before_next;
1025 base_klass->enable_buttons = on_enable_buttons;
1029 show_error (GtkWindow *parent_window, const gchar* text)
1031 GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
1037 gtk_dialog_run (dialog);
1038 gtk_widget_destroy (GTK_WIDGET (dialog));
1041 /** Attempt to create the account from the information that the user has entered.
1042 * @result: TRUE if the account was successfully created.
1045 create_account (ModestEasysetupWizardDialog *self)
1047 ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
1049 const gchar* account_name = gtk_entry_get_text (GTK_ENTRY (self->entry_account_title));
1055 /* We should have checked for this already,
1056 * and changed that name accordingly,
1057 * but let's check again just in case:
1059 if (modest_account_mgr_account_exists (self->account_manager, account_name, FALSE))
1062 /* username and password (for both incoming and outgoing): */
1063 const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username));
1064 const gchar* password = gtk_entry_get_text (GTK_ENTRY (self->entry_user_password));
1066 /* Incoming server: */
1067 /* Note: We need something as default for the ModestProtocol values,
1068 * or modest_account_mgr_add_server_account will fail. */
1069 gchar* servername_incoming = NULL;
1070 ModestProtocol protocol_incoming = MODEST_PROTOCOL_STORE_POP;
1071 ModestProtocol protocol_security_incoming = MODEST_PROTOCOL_SECURITY_NONE;
1072 ModestProtocol protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_NONE;
1074 /* Get details from the specified presets: */
1075 gchar* provider_id = easysetup_provider_combo_box_get_active_provider_id (
1076 EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider));
1080 servername_incoming = modest_presets_get_server (priv->presets, provider_id,
1081 TRUE /* incoming */);
1083 ModestPresetsServerType servertype_incoming = modest_presets_get_info_server_type (priv->presets, provider_id,
1084 TRUE /* incoming */);
1087 /* We don't check for SMTP here as that is impossible for an incoming server. */
1088 if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_IMAP)
1089 protocol_incoming = MODEST_PROTOCOL_STORE_IMAP;
1090 else if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_POP)
1091 protocol_incoming = MODEST_PROTOCOL_STORE_POP;
1093 ModestPresetsSecurity security_incoming = modest_presets_get_info_server_security (priv->presets, provider_id,
1094 TRUE /* incoming */);
1097 if (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING)
1098 protocol_security_incoming = MODEST_PROTOCOL_SECURITY_SSL; /* TODO: Is this what we want? */
1100 if (security_incoming & MODEST_PRESETS_SECURITY_APOP)
1101 protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_PASSWORD; /* TODO: Is this what we want? */
1104 /* Use custom pages because no preset was specified: */
1105 servername_incoming = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_incomingserver) ));
1107 protocol_incoming = easysetup_servertype_combo_box_get_active_servertype (
1108 EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype));
1110 protocol_security_incoming = easysetup_serversecurity_combo_box_get_active_serversecurity (
1111 EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
1113 protocol_authentication_incoming = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth))
1114 ? MODEST_PROTOCOL_AUTH_PASSWORD
1115 : MODEST_PROTOCOL_AUTH_NONE;
1119 gboolean created = modest_account_mgr_add_server_account (self->account_manager,
1121 servername_incoming,
1124 protocol_security_incoming,
1125 protocol_authentication_incoming);
1127 g_free (servername_incoming);
1130 /* TODO: Provide a Logical ID for the text: */
1131 show_error (GTK_WINDOW (self), _("An error occurred while creating the incoming account."));
1135 /* Outgoing server: */
1136 gchar* servername_outgoing = NULL;
1137 ModestProtocol protocol_outgoing = MODEST_PROTOCOL_STORE_POP;
1138 ModestProtocol protocol_security_outgoing = MODEST_PROTOCOL_SECURITY_NONE;
1139 ModestProtocol protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE;
1143 servername_outgoing = modest_presets_get_server (priv->presets, provider_id,
1144 FALSE /* incoming */);
1146 ModestPresetsServerType servertype_outgoing = modest_presets_get_info_server_type (priv->presets, provider_id,
1147 FALSE /* incoming */);
1149 /* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
1150 protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SENDMAIL;
1151 if (servertype_outgoing == MODEST_PRESETS_SERVER_TYPE_SMTP)
1152 protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SMTP; /* TODO: Is this what we want? */
1154 ModestPresetsSecurity security_outgoing =
1155 modest_presets_get_info_server_security (priv->presets, provider_id,
1156 FALSE /* incoming */);
1158 protocol_security_outgoing = MODEST_PROTOCOL_SECURITY_NONE;
1159 if (security_outgoing & MODEST_PRESETS_SECURITY_SECURE_SMTP)
1160 protocol_security_outgoing = MODEST_PROTOCOL_SECURITY_SSL; /* TODO: Is this what we want? */
1162 protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE;
1163 /* TODO: There is no SMTP authentication enum for presets. */
1166 /* Use custom pages because no preset was specified: */
1167 servername_outgoing = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_outgoingserver) ));
1169 protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SMTP; /* It's always SMTP for outgoing. */
1171 protocol_security_outgoing = easysetup_serversecurity_combo_box_get_active_serversecurity (
1172 EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security));
1174 protocol_authentication_outgoing = easysetup_secureauth_combo_box_get_active_secureauth (
1175 EASYSETUP_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth));
1177 gboolean specific = gtk_toggle_button_get_active (
1178 GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific));
1182 created = modest_account_mgr_add_server_account (self->account_manager,
1184 servername_outgoing,
1187 protocol_security_outgoing,
1188 protocol_authentication_outgoing);
1190 g_free (servername_outgoing);
1193 /* TODO: Provide a Logical ID for the text: */
1194 show_error (GTK_WINDOW (self), _("An error occurred while creating the outgoing account."));