1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "widgets/modest-account-settings-dialog.h"
32 #include <glib/gi18n.h>
35 #include "widgets/modest-serversecurity-combo-box.h"
36 #include "widgets/modest-secureauth-combo-box.h"
37 #include "widgets/modest-validating-entry.h"
38 #include "widgets/modest-retrieve-combo-box.h"
39 #include "widgets/modest-limit-retrieve-combo-box.h"
40 #include "modest-defs.h"
41 #include "modest-text-utils.h"
42 #include "modest-account-mgr.h"
43 #include "modest-account-mgr-helpers.h" /* For modest_account_mgr_get_account_data(). */
44 #include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
45 #include "modest-protocol-registry.h"
46 #include <modest-utils.h>
47 #include <modest-platform.h>
48 #include "widgets/modest-ui-constants.h"
49 #include "widgets/modest-default-account-settings-dialog.h"
50 #include <tny-account.h>
51 #include <tny-status.h>
52 #include <tny-simple-list.h>
54 #include <gconf/gconf-client.h>
55 #include <string.h> /* For strlen(). */
57 /* Include config.h so that _() works: */
63 #define PORT_MAX 65535
65 static void modest_account_settings_dialog_init (gpointer g, gpointer iface_data);
67 G_DEFINE_TYPE_EXTENDED (ModestDefaultAccountSettingsDialog,
68 modest_default_account_settings_dialog,
71 G_IMPLEMENT_INTERFACE (MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG,
72 modest_account_settings_dialog_init));
74 #define MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE(o) \
75 (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
76 MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG, \
77 ModestDefaultAccountSettingsDialogPrivate))
79 typedef struct _ModestDefaultAccountSettingsDialogPrivate ModestDefaultAccountSettingsDialogPrivate;
81 struct _ModestDefaultAccountSettingsDialogPrivate
83 /* Used by derived widgets to query existing accounts,
84 * and to create new accounts: */
85 ModestAccountMgr *account_manager;
86 ModestAccountSettings *settings;
89 gchar * account_name; /* This may not change. It is not user visible. */
90 ModestProtocolType incoming_protocol; /* This may not change. */
91 ModestProtocolType outgoing_protocol; /* This may not change. */
92 gchar * original_account_title;
94 ModestProtocolType protocol_authentication_incoming;
96 GtkNotebook *notebook;
98 GtkWidget *page_account_details;
99 GtkWidget *entry_account_title;
100 GtkWidget *combo_retrieve;
101 GtkWidget *combo_limit_retrieve;
102 GtkWidget *caption_leave_messages;
103 GtkWidget *checkbox_leave_messages;
105 GtkWidget *page_user_details;
106 GtkWidget *entry_user_name;
107 GtkWidget *entry_user_username;
108 GtkWidget *entry_user_password;
109 GtkWidget *entry_user_email;
110 GtkWidget *entry_incoming_port;
111 GtkWidget *button_signature;
113 GtkWidget *page_complete_easysetup;
115 GtkWidget *page_incoming;
116 GtkWidget *caption_incoming;
117 GtkWidget *entry_incomingserver;
118 GtkWidget *combo_incoming_security;
119 GtkWidget *checkbox_incoming_auth;
121 GtkWidget *page_outgoing;
122 GtkWidget *entry_outgoingserver;
123 GtkWidget *caption_outgoing_username;
124 GtkWidget *entry_outgoing_username;
125 GtkWidget *caption_outgoing_password;
126 GtkWidget *entry_outgoing_password;
127 GtkWidget *combo_outgoing_security;
128 GtkWidget *combo_outgoing_auth;
129 GtkWidget *entry_outgoing_port;
130 GtkWidget *checkbox_outgoing_smtp_specific;
131 GtkWidget *button_outgoing_smtp_servers;
133 GtkWidget *signature_dialog;
136 static void enable_buttons (ModestAccountSettingsDialog *self);
137 static gboolean save_configuration (ModestAccountSettingsDialog *dialog);
138 static void modest_default_account_settings_dialog_load_settings (ModestAccountSettingsDialog *dialog,
139 ModestAccountSettings *settings);
142 null_means_empty (const gchar * str)
144 return str ? str : "";
149 modest_account_settings_dialog_get_property (GObject *object, guint property_id,
150 GValue *value, GParamSpec *pspec)
152 switch (property_id) {
154 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
159 modest_account_settings_dialog_set_property (GObject *object, guint property_id,
160 const GValue *value, GParamSpec *pspec)
162 switch (property_id) {
164 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
169 modest_account_settings_dialog_dispose (GObject *object)
171 if (G_OBJECT_CLASS (modest_default_account_settings_dialog_parent_class)->dispose)
172 G_OBJECT_CLASS (modest_default_account_settings_dialog_parent_class)->dispose (object);
176 modest_account_settings_dialog_finalize (GObject *object)
178 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (object);
179 ModestDefaultAccountSettingsDialogPrivate *priv;
181 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
183 if (priv->account_name)
184 g_free (priv->account_name);
186 if (priv->original_account_title)
187 g_free (priv->original_account_title);
189 if (priv->account_manager)
190 g_object_unref (G_OBJECT (priv->account_manager));
192 if (priv->signature_dialog)
193 gtk_widget_destroy (priv->signature_dialog);
195 if (priv->settings) {
196 g_object_unref (priv->settings);
197 priv->settings = NULL;
200 G_OBJECT_CLASS (modest_default_account_settings_dialog_parent_class)->finalize (object);
204 on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data);
207 on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data);
210 on_modified_combobox_changed (GtkComboBox *widget, gpointer user_data)
212 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
213 ModestDefaultAccountSettingsDialogPrivate *priv;
215 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
216 priv->modified = TRUE;
220 on_modified_entry_changed (GtkEditable *editable, gpointer user_data)
222 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
223 ModestDefaultAccountSettingsDialogPrivate *priv;
225 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
226 priv->modified = TRUE;
230 on_modified_checkbox_toggled (GtkToggleButton *togglebutton, gpointer user_data)
232 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
233 ModestDefaultAccountSettingsDialogPrivate *priv;
235 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
236 priv->modified = TRUE;
240 on_modified_spin_button_changed (GtkSpinButton *spin_button, gpointer user_data)
242 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
243 ModestDefaultAccountSettingsDialogPrivate *priv;
245 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
246 gint value = gtk_spin_button_get_value_as_int (spin_button);
248 gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, value > 0);
249 priv->modified = TRUE;
252 /* Set a modified boolean whenever the widget is changed,
253 * so we can check for it later.
256 connect_for_modified (ModestDefaultAccountSettingsDialog *self,
259 if (GTK_SPIN_BUTTON (widget)) {
260 g_signal_connect (G_OBJECT (widget), "value_changed",
261 G_CALLBACK (on_modified_spin_button_changed), self);
263 else if (GTK_IS_ENTRY (widget)) {
264 g_signal_connect (G_OBJECT (widget), "changed",
265 G_CALLBACK (on_modified_entry_changed), self);
266 } else if (GTK_IS_COMBO_BOX (widget)) {
267 g_signal_connect (G_OBJECT (widget), "changed",
268 G_CALLBACK (on_modified_combobox_changed), self);
269 } else if (GTK_IS_TOGGLE_BUTTON (widget)) {
270 g_signal_connect (G_OBJECT (widget), "toggled",
271 G_CALLBACK (on_modified_checkbox_toggled), self);
276 on_field_entry_changed (GtkEditable *editable, gpointer user_data)
278 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
280 enable_buttons(self);
284 on_field_combobox_changed (GtkComboBox *widget, gpointer user_data)
286 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
288 enable_buttons(self);
291 /** This is a convenience function to create a field containing a mandatory widget.
292 * When the widget is edited, the enable_buttons() vfunc will be called.
295 create_field(ModestDefaultAccountSettingsDialog *self,
306 hbox = gtk_hbox_new (FALSE, 12);
308 title = g_strdup_printf("%s*:", value);
310 title = g_strdup_printf ("%s:", value);
311 label = gtk_label_new (title);
312 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
315 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
316 gtk_box_pack_start (GTK_BOX (hbox), control, TRUE, TRUE, 0);
317 gtk_size_group_add_widget (group, label);
319 /* Connect to the appropriate changed signal for the widget,
320 * so we can ask for the prev/next buttons to be enabled/disabled appropriately:
322 if (GTK_IS_ENTRY (control)) {
323 g_signal_connect (G_OBJECT (control), "changed",
324 G_CALLBACK (on_field_entry_changed), self);
327 else if (GTK_IS_COMBO_BOX (control)) {
328 g_signal_connect (G_OBJECT (control), "changed",
329 G_CALLBACK (on_field_combobox_changed), self);
331 gtk_widget_show_all (hbox);
337 on_entry_invalid_account_title_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
341 tmp = g_strndup (account_title_forbidden_chars, ACCOUNT_TITLE_FORBIDDEN_CHARS_LENGTH);
342 msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
344 modest_platform_information_banner (GTK_WIDGET (self), NULL, msg);
351 on_entry_invalid_fullname_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
355 tmp = g_strndup (user_name_forbidden_chars, USER_NAME_FORBIDDEN_CHARS_LENGTH);
356 msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
358 modest_platform_information_banner(GTK_WIDGET (self), NULL, msg);
366 on_entry_max (ModestValidatingEntry *self, gpointer user_data)
368 modest_platform_information_banner(GTK_WIDGET (self), NULL,
369 _CS("ckdg_ib_maximum_characters_reached"));
373 create_page_account_details (ModestDefaultAccountSettingsDialog *self)
375 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
376 GtkWidget *alignment;
377 GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
378 ModestDefaultAccountSettingsDialogPrivate *priv;
380 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
382 /* The description widgets: */
383 priv->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
384 GtkWidget *field = create_field (self, sizegroup, _("mcen_fi_account_title"),
385 priv->entry_account_title, NULL, TRUE);
386 gtk_widget_show (priv->entry_account_title);
387 connect_for_modified (self, priv->entry_account_title);
388 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
389 gtk_widget_show (field);
391 /* Prevent the use of some characters in the account title,
392 * as required by our UI specification: */
393 GList *list_prevent = NULL;
394 list_prevent = g_list_append (list_prevent, "\\");
395 list_prevent = g_list_append (list_prevent, "/");
396 list_prevent = g_list_append (list_prevent, ":");
397 list_prevent = g_list_append (list_prevent, "*");
398 list_prevent = g_list_append (list_prevent, "?");
399 list_prevent = g_list_append (list_prevent, "\"");
400 list_prevent = g_list_append (list_prevent, "<");
401 list_prevent = g_list_append (list_prevent, ">");
402 list_prevent = g_list_append (list_prevent, "|");
403 list_prevent = g_list_append (list_prevent, "^");
404 modest_validating_entry_set_unallowed_characters (
405 MODEST_VALIDATING_ENTRY (priv->entry_account_title), list_prevent);
406 g_list_free (list_prevent);
407 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
408 on_entry_invalid_account_title_character, self);
410 /* Set max length as in the UI spec:
411 * The UI spec seems to want us to show a dialog if we hit the maximum. */
412 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_account_title), 64);
413 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_account_title),
416 /* The retrieve combobox: */
417 priv->combo_retrieve = GTK_WIDGET (modest_retrieve_combo_box_new ());
418 field = create_field (self, sizegroup, _("mcen_fi_advsetup_retrievetype"),
419 priv->combo_retrieve, NULL, TRUE);
420 gtk_widget_show (priv->combo_retrieve);
421 connect_for_modified (self, priv->combo_retrieve);
422 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
423 gtk_widget_show (field);
425 /* The limit-retrieve combobox: */
426 priv->combo_limit_retrieve = GTK_WIDGET (modest_limit_retrieve_combo_box_new ());
427 field = create_field (self, sizegroup, _("mcen_fi_advsetup_limit_retrieve"),
428 priv->combo_limit_retrieve, NULL, TRUE);
429 gtk_widget_show (priv->combo_limit_retrieve);
430 connect_for_modified (self, priv->combo_limit_retrieve);
431 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
432 gtk_widget_show (field);
434 /* The leave-messages widgets: */
435 if(!priv->checkbox_leave_messages)
436 priv->checkbox_leave_messages = gtk_check_button_new ();
437 if (!priv->caption_leave_messages) {
438 priv->caption_leave_messages = create_field (self, sizegroup, _("mcen_fi_advsetup_leave_on_server"),
439 priv->checkbox_leave_messages, NULL, TRUE);
442 gtk_widget_show (priv->checkbox_leave_messages);
443 connect_for_modified (self, priv->checkbox_leave_messages);
444 gtk_box_pack_start (GTK_BOX (box), priv->caption_leave_messages, FALSE, FALSE, MODEST_MARGIN_HALF);
445 gtk_widget_show (priv->caption_leave_messages);
447 gtk_widget_show (GTK_WIDGET (box));
449 alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
450 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
451 gtk_container_add (GTK_CONTAINER (alignment), box);
452 gtk_widget_show (alignment);
454 return GTK_WIDGET (alignment);
458 get_entered_account_title (ModestAccountSettingsDialog *dialog)
460 ModestDefaultAccountSettingsDialogPrivate *priv;
462 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
464 const gchar* account_title =
465 gtk_entry_get_text (GTK_ENTRY (priv->entry_account_title));
466 if (!account_title || (strlen (account_title) == 0))
469 /* Strip it of whitespace at the start and end: */
470 gchar *result = g_strdup (account_title);
471 result = g_strstrip (result);
476 if (strlen (result) == 0) {
487 on_button_signature (GtkButton *button, gpointer user_data)
489 /* ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data); */
491 /* /\* Create the window, if necessary: *\/ */
492 /* if (!(priv->signature_dialog)) { */
493 /* priv->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ()); */
495 /* gboolean use_signature = modest_account_settings_get_use_signature (priv->settings); */
496 /* const gchar *signature = modest_account_settings_get_signature(priv->settings); */
497 /* gchar* account_title = get_entered_account_title (self); */
498 /* modest_signature_editor_dialog_set_settings ( */
499 /* MODEST_SIGNATURE_EDITOR_DIALOG (priv->signature_dialog), */
500 /* use_signature, signature, account_title); */
502 /* g_free (account_title); */
503 /* account_title = NULL; */
504 /* signature = NULL; */
507 /* /\* Show the window: *\/ */
508 /* gtk_window_set_transient_for (GTK_WINDOW (priv->signature_dialog), GTK_WINDOW (self)); */
509 /* gtk_window_set_modal (GTK_WINDOW (priv->signature_dialog), TRUE); */
510 /* const gint response = gtk_dialog_run (GTK_DIALOG (priv->signature_dialog)); */
511 /* gtk_widget_hide (priv->signature_dialog); */
512 /* if (response != GTK_RESPONSE_OK) { */
513 /* /\* Destroy the widget now, and its data: *\/ */
514 /* gtk_widget_destroy (priv->signature_dialog); */
515 /* priv->signature_dialog = NULL; */
518 /* /\* Mark modified, so we use the dialog's data later: *\/ */
519 /* priv->modified = TRUE; */
524 create_page_user_details (ModestDefaultAccountSettingsDialog *self)
526 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
527 GtkWidget *alignment;
528 GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
529 ModestDefaultAccountSettingsDialogPrivate *priv;
531 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
533 /* The name widgets: */
534 priv->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
536 /* Set max length as in the UI spec:
537 * The UI spec seems to want us to show a dialog if we hit the maximum. */
538 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_name), 64);
539 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_name),
541 GtkWidget *field = create_field (self, sizegroup,
542 _("mcen_li_emailsetup_name"), priv->entry_user_name, NULL, FALSE);
543 gtk_widget_show (priv->entry_user_name);
544 connect_for_modified (self, priv->entry_user_name);
545 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
546 gtk_widget_show (field);
549 /* Prevent the use of some characters in the name,
550 * as required by our UI specification: */
551 GList *list_prevent = NULL;
552 list_prevent = g_list_append (list_prevent, "<");
553 list_prevent = g_list_append (list_prevent, ">");
554 modest_validating_entry_set_unallowed_characters (
555 MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
556 g_list_free (list_prevent);
557 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
558 on_entry_invalid_fullname_character, self);
560 /* The username widgets: */
561 priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
562 field = create_field (self, sizegroup, _("mail_fi_username"),
563 priv->entry_user_username, NULL, TRUE);
564 gtk_widget_show (priv->entry_user_username);
565 connect_for_modified (self, priv->entry_user_username);
566 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
567 gtk_widget_show (field);
569 /* Prevent the use of some characters in the username,
570 * as required by our UI specification: */
571 modest_validating_entry_set_unallowed_characters_whitespace (
572 MODEST_VALIDATING_ENTRY (priv->entry_user_username));
574 /* Set max length as in the UI spec:
575 * The UI spec seems to want us to show a dialog if we hit the maximum. */
576 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
577 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_username),
580 /* The password widgets: */
581 priv->entry_user_password = gtk_entry_new ();
582 gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
583 /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
584 field = create_field (self, sizegroup,
585 _("mail_fi_password"), priv->entry_user_password, NULL, FALSE);
586 gtk_widget_show (priv->entry_user_password);
587 connect_for_modified (self, priv->entry_user_password);
588 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
589 gtk_widget_show (field);
591 /* The email address widgets: */
592 priv->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
593 field = create_field (self, sizegroup,
594 _("mcen_li_emailsetup_email_address"), priv->entry_user_email, NULL, TRUE);
595 gtk_entry_set_text (GTK_ENTRY (priv->entry_user_email), MODEST_EXAMPLE_EMAIL_ADDRESS); /* Default text. */
596 gtk_widget_show (priv->entry_user_email);
597 connect_for_modified (self, priv->entry_user_email);
598 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
599 gtk_widget_show (field);
601 /* Set max length as in the UI spec:
602 * The UI spec seems to want us to show a dialog if we hit the maximum. */
603 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_email), 64);
604 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_email),
607 /* Signature button: */
608 if (!priv->button_signature)
609 priv->button_signature = gtk_button_new_with_label (_("mcen_bd_edit"));
610 field = create_field (self, sizegroup, _("mcen_fi_email_signature"),
611 priv->button_signature, NULL, FALSE);
612 gtk_widget_show (priv->button_signature);
613 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
614 gtk_widget_show (field);
616 g_signal_connect (G_OBJECT (priv->button_signature), "clicked",
617 G_CALLBACK (on_button_signature), self);
619 gtk_widget_show (GTK_WIDGET (box));
621 alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
622 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
623 gtk_container_add (GTK_CONTAINER (alignment), box);
624 gtk_widget_show (alignment);
626 return GTK_WIDGET (alignment);
629 /** Change the field title for the incoming server,
630 * as specified in the UI spec:
633 update_incoming_server_title (ModestAccountSettingsDialog *self,
634 ModestProtocolType protocol)
636 ModestDefaultAccountSettingsDialogPrivate *priv;
638 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
641 (protocol == MODEST_PROTOCOLS_STORE_POP ?
642 _("mail_fi_emailtype_pop3") :
643 _("mail_fi_emailtype_imap") );
646 /* Note that this produces a compiler warning,
647 * because the compiler does not know that the translated string will have a %s in it.
648 * I do not see a way to avoid the warning while still using these Logical IDs. murrayc. */
649 gchar* incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), type);
651 /* This is a mandatory field, so add a *. This is usually done by
652 * create_field() but we can't use that here. */
653 gchar *with_asterisk = g_strconcat (incomingserver_title, "*", NULL);
654 g_free (incomingserver_title);
656 g_object_set (G_OBJECT (priv->caption_incoming), "label", with_asterisk, NULL);
657 g_free(with_asterisk);
660 /** Change the field title for the incoming server,
661 * as specified in the UI spec:
664 update_incoming_server_security_choices (ModestAccountSettingsDialog *self,
665 ModestProtocolType protocol)
667 ModestDefaultAccountSettingsDialogPrivate *priv;
669 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
671 /* Fill the combo with appropriately titled choices for POP or IMAP. */
672 /* The choices are the same, but the titles are different, as in the UI spec. */
673 modest_serversecurity_combo_box_fill (
674 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security), protocol);
678 create_page_incoming (ModestDefaultAccountSettingsDialog *self)
680 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
681 GtkWidget *alignment;
682 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
683 ModestDefaultAccountSettingsDialogPrivate *priv;
685 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
687 /* The incoming server widgets: */
688 if(!priv->entry_incomingserver)
689 priv->entry_incomingserver = gtk_entry_new ();
691 if (priv->caption_incoming)
692 gtk_widget_destroy (priv->caption_incoming);
694 /* The field title will be updated in update_incoming_server_title().
695 * so this default text will never be seen: */
696 /* (Note: Changing the title seems pointless. murrayc) */
697 priv->caption_incoming = create_field (self, sizegroup,
698 "Incoming Server", priv->entry_incomingserver, NULL, TRUE);
699 gtk_widget_show (priv->entry_incomingserver);
700 connect_for_modified (self, priv->entry_incomingserver);
701 gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
702 gtk_widget_show (priv->caption_incoming);
704 /* The secure connection widgets: */
705 /* This will be filled by update_incoming_server_security_choices(). */
706 if (!priv->combo_incoming_security)
707 priv->combo_incoming_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
708 GtkWidget *field = create_field (self, sizegroup, _("mcen_li_emailsetup_secure_connection"),
709 priv->combo_incoming_security, NULL, FALSE);
710 gtk_widget_show (priv->combo_incoming_security);
711 connect_for_modified (self, priv->combo_incoming_security);
712 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
713 gtk_widget_show (field);
715 /* Show a default port number when the security method changes, as per the UI spec: */
716 g_signal_connect (G_OBJECT (priv->combo_incoming_security), "changed", (GCallback)on_combo_incoming_security_changed, self);
719 /* The port widgets: */
720 if (!priv->entry_incoming_port)
721 priv->entry_incoming_port = GTK_WIDGET (gtk_spin_button_new_with_range ((gdouble) PORT_MIN, (gdouble) PORT_MAX, 1.0));
722 field = create_field (self, sizegroup, _("mcen_fi_emailsetup_port"),
723 priv->entry_incoming_port, NULL, FALSE);
724 gtk_widget_show (priv->entry_incoming_port);
725 connect_for_modified (self, priv->entry_incoming_port);
726 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
727 gtk_widget_show (field);
729 /* The secure authentication widgets: */
730 if(!priv->checkbox_incoming_auth)
731 priv->checkbox_incoming_auth = gtk_check_button_new ();
732 field = create_field (self, sizegroup, _("mcen_li_emailsetup_secure_authentication"),
733 priv->checkbox_incoming_auth, NULL, FALSE);
734 gtk_widget_show (priv->checkbox_incoming_auth);
735 connect_for_modified (self, priv->checkbox_incoming_auth);
736 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
737 gtk_widget_show (field);
739 gtk_widget_show (GTK_WIDGET (box));
741 alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
742 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
743 gtk_container_add (GTK_CONTAINER (alignment), box);
744 gtk_widget_show (alignment);
746 return GTK_WIDGET (alignment);
750 on_toggle_button_changed (GtkToggleButton *togglebutton, gpointer user_data)
752 GtkWidget *widget = GTK_WIDGET (user_data);
754 /* Enable the widget only if the toggle button is active: */
755 const gboolean enable = gtk_toggle_button_get_active (togglebutton);
756 gtk_widget_set_sensitive (widget, enable);
759 /* Make the sensitivity of a widget depend on a toggle button.
762 enable_widget_for_togglebutton (GtkWidget *widget, GtkToggleButton* button)
764 g_signal_connect (G_OBJECT (button), "toggled",
765 G_CALLBACK (on_toggle_button_changed), widget);
767 /* Set the starting sensitivity: */
768 on_toggle_button_changed (button, widget);
772 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
774 /* ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data); */
776 /* /\* Create the window if necessary: *\/ */
777 /* if (!(priv->specific_window)) { */
778 /* priv->specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ()); */
779 /* modest_connection_specific_smtp_window_fill_with_connections ( */
780 /* MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (priv->specific_window), priv->account_manager); */
783 /* /\* Show the window: *\/ */
784 /* gtk_window_set_transient_for (GTK_WINDOW (priv->specific_window), GTK_WINDOW (self)); */
785 /* gtk_window_set_modal (GTK_WINDOW (priv->specific_window), TRUE); */
786 /* gtk_widget_show (priv->specific_window); */
787 /* priv->modified = TRUE; */
791 on_combo_outgoing_auth_changed (GtkComboBox *widget, gpointer user_data)
793 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
794 ModestDefaultAccountSettingsDialogPrivate *priv;
796 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
798 ModestProtocolType protocol_security =
799 modest_secureauth_combo_box_get_active_secureauth (
800 MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth));
801 const gboolean secureauth_used = protocol_security != MODEST_PROTOCOLS_AUTH_NONE;
803 gtk_widget_set_sensitive (priv->caption_outgoing_username, secureauth_used);
804 gtk_widget_set_sensitive (priv->caption_outgoing_password, secureauth_used);
808 on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data)
810 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
811 ModestDefaultAccountSettingsDialogPrivate *priv;
813 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
815 const gint port_number =
816 modest_serversecurity_combo_box_get_active_serversecurity_port (
817 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security));
819 if(port_number != 0) {
820 gtk_spin_button_set_value (
821 GTK_SPIN_BUTTON (priv->entry_outgoing_port), (gdouble) port_number);
826 on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data)
828 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
829 ModestDefaultAccountSettingsDialogPrivate *priv;
831 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
833 const gint port_number =
834 modest_serversecurity_combo_box_get_active_serversecurity_port (
835 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security));
837 if(port_number != 0) {
838 gtk_spin_button_set_value (
839 GTK_SPIN_BUTTON (priv->entry_incoming_port), (gdouble) port_number);
845 create_page_outgoing (ModestDefaultAccountSettingsDialog *self)
847 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
848 GtkWidget *alignment;
849 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
851 ModestDefaultAccountSettingsDialogPrivate *priv;
853 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
855 /* The outgoing server widgets: */
856 if (!priv->entry_outgoingserver)
857 priv->entry_outgoingserver = gtk_entry_new ();
858 GtkWidget *field = create_field (self, sizegroup,
859 _("mcen_li_emailsetup_smtp"), priv->entry_outgoingserver, NULL, FALSE);
860 gtk_widget_show (priv->entry_outgoingserver);
861 connect_for_modified (self, priv->entry_outgoingserver);
862 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
863 gtk_widget_show (field);
865 /* The secure authentication widgets: */
866 if (!priv->combo_outgoing_auth)
867 priv->combo_outgoing_auth = GTK_WIDGET (modest_secureauth_combo_box_new ());
868 field = create_field (self, sizegroup, _("mcen_li_emailsetup_secure_authentication"),
869 priv->combo_outgoing_auth, NULL, FALSE);
870 gtk_widget_show (priv->combo_outgoing_auth);
871 connect_for_modified (self, priv->combo_outgoing_auth);
872 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
873 gtk_widget_show (field);
875 /* Dim the outgoing username and password when no secure authentication is used, as per the UI spec: */
876 g_signal_connect (G_OBJECT (priv->combo_outgoing_auth), "changed", (GCallback)on_combo_outgoing_auth_changed, self);
878 /* The username widgets: */
879 priv->entry_outgoing_username = GTK_WIDGET (modest_validating_entry_new ());
880 priv->caption_outgoing_username = create_field (self, sizegroup, _("mail_fi_username"),
881 priv->entry_outgoing_username, NULL, TRUE);
882 gtk_widget_show (priv->entry_outgoing_username);
883 connect_for_modified (self, priv->entry_outgoing_username);
884 gtk_box_pack_start (GTK_BOX (box), priv->caption_outgoing_username, FALSE, FALSE, MODEST_MARGIN_HALF);
885 gtk_widget_show (priv->caption_outgoing_username);
887 /* Prevent the use of some characters in the username,
888 * as required by our UI specification: */
889 modest_validating_entry_set_unallowed_characters_whitespace (
890 MODEST_VALIDATING_ENTRY (priv->entry_outgoing_username));
892 /* Set max length as in the UI spec:
893 * The UI spec seems to want us to show a dialog if we hit the maximum. */
894 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_outgoing_username), 64);
895 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_outgoing_username),
898 /* The password widgets: */
899 priv->entry_outgoing_password = gtk_entry_new ();
900 gtk_entry_set_visibility (GTK_ENTRY (priv->entry_outgoing_password), FALSE);
901 /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_outgoing_password), '*'); */
902 priv->caption_outgoing_password = create_field (self, sizegroup,
903 _("mail_fi_password"), priv->entry_outgoing_password, NULL, FALSE);
904 gtk_widget_show (priv->entry_outgoing_password);
905 connect_for_modified (self, priv->entry_outgoing_password);
906 gtk_box_pack_start (GTK_BOX (box), priv->caption_outgoing_password, FALSE, FALSE, MODEST_MARGIN_HALF);
907 gtk_widget_show (priv->caption_outgoing_password);
909 /* The secure connection widgets: */
910 /* This will be filled and set with modest_serversecurity_combo_box_fill()
911 * and modest_serversecurity_combo_box_set_active_serversecurity().
913 if (!priv->combo_outgoing_security)
915 priv->combo_outgoing_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
916 field = create_field (self, sizegroup, _("mcen_li_emailsetup_secure_connection"),
917 priv->combo_outgoing_security, NULL, FALSE);
918 gtk_widget_show (priv->combo_outgoing_security);
919 connect_for_modified (self, priv->combo_outgoing_security);
920 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
921 gtk_widget_show (field);
923 /* Show a default port number when the security method changes, as per the UI spec: */
924 g_signal_connect (G_OBJECT (priv->combo_outgoing_security), "changed", (GCallback)on_combo_outgoing_security_changed, self);
926 /* The port widgets: */
927 if (!priv->entry_outgoing_port)
928 priv->entry_outgoing_port = GTK_WIDGET (gtk_spin_button_new_with_range ((gdouble)PORT_MIN, (gdouble) PORT_MAX, 1.0));
929 field = create_field (self, sizegroup, _("mcen_fi_emailsetup_port"),
930 priv->entry_outgoing_port, NULL, FALSE);
931 gtk_widget_show (priv->entry_outgoing_port);
932 connect_for_modified (self, priv->entry_outgoing_port);
933 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
934 gtk_widget_show (field);
936 GtkWidget *separator = gtk_hseparator_new ();
937 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
938 gtk_widget_show (separator);
940 /* connection-specific checkbox: */
941 if (!priv->checkbox_outgoing_smtp_specific) {
942 priv->checkbox_outgoing_smtp_specific = gtk_check_button_new ();
943 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbox_outgoing_smtp_specific),
946 field = create_field (self, sizegroup, _("mcen_fi_advsetup_connection_smtp"),
947 priv->checkbox_outgoing_smtp_specific, NULL, FALSE);
948 gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
949 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
950 gtk_widget_show (field);
951 connect_for_modified (self, priv->checkbox_outgoing_smtp_specific);
953 /* Connection-specific SMTP-Severs Edit button: */
954 if (!priv->button_outgoing_smtp_servers)
955 priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_edit"));
956 field = create_field (self, sizegroup, _("mcen_fi_advsetup_optional_smtp"),
957 priv->button_outgoing_smtp_servers, NULL, FALSE);
958 gtk_widget_show (priv->button_outgoing_smtp_servers);
959 gtk_box_pack_start (GTK_BOX (box), field, FALSE, FALSE, MODEST_MARGIN_HALF);
960 gtk_widget_show (field);
962 /* Only enable the button when the checkbox is checked: */
963 enable_widget_for_togglebutton (priv->button_outgoing_smtp_servers,
964 GTK_TOGGLE_BUTTON (priv->checkbox_outgoing_smtp_specific));
966 g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
967 G_CALLBACK (on_button_outgoing_smtp_servers), self);
969 gtk_widget_show (GTK_WIDGET (box));
971 alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
972 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
973 gtk_container_add (GTK_CONTAINER (alignment), box);
974 gtk_widget_show (alignment);
976 return GTK_WIDGET (alignment);
980 check_data (ModestAccountSettingsDialog *self)
982 ModestDefaultAccountSettingsDialogPrivate *priv;
984 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
986 /* Check that the title is not already in use: */
987 gchar* account_title = get_entered_account_title (self);
989 return FALSE; /* Should be prevented already anyway. */
991 if (g_strcmp0 (account_title, priv->original_account_title) != 0) {
992 /* Check the changed title: */
993 const gboolean name_in_use = modest_account_mgr_account_with_display_name_exists (priv->account_manager,
997 /* Warn the user via a dialog: */
998 modest_platform_information_banner(NULL, NULL, _("mail_ib_account_name_already_existing"));
1000 g_free (account_title);
1005 g_free (account_title);
1006 account_title = NULL;
1008 /* Check that the email address is valid: */
1009 const gchar* email_address = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_email));
1010 if ((!email_address) || (strlen(email_address) == 0)) {
1014 if (!modest_text_utils_validate_email_address (email_address, NULL)) {
1015 /* Warn the user via a dialog: */
1016 modest_platform_information_banner (NULL, NULL, _("mcen_ib_invalid_email"));
1018 /* Return focus to the email address entry: */
1019 gtk_widget_grab_focus (priv->entry_user_email);
1020 gtk_editable_select_region (GTK_EDITABLE (priv->entry_user_email), 0, -1);
1024 /* make sure the domain name for the incoming server is valid */
1025 const gchar* hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_incomingserver));
1026 if ((!hostname) || (strlen(hostname) == 0)) {
1030 if (!modest_text_utils_validate_domain_name (hostname)) {
1031 /* Warn the user via a dialog: */
1032 modest_platform_information_banner (NULL, NULL, _("mcen_ib_invalid_servername"));
1034 /* Return focus to the email address entry: */
1035 gtk_widget_grab_focus (priv->entry_incomingserver);
1036 gtk_editable_select_region (GTK_EDITABLE (priv->entry_incomingserver), 0, -1);
1040 /* make sure the domain name for the outgoing server is valid */
1041 const gchar* hostname2 = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
1042 if ((!hostname2) || (strlen(hostname2) == 0)) {
1046 if (!modest_text_utils_validate_domain_name (hostname2)) {
1047 /* Warn the user via a dialog: */
1048 modest_platform_information_banner (priv->entry_outgoingserver, NULL, _("mcen_ib_invalid_servername"));
1050 /* Return focus to the email address entry: */
1051 gtk_widget_grab_focus (priv->entry_outgoingserver);
1052 gtk_editable_select_region (GTK_EDITABLE (priv->entry_outgoingserver), 0, -1);
1056 /* Find a suitable authentication method when secure authentication is desired */
1058 const gint port_num = gtk_spin_button_get_value_as_int (
1059 GTK_SPIN_BUTTON (priv->entry_incoming_port));
1060 const gchar* username = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username));
1063 const ModestProtocolType protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
1064 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security));
1066 /* If we use an encrypted protocol then there is no need to encrypt the password */
1067 /* I don't think this is a good assumption. It overrides the user's request. murrayc:
1068 * if (!modest_protocol_info_is_secure(protocol_security_incoming)) */
1071 if (gtk_toggle_button_get_active (
1072 GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth))) {
1073 GError *error = NULL;
1075 GList *list_auth_methods =
1076 modest_utils_get_supported_secure_authentication_methods (priv->incoming_protocol,
1077 hostname, port_num, username, GTK_WINDOW (self), &error);
1078 if (list_auth_methods) {
1079 /* Use the first supported method.
1080 * TODO: Should we prioritize them, to prefer a particular one? */
1082 for (method = list_auth_methods; method != NULL; method = g_list_next(method))
1084 ModestProtocolType proto = (ModestProtocolType)(GPOINTER_TO_INT(method->data));
1085 // Allow secure methods, e.g MD5 only
1086 if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (), proto))
1088 priv->protocol_authentication_incoming = proto;
1092 g_list_free (list_auth_methods);
1095 if (list_auth_methods == NULL ||
1096 !modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (),
1097 priv->protocol_authentication_incoming)) {
1098 if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
1099 error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
1100 modest_platform_information_banner(GTK_WIDGET (self), NULL,
1101 _("Could not discover supported secure authentication methods."));
1104 g_error_free(error);
1106 /* This is a nasty hack. jschmid. */
1107 /* Don't let the dialog close */
1108 /*g_signal_stop_emission_by_name (dialog, "response");*/
1119 on_response (GtkDialog *wizard_dialog,
1123 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (wizard_dialog);
1124 ModestDefaultAccountSettingsDialogPrivate *priv;
1126 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
1128 enable_buttons (self);
1130 gboolean prevent_response = FALSE;
1132 /* Warn about unsaved changes: */
1133 if (response_id == GTK_RESPONSE_CANCEL && priv->modified) {
1134 GtkDialog *dialog = GTK_DIALOG (modest_platform_run_confirmation_dialog (GTK_WINDOW (self),
1135 _("imum_nc_wizard_confirm_lose_changes")));
1136 /* TODO: These button names will be ambiguous, and not specified in the UI specification. */
1138 const gint dialog_response = gtk_dialog_run (dialog);
1139 gtk_widget_destroy (GTK_WIDGET (dialog));
1141 if (dialog_response != GTK_RESPONSE_OK)
1142 prevent_response = TRUE;
1144 /* Check for invalid input: */
1145 else if (response_id != GTK_RESPONSE_CANCEL && !check_data (self)) {
1146 prevent_response = TRUE;
1149 if (prevent_response) {
1150 /* This is a nasty hack. murrayc. */
1151 /* Don't let the dialog close */
1152 g_signal_stop_emission_by_name (wizard_dialog, "response");
1156 if (response_id == GTK_RESPONSE_OK) {
1157 /* Try to save the changes if modified (NB #59251): */
1160 const gboolean saved = save_configuration (self);
1162 /* Do not show the account-saved dialog if we are just saving this
1163 * temporarily, because from the user's point of view it will not
1164 * really be saved (saved + enabled) until later
1166 if (modest_account_settings_get_account_name (priv->settings) != NULL) {
1167 ModestServerAccountSettings *store_settings;
1168 ModestServerAccountSettings *transport_settings;
1169 const gchar *store_account_name;
1170 const gchar *transport_account_name;
1173 store_settings = modest_account_settings_get_store_settings (priv->settings);
1174 transport_settings = modest_account_settings_get_transport_settings (priv->settings);
1175 store_account_name = modest_server_account_settings_get_account_name (store_settings);
1176 transport_account_name = modest_server_account_settings_get_account_name (transport_settings);
1178 if (store_account_name) {
1179 modest_account_mgr_notify_account_update (priv->account_manager,
1180 store_account_name);
1182 if (transport_account_name) {
1183 modest_account_mgr_notify_account_update (priv->account_manager,
1184 transport_account_name);
1186 g_object_unref (store_settings);
1187 g_object_unref (transport_settings);
1189 modest_platform_information_banner(NULL, NULL, _("mcen_ib_advsetup_settings_saved"));
1192 modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
1199 modest_account_settings_dialog_init (gpointer g, gpointer iface_data)
1201 ModestAccountSettingsDialogClass *iface = (ModestAccountSettingsDialogClass *) g;
1203 iface->load_settings = modest_default_account_settings_dialog_load_settings;
1207 modest_default_account_settings_dialog_init (ModestDefaultAccountSettingsDialog *self)
1209 ModestDefaultAccountSettingsDialogPrivate *priv;
1211 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
1213 /* Create the notebook to be used by the GtkDialog base class:
1214 * Each page of the notebook will be a page of the wizard: */
1215 priv->notebook = GTK_NOTEBOOK (gtk_notebook_new());
1216 priv->settings = modest_account_settings_new ();
1218 /* Get the account manager object,
1219 * so we can check for existing accounts,
1220 * and create new accounts: */
1221 priv->account_manager = modest_runtime_get_account_mgr ();
1222 g_assert (priv->account_manager);
1223 g_object_ref (priv->account_manager);
1225 priv->protocol_authentication_incoming = MODEST_PROTOCOLS_AUTH_PASSWORD;
1227 /* Create the common pages,
1229 priv->page_account_details = create_page_account_details (self);
1230 priv->page_user_details = create_page_user_details (self);
1231 priv->page_incoming = create_page_incoming (self);
1232 priv->page_outgoing = create_page_outgoing (self);
1234 /* Add the notebook pages: */
1235 gtk_notebook_append_page (priv->notebook, priv->page_account_details,
1236 gtk_label_new (_("mcen_ti_account_settings_account")));
1237 gtk_notebook_append_page (priv->notebook, priv->page_user_details,
1238 gtk_label_new (_("mcen_ti_account_settings_userinfo")));
1239 gtk_notebook_append_page (priv->notebook, priv->page_incoming,
1240 gtk_label_new (_("mcen_ti_advsetup_retrieval")));
1241 gtk_notebook_append_page (priv->notebook, priv->page_outgoing,
1242 gtk_label_new (_("mcen_ti_advsetup_sending")));
1244 GtkDialog *dialog = GTK_DIALOG (self);
1245 gtk_container_add (GTK_CONTAINER (dialog->vbox), GTK_WIDGET (priv->notebook));
1246 gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), MODEST_MARGIN_HALF);
1247 gtk_widget_show (GTK_WIDGET (priv->notebook));
1249 /* Add the buttons: */
1250 gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
1251 gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_SAVE, GTK_RESPONSE_OK);
1253 /* Connect to the dialog's response signal: */
1254 /* We use connect-before
1255 * so we can stop the signal emission,
1256 * to stop the default signal handler from closing the dialog.
1258 g_signal_connect (G_OBJECT (self), "response",
1259 G_CALLBACK (on_response), self);
1261 priv->modified = FALSE;
1263 /* When this window is shown, hibernation should not be possible,
1264 * because there is no sensible way to save the state: */
1265 modest_window_mgr_prevent_hibernation_while_window_is_shown (
1266 modest_runtime_get_window_mgr (), GTK_WINDOW (self));
1268 gtk_window_set_default_size (GTK_WINDOW (self), 600, 400);
1270 /* hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_accountsettings", */
1271 /* modest_maemo_utils_get_osso_context()); */
1274 ModestAccountSettingsDialog*
1275 modest_default_account_settings_dialog_new (void)
1277 return g_object_new (MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG, NULL);
1280 /** Update the UI with the stored account details, so they can be edited.
1281 * @account_name: Name of the account, which should contain incoming and outgoing server accounts.
1284 modest_default_account_settings_dialog_load_settings (ModestAccountSettingsDialog *dialog,
1285 ModestAccountSettings *settings)
1287 ModestServerAccountSettings *incoming_account;
1288 ModestServerAccountSettings *outgoing_account;
1289 const gchar *account_name;
1291 g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
1292 ModestDefaultAccountSettingsDialogPrivate *priv;
1294 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
1296 incoming_account = modest_account_settings_get_store_settings (settings);
1297 outgoing_account = modest_account_settings_get_transport_settings (settings);
1299 account_name = modest_account_settings_get_account_name (settings);
1301 /* Save the account name so we can refer to it later: */
1302 if (priv->account_name)
1303 g_free (priv->account_name);
1304 priv->account_name = g_strdup (account_name);
1307 g_object_unref (priv->settings);
1308 priv->settings = g_object_ref (settings);
1310 /* Save the account title so we can refer to it if the user changes it: */
1311 if (priv->original_account_title)
1312 g_free (priv->original_account_title);
1313 priv->original_account_title = g_strdup (modest_account_settings_get_display_name (settings));
1315 /* Show the account data in the widgets: */
1317 /* Note that we never show the non-display name in the UI.
1318 * (Though the display name defaults to the non-display name at the start.) */
1319 gtk_entry_set_text( GTK_ENTRY (priv->entry_account_title),
1320 null_means_empty (modest_account_settings_get_display_name (settings)));
1321 gtk_entry_set_text( GTK_ENTRY (priv->entry_user_name),
1322 null_means_empty (modest_account_settings_get_fullname (settings)));
1323 gtk_entry_set_text( GTK_ENTRY (priv->entry_user_email),
1324 null_means_empty (modest_account_settings_get_email_address (settings)));
1325 modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve),
1326 modest_server_account_settings_get_protocol (incoming_account));
1327 modest_retrieve_combo_box_set_active_retrieve_conf (MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve),
1328 modest_account_settings_get_retrieve_type (settings));
1329 modest_limit_retrieve_combo_box_set_active_limit_retrieve (
1330 MODEST_LIMIT_RETRIEVE_COMBO_BOX (priv->combo_limit_retrieve),
1331 modest_account_settings_get_retrieve_limit (settings));
1334 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbox_leave_messages),
1335 modest_account_settings_get_leave_messages_on_server (settings));
1337 /* Only show the leave-on-server checkbox for POP,
1338 * as per the UI spec: */
1339 if (modest_server_account_settings_get_protocol (incoming_account) != MODEST_PROTOCOLS_STORE_POP) {
1340 gtk_widget_hide (priv->caption_leave_messages);
1342 gtk_widget_show (priv->caption_leave_messages);
1345 update_incoming_server_security_choices (dialog, modest_server_account_settings_get_protocol (incoming_account));
1346 if (incoming_account) {
1347 const gchar *username;
1348 const gchar *password;
1349 const gchar *hostname;
1350 /* Remember this for later: */
1351 priv->incoming_protocol = modest_server_account_settings_get_protocol (incoming_account);;
1353 hostname = modest_server_account_settings_get_hostname (incoming_account);
1354 username = modest_server_account_settings_get_username (incoming_account);
1355 password = modest_server_account_settings_get_password (incoming_account);
1356 gtk_entry_set_text( GTK_ENTRY (priv->entry_user_username),
1357 null_means_empty (username));
1358 gtk_entry_set_text( GTK_ENTRY (priv->entry_user_password),
1359 null_means_empty (password));
1361 gtk_entry_set_text( GTK_ENTRY (priv->entry_incomingserver),
1362 null_means_empty (hostname));
1364 /* The UI spec says:
1365 * If secure authentication is unchecked, allow sending username and password also as plain text.
1366 * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc.
1367 * TODO: Do we need to discover which of these (SSL, TLS, CRAM-MD5) is supported?
1369 modest_serversecurity_combo_box_set_active_serversecurity (
1370 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security),
1371 modest_server_account_settings_get_security_protocol (incoming_account));
1376 - use encrypted passwords
1378 const ModestProtocolType secure_auth = modest_server_account_settings_get_auth_protocol (incoming_account);
1379 priv->protocol_authentication_incoming = (secure_auth != MODEST_PROTOCOLS_AUTH_NONE)?
1380 secure_auth:MODEST_PROTOCOLS_AUTH_PASSWORD;
1381 if (modest_protocol_registry_protocol_type_is_secure(modest_runtime_get_protocol_registry (),
1384 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth),
1389 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth),
1393 update_incoming_server_title (dialog, priv->incoming_protocol);
1395 const gint port_num = modest_server_account_settings_get_port (incoming_account);
1396 if (port_num == 0) {
1397 /* Show the appropriate port number: */
1398 on_combo_incoming_security_changed (
1399 GTK_COMBO_BOX (priv->combo_incoming_security), dialog);
1401 /* Keep the user-entered port-number,
1402 * or the already-appropriate automatic port number: */
1403 gtk_spin_button_set_value (
1404 GTK_SPIN_BUTTON (priv->entry_incoming_port), (gdouble) port_num);
1406 g_object_unref (incoming_account);
1409 outgoing_account = modest_account_settings_get_transport_settings (settings);
1410 if (outgoing_account) {
1411 const gchar *hostname;
1412 const gchar *username;
1413 const gchar *password;
1415 /* Remember this for later: */
1416 priv->outgoing_protocol =
1417 modest_server_account_settings_get_protocol (outgoing_account);
1419 hostname = modest_server_account_settings_get_hostname (outgoing_account);
1420 username = modest_server_account_settings_get_username (outgoing_account);
1421 password = modest_server_account_settings_get_password (outgoing_account);
1422 gtk_entry_set_text( GTK_ENTRY (priv->entry_outgoingserver),
1423 null_means_empty (hostname));
1425 gtk_entry_set_text( GTK_ENTRY (priv->entry_outgoing_username),
1426 null_means_empty (username));
1427 gtk_entry_set_text( GTK_ENTRY (priv->entry_outgoing_password),
1428 null_means_empty (password));
1430 /* Get the secure-auth setting: */
1431 const ModestProtocolType secure_auth = modest_server_account_settings_get_auth_protocol (outgoing_account);
1432 modest_secureauth_combo_box_set_active_secureauth (
1433 MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth), secure_auth);
1434 on_combo_outgoing_auth_changed (GTK_COMBO_BOX (priv->combo_outgoing_auth), dialog);
1436 modest_serversecurity_combo_box_fill (
1437 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security),
1438 priv->outgoing_protocol);
1440 /* Get the security setting: */
1441 const ModestProtocolType security =
1442 modest_server_account_settings_get_security_protocol (outgoing_account);
1443 modest_serversecurity_combo_box_set_active_serversecurity (
1444 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), security);
1446 const gint port_num = modest_server_account_settings_get_port (outgoing_account);
1447 if (port_num == 0) {
1448 /* Show the appropriate port number: */
1449 on_combo_outgoing_security_changed (
1450 GTK_COMBO_BOX (priv->combo_outgoing_security), dialog);
1453 /* Keep the user-entered port-number,
1454 * or the already-appropriate automatic port number: */
1455 gtk_spin_button_set_value (
1456 GTK_SPIN_BUTTON (priv->entry_outgoing_port), (gdouble) port_num);
1459 const gboolean has_specific =
1460 modest_account_settings_get_use_connection_specific_smtp (settings);
1461 gtk_toggle_button_set_active (
1462 GTK_TOGGLE_BUTTON (priv->checkbox_outgoing_smtp_specific),
1464 g_object_unref (outgoing_account);
1467 /* Set window title according to account: */
1468 /* TODO: Is this the correct way to find a human-readable name for
1469 * the protocol used? */
1470 ModestProtocol *proto =
1471 modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
1472 priv->incoming_protocol);
1474 const gchar* proto_str = modest_protocol_get_display_name (proto);
1475 gchar *proto_name = g_utf8_strup(proto_str, -1);
1476 const gchar *account_title = modest_account_settings_get_display_name(settings);
1478 gchar *title = g_strdup_printf(_("mcen_ti_account_settings"), proto_name, account_title);
1479 g_free (proto_name);
1481 gtk_window_set_title (GTK_WINDOW (dialog), title);
1484 /* account_data->is_enabled, */
1485 /*account_data->is_default, */
1487 /* Unset the modified flag so we can detect changes later: */
1488 priv->modified = FALSE;
1491 /** Show the User Info tab.
1494 modest_account_settings_dialog_switch_to_user_info (ModestAccountSettingsDialog *dialog)
1496 ModestDefaultAccountSettingsDialogPrivate *priv;
1498 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
1500 const gint page_num = gtk_notebook_page_num (priv->notebook, priv->page_user_details);
1501 if (page_num == -1) {
1502 g_warning ("%s: notebook page not found.\n", __FUNCTION__);
1505 /* Ensure that the widget is visible so that gtk_notebook_set_current_page() works: */
1506 /* TODO: even this hack (recommened by the GTK+ documentation) doesn't seem to work. */
1508 gtk_widget_show (priv->page_user_details);
1509 gtk_widget_show (GTK_WIDGET (priv->notebook));
1510 gtk_widget_show (GTK_WIDGET (dialog));
1511 gtk_notebook_set_current_page (priv->notebook, page_num);
1515 save_configuration (ModestAccountSettingsDialog *dialog)
1517 ModestServerAccountSettings *store_settings;
1518 ModestServerAccountSettings *transport_settings;
1519 ModestDefaultAccountSettingsDialogPrivate *priv;
1521 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
1523 /* Set the account data from the widgets: */
1524 const gchar* account_name = priv->account_name;
1525 const gchar* user_fullname = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_name));
1526 modest_account_settings_set_fullname (priv->settings, user_fullname);
1528 const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_email));
1529 modest_account_settings_set_email_address (priv->settings, emailaddress);
1531 /* /\* Signature: *\/ */
1532 /* if (priv->signature_dialog) { */
1533 /* gboolean use_signature = FALSE; */
1534 /* gchar *signature = */
1535 /* modest_signature_editor_dialog_get_settings (MODEST_SIGNATURE_EDITOR_DIALOG (priv->signature_dialog), */
1536 /* &use_signature); */
1538 /* modest_account_settings_set_use_signature (priv->settings, use_signature); */
1539 /* modest_account_settings_set_signature (priv->settings, signature); */
1542 ModestAccountRetrieveType retrieve_type = modest_retrieve_combo_box_get_active_retrieve_conf (
1543 MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve));
1544 modest_account_settings_set_retrieve_type (priv->settings, retrieve_type);
1546 gint retrieve_limit = modest_limit_retrieve_combo_box_get_active_limit_retrieve (
1547 MODEST_LIMIT_RETRIEVE_COMBO_BOX (priv->combo_limit_retrieve));
1548 modest_account_settings_set_retrieve_limit (priv->settings, retrieve_limit);
1550 const gboolean leave_on_server = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->checkbox_leave_messages));
1551 modest_account_settings_set_leave_messages_on_server (priv->settings, leave_on_server);
1553 store_settings = modest_account_settings_get_store_settings (priv->settings);
1555 const gchar* hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_incomingserver));
1556 modest_server_account_settings_set_hostname (store_settings, hostname);
1558 const gchar* username = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username));
1559 modest_server_account_settings_set_username (store_settings, username);
1561 const gchar* password = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password));
1562 modest_server_account_settings_set_password (store_settings, password);
1565 gint port_num = gtk_spin_button_get_value_as_int (
1566 GTK_SPIN_BUTTON (priv->entry_incoming_port));
1567 modest_server_account_settings_set_port (store_settings, port_num);
1569 /* The UI spec says:
1570 * If secure authentication is unchecked, allow sending username and password also as plain text.
1571 * If secure authentication is checked, require one of the secure
1572 * methods during connection: SSL, TLS, CRAM-MD5 etc.
1575 const ModestProtocolType protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
1576 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security));
1577 modest_server_account_settings_set_security_protocol (store_settings,
1578 protocol_security_incoming);
1579 modest_server_account_settings_set_auth_protocol (store_settings,
1580 priv->protocol_authentication_incoming);
1582 g_object_unref (store_settings);
1585 transport_settings = modest_account_settings_get_transport_settings (priv->settings);
1587 hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
1588 modest_server_account_settings_set_hostname (transport_settings, hostname);
1590 username = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoing_username));
1591 modest_server_account_settings_set_username (transport_settings, username);
1593 password = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoing_password));
1594 modest_server_account_settings_set_password (transport_settings, password);
1596 const ModestProtocolType protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
1597 MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security));
1598 modest_server_account_settings_set_security_protocol (transport_settings,
1599 protocol_security_outgoing);
1601 const ModestProtocolType protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth (
1602 MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth));
1603 modest_server_account_settings_set_auth_protocol (transport_settings, protocol_authentication_outgoing);
1606 port_num = gtk_spin_button_get_value_as_int (
1607 GTK_SPIN_BUTTON (priv->entry_outgoing_port));
1608 modest_server_account_settings_set_port (transport_settings, port_num);
1609 g_object_unref (transport_settings);
1612 /* Set the changed account title last, to simplify the previous code: */
1613 gchar* account_title = get_entered_account_title (dialog);
1615 return FALSE; /* Should be prevented already anyway. */
1617 /* if (strcmp (account_title, account_name) != 0) { */
1618 modest_account_settings_set_display_name (priv->settings, account_title);
1620 g_free (account_title);
1621 account_title = NULL;
1623 /* Save connection-specific SMTP server accounts: */
1624 modest_account_settings_set_use_connection_specific_smtp
1626 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbox_outgoing_smtp_specific)));
1628 /* this configuration is not persistent, we should not save */
1629 if (account_name != NULL)
1630 modest_account_mgr_save_account_settings (priv->account_manager, priv->settings);
1632 /* if (priv->specific_window) { */
1633 /* return modest_connection_specific_smtp_window_save_server_accounts ( */
1634 /* MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (priv->specific_window)); */
1641 static gboolean entry_is_empty (GtkWidget *entry)
1646 const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
1647 if ((!text) || (strlen(text) == 0))
1650 /* Strip it of whitespace at the start and end: */
1651 gchar *stripped = g_strdup (text);
1652 stripped = g_strstrip (stripped);
1657 const gboolean result = (strlen (stripped) == 0);
1665 enable_buttons (ModestAccountSettingsDialog *self)
1667 gboolean enable_ok = TRUE;
1668 ModestProtocolType outgoing_auth_protocol;
1669 ModestDefaultAccountSettingsDialogPrivate *priv;
1671 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);;
1673 /* The account details title is mandatory: */
1674 if (entry_is_empty(priv->entry_account_title))
1677 /* The user details username is mandatory: */
1678 if (enable_ok && entry_is_empty(priv->entry_user_username))
1681 /* The user details email address is mandatory: */
1682 if (enable_ok && entry_is_empty (priv->entry_user_email))
1685 /* The custom incoming server is mandatory: */
1686 if (enable_ok && entry_is_empty(priv->entry_incomingserver))
1689 /* The custom incoming server is mandatory: */
1690 if (enable_ok && entry_is_empty(priv->entry_outgoingserver))
1693 /* Outgoing username is mandatory if outgoing auth is secure */
1694 if (priv->combo_outgoing_auth) {
1695 outgoing_auth_protocol = modest_secureauth_combo_box_get_active_secureauth (
1696 MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth));
1698 outgoing_auth_protocol != MODEST_PROTOCOLS_AUTH_NONE &&
1699 entry_is_empty (priv->entry_outgoing_username))
1703 /* Enable the buttons,
1704 * identifying them via their associated response codes:
1706 GtkDialog *dialog_base = GTK_DIALOG (self);
1707 gtk_dialog_set_response_sensitive (dialog_base,
1713 modest_account_settings_dialog_check_allow_changes (ModestAccountSettingsDialog *self)
1715 ModestServerAccountSettings *incoming_settings;
1716 const gchar *server_account_name;
1717 gboolean username_known;
1718 ModestDefaultAccountSettingsDialogPrivate *priv;
1720 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);;
1722 if (!G_IS_OBJECT (priv->settings))
1725 incoming_settings = modest_account_settings_get_store_settings (priv->settings);
1726 server_account_name = modest_server_account_settings_get_account_name (incoming_settings);
1728 username_known = modest_account_mgr_get_server_account_username_has_succeeded (priv->account_manager,
1729 server_account_name);
1731 /* Enable or disable widgets */
1732 gtk_widget_set_sensitive (priv->entry_user_username, !username_known);
1733 gtk_widget_set_sensitive (priv->entry_incomingserver, !username_known);
1734 gtk_widget_set_sensitive (priv->entry_incoming_port, !username_known);
1735 gtk_widget_set_sensitive (priv->combo_incoming_security, !username_known);
1739 modest_account_settings_dialog_save_password (ModestAccountSettingsDialog *dialog)
1741 ModestDefaultAccountSettingsDialogPrivate *priv;
1743 g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog));
1745 priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
1746 priv->modified = TRUE;
1750 modest_default_account_settings_dialog_class_init (ModestDefaultAccountSettingsDialogClass *klass)
1752 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1753 g_type_class_add_private (klass, sizeof (ModestDefaultAccountSettingsDialogPrivate));
1755 object_class->get_property = modest_account_settings_dialog_get_property;
1756 object_class->set_property = modest_account_settings_dialog_set_property;
1757 object_class->dispose = modest_account_settings_dialog_dispose;
1758 object_class->finalize = modest_account_settings_dialog_finalize;