aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/service/message_processor.vala5
-rw-r--r--plugins/http-files/src/manager.vala28
-rw-r--r--plugins/http-files/src/plugin.vala2
-rw-r--r--xmpp-vala/CMakeLists.txt1
-rw-r--r--xmpp-vala/src/module/xep/0066_out_of_band_data.vala11
5 files changed, 34 insertions, 13 deletions
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index 3ba3320c..757a0e1f 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -11,7 +11,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
public signal void pre_message_received(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation);
public signal void message_received(Entities.Message message, Conversation conversation);
- public signal void out_message_created(Entities.Message message, Conversation conversation);
+ public signal void build_message_stanza(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation);
public signal void pre_message_send(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation);
public signal void message_sent(Entities.Message message, Conversation conversation);
@@ -175,8 +175,6 @@ public class MessageProcessor : StreamInteractionModule, Object {
}
message.marked = Entities.Message.Marked.UNSENT;
message.encryption = conversation.encryption;
-
- out_message_created(message, conversation);
return message;
}
@@ -193,6 +191,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
} else {
new_message.type_ = Xmpp.Message.Stanza.TYPE_CHAT;
}
+ build_message_stanza(message, new_message, conversation);
pre_message_send(message, new_message, conversation);
if (message.marked == Entities.Message.Marked.UNSENT || message.marked == Entities.Message.Marked.WONTSEND) return;
if (delayed) {
diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala
index dd168b3d..83836989 100644
--- a/plugins/http-files/src/manager.vala
+++ b/plugins/http-files/src/manager.vala
@@ -12,12 +12,21 @@ public class Manager : StreamInteractionModule, FileSender, Object {
public signal void uploaded(FileTransfer file_transfer, string url);
private StreamInteractor stream_interactor;
+ private Database db;
private HashMap<Account, long> max_file_sizes = new HashMap<Account, long>(Account.hash_func, Account.equals_func);
- private Manager(StreamInteractor stream_interactor) {
+
+ public static void start(StreamInteractor stream_interactor, Database db) {
+ Manager m = new Manager(stream_interactor, db);
+ stream_interactor.add_module(m);
+ }
+
+ private Manager(StreamInteractor stream_interactor, Database db) {
this.stream_interactor = stream_interactor;
+ this.db = db;
stream_interactor.get_module(FileManager.IDENTITY).add_sender(this);
stream_interactor.stream_negotiated.connect(on_stream_negotiated);
+ stream_interactor.get_module(MessageProcessor.IDENTITY).build_message_stanza.connect(check_add_oob);
}
public void send_file(Conversation conversation, FileTransfer file_transfer) {
@@ -60,9 +69,10 @@ public class Manager : StreamInteractionModule, FileSender, Object {
});
}
- public static void start(StreamInteractor stream_interactor) {
- Manager m = new Manager(stream_interactor);
- stream_interactor.add_module(m);
+ private void check_add_oob(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) {
+ if (message_is_file(db, message)) {
+ Xep.OutOfBandData.add_url_to_message(message_stanza, message_stanza.body);
+ }
}
}
@@ -77,20 +87,20 @@ public class FileMessageFilterDisplay : Plugins.MessageDisplayProvider, Object {
}
public bool can_display(Entities.Message? message) {
- return message_is_file(message);
+ return message_is_file(db, message);
}
public Plugins.MetaConversationItem? get_item(Entities.Message message, Conversation conversation) {
return null;
}
+}
- private bool message_is_file(Entities.Message message) {
- Qlite.QueryBuilder builder = db.file_transfer.select()
+private bool message_is_file(Database db, Entities.Message message) {
+ Qlite.QueryBuilder builder = db.file_transfer.select()
.with(db.file_transfer.info, "=", message.body)
.with(db.file_transfer.account_id, "=", message.account.id)
.with(db.file_transfer.counterpart_id, "=", db.get_jid_id(message.counterpart));
- return builder.count() > 0;
- }
+ return builder.count() > 0;
}
}
diff --git a/plugins/http-files/src/plugin.vala b/plugins/http-files/src/plugin.vala
index 7fc01e65..b1c08d80 100644
--- a/plugins/http-files/src/plugin.vala
+++ b/plugins/http-files/src/plugin.vala
@@ -11,7 +11,7 @@ public class Plugin : RootInterface, Object {
public void registered(Dino.Application app) {
try {
this.app = app;
- Manager.start(this.app.stream_interactor);
+ Manager.start(this.app.stream_interactor, app.db);
file_provider = new FileProvider(app.stream_interactor, app.db);
diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt
index 3306cf7e..3c747bea 100644
--- a/xmpp-vala/CMakeLists.txt
+++ b/xmpp-vala/CMakeLists.txt
@@ -51,6 +51,7 @@ SOURCES
"src/module/xep/0049_private_xml_storage.vala"
"src/module/xep/0054_vcard/module.vala"
"src/module/xep/0060_pubsub.vala"
+ "src/module/xep/0066_out_of_band_data.vala"
"src/module/xep/0082_date_time_profiles.vala"
"src/module/xep/0084_user_avatars.vala"
"src/module/xep/0085_chat_state_notifications.vala"
diff --git a/xmpp-vala/src/module/xep/0066_out_of_band_data.vala b/xmpp-vala/src/module/xep/0066_out_of_band_data.vala
new file mode 100644
index 00000000..b482252b
--- /dev/null
+++ b/xmpp-vala/src/module/xep/0066_out_of_band_data.vala
@@ -0,0 +1,11 @@
+using Xmpp.Core;
+
+namespace Xmpp.Xep.OutOfBandData {
+
+public const string NS_URI = "jabber:x:oob";
+
+public static void add_url_to_message(Message.Stanza message, string url, string? desc = null) {
+ message.stanza.put_node(new StanzaNode.build("x", NS_URI).add_self_xmlns().put_node(new StanzaNode.build("url", NS_URI).put_node(new StanzaNode.text(url))));
+}
+
+}