From f6db249c92e8fd25c1cb52872d3a647be034b626 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 28 Jan 2018 20:56:27 +0100 Subject: Only display transferred images, display file names, open in system viewer, include and use pgp embedded file names --- plugins/openpgp/src/in_file_processor.vala | 8 +++++--- plugins/openpgp/src/out_file_processor.vala | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'plugins/openpgp/src') diff --git a/plugins/openpgp/src/in_file_processor.vala b/plugins/openpgp/src/in_file_processor.vala index 61baa37e..568315f9 100644 --- a/plugins/openpgp/src/in_file_processor.vala +++ b/plugins/openpgp/src/in_file_processor.vala @@ -17,10 +17,12 @@ public class InFileProcessor : IncommingFileProcessor, Object { data.append_vals(buf, (uint) len); } while(len > 0); - uint8[] clear_data = GPGHelper.decrypt_data(data.data); - file_transfer.input_stream = new MemoryInputStream.from_data(clear_data, GLib.free); + GPGHelper.DecryptedData clear_data = GPGHelper.decrypt_data(data.data); + file_transfer.input_stream = new MemoryInputStream.from_data(clear_data.data, GLib.free); file_transfer.encryption = Encryption.PGP; - if (file_transfer.file_name.has_suffix(".pgp")) { + if (clear_data.filename != null && clear_data.filename != "") { + file_transfer.file_name = clear_data.filename; + } else if (file_transfer.file_name.has_suffix(".pgp")) { file_transfer.file_name = file_transfer.file_name.substring(0, file_transfer.file_name.length - 4); } } catch (Error e) { diff --git a/plugins/openpgp/src/out_file_processor.vala b/plugins/openpgp/src/out_file_processor.vala index c644a190..522e518a 100644 --- a/plugins/openpgp/src/out_file_processor.vala +++ b/plugins/openpgp/src/out_file_processor.vala @@ -15,10 +15,10 @@ public class OutFileProcessor : OutgoingFileProcessor, Object { } public void process(Conversation conversation, FileTransfer file_transfer) { - string uri = file_transfer.get_uri(); + string path = file_transfer.get_file().get_path(); try { GPG.Key[] keys = stream_interactor.get_module(Manager.IDENTITY).get_key_fprs(conversation); - uint8[] enc_content = GPGHelper.encrypt_file(uri, keys, GPG.EncryptFlags.ALWAYS_TRUST); + uint8[] enc_content = GPGHelper.encrypt_file(path, keys, GPG.EncryptFlags.ALWAYS_TRUST, file_transfer.file_name); file_transfer.input_stream = new MemoryInputStream.from_data(enc_content, GLib.free); file_transfer.encryption = Encryption.PGP; file_transfer.server_file_name = Xmpp.random_uuid() + ".pgp"; -- cgit v1.2.3-54-g00ecf