[git] GPA - branch, master, updated. gpa-0.9.10-13-g069e354

by Werner Koch cvs at cvs.gnupg.org
Mon Apr 16 09:25:27 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Assistant".

The branch, master has been updated
       via  069e354d8265ef0071522b14df981281e78a6409 (commit)
       via  38aeb4b188904a475ac4659dd0aa7e89578093ed (commit)
      from  69c777580bb9eff0fbc373b3a84cdfe74b07f566 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 069e354d8265ef0071522b14df981281e78a6409
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Apr 16 09:17:54 2018 +0200

    Add a User ID notebook page.
    
    * src/gpa-uid-list.c, src/gpa-uid-list.h: New.
    * src/Makefile.am (gpa_SOURCES): Add them.
    * src/convert.c (keyorg_string): New.
    (gpa_update_origin_string): New.
    * src/gpgmetools.c (gpa_uid_validity_string): new.
    * src/gpa-key-details.c: Include gpa-uid-list.h.
    (_GpaKeyDetails): Add fields uid_page and uid_list.
    (construct_details_page): Add "Last Update" line.
    (build_uid_page): New.
    (ui_mode_changed): Call that function.
    (gpa_key_details_finalize): Free the uid_list.
    (gpa_key_details_update): Inset a new notepad page.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/Makefile.am b/src/Makefile.am
index 4957b66..3cc1dc9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -119,6 +119,7 @@ gpa_SOURCES = \
               selectkeydlg.c selectkeydlg.h \
 	      keymanager.c keymanager.h \
 	      gpa-key-details.c gpa-key-details.h \
+	      gpa-uid-list.c gpa-uid-list.h \
 	      gpa-tofu-list.c gpa-tofu-list.h \
 	      ownertrustdlg.c ownertrustdlg.h \
 	      keysigndlg.c keysigndlg.h \
diff --git a/src/convert.c b/src/convert.c
index 280c5b8..1e05c76 100644
--- a/src/convert.c
+++ b/src/convert.c
@@ -129,6 +129,48 @@ gpa_creation_date_string (unsigned long creation_time)
   return result;
 }
 
+
+#if GPGME_VERSION_NUMBER >= 0x010a00  /* GPGME >= 1.10.0 */
+static const char *
+keyorg_string (unsigned int origin)
+{
+  switch (origin)
+    {
+    case GPGME_KEYORG_UNKNOWN: return _("unknown");
+    case GPGME_KEYORG_KS:      return _("keyserver");
+    case GPGME_KEYORG_DANE:    return _("DANE");
+    case GPGME_KEYORG_WKD:     return _("Web Key Directory");
+    case GPGME_KEYORG_URL:     return _("URL");
+    case GPGME_KEYORG_FILE:    return _("file");
+    case GPGME_KEYORG_SELF:    return _("self");
+    case GPGME_KEYORG_OTHER:   return _("other");
+    }
+  return "[?]";
+}
+
+
+char *
+gpa_update_origin_string (unsigned long last_update, unsigned int origin)
+{
+  gchar *result;
+  GDate adate;
+
+  if (last_update && origin)
+    {
+      g_date_set_time_t (&adate, (time_t)last_update);
+      result = g_strdup_printf ("%04d-%02d-%02d (%s)",
+                                g_date_get_year (&adate),
+                                g_date_get_month (&adate),
+                                g_date_get_day (&adate),
+                                keyorg_string (origin));
+    }
+  else
+    result = g_strdup (_("Unknown"));
+  return result;
+}
+#endif /* gpgme >= 1.10.0 */
+
+
 const char *
 gpa_sex_char_to_string (char sex)
 {
diff --git a/src/convert.h b/src/convert.h
index 6373417..90e1b66 100644
--- a/src/convert.h
+++ b/src/convert.h
@@ -25,6 +25,7 @@ char gpa_time_unit_from_string (const char *string);
 char *gpa_date_string (unsigned long t);
 char *gpa_expiry_date_string (unsigned long expiry_time);
 char *gpa_creation_date_string (unsigned long creation_time);
+char *gpa_update_origin_string (unsigned long last_update, unsigned int origin);
 const char *gpa_sex_char_to_string (char sex);
 
 #endif /*CONVERT_H*/
diff --git a/src/gpa-key-details.c b/src/gpa-key-details.c
index d48e2b0..e10d17b 100644
--- a/src/gpa-key-details.c
+++ b/src/gpa-key-details.c
@@ -37,6 +37,7 @@
 #include "siglist.h"
 #include "certchain.h"
 #include "gpasubkeylist.h"
+#include "gpa-uid-list.h"
 #include "gpa-tofu-list.h"
 #include "gpa-key-details.h"
 #include "gtktools.h"
@@ -67,6 +68,11 @@ struct _GpaKeyDetails
   GtkWidget *detail_key_trust;
   GtkWidget *detail_key_type;
   GtkWidget *detail_creation;
+  GtkWidget *detail_last_update;
+
+  /* The widgets in the user ID page.  */
+  GtkWidget *uid_page;
+  GtkWidget *uid_list;
 
   /* The widgets in the signatures page.  */
   GtkWidget *signatures_page;
@@ -211,6 +217,12 @@ details_page_fill_key (GpaKeyDetails *kdt, gpgme_key_t key)
   gtk_label_set_text (GTK_LABEL (kdt->detail_creation), text);
   g_free (text);
 
+#if GPGME_VERSION_NUMBER >= 0x010100  /* GPGME >= 1.10.0 */
+  text = gpa_update_origin_string (key->last_update, key->origin);
+  gtk_label_set_text (GTK_LABEL (kdt->detail_last_update), text);
+  g_free (text);
+#endif
+
   gtk_widget_hide_all (kdt->details_num_label);
   gtk_widget_show_all (kdt->details_table);
   gtk_widget_set_no_show_all (kdt->details_num_label, TRUE);
@@ -324,12 +336,63 @@ construct_details_page (GpaKeyDetails *kdt)
     (table, table_row++, _("Key type:"), FALSE);
   kdt->detail_creation = add_details_row
     (table, table_row++, _("Created at:"), FALSE);
+  kdt->detail_last_update = add_details_row
+    (table, table_row++, _("Last update:"), FALSE);
 
   gtk_notebook_append_page (GTK_NOTEBOOK (kdt), scrolled,
                             gtk_label_new (_("Details")));
 }
 
 
+/* Create and append new page with USER ID info for KEY.  If KEY is NULL
+   remove an existing USER ID page. */
+static void
+build_uid_page (GpaKeyDetails *kdt, gpgme_key_t key)
+{
+  GtkWidget *vbox;
+  GtkWidget *scrolled;
+  GtkWidget *uidlist;
+  int pnum;
+
+  /* First remove an existing page.  */
+  if (kdt->uid_page)
+    {
+      pnum = gtk_notebook_page_num (GTK_NOTEBOOK (kdt), kdt->uid_page);
+      if (pnum >= 0)
+        gtk_notebook_remove_page (GTK_NOTEBOOK (kdt), pnum);
+      kdt->uid_page = NULL;
+      if (kdt->uid_list)
+        {
+          g_object_unref (kdt->uid_list);
+          kdt->uid_list = NULL;
+        }
+    }
+  if (!key)
+    return;
+
+  /* Create a new page.  */
+  vbox = gtk_vbox_new (FALSE, 5);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+  scrolled = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                       GTK_SHADOW_IN);
+  gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
+  uidlist = gpa_uid_list_new ();
+  gtk_container_add (GTK_CONTAINER (scrolled), uidlist);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                  GTK_POLICY_AUTOMATIC,
+                                  GTK_POLICY_AUTOMATIC);
+  kdt->uid_list = uidlist;
+  g_object_ref (kdt->uid_list);
+  kdt->uid_page = vbox;
+  gtk_notebook_append_page (GTK_NOTEBOOK (kdt), kdt->uid_page,
+                            gtk_label_new (_("User IDs")));
+
+  /* Fill this page.  */
+  gpa_uid_list_set_key (kdt->uid_list, key);
+}
+
+
 /* Add the signatures page to the notebook.  */
 static void
 build_signatures_page (GpaKeyDetails *kdt, gpgme_key_t key)
@@ -560,11 +623,13 @@ ui_mode_changed (GpaOptions *options, gpointer param)
 
   if (gpa_options_get_simplified_ui (gpa_options_get_instance ()))
     {
+      build_uid_page (kdt, NULL);
       build_signatures_page (kdt, NULL);
       build_subkeys_page (kdt, NULL);
     }
   else
     {
+      build_uid_page (kdt, kdt->current_key);
       build_signatures_page (kdt, kdt->current_key);
       build_subkeys_page (kdt, kdt->current_key);
     }
@@ -625,6 +690,11 @@ gpa_key_details_finalize (GObject *object)
       gpgme_key_unref (kdt->current_key);
       kdt->current_key = NULL;
     }
+  if (kdt->uid_list)
+    {
+      g_object_unref (kdt->uid_list);
+      kdt->uid_list = NULL;
+    }
   if (kdt->signatures_list)
     {
       g_object_unref (kdt->signatures_list);
@@ -709,13 +779,15 @@ gpa_key_details_update (GtkWidget *keydetails, gpgme_key_t key, int keycount)
   if (pnum >= 0
       && (widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (kdt), pnum)))
     {
-      if (widget == kdt->signatures_page)
+      if (widget == kdt->uid_page)
         pnum = 1;
-      else if (widget == kdt->subkeys_page)
+      else if (widget == kdt->signatures_page)
         pnum = 2;
+      else if (widget == kdt->subkeys_page)
+        pnum = 3;
 #ifdef ENABLE_TOFU_INFO
       else if (widget == kdt->tofu_page)
-        pnum = 3;
+        pnum = 4;
 #endif /*ENABLE_TOFU_INFO*/
       else
         pnum = 0;
@@ -739,11 +811,13 @@ gpa_key_details_update (GtkWidget *keydetails, gpgme_key_t key, int keycount)
       /* Depend the generation of pages on the mode of the UI.  */
       if (gpa_options_get_simplified_ui (gpa_options_get_instance ()))
         {
+          build_uid_page (kdt, NULL);
           build_signatures_page (kdt, NULL);
           build_subkeys_page (kdt, NULL);
         }
       else
         {
+          build_uid_page (kdt, key);
           build_signatures_page (kdt, key);
           build_subkeys_page (kdt, key);
         }
@@ -761,12 +835,14 @@ gpa_key_details_update (GtkWidget *keydetails, gpgme_key_t key, int keycount)
   gtk_widget_show_all (keydetails);
 
   /* Try to select the last selected page.  */
-  if (pnum == 1 && kdt->signatures_page)
+  if (pnum == 1 && kdt->uid_page)
+    pnum = gtk_notebook_page_num (GTK_NOTEBOOK (kdt), kdt->uid_page);
+  else if (pnum == 2 && kdt->signatures_page)
     pnum = gtk_notebook_page_num (GTK_NOTEBOOK (kdt), kdt->signatures_page);
-  else if (pnum == 2 && kdt->subkeys_page)
+  else if (pnum == 3 && kdt->subkeys_page)
     pnum = gtk_notebook_page_num (GTK_NOTEBOOK (kdt), kdt->subkeys_page);
 #ifdef ENABLE_TOFU_INFO
-  else if (pnum == 3 && kdt->tofu_page)
+  else if (pnum == 4 && kdt->tofu_page)
     pnum = gtk_notebook_page_num (GTK_NOTEBOOK (kdt), kdt->tofu_page);
 #endif /*ENABLE_TOFU_INFO*/
   else
diff --git a/src/gpa-uid-list.c b/src/gpa-uid-list.c
new file mode 100644
index 0000000..0136e57
--- /dev/null
+++ b/src/gpa-uid-list.c
@@ -0,0 +1,169 @@
+/* gpa-uid-list.c - A list to show User ID information.
+ * Copyright (C) 2018 g10 Code GmbH
+ *
+ * This file is part of GPA
+ *
+ * GPA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GPA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "gpa.h"
+#include "convert.h"
+#include "gtktools.h"
+#include "keytable.h"
+#include "gpa-uid-list.h"
+
+static gboolean uid_list_query_tooltip_cb (GtkWidget *wdiget, int x, int y,
+                                           gboolean keyboard_mode,
+                                           GtkTooltip *tooltip,
+                                           gpointer user_data);
+
+
+
+typedef enum
+{
+  UID_ADDRESS,
+  UID_VALIDITY,
+  UID_UPDATE,
+  UID_FULLUID,
+  UID_N_COLUMNS
+} UidListColumn;
+
+
+/* Create a new user id list.  */
+GtkWidget *
+gpa_uid_list_new (void)
+{
+  GtkListStore *store;
+  GtkWidget *list;
+  GtkTreeViewColumn *column;
+  GtkCellRenderer *renderer;
+
+  /* Init the model */
+  store = gtk_list_store_new (UID_N_COLUMNS,
+			      G_TYPE_STRING,  /* address */
+			      G_TYPE_STRING,  /* validity */
+			      G_TYPE_STRING,  /* updated */
+			      G_TYPE_STRING   /* fulluid */
+                              );
+
+  /* The view */
+  list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (list), TRUE);
+
+  /* Add the columns */
+  renderer = gtk_cell_renderer_text_new ();
+  column = gtk_tree_view_column_new_with_attributes (NULL, renderer,
+						     "text", UID_ADDRESS,
+						     NULL);
+  gpa_set_column_title (column, _("Address"),
+                        _("The mail address."));
+  gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);
+
+  renderer = gtk_cell_renderer_text_new ();
+  column = gtk_tree_view_column_new_with_attributes (NULL, renderer,
+						     "text", UID_VALIDITY,
+						     NULL);
+  gpa_set_column_title (column, _("Validity"),
+                        _("The validity of the mail address\n"));
+  gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);
+
+  renderer = gtk_cell_renderer_text_new ();
+  column = gtk_tree_view_column_new_with_attributes (NULL, renderer,
+						     "text", UID_UPDATE,
+						     NULL);
+  gpa_set_column_title (column, _("Update"),
+                _("The date the key was last updated via this mail address."));
+  gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);
+
+  renderer = gtk_cell_renderer_text_new ();
+  column = gtk_tree_view_column_new_with_attributes (NULL, renderer,
+						     "text", UID_FULLUID,
+						     NULL);
+  gpa_set_column_title (column, _("User ID"),
+                        _("The full user ID."));
+  gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);
+
+
+  g_object_set (list, "has-tooltip", TRUE, NULL);
+  g_signal_connect (list, "query-tooltip",
+                    G_CALLBACK (uid_list_query_tooltip_cb), list);
+
+  return list;
+}
+
+
+/* Set the key whose user ids shall be displayed. */
+void
+gpa_uid_list_set_key (GtkWidget *list, gpgme_key_t key)
+{
+  GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model
+                                        (GTK_TREE_VIEW (list)));
+  GtkTreeIter iter;
+  gpgme_user_id_t uid;
+
+  /* Empty the list */
+  gtk_list_store_clear (store);
+
+  if (!key || !key->uids)
+    return;
+
+  for (uid = key->uids; uid; uid = uid->next)
+    {
+      char *lupd = gpa_update_origin_string (uid->last_update, uid->origin);
+
+      gtk_list_store_append (store, &iter);
+      gtk_list_store_set
+        (store, &iter,
+         UID_ADDRESS,  uid->address? uid->address : "",
+         UID_VALIDITY, gpa_uid_validity_string (uid),
+         UID_UPDATE,   lupd,
+         UID_FULLUID,  uid->uid,
+         -1);
+
+      g_free (lupd);
+    }
+
+}
+
+
+/* Tooltip display callback.  */
+static gboolean
+uid_list_query_tooltip_cb (GtkWidget *widget, int x, int y,
+                           gboolean keyboard_tip,
+                           GtkTooltip *tooltip, gpointer user_data)
+{
+  GtkTreeView *tv = GTK_TREE_VIEW (widget);
+  GtkTreeViewColumn *column;
+  char *text;
+
+  (void)user_data;
+
+  if (!gtk_tree_view_get_tooltip_context (tv, &x, &y, keyboard_tip,
+                                          NULL, NULL, NULL))
+    return FALSE; /* Not at a row - do not show a tooltip.  */
+  if (!gtk_tree_view_get_path_at_pos (tv, x, y, NULL, &column, NULL, NULL))
+    return FALSE;
+
+  widget = gtk_tree_view_column_get_widget (column);
+  text = widget? gtk_widget_get_tooltip_text (widget) : NULL;
+  if (!text)
+    return FALSE; /* No tooltip desired.  */
+
+  gtk_tooltip_set_text (tooltip, text);
+  g_free (text);
+
+  return TRUE; /* Show tooltip.  */
+}
diff --git a/src/gpa-uid-list.h b/src/gpa-uid-list.h
new file mode 100644
index 0000000..5d07193
--- /dev/null
+++ b/src/gpa-uid-list.h
@@ -0,0 +1,31 @@
+/* gpa-uid-list.h - A list to show TOFU information
+ * Copyright (C) 2018 g10 Code GmbH
+ *
+ * This file is part of GPA
+ *
+ * GPA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GPA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GPA_UID_LIST_H
+#define GPA_UID_LIST_H
+
+#include <gtk/gtk.h>
+
+/* Create a new User ID list.  */
+GtkWidget * gpa_uid_list_new (void);
+
+/* Set the key for which User ID information shall be shown.  */
+void gpa_uid_list_set_key (GtkWidget *list, gpgme_key_t key);
+
+#endif /* GPA_UID_LIST_H */
diff --git a/src/gpgmetools.c b/src/gpgmetools.c
index cc45052..2dfd741 100644
--- a/src/gpgmetools.c
+++ b/src/gpgmetools.c
@@ -753,6 +753,28 @@ gpa_key_validity_string (gpgme_key_t key)
 }
 
 
+/* UID validity strings.  */
+const gchar *
+gpa_uid_validity_string (gpgme_user_id_t uid)
+{
+  if (uid->revoked)
+    return _("Revoked");
+  else if (uid->invalid)
+    return _("Invalid");
+
+  switch (uid->validity)
+    {
+    case GPGME_VALIDITY_UNKNOWN:
+    case GPGME_VALIDITY_UNDEFINED:return _("Unknown");
+    case GPGME_VALIDITY_NEVER:    return _("Faked");
+    case GPGME_VALIDITY_MARGINAL: return _("Marginal");
+    case GPGME_VALIDITY_FULL:     return _("Fully");
+    case GPGME_VALIDITY_ULTIMATE: return _("Ultimate");
+    default: return "[?]";
+    }
+}
+
+
 static GtkWidget *
 passphrase_question_label (const char *uid_hint,
 			   const char *passphrase_info,
diff --git a/src/gpgmetools.h b/src/gpgmetools.h
index 1cfeb3a..dc39839 100644
--- a/src/gpgmetools.h
+++ b/src/gpgmetools.h
@@ -171,6 +171,9 @@ const gchar *gpa_key_ownertrust_string (gpgme_key_t key);
 /* Key validity strings.  */
 const gchar *gpa_key_validity_string (gpgme_key_t key);
 
+/* UID validity strings.  */
+const gchar *gpa_uid_validity_string (gpgme_user_id_t uid);
+
 /* Function to manage import results.  */
 void gpa_gpgme_update_import_results (gpa_import_result_t result,
                                       unsigned int files,

commit 38aeb4b188904a475ac4659dd0aa7e89578093ed
Author: Damien Goutte-Gattat <dgouttegattat at incenp.org>
Date:   Thu Mar 29 13:52:57 2018 +0100

    Load the secret keyring before the public one.
    
    * src/keylist.c (gpa_keylist_init): Forcefully load the secret
    keyring before attempting to load the public keys.
    --
    
    Gpa loads the private keyring in a kind of "lazy mode", in that
    the private keyring is only loaded the first time Gpa needs to
    lookup a private key. This normally happens during the loading
    of the public keyring, since for each public key Gpa must lookup
    in the private keyring to check whether a private counterpart is
    available.
    
    The result is that a Gpg process is spawn to list the secret keys
    while another Gpg process is still listing the public keys. If
    the trust model happens to be TOFU or TOFU+PGP, this can cause
    some problems with regard to the locking of the TOFU database.
    
    To avoid that, this patch makes sure the private keyring is
    actively and synchronously loaded before we fetch the public keys
    (no more lazy loading).
    
    GnuPG-bug-id: 3748
    Signed-off-by: Damien Goutte-Gattat <dgouttegattat at incenp.org>

diff --git a/src/keylist.c b/src/keylist.c
index 442da08..2c8e7e8 100644
--- a/src/keylist.c
+++ b/src/keylist.c
@@ -231,7 +231,16 @@ gpa_keylist_init (GTypeInstance *instance, void *class_ptr)
     }
   else
     {
-      /* Initialize from the global keytable.  */
+      /* Initialize from the global keytable.
+       *
+       * We must forcefully load the secret keytable first to
+       * prevent concurrent access to the TOFU database. */
+      gpa_keytable_force_reload (gpa_keytable_get_secret_instance (),
+                                 NULL, (GpaKeyTableEndFunc) gtk_main_quit,
+                                 NULL);
+      gtk_main ();
+
+      /* Now we can load the public keyring. */
       gpa_keytable_list_keys (gpa_keytable_get_public_instance(),
                               gpa_keylist_next, gpa_keylist_end, list);
     }

-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am                         |   1 +
 src/convert.c                           |  42 ++++++++
 src/convert.h                           |   1 +
 src/gpa-key-details.c                   |  88 +++++++++++++++--
 src/gpa-uid-list.c                      | 169 ++++++++++++++++++++++++++++++++
 src/{gpa-tofu-list.h => gpa-uid-list.h} |  18 ++--
 src/gpgmetools.c                        |  22 +++++
 src/gpgmetools.h                        |   3 +
 src/keylist.c                           |  11 ++-
 9 files changed, 339 insertions(+), 16 deletions(-)
 create mode 100644 src/gpa-uid-list.c
 copy src/{gpa-tofu-list.h => gpa-uid-list.h} (65%)


hooks/post-receive
-- 
The GNU Privacy Assistant
http://git.gnupg.org




More information about the Gnupg-commits mailing list