From 8ea1212d992c564a3a7849a41be9000ce50d0f6b Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 21 Feb 2000 19:56:49 +0000 Subject: Add "authenticator" to CamelSession and update things to use it. svn path=/trunk/; revision=1890 --- mail/ChangeLog | 5 +++++ mail/session.c | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 198b2c612d..33f9690fcd 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,8 @@ +2000-02-21 Dan Winship + + * session.c (session_store_new): Pass a CamelAuthCallback + (evolution_auth_callback) to camel_session_new. + 2000-02-21 Dan Winship * session.c (session_store_new): Update session_store_new to diff --git a/mail/session.c b/mail/session.c index e0390c380f..a97b70ed26 100644 --- a/mail/session.c +++ b/mail/session.c @@ -7,12 +7,52 @@ * (C) 2000 Helix Code, Inc. http://www.helixcode.com */ #include +#include #include "session.h" #include "e-util/e-setup.h" #include "camel/camel.h" SessionStore *default_session; +static void +request_callback (gchar *string, gpointer data) +{ + char **ans = data; + + if (string) + *ans = g_strdup(string); + else + *ans = NULL; +} + +static char * +evolution_auth_callback (char *prompt, gboolean secret, + CamelService *service, char *item, + CamelException *ex) +{ + GtkWidget *dialog; + char *ans; + + /* XXX look up stored passwords */ + + /* XXX parent window? */ + dialog = gnome_request_dialog (secret, prompt, NULL, 0, + request_callback, &ans, NULL); + if (!dialog) { + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not create dialog box."); + return NULL; + } + if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == -1 || + ans == NULL) { + camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, + "User cancelled query."); + return NULL; + } + + return ans; +} + static void session_providers_init (void) { @@ -25,7 +65,7 @@ session_store_new (const char *uri) SessionStore *ss = g_new (SessionStore, 1); CamelException *ex; - ss->session = camel_session_new (); + ss->session = camel_session_new (evolution_auth_callback); ex = camel_exception_new (); ss->store = camel_session_get_store (ss->session, uri, ex); camel_exception_free (ex); -- cgit v1.2.3