[svn] pinentry - r216 - in trunk: . pinentry

svn author wk cvs at cvs.gnupg.org
Wed Feb 17 19:58:39 CET 2010


Author: wk
Date: 2010-02-17 19:58:39 +0100 (Wed, 17 Feb 2010)
New Revision: 216

Modified:
   trunk/ChangeLog
   trunk/pinentry/pinentry-curses.c
   trunk/pinentry/pinentry.c
   trunk/pinentry/pinentry.h
Log:
Provide default strings for ok and cancel in case a GUI wants it.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-02-16 19:05:59 UTC (rev 215)
+++ trunk/ChangeLog	2010-02-17 18:58:39 UTC (rev 216)
@@ -1,3 +1,11 @@
+2010-02-17  Werner Koch  <wk at g10code.com>
+
+	* pinentry/pinentry.h (struct pinentry): Add default_ok and
+	default_cancel.
+	* pinentry/pinentry.c (noprefix_strdup): New.
+	(option_handler): Support "default-ok" and "default-cancel".
+	(strcpy_escaped): Change second arg from unsigend char to char.
+
 2010-02-16  Werner Koch  <wk at g10code.com>
 
 	* qt4/document-encrypt.png, qt4/gtk-cancel.png, qt4/gtk-ok.png: New.

Modified: trunk/pinentry/pinentry-curses.c
===================================================================
--- trunk/pinentry/pinentry-curses.c	2010-02-16 19:05:59 UTC (rev 215)
+++ trunk/pinentry/pinentry-curses.c	2010-02-17 18:58:39 UTC (rev 216)
@@ -44,6 +44,9 @@
 
 #include "pinentry.h"
 
+/* FIXME: We should allow configuration of these button labels and in
+   any case use the default_ok, default_cancel values if available.
+   However, I have no clue about curses and localization.  */
 #define STRING_OK "<OK>"
 #define STRING_NOTOK "<No>"
 #define STRING_CANCEL "<Cancel>"

Modified: trunk/pinentry/pinentry.c
===================================================================
--- trunk/pinentry/pinentry.c	2010-02-16 19:05:59 UTC (rev 215)
+++ trunk/pinentry/pinentry.c	2010-02-17 18:58:39 UTC (rev 216)
@@ -1,5 +1,5 @@
 /* pinentry.c - The PIN entry support library
-   Copyright (C) 2002, 2003, 2007, 2008 g10 Code GmbH
+   Copyright (C) 2002, 2003, 2007, 2008, 2010 g10 Code GmbH
    
    This file is part of PINENTRY.
    
@@ -80,7 +80,9 @@
     PINENTRY_COLOR_DEFAULT,
     PINENTRY_COLOR_DEFAULT,
     0,
-    NULL        /* Assuan context.  */
+    NULL,        /* default_ok  */
+    NULL,        /* default_cancel  */
+    NULL         /* Assuan context.  */
   };
 
 
@@ -578,6 +580,20 @@
 }
 
 
+static char *
+noprefix_strdup (const char *string)
+{
+  const char *s;
+
+  if (*string == '|' && (s = strchr (string+1, '|')))
+    s++;
+  else
+    s = string;
+
+  return strdup (s);
+}
+
+
 static int
 option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
 {
@@ -645,6 +661,18 @@
       if (!pinentry.touch_file)
 	return ASSUAN_Out_Of_Core;
     }
+  else if (!strcmp (key, "default-ok"))
+    {
+      pinentry.default_ok = noprefix_strdup (value);
+      if (!pinentry.default_ok)
+	return ASSUAN_Out_Of_Core;
+    }
+  else if (!strcmp (key, "default-cancel"))
+    {
+      pinentry.default_cancel = noprefix_strdup (value);
+      if (!pinentry.default_cancel)
+	return ASSUAN_Out_Of_Core;
+    }
   else
     return ASSUAN_Invalid_Option;
   return 0;
@@ -654,7 +682,7 @@
 /* Note, that it is sufficient to allocate the target string D as
    long as the source string S, i.e.: strlen(s)+1; */
 static void
-strcpy_escaped (char *d, const unsigned char *s)
+strcpy_escaped (char *d, const char *s)
 {
   while (*s)
     {

Modified: trunk/pinentry/pinentry.h
===================================================================
--- trunk/pinentry/pinentry.h	2010-02-16 19:05:59 UTC (rev 215)
+++ trunk/pinentry/pinentry.h	2010-02-17 18:58:39 UTC (rev 216)
@@ -1,5 +1,5 @@
 /* pinentry.h - The interface for the PIN entry support library.
-   Copyright (C) 2002, 2003 g10 Code GmbH
+   Copyright (C) 2002, 2003, 2010 g10 Code GmbH
    
    This file is part of PINENTRY.
    
@@ -14,9 +14,8 @@
    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  */
+   along with this program; if not, see <http://www.gnu.org/licenses/>. 
+ */
 
 #ifndef PINENTRY_H
 #define PINENTRY_H
@@ -120,9 +119,16 @@
   pinentry_color_t color_so;
   int color_so_bright;
 
-  /* Fo the quality indicator we need to do an inquiry.  Thus we need
+  /* Malloced and i18ned default strings or NULL.  These strings may
+     include an underscore character to indicate an accelerator
+     key.  */
+  char *default_ok;
+  char *default_cancel;
+
+  /* For the quality indicator we need to do an inquiry.  Thus we need
      to save the assuan ctx.  */
   void *ctx_assuan;
+
 };
 typedef struct pinentry *pinentry_t;
 




More information about the Gnupg-commits mailing list