[svn] GnuPG - r5108 - trunk/g10

svn author wk cvs at cvs.gnupg.org
Wed Aug 5 15:48:24 CEST 2009


Author: wk
Date: 2009-08-05 15:48:23 +0200 (Wed, 05 Aug 2009)
New Revision: 5108

Modified:
   trunk/g10/ChangeLog
   trunk/g10/call-agent.c
   trunk/g10/card-util.c
Log:
Enable readline support in --card-edit.
better cope with re-inserted cards.


Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2009-08-05 11:24:43 UTC (rev 5107)
+++ trunk/g10/ChangeLog	2009-08-05 13:48:23 UTC (rev 5108)
@@ -1,5 +1,9 @@
 2009-08-05  Werner Koch  <wk at g10code.com>
 
+	* card-util.c: Enable readline support also in GnuPG-2.
+	
+	* call-agent.c (agent_learn): Always select the card first.
+
 	* gpg.c: Add --key-edit alias.
 
 	* call-agent.c (scd_genkey_cb): Forward progress status lines.

Modified: trunk/g10/call-agent.c
===================================================================
--- trunk/g10/call-agent.c	2009-08-05 11:24:43 UTC (rev 5107)
+++ trunk/g10/call-agent.c	2009-08-05 13:48:23 UTC (rev 5108)
@@ -458,6 +458,19 @@
   if (rc)
     return rc;
 
+  /* Send the serialno command to initialize the connection.  We don't
+     care about the data returned.  If the card has already been
+     initialized, this is a very fast command.  The main reason we
+     need to do this here is to handle a card removed case so that an
+     "l" command in --card-edit can be used to show ta newly inserted
+     card.  We request the openpgp card because that is what we
+     expect. */
+  rc = assuan_transact (agent_ctx, "SCD SERIALNO openpgp",
+                        NULL, NULL, NULL, NULL, NULL, NULL);
+  if (rc)
+    return rc;
+
+
   memset (info, 0, sizeof *info);
   rc = assuan_transact (agent_ctx, "SCD LEARN --force",
                         dummy_data_cb, NULL, default_inq_cb, NULL,

Modified: trunk/g10/card-util.c
===================================================================
--- trunk/g10/card-util.c	2009-08-05 11:24:43 UTC (rev 5107)
+++ trunk/g10/card-util.c	2009-08-05 13:48:23 UTC (rev 5108)
@@ -23,6 +23,10 @@
 #include <string.h>
 #include <errno.h>
 #include <assert.h>
+#ifdef HAVE_LIBREADLINE
+# define GNUPG_LIBREADLINE_H_INCLUDED
+# include <readline/readline.h>
+#endif /*HAVE_LIBREADLINE*/
 
 #if GNUPG_MAJOR_VERSION != 1
 # include "gpg.h"
@@ -34,12 +38,8 @@
 #include "options.h"
 #include "main.h"
 #include "keyserver-internal.h"
+
 #if GNUPG_MAJOR_VERSION == 1
-# ifdef HAVE_LIBREADLINE
-# define GNUPG_LIBREADLINE_H_INCLUDED
-# include <stdio.h>
-# include <readline/readline.h>
-# endif /*HAVE_LIBREADLINE*/
 # include "cardglue.h"
 #else /*GNUPG_MAJOR_VERSION!=1*/
 # include "call-agent.h"
@@ -1704,7 +1704,7 @@
   };
 
 
-#if GNUPG_MAJOR_VERSION == 1 && defined (HAVE_LIBREADLINE)
+#ifdef HAVE_LIBREADLINE
 
 /* These two functions are used by readline for command completion. */
 
@@ -1737,6 +1737,7 @@
 static char **
 card_edit_completion(const char *text, int start, int end)
 {
+  (void)end;
   /* If we are at the start of a line, we try and command-complete.
      If not, just do nothing for now. */
 
@@ -1747,7 +1748,7 @@
 
   return NULL;
 }
-#endif /* GNUPG_MAJOR_VERSION == 1 && HAVE_LIBREADLINE */
+#endif /*HAVE_LIBREADLINE*/
 
 /* Menu to edit all user changeable values on an OpenPGP card.  Only
    Key creation is not handled here. */
@@ -1815,15 +1816,11 @@
 
 	    if (!have_commands)
               {
-#if GNUPG_MAJOR_VERSION == 1
 		tty_enable_completion (card_edit_completion);
-#endif
 		answer = cpr_get_no_help("cardedit.prompt", _("Command> "));
 		cpr_kill_prompt();
-#if GNUPG_MAJOR_VERSION == 1
 		tty_disable_completion ();
-#endif
-	    }
+              }
 	    trim_spaces(answer);
 	}
       while ( *answer == '#' );




More information about the Gnupg-commits mailing list