aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src/service')
-rw-r--r--libdino/src/service/file_manager.vala1
-rw-r--r--libdino/src/service/jingle_file_manager.vala52
-rw-r--r--libdino/src/service/module_manager.vala4
3 files changed, 57 insertions, 0 deletions
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala
index 6f8ccee4..9873539a 100644
--- a/libdino/src/service/file_manager.vala
+++ b/libdino/src/service/file_manager.vala
@@ -65,6 +65,7 @@ public class FileManager : StreamInteractionModule, Object {
foreach (FileSender file_sender in file_senders) {
if (file_sender.can_send(conversation, file_transfer)) {
+ // TODO(hrxi): Currently, this tries to send the file with every transfer available, but it should probably only select one.
file_sender.send_file(conversation, file_transfer);
}
}
diff --git a/libdino/src/service/jingle_file_manager.vala b/libdino/src/service/jingle_file_manager.vala
new file mode 100644
index 00000000..055f0758
--- /dev/null
+++ b/libdino/src/service/jingle_file_manager.vala
@@ -0,0 +1,52 @@
+using Gdk;
+using Gee;
+
+using Xmpp;
+using Dino.Entities;
+
+namespace Dino {
+
+public class JingleFileManager : StreamInteractionModule, FileSender, Object {
+ public static ModuleIdentity<JingleFileManager> IDENTITY = new ModuleIdentity<JingleFileManager>("jingle_files");
+ public string id { get { return IDENTITY.id; } }
+
+ private StreamInteractor stream_interactor;
+
+ public static void start(StreamInteractor stream_interactor) {
+ JingleFileManager m = new JingleFileManager(stream_interactor);
+ stream_interactor.add_module(m);
+ }
+
+ private JingleFileManager(StreamInteractor stream_interactor) {
+ this.stream_interactor = stream_interactor;
+
+ stream_interactor.get_module(FileManager.IDENTITY).add_sender(this);
+ }
+
+ public bool is_upload_available(Conversation conversation) {
+ // TODO(hrxi) Here and in `send_file`: What should happen if `stream == null`?
+ XmppStream? stream = stream_interactor.get_stream(conversation.account);
+ foreach (Jid full_jid in stream.get_flag(Presence.Flag.IDENTITY).get_resources(conversation.counterpart)) {
+ if (stream.get_module(Xep.JingleFileTransfer.Module.IDENTITY).is_available(stream, full_jid)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ public bool can_send(Conversation conversation, FileTransfer file_transfer) {
+ return file_transfer.encryption != Encryption.OMEMO;
+ }
+ public void send_file(Conversation conversation, FileTransfer file_transfer) {
+ XmppStream? stream = stream_interactor.get_stream(file_transfer.account);
+ 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)) {
+ continue;
+ }
+ stream.get_module(Xep.JingleFileTransfer.Module.IDENTITY).offer_file_stream(stream, full_jid, file_transfer.input_stream, file_transfer.file_name, file_transfer.size);
+ return;
+ }
+ }
+}
+
+}
diff --git a/libdino/src/service/module_manager.vala b/libdino/src/service/module_manager.vala
index 41a2c6a0..16bf5a60 100644
--- a/libdino/src/service/module_manager.vala
+++ b/libdino/src/service/module_manager.vala
@@ -78,6 +78,10 @@ public class ModuleManager {
module_map[account].add(new StreamError.Module());
module_map[account].add(new Xep.InBandRegistration.Module());
module_map[account].add(new Xep.HttpFileUpload.Module());
+ module_map[account].add(new Xep.InBandBytestreams.Module());
+ module_map[account].add(new Xep.Jingle.Module());
+ module_map[account].add(new Xep.JingleInBandBytestreams.Module());
+ module_map[account].add(new Xep.JingleFileTransfer.Module());
initialize_account_modules(account, module_map[account]);
}
}