aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-04-22 15:44:12 +0200
committerfiaxh <git@lightrise.org>2020-04-22 15:44:12 +0200
commit51a23728694a3f1312cc9396fc093ca178457c3c (patch)
tree321771ae3d807d19387a8656805a648d75347994 /libdino/src/service
parent7c4260eed718961874fc0ea665263ea2ce59338b (diff)
downloaddino-51a23728694a3f1312cc9396fc093ca178457c3c.tar.gz
dino-51a23728694a3f1312cc9396fc093ca178457c3c.zip
Add file upload preview
fixes #756
Diffstat (limited to 'libdino/src/service')
-rw-r--r--libdino/src/service/file_manager.vala12
-rw-r--r--libdino/src/service/jingle_file_transfers.vala11
2 files changed, 21 insertions, 2 deletions
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala
index 20540e6e..00abe517 100644
--- a/libdino/src/service/file_manager.vala
+++ b/libdino/src/service/file_manager.vala
@@ -38,7 +38,15 @@ public class FileManager : StreamInteractionModule, Object {
this.add_sender(new JingleFileSender(stream_interactor));
}
- public async void send_file(string uri, Conversation conversation) {
+ public HashMap<int, long> get_file_size_limits(Conversation conversation) {
+ HashMap<int, long> ret = new HashMap<int, long>();
+ foreach (FileSender sender in file_senders) {
+ ret[sender.get_id()] = sender.get_file_size_limit(conversation);
+ }
+ return ret;
+ }
+
+ public async void send_file(File file, Conversation conversation) {
FileTransfer file_transfer = new FileTransfer();
file_transfer.account = conversation.account;
file_transfer.counterpart = conversation.counterpart;
@@ -53,7 +61,6 @@ public class FileManager : StreamInteractionModule, Object {
file_transfer.encryption = conversation.encryption;
try {
- File file = File.new_for_path(uri);
FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
file_transfer.file_name = file_info.get_display_name();
file_transfer.mime_type = file_info.get_content_type();
@@ -394,6 +401,7 @@ public interface FileSender : Object {
public signal void upload_available(Account account);
public abstract bool is_upload_available(Conversation conversation);
+ public abstract long get_file_size_limit(Conversation conversation);
public abstract bool can_send(Conversation conversation, FileTransfer file_transfer);
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, FileMeta file_meta) throws FileSendError;
diff --git a/libdino/src/service/jingle_file_transfers.vala b/libdino/src/service/jingle_file_transfers.vala
index 3a5fa95e..4c3646b3 100644
--- a/libdino/src/service/jingle_file_transfers.vala
+++ b/libdino/src/service/jingle_file_transfers.vala
@@ -164,7 +164,18 @@ public class JingleFileSender : FileSender, Object {
return false;
}
+ public long get_file_size_limit(Conversation conversation) {
+ if (can_send_(conversation)) {
+ return int.MAX;
+ }
+ return -1;
+ }
+
public bool can_send(Conversation conversation, FileTransfer file_transfer) {
+ return can_send_(conversation);
+ }
+
+ private bool can_send_(Conversation conversation) {
if (conversation.type_ != Conversation.Type.CHAT) return false;
// No file specific restrictions apply to Jingle file transfers