blob: 40eef7f5c30ae26a187089103d9f249ccbfb9b6d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
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 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(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";
} catch (Error e) {
warning(@"PGP file encryption error: $(e.message)\n");
file_transfer.state = FileTransfer.State.FAILED;
}
}
}
}
|