diff options
author | Not Zed <NotZed@Ximian.com> | 2004-01-20 13:33:12 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-01-20 13:33:12 +0800 |
commit | c5c43717419bcf6a6a3a5d5958090631dc7a13c9 (patch) | |
tree | 046170f46a9b68134ff08aa99c64c86113f18fde /camel | |
parent | b6e44f08f719efee9c6ed90813d03ddbf42e9121 (diff) | |
download | gsoc2013-evolution-c5c43717419bcf6a6a3a5d5958090631dc7a13c9.tar gsoc2013-evolution-c5c43717419bcf6a6a3a5d5958090631dc7a13c9.tar.gz gsoc2013-evolution-c5c43717419bcf6a6a3a5d5958090631dc7a13c9.tar.bz2 gsoc2013-evolution-c5c43717419bcf6a6a3a5d5958090631dc7a13c9.tar.lz gsoc2013-evolution-c5c43717419bcf6a6a3a5d5958090631dc7a13c9.tar.xz gsoc2013-evolution-c5c43717419bcf6a6a3a5d5958090631dc7a13c9.tar.zst gsoc2013-evolution-c5c43717419bcf6a6a3a5d5958090631dc7a13c9.zip |
** See bug #52817.
2004-01-20 Not Zed <NotZed@Ximian.com>
** See bug #52817.
* camel-session.c (camel_session_get_password): merged reprompt
and secret into a flags field, and add more options. Fixed all
callers.
svn path=/trunk/; revision=24323
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 6 | ||||
-rw-r--r-- | camel/camel-gpg-context.c | 2 | ||||
-rw-r--r-- | camel/camel-sasl-popb4smtp.c | 3 | ||||
-rw-r--r-- | camel/camel-session.c | 26 | ||||
-rw-r--r-- | camel/camel-session.h | 12 | ||||
-rw-r--r-- | camel/camel-smime-context.c | 3 | ||||
-rw-r--r-- | camel/camel-store.c | 3 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 2 | ||||
-rw-r--r-- | camel/providers/imapp/camel-imapp-store.c | 3 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-store.c | 2 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 8 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 2 | ||||
-rw-r--r-- | camel/tests/smime/pgp-mime.c | 4 | ||||
-rw-r--r-- | camel/tests/smime/pgp.c | 4 | ||||
-rw-r--r-- | camel/tests/smime/pkcs7.c | 4 |
15 files changed, 53 insertions, 31 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index fcf9d3c454..e22217db0e 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,11 @@ 2004-01-20 Not Zed <NotZed@Ximian.com> + ** See bug #52817. + + * camel-session.c (camel_session_get_password): merged reprompt + and secret into a flags field, and add more options. Fixed all + callers. + ** See bug #52899. * camel-gpg-context.c (gpg_ctx_parse_status): use need_id as the diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index d142c11c40..b6ff6cd916 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -761,7 +761,7 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) prompt = g_strdup_printf (_("You need a passphrase to unlock the key for\n" "user: \"%s\""), name); - if ((passwd = camel_session_get_password (gpg->session, prompt, FALSE, TRUE, NULL, gpg->need_id, ex)) && !gpg->utf8) { + if ((passwd = camel_session_get_password (gpg->session, prompt, CAMEL_SESSION_PASSWORD_SECRET, NULL, gpg->need_id, ex)) && !gpg->utf8) { char *opasswd = passwd; if ((passwd = g_locale_to_utf8 (passwd, -1, &nread, &nwritten, NULL))) { diff --git a/camel/camel-sasl-popb4smtp.c b/camel/camel-sasl-popb4smtp.c index 329151872e..338a235d60 100644 --- a/camel/camel-sasl-popb4smtp.c +++ b/camel/camel-sasl-popb4smtp.c @@ -100,8 +100,7 @@ popb4smtp_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex) sasl->authenticated = FALSE; - popuri = camel_session_get_password (session, _("POP Source URI"), FALSE, FALSE, - sasl->service, "popb4smtp_uri", ex); + popuri = camel_session_get_password (session, _("POP Source URI"), 0, sasl->service, "popb4smtp_uri", ex); if (popuri == NULL) { camel_exception_setv(ex, 1, _("POP Before SMTP auth using an unknown transport")); diff --git a/camel/camel-session.c b/camel/camel-session.c index ba7de9e14f..b7d86c571a 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -560,9 +560,9 @@ camel_session_get_storage_path (CamelSession *session, CamelService *service, * camel_session_get_password: * @session: session object * @prompt: prompt to provide to user - * @reprompt: TRUE if the prompt should force a reprompt - * @secret: whether or not the data is secret (eg, a password, as opposed - * to a smartcard response) + * @flags: CAMEL_SESSION_PASSWORD_REPROMPT, the prompt should force a reprompt + * CAMEL_SESSION_PASSWORD_SECRET, whether the password is secret + * CAMEL_SESSION_PASSWORD_STATIC, the password is remembered externally * @service: the service this query is being made by * @item: an identifier, unique within this service, for the information * @ex: a CamelException @@ -574,17 +574,23 @@ camel_session_get_storage_path (CamelSession *session, CamelService *service, * caller is concerned with. * * @prompt 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 will 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. + * already have the answer cached). If CAMEL_SESSION_PASSWORD_SECRET + * is set, the user's input will not be echoed back. + * + * If CAMEL_SESSION_PASSWORD_STATIC is set, it means the password returned + * will be stored statically by the caller automatically, for the current + * session. + * + * 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. * * Return value: the authentication information or %NULL. **/ char * camel_session_get_password (CamelSession *session, const char *prompt, - gboolean reprompt, gboolean secret, + guint32 flags, CamelService *service, const char *item, CamelException *ex) { @@ -592,7 +598,7 @@ camel_session_get_password (CamelSession *session, const char *prompt, g_return_val_if_fail (prompt != NULL, NULL); g_return_val_if_fail (item != NULL, NULL); - return CS_CLASS (session)->get_password (session, prompt, reprompt, secret, service, item, ex); + return CS_CLASS (session)->get_password (session, prompt, flags, service, item, ex); } diff --git a/camel/camel-session.h b/camel/camel-session.h index e99d31a334..cd811a6304 100644 --- a/camel/camel-session.h +++ b/camel/camel-session.h @@ -52,6 +52,12 @@ typedef enum { CAMEL_SESSION_ALERT_ERROR } CamelSessionAlertType; +enum { + CAMEL_SESSION_PASSWORD_REPROMPT = 1 << 0, + CAMEL_SESSION_PASSWORD_SECRET = 1 << 2, + CAMEL_SESSION_PASSWORD_STATIC = 1 << 3, +}; + struct _CamelSession { CamelObject parent_object; @@ -91,8 +97,7 @@ typedef struct { char * (*get_password) (CamelSession *session, const char *prompt, - gboolean reprompt, - gboolean secret, + guint32 flags, CamelService *service, const char *item, CamelException *ex); @@ -158,8 +163,7 @@ char * camel_session_get_storage_path (CamelSession *session, char * camel_session_get_password (CamelSession *session, const char *prompt, - gboolean reprompt, - gboolean secret, + guint32 flags, CamelService *service, const char *item, CamelException *ex); diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c index 8b132b6968..c32d6e4d72 100644 --- a/camel/camel-smime-context.c +++ b/camel/camel-smime-context.c @@ -102,7 +102,8 @@ sm_get_passwd(PK11SlotInfo *info, PRBool retry, void *arg) } prompt = g_strdup_printf(_("Enter security pass-phrase for `%s'"), PK11_GetTokenName(info)); - pass = camel_session_get_password(((CamelCipherContext *)context)->session, prompt, FALSE, TRUE, NULL, PK11_GetTokenName(info), ex); + pass = camel_session_get_password(((CamelCipherContext *)context)->session, prompt, + CAMEL_SESSION_PASSWORD_SECRET|CAMEL_SESSION_PASSWORD_STATIC, NULL, PK11_GetTokenName(info), ex); camel_exception_free(ex); g_free(prompt); if (pass) { diff --git a/camel/camel-store.c b/camel/camel-store.c index c076128c38..15256f8fb3 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -259,6 +259,7 @@ camel_store_get_folder (CamelStore *store, const char *folder_name, guint32 flag } CAMEL_STORE_UNLOCK(store, folder_lock); + return folder; } @@ -781,7 +782,7 @@ camel_store_get_folder_info (CamelStore *store, const char *top, g_return_val_if_fail ((store->flags & CAMEL_STORE_SUBSCRIPTIONS) || !(flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED), NULL); - + CAMEL_STORE_LOCK(store, folder_lock); info = CS_CLASS (store)->get_folder_info (store, top, flags, ex); CAMEL_STORE_UNLOCK(store, folder_lock); diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index d8ff6e0ec7..15f4a5c530 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -1287,7 +1287,7 @@ imap_auth_loop (CamelService *service, CamelException *ex) service->url->user, service->url->host); service->url->passwd = - camel_session_get_password (session, prompt, FALSE, TRUE, + camel_session_get_password (session, prompt, CAMEL_SESSION_PASSWORD_SECRET, service, "password", ex); g_free (prompt); g_free (errbuf); diff --git a/camel/providers/imapp/camel-imapp-store.c b/camel/providers/imapp/camel-imapp-store.c index 9123102a03..ad52b8790e 100644 --- a/camel/providers/imapp/camel-imapp-store.c +++ b/camel/providers/imapp/camel-imapp-store.c @@ -351,7 +351,8 @@ store_get_pass(CamelIMAPPStore *store) ((CamelService *)store)->url->user, ((CamelService *)store)->url->host); ((CamelService *)store)->url->passwd = camel_session_get_password(camel_service_get_session((CamelService *)store), - prompt, FALSE, TRUE, (CamelService*)store, "password", &ex); + prompt, CAMEL_SESSION_PASSWORD_SECRET, + (CamelService*)store, "password", &ex); g_free (prompt); if (camel_exception_is_set(&ex)) camel_exception_throw_ex(&ex); diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index fc067062ba..a439c4fd8a 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -1002,7 +1002,7 @@ camel_nntp_try_authenticate (CamelNNTPStore *store) camel_exception_init (&ex); service->url->passwd = - camel_session_get_password (session, prompt, FALSE, TRUE, + camel_session_get_password (session, prompt, CAMEL_SESSION_PASSWORD_SECRET, service, "password", &ex); camel_exception_clear (&ex); g_free (prompt); diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index fbdae86833..02e58dd98c 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -474,13 +474,17 @@ pop3_try_authenticate (CamelService *service, gboolean reprompt, const char *err if (!service->url->passwd) { char *prompt; - + guint32 flags = CAMEL_SESSION_PASSWORD_SECRET; + + if (reprompt) + flags |= CAMEL_SESSION_PASSWORD_REPROMPT; + prompt = g_strdup_printf (_("%sPlease enter the POP password for %s@%s"), errmsg ? errmsg : "", service->url->user, service->url->host); service->url->passwd = camel_session_get_password (camel_service_get_session (service), - prompt, reprompt, TRUE, service, "password", ex); + prompt, flags, service, "password", ex); g_free (prompt); if (!service->url->passwd) return FALSE; diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 5bf5add2ee..be5e1be9c0 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -515,7 +515,7 @@ smtp_connect (CamelService *service, CamelException *ex) errbuf ? errbuf : "", service->url->user, service->url->host); - service->url->passwd = camel_session_get_password (session, prompt, FALSE, TRUE, + service->url->passwd = camel_session_get_password (session, prompt, CAMEL_SESSION_PASSWORD_SECRET, service, "password", ex); g_free (prompt); diff --git a/camel/tests/smime/pgp-mime.c b/camel/tests/smime/pgp-mime.c index 102092679a..2ec805b4a4 100644 --- a/camel/tests/smime/pgp-mime.c +++ b/camel/tests/smime/pgp-mime.c @@ -61,7 +61,7 @@ typedef struct _CamelPgpSessionClass { static char *get_password (CamelSession *session, const char *prompt, - gboolean reprompt, gboolean secret, + guint32 flags, CamelService *service, const char *item, CamelException *ex); @@ -102,7 +102,7 @@ camel_pgp_session_get_type (void) } static char * -get_password (CamelSession *session, const char *prompt, gboolean reprompt, gboolean secret, +get_password (CamelSession *session, const char *prompt, guint32 flags, CamelService *service, const char *item, CamelException *ex) { return g_strdup ("no.secret"); diff --git a/camel/tests/smime/pgp.c b/camel/tests/smime/pgp.c index 81ea6fabdf..098e3de7eb 100644 --- a/camel/tests/smime/pgp.c +++ b/camel/tests/smime/pgp.c @@ -54,7 +54,7 @@ typedef struct _CamelPgpSessionClass { static char *get_password (CamelSession *session, const char *prompt, - gboolean reprompt, gboolean secret, + guint32 flags, CamelService *service, const char *item, CamelException *ex); @@ -95,7 +95,7 @@ camel_pgp_session_get_type (void) } static char * -get_password (CamelSession *session, const char *prompt, gboolean reprompt, gboolean secret, +get_password (CamelSession *session, const char *prompt, guint32 flags, CamelService *service, const char *item, CamelException *ex) { return g_strdup ("no.secret"); diff --git a/camel/tests/smime/pkcs7.c b/camel/tests/smime/pkcs7.c index 2248d8656d..baedd36c8c 100644 --- a/camel/tests/smime/pkcs7.c +++ b/camel/tests/smime/pkcs7.c @@ -27,7 +27,7 @@ typedef struct _CamelTestSessionClass { static char *get_password (CamelSession *session, const char *prompt, - gboolean secret, CamelService *service, + guint32 flags, CamelService *service, const char *item, CamelException *ex); static void @@ -67,7 +67,7 @@ camel_test_session_get_type (void) } static char * -get_password (CamelSession *session, const char *prompt, gboolean secret, +get_password (CamelSession *session, const char *prompt, guint32 flags, CamelService *service, const char *item, CamelException *ex) { return g_strdup ("S/MIME v3 is rfc263x, now go and read them."); |