From 56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 2 Mar 2017 15:37:32 +0100 Subject: Initial commit --- vala-xmpp/src/module/iq/stanza.vala | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 vala-xmpp/src/module/iq/stanza.vala (limited to 'vala-xmpp/src/module/iq/stanza.vala') diff --git a/vala-xmpp/src/module/iq/stanza.vala b/vala-xmpp/src/module/iq/stanza.vala new file mode 100644 index 00000000..99d589ff --- /dev/null +++ b/vala-xmpp/src/module/iq/stanza.vala @@ -0,0 +1,51 @@ +using Gee; + +using Xmpp.Core; + +namespace Xmpp.Iq { + +public class Stanza : Xmpp.Stanza { + + public const string TYPE_GET = "get"; + public const string TYPE_RESULT = "result"; + public const string TYPE_SET = "set"; + + private Stanza(string id = UUID.generate_random_unparsed()) { + base.outgoing(new StanzaNode.build("iq")); + this.id = id; + } + + public Stanza.get(StanzaNode stanza_node, string id = UUID.generate_random_unparsed()) { + this(id); + this.type_ = TYPE_GET; + stanza.put_node(stanza_node); + } + + public Stanza.result(Stanza request, StanzaNode? stanza_node = null) { + this(request.id); + this.type_ = TYPE_RESULT; + if (stanza_node != null) { + stanza.put_node(stanza_node); + } + } + + public Stanza.set(StanzaNode stanza_node, string id = UUID.generate_random_unparsed()) { + this(id); + type_ = TYPE_SET; + stanza.put_node(stanza_node); + } + + public Stanza.error(Stanza request, StanzaNode error_stanza, StanzaNode? associated_child = null) { + this(request.id); + this.type_ = TYPE_ERROR; + stanza.put_node(error_stanza); + if (associated_child != null) { + stanza.put_node(associated_child); + } + } + public Stanza.from_stanza(StanzaNode stanza_node, string? my_jid) { + base.incoming(stanza_node, my_jid); + } +} + +} -- cgit v1.2.3-70-g09d2