equal
deleted
inserted
replaced
30 #include <locale.h> |
30 #include <locale.h> |
31 #include <sys/mman.h> |
31 #include <sys/mman.h> |
32 #include <glib.h> |
32 #include <glib.h> |
33 |
33 |
34 #include "pgp.h" |
34 #include "pgp.h" |
|
35 #include "settings.h" |
35 #include "logprint.h" |
36 #include "logprint.h" |
36 |
37 |
37 #define MIN_GPGME_VERSION "1.0.0" |
38 #define MIN_GPGME_VERSION "1.1.0" |
38 |
39 |
39 static struct gpg_struct |
40 static struct gpg_struct |
40 { |
41 { |
41 int enabled; |
42 int enabled; |
42 int version1; |
43 int version1; |
54 { |
55 { |
55 gpgme_error_t err; |
56 gpgme_error_t err; |
56 |
57 |
57 gpgme_ctx_t ctx; |
58 gpgme_ctx_t ctx; |
58 gpgme_engine_info_t info; |
59 gpgme_engine_info_t info; |
|
60 const char *gpg_path; |
59 |
61 |
60 // Check for version and OpenPGP protocol support. |
62 // Check for version and OpenPGP protocol support. |
61 if (!gpgme_check_version(MIN_GPGME_VERSION)) { |
63 if (!gpgme_check_version(MIN_GPGME_VERSION)) { |
62 scr_LogPrint(LPRINT_LOGNORM, |
64 scr_LogPrint(LPRINT_LOGNORM, |
63 "GPGME initialization error: Bad library version"); |
65 "GPGME initialization error: Bad library version"); |
72 } |
74 } |
73 |
75 |
74 // Set the locale information. |
76 // Set the locale information. |
75 gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); |
77 gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); |
76 gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); |
78 gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); |
|
79 |
|
80 // The path to the gpg binary can be specified in order to force |
|
81 // version 1, for example. |
|
82 gpg_path = settings_opt_get("gpg_path"); |
|
83 if (gpg_path) { |
|
84 err = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, gpg_path, NULL); |
|
85 if (err) return -1; |
|
86 } |
77 |
87 |
78 // Store private data. |
88 // Store private data. |
79 gpg_set_private_key(priv_key); |
89 gpg_set_private_key(priv_key); |
80 gpg_set_passphrase(passphrase); |
90 gpg_set_passphrase(passphrase); |
81 |
91 |