about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-08-25 00:21:49 +0100
committerJames Booth <boothj5@gmail.com>2015-08-25 00:21:49 +0100
commitf6a91145b60ce924daaee6b2d5b9449c6170d9f9 (patch)
tree98f6fc96549928caca38276459dcbdaa7d7802b6 /src/command
parentd6ff72cf48bddf64e0e7e4b77929d0996770b2e6 (diff)
downloadprofani-tty-f6a91145b60ce924daaee6b2d5b9449c6170d9f9.tar.gz
Show public/private indicator when listing PGP keys
Diffstat (limited to 'src/command')
-rw-r--r--src/command/commands.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 082b1bf8..f3911aad 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4211,22 +4211,29 @@ cmd_pgp(ProfWin *window, const char * const command, gchar **args)
     }
 
     if (g_strcmp0(args[0], "keys") == 0) {
-        GSList *keys = p_gpg_list_keys();
-        if (!keys) {
+        GHashTable *keys = p_gpg_list_keys();
+        if (!keys || g_hash_table_size(keys) == 0) {
             cons_show("No keys found");
             return TRUE;
         }
 
         cons_show("PGP keys:");
-        GSList *curr = keys;
+        GList *keylist = g_hash_table_get_keys(keys);
+        GList *curr = keylist;
         while (curr) {
-            ProfPGPKey *key = curr->data;
+            ProfPGPKey *key = g_hash_table_lookup(keys, curr->data);
             cons_show("  %s", key->name);
             cons_show("    ID          : %s", key->id);
             cons_show("    Fingerprint : %s", key->fp);
-            curr = g_slist_next(curr);
+            if (key->secret) {
+                cons_show("    Type        : PUBLIC, PRIVATE");
+            } else {
+                cons_show("    Type        : PUBLIC");
+            }
+            curr = g_list_next(curr);
         }
-        g_slist_free_full(keys, (GDestroyNotify)p_gpg_free_key);
+        g_list_free(keylist);
+        p_gpg_free_keys(keys);
         return TRUE;
     }