aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/jingle_file_transfers.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-07-03 21:14:39 +0200
committerfiaxh <git@lightrise.org>2020-07-16 23:31:19 +0200
commite159fd2492c28c1ef4ab64828ca0e8c2de877b41 (patch)
treeaca3c42854b08b5683a1c85e7c7a74fd0a4bdf0d /libdino/src/service/jingle_file_transfers.vala
parent74f7fa897f9aec298eeadcfc7a7b971f06498858 (diff)
downloaddino-e159fd2492c28c1ef4ab64828ca0e8c2de877b41.tar.gz
dino-e159fd2492c28c1ef4ab64828ca0e8c2de877b41.zip
Only query entity caps when we need them
Diffstat (limited to 'libdino/src/service/jingle_file_transfers.vala')
-rw-r--r--libdino/src/service/jingle_file_transfers.vala30
1 files changed, 15 insertions, 15 deletions
diff --git a/libdino/src/service/jingle_file_transfers.vala b/libdino/src/service/jingle_file_transfers.vala
index 4c3646b3..6482e2e7 100644
--- a/libdino/src/service/jingle_file_transfers.vala
+++ b/libdino/src/service/jingle_file_transfers.vala
@@ -8,7 +8,7 @@ namespace Dino {
public interface JingleFileEncryptionHelper : Object {
public abstract bool can_transfer(Conversation conversation);
- public abstract bool can_encrypt(Conversation conversation, FileTransfer file_transfer, Jid? full_jid = null);
+ public abstract async bool can_encrypt(Conversation conversation, FileTransfer file_transfer, Jid? full_jid = null);
public abstract string? get_precondition_name(Conversation conversation, FileTransfer file_transfer);
public abstract Object? get_precondition_options(Conversation conversation, FileTransfer file_transfer);
public abstract FileMeta complete_meta(FileTransfer file_transfer, FileReceiveData receive_data, FileMeta file_meta, Xmpp.Xep.JingleFileTransfer.FileTransfer jingle_transfer);
@@ -18,7 +18,7 @@ public class JingleFileEncryptionHelperTransferOnly : JingleFileEncryptionHelper
public bool can_transfer(Conversation conversation) {
return true;
}
- public bool can_encrypt(Conversation conversation, FileTransfer file_transfer, Jid? full_jid) {
+ public async bool can_encrypt(Conversation conversation, FileTransfer file_transfer, Jid? full_jid) {
return false;
}
public string? get_precondition_name(Conversation conversation, FileTransfer file_transfer) {
@@ -143,7 +143,7 @@ public class JingleFileSender : FileSender, Object {
this.stream_interactor = stream_interactor;
}
- public bool is_upload_available(Conversation conversation) {
+ public async bool is_upload_available(Conversation conversation) {
if (conversation.type_ != Conversation.Type.CHAT) return false;
JingleFileEncryptionHelper? helper = JingleFileHelperRegistry.instance.get_encryption_helper(conversation.encryption);
@@ -157,35 +157,35 @@ public class JingleFileSender : FileSender, Object {
if (resources == null) return false;
foreach (Jid full_jid in resources) {
- if (stream.get_module(Xep.JingleFileTransfer.Module.IDENTITY).is_available(stream, full_jid)) {
+ if (yield stream.get_module(Xep.JingleFileTransfer.Module.IDENTITY).is_available(stream, full_jid)) {
return true;
}
}
return false;
}
- public long get_file_size_limit(Conversation conversation) {
- if (can_send_(conversation)) {
+ public async long get_file_size_limit(Conversation conversation) {
+ if (yield can_send_conv(conversation)) {
return int.MAX;
}
return -1;
}
- public bool can_send(Conversation conversation, FileTransfer file_transfer) {
- return can_send_(conversation);
+ public async bool can_send(Conversation conversation, FileTransfer file_transfer) {
+ return yield can_send_conv(conversation);
}
- private bool can_send_(Conversation conversation) {
+ private async bool can_send_conv(Conversation conversation) {
if (conversation.type_ != Conversation.Type.CHAT) return false;
// No file specific restrictions apply to Jingle file transfers
- return is_upload_available(conversation);
+ return yield is_upload_available(conversation);
}
- public bool can_encrypt(Conversation conversation, FileTransfer file_transfer) {
+ public async bool can_encrypt(Conversation conversation, FileTransfer file_transfer) {
JingleFileEncryptionHelper? helper = JingleFileHelperRegistry.instance.get_encryption_helper(file_transfer.encryption);
if (helper == null) return false;
- return helper.can_encrypt(conversation, file_transfer);
+ return yield helper.can_encrypt(conversation, file_transfer);
}
public async FileSendData? prepare_send_file(Conversation conversation, FileTransfer file_transfer, FileMeta file_meta) throws FileSendError {
@@ -199,13 +199,13 @@ public class JingleFileSender : FileSender, Object {
XmppStream? stream = stream_interactor.get_stream(file_transfer.account);
if (stream == null) throw new FileSendError.UPLOAD_FAILED("No stream available");
JingleFileEncryptionHelper? helper = JingleFileHelperRegistry.instance.get_encryption_helper(file_transfer.encryption);
- bool must_encrypt = helper != null && helper.can_encrypt(conversation, file_transfer);
+ bool must_encrypt = helper != null && yield helper.can_encrypt(conversation, file_transfer);
foreach (Jid full_jid in stream.get_flag(Presence.Flag.IDENTITY).get_resources(conversation.counterpart)) {
// TODO(hrxi): Prioritization of transports (and resources?).
- if (!stream.get_module(Xep.JingleFileTransfer.Module.IDENTITY).is_available(stream, full_jid)) {
+ if (!yield stream.get_module(Xep.JingleFileTransfer.Module.IDENTITY).is_available(stream, full_jid)) {
continue;
}
- if (must_encrypt && !helper.can_encrypt(conversation, file_transfer, full_jid)) {
+ if (must_encrypt && !yield helper.can_encrypt(conversation, file_transfer, full_jid)) {
continue;
}
string? precondition_name = null;