[Gpa-commits] r1022 - in trunk: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Nov 26 19:12:37 CET 2009


Author: werner
Date: 2009-11-26 19:12:33 +0100 (Thu, 26 Nov 2009)
New Revision: 1022

Modified:
   trunk/NEWS
   trunk/src/ChangeLog
   trunk/src/Signals
   trunk/src/clipboard.c
   trunk/src/encryptdlg.c
   trunk/src/filesigndlg.c
   trunk/src/gpa.c
   trunk/src/gpakeyselector.c
   trunk/src/gpakeyselector.h
   trunk/src/keylist.c
   trunk/src/keylist.h
   trunk/src/selectkeydlg.c
   trunk/src/settingsdlg.c
Log:
Do not list invalid keys in the key selection dialogs.


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/NEWS	2009-11-26 18:12:33 UTC (rev 1022)
@@ -1,7 +1,13 @@
 Noteworthy changes in version 0.9.1 (not released)
 -------------------------------------------------
 
+ * The key selection dialogs for encryption and signing do not anymore
+   list expired, revoked or otherwise invalid keys.
  
+ * If no recipients are given to the server, a generic key selection
+   dialog is now used.
+
+
 Noteworthy changes in version 0.9.0 (2009-06-20)
 ------------------------------------------------
  

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/ChangeLog	2009-11-26 18:12:33 UTC (rev 1022)
@@ -1,5 +1,18 @@
-2009-11-13    <wk at g10code.com>
+2009-11-26  Werner Koch  <wk at g10code.com>
 
+	* gpakeyselector.h (_GpaKeySelector): Add field ONLY_USABLE_KEYS.
+	* gpakeyselector.c (gpa_key_selector_new): Add arg
+	ONLY_USABLE_KEYS.  Change all callers.
+	(gpa_key_selector_next_key): Implement option.
+	* keylist.c (PROP_ONLY_USABLE_KEYS): New.
+	(gpa_keylist_get_property, gpa_keylist_set_property)
+	(gpa_keylist_class_init): Init new property.
+	(gpa_keylist_new_with_keys): Add arg ONLY_USABLE_KEYS.
+	* selectkeydlg.c (select_key_dlg_constructor): Ask only for usable
+	keys.
+
+2009-11-13  Werner koch  <wk at g10code.com>
+
 	* gpastreamencryptop.c (struct _GpaStreamEncryptOperation): Add
 	field KEY_DIALOG.
 	(gpa_stream_encrypt_operation_constructor): Use a simple key

Modified: trunk/src/Signals
===================================================================
--- trunk/src/Signals	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/Signals	2009-11-26 18:12:33 UTC (rev 1022)
@@ -28,5 +28,6 @@
 
 ** changed_view
 
+
 ** changed_backup_generated
 

Modified: trunk/src/clipboard.c
===================================================================
--- trunk/src/clipboard.c	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/clipboard.c	2009-11-26 18:12:33 UTC (rev 1022)
@@ -1102,7 +1102,8 @@
   return GTK_WIDGET (instance);
 }
 
-gboolean gpa_clipboard_is_open (void)
+gboolean
+gpa_clipboard_is_open (void)
 {
   return (instance != NULL);
 }

Modified: trunk/src/encryptdlg.c
===================================================================
--- trunk/src/encryptdlg.c	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/encryptdlg.c	2009-11-26 18:12:33 UTC (rev 1022)
@@ -179,7 +179,7 @@
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollerKeys),
 				       GTK_SHADOW_IN);
 
-  clistKeys = gpa_key_selector_new (FALSE);
+  clistKeys = gpa_key_selector_new (FALSE, TRUE);
   g_signal_connect (G_OBJECT (gtk_tree_view_get_selection 
 			      (GTK_TREE_VIEW (clistKeys))),
 		    "changed", G_CALLBACK (changed_select_row_cb),
@@ -207,7 +207,7 @@
 				       GTK_SHADOW_IN);
   gtk_box_pack_start (GTK_BOX (vboxEncrypt), scrollerWho, TRUE, TRUE, 0);
 
-  clistWho = gpa_key_selector_new (TRUE);
+  clistWho = gpa_key_selector_new (TRUE, TRUE);
   dialog->clist_who = clistWho;
   gtk_container_add (GTK_CONTAINER (scrollerWho), clistWho);
   gtk_label_set_mnemonic_widget (GTK_LABEL (labelWho), clistWho);

Modified: trunk/src/filesigndlg.c
===================================================================
--- trunk/src/filesigndlg.c	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/filesigndlg.c	2009-11-26 18:12:33 UTC (rev 1022)
@@ -191,7 +191,7 @@
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollerWho),
 				       GTK_SHADOW_IN);
 
-  clistWho = gpa_key_selector_new (TRUE);
+  clistWho = gpa_key_selector_new (TRUE, TRUE);
   dialog->clist_who = clistWho;
   gtk_container_add (GTK_CONTAINER (scrollerWho), clistWho);
   gtk_label_set_mnemonic_widget (GTK_LABEL (labelWho), clistWho);

Modified: trunk/src/gpa.c
===================================================================
--- trunk/src/gpa.c	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/gpa.c	2009-11-26 18:12:33 UTC (rev 1022)
@@ -213,7 +213,7 @@
 {
   /* FIXME: Shouldn't this connect only happen if the instance is
      created the first time?  Looks like a memory leak to me.  Right:
-     although the closure is ref counted an inetrnal data object will
+     although the closure is ref counted an internal data object will
      get allocated.  */
   g_signal_connect (G_OBJECT (gpa_clipboard_get_instance ()), "destroy",
 		    G_CALLBACK (quit_if_no_window), NULL);

Modified: trunk/src/gpakeyselector.c
===================================================================
--- trunk/src/gpakeyselector.c	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/gpakeyselector.c	2009-11-26 18:12:33 UTC (rev 1022)
@@ -134,11 +134,13 @@
 /* API */
 
 GtkWidget *
-gpa_key_selector_new (gboolean secret)
+gpa_key_selector_new (gboolean secret, gboolean only_usable_keys)
 {
   GtkWidget *sel = (GtkWidget*) g_object_new (GPA_KEY_SELECTOR_TYPE, NULL);
 
   GPA_KEY_SELECTOR (sel)->secret = secret;
+  GPA_KEY_SELECTOR (sel)->only_usable_keys = only_usable_keys;
+
   /* Disable the list while loading keys */
   gtk_widget_set_sensitive (GTK_WIDGET (sel), FALSE);
   if (secret)
@@ -214,6 +216,10 @@
   GtkTreeIter iter;
   const gchar *keyid;
   gchar *userid;
+
+  if (key && selector->only_usable_keys
+      && (key->revoked || key->disabled || key->expired || key->invalid))
+    return;
   
   selector->keys = g_list_prepend (selector->keys, key);
   store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (selector)));

Modified: trunk/src/gpakeyselector.h
===================================================================
--- trunk/src/gpakeyselector.h	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/gpakeyselector.h	2009-11-26 18:12:33 UTC (rev 1022)
@@ -39,8 +39,13 @@
 
 struct _GpaKeySelector {
   GtkTreeView parent;
+
   /* Whether we are listing secret or public keys */
   gboolean secret;
+
+  /* Whether we want only usable keys.  */
+  gboolean only_usable_keys;
+
   /* All gpgme_key_ts we hold. We keep them here to free them.
    * Ideally this should be done by the list itself, but that would
    * involve mucking around with GValues */
@@ -56,7 +61,7 @@
 
 /* API */
 
-GtkWidget *gpa_key_selector_new (gboolean secret);
+GtkWidget *gpa_key_selector_new (gboolean secret, gboolean only_usable_keys);
 
 /* Return a list of selected gpgme_key_t's. The caller must free the list, but
  * not dereference the keys, as they belong to the selector.

Modified: trunk/src/keylist.c
===================================================================
--- trunk/src/keylist.c	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/keylist.c	2009-11-26 18:12:33 UTC (rev 1022)
@@ -41,7 +41,8 @@
   PROP_PROTOCOL,
   PROP_INITIAL_KEYS,
   PROP_INITIAL_PATTERN,
-  PROP_REQUESTED_USAGE
+  PROP_REQUESTED_USAGE,
+  PROP_ONLY_USABLE_KEYS
 };
 
 /* GObject */
@@ -109,6 +110,9 @@
     case PROP_REQUESTED_USAGE:
       g_value_set_int (value, list->requested_usage);
       break;
+    case PROP_ONLY_USABLE_KEYS:
+      g_value_set_boolean (value, list->only_usable_keys);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -143,6 +147,9 @@
     case PROP_REQUESTED_USAGE:
       list->requested_usage = g_value_get_int (value);
       break;
+    case PROP_ONLY_USABLE_KEYS:
+      list->only_usable_keys = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -283,6 +290,15 @@
       0, 65535, 0, 
       G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
 
+  g_object_class_install_property 
+    (object_class, PROP_ONLY_USABLE_KEYS,
+     g_param_spec_boolean
+     ("only-usable-keys", "Only-usable-keys",
+      "Include only usable keys in the listing.",
+      FALSE,
+      G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
+
+
 }
 
 
@@ -441,6 +457,13 @@
         }
     }
 
+  if (key && list->only_usable_keys
+      && (key->revoked || key->disabled || key->expired || key->invalid))
+    {
+      gpgme_key_unref (key);
+      return;
+    }
+
   /* Append the key to the list.  */
   list->keys = g_list_append (list->keys, key);
   store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (list)));
@@ -653,7 +676,7 @@
 gpa_keylist_new_with_keys (GtkWidget *window, gboolean public_only,
                            gpgme_protocol_t protocol,
                            gpgme_key_t *keys, const char *pattern,
-                           int requested_usage)
+                           int requested_usage, gboolean only_usable_keys)
 {
   GpaKeyList *list;
 
@@ -663,6 +686,7 @@
                        "initial-keys", gpa_gpgme_copy_keyarray (keys),
                        "initial-pattern", pattern,
                        "requested-usage", requested_usage,
+                       "only-usable-keys", only_usable_keys,
                        NULL);
 
   return list;

Modified: trunk/src/keylist.h
===================================================================
--- trunk/src/keylist.h	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/keylist.h	2009-11-26 18:12:33 UTC (rev 1022)
@@ -54,6 +54,7 @@
   gpgme_key_t *initial_keys;
   const char *initial_pattern;
   int requested_usage;
+  gboolean only_usable_keys;
 
   int disposed;
 };
@@ -86,7 +87,8 @@
                                        gpgme_protocol_t protocol,
                                        gpgme_key_t *keys,
                                        const char *pattern,
-                                       int requested_usage);
+                                       int requested_usage,
+                                       gboolean only_usable_keys);
 
 /* Set the key list in "brief" mode.  */
 void gpa_keylist_set_brief (GpaKeyList * keylist);

Modified: trunk/src/selectkeydlg.c
===================================================================
--- trunk/src/selectkeydlg.c	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/selectkeydlg.c	2009-11-26 18:12:33 UTC (rev 1022)
@@ -208,7 +208,7 @@
                                                dialog->protocol,
                                                dialog->initial_keys,
                                                dialog->initial_pattern,
-                                               KEY_USAGE_ENCR);
+                                               KEY_USAGE_ENCR, TRUE);
   gpa_gpgme_release_keyarray (dialog->initial_keys);
   dialog->initial_keys = NULL;
   gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET(dialog->keylist));

Modified: trunk/src/settingsdlg.c
===================================================================
--- trunk/src/settingsdlg.c	2009-11-26 09:45:06 UTC (rev 1021)
+++ trunk/src/settingsdlg.c	2009-11-26 18:12:33 UTC (rev 1022)
@@ -306,7 +306,7 @@
   gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
   gtk_frame_set_label_widget (GTK_FRAME (frame), label);
 
-  list = gpa_key_selector_new (TRUE);
+  list = gpa_key_selector_new (TRUE, FALSE);
   dialog->default_key.list = GPA_KEY_SELECTOR (list);
   gtk_tree_selection_set_mode (gtk_tree_view_get_selection 
 			       (GTK_TREE_VIEW (list)), GTK_SELECTION_SINGLE);



More information about the Gpa-commits mailing list