1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Allow configuraton of pinentry tooltip.

Other minor buf fixes.
This commit is contained in:
Werner Koch 2007-12-04 11:23:31 +00:00
parent a9b7f3356b
commit 8c20500a5d
44 changed files with 7277 additions and 5746 deletions

View File

@ -46,7 +46,8 @@ Ivo Timmermans <itimmermans@bigfoot.com> Translations [nl]
Jacobo Tarri'o Barreiro <jtarrio@iname.com> Translations [gl]
Janusz Aleksander Urbanowicz <alex@bofh.torun.pl> Translations [po]
Janusz Aleksander Urbanowicz <alex@bofh.torun.pl> Translations [pl]
Jakub Bogusz <qboosh@pld-linux.org> Translations [pl]
Jedi Lin <Jedi@idej.org> Translations [zh-tw]

View File

@ -1,3 +1,7 @@
2007-12-03 Werner Koch <wk@g10code.com>
* configure.ac: Add test gt_LC_MESSAGES..
2007-10-01 Werner Koch <wk@g10code.com>
* configure.ac: Require assuan 1.0.4.

View File

@ -1,3 +1,7 @@
2007-12-04 Werner Koch <wk@g10code.com>
* call-pinentry.c (agent_askpin): Use gnupg_get_help_string.
2007-12-03 Werner Koch <wk@g10code.com>
* gpg-agent.c (main): s/standard_socket/use_standard_socket/ for

View File

@ -578,7 +578,7 @@ agent_askpin (ctrl_t ctrl,
to the pinentry. */
if (pininfo->with_qualitybar && opt.min_passphrase_len )
{
char *tmpstr;
char *tmpstr, *tmpstr2;
const char *tooltip;
/* TRANSLATORS: This string is displayed by pinentry as the
@ -595,21 +595,25 @@ agent_askpin (ctrl_t ctrl,
else if (rc)
return unlock_pinentry (rc);
/* TRANSLATORS: This string is a tooltip, shown by pinentry when
hovering over the quality bar. Please use an appropriate
string to describe what this is about. The length of the
tooltip is limited to about 900 characters. If you do not
translate this entry, a default english text (see source)
will be used. */
tooltip = _("pinentry.qualitybar.tooltip");
if (!strcmp ("pinentry.qualitybar.tooltip", tooltip))
tooltip = ("The quality of the text entered above.\n"
"Please ask your administrator for "
"details about the criteria.");
/* Fixme: As soon as we have the extended error reporting
facility (audit log), we can use a user specified helptext if
that has been configured. */
tmpstr2 = gnupg_get_help_string ("pinentry.qualitybar.tooltip");
if (tmpstr2)
tooltip = tmpstr2;
else
{
/* TRANSLATORS: This string is a tooltip, shown by pinentry
when hovering over the quality bar. Please use an
appropriate string to describe what this is about. The
length of the tooltip is limited to about 900 characters.
If you do not translate this entry, a default english
text (see source) will be used. */
tooltip = _("pinentry.qualitybar.tooltip");
if (!strcmp ("pinentry.qualitybar.tooltip", tooltip))
tooltip = ("The quality of the text entered above.\n"
"Please ask your administrator for "
"details about the criteria.");
}
tmpstr = try_percent_escape (tooltip, "\t\r\n\f\v");
xfree (tmpstr2);
snprintf (line, DIM(line)-1, "SETQUALITYBAR_TT %s", tmpstr? tmpstr:"");
line[DIM(line)-1] = 0;
xfree (tmpstr);

View File

@ -1,4 +1,12 @@
2007-12-03 Werner Koch <wk@g10code.com>
2007-12-04 Werner Koch <wk@g10code.com>
* Makefile.am (t_helpfile_LDADD, module_maint_tests): New.
* t-helpfile.c: New.
* helpfile.c: New.
* membuf.h (is_membuf_ready, MEMBUF_ZERO): New.
* localename.c: New. Taken from gettext with modifications as done
for GpgOL. Export one new function.
* util.h (gnupg_messages_locale_name, gnupg_get_help_string): Added.
* sysutils.c (gnupg_reopen_std): New. Taken from ../g10/gpg.c.

View File

@ -22,7 +22,7 @@ EXTRA_DIST = mkstrtable.awk exaudit.awk exstatus.awk \
audit-events.h status-codes.h
noinst_LIBRARIES = libcommon.a libcommonpth.a libsimple-pwquery.a libgpgrl.a
noinst_PROGRAMS = $(module_tests)
noinst_PROGRAMS = $(module_tests) $(module_maint_tests)
TESTS = $(module_tests)
BUILT_SOURCES = audit-events.h status-codes.h
@ -66,7 +66,9 @@ common_sources = \
srv.h \
dns-cert.c dns-cert.h \
pka.c pka.h \
http.c http.h
http.c http.h \
localename.c \
helpfile.c
@ -106,6 +108,7 @@ status-codes.h: Makefile mkstrtable.awk exstatus.awk status.h
# Module tests
#
module_tests = t-convert t-gettime t-sysutils
module_maint_tests = t-helpfile
t_common_ldadd = libcommon.a ../jnlib/libjnlib.a ../gl/libgnu.a \
$(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV)
@ -113,6 +116,6 @@ t_common_ldadd = libcommon.a ../jnlib/libjnlib.a ../gl/libgnu.a \
t_convert_LDADD = $(t_common_ldadd)
t_gettime_LDADD = $(t_common_ldadd)
t_sysutils_LDADD = $(t_common_ldadd)
t_helpfile_LDADD = $(t_common_ldadd)

254
common/helpfile.c Normal file
View File

@ -0,0 +1,254 @@
/* helpfile.c - GnuPG's helpfile feature
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG 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.
*
* GnuPG 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/>.
*/
#include <config.h>
#include <stdlib.h>
#include "util.h"
#include "i18n.h"
#include "membuf.h"
/* Try to find KEY in the file FNAME. */
static char *
findkey_fname (const char *key, const char *fname)
{
gpg_error_t err = 0;
FILE *fp;
int lnr = 0;
int c;
char *p, line[256];
int in_item = 0;
membuf_t mb = MEMBUF_ZERO;
fp = fopen (fname, "r");
if (!fp)
{
if (errno != ENOENT)
{
err = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"), fname, gpg_strerror (err));
}
return NULL;
}
while (fgets (line, DIM(line)-1, fp))
{
lnr++;
if (!*line || line[strlen(line)-1] != '\n')
{
/* Eat until end of line. */
while ( (c=getc (fp)) != EOF && c != '\n')
;
err = gpg_error (*line? GPG_ERR_LINE_TOO_LONG
: GPG_ERR_INCOMPLETE_LINE);
log_error (_("file `%s', line %d: %s\n"),
fname, lnr, gpg_strerror (err));
}
else
line[strlen(line)-1] = 0; /* Chop the LF. */
again:
if (!in_item)
{
/* Allow for empty lines and spaces while not in an item. */
for (p=line; spacep (p); p++)
;
if (!*p || *p == '#')
continue;
if (*line != '.' || spacep(line+1))
{
log_info (_("file `%s', line %d: %s\n"),
fname, lnr, _("ignoring garbage line"));
continue;
}
trim_trailing_spaces (line);
in_item = 1;
if (!strcmp (line+1, key))
{
/* Found. Start collecting. */
init_membuf (&mb, 1024);
}
continue;
}
/* If in an item only allow for comments in the first column
and provide ". " as an escape sequence to allow for
leading dots and hash marks in the actual text. */
if (*line == '#')
continue;
if (*line == '.')
{
if (spacep(line+1))
p = line + 2;
else
{
trim_trailing_spaces (line);
in_item = 0;
if (is_membuf_ready (&mb))
break; /* Yep, found and collected the item. */
if (!line[1])
continue; /* Just an end of text dot. */
goto again; /* A new key line. */
}
}
else
p = line;
if (is_membuf_ready (&mb))
{
put_membuf_str (&mb, p);
put_membuf (&mb, "\n", 1);
}
}
if ( !err && ferror (fp) )
{
err = gpg_error_from_syserror ();
log_error (_("error reading `%s', line %d: %s\n"),
fname, lnr, gpg_strerror (err));
}
fclose (fp);
if (is_membuf_ready (&mb))
{
/* We have collected something. */
if (err)
{
xfree (get_membuf (&mb, NULL));
return NULL;
}
else
{
put_membuf (&mb, "", 1); /* Terminate string. */
return get_membuf (&mb, NULL);
}
}
else
return NULL;
}
/* Try the help files depending on the locale. */
static char *
findkey_locale (const char *key, const char *locname, const char *dirname)
{
const char *s;
char *fname, *ext, *p;
char *result;
fname = xtrymalloc (strlen (dirname) + 6 + strlen (locname) + 4 + 1);
if (!fname)
return NULL;
ext = stpcpy (stpcpy (fname, dirname), "/help.");
/* Search with locale name and territory. ("help.LL_TT.txt") */
if (strchr (locname, '_'))
{
strcpy (stpcpy (ext, locname), ".txt");
result = findkey_fname (key, fname);
}
else
result = NULL; /* No territory. */
if (!result)
{
/* Search with just the locale name - if any. ("help.LL.txt") */
if (*locname)
{
for (p=ext, s=locname; *s && *s != '_';)
*p++ = *s++;
strcpy (p, ".txt");
result = findkey_fname (key, fname);
}
else
result = NULL;
}
if (!result)
{
/* Last try: Search in file without any local info. ("help.txt") */
strcpy (ext, "txt");
result = findkey_fname (key, fname);
}
xfree (fname);
return result;
}
/* Return a malloced help text as identified by KEY. The system takes
the string from an UTF-8 encoded file to be created by an
administrator or as distributed with GnuPG. On a GNU or Unix
system the entry is searched in these files:
/etc/gnupg/help.LL.txt
/etc/gnupg/help.txt
/usr/share/gnupg/help.LL.txt
/usr/share/gnupg/help.txt
Here LL denotes the two digit language code of the current locale.
The help file needs to be encoded in UTF-8, lines with a '#' in the
first column are comment lines and entirely ignored. Help keys are
identified by a key consisting of a single word with a single dot
as the first character. All key lines listed without any
intervening lines (except for comment lines) lead to the same help
text. Lines following the key lines make up the actual hep texts.
*/
char *
gnupg_get_help_string (const char *key)
{
static const char *locname;
char *result;
if (!locname)
{
char *buffer, *p;
int count = 0;
const char *s = gnupg_messages_locale_name ();
buffer = xtrystrdup (s);
if (!buffer)
locname = "";
else
{
for (p = buffer; *p; p++)
if (*p == '.' || *p == '@' || *p == '/' /*(safeguard)*/)
*p = 0;
else if (*p == '_')
{
if (count++)
*p = 0; /* Altho cut at a underscore in the territory. */
}
locname = buffer;
}
}
if (!key || !*key)
return NULL;
result = findkey_locale (key, locname, gnupg_sysconfdir ());
if (!result)
result = findkey_locale (key, locname, gnupg_datadir ());
return result;
}

1044
common/localename.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,9 @@ struct private_membuf_s
typedef struct private_membuf_s membuf_t;
/* Return the current length of the membuf. */
#define get_membuf_len(a) ((a)->len)
#define get_membuf_len(a) ((a)->len)
#define is_membuf_ready(a) ((a)->buf || (a)->out_of_core)
#define MEMBUF_ZERO { 0, 0, NULL, 0}
void init_membuf (membuf_t *mb, int initiallen);
void init_membuf_secure (membuf_t *mb, int initiallen);

66
common/t-helpfile.c Normal file
View File

@ -0,0 +1,66 @@
/* t-helpfile.c - Module test for helpfile.c
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG 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.
*
* GnuPG 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/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
/* #define pass() do { ; } while(0) */
/* #define fail(a) do { fprintf (stderr, "%s:%d: test %d failed\n",\ */
/* __FILE__,__LINE__, (a)); \ */
/* errcount++; \ */
/* } while(0) */
static int verbose;
static int errcount;
int
main (int argc, char **argv)
{
char *result;
if (argc)
{ argc--; argv++; }
i18n_init ();
if (argc && !strcmp (argv[0], "--verbose"))
{
verbose = 1;
argc--; argv++;
}
result = gnupg_get_help_string (argc? argv[0]:NULL);
if (!result)
{
fprintf (stderr,
"Error: nothing found for `%s'\n", argc?argv[0]:"(null)");
errcount++;
}
else
{
printf ("key `%s' result=`%s'\n", argc?argv[0]:"(null)", result);
xfree (result);
}
return !!errcount;
}

View File

@ -199,6 +199,12 @@ const char *gnupg_module_name (int which);
/*-- gpgrlhelp.c --*/
void gnupg_rl_initialize (void);
/*-- helpfile.c --*/
char *gnupg_get_help_string (const char *key);
/*-- localename.c --*/
const char *gnupg_messages_locale_name (void);
/*-- miscellaneous.c --*/
/* This function is called at startup to tell libgcrypt to use our own

View File

@ -903,6 +903,10 @@ fi
# We use HAVE_LANGINFO_CODESET in a couple of places.
AM_LANGINFO_CODESET
# Checks required for our use locales
gt_LC_MESSAGES
#
# SELinux support
#
@ -1024,7 +1028,6 @@ gl_INIT
#
GNUPG_FUNC_MKDIR_TAKES_ONE_ARG
#
# Sanity check regex. Tests adapted from mutt.
#

View File

@ -1,3 +1,8 @@
2007-12-04 Werner Koch <wk@g10code.com>
* help.txt, help.de.txt: New online help files.
* Makefile.am (dist_pkgdata_DATA): Add them.
2007-11-19 Werner Koch <wk@g10code.com>
* gpg.texi (GPG Configuration Options): English Grammar fix.

View File

@ -33,7 +33,8 @@ BUILT_SOURCES = gnupg-card-architecture.eps gnupg-card-architecture.png \
info_TEXINFOS = gnupg.texi
dist_pkgdata_DATA = qualified.txt FAQ faq.html com-certs.pem
dist_pkgdata_DATA = qualified.txt FAQ faq.html com-certs.pem \
help.txt help.de.txt
gnupg_TEXINFOS = \
gpg.texi gpgsm.texi gpg-agent.texi scdaemon.texi instguide.texi \

41
doc/help.de.txt Normal file
View File

@ -0,0 +1,41 @@
# help.de.txt - German GnuPG online help
# Copyright (C) 2007 Free Software Foundation, Inc.
#
# This file is part of GnuPG.
#
# GnuPG 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.
#
# GnuPG 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/>.
# Die Datei help.txt beschreibt das verwendete Format.
# Diese Datei muß UTF-8 kodiert sein.
.#pinentry.qualitybar.tooltip
# Dies ist lediglich eine kommentiertes Beispiel. Es ist am sinnvolssten
# einen individuellen Text in /etc/gnupg/help.de.txt zu erstellen.
Die Qualität der Passphrase, die Sie oben eingegeben haben. Bitte
fragen sie Ihren Systembeauftragten nach den Kriterien für die Messung
der Qualität.
.
# Local variables:
# mode: fundamental
# coding: utf-8
# End:

68
doc/help.txt Normal file
View File

@ -0,0 +1,68 @@
# help.txt - English GnuPG online help
# Copyright (C) 2007 Free Software Foundation, Inc.
#
# This file is part of GnuPG.
#
# GnuPG 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.
#
# GnuPG 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/>.
# Note that this help file needs to be UTF-8 encoded. When looking
# for a help item, GnuPG scans the help files in the following order
# (assuming a GNU or Unix system):
#
# /etc/gnupg/help.LL_TT.txt
# /etc/gnupg/help.LL.txt
# /etc/gnupg/help.txt
# /usr/share/gnupg/help.LL_TT.txt
# /usr/share/gnupg/help.LL.txt
# /usr/share/gnupg/help.txt
#
# Here LL_TT denotes the full name of the current locale with the
# territory (.e.g. "de_DE"), LL denotes just the locale name
# (e.g. "de"). The first matching item is returned. To put a dot or
# a hash mark at the beginning of a help text line, it needs to be
# prefixed with ". ". A single dot may be used to terminated ahelp
# entry.
.#pinentry.qualitybar.tooltip
# [remove the hash mark from the key to enable this text]
# This entry is just an example on how to customize the tooltip shown
# when hovering over the quality bar of the pinentry. We don't
# install this text so that the hardcoded translation takes
# precedence. An administrator should write up a short help to tell
# the users about the configured passphrase constraints and save that
# to /etc/gnupg/help.txt.
This bar indicates the quality of the passphrase entered above.
As long as the bar is shown in red, GnuPG considers the passphrase too
weak to accept. Please ask your administrator for details about the
configured passphrase constraints.
.
# Local variables:
# mode: fundamental
# coding: utf-8
# End:

View File

@ -1,5 +1,8 @@
2007-12-03 Werner Koch <wk@g10code.com>
* keygen.c (ask_key_flags): Add a translation remark and implement
a workaround.
* gpg.c (reopen_std): Moved to ../common and renamed to
gnupg_reopen_std.

View File

@ -1533,13 +1533,27 @@ print_key_flags(int flags)
static unsigned int
ask_key_flags(int algo,int subkey)
{
/* TRANSLATORS: Please use only plain ASCII characters for the
translation. If this is not possible use single digits. The
string needs to 8 bytes long. Here is a description of the
functions:
s = Toggle signing capability
e = Toggle encryption capability
a = Toggle authentication capability
q = Finish
*/
const char *togglers=_("SsEeAaQq");
char *answer=NULL;
unsigned int current=0;
unsigned int possible=openpgp_pk_algo_usage(algo);
if(strlen(togglers)!=8)
BUG();
if ( strlen(togglers) != 7 )
{
tty_printf ("NOTE: Bad translation at %s:%d. "
"Please report.\n", __FILE__, __LINE__);
togglers = "11223300";
}
/* Only primary keys may certify. */
if(subkey)

440
po/be.po

File diff suppressed because it is too large Load Diff

440
po/ca.po

File diff suppressed because it is too large Load Diff

440
po/cs.po

File diff suppressed because it is too large Load Diff

440
po/da.po

File diff suppressed because it is too large Load Diff

440
po/de.po

File diff suppressed because it is too large Load Diff

440
po/el.po

File diff suppressed because it is too large Load Diff

440
po/eo.po

File diff suppressed because it is too large Load Diff

440
po/es.po

File diff suppressed because it is too large Load Diff

440
po/et.po

File diff suppressed because it is too large Load Diff

440
po/fi.po

File diff suppressed because it is too large Load Diff

440
po/fr.po

File diff suppressed because it is too large Load Diff

440
po/gl.po

File diff suppressed because it is too large Load Diff

440
po/hu.po

File diff suppressed because it is too large Load Diff

440
po/id.po

File diff suppressed because it is too large Load Diff

440
po/it.po

File diff suppressed because it is too large Load Diff

440
po/ja.po

File diff suppressed because it is too large Load Diff

440
po/nb.po

File diff suppressed because it is too large Load Diff

440
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

440
po/ro.po

File diff suppressed because it is too large Load Diff

440
po/ru.po

File diff suppressed because it is too large Load Diff

440
po/sk.po

File diff suppressed because it is too large Load Diff

440
po/sv.po

File diff suppressed because it is too large Load Diff

440
po/tr.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff