[balsa] Fix broken display of expired key parts



commit a3937265a6fe11a8d6c8331da6b41869dede08fb
Author: Albrecht Dreß <albrecht dress arcor de>
Date:   Tue Dec 18 19:37:07 2018 -0500

    Fix broken display of expired key parts
    
    Fix broken display of expired application/pgp-keys parts
    
    * libbalsa/libbalsa-gpgme-keys.[hc]: add flag to
      libbalsa_gpgme_list_keys() for listing expired etc. keys, use
      the new api w/o allowing expired etc. keys
    * libbalsa/libbalsa-gpgme.c, libbalsa/rfc3156.c: use the new
      api w/o allowing expired etc. keys
    * src/balsa-mime-widget-crypto.c: use the new api, allowing
      expired etc. keys
    
    Signed-off-by: Peter Bloomfield <PeterBloomfield bellsouth net>

 ChangeLog                      | 13 +++++++++++++
 libbalsa/libbalsa-gpgme-keys.c |  5 +++--
 libbalsa/libbalsa-gpgme-keys.h |  2 ++
 libbalsa/libbalsa-gpgme.c      |  6 +++---
 libbalsa/rfc3156.c             |  2 +-
 src/balsa-mime-widget-crypto.c |  2 +-
 6 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cce6e7577..0b8df6537 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2018-12-18  Albrecht Dreß  <albrecht dress arcor de>
+
+       Fix broken display of expired application/pgp-keys parts
+
+       * libbalsa/libbalsa-gpgme-keys.[hc]: add flag to
+         libbalsa_gpgme_list_keys() for listing expired etc. keys, use
+         the new api w/o allowing expired etc. keys
+       * libbalsa/libbalsa-gpgme.c, libbalsa/rfc3156.c: use the new
+         api w/o allowing expired etc. keys
+       * src/balsa-mime-widget-crypto.c: use the new api, allowing
+         expired etc. keys
+
+
 2018-12-18  Albrecht Dreß  <albrecht dress arcor de>
 
        Fix buffer overflow and missing include
diff --git a/libbalsa/libbalsa-gpgme-keys.c b/libbalsa/libbalsa-gpgme-keys.c
index f45566e73..57f5fbff9 100644
--- a/libbalsa/libbalsa-gpgme-keys.c
+++ b/libbalsa/libbalsa-gpgme-keys.c
@@ -68,6 +68,7 @@ libbalsa_gpgme_list_keys(gpgme_ctx_t   ctx,
                                                 const gchar  *pattern,
                                                 gboolean      secret,
                                                 gboolean      on_keyserver,
+                                                gboolean          list_bad_keys,
                                                 GError      **error)
 {
        gpgme_error_t gpgme_err;
@@ -110,7 +111,7 @@ libbalsa_gpgme_list_keys(gpgme_ctx_t   ctx,
 
                                gpgme_err = gpgme_op_keylist_next(ctx, &key);
                                if (gpgme_err == GPG_ERR_NO_ERROR) {
-                                       if (check_key(key, secret, on_keyserver, now)) {
+                                       if (list_bad_keys || check_key(key, secret, on_keyserver, now)) {
                                                *keys = g_list_prepend(*keys, key);
                                        } else {
                                                bad++;
@@ -353,7 +354,7 @@ gpgme_keyserver_run(gpointer user_data)
        gboolean result;
        GError *error = NULL;
 
-       result = libbalsa_gpgme_list_keys(keyserver_op->gpgme_ctx, &keys, NULL, keyserver_op->fingerprint, 
FALSE, TRUE, &error);
+       result = libbalsa_gpgme_list_keys(keyserver_op->gpgme_ctx, &keys, NULL, keyserver_op->fingerprint, 
FALSE, TRUE, FALSE, &error);
        if (result) {
                GtkWidget *dialog;
 
diff --git a/libbalsa/libbalsa-gpgme-keys.h b/libbalsa/libbalsa-gpgme-keys.h
index dcef961b5..0468f833e 100644
--- a/libbalsa/libbalsa-gpgme-keys.h
+++ b/libbalsa/libbalsa-gpgme-keys.h
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
  * \param pattern key search pattern (e.g. name, fingerprint, ...), may be NULL to list all keys
  * \param secret TRUE to search for private keys, FALSE to search for public keys
  * \param on_keyserver TRUE to search on a key server, FALSE to search the local key ring
+ * \param list_bad_keys include expired, revoked, invalid and disabled keys
  * \param error filled with error information on error, may be NULL
  * \return TRUE on success, or FALSE if any error occurred
  *
@@ -61,6 +62,7 @@ gboolean libbalsa_gpgme_list_keys(gpgme_ctx_t   ctx,
                                                                  const gchar  *pattern,
                                                                  gboolean      secret,
                                                                  gboolean      on_keyserver,
+                                                                 gboolean              list_bad_keys,
                                                                  GError      **error);
 
 /** \brief Load a key
diff --git a/libbalsa/libbalsa-gpgme.c b/libbalsa/libbalsa-gpgme.c
index a093e69f2..98d797696 100644
--- a/libbalsa/libbalsa-gpgme.c
+++ b/libbalsa/libbalsa-gpgme.c
@@ -747,7 +747,7 @@ libbalsa_gpgme_get_seckey(gpgme_protocol_t   protocol,
                GList *keys = NULL;
 
                /* let gpgme list all available keys */
-               if (libbalsa_gpgme_list_keys(ctx, &keys, NULL, name, TRUE, FALSE, error)) {
+               if (libbalsa_gpgme_list_keys(ctx, &keys, NULL, name, TRUE, FALSE, FALSE, error)) {
                        if (keys != NULL) {
                                gpgme_key_t key;
 
@@ -913,7 +913,7 @@ get_key_from_name(gpgme_ctx_t   ctx,
        }
 
        /* let gpgme list keys */
-       list_res = libbalsa_gpgme_list_keys(ctx, &keys, &bad_keys, mail_name, secret, FALSE, error);
+       list_res = libbalsa_gpgme_list_keys(ctx, &keys, &bad_keys, mail_name, secret, FALSE, FALSE, error);
        g_free(mail_name);
        if (!list_res) {
                return GPG_ERR_GENERAL;
@@ -992,7 +992,7 @@ get_pubkey(gpgme_ctx_t   ctx,
        gpgme_key_t key = NULL;
 
        /* let gpgme list all available keys */
-       if (libbalsa_gpgme_list_keys(ctx, &keys, NULL, NULL, FALSE, FALSE, error)) {
+       if (libbalsa_gpgme_list_keys(ctx, &keys, NULL, NULL, FALSE, FALSE, FALSE, error)) {
                if (keys != NULL) {
                        /* let the user select a key from the list, even if there is only one */
                        if (select_key_cb != NULL) {
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index 224725769..3854b14f0 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -753,7 +753,7 @@ have_pub_key_for(gpgme_ctx_t          gpgme_ctx,
                result = FALSE;
                /* enclose the mail address into "<...>" to perform an exact search */
                mail_name = g_strconcat("<", INTERNET_ADDRESS_MAILBOX(ia)->addr, ">", NULL);
-               if (libbalsa_gpgme_list_keys(gpgme_ctx, &keys, NULL, mail_name, FALSE, FALSE, NULL)) {
+               if (libbalsa_gpgme_list_keys(gpgme_ctx, &keys, NULL, mail_name, FALSE, FALSE, FALSE, NULL)) {
                        if (keys != NULL) {
                                result = TRUE;
                                g_list_free_full(keys, (GDestroyNotify) gpgme_key_unref);
diff --git a/src/balsa-mime-widget-crypto.c b/src/balsa-mime-widget-crypto.c
index 4a9463a9f..49abdae80 100644
--- a/src/balsa-mime-widget-crypto.c
+++ b/src/balsa-mime-widget-crypto.c
@@ -292,7 +292,7 @@ create_import_keys_widget(GtkBox *box, const gchar *key_buf, GError **error)
 
                        success = libbalsa_gpgme_ctx_set_home(ctx, temp_dir, error) &&
                                libbalsa_gpgme_import_ascii_key(ctx, key_buf, NULL, error) &&
-                               libbalsa_gpgme_list_keys(ctx, &keys, NULL, NULL, FALSE, FALSE, error);
+                               libbalsa_gpgme_list_keys(ctx, &keys, NULL, NULL, FALSE, FALSE, TRUE, error);
 
                        if (success && (keys != NULL)) {
                                GList *item;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]