[svn] GnuPG - r5267 - trunk/agent

svn author wk cvs at cvs.gnupg.org
Wed Feb 17 20:03:38 CET 2010


Author: wk
Date: 2010-02-17 20:03:37 +0100 (Wed, 17 Feb 2010)
New Revision: 5267

Modified:
   trunk/agent/ChangeLog
   trunk/agent/call-pinentry.c
Log:
Provide default strings for the pinentry.


Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2010-02-17 19:00:04 UTC (rev 5266)
+++ trunk/agent/ChangeLog	2010-02-17 19:03:37 UTC (rev 5267)
@@ -1,3 +1,8 @@
+2010-02-17  Werner Koch  <wk at g10code.com>
+
+	* call-pinentry.c (start_pinentry): Always free OPTSTR.  Send
+	default-xxx strings.
+
 2010-01-26  Werner Koch  <wk at g10code.com>
 
 	* protect.c (do_encryption): Encode the s2kcount and no not use a

Modified: trunk/agent/call-pinentry.c
===================================================================
--- trunk/agent/call-pinentry.c	2010-02-17 19:00:04 UTC (rev 5266)
+++ trunk/agent/call-pinentry.c	2010-02-17 19:03:37 UTC (rev 5267)
@@ -1,5 +1,6 @@
-/* call-pinentry.c - fork of the pinentry to query stuff from the user
- * Copyright (C) 2001, 2002, 2004, 2007, 2008 Free Software Foundation, Inc.
+/* call-pinentry.c - Spawn the pinentry to query stuff from the user
+ * Copyright (C) 2001, 2002, 2004, 2007, 2008,
+ *               2010  Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -361,6 +362,7 @@
 	return unlock_pinentry (out_of_core ());
       rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
 			    NULL);
+      xfree (optstr);
       if (rc)
 	return unlock_pinentry (rc);
     }
@@ -371,6 +373,7 @@
 	return unlock_pinentry (out_of_core ());
       rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
 			    NULL);
+      xfree (optstr);
       if (rc)
 	return unlock_pinentry (rc);
     }
@@ -381,10 +384,37 @@
 	return unlock_pinentry (out_of_core ());
       rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
 			    NULL);
+      xfree (optstr);
       if (rc)
 	return unlock_pinentry (rc);
     }
 
+  {
+    /* Provide a few default strings for use by the pinentries.  This
+       may help a pinentry to avoid implementing localization code.  */
+    static struct { const char *key, *value; } tbl[] = {
+      /* TRANSLATORS: These are labels for buttons etc used in
+         Pinentries.  A underscore indicates that the next letter
+         should be used as an accelerator.  The actual to be
+         translated text starts after the second vertical bar.  */
+      { "ok",     N_("|pinentry-label|_OK") },
+      { "cancel", N_("|pinentry-label|_Cancel") },
+      { NULL, NULL}
+    };
+    char *optstr;
+    int idx;
+
+    for (idx=0; tbl[idx].key; idx++)
+      {
+        if (asprintf (&optstr, "OPTION default-ok=%s",
+                      tbl[idx].key, _(tbl[idx].value)) < 0 )
+          return unlock_pinentry (out_of_core ());
+        assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
+                         NULL);
+        xfree (optstr);
+      }
+  }
+
   
   /* Tell the pinentry the name of a file it shall touch after having
      messed with the tty.  This is optional and only supported by
@@ -923,7 +953,7 @@
   if (notok)
     {
       /* Try to use the newer NOTOK feature if a cancel button is
-         requested.  If no cacnel button is requested we keep on using
+         requested.  If no cancel button is requested we keep on using
          the standard cancel.  */
       if (with_cancel)
         {




More information about the Gnupg-commits mailing list