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 "modest-account-settings-dialog.h"
32 #include <glib/gi18n.h>
33 #include <gtk/gtknotebook.h>
34 #include <gtk/gtkvbox.h>
35 #include <gtk/gtklabel.h>
36 #include <gtk/gtkcombobox.h>
37 #include <gtk/gtkentry.h>
38 #include <gtk/gtkbutton.h>
39 #include <gtk/gtkcheckbutton.h>
40 #include <gtk/gtkmessagedialog.h>
41 #include <gtk/gtkstock.h>
42 #include "modest-hildon-includes.h"
44 #include "widgets/modest-serversecurity-combo-box.h"
45 #include "widgets/modest-secureauth-combo-box.h"
46 #include "widgets/modest-validating-entry.h"
47 #include "widgets/modest-retrieve-combo-box.h"
48 #include "widgets/modest-limit-retrieve-combo-box.h"
49 #include "modest-text-utils.h"
50 #include "modest-account-mgr.h"
51 #include "modest-account-mgr-helpers.h" /* For modest_account_mgr_get_account_data(). */
52 #include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
53 #include "modest-protocol-info.h"
54 #include "maemo/modest-connection-specific-smtp-window.h"
55 #include "maemo/modest-signature-editor-dialog.h"
56 #include "maemo/modest-maemo-utils.h"
57 #include "widgets/modest-ui-constants.h"
59 #include <tny-camel-transport-account.h>
60 #include <tny-camel-imap-store-account.h>
61 #include <tny-camel-pop-store-account.h>
62 #include <tny-status.h>
64 #include <gconf/gconf-client.h>
65 #include <string.h> /* For strlen(). */
67 /* Include config.h so that _() works: */
72 #define EXAMPLE_EMAIL_ADDRESS "first.last@provider.com"
75 #define PORT_MAX 65535
77 G_DEFINE_TYPE (ModestAccountSettingsDialog, modest_account_settings_dialog, GTK_TYPE_DIALOG);
79 #define ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE(o) \
80 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG, ModestAccountSettingsDialogPrivate))
82 typedef struct _ModestAccountSettingsDialogPrivate ModestAccountSettingsDialogPrivate;
84 struct _ModestAccountSettingsDialogPrivate
89 enable_buttons (ModestAccountSettingsDialog *self);
92 save_configuration (ModestAccountSettingsDialog *dialog);
95 modest_account_settings_dialog_get_property (GObject *object, guint property_id,
96 GValue *value, GParamSpec *pspec)
98 switch (property_id) {
100 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
105 modest_account_settings_dialog_set_property (GObject *object, guint property_id,
106 const GValue *value, GParamSpec *pspec)
108 switch (property_id) {
110 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
115 modest_account_settings_dialog_dispose (GObject *object)
117 if (G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->dispose)
118 G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->dispose (object);
122 modest_account_settings_dialog_finalize (GObject *object)
124 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (object);
126 if (self->account_name)
127 g_free (self->account_name);
129 if (self->original_account_title)
130 g_free (self->original_account_title);
132 if (self->account_manager)
133 g_object_unref (G_OBJECT (self->account_manager));
135 if (self->specific_window)
136 gtk_widget_destroy (self->specific_window);
138 if (self->signature_dialog)
139 gtk_widget_destroy (self->signature_dialog);
141 G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->finalize (object);
145 show_error (GtkWidget *parent_widget, const gchar* text);
148 on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data);
151 on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data);
154 on_modified_combobox_changed (GtkComboBox *widget, gpointer user_data)
156 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
157 self->modified = TRUE;
161 on_modified_entry_changed (GtkEditable *editable, gpointer user_data)
163 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
164 self->modified = TRUE;
168 on_modified_checkbox_toggled (GtkToggleButton *togglebutton, gpointer user_data)
170 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
171 self->modified = TRUE;
175 on_modified_number_editor_changed (HildonNumberEditor *number_editor, gint new_value, gpointer user_data)
177 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
178 self->modified = TRUE;
181 /* Set a modified boolean whenever the widget is changed,
182 * so we can check for it later.
185 connect_for_modified (ModestAccountSettingsDialog *self, GtkWidget *widget)
187 if (HILDON_IS_NUMBER_EDITOR (widget)) {
188 g_signal_connect (G_OBJECT (widget), "notify::value",
189 G_CALLBACK (on_modified_number_editor_changed), self);
191 else if (GTK_IS_ENTRY (widget)) {
192 g_signal_connect (G_OBJECT (widget), "changed",
193 G_CALLBACK (on_modified_entry_changed), self);
194 } else if (GTK_IS_COMBO_BOX (widget)) {
195 g_signal_connect (G_OBJECT (widget), "changed",
196 G_CALLBACK (on_modified_combobox_changed), self);
197 } else if (GTK_IS_TOGGLE_BUTTON (widget)) {
198 g_signal_connect (G_OBJECT (widget), "toggled",
199 G_CALLBACK (on_modified_checkbox_toggled), self);
204 on_caption_entry_changed (GtkEditable *editable, gpointer user_data)
206 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
208 enable_buttons(self);
212 on_caption_combobox_changed (GtkComboBox *widget, gpointer user_data)
214 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
216 enable_buttons(self);
219 /** This is a convenience function to create a caption containing a mandatory widget.
220 * When the widget is edited, the enable_buttons() vfunc will be called.
222 static GtkWidget* create_caption_new_with_asterisk(ModestAccountSettingsDialog *self,
227 HildonCaptionStatus flag)
229 GtkWidget *caption = NULL;
231 /* Note: Previously, the translated strings already contained the "*",
232 * Comment out this code if they do again.
234 /* Add a * character to indicate mandatory fields,
235 * as specified in our "Email UI Specification": */
236 if (flag == HILDON_CAPTION_MANDATORY) {
237 gchar* title = g_strdup_printf("%s*", value);
238 caption = hildon_caption_new (group, title, control, icon, flag);
242 caption = hildon_caption_new (group, value, control, icon, flag);
244 /* Connect to the appropriate changed signal for the widget,
245 * so we can ask for the prev/next buttons to be enabled/disabled appropriately:
247 if (GTK_IS_ENTRY (control)) {
248 g_signal_connect (G_OBJECT (control), "changed",
249 G_CALLBACK (on_caption_entry_changed), self);
252 else if (GTK_IS_COMBO_BOX (control)) {
253 g_signal_connect (G_OBJECT (control), "changed",
254 G_CALLBACK (on_caption_combobox_changed), self);
261 on_entry_invalid_account_title_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
265 tmp = g_strndup (account_title_forbidden_chars, ACCOUNT_TITLE_FORBIDDEN_CHARS_LENGTH);
266 msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
268 show_error (GTK_WIDGET (self), msg);
275 on_entry_invalid_fullname_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
279 tmp = g_strndup (user_name_forbidden_chars, USER_NAME_FORBIDDEN_CHARS_LENGTH);
280 msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
282 show_error (GTK_WIDGET (self), msg);
290 on_entry_max (ModestValidatingEntry *self, gpointer user_data)
292 /* ModestAccountSettingsDialog *dialog = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data); */
293 show_error (GTK_WIDGET (self), _CS("ckdg_ib_maximum_characters_reached"));
297 create_page_account_details (ModestAccountSettingsDialog *self)
299 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
300 GtkAdjustment *focus_adjustment = NULL;
302 /* Create a size group to be used by all captions.
303 * Note that HildonCaption does not create a default size group if we do not specify one.
304 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
305 GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
306 GtkWidget *scrollwin = gtk_scrolled_window_new (NULL, NULL);
307 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
308 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
310 /* The description widgets: */
311 self->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
312 /* Do use auto-capitalization: */
313 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_account_title),
314 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
315 GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_account_title"),
316 self->entry_account_title, NULL, HILDON_CAPTION_MANDATORY);
317 gtk_widget_show (self->entry_account_title);
318 connect_for_modified (self, self->entry_account_title);
319 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
320 gtk_widget_show (caption);
322 /* Prevent the use of some characters in the account title,
323 * as required by our UI specification: */
324 GList *list_prevent = NULL;
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 list_prevent = g_list_append (list_prevent, "\"");
331 list_prevent = g_list_append (list_prevent, "<");
332 list_prevent = g_list_append (list_prevent, ">");
333 list_prevent = g_list_append (list_prevent, "|");
334 list_prevent = g_list_append (list_prevent, "^");
335 modest_validating_entry_set_unallowed_characters (
336 MODEST_VALIDATING_ENTRY (self->entry_account_title), list_prevent);
337 g_list_free (list_prevent);
338 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_account_title),
339 on_entry_invalid_account_title_character, self);
341 /* Set max length as in the UI spec:
342 * The UI spec seems to want us to show a dialog if we hit the maximum. */
343 gtk_entry_set_max_length (GTK_ENTRY (self->entry_account_title), 64);
344 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_account_title),
347 /* The retrieve combobox: */
348 self->combo_retrieve = GTK_WIDGET (modest_retrieve_combo_box_new ());
349 caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_retrievetype"),
350 self->combo_retrieve, NULL, HILDON_CAPTION_MANDATORY);
351 gtk_widget_show (self->combo_retrieve);
352 connect_for_modified (self, self->combo_retrieve);
353 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
354 gtk_widget_show (caption);
356 /* The limit-retrieve combobox: */
357 self->combo_limit_retrieve = GTK_WIDGET (modest_limit_retrieve_combo_box_new ());
358 caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_limit_retrieve"),
359 self->combo_limit_retrieve, NULL, HILDON_CAPTION_MANDATORY);
360 gtk_widget_show (self->combo_limit_retrieve);
361 connect_for_modified (self, self->combo_limit_retrieve);
362 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
363 gtk_widget_show (caption);
365 /* The leave-messages widgets: */
366 if(!self->checkbox_leave_messages)
367 self->checkbox_leave_messages = gtk_check_button_new ();
368 if (!self->caption_leave_messages) {
369 self->caption_leave_messages = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_leave_on_server"),
370 self->checkbox_leave_messages, NULL, HILDON_CAPTION_MANDATORY);
373 gtk_widget_show (self->checkbox_leave_messages);
374 connect_for_modified (self, self->checkbox_leave_messages);
375 gtk_box_pack_start (GTK_BOX (box), self->caption_leave_messages, FALSE, FALSE, MODEST_MARGIN_HALF);
376 gtk_widget_show (self->caption_leave_messages);
378 gtk_widget_show (GTK_WIDGET (box));
380 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollwin), box);
381 gtk_widget_show (scrollwin);
383 focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
384 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
386 return GTK_WIDGET (scrollwin);
390 get_entered_account_title (ModestAccountSettingsDialog *dialog)
392 const gchar* account_title =
393 gtk_entry_get_text (GTK_ENTRY (dialog->entry_account_title));
394 if (!account_title || (strlen (account_title) == 0))
397 /* Strip it of whitespace at the start and end: */
398 gchar *result = g_strdup (account_title);
399 result = g_strstrip (result);
404 if (strlen (result) == 0) {
415 on_button_signature (GtkButton *button, gpointer user_data)
417 ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
419 /* Create the window, if necessary: */
420 if (!(self->signature_dialog)) {
421 self->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ());
423 gboolean use_signature = FALSE;
424 gchar *signature = modest_account_mgr_get_signature(self->account_manager, self->account_name,
426 gchar* account_title = get_entered_account_title (self);
427 modest_signature_editor_dialog_set_settings (
428 MODEST_SIGNATURE_EDITOR_DIALOG (self->signature_dialog),
429 use_signature, signature, account_title);
430 g_free (account_title);
431 account_title = NULL;
436 /* Show the window: */
437 gtk_window_set_transient_for (GTK_WINDOW (self->signature_dialog), GTK_WINDOW (self));
438 gtk_window_set_modal (GTK_WINDOW (self->signature_dialog), TRUE);
439 const gint response = gtk_dialog_run (GTK_DIALOG (self->signature_dialog));
440 gtk_widget_hide (self->signature_dialog);
441 if (response != GTK_RESPONSE_OK) {
442 /* Destroy the widget now, and its data: */
443 gtk_widget_destroy (self->signature_dialog);
444 self->signature_dialog = NULL;
447 /* Mark modified, so we use the dialog's data later: */
448 self->modified = TRUE;
453 create_page_user_details (ModestAccountSettingsDialog *self)
455 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
456 GtkAdjustment *focus_adjustment = NULL;
458 /* Create a size group to be used by all captions.
459 * Note that HildonCaption does not create a default size group if we do not specify one.
460 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
461 GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
462 GtkWidget *scrollwin = gtk_scrolled_window_new (NULL, NULL);
463 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
464 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
466 /* The name widgets: */
467 self->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
469 /* Auto-capitalization is the default, so let's turn it off: */
470 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_name), HILDON_GTK_INPUT_MODE_FULL);
471 /* Set max length as in the UI spec:
472 * The UI spec seems to want us to show a dialog if we hit the maximum. */
473 gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_name), 64);
474 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_name),
476 GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup,
477 _("mcen_li_emailsetup_name"), self->entry_user_name, NULL, HILDON_CAPTION_OPTIONAL);
478 gtk_widget_show (self->entry_user_name);
479 connect_for_modified (self, self->entry_user_name);
480 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
481 gtk_widget_show (caption);
484 /* Prevent the use of some characters in the name,
485 * as required by our UI specification: */
486 GList *list_prevent = NULL;
487 list_prevent = g_list_append (list_prevent, "<");
488 list_prevent = g_list_append (list_prevent, ">");
489 modest_validating_entry_set_unallowed_characters (
490 MODEST_VALIDATING_ENTRY (self->entry_user_name), list_prevent);
491 g_list_free (list_prevent);
492 modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_user_name),
493 on_entry_invalid_fullname_character, self);
495 /* The username widgets: */
496 self->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
497 /* Auto-capitalization is the default, so let's turn it off: */
498 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_username), HILDON_GTK_INPUT_MODE_FULL);
499 caption = create_caption_new_with_asterisk (self, sizegroup, _("mail_fi_username"),
500 self->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
501 gtk_widget_show (self->entry_user_username);
502 connect_for_modified (self, self->entry_user_username);
503 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
504 gtk_widget_show (caption);
506 /* Prevent the use of some characters in the username,
507 * as required by our UI specification: */
508 modest_validating_entry_set_unallowed_characters_whitespace (
509 MODEST_VALIDATING_ENTRY (self->entry_user_username));
511 /* Set max length as in the UI spec:
512 * The UI spec seems to want us to show a dialog if we hit the maximum. */
513 gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_username), 64);
514 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_username),
517 /* The password widgets: */
518 self->entry_user_password = gtk_entry_new ();
519 /* Auto-capitalization is the default, so let's turn it off: */
520 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_password),
521 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
522 gtk_entry_set_visibility (GTK_ENTRY (self->entry_user_password), FALSE);
523 /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_user_password), '*'); */
524 caption = create_caption_new_with_asterisk (self, sizegroup,
525 _("mail_fi_password"), self->entry_user_password, NULL, HILDON_CAPTION_OPTIONAL);
526 gtk_widget_show (self->entry_user_password);
527 connect_for_modified (self, self->entry_user_password);
528 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
529 gtk_widget_show (caption);
531 /* The email address widgets: */
532 self->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
533 /* Auto-capitalization is the default, so let's turn it off: */
534 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
535 caption = create_caption_new_with_asterisk (self, sizegroup,
536 _("mcen_li_emailsetup_email_address"), self->entry_user_email, NULL, HILDON_CAPTION_MANDATORY);
537 gtk_entry_set_text (GTK_ENTRY (self->entry_user_email), EXAMPLE_EMAIL_ADDRESS); /* Default text. */
538 gtk_widget_show (self->entry_user_email);
539 connect_for_modified (self, self->entry_user_email);
540 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
541 gtk_widget_show (caption);
543 /* Set max length as in the UI spec:
544 * The UI spec seems to want us to show a dialog if we hit the maximum. */
545 gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_email), 64);
546 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_email),
549 /* Signature button: */
550 if (!self->button_signature)
551 self->button_signature = gtk_button_new_with_label (_("mcen_bd_edit"));
552 caption = hildon_caption_new (sizegroup, _("mcen_fi_email_signature"),
553 self->button_signature, NULL, HILDON_CAPTION_OPTIONAL);
554 hildon_caption_set_child_expand (HILDON_CAPTION (caption), FALSE);
555 gtk_widget_show (self->button_signature);
556 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
557 gtk_widget_show (caption);
559 g_signal_connect (G_OBJECT (self->button_signature), "clicked",
560 G_CALLBACK (on_button_signature), self);
562 gtk_widget_show (GTK_WIDGET (box));
563 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollwin), box);
564 gtk_widget_show (scrollwin);
566 focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
567 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
569 return GTK_WIDGET (scrollwin);
572 /** Change the caption title for the incoming server,
573 * as specified in the UI spec:
575 static void update_incoming_server_title (ModestAccountSettingsDialog *self, ModestTransportStoreProtocol protocol)
578 (protocol == MODEST_PROTOCOL_STORE_POP ?
579 _("mail_fi_emailtype_pop3") :
580 _("mail_fi_emailtype_imap") );
583 /* Note that this produces a compiler warning,
584 * because the compiler does not know that the translated string will have a %s in it.
585 * I do not see a way to avoid the warning while still using these Logical IDs. murrayc. */
586 gchar* incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), type);
588 /* This is a mandatory field, so add a *. This is usually done by
589 * create_caption_new_with_asterisk() but we can't use that here. */
590 gchar *with_asterisk = g_strconcat (incomingserver_title, "*", NULL);
591 g_free (incomingserver_title);
593 g_object_set (G_OBJECT (self->caption_incoming), "label", with_asterisk, NULL);
594 g_free(with_asterisk);
597 /** Change the caption title for the incoming server,
598 * as specified in the UI spec:
600 static void update_incoming_server_security_choices (ModestAccountSettingsDialog *self, ModestTransportStoreProtocol protocol)
602 /* Fill the combo with appropriately titled choices for POP or IMAP. */
603 /* The choices are the same, but the titles are different, as in the UI spec. */
604 modest_serversecurity_combo_box_fill (
605 MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security), protocol);
608 static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self)
610 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
612 /* Create a size group to be used by all captions.
613 * Note that HildonCaption does not create a default size group if we do not specify one.
614 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
615 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
617 /* The incoming server widgets: */
618 if(!self->entry_incomingserver)
619 self->entry_incomingserver = gtk_entry_new ();
620 /* Auto-capitalization is the default, so let's turn it off: */
621 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
623 if (self->caption_incoming)
624 gtk_widget_destroy (self->caption_incoming);
626 /* The caption title will be updated in update_incoming_server_title().
627 * so this default text will never be seen: */
628 /* (Note: Changing the title seems pointless. murrayc) */
629 self->caption_incoming = create_caption_new_with_asterisk (self, sizegroup,
630 "Incoming Server", self->entry_incomingserver, NULL, HILDON_CAPTION_MANDATORY);
631 gtk_widget_show (self->entry_incomingserver);
632 connect_for_modified (self, self->entry_incomingserver);
633 gtk_box_pack_start (GTK_BOX (box), self->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
634 gtk_widget_show (self->caption_incoming);
636 /* The secure connection widgets: */
637 /* This will be filled by update_incoming_server_security_choices(). */
638 if (!self->combo_incoming_security)
639 self->combo_incoming_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
640 GtkWidget *caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
641 self->combo_incoming_security, NULL, HILDON_CAPTION_OPTIONAL);
642 gtk_widget_show (self->combo_incoming_security);
643 connect_for_modified (self, self->combo_incoming_security);
644 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
645 gtk_widget_show (caption);
647 /* Show a default port number when the security method changes, as per the UI spec: */
648 g_signal_connect (G_OBJECT (self->combo_incoming_security), "changed", (GCallback)on_combo_incoming_security_changed, self);
651 /* The port widgets: */
652 if (!self->entry_incoming_port)
653 self->entry_incoming_port = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
654 caption = hildon_caption_new (sizegroup, _("mcen_fi_emailsetup_port"),
655 self->entry_incoming_port, NULL, HILDON_CAPTION_OPTIONAL);
656 gtk_widget_show (self->entry_incoming_port);
657 connect_for_modified (self, self->entry_incoming_port);
658 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
659 gtk_widget_show (caption);
661 /* The secure authentication widgets: */
662 if(!self->checkbox_incoming_auth)
663 self->checkbox_incoming_auth = gtk_check_button_new ();
664 caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
665 self->checkbox_incoming_auth, NULL, HILDON_CAPTION_OPTIONAL);
666 gtk_widget_show (self->checkbox_incoming_auth);
667 connect_for_modified (self, self->checkbox_incoming_auth);
668 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
669 gtk_widget_show (caption);
671 gtk_widget_show (GTK_WIDGET (box));
673 return GTK_WIDGET (box);
677 on_toggle_button_changed (GtkToggleButton *togglebutton, gpointer user_data)
679 GtkWidget *widget = GTK_WIDGET (user_data);
681 /* Enable the widget only if the toggle button is active: */
682 const gboolean enable = gtk_toggle_button_get_active (togglebutton);
683 gtk_widget_set_sensitive (widget, enable);
686 /* Make the sensitivity of a widget depend on a toggle button.
689 enable_widget_for_togglebutton (GtkWidget *widget, GtkToggleButton* button)
691 g_signal_connect (G_OBJECT (button), "toggled",
692 G_CALLBACK (on_toggle_button_changed), widget);
694 /* Set the starting sensitivity: */
695 on_toggle_button_changed (button, widget);
699 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
701 ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
703 /* Create the window if necessary: */
704 if (!(self->specific_window)) {
705 self->specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
706 modest_connection_specific_smtp_window_fill_with_connections (
707 MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), self->account_manager);
710 /* Show the window: */
711 gtk_window_set_transient_for (GTK_WINDOW (self->specific_window), GTK_WINDOW (self));
712 gtk_window_set_modal (GTK_WINDOW (self->specific_window), TRUE);
713 gtk_widget_show (self->specific_window);
717 on_combo_outgoing_auth_changed (GtkComboBox *widget, gpointer user_data)
719 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
721 ModestAuthProtocol protocol_security =
722 modest_secureauth_combo_box_get_active_secureauth (
723 MODEST_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth));
724 const gboolean secureauth_used = protocol_security != MODEST_PROTOCOL_AUTH_NONE;
726 gtk_widget_set_sensitive (self->caption_outgoing_username, secureauth_used);
727 gtk_widget_set_sensitive (self->caption_outgoing_password, secureauth_used);
731 on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data)
733 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
735 const gint port_number =
736 modest_serversecurity_combo_box_get_active_serversecurity_port (
737 MODEST_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security));
739 if(port_number != 0) {
740 hildon_number_editor_set_value (
741 HILDON_NUMBER_EDITOR (self->entry_outgoing_port), port_number);
746 on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data)
748 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
750 const gint port_number =
751 modest_serversecurity_combo_box_get_active_serversecurity_port (
752 MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
754 if(port_number != 0) {
755 hildon_number_editor_set_value (
756 HILDON_NUMBER_EDITOR (self->entry_incoming_port), port_number);
761 static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
763 GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
764 GtkAdjustment *focus_adjustment = NULL;
766 /* Put it all in a scrolled window, so that all widgets can be
767 * accessed even when the on-screen keyboard is visible: */
768 GtkWidget *scrollwin = gtk_scrolled_window_new(NULL, NULL);
769 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
770 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
772 /* Create a size group to be used by all captions.
773 * Note that HildonCaption does not create a default size group if we do not specify one.
774 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
775 GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
777 /* The outgoing server widgets: */
778 if (!self->entry_outgoingserver)
779 self->entry_outgoingserver = gtk_entry_new ();
780 /* Auto-capitalization is the default, so let's turn it off: */
781 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
782 GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup,
783 _("mcen_li_emailsetup_smtp"), self->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL);
784 gtk_widget_show (self->entry_outgoingserver);
785 connect_for_modified (self, self->entry_outgoingserver);
786 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
787 gtk_widget_show (caption);
789 /* The secure authentication widgets: */
790 if (!self->combo_outgoing_auth)
791 self->combo_outgoing_auth = GTK_WIDGET (modest_secureauth_combo_box_new ());
792 caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
793 self->combo_outgoing_auth, NULL, HILDON_CAPTION_OPTIONAL);
794 gtk_widget_show (self->combo_outgoing_auth);
795 connect_for_modified (self, self->combo_outgoing_auth);
796 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
797 gtk_widget_show (caption);
799 /* Dim the outgoing username and password when no secure authentication is used, as per the UI spec: */
800 g_signal_connect (G_OBJECT (self->combo_outgoing_auth), "changed", (GCallback)on_combo_outgoing_auth_changed, self);
802 /* The username widgets: */
803 self->entry_outgoing_username = GTK_WIDGET (modest_validating_entry_new ());
804 /* Auto-capitalization is the default, so let's turn it off: */
805 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoing_username), HILDON_GTK_INPUT_MODE_FULL);
806 self->caption_outgoing_username = create_caption_new_with_asterisk (self, sizegroup, _("mail_fi_username"),
807 self->entry_outgoing_username, NULL, HILDON_CAPTION_MANDATORY);
808 gtk_widget_show (self->entry_outgoing_username);
809 connect_for_modified (self, self->entry_outgoing_username);
810 gtk_box_pack_start (GTK_BOX (box), self->caption_outgoing_username, FALSE, FALSE, MODEST_MARGIN_HALF);
811 gtk_widget_show (self->caption_outgoing_username);
813 /* Prevent the use of some characters in the username,
814 * as required by our UI specification: */
815 modest_validating_entry_set_unallowed_characters_whitespace (
816 MODEST_VALIDATING_ENTRY (self->entry_outgoing_username));
818 /* Set max length as in the UI spec:
819 * The UI spec seems to want us to show a dialog if we hit the maximum. */
820 gtk_entry_set_max_length (GTK_ENTRY (self->entry_outgoing_username), 64);
821 modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_outgoing_username),
824 /* The password widgets: */
825 self->entry_outgoing_password = gtk_entry_new ();
826 /* Auto-capitalization is the default, so let's turn it off: */
827 hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoing_password),
828 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
829 gtk_entry_set_visibility (GTK_ENTRY (self->entry_outgoing_password), FALSE);
830 /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_outgoing_password), '*'); */
831 self->caption_outgoing_password = create_caption_new_with_asterisk (self, sizegroup,
832 _("mail_fi_password"), self->entry_outgoing_password, NULL, HILDON_CAPTION_OPTIONAL);
833 gtk_widget_show (self->entry_outgoing_password);
834 connect_for_modified (self, self->entry_outgoing_password);
835 gtk_box_pack_start (GTK_BOX (box), self->caption_outgoing_password, FALSE, FALSE, MODEST_MARGIN_HALF);
836 gtk_widget_show (self->caption_outgoing_password);
838 /* The secure connection widgets: */
839 /* This will be filled and set with modest_serversecurity_combo_box_fill()
840 * and modest_serversecurity_combo_box_set_active_serversecurity().
842 if (!self->combo_outgoing_security)
844 self->combo_outgoing_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
845 caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
846 self->combo_outgoing_security, NULL, HILDON_CAPTION_OPTIONAL);
847 gtk_widget_show (self->combo_outgoing_security);
848 connect_for_modified (self, self->combo_outgoing_security);
849 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
850 gtk_widget_show (caption);
852 /* Show a default port number when the security method changes, as per the UI spec: */
853 g_signal_connect (G_OBJECT (self->combo_outgoing_security), "changed", (GCallback)on_combo_outgoing_security_changed, self);
855 /* The port widgets: */
856 if (!self->entry_outgoing_port)
857 self->entry_outgoing_port = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
858 caption = hildon_caption_new (sizegroup, _("mcen_fi_emailsetup_port"),
859 self->entry_outgoing_port, NULL, HILDON_CAPTION_OPTIONAL);
860 gtk_widget_show (self->entry_outgoing_port);
861 connect_for_modified (self, self->entry_outgoing_port);
862 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
863 gtk_widget_show (caption);
865 GtkWidget *separator = gtk_hseparator_new ();
866 gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
867 gtk_widget_show (separator);
869 /* connection-specific checkbox: */
870 if (!self->checkbox_outgoing_smtp_specific) {
871 self->checkbox_outgoing_smtp_specific = gtk_check_button_new ();
872 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific),
875 caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_connection_smtp"),
876 self->checkbox_outgoing_smtp_specific, NULL, HILDON_CAPTION_OPTIONAL);
877 gtk_widget_show (self->checkbox_outgoing_smtp_specific);
878 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
879 gtk_widget_show (caption);
880 connect_for_modified (self, self->checkbox_outgoing_smtp_specific);
882 /* Connection-specific SMTP-Severs Edit button: */
883 if (!self->button_outgoing_smtp_servers)
884 self->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_edit"));
885 caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_optional_smtp"),
886 self->button_outgoing_smtp_servers, NULL, HILDON_CAPTION_OPTIONAL);
887 hildon_caption_set_child_expand (HILDON_CAPTION (caption), FALSE);
888 gtk_widget_show (self->button_outgoing_smtp_servers);
889 gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
890 gtk_widget_show (caption);
892 /* Only enable the button when the checkbox is checked: */
893 enable_widget_for_togglebutton (self->button_outgoing_smtp_servers,
894 GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific));
896 g_signal_connect (G_OBJECT (self->button_outgoing_smtp_servers), "clicked",
897 G_CALLBACK (on_button_outgoing_smtp_servers), self);
899 gtk_widget_show (GTK_WIDGET (box));
900 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrollwin), box);
901 gtk_widget_show(scrollwin);
903 focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
904 gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
906 return GTK_WIDGET (scrollwin);
910 /** TODO: This doesn't work because hildon_number_editor_get_value() does not work until
911 * focus has been lost:
912 * See https://bugs.maemo.org/show_bug.cgi?id=1806.
915 check_hildon_number_editor_and_warn_value_not_in_range (HildonNumberEditor *widget, gint min, gint max)
917 g_return_val_if_fail (widget, FALSE);
919 const gint port = hildon_number_editor_get_value (widget);
920 /* printf ("DEBUG: %s, port=%d\n", __FUNCTION__, port); */
921 if (port < PORT_MIN ||
924 /* Warn the user via a dialog: */
925 /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
926 gchar *message = g_strdup_printf (_CS("ckct_ib_set_a_value_within_range"),
929 hildon_banner_show_information (GTK_WIDGET (widget), NULL, message);
933 /* Return focus to the email address entry: */
934 gtk_widget_grab_focus (GTK_WIDGET (widget));
944 check_data (ModestAccountSettingsDialog *self)
946 /* Check that the title is not already in use: */
947 gchar* account_title = get_entered_account_title (self);
949 return FALSE; /* Should be prevented already anyway. */
951 if (strcmp(account_title, self->original_account_title) != 0) {
952 /* Check the changed title: */
953 const gboolean name_in_use = modest_account_mgr_account_with_display_name_exists (self->account_manager,
957 /* Warn the user via a dialog: */
958 hildon_banner_show_information(NULL, NULL, _("mail_ib_account_name_already_existing"));
960 g_free (account_title);
965 g_free (account_title);
966 account_title = NULL;
968 /* Check that the email address is valid: */
969 const gchar* email_address = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
970 if ((!email_address) || (strlen(email_address) == 0)) {
974 if (!modest_text_utils_validate_email_address (email_address, NULL)) {
975 /* Warn the user via a dialog: */
976 /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
977 hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email"));
979 /* Return focus to the email address entry: */
980 gtk_widget_grab_focus (self->entry_user_email);
981 gtk_editable_select_region (GTK_EDITABLE (self->entry_user_email), 0, -1);
985 /* make sure the domain name for the incoming server is valid */
986 const gchar* hostname = gtk_entry_get_text (GTK_ENTRY (self->entry_incomingserver));
987 if ((!hostname) || (strlen(hostname) == 0)) {
991 if (!modest_text_utils_validate_domain_name (hostname)) {
992 /* Warn the user via a dialog: */
993 /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
994 hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_servername"));
996 /* Return focus to the email address entry: */
997 gtk_widget_grab_focus (self->entry_incomingserver);
998 gtk_editable_select_region (GTK_EDITABLE (self->entry_incomingserver), 0, -1);
1002 /* make sure the domain name for the outgoing server is valid */
1003 const gchar* hostname2 = gtk_entry_get_text (GTK_ENTRY (self->entry_outgoingserver));
1004 if ((!hostname2) || (strlen(hostname2) == 0)) {
1008 if (!modest_text_utils_validate_domain_name (hostname2)) {
1009 /* Warn the user via a dialog: */
1010 /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
1011 hildon_banner_show_information (self->entry_outgoingserver, NULL, _("mcen_ib_invalid_servername"));
1013 /* Return focus to the email address entry: */
1014 gtk_widget_grab_focus (self->entry_outgoingserver);
1015 gtk_editable_select_region (GTK_EDITABLE (self->entry_outgoingserver), 0, -1);
1019 /* Check that the port numbers are acceptable: */
1020 if (!check_hildon_number_editor_and_warn_value_not_in_range (
1021 HILDON_NUMBER_EDITOR (self->entry_incoming_port), PORT_MIN, PORT_MAX)) {
1025 if (!check_hildon_number_editor_and_warn_value_not_in_range (
1026 HILDON_NUMBER_EDITOR (self->entry_outgoing_port), PORT_MIN, PORT_MAX)) {
1031 /* Find a suitable authentication method when secure authentication is desired */
1033 const gint port_num = hildon_number_editor_get_value (
1034 HILDON_NUMBER_EDITOR (self->entry_incoming_port));
1035 const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username));
1038 const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
1039 MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
1041 /* If we use an encrypted protocol then there is no need to encrypt the password */
1042 /* I don't think this is a good assumption. It overrides the user's request. murrayc:
1043 * if (!modest_protocol_info_is_secure(protocol_security_incoming)) */
1046 if (gtk_toggle_button_get_active (
1047 GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth))) {
1048 GError *error = NULL;
1050 GList *list_auth_methods =
1051 modest_maemo_utils_get_supported_secure_authentication_methods (self->incoming_protocol,
1052 hostname, port_num, username, GTK_WINDOW (self), &error);
1053 if (list_auth_methods) {
1054 /* Use the first supported method.
1055 * TODO: Should we prioritize them, to prefer a particular one? */
1057 for (method = list_auth_methods; method != NULL; method = g_list_next(method))
1059 ModestAuthProtocol proto = (ModestAuthProtocol)(GPOINTER_TO_INT(method->data));
1060 // Allow secure methods, e.g MD5 only
1061 if (modest_protocol_info_auth_is_secure(proto))
1063 self->protocol_authentication_incoming = proto;
1067 g_list_free (list_auth_methods);
1070 if (list_auth_methods == NULL ||
1071 !modest_protocol_info_auth_is_secure(self->protocol_authentication_incoming))
1073 if(error == NULL || error->domain != modest_maemo_utils_get_supported_secure_authentication_error_quark() ||
1074 error->code != MODEST_MAEMO_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
1076 show_error (GTK_WIDGET (self), _("Could not discover supported secure authentication methods."));
1080 g_error_free(error);
1082 /* This is a nasty hack. jschmid. */
1083 /* Don't let the dialog close */
1084 /*g_signal_stop_emission_by_name (dialog, "response");*/
1095 on_response (GtkDialog *wizard_dialog,
1099 ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (wizard_dialog);
1100 enable_buttons (self);
1102 gboolean prevent_response = FALSE;
1104 /* Warn about unsaved changes: */
1105 if (response_id == GTK_RESPONSE_CANCEL && self->modified) {
1106 GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
1107 _("imum_nc_wizard_confirm_lose_changes")));
1108 /* TODO: These button names will be ambiguous, and not specified in the UI specification. */
1110 const gint dialog_response = gtk_dialog_run (dialog);
1111 gtk_widget_destroy (GTK_WIDGET (dialog));
1113 if (dialog_response != GTK_RESPONSE_OK)
1114 prevent_response = TRUE;
1116 /* Check for invalid input: */
1117 else if (response_id != GTK_RESPONSE_CANCEL && !check_data (self)) {
1118 prevent_response = TRUE;
1121 if (prevent_response) {
1122 /* This is a nasty hack. murrayc. */
1123 /* Don't let the dialog close */
1124 g_signal_stop_emission_by_name (wizard_dialog, "response");
1128 if (response_id == GTK_RESPONSE_OK) {
1129 /* Try to save the changes if modified (NB #59251): */
1132 const gboolean saved = save_configuration (self);
1134 /* Do not show the account-saved dialog if we are just saving this
1135 * temporarily, because from the user's point of view it will not
1136 * really be saved (saved + enabled) until later.
1138 const gboolean enabled =
1139 modest_account_mgr_get_enabled (self->account_manager, self->account_name);
1141 show_error (NULL, _("mcen_ib_advsetup_settings_saved"));
1144 show_error (NULL, _("mail_ib_setting_failed"));
1150 modest_account_settings_dialog_init (ModestAccountSettingsDialog *self)
1152 /* Create the notebook to be used by the GtkDialog base class:
1153 * Each page of the notebook will be a page of the wizard: */
1154 self->notebook = GTK_NOTEBOOK (gtk_notebook_new());
1156 /* Get the account manager object,
1157 * so we can check for existing accounts,
1158 * and create new accounts: */
1159 self->account_manager = modest_runtime_get_account_mgr ();
1160 g_assert (self->account_manager);
1161 g_object_ref (self->account_manager);
1163 self->protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_PASSWORD;
1165 /* Create the common pages,
1167 self->page_account_details = create_page_account_details (self);
1168 self->page_user_details = create_page_user_details (self);
1169 self->page_incoming = create_page_incoming (self);
1170 self->page_outgoing = create_page_outgoing (self);
1172 /* Add the notebook pages: */
1173 gtk_notebook_append_page (self->notebook, self->page_account_details,
1174 gtk_label_new (_("mcen_ti_account_settings_account")));
1175 gtk_notebook_append_page (self->notebook, self->page_user_details,
1176 gtk_label_new (_("mcen_ti_account_settings_userinfo")));
1177 gtk_notebook_append_page (self->notebook, self->page_incoming,
1178 gtk_label_new (_("mcen_ti_advsetup_retrieval")));
1179 gtk_notebook_append_page (self->notebook, self->page_outgoing,
1180 gtk_label_new (_("mcen_ti_advsetup_sending")));
1182 GtkDialog *dialog = GTK_DIALOG (self);
1183 gtk_container_add (GTK_CONTAINER (dialog->vbox), GTK_WIDGET (self->notebook));
1184 gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), MODEST_MARGIN_HALF);
1185 gtk_widget_show (GTK_WIDGET (self->notebook));
1187 /* Add the buttons: */
1188 gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK);
1189 gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL);
1191 /* Connect to the dialog's response signal: */
1192 /* We use connect-before
1193 * so we can stop the signal emission,
1194 * to stop the default signal handler from closing the dialog.
1196 g_signal_connect (G_OBJECT (self), "response",
1197 G_CALLBACK (on_response), self);
1199 self->modified = FALSE;
1201 /* When this window is shown, hibernation should not be possible,
1202 * because there is no sensible way to save the state: */
1203 modest_window_mgr_prevent_hibernation_while_window_is_shown (
1204 modest_runtime_get_window_mgr (), GTK_WINDOW (self));
1207 ModestAccountSettingsDialog*
1208 modest_account_settings_dialog_new (void)
1210 return g_object_new (MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG, NULL);
1213 /** Update the UI with the stored account details, so they can be edited.
1214 * @account_name: Name of the account, which should contain incoming and outgoing server accounts.
1216 void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialog *dialog, const gchar* account_name)
1221 /* Save the account name so we can refer to it later: */
1222 if (dialog->account_name)
1223 g_free (dialog->account_name);
1224 dialog->account_name = g_strdup (account_name);
1227 /* Get the account data for this account name: */
1228 ModestAccountData *account_data = modest_account_mgr_get_account_data (dialog->account_manager,
1230 if (!account_data) {
1231 g_printerr ("modest: failed to get account data for %s\n", account_name);
1235 /* Save the account title so we can refer to it if the user changes it: */
1236 if (dialog->original_account_title)
1237 g_free (dialog->original_account_title);
1238 dialog->original_account_title = g_strdup (account_data->display_name);
1241 if (!(account_data->store_account)) {
1242 g_printerr ("modest: account has no stores: %s\n", account_name);
1246 /* Show the account data in the widgets: */
1248 /* Note that we never show the non-display name in the UI.
1249 * (Though the display name defaults to the non-display name at the start.) */
1250 gtk_entry_set_text( GTK_ENTRY (dialog->entry_account_title),
1251 account_data->display_name ? account_data->display_name : "");
1253 gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_name),
1254 account_data->fullname ? account_data->fullname : "");
1255 gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_email),
1256 account_data->email ? account_data->email : "");
1258 ModestServerAccountData *incoming_account = account_data->store_account;
1260 if (incoming_account)
1261 modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), incoming_account->proto);
1262 gchar *retrieve = modest_account_mgr_get_string (dialog->account_manager, account_name,
1263 MODEST_ACCOUNT_RETRIEVE, FALSE /* not server account */);
1265 /* Default to something, though no default is specified in the UI spec: */
1266 retrieve = g_strdup (MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY);
1268 modest_retrieve_combo_box_set_active_retrieve_conf (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), retrieve);
1271 const gint limit_retrieve = modest_account_mgr_get_int (dialog->account_manager, account_name,
1272 MODEST_ACCOUNT_LIMIT_RETRIEVE, FALSE /* not server account */);
1273 modest_limit_retrieve_combo_box_set_active_limit_retrieve (MODEST_LIMIT_RETRIEVE_COMBO_BOX (dialog->combo_limit_retrieve), limit_retrieve);
1276 const gboolean leave_on_server = modest_account_mgr_get_bool (dialog->account_manager, account_name,
1277 MODEST_ACCOUNT_LEAVE_ON_SERVER, FALSE /* not server account */);
1278 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages), leave_on_server);
1280 /* Only show the leave-on-server checkbox for POP,
1281 * as per the UI spec: */
1282 if (incoming_account->proto != MODEST_PROTOCOL_STORE_POP) {
1283 gtk_widget_hide (dialog->caption_leave_messages);
1285 gtk_widget_show (dialog->caption_leave_messages);
1288 update_incoming_server_security_choices (dialog, incoming_account->proto);
1289 if (incoming_account) {
1290 /* Remember this for later: */
1291 dialog->incoming_protocol = incoming_account->proto;
1293 gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_username),
1294 incoming_account->username ? incoming_account->username : "");
1295 gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_password),
1296 incoming_account->password ? incoming_account->password : "");
1298 gtk_entry_set_text( GTK_ENTRY (dialog->entry_incomingserver),
1299 incoming_account->hostname ? incoming_account->hostname : "");
1301 /* The UI spec says:
1302 * If secure authentication is unchecked, allow sending username and password also as plain text.
1303 * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc.
1304 * TODO: Do we need to discover which of these (SSL, TLS, CRAM-MD5) is supported?
1306 const ModestConnectionProtocol security = modest_server_account_get_security (
1307 dialog->account_manager, incoming_account->account_name);
1308 modest_serversecurity_combo_box_set_active_serversecurity (
1309 MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security), security);
1314 - use encrypted passwords
1316 const ModestAuthProtocol secure_auth = modest_server_account_get_secure_auth(
1317 dialog->account_manager, incoming_account->account_name);
1318 dialog->protocol_authentication_incoming = secure_auth;
1319 if (modest_protocol_info_is_secure(security) ||
1320 modest_protocol_info_auth_is_secure(secure_auth))
1322 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth),
1327 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth),
1331 update_incoming_server_title (dialog, incoming_account->proto);
1333 const gint port_num = modest_account_mgr_get_int (dialog->account_manager, incoming_account->account_name,
1334 MODEST_ACCOUNT_PORT, TRUE /* server account */);
1336 if (port_num == 0) {
1337 /* Show the appropriate port number: */
1338 on_combo_incoming_security_changed (
1339 GTK_COMBO_BOX (dialog->combo_incoming_security), dialog);
1341 /* Keep the user-entered port-number,
1342 * or the already-appropriate automatic port number: */
1343 hildon_number_editor_set_value (
1344 HILDON_NUMBER_EDITOR (dialog->entry_incoming_port), port_num);
1348 ModestServerAccountData *outgoing_account = account_data->transport_account;
1349 if (outgoing_account) {
1350 /* Remember this for later: */
1351 dialog->outgoing_protocol = outgoing_account->proto;
1353 gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoingserver),
1354 outgoing_account->hostname ? outgoing_account->hostname : "");
1356 gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoing_username),
1357 outgoing_account->username ? outgoing_account->username : "");
1358 gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoing_password),
1359 outgoing_account->password ? outgoing_account->password : "");
1361 /* Get the secure-auth setting: */
1362 const ModestAuthProtocol secure_auth = modest_server_account_get_secure_auth(
1363 dialog->account_manager, outgoing_account->account_name);
1364 modest_secureauth_combo_box_set_active_secureauth (
1365 MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth), secure_auth);
1366 on_combo_outgoing_auth_changed (GTK_COMBO_BOX (dialog->combo_outgoing_auth), dialog);
1368 modest_serversecurity_combo_box_fill (
1369 MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), outgoing_account->proto);
1371 /* Get the security setting: */
1372 const ModestConnectionProtocol security = modest_server_account_get_security (
1373 dialog->account_manager, outgoing_account->account_name);
1374 modest_serversecurity_combo_box_set_active_serversecurity (
1375 MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), security);
1377 const gint port_num = modest_account_mgr_get_int (dialog->account_manager, outgoing_account->account_name,
1378 MODEST_ACCOUNT_PORT, TRUE /* server account */);
1379 if (port_num == 0) {
1380 /* Show the appropriate port number: */
1381 on_combo_outgoing_security_changed (
1382 GTK_COMBO_BOX (dialog->combo_outgoing_security), dialog);
1385 /* Keep the user-entered port-number,
1386 * or the already-appropriate automatic port number: */
1387 hildon_number_editor_set_value (
1388 HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port), port_num);
1391 const gboolean has_specific =
1392 modest_account_mgr_get_use_connection_specific_smtp (
1393 dialog->account_manager, account_name);
1394 gtk_toggle_button_set_active (
1395 GTK_TOGGLE_BUTTON (dialog->checkbox_outgoing_smtp_specific),
1399 /* Set window title according to account: */
1400 /* TODO: Is this the correct way to find a human-readable name for
1401 * the protocol used? */
1402 const gchar* proto_str = modest_protocol_info_get_transport_store_protocol_name (dialog->incoming_protocol);
1403 gchar *proto_name = g_utf8_strup(proto_str, -1);
1404 gchar *account_title = modest_account_mgr_get_display_name(dialog->account_manager, account_name);
1406 gchar *title = g_strdup_printf(_("mcen_ti_account_settings"), proto_name, account_title);
1407 g_free (proto_name);
1408 g_free (account_title);
1410 gtk_window_set_title (GTK_WINDOW (dialog), title);
1413 /* account_data->is_enabled, */
1414 /*account_data->is_default, */
1416 /* account_data->store_account->proto */
1418 modest_account_mgr_free_account_data (dialog->account_manager, account_data);
1420 /* Unset the modified flag so we can detect changes later: */
1421 dialog->modified = FALSE;
1424 /** Show the User Info tab.
1426 void modest_account_settings_dialog_switch_to_user_info (ModestAccountSettingsDialog *dialog)
1428 const gint page_num = gtk_notebook_page_num (dialog->notebook, dialog->page_user_details);
1429 if (page_num == -1) {
1430 g_warning ("%s: notebook page not found.\n", __FUNCTION__);
1433 /* Ensure that the widget is visible so that gtk_notebook_set_current_page() works: */
1434 /* TODO: even this hack (recommened by the GTK+ documentation) doesn't seem to work. */
1436 gtk_widget_show (dialog->page_user_details);
1437 gtk_widget_show (GTK_WIDGET (dialog->notebook));
1438 gtk_widget_show (GTK_WIDGET (dialog));
1439 gtk_notebook_set_current_page (dialog->notebook, page_num);
1443 save_configuration (ModestAccountSettingsDialog *dialog)
1445 g_assert (dialog->account_name);
1447 const gchar* account_name = dialog->account_name;
1449 /* Set the account data from the widgets: */
1450 const gchar* user_name = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_name));
1451 gboolean test = modest_account_mgr_set_string (dialog->account_manager, account_name,
1452 MODEST_ACCOUNT_FULLNAME, user_name, FALSE /* not server account */);
1456 const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_email));
1457 test = modest_account_mgr_set_string (dialog->account_manager, account_name,
1458 MODEST_ACCOUNT_EMAIL, emailaddress, FALSE /* not server account */);
1463 if (dialog->signature_dialog) {
1464 gboolean use_signature = FALSE;
1465 gchar *signature = modest_signature_editor_dialog_get_settings (
1466 MODEST_SIGNATURE_EDITOR_DIALOG (dialog->signature_dialog),
1469 modest_account_mgr_set_signature(dialog->account_manager, account_name,
1470 signature, use_signature);
1474 gchar *retrieve = modest_retrieve_combo_box_get_active_retrieve_conf (
1475 MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve));
1476 modest_account_mgr_set_string (dialog->account_manager, account_name,
1477 MODEST_ACCOUNT_RETRIEVE, retrieve, FALSE /* not server account */);
1480 const gint limit_retrieve = modest_limit_retrieve_combo_box_get_active_limit_retrieve (
1481 MODEST_LIMIT_RETRIEVE_COMBO_BOX (dialog->combo_limit_retrieve));
1482 modest_account_mgr_set_int (dialog->account_manager, account_name,
1483 MODEST_ACCOUNT_LIMIT_RETRIEVE, limit_retrieve, FALSE /* not server account */);
1485 const gboolean leave_on_server = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages));
1486 test = modest_account_mgr_set_bool (dialog->account_manager, account_name,
1487 MODEST_ACCOUNT_LEAVE_ON_SERVER, leave_on_server, FALSE /* not server account */);
1492 gchar* incoming_account_name = modest_account_mgr_get_string (dialog->account_manager, account_name,
1493 MODEST_ACCOUNT_STORE_ACCOUNT, FALSE /* not server account */);
1494 g_assert (incoming_account_name);
1496 const gchar* hostname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_incomingserver));
1497 test = modest_account_mgr_set_string (dialog->account_manager, incoming_account_name,
1498 MODEST_ACCOUNT_HOSTNAME, hostname, TRUE /* server account */);
1502 const gchar* username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_username));
1503 modest_server_account_set_username (dialog->account_manager, incoming_account_name, username);
1505 const gchar* password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_password));
1506 modest_server_account_set_password (dialog->account_manager, incoming_account_name, password);
1509 gint port_num = hildon_number_editor_get_value (
1510 HILDON_NUMBER_EDITOR (dialog->entry_incoming_port));
1511 modest_account_mgr_set_int (dialog->account_manager, incoming_account_name,
1512 MODEST_ACCOUNT_PORT, port_num, TRUE /* server account */);
1514 /* The UI spec says:
1515 * If secure authentication is unchecked, allow sending username and password also as plain text.
1516 * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc.
1519 const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
1520 MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security));
1521 modest_server_account_set_security (dialog->account_manager, incoming_account_name, protocol_security_incoming);
1523 modest_server_account_set_secure_auth (dialog->account_manager, incoming_account_name, dialog->protocol_authentication_incoming);
1526 g_free (incoming_account_name);
1529 gchar* outgoing_account_name = modest_account_mgr_get_string (dialog->account_manager, account_name,
1530 MODEST_ACCOUNT_TRANSPORT_ACCOUNT, FALSE /* not server account */);
1531 g_assert (outgoing_account_name);
1533 hostname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoingserver));
1534 test = modest_account_mgr_set_string (dialog->account_manager, outgoing_account_name,
1535 MODEST_ACCOUNT_HOSTNAME, hostname, TRUE /* server account */);
1539 username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_username));
1540 modest_server_account_set_username (dialog->account_manager, outgoing_account_name,
1543 password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_password));
1544 modest_server_account_set_password (dialog->account_manager, outgoing_account_name,
1547 const ModestConnectionProtocol protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
1548 MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security));
1549 modest_server_account_set_security (dialog->account_manager, outgoing_account_name, protocol_security_outgoing);
1551 const ModestAuthProtocol protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth (
1552 MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth));
1553 modest_server_account_set_secure_auth (dialog->account_manager, outgoing_account_name, protocol_authentication_outgoing);
1556 port_num = hildon_number_editor_get_value (
1557 HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port));
1558 modest_account_mgr_set_int (dialog->account_manager, outgoing_account_name,
1559 MODEST_ACCOUNT_PORT, port_num, TRUE /* server account */);
1561 g_free (outgoing_account_name);
1564 /* Set the changed account title last, to simplify the previous code: */
1565 gchar* account_title = get_entered_account_title (dialog);
1567 return FALSE; /* Should be prevented already anyway. */
1569 if (strcmp(account_title, account_name) != 0) {
1570 /* Change the title: */
1571 const gboolean test = modest_account_mgr_set_string (dialog->account_manager, account_name,
1572 MODEST_ACCOUNT_DISPLAY_NAME, account_title, FALSE /* not server account */);
1574 g_free (account_title);
1579 g_free (account_title);
1580 account_title = NULL;
1582 /* Save connection-specific SMTP server accounts: */
1583 modest_account_mgr_set_use_connection_specific_smtp(dialog->account_manager, account_name,
1584 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbox_outgoing_smtp_specific)));
1585 if (dialog->specific_window) {
1586 return modest_connection_specific_smtp_window_save_server_accounts (
1587 MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog->specific_window));
1593 static gboolean entry_is_empty (GtkWidget *entry)
1598 const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
1599 if ((!text) || (strlen(text) == 0))
1602 /* Strip it of whitespace at the start and end: */
1603 gchar *stripped = g_strdup (text);
1604 stripped = g_strstrip (stripped);
1609 const gboolean result = (strlen (stripped) == 0);
1617 enable_buttons (ModestAccountSettingsDialog *self)
1619 gboolean enable_ok = TRUE;
1621 /* The account details title is mandatory: */
1622 if (entry_is_empty(self->entry_account_title))
1625 /* The user details username is mandatory: */
1626 if (entry_is_empty(self->entry_user_username))
1629 /* The user details email address is mandatory: */
1630 if (enable_ok && entry_is_empty (self->entry_user_email))
1633 /* The custom incoming server is mandatory: */
1634 if (entry_is_empty(self->entry_incomingserver))
1637 /* Enable the buttons,
1638 * identifying them via their associated response codes:
1640 GtkDialog *dialog_base = GTK_DIALOG (self);
1641 gtk_dialog_set_response_sensitive (dialog_base,
1647 modest_account_settings_dialog_class_init (ModestAccountSettingsDialogClass *klass)
1649 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1650 g_type_class_add_private (klass, sizeof (ModestAccountSettingsDialogPrivate));
1653 object_class->get_property = modest_account_settings_dialog_get_property;
1654 object_class->set_property = modest_account_settings_dialog_set_property;
1655 object_class->dispose = modest_account_settings_dialog_dispose;
1656 object_class->finalize = modest_account_settings_dialog_finalize;
1660 show_error (GtkWidget *parent_widget, const gchar* text)
1662 hildon_banner_show_information(parent_widget, NULL, text);
1665 GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_widget, text);
1667 GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
1674 gtk_dialog_run (dialog);
1675 gtk_widget_destroy (GTK_WIDGET (dialog));