aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-08-21 19:31:46 +0200
committerfiaxh <git@lightrise.org>2019-08-21 22:37:52 +0200
commit0521afa3d828ea0dfc79e6c5c76697e2a3a270c0 (patch)
treeb7d64f2b2e13d01c81621962816d90e8b8e279ca
parent3ad2891eb80d9381fed8547d6429904120af1f3e (diff)
downloaddino-0521afa3d828ea0dfc79e6c5c76697e2a3a270c0.tar.gz
dino-0521afa3d828ea0dfc79e6c5c76697e2a3a270c0.zip
Fix specified size for encrypted file uploads
-rw-r--r--libdino/src/service/file_manager.vala4
-rw-r--r--libdino/src/service/jingle_file_transfers.vala2
-rw-r--r--plugins/http-files/src/file_provider.vala16
-rw-r--r--plugins/http-files/src/file_sender.vala4
-rw-r--r--plugins/omemo/src/file_transfer/file_decryptor.vala2
-rw-r--r--xmpp-vala/src/module/xep/0363_http_file_upload.vala2
6 files changed, 17 insertions, 13 deletions
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala
index 50b38f01..c4a9a393 100644
--- a/libdino/src/service/file_manager.vala
+++ b/libdino/src/service/file_manager.vala
@@ -86,7 +86,7 @@ public class FileManager : StreamInteractionModule, Object {
FileSendData file_send_data = null;
foreach (FileSender file_sender in file_senders) {
if (file_sender.can_send(conversation, file_transfer)) {
- file_send_data = yield file_sender.prepare_send_file(conversation, file_transfer);
+ file_send_data = yield file_sender.prepare_send_file(conversation, file_transfer, file_meta);
break;
}
}
@@ -393,7 +393,7 @@ public interface FileSender : Object {
public abstract bool is_upload_available(Conversation conversation);
public abstract bool can_send(Conversation conversation, FileTransfer file_transfer);
- public abstract async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer) throws FileSendError;
+ public abstract async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer, FileMeta file_meta) throws FileSendError;
public abstract async void send_file(Conversation conversation, FileTransfer file_transfer, FileSendData file_send_data) throws FileSendError;
public abstract int get_id();
diff --git a/libdino/src/service/jingle_file_transfers.vala b/libdino/src/service/jingle_file_transfers.vala
index 95c3266f..5df42a03 100644
--- a/libdino/src/service/jingle_file_transfers.vala
+++ b/libdino/src/service/jingle_file_transfers.vala
@@ -107,7 +107,7 @@ public class JingleFileSender : FileSender, Object {
return false;
}
- public async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer) throws FileSendError {
+ public async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer, FileMeta file_meta) throws FileSendError {
return new FileSendData();
}
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala
index 38687863..2ce8d96b 100644
--- a/plugins/http-files/src/file_provider.vala
+++ b/plugins/http-files/src/file_provider.vala
@@ -62,7 +62,7 @@ public class FileProvider : Dino.FileProvider, Object {
receive_data.url = message.body;
var file_meta = new HttpFileMeta();
- file_meta.file_name = Uri.unescape_string(message.body.substring(message.body.last_index_of("/") + 1));
+ file_meta.file_name = extract_file_name_from_url(message.body);
file_meta.message = message;
file_incoming(additional_info, message.from, message.time, message.local_time, conversation, receive_data, file_meta);
@@ -121,11 +121,7 @@ public class FileProvider : Dino.FileProvider, Object {
file_meta.size = file_transfer.size;
file_meta.mime_type = file_transfer.mime_type;
- // Extract file name from URL
- file_meta.file_name = Uri.unescape_string(message.body.substring(message.body.last_index_of("/") + 1));
- if (file_meta.file_name.contains("#")) {
- file_meta.file_name = file_meta.file_name.substring(0, file_meta.file_name.last_index_of("#"));
- }
+ file_meta.file_name = extract_file_name_from_url(message.body);
file_meta.message = message;
@@ -145,6 +141,14 @@ public class FileProvider : Dino.FileProvider, Object {
return receive_data;
}
+ private string extract_file_name_from_url(string url) {
+ string ret = Uri.unescape_string(url.substring(url.last_index_of("/") + 1));
+ if (ret.contains("#")) {
+ ret = ret.substring(0, ret.last_index_of("#"));
+ }
+ return ret;
+ }
+
public int get_id() { return 0; }
}
diff --git a/plugins/http-files/src/file_sender.vala b/plugins/http-files/src/file_sender.vala
index ce40d2f8..3ab0d736 100644
--- a/plugins/http-files/src/file_sender.vala
+++ b/plugins/http-files/src/file_sender.vala
@@ -17,7 +17,7 @@ public class HttpFileSender : FileSender, Object {
stream_interactor.get_module(MessageProcessor.IDENTITY).build_message_stanza.connect(check_add_oob);
}
- public async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer) throws FileSendError {
+ public async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer, FileMeta file_meta) throws FileSendError {
HttpFileSendData send_data = new HttpFileSendData();
if (send_data == null) return null;
@@ -25,7 +25,7 @@ public class HttpFileSender : FileSender, Object {
if (stream == null) return null;
try {
- var slot_result = yield stream_interactor.module_manager.get_module(file_transfer.account, Xmpp.Xep.HttpFileUpload.Module.IDENTITY).request_slot(stream, file_transfer.server_file_name, file_transfer.size, file_transfer.mime_type);
+ var slot_result = yield stream_interactor.module_manager.get_module(file_transfer.account, Xmpp.Xep.HttpFileUpload.Module.IDENTITY).request_slot(stream, file_transfer.server_file_name, file_meta.size, file_meta.mime_type);
send_data.url_down = slot_result.url_get;
send_data.url_up = slot_result.url_put;
} catch (Xep.HttpFileUpload.HttpFileTransferError e) {
diff --git a/plugins/omemo/src/file_transfer/file_decryptor.vala b/plugins/omemo/src/file_transfer/file_decryptor.vala
index dcb65301..6998fef2 100644
--- a/plugins/omemo/src/file_transfer/file_decryptor.vala
+++ b/plugins/omemo/src/file_transfer/file_decryptor.vala
@@ -15,7 +15,7 @@ public class OmemoFileDecryptor : FileDecryptor, Object {
public FileReceiveData prepare_get_meta_info(Conversation conversation, FileTransfer file_transfer, FileReceiveData receive_data) {
HttpFileReceiveData? http_receive_data = receive_data as HttpFileReceiveData;
if (http_receive_data == null) assert(false);
-// if ((receive_data as OmemoHttpFileReceiveData) != null) return receive_data;
+ if ((receive_data as OmemoHttpFileReceiveData) != null) return receive_data;
var omemo_http_receive_data = new OmemoHttpFileReceiveData();
omemo_http_receive_data.url = aesgcm_to_https_link(http_receive_data.url);
diff --git a/xmpp-vala/src/module/xep/0363_http_file_upload.vala b/xmpp-vala/src/module/xep/0363_http_file_upload.vala
index eefe05eb..822ddc6b 100644
--- a/xmpp-vala/src/module/xep/0363_http_file_upload.vala
+++ b/xmpp-vala/src/module/xep/0363_http_file_upload.vala
@@ -22,7 +22,7 @@ public class Module : XmppStreamModule {
public string url_get { get; set; }
public string url_put { get; set; }
}
- public async SlotResult request_slot(XmppStream stream, string filename, int file_size, string? content_type) throws HttpFileTransferError {
+ public async SlotResult request_slot(XmppStream stream, string filename, int64 file_size, string? content_type) throws HttpFileTransferError {
Flag? flag = stream.get_flag(Flag.IDENTITY);
if (flag == null) {
throw new HttpFileTransferError.SLOT_REQUEST("No flag");