From fb36ea055301b6db513a31acde30f315e2c0fd68 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 16 Aug 2017 11:44:42 +0200 Subject: Message Archive Management --- xmpp-vala/src/module/xep/0004_data_forms.vala | 93 ++++++++++----- xmpp-vala/src/module/xep/0045_muc/module.vala | 2 +- .../src/module/xep/0082_date_time_profiles.vala | 54 ++++----- .../src/module/xep/0203_delayed_delivery.vala | 18 +-- .../xep/0313_message_archive_management.vala | 126 +++++++++++++++++++++ 5 files changed, 227 insertions(+), 66 deletions(-) create mode 100644 xmpp-vala/src/module/xep/0313_message_archive_management.vala (limited to 'xmpp-vala/src') diff --git a/xmpp-vala/src/module/xep/0004_data_forms.vala b/xmpp-vala/src/module/xep/0004_data_forms.vala index a0e8cd43..57ff834a 100644 --- a/xmpp-vala/src/module/xep/0004_data_forms.vala +++ b/xmpp-vala/src/module/xep/0004_data_forms.vala @@ -21,8 +21,12 @@ public class DataForm { } public void submit() { + on_result(stream, get_submit_node()); + } + + public StanzaNode get_submit_node() { stanza_node.set_attribute("type", "submit"); - on_result(stream, stanza_node); + return stanza_node; } public enum Type { @@ -46,19 +50,24 @@ public class DataForm { } } - public abstract class Field { - public string label { + public class Field { + public StanzaNode node { get; set; } + public string? label { get { return node.get_attribute("label", NS_URI); } set { node.set_attribute("label", value); } + default = null; } - public StanzaNode node { get; set; } - public abstract Type type_ { get; internal set; } - public string var { + public virtual Type? type_ { get; internal set; default=null; } + public string? var { get { return node.get_attribute("var", NS_URI); } set { node.set_attribute("var", value); } } - public Field(StanzaNode node) { + public Field() { + this.node = new StanzaNode.build("field", NS_URI); + } + + public Field.from_node(StanzaNode node) { this.node = node; } @@ -103,73 +112,94 @@ public class DataForm { } public class BooleanField : Field { - public override Type type_ { get; internal set; default=Type.BOOLEAN; } public bool value { get { return get_value_string() == "1"; } set { set_value_string(value ? "1" : "0"); } } - public BooleanField(StanzaNode node) { base(node); } + public BooleanField(StanzaNode node) { + base.from_node(node); + type_ = Type.BOOLEAN; + } } public class FixedField : Field { - public override Type type_ { get; internal set; default=Type.FIXED; } public string value { owned get { return get_value_string(); } set { set_value_string(value); } } - public FixedField(StanzaNode node) { base(node); } + public FixedField(StanzaNode node) { + base.from_node(node); + type_ = Type.FIXED; + } } public class HiddenField : Field { - public override Type type_ { get; internal set; default=Type.HIDDEN; } - public HiddenField(StanzaNode node) { base(node); } + public HiddenField() { + base(); + type_ = Type.HIDDEN;; + node.put_attribute("type", "hidden"); + } + public HiddenField.from_node(StanzaNode node) { + base.from_node(node); + type_ = Type.HIDDEN;; + } } public class JidMultiField : Field { public Gee.List