From 8c46c423c09d2a2bb50f086414d2fb373b3a64c9 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 28 Jan 2018 23:26:37 +0100 Subject: http-files: Report correct file size for encrypted files (slot request) --- plugins/http-files/src/manager.vala | 2 +- plugins/http-files/src/upload_stream_module.vala | 28 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'plugins/http-files') diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala index c27babe2..7335b89a 100644 --- a/plugins/http-files/src/manager.vala +++ b/plugins/http-files/src/manager.vala @@ -32,7 +32,7 @@ public class Manager : StreamInteractionModule, FileSender, Object { public void send_file(Conversation conversation, FileTransfer file_transfer) { Xmpp.XmppStream? stream = stream_interactor.get_stream(file_transfer.account); if (stream != null) { - stream_interactor.module_manager.get_module(file_transfer.account, UploadStreamModule.IDENTITY).upload(stream, file_transfer.input_stream, file_transfer.server_file_name, file_transfer.size, file_transfer.mime_type, + stream_interactor.module_manager.get_module(file_transfer.account, UploadStreamModule.IDENTITY).upload(stream, file_transfer.input_stream, file_transfer.server_file_name, file_transfer.mime_type, (stream, url_down) => { uploaded(file_transfer, url_down); file_transfer.info = url_down; diff --git a/plugins/http-files/src/upload_stream_module.vala b/plugins/http-files/src/upload_stream_module.vala index 4835f268..934d4df5 100644 --- a/plugins/http-files/src/upload_stream_module.vala +++ b/plugins/http-files/src/upload_stream_module.vala @@ -15,21 +15,21 @@ public class UploadStreamModule : XmppStreamModule { public delegate void OnUploadOk(XmppStream stream, string url_down); public delegate void OnError(XmppStream stream, string error); - public void upload(XmppStream stream, InputStream input_stream, string file_name, int file_size, string file_content_type, owned OnUploadOk listener, owned OnError error_listener) { - request_slot(stream, file_name, file_size, file_content_type, - (stream, url_down, url_up) => { - uint8[] buf = new uint8[256]; - Array data = new Array(false, true, 0); - size_t len = -1; - do { - try { - len = input_stream.read(buf); - } catch (IOError error) { - error_listener(stream, @"HTTP upload: IOError reading stream: $(error.message)"); - } - data.append_vals(buf, (uint) len); - } while(len > 0); + public void upload(XmppStream stream, InputStream input_stream, string file_name, string file_content_type, owned OnUploadOk listener, owned OnError error_listener) { + uint8[] buf = new uint8[256]; + Array data = new Array(false, true, 0); + size_t len = -1; + do { + try { + len = input_stream.read(buf); + } catch (IOError error) { + error_listener(stream, @"HTTP upload: IOError reading stream: $(error.message)"); + } + data.append_vals(buf, (uint) len); + } while(len > 0); + request_slot(stream, file_name, (int) data.length, file_content_type, + (stream, url_down, url_up) => { Soup.Message message = new Soup.Message("PUT", url_up); message.set_request(file_content_type, Soup.MemoryUse.COPY, data.data); Soup.Session session = new Soup.Session(); -- cgit v1.2.3-70-g09d2