[git] GPA - branch, master, updated. gpa-0.9.10-22-gf8d64d1

by Werner Koch cvs at cvs.gnupg.org
Mon Oct 15 21:14:03 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  f8d64d13a15a4c8eaf8d41c536e1534ea2405ddf (commit)
      from  9e119866c02ceba8f596fa16a990b5fae562c202 (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 f8d64d13a15a4c8eaf8d41c536e1534ea2405ddf
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Oct 15 21:13:46 2018 +0200

    Add context menu to copy a private key to the clipboard.
    
    * src/gpaexportop.c (PROP_SECRET): New.
    (gpa_export_operation_get_property): Add new property.
    (gpa_export_operation_set_property): Add new property.
    (gpa_export_operation_class_init): Install property.
    (gpa_export_operation_idle_cb): USe Secret export mode.
    * src/gpaexportclipop.c
    (gpa_export_clipboard_operation_complete_export): Improve message.
    * src/gpaexportclipop.c (gpa_export_clipboard_operation_new): Add arg
    'secret' and change caller.
    * src/keymanager.c (key_manager_copy_sec): New.
    (key_manager_action_new): Register function.
    --
    
    GnuPG-bug-id: 4049
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/gpaexportclipop.c b/src/gpaexportclipop.c
index 1e4c306..b3f9acf 100644
--- a/src/gpaexportclipop.c
+++ b/src/gpaexportclipop.c
@@ -134,22 +134,33 @@ static void
 gpa_export_clipboard_operation_complete_export (GpaExportOperation *operation)
 {
   GpaExportClipboardOperation *op = GPA_EXPORT_CLIPBOARD_OPERATION (operation);
+  gboolean is_secret;
+  GList *keys;
+  unsigned int nkeys;
+
+  g_object_get (op, "secret", &is_secret, "keys", &keys, NULL);
+  nkeys = g_list_length (keys);
   if (!dump_data_to_clipboard (operation->dest, gtk_clipboard_get
                                (GDK_SELECTION_CLIPBOARD)))
-    gpa_show_info(GPA_OPERATION (op)->window,
-                  _("The keys have been copied to the clipboard."));
+    gpa_show_info
+      (GPA_OPERATION (op)->window,
+       is_secret? _("The private key has been copied to the clipboard.") :
+       nkeys==1 ? _("The key has bees copied to the clipboard.") :
+       /* */      _("The keys have been copied to the clipboard."));
 }
 
 /* API */
 
 GpaExportClipboardOperation*
-gpa_export_clipboard_operation_new (GtkWidget *window, GList *keys)
+gpa_export_clipboard_operation_new (GtkWidget *window, GList *keys,
+                                    gboolean secret)
 {
   GpaExportClipboardOperation *op;
 
   op = g_object_new (GPA_EXPORT_CLIPBOARD_OPERATION_TYPE,
 		     "window", window,
 		     "keys", keys,
+                     "secret", secret,
 		     NULL);
 
   return op;
diff --git a/src/gpaexportclipop.h b/src/gpaexportclipop.h
index a0d7b94..c99d595 100644
--- a/src/gpaexportclipop.h
+++ b/src/gpaexportclipop.h
@@ -54,6 +54,7 @@ GType gpa_export_clipboard_operation_get_type (void) G_GNUC_CONST;
 /* Creates a new export to file operation.
  */
 GpaExportClipboardOperation*
-gpa_export_clipboard_operation_new (GtkWidget *window, GList *keys);
+  gpa_export_clipboard_operation_new (GtkWidget *window, GList *keys,
+                                      gboolean secret);
 
 #endif
diff --git a/src/gpaexportop.c b/src/gpaexportop.c
index 9caf49f..d20f785 100644
--- a/src/gpaexportop.c
+++ b/src/gpaexportop.c
@@ -32,7 +32,8 @@ static GObjectClass *parent_class = NULL;
 enum
 {
   PROP_0,
-  PROP_KEYS
+  PROP_KEYS,
+  PROP_SECRET
 };
 
 static gboolean gpa_export_operation_idle_cb (gpointer data);
@@ -57,6 +58,9 @@ gpa_export_operation_get_property (GObject     *object,
     case PROP_KEYS:
       g_value_set_pointer (value, op->keys);
       break;
+    case PROP_SECRET:
+      g_value_set_boolean (value, op->secret);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -78,6 +82,9 @@ gpa_export_operation_set_property (GObject     *object,
       /* Make sure we keep a reference for our keys */
       g_list_foreach (op->keys, (GFunc) gpgme_key_ref, NULL);
       break;
+    case PROP_SECRET:
+      op->secret = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -106,6 +113,7 @@ gpa_export_operation_init (GpaExportOperation *op)
 {
   op->keys = NULL;
   op->dest = NULL;
+  op->secret = 0;
 }
 
 static GObject*
@@ -156,7 +164,13 @@ gpa_export_operation_class_init (GpaExportOperationClass *klass)
 				   g_param_spec_pointer
 				   ("keys", "Keys",
 				    "Keys",
-				    G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
+				    G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class,
+				   PROP_SECRET,
+				   g_param_spec_boolean
+				   ("secret", "Secret",
+				    "Secret", FALSE,
+				    G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
 }
 
 GType
@@ -203,6 +217,7 @@ gpa_export_operation_idle_cb (gpointer data)
       GList *k;
       int i;
       gpgme_protocol_t prot = GPGME_PROTOCOL_UNKNOWN;
+      gboolean secret;
 
       gpgme_set_armor (GPA_OPERATION (op)->context->ctx, armor);
       /* Create the set of keys to export */
@@ -229,8 +244,11 @@ gpa_export_operation_idle_cb (gpointer data)
         }
       gpgme_set_protocol (GPA_OPERATION (op)->context->ctx, prot);
       /* Export to the gpgme_data_t */
+      g_object_get (op, "secret", &secret, NULL);
       err = gpgme_op_export_ext_start (GPA_OPERATION (op)->context->ctx,
-				       patterns, 0, op->dest);
+				       patterns,
+                                       secret? GPGME_EXPORT_MODE_SECRET : 0,
+                                       op->dest);
       if (err)
 	{
 	  gpa_gpgme_warning (err);
diff --git a/src/gpaexportop.h b/src/gpaexportop.h
index 128e903..c88763d 100644
--- a/src/gpaexportop.h
+++ b/src/gpaexportop.h
@@ -43,6 +43,9 @@ struct _GpaExportOperation {
 
   GList *keys;
   gpgme_data_t dest;
+
+  /*:: private ::*/
+  int secret;
 };
 
 struct _GpaExportOperationClass {
diff --git a/src/keymanager.c b/src/keymanager.c
index a352515..ff64b0a 100644
--- a/src/keymanager.c
+++ b/src/keymanager.c
@@ -874,7 +874,25 @@ key_manager_copy (GtkAction *action, gpointer param)
   if (! selection)
     return;
 
-  op = gpa_export_clipboard_operation_new (GTK_WIDGET (self), selection);
+  op = gpa_export_clipboard_operation_new (GTK_WIDGET (self), selection, 0);
+  register_operation (self, GPA_OPERATION (op));
+}
+
+
+/* Copy the secret keys into the clipboard.  */
+static void
+key_manager_copy_sec (GtkAction *action, gpointer param)
+{
+  GpaKeyManager *self = param;
+  GList *selection;
+  GpaExportClipboardOperation *op;
+
+  selection = gpa_keylist_get_selected_keys (self->keylist,
+                                             GPGME_PROTOCOL_UNKNOWN);
+  if (!selection || g_list_length (selection) != 1)
+    return;
+
+  op = gpa_export_clipboard_operation_new (GTK_WIDGET (self), selection, 1);
   register_operation (self, GPA_OPERATION (op));
 }
 
@@ -997,6 +1015,8 @@ key_manager_action_new (GpaKeyManager *self,
 	N_("Copy the selection"), G_CALLBACK (key_manager_copy) },
       { "EditCopyFpr", GTK_STOCK_COPY, N_("Copy _Fingerprint"), "<control>F",
 	N_("Copy the fingerprints"), G_CALLBACK (key_manager_copy_fpr) },
+      { "EditCopySec", GTK_STOCK_COPY, N_("Copy Private Key"), NULL,
+	N_("Copy a single private key"), G_CALLBACK (key_manager_copy_sec) },
       { "EditPaste", GTK_STOCK_PASTE, NULL, NULL,
 	N_("Paste the clipboard"), G_CALLBACK (key_manager_paste) },
       { "EditSelectAll", GTK_STOCK_SELECT_ALL, NULL, "<control>A",
@@ -1129,6 +1149,7 @@ key_manager_action_new (GpaKeyManager *self,
     "    <menuitem action='KeysSign'/>"
     "    <menuitem action='KeysSetOwnerTrust'/>"
     "    <menuitem action='KeysEditPrivateKey'/>"
+    "    <menuitem action='EditCopySec'/>"
     "    <separator/>"
     "    <menuitem action='KeysExport'/>"
 #ifdef ENABLE_KEYSERVER_SUPPORT
@@ -1203,6 +1224,9 @@ key_manager_action_new (GpaKeyManager *self,
   action = gtk_action_group_get_action (action_group, "EditCopyFpr");
   add_selection_sensitive_action (self, action,
                                   key_manager_has_selection);
+  action = gtk_action_group_get_action (action_group, "EditCopySec");
+  add_selection_sensitive_action (self, action,
+                                  key_manager_has_single_selection);
   action = gtk_action_group_get_action (action_group, "KeysDelete");
   add_selection_sensitive_action (self, action,
                                   key_manager_has_selection);

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

Summary of changes:
 src/gpaexportclipop.c | 17 ++++++++++++++---
 src/gpaexportclipop.h |  3 ++-
 src/gpaexportop.c     | 24 +++++++++++++++++++++---
 src/gpaexportop.h     |  3 +++
 src/keymanager.c      | 26 +++++++++++++++++++++++++-
 5 files changed, 65 insertions(+), 8 deletions(-)


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




More information about the Gnupg-commits mailing list