diff options
author | James Booth <boothj5@gmail.com> | 2015-03-22 00:12:14 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-03-22 00:12:14 +0000 |
commit | 2490c3ed202a912438d34594c01811f7532430a4 (patch) | |
tree | b8dd9563c6f1bf4c320d60d525507d70adf720bb /src/command | |
parent | f1f047889eed360a0c91be4fcabd24199089c02a (diff) | |
download | profani-tty-2490c3ed202a912438d34594c01811f7532430a4.tar.gz |
Added pgp key list command
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 18 | ||||
-rw-r--r-- | src/command/commands.c | 28 | ||||
-rw-r--r-- | src/command/commands.h | 1 |
3 files changed, 45 insertions, 2 deletions
diff --git a/src/command/command.c b/src/command/command.c index e165254e..a8eb362b 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -848,6 +848,14 @@ static struct cmd_t command_defs[] = "Send chat state notifications during chat sessions.", NULL } } }, + { "/pgp", + cmd_pgp, parse_args, 1, 1, NULL, + { "/pgp keys", "Open PGP.", + { "/pgp keys", + "---------", + "Open PGP.", + NULL } } }, + { "/otr", cmd_otr, parse_args, 1, 3, NULL, { "/otr command [args..]", "Off The Record encryption commands.", @@ -1202,6 +1210,7 @@ static Autocomplete time_statusbar_ac; static Autocomplete resource_ac; static Autocomplete inpblock_ac; static Autocomplete receipts_ac; +static Autocomplete pgp_ac; /* * Initialise command autocompleter and history @@ -1563,6 +1572,9 @@ cmd_init(void) receipts_ac = autocomplete_new(); autocomplete_add(receipts_ac, "send"); autocomplete_add(receipts_ac, "request"); + + pgp_ac = autocomplete_new(); + autocomplete_add(pgp_ac, "keys"); } void @@ -1621,6 +1633,7 @@ cmd_uninit(void) autocomplete_free(resource_ac); autocomplete_free(inpblock_ac); autocomplete_free(receipts_ac); + autocomplete_free(pgp_ac); } gboolean @@ -1788,6 +1801,7 @@ cmd_reset_autocomplete() autocomplete_reset(resource_ac); autocomplete_reset(inpblock_ac); autocomplete_reset(receipts_ac); + autocomplete_reset(pgp_ac); if (ui_current_win_type() == WIN_CHAT) { ProfChatWin *chatwin = wins_get_current_chat(); @@ -1971,8 +1985,8 @@ _cmd_complete_parameters(const char * const input) } } - gchar *cmds[] = { "/help", "/prefs", "/disco", "/close", "/wins", "/subject", "/room" }; - Autocomplete completers[] = { help_ac, prefs_ac, disco_ac, close_ac, wins_ac, subject_ac, room_ac }; + gchar *cmds[] = { "/help", "/prefs", "/disco", "/close", "/wins", "/subject", "/room", "/pgp" }; + Autocomplete completers[] = { help_ac, prefs_ac, disco_ac, close_ac, wins_ac, subject_ac, room_ac, pgp_ac }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE); diff --git a/src/command/commands.c b/src/command/commands.c index 86285a46..bc1e162b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -56,6 +56,9 @@ #ifdef HAVE_LIBOTR #include "otr/otr.h" #endif +#ifdef HAVE_LIBGPGME +#include "pgp/gpg.h" +#endif #include "profanity.h" #include "tools/autocomplete.h" #include "tools/parser.h" @@ -4064,6 +4067,31 @@ cmd_xa(gchar **args, struct cmd_help_t help) } gboolean +cmd_pgp(gchar **args, struct cmd_help_t help) +{ +#ifdef HAVE_LIBGPGME + if (g_strcmp0(args[0], "keys") == 0) { + GSList *keys = p_gpg_list_keys(); + if (keys) { + while (keys) { + cons_debug("Key: %s", keys->data); + keys = g_slist_next(keys); + } + } else { + cons_debug("No keys found"); + } + g_slist_free_full(keys, (GDestroyNotify)free); + } + + return TRUE; +#else + cons_show("This version of Profanity has not been built with PGP support enabled"); + return TRUE; +#endif + +} + +gboolean cmd_otr(gchar **args, struct cmd_help_t help) { #ifdef HAVE_LIBOTR diff --git a/src/command/commands.h b/src/command/commands.h index 7b7e7c93..9fe645e3 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -103,6 +103,7 @@ gboolean cmd_nick(gchar **args, struct cmd_help_t help); gboolean cmd_notify(gchar **args, struct cmd_help_t help); gboolean cmd_online(gchar **args, struct cmd_help_t help); gboolean cmd_otr(gchar **args, struct cmd_help_t help); +gboolean cmd_pgp(gchar **args, struct cmd_help_t help); gboolean cmd_outtype(gchar **args, struct cmd_help_t help); gboolean cmd_prefs(gchar **args, struct cmd_help_t help); gboolean cmd_priority(gchar **args, struct cmd_help_t help); |