From 79f792e090330a05753f9edb27332a946eb0840d Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sat, 2 Nov 2024 22:24:59 +0100 Subject: Fix and improve stateless file-sharing --- .../src/module/xep/0104_http_scheme_url_data.vala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 xmpp-vala/src/module/xep/0104_http_scheme_url_data.vala (limited to 'xmpp-vala/src/module/xep/0104_http_scheme_url_data.vala') diff --git a/xmpp-vala/src/module/xep/0104_http_scheme_url_data.vala b/xmpp-vala/src/module/xep/0104_http_scheme_url_data.vala new file mode 100644 index 00000000..b177a1ef --- /dev/null +++ b/xmpp-vala/src/module/xep/0104_http_scheme_url_data.vala @@ -0,0 +1,19 @@ +using Xmpp; + +namespace Xmpp.Xep.HttpSchemeForUrlData { + public const string NS_URI = "http://jabber.org/protocol/url-data"; + + // If there are multiple URLs, this will only return the first one + public static string? get_url(StanzaNode node) { + StanzaNode? url_data_node = node.get_subnode("url-data", NS_URI); + if (url_data_node == null) return null; + + return url_data_node.get_attribute("target"); + } + + public static StanzaNode to_stanza_node(string url) { + return new StanzaNode.build("url-data", NS_URI).add_self_xmlns() + .put_attribute("target", url, NS_URI); + + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2