diff options
author | fiaxh <git@mx.ax.lt> | 2018-01-28 20:56:27 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2018-01-28 22:00:22 +0100 |
commit | f6db249c92e8fd25c1cb52872d3a647be034b626 (patch) | |
tree | 65ebb9d61fd27dcfd37a26137f507413193902d3 /plugins/gpgme-vala/src/gpgme_helper.vala | |
parent | bec810e234a7b9783eb8f35e2ffd7c60d75e09c7 (diff) | |
download | dino-f6db249c92e8fd25c1cb52872d3a647be034b626.tar.gz dino-f6db249c92e8fd25c1cb52872d3a647be034b626.zip |
Only display transferred images, display file names, open in system viewer, include and use pgp embedded file names
Diffstat (limited to 'plugins/gpgme-vala/src/gpgme_helper.vala')
-rw-r--r-- | plugins/gpgme-vala/src/gpgme_helper.vala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/gpgme-vala/src/gpgme_helper.vala b/plugins/gpgme-vala/src/gpgme_helper.vala index cc013164..c0121842 100644 --- a/plugins/gpgme-vala/src/gpgme_helper.vala +++ b/plugins/gpgme-vala/src/gpgme_helper.vala @@ -19,11 +19,12 @@ public static string encrypt_armor(string plain, Key[] keys, EncryptFlags flags) } } -public static uint8[] encrypt_file(string uri, Key[] keys, EncryptFlags flags) throws GLib.Error { +public static uint8[] encrypt_file(string uri, Key[] keys, EncryptFlags flags, string file_name) throws GLib.Error { global_mutex.lock(); try { initialize(); Data plain_data = Data.create_from_file(uri); + plain_data.set_file_name(file_name); Context context = Context.create(); context.set_armor(true); Data enc_data = context.op_encrypt(keys, flags, plain_data); @@ -46,14 +47,20 @@ public static string decrypt(string encr) throws GLib.Error { } } -public static uint8[] decrypt_data(uint8[] data) throws GLib.Error { +public class DecryptedData { + public uint8[] data { get; set; } + public string filename { get; set; } +} + +public static DecryptedData decrypt_data(uint8[] data) throws GLib.Error { global_mutex.lock(); try { initialize(); Data enc_data = Data.create_from_memory(data, false); Context context = Context.create(); Data dec_data = context.op_decrypt(enc_data); - return get_uint8_from_data(dec_data); + DecryptResult* dec_res = context.op_decrypt_result(); + return new DecryptedData() { data=get_uint8_from_data(dec_data), filename=dec_res->file_name}; } finally { global_mutex.unlock(); } |