diff options
Diffstat (limited to 'mail/session.c')
-rw-r--r-- | mail/session.c | 54 |
1 files changed, 35 insertions, 19 deletions
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; } |