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.
30 #include "modest-connection-specific-smtp-edit-window.h"
31 #include "widgets/modest-ui-constants.h"
32 #include "modest-hildon-includes.h"
33 #include "modest-runtime.h"
35 #include "modest-serversecurity-picker.h"
36 #include "modest-secureauth-picker.h"
37 #include "widgets/modest-validating-entry.h"
38 #include <hildon/hildon-pannable-area.h>
39 #include <hildon/hildon-entry.h>
40 #include <modest-ui-constants.h>
41 #include <gtk/gtkbutton.h>
42 #include <gtk/gtkhbox.h>
43 #include <gtk/gtkvbox.h>
44 #include <gtk/gtkstock.h>
45 #include "modest-text-utils.h"
46 #include "modest-maemo-utils.h"
48 #include <glib/gi18n.h>
50 #define PORT_RANGE_MIN 1
51 #define PORT_RANGE_MAX 65535
53 G_DEFINE_TYPE (ModestConnectionSpecificSmtpEditWindow, modest_connection_specific_smtp_edit_window, GTK_TYPE_DIALOG);
55 #define CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE(o) \
56 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, ModestConnectionSpecificSmtpEditWindowPrivate))
58 static void on_response (GtkDialog *dialog,
62 typedef struct _ModestConnectionSpecificSmtpEditWindowPrivate ModestConnectionSpecificSmtpEditWindowPrivate;
64 struct _ModestConnectionSpecificSmtpEditWindowPrivate
66 GtkWidget *entry_outgoingserver;
67 GtkWidget *outgoing_auth_picker;
68 GtkWidget *entry_user_username;
69 GtkWidget *entry_user_password;
70 GtkWidget *outgoing_security_picker;
71 GtkWidget *entry_port;
74 GtkWidget *button_cancel;
79 gboolean range_error_occured;
83 modest_connection_specific_smtp_edit_window_get_property (GObject *object, guint property_id,
84 GValue *value, GParamSpec *pspec)
86 switch (property_id) {
88 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
93 modest_connection_specific_smtp_edit_window_set_property (GObject *object, guint property_id,
94 const GValue *value, GParamSpec *pspec)
96 switch (property_id) {
98 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
103 modest_connection_specific_smtp_edit_window_dispose (GObject *object)
107 if (G_OBJECT_CLASS (modest_connection_specific_smtp_edit_window_parent_class)->dispose)
108 G_OBJECT_CLASS (modest_connection_specific_smtp_edit_window_parent_class)->dispose (object);
112 modest_connection_specific_smtp_edit_window_finalize (GObject *object)
114 ModestConnectionSpecificSmtpEditWindow *self = (ModestConnectionSpecificSmtpEditWindow *) object;
115 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
116 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
118 if (priv->account_name) {
119 g_free (priv->account_name);
120 priv->account_name = NULL;
122 G_OBJECT_CLASS (modest_connection_specific_smtp_edit_window_parent_class)->finalize (object);
126 modest_connection_specific_smtp_edit_window_class_init (ModestConnectionSpecificSmtpEditWindowClass *klass)
128 GObjectClass *object_class = G_OBJECT_CLASS (klass);
130 g_type_class_add_private (klass, sizeof (ModestConnectionSpecificSmtpEditWindowPrivate));
132 object_class->get_property = modest_connection_specific_smtp_edit_window_get_property;
133 object_class->set_property = modest_connection_specific_smtp_edit_window_set_property;
134 object_class->dispose = modest_connection_specific_smtp_edit_window_dispose;
135 object_class->finalize = modest_connection_specific_smtp_edit_window_finalize;
140 MODEL_COL_SERVER_NAME = 1,
145 on_change(GtkWidget* widget, ModestConnectionSpecificSmtpEditWindow *self)
147 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
148 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
149 priv->is_dirty = TRUE;
153 on_outgoing_server_changed (GtkWidget* widget, ModestConnectionSpecificSmtpEditWindow *self)
156 gboolean sensitive = FALSE;
158 on_change (widget, self);
159 text = hildon_entry_get_text (HILDON_ENTRY (widget));
160 if (text && (strlen(text) > 0))
163 gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, sensitive);
168 on_value_changed(GtkWidget* widget, GValue* value, ModestConnectionSpecificSmtpEditWindow *self)
170 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
171 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
173 priv->range_error_occured = FALSE;
174 on_change(widget, self);
178 on_range_error (GtkWidget *widget, ModestNumberEditorErrorType type, gpointer user_data)
181 ModestConnectionSpecificSmtpEditWindow *self = user_data;
182 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
183 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
185 /* We want to prevent the closure of the dialog when a range error occured. The problem is that
186 * the hildon number editor already resets the value to the default value, so we have to
187 * remember that such an error occured. */
188 priv->range_error_occured = TRUE;
190 if (type == MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED) {
191 msg = g_strdup_printf (dgettext ("hildon-libs", "ckct_ib_maximum_value"), 65535);
192 } else if (type == MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED) {
193 msg = g_strdup_printf (dgettext ("hildon-libs", "ckct_ib_minimum_value"), 1);
195 msg = g_strdup_printf (_HL("ckct_ib_set_a_value_within_range"), PORT_RANGE_MIN, PORT_RANGE_MAX);
197 modest_platform_information_banner (widget, NULL, msg);
200 /* Show error message by not returning TRUE */
205 on_delete_event (GtkWidget *widget,
209 ModestConnectionSpecificSmtpEditWindow *self = user_data;
210 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
211 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
213 /* If it's dirty, them the response method already asked the
214 user, because it's always executed before (see GtkDialog
215 code). If it's not then simply close */
216 return priv->is_dirty;
220 on_response (GtkDialog *dialog, int response_id, gpointer user_data)
222 const gchar *hostname;
223 ModestConnectionSpecificSmtpEditWindow *self = user_data;
224 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
225 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
227 hostname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver));
229 /* Don't close the dialog if a range error occured */
230 if(response_id == GTK_RESPONSE_OK && priv->range_error_occured)
232 priv->range_error_occured = FALSE;
233 g_signal_stop_emission_by_name (dialog, "response");
234 gtk_widget_grab_focus (priv->entry_port);
238 /* Don't close the dialog if a range error occured */
239 if (response_id == GTK_RESPONSE_OK) {
240 if (hostname && (hostname[0] != '\0') &&
241 (!modest_text_utils_validate_domain_name (hostname))) {
242 g_signal_stop_emission_by_name (dialog, "response");
243 hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_servername"));
244 gtk_widget_grab_focus (priv->entry_outgoingserver);
245 gtk_editable_select_region (GTK_EDITABLE (priv->entry_outgoingserver), 0, -1);
249 /* Ask user if they want to discard changes */
250 if (priv->is_dirty) {
252 response = modest_platform_run_confirmation_dialog (GTK_WINDOW (user_data),
253 _("imum_nc_wizard_confirm_lose_changes"));
255 if (response != GTK_RESPONSE_OK)
256 g_signal_stop_emission_by_name (dialog, "response");
262 on_set_focus_child (GtkContainer *container, GtkWidget *widget, gpointer user_data)
264 ModestConnectionSpecificSmtpEditWindow *self = user_data;
265 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
266 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
268 /* Another child gained focus. Since the number editor already reset a
269 * possible range error to the default value, we allow closure of the
271 priv->range_error_occured = FALSE;
275 security_picker_set_port (ModestConnectionSpecificSmtpEditWindowPrivate *priv)
277 const gint port_number =
278 modest_serversecurity_picker_get_active_serversecurity_port (
279 MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker));
281 if(port_number != 0) {
282 modest_number_editor_set_value (
283 MODEST_NUMBER_EDITOR (priv->entry_port), port_number);
288 on_security_picker_changed (HildonPickerButton *widget, gpointer user_data)
290 ModestConnectionSpecificSmtpEditWindow *self =
291 MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (user_data);
292 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
293 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
295 on_change(GTK_WIDGET(widget), self);
297 /* Enable/disable username and password fields */
298 security_picker_set_port (priv);
302 auth_picker_set_sensitive (ModestConnectionSpecificSmtpEditWindowPrivate *priv)
304 ModestProtocolType auth_proto;
307 modest_secureauth_picker_get_active_secureauth (MODEST_SECUREAUTH_PICKER (priv->outgoing_auth_picker));
309 if (auth_proto == modest_protocol_registry_get_none_auth_type_id ()) {
310 gtk_widget_set_sensitive (priv->entry_user_username, FALSE);
311 gtk_widget_set_sensitive (priv->entry_user_password, FALSE);
313 gtk_widget_set_sensitive (priv->entry_user_username, TRUE);
314 gtk_widget_set_sensitive (priv->entry_user_password, TRUE);
320 on_auth_picker_changed (HildonPickerButton *widget, gpointer user_data)
322 ModestConnectionSpecificSmtpEditWindow *self =
323 MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (user_data);
324 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
325 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
327 on_change (GTK_WIDGET(widget), self);
329 /* Enable/disable username and password fields */
330 auth_picker_set_sensitive (priv);
334 modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEditWindow *self)
336 ModestConnectionSpecificSmtpEditWindowPrivate *priv;
337 GtkWidget *dialog_box;
338 GtkWidget *pannable, *vbox;
341 /* The title of this dialog is quite long, so make the window wide enough */
342 gtk_widget_set_size_request (GTK_WIDGET (self), 600, 320);
344 priv = CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
345 dialog_box = GTK_DIALOG(self)->vbox; /* gtk_vbox_new (FALSE, MODEST_MARGIN_HALF); */
346 gtk_box_set_spacing (GTK_BOX (dialog_box), MODEST_MARGIN_NONE);
347 gtk_container_set_border_width (GTK_CONTAINER (dialog_box), MODEST_MARGIN_HALF);
349 vbox = gtk_vbox_new (FALSE, 0);
351 /* Create a size group to be used by all captions.
352 * Note that HildonCaption does not create a default size group if we do not specify one.
353 * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
354 GtkSizeGroup *title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
355 GtkSizeGroup *value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
357 /* The outgoing server widgets: */
358 if (!priv->entry_outgoingserver)
359 priv->entry_outgoingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
360 /* Auto-capitalization is the default, so let's turn it off: */
361 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
362 g_signal_connect(G_OBJECT(priv->entry_outgoingserver), "changed", G_CALLBACK(on_outgoing_server_changed), self);
364 server_label = g_strconcat (_("mcen_li_emailsetup_smtp"), "\n<small>(SMTP)</small>", NULL);
366 GtkWidget *captioned =
367 modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
369 priv->entry_outgoingserver);
370 g_free (server_label);
371 gtk_widget_show (priv->entry_outgoingserver);
372 gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, MODEST_MARGIN_HALF);
373 gtk_widget_show (captioned);
375 /* The secure authentication widgets: */
376 if (!priv->outgoing_auth_picker) {
377 priv->outgoing_auth_picker =
378 GTK_WIDGET (modest_secureauth_picker_new (MODEST_EDITABLE_SIZE,
379 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
381 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
382 _("mcen_li_emailsetup_secure_authentication"),
383 priv->outgoing_auth_picker);
384 gtk_widget_show (priv->outgoing_auth_picker);
385 gtk_box_pack_start (GTK_BOX (vbox), priv->outgoing_auth_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
387 /* The username widgets: */
388 priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
389 /* Auto-capitalization is the default, so let's turn it off: */
390 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username), HILDON_GTK_INPUT_MODE_FULL);
391 captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
392 _("mail_fi_username"), FALSE,
393 priv->entry_user_username);
394 g_signal_connect(G_OBJECT(priv->entry_user_username), "changed", G_CALLBACK(on_change), self);
395 gtk_widget_show (priv->entry_user_username);
396 gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, MODEST_MARGIN_HALF);
397 gtk_widget_show (captioned);
399 /* Prevent the use of some characters in the username,
400 * as required by our UI specification: */
401 modest_validating_entry_set_unallowed_characters_whitespace (
402 MODEST_VALIDATING_ENTRY (priv->entry_user_username));
404 /* Set max length as in the UI spec:
405 * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */
406 gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
408 /* The password widgets: */
409 priv->entry_user_password = hildon_entry_new (MODEST_EDITABLE_SIZE);
410 /* Auto-capitalization is the default, so let's turn it off: */
411 hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password),
412 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
413 gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
414 /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
415 captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
416 _("mail_fi_password"), FALSE, priv->entry_user_password);
417 g_signal_connect(G_OBJECT(priv->entry_user_password), "changed", G_CALLBACK(on_change), self);
418 gtk_widget_show (priv->entry_user_password);
419 gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, MODEST_MARGIN_HALF);
420 gtk_widget_show (captioned);
422 /* The secure connection widgets: */
423 if (!priv->outgoing_security_picker)
424 priv->outgoing_security_picker =
425 GTK_WIDGET (modest_serversecurity_picker_new (MODEST_EDITABLE_SIZE,
426 HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
427 modest_serversecurity_picker_fill (
428 MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker), MODEST_PROTOCOLS_TRANSPORT_SMTP);
429 modest_serversecurity_picker_set_active_serversecurity (
430 MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker), MODEST_PROTOCOLS_CONNECTION_NONE);
431 modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
432 _("mcen_li_emailsetup_secure_connection"),
433 priv->outgoing_security_picker);
434 gtk_widget_show (priv->outgoing_security_picker);
435 gtk_box_pack_start (GTK_BOX (vbox), priv->outgoing_security_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
437 /* The port number widgets: */
438 if (!priv->entry_port)
439 priv->entry_port = GTK_WIDGET (modest_number_editor_new (PORT_RANGE_MIN, PORT_RANGE_MAX));
440 captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
441 _("mcen_fi_emailsetup_port"), FALSE, priv->entry_port);
442 gtk_widget_add_events(GTK_WIDGET(priv->entry_port), GDK_FOCUS_CHANGE_MASK);
443 gtk_widget_show (priv->entry_port);
444 gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, MODEST_MARGIN_HALF);
445 gtk_widget_show (captioned);
447 /* Add the button. Disabled by default */
448 gtk_dialog_add_button (GTK_DIALOG (self), _HL("wdgt_bd_save"), GTK_RESPONSE_OK);
449 gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE);
451 priv->is_dirty = FALSE;
452 priv->range_error_occured = FALSE;
453 g_signal_connect(G_OBJECT(self), "response", G_CALLBACK(on_response), self);
454 g_signal_connect(G_OBJECT(self), "delete-event", G_CALLBACK(on_delete_event), self);
455 g_signal_connect(G_OBJECT(vbox), "set-focus-child", G_CALLBACK(on_set_focus_child), self);
457 priv->account_name = NULL;
459 pannable = hildon_pannable_area_new ();
460 g_object_set (G_OBJECT (pannable), "initial-hint", TRUE, NULL);
461 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), vbox);
462 gtk_box_pack_start (GTK_BOX (dialog_box), pannable, TRUE, TRUE, 0);
464 gtk_widget_show_all (dialog_box);
465 gtk_window_set_default_size (GTK_WINDOW (self), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
467 g_object_unref (title_sizegroup);
468 g_object_unref (value_sizegroup);
470 /* When this window is shown, hibernation should not be possible,
471 * because there is no sensible way to save the state: */
472 modest_window_mgr_prevent_hibernation_while_window_is_shown (
473 modest_runtime_get_window_mgr (), GTK_WINDOW (self));
475 hildon_help_dialog_help_enable (GTK_DIALOG(self),
476 "applications_email_connectionspecificsmtpconf",
477 modest_maemo_utils_get_osso_context());
479 /* Refresh view with current settings */
480 auth_picker_set_sensitive (priv);
481 security_picker_set_port (priv);
483 /* Connect signals to track changes */
484 g_signal_connect (G_OBJECT (priv->outgoing_security_picker),
486 (GCallback) on_security_picker_changed,
488 g_signal_connect (G_OBJECT (priv->outgoing_auth_picker),
490 (GCallback) on_auth_picker_changed,
492 g_signal_connect(G_OBJECT(priv->entry_port),
494 G_CALLBACK(on_range_error),
496 g_signal_connect(G_OBJECT(priv->entry_port),
498 G_CALLBACK(on_value_changed),
503 ModestConnectionSpecificSmtpEditWindow*
504 modest_connection_specific_smtp_edit_window_new (void)
506 return g_object_new (MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, NULL);
510 modest_connection_specific_smtp_edit_window_set_connection (
511 ModestConnectionSpecificSmtpEditWindow *window, const gchar* iap_id, const gchar* iap_name,
512 ModestServerAccountSettings *server_settings)
514 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
515 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
517 /* This causes a warning because of the %s in the translation, but not in the original string: */
518 gchar* title = g_strdup_printf (_("mcen_ti_connection_connection_name"), iap_name);
519 gtk_window_set_title (GTK_WINDOW (window), title);
524 /* Setting known values */
525 if (priv->account_name)
526 g_free (priv->account_name);
527 priv->account_name = g_strdup (modest_server_account_settings_get_account_name (server_settings));
528 hildon_entry_set_text (HILDON_ENTRY (priv->entry_outgoingserver),
529 modest_server_account_settings_get_hostname (server_settings));
530 hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_username),
531 modest_server_account_settings_get_username (server_settings));
532 hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_password),
533 modest_server_account_settings_get_password (server_settings));
535 modest_serversecurity_picker_set_active_serversecurity (
536 MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker),
537 modest_server_account_settings_get_security_protocol (server_settings));
539 modest_secureauth_picker_set_active_secureauth (
540 MODEST_SECUREAUTH_PICKER (priv->outgoing_auth_picker),
541 modest_server_account_settings_get_auth_protocol (server_settings));
544 modest_number_editor_set_value (
545 MODEST_NUMBER_EDITOR (priv->entry_port),
546 modest_server_account_settings_get_port (server_settings));
549 /* This will cause changed signals so we set dirty back to FALSE */
550 priv->is_dirty = FALSE;
554 ModestServerAccountSettings*
555 modest_connection_specific_smtp_edit_window_get_settings (ModestConnectionSpecificSmtpEditWindow *window)
557 ModestConnectionSpecificSmtpEditWindowPrivate *priv = NULL;
558 ModestServerAccountSettings *server_settings = NULL;
559 const gchar *outgoing_server = NULL;
561 priv = CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
562 outgoing_server = hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver));
564 /* If the outgoing server is NULL, we are removing the connection specific
566 if ((outgoing_server == NULL) || (outgoing_server[0] == '\0')) {
570 server_settings = modest_server_account_settings_new ();
572 modest_server_account_settings_set_hostname (server_settings,
573 hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver)));
574 modest_server_account_settings_set_protocol (server_settings,
575 MODEST_PROTOCOLS_TRANSPORT_SMTP);
576 modest_server_account_settings_set_username (server_settings,
577 hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_username)));
578 modest_server_account_settings_set_password (server_settings,
579 hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_password)));
581 modest_server_account_settings_set_security_protocol (server_settings,
582 modest_serversecurity_picker_get_active_serversecurity (
583 MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker)));
584 modest_server_account_settings_set_auth_protocol (server_settings,
585 modest_secureauth_picker_get_active_secureauth (
586 MODEST_SECUREAUTH_PICKER (priv->outgoing_auth_picker)));
587 modest_server_account_settings_set_account_name (server_settings,
591 modest_server_account_settings_set_port (server_settings,
592 modest_number_editor_get_value (MODEST_NUMBER_EDITOR (priv->entry_port)));
594 return server_settings;
598 modest_connection_specific_smtp_edit_window_is_dirty(ModestConnectionSpecificSmtpEditWindow *window)
600 ModestConnectionSpecificSmtpEditWindowPrivate *priv =
601 CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
603 return priv->is_dirty;