Debian Codegraph @

xmpp-vala/src/module/xep/0049_private_xml_storage.vala

raw
1 using Gee;
2
3 namespace Xmpp.Xep.PrivateXmlStorage {
4 private const string NS_URI = "jabber:iq:private";
5
6 public class Module : XmppStreamModule {
7 public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0049_private_xml_storage");
8
9 public async void store(XmppStream stream, StanzaNode node) {
10 StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node);
11 Iq.Stanza iq = new Iq.Stanza.set(queryNode);
12 yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
13 }
14
15 public async StanzaNode? retrieve(XmppStream stream, StanzaNode node) {
16 StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node);
17 Iq.Stanza iq = new Iq.Stanza.get(queryNode);
18 Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
19 return iq_result.stanza.get_subnode("query", NS_URI);
20 }
21
22 public override void attach(XmppStream stream) { }
23
24 public override void detach(XmppStream stream) { }
25
26 public override string get_ns() { return NS_URI; }
27 public override string get_id() { return IDENTITY.id; }
28 }
29 }