Debian Codegraph @

xmpp-vala/src/module/iq/stanza.vala

raw
1 using Gee;
2
3 namespace Xmpp.Iq {
4
5 public class Stanza : Xmpp.Stanza {
6
7 public const string TYPE_GET = "get";
8 public const string TYPE_RESULT = "result";
9 public const string TYPE_SET = "set";
10
11 private Stanza(string? id = null) {
12 base.outgoing(new StanzaNode.build("iq"));
13 this.id = id ?? random_uuid();
14 }
15
16 public Stanza.get(StanzaNode stanza_node, string? id = null) {
17 this(id);
18 this.type_ = TYPE_GET;
19 stanza.put_node(stanza_node);
20 }
21
22 public Stanza.result(Stanza request, StanzaNode? stanza_node = null) {
23 this(request.id);
24 this.to = request.from;
25 this.type_ = TYPE_RESULT;
26 if (stanza_node != null) {
27 stanza.put_node(stanza_node);
28 }
29 }
30
31 public Stanza.set(StanzaNode stanza_node, string? id = null) {
32 this(id);
33 this.type_ = TYPE_SET;
34 stanza.put_node(stanza_node);
35 }
36
37 public Stanza.error(Stanza request, ErrorStanza error_stanza) {
38 this(request.id);
39 this.type_ = TYPE_ERROR;
40 stanza.put_node(error_stanza.error_node);
41 }
42 public Stanza.from_stanza(StanzaNode stanza_node, Jid? my_jid) {
43 base.incoming(stanza_node, my_jid);
44 }
45 }
46
47 }