diff options
author | fiaxh <git@mx.ax.lt> | 2017-03-02 15:37:32 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-03-02 15:37:32 +0100 |
commit | 56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d (patch) | |
tree | 0bd0c2c80cb81179c26282fb3fbe8fd22983f40b /vala-xmpp/src/module/stanza_error.vala | |
download | dino-56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d.tar.gz dino-56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d.zip |
Initial commit
Diffstat (limited to 'vala-xmpp/src/module/stanza_error.vala')
-rw-r--r-- | vala-xmpp/src/module/stanza_error.vala | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vala-xmpp/src/module/stanza_error.vala b/vala-xmpp/src/module/stanza_error.vala new file mode 100644 index 00000000..be4633e9 --- /dev/null +++ b/vala-xmpp/src/module/stanza_error.vala @@ -0,0 +1,69 @@ +using Gee; + +using Xmpp.Core; + +namespace Xmpp { + + public class ErrorStanza { + public const string CONDITION_BAD_REQUEST = "bad-request"; + public const string CONDITION_CONFLICT = "conflict"; + public const string CONDITION_FEATURE_NOT_IMPLEMENTED = "feature-not-implemented"; + public const string CONDITION_FORBIDDEN = "forbidden"; + public const string CONDITION_GONE = "gone"; + public const string CONDITION_INTERNAL_SERVER_ERROR = "internal-server-error"; + public const string CONDITION_ITEM_NOT_FOUND = "item-not-found"; + public const string CONDITION_JID_MALFORMED = "jid-malformed"; + public const string CONDITION_NOT_ACCEPTABLE = "not-acceptable"; + public const string CONDITION_NOT_ALLOWED = "not-allowed"; + public const string CONDITION_NOT_AUTHORIZED = "not-authorized"; + public const string CONDITION_POLICY_VIOLATION = "policy-violation"; + public const string CONDITION_RECIPIENT_UNAVAILABLE = "recipient-unavailable"; + public const string CONDITION_REDIRECT = "redirect"; + public const string CONDITION_REGISTRATION_REQUIRED = "registration-required"; + public const string CONDITION_REMOTE_SERVER_NOT_FOUND = "remote-server-not-found"; + public const string CONDITION_REMOTE_SERVER_TIMEOUT = "remote-server-timeout"; + public const string CONDITION_RESOURCE_CONSTRAINT = "resource-constraint"; + public const string CONDITION_SERVICE_UNAVAILABLE = "service-unavailable"; + public const string CONDITION_SUBSCRIPTION_REQUIRED = "subscription-required"; + public const string CONDITION_UNDEFINED_CONDITION = "undefined-condition"; + public const string CONDITION_UNEXPECTED_REQUEST = "unexpected-request"; + + public const string TYPE_AUTH = "auth"; + public const string TYPE_CANCEL = "cancel"; + public const string TYPE_CONTINUE = "continue"; + public const string TYPE_MODIFY = "modify"; + public const string TYPE_WAIT = "wait"; + + public string? by { + get { return error_node.get_attribute("by"); } + } + + public string condition { + get { + ArrayList<StanzaNode> subnodes = error_node.sub_nodes; + foreach (StanzaNode subnode in subnodes) { // TODO get subnode by ns + if (subnode.ns_uri == "urn:ietf:params:xml:ns:xmpp-stanzas") { + return subnode.name; + } + } + return CONDITION_UNDEFINED_CONDITION; // TODO hm! + } + } + + public string? original_id { + get { return stanza.get_attribute("id"); } + } + + public string type_ { + get { return stanza.get_attribute("type"); } + } + + public StanzaNode stanza; + private StanzaNode error_node; + + public ErrorStanza.from_stanza(StanzaNode stanza) { + this.stanza = stanza; + error_node = stanza.get_subnode("error"); + } + } +}
\ No newline at end of file |