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.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);
675 const gchar* filepath = "/usr/share/operator-wizard/provider-data.keyfile";
676 priv->presets = modest_presets_new (filepath); /* TODO: the actual filepath. */
677 if (!(priv->presets))
679 const gchar* filepath_hack = "./src/maemo/easysetup/provider-data-test.keyfile";
680 g_warning ("Could not locate the official provider data keyfile from %s, "
681 "so attempting to load it instead from %s", filepath, filepath_hack);
682 priv->presets = modest_presets_new (filepath_hack); /* TODO: the actual filepath. */
685 g_assert(priv->presets);
688 /* Create the account manager object,
689 * so we can check for existing accounts,
690 * and create new accounts: */
691 ModestConf *conf = modest_conf_new (); /* Just a thin wrapper around GConfClient. */
692 self->account_manager = modest_account_mgr_new (conf);
693 g_object_unref (conf);
695 /* Create the common pages,
697 self->page_welcome = create_page_welcome (self);
698 self->page_account_details = create_page_account_details (self);
699 self->page_user_details = create_page_user_details (self);
701 /* Add the common pages: */
702 gtk_notebook_append_page (notebook, self->page_welcome,
703 gtk_label_new (_("mcen_ti_emailsetup_welcome")));
704 gtk_notebook_append_page (notebook, self->page_account_details,
705 gtk_label_new (_("mcen_ti_accountdetails")));
706 gtk_notebook_append_page (notebook, self->page_user_details,
707 gtk_label_new (_("mcen_ti_emailsetup_userdetails")));
709 /* Create and add the easysetup-specific pages,
710 * because we need _some_ final page to enable the Next and Finish buttons: */
711 create_subsequent_easysetup_pages (self);
714 /* Connect to the dialog's response signal so we can enable/disable buttons
715 * for the newly-selected page, because the prev/next buttons cause response to be emitted.
716 * Note that we use g_signal_connect_after() instead of g_signal_connect()
717 * so that we can be enable/disable after ModestWizardDialog has done its own
718 * enabling/disabling of buttons.
720 * HOWEVER, this doesn't work because ModestWizardDialog's response signal handler
721 * does g_signal_stop_emission_by_name(), stopping our signal handler from running.
723 * It's not enough to connect to the notebook's switch-page signal, because
724 * ModestWizardDialog's "response" signal handler enables the buttons itself,
725 * _after_ switching the page (understandably).
726 * (Note that if we had, if we used g_signal_connect() instead of g_signal_connect_after()
727 * then gtk_notebook_get_current_page() would return an incorrect value.)
729 g_signal_connect_after (G_OBJECT (self), "response",
730 G_CALLBACK (on_response), self);
733 ModestEasysetupWizardDialog*
734 modest_easysetup_wizard_dialog_new (void)
736 return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
739 static void create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
741 GtkNotebook *notebook = NULL;
742 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
745 /* Create the custom pages: */
746 if(!(self->page_custom_incoming)) {
747 self->page_custom_incoming = create_page_custom_incoming (self);
750 if(!(self->page_custom_outgoing)) {
751 self->page_custom_outgoing = create_page_custom_outgoing (self);
754 if(!(self->page_complete_customsetup)) {
755 self->page_complete_customsetup = create_page_complete_custom (self);
758 if (!gtk_widget_get_parent (GTK_WIDGET (self->page_custom_incoming)))
759 gtk_notebook_append_page (notebook, self->page_custom_incoming,
760 gtk_label_new (_("mcen_ti_emailsetup_incomingdetails")));
762 if (!gtk_widget_get_parent (GTK_WIDGET (self->page_custom_outgoing)))
763 gtk_notebook_append_page (notebook, self->page_custom_outgoing,
764 gtk_label_new (_("mcen_ti_emailsetup_outgoingdetails")));
766 if (!gtk_widget_get_parent (GTK_WIDGET (self->page_complete_customsetup)))
767 gtk_notebook_append_page (notebook, self->page_complete_customsetup,
768 gtk_label_new (_("mcen_ti_emailsetup_complete")));
771 static void create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self)
773 GtkNotebook *notebook = NULL;
774 g_object_get (self, "wizard-notebook", ¬ebook, NULL);
777 /* Create the easysetup-specific pages: */
778 if(!self->page_complete_easysetup)
779 self->page_complete_easysetup = create_page_complete_easysetup (self);
781 if (!gtk_widget_get_parent (GTK_WIDGET (self->page_complete_easysetup)))
782 gtk_notebook_append_page (notebook, self->page_complete_easysetup,
783 gtk_label_new (_("mcen_ti_emailsetup_complete")));
786 /* After the user details page,
787 * the following pages depend on whether "Other" was chosen
788 * in the provider combobox on the account page
790 static void create_subsequent_pages (ModestEasysetupWizardDialog *self)
792 if (easysetup_provider_combo_box_get_active_provider_id (
793 EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider)) == 0) {
794 /* "Other..." was selected: */
796 /* Make sure that the easysetup pages do not exist: */
797 if(self->page_complete_easysetup) {
798 gtk_widget_destroy (self->page_complete_easysetup);
799 self->page_complete_easysetup = NULL;
802 create_subsequent_customsetup_pages (self);
805 /* A specific provider was selected: */
807 /* Make sure that the custom pages do not exist:
808 * Because they will be used if they exist, when creating the account. */
809 if(self->page_custom_incoming) {
810 gtk_widget_destroy (self->page_custom_incoming);
811 self->page_custom_incoming = NULL;
814 if(self->page_custom_outgoing) {
815 gtk_widget_destroy (self->page_custom_outgoing);
816 self->page_custom_outgoing = NULL;
819 if(self->page_complete_customsetup) {
820 gtk_widget_destroy (self->page_complete_customsetup);
821 self->page_complete_customsetup = NULL;
825 /* Create the easysetup pages: */
826 create_subsequent_easysetup_pages (self);
831 util_get_default_servername_from_email_address (const gchar* email_address, ModestProtocol servertype)
836 gchar* at = g_utf8_strchr (email_address, -1, '@');
837 if (!at || (g_utf8_strlen (at, -1) < 2))
840 gchar* domain = g_utf8_next_char (at);
844 const gchar* hostname = NULL;
845 if (servertype == MODEST_PROTOCOL_STORE_POP)
847 else if (servertype == MODEST_PROTOCOL_STORE_IMAP)
849 else if (servertype == MODEST_PROTOCOL_TRANSPORT_SMTP)
855 return g_strdup_printf ("%s.%s", hostname, domain);
858 static void set_default_custom_servernames (ModestEasysetupWizardDialog *account_wizard)
860 /* Set a default domain for the server, based on the email address,
861 * if no server name was already specified.
863 const gchar* incoming_existing = gtk_entry_get_text (GTK_ENTRY (account_wizard->entry_incomingserver));
864 if ((!incoming_existing || (strlen(incoming_existing) == 0))
865 && account_wizard->entry_user_email) {
866 const ModestProtocol protocol = easysetup_servertype_combo_box_get_active_servertype (
867 EASYSETUP_SERVERTYPE_COMBO_BOX (account_wizard->combo_incoming_servertype));
868 const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(account_wizard->entry_user_email));
869 gtk_entry_set_text (GTK_ENTRY (account_wizard->entry_incomingserver), util_get_default_servername_from_email_address (email_address, protocol));
872 /* Set a default domain for the server, based on the email address,
873 * if no server name was already specified.
875 const gchar* outgoing_existing = gtk_entry_get_text (GTK_ENTRY (account_wizard->entry_outgoingserver));
876 if ((!outgoing_existing || (strlen(outgoing_existing) == 0))
877 && account_wizard->entry_user_email) {
878 const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(account_wizard->entry_user_email));
879 gtk_entry_set_text (GTK_ENTRY (account_wizard->entry_outgoingserver), util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOL_TRANSPORT_SMTP));
884 on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *next_page)
886 ModestEasysetupWizardDialog *account_wizard = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
888 /* Do extra validation that couldn't be done for every key press,
889 * either because it was too slow,
890 * or because it requires interaction:
892 if (current_page == account_wizard->page_account_details) {
893 /* Check that the title is not already in use: */
894 const gchar* account_name = gtk_entry_get_text (GTK_ENTRY (account_wizard->entry_account_title));
895 if ((!account_name) || (strlen(account_name) == 0))
898 gboolean name_in_use = FALSE;
899 name_in_use = modest_account_mgr_account_exists (account_wizard->account_manager,
900 account_name, TRUE /* server_account */);
903 /* Warn the user via a dialog: */
904 /* TODO: The UI spec says we should increment the title,
905 * as well as warning. This seems contradictory.
907 show_error (GTK_WINDOW (account_wizard), _("mail_ib_account_name_already_existing."));
912 else if (current_page == account_wizard->page_user_details) {
913 /* Check that the email address is valud: */
914 const gchar* email_address = gtk_entry_get_text (GTK_ENTRY (account_wizard->entry_user_email));
915 if ((!email_address) || (strlen(email_address) == 0))
918 if (!modest_text_utils_validate_email_address (email_address)) {
919 /* Warn the user via a dialog: */
920 show_error (GTK_WINDOW (account_wizard), _("mcen_ib_invalid_email"));
922 /* Return focus to the email address entry: */
923 gtk_widget_grab_focus (account_wizard->entry_user_email);
928 /* Make sure that the subsequent pages are appropriate for the provider choice. */
929 create_subsequent_pages (account_wizard);
932 /* TODO: The UI Spec wants us to check that the servernames are valid,
933 * but does not specify how.
936 if(next_page == account_wizard->page_custom_incoming) {
937 set_default_custom_servernames (account_wizard);
939 else if (next_page == account_wizard->page_custom_outgoing) {
940 set_default_custom_servernames (account_wizard);
943 /* If this is the last page, and this is a click on Finish,
944 * then attempt to create the dialog.
946 if(!next_page) /* This is NULL when this is a click on Finish. */
948 create_account (account_wizard);
955 static gboolean entry_is_empty (GtkWidget *entry)
960 const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
961 if ((!text) || (strlen(text) == 0))
968 on_enable_buttons (ModestWizardDialog *dialog, GtkWidget *current_page)
970 ModestEasysetupWizardDialog *account_wizard = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
972 gboolean enable_next = TRUE;
973 if (current_page == account_wizard->page_welcome) {
976 else if (current_page == account_wizard->page_account_details) {
977 /* The account details title is mandatory: */
978 if (entry_is_empty(account_wizard->entry_account_title))
981 else if (current_page == account_wizard->page_user_details) {
982 /* The user details username is mandatory: */
983 if (entry_is_empty(account_wizard->entry_user_username))
986 /* The user details email address is mandatory: */
987 if (enable_next && entry_is_empty (account_wizard->entry_user_email))
990 else if (current_page == account_wizard->page_custom_incoming) {
991 /* The custom incoming server is mandatory: */
992 if (entry_is_empty(account_wizard->entry_incomingserver))
996 /* Enable the buttons,
997 * identifying them via their associated response codes:
999 GtkDialog *dialog_base = GTK_DIALOG (dialog);
1000 gtk_dialog_set_response_sensitive (dialog_base,
1001 MODEST_WIZARD_DIALOG_NEXT,
1004 /* Disable the Finish button until we are on the last page,
1005 * because HildonWizardDialog enables this for all but the first page: */
1006 GtkNotebook *notebook = NULL;
1007 g_object_get (dialog_base, "wizard-notebook", ¬ebook, NULL);
1009 gint current = gtk_notebook_get_current_page (notebook);
1010 gint last = gtk_notebook_get_n_pages (notebook) - 1;
1011 gboolean is_last = (current == last);
1014 gtk_dialog_set_response_sensitive (dialog_base,
1015 MODEST_WIZARD_DIALOG_FINISH,
1021 modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *klass)
1023 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1024 g_type_class_add_private (klass, sizeof (ModestEasysetupWizardDialogPrivate));
1027 object_class->get_property = modest_easysetup_wizard_dialog_get_property;
1028 object_class->set_property = modest_easysetup_wizard_dialog_set_property;
1029 object_class->dispose = modest_easysetup_wizard_dialog_dispose;
1030 object_class->finalize = modest_easysetup_wizard_dialog_finalize;
1032 /* Provide a vfunc implementation so we can decide
1033 * when to enable/disable the prev/next buttons.
1035 ModestWizardDialogClass *base_klass = (ModestWizardDialogClass*)(klass);
1036 base_klass->before_next = on_before_next;
1037 base_klass->enable_buttons = on_enable_buttons;
1041 show_error (GtkWindow *parent_window, const gchar* text)
1043 GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
1049 gtk_dialog_run (dialog);
1050 gtk_widget_destroy (GTK_WIDGET (dialog));
1053 /** Attempt to create the account from the information that the user has entered.
1054 * @result: TRUE if the account was successfully created.
1057 create_account (ModestEasysetupWizardDialog *self)
1059 ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
1061 const gchar* account_name = gtk_entry_get_text (GTK_ENTRY (self->entry_account_title));
1067 /* We should have checked for this already,
1068 * and changed that name accordingly,
1069 * but let's check again just in case:
1071 if (modest_account_mgr_account_exists (self->account_manager, account_name, FALSE))
1074 /* username and password (for both incoming and outgoing): */
1075 const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username));
1076 const gchar* password = gtk_entry_get_text (GTK_ENTRY (self->entry_user_password));
1078 /* Incoming server: */
1079 /* Note: We need something as default for the ModestProtocol values,
1080 * or modest_account_mgr_add_server_account will fail. */
1081 gchar* servername_incoming = NULL;
1082 ModestProtocol protocol_incoming = MODEST_PROTOCOL_STORE_POP;
1083 ModestProtocol protocol_security_incoming = MODEST_PROTOCOL_SECURITY_NONE;
1084 ModestProtocol protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_NONE;
1086 /* Get details from the specified presets: */
1087 gchar* provider_id = easysetup_provider_combo_box_get_active_provider_id (
1088 EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider));
1092 servername_incoming = modest_presets_get_server (priv->presets, provider_id,
1093 TRUE /* incoming */);
1095 ModestPresetsServerType servertype_incoming = modest_presets_get_info_server_type (priv->presets, provider_id,
1096 TRUE /* incoming */);
1099 /* We don't check for SMTP here as that is impossible for an incoming server. */
1100 if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_IMAP)
1101 protocol_incoming = MODEST_PROTOCOL_STORE_IMAP;
1102 else if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_POP)
1103 protocol_incoming = MODEST_PROTOCOL_STORE_POP;
1105 ModestPresetsSecurity security_incoming = modest_presets_get_info_server_security (priv->presets, provider_id,
1106 TRUE /* incoming */);
1109 if (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING)
1110 protocol_security_incoming = MODEST_PROTOCOL_SECURITY_SSL; /* TODO: Is this what we want? */
1112 if (security_incoming & MODEST_PRESETS_SECURITY_APOP)
1113 protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_PASSWORD; /* TODO: Is this what we want? */
1116 /* Use custom pages because no preset was specified: */
1117 servername_incoming = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_incomingserver) ));
1119 protocol_incoming = easysetup_servertype_combo_box_get_active_servertype (
1120 EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype));
1122 protocol_security_incoming = easysetup_serversecurity_combo_box_get_active_serversecurity (
1123 EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
1125 protocol_authentication_incoming = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth))
1126 ? MODEST_PROTOCOL_AUTH_PASSWORD
1127 : MODEST_PROTOCOL_AUTH_NONE;
1131 gboolean created = modest_account_mgr_add_server_account (self->account_manager,
1133 servername_incoming,
1136 protocol_security_incoming,
1137 protocol_authentication_incoming);
1139 g_free (servername_incoming);
1142 /* TODO: Provide a Logical ID for the text: */
1143 show_error (GTK_WINDOW (self), _("An error occurred while creating the incoming account."));
1147 /* Outgoing server: */
1148 gchar* servername_outgoing = NULL;
1149 ModestProtocol protocol_outgoing = MODEST_PROTOCOL_STORE_POP;
1150 ModestProtocol protocol_security_outgoing = MODEST_PROTOCOL_SECURITY_NONE;
1151 ModestProtocol protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE;
1155 servername_outgoing = modest_presets_get_server (priv->presets, provider_id,
1156 FALSE /* incoming */);
1158 ModestPresetsServerType servertype_outgoing = modest_presets_get_info_server_type (priv->presets, provider_id,
1159 FALSE /* incoming */);
1161 /* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
1162 protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SENDMAIL;
1163 if (servertype_outgoing == MODEST_PRESETS_SERVER_TYPE_SMTP)
1164 protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SMTP; /* TODO: Is this what we want? */
1166 ModestPresetsSecurity security_outgoing =
1167 modest_presets_get_info_server_security (priv->presets, provider_id,
1168 FALSE /* incoming */);
1170 protocol_security_outgoing = MODEST_PROTOCOL_SECURITY_NONE;
1171 if (security_outgoing & MODEST_PRESETS_SECURITY_SECURE_SMTP)
1172 protocol_security_outgoing = MODEST_PROTOCOL_SECURITY_SSL; /* TODO: Is this what we want? */
1174 protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE;
1175 /* TODO: There is no SMTP authentication enum for presets. */
1178 /* Use custom pages because no preset was specified: */
1179 servername_outgoing = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_outgoingserver) ));
1181 protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SMTP; /* It's always SMTP for outgoing. */
1183 protocol_security_outgoing = easysetup_serversecurity_combo_box_get_active_serversecurity (
1184 EASYSETUP_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security));
1186 protocol_authentication_outgoing = easysetup_secureauth_combo_box_get_active_secureauth (
1187 EASYSETUP_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth));
1189 gboolean specific = gtk_toggle_button_get_active (
1190 GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific));
1194 created = modest_account_mgr_add_server_account (self->account_manager,
1196 servername_outgoing,
1199 protocol_security_outgoing,
1200 protocol_authentication_outgoing);
1202 g_free (servername_outgoing);
1205 /* TODO: Provide a Logical ID for the text: */
1206 show_error (GTK_WINDOW (self), _("An error occurred while creating the outgoing account."));