** See bug #52817.
authorNot Zed <NotZed@Ximian.com>
Tue, 20 Jan 2004 05:33:12 +0000 (05:33 +0000)
committerMichael Zucci <zucchi@src.gnome.org>
Tue, 20 Jan 2004 05:33:12 +0000 (05:33 +0000)
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.

15 files changed:
camel/ChangeLog
camel/camel-gpg-context.c
camel/camel-sasl-popb4smtp.c
camel/camel-session.c
camel/camel-session.h
camel/camel-smime-context.c
camel/camel-store.c
camel/providers/imap/camel-imap-store.c
camel/providers/imapp/camel-imapp-store.c
camel/providers/nntp/camel-nntp-store.c
camel/providers/pop3/camel-pop3-store.c
camel/providers/smtp/camel-smtp-transport.c
camel/tests/smime/pgp-mime.c
camel/tests/smime/pgp.c
camel/tests/smime/pkcs7.c

index fcf9d3c..e22217d 100644 (file)
@@ -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
index d142c11..b6ff6cd 100644 (file)
@@ -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))) {
index 3291518..338a235 100644 (file)
@@ -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"));
index ba7de9e..b7d86c5 100644 (file)
@@ -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);
 }
 
 
index e99d31a..cd811a6 100644 (file)
@@ -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);
index 8b132b6..c32d6e4 100644 (file)
@@ -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) {
index c076128..15256f8 100644 (file)
@@ -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);
index d8ff6e0..15f4a5c 100644 (file)
@@ -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);
index 9123102..ad52b87 100644 (file)
@@ -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);
index fc06706..a439c4f 100644 (file)
@@ -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);
index fbdae86..02e58dd 100644 (file)
@@ -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;
index 5bf5add..be5e1be 100644 (file)
@@ -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);
index 1020926..2ec805b 100644 (file)
@@ -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");
index 81ea6fa..098e3de 100644 (file)
@@ -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");
index 2248d86..baedd36 100644 (file)
@@ -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.");