diff options
author | Dan Winship <danw@src.gnome.org> | 2000-06-10 06:00:53 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-06-10 06:00:53 +0800 |
commit | 2aefadf282648010e9403e4a7f643fe78dc6df53 (patch) | |
tree | 9bb5f4816da0d70674ae4e27cf0f131f9c94b466 /camel | |
parent | cd84bd758091a39792e13c46804b496ce34fd940 (diff) | |
download | gsoc2013-evolution-2aefadf282648010e9403e4a7f643fe78dc6df53.tar.gz gsoc2013-evolution-2aefadf282648010e9403e4a7f643fe78dc6df53.tar.zst gsoc2013-evolution-2aefadf282648010e9403e4a7f643fe78dc6df53.zip |
Add another argument, "mode", which can be CAMEL_AUTHENTICATOR_ASK or
* camel-session.c (camel_session_query_authenticator): Add another
argument, "mode", which can be CAMEL_AUTHENTICATOR_ASK or
CAMEL_AUTHENTICATOR_TELL, so callers can get the app to un-cache
bad info.
* providers/pop3/camel-pop3-store.c (pop3_connect): uncache the
password if it doesn't work.
svn path=/trunk/; revision=3496
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 10 | ||||
-rw-r--r-- | camel/camel-session.c | 42 | ||||
-rw-r--r-- | camel/camel-session.h | 20 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 26 |
4 files changed, 65 insertions, 33 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index ed689724e2..6ddf78ef27 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,13 @@ +2000-06-09 Dan Winship <danw@helixcode.com> + + * camel-session.c (camel_session_query_authenticator): Add another + argument, "mode", which can be CAMEL_AUTHENTICATOR_ASK or + CAMEL_AUTHENTICATOR_TELL, so callers can get the app to un-cache + bad info. + + * providers/pop3/camel-pop3-store.c (pop3_connect): uncache the + password if it doesn't work. + 2000-06-09 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-stream.c (stream_read): Updated to reflect changes diff --git a/camel/camel-session.c b/camel/camel-session.c index 48424d5a2e..82334c978c 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -250,31 +250,41 @@ camel_session_get_service (CamelSession *session, const char *url_string, /** * camel_session_query_authenticator: query the session authenticator * @session: session object - * @prompt: prompt to use if authenticator can query the user + * @mode: %CAMEL_AUTHENTICATOR_ASK or %CAMEL_AUTHENTICATOR_TELL + * @data: prompt to query user with, or data to cache * @secret: whether or not the data is secret (eg, a password) * @service: the service this query is being made by * @item: an identifier, unique within this service, for the information * @ex: a CamelException * - * This function is used by a CamelService to request authentication - * information it needs to complete a connection. If the authenticator - * stores any authentication information in configuration files, it - * should use @service and @item as keys to find the right piece of - * information. If it doesn't store authentication information in config - * files, it should use the given @prompt to ask the user for the - * information. If @secret is set, the user's input should not be - * echoed back. The authenticator should set @ex to - * CAMEL_EXCEPTION_USER_CANCEL if the user did not provide the - * information. The caller must g_free() the information when it is - * done with it. + * This function is used by a CamelService to discuss authentication + * information with the application. * - * Return value: the authentication information or NULL. + * @service and @item together uniquely identify the piece of data the + * caller is concerned with. + * + * If @mode is %CAMEL_AUTHENTICATOR_ASK, then @data is a question to + * ask the user (if the application doesn't already have the answer + * cached). If @secret is set, the user's input should not be echoed + * back. The authenticator should set @ex to + * %CAMEL_EXCEPTION_USER_CANCEL if the user did not provide the + * information. The caller must g_free() the information returned when + * it is done with it. + * + * If @mode is %CAMEL_AUTHENTICATOR_TELL, then @data is information + * that the application should cache, or %NULL if it should stop + * caching anything about that datum (eg, because the data is a + * password that turned out to be incorrect). + * + * Return value: the authentication information or %NULL. **/ char * -camel_session_query_authenticator (CamelSession *session, char *prompt, - gboolean secret, +camel_session_query_authenticator (CamelSession *session, + CamelAuthCallbackMode mode, + char *prompt, gboolean secret, CamelService *service, char *item, CamelException *ex) { - return session->authenticator (prompt, secret, service, item, ex); + return session->authenticator (mode, prompt, secret, + service, item, ex); } diff --git a/camel/camel-session.h b/camel/camel-session.h index e6a6b2ffc2..c669a4b223 100644 --- a/camel/camel-session.h +++ b/camel/camel-session.h @@ -43,7 +43,12 @@ extern "C" { #define CAMEL_IS_SESSION(o) (GTK_CHECK_TYPE((o), CAMEL_SESSION_TYPE)) -typedef char *(*CamelAuthCallback) (char *prompt, gboolean secret, +typedef enum { + CAMEL_AUTHENTICATOR_ASK, CAMEL_AUTHENTICATOR_TELL +} CamelAuthCallbackMode; + +typedef char *(*CamelAuthCallback) (CamelAuthCallbackMode mode, + char *data, gboolean secret, CamelService *service, char *item, CamelException *ex); @@ -88,12 +93,13 @@ CamelService * camel_session_get_service (CamelSession *session, ((CamelTransport *) camel_session_get_service (session, url_string, CAMEL_PROVIDER_TRANSPORT, ex)) -char * camel_session_query_authenticator (CamelSession *session, - char *prompt, - gboolean secret, - CamelService *service, - char *item, - CamelException *ex); +char * camel_session_query_authenticator (CamelSession *session, + CamelAuthCallbackMode mode, + char *prompt, + gboolean secret, + CamelService *service, + char *item, + CamelException *ex); #ifdef __cplusplus } diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index 9607d6723f..d82ef7b0b4 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -393,11 +393,10 @@ pop3_connect (CamelService *service, CamelException *ex) char *prompt = g_strdup_printf ("Please enter the POP3 password for %s@%s", service->url->user, service->url->host); - service->url->passwd = - camel_session_query_authenticator (camel_service_get_session (service), - prompt, TRUE, - service, "password", - ex); + service->url->passwd = camel_session_query_authenticator ( + camel_service_get_session (service), + CAMEL_AUTHENTICATOR_ASK, prompt, TRUE, + service, "password", ex); g_free (prompt); if (!service->url->passwd) { pop3_disconnect (service, ex); @@ -415,7 +414,7 @@ pop3_connect (CamelService *service, CamelException *ex) "server. Error sending username:" " %s", msg ? msg : "(Unknown)"); g_free (msg); - pop3_disconnect (service, ex); + goto lose; } g_free (msg); @@ -440,8 +439,7 @@ pop3_connect (CamelService *service, CamelException *ex) camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, "No support for requested " "authentication mechanism."); - pop3_disconnect (service, ex); - return FALSE; + goto lose; } if (status != CAMEL_POP3_OK) { @@ -450,13 +448,21 @@ pop3_connect (CamelService *service, CamelException *ex) "server. Error sending password:" " %s", msg ? msg : "(Unknown)"); g_free (msg); - pop3_disconnect (service, ex); - return FALSE; + goto lose; } g_free (msg); service_class->connect (service, ex); return TRUE; + + lose: + /* Uncache the password. */ + camel_session_query_authenticator (camel_service_get_session (service), + CAMEL_AUTHENTICATOR_TELL, NULL, + TRUE, service, "password", ex); + + pop3_disconnect (service, ex); + return FALSE; } static gboolean |