diff mcabber/mcabber/pgp.c @ 2233:90c25a29fb35

New option: 'gpg_path' The path to the gpg binary can now be specified in order to force the use of GnuPG version 1 on systems which have both versions installed.
author Holger Weiß <holger@zedat.fu-berlin.de>
date Sat, 21 Nov 2015 17:44:55 +0100
parents 778280b01bcb
children 232c26383fc4
line wrap: on
line diff
--- a/mcabber/mcabber/pgp.c	Sun Nov 15 17:05:07 2015 +0100
+++ b/mcabber/mcabber/pgp.c	Sat Nov 21 17:44:55 2015 +0100
@@ -32,9 +32,10 @@
 #include <glib.h>
 
 #include "pgp.h"
+#include "settings.h"
 #include "logprint.h"
 
-#define MIN_GPGME_VERSION "1.0.0"
+#define MIN_GPGME_VERSION "1.1.0"
 
 static struct gpg_struct
 {
@@ -56,6 +57,7 @@
 
   gpgme_ctx_t ctx;
   gpgme_engine_info_t info;
+  const char *gpg_path;
 
   // Check for version and OpenPGP protocol support.
   if (!gpgme_check_version(MIN_GPGME_VERSION)) {
@@ -75,6 +77,14 @@
   gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
   gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL));
 
+  // The path to the gpg binary can be specified in order to force
+  // version 1, for example.
+  gpg_path = settings_opt_get("gpg_path");
+  if (gpg_path) {
+    err = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, gpg_path, NULL);
+    if (err) return -1;
+  }
+
   // Store private data.
   gpg_set_private_key(priv_key);
   gpg_set_passphrase(passphrase);