aboutsummaryrefslogtreecommitdiff
path: root/plugins/openpgp/src/out_file_processor.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-16 00:23:51 +0200
committerfiaxh <git@mx.ax.lt>2017-10-22 18:26:31 +0200
commit9ea16b6d8568cb383eb1f469d1dc54bfcad4f188 (patch)
tree27da8705fc99f2407af5e60083e34ddeeff39630 /plugins/openpgp/src/out_file_processor.vala
parent8b43df8ec3f92477f857280668a9f29f0b9d6229 (diff)
downloaddino-9ea16b6d8568cb383eb1f469d1dc54bfcad4f188.tar.gz
dino-9ea16b6d8568cb383eb1f469d1dc54bfcad4f188.zip
PGP encrypted file transfers
Diffstat (limited to 'plugins/openpgp/src/out_file_processor.vala')
-rw-r--r--plugins/openpgp/src/out_file_processor.vala27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/openpgp/src/out_file_processor.vala b/plugins/openpgp/src/out_file_processor.vala
new file mode 100644
index 00000000..81c53b16
--- /dev/null
+++ b/plugins/openpgp/src/out_file_processor.vala
@@ -0,0 +1,27 @@
+using Dino.Entities;
+
+namespace Dino.Plugins.OpenPgp {
+
+public class OutFileProcessor : OutgoingFileProcessor, Object {
+
+ StreamInteractor stream_interactor;
+
+ public OutFileProcessor(StreamInteractor stream_interactor) {
+ this.stream_interactor = stream_interactor;
+ }
+
+ public bool can_process(Conversation conversation, FileTransfer file_transfer) {
+ return conversation.encryption == Encryption.PGP;
+ }
+
+ public void process(Conversation conversation, FileTransfer file_transfer) {
+ string uri = file_transfer.get_uri();
+ 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);
+ file_transfer.input_stream = new MemoryInputStream.from_data(enc_content, GLib.free);
+ file_transfer.encryption = Encryption.PGP;
+ file_transfer.server_file_name = file_transfer.server_file_name + ".pgp";
+ }
+}
+
+}