From 2b1d1fdc36a85c3cd3b18cd1d24ef36e35d36504 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 9 Jan 2001 17:21:34 +0000 Subject: New function to set the password for a given url. 2001-01-09 Jeffrey Stedfast * session.c (mail_session_set_password): New function to set the password for a given url. * mail-config-druid.c (druid_finish): Don't save the password in the source url, instead insert it into the save-password hash. (mail_config_druid_get_source_url): Check to make sure the authmech isn't "", if it is then don't set the authmech. * mail-account-editor.c (apply_changes): Don't save the password in the source url, instead insert it into the save-password hash. Also check to make sure we don't set an empty string as the authmech for the source or transport. * mail-accounts.c (mail_default): After reloading the accounts, reselect the previously selected account. (mail_delete): Same. * mail-config-druid.c (druid_cancel): Fixed segfault bug. svn path=/trunk/; revision=7319 --- mail/mail-account-editor.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'mail/mail-account-editor.c') diff --git a/mail/mail-account-editor.c b/mail/mail-account-editor.c index a17fc389ad..89ad447b46 100644 --- a/mail/mail-account-editor.c +++ b/mail/mail-account-editor.c @@ -21,13 +21,12 @@ */ #include "mail-account-editor.h" +#include "mail-session.h" #include #include #include #include -extern CamelSession *session; - static void mail_account_editor_class_init (MailAccountEditorClass *class); static void mail_account_editor_init (MailAccountEditor *editor); static void mail_account_editor_finalise (GtkObject *obj); @@ -108,7 +107,7 @@ static gboolean apply_changes (MailAccountEditor *editor) { MailConfigAccount *account; - char *host, *pport; + char *host, *pport, *auth; CamelURL *url; int port; @@ -144,7 +143,8 @@ apply_changes (MailAccountEditor *editor) url->passwd = g_strdup (gtk_entry_get_text (editor->source_passwd)); g_free (url->authmech); - url->authmech = g_strdup (gtk_object_get_data (GTK_OBJECT (editor), "source_authmech")); + auth = gtk_object_get_data (GTK_OBJECT (editor), "source_authmech"); + url->authmech = auth && *auth ? g_strdup (auth) : NULL; g_free (url->host); host = g_strdup (gtk_entry_get_text (editor->source_host)); @@ -167,16 +167,26 @@ apply_changes (MailAccountEditor *editor) return FALSE; } + if (account->source->save_passwd) { + char *string; + + string = camel_url_to_string (url, FALSE); + mail_session_set_password (string, url->passwd); + mail_session_remember_password (string); + g_free (string); + } + /* now that we know this url works, set it */ g_free (account->source->url); - account->source->url = camel_url_to_string (url, account->source->save_passwd); + account->source->url = camel_url_to_string (url, FALSE); camel_url_free (url); /* transport */ url = camel_url_new (account->transport->url, NULL); g_free (url->authmech); - url->authmech = g_strdup (gtk_object_get_data (GTK_OBJECT (editor), "transport_authmech")); + auth = gtk_object_get_data (GTK_OBJECT (editor), "transport_authmech"); + url->authmech = auth && *auth ? g_strdup (auth) : NULL; g_free (url->host); host = g_strdup (gtk_entry_get_text (editor->transport_host)); -- cgit