From f24b47c44db03a8d9ba611f827e71aeb1f63d0bd Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 12 Mar 2017 14:44:09 +0100 Subject: PGP module: store data in own db, use pgp key as specified in account settings --- plugins/gpgme-vala/src/gpgme_helper.vala | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'plugins/gpgme-vala/src') diff --git a/plugins/gpgme-vala/src/gpgme_helper.vala b/plugins/gpgme-vala/src/gpgme_helper.vala index 9efa2b4c..429c96f0 100644 --- a/plugins/gpgme-vala/src/gpgme_helper.vala +++ b/plugins/gpgme-vala/src/gpgme_helper.vala @@ -28,12 +28,13 @@ public static string decrypt(string encr) throws GLib.Error { return get_string_from_data(dec_data); } -public static string sign(string plain, SigMode mode) throws GLib.Error { +public static string sign(string plain, SigMode mode, Key? key = null) throws GLib.Error { initialize(); global_mutex.lock(); Data plain_data = Data.create_from_memory(plain.data, false); Context context = Context.create(); + if (key != null) context.signers_add(key); Data signed_data = context.op_sign(plain_data, mode); global_mutex.unlock(); return get_string_from_data(signed_data); @@ -76,11 +77,19 @@ public static Gee.List get_keylist(string? pattern = null, bool secret_only } public static Key? get_public_key(string sig) throws GLib.Error { + return get_key(sig, false); +} + +public static Key? get_private_key(string sig) throws GLib.Error { + return get_key(sig, true); +} + +private static Key? get_key(string sig, bool priv) throws GLib.Error { initialize(); global_mutex.lock(); Context context = Context.create(); - Key key = context.get_key(sig, false); + Key key = context.get_key(sig, priv); global_mutex.unlock(); return key; } -- cgit v1.2.3-70-g09d2