[git] GPA - branch, master, updated. gpa-0.9.4-49-g1ffb7d1

by Werner Koch cvs at cvs.gnupg.org
Thu Nov 20 21:07:04 CET 2014


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  1ffb7d173b4268b61e2f955b3335ed37901e010c (commit)
       via  6e9fd523f7caf5508dfeabf4e53132cbac43d6a8 (commit)
      from  ac007f3204c06b3cb4b272fd1de17baa4d589ae8 (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 1ffb7d173b4268b61e2f955b3335ed37901e010c
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 19 10:34:32 2014 +0100

    po: Update German translation
    
    --
    
    Still 10 strings are not translated - they are mainly for the Telesec
    card - I am not inclinced to help them for free.

diff --git a/po/de.po b/po/de.po
index 0b5886f..fdb8ffe 100644
--- a/po/de.po
+++ b/po/de.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gpa\n"
 "Report-Msgid-Bugs-To: gpa-dev at gnupg.org\n"
-"PO-Revision-Date: 2014-01-07 23:06+0100\n"
+"PO-Revision-Date: 2014-11-20 15:46+0100\n"
 "Last-Translator: Werner Koch <wk at gnupg.org>\n"
 "Language-Team: German <de at li.org>\n"
 "Language: de\n"
@@ -269,9 +269,8 @@ msgstr "Zwischenablage öffnen"
 msgid "Open the settings dialog"
 msgstr "Öffne den Dialog für die Einstellungen"
 
-#, fuzzy
 msgid "Only start the UI server"
-msgstr "Den UI Server aktivieren"
+msgstr "Nur den UI Server starten"
 
 msgid "Disable support for X.509"
 msgstr "Keine Unterstützung von X.509"
@@ -280,7 +279,7 @@ msgid "Read options from file"
 msgstr "Optionen aus einer Datei lesen"
 
 msgid "Do not connect to a running instance"
-msgstr ""
+msgstr "Nicht mit einem laufenden GPA verbinden"
 
 msgid "[FILE...]"
 msgstr "[DATEI...]"
@@ -335,9 +334,9 @@ msgstr "Beim Erstellen der Datensicherung ist ein Fehler aufgetreten."
 msgid "Backup key to file"
 msgstr "_Sicherheitskopie des Schlüssels in Datei:"
 
-#, fuzzy, c-format
+#, c-format
 msgid "Generating backup of key: 0x%s"
-msgstr "Sicherheitskopie von Schlüssel %s erstellen"
+msgstr "Sicherheitskopie von Schlüssel 0x%s wird erstellt"
 
 msgid "The keys have been copied to the clipboard."
 msgstr "Die Schlüssel wurden in die Zwischenablage kopiert."
@@ -353,7 +352,7 @@ msgid "The keys have been exported to %s."
 msgstr "Die Schlüssel wurden exportiert nach %s."
 
 msgid "Only keys of the same procotol may be exported as a collection."
-msgstr ""
+msgstr "Nur Schlüssel eines Protokolls können zusammen exportiert werden"
 
 #, c-format
 msgid ""
@@ -463,24 +462,16 @@ msgstr "Schlüssel erzeugen..."
 msgid "Import keys from file"
 msgstr "Zertifikate aus Datei importieren"
 
-msgid "No keys were found."
-msgstr "Es wurde kein Schlüssel gefunden."
-
 #, c-format
 msgid ""
-"%i public keys read\n"
-"%i public keys imported\n"
-"%i public keys unchanged\n"
-"%i secret keys read\n"
-"%i secret keys imported\n"
-"%i secret keys unchanged"
+"More than %d keys match your search pattern.\n"
+"Use the long keyid or a fingerprint for a better match"
 msgstr ""
-"%i öffentliche Schlüssel gelesen\n"
-"%i öffentliche Schlüssel importiert\n"
-"%i öffentliche Schlüssel unverändert\n"
-"%i geheime Schlüssel gelesen\n"
-"%i geheime Schlüssel importiert\n"
-"%i geheime Schlüssel unverändert"
+"Mehr als %d Schlüssel entsprechen Ihren Suchkriterien.\n"
+"Benutzen Sie die lange Schlüsselkennung oder den Fingerprint für eine verfeinerte Suche."
+
+msgid "No keys were found."
+msgstr "Es wurde kein Schlüssel gefunden."
 
 msgid ""
 "Invalid time given.\n"
@@ -507,6 +498,9 @@ msgstr "Dieser Schlüssel ist bereits mit Ihrem eigenen Schlüssel signiert."
 msgid "You haven't selected a default key to sign with!"
 msgstr "Kein Standardschlüssel zum Signieren ausgewählt."
 
+msgid "Which key do you want to import?"
+msgstr "Welchen Schlüssel möchten Sie importieren?"
+
 msgid "Which key do you want to import? (The key must be specified by key ID)."
 msgstr "Welchen Schlüssel möchten Sie importieren? (Schlüsselkennung angeben)"
 
@@ -540,47 +534,44 @@ msgstr "Kennung des untergeordneten Schlüssels"
 msgid "Status"
 msgstr "Gültigkeit der Beglaubigung"
 
-#, fuzzy
 msgid "Algo"
-msgstr "_Verschlüsselungsalgorithmus"
+msgstr "Algo"
 
 msgid "Size"
 msgstr "Größe"
 
-#, fuzzy
 msgid "Created"
-msgstr "Erstellen"
+msgstr "Erstellt"
 
-#, fuzzy
 msgid "Expires"
-msgstr "Abgelaufen"
+msgstr "Läuft ab"
 
 msgid "S"
-msgstr ""
+msgstr "S"
 
 msgid "Can sign"
 msgstr "Zum Signieren verwendbar"
 
 msgid "C"
-msgstr ""
+msgstr "Z"
 
 msgid "Can certify"
 msgstr "Zum Überprüfen verwendbar"
 
 msgid "E"
-msgstr ""
+msgstr "V"
 
 msgid "Can encrypt"
 msgstr "Zum Verschlüsseln verwendbar"
 
 msgid "A"
-msgstr ""
+msgstr "A"
 
 msgid "Can authenticate"
 msgstr "Zum Authentifizieren verwendbar"
 
 msgid "T"
-msgstr ""
+msgstr "T"
 
 msgid "Secret key stored on a smartcard."
 msgstr "Geheimer Schlüssel befindet sich auf einer Smartcard"
@@ -862,8 +853,32 @@ msgstr "Der Schlüssel ist ausschließlich zum Verschlüsseln verwendbar."
 msgid "This key is useless."
 msgstr "Dieser Schlüssel ist nicht verwendbar."
 
-msgid "A required engine component is not installed."
+#, c-format
+msgid ""
+"%u file(s) read\n"
+"%u file(s) with errors"
+msgstr ""
+"%u Datei(en) gelesen\n"
+"%u Datei(en) mit Fehlern"
+
+#, c-format
+msgid ""
+"%i public keys read\n"
+"%i public keys imported\n"
+"%i public keys unchanged\n"
+"%i secret keys read\n"
+"%i secret keys imported\n"
+"%i secret keys unchanged"
 msgstr ""
+"%i öffentliche Schlüssel gelesen\n"
+"%i öffentliche Schlüssel importiert\n"
+"%i öffentliche Schlüssel unverändert\n"
+"%i geheime Schlüssel gelesen\n"
+"%i geheime Schlüssel importiert\n"
+"%i geheime Schlüssel unverändert"
+
+msgid "A required engine component is not installed."
+msgstr "Eine notwendige Krypto-Engine ist nicht installiert"
 
 msgid "Calling the crypto engine program failed."
 msgstr "Aufruf der Crypto-Engine fehlgeschlagen."
@@ -886,12 +901,6 @@ msgstr "Die Email Adresse ist nicht gültig."
 msgid "Invalid character in comments."
 msgstr "Ungültige Zeichen im Kommentarfeld."
 
-msgid "Error"
-msgstr "Fehler"
-
-msgid "Message"
-msgstr "Meldung"
-
 msgid "GPA is the GNU Privacy Assistant."
 msgstr "GPA ist der GNU Privacy Assistant"
 
@@ -1130,9 +1139,8 @@ msgstr ""
 "Die Schlüsselkennung (Key ID) is eine kurze Zahl zur Identifizerung eines "
 "Zertifikats."
 
-#, fuzzy
 msgid "The Creation Date is the date the certificate was created."
-msgstr "Das Ablaufdatum ist das Datum bis zu dem das Zertifikat gültig ist."
+msgstr "Das Erstellungsdatum ist das Datum ab dem das Zertifikat gültig ist."
 
 msgid "The Expiry Date is the date until the certificate is valid."
 msgstr "Das Ablaufdatum ist das Datum bis zu dem das Zertifikat gültig ist."
@@ -1389,6 +1397,12 @@ msgid ""
 "Please install a CMS engine or invoke this program\n"
 "with the option --disable-x509 ."
 msgstr ""
+"Anscheinend ist keine CMS Crypto-Engine installiert.\n"
+"\n"
+"Unterstütztung für X.509 wird vorerst ausgeschaltet.\n"
+"\n"
+"Bitte installieren Sie eine CMS Crypto-Engine oder starten\n"
+"Sie dieses Programm mit der Option --disable-x509 ."
 
 msgid ""
 "The private key you selected as default is no longer available.\n"
@@ -2253,6 +2267,12 @@ msgstr ""
 "können jedoch mit dem Knopf zur Anwendungsauswahl auf eine andere, auf der "
 "Karte verfügbare, Anwendung umschalten."
 
+#~ msgid "Error"
+#~ msgstr "Fehler"
+
+#~ msgid "Message"
+#~ msgstr "Meldung"
+
 #~ msgid "[S]"
 #~ msgstr "[S]"
 
@@ -2336,7 +2356,6 @@ msgstr ""
 #~ msgid "Keyring Editor"
 #~ msgstr "Schlüsselverwaltung"
 
-#, fuzzy
 #~ msgid "Generate new key..."
 #~ msgstr "Neuen Schlüssel erzeugen..."
 

commit 6e9fd523f7caf5508dfeabf4e53132cbac43d6a8
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 19 10:34:32 2014 +0100

    Implement the IMPORT_FILES server command.
    
    * src/server.c (cmd_file): Remove --continued stuff and add --clear.
    (conn_ctrl_s): Remove field files_finished.
    (impl_encrypt_sign_files): Adjust for this.
    (impl_decrypt_verify_files): Ditto.
    
    * src/server.c (impl_encrypt_sign_files): Add import feature.
    (cmd_import_files): Implement.
    * src/gpgmetools.h (gpa_import_result_s): New.
    * src/gpgmetools.c (gpa_gpgme_update_import_results): New.
    (gpa_gpgme_show_import_results): New.
    * src/gpaimportop.c (key_import_results_dialog_run): Remove.
    (gpa_import_operation_done_cb): Use new functions.
    * src/gpafileimportop.c, src/gpafileimportop.h: New.
    --
    
    The error and progress handling is not very pretty; this should be
    improved similar to the verify command.

diff --git a/src/Makefile.am b/src/Makefile.am
index d961144..9a2a408 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -154,6 +154,7 @@ gpa_SOURCES = \
 	      gpafileencryptop.h gpafileencryptop.c \
 	      gpafilesignop.h gpafilesignop.c \
 	      gpafileverifyop.h gpafileverifyop.c \
+	      gpafileimportop.h gpafileimportop.c \
 	      gpakeyop.h gpakeyop.c \
 	      gpakeydeleteop.h gpakeydeleteop.c \
 	      gpakeysignop.h gpakeysignop.c \
diff --git a/src/gpafileimportop.c b/src/gpafileimportop.c
new file mode 100644
index 0000000..4cc0dc1
--- /dev/null
+++ b/src/gpafileimportop.c
@@ -0,0 +1,311 @@
+/* gpafileimportop.c - Import keys from a file.
+   Copyright (C) 2003 Miguel Coca.
+   Copyright (C) 2008, 2014 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/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <glib.h>
+
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#else
+#include <io.h>
+#endif
+
+#include "gpa.h"
+#include "gtktools.h"
+#include "gpgmetools.h"
+#include "filetype.h"
+#include "gpafileimportop.h"
+
+
+/* Internal functions */
+static gboolean gpa_file_import_operation_idle_cb (gpointer data);
+static void gpa_file_import_operation_done_error_cb (GpaContext *context,
+						     gpg_error_t err,
+						   GpaFileImportOperation *op);
+static void gpa_file_import_operation_done_cb (GpaContext *context,
+						gpg_error_t err,
+						GpaFileImportOperation *op);
+
+/* GObject */
+
+static GObjectClass *parent_class = NULL;
+
+static void
+gpa_file_import_operation_finalize (GObject *object)
+{
+  /* GpaFileImportOperation *op = GPA_FILE_IMPORT_OPERATION (object); */
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+static void
+gpa_file_import_operation_init (GpaFileImportOperation *op)
+{
+  memset (&op->counters, 0, sizeof op->counters);
+}
+
+
+static GObject*
+gpa_file_import_operation_constructor (GType type,
+                                       guint n_construct_properties,
+                             GObjectConstructParam *construct_properties)
+{
+  GObject *object;
+  GpaFileImportOperation *op;
+
+  /* Invoke parent's constructor */
+  object = parent_class->constructor (type,
+				      n_construct_properties,
+				      construct_properties);
+  op = GPA_FILE_IMPORT_OPERATION (object);
+  /* Initialize */
+  /* Start with the first file after going back into the main loop */
+  g_idle_add (gpa_file_import_operation_idle_cb, op);
+  /* Connect to the "done" signal */
+  g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
+		    G_CALLBACK (gpa_file_import_operation_done_error_cb), op);
+  g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
+		    G_CALLBACK (gpa_file_import_operation_done_cb), op);
+  /* Give a title to the progress dialog */
+  gtk_window_set_title (GTK_WINDOW (GPA_FILE_OPERATION (op)->progress_dialog),
+			_("Importing..."));
+
+  return object;
+}
+
+
+static void
+gpa_file_import_operation_class_init (GpaFileImportOperationClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  parent_class = g_type_class_peek_parent (klass);
+
+  object_class->constructor = gpa_file_import_operation_constructor;
+  object_class->finalize = gpa_file_import_operation_finalize;
+}
+
+
+GType
+gpa_file_import_operation_get_type (void)
+{
+  static GType file_import_operation_type = 0;
+
+  if (!file_import_operation_type)
+    {
+      static const GTypeInfo file_import_operation_info =
+      {
+        sizeof (GpaFileImportOperationClass),
+        (GBaseInitFunc) NULL,
+        (GBaseFinalizeFunc) NULL,
+        (GClassInitFunc) gpa_file_import_operation_class_init,
+        NULL,           /* class_finalize */
+        NULL,           /* class_data */
+        sizeof (GpaFileImportOperation),
+        0,              /* n_preallocs */
+        (GInstanceInitFunc) gpa_file_import_operation_init
+      };
+
+      file_import_operation_type = g_type_register_static
+	(GPA_FILE_OPERATION_TYPE, "GpaFileImportOperation",
+	 &file_import_operation_info, 0);
+    }
+
+  return file_import_operation_type;
+}
+
+
+/* API */
+
+
+GpaFileImportOperation*
+gpa_file_import_operation_new (GtkWidget *window, GList *files)
+{
+  GpaFileImportOperation *op;
+
+  op = g_object_new (GPA_FILE_IMPORT_OPERATION_TYPE,
+		     "window", window,
+		     "input_files", files,
+		     NULL);
+
+  return op;
+}
+
+
+/* Internal */
+
+
+static gboolean
+proc_one_file (GpaFileImportOperation *op, gpa_file_item_t file_item)
+{
+  gpg_error_t err;
+  int fd;
+  gpgme_data_t data;
+
+  if (file_item->direct_in)
+    {
+      /* No copy is made.  */
+      err = gpgme_data_new_from_mem (&data, file_item->direct_in,
+				     file_item->direct_in_len, 0);
+      if (err)
+	{
+	  gpa_gpgme_warning (err);
+	  return FALSE;
+	}
+
+      gpgme_set_protocol (GPA_OPERATION (op)->context->ctx,
+                          is_cms_data (file_item->direct_in,
+                                       file_item->direct_in_len) ?
+                          GPGME_PROTOCOL_CMS : GPGME_PROTOCOL_OpenPGP);
+    }
+  else
+    {
+      const char *filename = file_item->filename_in;
+
+      fd = gpa_open_input (filename, &data, GPA_OPERATION (op)->window);
+      if (fd == -1)
+        return FALSE;
+
+      gpgme_set_protocol (GPA_OPERATION (op)->context->ctx,
+                          is_cms_file (filename) ?
+                          GPGME_PROTOCOL_CMS : GPGME_PROTOCOL_OpenPGP);
+    }
+
+
+  /* Start importing one file.  */
+  err = gpgme_op_import_start (GPA_OPERATION (op)->context->ctx, data);
+  if (err)
+    {
+      gpa_gpgme_warning (err);
+      return FALSE;
+    }
+
+  /* Show and update the progress dialog */
+  gtk_widget_show_all (GPA_FILE_OPERATION (op)->progress_dialog);
+  gpa_progress_dialog_set_label (GPA_PROGRESS_DIALOG
+				 (GPA_FILE_OPERATION (op)->progress_dialog),
+				 file_item->direct_name
+				 ? file_item->direct_name
+				 : file_item->filename_in);
+
+  return TRUE;
+}
+
+
+static void
+gpa_file_import_operation_next (GpaFileImportOperation *op)
+{
+  if (!GPA_FILE_OPERATION (op)->current
+      || !proc_one_file (op, GPA_FILE_OPERATION (op)->current->data))
+    {
+      /* Finished all files.  */
+      gtk_widget_hide (GPA_FILE_OPERATION (op)->progress_dialog);
+      if (op->counters.imported > 0)
+        {
+          if (op->counters.secret_imported)
+            g_signal_emit_by_name (GPA_OPERATION (op), "imported_secret_keys");
+          else
+            g_signal_emit_by_name (GPA_OPERATION (op), "imported_keys");
+	}
+      gpa_gpgme_show_import_results (GPA_OPERATION (op)->window, &op->counters);
+    }
+}
+
+
+static gboolean
+gpa_file_import_operation_idle_cb (gpointer data)
+{
+  GpaFileImportOperation *op = data;
+
+  gpa_file_import_operation_next (op);
+
+  return FALSE;
+}
+
+
+static void
+gpa_file_import_operation_done_cb (GpaContext *context,
+                                   gpg_error_t err,
+                                   GpaFileImportOperation *op)
+{
+  if (err)
+    {
+      gpa_gpgme_update_import_results (&op->counters, 1, 1, NULL);
+    }
+  else
+    {
+      gpgme_import_result_t res;
+
+      res = gpgme_op_import_result (GPA_OPERATION (op)->context->ctx);
+      gpa_gpgme_update_import_results (&op->counters, 1, 0, res);
+
+    }
+
+  if (gpg_err_code (err) != GPG_ERR_CANCELED)
+    {
+      /* Go to the next file in the list and import it.  */
+      GPA_FILE_OPERATION (op)->current = (g_list_next
+                                          (GPA_FILE_OPERATION (op)->current));
+      gpa_file_import_operation_next (op);
+    }
+}
+
+
+static void
+gpa_file_import_operation_done_error_cb (GpaContext *context, gpg_error_t err,
+					 GpaFileImportOperation *op)
+{
+  gpa_file_item_t file_item = GPA_FILE_OPERATION (op)->current->data;
+
+  /* FIXME: Add the errors to a list and show a dialog with all import
+     errors, similar to the verify status.  */
+  switch (gpg_err_code (err))
+    {
+    case GPG_ERR_NO_ERROR:
+    case GPG_ERR_CANCELED:
+      /* Ignore these */
+      break;
+
+    case GPG_ERR_NO_DATA:
+      gpa_show_warning (GPA_OPERATION (op)->window,
+                        file_item->direct_name
+                        ? _("\"%s\" contained no OpenPGP data.")
+                        : _("The file \"%s\" contained no OpenPGP"
+                            "data."),
+                        file_item->direct_name
+                        ? file_item->direct_name
+                        : file_item->filename_in);
+      break;
+
+    default:
+      gpa_show_warning (GPA_OPERATION (op)->window,
+                        _("Error importing \"%s\": %s <%s>"),
+                        file_item->direct_name
+                        ? file_item->direct_name
+                        : file_item->filename_in,
+                        gpg_strerror (err), gpg_strsource (err));
+      break;
+    }
+}
diff --git a/src/gpafileimportop.h b/src/gpafileimportop.h
new file mode 100644
index 0000000..8da190c
--- /dev/null
+++ b/src/gpafileimportop.h
@@ -0,0 +1,77 @@
+/* gpafileimportop.h - The GpaFileImportOperation object.
+ * Copyright (C) 2003 Miguel Coca.
+ * Copyright (C) 2014 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef GPA_FILE_IMPORT_OP_H
+#define GPA_FILE_IMPORT_OP_H
+
+#include <glib.h>
+#include <glib-object.h>
+#include "gpgmetools.h"
+#include "gpafileop.h"
+
+
+/* GObject stuff */
+#define GPA_FILE_IMPORT_OPERATION_TYPE	(gpa_file_import_operation_get_type ())
+
+#define GPA_FILE_IMPORT_OPERATION(obj)                                  \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPA_FILE_IMPORT_OPERATION_TYPE,   \
+                               GpaFileImportOperation))
+
+#define GPA_FILE_IMPORT_OPERATION_CLASS(klass)                          \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), GPA_FILE_IMPORT_OPERATION_TYPE,    \
+                            GpaFileImportOperationClass))
+
+#define GPA_IS_FILE_IMPORT_OPERATION(obj)                               \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPA_FILE_IMPORT_OPERATION_TYPE))
+
+#define GPA_IS_FILE_IMPORT_OPERATION_CLASS(klass)                       \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), GPA_FILE_IMPORT_OPERATION_TYPE))
+
+#define GPA_FILE_IMPORT_OPERATION_GET_CLASS(obj)                        \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), GPA_FILE_IMPORT_OPERATION_TYPE,    \
+                              GpaFileImportOperationClass))
+
+typedef struct _GpaFileImportOperation      GpaFileImportOperation;
+typedef struct _GpaFileImportOperationClass GpaFileImportOperationClass;
+
+struct _GpaFileImportOperation
+{
+  GpaFileOperation parent;
+
+  struct gpa_import_result_s counters;
+};
+
+
+struct _GpaFileImportOperationClass
+{
+  GpaFileOperationClass parent_class;
+};
+
+
+GType gpa_file_import_operation_get_type (void) G_GNUC_CONST;
+
+/* API */
+
+/* Creates a new import operation. */
+GpaFileImportOperation *
+gpa_file_import_operation_new (GtkWidget *window, GList *files);
+
+#endif
diff --git a/src/gpaimportop.c b/src/gpaimportop.c
index 6169952..15b38cd 100644
--- a/src/gpaimportop.c
+++ b/src/gpaimportop.c
@@ -26,6 +26,7 @@
 #include "gtktools.h"
 #include "gpaimportop.h"
 #include "filetype.h"
+#include "gpgmetools.h"
 
 static GObjectClass *parent_class = NULL;
 
@@ -208,36 +209,16 @@ gpa_import_operation_idle_cb (gpointer data)
 
 
 static void
-key_import_results_dialog_run (GtkWidget *parent,
-			       gpgme_import_result_t info)
-{
-  GtkWidget *dialog;
-
-  if (info->considered == 0)
-    gpa_show_warning (parent, _("No keys were found."));
-  else
-    gpa_show_info (parent,
-                   _("%i public keys read\n"
-                     "%i public keys imported\n"
-                     "%i public keys unchanged\n"
-                     "%i secret keys read\n"
-                     "%i secret keys imported\n"
-                     "%i secret keys unchanged"),
-                   info->considered, info->imported,
-                   info->unchanged, info->secret_read,
-                   info->secret_imported,
-                   info->secret_unchanged);
-}
-
-
-static void
 gpa_import_operation_done_cb (GpaContext *context, gpg_error_t err,
 			      GpaImportOperation *op)
 {
   if (! err)
     {
+      struct gpa_import_result_s result;
       gpgme_import_result_t res;
 
+      memset (&result, 0, sizeof result);
+
       GPA_IMPORT_OPERATION_GET_CLASS (op)->complete_import (op);
 
       res = gpgme_op_import_result (GPA_OPERATION (op)->context->ctx);
@@ -249,7 +230,9 @@ gpa_import_operation_done_cb (GpaContext *context, gpg_error_t err,
 	{
 	  g_signal_emit_by_name (GPA_OPERATION (op), "imported_keys");
 	}
-      key_import_results_dialog_run (GPA_OPERATION (op)->window, res);
+
+      gpa_gpgme_update_import_results (&result, 0, 0, res);
+      gpa_gpgme_show_import_results (GPA_OPERATION (op)->window, &result);
     }
   g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
 }
diff --git a/src/gpgmetools.c b/src/gpgmetools.c
index 3b2eba9..e2e6ec1 100644
--- a/src/gpgmetools.c
+++ b/src/gpgmetools.c
@@ -1219,6 +1219,73 @@ gpa_get_key_capabilities_text (gpgme_key_t key)
 }
 
 
+/* Update the result structure RESULT using the gpgme result INFO and
+   the FILES and BAD_FILES counter.  */
+void
+gpa_gpgme_update_import_results (gpa_import_result_t result,
+                                 unsigned int files, unsigned int bad_files,
+                                 gpgme_import_result_t info)
+{
+  result->files     += files;
+  result->bad_files += bad_files;
+  if (info)
+    {
+      result->considered       += info->considered;
+      result->imported         += info->imported;
+      result->unchanged        += info->unchanged;
+      result->secret_read      += info->secret_read;
+      result->secret_imported  += info->secret_imported;
+      result->secret_unchanged += info->secret_unchanged;
+    }
+}
+
+
+void
+gpa_gpgme_show_import_results (GtkWidget *parent, gpa_import_result_t result)
+{
+  char *buf1, *buf2;
+
+  if (result->files)
+    buf2 = g_strdup_printf (_("%u file(s) read\n"
+                              "%u file(s) with errors"),
+                            result->files,
+                            result->bad_files);
+  else
+    buf2 = NULL;
+
+
+  if (!result->considered)
+    gpa_show_warning (parent, "%s%s%s",
+                      _("No keys were found."),
+                      buf2? "\n":"",
+                      buf2? buf2:"");
+  else
+    {
+      buf1 = g_strdup_printf (_("%i public keys read\n"
+                                "%i public keys imported\n"
+                                "%i public keys unchanged\n"
+                                "%i secret keys read\n"
+                                "%i secret keys imported\n"
+                                "%i secret keys unchanged"),
+                              result->considered,
+                              result->imported,
+                              result->unchanged,
+                              result->secret_read,
+                              result->secret_imported,
+                              result->secret_unchanged);
+
+      gpa_show_info (parent,
+                     "%s%s%s",
+                     buf1,
+                     buf2? "\n":"",
+                     buf2? buf2:"");
+      g_free (buf1);
+    }
+
+  g_free (buf2);
+}
+
+
 /* Return a copy of the key array.  */
 gpgme_key_t *
 gpa_gpgme_copy_keyarray (gpgme_key_t *keys)
@@ -1244,7 +1311,7 @@ gpa_gpgme_copy_keyarray (gpgme_key_t *keys)
 }
 
 
-/* Release all keys in the array KEYS as weel as ARRY itself.  */
+/* Release all keys in the array KEYS as well as ARRAY itself.  */
 void
 gpa_gpgme_release_keyarray (gpgme_key_t *keys)
 {
diff --git a/src/gpgmetools.h b/src/gpgmetools.h
index c6d4885..1320f88 100644
--- a/src/gpgmetools.h
+++ b/src/gpgmetools.h
@@ -68,6 +68,25 @@ typedef struct
 } gpa_keygen_para_t;
 
 
+/* An object to collect information about key imports.  */
+struct gpa_import_result_s
+{
+  unsigned int files;     /* # of files imported.  */
+  unsigned int bad_files; /* # of files with errors.  */
+
+  /* To avoid breaking translated strings the variables below are int
+     and not unsigned int as they should be for counters.  */
+  int considered;
+  int imported;
+  int unchanged;
+  int secret_read;
+  int secret_imported;
+  int secret_unchanged;
+};
+typedef struct gpa_import_result_s *gpa_import_result_t;
+
+
+
 /* Report an unexpected error in GPGME and quit the application.
    Better to use the macro instead of the function.  */
 #define gpa_gpgme_error(err) \
@@ -142,6 +161,16 @@ const gchar *gpa_key_ownertrust_string (gpgme_key_t key);
 /* Key validity strings.  */
 const gchar *gpa_key_validity_string (gpgme_key_t key);
 
+/* Function to manage import results.  */
+void gpa_gpgme_update_import_results (gpa_import_result_t result,
+                                      unsigned int files,
+                                      unsigned int bad_files,
+                                      gpgme_import_result_t info);
+void gpa_gpgme_show_import_results (GtkWidget *parent,
+                                    gpa_import_result_t result);
+
+
+
 /* This is the function called by GPGME when it wants a
    passphrase.  */
 gpg_error_t gpa_passphrase_cb (void *hook, const char *uid_hint,
diff --git a/src/server.c b/src/server.c
index c7c7740..0c7209a 100644
--- a/src/server.c
+++ b/src/server.c
@@ -45,6 +45,7 @@
 #include "gpafilesignop.h"
 #include "gpafiledecryptop.h"
 #include "gpafileverifyop.h"
+#include "gpafileimportop.h"
 
 
 #define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
@@ -107,7 +108,6 @@ struct conn_ctrl_s
 
   /* The list of all files to be processed.  */
   GList *files;
-  gboolean files_finished;
 };
 
 
@@ -349,7 +349,6 @@ release_files (conn_ctrl_t ctrl)
   g_list_foreach (ctrl->files, (GFunc) free_file_item, NULL);
   g_list_free (ctrl->files);
   ctrl->files = NULL;
-  ctrl->files_finished = FALSE;
 }
 
 
@@ -1261,22 +1260,24 @@ cmd_getinfo (assuan_context_t ctx, char *line)
 }
 
 

-/* FILE <file> [--continued]
-
-   Set the files on which to operate.
- */
+static const char hlp_file[] =
+  "FILE [--clear] <file>\n"
+  "\n"
+  "Add FILE to the list of files on which to operate.\n"
+  "With --clear given, that list is first cleared.";
 static gpg_error_t
 cmd_file (assuan_context_t ctx, char *line)
 {
   gpg_error_t err = 0;
   conn_ctrl_t ctrl = assuan_get_pointer (ctx);
-  gboolean continued;
+  gboolean clear;
   gpa_file_item_t file_item;
   char *tail;
 
-  continued = has_option (line, "--continued");
+  clear = has_option (line, "--clear");
+  line = skip_options (line);
 
-  if (ctrl->files_finished)
+  if (clear)
     release_files (ctrl);
 
   tail = line;
@@ -1289,13 +1290,12 @@ cmd_file (assuan_context_t ctx, char *line)
   file_item->filename_in = g_strdup (line);
   ctrl->files = g_list_append (ctrl->files, file_item);
 
-  if (! continued)
-    ctrl->files_finished = TRUE;
-
   return assuan_process_done (ctx, err);
 }
 
 

+/* Encrypt or sign files.  If neither ENCR nor SIGN is set, import
+   files. */
 static gpg_error_t
 impl_encrypt_sign_files (assuan_context_t ctx, int encr, int sign)
 {
@@ -1308,11 +1308,6 @@ impl_encrypt_sign_files (assuan_context_t ctx, int encr, int sign)
       err = set_error (GPG_ERR_ASS_SYNTAX, "no files specified");
       return assuan_process_done (ctx, err);
     }
-  else if (! ctrl->files_finished)
-    {
-      err = set_error (GPG_ERR_ASS_SYNTAX, "more files expected");
-      return assuan_process_done (ctx, err);
-    }
 
   /* FIXME: Needs a root window.  Need to set "sign" default.  */
   if (encr && sign)
@@ -1321,13 +1316,15 @@ impl_encrypt_sign_files (assuan_context_t ctx, int encr, int sign)
   else if (encr)
     op = (GpaFileOperation *)
       gpa_file_encrypt_operation_new (NULL, ctrl->files, FALSE);
-  else
+  else if (sign)
     op = (GpaFileOperation *)
       gpa_file_sign_operation_new (NULL, ctrl->files, FALSE);
+  else
+    op = (GpaFileOperation *)
+      gpa_file_import_operation_new (NULL, ctrl->files);
 
   /* Ownership of CTRL->files was passed to callee.  */
   ctrl->files = NULL;
-  ctrl->files_finished = FALSE;
   g_signal_connect (G_OBJECT (op), "completed",
 		    G_CALLBACK (g_object_unref), NULL);
 
@@ -1416,11 +1413,6 @@ impl_decrypt_verify_files (assuan_context_t ctx, int decrypt, int verify)
       err = set_error (GPG_ERR_ASS_SYNTAX, "no files specified");
       return assuan_process_done (ctx, err);
     }
-  else if (! ctrl->files_finished)
-    {
-      err = set_error (GPG_ERR_ASS_SYNTAX, "more files expected");
-      return assuan_process_done (ctx, err);
-    }
 
   /* FIXME: Needs a root window.  Need to enable "verify".  */
   if (decrypt && verify)
@@ -1435,7 +1427,6 @@ impl_decrypt_verify_files (assuan_context_t ctx, int decrypt, int verify)
 
   /* Ownership of CTRL->files was passed to callee.  */
   ctrl->files = NULL;
-  ctrl->files_finished = FALSE;
   g_signal_connect (G_OBJECT (op), "completed",
 		    G_CALLBACK (g_object_unref), NULL);
 
@@ -1531,10 +1522,10 @@ cmd_import_files (assuan_context_t ctx, char *line)
       return assuan_process_done (ctx, err);
     }
 
-  err = set_error (GPG_ERR_NOT_IMPLEMENTED, "not implemented");
-  return assuan_process_done (ctx, err);
+  return impl_encrypt_sign_files (ctx, 0, 0);
 }
 
+
 

 /* CHECKSUM_CREATE_FILES --nohup  */
 static gpg_error_t
@@ -1670,7 +1661,7 @@ register_commands (assuan_context_t ctx)
 #endif /*ENABLE_CARD_MANAGER*/
     { "START_CONFDIALOG", cmd_start_confdialog, hlp_start_confdialog },
     { "GETINFO", cmd_getinfo, hlp_getinfo },
-    { "FILE", cmd_file },
+    { "FILE", cmd_file, hlp_file },
     { "ENCRYPT_FILES", cmd_encrypt_files },
     { "SIGN_FILES", cmd_sign_files },
     { "ENCRYPT_SIGN_FILES", cmd_encrypt_sign_files },

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

Summary of changes:
 po/de.po              |  105 ++++++++++-------
 src/Makefile.am       |    1 +
 src/gpafileimportop.c |  311 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/gpafileimportop.h |   77 ++++++++++++
 src/gpaimportop.c     |   31 ++---
 src/gpgmetools.c      |   69 ++++++++++-
 src/gpgmetools.h      |   29 +++++
 src/server.c          |   47 +++-----
 8 files changed, 574 insertions(+), 96 deletions(-)
 create mode 100644 src/gpafileimportop.c
 create mode 100644 src/gpafileimportop.h


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




More information about the Gnupg-commits mailing list