From 871ff33ac79f3d17b0260b8bfcd27780038edd6d Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 3 Apr 2020 22:49:59 +0200 Subject: Add support for last message correction --- xmpp-vala/CMakeLists.txt | 1 + .../module/xep/0308_last_message_correction.vala | 31 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 xmpp-vala/src/module/xep/0308_last_message_correction.vala (limited to 'xmpp-vala') diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt index 246f0108..6691f950 100644 --- a/xmpp-vala/CMakeLists.txt +++ b/xmpp-vala/CMakeLists.txt @@ -85,6 +85,7 @@ SOURCES "src/module/xep/0260_jingle_socks5_bytestreams.vala" "src/module/xep/0261_jingle_in_band_bytestreams.vala" "src/module/xep/0280_message_carbons.vala" + "src/module/xep/0308_last_message_correction.vala" "src/module/xep/0313_message_archive_management.vala" "src/module/xep/0333_chat_markers.vala" "src/module/xep/0334_message_processing_hints.vala" diff --git a/xmpp-vala/src/module/xep/0308_last_message_correction.vala b/xmpp-vala/src/module/xep/0308_last_message_correction.vala new file mode 100644 index 00000000..7669b244 --- /dev/null +++ b/xmpp-vala/src/module/xep/0308_last_message_correction.vala @@ -0,0 +1,31 @@ +namespace Xmpp.Xep.LastMessageCorrection { + +private const string NS_URI = "urn:xmpp:message-correct:0"; + +public static void set_replace_id(MessageStanza message, string replace_id) { + StanzaNode hint_node = (new StanzaNode.build("replace", NS_URI)).add_self_xmlns().put_attribute("id", replace_id); + message.stanza.put_node(hint_node); +} + +public static string? get_replace_id(MessageStanza message) { + StanzaNode? node = message.stanza.get_subnode("replace", NS_URI); + if (node == null) return null; + + return node.get_attribute("id"); +} + +public class Module : XmppStreamModule { + public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0308_last_message_correction"); + + public override void attach(XmppStream stream) { + stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); + } + + public override void detach(XmppStream stream) {} + + public override string get_ns() { return NS_URI; } + + public override string get_id() { return IDENTITY.id; } +} + +} -- cgit v1.2.3-70-g09d2