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
This commit is contained in:
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user