summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2002-08-21 13:11:04 +0200
committerWerner Koch <wk@gnupg.org>2002-08-21 13:11:04 +0200
commitcda3b913dbf23cab6829852022584fa510b57fa6 (patch)
treeeb6512398a06e17135e4204674f4c071b54061d0
parentuse setlocale(). (diff)
downloadgnupg2-cda3b913dbf23cab6829852022584fa510b57fa6.tar.xz
gnupg2-cda3b913dbf23cab6829852022584fa510b57fa6.zip
* query.c (agent_askpin): Hack to show the right default prompt.NEWPG-0-9-0
(agent_get_passphrase): Ditto. * Makefile.am: Renamed the binary protect-tool to gpg-protect-tool. * protect-tool.c: Removed the note about internal use only. * gpg-agent.c (main): New option --daemon so that the program is not accidently started in the background.
-rw-r--r--agent/ChangeLog5
-rw-r--r--agent/agent.h3
-rw-r--r--agent/genkey.c8
-rw-r--r--agent/gpg-agent.c6
-rw-r--r--agent/protect-tool.c6
-rw-r--r--agent/query.c36
6 files changed, 37 insertions, 27 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog
index f43014f66..0fbccc946 100644
--- a/agent/ChangeLog
+++ b/agent/ChangeLog
@@ -1,5 +1,10 @@
2002-08-21 Werner Koch <wk@gnupg.org>
+ * query.c (agent_askpin): Hack to show the right default prompt.
+ (agent_get_passphrase): Ditto.
+
+ * trans.c: Removed and replaced all usages with standard _()
+
* divert-scd.c (getpin_cb): Pass a more descritive text to the
pinentry.
diff --git a/agent/agent.h b/agent/agent.h
index 4446cf206..51ab19800 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -107,9 +107,6 @@ enum {
/*-- gpg-agent.c --*/
void agent_exit (int rc); /* also implemented in other tools */
-/*-- trans.c --*/
-const char *trans (const char *text);
-
/*-- command.c --*/
void start_command_handler (int, int);
diff --git a/agent/genkey.c b/agent/genkey.c
index 630e0e30d..dccac94da 100644
--- a/agent/genkey.c
+++ b/agent/genkey.c
@@ -27,7 +27,7 @@
#include <assert.h>
#include "agent.h"
-
+#include "i18n.h"
static int
store_key (GCRY_SEXP private, const char *passphrase)
@@ -79,7 +79,7 @@ reenter_compare_cb (struct pin_entry_info_s *pi)
if (!strcmp (pin1, pi->pin))
return 0; /* okay */
- pi->cb_errtext = trans ("does not match - try again");
+ pi->cb_errtext = _("does not match - try again");
return -1;
}
@@ -106,9 +106,9 @@ agent_genkey (CTRL ctrl, const char *keyparam, size_t keyparamlen,
/* Get the passphrase now, cause key generation may take a while. */
{
- const char *text1 = trans ("Please enter the passphrase to%0A"
+ const char *text1 = _("Please enter the passphrase to%0A"
"to protect your new key");
- const char *text2 = trans ("Please re-enter this passphrase");
+ const char *text2 = _("Please re-enter this passphrase");
pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
pi2 = pi + (sizeof *pi + 100);
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 79bd960ed..73569b8d6 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -173,9 +173,9 @@ i18n_init (void)
set_gettext_file( PACKAGE );
#else
#ifdef ENABLE_NLS
- /* gtk_set_locale (); HMMM: We have not yet called gtk_init */
- bindtextdomain( PACKAGE, LOCALEDIR );
- textdomain( PACKAGE );
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
#endif
#endif
}
diff --git a/agent/protect-tool.c b/agent/protect-tool.c
index b762437a8..1d706ea2b 100644
--- a/agent/protect-tool.c
+++ b/agent/protect-tool.c
@@ -133,9 +133,9 @@ i18n_init (void)
set_gettext_file( PACKAGE );
#else
#ifdef ENABLE_NLS
- /* gtk_set_locale (); HMMM: We have not yet called gtk_init */
- bindtextdomain( PACKAGE, LOCALEDIR );
- textdomain( PACKAGE );
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
#endif
#endif
}
diff --git a/agent/query.c b/agent/query.c
index 64333d035..7780abb26 100644
--- a/agent/query.c
+++ b/agent/query.c
@@ -32,6 +32,7 @@
#endif
#include "agent.h"
+#include "i18n.h"
#include "../assuan/assuan.h"
#ifdef _POSIX_OPEN_MAX
@@ -235,6 +236,7 @@ agent_askpin (const char *desc_text, struct pin_entry_info_s *pininfo)
char line[ASSUAN_LINELENGTH];
struct entry_parm_s parm;
const char *errtext = NULL;
+ int is_pin;
if (opt.batch)
return 0; /* fixme: we should return BAD PIN */
@@ -242,9 +244,11 @@ agent_askpin (const char *desc_text, struct pin_entry_info_s *pininfo)
if (!pininfo || pininfo->max_length < 1)
return seterr (Invalid_Value);
if (!desc_text)
- desc_text = trans ("Please enter you PIN, so that the secret key "
- "can be unlocked for this session");
-
+ desc_text = _("Please enter you PIN, so that the secret key "
+ "can be unlocked for this session");
+
+ is_pin = desc_text && strstr (desc_text, "PIN");
+
rc = start_pinentry ();
if (rc)
return rc;
@@ -256,8 +260,8 @@ agent_askpin (const char *desc_text, struct pin_entry_info_s *pininfo)
return unlock_pinentry (map_assuan_err (rc));
rc = assuan_transact (entry_ctx,
- pininfo->min_digits? "SETPROMPT PIN:"
- : "SETPROMPT Passphrase:",
+ is_pin? "SETPROMPT PIN:"
+ : "SETPROMPT Passphrase:",
NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return unlock_pinentry (map_assuan_err (rc));
@@ -283,21 +287,21 @@ agent_askpin (const char *desc_text, struct pin_entry_info_s *pininfo)
rc = assuan_transact (entry_ctx, "GETPIN", getpin_cb, &parm,
NULL, NULL, NULL, NULL);
if (rc == ASSUAN_Too_Much_Data)
- errtext = pininfo->min_digits? trans ("PIN too long")
- : trans ("Passphrase too long");
+ errtext = is_pin? _("PIN too long")
+ : _("Passphrase too long");
else if (rc)
return unlock_pinentry (map_assuan_err (rc));
- if (!errtext && pininfo->min_digits)
+ if (!errtext && is_pin)
{
/* do some basic checks on the entered PIN. */
if (!all_digitsp (pininfo->pin))
- errtext = trans ("Invalid characters in PIN");
+ errtext = _("Invalid characters in PIN");
else if (pininfo->max_digits
&& strlen (pininfo->pin) > pininfo->max_digits)
- errtext = trans ("PIN too long");
+ errtext = _("PIN too long");
else if (strlen (pininfo->pin) < pininfo->min_digits)
- errtext = trans ("PIN too short");
+ errtext = _("PIN too short");
}
if (!errtext && pininfo->check_cb)
@@ -308,8 +312,8 @@ agent_askpin (const char *desc_text, struct pin_entry_info_s *pininfo)
if (rc == -1 && pininfo->cb_errtext)
errtext = pininfo->cb_errtext;
else if (rc == GNUPG_Bad_Passphrase || rc == GNUPG_Bad_PIN)
- errtext = (pininfo->min_digits? trans ("Bad PIN")
- : trans ("Bad Passphrase"));
+ errtext = (is_pin? _("Bad PIN")
+ : _("Bad Passphrase"));
else if (rc)
return unlock_pinentry (map_assuan_err (rc));
}
@@ -346,6 +350,10 @@ agent_get_passphrase (char **retpass, const char *desc, const char *prompt,
if (rc)
return rc;
+ if (!prompt)
+ prompt = desc && strstr (desc, "PIN")? "PIN": _("Passphrase");
+
+
if (desc)
snprintf (line, DIM(line)-1, "SETDESC %s", desc);
else
@@ -355,7 +363,7 @@ agent_get_passphrase (char **retpass, const char *desc, const char *prompt,
if (rc)
return unlock_pinentry (map_assuan_err (rc));
- snprintf (line, DIM(line)-1, "SETPROMPT %s", prompt? prompt : "Passphrase");
+ snprintf (line, DIM(line)-1, "SETPROMPT %s", prompt);
line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)