2008-11-26 [colin] 3.6.1cvs45
authorColin Leroy <colin@colino.net>
Wed, 26 Nov 2008 17:28:23 +0000 (17:28 +0000)
committerColin Leroy <colin@colino.net>
Wed, 26 Nov 2008 17:28:23 +0000 (17:28 +0000)
* src/plugins/pgpcore/select-keys.c
* src/plugins/pgpcore/sgpgme.c
Fix bug 1591, 'S/MIME: better key
handling/selection dialog'
Really ignore revoked/expired keys

ChangeLog
PATCHSETS
configure.ac
src/plugins/pgpcore/select-keys.c
src/plugins/pgpcore/sgpgme.c

index b66d750c0fccf6db84f6fb68c7d2a436cff64bf1..995536c71dcf62480e9e7dceceea37e3aa0e093b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-11-26 [colin]     3.6.1cvs45
+
+       * src/plugins/pgpcore/select-keys.c
+       * src/plugins/pgpcore/sgpgme.c
+               Fix bug 1591, 'S/MIME: better key 
+               handling/selection dialog'
+               Really ignore revoked/expired keys
+
 2008-11-26 [colin]     3.6.1cvs44
 
        * src/main.c
index 4e25735270a074fa345517139c6e51782ea6916b..36342cce2aaad564a71dc42e00a55e80ad161d91 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.49.2.121 -r 1.49.2.122 src/procmime.c;  ) > 3.6.1cvs42.patchset
 ( cvs diff -u -r 1.179.2.236 -r 1.179.2.237 src/imap.c;  cvs diff -u -r 1.101.2.57 -r 1.101.2.58 src/news.c;  cvs diff -u -r 1.1.4.105 -r 1.1.4.106 src/etpan/imap-thread.c;  ) > 3.6.1cvs43.patchset
 ( cvs diff -u -r 1.115.2.215 -r 1.115.2.216 src/main.c;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/common/claws.c;  cvs diff -u -r 1.9.2.35 -r 1.9.2.36 src/common/ssl.c;  ) > 3.6.1cvs44.patchset
+( cvs diff -u -r 1.1.2.21 -r 1.1.2.22 src/plugins/pgpcore/select-keys.c;  cvs diff -u -r 1.1.2.56 -r 1.1.2.57 src/plugins/pgpcore/sgpgme.c;  ) > 3.6.1cvs45.patchset
index 7bbc7b5a6899b96aeb865fe84dc1dfe8c436fad2..a8270554ffda1b5f97bb45ca42038f18e55c461b 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=6
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=44
+EXTRA_VERSION=45
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 803af2f8b2ca3f6c88ada3a9c847e9768560106b..6ee99e2e54ec66981981928f2029a37982ca0e9a 100644 (file)
@@ -183,8 +183,9 @@ set_row (GtkCMCList *clist, gpgme_key_t key, gpgme_protocol_t proto)
 
     /* first check whether the key is capable of encryption which is not
      * the case for revoked, expired or sign-only keys */
-    if (!key->can_encrypt)
+    if (!key->can_encrypt || key->revoked || key->expired)
         return;
+
     algo_buf = g_strdup_printf ("%du/%s", 
          key->subkeys->length,
          gpgme_pubkey_algo_name(key->subkeys->pubkey_algo) );
@@ -235,23 +236,23 @@ set_row (GtkCMCList *clist, gpgme_key_t key, gpgme_protocol_t proto)
     switch (key->uids->validity)
       {
       case GPGME_VALIDITY_UNDEFINED:
-        s = "q";
+        s = _("Undefined");
         break;
       case GPGME_VALIDITY_NEVER:
-        s = "n";
+        s = _("Never");
         break;
       case GPGME_VALIDITY_MARGINAL:
-        s = "m";
+        s = _("Marginal");
         break;
       case GPGME_VALIDITY_FULL:
-        s = "f";
+        s = _("Full");
         break;
       case GPGME_VALIDITY_ULTIMATE:
-        s = "u";
+        s = _("Ultimate");
         break;
       case GPGME_VALIDITY_UNKNOWN:
       default:
-        s = "?";
+        s = _("Unknown");
         break;
       }
     text[COL_VALIDITY] = s;
@@ -301,7 +302,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
     update_progress (sk, ++running, pattern);
     while ( !(err = gpgme_op_keylist_next ( ctx, &key )) ) {
        gpgme_user_id_t uid = key->uids;
-       if (!key->can_encrypt)
+       if (!key->can_encrypt || key->revoked || key->expired)
                continue;
         debug_print ("%% %s:%d:  insert\n", __FILE__ ,__LINE__ );
         set_row (clist, key, proto ); 
@@ -312,7 +313,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
                        continue;
                raw_mail = g_strdup(uid->email);
                extract_address(raw_mail);
-               if (!strcmp(pattern, raw_mail)) {
+               if (!strcasecmp(pattern, raw_mail)) {
                        exact_match = TRUE;
                        g_free(raw_mail);
                        break;
@@ -394,7 +395,7 @@ create_dialog (struct select_keys_s *sk)
     titles[COL_KEYID]    = _("Key ID");
     titles[COL_NAME]     = _("Name");
     titles[COL_EMAIL]    = _("Address");
-    titles[COL_VALIDITY] = _("Val");
+    titles[COL_VALIDITY] = _("Trust");
 
     clist = gtk_cmclist_new_with_titles (N_COL_TITLES, (char**)titles);
     gtk_container_add (GTK_CONTAINER (scrolledwin), clist);
index 3bb59afb586c8c9859de567e4b80ed5f71ec2eb5..b0c0bd1906172f5a189078523c0321adf0953732 100644 (file)
@@ -503,16 +503,44 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account)
                        goto bail;
 
                err = gpgme_op_keylist_start(ctx, keyid, 1);
-               if (!err)
-                       err = gpgme_op_keylist_next(ctx, &key);
+               if (!err) {
+                       do {
+                               err = gpgme_op_keylist_next(ctx, &key);
+                               if (!err && key && key->protocol == gpgme_get_protocol(ctx) &&
+                                   !key->expired && !key->revoked)
+                                       break;
+                               if (!err && key && key->protocol != gpgme_get_protocol(ctx)) {
+                                       debug_print("skipping a key (wrong protocol %d)\n", key->protocol);
+                                       gpgme_key_release(key);
+                               }
+                               if (!err && key && (key->expired || key->revoked)) {
+                                       debug_print("skipping a key (%s)\n", key->expired?"expired":"revoked");
+                                       gpgme_key_release(key);
+                               }
+                       } while (!err);
+               }
                if (err) {
                        g_warning("setup_signers start: %s", gpgme_strerror(err));
                        privacy_set_error(_("Secret key not found (%s)"), gpgme_strerror(err));
                        goto bail;
                }
                
-               err = gpgme_op_keylist_next(ctx, &key2);
+               do {
+                       err = gpgme_op_keylist_next(ctx, &key2);
+                       if (!err && key2 && key2->protocol == gpgme_get_protocol(ctx) &&
+                           !key2->expired && !key2->revoked)
+                               break;
+                       if (!err && key && key2->protocol != gpgme_get_protocol(ctx)) {
+                               debug_print("skipping a key (wrong protocol %d)\n", key2->protocol);
+                               gpgme_key_release(key2);
+                       }
+                       if (!err && key && (key2->expired || key2->revoked)) {
+                               debug_print("skipping a key (%s)\n", key2->expired?"expired":"revoked");
+                               gpgme_key_release(key2);
+                       }
+               } while (!err);
                if (!err) {
+                       gpgme_key_release(key2);
                        g_warning("ambiguous specification of secret key '%s'\n",
                                keyid);
                        privacy_set_error(_("Secret key specification is ambiguous"));
@@ -521,6 +549,8 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account)
                
                gpgme_op_keylist_end(ctx);
                err = gpgme_signers_add(ctx, key);
+               debug_print("got key (proto %d (pgp %d, smime %d).\n", key->protocol,
+                               GPGME_PROTOCOL_OpenPGP, GPGME_PROTOCOL_CMS);
                gpgme_key_release(key);
                
                if (err) {