diff options
author | fiaxh <git@mx.ax.lt> | 2017-03-10 17:01:45 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-03-10 17:11:25 +0100 |
commit | 2fe8489d368a371aefbfbe66e74621a8df14cdc2 (patch) | |
tree | 4dec90236b28101383753ffe4a1c7a34b09b0208 /xmpp-vala/src/core/stanza_attribute.vala | |
parent | 7a1aa8c806a63cfd031c082524501e26d4a181ee (diff) | |
download | dino-2fe8489d368a371aefbfbe66e74621a8df14cdc2.tar.gz dino-2fe8489d368a371aefbfbe66e74621a8df14cdc2.zip |
Rename vala-xmpp library to xmpp-vala
Diffstat (limited to 'xmpp-vala/src/core/stanza_attribute.vala')
-rw-r--r-- | xmpp-vala/src/core/stanza_attribute.vala | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/xmpp-vala/src/core/stanza_attribute.vala b/xmpp-vala/src/core/stanza_attribute.vala new file mode 100644 index 00000000..3169e90e --- /dev/null +++ b/xmpp-vala/src/core/stanza_attribute.vala @@ -0,0 +1,29 @@ +namespace Xmpp.Core { +public class StanzaAttribute : StanzaEntry { + + public StanzaAttribute() {} + + public StanzaAttribute.build(string ns_uri, string name, string val) { + this.ns_uri = ns_uri; + this.name = name; + this.val = val; + } + + public string to_string() { + if (ns_uri == null) { + return @"$name='$val'"; + } else { + return @"{$ns_uri}:$name='$val'"; + } + } + + public string to_xml(NamespaceState? state_) throws XmlError { + NamespaceState state = state_ ?? new NamespaceState(); + if (ns_uri == state.current_ns_uri || (ns_uri == XMLNS_URI && name == "xmlns")) { + return @"$name='$val'"; + } else { + return "%s:%s='%s'".printf (state.find_name (ns_uri), name, val); + } + } +} +} |