aboutsummaryrefslogtreecommitdiff
path: root/plugins/openpgp/src/file_transfer
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/openpgp/src/file_transfer')
-rw-r--r--plugins/openpgp/src/file_transfer/file_decryptor.vala8
-rw-r--r--plugins/openpgp/src/file_transfer/file_encryptor.vala6
2 files changed, 10 insertions, 4 deletions
diff --git a/plugins/openpgp/src/file_transfer/file_decryptor.vala b/plugins/openpgp/src/file_transfer/file_decryptor.vala
index 97eb9f43..455f853d 100644
--- a/plugins/openpgp/src/file_transfer/file_decryptor.vala
+++ b/plugins/openpgp/src/file_transfer/file_decryptor.vala
@@ -19,18 +19,20 @@ public class PgpFileDecryptor : FileDecryptor, Object {
public async InputStream decrypt_file(InputStream encrypted_stream, Conversation conversation, FileTransfer file_transfer, FileReceiveData receive_data) throws FileReceiveError {
try {
uint8[] buf = new uint8[256];
- Array<uint8> data = new Array<uint8>(false, true, 0);
+ ByteArray data = new ByteArray();
size_t len = -1;
do {
- len = encrypted_stream.read(buf);
- data.append_vals(buf, (uint) len);
+ len = yield encrypted_stream.read_async(buf);
+ data.append(buf[0:len]);
} while(len > 0);
GPGHelper.DecryptedData clear_data = GPGHelper.decrypt_data(data.data);
file_transfer.encryption = Encryption.PGP;
if (clear_data.filename != null && clear_data.filename != "") {
+ debug("Decrypting file %s from %s", clear_data.filename, file_transfer.file_name);
file_transfer.file_name = clear_data.filename;
} else if (file_transfer.file_name.has_suffix(".pgp")) {
+ debug("Decrypting file %s from %s", file_transfer.file_name.substring(0, file_transfer.file_name.length - 4), file_transfer.file_name);
file_transfer.file_name = file_transfer.file_name.substring(0, file_transfer.file_name.length - 4);
}
return new MemoryInputStream.from_data(clear_data.data, GLib.free);
diff --git a/plugins/openpgp/src/file_transfer/file_encryptor.vala b/plugins/openpgp/src/file_transfer/file_encryptor.vala
index 7d51be60..66e93bd9 100644
--- a/plugins/openpgp/src/file_transfer/file_encryptor.vala
+++ b/plugins/openpgp/src/file_transfer/file_encryptor.vala
@@ -15,17 +15,21 @@ public class PgpFileEncryptor : Dino.FileEncryptor, Object {
}
public FileMeta encrypt_file(Conversation conversation, FileTransfer file_transfer) throws FileSendError {
+ FileMeta file_meta = new FileMeta();
+
try {
GPG.Key[] keys = stream_interactor.get_module(Manager.IDENTITY).get_key_fprs(conversation);
uint8[] enc_content = GPGHelper.encrypt_file(file_transfer.get_file().get_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";
+ file_meta.size = enc_content.length;
} catch (Error e) {
throw new FileSendError.ENCRYPTION_FAILED("PGP file encryption error: %s".printf(e.message));
}
+ debug("Encrypting file %s as %s", file_transfer.file_name, file_transfer.server_file_name);
- return new FileMeta();
+ return file_meta;
}
public FileSendData? preprocess_send_file(Conversation conversation, FileTransfer file_transfer, FileSendData file_send_data, FileMeta file_meta) {