From aeb515ebe698cc33ab7b539a5b768ef53b01c0d9 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 9 Jun 2000 22:01:50 +0000 Subject: Update for CamelAuthCallback changes. (Uncache passwords when asked to.) * session.c (evolution_auth_callback): Update for CamelAuthCallback changes. (Uncache passwords when asked to.) svn path=/trunk/; revision=3497 --- mail/ChangeLog | 3 +++ mail/session.c | 54 +++++++++++++++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 19 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 23d524cdf3..8b99e3b128 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,8 @@ 2000-06-09 Dan Winship + * session.c (evolution_auth_callback): Update for + CamelAuthCallback changes. (Uncache passwords when asked to.) + * mail-ops.c (fetch_mail): close and expunge the source folder after copying it to a local folder. diff --git a/mail/session.c b/mail/session.c index c9dbb0b1ae..259a087377 100644 --- a/mail/session.c +++ b/mail/session.c @@ -1,5 +1,5 @@ /* - * session.c: handles the session infomration and resource manipulation + * session.c: handles the session information and resource manipulation * * Author: * Miguel de Icaza (miguel@gnu.org) @@ -26,28 +26,48 @@ request_callback (gchar *string, gpointer data) } static char * -evolution_auth_callback (char *prompt, gboolean secret, - CamelService *service, char *item, +evolution_auth_callback (CamelAuthCallbackMode mode, char *data, + gboolean secret, CamelService *service, char *item, CamelException *ex) { GtkWidget *dialog; - char *key = NULL, *ans; + char *key, *ans; - if (service && item) { - key = g_strdup_printf ("%s:%s", camel_url_to_string (service->url, FALSE), item); + if (!passwords) + passwords = g_hash_table_new (g_str_hash, g_str_equal); - if (passwords) { - ans = g_hash_table_lookup (passwords, key); - if (ans) { + key = g_strdup_printf ("%s:%s", + camel_url_to_string (service->url, FALSE), + item); + + if (mode == CAMEL_AUTHENTICATOR_TELL) { + if (!data) { + g_hash_table_remove (passwords, key); + g_free (key); + } else { + gpointer old_key, old_data; + + if (g_hash_table_lookup_extended (passwords, key, + &old_key, + &old_data)) { + g_hash_table_insert (passwords, old_key, data); + g_free (old_data); g_free (key); - return g_strdup (ans); - } - } else - passwords = g_hash_table_new (g_str_hash, g_str_equal); + } else + g_hash_table_insert (passwords, key, data); + } + + return NULL; + } + + ans = g_hash_table_lookup (passwords, key); + if (ans) { + g_free (key); + return g_strdup (ans); } /* XXX parent window? */ - dialog = gnome_request_dialog (secret, prompt, NULL, 0, + dialog = gnome_request_dialog (secret, data, NULL, 0, request_callback, &ans, NULL); if (!dialog) { camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, @@ -63,11 +83,7 @@ evolution_auth_callback (char *prompt, gboolean secret, return NULL; } - if (service && item) - g_hash_table_insert (passwords, key, g_strdup (ans)); - else - g_free (key); - + g_hash_table_insert (passwords, key, g_strdup (ans)); return ans; } -- cgit v1.2.3