aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-29 15:15:28 +0100
committerfiaxh <git@mx.ax.lt>2017-10-31 15:41:45 +0100
commit0102abeec1d2055b19dccbb7edc7f06e527642b1 (patch)
tree4018e82224c19142c4a7a6eced67d9c2550b2dd8 /plugins/http-files
parentb9df78e4494879752e9e68dcc5d54e03fffe9467 (diff)
downloaddino-0102abeec1d2055b19dccbb7edc7f06e527642b1.tar.gz
dino-0102abeec1d2055b19dccbb7edc7f06e527642b1.zip
Fix warnings
Diffstat (limited to 'plugins/http-files')
-rw-r--r--plugins/http-files/src/file_provider.vala8
-rw-r--r--plugins/http-files/src/upload_stream_module.vala8
2 files changed, 12 insertions, 4 deletions
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala
index 9e677a92..53fe3bb0 100644
--- a/plugins/http-files/src/file_provider.vala
+++ b/plugins/http-files/src/file_provider.vala
@@ -48,8 +48,13 @@ public class FileProvider : Dino.FileProvider, Object {
if (name == "Content-Length") content_length = val;
});
if (/*content_type != null && content_type.has_prefix("image") &&*/ content_length != null && int.parse(content_length) < 5000000) {
- Soup.Request request = session.request (message.body);
FileTransfer file_transfer = new FileTransfer();
+ try {
+ Soup.Request request = session.request(message.body);
+ file_transfer.input_stream = request.send();
+ } catch (Error e) {
+ return;
+ }
file_transfer.account = conversation.account;
file_transfer.counterpart = message.counterpart;
file_transfer.ourpart = message.ourpart;
@@ -57,7 +62,6 @@ public class FileProvider : Dino.FileProvider, Object {
file_transfer.time = message.time;
file_transfer.local_time = message.local_time;
file_transfer.direction = message.direction;
- file_transfer.input_stream = request.send();
file_transfer.file_name = message.body.substring(message.body.last_index_of("/") + 1);
file_transfer.mime_type = content_type;
file_transfer.size = int.parse(content_length);
diff --git a/plugins/http-files/src/upload_stream_module.vala b/plugins/http-files/src/upload_stream_module.vala
index ee70e49d..08e6105f 100644
--- a/plugins/http-files/src/upload_stream_module.vala
+++ b/plugins/http-files/src/upload_stream_module.vala
@@ -21,7 +21,11 @@ public class UploadStreamModule : XmppStreamModule {
Array<uint8> data = new Array<uint8>(false, true, 0);
size_t len = -1;
do {
- len = input_stream.read(buf);
+ 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);
@@ -41,7 +45,7 @@ public class UploadStreamModule : XmppStreamModule {
}
});
},
- error_listener);
+ (stream, error) => error_listener(stream, error));
}
private delegate void OnSlotOk(XmppStream stream, string url_get, string url_put);