From 468a01fdf057e6cff05e9f99733c1281b9001dca Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Tue, 30 Oct 2007 11:10:49 +0000 Subject: [PATCH] * src/modest-account-mgr-helpers.c: * On removing a smtp connection account, we shouldn't spoil the list of accounts. * src/maemo/modest-connection-specific-smtp-window.c: * Now we can remove accounts simply removing the hostname of the server (fixes NB#65559). * src/maemo/modest-connection-specific-smtp-edit-window.c: * Now we accept empty hostnames as valid, so that we can remove accounts. pmo-trunk-r3600 --- .../modest-connection-specific-smtp-edit-window.c | 19 ++++++++--- src/maemo/modest-connection-specific-smtp-window.c | 33 +++++++++++++++----- src/modest-account-mgr-helpers.c | 5 +-- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/maemo/modest-connection-specific-smtp-edit-window.c b/src/maemo/modest-connection-specific-smtp-edit-window.c index 520a27e..2faf2ac 100644 --- a/src/maemo/modest-connection-specific-smtp-edit-window.c +++ b/src/maemo/modest-connection-specific-smtp-edit-window.c @@ -174,7 +174,8 @@ on_response (GtkDialog *dialog, int response_id, gpointer user_data) /* Don't close the dialog if a range error occured */ if(response_id == GTK_RESPONSE_OK) { - if (!modest_text_utils_validate_domain_name (hostname)) { + if (hostname && (hostname[0] != '\0') && + (!modest_text_utils_validate_domain_name (hostname))) { g_signal_stop_emission_by_name (dialog, "response"); hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_servername")); gtk_widget_grab_focus (priv->entry_outgoingserver); @@ -384,12 +385,22 @@ modest_connection_specific_smtp_edit_window_get_settings ( ModestConnectionSpecificSmtpEditWindow *window, ModestAccountMgr *account_manager) { - ModestConnectionSpecificSmtpEditWindowPrivate *priv = - CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window); + ModestConnectionSpecificSmtpEditWindowPrivate *priv = NULL; + ModestServerAccountData *result = NULL; + const gchar *outgoing_server = NULL; + + priv = CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window); + outgoing_server = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver)); + + /* If the outgoing server is NULL, we are removing the connection specific + * settings */ + if ((outgoing_server == NULL) || (outgoing_server[0] == '\0')) { + return NULL; + } /* Use g_slice_new0(), because that's what modest_account_mgr_free_server_account_data() * expects us to use. */ - ModestServerAccountData *result = g_slice_new0 (ModestServerAccountData); + result = g_slice_new0 (ModestServerAccountData); result->hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver))); result->username = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username))); diff --git a/src/maemo/modest-connection-specific-smtp-window.c b/src/maemo/modest-connection-specific-smtp-window.c index e8c76a5..2276fa4 100644 --- a/src/maemo/modest-connection-specific-smtp-window.c +++ b/src/maemo/modest-connection-specific-smtp-window.c @@ -282,11 +282,18 @@ on_button_edit (GtkButton *button, gpointer user_data) MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window), priv->account_manager); - const gchar* server_name = data ? data->hostname : NULL; - gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, - MODEL_COL_SERVER_ACCOUNT_DATA, data, - MODEL_COL_SERVER_NAME, server_name, - -1); + if (data) { + gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, + MODEL_COL_SERVER_ACCOUNT_DATA, data, + MODEL_COL_SERVER_NAME, data->hostname, + -1); + } else { + gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, + MODEL_COL_SERVER_ACCOUNT_DATA, NULL, + MODEL_COL_SERVER_NAME, NULL, + MODEL_COL_SERVER_ACCOUNT_NAME, NULL, + -1); + } } else { @@ -314,6 +321,7 @@ on_button_edit (GtkButton *button, gpointer user_data) g_free (connection_name); g_free (id); g_free (server_account_name); + update_model_server_names (self); } static void @@ -482,7 +490,7 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe /* Walk through the list, reading each row */ while (valid) { - gchar *id = NULL; + gchar *id = NULL; gchar *connection_name = NULL; gchar *server_account_name = NULL; ModestServerAccountData *data = NULL; @@ -539,6 +547,11 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe modest_account_mgr_set_server_account_port (priv->account_manager, server_account_name, data->port); } + } else if (connection_name) { + modest_account_mgr_remove_connection_specific_smtp (priv->account_manager, + connection_name); + gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, + MODEL_COL_SERVER_ACCOUNT_NAME, NULL, -1); } g_free (connection_name); @@ -566,11 +579,13 @@ void update_model_server_names (ModestConnectionSpecificSmtpWindow *self) while (valid) { gchar *server_account_name = NULL; + ModestServerAccountData *data = NULL; gtk_tree_model_get (priv->model, &iter, MODEL_COL_SERVER_ACCOUNT_NAME, &server_account_name, + MODEL_COL_SERVER_ACCOUNT_DATA, &data, -1); - if (server_account_name) { + /* Get the server hostname and show it in the treemodel: */ gchar *hostname = modest_account_mgr_get_server_account_hostname (priv->account_manager, server_account_name); @@ -578,6 +593,10 @@ void update_model_server_names (ModestConnectionSpecificSmtpWindow *self) MODEL_COL_SERVER_NAME, hostname, -1); g_free (hostname); + } else if (data && data->hostname && (data->hostname[0] != '\0')) { + gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, + MODEL_COL_SERVER_NAME, data->hostname, + -1); } else { gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, MODEL_COL_SERVER_NAME, _("mcen_ia_optionalsmtp_notdefined"), diff --git a/src/modest-account-mgr-helpers.c b/src/modest-account-mgr-helpers.c index 6cc1282..3891d64 100644 --- a/src/modest-account-mgr-helpers.c +++ b/src/modest-account-mgr-helpers.c @@ -159,9 +159,10 @@ gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *s /* The server account is in the item after the connection name: */ GSList *list_connection = g_slist_find_custom (list, connection_name, (GCompareFunc)strcmp); if (list_connection) { + GSList *account_node = g_slist_next (list_connection); /* remove both items: */ - GSList *temp = g_slist_delete_link(list_connection, list_connection); - temp = g_slist_delete_link(temp, g_slist_next(temp)); + list = g_slist_delete_link(list, list_connection); + list = g_slist_delete_link(list, account_node); } /* Reset the changed list: */ -- 1.7.9.5