+
+ g_free (incoming_account_name);
+
+ /* Outgoing: */
+ gchar* outgoing_account_name = modest_account_mgr_get_string (dialog->account_manager, account_name,
+ MODEST_ACCOUNT_TRANSPORT_ACCOUNT, FALSE /* not server account */);
+ g_assert (outgoing_account_name);
+
+ hostname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoingserver));
+ test = modest_account_mgr_set_string (dialog->account_manager, outgoing_account_name,
+ MODEST_ACCOUNT_HOSTNAME, hostname, TRUE /* server account */);
+ if (!test)
+ return FALSE;
+
+ username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_username));
+ modest_server_account_set_username (dialog->account_manager, outgoing_account_name,
+ username);
+
+ password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_password));
+ modest_server_account_set_password (dialog->account_manager, outgoing_account_name,
+ password);
+
+ const ModestConnectionProtocol protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
+ MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security));
+ modest_server_account_set_security (dialog->account_manager, outgoing_account_name, protocol_security_outgoing);
+
+ const ModestAuthProtocol protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth (
+ MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth));
+ modest_server_account_set_secure_auth (dialog->account_manager, outgoing_account_name, protocol_authentication_outgoing);
+
+ /* port: */
+ port_num = hildon_number_editor_get_value (
+ HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port));
+ modest_account_mgr_set_int (dialog->account_manager, outgoing_account_name,
+ MODEST_ACCOUNT_PORT, port_num, TRUE /* server account */);
+
+ g_free (outgoing_account_name);
+
+
+ /* Set the changed account title last, to simplify the previous code: */
+ const gchar* account_title = gtk_entry_get_text (GTK_ENTRY (dialog->entry_account_title));
+ if ((!account_title) || (strlen(account_title) == 0))
+ return FALSE; /* Should be prevented already anyway. */
+
+ if (strcmp(account_title, account_name) != 0) {
+ /* Change the title: */
+ gboolean test = modest_account_mgr_set_string (dialog->account_manager, account_name,
+ MODEST_ACCOUNT_DISPLAY_NAME, account_title, FALSE /* not server account */);
+ if (!test)
+ return FALSE;
+ }
+
+ /* Save connection-specific SMTP server accounts: */
+ if (dialog->specific_window) {
+ return modest_connection_specific_smtp_window_save_server_accounts (
+ MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog->specific_window), account_name);
+ }
+ else
+ return TRUE;