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
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))) {
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"));
* 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
* 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)
{
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);
}
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;
char * (*get_password) (CamelSession *session,
const char *prompt,
- gboolean reprompt,
- gboolean secret,
+ guint32 flags,
CamelService *service,
const char *item,
CamelException *ex);
char * camel_session_get_password (CamelSession *session,
const char *prompt,
- gboolean reprompt,
- gboolean secret,
+ guint32 flags,
CamelService *service,
const char *item,
CamelException *ex);
}
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) {
}
CAMEL_STORE_UNLOCK(store, folder_lock);
+
return folder;
}
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);
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);
((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);
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);
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;
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);
static char *get_password (CamelSession *session, const char *prompt,
- gboolean reprompt, gboolean secret,
+ guint32 flags,
CamelService *service, const char *item,
CamelException *ex);
}
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");
static char *get_password (CamelSession *session, const char *prompt,
- gboolean reprompt, gboolean secret,
+ guint32 flags,
CamelService *service, const char *item,
CamelException *ex);
}
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");
static char *get_password (CamelSession *session, const char *prompt,
- gboolean secret, CamelService *service,
+ guint32 flags, CamelService *service,
const char *item, CamelException *ex);
static 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.");