* trustdb.h, trustdb.c (uid_trust_string_fixed): New. Return a fixed-size
authorDavid Shaw <dshaw@jabberwocky.com>
Wed, 24 Nov 2004 05:25:03 +0000 (05:25 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Wed, 24 Nov 2004 05:25:03 +0000 (05:25 +0000)
translatable string similar to trust_value_to_string. This allows for
easier lining up of displays.

* keyedit.c (show_key_with_all_names), keylist.c (list_keyblock_print):
Use it here to print validity strings.

* gpgv.c: Stub.

g10/ChangeLog
g10/gpgv.c
g10/keyedit.c
g10/keylist.c
g10/trustdb.c
g10/trustdb.h

index 010d58b..6657690 100644 (file)
@@ -1,3 +1,14 @@
+2004-11-24  David Shaw  <dshaw@jabberwocky.com>
+
+       * trustdb.h, trustdb.c (uid_trust_string_fixed): New.  Return a
+       fixed-size translatable string similar to trust_value_to_string.
+       This allows for easier lining up of displays.
+
+       * keyedit.c (show_key_with_all_names), keylist.c
+       (list_keyblock_print): Use it here to print validity strings.
+
+       * gpgv.c: Stub.
+
 2004-11-18  Werner Koch  <wk@g10code.com>
 
        * g10.c (S_IRGRP) [HAVE_DOSISH_SYSTEM]: Define to 0.
index 2a316c3..7778953 100644 (file)
@@ -251,7 +251,12 @@ trust_value_to_string (unsigned int value)
   return "err";
 }
 
-/* Stub: */
+const char *
+uid_trust_string_fixed(PKT_public_key *key,PKT_user_id *uid)
+{
+  return "err";
+}
+
 int
 get_ownertrust_info (PKT_public_key *pk)
 {
index f1ececb..94be382 100644 (file)
@@ -892,7 +892,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
                while(class==0)
                  {
                    answer = cpr_get("sign_uid.class",_("Your selection? "
-                                       "(enter '?' for more information): "));
+                                       "(enter `?' for more information): "));
                    if(answer[0]=='\0')
                      class=0x10+opt.def_cert_level; /* Default */
                    else if(ascii_strcasecmp(answer,"0")==0)
@@ -2360,16 +2360,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
            if( !only_marked || (only_marked && (node->flag & NODFLG_MARK_A)))
              {
                if(!only_marked)
-                 {
-                   if(uid->is_revoked)
-                     tty_printf(_("[%8.8s] "),_("revoked"));
-                   else if(uid->is_expired)
-                     tty_printf(_("[%8.8s] "),_("expired"));
-                   else if(primary)
-                     tty_printf(_("[%8.8s] "),
-                                trust_value_to_string(get_validity(primary,
-                                                                   uid)));
-                 }
+                 tty_printf("%s ",uid_trust_string_fixed(primary,uid));
 
                if( only_marked )
                  tty_printf("     ");
@@ -2403,16 +2394,16 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
                        show_prefs (uid, selfsig, with_prefs == 2);
                      }
                    else
-                     tty_printf(_("There are no preferences on a "
-                                  "PGP 2.x-style user ID.\n"));
+                     tty_printf(_("There are no preferences on a"
+                                  " PGP 2.x-style user ID.\n"));
                  }
              }
          }
       }
 
     if (do_warn)
-        tty_printf (_("Please note that the shown key validity "
-                      "is not necessarily correct\n"
+        tty_printf (_("Please note that the shown key validity"
+                      " is not necessarily correct\n"
                       "unless you restart the program.\n")); 
 }
 
index f874b2d..e4c9e6e 100644 (file)
@@ -778,19 +778,13 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
                const char *validity;
                int indent;
 
-               if(uid->is_revoked)
-                 validity=_("revoked");
-               else if(uid->is_expired)
-                 validity=_("expired");
-               else
-                 validity=trust_value_to_string(get_validity(pk,uid));
-
-               indent=(keystrlen()+7)-strlen(validity);
+               validity=uid_trust_string_fixed(pk,uid);
+               indent=(keystrlen()+9)-atoi(uid_trust_string_fixed(NULL,NULL));
 
-               if(indent<0)
+               if(indent<0 || indent>40)
                  indent=0;
 
-               printf("uid%*s[%s] ",indent,"",validity);
+               printf("uid%*s%s ",indent,"",validity);
              }
            else
              printf("uid%*s",keystrlen()+10,"");
index e4e8f81..75aa752 100644 (file)
@@ -489,6 +489,34 @@ trust_letter (unsigned int value)
     }
 }
 
+/* NOTE TO TRANSLATOR: these strings are similar to those in
+   trust_value_to_string(), but are a fixed length.  This is needed to
+   make attractive information listings where columns line up
+   properly.  The value "10" should be the length of the strings you
+   choose to translate to.  This is the length in printable
+   columns. */
+const char *
+uid_trust_string_fixed(PKT_public_key *key,PKT_user_id *uid)
+{
+  if(!key && !uid)
+    return _("10");
+  else if(uid->is_revoked)
+    return                         _("[ revoked]");
+  else if(uid->is_expired)
+    return                         _("[ expired]");
+  else if(key)
+    switch(get_validity(key,uid)&TRUST_MASK)
+      {
+      case TRUST_UNKNOWN:   return _("[ unknown]");
+      case TRUST_UNDEFINED: return _("[  undef ]");
+      case TRUST_MARGINAL:  return _("[marginal]");
+      case TRUST_FULLY:     return _("[  full  ]");
+      case TRUST_ULTIMATE:  return _("[ultimate]");
+      }
+
+  return "err";
+}
+
 /* The strings here are similar to those in
    pkclist.c:do_edit_ownertrust() */
 const char *
index ad19275..baeab3f 100644 (file)
@@ -1,6 +1,6 @@
 /* trustdb.h - Trust database
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
- *                                             Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
+ *               2004 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -22,7 +22,6 @@
 #ifndef G10_TRUSTDB_H
 #define G10_TRUSTDB_H
 
-
 /* Trust values must be sorted in ascending order */
 #define TRUST_MASK      15
 #define TRUST_UNKNOWN    0  /* o: not yet calculated/assigned */
@@ -48,6 +47,7 @@ void init_trustdb( void );
 void check_trustdb_stale(void);
 void sync_trustdb( void );
 
+const char *uid_trust_string_fixed(PKT_public_key *key,PKT_user_id *uid);
 const char *trust_value_to_string (unsigned int value);
 int string_to_trust_value (const char *str);