about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c9
-rw-r--r--src/command/commands.c10
-rw-r--r--src/pgp/gpg.c13
-rw-r--r--src/pgp/gpg.h1
-rw-r--r--tests/pgp/stub_gpg.c6
5 files changed, 34 insertions, 5 deletions
diff --git a/src/command/command.c b/src/command/command.c
index a8eb362b..820ca058 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -850,10 +850,12 @@ static struct cmd_t command_defs[] =
 
     { "/pgp",
         cmd_pgp, parse_args, 1, 1, NULL,
-        { "/pgp keys", "Open PGP.",
-        { "/pgp keys",
-          "---------",
+        { "/pgp keys|libver", "Open PGP.",
+        { "/pgp keys|libver",
+          "----------------",
           "Open PGP.",
+          "keys   : List private keys."
+          "libver : Show which version of the libgpgme library is being used.",
           NULL } } },
 
     { "/otr",
@@ -1575,6 +1577,7 @@ cmd_init(void)
 
     pgp_ac = autocomplete_new();
     autocomplete_add(pgp_ac, "keys");
+    autocomplete_add(pgp_ac, "libver");
 }
 
 void
diff --git a/src/command/commands.c b/src/command/commands.c
index bc1e162b..5d1ddf12 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4081,6 +4081,16 @@ cmd_pgp(gchar **args, struct cmd_help_t help)
             cons_debug("No keys found");
         }
         g_slist_free_full(keys, (GDestroyNotify)free);
+    } else if (g_strcmp0(args[0], "libver") == 0) {
+        const char *libver = p_gpg_libver();
+        if (libver) {
+            GString *fullstr = g_string_new("Using libgpgme version ");
+            g_string_append(fullstr, libver);
+            cons_show("%s", fullstr->str);
+            g_string_free(fullstr, TRUE);
+        } else {
+            cons_show("Could not get libgpgme version");
+        }
     }
 
     return TRUE;
diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c
index 2a9e6431..4b1b57c9 100644
--- a/src/pgp/gpg.c
+++ b/src/pgp/gpg.c
@@ -39,11 +39,13 @@
 
 #include "log.h"
 
+static const char *libversion;
+
 void
 p_gpg_init(void)
 {
-    char *version = gpgme_check_version (NULL);
-    log_debug("GPG: Found gpgme version: %s",version);
+    libversion = gpgme_check_version(NULL);
+    log_debug("GPG: Found gpgme version: %s", libversion);
     gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
 }
 
@@ -79,3 +81,10 @@ p_gpg_list_keys(void)
 
     return result;
 }
+
+const char*
+p_gpg_libver(void)
+{
+    return libversion;
+}
+
diff --git a/src/pgp/gpg.h b/src/pgp/gpg.h
index 3dc256dc..9702e31a 100644
--- a/src/pgp/gpg.h
+++ b/src/pgp/gpg.h
@@ -37,5 +37,6 @@
 
 void p_gpg_init(void);
 GSList* p_gpg_list_keys(void);
+char* p_gpg_libver(void);
 
 #endif
diff --git a/tests/pgp/stub_gpg.c b/tests/pgp/stub_gpg.c
index 4ee03129..f0c30b55 100644
--- a/tests/pgp/stub_gpg.c
+++ b/tests/pgp/stub_gpg.c
@@ -1,7 +1,13 @@
 #include <glib.h>
 
 void p_gpg_init(void) {}
+
 GSList* p_gpg_list_keys(void)
 {
     return NULL;
 }
+
+const char* p_gpg_libver(void) {
+    return NULL;
+}
+